diff --git a/dist/butterchurn.js b/dist/butterchurn.js
index bc11139fbe6e0757842662f9d3a59e07c9866468..a26aa8c376de3a758649ebb9adb73c94c074382b 100644
--- a/dist/butterchurn.js
+++ b/dist/butterchurn.js
@@ -184,2333 +184,7 @@ window.memcpy = function memcpy(megabuf, dst, src, len) {
 };
 /* eslint-enable */
 
-var src = {};
-
-var parser$1 = {};
-
-var preProcessor = {};
-
-var hasRequiredPreProcessor;
-
-function requirePreProcessor () {
-	if (hasRequiredPreProcessor) return preProcessor;
-	hasRequiredPreProcessor = 1;
-	Object.defineProperty(preProcessor, "__esModule", { value: true });
-	function getLoc(mapper, destCol) {
-	    let previousAnchor = { destCol: 1, srcCol: 1, srcLine: 1 };
-	    // Find the last anchor with a destCol > destCol.
-	    // Reversed: Find the first anchor with a destCol <= destCol
-	    // TODO: Use binary search
-	    mapper.forEach(anchor => {
-	        if (anchor.destCol > destCol) {
-	            return;
-	        }
-	        previousAnchor = anchor;
-	    });
-	    const remainingColumns = destCol - previousAnchor.destCol;
-	    return {
-	        column: previousAnchor.srcCol + remainingColumns,
-	        line: previousAnchor.srcLine,
-	    };
-	}
-	preProcessor.getLoc = getLoc;
-	// Started with this function: https://github.com/WACUP/vis_milk2/blob/cc2e85aed44373d0b6b2115c0806ec035856860a/vis_milk2/state.cpp#L1532-L1557
-	function preProcess(src) {
-	    const mapper = [];
-	    let srcLine = 1;
-	    let dest = "";
-	    let lineStart = 0;
-	    let inlineComment = false;
-	    let blockComment = false;
-	    let emitAnchor = false;
-	    for (let i = 0; i < src.length; i++) {
-	        const char = src[i];
-	        if (emitAnchor) {
-	            const destCol = dest.length + 1;
-	            const srcCol = i - lineStart + 1;
-	            mapper.push({ destCol, srcCol, srcLine });
-	            emitAnchor = false;
-	        }
-	        if (char === "\n") {
-	            inlineComment = false;
-	            srcLine++;
-	            lineStart = i + 1;
-	            emitAnchor = true;
-	        }
-	        else if (char === "\r" && src[i + 1] === "\n") {
-	            i++;
-	            inlineComment = false;
-	            srcLine++;
-	            lineStart = i + 1;
-	            emitAnchor = true;
-	        }
-	        else if (blockComment && char === "*" && src[i + 1] === "/") {
-	            // TODO: What if we are not currently in a block comment?
-	            blockComment = false;
-	            i++;
-	            emitAnchor = true;
-	        }
-	        else if ((char === "\\" && src[i + 1] === "\\") ||
-	            (char === "/" && src[i + 1] === "/")) {
-	            inlineComment = true;
-	            i++;
-	        }
-	        else if (char === "/" && src[i + 1] === "*") {
-	            blockComment = true;
-	            i++;
-	        }
-	        else if (!inlineComment && !blockComment) {
-	            dest += char;
-	        }
-	    }
-	    return [dest, mapper];
-	}
-	preProcessor.preProcess = preProcess;
-	
-	return preProcessor;
-}
-
-function commonjsRequire(path) {
-	throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
-}
-
-var parser = {};
-
-/* parser generated by jison 0.4.18 */
-
-var hasRequiredParser$1;
-
-function requireParser$1 () {
-	if (hasRequiredParser$1) return parser;
-	hasRequiredParser$1 = 1;
-	(function (exports) {
-		/*
-		  Returns a Parser object of the following structure:
-
-		  Parser: {
-		    yy: {}
-		  }
-
-		  Parser.prototype: {
-		    yy: {},
-		    trace: function(),
-		    symbols_: {associative list: name ==> number},
-		    terminals_: {associative list: number ==> name},
-		    productions_: [...],
-		    performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
-		    table: [...],
-		    defaultActions: {...},
-		    parseError: function(str, hash),
-		    parse: function(input),
-
-		    lexer: {
-		        EOF: 1,
-		        parseError: function(str, hash),
-		        setInput: function(input),
-		        input: function(),
-		        unput: function(str),
-		        more: function(),
-		        less: function(n),
-		        pastInput: function(),
-		        upcomingInput: function(),
-		        showPosition: function(),
-		        test_match: function(regex_match_array, rule_index),
-		        next: function(),
-		        lex: function(),
-		        begin: function(condition),
-		        popState: function(),
-		        _currentRules: function(),
-		        topState: function(),
-		        pushState: function(condition),
-
-		        options: {
-		            ranges: boolean           (optional: true ==> token location info will include a .range[] member)
-		            flex: boolean             (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
-		            backtrack_lexer: boolean  (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
-		        },
-
-		        performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
-		        rules: [...],
-		        conditions: {associative list: name ==> set},
-		    }
-		  }
-
-
-		  token location info (@$, _$, etc.): {
-		    first_line: n,
-		    last_line: n,
-		    first_column: n,
-		    last_column: n,
-		    range: [start_number, end_number]       (where the numbers are indexes into the input string, regular zero-based)
-		  }
-
-
-		  the parseError function receives a 'hash' object with these members for lexer and parser errors: {
-		    text:        (matched text)
-		    token:       (the produced terminal token, if any)
-		    line:        (yylineno)
-		  }
-		  while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
-		    loc:         (yylloc)
-		    expected:    (string describing the set of expected tokens)
-		    recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
-		  }
-		*/
-		var parser = (function () {
-		    var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v)
-		        ; return o; }, $V0 = [1, 18], $V1 = [1, 7], $V2 = [1, 19], $V3 = [1, 20], $V4 = [1, 14], $V5 = [1, 15], $V6 = [1, 16], $V7 = [1, 33], $V8 = [1, 31], $V9 = [1, 23], $Va = [1, 22], $Vb = [1, 24], $Vc = [1, 25], $Vd = [1, 26], $Ve = [1, 27], $Vf = [1, 28], $Vg = [1, 29], $Vh = [1, 30], $Vi = [5, 8, 15, 18, 20, 28, 29, 32, 33, 34, 35, 36, 37, 38], $Vj = [5, 15, 18], $Vk = [5, 12, 15, 17, 18, 24, 25, 28, 29, 30], $Vl = [1, 57], $Vm = [5, 8, 12, 15, 17, 18, 24, 25, 28, 29, 30], $Vn = [15, 18], $Vo = [5, 8, 15, 18, 28, 29, 38], $Vp = [5, 8, 15, 18, 28, 29, 32, 33, 38], $Vq = [5, 8, 15, 18, 28, 29, 32, 33, 34, 37, 38], $Vr = [5, 8, 15, 18, 28, 29, 32, 33, 34, 35, 36, 37, 38], $Vs = [5, 8, 15, 18], $Vt = [5, 8, 15, 18, 20, 22, 28, 29, 32, 33, 34, 35, 36, 37, 38];
-		    var parser = { trace: function trace() { },
-		        yy: {},
-		        symbols_: { "error": 2, "SCRIPT": 3, "expression": 4, "EOF": 5, "expressionsOptionalTrailingSemi": 6, "separator": 7, ";": 8, "expressions": 9, "EXPRESSION_BLOCK": 10, "IDENTIFIER": 11, "IDENTIFIER_TOKEN": 12, "argument": 13, "arguments": 14, ",": 15, "FUNCTION_CALL": 16, "(": 17, ")": 18, "LOGICAL_EXPRESSION": 19, "LOGICAL_OPERATOR_TOKEN": 20, "ASSIGNMENT": 21, "ASSIGNMENT_OPERATOR_TOKEN": 22, "number": 23, "DIGITS_TOKEN": 24, ".": 25, "NUMBER_LITERAL": 26, "UNARY_EXPRESSION": 27, "-": 28, "+": 29, "!": 30, "BINARY_EXPRESSION": 31, "*": 32, "/": 33, "%": 34, "&": 35, "|": 36, "^": 37, "COMPARISON_TOKEN": 38, "$accept": 0, "$end": 1 },
-		        terminals_: { 2: "error", 5: "EOF", 8: ";", 12: "IDENTIFIER_TOKEN", 15: ",", 17: "(", 18: ")", 20: "LOGICAL_OPERATOR_TOKEN", 22: "ASSIGNMENT_OPERATOR_TOKEN", 24: "DIGITS_TOKEN", 25: ".", 28: "-", 29: "+", 30: "!", 32: "*", 33: "/", 34: "%", 35: "&", 36: "|", 37: "^", 38: "COMPARISON_TOKEN" },
-		        productions_: [0, [3, 2], [3, 2], [3, 1], [7, 1], [7, 2], [9, 2], [9, 3], [6, 1], [6, 2], [10, 1], [11, 1], [13, 1], [13, 1], [14, 1], [14, 3], [16, 3], [16, 4], [19, 3], [21, 3], [21, 3], [23, 1], [23, 2], [23, 3], [23, 2], [23, 1], [26, 1], [27, 2], [27, 2], [27, 2], [31, 3], [31, 3], [31, 3], [31, 3], [31, 3], [31, 3], [31, 3], [31, 3], [31, 3], [4, 1], [4, 1], [4, 3], [4, 1], [4, 1], [4, 1], [4, 1], [4, 1], [4, 3]],
-		        performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
-		            /* this == yyval */
-		            var $0 = $$.length - 1;
-		            switch (yystate) {
-		                case 1:
-		                    return { type: 'SCRIPT', body: [$$[$0 - 1]], loc: this._$ };
-		                case 2:
-		                    return { type: 'SCRIPT', body: $$[$0 - 1], loc: this._$ };
-		                case 3:
-		                    return { type: 'SCRIPT', body: [], loc: this._$ };
-		                case 6:
-		                    this.$ = [$$[$0 - 1]];
-		                    break;
-		                case 7:
-		                    this.$ = $$[$0 - 2].concat([$$[$0 - 1]]);
-		                    break;
-		                case 8:
-		                    this.$ = $$[$0];
-		                    break;
-		                case 9:
-		                    this.$ = $$[$0 - 1].concat([$$[$0]]);
-		                    break;
-		                case 10:
-		                    this.$ = { type: 'EXPRESSION_BLOCK', body: $$[$0], loc: this._$ };
-		                    break;
-		                case 11:
-		                    this.$ = { type: 'IDENTIFIER', value: $$[$0].toLowerCase(), loc: this._$ };
-		                    break;
-		                case 14:
-		                    this.$ = [$$[$0]];
-		                    break;
-		                case 15:
-		                    this.$ = $$[$0 - 2].concat([$$[$0]]);
-		                    break;
-		                case 16:
-		                    this.$ = { type: 'CALL_EXPRESSION', callee: $$[$0 - 2], arguments: [], loc: this._$ };
-		                    break;
-		                case 17:
-		                    this.$ = { type: 'CALL_EXPRESSION', callee: $$[$0 - 3], arguments: $$[$0 - 1], loc: this._$ };
-		                    break;
-		                case 18:
-		                    this.$ = { type: 'LOGICAL_EXPRESSION', left: $$[$0 - 2], right: $$[$0], operator: $$[$0 - 1], loc: this._$ };
-		                    break;
-		                case 19:
-		                case 20:
-		                    this.$ = { type: 'ASSIGNMENT_EXPRESSION', left: $$[$0 - 2], operator: $$[$0 - 1], right: $$[$0], loc: this._$ };
-		                    break;
-		                case 21:
-		                    this.$ = Number($$[$0]);
-		                    break;
-		                case 22:
-		                    this.$ = Number($$[$0 - 1]);
-		                    break;
-		                case 23:
-		                    this.$ = Number($$[$0 - 2] + $$[$0 - 1] + $$[$0]);
-		                    break;
-		                case 24:
-		                    this.$ = Number('0' + $$[$0 - 1] + $$[$0]);
-		                    break;
-		                case 25:
-		                    this.$ = 0;
-		                    break;
-		                case 26:
-		                    this.$ = { type: 'NUMBER_LITERAL', value: $$[$0], loc: this._$ };
-		                    break;
-		                case 27:
-		                case 28:
-		                case 29:
-		                    this.$ = { type: 'UNARY_EXPRESSION', value: $$[$0], operator: $$[$0 - 1], loc: this._$ };
-		                    break;
-		                case 30:
-		                case 31:
-		                case 32:
-		                case 33:
-		                case 34:
-		                case 35:
-		                case 36:
-		                case 37:
-		                case 38:
-		                    this.$ = { type: 'BINARY_EXPRESSION', left: $$[$0 - 2], right: $$[$0], operator: $$[$0 - 1], loc: this._$ };
-		                    break;
-		                case 41:
-		                case 47:
-		                    this.$ = $$[$0 - 1];
-		                    break;
-		            }
-		        },
-		        table: [{ 3: 1, 4: 2, 5: [1, 4], 6: 3, 9: 13, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 1: [3] }, { 5: [1, 21], 7: 32, 8: $V7, 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }, { 5: [1, 34] }, { 1: [2, 3] }, o($Vi, [2, 39]), o($Vi, [2, 40]), { 4: 35, 6: 37, 9: 13, 10: 36, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, o($Vi, [2, 42]), o($Vi, [2, 43]), o($Vi, [2, 44], { 22: [1, 38] }), o($Vi, [2, 45], { 17: [1, 40], 22: [1, 39] }), o($Vi, [2, 46]), o($Vj, [2, 8], { 31: 5, 27: 6, 26: 8, 21: 9, 16: 10, 11: 11, 19: 12, 23: 17, 4: 41, 12: $V0, 17: $V1, 24: $V2, 25: $V3, 28: $V4, 29: $V5, 30: $V6 }), { 4: 42, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 43, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 44, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, o($Vi, [2, 26]), o([5, 8, 15, 17, 18, 20, 22, 28, 29, 32, 33, 34, 35, 36, 37, 38], [2, 11]), o($Vi, [2, 21], { 25: [1, 45] }), o($Vi, [2, 25], { 24: [1, 46] }), { 1: [2, 1] }, { 4: 47, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 48, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 49, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 50, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 51, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 52, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 53, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 54, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 55, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 56, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, o($Vk, [2, 6], { 8: $Vl }), o($Vm, [2, 4]), { 1: [2, 2] }, { 7: 32, 8: $V7, 18: [1, 58], 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }, { 18: [1, 59] }, o($Vn, [2, 10]), { 4: 60, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 61, 11: 11, 12: $V0, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, { 4: 65, 6: 37, 9: 13, 10: 66, 11: 11, 12: $V0, 13: 64, 14: 63, 16: 10, 17: $V1, 18: [1, 62], 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, o($Vj, [2, 9], { 7: 67, 8: $V7, 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }), o($Vo, [2, 27], { 20: $V8, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vo, [2, 28], { 20: $V8, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vo, [2, 29], { 20: $V8, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vi, [2, 22], { 24: [1, 68] }), o($Vi, [2, 24]), o($Vo, [2, 30], { 20: $V8, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vo, [2, 31], { 20: $V8, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vp, [2, 32], { 20: $V8, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vp, [2, 33], { 20: $V8, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg }), o($Vq, [2, 34], { 20: $V8, 35: $Ve, 36: $Vf }), o($Vr, [2, 35], { 20: $V8 }), o($Vr, [2, 36], { 20: $V8 }), o($Vq, [2, 37], { 20: $V8, 35: $Ve, 36: $Vf }), o($Vs, [2, 38], { 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }), o($Vi, [2, 18]), o($Vm, [2, 5]), o($Vi, [2, 41]), o($Vi, [2, 47]), o($Vs, [2, 20], { 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }), o($Vs, [2, 19], { 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }), o($Vt, [2, 16]), { 15: [1, 70], 18: [1, 69] }, o($Vn, [2, 14]), o($Vn, [2, 12], { 7: 32, 8: $V7, 20: $V8, 28: $V9, 29: $Va, 32: $Vb, 33: $Vc, 34: $Vd, 35: $Ve, 36: $Vf, 37: $Vg, 38: $Vh }), o($Vn, [2, 13]), o($Vk, [2, 7], { 8: $Vl }), o($Vi, [2, 23]), o($Vt, [2, 17]), { 4: 65, 6: 37, 9: 13, 10: 66, 11: 11, 12: $V0, 13: 71, 16: 10, 17: $V1, 19: 12, 21: 9, 23: 17, 24: $V2, 25: $V3, 26: 8, 27: 6, 28: $V4, 29: $V5, 30: $V6, 31: 5 }, o($Vn, [2, 15])],
-		        defaultActions: { 4: [2, 3], 21: [2, 1], 34: [2, 2] },
-		        parseError: function parseError(str, hash) {
-		            if (hash.recoverable) {
-		                this.trace(str);
-		            }
-		            else {
-		                var error = new Error(str);
-		                error.hash = hash;
-		                throw error;
-		            }
-		        },
-		        parse: function parse(input) {
-		            var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
-		            var args = lstack.slice.call(arguments, 1);
-		            var lexer = Object.create(this.lexer);
-		            var sharedState = { yy: {} };
-		            for (var k in this.yy) {
-		                if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
-		                    sharedState.yy[k] = this.yy[k];
-		                }
-		            }
-		            lexer.setInput(input, sharedState.yy);
-		            sharedState.yy.lexer = lexer;
-		            sharedState.yy.parser = this;
-		            if (typeof lexer.yylloc == 'undefined') {
-		                lexer.yylloc = {};
-		            }
-		            var yyloc = lexer.yylloc;
-		            lstack.push(yyloc);
-		            var ranges = lexer.options && lexer.options.ranges;
-		            if (typeof sharedState.yy.parseError === 'function') {
-		                this.parseError = sharedState.yy.parseError;
-		            }
-		            else {
-		                this.parseError = Object.getPrototypeOf(this).parseError;
-		            }
-		            var lex = function () {
-		                var token;
-		                token = lexer.lex() || EOF;
-		                if (typeof token !== 'number') {
-		                    token = self.symbols_[token] || token;
-		                }
-		                return token;
-		            };
-		            var symbol, state, action, r, yyval = {}, p, len, newState, expected;
-		            while (true) {
-		                state = stack[stack.length - 1];
-		                if (this.defaultActions[state]) {
-		                    action = this.defaultActions[state];
-		                }
-		                else {
-		                    if (symbol === null || typeof symbol == 'undefined') {
-		                        symbol = lex();
-		                    }
-		                    action = table[state] && table[state][symbol];
-		                }
-		                if (typeof action === 'undefined' || !action.length || !action[0]) {
-		                    var errStr = '';
-		                    expected = [];
-		                    for (p in table[state]) {
-		                        if (this.terminals_[p] && p > TERROR) {
-		                            expected.push('\'' + this.terminals_[p] + '\'');
-		                        }
-		                    }
-		                    if (lexer.showPosition) {
-		                        errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
-		                    }
-		                    else {
-		                        errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
-		                    }
-		                    this.parseError(errStr, {
-		                        text: lexer.match,
-		                        token: this.terminals_[symbol] || symbol,
-		                        line: lexer.yylineno,
-		                        loc: yyloc,
-		                        expected: expected
-		                    });
-		                }
-		                if (action[0] instanceof Array && action.length > 1) {
-		                    throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
-		                }
-		                switch (action[0]) {
-		                    case 1:
-		                        stack.push(symbol);
-		                        vstack.push(lexer.yytext);
-		                        lstack.push(lexer.yylloc);
-		                        stack.push(action[1]);
-		                        symbol = null;
-		                        {
-		                            yyleng = lexer.yyleng;
-		                            yytext = lexer.yytext;
-		                            yylineno = lexer.yylineno;
-		                            yyloc = lexer.yylloc;
-		                        }
-		                        break;
-		                    case 2:
-		                        len = this.productions_[action[1]][1];
-		                        yyval.$ = vstack[vstack.length - len];
-		                        yyval._$ = {
-		                            first_line: lstack[lstack.length - (len || 1)].first_line,
-		                            last_line: lstack[lstack.length - 1].last_line,
-		                            first_column: lstack[lstack.length - (len || 1)].first_column,
-		                            last_column: lstack[lstack.length - 1].last_column
-		                        };
-		                        if (ranges) {
-		                            yyval._$.range = [
-		                                lstack[lstack.length - (len || 1)].range[0],
-		                                lstack[lstack.length - 1].range[1]
-		                            ];
-		                        }
-		                        r = this.performAction.apply(yyval, [
-		                            yytext,
-		                            yyleng,
-		                            yylineno,
-		                            sharedState.yy,
-		                            action[1],
-		                            vstack,
-		                            lstack
-		                        ].concat(args));
-		                        if (typeof r !== 'undefined') {
-		                            return r;
-		                        }
-		                        if (len) {
-		                            stack = stack.slice(0, -1 * len * 2);
-		                            vstack = vstack.slice(0, -1 * len);
-		                            lstack = lstack.slice(0, -1 * len);
-		                        }
-		                        stack.push(this.productions_[action[1]][0]);
-		                        vstack.push(yyval.$);
-		                        lstack.push(yyval._$);
-		                        newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
-		                        stack.push(newState);
-		                        break;
-		                    case 3:
-		                        return true;
-		                }
-		            }
-		            return true;
-		        } };
-		    /* generated by jison-lex 0.3.4 */
-		    var lexer = (function () {
-		        var lexer = ({
-		            EOF: 1,
-		            parseError: function parseError(str, hash) {
-		                if (this.yy.parser) {
-		                    this.yy.parser.parseError(str, hash);
-		                }
-		                else {
-		                    throw new Error(str);
-		                }
-		            },
-		            // resets the lexer, sets new input
-		            setInput: function (input, yy) {
-		                this.yy = yy || this.yy || {};
-		                this._input = input;
-		                this._more = this._backtrack = this.done = false;
-		                this.yylineno = this.yyleng = 0;
-		                this.yytext = this.matched = this.match = '';
-		                this.conditionStack = ['INITIAL'];
-		                this.yylloc = {
-		                    first_line: 1,
-		                    first_column: 0,
-		                    last_line: 1,
-		                    last_column: 0
-		                };
-		                if (this.options.ranges) {
-		                    this.yylloc.range = [0, 0];
-		                }
-		                this.offset = 0;
-		                return this;
-		            },
-		            // consumes and returns one char from the input
-		            input: function () {
-		                var ch = this._input[0];
-		                this.yytext += ch;
-		                this.yyleng++;
-		                this.offset++;
-		                this.match += ch;
-		                this.matched += ch;
-		                var lines = ch.match(/(?:\r\n?|\n).*/g);
-		                if (lines) {
-		                    this.yylineno++;
-		                    this.yylloc.last_line++;
-		                }
-		                else {
-		                    this.yylloc.last_column++;
-		                }
-		                if (this.options.ranges) {
-		                    this.yylloc.range[1]++;
-		                }
-		                this._input = this._input.slice(1);
-		                return ch;
-		            },
-		            // unshifts one char (or a string) into the input
-		            unput: function (ch) {
-		                var len = ch.length;
-		                var lines = ch.split(/(?:\r\n?|\n)/g);
-		                this._input = ch + this._input;
-		                this.yytext = this.yytext.substr(0, this.yytext.length - len);
-		                //this.yyleng -= len;
-		                this.offset -= len;
-		                var oldLines = this.match.split(/(?:\r\n?|\n)/g);
-		                this.match = this.match.substr(0, this.match.length - 1);
-		                this.matched = this.matched.substr(0, this.matched.length - 1);
-		                if (lines.length - 1) {
-		                    this.yylineno -= lines.length - 1;
-		                }
-		                var r = this.yylloc.range;
-		                this.yylloc = {
-		                    first_line: this.yylloc.first_line,
-		                    last_line: this.yylineno + 1,
-		                    first_column: this.yylloc.first_column,
-		                    last_column: lines ?
-		                        (lines.length === oldLines.length ? this.yylloc.first_column : 0)
-		                            + oldLines[oldLines.length - lines.length].length - lines[0].length :
-		                        this.yylloc.first_column - len
-		                };
-		                if (this.options.ranges) {
-		                    this.yylloc.range = [r[0], r[0] + this.yyleng - len];
-		                }
-		                this.yyleng = this.yytext.length;
-		                return this;
-		            },
-		            // When called from action, caches matched text and appends it on next action
-		            more: function () {
-		                this._more = true;
-		                return this;
-		            },
-		            // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
-		            reject: function () {
-		                if (this.options.backtrack_lexer) {
-		                    this._backtrack = true;
-		                }
-		                else {
-		                    return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
-		                        text: "",
-		                        token: null,
-		                        line: this.yylineno
-		                    });
-		                }
-		                return this;
-		            },
-		            // retain first n characters of the match
-		            less: function (n) {
-		                this.unput(this.match.slice(n));
-		            },
-		            // displays already matched input, i.e. for error messages
-		            pastInput: function () {
-		                var past = this.matched.substr(0, this.matched.length - this.match.length);
-		                return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, "");
-		            },
-		            // displays upcoming input, i.e. for error messages
-		            upcomingInput: function () {
-		                var next = this.match;
-		                if (next.length < 20) {
-		                    next += this._input.substr(0, 20 - next.length);
-		                }
-		                return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
-		            },
-		            // displays the character position where the lexing error occurred, i.e. for error messages
-		            showPosition: function () {
-		                var pre = this.pastInput();
-		                var c = new Array(pre.length + 1).join("-");
-		                return pre + this.upcomingInput() + "\n" + c + "^";
-		            },
-		            // test the lexed token: return FALSE when not a match, otherwise return token
-		            test_match: function (match, indexed_rule) {
-		                var token, lines, backup;
-		                if (this.options.backtrack_lexer) {
-		                    // save context
-		                    backup = {
-		                        yylineno: this.yylineno,
-		                        yylloc: {
-		                            first_line: this.yylloc.first_line,
-		                            last_line: this.last_line,
-		                            first_column: this.yylloc.first_column,
-		                            last_column: this.yylloc.last_column
-		                        },
-		                        yytext: this.yytext,
-		                        match: this.match,
-		                        matches: this.matches,
-		                        matched: this.matched,
-		                        yyleng: this.yyleng,
-		                        offset: this.offset,
-		                        _more: this._more,
-		                        _input: this._input,
-		                        yy: this.yy,
-		                        conditionStack: this.conditionStack.slice(0),
-		                        done: this.done
-		                    };
-		                    if (this.options.ranges) {
-		                        backup.yylloc.range = this.yylloc.range.slice(0);
-		                    }
-		                }
-		                lines = match[0].match(/(?:\r\n?|\n).*/g);
-		                if (lines) {
-		                    this.yylineno += lines.length;
-		                }
-		                this.yylloc = {
-		                    first_line: this.yylloc.last_line,
-		                    last_line: this.yylineno + 1,
-		                    first_column: this.yylloc.last_column,
-		                    last_column: lines ?
-		                        lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
-		                        this.yylloc.last_column + match[0].length
-		                };
-		                this.yytext += match[0];
-		                this.match += match[0];
-		                this.matches = match;
-		                this.yyleng = this.yytext.length;
-		                if (this.options.ranges) {
-		                    this.yylloc.range = [this.offset, this.offset += this.yyleng];
-		                }
-		                this._more = false;
-		                this._backtrack = false;
-		                this._input = this._input.slice(match[0].length);
-		                this.matched += match[0];
-		                token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
-		                if (this.done && this._input) {
-		                    this.done = false;
-		                }
-		                if (token) {
-		                    return token;
-		                }
-		                else if (this._backtrack) {
-		                    // recover context
-		                    for (var k in backup) {
-		                        this[k] = backup[k];
-		                    }
-		                    return false; // rule action called reject() implying the next rule should be tested instead.
-		                }
-		                return false;
-		            },
-		            // return next match in input
-		            next: function () {
-		                if (this.done) {
-		                    return this.EOF;
-		                }
-		                if (!this._input) {
-		                    this.done = true;
-		                }
-		                var token, match, tempMatch, index;
-		                if (!this._more) {
-		                    this.yytext = '';
-		                    this.match = '';
-		                }
-		                var rules = this._currentRules();
-		                for (var i = 0; i < rules.length; i++) {
-		                    tempMatch = this._input.match(this.rules[rules[i]]);
-		                    if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
-		                        match = tempMatch;
-		                        index = i;
-		                        if (this.options.backtrack_lexer) {
-		                            token = this.test_match(tempMatch, rules[i]);
-		                            if (token !== false) {
-		                                return token;
-		                            }
-		                            else if (this._backtrack) {
-		                                match = false;
-		                                continue; // rule action called reject() implying a rule MISmatch.
-		                            }
-		                            else {
-		                                // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
-		                                return false;
-		                            }
-		                        }
-		                        else if (!this.options.flex) {
-		                            break;
-		                        }
-		                    }
-		                }
-		                if (match) {
-		                    token = this.test_match(match, rules[index]);
-		                    if (token !== false) {
-		                        return token;
-		                    }
-		                    // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
-		                    return false;
-		                }
-		                if (this._input === "") {
-		                    return this.EOF;
-		                }
-		                else {
-		                    return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
-		                        text: "",
-		                        token: null,
-		                        line: this.yylineno
-		                    });
-		                }
-		            },
-		            // return next match that has a token
-		            lex: function lex() {
-		                var r = this.next();
-		                if (r) {
-		                    return r;
-		                }
-		                else {
-		                    return this.lex();
-		                }
-		            },
-		            // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
-		            begin: function begin(condition) {
-		                this.conditionStack.push(condition);
-		            },
-		            // pop the previously active lexer condition state off the condition stack
-		            popState: function popState() {
-		                var n = this.conditionStack.length - 1;
-		                if (n > 0) {
-		                    return this.conditionStack.pop();
-		                }
-		                else {
-		                    return this.conditionStack[0];
-		                }
-		            },
-		            // produce the lexer rule set which is active for the currently active lexer condition state
-		            _currentRules: function _currentRules() {
-		                if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
-		                    return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
-		                }
-		                else {
-		                    return this.conditions["INITIAL"].rules;
-		                }
-		            },
-		            // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
-		            topState: function topState(n) {
-		                n = this.conditionStack.length - 1 - Math.abs(n || 0);
-		                if (n >= 0) {
-		                    return this.conditionStack[n];
-		                }
-		                else {
-		                    return "INITIAL";
-		                }
-		            },
-		            // alias for begin(condition)
-		            pushState: function pushState(condition) {
-		                this.begin(condition);
-		            },
-		            // return the number of states currently on the stack
-		            stateStackSize: function stateStackSize() {
-		                return this.conditionStack.length;
-		            },
-		            options: {},
-		            performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
-		                switch ($avoiding_name_collisions) {
-		                    case 0: /* skip whitespace */
-		                        break;
-		                    case 1:
-		                        return 24;
-		                    case 2:
-		                        return 38;
-		                    case 3:
-		                        return 22;
-		                    case 4:
-		                        return 20;
-		                    case 5:
-		                        return 12;
-		                    case 6:
-		                        return 5;
-		                    case 7:
-		                        return yy_.yytext[0];
-		                }
-		            },
-		            rules: [/^(?:\s+)/, /^(?:[0-9]+)/, /^(?:(==|!=|<=|>=|<|>))/, /^(?:[+\-*/%]?=)/, /^(?:(\&\&)|\|\|)/, /^(?:[a-zA-Z_][a-zA-Z0-9._]*)/, /^(?:$)/, /^(?:.)/],
-		            conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } }
-		        });
-		        return lexer;
-		    })();
-		    parser.lexer = lexer;
-		    function Parser() {
-		        this.yy = {};
-		    }
-		    Parser.prototype = parser;
-		    parser.Parser = Parser;
-		    return new Parser;
-		})();
-		if (typeof commonjsRequire !== 'undefined' && 'object' !== 'undefined') {
-		    exports.parser = parser;
-		    exports.Parser = parser.Parser;
-		    exports.parse = function () { return parser.parse.apply(parser, arguments); };
-		    exports.main = () => { };
-		}
-		
-	} (parser));
-	return parser;
-}
-
-var envParser;
-var hasRequiredEnvParser;
-
-function requireEnvParser () {
-	if (hasRequiredEnvParser) return envParser;
-	hasRequiredEnvParser = 1;
-	// This module is in charge of selecting either the pre-built module or the one
-	// that builds it a runtime with jison.
-	let parserImpl = requireParser$1();
-	/*
-	let parserImpl = null;
-	// Always use the dynamic one, while we figure out why the built one doens't work.
-	if (process.env.NODE_ENV === "production") {
-	  parserImpl = require("../build/parser");
-	} else {
-	  parserImpl = require("../tools/buildParser");
-	}
-	*/
-	envParser = { parse: parserImpl.parse };
-	
-	return envParser;
-}
-
-var astUtils = {};
-
-var hasRequiredAstUtils;
-
-function requireAstUtils () {
-	if (hasRequiredAstUtils) return astUtils;
-	hasRequiredAstUtils = 1;
-	Object.defineProperty(astUtils, "__esModule", { value: true });
-	const CHILDREN = {
-	    ASSIGNMENT_EXPRESSION: [
-	        { type: "NODE", key: "right" },
-	    ],
-	    SCRIPT: [{ type: "ARRAY", key: "body" }],
-	    EXPRESSION_BLOCK: [{ type: "ARRAY", key: "body" }],
-	    UNARY_EXPRESSION: [{ type: "NODE", key: "value" }],
-	    NUMBER_LITERAL: [],
-	    IDENTIFIER: [],
-	    CALL_EXPRESSION: [
-	        { type: "ARRAY", key: "arguments" },
-	        { type: "NODE", key: "callee" },
-	    ],
-	    BINARY_EXPRESSION: [
-	        { type: "NODE", key: "left" },
-	        { type: "NODE", key: "right" },
-	    ],
-	    LOGICAL_EXPRESSION: [
-	        { type: "NODE", key: "left" },
-	        { type: "NODE", key: "right" },
-	    ],
-	};
-	function mapAst(ast, cb) {
-	    const children = CHILDREN[ast.type];
-	    let newAst = ast;
-	    if (children == null) {
-	        throw new Error(`Unknown children definition for ${ast.type}`);
-	    }
-	    children.forEach(child => {
-	        if (child.type === "NODE") {
-	            const orignalChild = ast[child.key];
-	            const newChild = mapAst(orignalChild, cb);
-	            if (newChild !== orignalChild) {
-	                newAst = Object.assign(Object.assign({}, newAst), { [child.key]: newChild });
-	            }
-	        }
-	        else if (child.type === "ARRAY") {
-	            const orignalChildren = ast[child.key];
-	            const newChildren = orignalChildren.map(originalChild => mapAst(originalChild, cb));
-	            const childrenHaveChanged = orignalChildren.some((child, i) => child !== newChildren[i]);
-	            if (childrenHaveChanged) {
-	                newAst = Object.assign(Object.assign({}, newAst), { [child.key]: newChildren });
-	            }
-	        }
-	    });
-	    return cb(newAst);
-	}
-	astUtils.mapAst = mapAst;
-	
-	return astUtils;
-}
-
-var errorUtils = {};
-
-var utils = {};
-
-var hasRequiredUtils;
-
-function requireUtils () {
-	if (hasRequiredUtils) return utils;
-	hasRequiredUtils = 1;
-	Object.defineProperty(utils, "__esModule", { value: true });
-	function arrayJoin(arr, joiner) {
-	    const newArr = [];
-	    for (let i = 0; i < arr.length; i++) {
-	        newArr.push(arr[i]);
-	        const last = i === arr.length - 1;
-	        if (!last) {
-	            newArr.push(joiner);
-	        }
-	    }
-	    return newArr;
-	}
-	utils.arrayJoin = arrayJoin;
-	function flatten(arr) {
-	    return [].concat.apply([], arr);
-	}
-	utils.flatten = flatten;
-	function times(n, cb) {
-	    return new Array(n).fill(null).map((_, i) => cb(i));
-	}
-	utils.times = times;
-	function repeat(n, char) {
-	    return new Array(n).fill(char).join("");
-	}
-	utils.repeat = repeat;
-	// Maintain an ordered list of indexes for namespace/key pairs.
-	// In Wasm binary variables are referenced by their index. In our emitter we
-	// want to emit variables indexes as we encounter their names. This data
-	// structure lets us issue variable indexes on demmand and then iterate through
-	// them post facto.
-	//
-	// `null` may be passed for the namespace argument in order to get a global
-	// variable that exists in all namespaces.
-	class ScopedIdMap {
-	    constructor() {
-	        this._map = new Map();
-	    }
-	    // Get the index of a given namespace/key pair
-	    get(namespace, key) {
-	        const jointKey = namespace == null ? key : `${namespace}::${key}`;
-	        if (!this._map.has(jointKey)) {
-	            this._map.set(jointKey, this._map.size);
-	        }
-	        // @ts-ignore We know the key is here.
-	        return this._map.get(jointKey);
-	    }
-	    size() {
-	        return this._map.size;
-	    }
-	}
-	utils.ScopedIdMap = ScopedIdMap;
-	function formatList(list) {
-	    if (list.length === 0) {
-	        throw new Error("Cannot format an empty list");
-	    }
-	    if (list.length === 1) {
-	        return list[0];
-	    }
-	    const quoted = list.map(name => `"${name}"`);
-	    const last = quoted.pop();
-	    return quoted.join(", ") + ` and ${last}`;
-	}
-	utils.formatList = formatList;
-	
-	return utils;
-}
-
-var hasRequiredErrorUtils;
-
-function requireErrorUtils () {
-	if (hasRequiredErrorUtils) return errorUtils;
-	hasRequiredErrorUtils = 1;
-	Object.defineProperty(errorUtils, "__esModule", { value: true });
-	const utils_1 = requireUtils();
-	/* Build up a string showing a formatted source location in context with line numbers.
-	 *
-	 *   2 | z = sqr(y, 10);
-	 * > 3 | x = wat();
-	 *     |     ^^^
-	 *   4 | y = 100;
-	 */
-	function printLoc(loc, rawSource, contextLines = 1) {
-	    const firstIndex = Math.max(loc.first_line - 1 - contextLines, 0);
-	    const lastIndex = loc.last_line + contextLines;
-	    const sourceLines = rawSource.split("\n").slice(firstIndex, lastIndex);
-	    const annotatedLines = sourceLines.map((line, i) => {
-	        const lineNumber = i + firstIndex + 1;
-	        const inRange = lineNumber >= loc.first_line && lineNumber <= loc.last_line;
-	        const gutter = inRange ? ">" : " ";
-	        return `${gutter} ${lineNumber} | ${line}`;
-	    });
-	    if (loc.first_line === loc.last_line) {
-	        const padding = utils_1.repeat(loc.first_column, " ");
-	        const underline = utils_1.repeat(loc.last_column - loc.first_column, "^");
-	        const insertIndex = loc.first_line - firstIndex;
-	        annotatedLines.splice(insertIndex, 0, `    | ${padding}${underline}`);
-	    }
-	    return annotatedLines.join("\n");
-	}
-	errorUtils.printLoc = printLoc;
-	class CompilerError extends Error {
-	    constructor(message, loc, rawSource) {
-	        super(message);
-	        // TODO: Create an error message that encourages users to open an issue at
-	        // https://github.com/captbaritone/eel-wasm/issues is they see this, and gives
-	        // Them an easy way to attach the right context.
-	        this.sourceContext = printLoc(loc, rawSource);
-	        this.loc = loc;
-	    }
-	}
-	class UserError extends CompilerError {
-	}
-	function createUserError(message, loc, rawSource) {
-	    return new UserError(message, loc, rawSource);
-	}
-	errorUtils.createUserError = createUserError;
-	function createCompilerError(message, loc, rawSource) {
-	    return new CompilerError(message, loc, rawSource);
-	}
-	errorUtils.createCompilerError = createCompilerError;
-	
-	return errorUtils;
-}
-
-var hasRequiredParser;
-
-function requireParser () {
-	if (hasRequiredParser) return parser$1;
-	hasRequiredParser = 1;
-	Object.defineProperty(parser$1, "__esModule", { value: true });
-	const preProcessor_1 = requirePreProcessor();
-	const envParser_1 = requireEnvParser();
-	const astUtils_1 = requireAstUtils();
-	const errorUtils_1 = requireErrorUtils();
-	function mapLoc(loc, mapper) {
-	    const first = preProcessor_1.getLoc(mapper, loc.first_column);
-	    const last = preProcessor_1.getLoc(mapper, loc.last_column);
-	    return {
-	        first_column: first.column,
-	        last_column: last.column,
-	        first_line: first.line,
-	        last_line: last.line,
-	    };
-	}
-	function parse(code) {
-	    const [processedCode, mapper] = preProcessor_1.preProcess(code);
-	    try {
-	        const ast = envParser_1.parse(processedCode);
-	        return astUtils_1.mapAst(ast, (node) => {
-	            if (node.loc.first_line !== 1 || node.loc.last_line != 1) {
-	                throw errorUtils_1.createCompilerError("Unexpected multiline", node.loc, code);
-	            }
-	            return Object.assign(Object.assign({}, node), { loc: mapLoc(node.loc, mapper) });
-	        });
-	    }
-	    catch (e) {
-	        if (e.hash == null) {
-	            throw e;
-	        }
-	        throw errorUtils_1.createUserError(`Parse Error: ${e.message.split("\n")[3]}`, mapLoc(e.hash.loc, mapper), code);
-	    }
-	}
-	parser$1.parse = parse;
-	
-	return parser$1;
-}
-
-var compiler = {};
-
-var emitter = {};
-
-var encoding = {};
-
-var ieee754 = {};
-
-var hasRequiredIeee754;
-
-function requireIeee754 () {
-	if (hasRequiredIeee754) return ieee754;
-	hasRequiredIeee754 = 1;
-	Object.defineProperty(ieee754, "__esModule", { value: true });
-	// Copied from https://github.com/feross/ieee754/blob/master/index.js
-	function write(buffer, value) {
-	    // Originally these four were arguments, but we only ever use it like this.
-	    const offset = 0;
-	    let mLen = 52;
-	    const nBytes = 8;
-	    var e, m, c;
-	    var eLen = nBytes * 8 - mLen - 1;
-	    var eMax = (1 << eLen) - 1;
-	    var eBias = eMax >> 1;
-	    var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
-	    var i = 0 ;
-	    var d = 1 ;
-	    var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
-	    value = Math.abs(value);
-	    if (isNaN(value) || value === Infinity) {
-	        m = isNaN(value) ? 1 : 0;
-	        e = eMax;
-	    }
-	    else {
-	        e = Math.floor(Math.log(value) / Math.LN2);
-	        if (value * (c = Math.pow(2, -e)) < 1) {
-	            e--;
-	            c *= 2;
-	        }
-	        if (e + eBias >= 1) {
-	            value += rt / c;
-	        }
-	        else {
-	            value += rt * Math.pow(2, 1 - eBias);
-	        }
-	        if (value * c >= 2) {
-	            e++;
-	            c /= 2;
-	        }
-	        if (e + eBias >= eMax) {
-	            m = 0;
-	            e = eMax;
-	        }
-	        else if (e + eBias >= 1) {
-	            m = (value * c - 1) * Math.pow(2, mLen);
-	            e = e + eBias;
-	        }
-	        else {
-	            m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
-	            e = 0;
-	        }
-	    }
-	    for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) { }
-	    e = (e << mLen) | m;
-	    eLen += mLen;
-	    for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) { }
-	    buffer[offset + i - d] |= s * 128;
-	}
-	ieee754.write = write;
-	
-	return ieee754;
-}
-
-var hasRequiredEncoding;
-
-function requireEncoding () {
-	if (hasRequiredEncoding) return encoding;
-	hasRequiredEncoding = 1;
-	(function (exports) {
-		var __importStar = (encoding && encoding.__importStar) || function (mod) {
-		    if (mod && mod.__esModule) return mod;
-		    var result = {};
-		    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
-		    result["default"] = mod;
-		    return result;
-		};
-		Object.defineProperty(exports, "__esModule", { value: true });
-		const ieee754 = __importStar(requireIeee754());
-		const utils_1 = requireUtils();
-		exports.MAGIC = [0x00, 0x61, 0x73, 0x6d];
-		exports.WASM_VERSION = [0x01, 0x00, 0x00, 0x00];
-		exports.EPSILON = 0.00001;
-		// An intial attempt to construct a Wasm binary by hand.
-		/*
-		0	custom section
-		1	type section
-		2	import section
-		3	function section
-		4	table section
-		5	memory section
-		6	global section
-		7	export section
-		8	start section
-		9	element section
-		10	code section
-		11	data section
-		*/
-		// https://webassembly.github.io/spec/core/binary/modules.html#sections
-		exports.SECTION = {
-		    TYPE: 1,
-		    IMPORT: 2,
-		    FUNC: 3,
-		    MEMORY: 5,
-		    GLOBAL: 6,
-		    EXPORT: 7,
-		    CODE: 10,
-		};
-		exports.EXPORT_TYPE = {
-		    FUNC: 0x00,
-		    TABLE: 0x01,
-		    MEMORY: 0x02,
-		    GLOBAL: 0x03,
-		};
-		exports.op = {
-		    /*
-		     * Control Instructions
-		     * https://webassembly.github.io/spec/core/binary/instructions.html#control-instructions
-		     */
-		    // unreachable: 0x00,
-		    // nop: 0x01,
-		    block: (blockType) => [0x02, blockType],
-		    loop: (blockType) => [0x03, blockType],
-		    if: (retType) => [0x04, retType],
-		    else: 0x05,
-		    end: 0x0b,
-		    // br: (i: number) => [0x0c, ...signedLEB128(i)],
-		    br_if: (i) => [0x0d, ...unsignedLEB128(i)],
-		    // br_table: 0x0d,
-		    // return: 0x0f,
-		    call: (i) => [0x10, ...unsignedLEB128(i)],
-		    // call_indirect: 0x11,
-		    /*
-		     * Parametric Instructions
-		     * https://webassembly.github.io/spec/core/binary/instructions.html#parametric-instructions
-		     */
-		    drop: 0x1a,
-		    select: 0x1b,
-		    /*
-		     * Variable Instructions
-		     * https://webassembly.github.io/spec/core/binary/instructions.html#variable-instructions
-		     */
-		    local_get: (i) => [0x20, ...unsignedLEB128(i)],
-		    local_set: (i) => [0x21, ...unsignedLEB128(i)],
-		    local_tee: (i) => [0x22, ...unsignedLEB128(i)],
-		    global_get: (i) => [0x23, ...unsignedLEB128(i)],
-		    global_set: (i) => [0x24, ...unsignedLEB128(i)],
-		    /*
-		     * Memory Instructions
-		     * https://webassembly.github.io/spec/core/binary/instructions.html#memory-instructions
-		     */
-		    f64_load: (align, offset) => [
-		        0x2b,
-		        ...unsignedLEB128(align),
-		        ...unsignedLEB128(offset),
-		    ],
-		    f64_store: (align, offset) => [
-		        0x39,
-		        ...unsignedLEB128(align),
-		        ...unsignedLEB128(offset),
-		    ],
-		    /*
-		     * Numeric Instructions
-		     * https://webassembly.github.io/spec/core/binary/instructions.html#numeric-instructions
-		     */
-		    i32_const: (i) => [0x41, ...signedLEB128(i)],
-		    // i64_const: 0x42,
-		    // f32_const: 0x43,
-		    f64_const: (i) => [0x44, ...encodef64(i)],
-		    i32_eqz: 0x45,
-		    // i32_eq: 0x46,
-		    i32_ne: 0x47,
-		    i32_lt_s: 0x48,
-		    i32_lt_u: 0x49,
-		    i32_gt_s: 0x4a,
-		    // i32_gt_u: 0x4b,
-		    i32_le_s: 0x4c,
-		    i32_le_u: 0x4d,
-		    i32_ge_s: 0x4e,
-		    // i32_ge_u: 0x4f,
-		    // [0x50...0x5a] i64
-		    // [0x5b...0x60] f32
-		    f64_eq: 0x61,
-		    f64_ne: 0x62,
-		    f64_lt: 0x63,
-		    f64_gt: 0x64,
-		    f64_le: 0x65,
-		    f64_ge: 0x66,
-		    // i32_clz: 0x67,
-		    // i32_ctz: 0x68,
-		    // i32_popcnt: 0x69,
-		    i32_add: 0x6a,
-		    i32_sub: 0x6b,
-		    i32_mul: 0x6c,
-		    // i32_div_s: 0x6d,
-		    // i32_div_u: 0x6e,
-		    i32_rem_s: 0x6f,
-		    // i32_rem_u: 0x70,
-		    i32_and: 0x71,
-		    i32_or: 0x72,
-		    // [0x73...0x78] More i32
-		    // [0x79...0x8a] More i64
-		    i64_rem_s: 0x81,
-		    i64_and: 0x83,
-		    i64_or: 0x84,
-		    // [0x8b...0x98] More f32
-		    f64_abs: 0x99,
-		    f64_neg: 0x9a,
-		    f64_ceil: 0x9b,
-		    f64_floor: 0x9c,
-		    // f64_trunc: 0x9d,
-		    // f64_nearest: 0x9e,
-		    f64_sqrt: 0x9f,
-		    f64_add: 0xa0,
-		    f64_sub: 0xa1,
-		    f64_mul: 0xa2,
-		    f64_div: 0xa3,
-		    f64_min: 0xa4,
-		    f64_max: 0xa5,
-		    // f64_copysign: 0xa6,
-		    i32_trunc_f64_s: 0xaa,
-		    i32_trunc_f64_u: 0xab,
-		    i64_trunc_s_f64: 0xb0,
-		    f64_convert_i64_s: 0xb9,
-		    f64_convert_i32_s: 0xb7,
-		};
-		// https://webassembly.github.io/spec/core/binary/instructions.html#binary-blocktype
-		exports.VAL_TYPE = {
-		    i32: 0x7f,
-		    i64: 0x7e,
-		    f32: 0x7d,
-		    f64: 0x7c,
-		};
-		exports.MUTABILITY = {
-		    const: 0x00,
-		    var: 0x01,
-		};
-		exports.BLOCK = {
-		    void: 0x40,
-		    i32: 0x7f,
-		    i64: 0x7e,
-		    f32: 0x7d,
-		    f64: 0x7c,
-		};
-		// http://webassembly.github.io/spec/core/binary/types.html#function-types
-		exports.FUNCTION_TYPE = 0x60;
-		// I think these might actually be specific to importdesc
-		exports.MEMORY_IDX = 0x02;
-		exports.GLOBAL_TYPE = 0x03;
-		exports.TYPE_IDX = 0x00;
-		// Takes an f64 on the stack and leaves an int32 boolean representing if it's
-		// within epsilon of zero.
-		exports.IS_ZEROISH = [
-		    exports.op.f64_abs,
-		    ...exports.op.f64_const(exports.EPSILON),
-		    exports.op.f64_lt,
-		];
-		exports.IS_NOT_ZEROISH = [
-		    exports.op.f64_abs,
-		    ...exports.op.f64_const(exports.EPSILON),
-		    exports.op.f64_gt,
-		];
-		// f64
-		function encodef64(num) {
-		    const arr = new Uint8Array(8);
-		    ieee754.write(arr, num);
-		    return arr;
-		}
-		exports.encodef64 = encodef64;
-		exports.encodeString = (str) => [str.length].concat(str.split("").map(s => s.charCodeAt(0)));
-		function unsignedLEB128(n) {
-		    const buffer = [];
-		    do {
-		        let byte = n & 0x7f;
-		        n >>>= 7;
-		        if (n !== 0) {
-		            byte |= 0x80;
-		        }
-		        buffer.push(byte);
-		    } while (n !== 0);
-		    return buffer;
-		}
-		exports.unsignedLEB128 = unsignedLEB128;
-		// https://github.com/shmishtopher/wasm-LEB128/blob/2f1039636e758293e571f996e8012c4d69f4b58f/lib/index.js#L6
-		function signedLEB128(value) {
-		    let bytes = [];
-		    let byte = 0x00;
-		    let size = Math.ceil(Math.log2(Math.abs(value)));
-		    let negative = value < 0;
-		    let more = true;
-		    while (more) {
-		        byte = value & 127;
-		        value = value >> 7;
-		        if (negative) {
-		            value = value | -(1 << (size - 7));
-		        }
-		        if ((value == 0 && (byte & 0x40) == 0) ||
-		            (value == -1 && (byte & 0x40) == 0x40)) {
-		            more = false;
-		        }
-		        else {
-		            byte = byte | 128;
-		        }
-		        bytes.push(byte);
-		    }
-		    return bytes;
-		}
-		exports.signedLEB128 = signedLEB128;
-		// https://webassembly.github.io/spec/core/binary/conventions.html#binary-vec
-		// Vectors are encoded with their length followed by their element sequence
-		exports.encodeFlatVector = (data) => unsignedLEB128(data.length).concat(data);
-		exports.encodeNestedVector = (data) => unsignedLEB128(data.length).concat(utils_1.flatten(data));
-		// subSections is an array of arrays
-		function encodeSection(type, subSections) {
-		    // Sections are all optional, so if we get an empty vector of subSections, we
-		    // can omit the whole section.
-		    if (subSections.length === 0) {
-		        return [];
-		    }
-		    // The size of this vector is not needed for decoding, but can be
-		    // used to skip sections when navigating through a binary.
-		    // TODO: Remove this assertion once we are more confident in our output.
-		    const vec = exports.encodeFlatVector(exports.encodeNestedVector(subSections));
-		    vec.unshift(type);
-		    return vec;
-		}
-		exports.encodeSection = encodeSection;
-		
-	} (encoding));
-	return encoding;
-}
-
-var shims = {};
-
-var hasRequiredShims;
-
-function requireShims () {
-	if (hasRequiredShims) return shims;
-	hasRequiredShims = 1;
-	Object.defineProperty(shims, "__esModule", { value: true });
-	const EPSILON = 0.00001;
-	const shims$1 = {
-	    // TODO: Reimplement some of these functions natively in Wasm?
-	    sin: Math.sin,
-	    cos: Math.cos,
-	    tan: Math.tan,
-	    asin: Math.asin,
-	    acos: Math.acos,
-	    atan: Math.atan,
-	    atan2: Math.atan2,
-	    rand: a => Math.random() * a,
-	    pow: Math.pow,
-	    log: Math.log,
-	    log10: Math.log10,
-	    exp: Math.exp,
-	    sigmoid: function (x, y) {
-	        const t = 1 + Math.exp(-x * y);
-	        return Math.abs(t) > EPSILON ? 1.0 / t : 0;
-	    },
-	};
-	shims.default = shims$1;
-	
-	return shims;
-}
-
-var wasmFunctions = {};
-
-var constants = {};
-
-var hasRequiredConstants;
-
-function requireConstants () {
-	if (hasRequiredConstants) return constants;
-	hasRequiredConstants = 1;
-	(function (exports) {
-		Object.defineProperty(exports, "__esModule", { value: true });
-		// https://webassembly.github.io/spec/core/exec/runtime.html#page-size
-		const WASM_PAGE_SIZE = 65536;
-		const BYTES_PER_F64 = 8;
-		const BUFFER_COUNT = 2;
-		// https://github.com/WACUP/vis_milk2/blob/de9625a89e724afe23ed273b96b8e48496095b6c/ns-eel2/ns-eel.h#L136
-		exports.MAX_LOOP_COUNT = 1048576;
-		// The number of items allowed in each buffer (megabuf/gmegabuf).
-		// https://github.com/WACUP/vis_milk2/blob/de9625a89e724afe23ed273b96b8e48496095b6c/ns-eel2/ns-eel.h#L145
-		exports.BUFFER_SIZE = 65536 * 128;
-		exports.WASM_MEMORY_SIZE = Math.ceil((exports.BUFFER_SIZE * BYTES_PER_F64 * BUFFER_COUNT) / WASM_PAGE_SIZE);
-		
-	} (constants));
-	return constants;
-}
-
-var hasRequiredWasmFunctions;
-
-function requireWasmFunctions () {
-	if (hasRequiredWasmFunctions) return wasmFunctions;
-	hasRequiredWasmFunctions = 1;
-	Object.defineProperty(wasmFunctions, "__esModule", { value: true });
-	const encoding_1 = requireEncoding();
-	const constants_1 = requireConstants();
-	wasmFunctions.localFuncMap = {
-	    sqr: {
-	        args: [encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        binary: [...encoding_1.op.local_get(0), ...encoding_1.op.local_get(0), encoding_1.op.f64_mul],
-	    },
-	    bor: {
-	        args: [encoding_1.VAL_TYPE.f64, encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        binary: [
-	            ...encoding_1.op.local_get(0),
-	            ...encoding_1.IS_NOT_ZEROISH,
-	            ...encoding_1.op.local_get(1),
-	            ...encoding_1.IS_NOT_ZEROISH,
-	            encoding_1.op.i32_or,
-	            ...encoding_1.op.i32_const(0),
-	            encoding_1.op.i32_ne,
-	            encoding_1.op.f64_convert_i32_s,
-	        ],
-	    },
-	    band: {
-	        args: [encoding_1.VAL_TYPE.f64, encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        binary: [
-	            ...encoding_1.op.local_get(0),
-	            ...encoding_1.IS_NOT_ZEROISH,
-	            ...encoding_1.op.local_get(1),
-	            ...encoding_1.IS_NOT_ZEROISH,
-	            encoding_1.op.i32_and,
-	            ...encoding_1.op.i32_const(0),
-	            encoding_1.op.i32_ne,
-	            encoding_1.op.f64_convert_i32_s,
-	        ],
-	    },
-	    sign: {
-	        args: [encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        binary: [
-	            ...encoding_1.op.f64_const(0),
-	            ...encoding_1.op.local_get(0),
-	            encoding_1.op.f64_lt,
-	            ...encoding_1.op.local_get(0),
-	            ...encoding_1.op.f64_const(0),
-	            encoding_1.op.f64_lt,
-	            encoding_1.op.i32_sub,
-	            encoding_1.op.f64_convert_i32_s,
-	        ],
-	    },
-	    mod: {
-	        args: [encoding_1.VAL_TYPE.f64, encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        localVariables: [encoding_1.VAL_TYPE.i32],
-	        // TODO: Simplify all this type coersion
-	        binary: [
-	            ...encoding_1.op.local_get(1),
-	            encoding_1.op.i32_trunc_f64_s,
-	            ...encoding_1.op.local_tee(2),
-	            ...encoding_1.op.i32_const(0),
-	            encoding_1.op.i32_ne,
-	            ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	            ...encoding_1.op.local_get(0),
-	            encoding_1.op.i32_trunc_f64_s,
-	            ...encoding_1.op.local_get(2),
-	            encoding_1.op.i32_rem_s,
-	            encoding_1.op.f64_convert_i32_s,
-	            encoding_1.op.else,
-	            ...encoding_1.op.f64_const(0),
-	            encoding_1.op.end,
-	        ],
-	    },
-	    bitwiseOr: {
-	        args: [encoding_1.VAL_TYPE.f64, encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        binary: [
-	            ...encoding_1.op.local_get(0),
-	            encoding_1.op.i64_trunc_s_f64,
-	            ...encoding_1.op.local_get(1),
-	            encoding_1.op.i64_trunc_s_f64,
-	            encoding_1.op.i64_or,
-	            encoding_1.op.f64_convert_i64_s,
-	        ],
-	    },
-	    bitwiseAnd: {
-	        args: [encoding_1.VAL_TYPE.f64, encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        binary: [
-	            ...encoding_1.op.local_get(0),
-	            encoding_1.op.i64_trunc_s_f64,
-	            ...encoding_1.op.local_get(1),
-	            encoding_1.op.i64_trunc_s_f64,
-	            encoding_1.op.i64_and,
-	            encoding_1.op.f64_convert_i64_s,
-	        ],
-	    },
-	    div: {
-	        args: [encoding_1.VAL_TYPE.f64, encoding_1.VAL_TYPE.f64],
-	        returns: [encoding_1.VAL_TYPE.f64],
-	        localVariables: [encoding_1.VAL_TYPE.i32],
-	        binary: [
-	            ...encoding_1.op.local_get(1),
-	            ...encoding_1.op.f64_const(0),
-	            encoding_1.op.f64_ne,
-	            ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	            ...encoding_1.op.local_get(0),
-	            ...encoding_1.op.local_get(1),
-	            encoding_1.op.f64_div,
-	            encoding_1.op.else,
-	            ...encoding_1.op.f64_const(0),
-	            encoding_1.op.end,
-	        ],
-	    },
-	    // Takes a float buffer index and converts it to an int. Values out of range
-	    // are returned as `-1`.
-	    //
-	    // NOTE: There's actually a subtle bug that exists in Milkdrop's Eel
-	    // implementation, which we reproduce here.
-	    //
-	    // Wasm's `trunc()` rounds towards zero. This means that for index `-1` we
-	    // will return zero, since: `roundTowardZero(-1 + EPSILON) == 0`
-	    //
-	    // A subsequent check handles negative indexes, so negative indexes > than
-	    // `-1` are not affected.
-	    _getBufferIndex: {
-	        args: [encoding_1.VAL_TYPE.f64 /* 0: $index */],
-	        returns: [encoding_1.VAL_TYPE.i32 /* $noramlizedIndex */],
-	        localVariables: [
-	            encoding_1.VAL_TYPE.f64,
-	            encoding_1.VAL_TYPE.i32,
-	        ],
-	        binary: [
-	            ...encoding_1.op.f64_const(encoding_1.EPSILON),
-	            ...encoding_1.op.local_get(0),
-	            encoding_1.op.f64_add,
-	            // STACK: [$i + EPSILON]
-	            ...encoding_1.op.local_tee(1),
-	            encoding_1.op.i32_trunc_f64_s,
-	            // TODO We could probably make this a tee and get rid of the next get if we swap the final condition
-	            ...encoding_1.op.local_set(2),
-	            // STACK: []
-	            ...encoding_1.op.i32_const(-1),
-	            ...encoding_1.op.local_get(2),
-	            // STACK: [-1, $truncated]
-	            ...encoding_1.op.i32_const(8),
-	            encoding_1.op.i32_mul,
-	            // STACK: [-1, $truncated * 8]
-	            ...encoding_1.op.local_get(2),
-	            ...encoding_1.op.i32_const(0),
-	            // STACK: [-1, $truncated * 8, $truncated, 0]
-	            encoding_1.op.i32_lt_s,
-	            // STACK: [-1, $truncated * 8, <is index less than 0>]
-	            ...encoding_1.op.local_get(2),
-	            ...encoding_1.op.i32_const(constants_1.BUFFER_SIZE - 1),
-	            encoding_1.op.i32_gt_s,
-	            // STACK: [-1, $truncated * 8, <is index less than 0>, <is index more than MAX>]
-	            encoding_1.op.i32_or,
-	            // STACK: [-1, $truncated * 8, <is index out of range>]
-	            encoding_1.op.select,
-	        ],
-	    },
-	};
-	
-	return wasmFunctions;
-}
-
-var hasRequiredEmitter;
-
-function requireEmitter () {
-	if (hasRequiredEmitter) return emitter;
-	hasRequiredEmitter = 1;
-	var __importDefault = (emitter && emitter.__importDefault) || function (mod) {
-	    return (mod && mod.__esModule) ? mod : { "default": mod };
-	};
-	Object.defineProperty(emitter, "__esModule", { value: true });
-	const encoding_1 = requireEncoding();
-	const shims_1 = __importDefault(requireShims());
-	const errorUtils_1 = requireErrorUtils();
-	const wasmFunctions_1 = requireWasmFunctions();
-	const utils_1 = requireUtils();
-	const constants_1 = requireConstants();
-	function emit(ast, context) {
-	    var _a, _b, _c;
-	    switch (ast.type) {
-	        case "SCRIPT": {
-	            const body = ast.body.map((statement, i) => {
-	                return [...emit(statement, context), encoding_1.op.drop];
-	            });
-	            return utils_1.flatten(body);
-	        }
-	        case "EXPRESSION_BLOCK": {
-	            return emitExpressionBlock(ast.body, context);
-	        }
-	        case "BINARY_EXPRESSION": {
-	            const left = emit(ast.left, context);
-	            const right = emit(ast.right, context);
-	            const operatorToOps = {
-	                "+": [encoding_1.op.f64_add],
-	                "-": [encoding_1.op.f64_sub],
-	                "*": [encoding_1.op.f64_mul],
-	                "/": context.resolveFunc("div"),
-	                "%": context.resolveFunc("mod"),
-	                "|": context.resolveFunc("bitwiseOr"),
-	                "&": context.resolveFunc("bitwiseAnd"),
-	                "^": context.resolveFunc("pow"),
-	                // Comparison operators
-	                "==": [encoding_1.op.f64_sub, ...encoding_1.IS_ZEROISH, encoding_1.op.f64_convert_i32_s],
-	                "!=": [encoding_1.op.f64_sub, ...encoding_1.IS_NOT_ZEROISH, encoding_1.op.f64_convert_i32_s],
-	                "<": [encoding_1.op.f64_lt, encoding_1.op.f64_convert_i32_s],
-	                ">": [encoding_1.op.f64_gt, encoding_1.op.f64_convert_i32_s],
-	                "<=": [encoding_1.op.f64_le, encoding_1.op.f64_convert_i32_s],
-	                ">=": [encoding_1.op.f64_ge, encoding_1.op.f64_convert_i32_s],
-	            };
-	            const code = operatorToOps[ast.operator];
-	            if (code == null) {
-	                throw errorUtils_1.createCompilerError(`Unknown binary expression operator ${ast.operator}`, ast.loc, context.rawSource);
-	            }
-	            return [...left, ...right, ...code];
-	        }
-	        case "CALL_EXPRESSION": {
-	            const functionName = ast.callee.value;
-	            // Destructure this so that TypeScript knows it won't get mutated.
-	            const argList = ast.arguments;
-	            const assertArity = (arity) => {
-	                if (argList.length < arity) {
-	                    throw errorUtils_1.createUserError(`Too few arguments passed to \`${functionName}()\`. Expected ${arity} but only got ${argList.length}.`, ast.loc, context.rawSource);
-	                }
-	                if (argList.length > arity) {
-	                    throw errorUtils_1.createUserError(`Too many arguments passed to \`${functionName}()\`. Expected ${arity} but got ${argList.length}.`, argList[arity].loc, context.rawSource);
-	                }
-	            };
-	            // Some functions have special behavior
-	            switch (functionName) {
-	                case "exec2":
-	                    assertArity(2);
-	                    return emitExpressionBlock(ast.arguments, context);
-	                case "exec3":
-	                    assertArity(3);
-	                    return emitExpressionBlock(ast.arguments, context);
-	                case "if":
-	                    assertArity(3);
-	                    const [test, consiquent, alternate] = ast.arguments;
-	                    return emitConditional(test, consiquent, alternate, context);
-	                case "while":
-	                    assertArity(1);
-	                    return emitWhile(ast.arguments[0], context);
-	                case "loop":
-	                    assertArity(2);
-	                    return emitLoop(ast.arguments[0], ast.arguments[1], context);
-	                case "megabuf":
-	                case "gmegabuf":
-	                    assertArity(1);
-	                    const index = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	                    return [
-	                        ...emit(ast.arguments[0], context),
-	                        ...((_a = context.resolveFunc("_getBufferIndex")) !== null && _a !== void 0 ? _a : []),
-	                        ...encoding_1.op.local_tee(index),
-	                        ...encoding_1.op.i32_const(-1),
-	                        encoding_1.op.i32_ne,
-	                        // STACK: [in range]
-	                        ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	                        ...encoding_1.op.local_get(index),
-	                        ...encoding_1.op.f64_load(3, emitAddMemoryOffset(functionName)),
-	                        encoding_1.op.else,
-	                        ...encoding_1.op.f64_const(0),
-	                        encoding_1.op.end,
-	                    ];
-	                case "assign":
-	                    assertArity(2);
-	                    const variableIdentifier = ast.arguments[0];
-	                    if (variableIdentifier.type != "IDENTIFIER") {
-	                        throw errorUtils_1.createUserError("Expected the first argument of `assign()` to be an identifier.", variableIdentifier.loc, context.rawSource);
-	                    }
-	                    const resolvedName = context.resolveVar(variableIdentifier.value);
-	                    return [
-	                        ...emit(ast.arguments[1], context),
-	                        ...encoding_1.op.global_set(resolvedName),
-	                        ...encoding_1.op.global_get(resolvedName),
-	                    ];
-	            }
-	            // Function calls which can be linlined
-	            const args = utils_1.flatten(ast.arguments.map(node => emit(node, context)));
-	            // This is just a continuation of the above switch statement, but it's for functions which all parse their args the same.
-	            switch (functionName) {
-	                case "abs":
-	                    assertArity(1);
-	                    return [...args, encoding_1.op.f64_abs];
-	                case "sqrt":
-	                    assertArity(1);
-	                    return [...args, encoding_1.op.f64_abs, encoding_1.op.f64_sqrt];
-	                case "int":
-	                    assertArity(1);
-	                    return [...args, encoding_1.op.f64_floor];
-	                case "min":
-	                    assertArity(2);
-	                    return [...args, encoding_1.op.f64_min];
-	                case "max":
-	                    assertArity(2);
-	                    return [...args, encoding_1.op.f64_max];
-	                case "above":
-	                    assertArity(2);
-	                    return [...args, encoding_1.op.f64_gt, encoding_1.op.f64_convert_i32_s];
-	                case "below":
-	                    assertArity(2);
-	                    return [...args, encoding_1.op.f64_lt, encoding_1.op.f64_convert_i32_s];
-	                case "equal":
-	                    assertArity(2);
-	                    return [...args, encoding_1.op.f64_sub, ...encoding_1.IS_ZEROISH, encoding_1.op.f64_convert_i32_s];
-	                case "bnot":
-	                    assertArity(1);
-	                    return [...args, ...encoding_1.IS_ZEROISH, encoding_1.op.f64_convert_i32_s];
-	                case "floor":
-	                    assertArity(1);
-	                    return [...args, encoding_1.op.f64_floor];
-	                case "ceil":
-	                    assertArity(1);
-	                    return [...args, encoding_1.op.f64_ceil];
-	            }
-	            const invocation = context.resolveFunc(functionName);
-	            if (invocation == null ||
-	                // Ensure this isn't a private function. This is a bit awkward becuase
-	                // Eel does implement some _ functions but while they are _intended_ to be
-	                // private, they accidentally expose them. We should find a cleaner way
-	                // to defining user accessible functions vs utility functions used by
-	                // the compiler.
-	                functionName.startsWith("_")) {
-	                throw errorUtils_1.createUserError(`"${functionName}" is not defined.`, ast.callee.loc, context.rawSource);
-	            }
-	            if (shims_1.default[functionName] != null) {
-	                assertArity(shims_1.default[functionName].length);
-	            }
-	            else if (wasmFunctions_1.localFuncMap[functionName] != null) {
-	                assertArity(wasmFunctions_1.localFuncMap[functionName].args.length);
-	            }
-	            else {
-	                throw errorUtils_1.createCompilerError(`Missing arity information for the function \`${functionName}()\``, ast.callee.loc, context.rawSource);
-	            }
-	            return [...args, ...invocation];
-	        }
-	        case "ASSIGNMENT_EXPRESSION": {
-	            const { left } = ast;
-	            const rightCode = emit(ast.right, context);
-	            const mutationCode = getAssignmentOperatorMutation(ast, context);
-	            if (left.type === "IDENTIFIER") {
-	                const resolvedName = context.resolveVar(left.value);
-	                // TODO: In lots of cases we don't care about the return value. In those
-	                // cases we should try to find a way to omit the `get/drop` combo.
-	                // Peephole optimization seems to be the conventional way to do this.
-	                // https://en.wikipedia.org/wiki/Peephole_optimization
-	                const get = encoding_1.op.global_get(resolvedName);
-	                const set = encoding_1.op.global_set(resolvedName);
-	                // `=` is a special case in that it does not need the original value.
-	                if (mutationCode === null) {
-	                    return [...rightCode, ...set, ...get];
-	                }
-	                return [...get, ...rightCode, ...mutationCode, ...set, ...get];
-	            }
-	            if (left.type !== "CALL_EXPRESSION") {
-	                throw errorUtils_1.createCompilerError(
-	                // @ts-ignore This is a guard in case the parser has an error
-	                `Unexpected left hand side type for assignment: ${left.type}`, ast.loc, context.rawSource);
-	            }
-	            // Special assignment case for `megabuf(n) = e` and `gmegabuf(n) = e`.
-	            const localIndex = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	            if (left.arguments.length !== 1) {
-	                throw errorUtils_1.createUserError(`Expected 1 argument when assinging to a buffer but got ${left.arguments.length}.`, left.arguments.length === 0 ? left.loc : left.arguments[1].loc, context.rawSource);
-	            }
-	            const bufferName = left.callee.value;
-	            if (bufferName !== "gmegabuf" && bufferName !== "megabuf") {
-	                throw errorUtils_1.createUserError("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.", left.callee.loc, context.rawSource);
-	            }
-	            const addOffset = emitAddMemoryOffset(bufferName);
-	            if (mutationCode === null) {
-	                // TODO: Move this to wasmFunctions once we know how to call functions
-	                // from within functions (need to get the offset).
-	                const unnormalizedIndex = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	                const rightValue = context.resolveLocal(encoding_1.VAL_TYPE.f64);
-	                return [
-	                    // Emit the right hand side unconditionally to ensure it always runs.
-	                    ...rightCode,
-	                    ...encoding_1.op.local_set(rightValue),
-	                    ...emit(left.arguments[0], context),
-	                    ...((_b = context.resolveFunc("_getBufferIndex")) !== null && _b !== void 0 ? _b : []),
-	                    ...encoding_1.op.local_tee(unnormalizedIndex),
-	                    ...encoding_1.op.i32_const(0),
-	                    encoding_1.op.i32_lt_s,
-	                    // STACK: [is the index out of range?]
-	                    ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	                    ...encoding_1.op.f64_const(0),
-	                    encoding_1.op.else,
-	                    ...encoding_1.op.local_get(unnormalizedIndex),
-	                    ...encoding_1.op.local_tee(localIndex),
-	                    // STACK: [buffer index]
-	                    ...encoding_1.op.local_get(rightValue),
-	                    // STACK: [buffer index, right]
-	                    ...encoding_1.op.f64_store(3, addOffset),
-	                    // STACK: []
-	                    ...encoding_1.op.local_get(rightValue),
-	                    // STACK: [Right/Buffer value]
-	                    encoding_1.op.end,
-	                ];
-	            }
-	            // TODO: Move this to wasmFunctions once we know how to call functions
-	            // from within functions (need to get the offset).
-	            const index = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	            const inBounds = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	            const rightValue = context.resolveLocal(encoding_1.VAL_TYPE.f64);
-	            const result = context.resolveLocal(encoding_1.VAL_TYPE.f64);
-	            return [
-	                ...rightCode,
-	                ...encoding_1.op.local_set(rightValue),
-	                ...emit(left.arguments[0], context),
-	                ...((_c = context.resolveFunc("_getBufferIndex")) !== null && _c !== void 0 ? _c : []),
-	                ...encoding_1.op.local_tee(index),
-	                // STACK: [index]
-	                ...encoding_1.op.i32_const(-1),
-	                encoding_1.op.i32_ne,
-	                ...encoding_1.op.local_tee(inBounds),
-	                ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	                ...encoding_1.op.local_get(index),
-	                ...encoding_1.op.f64_load(3, addOffset),
-	                encoding_1.op.else,
-	                ...encoding_1.op.f64_const(0),
-	                encoding_1.op.end,
-	                // STACK: [current value from memory || 0]
-	                // Apply the mutation
-	                ...encoding_1.op.local_get(rightValue),
-	                ...mutationCode,
-	                ...encoding_1.op.local_tee(result),
-	                // STACK: [new value]
-	                ...encoding_1.op.local_get(inBounds),
-	                ...encoding_1.op.if(encoding_1.BLOCK.void),
-	                ...encoding_1.op.local_get(index),
-	                ...encoding_1.op.local_get(result),
-	                ...encoding_1.op.f64_store(3, addOffset),
-	                encoding_1.op.end,
-	            ];
-	        }
-	        case "LOGICAL_EXPRESSION": {
-	            const left = emit(ast.left, context);
-	            const right = emit(ast.right, context);
-	            const behaviorMap = {
-	                "&&": {
-	                    comparison: encoding_1.IS_ZEROISH,
-	                    shortCircutValue: 0,
-	                },
-	                "||": {
-	                    comparison: encoding_1.IS_NOT_ZEROISH,
-	                    shortCircutValue: 1,
-	                },
-	            };
-	            const behavior = behaviorMap[ast.operator];
-	            if (behavior == null) {
-	                throw errorUtils_1.createCompilerError(`Unknown logical expression operator ${ast.operator}`, ast.loc, context.rawSource);
-	            }
-	            const { comparison, shortCircutValue } = behavior;
-	            return [
-	                ...left,
-	                ...comparison,
-	                ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	                ...encoding_1.op.f64_const(shortCircutValue),
-	                encoding_1.op.else,
-	                ...right,
-	                ...encoding_1.IS_NOT_ZEROISH,
-	                encoding_1.op.f64_convert_i32_s,
-	                encoding_1.op.end,
-	            ];
-	        }
-	        case "UNARY_EXPRESSION": {
-	            const value = emit(ast.value, context);
-	            const operatorToCode = {
-	                "-": [encoding_1.op.f64_neg],
-	                "+": [],
-	                "!": [...encoding_1.IS_ZEROISH, encoding_1.op.f64_convert_i32_s],
-	            };
-	            const code = operatorToCode[ast.operator];
-	            if (code == null) {
-	                throw errorUtils_1.createCompilerError(`Unknown logical unary operator ${ast.operator}`, ast.loc, context.rawSource);
-	            }
-	            return [...value, ...code];
-	        }
-	        case "IDENTIFIER":
-	            const variableName = ast.value;
-	            // TODO: It's a bit odd that not every IDENTIFIER node gets emitted. In
-	            // function calls and assignments we just peek at the name and never emit
-	            // it.
-	            return encoding_1.op.global_get(context.resolveVar(variableName));
-	        case "NUMBER_LITERAL":
-	            return encoding_1.op.f64_const(ast.value);
-	        default:
-	            throw errorUtils_1.createCompilerError(
-	            // @ts-ignore This runtime check is here because the caller may not be type-checked
-	            `Unknown AST node type ${ast.type}`, 
-	            // @ts-ignore This runtime check is here because the caller may not be type-checked
-	            ast.loc, context.rawSource);
-	    }
-	}
-	emitter.emit = emit;
-	function emitExpressionBlock(body, context) {
-	    const statements = body.map((statement, i) => {
-	        return emit(statement, context);
-	    });
-	    return utils_1.flatten(utils_1.arrayJoin(statements, [encoding_1.op.drop]));
-	}
-	function emitWhile(expression, context) {
-	    const body = emit(expression, context);
-	    const iterationCount = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	    return [
-	        ...encoding_1.op.i32_const(0),
-	        ...encoding_1.op.local_set(iterationCount),
-	        ...encoding_1.op.loop(encoding_1.BLOCK.void),
-	        // Increment and check loop count
-	        ...encoding_1.op.local_get(iterationCount),
-	        ...encoding_1.op.i32_const(1),
-	        encoding_1.op.i32_add,
-	        ...encoding_1.op.local_tee(iterationCount),
-	        // STACK: [iteration count]
-	        ...encoding_1.op.i32_const(constants_1.MAX_LOOP_COUNT),
-	        encoding_1.op.i32_lt_u,
-	        // STACK: [loop in range]
-	        ...body,
-	        ...encoding_1.IS_NOT_ZEROISH,
-	        // STACK: [loop in range, body is truthy]
-	        encoding_1.op.i32_and,
-	        // STACK: [can continue]
-	        ...encoding_1.op.br_if(0),
-	        encoding_1.op.end,
-	        ...encoding_1.op.f64_const(0),
-	    ];
-	}
-	function emitLoop(count, expression, context) {
-	    const body = emit(expression, context);
-	    const localIndex = context.resolveLocal(encoding_1.VAL_TYPE.i32);
-	    return [
-	        ...encoding_1.op.block(encoding_1.BLOCK.void),
-	        // Assign the count to a variable
-	        ...emit(count, context),
-	        encoding_1.op.i32_trunc_f64_s,
-	        ...encoding_1.op.local_tee(localIndex),
-	        ...encoding_1.op.i32_const(0),
-	        encoding_1.op.i32_le_s,
-	        ...encoding_1.op.br_if(1),
-	        ...encoding_1.op.loop(encoding_1.BLOCK.void),
-	        // Run the body
-	        ...body,
-	        encoding_1.op.drop,
-	        // Decrement the count
-	        ...encoding_1.op.local_get(localIndex),
-	        ...encoding_1.op.i32_const(1),
-	        encoding_1.op.i32_sub,
-	        ...encoding_1.op.local_tee(localIndex),
-	        ...encoding_1.op.i32_const(0),
-	        encoding_1.op.i32_ne,
-	        ...encoding_1.op.br_if(0),
-	        encoding_1.op.end,
-	        encoding_1.op.end,
-	        ...encoding_1.op.f64_const(0),
-	    ];
-	}
-	function emitConditional(test, consiquent, alternate, context) {
-	    // TODO: In some cases https://webassembly.studio/ compiles these to use `select`.
-	    // Is that an optimization that we might want as well?
-	    return [
-	        ...emit(test, context),
-	        ...encoding_1.IS_NOT_ZEROISH,
-	        ...encoding_1.op.if(encoding_1.BLOCK.f64),
-	        ...emit(consiquent, context),
-	        encoding_1.op.else,
-	        ...emit(alternate, context),
-	        encoding_1.op.end,
-	    ];
-	}
-	// There are two sections of memory. This function emits code to add the correct
-	// offset to an i32 index already on the stack.
-	function emitAddMemoryOffset(name) {
-	    switch (name) {
-	        case "gmegabuf":
-	            return constants_1.BUFFER_SIZE * 8;
-	        case "megabuf":
-	            return 0;
-	    }
-	}
-	function getAssignmentOperatorMutation(ast, context) {
-	    const operatorToCode = {
-	        "+=": [encoding_1.op.f64_add],
-	        "-=": [encoding_1.op.f64_sub],
-	        "*=": [encoding_1.op.f64_mul],
-	        "/=": [encoding_1.op.f64_div],
-	        "%=": context.resolveFunc("mod"),
-	        "=": null,
-	    };
-	    const operatorCode = operatorToCode[ast.operator];
-	    if (operatorCode === undefined) {
-	        throw errorUtils_1.createCompilerError(`Unknown assignment operator "${ast.operator}"`, ast.loc, context.rawSource);
-	    }
-	    return operatorCode;
-	}
-	
-	return emitter;
-}
-
-var hasRequiredCompiler;
-
-function requireCompiler () {
-	if (hasRequiredCompiler) return compiler;
-	hasRequiredCompiler = 1;
-	var __importDefault = (compiler && compiler.__importDefault) || function (mod) {
-	    return (mod && mod.__esModule) ? mod : { "default": mod };
-	};
-	var __importStar = (compiler && compiler.__importStar) || function (mod) {
-	    if (mod && mod.__esModule) return mod;
-	    var result = {};
-	    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
-	    result["default"] = mod;
-	    return result;
-	};
-	Object.defineProperty(compiler, "__esModule", { value: true });
-	const parser_1 = requireParser();
-	const emitter_1 = requireEmitter();
-	const encoding_1 = requireEncoding();
-	const shims_1 = __importDefault(requireShims());
-	const Utils = __importStar(requireUtils());
-	const wasmFunctions_1 = requireWasmFunctions();
-	const constants_1 = requireConstants();
-	function compileModule({ pools, functions: funcs, eelVersion = 2, preParsed = false, }) {
-	    if (Object.keys(pools).includes("shims")) {
-	        throw new Error('You may not name a pool "shims". "shims" is reserved for injected JavaScript functions.');
-	    }
-	    // Collect all the globals that we expect to get as imports.
-	    const importedVars = [];
-	    Object.entries(pools).forEach(([poolName, pool]) => {
-	        pool.forEach(variableName => {
-	            importedVars.push([poolName, variableName]);
-	        });
-	    });
-	    // Ensure all the imported globals get the first ids.
-	    const varResolver = new Utils.ScopedIdMap();
-	    importedVars.forEach(([poolName, variableName]) => {
-	        varResolver.get(poolName, variableName);
-	    });
-	    const functionImports = Object.entries(shims_1.default).map(([name, func]) => {
-	        return {
-	            args: new Array(func.length).fill(null).map(_ => encoding_1.VAL_TYPE.f64),
-	            // Shims implicitly always return a number
-	            returns: [encoding_1.VAL_TYPE.f64],
-	            name,
-	        };
-	    });
-	    const localFuncOrder = [];
-	    const moduleFuncs = [];
-	    Object.entries(funcs).forEach(([name, { pool, code }]) => {
-	        if (pools[pool] == null) {
-	            const poolsList = Object.keys(pools);
-	            if (poolsList.length === 0) {
-	                throw new Error(`The function "${name}" was declared as using a variable ` +
-	                    `pool named "${pool}" but no pools were defined.`);
-	            }
-	            throw new Error(`The function "${name}" was declared as using a variable ` +
-	                `pool named "${pool}" which is not among the variable ` +
-	                `pools defined. The defined variable pools are: ` +
-	                `${Utils.formatList(poolsList)}.`);
-	        }
-	        const ast = preParsed ? code : parser_1.parse(code);
-	        if (typeof ast === "string") {
-	            // TODO: Change the API so this can be enforced by types
-	            throw new Error("Got passed unparsed code without setting the preParsed flag");
-	        }
-	        if (ast.type !== "SCRIPT") {
-	            throw new Error("Invalid AST");
-	        }
-	        if (ast.body.length === 0) {
-	            return;
-	        }
-	        const localVariables = [];
-	        const context = {
-	            resolveVar: name => {
-	                // The `reg00`-`reg99` variables are special in that they are shared between all pools.
-	                if (/^reg\d\d$/.test(name)) {
-	                    return varResolver.get(null, name);
-	                }
-	                return varResolver.get(pool, name);
-	            },
-	            resolveLocal: type => {
-	                // TODO: We could provide a way for the emitter to release a local
-	                // variable so that we can reuse it, much in the same way a traditional
-	                // compiler does in register allocation.
-	                localVariables.push(type);
-	                return localVariables.length - 1;
-	            },
-	            resolveFunc: name => {
-	                // If this is a shim, return the shim index.
-	                const shimdex = functionImports.findIndex(func => func.name === name);
-	                if (shimdex !== -1) {
-	                    const call = encoding_1.op.call(shimdex);
-	                    if (name === "rand" && eelVersion === 1) {
-	                        return [...call, encoding_1.op.f64_floor];
-	                    }
-	                    return call;
-	                }
-	                // If it's not a shim and it's not a defined function, return null.
-	                // The emitter will generate a nice error.
-	                if (wasmFunctions_1.localFuncMap[name] == null) {
-	                    return null;
-	                }
-	                let index = localFuncOrder.indexOf(name);
-	                if (index === -1) {
-	                    localFuncOrder.push(name);
-	                    index = localFuncOrder.length - 1;
-	                }
-	                return encoding_1.op.call(index + functionImports.length);
-	            },
-	            rawSource: code,
-	        };
-	        const binary = emitter_1.emit(ast, context);
-	        moduleFuncs.push({
-	            binary,
-	            exportName: name,
-	            args: [],
-	            returns: [],
-	            localVariables,
-	        });
-	    });
-	    const localFuncs = localFuncOrder.map(name => {
-	        const func = wasmFunctions_1.localFuncMap[name];
-	        // This check is technicaly redundant since we check inside resolveLocalFunc
-	        // in the compiler context. It's here just to catch potential compiler bugs.
-	        if (func == null) {
-	            throw new Error(`Undefined local function "${name}"`);
-	        }
-	        return func;
-	    });
-	    // Given a function definition, return a hashable string representation of its signature.
-	    const getSignatureKey = (func) => {
-	        return [...func.args, "|", ...func.returns].join("-");
-	    };
-	    // https://webassembly.github.io/spec/core/binary/modules.html#type-section
-	    const types = [];
-	    const typeIndexByKey = new Map();
-	    [...functionImports, ...localFuncs, ...moduleFuncs].forEach(func => {
-	        const key = getSignatureKey(func);
-	        if (typeIndexByKey.has(key)) {
-	            return;
-	        }
-	        types.push([
-	            encoding_1.FUNCTION_TYPE,
-	            ...encoding_1.encodeFlatVector(func.args),
-	            ...encoding_1.encodeFlatVector(func.returns),
-	        ]);
-	        typeIndexByKey.set(key, types.length - 1);
-	    });
-	    function getTypeIndex(func) {
-	        const key = getSignatureKey(func);
-	        const typeIndex = typeIndexByKey.get(key);
-	        if (typeIndex == null) {
-	            throw new Error(`Failed to get a type index for key ${key}`);
-	        }
-	        return typeIndex;
-	    }
-	    // https://webassembly.github.io/spec/core/binary/modules.html#import-section
-	    const imports = [
-	        ...importedVars.map(([namespace, name]) => {
-	            return [
-	                ...encoding_1.encodeString(namespace),
-	                ...encoding_1.encodeString(name),
-	                ...[encoding_1.GLOBAL_TYPE, encoding_1.VAL_TYPE.f64, encoding_1.MUTABILITY.var],
-	            ];
-	        }),
-	        ...functionImports.map((func, i) => {
-	            const typeIndex = getTypeIndex(func);
-	            return [
-	                ...encoding_1.encodeString("shims"),
-	                ...encoding_1.encodeString(func.name),
-	                ...[encoding_1.TYPE_IDX, ...encoding_1.unsignedLEB128(typeIndex)],
-	            ];
-	        }),
-	    ];
-	    // https://webassembly.github.io/spec/core/binary/modules.html#function-section
-	    //
-	    // > Functions are referenced through function indices, starting with the smallest
-	    // > index not referencing a function import.
-	    const functions = [...localFuncs, ...moduleFuncs].map(func => {
-	        const typeIndex = getTypeIndex(func);
-	        return encoding_1.unsignedLEB128(typeIndex);
-	    });
-	    const memories = [
-	        // Only one memory
-	        [
-	            0x01,
-	            ...encoding_1.unsignedLEB128(constants_1.WASM_MEMORY_SIZE),
-	            ...encoding_1.unsignedLEB128(constants_1.WASM_MEMORY_SIZE),
-	        ],
-	    ];
-	    // https://webassembly.github.io/spec/core/binary/modules.html#global-section
-	    const globalCount = varResolver.size() - importedVars.length;
-	    const globals = Utils.times(globalCount, () => {
-	        return [
-	            encoding_1.VAL_TYPE.f64,
-	            encoding_1.MUTABILITY.var,
-	            ...encoding_1.op.f64_const(0),
-	            encoding_1.op.end,
-	        ];
-	    });
-	    // https://webassembly.github.io/spec/core/binary/modules.html#binary-exportsec
-	    const xports = [...moduleFuncs].map((func, i) => {
-	        const funcIndex = i + functionImports.length + localFuncs.length;
-	        return [
-	            ...encoding_1.encodeString(func.exportName),
-	            encoding_1.EXPORT_TYPE.FUNC,
-	            ...encoding_1.unsignedLEB128(funcIndex),
-	        ];
-	    });
-	    /* Uncomment this to expose memory
-	    xports.push([
-	      ...encodeString("memory"),
-	      EXPORT_TYPE.MEMORY,
-	      ...unsignedLEB128(0),
-	    ]);
-	    */
-	    // https://webassembly.github.io/spec/core/binary/modules.html#code-section
-	    const codes = [...localFuncs, ...moduleFuncs].map(func => {
-	        var _a;
-	        // TODO: We could collapose consecutive types here, or even move to a two
-	        // pass approach where ids are resolved after the emitter is run.
-	        const localTypes = ((_a = func.localVariables) !== null && _a !== void 0 ? _a : []).map(type => {
-	            return [...encoding_1.unsignedLEB128(1), type];
-	        });
-	        // It's a bit odd that every other section is an array of arrays and this
-	        // one is an array of vectors. The spec says this is so that when navigating
-	        // the binary functions can be skipped efficiently.
-	        return encoding_1.encodeFlatVector([
-	            ...encoding_1.encodeNestedVector(localTypes),
-	            ...func.binary,
-	            encoding_1.op.end,
-	        ]);
-	    });
-	    return new Uint8Array([
-	        // Magic module header
-	        ...encoding_1.MAGIC,
-	        // Version number
-	        ...encoding_1.WASM_VERSION,
-	        ...encoding_1.encodeSection(encoding_1.SECTION.TYPE, types),
-	        ...encoding_1.encodeSection(encoding_1.SECTION.IMPORT, imports),
-	        ...encoding_1.encodeSection(encoding_1.SECTION.FUNC, functions),
-	        ...encoding_1.encodeSection(encoding_1.SECTION.MEMORY, memories),
-	        ...encoding_1.encodeSection(encoding_1.SECTION.GLOBAL, globals),
-	        ...encoding_1.encodeSection(encoding_1.SECTION.EXPORT, xports),
-	        ...encoding_1.encodeSection(encoding_1.SECTION.CODE, codes),
-	    ]);
-	}
-	compiler.compileModule = compileModule;
-	
-	return compiler;
-}
-
-var loader = {};
-
-var hasRequiredLoader;
-
-function requireLoader () {
-	if (hasRequiredLoader) return loader;
-	hasRequiredLoader = 1;
-	var __importDefault = (loader && loader.__importDefault) || function (mod) {
-	    return (mod && mod.__esModule) ? mod : { "default": mod };
-	};
-	Object.defineProperty(loader, "__esModule", { value: true });
-	const shims_1 = __importDefault(requireShims());
-	const compiler_1 = requireCompiler();
-	async function loadModule({ pools, functions, eelVersion = 2, }) {
-	    let compilerPools = {};
-	    Object.entries(pools).forEach(([key, globals]) => {
-	        compilerPools[key] = new Set(Object.keys(globals));
-	    });
-	    const buffer = compiler_1.compileModule({
-	        pools: compilerPools,
-	        functions,
-	        eelVersion,
-	    });
-	    const mod = await WebAssembly.compile(buffer);
-	    var importObject = Object.assign(Object.assign({}, pools), { shims: shims_1.default });
-	    return await WebAssembly.instantiate(mod, importObject);
-	}
-	loader.loadModule = loadModule;
-	
-	return loader;
-}
-
-var hasRequiredSrc;
-
-function requireSrc () {
-	if (hasRequiredSrc) return src;
-	hasRequiredSrc = 1;
-	var __importDefault = (src && src.__importDefault) || function (mod) {
-	    return (mod && mod.__esModule) ? mod : { "default": mod };
-	};
-	Object.defineProperty(src, "__esModule", { value: true });
-	const parser_1 = requireParser();
-	src.parse = parser_1.parse;
-	const compiler_1 = requireCompiler();
-	src.compileModule = compiler_1.compileModule;
-	const shims_1 = __importDefault(requireShims());
-	src.shims = shims_1.default;
-	const loader_1 = requireLoader();
-	src.loadModule = loader_1.loadModule;
-	
-	return src;
-}
-
-var srcExports = requireSrc();
+function t(t,e){let n={destCol:1,srcCol:1,srcLine:1};t.forEach(t=>{t.destCol>e||(n=t);});const r=e-n.destCol;return {column:n.srcCol+r,line:n.srcLine}}var e=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,18],n=[1,7],r=[1,19],s=[1,20],i=[1,14],o=[1,15],a=[1,16],c=[1,33],l=[1,31],h=[1,23],u=[1,22],y=[1,24],p=[1,25],f=[1,26],g=[1,27],m=[1,28],_=[1,29],E=[1,30],d=[5,8,15,18,20,28,29,32,33,34,35,36,37,38],b=[5,15,18],w=[5,12,15,17,18,24,25,28,29,30],S=[1,57],I=[5,8,12,15,17,18,24,25,28,29,30],k=[15,18],O=[5,8,15,18,28,29,38],N=[5,8,15,18,28,29,32,33,38],v=[5,8,15,18,28,29,32,33,34,37,38],R=[5,8,15,18,28,29,32,33,34,35,36,37,38],$=[5,8,15,18],A=[5,8,15,18,20,22,28,29,32,33,34,35,36,37,38],x={trace:function(){},yy:{},symbols_:{error:2,SCRIPT:3,expression:4,EOF:5,expressionsOptionalTrailingSemi:6,separator:7,";":8,expressions:9,EXPRESSION_BLOCK:10,IDENTIFIER:11,IDENTIFIER_TOKEN:12,argument:13,arguments:14,",":15,FUNCTION_CALL:16,"(":17,")":18,LOGICAL_EXPRESSION:19,LOGICAL_OPERATOR_TOKEN:20,ASSIGNMENT:21,ASSIGNMENT_OPERATOR_TOKEN:22,number:23,DIGITS_TOKEN:24,".":25,NUMBER_LITERAL:26,UNARY_EXPRESSION:27,"-":28,"+":29,"!":30,BINARY_EXPRESSION:31,"*":32,"/":33,"%":34,"&":35,"|":36,"^":37,COMPARISON_TOKEN:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:";",12:"IDENTIFIER_TOKEN",15:",",17:"(",18:")",20:"LOGICAL_OPERATOR_TOKEN",22:"ASSIGNMENT_OPERATOR_TOKEN",24:"DIGITS_TOKEN",25:".",28:"-",29:"+",30:"!",32:"*",33:"/",34:"%",35:"&",36:"|",37:"^",38:"COMPARISON_TOKEN"},productions_:[0,[3,2],[3,2],[3,1],[7,1],[7,2],[9,2],[9,3],[6,1],[6,2],[10,1],[11,1],[13,1],[13,1],[14,1],[14,3],[16,3],[16,4],[19,3],[21,3],[21,3],[23,1],[23,2],[23,3],[23,2],[23,1],[26,1],[27,2],[27,2],[27,2],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[4,1],[4,1],[4,3],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3]],performAction:function(t,e,n,r,s,i,o){var a=i.length-1;switch(s){case 1:return {type:"SCRIPT",body:[i[a-1]],loc:this._$};case 2:return {type:"SCRIPT",body:i[a-1],loc:this._$};case 3:return {type:"SCRIPT",body:[],loc:this._$};case 6:this.$=[i[a-1]];break;case 7:this.$=i[a-2].concat([i[a-1]]);break;case 8:this.$=i[a];break;case 9:this.$=i[a-1].concat([i[a]]);break;case 10:this.$={type:"EXPRESSION_BLOCK",body:i[a],loc:this._$};break;case 11:this.$={type:"IDENTIFIER",value:i[a].toLowerCase(),loc:this._$};break;case 14:this.$=[i[a]];break;case 15:this.$=i[a-2].concat([i[a]]);break;case 16:this.$={type:"CALL_EXPRESSION",callee:i[a-2],arguments:[],loc:this._$};break;case 17:this.$={type:"CALL_EXPRESSION",callee:i[a-3],arguments:i[a-1],loc:this._$};break;case 18:this.$={type:"LOGICAL_EXPRESSION",left:i[a-2],right:i[a],operator:i[a-1],loc:this._$};break;case 19:case 20:this.$={type:"ASSIGNMENT_EXPRESSION",left:i[a-2],operator:i[a-1],right:i[a],loc:this._$};break;case 21:this.$=Number(i[a]);break;case 22:this.$=Number(i[a-1]);break;case 23:this.$=Number(i[a-2]+i[a-1]+i[a]);break;case 24:this.$=Number("0"+i[a-1]+i[a]);break;case 25:this.$=0;break;case 26:this.$={type:"NUMBER_LITERAL",value:i[a],loc:this._$};break;case 27:case 28:case 29:this.$={type:"UNARY_EXPRESSION",value:i[a],operator:i[a-1],loc:this._$};break;case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:this.$={type:"BINARY_EXPRESSION",left:i[a-2],right:i[a],operator:i[a-1],loc:this._$};break;case 41:case 47:this.$=i[a-1];}},table:[{3:1,4:2,5:[1,4],6:3,9:13,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{1:[3]},{5:[1,21],7:32,8:c,20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E},{5:[1,34]},{1:[2,3]},t(d,[2,39]),t(d,[2,40]),{4:35,6:37,9:13,10:36,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},t(d,[2,42]),t(d,[2,43]),t(d,[2,44],{22:[1,38]}),t(d,[2,45],{17:[1,40],22:[1,39]}),t(d,[2,46]),t(b,[2,8],{31:5,27:6,26:8,21:9,16:10,11:11,19:12,23:17,4:41,12:e,17:n,24:r,25:s,28:i,29:o,30:a}),{4:42,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:43,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:44,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},t(d,[2,26]),t([5,8,15,17,18,20,22,28,29,32,33,34,35,36,37,38],[2,11]),t(d,[2,21],{25:[1,45]}),t(d,[2,25],{24:[1,46]}),{1:[2,1]},{4:47,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:48,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:49,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:50,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:51,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:52,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:53,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:54,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:55,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:56,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},t(w,[2,6],{8:S}),t(I,[2,4]),{1:[2,2]},{7:32,8:c,18:[1,58],20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E},{18:[1,59]},t(k,[2,10]),{4:60,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:61,11:11,12:e,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},{4:65,6:37,9:13,10:66,11:11,12:e,13:64,14:63,16:10,17:n,18:[1,62],19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},t(b,[2,9],{7:67,8:c,20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E}),t(O,[2,27],{20:l,32:y,33:p,34:f,35:g,36:m,37:_}),t(O,[2,28],{20:l,32:y,33:p,34:f,35:g,36:m,37:_}),t(O,[2,29],{20:l,32:y,33:p,34:f,35:g,36:m,37:_}),t(d,[2,22],{24:[1,68]}),t(d,[2,24]),t(O,[2,30],{20:l,32:y,33:p,34:f,35:g,36:m,37:_}),t(O,[2,31],{20:l,32:y,33:p,34:f,35:g,36:m,37:_}),t(N,[2,32],{20:l,34:f,35:g,36:m,37:_}),t(N,[2,33],{20:l,34:f,35:g,36:m,37:_}),t(v,[2,34],{20:l,35:g,36:m}),t(R,[2,35],{20:l}),t(R,[2,36],{20:l}),t(v,[2,37],{20:l,35:g,36:m}),t($,[2,38],{20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E}),t(d,[2,18]),t(I,[2,5]),t(d,[2,41]),t(d,[2,47]),t($,[2,20],{20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E}),t($,[2,19],{20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E}),t(A,[2,16]),{15:[1,70],18:[1,69]},t(k,[2,14]),t(k,[2,12],{7:32,8:c,20:l,28:h,29:u,32:y,33:p,34:f,35:g,36:m,37:_,38:E}),t(k,[2,13]),t(w,[2,7],{8:S}),t(d,[2,23]),t(A,[2,17]),{4:65,6:37,9:13,10:66,11:11,12:e,13:71,16:10,17:n,19:12,21:9,23:17,24:r,25:s,26:8,27:6,28:i,29:o,30:a,31:5},t(k,[2,15])],defaultActions:{4:[2,3],21:[2,1],34:[2,2]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[null],s=[],i=this.table,o="",a=0,c=0,l=s.slice.call(arguments,1),h=Object.create(this.lexer),u={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(u.yy[y]=this.yy[y]);h.setInput(t,u.yy),u.yy.lexer=h,u.yy.parser=this,void 0===h.yylloc&&(h.yylloc={});var p=h.yylloc;s.push(p);var f=h.options&&h.options.ranges;"function"==typeof u.yy.parseError?this.parseError=u.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,m,_,E,d,b,w,S,I=function(){var t;return "number"!=typeof(t=h.lex()||1)&&(t=e.symbols_[t]||t),t},k={};;){if(m=n[n.length-1],this.defaultActions[m]?_=this.defaultActions[m]:(null==g&&(g=I()),_=i[m]&&i[m][g]),void 0===_||!_.length||!_[0]){var O="";for(d in S=[],i[m])this.terminals_[d]&&d>2&&S.push("'"+this.terminals_[d]+"'");O=h.showPosition?"Parse error on line "+(a+1)+":\n"+h.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(O,{text:h.match,token:this.terminals_[g]||g,line:h.yylineno,loc:p,expected:S});}if(_[0]instanceof Array&&_.length>1)throw new Error("Parse Error: multiple actions possible at state: "+m+", token: "+g);switch(_[0]){case 1:n.push(g),r.push(h.yytext),s.push(h.yylloc),n.push(_[1]),g=null,c=h.yyleng,o=h.yytext,a=h.yylineno,p=h.yylloc;break;case 2:if(b=this.productions_[_[1]][1],k.$=r[r.length-b],k._$={first_line:s[s.length-(b||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(b||1)].first_column,last_column:s[s.length-1].last_column},f&&(k._$.range=[s[s.length-(b||1)].range[0],s[s.length-1].range[1]]),void 0!==(E=this.performAction.apply(k,[o,c,a,u.yy,_[1],r,s].concat(l))))return E;b&&(n=n.slice(0,-1*b*2),r=r.slice(0,-1*b),s=s.slice(0,-1*b)),n.push(this.productions_[_[1]][0]),r.push(k.$),s.push(k._$),w=i[n[n.length-2]][n[n.length-1]],n.push(w);break;case 3:return  true}}return  true}},L={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=false,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=true,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=true,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=false,this._backtrack=false,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=false),n)return n;if(this._backtrack){for(var i in s)this[i]=s[i];return  false}return  false},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=true),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),i=0;i<s.length;i++)if((n=this._input.match(this.rules[s[i]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=i,this.options.backtrack_lexer){if(false!==(t=this.test_match(n,s[i])))return t;if(this._backtrack){e=false;continue}return  false}if(!this.options.flex)break}return e?false!==(t=this.test_match(e,s[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:break;case 1:return 24;case 2:return 38;case 3:return 22;case 4:return 20;case 5:return 12;case 6:return 5;case 7:return e.yytext[0]}},rules:[/^(?:\s+)/,/^(?:[0-9]+)/,/^(?:(==|!=|<=|>=|<|>))/,/^(?:[+\-*/%]?=)/,/^(?:(\&\&)|\|\|)/,/^(?:[a-zA-Z_][a-zA-Z0-9._]*)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:true}}};function T(){this.yy={};}return x.lexer=L,T.prototype=x,x.Parser=T,new T}();const n={ASSIGNMENT_EXPRESSION:[{type:"NODE",key:"right"}],SCRIPT:[{type:"ARRAY",key:"body"}],EXPRESSION_BLOCK:[{type:"ARRAY",key:"body"}],UNARY_EXPRESSION:[{type:"NODE",key:"value"}],NUMBER_LITERAL:[],IDENTIFIER:[],CALL_EXPRESSION:[{type:"ARRAY",key:"arguments"},{type:"NODE",key:"callee"}],BINARY_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}],LOGICAL_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}]};function r(t,e){const s=n[t.type];let i=t;if(null==s)throw new Error(`Unknown children definition for ${t.type}`);return s.forEach(n=>{if("NODE"===n.type){const s=t[n.key],o=r(s,e);o!==s&&(i={...i,[n.key]:o});}else if("ARRAY"===n.type){const s=t[n.key],o=s.map(t=>r(t,e)),a=s.some((t,e)=>t!==o[e]);a&&(i={...i,[n.key]:o});}}),e(i)}function s(t){return [].concat.apply([],t)}function i(t,e){return new Array(t).fill(e).join("")}class o{constructor(){this._map=new Map;}get(t,e){const n=null==t?e:`${t}::${e}`;return this._map.has(n)||this._map.set(n,this._map.size),this._map.get(n)}size(){return this._map.size}}class a extends Error{constructor(t,e,n){super(t),this.sourceContext=function(t,e,n=1){const r=Math.max(t.first_line-1-n,0),s=t.last_line+n,o=e.split("\n").slice(r,s).map((e,n)=>{const s=n+r+1;return `${s>=t.first_line&&s<=t.last_line?">":" "} ${s} | ${e}`});if(t.first_line===t.last_line){const e=i(t.first_column," "),n=i(t.last_column-t.first_column,"^"),s=t.first_line-r;o.splice(s,0,`    | ${e}${n}`);}return o.join("\n")}(e,n),this.loc=e;}}class c extends a{}function l(t,e,n){return new c(t,e,n)}function h(t,e,n){return new a(t,e,n)}function u(e,n){const r=t(n,e.first_column),s=t(n,e.last_column);return {first_column:r.column,last_column:s.column,first_line:r.line,last_line:s.line}}function y(t){const[n,s]=function(t){const e=[];let n=1,r="",s=0,i=false,o=false,a=false;for(let c=0;c<t.length;c++){const l=t[c];if(a){const t=r.length+1,i=c-s+1;e.push({destCol:t,srcCol:i,srcLine:n}),a=false;}"\n"===l?(i=false,n++,s=c+1,a=true):"\r"===l&&"\n"===t[c+1]?(c++,i=false,n++,s=c+1,a=true):o&&"*"===l&&"/"===t[c+1]?(o=false,c++,a=true):"\\"===l&&"\\"===t[c+1]||"/"===l&&"/"===t[c+1]?(i=true,c++):"/"===l&&"*"===t[c+1]?(o=true,c++):i||o||(r+=l);}return [r,e]}(t);try{const i=function(){return e.parse.apply(e,arguments)}(n);return r(i,e=>{if(1!==e.loc.first_line||1!=e.loc.last_line)throw h("Unexpected multiline",e.loc,t);return Object.assign(Object.assign({},e),{loc:u(e.loc,s)})})}catch(e){if(null==e.hash)throw e;throw l(`Parse Error: ${e.message.split("\n")[3]}`,u(e.hash.loc,s),t)}}const p=[0,97,115,109],f=[1,0,0,0],g=1e-5,m=1,_=2,E=3,d=5,b=6,w=7,S=10,I=0,k=t=>[2,t],O=t=>[3,t],N=t=>[4,t],v=5,R=11,$=t=>[13,...Pt(t)],A=t=>[16,...Pt(t)],x=26,L=27,T=t=>[32,...Pt(t)],P=t=>[33,...Pt(t)],C=t=>[34,...Pt(t)],M=t=>[35,...Pt(t)],F=t=>[36,...Pt(t)],X=(t,e)=>[43,...Pt(t),...Pt(e)],j=(t,e)=>[57,...Pt(t),...Pt(e)],U=t=>[65,...Ct(t)],D=t=>[66,...Ct(t)],B=t=>[68,...Lt(t)],V=71,G=72,K=73,Y=74,z=76,q=82,W=98,Z=99,J=100,H=101,Q=102,tt=106,et=107,nt=108,rt=113,st=114,it=129,ot=131,at=132,ct=153,lt=154,ht=155,ut=156,yt=159,pt=160,ft=161,gt=162,mt=163,_t=164,Et=165,dt=170,bt=176,wt=185,St=183,It=176,kt=127,Ot=126,Nt=124,vt=1,Rt=64,$t=124,At=[ct,...B(g),Z],xt=[ct,...B(g),J];function Lt(t){const e=new Uint8Array(8);return function(t,e){const n=new ArrayBuffer(8);new DataView(n).setFloat64(0,e);const r=new Uint8Array(n).reverse();t.set(r,0);}(e,t),e}const Tt=t=>[t.length].concat(t.split("").map(t=>t.charCodeAt(0)));function Pt(t){const e=[];do{let n=127&t;0!==(t>>>=7)&&(n|=128),e.push(n);}while(0!==t);return e}function Ct(t){let e=[],n=0,r=Math.ceil(Math.log2(Math.abs(t))),s=t<0,i=true;for(;i;)n=127&t,t>>=7,s&&(t|=-(1<<r-7)),(0!=t||64&n)&&(-1!=t||64&~n)?n|=128:i=false,e.push(n);return e}const Mt=t=>Pt(t.length).concat(t),Ft=t=>Pt(t.length).concat(s(t));function Xt(t,e){if(0===e.length)return [];const n=Mt(Ft(e));return n.unshift(t),n}const jt=(t,e,n)=>{const r=[...Tt(e),...n];return [t,...Mt(r)]},Ut={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,rand:t=>Math.random()*t,pow:Math.pow,log:Math.log,log10:Math.log10,exp:Math.exp,sigmoid:function(t,e){const n=1+Math.exp(-t*e);return Math.abs(n)>1e-5?1/n:0}},Dt=1048576,Bt=Math.ceil(2048),Vt=B(Math.pow(2,31)),Gt=B(Math.pow(2,31));function Kt(t){return [...T(t),...Vt,Z,...N($t),...T(t),ct,v,...Gt,R,It]}const Yt={sqr:{args:[Nt],returns:[Nt],binary:[...T(0),...T(0),gt]},bor:{args:[Nt,Nt],returns:[Nt],binary:[...T(0),...xt,...T(1),...xt,st,...U(0),V,St]},band:{args:[Nt,Nt],returns:[Nt],binary:[...T(0),...xt,...T(1),...xt,rt,...U(0),V,St]},sign:{args:[Nt],returns:[Nt],binary:[...B(0),...T(0),Z,...T(0),...B(0),Z,et,St]},mod:{args:[Nt,Nt],returns:[Nt],localVariables:[Ot],binary:[...Kt(1),...C(2),...D(0),q,...N($t),...Kt(0),...T(2),it,wt,v,...B(0),R]},bitwiseOr:{args:[Nt,Nt],returns:[Nt],binary:[...T(0),bt,...T(1),bt,at,wt]},bitwiseAnd:{args:[Nt,Nt],returns:[Nt],binary:[...T(0),bt,...T(1),bt,ot,wt]},div:{args:[Nt,Nt],returns:[Nt],localVariables:[kt],binary:[...T(1),...B(0),W,...N($t),...T(0),...T(1),mt,v,...B(0),R]},_getBufferIndex:{args:[Nt],returns:[kt],localVariables:[Nt,kt],binary:[...B(g),...T(0),pt,...C(1),dt,...P(2),...U(-1),...T(2),...U(8),nt,...T(2),...U(0),G,...T(2),...U(8388607),Y,st,L]}};function zt(t,e){var n,r,i;switch(t.type){case "SCRIPT":return s(t.body.map((t,n)=>[...zt(t,e),x]));case "EXPRESSION_BLOCK":return qt(t.body,e);case "BINARY_EXPRESSION":{const n=zt(t.left,e),r=zt(t.right,e),s={"+":[pt],"-":[ft],"*":[gt],"/":e.resolveFunc("div"),"%":e.resolveFunc("mod"),"|":e.resolveFunc("bitwiseOr"),"&":e.resolveFunc("bitwiseAnd"),"^":e.resolveFunc("pow"),"==":[ft,...At,St],"!=":[ft,...xt,St],"<":[Z,St],">":[J,St],"<=":[H,St],">=":[Q,St]}[t.operator];if(null==s)throw h(`Unknown binary expression operator ${t.operator}`,t.loc,e.rawSource);return [...n,...r,...s]}case "CALL_EXPRESSION":{const r=t.callee.value,i=t.arguments,o=n=>{if(i.length<n)throw l(`Too few arguments passed to \`${r}()\`. Expected ${n} but only got ${i.length}.`,t.loc,e.rawSource);if(i.length>n)throw l(`Too many arguments passed to \`${r}()\`. Expected ${n} but got ${i.length}.`,i[n].loc,e.rawSource)};switch(r){case "exec2":return o(2),qt(t.arguments,e);case "exec3":return o(3),qt(t.arguments,e);case "if":o(3);const[s,i,a]=t.arguments;return function(t,e,n,r){return [...zt(t,r),...xt,...N($t),...zt(e,r),v,...zt(n,r),R]}(s,i,a,e);case "while":return o(1),function(t,e){const n=zt(t,e),r=e.resolveLocal(kt);return [...U(0),...P(r),...O(Rt),...T(r),...U(1),tt,...C(r),...U(Dt),K,...n,...xt,rt,...$(0),R,...B(0)]}(t.arguments[0],e);case "loop":return o(2),function(t,e,n){const r=zt(e,n),s=n.resolveLocal(kt);return [...k(Rt),...zt(t,n),dt,...C(s),...U(0),z,...$(1),...O(Rt),...r,x,...T(s),...U(1),et,...C(s),...U(0),V,...$(0),R,R,...B(0)]}(t.arguments[0],t.arguments[1],e);case "megabuf":case "gmegabuf":o(1);const c=e.resolveLocal(kt);return [...zt(t.arguments[0],e),...null!==(n=e.resolveFunc("_getBufferIndex"))&&void 0!==n?n:[],...C(c),...U(-1),V,...N($t),...T(c),...X(3,Wt(r)),v,...B(0),R];case "assign":o(2);const h=t.arguments[0];if("IDENTIFIER"!=h.type)throw l("Expected the first argument of `assign()` to be an identifier.",h.loc,e.rawSource);const u=e.resolveVar(h.value);return [...zt(t.arguments[1],e),...F(u),...M(u)]}const a=s(t.arguments.map(t=>zt(t,e)));switch(r){case "abs":return o(1),[...a,ct];case "sqrt":return o(1),[...a,ct,yt];case "int":case "floor":return o(1),[...a,ut];case "min":return o(2),[...a,_t];case "max":return o(2),[...a,Et];case "above":return o(2),[...a,J,St];case "below":return o(2),[...a,Z,St];case "equal":return o(2),[...a,ft,...At,St];case "bnot":return o(1),[...a,...At,St];case "ceil":return o(1),[...a,ht]}const c=e.resolveFunc(r);if(null==c||r.startsWith("_"))throw l(`"${r}" is not defined.`,t.callee.loc,e.rawSource);if(null!=Ut[r])o(Ut[r].length);else {if(null==Yt[r])throw h(`Missing arity information for the function \`${r}()\``,t.callee.loc,e.rawSource);o(Yt[r].args.length);}return [...a,...c]}case "ASSIGNMENT_EXPRESSION":{const{left:n}=t,s=zt(t.right,e),o=function(t,e){const n={"+=":[pt],"-=":[ft],"*=":[gt],"/=":[mt],"%=":e.resolveFunc("mod"),"=":null},r=n[t.operator];if(void 0===r)throw h(`Unknown assignment operator "${t.operator}"`,t.loc,e.rawSource);return r}(t,e);if("IDENTIFIER"===n.type){const t=e.resolveVar(n.value),r=M(t),i=F(t);return null===o?[...s,...i,...r]:[...r,...s,...o,...i,...r]}if("CALL_EXPRESSION"!==n.type)throw h(`Unexpected left hand side type for assignment: ${n.type}`,t.loc,e.rawSource);const a=e.resolveLocal(kt);if(1!==n.arguments.length)throw l(`Expected 1 argument when assigning to a buffer but got ${n.arguments.length}.`,0===n.arguments.length?n.loc:n.arguments[1].loc,e.rawSource);const c=n.callee.value;if("gmegabuf"!==c&&"megabuf"!==c)throw l("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.",n.callee.loc,e.rawSource);const u=Wt(c);if(null===o){const t=e.resolveLocal(kt),i=e.resolveLocal(Nt);return [...s,...P(i),...zt(n.arguments[0],e),...null!==(r=e.resolveFunc("_getBufferIndex"))&&void 0!==r?r:[],...C(t),...U(0),G,...N($t),...B(0),v,...T(t),...C(a),...T(i),...j(3,u),...T(i),R]}const y=e.resolveLocal(kt),p=e.resolveLocal(kt),f=e.resolveLocal(Nt),g=e.resolveLocal(Nt);return [...s,...P(f),...zt(n.arguments[0],e),...null!==(i=e.resolveFunc("_getBufferIndex"))&&void 0!==i?i:[],...C(y),...U(-1),V,...C(p),...N($t),...T(y),...X(3,u),v,...B(0),R,...T(f),...o,...C(g),...T(p),...N(Rt),...T(y),...T(g),...j(3,u),R]}case "LOGICAL_EXPRESSION":{const n=zt(t.left,e),r=zt(t.right,e),s={"&&":{comparison:At,shortCircuitValue:0},"||":{comparison:xt,shortCircuitValue:1}}[t.operator];if(null==s)throw h(`Unknown logical expression operator ${t.operator}`,t.loc,e.rawSource);const{comparison:i,shortCircuitValue:o}=s;return [...n,...i,...N($t),...B(o),v,...r,...xt,St,R]}case "UNARY_EXPRESSION":{const n=zt(t.value,e),r={"-":[lt],"+":[],"!":[...At,St]}[t.operator];if(null==r)throw h(`Unknown logical unary operator ${t.operator}`,t.loc,e.rawSource);return [...n,...r]}case "IDENTIFIER":const o=t.value;return M(e.resolveVar(o));case "NUMBER_LITERAL":return B(t.value);default:throw h(`Unknown AST node type ${t.type}`,t.loc,e.rawSource)}}function qt(t,e){return s(function(t,e){const n=[];for(let r=0;r<t.length;r++)n.push(t[r]),r===t.length-1||n.push(e);return n}(t.map((t,n)=>zt(t,e)),[x]))}function Wt(t){switch(t){case "gmegabuf":return 67108864;case "megabuf":return 0}}function Zt({pools:t,functions:e,eelVersion:n=2,preParsed:r=false}){if(Object.keys(t).includes("shims"))throw new Error('You may not name a pool "shims". "shims" is reserved for injected JavaScript functions.');const s=[];Object.entries(t).forEach(([t,e])=>{e.forEach(e=>{s.push([t,e]);});});const i=new o;s.forEach(([t,e])=>{i.get(t,e);});const a=Object.entries(Ut).map(([t,e])=>({args:new Array(e.length).fill(null).map(t=>Nt),returns:[Nt],name:t})),c=[],l=[];Object.entries(e).forEach(([e,{pool:s,code:o}])=>{if(null==t[s]){const n=Object.keys(t);if(0===n.length)throw new Error(`The function "${e}" was declared as using a variable pool named "${s}" but no pools were defined.`);throw new Error(`The function "${e}" was declared as using a variable pool named "${s}" which is not among the variable pools defined. The defined variable pools are: ${function(t){if(0===t.length)throw new Error("Cannot format an empty list");if(1===t.length)return t[0];const e=t.map(t=>`"${t}"`),n=e.pop();return e.join(", ")+` and ${n}`}(n)}.`)}const h=r?o:y(o);if("string"==typeof h)throw new Error("Got passed unparsed code without setting the preParsed flag");if("SCRIPT"!==h.type)throw new Error("Invalid AST");if(0===h.body.length)return;const u=[],p={resolveVar:t=>/^reg\d\d$/.test(t)?i.get(null,t):i.get(s,t),resolveLocal:t=>(u.push(t),u.length-1),resolveFunc:t=>{const e=a.findIndex(e=>e.name===t);if(-1!==e){const r=A(e);return "rand"===t&&1===n?[...r,ut]:r}if(null==Yt[t])return null;let r=c.indexOf(t);return  -1===r&&(c.push(t),r=c.length-1),A(r+a.length)},rawSource:o},f=zt(h,p);l.push({binary:f,exportName:e,args:[],returns:[],localVariables:u});});const h=c.map(t=>{const e=Yt[t];if(null==e)throw new Error(`Undefined local function "${t}"`);return e}),u=t=>[...t.args,"|",...t.returns].join("-"),g=[],k=new Map;function O(t){const e=u(t),n=k.get(e);if(null==n)throw new Error(`Failed to get a type index for key ${e}`);return n}[...a,...h,...l].forEach(t=>{const e=u(t);k.has(e)||(g.push([96,...Mt(t.args),...Mt(t.returns)]),k.set(e,g.length-1));});const N=[...s.map(([t,e])=>[...Tt(t),...Tt(e),3,Nt,vt]),...a.map((t,e)=>{const n=O(t);return [...Tt("shims"),...Tt(t.name),0,...Pt(n)]})],v=[...h,...l].map(t=>Pt(O(t))),$=[[1,...Pt(Bt),...Pt(Bt)]],x=i.size()-s.length,L=(T=()=>[Nt,vt,...B(0),R],new Array(x).fill(null).map((t,e)=>T(e)));var T;const P=[...l].map((t,e)=>{const n=e+a.length+h.length;return [...Tt(t.exportName),I,...Pt(n)]}),C=[...h,...l].map(t=>{var e;const n=(null!==(e=t.localVariables)&&void 0!==e?e:[]).map(t=>[...Pt(1),t]);return Mt([...Ft(n),...t.binary,R])}),M=[...a.map(t=>t.name),...c,...l.map(t=>t.exportName)].map((t,e)=>[...Pt(e),...Tt(t)]),F=[1,...Mt(Ft(M))];return new Uint8Array([...p,...f,...Xt(m,g),...Xt(_,N),...Xt(E,v),...Xt(d,$),...Xt(b,L),...Xt(w,P),...Xt(S,C),...jt(0,"name",F)])}async function Jt({pools:t,functions:e,eelVersion:n=2}){let r={};Object.entries(t).forEach(([t,e])=>{r[t]=new Set(Object.keys(e));});const s=Zt({pools:r,functions:e,eelVersion:n}),i=await WebAssembly.compile(s);var o=Object.assign(Object.assign({},t),{shims:Ut});return await WebAssembly.instantiate(i,o)}
 
 // Runtime header offsets
 const ID_OFFSET = -8;
@@ -12630,7 +10304,7 @@ class Visualizer {
       }
     }
 
-    const mod = await srcExports.loadModule({
+    const mod = await Jt({
       pools: wasmVarPools,
       functions: wasmFunctions,
       eelVersion: preset.version || 2,
diff --git a/dist/butterchurn.min.js b/dist/butterchurn.min.js
index 4842342a245e4ac06c83db66becd53737cf26e84..2cc9f8ea71e5956bf9e0afe80d71cd1a7f080ca2 100644
--- a/dist/butterchurn.min.js
+++ b/dist/butterchurn.min.js
@@ -1,2 +1,2 @@
-{const t=(t,e)=>{var i="function"==typeof e,s="function"==typeof e,r="function"==typeof e;Object.defineProperty(Math,t,{configurable:i,enumerable:r,writable:s,value:e})};t("DEG_PER_RAD",Math.PI/180),t("RAD_PER_DEG",180/Math.PI);const e=new Float32Array(1);t("scale",function(t,e,i,s,r){return 0===arguments.length||Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(r)?NaN:t===1/0||t===-1/0?t:(t-e)*(r-s)/(i-e)+s}),t("fscale",function(t,i,s,r,a){return e[0]=Math.scale(t,i,s,r,a),e[0]}),t("clamp",function(t,e,i){return Math.min(i,Math.max(e,t))}),t("radians",function(t){return t*Math.DEG_PER_RAD}),t("degrees",function(t){return t*Math.RAD_PER_DEG})}var t=1e-5;window.sqr=function(t){return t*t},window.sqrt=function(t){return Math.sqrt(Math.abs(t))},window.log10=function(t){return Math.log(t)*Math.LOG10E},window.sign=function(t){return t>0?1:t<0?-1:0},window.rand=function(t){var e=Math.floor(t);return e<1?Math.random():Math.random()*e},window.randint=function(t){return Math.floor(rand(t))},window.bnot=function(e){return Math.abs(e)<t?1:0},window.pow=function(t,e){var i,s=Math.pow(t,e);return i=s,!isFinite(i)||isNaN(i)?0:s},window.div=function(t,e){return 0===e?0:t/e},window.mod=function(t,e){return 0===e?0:Math.floor(t)%Math.floor(e)},window.bitor=function(t,e){return Math.floor(t)|Math.floor(e)},window.bitand=function(t,e){return Math.floor(t)&Math.floor(e)},window.sigmoid=function(e,i){var s=1+Math.exp(-e*i);return Math.abs(s)>t?1/s:0},window.bor=function(e,i){return Math.abs(e)>t||Math.abs(i)>t?1:0},window.band=function(e,i){return Math.abs(e)>t&&Math.abs(i)>t?1:0},window.equal=function(e,i){return Math.abs(e-i)<t?1:0},window.above=function(t,e){return t>e?1:0},window.below=function(t,e){return t<e?1:0},window.ifcond=function(e,i,s){return Math.abs(e)>t?i:s},window.memcpy=function(t,e,i,s){let r=e,a=i,o=s;return a<0&&(o+=a,r-=a,a=0),r<0&&(o+=r,a-=r,r=0),o>0&&t.copyWithin(r,a,o),e};var e,i={},s={},r={};function a(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var o,h,A,n={};function l(){return o||(o=1,function(t){var e=function(){var t=function(t,e,i,s){for(i=i||{},s=t.length;s--;i[t[s]]=e);return i},e=[1,18],i=[1,7],s=[1,19],r=[1,20],a=[1,14],o=[1,15],h=[1,16],A=[1,33],n=[1,31],l=[1,23],c=[1,22],g=[1,24],m=[1,25],u=[1,26],f=[1,27],d=[1,28],p=[1,29],_=[1,30],E=[5,8,15,18,20,28,29,32,33,34,35,36,37,38],b=[5,15,18],x=[5,12,15,17,18,24,25,28,29,30],v=[1,57],T=[5,8,12,15,17,18,24,25,28,29,30],S=[15,18],P=[5,8,15,18,28,29,38],w=[5,8,15,18,28,29,32,33,38],I=[5,8,15,18,28,29,32,33,34,37,38],R=[5,8,15,18,28,29,32,33,34,35,36,37,38],y=[5,8,15,18],B=[5,8,15,18,20,22,28,29,32,33,34,35,36,37,38],L={trace:function(){},yy:{},symbols_:{error:2,SCRIPT:3,expression:4,EOF:5,expressionsOptionalTrailingSemi:6,separator:7,";":8,expressions:9,EXPRESSION_BLOCK:10,IDENTIFIER:11,IDENTIFIER_TOKEN:12,argument:13,arguments:14,",":15,FUNCTION_CALL:16,"(":17,")":18,LOGICAL_EXPRESSION:19,LOGICAL_OPERATOR_TOKEN:20,ASSIGNMENT:21,ASSIGNMENT_OPERATOR_TOKEN:22,number:23,DIGITS_TOKEN:24,".":25,NUMBER_LITERAL:26,UNARY_EXPRESSION:27,"-":28,"+":29,"!":30,BINARY_EXPRESSION:31,"*":32,"/":33,"%":34,"&":35,"|":36,"^":37,COMPARISON_TOKEN:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:";",12:"IDENTIFIER_TOKEN",15:",",17:"(",18:")",20:"LOGICAL_OPERATOR_TOKEN",22:"ASSIGNMENT_OPERATOR_TOKEN",24:"DIGITS_TOKEN",25:".",28:"-",29:"+",30:"!",32:"*",33:"/",34:"%",35:"&",36:"|",37:"^",38:"COMPARISON_TOKEN"},productions_:[0,[3,2],[3,2],[3,1],[7,1],[7,2],[9,2],[9,3],[6,1],[6,2],[10,1],[11,1],[13,1],[13,1],[14,1],[14,3],[16,3],[16,4],[19,3],[21,3],[21,3],[23,1],[23,2],[23,3],[23,2],[23,1],[26,1],[27,2],[27,2],[27,2],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[4,1],[4,1],[4,3],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3]],performAction:function(t,e,i,s,r,a,o){var h=a.length-1;switch(r){case 1:return{type:"SCRIPT",body:[a[h-1]],loc:this._$};case 2:return{type:"SCRIPT",body:a[h-1],loc:this._$};case 3:return{type:"SCRIPT",body:[],loc:this._$};case 6:this.$=[a[h-1]];break;case 7:this.$=a[h-2].concat([a[h-1]]);break;case 8:this.$=a[h];break;case 9:this.$=a[h-1].concat([a[h]]);break;case 10:this.$={type:"EXPRESSION_BLOCK",body:a[h],loc:this._$};break;case 11:this.$={type:"IDENTIFIER",value:a[h].toLowerCase(),loc:this._$};break;case 14:this.$=[a[h]];break;case 15:this.$=a[h-2].concat([a[h]]);break;case 16:this.$={type:"CALL_EXPRESSION",callee:a[h-2],arguments:[],loc:this._$};break;case 17:this.$={type:"CALL_EXPRESSION",callee:a[h-3],arguments:a[h-1],loc:this._$};break;case 18:this.$={type:"LOGICAL_EXPRESSION",left:a[h-2],right:a[h],operator:a[h-1],loc:this._$};break;case 19:case 20:this.$={type:"ASSIGNMENT_EXPRESSION",left:a[h-2],operator:a[h-1],right:a[h],loc:this._$};break;case 21:this.$=Number(a[h]);break;case 22:this.$=Number(a[h-1]);break;case 23:this.$=Number(a[h-2]+a[h-1]+a[h]);break;case 24:this.$=Number("0"+a[h-1]+a[h]);break;case 25:this.$=0;break;case 26:this.$={type:"NUMBER_LITERAL",value:a[h],loc:this._$};break;case 27:case 28:case 29:this.$={type:"UNARY_EXPRESSION",value:a[h],operator:a[h-1],loc:this._$};break;case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:this.$={type:"BINARY_EXPRESSION",left:a[h-2],right:a[h],operator:a[h-1],loc:this._$};break;case 41:case 47:this.$=a[h-1]}},table:[{3:1,4:2,5:[1,4],6:3,9:13,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{1:[3]},{5:[1,21],7:32,8:A,20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_},{5:[1,34]},{1:[2,3]},t(E,[2,39]),t(E,[2,40]),{4:35,6:37,9:13,10:36,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(E,[2,42]),t(E,[2,43]),t(E,[2,44],{22:[1,38]}),t(E,[2,45],{17:[1,40],22:[1,39]}),t(E,[2,46]),t(b,[2,8],{31:5,27:6,26:8,21:9,16:10,11:11,19:12,23:17,4:41,12:e,17:i,24:s,25:r,28:a,29:o,30:h}),{4:42,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:43,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:44,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(E,[2,26]),t([5,8,15,17,18,20,22,28,29,32,33,34,35,36,37,38],[2,11]),t(E,[2,21],{25:[1,45]}),t(E,[2,25],{24:[1,46]}),{1:[2,1]},{4:47,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:48,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:49,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:50,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:51,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:52,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:53,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:54,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:55,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:56,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(x,[2,6],{8:v}),t(T,[2,4]),{1:[2,2]},{7:32,8:A,18:[1,58],20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_},{18:[1,59]},t(S,[2,10]),{4:60,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:61,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:65,6:37,9:13,10:66,11:11,12:e,13:64,14:63,16:10,17:i,18:[1,62],19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(b,[2,9],{7:67,8:A,20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_}),t(P,[2,27],{20:n,32:g,33:m,34:u,35:f,36:d,37:p}),t(P,[2,28],{20:n,32:g,33:m,34:u,35:f,36:d,37:p}),t(P,[2,29],{20:n,32:g,33:m,34:u,35:f,36:d,37:p}),t(E,[2,22],{24:[1,68]}),t(E,[2,24]),t(P,[2,30],{20:n,32:g,33:m,34:u,35:f,36:d,37:p}),t(P,[2,31],{20:n,32:g,33:m,34:u,35:f,36:d,37:p}),t(w,[2,32],{20:n,34:u,35:f,36:d,37:p}),t(w,[2,33],{20:n,34:u,35:f,36:d,37:p}),t(I,[2,34],{20:n,35:f,36:d}),t(R,[2,35],{20:n}),t(R,[2,36],{20:n}),t(I,[2,37],{20:n,35:f,36:d}),t(y,[2,38],{20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_}),t(E,[2,18]),t(T,[2,5]),t(E,[2,41]),t(E,[2,47]),t(y,[2,20],{20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_}),t(y,[2,19],{20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_}),t(B,[2,16]),{15:[1,70],18:[1,69]},t(S,[2,14]),t(S,[2,12],{7:32,8:A,20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:d,37:p,38:_}),t(S,[2,13]),t(x,[2,7],{8:v}),t(E,[2,23]),t(B,[2,17]),{4:65,6:37,9:13,10:66,11:11,12:e,13:71,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(S,[2,15])],defaultActions:{4:[2,3],21:[2,1],34:[2,2]},parseError:function(t,e){if(!e.recoverable){var i=new Error(t);throw i.hash=e,i}this.trace(t)},parse:function(t){var e=this,i=[0],s=[null],r=[],a=this.table,o="",h=0,A=0,n=r.slice.call(arguments,1),l=Object.create(this.lexer),c={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(c.yy[g]=this.yy[g]);l.setInput(t,c.yy),c.yy.lexer=l,c.yy.parser=this,void 0===l.yylloc&&(l.yylloc={});var m=l.yylloc;r.push(m);var u=l.options&&l.options.ranges;"function"==typeof c.yy.parseError?this.parseError=c.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var f,d,p,_,E,b,x,v,T=function(){var t;return"number"!=typeof(t=l.lex()||1)&&(t=e.symbols_[t]||t),t},S={};;){if(d=i[i.length-1],this.defaultActions[d]?p=this.defaultActions[d]:(null==f&&(f=T()),p=a[d]&&a[d][f]),void 0===p||!p.length||!p[0]){var P="";for(E in v=[],a[d])this.terminals_[E]&&E>2&&v.push("'"+this.terminals_[E]+"'");P=l.showPosition?"Parse error on line "+(h+1)+":\n"+l.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[f]||f)+"'":"Parse error on line "+(h+1)+": Unexpected "+(1==f?"end of input":"'"+(this.terminals_[f]||f)+"'"),this.parseError(P,{text:l.match,token:this.terminals_[f]||f,line:l.yylineno,loc:m,expected:v})}if(p[0]instanceof Array&&p.length>1)throw new Error("Parse Error: multiple actions possible at state: "+d+", token: "+f);switch(p[0]){case 1:i.push(f),s.push(l.yytext),r.push(l.yylloc),i.push(p[1]),f=null,A=l.yyleng,o=l.yytext,h=l.yylineno,m=l.yylloc;break;case 2:if(b=this.productions_[p[1]][1],S.$=s[s.length-b],S._$={first_line:r[r.length-(b||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(b||1)].first_column,last_column:r[r.length-1].last_column},u&&(S._$.range=[r[r.length-(b||1)].range[0],r[r.length-1].range[1]]),void 0!==(_=this.performAction.apply(S,[o,A,h,c.yy,p[1],s,r].concat(n))))return _;b&&(i=i.slice(0,-1*b*2),s=s.slice(0,-1*b),r=r.slice(0,-1*b)),i.push(this.productions_[p[1]][0]),s.push(S.$),r.push(S._$),x=a[i[i.length-2]][i[i.length-1]],i.push(x);break;case 3:return!0}}return!0}},C={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var i,s,r;if(this.options.backtrack_lexer&&(r={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(r.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var a in r)this[a]=r[a];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,i,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),a=0;a<r.length;a++)if((i=this._input.match(this.rules[r[a]]))&&(!e||i[0].length>e[0].length)){if(e=i,s=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,r[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,r[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,i,s){switch(i){case 0:break;case 1:return 24;case 2:return 38;case 3:return 22;case 4:return 20;case 5:return 12;case 6:return 5;case 7:return e.yytext[0]}},rules:[/^(?:\s+)/,/^(?:[0-9]+)/,/^(?:(==|!=|<=|>=|<|>))/,/^(?:[+\-*/%]?=)/,/^(?:(\&\&)|\|\|)/,/^(?:[a-zA-Z_][a-zA-Z0-9._]*)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};function U(){this.yy={}}return L.lexer=C,U.prototype=L,L.Parser=U,new U}();void 0!==a&&(t.parser=e,t.Parser=e.Parser,t.parse=function(){return e.parse.apply(e,arguments)},t.main=()=>{})}(n)),n}var c,g={};var m,u,f,d={},p={};function _(){if(m)return p;m=1,Object.defineProperty(p,"__esModule",{value:!0}),p.arrayJoin=function(t,e){const i=[];for(let s=0;s<t.length;s++){i.push(t[s]);s===t.length-1||i.push(e)}return i},p.flatten=function(t){return[].concat.apply([],t)},p.times=function(t,e){return new Array(t).fill(null).map((t,i)=>e(i))},p.repeat=function(t,e){return new Array(t).fill(e).join("")};return p.ScopedIdMap=class{constructor(){this._map=new Map}get(t,e){const i=null==t?e:`${t}::${e}`;return this._map.has(i)||this._map.set(i,this._map.size),this._map.get(i)}size(){return this._map.size}},p.formatList=function(t){if(0===t.length)throw new Error("Cannot format an empty list");if(1===t.length)return t[0];const e=t.map(t=>`"${t}"`),i=e.pop();return e.join(", ")+` and ${i}`},p}function E(){if(u)return d;u=1,Object.defineProperty(d,"__esModule",{value:!0});const t=_();function e(e,i,s=1){const r=Math.max(e.first_line-1-s,0),a=e.last_line+s,o=i.split("\n").slice(r,a).map((t,i)=>{const s=i+r+1;return`${s>=e.first_line&&s<=e.last_line?">":" "} ${s} | ${t}`});if(e.first_line===e.last_line){const i=t.repeat(e.first_column," "),s=t.repeat(e.last_column-e.first_column,"^"),a=e.first_line-r;o.splice(a,0,`    | ${i}${s}`)}return o.join("\n")}d.printLoc=e;class i extends Error{constructor(t,i,s){super(t),this.sourceContext=e(i,s),this.loc=i}}class s extends i{}return d.createUserError=function(t,e,i){return new s(t,e,i)},d.createCompilerError=function(t,e,s){return new i(t,e,s)},d}function b(){if(f)return s;f=1,Object.defineProperty(s,"__esModule",{value:!0});const t=(e||(e=1,Object.defineProperty(r,"__esModule",{value:!0}),r.getLoc=function(t,e){let i={destCol:1,srcCol:1,srcLine:1};t.forEach(t=>{t.destCol>e||(i=t)});const s=e-i.destCol;return{column:i.srcCol+s,line:i.srcLine}},r.preProcess=function(t){const e=[];let i=1,s="",r=0,a=!1,o=!1,h=!1;for(let A=0;A<t.length;A++){const n=t[A];if(h){const t=s.length+1,a=A-r+1;e.push({destCol:t,srcCol:a,srcLine:i}),h=!1}"\n"===n?(a=!1,i++,r=A+1,h=!0):"\r"===n&&"\n"===t[A+1]?(A++,a=!1,i++,r=A+1,h=!0):o&&"*"===n&&"/"===t[A+1]?(o=!1,A++,h=!0):"\\"===n&&"\\"===t[A+1]||"/"===n&&"/"===t[A+1]?(a=!0,A++):"/"===n&&"*"===t[A+1]?(o=!0,A++):a||o||(s+=n)}return[s,e]}),r),i=function(){if(A)return h;A=1;let t=l();return h={parse:t.parse}}(),a=function(){if(c)return g;c=1,Object.defineProperty(g,"__esModule",{value:!0});const t={ASSIGNMENT_EXPRESSION:[{type:"NODE",key:"right"}],SCRIPT:[{type:"ARRAY",key:"body"}],EXPRESSION_BLOCK:[{type:"ARRAY",key:"body"}],UNARY_EXPRESSION:[{type:"NODE",key:"value"}],NUMBER_LITERAL:[],IDENTIFIER:[],CALL_EXPRESSION:[{type:"ARRAY",key:"arguments"},{type:"NODE",key:"callee"}],BINARY_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}],LOGICAL_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}]};return g.mapAst=function e(i,s){const r=t[i.type];let a=i;if(null==r)throw new Error(`Unknown children definition for ${i.type}`);return r.forEach(t=>{if("NODE"===t.type){const r=i[t.key],o=e(r,s);o!==r&&(a=Object.assign(Object.assign({},a),{[t.key]:o}))}else if("ARRAY"===t.type){const r=i[t.key],o=r.map(t=>e(t,s)),h=r.some((t,e)=>t!==o[e]);h&&(a=Object.assign(Object.assign({},a),{[t.key]:o}))}}),s(a)},g}(),o=E();function n(e,i){const s=t.getLoc(i,e.first_column),r=t.getLoc(i,e.last_column);return{first_column:s.column,last_column:r.column,first_line:s.line,last_line:r.line}}return s.parse=function(e){const[s,r]=t.preProcess(e);try{const t=i.parse(s);return a.mapAst(t,t=>{if(1!==t.loc.first_line||1!=t.loc.last_line)throw o.createCompilerError("Unexpected multiline",t.loc,e);return Object.assign(Object.assign({},t),{loc:n(t.loc,r)})})}catch(t){if(null==t.hash)throw t;throw o.createUserError(`Parse Error: ${t.message.split("\n")[3]}`,n(t.hash.loc,r),e)}},s}var x,v,T={},S={},P={},w={};function I(){if(x)return w;return x=1,Object.defineProperty(w,"__esModule",{value:!0}),w.write=function(t,e){let i=52;var s,r,a,o=64-i-1,h=(1<<o)-1,A=h>>1,n=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=0,c=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(r=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+A>=1?n/a:n*Math.pow(2,1-A))*a>=2&&(s++,a/=2),s+A>=h?(r=0,s=h):s+A>=1?(r=(e*a-1)*Math.pow(2,i),s+=A):(r=e*Math.pow(2,A-1)*Math.pow(2,i),s=0));i>=8;t[0+l]=255&r,l+=1,r/=256,i-=8);for(s=s<<i|r,o+=i;o>0;t[0+l]=255&s,l+=1,s/=256,o-=8);t[0+l-1]|=128*c},w}function R(){return v||(v=1,function(t){var e=P&&P.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e};Object.defineProperty(t,"__esModule",{value:!0});const i=e(I()),s=_();function r(t){const e=new Uint8Array(8);return i.write(e,t),e}function a(t){const e=[];do{let i=127&t;0!==(t>>>=7)&&(i|=128),e.push(i)}while(0!==t);return e}function o(t){let e=[],i=0,s=Math.ceil(Math.log2(Math.abs(t))),r=t<0,a=!0;for(;a;)i=127&t,t>>=7,r&&(t|=-(1<<s-7)),(0!=t||64&i)&&(-1!=t||64&~i)?i|=128:a=!1,e.push(i);return e}t.MAGIC=[0,97,115,109],t.WASM_VERSION=[1,0,0,0],t.EPSILON=1e-5,t.SECTION={TYPE:1,IMPORT:2,FUNC:3,MEMORY:5,GLOBAL:6,EXPORT:7,CODE:10},t.EXPORT_TYPE={FUNC:0,TABLE:1,MEMORY:2,GLOBAL:3},t.op={block:t=>[2,t],loop:t=>[3,t],if:t=>[4,t],else:5,end:11,br_if:t=>[13,...a(t)],call:t=>[16,...a(t)],drop:26,select:27,local_get:t=>[32,...a(t)],local_set:t=>[33,...a(t)],local_tee:t=>[34,...a(t)],global_get:t=>[35,...a(t)],global_set:t=>[36,...a(t)],f64_load:(t,e)=>[43,...a(t),...a(e)],f64_store:(t,e)=>[57,...a(t),...a(e)],i32_const:t=>[65,...o(t)],f64_const:t=>[68,...r(t)],i32_eqz:69,i32_ne:71,i32_lt_s:72,i32_lt_u:73,i32_gt_s:74,i32_le_s:76,i32_le_u:77,i32_ge_s:78,f64_eq:97,f64_ne:98,f64_lt:99,f64_gt:100,f64_le:101,f64_ge:102,i32_add:106,i32_sub:107,i32_mul:108,i32_rem_s:111,i32_and:113,i32_or:114,i64_rem_s:129,i64_and:131,i64_or:132,f64_abs:153,f64_neg:154,f64_ceil:155,f64_floor:156,f64_sqrt:159,f64_add:160,f64_sub:161,f64_mul:162,f64_div:163,f64_min:164,f64_max:165,i32_trunc_f64_s:170,i32_trunc_f64_u:171,i64_trunc_s_f64:176,f64_convert_i64_s:185,f64_convert_i32_s:183},t.VAL_TYPE={i32:127,i64:126,f32:125,f64:124},t.MUTABILITY={const:0,var:1},t.BLOCK={void:64,i32:127,i64:126,f32:125,f64:124},t.FUNCTION_TYPE=96,t.MEMORY_IDX=2,t.GLOBAL_TYPE=3,t.TYPE_IDX=0,t.IS_ZEROISH=[t.op.f64_abs,...t.op.f64_const(t.EPSILON),t.op.f64_lt],t.IS_NOT_ZEROISH=[t.op.f64_abs,...t.op.f64_const(t.EPSILON),t.op.f64_gt],t.encodef64=r,t.encodeString=t=>[t.length].concat(t.split("").map(t=>t.charCodeAt(0))),t.unsignedLEB128=a,t.signedLEB128=o,t.encodeFlatVector=t=>a(t.length).concat(t),t.encodeNestedVector=t=>a(t.length).concat(s.flatten(t)),t.encodeSection=function(e,i){if(0===i.length)return[];const s=t.encodeFlatVector(t.encodeNestedVector(i));return s.unshift(e),s}}(P)),P}var y,B={};function L(){if(y)return B;y=1,Object.defineProperty(B,"__esModule",{value:!0});const t={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,rand:t=>Math.random()*t,pow:Math.pow,log:Math.log,log10:Math.log10,exp:Math.exp,sigmoid:function(t,e){const i=1+Math.exp(-t*e);return Math.abs(i)>1e-5?1/i:0}};return B.default=t,B}var C,U,M,F,Q={},V={};function D(){return C||(C=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});t.MAX_LOOP_COUNT=1048576,t.BUFFER_SIZE=8388608,t.WASM_MEMORY_SIZE=Math.ceil(8*t.BUFFER_SIZE*2/65536)}(V)),V}function q(){if(U)return Q;U=1,Object.defineProperty(Q,"__esModule",{value:!0});const t=R(),e=D();return Q.localFuncMap={sqr:{args:[t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],binary:[...t.op.local_get(0),...t.op.local_get(0),t.op.f64_mul]},bor:{args:[t.VAL_TYPE.f64,t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],binary:[...t.op.local_get(0),...t.IS_NOT_ZEROISH,...t.op.local_get(1),...t.IS_NOT_ZEROISH,t.op.i32_or,...t.op.i32_const(0),t.op.i32_ne,t.op.f64_convert_i32_s]},band:{args:[t.VAL_TYPE.f64,t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],binary:[...t.op.local_get(0),...t.IS_NOT_ZEROISH,...t.op.local_get(1),...t.IS_NOT_ZEROISH,t.op.i32_and,...t.op.i32_const(0),t.op.i32_ne,t.op.f64_convert_i32_s]},sign:{args:[t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],binary:[...t.op.f64_const(0),...t.op.local_get(0),t.op.f64_lt,...t.op.local_get(0),...t.op.f64_const(0),t.op.f64_lt,t.op.i32_sub,t.op.f64_convert_i32_s]},mod:{args:[t.VAL_TYPE.f64,t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],localVariables:[t.VAL_TYPE.i32],binary:[...t.op.local_get(1),t.op.i32_trunc_f64_s,...t.op.local_tee(2),...t.op.i32_const(0),t.op.i32_ne,...t.op.if(t.BLOCK.f64),...t.op.local_get(0),t.op.i32_trunc_f64_s,...t.op.local_get(2),t.op.i32_rem_s,t.op.f64_convert_i32_s,t.op.else,...t.op.f64_const(0),t.op.end]},bitwiseOr:{args:[t.VAL_TYPE.f64,t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],binary:[...t.op.local_get(0),t.op.i64_trunc_s_f64,...t.op.local_get(1),t.op.i64_trunc_s_f64,t.op.i64_or,t.op.f64_convert_i64_s]},bitwiseAnd:{args:[t.VAL_TYPE.f64,t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],binary:[...t.op.local_get(0),t.op.i64_trunc_s_f64,...t.op.local_get(1),t.op.i64_trunc_s_f64,t.op.i64_and,t.op.f64_convert_i64_s]},div:{args:[t.VAL_TYPE.f64,t.VAL_TYPE.f64],returns:[t.VAL_TYPE.f64],localVariables:[t.VAL_TYPE.i32],binary:[...t.op.local_get(1),...t.op.f64_const(0),t.op.f64_ne,...t.op.if(t.BLOCK.f64),...t.op.local_get(0),...t.op.local_get(1),t.op.f64_div,t.op.else,...t.op.f64_const(0),t.op.end]},_getBufferIndex:{args:[t.VAL_TYPE.f64],returns:[t.VAL_TYPE.i32],localVariables:[t.VAL_TYPE.f64,t.VAL_TYPE.i32],binary:[...t.op.f64_const(t.EPSILON),...t.op.local_get(0),t.op.f64_add,...t.op.local_tee(1),t.op.i32_trunc_f64_s,...t.op.local_set(2),...t.op.i32_const(-1),...t.op.local_get(2),...t.op.i32_const(8),t.op.i32_mul,...t.op.local_get(2),...t.op.i32_const(0),t.op.i32_lt_s,...t.op.local_get(2),...t.op.i32_const(e.BUFFER_SIZE-1),t.op.i32_gt_s,t.op.i32_or,t.op.select]}},Q}function z(){if(M)return S;M=1;var t=S&&S.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(S,"__esModule",{value:!0});const e=R(),i=t(L()),s=E(),r=q(),a=_(),o=D();function h(t,l){var c,g,m;switch(t.type){case"SCRIPT":{const i=t.body.map((t,i)=>[...h(t,l),e.op.drop]);return a.flatten(i)}case"EXPRESSION_BLOCK":return A(t.body,l);case"BINARY_EXPRESSION":{const i=h(t.left,l),r=h(t.right,l),a={"+":[e.op.f64_add],"-":[e.op.f64_sub],"*":[e.op.f64_mul],"/":l.resolveFunc("div"),"%":l.resolveFunc("mod"),"|":l.resolveFunc("bitwiseOr"),"&":l.resolveFunc("bitwiseAnd"),"^":l.resolveFunc("pow"),"==":[e.op.f64_sub,...e.IS_ZEROISH,e.op.f64_convert_i32_s],"!=":[e.op.f64_sub,...e.IS_NOT_ZEROISH,e.op.f64_convert_i32_s],"<":[e.op.f64_lt,e.op.f64_convert_i32_s],">":[e.op.f64_gt,e.op.f64_convert_i32_s],"<=":[e.op.f64_le,e.op.f64_convert_i32_s],">=":[e.op.f64_ge,e.op.f64_convert_i32_s]}[t.operator];if(null==a)throw s.createCompilerError(`Unknown binary expression operator ${t.operator}`,t.loc,l.rawSource);return[...i,...r,...a]}case"CALL_EXPRESSION":{const g=t.callee.value,m=t.arguments,u=e=>{if(m.length<e)throw s.createUserError(`Too few arguments passed to \`${g}()\`. Expected ${e} but only got ${m.length}.`,t.loc,l.rawSource);if(m.length>e)throw s.createUserError(`Too many arguments passed to \`${g}()\`. Expected ${e} but got ${m.length}.`,m[e].loc,l.rawSource)};switch(g){case"exec2":return u(2),A(t.arguments,l);case"exec3":return u(3),A(t.arguments,l);case"if":u(3);const[i,r,a]=t.arguments;return function(t,i,s,r){return[...h(t,r),...e.IS_NOT_ZEROISH,...e.op.if(e.BLOCK.f64),...h(i,r),e.op.else,...h(s,r),e.op.end]}(i,r,a,l);case"while":return u(1),function(t,i){const s=h(t,i),r=i.resolveLocal(e.VAL_TYPE.i32);return[...e.op.i32_const(0),...e.op.local_set(r),...e.op.loop(e.BLOCK.void),...e.op.local_get(r),...e.op.i32_const(1),e.op.i32_add,...e.op.local_tee(r),...e.op.i32_const(o.MAX_LOOP_COUNT),e.op.i32_lt_u,...s,...e.IS_NOT_ZEROISH,e.op.i32_and,...e.op.br_if(0),e.op.end,...e.op.f64_const(0)]}(t.arguments[0],l);case"loop":return u(2),function(t,i,s){const r=h(i,s),a=s.resolveLocal(e.VAL_TYPE.i32);return[...e.op.block(e.BLOCK.void),...h(t,s),e.op.i32_trunc_f64_s,...e.op.local_tee(a),...e.op.i32_const(0),e.op.i32_le_s,...e.op.br_if(1),...e.op.loop(e.BLOCK.void),...r,e.op.drop,...e.op.local_get(a),...e.op.i32_const(1),e.op.i32_sub,...e.op.local_tee(a),...e.op.i32_const(0),e.op.i32_ne,...e.op.br_if(0),e.op.end,e.op.end,...e.op.f64_const(0)]}(t.arguments[0],t.arguments[1],l);case"megabuf":case"gmegabuf":u(1);const m=l.resolveLocal(e.VAL_TYPE.i32);return[...h(t.arguments[0],l),...null!==(c=l.resolveFunc("_getBufferIndex"))&&void 0!==c?c:[],...e.op.local_tee(m),...e.op.i32_const(-1),e.op.i32_ne,...e.op.if(e.BLOCK.f64),...e.op.local_get(m),...e.op.f64_load(3,n(g)),e.op.else,...e.op.f64_const(0),e.op.end];case"assign":u(2);const f=t.arguments[0];if("IDENTIFIER"!=f.type)throw s.createUserError("Expected the first argument of `assign()` to be an identifier.",f.loc,l.rawSource);const d=l.resolveVar(f.value);return[...h(t.arguments[1],l),...e.op.global_set(d),...e.op.global_get(d)]}const f=a.flatten(t.arguments.map(t=>h(t,l)));switch(g){case"abs":return u(1),[...f,e.op.f64_abs];case"sqrt":return u(1),[...f,e.op.f64_abs,e.op.f64_sqrt];case"int":case"floor":return u(1),[...f,e.op.f64_floor];case"min":return u(2),[...f,e.op.f64_min];case"max":return u(2),[...f,e.op.f64_max];case"above":return u(2),[...f,e.op.f64_gt,e.op.f64_convert_i32_s];case"below":return u(2),[...f,e.op.f64_lt,e.op.f64_convert_i32_s];case"equal":return u(2),[...f,e.op.f64_sub,...e.IS_ZEROISH,e.op.f64_convert_i32_s];case"bnot":return u(1),[...f,...e.IS_ZEROISH,e.op.f64_convert_i32_s];case"ceil":return u(1),[...f,e.op.f64_ceil]}const d=l.resolveFunc(g);if(null==d||g.startsWith("_"))throw s.createUserError(`"${g}" is not defined.`,t.callee.loc,l.rawSource);if(null!=i.default[g])u(i.default[g].length);else{if(null==r.localFuncMap[g])throw s.createCompilerError(`Missing arity information for the function \`${g}()\``,t.callee.loc,l.rawSource);u(r.localFuncMap[g].args.length)}return[...f,...d]}case"ASSIGNMENT_EXPRESSION":{const{left:i}=t,r=h(t.right,l),a=function(t,i){const r={"+=":[e.op.f64_add],"-=":[e.op.f64_sub],"*=":[e.op.f64_mul],"/=":[e.op.f64_div],"%=":i.resolveFunc("mod"),"=":null},a=r[t.operator];if(void 0===a)throw s.createCompilerError(`Unknown assignment operator "${t.operator}"`,t.loc,i.rawSource);return a}(t,l);if("IDENTIFIER"===i.type){const t=l.resolveVar(i.value),s=e.op.global_get(t),o=e.op.global_set(t);return null===a?[...r,...o,...s]:[...s,...r,...a,...o,...s]}if("CALL_EXPRESSION"!==i.type)throw s.createCompilerError(`Unexpected left hand side type for assignment: ${i.type}`,t.loc,l.rawSource);const o=l.resolveLocal(e.VAL_TYPE.i32);if(1!==i.arguments.length)throw s.createUserError(`Expected 1 argument when assinging to a buffer but got ${i.arguments.length}.`,0===i.arguments.length?i.loc:i.arguments[1].loc,l.rawSource);const A=i.callee.value;if("gmegabuf"!==A&&"megabuf"!==A)throw s.createUserError("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.",i.callee.loc,l.rawSource);const c=n(A);if(null===a){const t=l.resolveLocal(e.VAL_TYPE.i32),s=l.resolveLocal(e.VAL_TYPE.f64);return[...r,...e.op.local_set(s),...h(i.arguments[0],l),...null!==(g=l.resolveFunc("_getBufferIndex"))&&void 0!==g?g:[],...e.op.local_tee(t),...e.op.i32_const(0),e.op.i32_lt_s,...e.op.if(e.BLOCK.f64),...e.op.f64_const(0),e.op.else,...e.op.local_get(t),...e.op.local_tee(o),...e.op.local_get(s),...e.op.f64_store(3,c),...e.op.local_get(s),e.op.end]}const u=l.resolveLocal(e.VAL_TYPE.i32),f=l.resolveLocal(e.VAL_TYPE.i32),d=l.resolveLocal(e.VAL_TYPE.f64),p=l.resolveLocal(e.VAL_TYPE.f64);return[...r,...e.op.local_set(d),...h(i.arguments[0],l),...null!==(m=l.resolveFunc("_getBufferIndex"))&&void 0!==m?m:[],...e.op.local_tee(u),...e.op.i32_const(-1),e.op.i32_ne,...e.op.local_tee(f),...e.op.if(e.BLOCK.f64),...e.op.local_get(u),...e.op.f64_load(3,c),e.op.else,...e.op.f64_const(0),e.op.end,...e.op.local_get(d),...a,...e.op.local_tee(p),...e.op.local_get(f),...e.op.if(e.BLOCK.void),...e.op.local_get(u),...e.op.local_get(p),...e.op.f64_store(3,c),e.op.end]}case"LOGICAL_EXPRESSION":{const i=h(t.left,l),r=h(t.right,l),a={"&&":{comparison:e.IS_ZEROISH,shortCircutValue:0},"||":{comparison:e.IS_NOT_ZEROISH,shortCircutValue:1}}[t.operator];if(null==a)throw s.createCompilerError(`Unknown logical expression operator ${t.operator}`,t.loc,l.rawSource);const{comparison:o,shortCircutValue:A}=a;return[...i,...o,...e.op.if(e.BLOCK.f64),...e.op.f64_const(A),e.op.else,...r,...e.IS_NOT_ZEROISH,e.op.f64_convert_i32_s,e.op.end]}case"UNARY_EXPRESSION":{const i=h(t.value,l),r={"-":[e.op.f64_neg],"+":[],"!":[...e.IS_ZEROISH,e.op.f64_convert_i32_s]}[t.operator];if(null==r)throw s.createCompilerError(`Unknown logical unary operator ${t.operator}`,t.loc,l.rawSource);return[...i,...r]}case"IDENTIFIER":const u=t.value;return e.op.global_get(l.resolveVar(u));case"NUMBER_LITERAL":return e.op.f64_const(t.value);default:throw s.createCompilerError(`Unknown AST node type ${t.type}`,t.loc,l.rawSource)}}function A(t,i){const s=t.map((t,e)=>h(t,i));return a.flatten(a.arrayJoin(s,[e.op.drop]))}function n(t){switch(t){case"gmegabuf":return 8*o.BUFFER_SIZE;case"megabuf":return 0}}return S.emit=h,S}function N(){if(F)return T;F=1;var t=T&&T.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e};Object.defineProperty(T,"__esModule",{value:!0});const i=b(),s=z(),r=R(),a=t(L()),o=e(_()),h=q(),A=D();return T.compileModule=function({pools:t,functions:e,eelVersion:n=2,preParsed:l=!1}){if(Object.keys(t).includes("shims"))throw new Error('You may not name a pool "shims". "shims" is reserved for injected JavaScript functions.');const c=[];Object.entries(t).forEach(([t,e])=>{e.forEach(e=>{c.push([t,e])})});const g=new o.ScopedIdMap;c.forEach(([t,e])=>{g.get(t,e)});const m=Object.entries(a.default).map(([t,e])=>({args:new Array(e.length).fill(null).map(t=>r.VAL_TYPE.f64),returns:[r.VAL_TYPE.f64],name:t})),u=[],f=[];Object.entries(e).forEach(([e,{pool:a,code:A}])=>{if(null==t[a]){const i=Object.keys(t);if(0===i.length)throw new Error(`The function "${e}" was declared as using a variable pool named "${a}" but no pools were defined.`);throw new Error(`The function "${e}" was declared as using a variable pool named "${a}" which is not among the variable pools defined. The defined variable pools are: ${o.formatList(i)}.`)}const c=l?A:i.parse(A);if("string"==typeof c)throw new Error("Got passed unparsed code without setting the preParsed flag");if("SCRIPT"!==c.type)throw new Error("Invalid AST");if(0===c.body.length)return;const d=[],p={resolveVar:t=>/^reg\d\d$/.test(t)?g.get(null,t):g.get(a,t),resolveLocal:t=>(d.push(t),d.length-1),resolveFunc:t=>{const e=m.findIndex(e=>e.name===t);if(-1!==e){const i=r.op.call(e);return"rand"===t&&1===n?[...i,r.op.f64_floor]:i}if(null==h.localFuncMap[t])return null;let i=u.indexOf(t);return-1===i&&(u.push(t),i=u.length-1),r.op.call(i+m.length)},rawSource:A},_=s.emit(c,p);f.push({binary:_,exportName:e,args:[],returns:[],localVariables:d})});const d=u.map(t=>{const e=h.localFuncMap[t];if(null==e)throw new Error(`Undefined local function "${t}"`);return e}),p=t=>[...t.args,"|",...t.returns].join("-"),_=[],E=new Map;function b(t){const e=p(t),i=E.get(e);if(null==i)throw new Error(`Failed to get a type index for key ${e}`);return i}[...m,...d,...f].forEach(t=>{const e=p(t);E.has(e)||(_.push([r.FUNCTION_TYPE,...r.encodeFlatVector(t.args),...r.encodeFlatVector(t.returns)]),E.set(e,_.length-1))});const x=[...c.map(([t,e])=>[...r.encodeString(t),...r.encodeString(e),r.GLOBAL_TYPE,r.VAL_TYPE.f64,r.MUTABILITY.var]),...m.map((t,e)=>{const i=b(t);return[...r.encodeString("shims"),...r.encodeString(t.name),r.TYPE_IDX,...r.unsignedLEB128(i)]})],v=[...d,...f].map(t=>{const e=b(t);return r.unsignedLEB128(e)}),T=[[1,...r.unsignedLEB128(A.WASM_MEMORY_SIZE),...r.unsignedLEB128(A.WASM_MEMORY_SIZE)]],S=g.size()-c.length,P=o.times(S,()=>[r.VAL_TYPE.f64,r.MUTABILITY.var,...r.op.f64_const(0),r.op.end]),w=[...f].map((t,e)=>{const i=e+m.length+d.length;return[...r.encodeString(t.exportName),r.EXPORT_TYPE.FUNC,...r.unsignedLEB128(i)]}),I=[...d,...f].map(t=>{var e;const i=(null!==(e=t.localVariables)&&void 0!==e?e:[]).map(t=>[...r.unsignedLEB128(1),t]);return r.encodeFlatVector([...r.encodeNestedVector(i),...t.binary,r.op.end])});return new Uint8Array([...r.MAGIC,...r.WASM_VERSION,...r.encodeSection(r.SECTION.TYPE,_),...r.encodeSection(r.SECTION.IMPORT,x),...r.encodeSection(r.SECTION.FUNC,v),...r.encodeSection(r.SECTION.MEMORY,T),...r.encodeSection(r.SECTION.GLOBAL,P),...r.encodeSection(r.SECTION.EXPORT,w),...r.encodeSection(r.SECTION.CODE,I)])},T}var X,O,k={};var G=function(){if(O)return i;O=1;var t=i&&i.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(i,"__esModule",{value:!0});const e=b();i.parse=e.parse;const s=N();i.compileModule=s.compileModule;const r=t(L());i.shims=r.default;const a=function(){if(X)return k;X=1;var t=k&&k.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(k,"__esModule",{value:!0});const e=t(L()),i=N();return k.loadModule=async function({pools:t,functions:s,eelVersion:r=2}){let a={};Object.entries(t).forEach(([t,e])=>{a[t]=new Set(Object.keys(e))});const o=i.compileModule({pools:a,functions:s,eelVersion:r}),h=await WebAssembly.compile(o);var A=Object.assign(Object.assign({},t),{shims:e.default});return await WebAssembly.instantiate(h,A)},k}();return i.loadModule=a.loadModule,i}();const Y="undefined"!=typeof BigUint64Array,W=Symbol(),J=new TextDecoder("utf-16le");function K(t,e){const i=new Uint32Array(t)[e+-4>>>2]>>>1,s=new Uint16Array(t,e,i);return i<=32?String.fromCharCode.apply(String,s):J.decode(s)}function j(t){const e={};function i(t,e){return t?K(t.buffer,e):"<yet unknown>"}const s=t.env=t.env||{};return s.abort=s.abort||function(t,r,a,o){const h=e.memory||s.memory;throw Error(`abort: ${i(h,t)} at ${i(h,r)}:${a}:${o}`)},s.trace=s.trace||function(t,r,...a){const o=e.memory||s.memory;console.log(`trace: ${i(o,t)}${r?" ":""}${a.slice(0,r).join(", ")}`)},s.seed=s.seed||Date.now,t.Math=t.Math||Math,t.Date=t.Date||Date,e}function H(t,e){const i=e.exports,s=i.memory,r=i.table,a=i.__new,o=i.__retain,h=i.__rtti_base||-1;function A(t){const e=function(t){const e=new Uint32Array(s.buffer);if((t>>>=0)>=e[h>>>2])throw Error(`invalid id: ${t}`);return e[(h+4>>>2)+2*t]}(t);if(!(7&e))throw Error(`not an array: ${t}, flags=${e}`);return e}function n(t){const e=new Uint32Array(s.buffer);if((t>>>=0)>=e[h>>>2])throw Error(`invalid id: ${t}`);return e[(h+4>>>2)+2*t+1]}function l(t){return 31-Math.clz32(t>>>6&31)}function c(t,e,i){const r=s.buffer;if(i)switch(t){case 2:return new Float32Array(r);case 3:return new Float64Array(r)}else switch(t){case 0:return new(e?Int8Array:Uint8Array)(r);case 1:return new(e?Int16Array:Uint16Array)(r);case 2:return new(e?Int32Array:Uint32Array)(r);case 3:return new(e?BigInt64Array:BigUint64Array)(r)}throw Error(`unsupported align: ${t}`)}function g(t){const e=new Uint32Array(s.buffer),i=A(e[t+-8>>>2]),r=l(i);let a=4&i?t:e[t+4>>>2];const o=2&i?e[t+12>>>2]:e[a+-4>>>2]>>>r;return c(r,2048&i,4096&i).subarray(a>>>=r,a+o)}function m(t,e,i){return new t(u(t,e,i))}function u(t,e,i){const r=s.buffer,a=new Uint32Array(r),o=a[i+4>>>2];return new t(r,o,a[o+-4>>>2]>>>e)}function f(e,i,s){t[`__get${i}`]=m.bind(null,e,s),t[`__get${i}View`]=u.bind(null,e,s)}return t.__newString=function(t){if(null==t)return 0;const e=t.length,i=a(e<<1,1),r=new Uint16Array(s.buffer);for(var o=0,h=i>>>1;o<e;++o)r[h+o]=t.charCodeAt(o);return i},t.__getString=function(t){if(!t)return null;const e=s.buffer;if(1!==new Uint32Array(e)[t+-8>>>2])throw Error(`not a string: ${t}`);return K(e,t)},t.__newArray=function(t,e){const i=A(t),r=l(i),h=e.length,n=a(h<<r,4&i?t:0);let g;if(4&i)g=n;else{const e=a(2&i?16:12,t),A=new Uint32Array(s.buffer);A[e+0>>>2]=o(n),A[e+4>>>2]=n,A[e+8>>>2]=h<<r,2&i&&(A[e+12>>>2]=h),g=e}const m=c(r,2048&i,4096&i);if(16384&i)for(let t=0;t<h;++t)m[(n>>>r)+t]=o(e[t]);else m.set(e,n>>>r);return g},t.__getArrayView=g,t.__getArray=function(t){const e=g(t),i=e.length,s=new Array(i);for(let t=0;t<i;t++)s[t]=e[t];return s},t.__getArrayBuffer=function(t){const e=s.buffer,i=new Uint32Array(e)[t+-4>>>2];return e.slice(t,t+i)},[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array].forEach(t=>{f(t,t.name,31-Math.clz32(t.BYTES_PER_ELEMENT))}),Y&&[BigUint64Array,BigInt64Array].forEach(t=>{f(t,t.name.slice(3),3)}),t.__instanceof=function(t,e){const i=new Uint32Array(s.buffer);let r=i[t+-8>>>2];if(r<=i[h>>>2])do{if(r==e)return!0;r=n(r)}while(r);return!1},t.memory=t.memory||s,t.table=t.table||r,it(i,t)}function Z(t){return"undefined"!=typeof Response&&t instanceof Response}function $(t){return t instanceof WebAssembly.Module}async function tt(t,e={}){if(Z(t=await t))return et(t,e);const i=$(t)?t:await WebAssembly.compile(t),s=j(e),r=await WebAssembly.instantiate(i,e);return{module:i,instance:r,exports:H(s,r)}}async function et(t,e={}){if(!WebAssembly.instantiateStreaming)return tt(Z(t=await t)?t.arrayBuffer():t,e);const i=j(e),s=await WebAssembly.instantiateStreaming(t,e),r=H(i,s.instance);return{...s,exports:r}}function it(t,e={}){const i=t.__argumentsLength?e=>{t.__argumentsLength.value=e}:t.__setArgumentsLength||t.__setargc||(()=>{});for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const r=t[s];let a=s.split("."),o=e;for(;a.length>1;){let t=a.shift();Object.prototype.hasOwnProperty.call(o,t)||(o[t]={}),o=o[t]}let h=a[0],A=h.indexOf("#");if(A>=0){const e=h.substring(0,A),a=o[e];if(void 0===a||!a.prototype){const t=function(...e){return t.wrap(t.prototype.constructor(0,...e))};t.prototype={valueOf(){return this[W]}},t.wrap=function(e){return Object.create(t.prototype,{[W]:{value:e,writable:!1}})},a&&Object.getOwnPropertyNames(a).forEach(e=>Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))),o[e]=t}if(h=h.substring(A+1),o=o[e].prototype,/^(get|set):/.test(h)){if(!Object.prototype.hasOwnProperty.call(o,h=h.substring(4))){let e=t[s.replace("set:","get:")],i=t[s.replace("get:","set:")];Object.defineProperty(o,h,{get(){return e(this[W])},set(t){i(this[W],t)},enumerable:!0})}}else"constructor"===h?(o[h]=(...t)=>(i(t.length),r(...t))).original=r:(o[h]=function(...t){return i(t.length),r(this[W],...t)}).original=r}else/^(get|set):/.test(h)?Object.prototype.hasOwnProperty.call(o,h=h.substring(4))||Object.defineProperty(o,h,{get:t[s.replace("set:","get:")],set:t[s.replace("get:","set:")],enumerable:!0}):"function"==typeof r&&r!==i?(o[h]=(...t)=>(i(t.length),r(...t))).original=r:o[h]=r}return e}var st={instantiate:tt,instantiateSync:function(t,e={}){const i=$(t)?t:new WebAssembly.Module(t),s=j(e),r=new WebAssembly.Instance(i,e);return{module:i,instance:r,exports:H(s,r)}},instantiateStreaming:et,demangle:it};class rt{constructor(t,e,i=!1){this.samplesIn=t,this.samplesOut=e,this.equalize=i,this.NFREQ=2*e,this.equalize&&this.initEqualizeTable(),this.initBitRevTable(),this.initCosSinTable()}initEqualizeTable(){this.equalizeArr=new Float32Array(this.samplesOut);const t=1/this.samplesOut;for(let e=0;e<this.samplesOut;e++)this.equalizeArr[e]=-.02*Math.log((this.samplesOut-e)*t)}initBitRevTable(){this.bitrevtable=new Uint16Array(this.NFREQ);for(let t=0;t<this.NFREQ;t++)this.bitrevtable[t]=t;let t=0;for(let e=0;e<this.NFREQ;e++){if(t>e){const i=this.bitrevtable[e];this.bitrevtable[e]=this.bitrevtable[t],this.bitrevtable[t]=i}let i=this.NFREQ>>1;for(;i>=1&&t>=i;)t-=i,i>>=1;t+=i}}initCosSinTable(){let t=2,e=0;for(;t<=this.NFREQ;)e+=1,t<<=1;this.cossintable=[new Float32Array(e),new Float32Array(e)],t=2;let i=0;for(;t<=this.NFREQ;){const e=-2*Math.PI/t;this.cossintable[0][i]=Math.cos(e),this.cossintable[1][i]=Math.sin(e),i+=1,t<<=1}}timeToFrequencyDomain(t){const e=new Float32Array(this.NFREQ),i=new Float32Array(this.NFREQ);for(let s=0;s<this.NFREQ;s++){const r=this.bitrevtable[s];r<this.samplesIn?e[s]=t[r]:e[s]=0,i[s]=0}let s=2,r=0;for(;s<=this.NFREQ;){const t=this.cossintable[0][r],a=this.cossintable[1][r];let o=1,h=0;const A=s>>1;for(let r=0;r<A;r++){for(let t=r;t<this.NFREQ;t+=s){const s=t+A,r=o*e[s]-h*i[s],a=o*i[s]+h*e[s];e[s]=e[t]-r,i[s]=i[t]-a,e[t]+=r,i[t]+=a}const n=o;o=n*t-h*a,h=h*t+n*a}s<<=1,r+=1}const a=new Float32Array(this.samplesOut);if(this.equalize)for(let t=0;t<this.samplesOut;t++)a[t]=this.equalizeArr[t]*Math.sqrt(e[t]*e[t]+i[t]*i[t]);else for(let t=0;t<this.samplesOut;t++)a[t]=Math.sqrt(e[t]*e[t]+i[t]*i[t]);return a}}class at{constructor(t){this.numSamps=512,this.fftSize=2*this.numSamps,this.fft=new rt(this.fftSize,512,!0),t&&(this.audioContext=t,this.audible=t.createDelay(),this.analyser=t.createAnalyser(),this.analyser.smoothingTimeConstant=0,this.analyser.fftSize=this.fftSize,this.audible.connect(this.analyser),this.analyserL=t.createAnalyser(),this.analyserL.smoothingTimeConstant=0,this.analyserL.fftSize=this.fftSize,this.analyserR=t.createAnalyser(),this.analyserR.smoothingTimeConstant=0,this.analyserR.fftSize=this.fftSize,this.splitter=t.createChannelSplitter(2),this.audible.connect(this.splitter),this.splitter.connect(this.analyserL,0),this.splitter.connect(this.analyserR,1)),this.timeByteArray=new Uint8Array(this.fftSize),this.timeByteArrayL=new Uint8Array(this.fftSize),this.timeByteArrayR=new Uint8Array(this.fftSize),this.timeArray=new Int8Array(this.fftSize),this.timeByteArraySignedL=new Int8Array(this.fftSize),this.timeByteArraySignedR=new Int8Array(this.fftSize),this.tempTimeArrayL=new Int8Array(this.fftSize),this.tempTimeArrayR=new Int8Array(this.fftSize),this.timeArrayL=new Int8Array(this.numSamps),this.timeArrayR=new Int8Array(this.numSamps)}sampleAudio(){this.analyser.getByteTimeDomainData(this.timeByteArray),this.analyserL.getByteTimeDomainData(this.timeByteArrayL),this.analyserR.getByteTimeDomainData(this.timeByteArrayR),this.processAudio()}updateAudio(t,e,i){this.timeByteArray.set(t),this.timeByteArrayL.set(e),this.timeByteArrayR.set(i),this.processAudio()}processAudio(){for(let t=0,e=0,i=0;t<this.fftSize;t++)this.timeArray[t]=this.timeByteArray[t]-128,this.timeByteArraySignedL[t]=this.timeByteArrayL[t]-128,this.timeByteArraySignedR[t]=this.timeByteArrayR[t]-128,this.tempTimeArrayL[t]=.5*(this.timeByteArraySignedL[t]+this.timeByteArraySignedL[i]),this.tempTimeArrayR[t]=.5*(this.timeByteArraySignedR[t]+this.timeByteArraySignedR[i]),t%2==0&&(this.timeArrayL[e]=this.tempTimeArrayL[t],this.timeArrayR[e]=this.tempTimeArrayR[t],e+=1),i=t;this.freqArray=this.fft.timeToFrequencyDomain(this.timeArray),this.freqArrayL=this.fft.timeToFrequencyDomain(this.timeByteArraySignedL),this.freqArrayR=this.fft.timeToFrequencyDomain(this.timeByteArraySignedR)}connectAudio(t){t.connect(this.audible)}disconnectAudio(t){t.disconnect(this.audible)}}class ot{constructor(t){let e;this.audio=t,e=this.audio.audioContext?this.audio.audioContext.sampleRate:44100;const i=e/this.audio.fftSize,s=Math.clamp(Math.round(20/i)-1,0,this.audio.numSamps-1),r=Math.clamp(Math.round(320/i)-1,0,this.audio.numSamps-1),a=Math.clamp(Math.round(2800/i)-1,0,this.audio.numSamps-1),o=Math.clamp(Math.round(11025/i)-1,0,this.audio.numSamps-1);this.starts=[s,r,a],this.stops=[r,a,o],this.val=new Float32Array(3),this.imm=new Float32Array(3),this.att=new Float32Array(3),this.avg=new Float32Array(3),this.longAvg=new Float32Array(3),this.att.fill(1),this.avg.fill(1),this.longAvg.fill(1)}get bass(){return this.val[0]}get bass_att(){return this.att[0]}get mid(){return this.val[1]}get mid_att(){return this.att[1]}get treb(){return this.val[2]}get treb_att(){return this.att[2]}static isFiniteNumber(t){return Number.isFinite(t)&&!Number.isNaN(t)}static adjustRateToFPS(t,e,i){return t**(e/i)}updateAudioLevels(t,e){if(this.audio.freqArray.length>0){let i=t;!ot.isFiniteNumber(i)||i<15?i=15:i>144&&(i=144),this.imm.fill(0);for(let t=0;t<3;t++)for(let e=this.starts[t];e<this.stops[t];e++)this.imm[t]+=this.audio.freqArray[e];for(let t=0;t<3;t++){let s;s=this.imm[t]>this.avg[t]?.2:.5,s=ot.adjustRateToFPS(s,30,i),this.avg[t]=this.avg[t]*s+this.imm[t]*(1-s),s=e<50?.9:.992,s=ot.adjustRateToFPS(s,30,i),this.longAvg[t]=this.longAvg[t]*s+this.imm[t]*(1-s),this.longAvg[t]<.001?(this.val[t]=1,this.att[t]=1):(this.val[t]=this.imm[t]/this.longAvg[t],this.att[t]=this.avg[t]/this.longAvg[t])}}}}const ht={baseVals:{gammaadj:1.25,wave_g:.5,mv_x:12,warpscale:1,brighten:0,mv_y:9,wave_scale:1,echo_alpha:0,additivewave:0,sx:1,sy:1,warp:.01,red_blue:0,wave_mode:0,wave_brighten:0,wrap:0,zoomexp:1,fshader:0,wave_r:.5,echo_zoom:1,wave_smoothing:.75,warpanimspeed:1,wave_dots:0,wave_x:.5,wave_y:.5,zoom:1,solarize:0,modwavealphabyvolume:0,dx:0,cx:.5,dy:0,darken_center:0,cy:.5,invert:0,bmotionvectorson:0,rot:0,modwavealphaend:.95,wave_mystery:-.2,decay:.9,wave_a:1,wave_b:.5,rating:5,modwavealphastart:.75,darken:0,echo_orient:0,ib_r:.5,ib_g:.5,ib_b:.5,ib_a:0,ib_size:0,ob_r:.5,ob_g:.5,ob_b:.5,ob_a:0,ob_size:0,mv_dx:0,mv_dy:0,mv_a:0,mv_r:.5,mv_g:.5,mv_b:.5,mv_l:0},init_eqs:function(){return{}},frame_eqs:function(t){return t.rkeys=["warp"],t.zoom=1.01+.02*t.treb_att,t.warp=.15+.25*t.bass_att,t},pixel_eqs:function(t){return t.warp=t.warp+.15*t.rad,t},waves:[{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""}],shapes:[{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}}],warp:"shader_body {\nret = texture2D(sampler_main, uv).rgb;\nret -= 0.004;\n}\n",comp:"shader_body {\nret = texture2D(sampler_main, uv).rgb;\nret *= hue_shader;\n}\n"};class At{static atan2(t,e){let i=Math.atan2(t,e);return i<0&&(i+=2*Math.PI),i}static cloneVars(t){return Object.assign({},t)}static range(t,e){return void 0===e?[...Array(t).keys()]:Array.from({length:e-t},(e,i)=>i+t)}static pick(t,e){const i={};for(let s=0;s<e.length;s++){const r=e[s];i[r]=t[r]||0}return i}static omit(t,e){const i=Object.assign({},t);for(let t=0;t<e.length;t++){delete i[e[t]]}return i}static setWasm(t,e,i){for(let s=0;s<i.length;s++){const r=i[s];t[r].value=e[r]}}static pickWasm(t,e){const i={};for(let s=0;s<e.length;s++){const r=e[s];i[r]=t[r].value}return i}}class nt{constructor(t=1){this.state=new Uint32Array(4),nt.initializeState(this.state,t),this.warmUp()}static initializeState(t,e){t[0]=e,t[1]=2654435769^e,t[2]=1779033703^e,t[3]=3144134277^e}warmUp(){for(let t=0;t<10;t++)this.next()}next(){let t=this.state[3],e=this.state[0];return this.state[3]=this.state[2],this.state[2]=this.state[1],this.state[1]=e,t^=t<<11,t^=t>>>8,this.state[0]=t^e^e>>>19,(this.state[0]>>>0)/4294967296}nextInt(t){return Math.floor(this.next()*t)}rand(t){return t<1?this.next():Math.floor(this.next()*Math.floor(t))}reset(t){nt.initializeState(this.state,t),this.warmUp()}}function lt(){return{random:Math.random,rand:t=>t<1?Math.random():Math.random()*Math.floor(t),randint:t=>Math.floor((t<1?Math.random():Math.random()*Math.floor(t))+1),getRNG:()=>null,reset:()=>{}}}let ct=null;function gt(t={}){return ct=t.deterministic||t.testMode?function(t=1){const e=new nt(t);return{random:()=>e.next(),rand:t=>e.rand(t),randint:t=>Math.floor(e.rand(t)+1),getRNG:()=>e,reset:i=>{void 0!==i?e.reset(i):e.reset(t)}}}(t.seed||12345):lt(),(t.deterministic||t.testMode)&&(window.rand=t=>ct.rand(t),window.randint=t=>ct.randint(t),Math.random=()=>ct.random()),ct}function mt(){return ct||(ct=lt()),ct}class ut{constructor(t,e,i){this.rng=mt(),this.preset=t,this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=At.range(1,33).map(t=>`q${t}`),this.ts=At.range(1,9).map(t=>`t${t}`),this.regs=At.range(100).map(t=>t<10?`reg0${t}`:`reg${t}`),this.initializeEquations(e)}initializeEquations(t){this.runVertEQs=""!==this.preset.pixel_eqs,this.mdVSQInit=null,this.mdVSRegs=null,this.mdVSFrame=null,this.mdVSUserKeys=null,this.mdVSFrameMap=null,this.mdVSShapes=null,this.mdVSUserKeysShapes=null,this.mdVSFrameMapShapes=null,this.mdVSWaves=null,this.mdVSUserKeysWaves=null,this.mdVSFrameMapWaves=null,this.mdVSQAfterFrame=null,this.gmegabuf=new Array(1048576).fill(0);const e={frame:t.frame,time:t.time,fps:t.fps,bass:t.bass,bass_att:t.bass_att,mid:t.mid,mid_att:t.mid_att,treb:t.treb,treb_att:t.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY,gmegabuf:this.gmegabuf};this.mdVS=Object.assign({},this.preset.baseVals,e),this.mdVS.megabuf=new Array(1048576).fill(0),this.mdVS.rand_start=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]),this.mdVS.rand_preset=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]);const i=this.qs.concat(this.regs,Object.keys(this.mdVS)),s=this.preset.init_eqs(At.cloneVars(this.mdVS));this.mdVSQInit=At.pick(s,this.qs),this.mdVSRegs=At.pick(s,this.regs);const r=At.pick(s,Object.keys(At.omit(s,i)));if(r.megabuf=s.megabuf,r.gmegabuf=s.gmegabuf,this.mdVSFrame=this.preset.frame_eqs(Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSRegs,r)),this.mdVSUserKeys=Object.keys(At.omit(this.mdVSFrame,i)),this.mdVSFrameMap=At.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=At.pick(this.mdVSFrame,this.qs),this.mdVSRegs=At.pick(this.mdVSFrame,this.regs),this.mdVSWaves=[],this.mdVSTWaveInits=[],this.mdVSUserKeysWaves=[],this.mdVSFrameMapWaves=[],this.preset.waves&&this.preset.waves.length>0)for(let t=0;t<this.preset.waves.length;t++){const i=this.preset.waves[t],s=i.baseVals;if(0!==s.enabled){let r=Object.assign({},s,e);const a=this.qs.concat(this.ts,this.regs,Object.keys(r));Object.assign(r,this.mdVSQAfterFrame,this.mdVSRegs),r.megabuf=new Array(1048576).fill(0),i.init_eqs&&(r=i.init_eqs(r),this.mdVSRegs=At.pick(r,this.regs),Object.assign(r,s)),this.mdVSWaves.push(r),this.mdVSTWaveInits.push(At.pick(r,this.ts)),this.mdVSUserKeysWaves.push(Object.keys(At.omit(r,a))),this.mdVSFrameMapWaves.push(At.pick(r,this.mdVSUserKeysWaves[t]))}else this.mdVSWaves.push({}),this.mdVSTWaveInits.push({}),this.mdVSUserKeysWaves.push([]),this.mdVSFrameMapWaves.push({})}if(this.mdVSShapes=[],this.mdVSTShapeInits=[],this.mdVSUserKeysShapes=[],this.mdVSFrameMapShapes=[],this.preset.shapes&&this.preset.shapes.length>0)for(let t=0;t<this.preset.shapes.length;t++){const i=this.preset.shapes[t],s=i.baseVals;if(0!==s.enabled){let r=Object.assign({},s,e);const a=this.qs.concat(this.ts,this.regs,Object.keys(r));Object.assign(r,this.mdVSQAfterFrame,this.mdVSRegs),r.megabuf=new Array(1048576).fill(0),i.init_eqs&&(r=i.init_eqs(r),this.mdVSRegs=At.pick(r,this.regs),Object.assign(r,s)),this.mdVSShapes.push(r),this.mdVSTShapeInits.push(At.pick(r,this.ts)),this.mdVSUserKeysShapes.push(Object.keys(At.omit(r,a))),this.mdVSFrameMapShapes.push(At.pick(r,this.mdVSUserKeysShapes[t]))}else this.mdVSShapes.push({}),this.mdVSTShapeInits.push({}),this.mdVSUserKeysShapes.push([]),this.mdVSFrameMapShapes.push({})}}updatePreset(t,e){this.preset=t,this.initializeEquations(e)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}runFrameEquations(t){return this.mdVSFrame=Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSFrameMap,t),this.mdVSFrame=this.preset.frame_eqs(this.mdVSFrame),this.mdVSFrameMap=At.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=At.pick(this.mdVSFrame,this.qs),this.mdVSFrame}runPixelEquations(t){return this.preset.pixel_eqs(t)}runShapeFrameEquations(t,e){return this.preset.shapes[t].frame_eqs(e)}runWaveFrameEquations(t,e){return this.preset.waves[t].frame_eqs(e)}runWavePointEquations(t,e){return this.preset.waves[t].point_eqs(e)}}class ft{constructor(t,e,i){this.rng=mt(),this.preset=t,this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=At.range(1,33).map(t=>`q${t}`),this.ts=At.range(1,9).map(t=>`t${t}`),this.regs=At.range(100).map(t=>t<10?`reg0${t}`:`reg${t}`),this.globalKeys=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy"],this.frameKeys=["decay","wave_a","wave_r","wave_g","wave_b","wave_x","wave_y","wave_scale","wave_smoothing","wave_mode","old_wave_mode","wave_mystery","ob_size","ob_r","ob_g","ob_b","ob_a","ib_size","ib_r","ib_g","ib_b","ib_a","mv_x","mv_y","mv_dx","mv_dy","mv_l","mv_r","mv_g","mv_b","mv_a","echo_zoom","echo_alpha","echo_orient","wave_dots","wave_thick","additivewave","wave_brighten","modwavealphabyvolume","modwavealphastart","modwavealphaend","darken_center","gammaadj","warp","warpanimspeed","warpscale","zoom","zoomexp","rot","cx","cy","dx","dy","sx","sy","fshader","wrap","invert","brighten","darken","solarize","bmotionvectorson","b1n","b2n","b3n","b1x","b2x","b3x","b1ed"],this.waveFrameKeys=["samples","sep","scaling","spectrum","smoothing","r","g","b","a"],this.waveFrameInputKeys=["samples","r","g","b","a"],this.initializeEquations(e)}getQVars(t){return At.pickWasm(this.preset.globalPools[t],this.qs)}getTVars(t){return At.pickWasm(this.preset.globalPools[t],this.ts)}initializeEquations(t){this.runVertEQs=!!this.preset.pixel_eqs,this.mdVSQInit=null,this.mdVSQAfterFrame=null;const e={frame:t.frame,time:t.time,fps:t.fps,bass:t.bass,bass_att:t.bass_att,mid:t.mid,mid_att:t.mid_att,treb:t.treb,treb_att:t.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY};if(this.mdVS=Object.assign({},this.preset.baseVals,e),At.setWasm(this.preset.globalPools.perFrame,this.mdVS,Object.keys(this.mdVS)),this.rand_start=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]),this.rand_preset=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]),this.preset.init_eqs(),this.mdVSQInit=this.getQVars("perFrame"),this.preset.frame_eqs(),this.mdVSQAfterFrame=this.getQVars("perFrame"),this.mdVSTWaveInits=[],this.preset.waves&&this.preset.waves.length>0)for(let t=0;t<this.preset.waves.length;t++){const e=this.preset.waves[t],i=e.baseVals;0!==i.enabled?(At.setWasm(this.preset.globalPools[`wavePerFrame${t}`],i,Object.keys(i)),e.init_eqs&&(e.init_eqs(),At.setWasm(this.preset.globalPools[`wavePerFrame${t}`],i,Object.keys(i))),this.mdVSTWaveInits.push(this.getTVars(`wavePerFrame${t}`))):this.mdVSTWaveInits.push({})}if(this.mdVSTShapeInits=[],this.preset.shapes&&this.preset.shapes.length>0)for(let t=0;t<this.preset.shapes.length;t++){const e=this.preset.shapes[t],i=e.baseVals;0!==i.enabled?(At.setWasm(this.preset.globalPools[`shapePerFrame${t}`],i,Object.keys(i)),e.init_eqs&&(e.init_eqs(),At.setWasm(this.preset.globalPools[`shapePerFrame${t}`],i,Object.keys(i))),this.mdVSTShapeInits.push(this.getTVars(`shapePerFrame${t}`))):this.mdVSTShapeInits.push({})}}updatePreset(t,e){this.preset=t,this.initializeEquations(e)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}runFrameEquations(t){At.setWasm(this.preset.globalPools.perFrame,this.mdVS,this.frameKeys),At.setWasm(this.preset.globalPools.perFrame,this.mdVSQInit,this.qs),At.setWasm(this.preset.globalPools.perFrame,t,this.globalKeys),this.preset.frame_eqs(),this.preset.save_qs(),this.mdVSQAfterFrame=this.getQVars("perFrame");const e=At.pickWasm(this.preset.globalPools.perFrame,[...this.frameKeys,...this.globalKeys]);return e.rand_preset=this.rand_preset,e.rand_start=this.rand_start,e}runWaveFrameEquations(t,e){const i=this.preset.waves[t].baseVals;return At.setWasm(this.preset.globalPools[`wavePerFrame${t}`],i,this.waveFrameInputKeys),At.setWasm(this.preset.globalPools[`wavePerFrame${t}`],this.mdVSQAfterFrame,this.qs),At.setWasm(this.preset.globalPools[`wavePerFrame${t}`],this.mdVSTWaveInits[t],this.ts),At.setWasm(this.preset.globalPools[`wavePerFrame${t}`],e,this.globalKeys),this.preset.waves[t].frame_eqs(),At.pickWasm(this.preset.globalPools[`wavePerFrame${t}`],this.waveFrameKeys)}}const dt=/uniform sampler2D sampler_(?:.+?);/g,pt=/uniform sampler2D sampler_(.+?);/;class _t{static getShaderParts(t){const e=t.indexOf("shader_body");if(t&&e>-1){const i=t.substring(0,e),s=t.substring(e),r=s.indexOf("{"),a=s.lastIndexOf("}");return[i,s.substring(r+1,a)]}return["",t]}static getFragmentFloatPrecision(t){return t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0?"highp":t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}static getUserSamplers(t){const e=[],i=t.match(dt);if(i&&i.length>0)for(let t=0;t<i.length;t++){const s=i[t].match(pt);if(s&&s.length>0){const t=s[1];e.push({sampler:t})}}return e}}class Et{static smoothWave(t,e,i,s=!1){const r=-.15,a=1.15,o=1.15,h=-.15;let A,n=0,l=0,c=1;for(let g=0;g<i-1;g++){A=c,c=Math.min(i-1,g+2);for(let i=0;i<3;i++)e[3*n+i]=t[3*g+i];if(s)for(let i=0;i<3;i++)e[3*(n+1)+i]=.5*(r*t[3*l+i]+a*t[3*g+i]+o*t[3*A+i]+h*t[3*c+i]);else{for(let i=0;i<2;i++)e[3*(n+1)+i]=.5*(r*t[3*l+i]+a*t[3*g+i]+o*t[3*A+i]+h*t[3*c+i]);e[3*(n+1)+2]=0}l=g,n+=2}for(let s=0;s<3;s++)e[3*n+s]=t[3*(i-1)+s]}static smoothWaveAndColor(t,e,i,s,r,a=!1){const o=-.15,h=1.15,A=1.15,n=-.15;let l,c=0,g=0,m=1;for(let u=0;u<r-1;u++){l=m,m=Math.min(r-1,u+2);for(let e=0;e<3;e++)i[3*c+e]=t[3*u+e];if(a)for(let e=0;e<3;e++)i[3*(c+1)+e]=.5*(o*t[3*g+e]+h*t[3*u+e]+A*t[3*l+e]+n*t[3*m+e]);else{for(let e=0;e<2;e++)i[3*(c+1)+e]=.5*(o*t[3*g+e]+h*t[3*u+e]+A*t[3*l+e]+n*t[3*m+e]);i[3*(c+1)+2]=0}for(let t=0;t<4;t++)s[4*c+t]=e[4*u+t],s[4*(c+1)+t]=e[4*u+t];g=u,c+=2}for(let e=0;e<3;e++)i[3*c+e]=t[3*(r-1)+e];for(let t=0;t<4;t++)s[4*c+t]=e[4*(r-1)+t]}}class bt{constructor(t,e={}){this.gl=t;this.positions=new Float32Array(1536),this.positions2=new Float32Array(1536),this.oldPositions=new Float32Array(1536),this.oldPositions2=new Float32Array(1536),this.smoothedPositions=new Float32Array(3069),this.smoothedPositions2=new Float32Array(3069),this.color=[0,0,0,1],this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      uniform vec2 thickOffset;\n      void main(void) {\n        gl_Position = vec4(aPos + vec3(thickOffset, 0.0), 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 u_color;\n      void main(void) {\n        fragColor = u_color;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}static processWaveform(t,e){const i=[],s=e.wave_scale/128,r=e.wave_smoothing,a=s*(1-r);i.push(t[0]*s);for(let e=1;e<t.length;e++)i.push(t[e]*a+i[e-1]*r);return i}generateWaveform(t,e,i,s,r){let a=r.wave_a;const o=(r.bass+r.mid+r.treb)/3;if(o>-.01&&a>.001&&i.length>0){const h=bt.processWaveform(i,r),A=bt.processWaveform(s,r),n=Math.floor(r.wave_mode)%8,l=Math.floor(r.old_wave_mode)%8,c=2*r.wave_x-1,g=2*r.wave_y-1;this.numVert=0,this.oldNumVert=0;const m=t&&n!==l?2:1;for(let t=0;t<m;t++){const e=0===t?n:l;let i,s,m,u=r.wave_mystery;if(0!==e&&1!==e&&4!==e||!(u<-1||u>1)||(u=.5*u+.5,u-=Math.floor(u),u=Math.abs(u),u=2*u-1),0===t?(s=this.positions,m=this.positions2):(s=this.oldPositions,m=this.oldPositions2),a=r.wave_a,0===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=Math.floor(h.length/2)+1;const t=1/(i-1),e=Math.floor((h.length-i)/2);for(let a=0;a<i-1;a++){let o=.5+.4*A[a+e]+u;const h=a*t*2*Math.PI+.2*r.time;if(a<i/10){let t=a/(.1*i);t=.5-.5*Math.cos(t*Math.PI);o=(1-t)*(.5+.4*A[a+i+e]+u)+o*t}s[3*a+0]=o*Math.cos(h)*this.aspecty+c,s[3*a+1]=o*Math.sin(h)*this.aspectx+g,s[3*a+2]=0}s[3*(i-1)+0]=s[0],s[3*(i-1)+1]=s[1],s[3*(i-1)+2]=0}else if(1===e){if(a*=1.25,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=Math.floor(h.length/2);for(let t=0;t<i;t++){const e=.53+.43*A[t]+u,i=.5*h[t+32]*Math.PI+2.3*r.time;s[3*t+0]=e*Math.cos(i)*this.aspecty+c,s[3*t+1]=e*Math.sin(i)*this.aspectx+g,s[3*t+2]=0}}else if(2===e){if(this.texsizeX<1024?a*=.09:this.texsizeX>=1024&&this.texsizeX<2048?a*=.11:a*=.13,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=h.length;for(let t=0;t<h.length;t++)s[3*t+0]=A[t]*this.aspecty+c,s[3*t+1]=h[(t+32)%h.length]*this.aspectx+g,s[3*t+2]=0}else if(3===e){if(this.texsizeX<1024?a*=.15:this.texsizeX>=1024&&this.texsizeX<2048?a*=.22:a*=.33,a*=1.3,a*=r.treb*r.treb,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=h.length;for(let t=0;t<h.length;t++)s[3*t+0]=A[t]*this.aspecty+c,s[3*t+1]=h[(t+32)%h.length]*this.aspectx+g,s[3*t+2]=0}else if(4===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=h.length,i>this.texsizeX/3&&(i=Math.floor(this.texsizeX/3));const t=1/i,e=Math.floor((h.length-i)/2),n=.45+.5*(.5*u+.5),l=1-n;for(let r=0;r<i;r++){let i=2*r*t+(c-1)+.44*A[(r+25+e)%h.length],a=.47*h[r+e]+g;r>1&&(i=i*l+n*(2*s[3*(r-1)+0]-s[3*(r-2)+0]),a=a*l+n*(2*s[3*(r-1)+1]-s[3*(r-2)+1])),s[3*r+0]=i,s[3*r+1]=a,s[3*r+2]=0}}else if(5===e){if(this.texsizeX<1024?a*=.09:this.texsizeX>=1024&&this.texsizeX<2048?a*=.11:a*=.13,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1);const t=Math.cos(.3*r.time),e=Math.sin(.3*r.time);i=h.length;for(let i=0;i<h.length;i++){const r=(i+32)%h.length,a=A[i]*h[r]+h[i]*A[r],o=A[i]*A[i]-h[r]*h[r];s[3*i+0]=(a*t-o*e)*(this.aspecty+c),s[3*i+1]=(a*e+o*t)*(this.aspectx+g),s[3*i+2]=0}}else if(6===e||7===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=Math.floor(h.length/2),i>this.texsizeX/3&&(i=Math.floor(this.texsizeX/3));const t=Math.floor((h.length-i)/2),n=.5*Math.PI*u;let l=Math.cos(n),f=Math.sin(n);const d=[c*Math.cos(n+.5*Math.PI)-3*l,c*Math.cos(n+.5*Math.PI)+3*l],p=[c*Math.sin(n+.5*Math.PI)-3*f,c*Math.sin(n+.5*Math.PI)+3*f];for(let t=0;t<2;t++)for(let e=0;e<4;e++){let i,s=!1;switch(e){case 0:d[t]>1.1&&(i=(1.1-d[1-t])/(d[t]-d[1-t]),s=!0);break;case 1:d[t]<-1.1&&(i=(-1.1-d[1-t])/(d[t]-d[1-t]),s=!0);break;case 2:p[t]>1.1&&(i=(1.1-p[1-t])/(p[t]-p[1-t]),s=!0);break;case 3:p[t]<-1.1&&(i=(-1.1-p[1-t])/(p[t]-p[1-t]),s=!0)}if(s){const e=d[t]-d[1-t],s=p[t]-p[1-t];d[t]=d[1-t]+e*i,p[t]=p[1-t]+s*i}}l=(d[1]-d[0])/i,f=(p[1]-p[0])/i;const _=Math.atan2(f,l),E=Math.cos(_+.5*Math.PI),b=Math.sin(_+.5*Math.PI);if(6===e)for(let e=0;e<i;e++){const i=h[e+t];s[3*e+0]=d[0]+l*e+.25*E*i,s[3*e+1]=p[0]+f*e+.25*b*i,s[3*e+2]=0}else if(7===e){const e=(.5*g+.5)**2;for(let r=0;r<i;r++){const i=h[r+t];s[3*r+0]=d[0]+l*r+E*(.25*i+e),s[3*r+1]=p[0]+f*r+b*(.25*i+e),s[3*r+2]=0}for(let s=0;s<i;s++){const i=A[s+t];m[3*s+0]=d[0]+l*s+E*(.25*i-e),m[3*s+1]=p[0]+f*s+b*(.25*i-e),m[3*s+2]=0}}}0===t?(this.positions=s,this.positions2=m,this.numVert=i,this.alpha=a):(this.oldPositions=s,this.oldPositions2=m,this.oldNumVert=i,this.oldAlpha=a)}const u=.5-.5*Math.cos(e*Math.PI),f=1-u;this.oldNumVert>0&&(a=u*this.alpha+f*this.oldAlpha);let d=Math.clamp(r.wave_r,0,1),p=Math.clamp(r.wave_g,0,1),_=Math.clamp(r.wave_b,0,1);if(0!==r.wave_brighten){const t=Math.max(d,p,_);t>.01&&(d/=t,p/=t,_/=t)}if(this.color=[d,p,_,a],this.oldNumVert>0)if(7===n){const t=(this.oldNumVert-1)/(2*this.numVert);for(let e=0;e<this.numVert;e++){const i=e*t,s=Math.floor(i),r=i-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions[3*e+0]=this.positions[3*e+0]*u+a*f,this.positions[3*e+1]=this.positions[3*e+1]*u+o*f,this.positions[3*e+2]=0}for(let e=0;e<this.numVert;e++){const i=(e+this.numVert)*t,s=Math.floor(i),r=i-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions2[3*e+0]=this.positions2[3*e+0]*u+a*f,this.positions2[3*e+1]=this.positions2[3*e+1]*u+o*f,this.positions2[3*e+2]=0}}else if(7===l){const t=this.numVert/2,e=(this.oldNumVert-1)/t;for(let i=0;i<t;i++){const t=i*e,s=Math.floor(t),r=t-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions[3*i+0]=this.positions[3*i+0]*u+a*f,this.positions[3*i+1]=this.positions[3*i+1]*u+o*f,this.positions[3*i+2]=0}for(let i=0;i<t;i++){const s=i*e,r=Math.floor(s),a=s-r,o=this.oldPositions2[3*r+0]*(1-a)+this.oldPositions2[3*(r+1)+0]*a,h=this.oldPositions2[3*r+1]*(1-a)+this.oldPositions2[3*(r+1)+1]*a;this.positions2[3*i+0]=this.positions[3*(i+t)+0]*u+o*f,this.positions2[3*i+1]=this.positions[3*(i+t)+1]*u+h*f,this.positions2[3*i+2]=0}}else{const t=(this.oldNumVert-1)/this.numVert;for(let e=0;e<this.numVert;e++){const i=e*t,s=Math.floor(i),r=i-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions[3*e+0]=this.positions[3*e+0]*u+a*f,this.positions[3*e+1]=this.positions[3*e+1]*u+o*f,this.positions[3*e+2]=0}}for(let t=0;t<this.numVert;t++)this.positions[3*t+1]=-this.positions[3*t+1];if(this.smoothedNumVert=2*this.numVert-1,Et.smoothWave(this.positions,this.smoothedPositions,this.numVert),7===n||7===l){for(let t=0;t<this.numVert;t++)this.positions2[3*t+1]=-this.positions2[3*t+1];Et.smoothWave(this.positions2,this.smoothedPositions2,this.numVert)}return!0}return!1}drawBasicWaveform(t,e,i,s,r){if(this.generateWaveform(t,e,i,s,r)){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.smoothedPositions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,this.color);let t=1;0===r.wave_thick&&0===r.wave_dots||(t=4),0!==r.additivewave?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const e=0!==r.wave_dots?this.gl.POINTS:this.gl.LINE_STRIP;for(let i=0;i<t;i++){const t=2;0===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===i?this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,0]):2===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,t/this.texsizeY]):3===i&&this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,t/this.texsizeY]),this.gl.drawArrays(e,0,this.smoothedNumVert)}if(7===Math.floor(r.wave_mode)%8){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.smoothedPositions2,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc);for(let i=0;i<t;i++){const t=2;0===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===i?this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,0]):2===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,t/this.texsizeY]):3===i&&this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,t/this.texsizeY]),this.gl.drawArrays(e,0,this.smoothedNumVert)}}}}}class xt{constructor(t,e,i){this.index=t,this.gl=e;const s=512;this.pointsData=[new Float32Array(s),new Float32Array(s)],this.positions=new Float32Array(1536),this.colors=new Float32Array(2048),this.smoothedPositions=new Float32Array(3069),this.smoothedColors=new Float32Array(4092),this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      uniform float uSize;\n      uniform vec2 thickOffset;\n      in vec3 aPos;\n      in vec4 aColor;\n      out vec4 vColor;\n      void main(void) {\n        vColor = aColor;\n        gl_PointSize = uSize;\n        gl_Position = vec4(aPos + vec3(thickOffset, 0.0), 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      in vec4 vColor;\n      out vec4 fragColor;\n      void main(void) {\n        fragColor = vColor;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor"),this.sizeLoc=this.gl.getUniformLocation(this.shaderProgram,"uSize"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}generateWaveform(t,e,i,s,r,a,o,h){if(0!==o.baseVals.enabled&&t.length>0){let A;if(a.preset.useWASM)A=a.runWaveFrameEquations(this.index,r);else{const t=Object.assign({},a.mdVSWaves[this.index],a.mdVSFrameMapWaves[this.index],a.mdVSQAfterFrame,a.mdVSTWaveInits[this.index],r);A=a.runWaveFrameEquations(this.index,t)}const n=512;Object.prototype.hasOwnProperty.call(A,"samples")?this.samples=A.samples:this.samples=n,this.samples>n&&(this.samples=n),this.samples=Math.floor(this.samples);const l=a.preset.waves[this.index].baseVals,c=Math.floor(A.sep),g=A.scaling,m=A.spectrum,u=A.smoothing,f=l.usedots,d=A.r,p=A.g,_=A.b,E=A.a,b=a.preset.baseVals.wave_scale;if(this.samples-=c,this.samples>=2||0!==f&&this.samples>=1){const r=0!==m,x=(r?.15:.004)*g*b,v=r?i:t,T=r?s:e,S=r?0:Math.floor((n-this.samples)/2-c/2),P=r?0:Math.floor((n-this.samples)/2+c/2),w=r?(n-c)/this.samples:1,I=(.98*u)**.5,R=1-I;this.pointsData[0][0]=v[S],this.pointsData[1][0]=T[P];for(let t=1;t<this.samples;t++){const e=v[Math.floor(t*w+S)],i=T[Math.floor(t*w+P)];this.pointsData[0][t]=e*R+this.pointsData[0][t-1]*I,this.pointsData[1][t]=i*R+this.pointsData[1][t-1]*I}for(let t=this.samples-2;t>=0;t--)this.pointsData[0][t]=this.pointsData[0][t]*R+this.pointsData[0][t+1]*I,this.pointsData[1][t]=this.pointsData[1][t]*R+this.pointsData[1][t+1]*I;for(let t=0;t<this.samples;t++)this.pointsData[0][t]*=x,this.pointsData[1][t]*=x;if(a.preset.useWASM){const t=a.preset.globalPools[`wavePerFrame${this.index}`];for(let e=0;e<this.samples;e++){const i=this.pointsData[0][e],s=this.pointsData[1][e];t.sample.value=e/(this.samples-1),t.value1.value=i,t.value2.value=s,t.x.value=.5+i,t.y.value=.5+s,t.r.value=d,t.g.value=p,t.b.value=_,t.a.value=E,o.point_eqs&&a.preset.waves[this.index].point_eqs();const r=(2*t.x.value-1)*this.invAspectx,A=(-2*t.y.value+1)*this.invAspecty,n=t.r.value,l=t.g.value,c=t.b.value,g=t.a.value;this.positions[3*e+0]=r,this.positions[3*e+1]=A,this.positions[3*e+2]=0,this.colors[4*e+0]=n,this.colors[4*e+1]=l,this.colors[4*e+2]=c,this.colors[4*e+3]=g*h}}else for(let t=0;t<this.samples;t++){const e=this.pointsData[0][t],i=this.pointsData[1][t];A.sample=t/(this.samples-1),A.value1=e,A.value2=i,A.x=.5+e,A.y=.5+i,A.r=d,A.g=p,A.b=_,A.a=E,""!==o.point_eqs&&(A=a.runWavePointEquations(this.index,A));const s=(2*A.x-1)*this.invAspectx,r=(-2*A.y+1)*this.invAspecty,n=A.r,l=A.g,c=A.b,g=A.a;this.positions[3*t+0]=s,this.positions[3*t+1]=r,this.positions[3*t+2]=0,this.colors[4*t+0]=n,this.colors[4*t+1]=l,this.colors[4*t+2]=c,this.colors[4*t+3]=g*h}if(a.preset.useWASM)A.usedots=f,A.thick=l.thick,A.additive=l.additive;else{const t=a.mdVSUserKeysWaves[this.index],e=At.pick(A,t);a.mdVSFrameMapWaves[this.index]=e}return this.mdVSWaveFrame=A,0===f&&Et.smoothWaveAndColor(this.positions,this.colors,this.smoothedPositions,this.smoothedColors,this.samples),!0}}return!1}drawCustomWaveform(t,e,i,s,r,a,o,h){if(h&&this.generateWaveform(e,i,s,r,a,o,h,t)){this.gl.useProgram(this.shaderProgram);const t=0!==this.mdVSWaveFrame.usedots,e=0!==this.mdVSWaveFrame.thick,i=0!==this.mdVSWaveFrame.additive;let s,r,a;t?(s=this.positions,r=this.colors,a=this.samples):(s=this.smoothedPositions,r=this.smoothedColors,a=2*this.samples-1),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation);let o=1;t?e?this.gl.uniform1f(this.sizeLoc,2+(this.texsizeX>=1024?1:0)):this.gl.uniform1f(this.sizeLoc,1+(this.texsizeX>=1024?1:0)):(this.gl.uniform1f(this.sizeLoc,1),e&&(o=4)),i?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const h=t?this.gl.POINTS:this.gl.LINE_STRIP;for(let t=0;t<o;t++){const e=2;0===t?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===t?this.gl.uniform2fv(this.thickOffsetLoc,[e/this.texsizeX,0]):2===t?this.gl.uniform2fv(this.thickOffsetLoc,[0,e/this.texsizeY]):3===t&&this.gl.uniform2fv(this.thickOffsetLoc,[e/this.texsizeX,e/this.texsizeY]),this.gl.drawArrays(h,0,a)}}}}let vt=class{constructor(t,e,i){this.index=t,this.gl=e;this.positions=new Float32Array(309),this.colors=new Float32Array(412),this.uvs=new Float32Array(206),this.borderPositions=new Float32Array(306),this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.uvVertexBuf=this.gl.createBuffer(),this.borderPositionVertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader(),this.createBorderShader(),this.mainSampler=this.gl.createSampler(),e.samplerParameteri(this.mainSampler,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_T,e.REPEAT)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      in vec4 aColor;\n      in vec2 aUv;\n      out vec4 vColor;\n      out vec2 vUv;\n      void main(void) {\n        vColor = aColor;\n        vUv = aUv;\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      uniform sampler2D uTexture;\n      uniform float uTextured;\n      in vec4 vColor;\n      in vec2 vUv;\n      out vec4 fragColor;\n      void main(void) {\n        if (uTextured != 0.0) {\n          fragColor = texture(uTexture, vUv) * vColor;\n        } else {\n          fragColor = vColor;\n        }\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor"),this.aUvLocation=this.gl.getAttribLocation(this.shaderProgram,"aUv"),this.texturedLoc=this.gl.getUniformLocation(this.shaderProgram,"uTextured"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}createBorderShader(){this.borderShaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aBorderPos;\n      uniform vec2 thickOffset;\n      void main(void) {\n        gl_Position = vec4(aBorderPos +\n                            vec3(thickOffset, 0.0), 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 uBorderColor;\n      void main(void) {\n        fragColor = uBorderColor;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.borderShaderProgram,t),this.gl.attachShader(this.borderShaderProgram,e),this.gl.linkProgram(this.borderShaderProgram),this.aBorderPosLoc=this.gl.getAttribLocation(this.borderShaderProgram,"aBorderPos"),this.uBorderColorLoc=this.gl.getUniformLocation(this.borderShaderProgram,"uBorderColor"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}drawCustomShape(t,e,i,s,r){if(0!==s.baseVals.enabled)if(i.preset.useWASM){this.setupShapeBuffers(i.preset.globalPools.perFrame.wrap.value);const s=i.preset.shapes[this.index].baseVals,a=i.preset.globalPools[`shapePerFrame${this.index}`];At.setWasm(a,e,i.globalKeys),i.preset.shapes[this.index].frame_eqs||i.preset.restore_qs(),At.setWasm(a,i.mdVSTShapeInits[this.index],i.ts),i.preset.save_ts(),a.x.value=s.x,a.y.value=s.y,a.rad.value=s.rad,a.ang.value=s.ang,a.r.value=s.r,a.g.value=s.g,a.b.value=s.b,a.a.value=s.a,a.r2.value=s.r2,a.g2.value=s.g2,a.b2.value=s.b2,a.a2.value=s.a2,a.border_r.value=s.border_r,a.border_g.value=s.border_g,a.border_b.value=s.border_b,a.border_a.value=s.border_a,a.thickoutline.value=s.thickoutline,a.textured.value=s.textured,a.tex_zoom.value=s.tex_zoom,a.tex_ang.value=s.tex_ang,a.additive.value=s.additive,i.preset.shapes[this.index].frame_eqs_save();const o=Math.clamp(s.num_inst,1,1024);for(let e=0;e<o;e++){a.instance.value=e,i.preset.shapes[this.index].frame_eqs&&(i.preset.shapes[this.index].frame_eqs_restore(),i.preset.restore_qs(),i.preset.restore_ts(),i.preset.shapes[this.index].frame_eqs());let s=a.sides.value;s=Math.clamp(s,3,100),s=Math.floor(s);const o=a.rad.value,h=a.ang.value,A=2*a.x.value-1,n=-2*a.y.value+1,l=a.r.value,c=a.g.value,g=a.b.value,m=a.a.value,u=a.r2.value,f=a.g2.value,d=a.b2.value,p=a.a2.value,_=a.border_r.value,E=a.border_g.value,b=a.border_b.value,x=a.border_a.value;this.borderColor=[_,E,b,x*t];const v=a.thickoutline.value,T=a.textured.value,S=a.tex_zoom.value,P=a.tex_ang.value,w=a.additive.value,I=this.borderColor[3]>0,R=Math.abs(T)>=1,y=Math.abs(v)>=1,B=Math.abs(w)>=1;this.positions[0]=A,this.positions[1]=n,this.positions[2]=0,this.colors[0]=l,this.colors[1]=c,this.colors[2]=g,this.colors[3]=m*t,R&&(this.uvs[0]=.5,this.uvs[1]=.5);const L=.25*Math.PI;for(let e=1;e<=s+1;e++){const i=2*((e-1)/s)*Math.PI,r=i+h+L;if(this.positions[3*e+0]=A+o*Math.cos(r)*this.aspecty,this.positions[3*e+1]=n+o*Math.sin(r),this.positions[3*e+2]=0,this.colors[4*e+0]=u,this.colors[4*e+1]=f,this.colors[4*e+2]=d,this.colors[4*e+3]=p*t,R){const t=i+P+L;this.uvs[2*e+0]=.5+.5*Math.cos(t)/S*this.aspecty,this.uvs[2*e+1]=.5+.5*Math.sin(t)/S}I&&(this.borderPositions[3*(e-1)+0]=this.positions[3*e+0],this.borderPositions[3*(e-1)+1]=this.positions[3*e+1],this.borderPositions[3*(e-1)+2]=this.positions[3*e+2])}this.drawCustomShapeInstance(r,s,R,I,y,B)}}else{this.setupShapeBuffers(i.mdVSFrame.wrap);let s=Object.assign({},i.mdVSShapes[this.index],i.mdVSFrameMapShapes[this.index],e);""===i.preset.shapes[this.index].frame_eqs_str&&(s=Object.assign(s,i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index]));const a=i.preset.shapes[this.index].baseVals,o=Math.clamp(a.num_inst,1,1024);for(let e=0;e<o;e++){let o;s.instance=e,s.x=a.x,s.y=a.y,s.rad=a.rad,s.ang=a.ang,s.r=a.r,s.g=a.g,s.b=a.b,s.a=a.a,s.r2=a.r2,s.g2=a.g2,s.b2=a.b2,s.a2=a.a2,s.border_r=a.border_r,s.border_g=a.border_g,s.border_b=a.border_b,s.border_a=a.border_a,s.thickoutline=a.thickoutline,s.textured=a.textured,s.tex_zoom=a.tex_zoom,s.tex_ang=a.tex_ang,s.additive=a.additive,""!==i.preset.shapes[this.index].frame_eqs_str?(s=Object.assign(s,i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index]),o=i.runShapeFrameEquations(this.index,s)):o=s;let h=o.sides;h=Math.clamp(h,3,100),h=Math.floor(h);const A=o.rad,n=o.ang,l=2*o.x-1,c=-2*o.y+1,g=o.r,m=o.g,u=o.b,f=o.a,d=o.r2,p=o.g2,_=o.b2,E=o.a2,b=o.border_r,x=o.border_g,v=o.border_b,T=o.border_a;this.borderColor=[b,x,v,T*t];const S=o.thickoutline,P=o.textured,w=o.tex_zoom,I=o.tex_ang,R=o.additive,y=this.borderColor[3]>0,B=Math.abs(P)>=1,L=Math.abs(S)>=1,C=Math.abs(R)>=1;this.positions[0]=l,this.positions[1]=c,this.positions[2]=0,this.colors[0]=g,this.colors[1]=m,this.colors[2]=u,this.colors[3]=f*t,B&&(this.uvs[0]=.5,this.uvs[1]=.5);const U=.25*Math.PI;for(let e=1;e<=h+1;e++){const i=2*((e-1)/h)*Math.PI,s=i+n+U;if(this.positions[3*e+0]=l+A*Math.cos(s)*this.aspecty,this.positions[3*e+1]=c+A*Math.sin(s),this.positions[3*e+2]=0,this.colors[4*e+0]=d,this.colors[4*e+1]=p,this.colors[4*e+2]=_,this.colors[4*e+3]=E*t,B){const t=i+I+U;this.uvs[2*e+0]=.5+.5*Math.cos(t)/w*this.aspecty,this.uvs[2*e+1]=.5+.5*Math.sin(t)/w}y&&(this.borderPositions[3*(e-1)+0]=this.positions[3*e+0],this.borderPositions[3*(e-1)+1]=this.positions[3*e+1],this.borderPositions[3*(e-1)+2]=this.positions[3*e+2])}this.mdVSShapeFrame=o,this.drawCustomShapeInstance(r,h,B,y,L,C)}const h=i.mdVSUserKeysShapes[this.index],A=At.pick(this.mdVSShapeFrame,h);i.mdVSFrameMapShapes[this.index]=A}}setupShapeBuffers(t){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.colors,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.uvs,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.borderPositions,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc);const e=0!==t?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,e),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,e)}drawCustomShapeInstance(t,e,i,s,r,a){if(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.positions,0,3*(e+2)),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.colors,0,4*(e+2)),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),i&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.uvs,0,2*(e+2)),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation)),this.gl.uniform1f(this.texturedLoc,i?1:0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),a?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,e+2),s){this.gl.useProgram(this.borderShaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.borderPositions,0,3*(e+1)),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc),this.gl.uniform4fv(this.uBorderColorLoc,this.borderColor);const t=r?4:1;for(let i=0;i<t;i++){const t=2;0===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===i?this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,0]):2===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,t/this.texsizeY]):3===i&&this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,t/this.texsizeY]),this.gl.drawArrays(this.gl.LINE_STRIP,0,e+1)}}}};class Tt{constructor(t,e={}){this.gl=t,this.positions=new Float32Array(72),this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}updateGlobals(t){this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      void main(void) {\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 u_color;\n      void main(void) {\n        fragColor = u_color;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color")}addTriangle(t,e,i,s){this.positions[t+0]=e[0],this.positions[t+1]=e[1],this.positions[t+2]=e[2],this.positions[t+3]=i[0],this.positions[t+4]=i[1],this.positions[t+5]=i[2],this.positions[t+6]=s[0],this.positions[t+7]=s[1],this.positions[t+8]=s[2]}generateBorder(t,e,i){if(e>0&&t[3]>0){const t=2,s=2,r=t/2,a=s/2,o=i/2,h=e/2+o,A=o*t,n=o*s,l=h*t,c=h*s;let g=[-r+A,-a+c,0],m=[-r+A,a-c,0],u=[-r+l,a-c,0],f=[-r+l,-a+c,0];return this.addTriangle(0,f,m,g),this.addTriangle(9,f,u,m),g=[r-A,-a+c,0],m=[r-A,a-c,0],u=[r-l,a-c,0],f=[r-l,-a+c,0],this.addTriangle(18,g,m,f),this.addTriangle(27,m,u,f),g=[-r+A,-a+n,0],m=[-r+A,c-a,0],u=[r-A,c-a,0],f=[r-A,-a+n,0],this.addTriangle(36,f,m,g),this.addTriangle(45,f,u,m),g=[-r+A,a-n,0],m=[-r+A,a-c,0],u=[r-A,a-c,0],f=[r-A,a-n,0],this.addTriangle(54,g,m,f),this.addTriangle(63,m,u,f),!0}return!1}drawBorder(t,e,i){this.generateBorder(t,e,i)&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,t),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLES,0,this.positions.length/3))}}class St{constructor(t,e){this.gl=t,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.generatePositions(),this.colors=new Float32Array([0,0,0,3/32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}updateGlobals(t){this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.generatePositions()}generatePositions(){const t=.05;this.positions=new Float32Array([0,0,0,-.05*this.aspecty,0,0,0,-.05,0,t*this.aspecty,0,0,0,t,0,-.05*this.aspecty,0,0])}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      in vec4 aColor;\n      out vec4 vColor;\n      void main(void) {\n        vColor = aColor;\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      in vec4 vColor;\n      out vec4 fragColor;\n      void main(void) {\n        fragColor = vColor;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor")}drawDarkenCenter(t){0!==t.darken_center&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.colors,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,this.positions.length/3))}}class Pt{constructor(t,e){this.gl=t,this.maxX=64,this.maxY=48,this.positions=new Float32Array(this.maxX*this.maxY*2*3),this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.mesh_width=e.mesh_width,this.mesh_height=e.mesh_height,this.positionVertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      void main(void) {\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 u_color;\n      void main(void) {\n        fragColor = u_color;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color")}getMotionDir(t,e,i){const s=Math.floor(i*this.mesh_height),r=i*this.mesh_height-s,a=Math.floor(e*this.mesh_width),o=e*this.mesh_width-a,h=a+1,A=s+1,n=this.mesh_width+1;let l,c;return l=t[2*(s*n+a)+0]*(1-o)*(1-r),c=t[2*(s*n+a)+1]*(1-o)*(1-r),l+=t[2*(s*n+h)+0]*o*(1-r),c+=t[2*(s*n+h)+1]*o*(1-r),l+=t[2*(A*n+a)+0]*(1-o)*r,c+=t[2*(A*n+a)+1]*(1-o)*r,l+=t[2*(A*n+h)+0]*o*r,c+=t[2*(A*n+h)+1]*o*r,[l,1-c]}generateMotionVectors(t,e){const i=0===t.bmotionvectorson?0:t.mv_a;let s=Math.floor(t.mv_x),r=Math.floor(t.mv_y);if(i>.001&&s>0&&r>0){let a=t.mv_x-s,o=t.mv_y-r;s>this.maxX&&(s=this.maxX,a=0),r>this.maxY&&(r=this.maxY,o=0);const h=t.mv_dx,A=t.mv_dy,n=t.mv_l,l=1/this.texsizeX;this.numVecVerts=0;for(let t=0;t<r;t++){let i=(t+.25)/(r+o+.25-1);if(i-=A,i>1e-4&&i<.9999)for(let t=0;t<s;t++){let r=(t+.25)/(s+a+.25-1);if(r+=h,r>1e-4&&r<.9999){const t=this.getMotionDir(e,r,i);let s=t[0],a=t[1],o=s-r,h=a-i;o*=n,h*=n;let A=Math.sqrt(o*o+h*h);A<l&&A>1e-8?(A=l/A,o*=A,h*=A):(o=l,o=l),s=r+o,a=i+h;const c=2*r-1,g=2*i-1,m=2*s-1,u=2*a-1;this.positions[3*this.numVecVerts+0]=c,this.positions[3*this.numVecVerts+1]=g,this.positions[3*this.numVecVerts+2]=0,this.positions[3*(this.numVecVerts+1)+0]=m,this.positions[3*(this.numVecVerts+1)+1]=u,this.positions[3*(this.numVecVerts+1)+2]=0,this.numVecVerts+=2}}}if(this.numVecVerts>0)return this.color=[t.mv_r,t.mv_g,t.mv_b,i],!0}return!1}drawMotionVectors(t,e){this.generateMotionVectors(t,e)&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,this.color),this.gl.lineWidth(1),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.LINES,0,this.numVecVerts))}}class wt{constructor(t,e,i,s={}){this.gl=t,this.noise=e,this.image=i,this.rng=mt(),this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions(),this.indexBuf=t.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.warpUvVertexBuf=this.gl.createBuffer(),this.warpColorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader(),this.mainSampler=this.gl.createSampler(),this.mainSamplerFW=this.gl.createSampler(),this.mainSamplerFC=this.gl.createSampler(),this.mainSamplerPW=this.gl.createSampler(),this.mainSamplerPC=this.gl.createSampler(),t.samplerParameteri(this.mainSampler,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}buildPositions(){const t=this.mesh_width,e=this.mesh_height,i=t+1,s=e+1,r=2/t,a=2/e,o=[];for(let t=0;t<s;t++){const e=t*a-1;for(let t=0;t<i;t++){const i=t*r-1;o.push(i,-e,0)}}const h=[];for(let s=0;s<e;s++)for(let e=0;e<t;e++){const t=e+i*s,r=e+i*(s+1),a=e+1+i*(s+1),o=e+1+i*s;h.push(t,r,o),h.push(r,a,o)}this.vertices=new Float32Array(o),this.indices=new Uint16Array(h)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions()}createShader(t=""){let e,i;if(0===t.length)e="ret = texture(sampler_main, uv).rgb * decay;",i="";else{const s=_t.getShaderParts(t);i=s[0],e=s[1]}e=e.replace(/texture2D/g,"texture"),e=e.replace(/texture3D/g,"texture"),this.userTextures=_t.getUserSamplers(i),this.shaderProgram=this.gl.createProgram();const s=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(s,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      in vec2 aWarpUv;\n      in vec4 aWarpColor;\n      out vec2 uv;\n      out vec2 uv_orig;\n      out vec4 vColor;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        uv_orig = aPos * halfmad + halfmad;\n        uv = aWarpUv;\n        vColor = aWarpColor;\n      }\n      `.trim()),this.gl.compileShader(s);const r=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(r,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      precision mediump sampler3D;\n\n      in vec2 uv;\n      in vec2 uv_orig;\n      in vec4 vColor;\n      out vec4 fragColor;\n      uniform sampler2D sampler_main;\n      uniform sampler2D sampler_fw_main;\n      uniform sampler2D sampler_fc_main;\n      uniform sampler2D sampler_pw_main;\n      uniform sampler2D sampler_pc_main;\n      uniform sampler2D sampler_blur1;\n      uniform sampler2D sampler_blur2;\n      uniform sampler2D sampler_blur3;\n      uniform sampler2D sampler_noise_lq;\n      uniform sampler2D sampler_noise_lq_lite;\n      uniform sampler2D sampler_noise_mq;\n      uniform sampler2D sampler_noise_hq;\n      uniform sampler2D sampler_pw_noise_lq;\n      uniform sampler3D sampler_noisevol_lq;\n      uniform sampler3D sampler_noisevol_hq;\n      uniform float time;\n      uniform float decay;\n      uniform vec2 resolution;\n      uniform vec4 aspect;\n      uniform vec4 texsize;\n      uniform vec4 texsize_noise_lq;\n      uniform vec4 texsize_noise_mq;\n      uniform vec4 texsize_noise_hq;\n      uniform vec4 texsize_noise_lq_lite;\n      uniform vec4 texsize_noisevol_lq;\n      uniform vec4 texsize_noisevol_hq;\n\n      uniform float bass;\n      uniform float mid;\n      uniform float treb;\n      uniform float vol;\n      uniform float bass_att;\n      uniform float mid_att;\n      uniform float treb_att;\n      uniform float vol_att;\n\n      uniform float frame;\n      uniform float fps;\n\n      uniform vec4 _qa;\n      uniform vec4 _qb;\n      uniform vec4 _qc;\n      uniform vec4 _qd;\n      uniform vec4 _qe;\n      uniform vec4 _qf;\n      uniform vec4 _qg;\n      uniform vec4 _qh;\n\n      #define q1 _qa.x\n      #define q2 _qa.y\n      #define q3 _qa.z\n      #define q4 _qa.w\n      #define q5 _qb.x\n      #define q6 _qb.y\n      #define q7 _qb.z\n      #define q8 _qb.w\n      #define q9 _qc.x\n      #define q10 _qc.y\n      #define q11 _qc.z\n      #define q12 _qc.w\n      #define q13 _qd.x\n      #define q14 _qd.y\n      #define q15 _qd.z\n      #define q16 _qd.w\n      #define q17 _qe.x\n      #define q18 _qe.y\n      #define q19 _qe.z\n      #define q20 _qe.w\n      #define q21 _qf.x\n      #define q22 _qf.y\n      #define q23 _qf.z\n      #define q24 _qf.w\n      #define q25 _qg.x\n      #define q26 _qg.y\n      #define q27 _qg.z\n      #define q28 _qg.w\n      #define q29 _qh.x\n      #define q30 _qh.y\n      #define q31 _qh.z\n      #define q32 _qh.w\n\n      uniform vec4 slow_roam_cos;\n      uniform vec4 roam_cos;\n      uniform vec4 slow_roam_sin;\n      uniform vec4 roam_sin;\n\n      uniform float blur1_min;\n      uniform float blur1_max;\n      uniform float blur2_min;\n      uniform float blur2_max;\n      uniform float blur3_min;\n      uniform float blur3_max;\n\n      uniform float scale1;\n      uniform float scale2;\n      uniform float scale3;\n      uniform float bias1;\n      uniform float bias2;\n      uniform float bias3;\n\n      uniform vec4 rand_frame;\n      uniform vec4 rand_preset;\n\n      float PI = ${Math.PI};\n\n      ${i}\n\n      void main(void) {\n        vec3 ret;\n        float rad = length(uv_orig - 0.5);\n        float ang = atan(uv_orig.x - 0.5, uv_orig.y - 0.5);\n\n        ${e}\n\n        fragColor = vec4(ret, 1.0) * vColor;\n      }\n      `.trim()),this.gl.compileShader(r),this.gl.attachShader(this.shaderProgram,s),this.gl.attachShader(this.shaderProgram,r),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.warpUvLocation=this.gl.getAttribLocation(this.shaderProgram,"aWarpUv"),this.warpColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aWarpColor"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_main"),this.textureFWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fw_main"),this.textureFCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fc_main"),this.texturePWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_main"),this.texturePCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pc_main"),this.blurTexture1Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur1"),this.blurTexture2Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur2"),this.blurTexture3Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur3"),this.noiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq"),this.noiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_mq"),this.noiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_hq"),this.noiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq_lite"),this.noisePointLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_noise_lq"),this.noiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_lq"),this.noiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_hq"),this.decayLoc=this.gl.getUniformLocation(this.shaderProgram,"decay"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.texsizeNoiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq"),this.texsizeNoiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_mq"),this.texsizeNoiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_hq"),this.texsizeNoiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq_lite"),this.texsizeNoiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_lq"),this.texsizeNoiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_hq"),this.resolutionLoc=this.gl.getUniformLocation(this.shaderProgram,"resolution"),this.aspectLoc=this.gl.getUniformLocation(this.shaderProgram,"aspect"),this.bassLoc=this.gl.getUniformLocation(this.shaderProgram,"bass"),this.midLoc=this.gl.getUniformLocation(this.shaderProgram,"mid"),this.trebLoc=this.gl.getUniformLocation(this.shaderProgram,"treb"),this.volLoc=this.gl.getUniformLocation(this.shaderProgram,"vol"),this.bassAttLoc=this.gl.getUniformLocation(this.shaderProgram,"bass_att"),this.midAttLoc=this.gl.getUniformLocation(this.shaderProgram,"mid_att"),this.trebAttLoc=this.gl.getUniformLocation(this.shaderProgram,"treb_att"),this.volAttLoc=this.gl.getUniformLocation(this.shaderProgram,"vol_att"),this.timeLoc=this.gl.getUniformLocation(this.shaderProgram,"time"),this.frameLoc=this.gl.getUniformLocation(this.shaderProgram,"frame"),this.fpsLoc=this.gl.getUniformLocation(this.shaderProgram,"fps"),this.blur1MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_min"),this.blur1MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_max"),this.blur2MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_min"),this.blur2MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_max"),this.blur3MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_min"),this.blur3MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_max"),this.scale1Loc=this.gl.getUniformLocation(this.shaderProgram,"scale1"),this.scale2Loc=this.gl.getUniformLocation(this.shaderProgram,"scale2"),this.scale3Loc=this.gl.getUniformLocation(this.shaderProgram,"scale3"),this.bias1Loc=this.gl.getUniformLocation(this.shaderProgram,"bias1"),this.bias2Loc=this.gl.getUniformLocation(this.shaderProgram,"bias2"),this.bias3Loc=this.gl.getUniformLocation(this.shaderProgram,"bias3"),this.randPresetLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_preset"),this.randFrameLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_frame"),this.qaLoc=this.gl.getUniformLocation(this.shaderProgram,"_qa"),this.qbLoc=this.gl.getUniformLocation(this.shaderProgram,"_qb"),this.qcLoc=this.gl.getUniformLocation(this.shaderProgram,"_qc"),this.qdLoc=this.gl.getUniformLocation(this.shaderProgram,"_qd"),this.qeLoc=this.gl.getUniformLocation(this.shaderProgram,"_qe"),this.qfLoc=this.gl.getUniformLocation(this.shaderProgram,"_qf"),this.qgLoc=this.gl.getUniformLocation(this.shaderProgram,"_qg"),this.qhLoc=this.gl.getUniformLocation(this.shaderProgram,"_qh"),this.slowRoamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_cos"),this.roamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_cos"),this.slowRoamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_sin"),this.roamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_sin");for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];e.textureLoc=this.gl.getUniformLocation(this.shaderProgram,`sampler_${e.sampler}`)}}updateShader(t){this.createShader(t)}bindBlurVals(t,e){const i=t[0],s=t[1],r=t[2],a=e[0],o=e[1],h=e[2],A=a-i,n=i,l=o-s,c=s,g=h-r,m=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,a),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,o),this.gl.uniform1f(this.blur3MinLoc,r),this.gl.uniform1f(this.blur3MaxLoc,h),this.gl.uniform1f(this.scale1Loc,A),this.gl.uniform1f(this.scale2Loc,l),this.gl.uniform1f(this.scale3Loc,g),this.gl.uniform1f(this.bias1Loc,n),this.gl.uniform1f(this.bias2Loc,c),this.gl.uniform1f(this.bias3Loc,m)}renderQuadTexture(t,e,i,s,r,a,o,h,A,n,l){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.warpUvVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.warpUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.warpUvLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.warpColorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.warpColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.warpColorLocation);const c=0!==h.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,c),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,c),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(1,this.mainSamplerFW),this.gl.uniform1i(this.textureFWLoc,1),this.gl.activeTexture(this.gl.TEXTURE2),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(2,this.mainSamplerFC),this.gl.uniform1i(this.textureFCLoc,2),this.gl.activeTexture(this.gl.TEXTURE3),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(3,this.mainSamplerPW),this.gl.uniform1i(this.texturePWLoc,3),this.gl.activeTexture(this.gl.TEXTURE4),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(4,this.mainSamplerPC),this.gl.uniform1i(this.texturePCLoc,4),this.gl.activeTexture(this.gl.TEXTURE5),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(this.blurTexture1Loc,5),this.gl.activeTexture(this.gl.TEXTURE6),this.gl.bindTexture(this.gl.TEXTURE_2D,s),this.gl.uniform1i(this.blurTexture2Loc,6),this.gl.activeTexture(this.gl.TEXTURE7),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(this.blurTexture3Loc,7),this.gl.activeTexture(this.gl.TEXTURE8),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.uniform1i(this.noiseLQLoc,8),this.gl.activeTexture(this.gl.TEXTURE9),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexMQ),this.gl.uniform1i(this.noiseMQLoc,9),this.gl.activeTexture(this.gl.TEXTURE10),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexHQ),this.gl.uniform1i(this.noiseHQLoc,10),this.gl.activeTexture(this.gl.TEXTURE11),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQLite),this.gl.uniform1i(this.noiseLQLiteLoc,11),this.gl.activeTexture(this.gl.TEXTURE12),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.bindSampler(12,this.noise.noiseTexPointLQ),this.gl.uniform1i(this.noisePointLQLoc,12),this.gl.activeTexture(this.gl.TEXTURE13),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolLQ),this.gl.uniform1i(this.noiseVolLQLoc,13),this.gl.activeTexture(this.gl.TEXTURE14),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolHQ),this.gl.uniform1i(this.noiseVolHQLoc,14);for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];this.gl.activeTexture(this.gl.TEXTURE15+t),this.gl.bindTexture(this.gl.TEXTURE_2D,this.image.getTexture(e.sampler)),this.gl.uniform1i(e.textureLoc,15+t)}this.gl.uniform1f(this.decayLoc,h.decay),this.gl.uniform2fv(this.resolutionLoc,[this.texsizeX,this.texsizeY]),this.gl.uniform4fv(this.aspectLoc,[this.aspectx,this.aspecty,this.invAspectx,this.invAspecty]),this.gl.uniform4fv(this.texsizeLoc,[this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY]),this.gl.uniform4fv(this.texsizeNoiseLQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseMQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseHQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseLQLiteLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolLQLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolHQLoc,[32,32,1/32,1/32]),this.gl.uniform1f(this.bassLoc,h.bass),this.gl.uniform1f(this.midLoc,h.mid),this.gl.uniform1f(this.trebLoc,h.treb),this.gl.uniform1f(this.volLoc,(h.bass+h.mid+h.treb)/3),this.gl.uniform1f(this.bassAttLoc,h.bass_att),this.gl.uniform1f(this.midAttLoc,h.mid_att),this.gl.uniform1f(this.trebAttLoc,h.treb_att),this.gl.uniform1f(this.volAttLoc,(h.bass_att+h.mid_att+h.treb_att)/3),this.gl.uniform1f(this.timeLoc,h.time),this.gl.uniform1f(this.frameLoc,h.frame),this.gl.uniform1f(this.fpsLoc,h.fps),this.gl.uniform4fv(this.randPresetLoc,h.rand_preset),this.gl.uniform4fv(this.randFrameLoc,new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()])),this.gl.uniform4fv(this.qaLoc,new Float32Array([A.q1||0,A.q2||0,A.q3||0,A.q4||0])),this.gl.uniform4fv(this.qbLoc,new Float32Array([A.q5||0,A.q6||0,A.q7||0,A.q8||0])),this.gl.uniform4fv(this.qcLoc,new Float32Array([A.q9||0,A.q10||0,A.q11||0,A.q12||0])),this.gl.uniform4fv(this.qdLoc,new Float32Array([A.q13||0,A.q14||0,A.q15||0,A.q16||0])),this.gl.uniform4fv(this.qeLoc,new Float32Array([A.q17||0,A.q18||0,A.q19||0,A.q20||0])),this.gl.uniform4fv(this.qfLoc,new Float32Array([A.q21||0,A.q22||0,A.q23||0,A.q24||0])),this.gl.uniform4fv(this.qgLoc,new Float32Array([A.q25||0,A.q26||0,A.q27||0,A.q28||0])),this.gl.uniform4fv(this.qhLoc,new Float32Array([A.q29||0,A.q30||0,A.q31||0,A.q32||0])),this.gl.uniform4fv(this.slowRoamCosLoc,[.5+.5*Math.cos(.005*h.time),.5+.5*Math.cos(.008*h.time),.5+.5*Math.cos(.013*h.time),.5+.5*Math.cos(.022*h.time)]),this.gl.uniform4fv(this.roamCosLoc,[.5+.5*Math.cos(.3*h.time),.5+.5*Math.cos(1.3*h.time),.5+.5*Math.cos(5*h.time),.5+.5*Math.cos(20*h.time)]),this.gl.uniform4fv(this.slowRoamSinLoc,[.5+.5*Math.sin(.005*h.time),.5+.5*Math.sin(.008*h.time),.5+.5*Math.sin(.013*h.time),.5+.5*Math.sin(.022*h.time)]),this.gl.uniform4fv(this.roamSinLoc,[.5+.5*Math.sin(.3*h.time),.5+.5*Math.sin(1.3*h.time),.5+.5*Math.sin(5*h.time),.5+.5*Math.sin(20*h.time)]),this.bindBlurVals(a,o),t?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.disable(this.gl.BLEND),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0),t||this.gl.enable(this.gl.BLEND)}}class It{constructor(t,e,i,s={}){this.gl=t,this.noise=e,this.image=i,this.rng=mt(),this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.compWidth=32,this.compHeight=24,this.buildPositions(),this.indexBuf=t.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.compColorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader(),this.mainSampler=this.gl.createSampler(),this.mainSamplerFW=this.gl.createSampler(),this.mainSamplerFC=this.gl.createSampler(),this.mainSamplerPW=this.gl.createSampler(),this.mainSamplerPC=this.gl.createSampler(),t.samplerParameteri(this.mainSampler,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}buildPositions(){const t=this.compWidth,e=this.compHeight,i=t+1,s=e+1,r=2/t,a=2/e,o=[];for(let t=0;t<s;t++){const e=t*a-1;for(let t=0;t<i;t++){const i=t*r-1;o.push(i,-e,0)}}const h=[];for(let s=0;s<e;s++)for(let e=0;e<t;e++){const t=e+i*s,r=e+i*(s+1),a=e+1+i*(s+1),o=e+1+i*s;h.push(t,r,o),h.push(r,a,o)}this.vertices=new Float32Array(o),this.indices=new Uint16Array(h)}updateGlobals(t){this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions()}createShader(t=""){let e,i;if(0===t.length)e="float orient_horiz = mod(echo_orientation, 2.0);\n                        float orient_x = (orient_horiz != 0.0) ? -1.0 : 1.0;\n                        float orient_y = (echo_orientation >= 2.0) ? -1.0 : 1.0;\n                        vec2 uv_echo = ((uv - 0.5) *\n                                        (1.0 / echo_zoom) *\n                                        vec2(orient_x, orient_y)) + 0.5;\n\n                        ret = mix(texture(sampler_main, uv).rgb,\n                                  texture(sampler_main, uv_echo).rgb,\n                                  echo_alpha);\n\n                        ret *= gammaAdj;\n\n                        if(fShader >= 1.0) {\n                          ret *= hue_shader;\n                        } else if(fShader > 0.001) {\n                          ret *= (1.0 - fShader) + (fShader * hue_shader);\n                        }\n\n                        if(brighten != 0) ret = sqrt(ret);\n                        if(darken != 0) ret = ret*ret;\n                        if(solarize != 0) ret = ret * (1.0 - ret) * 4.0;\n                        if(invert != 0) ret = 1.0 - ret;",i="";else{const s=_t.getShaderParts(t);i=s[0],e=s[1]}e=e.replace(/texture2D/g,"texture"),e=e.replace(/texture3D/g,"texture"),this.userTextures=_t.getUserSamplers(i),this.shaderProgram=this.gl.createProgram();const s=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(s,"\n      #version 300 es\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      in vec4 aCompColor;\n      out vec2 vUv;\n      out vec4 vColor;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        vUv = aPos * halfmad + halfmad;\n        vColor = aCompColor;\n      }\n      ".trim()),this.gl.compileShader(s);const r=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(r,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      precision mediump sampler3D;\n\n      vec3 lum(vec3 v){\n          return vec3(dot(v, vec3(0.32,0.49,0.29)));\n      }\n\n      in vec2 vUv;\n      in vec4 vColor;\n      out vec4 fragColor;\n      uniform sampler2D sampler_main;\n      uniform sampler2D sampler_fw_main;\n      uniform sampler2D sampler_fc_main;\n      uniform sampler2D sampler_pw_main;\n      uniform sampler2D sampler_pc_main;\n      uniform sampler2D sampler_blur1;\n      uniform sampler2D sampler_blur2;\n      uniform sampler2D sampler_blur3;\n      uniform sampler2D sampler_noise_lq;\n      uniform sampler2D sampler_noise_lq_lite;\n      uniform sampler2D sampler_noise_mq;\n      uniform sampler2D sampler_noise_hq;\n      uniform sampler2D sampler_pw_noise_lq;\n      uniform sampler3D sampler_noisevol_lq;\n      uniform sampler3D sampler_noisevol_hq;\n\n      uniform float time;\n      uniform float gammaAdj;\n      uniform float echo_zoom;\n      uniform float echo_alpha;\n      uniform float echo_orientation;\n      uniform int invert;\n      uniform int brighten;\n      uniform int darken;\n      uniform int solarize;\n      uniform vec2 resolution;\n      uniform vec4 aspect;\n      uniform vec4 texsize;\n      uniform vec4 texsize_noise_lq;\n      uniform vec4 texsize_noise_mq;\n      uniform vec4 texsize_noise_hq;\n      uniform vec4 texsize_noise_lq_lite;\n      uniform vec4 texsize_noisevol_lq;\n      uniform vec4 texsize_noisevol_hq;\n\n      uniform float bass;\n      uniform float mid;\n      uniform float treb;\n      uniform float vol;\n      uniform float bass_att;\n      uniform float mid_att;\n      uniform float treb_att;\n      uniform float vol_att;\n\n      uniform float frame;\n      uniform float fps;\n\n      uniform vec4 _qa;\n      uniform vec4 _qb;\n      uniform vec4 _qc;\n      uniform vec4 _qd;\n      uniform vec4 _qe;\n      uniform vec4 _qf;\n      uniform vec4 _qg;\n      uniform vec4 _qh;\n\n      #define q1 _qa.x\n      #define q2 _qa.y\n      #define q3 _qa.z\n      #define q4 _qa.w\n      #define q5 _qb.x\n      #define q6 _qb.y\n      #define q7 _qb.z\n      #define q8 _qb.w\n      #define q9 _qc.x\n      #define q10 _qc.y\n      #define q11 _qc.z\n      #define q12 _qc.w\n      #define q13 _qd.x\n      #define q14 _qd.y\n      #define q15 _qd.z\n      #define q16 _qd.w\n      #define q17 _qe.x\n      #define q18 _qe.y\n      #define q19 _qe.z\n      #define q20 _qe.w\n      #define q21 _qf.x\n      #define q22 _qf.y\n      #define q23 _qf.z\n      #define q24 _qf.w\n      #define q25 _qg.x\n      #define q26 _qg.y\n      #define q27 _qg.z\n      #define q28 _qg.w\n      #define q29 _qh.x\n      #define q30 _qh.y\n      #define q31 _qh.z\n      #define q32 _qh.w\n\n      uniform vec4 slow_roam_cos;\n      uniform vec4 roam_cos;\n      uniform vec4 slow_roam_sin;\n      uniform vec4 roam_sin;\n\n      uniform float blur1_min;\n      uniform float blur1_max;\n      uniform float blur2_min;\n      uniform float blur2_max;\n      uniform float blur3_min;\n      uniform float blur3_max;\n\n      uniform float scale1;\n      uniform float scale2;\n      uniform float scale3;\n      uniform float bias1;\n      uniform float bias2;\n      uniform float bias3;\n\n      uniform vec4 rand_frame;\n      uniform vec4 rand_preset;\n\n      uniform float fShader;\n\n      float PI = ${Math.PI};\n\n      ${i}\n\n      void main(void) {\n        vec3 ret;\n        vec2 uv = vUv;\n        vec2 uv_orig = vUv;\n        uv.y = 1.0 - uv.y;\n        uv_orig.y = 1.0 - uv_orig.y;\n        float rad = length(uv - 0.5);\n        float ang = atan(uv.x - 0.5, uv.y - 0.5);\n        vec3 hue_shader = vColor.rgb;\n\n        ${e}\n\n        fragColor = vec4(ret, vColor.a);\n      }\n      `.trim()),this.gl.compileShader(r),this.gl.attachShader(this.shaderProgram,s),this.gl.attachShader(this.shaderProgram,r),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.compColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aCompColor"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_main"),this.textureFWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fw_main"),this.textureFCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fc_main"),this.texturePWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_main"),this.texturePCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pc_main"),this.blurTexture1Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur1"),this.blurTexture2Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur2"),this.blurTexture3Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur3"),this.noiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq"),this.noiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_mq"),this.noiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_hq"),this.noiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq_lite"),this.noisePointLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_noise_lq"),this.noiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_lq"),this.noiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_hq"),this.timeLoc=this.gl.getUniformLocation(this.shaderProgram,"time"),this.gammaAdjLoc=this.gl.getUniformLocation(this.shaderProgram,"gammaAdj"),this.echoZoomLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_zoom"),this.echoAlphaLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_alpha"),this.echoOrientationLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_orientation"),this.invertLoc=this.gl.getUniformLocation(this.shaderProgram,"invert"),this.brightenLoc=this.gl.getUniformLocation(this.shaderProgram,"brighten"),this.darkenLoc=this.gl.getUniformLocation(this.shaderProgram,"darken"),this.solarizeLoc=this.gl.getUniformLocation(this.shaderProgram,"solarize"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.texsizeNoiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq"),this.texsizeNoiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_mq"),this.texsizeNoiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_hq"),this.texsizeNoiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq_lite"),this.texsizeNoiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_lq"),this.texsizeNoiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_hq"),this.resolutionLoc=this.gl.getUniformLocation(this.shaderProgram,"resolution"),this.aspectLoc=this.gl.getUniformLocation(this.shaderProgram,"aspect"),this.bassLoc=this.gl.getUniformLocation(this.shaderProgram,"bass"),this.midLoc=this.gl.getUniformLocation(this.shaderProgram,"mid"),this.trebLoc=this.gl.getUniformLocation(this.shaderProgram,"treb"),this.volLoc=this.gl.getUniformLocation(this.shaderProgram,"vol"),this.bassAttLoc=this.gl.getUniformLocation(this.shaderProgram,"bass_att"),this.midAttLoc=this.gl.getUniformLocation(this.shaderProgram,"mid_att"),this.trebAttLoc=this.gl.getUniformLocation(this.shaderProgram,"treb_att"),this.volAttLoc=this.gl.getUniformLocation(this.shaderProgram,"vol_att"),this.frameLoc=this.gl.getUniformLocation(this.shaderProgram,"frame"),this.fpsLoc=this.gl.getUniformLocation(this.shaderProgram,"fps"),this.blur1MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_min"),this.blur1MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_max"),this.blur2MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_min"),this.blur2MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_max"),this.blur3MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_min"),this.blur3MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_max"),this.scale1Loc=this.gl.getUniformLocation(this.shaderProgram,"scale1"),this.scale2Loc=this.gl.getUniformLocation(this.shaderProgram,"scale2"),this.scale3Loc=this.gl.getUniformLocation(this.shaderProgram,"scale3"),this.bias1Loc=this.gl.getUniformLocation(this.shaderProgram,"bias1"),this.bias2Loc=this.gl.getUniformLocation(this.shaderProgram,"bias2"),this.bias3Loc=this.gl.getUniformLocation(this.shaderProgram,"bias3"),this.randPresetLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_preset"),this.randFrameLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_frame"),this.fShaderLoc=this.gl.getUniformLocation(this.shaderProgram,"fShader"),this.qaLoc=this.gl.getUniformLocation(this.shaderProgram,"_qa"),this.qbLoc=this.gl.getUniformLocation(this.shaderProgram,"_qb"),this.qcLoc=this.gl.getUniformLocation(this.shaderProgram,"_qc"),this.qdLoc=this.gl.getUniformLocation(this.shaderProgram,"_qd"),this.qeLoc=this.gl.getUniformLocation(this.shaderProgram,"_qe"),this.qfLoc=this.gl.getUniformLocation(this.shaderProgram,"_qf"),this.qgLoc=this.gl.getUniformLocation(this.shaderProgram,"_qg"),this.qhLoc=this.gl.getUniformLocation(this.shaderProgram,"_qh"),this.slowRoamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_cos"),this.roamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_cos"),this.slowRoamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_sin"),this.roamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_sin");for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];e.textureLoc=this.gl.getUniformLocation(this.shaderProgram,`sampler_${e.sampler}`)}}updateShader(t){this.createShader(t)}bindBlurVals(t,e){const i=t[0],s=t[1],r=t[2],a=e[0],o=e[1],h=e[2],A=a-i,n=i,l=o-s,c=s,g=h-r,m=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,a),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,o),this.gl.uniform1f(this.blur3MinLoc,r),this.gl.uniform1f(this.blur3MaxLoc,h),this.gl.uniform1f(this.scale1Loc,A),this.gl.uniform1f(this.scale2Loc,l),this.gl.uniform1f(this.scale3Loc,g),this.gl.uniform1f(this.bias1Loc,n),this.gl.uniform1f(this.bias2Loc,c),this.gl.uniform1f(this.bias3Loc,m)}static generateHueBase(t){const e=new Float32Array([1,1,1,1,1,1,1,1,1,1,1,1]);for(let i=0;i<4;i++){e[3*i+0]=.6+.3*Math.sin(30*t.time*.0143+3+21*i+t.rand_start[3]),e[3*i+1]=.6+.3*Math.sin(30*t.time*.0107+1+13*i+t.rand_start[1]),e[3*i+2]=.6+.3*Math.sin(30*t.time*.0129+6+9*i+t.rand_start[2]);const s=Math.max(e[3*i],e[3*i+1],e[3*i+2]);for(let t=0;t<3;t++)e[3*i+t]=e[3*i+t]/s,e[3*i+t]=.5+.5*e[3*i+t]}return e}generateCompColors(t,e,i){const s=It.generateHueBase(e),r=this.compWidth+1,a=this.compHeight+1,o=new Float32Array(r*a*4);let h=0;for(let e=0;e<a;e++)for(let a=0;a<r;a++){let r=a/this.compWidth,A=e/this.compHeight;const n=[1,1,1];for(let t=0;t<3;t++)n[t]=s[0+t]*r*A+s[3+t]*(1-r)*A+s[6+t]*r*(1-A)+s[9+t]*(1-r)*(1-A);let l=1;if(t){r*=this.mesh_width+1,A*=this.mesh_height+1,r=Math.clamp(r,0,this.mesh_width-1),A=Math.clamp(A,0,this.mesh_height-1);const t=Math.floor(r),e=Math.floor(A),s=r-t,a=A-e;l=i[4*(e*(this.mesh_width+1)+t)+3]*(1-s)*(1-a)+i[4*(e*(this.mesh_width+1)+(t+1))+3]*s*(1-a)+i[4*((e+1)*(this.mesh_width+1)+t)+3]*(1-s)*a+i[4*((e+1)*(this.mesh_width+1)+(t+1))+3]*s*a}o[h+0]=n[0],o[h+1]=n[1],o[h+2]=n[2],o[h+3]=l,h+=4}return o}renderQuadTexture(t,e,i,s,r,a,o,h,A,n){const l=this.generateCompColors(t,h,n);this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.compColorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.compColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.compColorLocation);const c=0!==h.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,c),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,c),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(1,this.mainSamplerFW),this.gl.uniform1i(this.textureFWLoc,1),this.gl.activeTexture(this.gl.TEXTURE2),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(2,this.mainSamplerFC),this.gl.uniform1i(this.textureFCLoc,2),this.gl.activeTexture(this.gl.TEXTURE3),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(3,this.mainSamplerPW),this.gl.uniform1i(this.texturePWLoc,3),this.gl.activeTexture(this.gl.TEXTURE4),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(4,this.mainSamplerPC),this.gl.uniform1i(this.texturePCLoc,4),this.gl.activeTexture(this.gl.TEXTURE5),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(this.blurTexture1Loc,5),this.gl.activeTexture(this.gl.TEXTURE6),this.gl.bindTexture(this.gl.TEXTURE_2D,s),this.gl.uniform1i(this.blurTexture2Loc,6),this.gl.activeTexture(this.gl.TEXTURE7),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(this.blurTexture3Loc,7),this.gl.activeTexture(this.gl.TEXTURE8),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.uniform1i(this.noiseLQLoc,8),this.gl.activeTexture(this.gl.TEXTURE9),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexMQ),this.gl.uniform1i(this.noiseMQLoc,9),this.gl.activeTexture(this.gl.TEXTURE10),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexHQ),this.gl.uniform1i(this.noiseHQLoc,10),this.gl.activeTexture(this.gl.TEXTURE11),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQLite),this.gl.uniform1i(this.noiseLQLiteLoc,11),this.gl.activeTexture(this.gl.TEXTURE12),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.bindSampler(12,this.noise.noiseTexPointLQ),this.gl.uniform1i(this.noisePointLQLoc,12),this.gl.activeTexture(this.gl.TEXTURE13),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolLQ),this.gl.uniform1i(this.noiseVolLQLoc,13),this.gl.activeTexture(this.gl.TEXTURE14),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolHQ),this.gl.uniform1i(this.noiseVolHQLoc,14);for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];this.gl.activeTexture(this.gl.TEXTURE15+t),this.gl.bindTexture(this.gl.TEXTURE_2D,this.image.getTexture(e.sampler)),this.gl.uniform1i(e.textureLoc,15+t)}this.gl.uniform1f(this.timeLoc,h.time),this.gl.uniform1f(this.gammaAdjLoc,h.gammaadj),this.gl.uniform1f(this.echoZoomLoc,h.echo_zoom),this.gl.uniform1f(this.echoAlphaLoc,h.echo_alpha),this.gl.uniform1f(this.echoOrientationLoc,h.echo_orient),this.gl.uniform1i(this.invertLoc,h.invert),this.gl.uniform1i(this.brightenLoc,h.brighten),this.gl.uniform1i(this.darkenLoc,h.darken),this.gl.uniform1i(this.solarizeLoc,h.solarize),this.gl.uniform2fv(this.resolutionLoc,[this.texsizeX,this.texsizeY]),this.gl.uniform4fv(this.aspectLoc,[this.aspectx,this.aspecty,this.invAspectx,this.invAspecty]),this.gl.uniform4fv(this.texsizeLoc,new Float32Array([this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY])),this.gl.uniform4fv(this.texsizeNoiseLQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseMQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseHQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseLQLiteLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolLQLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolHQLoc,[32,32,1/32,1/32]),this.gl.uniform1f(this.bassLoc,h.bass),this.gl.uniform1f(this.midLoc,h.mid),this.gl.uniform1f(this.trebLoc,h.treb),this.gl.uniform1f(this.volLoc,(h.bass+h.mid+h.treb)/3),this.gl.uniform1f(this.bassAttLoc,h.bass_att),this.gl.uniform1f(this.midAttLoc,h.mid_att),this.gl.uniform1f(this.trebAttLoc,h.treb_att),this.gl.uniform1f(this.volAttLoc,(h.bass_att+h.mid_att+h.treb_att)/3),this.gl.uniform1f(this.frameLoc,h.frame),this.gl.uniform1f(this.fpsLoc,h.fps),this.gl.uniform4fv(this.randPresetLoc,h.rand_preset),this.gl.uniform4fv(this.randFrameLoc,new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()])),this.gl.uniform1f(this.fShaderLoc,h.fshader),this.gl.uniform4fv(this.qaLoc,new Float32Array([A.q1||0,A.q2||0,A.q3||0,A.q4||0])),this.gl.uniform4fv(this.qbLoc,new Float32Array([A.q5||0,A.q6||0,A.q7||0,A.q8||0])),this.gl.uniform4fv(this.qcLoc,new Float32Array([A.q9||0,A.q10||0,A.q11||0,A.q12||0])),this.gl.uniform4fv(this.qdLoc,new Float32Array([A.q13||0,A.q14||0,A.q15||0,A.q16||0])),this.gl.uniform4fv(this.qeLoc,new Float32Array([A.q17||0,A.q18||0,A.q19||0,A.q20||0])),this.gl.uniform4fv(this.qfLoc,new Float32Array([A.q21||0,A.q22||0,A.q23||0,A.q24||0])),this.gl.uniform4fv(this.qgLoc,new Float32Array([A.q25||0,A.q26||0,A.q27||0,A.q28||0])),this.gl.uniform4fv(this.qhLoc,new Float32Array([A.q29||0,A.q30||0,A.q31||0,A.q32||0])),this.gl.uniform4fv(this.slowRoamCosLoc,[.5+.5*Math.cos(.005*h.time),.5+.5*Math.cos(.008*h.time),.5+.5*Math.cos(.013*h.time),.5+.5*Math.cos(.022*h.time)]),this.gl.uniform4fv(this.roamCosLoc,[.5+.5*Math.cos(.3*h.time),.5+.5*Math.cos(1.3*h.time),.5+.5*Math.cos(5*h.time),.5+.5*Math.cos(20*h.time)]),this.gl.uniform4fv(this.slowRoamSinLoc,[.5+.5*Math.sin(.005*h.time),.5+.5*Math.sin(.008*h.time),.5+.5*Math.sin(.013*h.time),.5+.5*Math.sin(.022*h.time)]),this.gl.uniform4fv(this.roamSinLoc,[.5+.5*Math.sin(.3*h.time),.5+.5*Math.sin(1.3*h.time),.5+.5*Math.sin(5*h.time),.5+.5*Math.sin(20*h.time)]),this.bindBlurVals(a,o),t?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.disable(this.gl.BLEND),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0),t||this.gl.enable(this.gl.BLEND)}}class Rt{constructor(t,e){this.gl=t,this.textureRatio=e.textureRatio,this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.useFXAA()?this.createFXAAShader():this.createShader()}useFXAA(){return this.textureRatio<=1}updateGlobals(t){this.textureRatio=t.textureRatio,this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.gl.deleteProgram(this.shaderProgram),this.useFXAA()?this.createFXAAShader():this.createShader()}createFXAAShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       out vec2 v_rgbM;\n       out vec2 v_rgbNW;\n       out vec2 v_rgbNE;\n       out vec2 v_rgbSW;\n       out vec2 v_rgbSE;\n       uniform vec4 texsize;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n\n         v_rgbM = aPos * halfmad + halfmad;\n         v_rgbNW = v_rgbM + (vec2(-1.0, -1.0) * texsize.zx);\n         v_rgbNE = v_rgbM + (vec2(1.0, -1.0) * texsize.zx);\n         v_rgbSW = v_rgbM + (vec2(-1.0, 1.0) * texsize.zx);\n         v_rgbSE = v_rgbM + (vec2(1.0, 1.0) * texsize.zx);\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 v_rgbM;\n       in vec2 v_rgbNW;\n       in vec2 v_rgbNE;\n       in vec2 v_rgbSW;\n       in vec2 v_rgbSE;\n       out vec4 fragColor;\n       uniform vec4 texsize;\n       uniform sampler2D uTexture;\n\n       #ifndef FXAA_REDUCE_MIN\n         #define FXAA_REDUCE_MIN   (1.0/ 128.0)\n       #endif\n       #ifndef FXAA_REDUCE_MUL\n         #define FXAA_REDUCE_MUL   (1.0 / 8.0)\n       #endif\n       #ifndef FXAA_SPAN_MAX\n         #define FXAA_SPAN_MAX     8.0\n       #endif\n\n       void main(void) {\n         vec4 color;\n         vec3 rgbNW = textureLod(uTexture, v_rgbNW, 0.0).xyz;\n         vec3 rgbNE = textureLod(uTexture, v_rgbNE, 0.0).xyz;\n         vec3 rgbSW = textureLod(uTexture, v_rgbSW, 0.0).xyz;\n         vec3 rgbSE = textureLod(uTexture, v_rgbSE, 0.0).xyz;\n         vec3 rgbM  = textureLod(uTexture, v_rgbM, 0.0).xyz;\n         vec3 luma = vec3(0.299, 0.587, 0.114);\n         float lumaNW = dot(rgbNW, luma);\n         float lumaNE = dot(rgbNE, luma);\n         float lumaSW = dot(rgbSW, luma);\n         float lumaSE = dot(rgbSE, luma);\n         float lumaM  = dot(rgbM,  luma);\n         float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n         float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n         mediump vec2 dir;\n         dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n         dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n         float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n                               (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n         float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n         dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n                   max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n                   dir * rcpDirMin)) * texsize.zw;\n\n         vec3 rgbA = 0.5 * (\n             textureLod(uTexture, v_rgbM + dir * (1.0 / 3.0 - 0.5), 0.0).xyz +\n             textureLod(uTexture, v_rgbM + dir * (2.0 / 3.0 - 0.5), 0.0).xyz);\n         vec3 rgbB = rgbA * 0.5 + 0.25 * (\n             textureLod(uTexture, v_rgbM + dir * -0.5, 0.0).xyz +\n             textureLod(uTexture, v_rgbM + dir * 0.5, 0.0).xyz);\n\n         float lumaB = dot(rgbB, luma);\n         if ((lumaB < lumaMin) || (lumaB > lumaMax))\n           color = vec4(rgbA, 1.0);\n         else\n           color = vec4(rgbB, 1.0);\n\n         fragColor = color;\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize")}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       out vec2 uv;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n         uv = aPos * halfmad + halfmad;\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n\n       void main(void) {\n         fragColor = vec4(texture(uTexture, uv).rgb, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}renderQuadTexture(t){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0),this.useFXAA()&&this.gl.uniform4fv(this.texsizeLoc,new Float32Array([this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY])),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class yt{constructor(t){this.gl=t,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       out vec2 uv;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n         uv = aPos * halfmad + halfmad;\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n\n       void main(void) {\n         fragColor = vec4(texture(uTexture, uv).rgb, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}renderQuadTexture(t){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.uniform1i(this.textureLoc,0),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class Bt{constructor(t,e){this.gl=t,this.blurLevel=e;const i=[4,3.8,3.5,2.9,1.9,1.2,.7,.3],s=i[0]+i[1]+i[2]+i[3],r=i[4]+i[5]+i[6]+i[7],a=0+(i[2]+i[3])/s*2,o=2+(i[6]+i[7])/r*2;this.wds=new Float32Array([s,r,a,o]),this.wDiv=1/(2*(s+r)),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      out vec2 uv;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        uv = aPos * halfmad + halfmad;\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n       uniform vec4 texsize;\n       uniform float ed1;\n       uniform float ed2;\n       uniform float ed3;\n       uniform vec4 wds;\n       uniform float wdiv;\n\n       void main(void) {\n         float w1 = wds[0];\n         float w2 = wds[1];\n         float d1 = wds[2];\n         float d2 = wds[3];\n\n         vec2 uv2 = uv.xy;\n\n         vec3 blur =\n           ( texture(uTexture, uv2 + vec2(0.0, d1 * texsize.w) ).xyz\n           + texture(uTexture, uv2 + vec2(0.0,-d1 * texsize.w) ).xyz) * w1 +\n           ( texture(uTexture, uv2 + vec2(0.0, d2 * texsize.w) ).xyz\n           + texture(uTexture, uv2 + vec2(0.0,-d2 * texsize.w) ).xyz) * w2;\n\n         blur.xyz *= wdiv;\n\n         float t = min(min(uv.x, uv.y), 1.0 - max(uv.x, uv.y));\n         t = sqrt(t);\n         t = ed1 + ed2 * clamp(t * ed3, 0.0, 1.0);\n         blur.xyz *= t;\n\n         fragColor = vec4(blur, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLocation=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.ed1Loc=this.gl.getUniformLocation(this.shaderProgram,"ed1"),this.ed2Loc=this.gl.getUniformLocation(this.shaderProgram,"ed2"),this.ed3Loc=this.gl.getUniformLocation(this.shaderProgram,"ed3"),this.wdsLocation=this.gl.getUniformLocation(this.shaderProgram,"wds"),this.wdivLoc=this.gl.getUniformLocation(this.shaderProgram,"wdiv")}renderQuadTexture(t,e,i){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0);const s=0===this.blurLevel?e.b1ed:0;this.gl.uniform4fv(this.texsizeLocation,[i[0],i[1],1/i[0],1/i[1]]),this.gl.uniform1f(this.ed1Loc,1-s),this.gl.uniform1f(this.ed2Loc,s),this.gl.uniform1f(this.ed3Loc,5),this.gl.uniform4fv(this.wdsLocation,this.wds),this.gl.uniform1f(this.wdivLoc,this.wDiv),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class Lt{constructor(t,e){this.gl=t,this.blurLevel=e;const i=[4,3.8,3.5,2.9,1.9,1.2,.7,.3],s=i[0]+i[1],r=i[2]+i[3],a=i[4]+i[5],o=i[6]+i[7],h=0+2*i[1]/s,A=2+2*i[3]/r,n=4+2*i[5]/a,l=6+2*i[7]/o;this.ws=new Float32Array([s,r,a,o]),this.ds=new Float32Array([h,A,n,l]),this.wDiv=.5/(s+r+a+o),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      out vec2 uv;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        uv = aPos * halfmad + halfmad;\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n       uniform vec4 texsize;\n       uniform float scale;\n       uniform float bias;\n       uniform vec4 ws;\n       uniform vec4 ds;\n       uniform float wdiv;\n\n       void main(void) {\n         float w1 = ws[0];\n         float w2 = ws[1];\n         float w3 = ws[2];\n         float w4 = ws[3];\n         float d1 = ds[0];\n         float d2 = ds[1];\n         float d3 = ds[2];\n         float d4 = ds[3];\n\n         vec2 uv2 = uv.xy;\n\n         vec3 blur =\n           ( texture(uTexture, uv2 + vec2( d1 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d1 * texsize.z,0.0) ).xyz) * w1 +\n           ( texture(uTexture, uv2 + vec2( d2 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d2 * texsize.z,0.0) ).xyz) * w2 +\n           ( texture(uTexture, uv2 + vec2( d3 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d3 * texsize.z,0.0) ).xyz) * w3 +\n           ( texture(uTexture, uv2 + vec2( d4 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d4 * texsize.z,0.0) ).xyz) * w4;\n\n         blur.xyz *= wdiv;\n         blur.xyz = blur.xyz * scale + bias;\n\n         fragColor = vec4(blur, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLocation=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.scaleLoc=this.gl.getUniformLocation(this.shaderProgram,"scale"),this.biasLoc=this.gl.getUniformLocation(this.shaderProgram,"bias"),this.wsLoc=this.gl.getUniformLocation(this.shaderProgram,"ws"),this.dsLocation=this.gl.getUniformLocation(this.shaderProgram,"ds"),this.wdivLoc=this.gl.getUniformLocation(this.shaderProgram,"wdiv")}getScaleAndBias(t,e){const i=[1,1,1],s=[0,0,0];let r,a;return i[0]=1/(e[0]-t[0]),s[0]=-t[0]*i[0],r=(t[1]-t[0])/(e[0]-t[0]),a=(e[1]-t[0])/(e[0]-t[0]),i[1]=1/(a-r),s[1]=-r*i[1],r=(t[2]-t[1])/(e[1]-t[1]),a=(e[2]-t[1])/(e[1]-t[1]),i[2]=1/(a-r),s[2]=-r*i[2],{scale:i[this.blurLevel],bias:s[this.blurLevel]}}renderQuadTexture(t,e,i,s,r){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0);const{scale:a,bias:o}=this.getScaleAndBias(i,s);this.gl.uniform4fv(this.texsizeLocation,[r[0],r[1],1/r[0],1/r[1]]),this.gl.uniform1f(this.scaleLoc,a),this.gl.uniform1f(this.biasLoc,o),this.gl.uniform4fv(this.wsLoc,this.ws),this.gl.uniform4fv(this.dsLocation,this.ds),this.gl.uniform1f(this.wdivLoc,this.wDiv),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class Ct{constructor(t,e,i,s={}){this.blurLevel=t,this.blurRatios=e,this.gl=i,this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.blurHorizontalFrameBuffer=this.gl.createFramebuffer(),this.blurVerticalFrameBuffer=this.gl.createFramebuffer(),this.blurHorizontalTexture=this.gl.createTexture(),this.blurVerticalTexture=this.gl.createTexture(),this.setupFrameBufferTextures(),this.blurHorizontal=new Lt(i,this.blurLevel,s),this.blurVertical=new Bt(i,this.blurLevel,s)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.setupFrameBufferTextures()}getTextureSize(t){let e=Math.max(this.texsizeX*t,16);e=16*Math.floor((e+3)/16);let i=Math.max(this.texsizeY*t,16);return i=4*Math.floor((i+3)/4),[e,i]}setupFrameBufferTextures(){const t=this.blurLevel>0?this.blurRatios[this.blurLevel-1]:[1,1],e=this.blurRatios[this.blurLevel],i=this.getTextureSize(t[1]),s=this.getTextureSize(e[0]);this.bindFrameBufferTexture(this.blurHorizontalFrameBuffer,this.blurHorizontalTexture,s);const r=s,a=this.getTextureSize(e[1]);this.bindFrameBufferTexture(this.blurVerticalFrameBuffer,this.blurVerticalTexture,a),this.horizontalTexsizes=[i,s],this.verticalTexsizes=[r,a]}bindFrambufferAndSetViewport(t,e){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.viewport(0,0,e[0],e[1])}bindFrameBufferTexture(t,e,i){if(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i[0],i[1],0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(i[0]*i[1]*4)),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e,0)}renderBlurTexture(t,e,i,s){this.bindFrambufferAndSetViewport(this.blurHorizontalFrameBuffer,this.horizontalTexsizes[1]),this.blurHorizontal.renderQuadTexture(t,e,i,s,this.horizontalTexsizes[0]),this.gl.bindTexture(this.gl.TEXTURE_2D,this.blurHorizontalTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(this.blurVerticalFrameBuffer,this.verticalTexsizes[1]),this.blurVertical.renderQuadTexture(this.blurHorizontalTexture,e,this.verticalTexsizes[0]),this.gl.bindTexture(this.gl.TEXTURE_2D,this.blurVerticalTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D)}}class Ut{constructor(t){this.gl=t,this.randomFn=mt().random,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.noiseTexLQ=this.gl.createTexture(),this.noiseTexLQLite=this.gl.createTexture(),this.noiseTexMQ=this.gl.createTexture(),this.noiseTexHQ=this.gl.createTexture(),this.noiseTexVolLQ=this.gl.createTexture(),this.noiseTexVolHQ=this.gl.createTexture(),this.nTexArrLQ=Ut.createNoiseTex(256,1,this.randomFn),this.nTexArrLQLite=Ut.createNoiseTex(32,1,this.randomFn),this.nTexArrMQ=Ut.createNoiseTex(256,4,this.randomFn),this.nTexArrHQ=Ut.createNoiseTex(256,8,this.randomFn),this.nTexArrVolLQ=Ut.createNoiseVolTex(32,1,this.randomFn),this.nTexArrVolHQ=Ut.createNoiseVolTex(32,4,this.randomFn),this.bindTexture(this.noiseTexLQ,this.nTexArrLQ,256,256),this.bindTexture(this.noiseTexLQLite,this.nTexArrLQLite,32,32),this.bindTexture(this.noiseTexMQ,this.nTexArrMQ,256,256),this.bindTexture(this.noiseTexHQ,this.nTexArrHQ,256,256),this.bindTexture3D(this.noiseTexVolLQ,this.nTexArrVolLQ,32,32,32),this.bindTexture3D(this.noiseTexVolHQ,this.nTexArrVolHQ,32,32,32),this.noiseTexPointLQ=this.gl.createSampler(),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_WRAP_T,t.REPEAT)}bindTexture(t,e,i,s){if(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i,s,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}}bindTexture3D(t,e,i,s,r){if(this.gl.bindTexture(this.gl.TEXTURE_3D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage3D(this.gl.TEXTURE_3D,0,this.gl.RGBA,i,s,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_3D),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_R,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_3D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}}static fCubicInterpolate(t,e,i,s,r){const a=r*r,o=s-i-t+e;return o*(r*a)+(t-e-o)*a+(i-t)*r+e}static dwCubicInterpolate(t,e,i,s,r){const a=[];for(let o=0;o<4;o++){let h=Ut.fCubicInterpolate(t[o]/255,e[o]/255,i[o]/255,s[o]/255,r);h=Math.clamp(h,0,1),a[o]=255*h}return a}static createNoiseVolTex(t,e,i){const s=t*t*t,r=new Uint8Array(4*s),a=e>1?216:256,o=.5*a;for(let t=0;t<s;t++)r[4*t+0]=Math.floor(i()*a+o),r[4*t+1]=Math.floor(i()*a+o),r[4*t+2]=Math.floor(i()*a+o),r[4*t+3]=Math.floor(i()*a+o);const h=t*t,A=t;if(e>1){for(let i=0;i<t;i+=e)for(let s=0;s<t;s+=e)for(let a=0;a<t;a++)if(a%e!==0){const o=Math.floor(a/e)*e+t,n=i*h+s*A,l=[],c=[],g=[],m=[];for(let i=0;i<4;i++)l[i]=r[4*n+(o-e)%t*4+i],c[i]=r[4*n+o%t*4+i],g[i]=r[4*n+(o+e)%t*4+i],m[i]=r[4*n+(o+2*e)%t*4+i];const u=a%e/e,f=Ut.dwCubicInterpolate(l,c,g,m,u);for(let t=0;t<4;t++){r[i*h*4+s*A*4+(4*a+t)]=f[t]}}for(let i=0;i<t;i+=e)for(let s=0;s<t;s++)for(let a=0;a<t;a++)if(a%e!==0){const o=Math.floor(a/e)*e+t,n=i*h,l=[],c=[],g=[],m=[];for(let i=0;i<4;i++){const a=4*s+4*n+i;l[i]=r[(o-e)%t*A*4+a],c[i]=r[o%t*A*4+a],g[i]=r[(o+e)%t*A*4+a],m[i]=r[(o+2*e)%t*A*4+a]}const u=a%e/e,f=Ut.dwCubicInterpolate(l,c,g,m,u);for(let t=0;t<4;t++){r[a*A*4+(4*s+4*n+t)]=f[t]}}for(let i=0;i<t;i++)for(let s=0;s<t;s++)for(let a=0;a<t;a++)if(a%e!==0){const o=s*A,n=Math.floor(a/e)*e+t,l=[],c=[],g=[],m=[];for(let s=0;s<4;s++){const a=4*i+4*o+s;l[s]=r[(n-e)%t*h*4+a],c[s]=r[n%t*h*4+a],g[s]=r[(n+e)%t*h*4+a],m[s]=r[(n+2*e)%t*h*4+a]}const u=s%e/e,f=Ut.dwCubicInterpolate(l,c,g,m,u);for(let t=0;t<4;t++){r[a*h*4+(4*i+4*o+t)]=f[t]}}}return r}static createNoiseTex(t,e,i){const s=t*t,r=new Uint8Array(4*s),a=e>1?216:256,o=.5*a;for(let t=0;t<s;t++)r[4*t+0]=Math.floor(i()*a+o),r[4*t+1]=Math.floor(i()*a+o),r[4*t+2]=Math.floor(i()*a+o),r[4*t+3]=Math.floor(i()*a+o);if(e>1){for(let i=0;i<t;i+=e)for(let s=0;s<t;s++)if(s%e!==0){const a=Math.floor(s/e)*e+t,o=i*t,h=[],A=[],n=[],l=[];for(let i=0;i<4;i++)h[i]=r[4*o+(a-e)%t*4+i],A[i]=r[4*o+a%t*4+i],n[i]=r[4*o+(a+e)%t*4+i],l[i]=r[4*o+(a+2*e)%t*4+i];const c=s%e/e,g=Ut.dwCubicInterpolate(h,A,n,l,c);for(let e=0;e<4;e++)r[i*t*4+4*s+e]=g[e]}for(let i=0;i<t;i++)for(let s=0;s<t;s++)if(s%e!==0){const a=Math.floor(s/e)*e+t,o=[],h=[],A=[],n=[];for(let s=0;s<4;s++)o[s]=r[(a-e)%t*t*4+4*i+s],h[s]=r[a%t*t*4+4*i+s],A[s]=r[(a+e)%t*t*4+4*i+s],n[s]=r[(a+2*e)%t*t*4+4*i+s];const l=s%e/e,c=Ut.dwCubicInterpolate(o,h,A,n,l);for(let e=0;e<4;e++)r[s*t*4+4*i+e]=c[e]}}return r}}class Mt{constructor(t){this.gl=t,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.samplers={},this.clouds2Image=new Image,this.clouds2Image.onload=()=>{this.samplers.clouds2=this.gl.createTexture(),this.bindTexture(this.samplers.clouds2,this.clouds2Image,128,128)},this.clouds2Image.src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4RP+RXhpZgAASUkqAAgAAAAJAA8BAgAGAAAAegAAABABAgAVAAAAgAAAABIBAwABAAAAAQAAABoBBQABAAAAoAAAABsBBQABAAAAqAAAACgBAwABAAAAAgAAADIBAgAUAAAAsAAAABMCAwABAAAAAQAAAGmHBAABAAAAxAAAAGYFAABDYW5vbgBDYW5vbiBQb3dlclNob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pwpVuWySl3I/wD1pQ9erfrM2c+0i3I8sFBcQtMTkI7c7e3PvoZNcPHcCQjj371aiCPGUB5rLNfviqyKYiTU2VrbQdiXHBnIz21CqNq1WpwUzaPDMhtxsLCmkZwD747aOLwgXNHt522avZjQiLWHEEp+dsDcBt9uSM/jVFRLZ6vWBSZF2dNHZSIzzKm5jbRStSRzwUkHgZznHfVxLkyLxgH9DVdo1j6nIpK31QaoylfqMEEDCgBoHl0OU7HVUm2VpS3wpvGc8d9ak6WVGL1IdnW51Ht6NMmuO+ozMGGHMEYKSBhJAPIOO5OfGqC//h1doNVcnUOnThGUopKS0HAoc9iO/wDHjUqak0bGNxz+lQtbK3xrX//Z",this.emptyImage=new Image,this.emptyImage.onload=()=>{this.samplers.empty=this.gl.createTexture(),this.bindTexture(this.samplers.empty,this.emptyImage,1,1)},this.emptyImage.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="}bindTexture(t,e,i,s){if(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i,s,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}}loadExtraImages(t){Object.keys(t).forEach(e=>{const{data:i,width:s,height:r}=t[e];if(!this.samplers[e]){const t=new Image;t.onload=()=>{this.samplers[e]=this.gl.createTexture(),this.bindTexture(this.samplers[e],t,s,r)},t.src=i}})}getTexture(t){const e=this.samplers[t];return e||this.samplers.clouds2}}class Ft{constructor(t,e={}){this.gl=t,this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions(),this.textTexture=this.gl.createTexture(),this.indexBuf=t.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.vertexBuf=this.gl.createBuffer(),this.canvas=document.createElement("canvas"),this.canvas.width=this.texsizeX,this.canvas.height=this.texsizeY,this.context2D=this.canvas.getContext("2d",{willReadFrequently:!1}),this.floatPrecision=_t.getFragmentFloatPrecision(this.gl),this.createShader()}generateTitleTexture(t){this.context2D.clearRect(0,0,this.texsizeX,this.texsizeY),this.fontSize=Math.floor(this.texsizeX/256*16),this.fontSize=Math.max(this.fontSize,6),this.context2D.font=`italic ${this.fontSize}px Times New Roman`;let e=t,i=this.context2D.measureText(e).width;if(i>this.texsizeX){const t=this.texsizeX/i*.91;e=`${e.substring(0,Math.floor(e.length*t))}...`,i=this.context2D.measureText(e).width}this.context2D.fillStyle="#FFFFFF",this.context2D.fillText(e,(this.texsizeX-i)/2,this.texsizeY/2);const s=new Uint8Array(this.context2D.getImageData(0,0,this.texsizeX,this.texsizeY).data.buffer);this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.texsizeX,this.texsizeY,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,s),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.bindTexture(this.gl.TEXTURE_2D,null)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.canvas.width=this.texsizeX,this.canvas.height=this.texsizeY}buildPositions(){const t=2/15,e=2/7,i=[];for(let s=0;s<8;s++){const r=s*e-1;for(let e=0;e<16;e++){const s=e*t-1;i.push(s,-r,0)}}const s=[];for(let t=0;t<7;t++)for(let e=0;e<15;e++){const i=e+16*t,r=e+16*(t+1),a=e+1+16*(t+1),o=e+1+16*t;s.push(i,r,o),s.push(r,a,o)}this.vertices=new Float32Array(i),this.indices=new Uint16Array(s)}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       in vec2 aUv;\n       out vec2 uv_orig;\n       out vec2 uv;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n         uv_orig = aPos * halfmad + halfmad;\n         uv = aUv;\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv_orig;\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n       uniform float textColor;\n\n       void main(void) {\n         fragColor = texture(uTexture, uv) * vec4(textColor);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.uvLocation=this.gl.getAttribLocation(this.shaderProgram,"aUv"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.textColorLoc=this.gl.getUniformLocation(this.shaderProgram,"textColor")}generateUvs(t,e,i){const s=[];for(let i=0;i<8;i++)for(let r=0;r<16;r++){const a=2*(r/15)-1;let o=2*(.75*(i/7-.5)+.5)-1;t>=1&&(o+=1/this.texsizeY),s.push(a,e?o:-o)}const r=Math.max(0,1-1.5*t)**1.8*1.3;for(let t=0;t<8;t++)for(let e=0;e<16;e++){const a=16*t+e;s[a]+=.07*r*Math.sin(.31*i.time+.39*s[a]-1.94*s[a+1]),s[a]+=.044*r*Math.sin(.81*i.time-1.91*s[a]+.27*s[a+1]),s[a]+=.061*r*Math.sin(1.31*i.time+.61*s[a]+.74*s[a+1]),s[a+1]+=.061*r*Math.sin(.37*i.time+1.83*s[a]+.69*s[a+1]),s[a+1]+=.07*r*Math.sin(.67*i.time+.42*s[a]-1.39*s[a+1]),s[a+1]+=.087*r*Math.sin(1.07*i.time+3.55*s[a]+.89*s[a+1])}const a=1.01/(t**.21+.01);for(let t=0;t<s.length/2;t++)s[2*t]*=a,s[2*t+1]*=a*this.invAspecty,s[2*t]=(s[2*t]+1)/2,s[2*t+1]=(s[2*t+1]+1)/2;return new Float32Array(s)}renderTitle(t,e,i){this.gl.useProgram(this.shaderProgram);const s=this.generateUvs(t,e,i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.uvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.uvLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textTexture),this.gl.uniform1i(this.textureLoc,0),this.gl.uniform1f(this.textColorLoc,t**.3),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0)}}class Qt{constructor(t){this.rng=mt(),this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.vertInfoA=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)),this.vertInfoC=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)),this.createBlendPattern()}static resizeMatrixValues(t,e,i,s,r){const a=new Float32Array((s+1)*(r+1));let o=0;for(let h=0;h<r+1;h++)for(let A=0;A<s+1;A++){let n=A/r,l=h/s;n*=e+1,l*=i+1,n=Math.clamp(n,0,e-1),l=Math.clamp(l,0,i-1);const c=Math.floor(n),g=Math.floor(l),m=n-c,u=l-g,f=t[g*(e+1)+c],d=t[g*(e+1)+(c+1)],p=t[(g+1)*(e+1)+c],_=t[(g+1)*(e+1)+(c+1)];a[o]=f*(1-m)*(1-u)+d*m*(1-u)+p*(1-m)*u+_*m*u,o+=1}return a}updateGlobals(t){const e=this.mesh_width,i=this.mesh_height;this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.mesh_width===e&&this.mesh_height===i||(this.vertInfoA=Qt.resizeMatrixValues(this.vertInfoA,e,i,this.mesh_width,this.mesh_height),this.vertInfoC=Qt.resizeMatrixValues(this.vertInfoC,e,i,this.mesh_width,this.mesh_height))}genPlasma(t,e,i,s,r){const a=Math.floor((t+e)/2),o=Math.floor((i+s)/2);let h=this.vertInfoC[i*(this.mesh_width+1)+t],A=this.vertInfoC[i*(this.mesh_width+1)+e],n=this.vertInfoC[s*(this.mesh_width+1)+t],l=this.vertInfoC[s*(this.mesh_width+1)+e];s-i>=2&&(0===t&&(this.vertInfoC[o*(this.mesh_width+1)+t]=.5*(h+n)+(2*this.rng.random()-1)*r*this.aspecty),this.vertInfoC[o*(this.mesh_width+1)+e]=.5*(A+l)+(2*this.rng.random()-1)*r*this.aspecty),e-t>=2&&(0===i&&(this.vertInfoC[i*(this.mesh_width+1)+a]=.5*(h+A)+(2*this.rng.random()-1)*r*this.aspectx),this.vertInfoC[s*(this.mesh_width+1)+a]=.5*(n+l)+(2*this.rng.random()-1)*r*this.aspectx),s-i>=2&&e-t>=2&&(h=this.vertInfoC[o*(this.mesh_width+1)+t],A=this.vertInfoC[o*(this.mesh_width+1)+e],n=this.vertInfoC[i*(this.mesh_width+1)+a],l=this.vertInfoC[s*(this.mesh_width+1)+a],this.vertInfoC[o*(this.mesh_width+1)+a]=.25*(n+l+h+A)+(2*this.rng.random()-1)*r,this.genPlasma(t,a,i,o,.5*r),this.genPlasma(a,e,i,o,.5*r),this.genPlasma(t,a,o,s,.5*r),this.genPlasma(a,e,o,s,.5*r))}createBlendPattern(){const t=1+Math.floor(3*this.rng.random());if(0===t){let t=0;for(let e=0;e<=this.mesh_height;e++)for(let e=0;e<=this.mesh_width;e++)this.vertInfoA[t]=1,this.vertInfoC[t]=0,t+=1}else if(1===t){const t=6.28*this.rng.random(),e=Math.cos(t),i=Math.sin(t),s=.1+.2*this.rng.random(),r=1/s;let a=0;for(let t=0;t<=this.mesh_height;t++){const o=t/this.mesh_height*this.aspecty;for(let t=0;t<=this.mesh_width;t++){let h=(t/this.mesh_width*this.aspectx-.5)*e+(o-.5)*i+.5;h=(h-.5)/Math.sqrt(2)+.5,this.vertInfoA[a]=r*(1+s),this.vertInfoC[a]=r*h-r,a+=1}}}else if(2===t){const t=.12+.13*this.rng.random(),e=1/t;this.vertInfoC[0]=this.rng.random(),this.vertInfoC[this.mesh_width]=this.rng.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)]=this.rng.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)+this.mesh_width]=this.rng.random(),this.genPlasma(0,this.mesh_width,0,this.mesh_height,.25);let i=this.vertInfoC[0],s=this.vertInfoC[0],r=0;for(let t=0;t<=this.mesh_height;t++)for(let t=0;t<=this.mesh_width;t++)i>this.vertInfoC[r]&&(i=this.vertInfoC[r]),s<this.vertInfoC[r]&&(s=this.vertInfoC[r]),r+=1;const a=1/(s-i);r=0;for(let s=0;s<=this.mesh_height;s++)for(let s=0;s<=this.mesh_width;s++){const s=(this.vertInfoC[r]-i)*a;this.vertInfoA[r]=e*(1+t),this.vertInfoC[r]=e*s-e,r+=1}}else if(3===t){const t=.02+.14*this.rng.random()+.34*this.rng.random(),e=1/t,i=2*Math.floor(2*this.rng.random())-1;let s=0;for(let r=0;r<=this.mesh_height;r++){const a=(r/this.mesh_height-.5)*this.aspecty;for(let r=0;r<=this.mesh_width;r++){const o=(r/this.mesh_width-.5)*this.aspectx;let h=1.41421*Math.sqrt(o*o+a*a);-1===i&&(h=1-h),this.vertInfoA[s]=e*(1+t),this.vertInfoC[s]=e*h-e,s+=1}}}}}class Vt{constructor(t,e,i){this.gl=t,this.audio=e,this.frameNum=0,this.fps=30,this.time=0,this.presetTime=0,this.lastTime=performance.now(),this.timeHist=[0],this.timeHistMax=120,this.blending=!1,this.blendStartTime=0,this.blendProgress=0,this.blendDuration=0,this.width=i.width||1200,this.height=i.height||900,this.mesh_width=i.meshWidth||48,this.mesh_height=i.meshHeight||36,this.pixelRatio=i.pixelRatio||window.devicePixelRatio||1,this.textureRatio=i.textureRatio||1,this.outputFXAA=i.outputFXAA||!1,this.texsizeX=this.width*this.pixelRatio*this.textureRatio,this.texsizeY=this.height*this.pixelRatio*this.textureRatio,this.aspectx=this.texsizeY>this.texsizeX?this.texsizeX/this.texsizeY:1,this.aspecty=this.texsizeX>this.texsizeY?this.texsizeY/this.texsizeX:1,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=At.range(1,33).map(t=>`q${t}`),this.ts=At.range(1,9).map(t=>`t${t}`),this.regs=At.range(0,100).map(t=>t<10?`reg0${t}`:`reg${t}`),this.blurRatios=[[.5,.25],[.125,.125],[.0625,.0625]],this.audioLevels=new ot(this.audio),this.prevFrameBuffer=this.gl.createFramebuffer(),this.targetFrameBuffer=this.gl.createFramebuffer(),this.prevTexture=this.gl.createTexture(),this.targetTexture=this.gl.createTexture(),this.compFrameBuffer=this.gl.createFramebuffer(),this.compTexture=this.gl.createTexture(),this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.bindFrameBufferTexture(this.prevFrameBuffer,this.prevTexture),this.bindFrameBufferTexture(this.targetFrameBuffer,this.targetTexture),this.bindFrameBufferTexture(this.compFrameBuffer,this.compTexture);const s={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.noise=new Ut(t),this.image=new Mt(t),this.warpShader=new wt(t,this.noise,this.image,s),this.compShader=new It(t,this.noise,this.image,s),this.outputShader=new Rt(t,s),this.prevWarpShader=new wt(t,this.noise,this.image,s),this.prevCompShader=new It(t,this.noise,this.image,s),this.numBlurPasses=0,this.blurShader1=new Ct(0,this.blurRatios,t,s),this.blurShader2=new Ct(1,this.blurRatios,t,s),this.blurShader3=new Ct(2,this.blurRatios,t,s),this.blurTexture1=this.blurShader1.blurVerticalTexture,this.blurTexture2=this.blurShader2.blurVerticalTexture,this.blurTexture3=this.blurShader3.blurVerticalTexture,this.basicWaveform=new bt(t,s),this.customWaveforms=At.range(4).map(e=>new xt(e,t,s)),this.customShapes=At.range(4).map(e=>new vt(e,t,s)),this.prevCustomWaveforms=At.range(4).map(e=>new xt(e,t,s)),this.prevCustomShapes=At.range(4).map(e=>new vt(e,t,s)),this.darkenCenter=new St(t,s),this.innerBorder=new Tt(t,s),this.outerBorder=new Tt(t,s),this.motionVectors=new Pt(t,s),this.titleText=new Ft(t,s),this.blendPattern=new Qt(s),this.resampleShader=new yt(t),this.supertext={startTime:-1},this.warpUVs=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*2),this.warpColor=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*4),this.gl.clearColor(0,0,0,1),this.blankPreset=ht;const r={frame:0,time:0,fps:45,bass:1,bass_att:1,mid:1,mid_att:1,treb:1,treb_att:1};this.preset=ht,this.prevPreset=this.preset,this.presetEquationRunner=new ut(this.preset,r,s),this.prevPresetEquationRunner=new ut(this.prevPreset,r,s),this.preset.useWASM||(this.regVars=this.presetEquationRunner.mdVSRegs)}static getHighestBlur(t){return/sampler_blur3/.test(t)?3:/sampler_blur2/.test(t)?2:/sampler_blur1/.test(t)?1:0}loadPreset(t,e){this.blendPattern.createBlendPattern(),this.blending=!0,this.blendStartTime=this.time,this.blendDuration=e,this.blendProgress=0,this.prevPresetEquationRunner=this.presetEquationRunner,this.prevPreset=this.preset,this.preset=t,this.presetTime=this.time;const i={frame:this.frameNum,time:this.time,fps:this.fps,bass:this.audioLevels.bass,bass_att:this.audioLevels.bass_att,mid:this.audioLevels.mid,mid_att:this.audioLevels.mid_att,treb:this.audioLevels.treb,treb_att:this.audioLevels.treb_att},s={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};t.useWASM?(this.preset.globalPools.perFrame.old_wave_mode.value=this.prevPreset.baseVals.wave_mode,this.preset.baseVals.old_wave_mode=this.prevPreset.baseVals.wave_mode,this.presetEquationRunner=new ft(this.preset,i,s),this.preset.pixel_eqs_initialize_array&&this.preset.pixel_eqs_initialize_array(this.mesh_width,this.mesh_height)):(this.preset.baseVals.old_wave_mode=this.prevPreset.baseVals.wave_mode,this.presetEquationRunner=new ut(this.preset,i,s),this.regVars=this.presetEquationRunner.mdVSRegs);const r=this.prevWarpShader;this.prevWarpShader=this.warpShader,this.warpShader=r;const a=this.prevCompShader;this.prevCompShader=this.compShader,this.compShader=a;const o=this.preset.warp.trim(),h=this.preset.comp.trim();this.warpShader.updateShader(o),this.compShader.updateShader(h),0===o.length?this.numBlurPasses=0:this.numBlurPasses=Vt.getHighestBlur(o),0!==h.length&&(this.numBlurPasses=Math.max(this.numBlurPasses,Vt.getHighestBlur(h)))}loadExtraImages(t){this.image.loadExtraImages(t)}setRendererSize(t,e,i){const s=this.texsizeX,r=this.texsizeY;if(this.width=t,this.height=e,this.mesh_width=i.meshWidth||this.mesh_width,this.mesh_height=i.meshHeight||this.mesh_height,this.pixelRatio=i.pixelRatio||this.pixelRatio,this.textureRatio=i.textureRatio||this.textureRatio,this.texsizeX=t*this.pixelRatio*this.textureRatio,this.texsizeY=e*this.pixelRatio*this.textureRatio,this.aspectx=this.texsizeY>this.texsizeX?this.texsizeX/this.texsizeY:1,this.aspecty=this.texsizeX>this.texsizeY?this.texsizeY/this.texsizeX:1,this.texsizeX!==s||this.texsizeY!==r){const t=this.gl.createTexture();this.bindFrameBufferTexture(this.targetFrameBuffer,t),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY),this.resampleShader.renderQuadTexture(this.targetTexture),this.targetTexture=t,this.bindFrameBufferTexture(this.prevFrameBuffer,this.prevTexture),this.bindFrameBufferTexture(this.compFrameBuffer,this.compTexture)}this.updateGlobals(),this.frameNum>0&&this.renderToScreen()}setInternalMeshSize(t,e){this.mesh_width=t,this.mesh_height=e,this.updateGlobals()}setOutputAA(t){this.outputFXAA=t}updateGlobals(){const t={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.presetEquationRunner.updateGlobals(t),this.prevPresetEquationRunner.updateGlobals(t),this.warpShader.updateGlobals(t),this.prevWarpShader.updateGlobals(t),this.compShader.updateGlobals(t),this.prevCompShader.updateGlobals(t),this.outputShader.updateGlobals(t),this.blurShader1.updateGlobals(t),this.blurShader2.updateGlobals(t),this.blurShader3.updateGlobals(t),this.basicWaveform.updateGlobals(t),this.customWaveforms.forEach(e=>e.updateGlobals(t)),this.customShapes.forEach(e=>e.updateGlobals(t)),this.prevCustomWaveforms.forEach(e=>e.updateGlobals(t)),this.prevCustomShapes.forEach(e=>e.updateGlobals(t)),this.darkenCenter.updateGlobals(t),this.innerBorder.updateGlobals(t),this.outerBorder.updateGlobals(t),this.motionVectors.updateGlobals(t),this.titleText.updateGlobals(t),this.blendPattern.updateGlobals(t),this.warpUVs=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*2),this.warpColor=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*4),this.preset.pixel_eqs_initialize_array&&this.preset.pixel_eqs_initialize_array(this.mesh_width,this.mesh_height)}calcTimeAndFPS(t){let e;if(t)e=t;else{const t=performance.now();e=(t-this.lastTime)/1e3,(e>1||e<0||this.frame<2)&&(e=1/30),this.lastTime=t}this.time+=1/this.fps,this.blending&&(this.blendProgress=(this.time-this.blendStartTime)/this.blendDuration,this.blendProgress>1&&(this.blending=!1));const i=this.timeHist[this.timeHist.length-1]+e;this.timeHist.push(i),this.timeHist.length>this.timeHistMax&&this.timeHist.shift();const s=this.timeHist.length/(i-this.timeHist[0]);if(Math.abs(s-this.fps)>3&&this.frame>this.timeHistMax)this.fps=s;else{const t=.93;this.fps=t*this.fps+(1-t)*s}}runPixelEquations(t,e,i,s){const r=this.mesh_width,a=this.mesh_height,o=r+1,h=a+1,A=this.time*e.warpanimspeed,n=1/e.warpscale,l=11.68+4*Math.cos(1.413*A+10),c=8.77+3*Math.cos(1.113*A+7),g=10.54+3*Math.cos(1.233*A+3),m=11.49+4*Math.cos(.933*A+5),u=0/this.texsizeX,f=0/this.texsizeY,d=this.aspectx,p=this.aspecty;let _=0,E=0;if(t.preset.useWASM){const r=t.preset.globalPools.perVertex;if(At.setWasm(r,i,t.globalKeys),At.setWasm(r,t.mdVSQAfterFrame,t.qs),r.zoom.value=e.zoom,r.zoomexp.value=e.zoomexp,r.rot.value=e.rot,r.warp.value=e.warp,r.cx.value=e.cx,r.cy.value=e.cy,r.dx.value=e.dx,r.dy.value=e.dy,r.sx.value=e.sx,r.sy.value=e.sy,t.preset.pixel_eqs_wasm(t.runVertEQs,this.mesh_width,this.mesh_height,this.time,e.warpanimspeed,e.warpscale,this.aspectx,this.aspecty),s){const e=t.preset.pixel_eqs_get_array();let i=0,s=0;for(let t=0;t<h;t++)for(let t=0;t<o;t++){const t=e[i],r=e[i+1];let a=this.blendPattern.vertInfoA[i/2]*this.blendProgress+this.blendPattern.vertInfoC[i/2];a=Math.clamp(a,0,1),this.warpUVs[i]=this.warpUVs[i]*a+t*(1-a),this.warpUVs[i+1]=this.warpUVs[i+1]*a+r*(1-a),this.warpColor[s+0]=1,this.warpColor[s+1]=1,this.warpColor[s+2]=1,this.warpColor[s+3]=a,i+=2,s+=4}}else this.warpUVs=t.preset.pixel_eqs_get_array(),this.warpColor.fill(1)}else{let i=At.cloneVars(e),b=i.warp,x=i.zoom,v=i.zoomexp,T=i.cx,S=i.cy,P=i.sx,w=i.sy,I=i.dx,R=i.dy,y=i.rot;for(let B=0;B<h;B++)for(let h=0;h<o;h++){const o=h/r*2-1,L=B/a*2-1,C=Math.sqrt(o*o*d*d+L*L*p*p);if(t.runVertEQs){let s;s=B===a/2&&h===r/2?0:At.atan2(L*p,o*d),i.x=.5*o*d+.5,i.y=-.5*L*p+.5,i.rad=C,i.ang=s,i.zoom=e.zoom,i.zoomexp=e.zoomexp,i.rot=e.rot,i.warp=e.warp,i.cx=e.cx,i.cy=e.cy,i.dx=e.dx,i.dy=e.dy,i.sx=e.sx,i.sy=e.sy,i=t.runPixelEquations(i),b=i.warp,x=i.zoom,v=i.zoomexp,T=i.cx,S=i.cy,P=i.sx,w=i.sy,I=i.dx,R=i.dy,y=i.rot}const U=1/x**(v**(2*C-1));let M=.5*o*d*U+.5,F=.5*-L*p*U+.5;M=(M-T)/P+T,F=(F-S)/w+S,0!==b&&(M+=.0035*b*Math.sin(.333*A+n*(o*l-L*m)),F+=.0035*b*Math.cos(.375*A-n*(o*g+L*c)),M+=.0035*b*Math.cos(.753*A-n*(o*c-L*g)),F+=.0035*b*Math.sin(.825*A+n*(o*l+L*m)));const Q=M-T,V=F-S,D=Math.cos(y),q=Math.sin(y);if(M=Q*D-V*q+T,F=Q*q+V*D+S,M-=I,F-=R,M=(M-.5)/d+.5,F=(F-.5)/p+.5,M+=u,F+=f,s){let t=this.blendPattern.vertInfoA[_/2]*this.blendProgress+this.blendPattern.vertInfoC[_/2];t=Math.clamp(t,0,1),this.warpUVs[_]=this.warpUVs[_]*t+M*(1-t),this.warpUVs[_+1]=this.warpUVs[_+1]*t+F*(1-t),this.warpColor[E+0]=1,this.warpColor[E+1]=1,this.warpColor[E+2]=1,this.warpColor[E+3]=t}else this.warpUVs[_]=M,this.warpUVs[_+1]=F,this.warpColor[E+0]=1,this.warpColor[E+1]=1,this.warpColor[E+2]=1,this.warpColor[E+3]=1;_+=2,E+=4}this.mdVSVertex=i}}static mixFrameEquations(t,e,i){const s=.5-.5*Math.cos(t*Math.PI),r=1-s,a=.5,o=At.cloneVars(e);return o.decay=s*e.decay+r*i.decay,o.wave_a=s*e.wave_a+r*i.wave_a,o.wave_r=s*e.wave_r+r*i.wave_r,o.wave_g=s*e.wave_g+r*i.wave_g,o.wave_b=s*e.wave_b+r*i.wave_b,o.wave_x=s*e.wave_x+r*i.wave_x,o.wave_y=s*e.wave_y+r*i.wave_y,o.wave_mystery=s*e.wave_mystery+r*i.wave_mystery,o.ob_size=s*e.ob_size+r*i.ob_size,o.ob_r=s*e.ob_r+r*i.ob_r,o.ob_g=s*e.ob_g+r*i.ob_g,o.ob_b=s*e.ob_b+r*i.ob_b,o.ob_a=s*e.ob_a+r*i.ob_a,o.ib_size=s*e.ib_size+r*i.ib_size,o.ib_r=s*e.ib_r+r*i.ib_r,o.ib_g=s*e.ib_g+r*i.ib_g,o.ib_b=s*e.ib_b+r*i.ib_b,o.ib_a=s*e.ib_a+r*i.ib_a,o.mv_x=s*e.mv_x+r*i.mv_x,o.mv_y=s*e.mv_y+r*i.mv_y,o.mv_dx=s*e.mv_dx+r*i.mv_dx,o.mv_dy=s*e.mv_dy+r*i.mv_dy,o.mv_l=s*e.mv_l+r*i.mv_l,o.mv_r=s*e.mv_r+r*i.mv_r,o.mv_g=s*e.mv_g+r*i.mv_g,o.mv_b=s*e.mv_b+r*i.mv_b,o.mv_a=s*e.mv_a+r*i.mv_a,o.echo_zoom=s*e.echo_zoom+r*i.echo_zoom,o.echo_alpha=s*e.echo_alpha+r*i.echo_alpha,o.echo_orient=s*e.echo_orient+r*i.echo_orient,o.wave_dots=s<a?i.wave_dots:e.wave_dots,o.wave_thick=s<a?i.wave_thick:e.wave_thick,o.additivewave=s<a?i.additivewave:e.additivewave,o.wave_brighten=s<a?i.wave_brighten:e.wave_brighten,o.darken_center=s<a?i.darken_center:e.darken_center,o.gammaadj=s<a?i.gammaadj:e.gammaadj,o.wrap=s<a?i.wrap:e.wrap,o.invert=s<a?i.invert:e.invert,o.brighten=s<a?i.brighten:e.brighten,o.darken=s<a?i.darken:e.darken,o.solarize=s<a?i.brighten:e.solarize,o.b1n=s*e.b1n+r*i.b1n,o.b2n=s*e.b2n+r*i.b2n,o.b3n=s*e.b3n+r*i.b3n,o.b1x=s*e.b1x+r*i.b1x,o.b2x=s*e.b2x+r*i.b2x,o.b3x=s*e.b3x+r*i.b3x,o.b1ed=s*e.b1ed+r*i.b1ed,o}static getBlurValues(t){let e=t.b1n,i=t.b2n,s=t.b3n,r=t.b1x,a=t.b2x,o=t.b3x;const h=.1;if(r-e<h){const t=.5*(e+r);e=t-.05,r=t-.05}if(a=Math.min(r,a),i=Math.max(e,i),a-i<h){const t=.5*(i+a);i=t-.05,a=t-.05}if(o=Math.min(a,o),s=Math.max(i,s),o-s<h){const t=.5*(s+o);s=t-.05,o=t-.05}return{blurMins:[e,i,s],blurMaxs:[r,a,o]}}bindFrambufferAndSetViewport(t,e,i){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.viewport(0,0,e,i)}bindFrameBufferTexture(t,e){if(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.texsizeX,this.texsizeY,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(this.texsizeX*this.texsizeY*4)),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e,0)}render({audioLevels:t,elapsedTime:e}={}){this.calcTimeAndFPS(e),this.frameNum+=1,t?this.audio.updateAudio(t.timeByteArray,t.timeByteArrayL,t.timeByteArrayR):this.audio.sampleAudio(),this.audioLevels.updateAudioLevels(this.fps,this.frameNum);const i={frame:this.frameNum,time:this.time,fps:this.fps,bass:this.audioLevels.bass,bass_att:this.audioLevels.bass_att,mid:this.audioLevels.mid,mid_att:this.audioLevels.mid_att,treb:this.audioLevels.treb,treb_att:this.audioLevels.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY},s=Object.assign({},i);this.prevPreset.useWASM||(s.gmegabuf=this.prevPresetEquationRunner.gmegabuf),this.preset.useWASM||(i.gmegabuf=this.presetEquationRunner.gmegabuf,Object.assign(i,this.regVars));const r=this.presetEquationRunner.runFrameEquations(i);let a;this.runPixelEquations(this.presetEquationRunner,r,i,!1),this.preset.useWASM||(Object.assign(this.regVars,At.pick(this.mdVSVertex,this.regs)),Object.assign(i,this.regVars)),this.blending?(this.prevMDVSFrame=this.prevPresetEquationRunner.runFrameEquations(s),this.runPixelEquations(this.prevPresetEquationRunner,this.prevMDVSFrame,s,!0),a=Vt.mixFrameEquations(this.blendProgress,r,this.prevMDVSFrame)):a=r;const o=this.targetTexture;this.targetTexture=this.prevTexture,this.prevTexture=o;const h=this.targetFrameBuffer;this.targetFrameBuffer=this.prevFrameBuffer,this.prevFrameBuffer=h,this.gl.bindTexture(this.gl.TEXTURE_2D,this.prevTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.enable(this.gl.BLEND),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const{blurMins:A,blurMaxs:n}=Vt.getBlurValues(a);this.blending?(this.prevWarpShader.renderQuadTexture(!1,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,A,n,this.prevMDVSFrame,this.prevPresetEquationRunner.mdVSQAfterFrame,this.warpUVs,this.warpColor),this.warpShader.renderQuadTexture(!0,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,A,n,a,this.presetEquationRunner.mdVSQAfterFrame,this.warpUVs,this.warpColor)):this.warpShader.renderQuadTexture(!1,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,A,n,r,this.presetEquationRunner.mdVSQAfterFrame,this.warpUVs,this.warpColor),this.numBlurPasses>0&&(this.blurShader1.renderBlurTexture(this.targetTexture,r,A,n),this.numBlurPasses>1&&(this.blurShader2.renderBlurTexture(this.blurTexture1,r,A,n),this.numBlurPasses>2&&this.blurShader3.renderBlurTexture(this.blurTexture2,r,A,n)),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY)),this.motionVectors.drawMotionVectors(a,this.warpUVs),this.preset.shapes&&this.preset.shapes.length>0&&this.customShapes.forEach((t,e)=>{t.drawCustomShape(this.blending?this.blendProgress:1,i,this.presetEquationRunner,this.preset.shapes[e],this.prevTexture)}),this.preset.waves&&this.preset.waves.length>0&&this.customWaveforms.forEach((t,e)=>{t.drawCustomWaveform(this.blending?this.blendProgress:1,this.audio.timeArrayL,this.audio.timeArrayR,this.audio.freqArrayL,this.audio.freqArrayR,i,this.presetEquationRunner,this.preset.waves[e])}),this.blending&&(this.prevPreset.shapes&&this.prevPreset.shapes.length>0&&this.prevCustomShapes.forEach((t,e)=>{t.drawCustomShape(1-this.blendProgress,s,this.prevPresetEquationRunner,this.prevPreset.shapes[e],this.prevTexture)}),this.prevPreset.waves&&this.prevPreset.waves.length>0&&this.prevCustomWaveforms.forEach((t,e)=>{t.drawCustomWaveform(1-this.blendProgress,this.audio.timeArrayL,this.audio.timeArrayR,this.audio.freqArrayL,this.audio.freqArrayR,s,this.prevPresetEquationRunner,this.prevPreset.waves[e])})),this.basicWaveform.drawBasicWaveform(this.blending,this.blendProgress,this.audio.timeArrayL,this.audio.timeArrayR,a),this.darkenCenter.drawDarkenCenter(a);const l=[a.ob_r,a.ob_g,a.ob_b,a.ob_a];this.outerBorder.drawBorder(l,a.ob_size,0);const c=[a.ib_r,a.ib_g,a.ib_b,a.ib_a];if(this.innerBorder.drawBorder(c,a.ib_size,a.ob_size),this.supertext.startTime>=0){const t=(this.time-this.supertext.startTime)/this.supertext.duration;t>=1&&this.titleText.renderTitle(t,!0,i)}this.globalVars=i,this.mdVSFrame=r,this.mdVSFrameMixed=a,this.renderToScreen()}renderToScreen(){this.outputFXAA?this.bindFrambufferAndSetViewport(this.compFrameBuffer,this.texsizeX,this.texsizeY):this.bindFrambufferAndSetViewport(null,this.width,this.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.enable(this.gl.BLEND),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const{blurMins:t,blurMaxs:e}=Vt.getBlurValues(this.mdVSFrameMixed);if(this.blending?(this.prevCompShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,t,e,this.prevMDVSFrame,this.prevPresetEquationRunner.mdVSQAfterFrame,this.warpColor),this.compShader.renderQuadTexture(!0,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,t,e,this.mdVSFrameMixed,this.presetEquationRunner.mdVSQAfterFrame,this.warpColor)):this.compShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,t,e,this.mdVSFrame,this.presetEquationRunner.mdVSQAfterFrame,this.warpColor),this.supertext.startTime>=0){const t=(this.time-this.supertext.startTime)/this.supertext.duration;this.titleText.renderTitle(t,!1,this.globalVars),t>=1&&(this.supertext.startTime=-1)}this.outputFXAA&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.compTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(null,this.width,this.height),this.outputShader.renderQuadTexture(this.compTexture))}launchSongTitleAnim(t){this.supertext={startTime:this.time,duration:1.7},this.titleText.generateTitleTexture(t)}toDataURL(){const t=new Uint8Array(this.texsizeX*this.texsizeY*4),e=this.gl.createFramebuffer(),i=this.gl.createTexture();this.bindFrameBufferTexture(e,i);const{blurMins:s,blurMaxs:r}=Vt.getBlurValues(this.mdVSFrameMixed);this.compShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,s,r,this.mdVSFrame,this.presetEquationRunner.mdVSQAfterFrame,this.warpColor),this.gl.readPixels(0,0,this.texsizeX,this.texsizeY,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),Array.from({length:this.texsizeY},(e,i)=>t.slice(i*this.texsizeX*4,(i+1)*this.texsizeX*4)).forEach((e,i)=>t.set(e,(this.texsizeY-i-1)*this.texsizeX*4));const a=document.createElement("canvas");a.width=this.texsizeX,a.height=this.texsizeY;const o=a.getContext("2d",{willReadFrequently:!1}),h=o.createImageData(this.texsizeX,this.texsizeY);return h.data.set(t),o.putImageData(h,0,0),this.gl.deleteTexture(i),this.gl.deleteFramebuffer(e),a.toDataURL()}warpBufferToDataURL(){const t=new Uint8Array(this.texsizeX*this.texsizeY*4);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.targetFrameBuffer),this.gl.readPixels(0,0,this.texsizeX,this.texsizeY,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t);const e=document.createElement("canvas");e.width=this.texsizeX,e.height=this.texsizeY;const i=e.getContext("2d",{willReadFrequently:!1}),s=i.createImageData(this.texsizeX,this.texsizeY);return s.data.set(t),i.putImageData(s,0,0),e.toDataURL()}}class Dt{constructor(t,e,i){this.opts=i,this.rng=gt(i),this.deterministicMode=i.deterministic||i.testMode,this.audio=new at(t);const s=i.width||1200,r=i.height||900;window.OffscreenCanvas?this.internalCanvas=new OffscreenCanvas(s,r):(this.internalCanvas=document.createElement("canvas"),this.internalCanvas.width=s,this.internalCanvas.height=r),this.gl=this.internalCanvas.getContext("webgl2",{alpha:!1,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1}),this.outputGl=e.getContext("2d",{willReadFrequently:!1}),this.baseValsDefaults={decay:.98,gammaadj:2,echo_zoom:2,echo_alpha:0,echo_orient:0,red_blue:0,brighten:0,darken:0,wrap:1,darken_center:0,solarize:0,invert:0,bmotionvectorson:1,fshader:0,b1n:0,b2n:0,b3n:0,b1x:1,b2x:1,b3x:1,b1ed:.25,wave_mode:0,additivewave:0,wave_dots:0,wave_thick:0,wave_a:.8,wave_scale:1,wave_smoothing:.75,wave_mystery:0,modwavealphabyvolume:0,modwavealphastart:.75,modwavealphaend:.95,wave_r:1,wave_g:1,wave_b:1,wave_x:.5,wave_y:.5,wave_brighten:1,mv_x:12,mv_y:9,mv_dx:0,mv_dy:0,mv_l:.9,mv_r:1,mv_g:1,mv_b:1,mv_a:1,warpanimspeed:1,warpscale:1,zoomexp:1,zoom:1,rot:0,cx:.5,cy:.5,dx:0,dy:0,warp:1,sx:1,sy:1,ob_size:.01,ob_r:0,ob_g:0,ob_b:0,ob_a:0,ib_size:.01,ib_r:.25,ib_g:.25,ib_b:.25,ib_a:0},this.shapeBaseValsDefaults={enabled:0,sides:4,additive:0,thickoutline:0,textured:0,num_inst:1,tex_zoom:1,tex_ang:0,x:.5,y:.5,rad:.1,ang:0,r:1,g:0,b:0,a:1,r2:0,g2:1,b2:0,a2:0,border_r:1,border_g:1,border_b:1,border_a:.1},this.waveBaseValsDefaults={enabled:0,samples:512,sep:0,scaling:1,smoothing:.5,r:1,g:1,b:1,a:1,spectrum:0,usedots:0,thick:0,additive:0},this.qs=At.range(1,33).map(t=>`q${t}`),this.ts=At.range(1,9).map(t=>`t${t}`),this.globalPerFrameVars=["old_wave_mode","frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset"],this.globalPerPixelVars=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset","x","y","rad","ang"],this.globalShapeVars=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset","instance"],this.shapeBaseVars=["x","y","rad","ang","r","g","b","a","r2","g2","b2","a2","border_r","border_g","border_b","border_a","thickoutline","textured","tex_zoom","tex_ang","additive"],this.globalWaveVars=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset","x","y","sample","value1","value2"],this.renderer=new Vt(this.gl,this.audio,i)}loseGLContext(){this.gl.getExtension("WEBGL_lose_context").loseContext(),this.outputGl=null}connectAudio(t){this.audioNode=t,this.audio.connectAudio(t)}disconnectAudio(t){this.audio.disconnectAudio(t)}static overrideDefaultVars(t,e){const i={};return Object.keys(t).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)?i[s]=e[s]:i[s]=t[s]}),i}createQVars(){const t={};return this.qs.forEach(e=>{t[e]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),t}createTVars(){const t={};return this.ts.forEach(e=>{t[e]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),t}createPerFramePool(t){const e={};return Object.keys(this.baseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalPerFrameVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}createPerPixelPool(t){const e={};return Object.keys(this.baseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalPerPixelVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}createCustomShapePerFramePool(t){const e={};return Object.keys(this.shapeBaseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalShapeVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}createCustomWavePerFramePool(t){const e={};return Object.keys(this.waveBaseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalWaveVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}static makeShapeResetPool(t,e,i){return e.reduce((e,s)=>({...e,[`${s}_${i}`]:t[s]}),{})}static base64ToArrayBuffer(t){for(var e=window.atob(t),i=e.length,s=new Uint8Array(i),r=0;r<i;r++)s[r]=e.charCodeAt(r);return s.buffer}async loadPreset(t,e=0){const i=JSON.parse(JSON.stringify(t));i.baseVals=Dt.overrideDefaultVars(this.baseValsDefaults,i.baseVals);for(let t=0;t<i.shapes.length;t++)i.shapes[t].baseVals=Dt.overrideDefaultVars(this.shapeBaseValsDefaults,i.shapes[t].baseVals);for(let t=0;t<i.waves.length;t++)i.waves[t].baseVals=Dt.overrideDefaultVars(this.waveBaseValsDefaults,i.waves[t].baseVals);const s=i.useJS&&!this.opts.onlyUseWASM;Object.prototype.hasOwnProperty.call(i,"init_eqs_eel")&&!s?(i.useWASM=!0,await this.loadWASMPreset(i,e)):this.opts.onlyUseWASM?console.warn("Tried to load a preset that doesn't support WASM with onlyUseWASM on"):Object.prototype.hasOwnProperty.call(i,"init_eqs_str")?this.loadJSPreset(i,e):console.warn("Tried to load a JS preset that doesn't have converted strings")}async loadWASMPreset(t,e){const i=this.createQVars(),s=this.createTVars(),r={perFrame:{...i,...this.createPerFramePool(t.baseVals)},perVertex:{...i,...this.createPerPixelPool(t.baseVals)}},a={presetInit:{pool:"perFrame",code:t.init_eqs_eel},perFrame:{pool:"perFrame",code:t.frame_eqs_eel}};""!==t.pixel_eqs_eel&&(a.perPixel={pool:"perVertex",code:t.pixel_eqs_eel});for(let e=0;e<t.shapes.length;e++)r[`shapePerFrame${e}`]={...i,...s,...this.createCustomShapePerFramePool(t.shapes[e].baseVals)},0!==t.shapes[e].baseVals.enabled&&(a[`shapes_${e}_init_eqs`]={pool:`shapePerFrame${e}`,code:t.shapes[e].init_eqs_eel},a[`shapes_${e}_frame_eqs`]={pool:`shapePerFrame${e}`,code:t.shapes[e].frame_eqs_eel});for(let e=0;e<t.waves.length;e++)0!==t.waves[e].baseVals.enabled&&(r[`wavePerFrame${e}`]={...i,...s,...this.createCustomWavePerFramePool(t.waves[e].baseVals)},a[`waves_${e}_init_eqs`]={pool:`wavePerFrame${e}`,code:t.waves[e].init_eqs_eel},a[`waves_${e}_frame_eqs`]={pool:`wavePerFrame${e}`,code:t.waves[e].frame_eqs_eel},t.waves[e].point_eqs_eel&&""!==t.waves[e].point_eqs_eel&&(a[`waves_${e}_point_eqs`]={pool:`wavePerFrame${e}`,code:t.waves[e].point_eqs_eel}));const o=await G.loadModule({pools:r,functions:a,eelVersion:t.version||2}),h=t=>t||(()=>{}),A=await st.instantiate(Dt.base64ToArrayBuffer("AGFzbQEAAAABPQpgAABgAXwBfGACfHwBfGACf38AYAR/f39/AGAJf39/f3x8fHx8AGADf399AGABfwF/YAJ/fwF/YAF+AX8CuBWMAQNlbnYFYWJvcnQABAhwaXhlbEVxcwtwZXJQaXhlbEVxcwAADHBpeGVsVmFyUG9vbAR3YXJwA3wBDHBpeGVsVmFyUG9vbAR6b29tA3wBDHBpeGVsVmFyUG9vbAd6b29tZXhwA3wBDHBpeGVsVmFyUG9vbAJjeAN8AQxwaXhlbFZhclBvb2wCY3kDfAEMcGl4ZWxWYXJQb29sAnN4A3wBDHBpeGVsVmFyUG9vbAJzeQN8AQxwaXhlbFZhclBvb2wCZHgDfAEMcGl4ZWxWYXJQb29sAmR5A3wBDHBpeGVsVmFyUG9vbANyb3QDfAEMcGl4ZWxWYXJQb29sA3J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NACAAQQA2AgQgAEEANgIIIAFBADYCECABQQA2AhQgAkEYTQ0AIABBADYCDCAAQQA2AhAgAEEANgIUIABBADYCGCABQQA2AgAgAUEANgIEIAFBADYCCCABQQA2AgwgACAAQQRxQRhqIgFqIQAgAiABayEBA0AgAUEgTwRAIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGCABQSBrIQEgAEEgaiEADAELCwsLdwECfwJ/QQxBAxACIgFFBEBBDEECEAIhAQsgAQtBADYCACABQQA2AgQgAUEANgIIIABB/////wBLBEBBoAhB0AhBEkE5EAAACyAAQQJ0IgBBABACIgIgABADIAEoAgAaIAEgAjYCACABIAI2AgQgASAANgIIIAELuwQDAX8KfgF8IABC////////////AINCNIhClQh9IgVCBoenQQN0QYAJaiIBKQMAIQcgASkDCCEEIAEpAxAhAiAFQj+DIgVCAFIEQAJ+IAcgBYYgBELAACAFfSIDiIQhByAEIAWGIAIgA4iEIQQgAiAFhiABKQMYIAOIhAshAgsgAEL/////////B4NCgICAgICAgAiEIgVC/////w+DIgMgBEIgiCIIfiAEQv////8PgyIGIAN+IglCIIh8IQQgBiAFQiCIIgZ+IARC/////w+DfCEDIAYgCH4gBEIgiHwgA0IgiHwkkwIgBUIghyACQiCIfiIEIAlC/////w+DIANCIIZ8fCECIAIgBFStI5MCIAUgB358fCIIQgKGIAJCPoiEIgdCP4ciBUIBhyAHhSIDeSEEIAMgBIYgBSACQgKGhSIGQsAAIAR9iIQiAkL/////D4MhAyACQiCIIglCtISjiwJ+IANCorW/yAx+IANCtISjiwJ+IgpCIIh8IgtC/////w+DfCEDIAlCorW/yAx+IAtCIIh8IANCIIh8JJMCIApC/////w+DIANCIIZ8IgMgArpEhBtwUcyYOD+iIAYgBIa6RBgtRFT7ITk/oqCxIgJUrSOTAiIGQguIfLokkQIgAiAGQjWGIANCC4iEfLpEAAAAAAAA8DuiJJICI5ECQoCAgICAgIDYPCAEQjSGfSAAIAeFQoCAgICAgICAgH+DhL8iDKIkkQIjkgIgDKIkkgI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kGQQzw6biS3YcW73uouSQbg0k1CHOsd/hyS0Qn1NYLoPqcpsSZwnOmERLsuOdaROUF+X7SLX4Sc9DlTg/+X+B87KPm9ixEv7w+YBd7PfjZtH20KWmY/Rk+3Ccsnx7ondS3qX573OQc9e/Hl67Ff+2vqklKKRjADVghdjR8gvM/wq2t7/GGR46kdNvSaX4WZZQgb5l6A2P+NQGigFFcVBgYxJ3NN"),{pixelEqs:{perPixelEqs:h(o.exports.perPixel)},pixelVarPool:{warp:r.perVertex.warp,zoom:r.perVertex.zoom,zoomexp:r.perVertex.zoomexp,cx:r.perVertex.cx,cy:r.perVertex.cy,sx:r.perVertex.sx,sy:r.perVertex.sy,dx:r.perVertex.dx,dy:r.perVertex.dy,rot:r.perVertex.rot,x:r.perVertex.x,y:r.perVertex.y,ang:r.perVertex.ang,rad:r.perVertex.rad},qVarPool:i,tVarPool:s,shapePool0:Dt.makeShapeResetPool(r.shapePerFrame0,this.shapeBaseVars,0),shapePool1:Dt.makeShapeResetPool(r.shapePerFrame1,this.shapeBaseVars,1),shapePool2:Dt.makeShapeResetPool(r.shapePerFrame2,this.shapeBaseVars,2),shapePool3:Dt.makeShapeResetPool(r.shapePerFrame3,this.shapeBaseVars,3),console:{logi:t=>{console.log("logi: "+t)},logf:t=>{console.log("logf: "+t)}},env:{abort:()=>{}}});t.globalPools=r,t.init_eqs=h(o.exports.presetInit),t.frame_eqs=h(o.exports.perFrame),t.save_qs=A.exports.saveQs,t.restore_qs=A.exports.restoreQs,t.save_ts=A.exports.saveTs,t.restore_ts=A.exports.restoreTs,o.exports.perPixel&&(t.pixel_eqs=o.exports.perPixel),t.pixel_eqs_initialize_array=(e,i)=>{const s=A.exports.createFloat32Array((e+1)*(i+1)*2);t.pixel_eqs_array=s},t.pixel_eqs_get_array=()=>A.exports.__getFloat32ArrayView(t.pixel_eqs_array),t.pixel_eqs_wasm=(...e)=>A.exports.runPixelEquations(t.pixel_eqs_array,...e);for(let e=0;e<t.shapes.length;e++)0!==t.shapes[e].baseVals.enabled&&(t.shapes[e].init_eqs=h(o.exports[`shapes_${e}_init_eqs`]),t.shapes[e].frame_eqs=o.exports[`shapes_${e}_frame_eqs`],t.shapes[e].frame_eqs_save=()=>A.exports[`shape${e}_save`](),t.shapes[e].frame_eqs_restore=()=>A.exports[`shape${e}_restore`]());for(let e=0;e<t.waves.length;e++)if(0!==t.waves[e].baseVals.enabled){const i={init_eqs:h(o.exports[`waves_${e}_init_eqs`]),frame_eqs:h(o.exports[`waves_${e}_frame_eqs`])};t.waves[e].point_eqs_eel&&""!==t.waves[e].point_eqs_eel?i.point_eqs=o.exports[`waves_${e}_point_eqs`]:i.point_eqs="",t.waves[e]=Object.assign({},t.waves[e],i)}this.renderer.loadPreset(t,e)}loadJSPreset(t,e){if("function"!=typeof t.init_eqs){t.init_eqs=new Function("a",`${t.init_eqs_str} return a;`),t.frame_eqs=new Function("a",`${t.frame_eqs_str} return a;`),t.pixel_eqs_str&&""!==t.pixel_eqs_str?t.pixel_eqs=new Function("a",`${t.pixel_eqs_str} return a;`):t.pixel_eqs="";for(let e=0;e<t.shapes.length;e++)0!==t.shapes[e].baseVals.enabled&&(t.shapes[e]=Object.assign({},t.shapes[e],{init_eqs:new Function("a",`${t.shapes[e].init_eqs_str} return a;`),frame_eqs:new Function("a",`${t.shapes[e].frame_eqs_str} return a;`)}));for(let e=0;e<t.waves.length;e++)if(0!==t.waves[e].baseVals.enabled){const i={init_eqs:new Function("a",`${t.waves[e].init_eqs_str} return a;`),frame_eqs:new Function("a",`${t.waves[e].frame_eqs_str} return a;`)};t.waves[e].point_eqs_str&&""!==t.waves[e].point_eqs_str?i.point_eqs=new Function("a",`${t.waves[e].point_eqs_str} return a;`):i.point_eqs="",t.waves[e]=Object.assign({},t.waves[e],i)}}this.renderer.loadPreset(t,e)}loadExtraImages(t){this.renderer.loadExtraImages(t)}setRendererSize(t,e,i={}){this.internalCanvas.width=t,this.internalCanvas.height=e,this.renderer.setRendererSize(t,e,i)}setInternalMeshSize(t,e){this.renderer.setInternalMeshSize(t,e)}setOutputAA(t){this.renderer.setOutputAA(t)}setCanvas(t){this.outputGl=t.getContext("2d",{willReadFrequently:!1})}render(t){const e=this.renderer.render(t);return this.outputGl&&this.outputGl.drawImage(this.internalCanvas,0,0),e}launchSongTitleAnim(t){this.renderer.launchSongTitleAnim(t)}toDataURL(){return this.renderer.toDataURL()}warpBufferToDataURL(){return this.renderer.warpBufferToDataURL()}}class qt{static createVisualizer(t,e,i){return new Dt(t,e,i)}}export{qt as default};
+{const t=(t,e)=>{var i="function"==typeof e,s="function"==typeof e,r="function"==typeof e;Object.defineProperty(Math,t,{configurable:i,enumerable:r,writable:s,value:e})};t("DEG_PER_RAD",Math.PI/180),t("RAD_PER_DEG",180/Math.PI);const e=new Float32Array(1);t("scale",function(t,e,i,s,r){return 0===arguments.length||Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(r)?NaN:t===1/0||t===-1/0?t:(t-e)*(r-s)/(i-e)+s}),t("fscale",function(t,i,s,r,a){return e[0]=Math.scale(t,i,s,r,a),e[0]}),t("clamp",function(t,e,i){return Math.min(i,Math.max(e,t))}),t("radians",function(t){return t*Math.DEG_PER_RAD}),t("degrees",function(t){return t*Math.RAD_PER_DEG})}var t=1e-5;function e(t,e){let i={destCol:1,srcCol:1,srcLine:1};t.forEach(t=>{t.destCol>e||(i=t)});const s=e-i.destCol;return{column:i.srcCol+s,line:i.srcLine}}window.sqr=function(t){return t*t},window.sqrt=function(t){return Math.sqrt(Math.abs(t))},window.log10=function(t){return Math.log(t)*Math.LOG10E},window.sign=function(t){return t>0?1:t<0?-1:0},window.rand=function(t){var e=Math.floor(t);return e<1?Math.random():Math.random()*e},window.randint=function(t){return Math.floor(rand(t))},window.bnot=function(e){return Math.abs(e)<t?1:0},window.pow=function(t,e){var i,s=Math.pow(t,e);return i=s,!isFinite(i)||isNaN(i)?0:s},window.div=function(t,e){return 0===e?0:t/e},window.mod=function(t,e){return 0===e?0:Math.floor(t)%Math.floor(e)},window.bitor=function(t,e){return Math.floor(t)|Math.floor(e)},window.bitand=function(t,e){return Math.floor(t)&Math.floor(e)},window.sigmoid=function(e,i){var s=1+Math.exp(-e*i);return Math.abs(s)>t?1/s:0},window.bor=function(e,i){return Math.abs(e)>t||Math.abs(i)>t?1:0},window.band=function(e,i){return Math.abs(e)>t&&Math.abs(i)>t?1:0},window.equal=function(e,i){return Math.abs(e-i)<t?1:0},window.above=function(t,e){return t>e?1:0},window.below=function(t,e){return t<e?1:0},window.ifcond=function(e,i,s){return Math.abs(e)>t?i:s},window.memcpy=function(t,e,i,s){let r=e,a=i,o=s;return a<0&&(o+=a,r-=a,a=0),r<0&&(o+=r,a-=r,r=0),o>0&&t.copyWithin(r,a,o),e};var i=function(){var t=function(t,e,i,s){for(i=i||{},s=t.length;s--;i[t[s]]=e);return i},e=[1,18],i=[1,7],s=[1,19],r=[1,20],a=[1,14],o=[1,15],h=[1,16],A=[1,33],n=[1,31],l=[1,23],g=[1,22],c=[1,24],m=[1,25],u=[1,26],f=[1,27],d=[1,28],p=[1,29],E=[1,30],_=[5,8,15,18,20,28,29,32,33,34,35,36,37,38],b=[5,15,18],x=[5,12,15,17,18,24,25,28,29,30],v=[1,57],T=[5,8,12,15,17,18,24,25,28,29,30],w=[15,18],S=[5,8,15,18,28,29,38],P=[5,8,15,18,28,29,32,33,38],R=[5,8,15,18,28,29,32,33,34,37,38],I=[5,8,15,18,28,29,32,33,34,35,36,37,38],y=[5,8,15,18],B=[5,8,15,18,20,22,28,29,32,33,34,35,36,37,38],L={trace:function(){},yy:{},symbols_:{error:2,SCRIPT:3,expression:4,EOF:5,expressionsOptionalTrailingSemi:6,separator:7,";":8,expressions:9,EXPRESSION_BLOCK:10,IDENTIFIER:11,IDENTIFIER_TOKEN:12,argument:13,arguments:14,",":15,FUNCTION_CALL:16,"(":17,")":18,LOGICAL_EXPRESSION:19,LOGICAL_OPERATOR_TOKEN:20,ASSIGNMENT:21,ASSIGNMENT_OPERATOR_TOKEN:22,number:23,DIGITS_TOKEN:24,".":25,NUMBER_LITERAL:26,UNARY_EXPRESSION:27,"-":28,"+":29,"!":30,BINARY_EXPRESSION:31,"*":32,"/":33,"%":34,"&":35,"|":36,"^":37,COMPARISON_TOKEN:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:";",12:"IDENTIFIER_TOKEN",15:",",17:"(",18:")",20:"LOGICAL_OPERATOR_TOKEN",22:"ASSIGNMENT_OPERATOR_TOKEN",24:"DIGITS_TOKEN",25:".",28:"-",29:"+",30:"!",32:"*",33:"/",34:"%",35:"&",36:"|",37:"^",38:"COMPARISON_TOKEN"},productions_:[0,[3,2],[3,2],[3,1],[7,1],[7,2],[9,2],[9,3],[6,1],[6,2],[10,1],[11,1],[13,1],[13,1],[14,1],[14,3],[16,3],[16,4],[19,3],[21,3],[21,3],[23,1],[23,2],[23,3],[23,2],[23,1],[26,1],[27,2],[27,2],[27,2],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[4,1],[4,1],[4,3],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3]],performAction:function(t,e,i,s,r,a,o){var h=a.length-1;switch(r){case 1:return{type:"SCRIPT",body:[a[h-1]],loc:this._$};case 2:return{type:"SCRIPT",body:a[h-1],loc:this._$};case 3:return{type:"SCRIPT",body:[],loc:this._$};case 6:this.$=[a[h-1]];break;case 7:this.$=a[h-2].concat([a[h-1]]);break;case 8:this.$=a[h];break;case 9:this.$=a[h-1].concat([a[h]]);break;case 10:this.$={type:"EXPRESSION_BLOCK",body:a[h],loc:this._$};break;case 11:this.$={type:"IDENTIFIER",value:a[h].toLowerCase(),loc:this._$};break;case 14:this.$=[a[h]];break;case 15:this.$=a[h-2].concat([a[h]]);break;case 16:this.$={type:"CALL_EXPRESSION",callee:a[h-2],arguments:[],loc:this._$};break;case 17:this.$={type:"CALL_EXPRESSION",callee:a[h-3],arguments:a[h-1],loc:this._$};break;case 18:this.$={type:"LOGICAL_EXPRESSION",left:a[h-2],right:a[h],operator:a[h-1],loc:this._$};break;case 19:case 20:this.$={type:"ASSIGNMENT_EXPRESSION",left:a[h-2],operator:a[h-1],right:a[h],loc:this._$};break;case 21:this.$=Number(a[h]);break;case 22:this.$=Number(a[h-1]);break;case 23:this.$=Number(a[h-2]+a[h-1]+a[h]);break;case 24:this.$=Number("0"+a[h-1]+a[h]);break;case 25:this.$=0;break;case 26:this.$={type:"NUMBER_LITERAL",value:a[h],loc:this._$};break;case 27:case 28:case 29:this.$={type:"UNARY_EXPRESSION",value:a[h],operator:a[h-1],loc:this._$};break;case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:this.$={type:"BINARY_EXPRESSION",left:a[h-2],right:a[h],operator:a[h-1],loc:this._$};break;case 41:case 47:this.$=a[h-1]}},table:[{3:1,4:2,5:[1,4],6:3,9:13,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{1:[3]},{5:[1,21],7:32,8:A,20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E},{5:[1,34]},{1:[2,3]},t(_,[2,39]),t(_,[2,40]),{4:35,6:37,9:13,10:36,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(_,[2,42]),t(_,[2,43]),t(_,[2,44],{22:[1,38]}),t(_,[2,45],{17:[1,40],22:[1,39]}),t(_,[2,46]),t(b,[2,8],{31:5,27:6,26:8,21:9,16:10,11:11,19:12,23:17,4:41,12:e,17:i,24:s,25:r,28:a,29:o,30:h}),{4:42,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:43,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:44,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(_,[2,26]),t([5,8,15,17,18,20,22,28,29,32,33,34,35,36,37,38],[2,11]),t(_,[2,21],{25:[1,45]}),t(_,[2,25],{24:[1,46]}),{1:[2,1]},{4:47,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:48,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:49,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:50,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:51,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:52,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:53,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:54,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:55,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:56,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(x,[2,6],{8:v}),t(T,[2,4]),{1:[2,2]},{7:32,8:A,18:[1,58],20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E},{18:[1,59]},t(w,[2,10]),{4:60,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:61,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},{4:65,6:37,9:13,10:66,11:11,12:e,13:64,14:63,16:10,17:i,18:[1,62],19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(b,[2,9],{7:67,8:A,20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E}),t(S,[2,27],{20:n,32:c,33:m,34:u,35:f,36:d,37:p}),t(S,[2,28],{20:n,32:c,33:m,34:u,35:f,36:d,37:p}),t(S,[2,29],{20:n,32:c,33:m,34:u,35:f,36:d,37:p}),t(_,[2,22],{24:[1,68]}),t(_,[2,24]),t(S,[2,30],{20:n,32:c,33:m,34:u,35:f,36:d,37:p}),t(S,[2,31],{20:n,32:c,33:m,34:u,35:f,36:d,37:p}),t(P,[2,32],{20:n,34:u,35:f,36:d,37:p}),t(P,[2,33],{20:n,34:u,35:f,36:d,37:p}),t(R,[2,34],{20:n,35:f,36:d}),t(I,[2,35],{20:n}),t(I,[2,36],{20:n}),t(R,[2,37],{20:n,35:f,36:d}),t(y,[2,38],{20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E}),t(_,[2,18]),t(T,[2,5]),t(_,[2,41]),t(_,[2,47]),t(y,[2,20],{20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E}),t(y,[2,19],{20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E}),t(B,[2,16]),{15:[1,70],18:[1,69]},t(w,[2,14]),t(w,[2,12],{7:32,8:A,20:n,28:l,29:g,32:c,33:m,34:u,35:f,36:d,37:p,38:E}),t(w,[2,13]),t(x,[2,7],{8:v}),t(_,[2,23]),t(B,[2,17]),{4:65,6:37,9:13,10:66,11:11,12:e,13:71,16:10,17:i,19:12,21:9,23:17,24:s,25:r,26:8,27:6,28:a,29:o,30:h,31:5},t(w,[2,15])],defaultActions:{4:[2,3],21:[2,1],34:[2,2]},parseError:function(t,e){if(!e.recoverable){var i=new Error(t);throw i.hash=e,i}this.trace(t)},parse:function(t){var e=this,i=[0],s=[null],r=[],a=this.table,o="",h=0,A=0,n=r.slice.call(arguments,1),l=Object.create(this.lexer),g={yy:{}};for(var c in this.yy)Object.prototype.hasOwnProperty.call(this.yy,c)&&(g.yy[c]=this.yy[c]);l.setInput(t,g.yy),g.yy.lexer=l,g.yy.parser=this,void 0===l.yylloc&&(l.yylloc={});var m=l.yylloc;r.push(m);var u=l.options&&l.options.ranges;"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var f,d,p,E,_,b,x,v,T=function(){var t;return"number"!=typeof(t=l.lex()||1)&&(t=e.symbols_[t]||t),t},w={};;){if(d=i[i.length-1],this.defaultActions[d]?p=this.defaultActions[d]:(null==f&&(f=T()),p=a[d]&&a[d][f]),void 0===p||!p.length||!p[0]){var S;for(_ in v=[],a[d])this.terminals_[_]&&_>2&&v.push("'"+this.terminals_[_]+"'");S=l.showPosition?"Parse error on line "+(h+1)+":\n"+l.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[f]||f)+"'":"Parse error on line "+(h+1)+": Unexpected "+(1==f?"end of input":"'"+(this.terminals_[f]||f)+"'"),this.parseError(S,{text:l.match,token:this.terminals_[f]||f,line:l.yylineno,loc:m,expected:v})}if(p[0]instanceof Array&&p.length>1)throw new Error("Parse Error: multiple actions possible at state: "+d+", token: "+f);switch(p[0]){case 1:i.push(f),s.push(l.yytext),r.push(l.yylloc),i.push(p[1]),f=null,A=l.yyleng,o=l.yytext,h=l.yylineno,m=l.yylloc;break;case 2:if(b=this.productions_[p[1]][1],w.$=s[s.length-b],w._$={first_line:r[r.length-(b||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(b||1)].first_column,last_column:r[r.length-1].last_column},u&&(w._$.range=[r[r.length-(b||1)].range[0],r[r.length-1].range[1]]),void 0!==(E=this.performAction.apply(w,[o,A,h,g.yy,p[1],s,r].concat(n))))return E;b&&(i=i.slice(0,-1*b*2),s=s.slice(0,-1*b),r=r.slice(0,-1*b)),i.push(this.productions_[p[1]][0]),s.push(w.$),r.push(w._$),x=a[i[i.length-2]][i[i.length-1]],i.push(x);break;case 3:return!0}}return!0}},U={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var i,s,r;if(this.options.backtrack_lexer&&(r={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(r.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var a in r)this[a]=r[a];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,i,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),a=0;a<r.length;a++)if((i=this._input.match(this.rules[r[a]]))&&(!e||i[0].length>e[0].length)){if(e=i,s=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,r[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,r[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,i,s){switch(i){case 0:break;case 1:return 24;case 2:return 38;case 3:return 22;case 4:return 20;case 5:return 12;case 6:return 5;case 7:return e.yytext[0]}},rules:[/^(?:\s+)/,/^(?:[0-9]+)/,/^(?:(==|!=|<=|>=|<|>))/,/^(?:[+\-*/%]?=)/,/^(?:(\&\&)|\|\|)/,/^(?:[a-zA-Z_][a-zA-Z0-9._]*)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};function C(){this.yy={}}return L.lexer=U,C.prototype=L,L.Parser=C,new C}();const s={ASSIGNMENT_EXPRESSION:[{type:"NODE",key:"right"}],SCRIPT:[{type:"ARRAY",key:"body"}],EXPRESSION_BLOCK:[{type:"ARRAY",key:"body"}],UNARY_EXPRESSION:[{type:"NODE",key:"value"}],NUMBER_LITERAL:[],IDENTIFIER:[],CALL_EXPRESSION:[{type:"ARRAY",key:"arguments"},{type:"NODE",key:"callee"}],BINARY_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}],LOGICAL_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}]};function r(t,e){const i=s[t.type];let a=t;if(null==i)throw new Error(`Unknown children definition for ${t.type}`);return i.forEach(i=>{if("NODE"===i.type){const s=t[i.key],o=r(s,e);o!==s&&(a={...a,[i.key]:o})}else if("ARRAY"===i.type){const s=t[i.key],o=s.map(t=>r(t,e)),h=s.some((t,e)=>t!==o[e]);h&&(a={...a,[i.key]:o})}}),e(a)}function a(t){return[].concat.apply([],t)}function o(t,e){return new Array(t).fill(e).join("")}class h{constructor(){this._map=new Map}get(t,e){const i=null==t?e:`${t}::${e}`;return this._map.has(i)||this._map.set(i,this._map.size),this._map.get(i)}size(){return this._map.size}}class A extends Error{constructor(t,e,i){super(t),this.sourceContext=function(t,e,i=1){const s=Math.max(t.first_line-1-i,0),r=t.last_line+i,a=e.split("\n").slice(s,r).map((e,i)=>{const r=i+s+1;return`${r>=t.first_line&&r<=t.last_line?">":" "} ${r} | ${e}`});if(t.first_line===t.last_line){const e=o(t.first_column," "),i=o(t.last_column-t.first_column,"^"),r=t.first_line-s;a.splice(r,0,`    | ${e}${i}`)}return a.join("\n")}(e,i),this.loc=e}}class n extends A{}function l(t,e,i){return new n(t,e,i)}function g(t,e,i){return new A(t,e,i)}function c(t,i){const s=e(i,t.first_column),r=e(i,t.last_column);return{first_column:s.column,last_column:r.column,first_line:s.line,last_line:r.line}}function m(t){const[e,s]=function(t){const e=[];let i=1,s="",r=0,a=!1,o=!1,h=!1;for(let A=0;A<t.length;A++){const n=t[A];if(h){const t=s.length+1,a=A-r+1;e.push({destCol:t,srcCol:a,srcLine:i}),h=!1}"\n"===n?(a=!1,i++,r=A+1,h=!0):"\r"===n&&"\n"===t[A+1]?(A++,a=!1,i++,r=A+1,h=!0):o&&"*"===n&&"/"===t[A+1]?(o=!1,A++,h=!0):"\\"===n&&"\\"===t[A+1]||"/"===n&&"/"===t[A+1]?(a=!0,A++):"/"===n&&"*"===t[A+1]?(o=!0,A++):a||o||(s+=n)}return[s,e]}(t);try{const a=function(){return i.parse.apply(i,arguments)}(e);return r(a,e=>{if(1!==e.loc.first_line||1!=e.loc.last_line)throw g("Unexpected multiline",e.loc,t);return Object.assign(Object.assign({},e),{loc:c(e.loc,s)})})}catch(e){if(null==e.hash)throw e;throw l(`Parse Error: ${e.message.split("\n")[3]}`,c(e.hash.loc,s),t)}}const u=[0,97,115,109],f=[1,0,0,0],d=1e-5,p=t=>[2,t],E=t=>[3,t],_=t=>[4,t],b=11,x=t=>[13,...G(t)],v=t=>[16,...G(t)],T=t=>[32,...G(t)],w=t=>[33,...G(t)],S=t=>[34,...G(t)],P=t=>[35,...G(t)],R=t=>[36,...G(t)],I=(t,e)=>[43,...G(t),...G(e)],y=(t,e)=>[57,...G(t),...G(e)],B=t=>[65,...O(t)],L=t=>[68,...X(t)],U=99,C=153,F=161,Q=176,M=183,D=127,V=124,q=124,z=[C,...L(d),U],N=[C,...L(d),100];function X(t){const e=new Uint8Array(8);return function(t,e){const i=new ArrayBuffer(8);new DataView(i).setFloat64(0,e);const s=new Uint8Array(i).reverse();t.set(s,0)}(e,t),e}const k=t=>[t.length].concat(t.split("").map(t=>t.charCodeAt(0)));function G(t){const e=[];do{let i=127&t;0!=(t>>>=7)&&(i|=128),e.push(i)}while(0!==t);return e}function O(t){let e=[],i=0,s=Math.ceil(Math.log2(Math.abs(t))),r=t<0,a=!0;for(;a;)i=127&t,t>>=7,r&&(t|=-(1<<s-7)),(0!=t||64&i)&&(-1!=t||64&~i)?i|=128:a=!1,e.push(i);return e}const W=t=>G(t.length).concat(t),Y=t=>G(t.length).concat(a(t));function J(t,e){if(0===e.length)return[];const i=W(Y(e));return i.unshift(t),i}const K=(t,e,i)=>{const s=[...k(e),...i];return[t,...W(s)]},j={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,rand:t=>Math.random()*t,pow:Math.pow,log:Math.log,log10:Math.log10,exp:Math.exp,sigmoid:function(t,e){const i=1+Math.exp(-t*e);return Math.abs(i)>1e-5?1/i:0}},H=Math.ceil(2048),Z=L(Math.pow(2,31)),$=L(Math.pow(2,31));function tt(t){return[...T(t),...Z,U,..._(q),...T(t),C,5,...$,b,176]}const et={sqr:{args:[V],returns:[V],binary:[...T(0),...T(0),162]},bor:{args:[V,V],returns:[V],binary:[...T(0),...N,...T(1),...N,114,...B(0),71,M]},band:{args:[V,V],returns:[V],binary:[...T(0),...N,...T(1),...N,113,...B(0),71,M]},sign:{args:[V],returns:[V],binary:[...L(0),...T(0),U,...T(0),...L(0),U,107,M]},mod:{args:[V,V],returns:[V],localVariables:[126],binary:[...tt(1),...S(2),...(t=>[66,...O(t)])(0),82,..._(q),...tt(0),...T(2),129,185,5,...L(0),b]},bitwiseOr:{args:[V,V],returns:[V],binary:[...T(0),Q,...T(1),Q,132,185]},bitwiseAnd:{args:[V,V],returns:[V],binary:[...T(0),Q,...T(1),Q,131,185]},div:{args:[V,V],returns:[V],localVariables:[D],binary:[...T(1),...L(0),98,..._(q),...T(0),...T(1),163,5,...L(0),b]},_getBufferIndex:{args:[V],returns:[D],localVariables:[V,D],binary:[...L(d),...T(0),160,...S(1),170,...w(2),...B(-1),...T(2),...B(8),108,...T(2),...B(0),72,...T(2),...B(8388607),74,114,27]}};function it(t,e){var i,s,r;switch(t.type){case"SCRIPT":return a(t.body.map((t,i)=>[...it(t,e),26]));case"EXPRESSION_BLOCK":return st(t.body,e);case"BINARY_EXPRESSION":{const i=it(t.left,e),s=it(t.right,e),r={"+":[160],"-":[F],"*":[162],"/":e.resolveFunc("div"),"%":e.resolveFunc("mod"),"|":e.resolveFunc("bitwiseOr"),"&":e.resolveFunc("bitwiseAnd"),"^":e.resolveFunc("pow"),"==":[F,...z,M],"!=":[F,...N,M],"<":[U,M],">":[100,M],"<=":[101,M],">=":[102,M]}[t.operator];if(null==r)throw g(`Unknown binary expression operator ${t.operator}`,t.loc,e.rawSource);return[...i,...s,...r]}case"CALL_EXPRESSION":{const s=t.callee.value,r=t.arguments,o=i=>{if(r.length<i)throw l(`Too few arguments passed to \`${s}()\`. Expected ${i} but only got ${r.length}.`,t.loc,e.rawSource);if(r.length>i)throw l(`Too many arguments passed to \`${s}()\`. Expected ${i} but got ${r.length}.`,r[i].loc,e.rawSource)};switch(s){case"exec2":return o(2),st(t.arguments,e);case"exec3":return o(3),st(t.arguments,e);case"if":o(3);const[r,a,h]=t.arguments;return function(t,e,i,s){return[...it(t,s),...N,..._(q),...it(e,s),5,...it(i,s),b]}(r,a,h,e);case"while":return o(1),function(t,e){const i=it(t,e),s=e.resolveLocal(D);return[...B(0),...w(s),...E(64),...T(s),...B(1),106,...S(s),...B(1048576),73,...i,...N,113,...x(0),b,...L(0)]}(t.arguments[0],e);case"loop":return o(2),function(t,e,i){const s=it(e,i),r=i.resolveLocal(D);return[...p(64),...it(t,i),170,...S(r),...B(0),76,...x(1),...E(64),...s,26,...T(r),...B(1),107,...S(r),...B(0),71,...x(0),b,b,...L(0)]}(t.arguments[0],t.arguments[1],e);case"megabuf":case"gmegabuf":o(1);const A=e.resolveLocal(D);return[...it(t.arguments[0],e),...null!==(i=e.resolveFunc("_getBufferIndex"))&&void 0!==i?i:[],...S(A),...B(-1),71,..._(q),...T(A),...I(3,rt(s)),5,...L(0),b];case"assign":o(2);const n=t.arguments[0];if("IDENTIFIER"!=n.type)throw l("Expected the first argument of `assign()` to be an identifier.",n.loc,e.rawSource);const g=e.resolveVar(n.value);return[...it(t.arguments[1],e),...R(g),...P(g)]}const h=a(t.arguments.map(t=>it(t,e)));switch(s){case"abs":return o(1),[...h,C];case"sqrt":return o(1),[...h,C,159];case"int":case"floor":return o(1),[...h,156];case"min":return o(2),[...h,164];case"max":return o(2),[...h,165];case"above":return o(2),[...h,100,M];case"below":return o(2),[...h,U,M];case"equal":return o(2),[...h,F,...z,M];case"bnot":return o(1),[...h,...z,M];case"ceil":return o(1),[...h,155]}const A=e.resolveFunc(s);if(null==A||s.startsWith("_"))throw l(`"${s}" is not defined.`,t.callee.loc,e.rawSource);if(null!=j[s])o(j[s].length);else{if(null==et[s])throw g(`Missing arity information for the function \`${s}()\``,t.callee.loc,e.rawSource);o(et[s].args.length)}return[...h,...A]}case"ASSIGNMENT_EXPRESSION":{const{left:i}=t,a=it(t.right,e),o=function(t,e){const i={"+=":[160],"-=":[F],"*=":[162],"/=":[163],"%=":e.resolveFunc("mod"),"=":null}[t.operator];if(void 0===i)throw g(`Unknown assignment operator "${t.operator}"`,t.loc,e.rawSource);return i}(t,e);if("IDENTIFIER"===i.type){const t=e.resolveVar(i.value),s=P(t),r=R(t);return null===o?[...a,...r,...s]:[...s,...a,...o,...r,...s]}if("CALL_EXPRESSION"!==i.type)throw g(`Unexpected left hand side type for assignment: ${i.type}`,t.loc,e.rawSource);const h=e.resolveLocal(D);if(1!==i.arguments.length)throw l(`Expected 1 argument when assigning to a buffer but got ${i.arguments.length}.`,0===i.arguments.length?i.loc:i.arguments[1].loc,e.rawSource);const A=i.callee.value;if("gmegabuf"!==A&&"megabuf"!==A)throw l("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.",i.callee.loc,e.rawSource);const n=rt(A);if(null===o){const t=e.resolveLocal(D),r=e.resolveLocal(V);return[...a,...w(r),...it(i.arguments[0],e),...null!==(s=e.resolveFunc("_getBufferIndex"))&&void 0!==s?s:[],...S(t),...B(0),72,..._(q),...L(0),5,...T(t),...S(h),...T(r),...y(3,n),...T(r),b]}const c=e.resolveLocal(D),m=e.resolveLocal(D),u=e.resolveLocal(V),f=e.resolveLocal(V);return[...a,...w(u),...it(i.arguments[0],e),...null!==(r=e.resolveFunc("_getBufferIndex"))&&void 0!==r?r:[],...S(c),...B(-1),71,...S(m),..._(q),...T(c),...I(3,n),5,...L(0),b,...T(u),...o,...S(f),...T(m),..._(64),...T(c),...T(f),...y(3,n),b]}case"LOGICAL_EXPRESSION":{const i=it(t.left,e),s=it(t.right,e),r={"&&":{comparison:z,shortCircuitValue:0},"||":{comparison:N,shortCircuitValue:1}}[t.operator];if(null==r)throw g(`Unknown logical expression operator ${t.operator}`,t.loc,e.rawSource);const{comparison:a,shortCircuitValue:o}=r;return[...i,...a,..._(q),...L(o),5,...s,...N,M,b]}case"UNARY_EXPRESSION":{const i=it(t.value,e),s={"-":[154],"+":[],"!":[...z,M]}[t.operator];if(null==s)throw g(`Unknown logical unary operator ${t.operator}`,t.loc,e.rawSource);return[...i,...s]}case"IDENTIFIER":const o=t.value;return P(e.resolveVar(o));case"NUMBER_LITERAL":return L(t.value);default:throw g(`Unknown AST node type ${t.type}`,t.loc,e.rawSource)}}function st(t,e){return a(function(t,e){const i=[];for(let s=0;s<t.length;s++)i.push(t[s]),s===t.length-1||i.push(e);return i}(t.map((t,i)=>it(t,e)),[26]))}function rt(t){switch(t){case"gmegabuf":return 67108864;case"megabuf":return 0}}function at({pools:t,functions:e,eelVersion:i=2,preParsed:s=!1}){if(Object.keys(t).includes("shims"))throw new Error('You may not name a pool "shims". "shims" is reserved for injected JavaScript functions.');const r=[];Object.entries(t).forEach(([t,e])=>{e.forEach(e=>{r.push([t,e])})});const a=new h;r.forEach(([t,e])=>{a.get(t,e)});const o=Object.entries(j).map(([t,e])=>({args:new Array(e.length).fill(null).map(t=>V),returns:[V],name:t})),A=[],n=[];Object.entries(e).forEach(([e,{pool:r,code:h}])=>{if(null==t[r]){const i=Object.keys(t);if(0===i.length)throw new Error(`The function "${e}" was declared as using a variable pool named "${r}" but no pools were defined.`);throw new Error(`The function "${e}" was declared as using a variable pool named "${r}" which is not among the variable pools defined. The defined variable pools are: ${function(t){if(0===t.length)throw new Error("Cannot format an empty list");if(1===t.length)return t[0];const e=t.map(t=>`"${t}"`),i=e.pop();return e.join(", ")+` and ${i}`}(i)}.`)}const l=s?h:m(h);if("string"==typeof l)throw new Error("Got passed unparsed code without setting the preParsed flag");if("SCRIPT"!==l.type)throw new Error("Invalid AST");if(0===l.body.length)return;const g=[],c={resolveVar:t=>/^reg\d\d$/.test(t)?a.get(null,t):a.get(r,t),resolveLocal:t=>(g.push(t),g.length-1),resolveFunc:t=>{const e=o.findIndex(e=>e.name===t);if(-1!==e){const s=v(e);return"rand"===t&&1===i?[...s,156]:s}if(null==et[t])return null;let s=A.indexOf(t);return-1===s&&(A.push(t),s=A.length-1),v(s+o.length)},rawSource:h},u=it(l,c);n.push({binary:u,exportName:e,args:[],returns:[],localVariables:g})});const l=A.map(t=>{const e=et[t];if(null==e)throw new Error(`Undefined local function "${t}"`);return e}),g=t=>[...t.args,"|",...t.returns].join("-"),c=[],d=new Map;function p(t){const e=g(t),i=d.get(e);if(null==i)throw new Error(`Failed to get a type index for key ${e}`);return i}[...o,...l,...n].forEach(t=>{const e=g(t);d.has(e)||(c.push([96,...W(t.args),...W(t.returns)]),d.set(e,c.length-1))});const E=[...r.map(([t,e])=>[...k(t),...k(e),3,V,1]),...o.map((t,e)=>{const i=p(t);return[...k("shims"),...k(t.name),0,...G(i)]})],_=[...l,...n].map(t=>G(p(t))),x=[[1,...G(H),...G(H)]],T=a.size()-r.length,w=(S=()=>[V,1,...L(0),b],new Array(T).fill(null).map((t,e)=>S()));var S;const P=[...n].map((t,e)=>{const i=e+o.length+l.length;return[...k(t.exportName),0,...G(i)]}),R=[...l,...n].map(t=>{var e;const i=(null!==(e=t.localVariables)&&void 0!==e?e:[]).map(t=>[...G(1),t]);return W([...Y(i),...t.binary,b])}),I=[...o.map(t=>t.name),...A,...n.map(t=>t.exportName)].map((t,e)=>[...G(e),...k(t)]),y=[1,...W(Y(I))];return new Uint8Array([...u,...f,...J(1,c),...J(2,E),...J(3,_),...J(5,x),...J(6,w),...J(7,P),...J(10,R),...K(0,"name",y)])}const ot="undefined"!=typeof BigUint64Array,ht=Symbol(),At=new TextDecoder("utf-16le");function nt(t,e){const i=new Uint32Array(t)[e+-4>>>2]>>>1,s=new Uint16Array(t,e,i);return i<=32?String.fromCharCode.apply(String,s):At.decode(s)}function lt(t){const e={};function i(t,e){return t?nt(t.buffer,e):"<yet unknown>"}const s=t.env=t.env||{};return s.abort=s.abort||function(t,r,a,o){const h=e.memory||s.memory;throw Error(`abort: ${i(h,t)} at ${i(h,r)}:${a}:${o}`)},s.trace=s.trace||function(t,r,...a){const o=e.memory||s.memory;console.log(`trace: ${i(o,t)}${r?" ":""}${a.slice(0,r).join(", ")}`)},s.seed=s.seed||Date.now,t.Math=t.Math||Math,t.Date=t.Date||Date,e}function gt(t,e){const i=e.exports,s=i.memory,r=i.table,a=i.__new,o=i.__retain,h=i.__rtti_base||-1;function A(t){const e=function(t){const e=new Uint32Array(s.buffer);if((t>>>=0)>=e[h>>>2])throw Error(`invalid id: ${t}`);return e[(h+4>>>2)+2*t]}(t);if(!(7&e))throw Error(`not an array: ${t}, flags=${e}`);return e}function n(t){const e=new Uint32Array(s.buffer);if((t>>>=0)>=e[h>>>2])throw Error(`invalid id: ${t}`);return e[(h+4>>>2)+2*t+1]}function l(t){return 31-Math.clz32(t>>>6&31)}function g(t,e,i){const r=s.buffer;if(i)switch(t){case 2:return new Float32Array(r);case 3:return new Float64Array(r)}else switch(t){case 0:return new(e?Int8Array:Uint8Array)(r);case 1:return new(e?Int16Array:Uint16Array)(r);case 2:return new(e?Int32Array:Uint32Array)(r);case 3:return new(e?BigInt64Array:BigUint64Array)(r)}throw Error(`unsupported align: ${t}`)}function c(t){const e=new Uint32Array(s.buffer),i=A(e[t+-8>>>2]),r=l(i);let a=4&i?t:e[t+4>>>2];const o=2&i?e[t+12>>>2]:e[a+-4>>>2]>>>r;return g(r,2048&i,4096&i).subarray(a>>>=r,a+o)}function m(t,e,i){return new t(u(t,e,i))}function u(t,e,i){const r=s.buffer,a=new Uint32Array(r),o=a[i+4>>>2];return new t(r,o,a[o+-4>>>2]>>>e)}function f(e,i,s){t[`__get${i}`]=m.bind(null,e,s),t[`__get${i}View`]=u.bind(null,e,s)}return t.__newString=function(t){if(null==t)return 0;const e=t.length,i=a(e<<1,1),r=new Uint16Array(s.buffer);for(var o=0,h=i>>>1;o<e;++o)r[h+o]=t.charCodeAt(o);return i},t.__getString=function(t){if(!t)return null;const e=s.buffer;if(1!==new Uint32Array(e)[t+-8>>>2])throw Error(`not a string: ${t}`);return nt(e,t)},t.__newArray=function(t,e){const i=A(t),r=l(i),h=e.length,n=a(h<<r,4&i?t:0);let c;if(4&i)c=n;else{const e=a(2&i?16:12,t),A=new Uint32Array(s.buffer);A[e+0>>>2]=o(n),A[e+4>>>2]=n,A[e+8>>>2]=h<<r,2&i&&(A[e+12>>>2]=h),c=e}const m=g(r,2048&i,4096&i);if(16384&i)for(let t=0;t<h;++t)m[(n>>>r)+t]=o(e[t]);else m.set(e,n>>>r);return c},t.__getArrayView=c,t.__getArray=function(t){const e=c(t),i=e.length,s=new Array(i);for(let t=0;t<i;t++)s[t]=e[t];return s},t.__getArrayBuffer=function(t){const e=s.buffer,i=new Uint32Array(e)[t+-4>>>2];return e.slice(t,t+i)},[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array].forEach(t=>{f(t,t.name,31-Math.clz32(t.BYTES_PER_ELEMENT))}),ot&&[BigUint64Array,BigInt64Array].forEach(t=>{f(t,t.name.slice(3),3)}),t.__instanceof=function(t,e){const i=new Uint32Array(s.buffer);let r=i[t+-8>>>2];if(r<=i[h>>>2])do{if(r==e)return!0;r=n(r)}while(r);return!1},t.memory=t.memory||s,t.table=t.table||r,dt(i,t)}function ct(t){return"undefined"!=typeof Response&&t instanceof Response}function mt(t){return t instanceof WebAssembly.Module}async function ut(t,e={}){if(ct(t=await t))return ft(t,e);const i=mt(t)?t:await WebAssembly.compile(t),s=lt(e),r=await WebAssembly.instantiate(i,e);return{module:i,instance:r,exports:gt(s,r)}}async function ft(t,e={}){if(!WebAssembly.instantiateStreaming)return ut(ct(t=await t)?t.arrayBuffer():t,e);const i=lt(e),s=await WebAssembly.instantiateStreaming(t,e),r=gt(i,s.instance);return{...s,exports:r}}function dt(t,e={}){const i=t.__argumentsLength?e=>{t.__argumentsLength.value=e}:t.__setArgumentsLength||t.__setargc||(()=>{});for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const r=t[s];let a=s.split("."),o=e;for(;a.length>1;){let t=a.shift();Object.prototype.hasOwnProperty.call(o,t)||(o[t]={}),o=o[t]}let h=a[0],A=h.indexOf("#");if(A>=0){const e=h.substring(0,A),a=o[e];if(void 0===a||!a.prototype){const t=function(...e){return t.wrap(t.prototype.constructor(0,...e))};t.prototype={valueOf(){return this[ht]}},t.wrap=function(e){return Object.create(t.prototype,{[ht]:{value:e,writable:!1}})},a&&Object.getOwnPropertyNames(a).forEach(e=>Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))),o[e]=t}if(h=h.substring(A+1),o=o[e].prototype,/^(get|set):/.test(h)){if(!Object.prototype.hasOwnProperty.call(o,h=h.substring(4))){let e=t[s.replace("set:","get:")],i=t[s.replace("get:","set:")];Object.defineProperty(o,h,{get(){return e(this[ht])},set(t){i(this[ht],t)},enumerable:!0})}}else"constructor"===h?(o[h]=(...t)=>(i(t.length),r(...t))).original=r:(o[h]=function(...t){return i(t.length),r(this[ht],...t)}).original=r}else/^(get|set):/.test(h)?Object.prototype.hasOwnProperty.call(o,h=h.substring(4))||Object.defineProperty(o,h,{get:t[s.replace("set:","get:")],set:t[s.replace("get:","set:")],enumerable:!0}):"function"==typeof r&&r!==i?(o[h]=(...t)=>(i(t.length),r(...t))).original=r:o[h]=r}return e}var pt={instantiate:ut,instantiateSync:function(t,e={}){const i=mt(t)?t:new WebAssembly.Module(t),s=lt(e),r=new WebAssembly.Instance(i,e);return{module:i,instance:r,exports:gt(s,r)}},instantiateStreaming:ft,demangle:dt};class Et{constructor(t,e,i=!1){this.samplesIn=t,this.samplesOut=e,this.equalize=i,this.NFREQ=2*e,this.equalize&&this.initEqualizeTable(),this.initBitRevTable(),this.initCosSinTable()}initEqualizeTable(){this.equalizeArr=new Float32Array(this.samplesOut);const t=1/this.samplesOut;for(let e=0;e<this.samplesOut;e++)this.equalizeArr[e]=-.02*Math.log((this.samplesOut-e)*t)}initBitRevTable(){this.bitrevtable=new Uint16Array(this.NFREQ);for(let t=0;t<this.NFREQ;t++)this.bitrevtable[t]=t;let t=0;for(let e=0;e<this.NFREQ;e++){if(t>e){const i=this.bitrevtable[e];this.bitrevtable[e]=this.bitrevtable[t],this.bitrevtable[t]=i}let i=this.NFREQ>>1;for(;i>=1&&t>=i;)t-=i,i>>=1;t+=i}}initCosSinTable(){let t=2,e=0;for(;t<=this.NFREQ;)e+=1,t<<=1;this.cossintable=[new Float32Array(e),new Float32Array(e)],t=2;let i=0;for(;t<=this.NFREQ;){const e=-2*Math.PI/t;this.cossintable[0][i]=Math.cos(e),this.cossintable[1][i]=Math.sin(e),i+=1,t<<=1}}timeToFrequencyDomain(t){const e=new Float32Array(this.NFREQ),i=new Float32Array(this.NFREQ);for(let s=0;s<this.NFREQ;s++){const r=this.bitrevtable[s];r<this.samplesIn?e[s]=t[r]:e[s]=0,i[s]=0}let s=2,r=0;for(;s<=this.NFREQ;){const t=this.cossintable[0][r],a=this.cossintable[1][r];let o=1,h=0;const A=s>>1;for(let r=0;r<A;r++){for(let t=r;t<this.NFREQ;t+=s){const s=t+A,r=o*e[s]-h*i[s],a=o*i[s]+h*e[s];e[s]=e[t]-r,i[s]=i[t]-a,e[t]+=r,i[t]+=a}const n=o;o=n*t-h*a,h=h*t+n*a}s<<=1,r+=1}const a=new Float32Array(this.samplesOut);if(this.equalize)for(let t=0;t<this.samplesOut;t++)a[t]=this.equalizeArr[t]*Math.sqrt(e[t]*e[t]+i[t]*i[t]);else for(let t=0;t<this.samplesOut;t++)a[t]=Math.sqrt(e[t]*e[t]+i[t]*i[t]);return a}}class _t{constructor(t){this.numSamps=512,this.fftSize=2*this.numSamps,this.fft=new Et(this.fftSize,512,!0),t&&(this.audioContext=t,this.audible=t.createDelay(),this.analyser=t.createAnalyser(),this.analyser.smoothingTimeConstant=0,this.analyser.fftSize=this.fftSize,this.audible.connect(this.analyser),this.analyserL=t.createAnalyser(),this.analyserL.smoothingTimeConstant=0,this.analyserL.fftSize=this.fftSize,this.analyserR=t.createAnalyser(),this.analyserR.smoothingTimeConstant=0,this.analyserR.fftSize=this.fftSize,this.splitter=t.createChannelSplitter(2),this.audible.connect(this.splitter),this.splitter.connect(this.analyserL,0),this.splitter.connect(this.analyserR,1)),this.timeByteArray=new Uint8Array(this.fftSize),this.timeByteArrayL=new Uint8Array(this.fftSize),this.timeByteArrayR=new Uint8Array(this.fftSize),this.timeArray=new Int8Array(this.fftSize),this.timeByteArraySignedL=new Int8Array(this.fftSize),this.timeByteArraySignedR=new Int8Array(this.fftSize),this.tempTimeArrayL=new Int8Array(this.fftSize),this.tempTimeArrayR=new Int8Array(this.fftSize),this.timeArrayL=new Int8Array(this.numSamps),this.timeArrayR=new Int8Array(this.numSamps)}sampleAudio(){this.analyser.getByteTimeDomainData(this.timeByteArray),this.analyserL.getByteTimeDomainData(this.timeByteArrayL),this.analyserR.getByteTimeDomainData(this.timeByteArrayR),this.processAudio()}updateAudio(t,e,i){this.timeByteArray.set(t),this.timeByteArrayL.set(e),this.timeByteArrayR.set(i),this.processAudio()}processAudio(){for(let t=0,e=0,i=0;t<this.fftSize;t++)this.timeArray[t]=this.timeByteArray[t]-128,this.timeByteArraySignedL[t]=this.timeByteArrayL[t]-128,this.timeByteArraySignedR[t]=this.timeByteArrayR[t]-128,this.tempTimeArrayL[t]=.5*(this.timeByteArraySignedL[t]+this.timeByteArraySignedL[i]),this.tempTimeArrayR[t]=.5*(this.timeByteArraySignedR[t]+this.timeByteArraySignedR[i]),t%2==0&&(this.timeArrayL[e]=this.tempTimeArrayL[t],this.timeArrayR[e]=this.tempTimeArrayR[t],e+=1),i=t;this.freqArray=this.fft.timeToFrequencyDomain(this.timeArray),this.freqArrayL=this.fft.timeToFrequencyDomain(this.timeByteArraySignedL),this.freqArrayR=this.fft.timeToFrequencyDomain(this.timeByteArraySignedR)}connectAudio(t){t.connect(this.audible)}disconnectAudio(t){t.disconnect(this.audible)}}class bt{constructor(t){let e;this.audio=t,e=this.audio.audioContext?this.audio.audioContext.sampleRate:44100;const i=e/this.audio.fftSize,s=Math.clamp(Math.round(20/i)-1,0,this.audio.numSamps-1),r=Math.clamp(Math.round(320/i)-1,0,this.audio.numSamps-1),a=Math.clamp(Math.round(2800/i)-1,0,this.audio.numSamps-1),o=Math.clamp(Math.round(11025/i)-1,0,this.audio.numSamps-1);this.starts=[s,r,a],this.stops=[r,a,o],this.val=new Float32Array(3),this.imm=new Float32Array(3),this.att=new Float32Array(3),this.avg=new Float32Array(3),this.longAvg=new Float32Array(3),this.att.fill(1),this.avg.fill(1),this.longAvg.fill(1)}get bass(){return this.val[0]}get bass_att(){return this.att[0]}get mid(){return this.val[1]}get mid_att(){return this.att[1]}get treb(){return this.val[2]}get treb_att(){return this.att[2]}static isFiniteNumber(t){return Number.isFinite(t)&&!Number.isNaN(t)}static adjustRateToFPS(t,e,i){return t**(e/i)}updateAudioLevels(t,e){if(this.audio.freqArray.length>0){let i=t;!bt.isFiniteNumber(i)||i<15?i=15:i>144&&(i=144),this.imm.fill(0);for(let t=0;t<3;t++)for(let e=this.starts[t];e<this.stops[t];e++)this.imm[t]+=this.audio.freqArray[e];for(let t=0;t<3;t++){let s;s=this.imm[t]>this.avg[t]?.2:.5,s=bt.adjustRateToFPS(s,30,i),this.avg[t]=this.avg[t]*s+this.imm[t]*(1-s),s=e<50?.9:.992,s=bt.adjustRateToFPS(s,30,i),this.longAvg[t]=this.longAvg[t]*s+this.imm[t]*(1-s),this.longAvg[t]<.001?(this.val[t]=1,this.att[t]=1):(this.val[t]=this.imm[t]/this.longAvg[t],this.att[t]=this.avg[t]/this.longAvg[t])}}}}const xt={baseVals:{gammaadj:1.25,wave_g:.5,mv_x:12,warpscale:1,brighten:0,mv_y:9,wave_scale:1,echo_alpha:0,additivewave:0,sx:1,sy:1,warp:.01,red_blue:0,wave_mode:0,wave_brighten:0,wrap:0,zoomexp:1,fshader:0,wave_r:.5,echo_zoom:1,wave_smoothing:.75,warpanimspeed:1,wave_dots:0,wave_x:.5,wave_y:.5,zoom:1,solarize:0,modwavealphabyvolume:0,dx:0,cx:.5,dy:0,darken_center:0,cy:.5,invert:0,bmotionvectorson:0,rot:0,modwavealphaend:.95,wave_mystery:-.2,decay:.9,wave_a:1,wave_b:.5,rating:5,modwavealphastart:.75,darken:0,echo_orient:0,ib_r:.5,ib_g:.5,ib_b:.5,ib_a:0,ib_size:0,ob_r:.5,ob_g:.5,ob_b:.5,ob_a:0,ob_size:0,mv_dx:0,mv_dy:0,mv_a:0,mv_r:.5,mv_g:.5,mv_b:.5,mv_l:0},init_eqs:function(){return{}},frame_eqs:function(t){return t.rkeys=["warp"],t.zoom=1.01+.02*t.treb_att,t.warp=.15+.25*t.bass_att,t},pixel_eqs:function(t){return t.warp=t.warp+.15*t.rad,t},waves:[{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""}],shapes:[{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}}],warp:"shader_body {\nret = texture2D(sampler_main, uv).rgb;\nret -= 0.004;\n}\n",comp:"shader_body {\nret = texture2D(sampler_main, uv).rgb;\nret *= hue_shader;\n}\n"};class vt{static atan2(t,e){let i=Math.atan2(t,e);return i<0&&(i+=2*Math.PI),i}static cloneVars(t){return Object.assign({},t)}static range(t,e){return void 0===e?[...Array(t).keys()]:Array.from({length:e-t},(e,i)=>i+t)}static pick(t,e){const i={};for(let s=0;s<e.length;s++){const r=e[s];i[r]=t[r]||0}return i}static omit(t,e){const i=Object.assign({},t);for(let t=0;t<e.length;t++){delete i[e[t]]}return i}static setWasm(t,e,i){for(let s=0;s<i.length;s++){const r=i[s];t[r].value=e[r]}}static pickWasm(t,e){const i={};for(let s=0;s<e.length;s++){const r=e[s];i[r]=t[r].value}return i}}class Tt{constructor(t=1){this.state=new Uint32Array(4),Tt.initializeState(this.state,t),this.warmUp()}static initializeState(t,e){t[0]=e,t[1]=2654435769^e,t[2]=1779033703^e,t[3]=3144134277^e}warmUp(){for(let t=0;t<10;t++)this.next()}next(){let t=this.state[3],e=this.state[0];return this.state[3]=this.state[2],this.state[2]=this.state[1],this.state[1]=e,t^=t<<11,t^=t>>>8,this.state[0]=t^e^e>>>19,(this.state[0]>>>0)/4294967296}nextInt(t){return Math.floor(this.next()*t)}rand(t){return t<1?this.next():Math.floor(this.next()*Math.floor(t))}reset(t){Tt.initializeState(this.state,t),this.warmUp()}}function wt(){return{random:Math.random,rand:t=>t<1?Math.random():Math.random()*Math.floor(t),randint:t=>Math.floor((t<1?Math.random():Math.random()*Math.floor(t))+1),getRNG:()=>null,reset:()=>{}}}let St=null;function Pt(t={}){return St=t.deterministic||t.testMode?function(t=1){const e=new Tt(t);return{random:()=>e.next(),rand:t=>e.rand(t),randint:t=>Math.floor(e.rand(t)+1),getRNG:()=>e,reset:i=>{void 0!==i?e.reset(i):e.reset(t)}}}(t.seed||12345):wt(),(t.deterministic||t.testMode)&&(window.rand=t=>St.rand(t),window.randint=t=>St.randint(t),Math.random=()=>St.random()),St}function Rt(){return St||(St=wt()),St}class It{constructor(t,e,i){this.rng=Rt(),this.preset=t,this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=vt.range(1,33).map(t=>`q${t}`),this.ts=vt.range(1,9).map(t=>`t${t}`),this.regs=vt.range(100).map(t=>t<10?`reg0${t}`:`reg${t}`),this.initializeEquations(e)}initializeEquations(t){this.runVertEQs=""!==this.preset.pixel_eqs,this.mdVSQInit=null,this.mdVSRegs=null,this.mdVSFrame=null,this.mdVSUserKeys=null,this.mdVSFrameMap=null,this.mdVSShapes=null,this.mdVSUserKeysShapes=null,this.mdVSFrameMapShapes=null,this.mdVSWaves=null,this.mdVSUserKeysWaves=null,this.mdVSFrameMapWaves=null,this.mdVSQAfterFrame=null,this.gmegabuf=new Array(1048576).fill(0);const e={frame:t.frame,time:t.time,fps:t.fps,bass:t.bass,bass_att:t.bass_att,mid:t.mid,mid_att:t.mid_att,treb:t.treb,treb_att:t.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY,gmegabuf:this.gmegabuf};this.mdVS=Object.assign({},this.preset.baseVals,e),this.mdVS.megabuf=new Array(1048576).fill(0),this.mdVS.rand_start=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]),this.mdVS.rand_preset=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]);const i=this.qs.concat(this.regs,Object.keys(this.mdVS)),s=this.preset.init_eqs(vt.cloneVars(this.mdVS));this.mdVSQInit=vt.pick(s,this.qs),this.mdVSRegs=vt.pick(s,this.regs);const r=vt.pick(s,Object.keys(vt.omit(s,i)));if(r.megabuf=s.megabuf,r.gmegabuf=s.gmegabuf,this.mdVSFrame=this.preset.frame_eqs(Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSRegs,r)),this.mdVSUserKeys=Object.keys(vt.omit(this.mdVSFrame,i)),this.mdVSFrameMap=vt.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=vt.pick(this.mdVSFrame,this.qs),this.mdVSRegs=vt.pick(this.mdVSFrame,this.regs),this.mdVSWaves=[],this.mdVSTWaveInits=[],this.mdVSUserKeysWaves=[],this.mdVSFrameMapWaves=[],this.preset.waves&&this.preset.waves.length>0)for(let t=0;t<this.preset.waves.length;t++){const i=this.preset.waves[t],s=i.baseVals;if(0!==s.enabled){let r=Object.assign({},s,e);const a=this.qs.concat(this.ts,this.regs,Object.keys(r));Object.assign(r,this.mdVSQAfterFrame,this.mdVSRegs),r.megabuf=new Array(1048576).fill(0),i.init_eqs&&(r=i.init_eqs(r),this.mdVSRegs=vt.pick(r,this.regs),Object.assign(r,s)),this.mdVSWaves.push(r),this.mdVSTWaveInits.push(vt.pick(r,this.ts)),this.mdVSUserKeysWaves.push(Object.keys(vt.omit(r,a))),this.mdVSFrameMapWaves.push(vt.pick(r,this.mdVSUserKeysWaves[t]))}else this.mdVSWaves.push({}),this.mdVSTWaveInits.push({}),this.mdVSUserKeysWaves.push([]),this.mdVSFrameMapWaves.push({})}if(this.mdVSShapes=[],this.mdVSTShapeInits=[],this.mdVSUserKeysShapes=[],this.mdVSFrameMapShapes=[],this.preset.shapes&&this.preset.shapes.length>0)for(let t=0;t<this.preset.shapes.length;t++){const i=this.preset.shapes[t],s=i.baseVals;if(0!==s.enabled){let r=Object.assign({},s,e);const a=this.qs.concat(this.ts,this.regs,Object.keys(r));Object.assign(r,this.mdVSQAfterFrame,this.mdVSRegs),r.megabuf=new Array(1048576).fill(0),i.init_eqs&&(r=i.init_eqs(r),this.mdVSRegs=vt.pick(r,this.regs),Object.assign(r,s)),this.mdVSShapes.push(r),this.mdVSTShapeInits.push(vt.pick(r,this.ts)),this.mdVSUserKeysShapes.push(Object.keys(vt.omit(r,a))),this.mdVSFrameMapShapes.push(vt.pick(r,this.mdVSUserKeysShapes[t]))}else this.mdVSShapes.push({}),this.mdVSTShapeInits.push({}),this.mdVSUserKeysShapes.push([]),this.mdVSFrameMapShapes.push({})}}updatePreset(t,e){this.preset=t,this.initializeEquations(e)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}runFrameEquations(t){return this.mdVSFrame=Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSFrameMap,t),this.mdVSFrame=this.preset.frame_eqs(this.mdVSFrame),this.mdVSFrameMap=vt.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=vt.pick(this.mdVSFrame,this.qs),this.mdVSFrame}runPixelEquations(t){return this.preset.pixel_eqs(t)}runShapeFrameEquations(t,e){return this.preset.shapes[t].frame_eqs(e)}runWaveFrameEquations(t,e){return this.preset.waves[t].frame_eqs(e)}runWavePointEquations(t,e){return this.preset.waves[t].point_eqs(e)}}class yt{constructor(t,e,i){this.rng=Rt(),this.preset=t,this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=vt.range(1,33).map(t=>`q${t}`),this.ts=vt.range(1,9).map(t=>`t${t}`),this.regs=vt.range(100).map(t=>t<10?`reg0${t}`:`reg${t}`),this.globalKeys=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy"],this.frameKeys=["decay","wave_a","wave_r","wave_g","wave_b","wave_x","wave_y","wave_scale","wave_smoothing","wave_mode","old_wave_mode","wave_mystery","ob_size","ob_r","ob_g","ob_b","ob_a","ib_size","ib_r","ib_g","ib_b","ib_a","mv_x","mv_y","mv_dx","mv_dy","mv_l","mv_r","mv_g","mv_b","mv_a","echo_zoom","echo_alpha","echo_orient","wave_dots","wave_thick","additivewave","wave_brighten","modwavealphabyvolume","modwavealphastart","modwavealphaend","darken_center","gammaadj","warp","warpanimspeed","warpscale","zoom","zoomexp","rot","cx","cy","dx","dy","sx","sy","fshader","wrap","invert","brighten","darken","solarize","bmotionvectorson","b1n","b2n","b3n","b1x","b2x","b3x","b1ed"],this.waveFrameKeys=["samples","sep","scaling","spectrum","smoothing","r","g","b","a"],this.waveFrameInputKeys=["samples","r","g","b","a"],this.initializeEquations(e)}getQVars(t){return vt.pickWasm(this.preset.globalPools[t],this.qs)}getTVars(t){return vt.pickWasm(this.preset.globalPools[t],this.ts)}initializeEquations(t){this.runVertEQs=!!this.preset.pixel_eqs,this.mdVSQInit=null,this.mdVSQAfterFrame=null;const e={frame:t.frame,time:t.time,fps:t.fps,bass:t.bass,bass_att:t.bass_att,mid:t.mid,mid_att:t.mid_att,treb:t.treb,treb_att:t.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY};if(this.mdVS=Object.assign({},this.preset.baseVals,e),vt.setWasm(this.preset.globalPools.perFrame,this.mdVS,Object.keys(this.mdVS)),this.rand_start=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]),this.rand_preset=new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()]),this.preset.init_eqs(),this.mdVSQInit=this.getQVars("perFrame"),this.preset.frame_eqs(),this.mdVSQAfterFrame=this.getQVars("perFrame"),this.mdVSTWaveInits=[],this.preset.waves&&this.preset.waves.length>0)for(let t=0;t<this.preset.waves.length;t++){const e=this.preset.waves[t],i=e.baseVals;0!==i.enabled?(vt.setWasm(this.preset.globalPools[`wavePerFrame${t}`],i,Object.keys(i)),e.init_eqs&&(e.init_eqs(),vt.setWasm(this.preset.globalPools[`wavePerFrame${t}`],i,Object.keys(i))),this.mdVSTWaveInits.push(this.getTVars(`wavePerFrame${t}`))):this.mdVSTWaveInits.push({})}if(this.mdVSTShapeInits=[],this.preset.shapes&&this.preset.shapes.length>0)for(let t=0;t<this.preset.shapes.length;t++){const e=this.preset.shapes[t],i=e.baseVals;0!==i.enabled?(vt.setWasm(this.preset.globalPools[`shapePerFrame${t}`],i,Object.keys(i)),e.init_eqs&&(e.init_eqs(),vt.setWasm(this.preset.globalPools[`shapePerFrame${t}`],i,Object.keys(i))),this.mdVSTShapeInits.push(this.getTVars(`shapePerFrame${t}`))):this.mdVSTShapeInits.push({})}}updatePreset(t,e){this.preset=t,this.initializeEquations(e)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}runFrameEquations(t){vt.setWasm(this.preset.globalPools.perFrame,this.mdVS,this.frameKeys),vt.setWasm(this.preset.globalPools.perFrame,this.mdVSQInit,this.qs),vt.setWasm(this.preset.globalPools.perFrame,t,this.globalKeys),this.preset.frame_eqs(),this.preset.save_qs(),this.mdVSQAfterFrame=this.getQVars("perFrame");const e=vt.pickWasm(this.preset.globalPools.perFrame,[...this.frameKeys,...this.globalKeys]);return e.rand_preset=this.rand_preset,e.rand_start=this.rand_start,e}runWaveFrameEquations(t,e){const i=this.preset.waves[t].baseVals;return vt.setWasm(this.preset.globalPools[`wavePerFrame${t}`],i,this.waveFrameInputKeys),vt.setWasm(this.preset.globalPools[`wavePerFrame${t}`],this.mdVSQAfterFrame,this.qs),vt.setWasm(this.preset.globalPools[`wavePerFrame${t}`],this.mdVSTWaveInits[t],this.ts),vt.setWasm(this.preset.globalPools[`wavePerFrame${t}`],e,this.globalKeys),this.preset.waves[t].frame_eqs(),vt.pickWasm(this.preset.globalPools[`wavePerFrame${t}`],this.waveFrameKeys)}}const Bt=/uniform sampler2D sampler_(?:.+?);/g,Lt=/uniform sampler2D sampler_(.+?);/;class Ut{static getShaderParts(t){const e=t.indexOf("shader_body");if(t&&e>-1){const i=t.substring(0,e),s=t.substring(e),r=s.indexOf("{"),a=s.lastIndexOf("}");return[i,s.substring(r+1,a)]}return["",t]}static getFragmentFloatPrecision(t){return t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0?"highp":t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}static getUserSamplers(t){const e=[],i=t.match(Bt);if(i&&i.length>0)for(let t=0;t<i.length;t++){const s=i[t].match(Lt);if(s&&s.length>0){const t=s[1];e.push({sampler:t})}}return e}}class Ct{static smoothWave(t,e,i,s=!1){const r=-.15,a=1.15,o=1.15,h=-.15;let A,n=0,l=0,g=1;for(let c=0;c<i-1;c++){A=g,g=Math.min(i-1,c+2);for(let i=0;i<3;i++)e[3*n+i]=t[3*c+i];if(s)for(let i=0;i<3;i++)e[3*(n+1)+i]=.5*(r*t[3*l+i]+a*t[3*c+i]+o*t[3*A+i]+h*t[3*g+i]);else{for(let i=0;i<2;i++)e[3*(n+1)+i]=.5*(r*t[3*l+i]+a*t[3*c+i]+o*t[3*A+i]+h*t[3*g+i]);e[3*(n+1)+2]=0}l=c,n+=2}for(let s=0;s<3;s++)e[3*n+s]=t[3*(i-1)+s]}static smoothWaveAndColor(t,e,i,s,r,a=!1){const o=-.15,h=1.15,A=1.15,n=-.15;let l,g=0,c=0,m=1;for(let u=0;u<r-1;u++){l=m,m=Math.min(r-1,u+2);for(let e=0;e<3;e++)i[3*g+e]=t[3*u+e];if(a)for(let e=0;e<3;e++)i[3*(g+1)+e]=.5*(o*t[3*c+e]+h*t[3*u+e]+A*t[3*l+e]+n*t[3*m+e]);else{for(let e=0;e<2;e++)i[3*(g+1)+e]=.5*(o*t[3*c+e]+h*t[3*u+e]+A*t[3*l+e]+n*t[3*m+e]);i[3*(g+1)+2]=0}for(let t=0;t<4;t++)s[4*g+t]=e[4*u+t],s[4*(g+1)+t]=e[4*u+t];c=u,g+=2}for(let e=0;e<3;e++)i[3*g+e]=t[3*(r-1)+e];for(let t=0;t<4;t++)s[4*g+t]=e[4*(r-1)+t]}}class Ft{constructor(t,e={}){this.gl=t;this.positions=new Float32Array(1536),this.positions2=new Float32Array(1536),this.oldPositions=new Float32Array(1536),this.oldPositions2=new Float32Array(1536),this.smoothedPositions=new Float32Array(3069),this.smoothedPositions2=new Float32Array(3069),this.color=[0,0,0,1],this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      uniform vec2 thickOffset;\n      void main(void) {\n        gl_Position = vec4(aPos + vec3(thickOffset, 0.0), 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 u_color;\n      void main(void) {\n        fragColor = u_color;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}static processWaveform(t,e){const i=[],s=e.wave_scale/128,r=e.wave_smoothing,a=s*(1-r);i.push(t[0]*s);for(let e=1;e<t.length;e++)i.push(t[e]*a+i[e-1]*r);return i}generateWaveform(t,e,i,s,r){let a=r.wave_a;const o=(r.bass+r.mid+r.treb)/3;if(o>-.01&&a>.001&&i.length>0){const h=Ft.processWaveform(i,r),A=Ft.processWaveform(s,r),n=Math.floor(r.wave_mode)%8,l=Math.floor(r.old_wave_mode)%8,g=2*r.wave_x-1,c=2*r.wave_y-1;this.numVert=0,this.oldNumVert=0;const m=t&&n!==l?2:1;for(let t=0;t<m;t++){const e=0===t?n:l;let i,s,m,u=r.wave_mystery;if(0!==e&&1!==e&&4!==e||!(u<-1||u>1)||(u=.5*u+.5,u-=Math.floor(u),u=Math.abs(u),u=2*u-1),0===t?(s=this.positions,m=this.positions2):(s=this.oldPositions,m=this.oldPositions2),a=r.wave_a,0===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=Math.floor(h.length/2)+1;const t=1/(i-1),e=Math.floor((h.length-i)/2);for(let a=0;a<i-1;a++){let o=.5+.4*A[a+e]+u;const h=a*t*2*Math.PI+.2*r.time;if(a<i/10){let t=a/(.1*i);t=.5-.5*Math.cos(t*Math.PI);o=(1-t)*(.5+.4*A[a+i+e]+u)+o*t}s[3*a+0]=o*Math.cos(h)*this.aspecty+g,s[3*a+1]=o*Math.sin(h)*this.aspectx+c,s[3*a+2]=0}s[3*(i-1)+0]=s[0],s[3*(i-1)+1]=s[1],s[3*(i-1)+2]=0}else if(1===e){if(a*=1.25,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=Math.floor(h.length/2);for(let t=0;t<i;t++){const e=.53+.43*A[t]+u,i=.5*h[t+32]*Math.PI+2.3*r.time;s[3*t+0]=e*Math.cos(i)*this.aspecty+g,s[3*t+1]=e*Math.sin(i)*this.aspectx+c,s[3*t+2]=0}}else if(2===e){if(this.texsizeX<1024?a*=.09:this.texsizeX>=1024&&this.texsizeX<2048?a*=.11:a*=.13,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=h.length;for(let t=0;t<h.length;t++)s[3*t+0]=A[t]*this.aspecty+g,s[3*t+1]=h[(t+32)%h.length]*this.aspectx+c,s[3*t+2]=0}else if(3===e){if(this.texsizeX<1024?a*=.15:this.texsizeX>=1024&&this.texsizeX<2048?a*=.22:a*=.33,a*=1.3,a*=r.treb*r.treb,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=h.length;for(let t=0;t<h.length;t++)s[3*t+0]=A[t]*this.aspecty+g,s[3*t+1]=h[(t+32)%h.length]*this.aspectx+c,s[3*t+2]=0}else if(4===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=h.length,i>this.texsizeX/3&&(i=Math.floor(this.texsizeX/3));const t=1/i,e=Math.floor((h.length-i)/2),n=.45+.5*(.5*u+.5),l=1-n;for(let r=0;r<i;r++){let i=2*r*t+(g-1)+.44*A[(r+25+e)%h.length],a=.47*h[r+e]+c;r>1&&(i=i*l+n*(2*s[3*(r-1)+0]-s[3*(r-2)+0]),a=a*l+n*(2*s[3*(r-1)+1]-s[3*(r-2)+1])),s[3*r+0]=i,s[3*r+1]=a,s[3*r+2]=0}}else if(5===e){if(this.texsizeX<1024?a*=.09:this.texsizeX>=1024&&this.texsizeX<2048?a*=.11:a*=.13,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1);const t=Math.cos(.3*r.time),e=Math.sin(.3*r.time);i=h.length;for(let i=0;i<h.length;i++){const r=(i+32)%h.length,a=A[i]*h[r]+h[i]*A[r],o=A[i]*A[i]-h[r]*h[r];s[3*i+0]=(a*t-o*e)*(this.aspecty+g),s[3*i+1]=(a*e+o*t)*(this.aspectx+c),s[3*i+2]=0}}else if(6===e||7===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;a*=(o-r.modwavealphastart)/t}a=Math.clamp(a,0,1),i=Math.floor(h.length/2),i>this.texsizeX/3&&(i=Math.floor(this.texsizeX/3));const t=Math.floor((h.length-i)/2),n=.5*Math.PI*u;let l=Math.cos(n),f=Math.sin(n);const d=[g*Math.cos(n+.5*Math.PI)-3*l,g*Math.cos(n+.5*Math.PI)+3*l],p=[g*Math.sin(n+.5*Math.PI)-3*f,g*Math.sin(n+.5*Math.PI)+3*f];for(let t=0;t<2;t++)for(let e=0;e<4;e++){let i,s=!1;switch(e){case 0:d[t]>1.1&&(i=(1.1-d[1-t])/(d[t]-d[1-t]),s=!0);break;case 1:d[t]<-1.1&&(i=(-1.1-d[1-t])/(d[t]-d[1-t]),s=!0);break;case 2:p[t]>1.1&&(i=(1.1-p[1-t])/(p[t]-p[1-t]),s=!0);break;case 3:p[t]<-1.1&&(i=(-1.1-p[1-t])/(p[t]-p[1-t]),s=!0)}if(s){const e=d[t]-d[1-t],s=p[t]-p[1-t];d[t]=d[1-t]+e*i,p[t]=p[1-t]+s*i}}l=(d[1]-d[0])/i,f=(p[1]-p[0])/i;const E=Math.atan2(f,l),_=Math.cos(E+.5*Math.PI),b=Math.sin(E+.5*Math.PI);if(6===e)for(let e=0;e<i;e++){const i=h[e+t];s[3*e+0]=d[0]+l*e+.25*_*i,s[3*e+1]=p[0]+f*e+.25*b*i,s[3*e+2]=0}else if(7===e){const e=(.5*c+.5)**2;for(let r=0;r<i;r++){const i=h[r+t];s[3*r+0]=d[0]+l*r+_*(.25*i+e),s[3*r+1]=p[0]+f*r+b*(.25*i+e),s[3*r+2]=0}for(let s=0;s<i;s++){const i=A[s+t];m[3*s+0]=d[0]+l*s+_*(.25*i-e),m[3*s+1]=p[0]+f*s+b*(.25*i-e),m[3*s+2]=0}}}0===t?(this.positions=s,this.positions2=m,this.numVert=i,this.alpha=a):(this.oldPositions=s,this.oldPositions2=m,this.oldNumVert=i,this.oldAlpha=a)}const u=.5-.5*Math.cos(e*Math.PI),f=1-u;this.oldNumVert>0&&(a=u*this.alpha+f*this.oldAlpha);let d=Math.clamp(r.wave_r,0,1),p=Math.clamp(r.wave_g,0,1),E=Math.clamp(r.wave_b,0,1);if(0!==r.wave_brighten){const t=Math.max(d,p,E);t>.01&&(d/=t,p/=t,E/=t)}if(this.color=[d,p,E,a],this.oldNumVert>0)if(7===n){const t=(this.oldNumVert-1)/(2*this.numVert);for(let e=0;e<this.numVert;e++){const i=e*t,s=Math.floor(i),r=i-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions[3*e+0]=this.positions[3*e+0]*u+a*f,this.positions[3*e+1]=this.positions[3*e+1]*u+o*f,this.positions[3*e+2]=0}for(let e=0;e<this.numVert;e++){const i=(e+this.numVert)*t,s=Math.floor(i),r=i-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions2[3*e+0]=this.positions2[3*e+0]*u+a*f,this.positions2[3*e+1]=this.positions2[3*e+1]*u+o*f,this.positions2[3*e+2]=0}}else if(7===l){const t=this.numVert/2,e=(this.oldNumVert-1)/t;for(let i=0;i<t;i++){const t=i*e,s=Math.floor(t),r=t-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions[3*i+0]=this.positions[3*i+0]*u+a*f,this.positions[3*i+1]=this.positions[3*i+1]*u+o*f,this.positions[3*i+2]=0}for(let i=0;i<t;i++){const s=i*e,r=Math.floor(s),a=s-r,o=this.oldPositions2[3*r+0]*(1-a)+this.oldPositions2[3*(r+1)+0]*a,h=this.oldPositions2[3*r+1]*(1-a)+this.oldPositions2[3*(r+1)+1]*a;this.positions2[3*i+0]=this.positions[3*(i+t)+0]*u+o*f,this.positions2[3*i+1]=this.positions[3*(i+t)+1]*u+h*f,this.positions2[3*i+2]=0}}else{const t=(this.oldNumVert-1)/this.numVert;for(let e=0;e<this.numVert;e++){const i=e*t,s=Math.floor(i),r=i-s,a=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,o=this.oldPositions[3*s+1]*(1-r)+this.oldPositions[3*(s+1)+1]*r;this.positions[3*e+0]=this.positions[3*e+0]*u+a*f,this.positions[3*e+1]=this.positions[3*e+1]*u+o*f,this.positions[3*e+2]=0}}for(let t=0;t<this.numVert;t++)this.positions[3*t+1]=-this.positions[3*t+1];if(this.smoothedNumVert=2*this.numVert-1,Ct.smoothWave(this.positions,this.smoothedPositions,this.numVert),7===n||7===l){for(let t=0;t<this.numVert;t++)this.positions2[3*t+1]=-this.positions2[3*t+1];Ct.smoothWave(this.positions2,this.smoothedPositions2,this.numVert)}return!0}return!1}drawBasicWaveform(t,e,i,s,r){if(this.generateWaveform(t,e,i,s,r)){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.smoothedPositions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,this.color);let t=1;0===r.wave_thick&&0===r.wave_dots||(t=4),0!==r.additivewave?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const e=0!==r.wave_dots?this.gl.POINTS:this.gl.LINE_STRIP;for(let i=0;i<t;i++){const t=2;0===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===i?this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,0]):2===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,t/this.texsizeY]):3===i&&this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,t/this.texsizeY]),this.gl.drawArrays(e,0,this.smoothedNumVert)}if(7===Math.floor(r.wave_mode)%8){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.smoothedPositions2,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc);for(let i=0;i<t;i++){const t=2;0===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===i?this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,0]):2===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,t/this.texsizeY]):3===i&&this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,t/this.texsizeY]),this.gl.drawArrays(e,0,this.smoothedNumVert)}}}}}class Qt{constructor(t,e,i){this.index=t,this.gl=e;const s=512;this.pointsData=[new Float32Array(s),new Float32Array(s)],this.positions=new Float32Array(1536),this.colors=new Float32Array(2048),this.smoothedPositions=new Float32Array(3069),this.smoothedColors=new Float32Array(4092),this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      uniform float uSize;\n      uniform vec2 thickOffset;\n      in vec3 aPos;\n      in vec4 aColor;\n      out vec4 vColor;\n      void main(void) {\n        vColor = aColor;\n        gl_PointSize = uSize;\n        gl_Position = vec4(aPos + vec3(thickOffset, 0.0), 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      in vec4 vColor;\n      out vec4 fragColor;\n      void main(void) {\n        fragColor = vColor;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor"),this.sizeLoc=this.gl.getUniformLocation(this.shaderProgram,"uSize"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}generateWaveform(t,e,i,s,r,a,o,h){if(0!==o.baseVals.enabled&&t.length>0){let A;if(a.preset.useWASM)A=a.runWaveFrameEquations(this.index,r);else{const t=Object.assign({},a.mdVSWaves[this.index],a.mdVSFrameMapWaves[this.index],a.mdVSQAfterFrame,a.mdVSTWaveInits[this.index],r);A=a.runWaveFrameEquations(this.index,t)}const n=512;Object.prototype.hasOwnProperty.call(A,"samples")?this.samples=A.samples:this.samples=n,this.samples>n&&(this.samples=n),this.samples=Math.floor(this.samples);const l=a.preset.waves[this.index].baseVals,g=Math.floor(A.sep),c=A.scaling,m=A.spectrum,u=A.smoothing,f=l.usedots,d=A.r,p=A.g,E=A.b,_=A.a,b=a.preset.baseVals.wave_scale;if(this.samples-=g,this.samples>=2||0!==f&&this.samples>=1){const r=0!==m,x=(r?.15:.004)*c*b,v=r?i:t,T=r?s:e,w=r?0:Math.floor((n-this.samples)/2-g/2),S=r?0:Math.floor((n-this.samples)/2+g/2),P=r?(n-g)/this.samples:1,R=(.98*u)**.5,I=1-R;this.pointsData[0][0]=v[w],this.pointsData[1][0]=T[S];for(let t=1;t<this.samples;t++){const e=v[Math.floor(t*P+w)],i=T[Math.floor(t*P+S)];this.pointsData[0][t]=e*I+this.pointsData[0][t-1]*R,this.pointsData[1][t]=i*I+this.pointsData[1][t-1]*R}for(let t=this.samples-2;t>=0;t--)this.pointsData[0][t]=this.pointsData[0][t]*I+this.pointsData[0][t+1]*R,this.pointsData[1][t]=this.pointsData[1][t]*I+this.pointsData[1][t+1]*R;for(let t=0;t<this.samples;t++)this.pointsData[0][t]*=x,this.pointsData[1][t]*=x;if(a.preset.useWASM){const t=a.preset.globalPools[`wavePerFrame${this.index}`];for(let e=0;e<this.samples;e++){const i=this.pointsData[0][e],s=this.pointsData[1][e];t.sample.value=e/(this.samples-1),t.value1.value=i,t.value2.value=s,t.x.value=.5+i,t.y.value=.5+s,t.r.value=d,t.g.value=p,t.b.value=E,t.a.value=_,o.point_eqs&&a.preset.waves[this.index].point_eqs();const r=(2*t.x.value-1)*this.invAspectx,A=(-2*t.y.value+1)*this.invAspecty,n=t.r.value,l=t.g.value,g=t.b.value,c=t.a.value;this.positions[3*e+0]=r,this.positions[3*e+1]=A,this.positions[3*e+2]=0,this.colors[4*e+0]=n,this.colors[4*e+1]=l,this.colors[4*e+2]=g,this.colors[4*e+3]=c*h}}else for(let t=0;t<this.samples;t++){const e=this.pointsData[0][t],i=this.pointsData[1][t];A.sample=t/(this.samples-1),A.value1=e,A.value2=i,A.x=.5+e,A.y=.5+i,A.r=d,A.g=p,A.b=E,A.a=_,""!==o.point_eqs&&(A=a.runWavePointEquations(this.index,A));const s=(2*A.x-1)*this.invAspectx,r=(-2*A.y+1)*this.invAspecty,n=A.r,l=A.g,g=A.b,c=A.a;this.positions[3*t+0]=s,this.positions[3*t+1]=r,this.positions[3*t+2]=0,this.colors[4*t+0]=n,this.colors[4*t+1]=l,this.colors[4*t+2]=g,this.colors[4*t+3]=c*h}if(a.preset.useWASM)A.usedots=f,A.thick=l.thick,A.additive=l.additive;else{const t=a.mdVSUserKeysWaves[this.index],e=vt.pick(A,t);a.mdVSFrameMapWaves[this.index]=e}return this.mdVSWaveFrame=A,0===f&&Ct.smoothWaveAndColor(this.positions,this.colors,this.smoothedPositions,this.smoothedColors,this.samples),!0}}return!1}drawCustomWaveform(t,e,i,s,r,a,o,h){if(h&&this.generateWaveform(e,i,s,r,a,o,h,t)){this.gl.useProgram(this.shaderProgram);const t=0!==this.mdVSWaveFrame.usedots,e=0!==this.mdVSWaveFrame.thick,i=0!==this.mdVSWaveFrame.additive;let s,r,a;t?(s=this.positions,r=this.colors,a=this.samples):(s=this.smoothedPositions,r=this.smoothedColors,a=2*this.samples-1),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation);let o=1;t?e?this.gl.uniform1f(this.sizeLoc,2+(this.texsizeX>=1024?1:0)):this.gl.uniform1f(this.sizeLoc,1+(this.texsizeX>=1024?1:0)):(this.gl.uniform1f(this.sizeLoc,1),e&&(o=4)),i?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const h=t?this.gl.POINTS:this.gl.LINE_STRIP;for(let t=0;t<o;t++){const e=2;0===t?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===t?this.gl.uniform2fv(this.thickOffsetLoc,[e/this.texsizeX,0]):2===t?this.gl.uniform2fv(this.thickOffsetLoc,[0,e/this.texsizeY]):3===t&&this.gl.uniform2fv(this.thickOffsetLoc,[e/this.texsizeX,e/this.texsizeY]),this.gl.drawArrays(h,0,a)}}}}let Mt=class{constructor(t,e,i){this.index=t,this.gl=e;this.positions=new Float32Array(309),this.colors=new Float32Array(412),this.uvs=new Float32Array(206),this.borderPositions=new Float32Array(306),this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.uvVertexBuf=this.gl.createBuffer(),this.borderPositionVertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader(),this.createBorderShader(),this.mainSampler=this.gl.createSampler(),e.samplerParameteri(this.mainSampler,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_T,e.REPEAT)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      in vec4 aColor;\n      in vec2 aUv;\n      out vec4 vColor;\n      out vec2 vUv;\n      void main(void) {\n        vColor = aColor;\n        vUv = aUv;\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      uniform sampler2D uTexture;\n      uniform float uTextured;\n      in vec4 vColor;\n      in vec2 vUv;\n      out vec4 fragColor;\n      void main(void) {\n        if (uTextured != 0.0) {\n          fragColor = texture(uTexture, vUv) * vColor;\n        } else {\n          fragColor = vColor;\n        }\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor"),this.aUvLocation=this.gl.getAttribLocation(this.shaderProgram,"aUv"),this.texturedLoc=this.gl.getUniformLocation(this.shaderProgram,"uTextured"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}createBorderShader(){this.borderShaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aBorderPos;\n      uniform vec2 thickOffset;\n      void main(void) {\n        gl_Position = vec4(aBorderPos +\n                            vec3(thickOffset, 0.0), 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 uBorderColor;\n      void main(void) {\n        fragColor = uBorderColor;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.borderShaderProgram,t),this.gl.attachShader(this.borderShaderProgram,e),this.gl.linkProgram(this.borderShaderProgram),this.aBorderPosLoc=this.gl.getAttribLocation(this.borderShaderProgram,"aBorderPos"),this.uBorderColorLoc=this.gl.getUniformLocation(this.borderShaderProgram,"uBorderColor"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}drawCustomShape(t,e,i,s,r){if(0!==s.baseVals.enabled)if(i.preset.useWASM){this.setupShapeBuffers(i.preset.globalPools.perFrame.wrap.value);const s=i.preset.shapes[this.index].baseVals,a=i.preset.globalPools[`shapePerFrame${this.index}`];vt.setWasm(a,e,i.globalKeys),i.preset.shapes[this.index].frame_eqs||i.preset.restore_qs(),vt.setWasm(a,i.mdVSTShapeInits[this.index],i.ts),i.preset.save_ts(),a.x.value=s.x,a.y.value=s.y,a.rad.value=s.rad,a.ang.value=s.ang,a.r.value=s.r,a.g.value=s.g,a.b.value=s.b,a.a.value=s.a,a.r2.value=s.r2,a.g2.value=s.g2,a.b2.value=s.b2,a.a2.value=s.a2,a.border_r.value=s.border_r,a.border_g.value=s.border_g,a.border_b.value=s.border_b,a.border_a.value=s.border_a,a.thickoutline.value=s.thickoutline,a.textured.value=s.textured,a.tex_zoom.value=s.tex_zoom,a.tex_ang.value=s.tex_ang,a.additive.value=s.additive,i.preset.shapes[this.index].frame_eqs_save();const o=Math.clamp(s.num_inst,1,1024);for(let e=0;e<o;e++){a.instance.value=e,i.preset.shapes[this.index].frame_eqs&&(i.preset.shapes[this.index].frame_eqs_restore(),i.preset.restore_qs(),i.preset.restore_ts(),i.preset.shapes[this.index].frame_eqs());let s=a.sides.value;s=Math.clamp(s,3,100),s=Math.floor(s);const o=a.rad.value,h=a.ang.value,A=2*a.x.value-1,n=-2*a.y.value+1,l=a.r.value,g=a.g.value,c=a.b.value,m=a.a.value,u=a.r2.value,f=a.g2.value,d=a.b2.value,p=a.a2.value,E=a.border_r.value,_=a.border_g.value,b=a.border_b.value,x=a.border_a.value;this.borderColor=[E,_,b,x*t];const v=a.thickoutline.value,T=a.textured.value,w=a.tex_zoom.value,S=a.tex_ang.value,P=a.additive.value,R=this.borderColor[3]>0,I=Math.abs(T)>=1,y=Math.abs(v)>=1,B=Math.abs(P)>=1;this.positions[0]=A,this.positions[1]=n,this.positions[2]=0,this.colors[0]=l,this.colors[1]=g,this.colors[2]=c,this.colors[3]=m*t,I&&(this.uvs[0]=.5,this.uvs[1]=.5);const L=.25*Math.PI;for(let e=1;e<=s+1;e++){const i=2*((e-1)/s)*Math.PI,r=i+h+L;if(this.positions[3*e+0]=A+o*Math.cos(r)*this.aspecty,this.positions[3*e+1]=n+o*Math.sin(r),this.positions[3*e+2]=0,this.colors[4*e+0]=u,this.colors[4*e+1]=f,this.colors[4*e+2]=d,this.colors[4*e+3]=p*t,I){const t=i+S+L;this.uvs[2*e+0]=.5+.5*Math.cos(t)/w*this.aspecty,this.uvs[2*e+1]=.5+.5*Math.sin(t)/w}R&&(this.borderPositions[3*(e-1)+0]=this.positions[3*e+0],this.borderPositions[3*(e-1)+1]=this.positions[3*e+1],this.borderPositions[3*(e-1)+2]=this.positions[3*e+2])}this.drawCustomShapeInstance(r,s,I,R,y,B)}}else{this.setupShapeBuffers(i.mdVSFrame.wrap);let s=Object.assign({},i.mdVSShapes[this.index],i.mdVSFrameMapShapes[this.index],e);""===i.preset.shapes[this.index].frame_eqs_str&&(s=Object.assign(s,i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index]));const a=i.preset.shapes[this.index].baseVals,o=Math.clamp(a.num_inst,1,1024);for(let e=0;e<o;e++){let o;s.instance=e,s.x=a.x,s.y=a.y,s.rad=a.rad,s.ang=a.ang,s.r=a.r,s.g=a.g,s.b=a.b,s.a=a.a,s.r2=a.r2,s.g2=a.g2,s.b2=a.b2,s.a2=a.a2,s.border_r=a.border_r,s.border_g=a.border_g,s.border_b=a.border_b,s.border_a=a.border_a,s.thickoutline=a.thickoutline,s.textured=a.textured,s.tex_zoom=a.tex_zoom,s.tex_ang=a.tex_ang,s.additive=a.additive,""!==i.preset.shapes[this.index].frame_eqs_str?(s=Object.assign(s,i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index]),o=i.runShapeFrameEquations(this.index,s)):o=s;let h=o.sides;h=Math.clamp(h,3,100),h=Math.floor(h);const A=o.rad,n=o.ang,l=2*o.x-1,g=-2*o.y+1,c=o.r,m=o.g,u=o.b,f=o.a,d=o.r2,p=o.g2,E=o.b2,_=o.a2,b=o.border_r,x=o.border_g,v=o.border_b,T=o.border_a;this.borderColor=[b,x,v,T*t];const w=o.thickoutline,S=o.textured,P=o.tex_zoom,R=o.tex_ang,I=o.additive,y=this.borderColor[3]>0,B=Math.abs(S)>=1,L=Math.abs(w)>=1,U=Math.abs(I)>=1;this.positions[0]=l,this.positions[1]=g,this.positions[2]=0,this.colors[0]=c,this.colors[1]=m,this.colors[2]=u,this.colors[3]=f*t,B&&(this.uvs[0]=.5,this.uvs[1]=.5);const C=.25*Math.PI;for(let e=1;e<=h+1;e++){const i=2*((e-1)/h)*Math.PI,s=i+n+C;if(this.positions[3*e+0]=l+A*Math.cos(s)*this.aspecty,this.positions[3*e+1]=g+A*Math.sin(s),this.positions[3*e+2]=0,this.colors[4*e+0]=d,this.colors[4*e+1]=p,this.colors[4*e+2]=E,this.colors[4*e+3]=_*t,B){const t=i+R+C;this.uvs[2*e+0]=.5+.5*Math.cos(t)/P*this.aspecty,this.uvs[2*e+1]=.5+.5*Math.sin(t)/P}y&&(this.borderPositions[3*(e-1)+0]=this.positions[3*e+0],this.borderPositions[3*(e-1)+1]=this.positions[3*e+1],this.borderPositions[3*(e-1)+2]=this.positions[3*e+2])}this.mdVSShapeFrame=o,this.drawCustomShapeInstance(r,h,B,y,L,U)}const h=i.mdVSUserKeysShapes[this.index],A=vt.pick(this.mdVSShapeFrame,h);i.mdVSFrameMapShapes[this.index]=A}}setupShapeBuffers(t){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.colors,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.uvs,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.borderPositions,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc);const e=0!==t?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,e),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,e)}drawCustomShapeInstance(t,e,i,s,r,a){if(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.positions,0,3*(e+2)),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.colors,0,4*(e+2)),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),i&&(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.uvs,0,2*(e+2)),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation)),this.gl.uniform1f(this.texturedLoc,i?1:0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),a?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,e+2),s){this.gl.useProgram(this.borderShaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.borderPositions,0,3*(e+1)),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc),this.gl.uniform4fv(this.uBorderColorLoc,this.borderColor);const t=r?4:1;for(let i=0;i<t;i++){const t=2;0===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===i?this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,0]):2===i?this.gl.uniform2fv(this.thickOffsetLoc,[0,t/this.texsizeY]):3===i&&this.gl.uniform2fv(this.thickOffsetLoc,[t/this.texsizeX,t/this.texsizeY]),this.gl.drawArrays(this.gl.LINE_STRIP,0,e+1)}}}};class Dt{constructor(t,e={}){this.gl=t,this.positions=new Float32Array(72),this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}updateGlobals(t){this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      void main(void) {\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 u_color;\n      void main(void) {\n        fragColor = u_color;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color")}addTriangle(t,e,i,s){this.positions[t+0]=e[0],this.positions[t+1]=e[1],this.positions[t+2]=e[2],this.positions[t+3]=i[0],this.positions[t+4]=i[1],this.positions[t+5]=i[2],this.positions[t+6]=s[0],this.positions[t+7]=s[1],this.positions[t+8]=s[2]}generateBorder(t,e,i){if(e>0&&t[3]>0){const t=2,s=2,r=t/2,a=s/2,o=i/2,h=e/2+o,A=o*t,n=o*s,l=h*t,g=h*s;let c=[-r+A,-a+g,0],m=[-r+A,a-g,0],u=[-r+l,a-g,0],f=[-r+l,-a+g,0];return this.addTriangle(0,f,m,c),this.addTriangle(9,f,u,m),c=[r-A,-a+g,0],m=[r-A,a-g,0],u=[r-l,a-g,0],f=[r-l,-a+g,0],this.addTriangle(18,c,m,f),this.addTriangle(27,m,u,f),c=[-r+A,-a+n,0],m=[-r+A,g-a,0],u=[r-A,g-a,0],f=[r-A,-a+n,0],this.addTriangle(36,f,m,c),this.addTriangle(45,f,u,m),c=[-r+A,a-n,0],m=[-r+A,a-g,0],u=[r-A,a-g,0],f=[r-A,a-n,0],this.addTriangle(54,c,m,f),this.addTriangle(63,m,u,f),!0}return!1}drawBorder(t,e,i){this.generateBorder(t,e,i)&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,t),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLES,0,this.positions.length/3))}}class Vt{constructor(t,e){this.gl=t,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.generatePositions(),this.colors=new Float32Array([0,0,0,3/32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}updateGlobals(t){this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.generatePositions()}generatePositions(){const t=.05;this.positions=new Float32Array([0,0,0,-.05*this.aspecty,0,0,0,-.05,0,t*this.aspecty,0,0,0,t,0,-.05*this.aspecty,0,0])}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      in vec4 aColor;\n      out vec4 vColor;\n      void main(void) {\n        vColor = aColor;\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      in vec4 vColor;\n      out vec4 fragColor;\n      void main(void) {\n        fragColor = vColor;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor")}drawDarkenCenter(t){0!==t.darken_center&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.colors,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,this.positions.length/3))}}class qt{constructor(t,e){this.gl=t,this.maxX=64,this.maxY=48,this.positions=new Float32Array(this.maxX*this.maxY*2*3),this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.mesh_width=e.mesh_width,this.mesh_height=e.mesh_height,this.positionVertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      in vec3 aPos;\n      void main(void) {\n        gl_Position = vec4(aPos, 1.0);\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      out vec4 fragColor;\n      uniform vec4 u_color;\n      void main(void) {\n        fragColor = u_color;\n      }\n      `.trim()),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color")}getMotionDir(t,e,i){const s=Math.floor(i*this.mesh_height),r=i*this.mesh_height-s,a=Math.floor(e*this.mesh_width),o=e*this.mesh_width-a,h=a+1,A=s+1,n=this.mesh_width+1;let l,g;return l=t[2*(s*n+a)+0]*(1-o)*(1-r),g=t[2*(s*n+a)+1]*(1-o)*(1-r),l+=t[2*(s*n+h)+0]*o*(1-r),g+=t[2*(s*n+h)+1]*o*(1-r),l+=t[2*(A*n+a)+0]*(1-o)*r,g+=t[2*(A*n+a)+1]*(1-o)*r,l+=t[2*(A*n+h)+0]*o*r,g+=t[2*(A*n+h)+1]*o*r,[l,1-g]}generateMotionVectors(t,e){const i=0===t.bmotionvectorson?0:t.mv_a;let s=Math.floor(t.mv_x),r=Math.floor(t.mv_y);if(i>.001&&s>0&&r>0){let a=t.mv_x-s,o=t.mv_y-r;s>this.maxX&&(s=this.maxX,a=0),r>this.maxY&&(r=this.maxY,o=0);const h=t.mv_dx,A=t.mv_dy,n=t.mv_l,l=1/this.texsizeX;this.numVecVerts=0;for(let t=0;t<r;t++){let i=(t+.25)/(r+o+.25-1);if(i-=A,i>1e-4&&i<.9999)for(let t=0;t<s;t++){let r=(t+.25)/(s+a+.25-1);if(r+=h,r>1e-4&&r<.9999){const t=this.getMotionDir(e,r,i);let s=t[0],a=t[1],o=s-r,h=a-i;o*=n,h*=n;let A=Math.sqrt(o*o+h*h);A<l&&A>1e-8?(A=l/A,o*=A,h*=A):(o=l,o=l),s=r+o,a=i+h;const g=2*r-1,c=2*i-1,m=2*s-1,u=2*a-1;this.positions[3*this.numVecVerts+0]=g,this.positions[3*this.numVecVerts+1]=c,this.positions[3*this.numVecVerts+2]=0,this.positions[3*(this.numVecVerts+1)+0]=m,this.positions[3*(this.numVecVerts+1)+1]=u,this.positions[3*(this.numVecVerts+1)+2]=0,this.numVecVerts+=2}}}if(this.numVecVerts>0)return this.color=[t.mv_r,t.mv_g,t.mv_b,i],!0}return!1}drawMotionVectors(t,e){this.generateMotionVectors(t,e)&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,this.color),this.gl.lineWidth(1),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.LINES,0,this.numVecVerts))}}class zt{constructor(t,e,i,s={}){this.gl=t,this.noise=e,this.image=i,this.rng=Rt(),this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions(),this.indexBuf=t.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.warpUvVertexBuf=this.gl.createBuffer(),this.warpColorVertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader(),this.mainSampler=this.gl.createSampler(),this.mainSamplerFW=this.gl.createSampler(),this.mainSamplerFC=this.gl.createSampler(),this.mainSamplerPW=this.gl.createSampler(),this.mainSamplerPC=this.gl.createSampler(),t.samplerParameteri(this.mainSampler,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}buildPositions(){const t=this.mesh_width,e=this.mesh_height,i=t+1,s=e+1,r=2/t,a=2/e,o=[];for(let t=0;t<s;t++){const e=t*a-1;for(let t=0;t<i;t++){const i=t*r-1;o.push(i,-e,0)}}const h=[];for(let s=0;s<e;s++)for(let e=0;e<t;e++){const t=e+i*s,r=e+i*(s+1),a=e+1+i*(s+1),o=e+1+i*s;h.push(t,r,o),h.push(r,a,o)}this.vertices=new Float32Array(o),this.indices=new Uint16Array(h)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions()}createShader(t=""){let e,i;if(0===t.length)e="ret = texture(sampler_main, uv).rgb * decay;",i="";else{const s=Ut.getShaderParts(t);i=s[0],e=s[1]}e=e.replace(/texture2D/g,"texture"),e=e.replace(/texture3D/g,"texture"),this.userTextures=Ut.getUserSamplers(i),this.shaderProgram=this.gl.createProgram();const s=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(s,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      in vec2 aWarpUv;\n      in vec4 aWarpColor;\n      out vec2 uv;\n      out vec2 uv_orig;\n      out vec4 vColor;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        uv_orig = aPos * halfmad + halfmad;\n        uv = aWarpUv;\n        vColor = aWarpColor;\n      }\n      `.trim()),this.gl.compileShader(s);const r=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(r,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      precision mediump sampler3D;\n\n      in vec2 uv;\n      in vec2 uv_orig;\n      in vec4 vColor;\n      out vec4 fragColor;\n      uniform sampler2D sampler_main;\n      uniform sampler2D sampler_fw_main;\n      uniform sampler2D sampler_fc_main;\n      uniform sampler2D sampler_pw_main;\n      uniform sampler2D sampler_pc_main;\n      uniform sampler2D sampler_blur1;\n      uniform sampler2D sampler_blur2;\n      uniform sampler2D sampler_blur3;\n      uniform sampler2D sampler_noise_lq;\n      uniform sampler2D sampler_noise_lq_lite;\n      uniform sampler2D sampler_noise_mq;\n      uniform sampler2D sampler_noise_hq;\n      uniform sampler2D sampler_pw_noise_lq;\n      uniform sampler3D sampler_noisevol_lq;\n      uniform sampler3D sampler_noisevol_hq;\n      uniform float time;\n      uniform float decay;\n      uniform vec2 resolution;\n      uniform vec4 aspect;\n      uniform vec4 texsize;\n      uniform vec4 texsize_noise_lq;\n      uniform vec4 texsize_noise_mq;\n      uniform vec4 texsize_noise_hq;\n      uniform vec4 texsize_noise_lq_lite;\n      uniform vec4 texsize_noisevol_lq;\n      uniform vec4 texsize_noisevol_hq;\n\n      uniform float bass;\n      uniform float mid;\n      uniform float treb;\n      uniform float vol;\n      uniform float bass_att;\n      uniform float mid_att;\n      uniform float treb_att;\n      uniform float vol_att;\n\n      uniform float frame;\n      uniform float fps;\n\n      uniform vec4 _qa;\n      uniform vec4 _qb;\n      uniform vec4 _qc;\n      uniform vec4 _qd;\n      uniform vec4 _qe;\n      uniform vec4 _qf;\n      uniform vec4 _qg;\n      uniform vec4 _qh;\n\n      #define q1 _qa.x\n      #define q2 _qa.y\n      #define q3 _qa.z\n      #define q4 _qa.w\n      #define q5 _qb.x\n      #define q6 _qb.y\n      #define q7 _qb.z\n      #define q8 _qb.w\n      #define q9 _qc.x\n      #define q10 _qc.y\n      #define q11 _qc.z\n      #define q12 _qc.w\n      #define q13 _qd.x\n      #define q14 _qd.y\n      #define q15 _qd.z\n      #define q16 _qd.w\n      #define q17 _qe.x\n      #define q18 _qe.y\n      #define q19 _qe.z\n      #define q20 _qe.w\n      #define q21 _qf.x\n      #define q22 _qf.y\n      #define q23 _qf.z\n      #define q24 _qf.w\n      #define q25 _qg.x\n      #define q26 _qg.y\n      #define q27 _qg.z\n      #define q28 _qg.w\n      #define q29 _qh.x\n      #define q30 _qh.y\n      #define q31 _qh.z\n      #define q32 _qh.w\n\n      uniform vec4 slow_roam_cos;\n      uniform vec4 roam_cos;\n      uniform vec4 slow_roam_sin;\n      uniform vec4 roam_sin;\n\n      uniform float blur1_min;\n      uniform float blur1_max;\n      uniform float blur2_min;\n      uniform float blur2_max;\n      uniform float blur3_min;\n      uniform float blur3_max;\n\n      uniform float scale1;\n      uniform float scale2;\n      uniform float scale3;\n      uniform float bias1;\n      uniform float bias2;\n      uniform float bias3;\n\n      uniform vec4 rand_frame;\n      uniform vec4 rand_preset;\n\n      float PI = ${Math.PI};\n\n      ${i}\n\n      void main(void) {\n        vec3 ret;\n        float rad = length(uv_orig - 0.5);\n        float ang = atan(uv_orig.x - 0.5, uv_orig.y - 0.5);\n\n        ${e}\n\n        fragColor = vec4(ret, 1.0) * vColor;\n      }\n      `.trim()),this.gl.compileShader(r),this.gl.attachShader(this.shaderProgram,s),this.gl.attachShader(this.shaderProgram,r),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.warpUvLocation=this.gl.getAttribLocation(this.shaderProgram,"aWarpUv"),this.warpColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aWarpColor"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_main"),this.textureFWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fw_main"),this.textureFCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fc_main"),this.texturePWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_main"),this.texturePCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pc_main"),this.blurTexture1Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur1"),this.blurTexture2Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur2"),this.blurTexture3Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur3"),this.noiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq"),this.noiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_mq"),this.noiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_hq"),this.noiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq_lite"),this.noisePointLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_noise_lq"),this.noiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_lq"),this.noiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_hq"),this.decayLoc=this.gl.getUniformLocation(this.shaderProgram,"decay"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.texsizeNoiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq"),this.texsizeNoiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_mq"),this.texsizeNoiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_hq"),this.texsizeNoiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq_lite"),this.texsizeNoiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_lq"),this.texsizeNoiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_hq"),this.resolutionLoc=this.gl.getUniformLocation(this.shaderProgram,"resolution"),this.aspectLoc=this.gl.getUniformLocation(this.shaderProgram,"aspect"),this.bassLoc=this.gl.getUniformLocation(this.shaderProgram,"bass"),this.midLoc=this.gl.getUniformLocation(this.shaderProgram,"mid"),this.trebLoc=this.gl.getUniformLocation(this.shaderProgram,"treb"),this.volLoc=this.gl.getUniformLocation(this.shaderProgram,"vol"),this.bassAttLoc=this.gl.getUniformLocation(this.shaderProgram,"bass_att"),this.midAttLoc=this.gl.getUniformLocation(this.shaderProgram,"mid_att"),this.trebAttLoc=this.gl.getUniformLocation(this.shaderProgram,"treb_att"),this.volAttLoc=this.gl.getUniformLocation(this.shaderProgram,"vol_att"),this.timeLoc=this.gl.getUniformLocation(this.shaderProgram,"time"),this.frameLoc=this.gl.getUniformLocation(this.shaderProgram,"frame"),this.fpsLoc=this.gl.getUniformLocation(this.shaderProgram,"fps"),this.blur1MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_min"),this.blur1MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_max"),this.blur2MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_min"),this.blur2MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_max"),this.blur3MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_min"),this.blur3MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_max"),this.scale1Loc=this.gl.getUniformLocation(this.shaderProgram,"scale1"),this.scale2Loc=this.gl.getUniformLocation(this.shaderProgram,"scale2"),this.scale3Loc=this.gl.getUniformLocation(this.shaderProgram,"scale3"),this.bias1Loc=this.gl.getUniformLocation(this.shaderProgram,"bias1"),this.bias2Loc=this.gl.getUniformLocation(this.shaderProgram,"bias2"),this.bias3Loc=this.gl.getUniformLocation(this.shaderProgram,"bias3"),this.randPresetLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_preset"),this.randFrameLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_frame"),this.qaLoc=this.gl.getUniformLocation(this.shaderProgram,"_qa"),this.qbLoc=this.gl.getUniformLocation(this.shaderProgram,"_qb"),this.qcLoc=this.gl.getUniformLocation(this.shaderProgram,"_qc"),this.qdLoc=this.gl.getUniformLocation(this.shaderProgram,"_qd"),this.qeLoc=this.gl.getUniformLocation(this.shaderProgram,"_qe"),this.qfLoc=this.gl.getUniformLocation(this.shaderProgram,"_qf"),this.qgLoc=this.gl.getUniformLocation(this.shaderProgram,"_qg"),this.qhLoc=this.gl.getUniformLocation(this.shaderProgram,"_qh"),this.slowRoamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_cos"),this.roamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_cos"),this.slowRoamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_sin"),this.roamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_sin");for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];e.textureLoc=this.gl.getUniformLocation(this.shaderProgram,`sampler_${e.sampler}`)}}updateShader(t){this.createShader(t)}bindBlurVals(t,e){const i=t[0],s=t[1],r=t[2],a=e[0],o=e[1],h=e[2],A=a-i,n=i,l=o-s,g=s,c=h-r,m=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,a),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,o),this.gl.uniform1f(this.blur3MinLoc,r),this.gl.uniform1f(this.blur3MaxLoc,h),this.gl.uniform1f(this.scale1Loc,A),this.gl.uniform1f(this.scale2Loc,l),this.gl.uniform1f(this.scale3Loc,c),this.gl.uniform1f(this.bias1Loc,n),this.gl.uniform1f(this.bias2Loc,g),this.gl.uniform1f(this.bias3Loc,m)}renderQuadTexture(t,e,i,s,r,a,o,h,A,n,l){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.warpUvVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.warpUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.warpUvLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.warpColorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.warpColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.warpColorLocation);const g=0!==h.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,g),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,g),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(1,this.mainSamplerFW),this.gl.uniform1i(this.textureFWLoc,1),this.gl.activeTexture(this.gl.TEXTURE2),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(2,this.mainSamplerFC),this.gl.uniform1i(this.textureFCLoc,2),this.gl.activeTexture(this.gl.TEXTURE3),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(3,this.mainSamplerPW),this.gl.uniform1i(this.texturePWLoc,3),this.gl.activeTexture(this.gl.TEXTURE4),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(4,this.mainSamplerPC),this.gl.uniform1i(this.texturePCLoc,4),this.gl.activeTexture(this.gl.TEXTURE5),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(this.blurTexture1Loc,5),this.gl.activeTexture(this.gl.TEXTURE6),this.gl.bindTexture(this.gl.TEXTURE_2D,s),this.gl.uniform1i(this.blurTexture2Loc,6),this.gl.activeTexture(this.gl.TEXTURE7),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(this.blurTexture3Loc,7),this.gl.activeTexture(this.gl.TEXTURE8),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.uniform1i(this.noiseLQLoc,8),this.gl.activeTexture(this.gl.TEXTURE9),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexMQ),this.gl.uniform1i(this.noiseMQLoc,9),this.gl.activeTexture(this.gl.TEXTURE10),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexHQ),this.gl.uniform1i(this.noiseHQLoc,10),this.gl.activeTexture(this.gl.TEXTURE11),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQLite),this.gl.uniform1i(this.noiseLQLiteLoc,11),this.gl.activeTexture(this.gl.TEXTURE12),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.bindSampler(12,this.noise.noiseTexPointLQ),this.gl.uniform1i(this.noisePointLQLoc,12),this.gl.activeTexture(this.gl.TEXTURE13),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolLQ),this.gl.uniform1i(this.noiseVolLQLoc,13),this.gl.activeTexture(this.gl.TEXTURE14),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolHQ),this.gl.uniform1i(this.noiseVolHQLoc,14);for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];this.gl.activeTexture(this.gl.TEXTURE15+t),this.gl.bindTexture(this.gl.TEXTURE_2D,this.image.getTexture(e.sampler)),this.gl.uniform1i(e.textureLoc,15+t)}this.gl.uniform1f(this.decayLoc,h.decay),this.gl.uniform2fv(this.resolutionLoc,[this.texsizeX,this.texsizeY]),this.gl.uniform4fv(this.aspectLoc,[this.aspectx,this.aspecty,this.invAspectx,this.invAspecty]),this.gl.uniform4fv(this.texsizeLoc,[this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY]),this.gl.uniform4fv(this.texsizeNoiseLQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseMQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseHQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseLQLiteLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolLQLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolHQLoc,[32,32,1/32,1/32]),this.gl.uniform1f(this.bassLoc,h.bass),this.gl.uniform1f(this.midLoc,h.mid),this.gl.uniform1f(this.trebLoc,h.treb),this.gl.uniform1f(this.volLoc,(h.bass+h.mid+h.treb)/3),this.gl.uniform1f(this.bassAttLoc,h.bass_att),this.gl.uniform1f(this.midAttLoc,h.mid_att),this.gl.uniform1f(this.trebAttLoc,h.treb_att),this.gl.uniform1f(this.volAttLoc,(h.bass_att+h.mid_att+h.treb_att)/3),this.gl.uniform1f(this.timeLoc,h.time),this.gl.uniform1f(this.frameLoc,h.frame),this.gl.uniform1f(this.fpsLoc,h.fps),this.gl.uniform4fv(this.randPresetLoc,h.rand_preset),this.gl.uniform4fv(this.randFrameLoc,new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()])),this.gl.uniform4fv(this.qaLoc,new Float32Array([A.q1||0,A.q2||0,A.q3||0,A.q4||0])),this.gl.uniform4fv(this.qbLoc,new Float32Array([A.q5||0,A.q6||0,A.q7||0,A.q8||0])),this.gl.uniform4fv(this.qcLoc,new Float32Array([A.q9||0,A.q10||0,A.q11||0,A.q12||0])),this.gl.uniform4fv(this.qdLoc,new Float32Array([A.q13||0,A.q14||0,A.q15||0,A.q16||0])),this.gl.uniform4fv(this.qeLoc,new Float32Array([A.q17||0,A.q18||0,A.q19||0,A.q20||0])),this.gl.uniform4fv(this.qfLoc,new Float32Array([A.q21||0,A.q22||0,A.q23||0,A.q24||0])),this.gl.uniform4fv(this.qgLoc,new Float32Array([A.q25||0,A.q26||0,A.q27||0,A.q28||0])),this.gl.uniform4fv(this.qhLoc,new Float32Array([A.q29||0,A.q30||0,A.q31||0,A.q32||0])),this.gl.uniform4fv(this.slowRoamCosLoc,[.5+.5*Math.cos(.005*h.time),.5+.5*Math.cos(.008*h.time),.5+.5*Math.cos(.013*h.time),.5+.5*Math.cos(.022*h.time)]),this.gl.uniform4fv(this.roamCosLoc,[.5+.5*Math.cos(.3*h.time),.5+.5*Math.cos(1.3*h.time),.5+.5*Math.cos(5*h.time),.5+.5*Math.cos(20*h.time)]),this.gl.uniform4fv(this.slowRoamSinLoc,[.5+.5*Math.sin(.005*h.time),.5+.5*Math.sin(.008*h.time),.5+.5*Math.sin(.013*h.time),.5+.5*Math.sin(.022*h.time)]),this.gl.uniform4fv(this.roamSinLoc,[.5+.5*Math.sin(.3*h.time),.5+.5*Math.sin(1.3*h.time),.5+.5*Math.sin(5*h.time),.5+.5*Math.sin(20*h.time)]),this.bindBlurVals(a,o),t?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.disable(this.gl.BLEND),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0),t||this.gl.enable(this.gl.BLEND)}}class Nt{constructor(t,e,i,s={}){this.gl=t,this.noise=e,this.image=i,this.rng=Rt(),this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.compWidth=32,this.compHeight=24,this.buildPositions(),this.indexBuf=t.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.compColorVertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader(),this.mainSampler=this.gl.createSampler(),this.mainSamplerFW=this.gl.createSampler(),this.mainSamplerFC=this.gl.createSampler(),this.mainSamplerPW=this.gl.createSampler(),this.mainSamplerPC=this.gl.createSampler(),t.samplerParameteri(this.mainSampler,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSampler,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerFW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_MAG_FILTER,t.LINEAR),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerFC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.mainSamplerPW,t.TEXTURE_WRAP_T,t.REPEAT),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.samplerParameteri(this.mainSamplerPC,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}buildPositions(){const t=this.compWidth,e=this.compHeight,i=t+1,s=e+1,r=2/t,a=2/e,o=[];for(let t=0;t<s;t++){const e=t*a-1;for(let t=0;t<i;t++){const i=t*r-1;o.push(i,-e,0)}}const h=[];for(let s=0;s<e;s++)for(let e=0;e<t;e++){const t=e+i*s,r=e+i*(s+1),a=e+1+i*(s+1),o=e+1+i*s;h.push(t,r,o),h.push(r,a,o)}this.vertices=new Float32Array(o),this.indices=new Uint16Array(h)}updateGlobals(t){this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions()}createShader(t=""){let e,i;if(0===t.length)e="float orient_horiz = mod(echo_orientation, 2.0);\n                        float orient_x = (orient_horiz != 0.0) ? -1.0 : 1.0;\n                        float orient_y = (echo_orientation >= 2.0) ? -1.0 : 1.0;\n                        vec2 uv_echo = ((uv - 0.5) *\n                                        (1.0 / echo_zoom) *\n                                        vec2(orient_x, orient_y)) + 0.5;\n\n                        ret = mix(texture(sampler_main, uv).rgb,\n                                  texture(sampler_main, uv_echo).rgb,\n                                  echo_alpha);\n\n                        ret *= gammaAdj;\n\n                        if(fShader >= 1.0) {\n                          ret *= hue_shader;\n                        } else if(fShader > 0.001) {\n                          ret *= (1.0 - fShader) + (fShader * hue_shader);\n                        }\n\n                        if(brighten != 0) ret = sqrt(ret);\n                        if(darken != 0) ret = ret*ret;\n                        if(solarize != 0) ret = ret * (1.0 - ret) * 4.0;\n                        if(invert != 0) ret = 1.0 - ret;",i="";else{const s=Ut.getShaderParts(t);i=s[0],e=s[1]}e=e.replace(/texture2D/g,"texture"),e=e.replace(/texture3D/g,"texture"),this.userTextures=Ut.getUserSamplers(i),this.shaderProgram=this.gl.createProgram();const s=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(s,"\n      #version 300 es\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      in vec4 aCompColor;\n      out vec2 vUv;\n      out vec4 vColor;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        vUv = aPos * halfmad + halfmad;\n        vColor = aCompColor;\n      }\n      ".trim()),this.gl.compileShader(s);const r=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(r,`\n      #version 300 es\n      precision ${this.floatPrecision} float;\n      precision highp int;\n      precision mediump sampler2D;\n      precision mediump sampler3D;\n\n      vec3 lum(vec3 v){\n          return vec3(dot(v, vec3(0.32,0.49,0.29)));\n      }\n\n      in vec2 vUv;\n      in vec4 vColor;\n      out vec4 fragColor;\n      uniform sampler2D sampler_main;\n      uniform sampler2D sampler_fw_main;\n      uniform sampler2D sampler_fc_main;\n      uniform sampler2D sampler_pw_main;\n      uniform sampler2D sampler_pc_main;\n      uniform sampler2D sampler_blur1;\n      uniform sampler2D sampler_blur2;\n      uniform sampler2D sampler_blur3;\n      uniform sampler2D sampler_noise_lq;\n      uniform sampler2D sampler_noise_lq_lite;\n      uniform sampler2D sampler_noise_mq;\n      uniform sampler2D sampler_noise_hq;\n      uniform sampler2D sampler_pw_noise_lq;\n      uniform sampler3D sampler_noisevol_lq;\n      uniform sampler3D sampler_noisevol_hq;\n\n      uniform float time;\n      uniform float gammaAdj;\n      uniform float echo_zoom;\n      uniform float echo_alpha;\n      uniform float echo_orientation;\n      uniform int invert;\n      uniform int brighten;\n      uniform int darken;\n      uniform int solarize;\n      uniform vec2 resolution;\n      uniform vec4 aspect;\n      uniform vec4 texsize;\n      uniform vec4 texsize_noise_lq;\n      uniform vec4 texsize_noise_mq;\n      uniform vec4 texsize_noise_hq;\n      uniform vec4 texsize_noise_lq_lite;\n      uniform vec4 texsize_noisevol_lq;\n      uniform vec4 texsize_noisevol_hq;\n\n      uniform float bass;\n      uniform float mid;\n      uniform float treb;\n      uniform float vol;\n      uniform float bass_att;\n      uniform float mid_att;\n      uniform float treb_att;\n      uniform float vol_att;\n\n      uniform float frame;\n      uniform float fps;\n\n      uniform vec4 _qa;\n      uniform vec4 _qb;\n      uniform vec4 _qc;\n      uniform vec4 _qd;\n      uniform vec4 _qe;\n      uniform vec4 _qf;\n      uniform vec4 _qg;\n      uniform vec4 _qh;\n\n      #define q1 _qa.x\n      #define q2 _qa.y\n      #define q3 _qa.z\n      #define q4 _qa.w\n      #define q5 _qb.x\n      #define q6 _qb.y\n      #define q7 _qb.z\n      #define q8 _qb.w\n      #define q9 _qc.x\n      #define q10 _qc.y\n      #define q11 _qc.z\n      #define q12 _qc.w\n      #define q13 _qd.x\n      #define q14 _qd.y\n      #define q15 _qd.z\n      #define q16 _qd.w\n      #define q17 _qe.x\n      #define q18 _qe.y\n      #define q19 _qe.z\n      #define q20 _qe.w\n      #define q21 _qf.x\n      #define q22 _qf.y\n      #define q23 _qf.z\n      #define q24 _qf.w\n      #define q25 _qg.x\n      #define q26 _qg.y\n      #define q27 _qg.z\n      #define q28 _qg.w\n      #define q29 _qh.x\n      #define q30 _qh.y\n      #define q31 _qh.z\n      #define q32 _qh.w\n\n      uniform vec4 slow_roam_cos;\n      uniform vec4 roam_cos;\n      uniform vec4 slow_roam_sin;\n      uniform vec4 roam_sin;\n\n      uniform float blur1_min;\n      uniform float blur1_max;\n      uniform float blur2_min;\n      uniform float blur2_max;\n      uniform float blur3_min;\n      uniform float blur3_max;\n\n      uniform float scale1;\n      uniform float scale2;\n      uniform float scale3;\n      uniform float bias1;\n      uniform float bias2;\n      uniform float bias3;\n\n      uniform vec4 rand_frame;\n      uniform vec4 rand_preset;\n\n      uniform float fShader;\n\n      float PI = ${Math.PI};\n\n      ${i}\n\n      void main(void) {\n        vec3 ret;\n        vec2 uv = vUv;\n        vec2 uv_orig = vUv;\n        uv.y = 1.0 - uv.y;\n        uv_orig.y = 1.0 - uv_orig.y;\n        float rad = length(uv - 0.5);\n        float ang = atan(uv.x - 0.5, uv.y - 0.5);\n        vec3 hue_shader = vColor.rgb;\n\n        ${e}\n\n        fragColor = vec4(ret, vColor.a);\n      }\n      `.trim()),this.gl.compileShader(r),this.gl.attachShader(this.shaderProgram,s),this.gl.attachShader(this.shaderProgram,r),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.compColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aCompColor"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_main"),this.textureFWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fw_main"),this.textureFCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fc_main"),this.texturePWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_main"),this.texturePCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pc_main"),this.blurTexture1Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur1"),this.blurTexture2Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur2"),this.blurTexture3Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur3"),this.noiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq"),this.noiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_mq"),this.noiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_hq"),this.noiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq_lite"),this.noisePointLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_noise_lq"),this.noiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_lq"),this.noiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_hq"),this.timeLoc=this.gl.getUniformLocation(this.shaderProgram,"time"),this.gammaAdjLoc=this.gl.getUniformLocation(this.shaderProgram,"gammaAdj"),this.echoZoomLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_zoom"),this.echoAlphaLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_alpha"),this.echoOrientationLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_orientation"),this.invertLoc=this.gl.getUniformLocation(this.shaderProgram,"invert"),this.brightenLoc=this.gl.getUniformLocation(this.shaderProgram,"brighten"),this.darkenLoc=this.gl.getUniformLocation(this.shaderProgram,"darken"),this.solarizeLoc=this.gl.getUniformLocation(this.shaderProgram,"solarize"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.texsizeNoiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq"),this.texsizeNoiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_mq"),this.texsizeNoiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_hq"),this.texsizeNoiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq_lite"),this.texsizeNoiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_lq"),this.texsizeNoiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_hq"),this.resolutionLoc=this.gl.getUniformLocation(this.shaderProgram,"resolution"),this.aspectLoc=this.gl.getUniformLocation(this.shaderProgram,"aspect"),this.bassLoc=this.gl.getUniformLocation(this.shaderProgram,"bass"),this.midLoc=this.gl.getUniformLocation(this.shaderProgram,"mid"),this.trebLoc=this.gl.getUniformLocation(this.shaderProgram,"treb"),this.volLoc=this.gl.getUniformLocation(this.shaderProgram,"vol"),this.bassAttLoc=this.gl.getUniformLocation(this.shaderProgram,"bass_att"),this.midAttLoc=this.gl.getUniformLocation(this.shaderProgram,"mid_att"),this.trebAttLoc=this.gl.getUniformLocation(this.shaderProgram,"treb_att"),this.volAttLoc=this.gl.getUniformLocation(this.shaderProgram,"vol_att"),this.frameLoc=this.gl.getUniformLocation(this.shaderProgram,"frame"),this.fpsLoc=this.gl.getUniformLocation(this.shaderProgram,"fps"),this.blur1MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_min"),this.blur1MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_max"),this.blur2MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_min"),this.blur2MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_max"),this.blur3MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_min"),this.blur3MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_max"),this.scale1Loc=this.gl.getUniformLocation(this.shaderProgram,"scale1"),this.scale2Loc=this.gl.getUniformLocation(this.shaderProgram,"scale2"),this.scale3Loc=this.gl.getUniformLocation(this.shaderProgram,"scale3"),this.bias1Loc=this.gl.getUniformLocation(this.shaderProgram,"bias1"),this.bias2Loc=this.gl.getUniformLocation(this.shaderProgram,"bias2"),this.bias3Loc=this.gl.getUniformLocation(this.shaderProgram,"bias3"),this.randPresetLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_preset"),this.randFrameLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_frame"),this.fShaderLoc=this.gl.getUniformLocation(this.shaderProgram,"fShader"),this.qaLoc=this.gl.getUniformLocation(this.shaderProgram,"_qa"),this.qbLoc=this.gl.getUniformLocation(this.shaderProgram,"_qb"),this.qcLoc=this.gl.getUniformLocation(this.shaderProgram,"_qc"),this.qdLoc=this.gl.getUniformLocation(this.shaderProgram,"_qd"),this.qeLoc=this.gl.getUniformLocation(this.shaderProgram,"_qe"),this.qfLoc=this.gl.getUniformLocation(this.shaderProgram,"_qf"),this.qgLoc=this.gl.getUniformLocation(this.shaderProgram,"_qg"),this.qhLoc=this.gl.getUniformLocation(this.shaderProgram,"_qh"),this.slowRoamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_cos"),this.roamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_cos"),this.slowRoamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_sin"),this.roamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_sin");for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];e.textureLoc=this.gl.getUniformLocation(this.shaderProgram,`sampler_${e.sampler}`)}}updateShader(t){this.createShader(t)}bindBlurVals(t,e){const i=t[0],s=t[1],r=t[2],a=e[0],o=e[1],h=e[2],A=a-i,n=i,l=o-s,g=s,c=h-r,m=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,a),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,o),this.gl.uniform1f(this.blur3MinLoc,r),this.gl.uniform1f(this.blur3MaxLoc,h),this.gl.uniform1f(this.scale1Loc,A),this.gl.uniform1f(this.scale2Loc,l),this.gl.uniform1f(this.scale3Loc,c),this.gl.uniform1f(this.bias1Loc,n),this.gl.uniform1f(this.bias2Loc,g),this.gl.uniform1f(this.bias3Loc,m)}static generateHueBase(t){const e=new Float32Array([1,1,1,1,1,1,1,1,1,1,1,1]);for(let i=0;i<4;i++){e[3*i+0]=.6+.3*Math.sin(30*t.time*.0143+3+21*i+t.rand_start[3]),e[3*i+1]=.6+.3*Math.sin(30*t.time*.0107+1+13*i+t.rand_start[1]),e[3*i+2]=.6+.3*Math.sin(30*t.time*.0129+6+9*i+t.rand_start[2]);const s=Math.max(e[3*i],e[3*i+1],e[3*i+2]);for(let t=0;t<3;t++)e[3*i+t]=e[3*i+t]/s,e[3*i+t]=.5+.5*e[3*i+t]}return e}generateCompColors(t,e,i){const s=Nt.generateHueBase(e),r=this.compWidth+1,a=this.compHeight+1,o=new Float32Array(r*a*4);let h=0;for(let e=0;e<a;e++)for(let a=0;a<r;a++){let r=a/this.compWidth,A=e/this.compHeight;const n=[1,1,1];for(let t=0;t<3;t++)n[t]=s[0+t]*r*A+s[3+t]*(1-r)*A+s[6+t]*r*(1-A)+s[9+t]*(1-r)*(1-A);let l=1;if(t){r*=this.mesh_width+1,A*=this.mesh_height+1,r=Math.clamp(r,0,this.mesh_width-1),A=Math.clamp(A,0,this.mesh_height-1);const t=Math.floor(r),e=Math.floor(A),s=r-t,a=A-e;l=i[4*(e*(this.mesh_width+1)+t)+3]*(1-s)*(1-a)+i[4*(e*(this.mesh_width+1)+(t+1))+3]*s*(1-a)+i[4*((e+1)*(this.mesh_width+1)+t)+3]*(1-s)*a+i[4*((e+1)*(this.mesh_width+1)+(t+1))+3]*s*a}o[h+0]=n[0],o[h+1]=n[1],o[h+2]=n[2],o[h+3]=l,h+=4}return o}renderQuadTexture(t,e,i,s,r,a,o,h,A,n){const l=this.generateCompColors(t,h,n);this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.compColorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.compColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.compColorLocation);const g=0!==h.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,g),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,g),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(1,this.mainSamplerFW),this.gl.uniform1i(this.textureFWLoc,1),this.gl.activeTexture(this.gl.TEXTURE2),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(2,this.mainSamplerFC),this.gl.uniform1i(this.textureFCLoc,2),this.gl.activeTexture(this.gl.TEXTURE3),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(3,this.mainSamplerPW),this.gl.uniform1i(this.texturePWLoc,3),this.gl.activeTexture(this.gl.TEXTURE4),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(4,this.mainSamplerPC),this.gl.uniform1i(this.texturePCLoc,4),this.gl.activeTexture(this.gl.TEXTURE5),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(this.blurTexture1Loc,5),this.gl.activeTexture(this.gl.TEXTURE6),this.gl.bindTexture(this.gl.TEXTURE_2D,s),this.gl.uniform1i(this.blurTexture2Loc,6),this.gl.activeTexture(this.gl.TEXTURE7),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(this.blurTexture3Loc,7),this.gl.activeTexture(this.gl.TEXTURE8),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.uniform1i(this.noiseLQLoc,8),this.gl.activeTexture(this.gl.TEXTURE9),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexMQ),this.gl.uniform1i(this.noiseMQLoc,9),this.gl.activeTexture(this.gl.TEXTURE10),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexHQ),this.gl.uniform1i(this.noiseHQLoc,10),this.gl.activeTexture(this.gl.TEXTURE11),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQLite),this.gl.uniform1i(this.noiseLQLiteLoc,11),this.gl.activeTexture(this.gl.TEXTURE12),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.bindSampler(12,this.noise.noiseTexPointLQ),this.gl.uniform1i(this.noisePointLQLoc,12),this.gl.activeTexture(this.gl.TEXTURE13),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolLQ),this.gl.uniform1i(this.noiseVolLQLoc,13),this.gl.activeTexture(this.gl.TEXTURE14),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolHQ),this.gl.uniform1i(this.noiseVolHQLoc,14);for(let t=0;t<this.userTextures.length;t++){const e=this.userTextures[t];this.gl.activeTexture(this.gl.TEXTURE15+t),this.gl.bindTexture(this.gl.TEXTURE_2D,this.image.getTexture(e.sampler)),this.gl.uniform1i(e.textureLoc,15+t)}this.gl.uniform1f(this.timeLoc,h.time),this.gl.uniform1f(this.gammaAdjLoc,h.gammaadj),this.gl.uniform1f(this.echoZoomLoc,h.echo_zoom),this.gl.uniform1f(this.echoAlphaLoc,h.echo_alpha),this.gl.uniform1f(this.echoOrientationLoc,h.echo_orient),this.gl.uniform1i(this.invertLoc,h.invert),this.gl.uniform1i(this.brightenLoc,h.brighten),this.gl.uniform1i(this.darkenLoc,h.darken),this.gl.uniform1i(this.solarizeLoc,h.solarize),this.gl.uniform2fv(this.resolutionLoc,[this.texsizeX,this.texsizeY]),this.gl.uniform4fv(this.aspectLoc,[this.aspectx,this.aspecty,this.invAspectx,this.invAspecty]),this.gl.uniform4fv(this.texsizeLoc,new Float32Array([this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY])),this.gl.uniform4fv(this.texsizeNoiseLQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseMQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseHQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseLQLiteLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolLQLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolHQLoc,[32,32,1/32,1/32]),this.gl.uniform1f(this.bassLoc,h.bass),this.gl.uniform1f(this.midLoc,h.mid),this.gl.uniform1f(this.trebLoc,h.treb),this.gl.uniform1f(this.volLoc,(h.bass+h.mid+h.treb)/3),this.gl.uniform1f(this.bassAttLoc,h.bass_att),this.gl.uniform1f(this.midAttLoc,h.mid_att),this.gl.uniform1f(this.trebAttLoc,h.treb_att),this.gl.uniform1f(this.volAttLoc,(h.bass_att+h.mid_att+h.treb_att)/3),this.gl.uniform1f(this.frameLoc,h.frame),this.gl.uniform1f(this.fpsLoc,h.fps),this.gl.uniform4fv(this.randPresetLoc,h.rand_preset),this.gl.uniform4fv(this.randFrameLoc,new Float32Array([this.rng.random(),this.rng.random(),this.rng.random(),this.rng.random()])),this.gl.uniform1f(this.fShaderLoc,h.fshader),this.gl.uniform4fv(this.qaLoc,new Float32Array([A.q1||0,A.q2||0,A.q3||0,A.q4||0])),this.gl.uniform4fv(this.qbLoc,new Float32Array([A.q5||0,A.q6||0,A.q7||0,A.q8||0])),this.gl.uniform4fv(this.qcLoc,new Float32Array([A.q9||0,A.q10||0,A.q11||0,A.q12||0])),this.gl.uniform4fv(this.qdLoc,new Float32Array([A.q13||0,A.q14||0,A.q15||0,A.q16||0])),this.gl.uniform4fv(this.qeLoc,new Float32Array([A.q17||0,A.q18||0,A.q19||0,A.q20||0])),this.gl.uniform4fv(this.qfLoc,new Float32Array([A.q21||0,A.q22||0,A.q23||0,A.q24||0])),this.gl.uniform4fv(this.qgLoc,new Float32Array([A.q25||0,A.q26||0,A.q27||0,A.q28||0])),this.gl.uniform4fv(this.qhLoc,new Float32Array([A.q29||0,A.q30||0,A.q31||0,A.q32||0])),this.gl.uniform4fv(this.slowRoamCosLoc,[.5+.5*Math.cos(.005*h.time),.5+.5*Math.cos(.008*h.time),.5+.5*Math.cos(.013*h.time),.5+.5*Math.cos(.022*h.time)]),this.gl.uniform4fv(this.roamCosLoc,[.5+.5*Math.cos(.3*h.time),.5+.5*Math.cos(1.3*h.time),.5+.5*Math.cos(5*h.time),.5+.5*Math.cos(20*h.time)]),this.gl.uniform4fv(this.slowRoamSinLoc,[.5+.5*Math.sin(.005*h.time),.5+.5*Math.sin(.008*h.time),.5+.5*Math.sin(.013*h.time),.5+.5*Math.sin(.022*h.time)]),this.gl.uniform4fv(this.roamSinLoc,[.5+.5*Math.sin(.3*h.time),.5+.5*Math.sin(1.3*h.time),.5+.5*Math.sin(5*h.time),.5+.5*Math.sin(20*h.time)]),this.bindBlurVals(a,o),t?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.disable(this.gl.BLEND),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0),t||this.gl.enable(this.gl.BLEND)}}class Xt{constructor(t,e){this.gl=t,this.textureRatio=e.textureRatio,this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.useFXAA()?this.createFXAAShader():this.createShader()}useFXAA(){return this.textureRatio<=1}updateGlobals(t){this.textureRatio=t.textureRatio,this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.gl.deleteProgram(this.shaderProgram),this.useFXAA()?this.createFXAAShader():this.createShader()}createFXAAShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       out vec2 v_rgbM;\n       out vec2 v_rgbNW;\n       out vec2 v_rgbNE;\n       out vec2 v_rgbSW;\n       out vec2 v_rgbSE;\n       uniform vec4 texsize;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n\n         v_rgbM = aPos * halfmad + halfmad;\n         v_rgbNW = v_rgbM + (vec2(-1.0, -1.0) * texsize.zx);\n         v_rgbNE = v_rgbM + (vec2(1.0, -1.0) * texsize.zx);\n         v_rgbSW = v_rgbM + (vec2(-1.0, 1.0) * texsize.zx);\n         v_rgbSE = v_rgbM + (vec2(1.0, 1.0) * texsize.zx);\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 v_rgbM;\n       in vec2 v_rgbNW;\n       in vec2 v_rgbNE;\n       in vec2 v_rgbSW;\n       in vec2 v_rgbSE;\n       out vec4 fragColor;\n       uniform vec4 texsize;\n       uniform sampler2D uTexture;\n\n       #ifndef FXAA_REDUCE_MIN\n         #define FXAA_REDUCE_MIN   (1.0/ 128.0)\n       #endif\n       #ifndef FXAA_REDUCE_MUL\n         #define FXAA_REDUCE_MUL   (1.0 / 8.0)\n       #endif\n       #ifndef FXAA_SPAN_MAX\n         #define FXAA_SPAN_MAX     8.0\n       #endif\n\n       void main(void) {\n         vec4 color;\n         vec3 rgbNW = textureLod(uTexture, v_rgbNW, 0.0).xyz;\n         vec3 rgbNE = textureLod(uTexture, v_rgbNE, 0.0).xyz;\n         vec3 rgbSW = textureLod(uTexture, v_rgbSW, 0.0).xyz;\n         vec3 rgbSE = textureLod(uTexture, v_rgbSE, 0.0).xyz;\n         vec3 rgbM  = textureLod(uTexture, v_rgbM, 0.0).xyz;\n         vec3 luma = vec3(0.299, 0.587, 0.114);\n         float lumaNW = dot(rgbNW, luma);\n         float lumaNE = dot(rgbNE, luma);\n         float lumaSW = dot(rgbSW, luma);\n         float lumaSE = dot(rgbSE, luma);\n         float lumaM  = dot(rgbM,  luma);\n         float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n         float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n         mediump vec2 dir;\n         dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n         dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n         float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n                               (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n         float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n         dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n                   max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n                   dir * rcpDirMin)) * texsize.zw;\n\n         vec3 rgbA = 0.5 * (\n             textureLod(uTexture, v_rgbM + dir * (1.0 / 3.0 - 0.5), 0.0).xyz +\n             textureLod(uTexture, v_rgbM + dir * (2.0 / 3.0 - 0.5), 0.0).xyz);\n         vec3 rgbB = rgbA * 0.5 + 0.25 * (\n             textureLod(uTexture, v_rgbM + dir * -0.5, 0.0).xyz +\n             textureLod(uTexture, v_rgbM + dir * 0.5, 0.0).xyz);\n\n         float lumaB = dot(rgbB, luma);\n         if ((lumaB < lumaMin) || (lumaB > lumaMax))\n           color = vec4(rgbA, 1.0);\n         else\n           color = vec4(rgbB, 1.0);\n\n         fragColor = color;\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize")}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       out vec2 uv;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n         uv = aPos * halfmad + halfmad;\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n\n       void main(void) {\n         fragColor = vec4(texture(uTexture, uv).rgb, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}renderQuadTexture(t){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0),this.useFXAA()&&this.gl.uniform4fv(this.texsizeLoc,new Float32Array([this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY])),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class kt{constructor(t){this.gl=t,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       out vec2 uv;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n         uv = aPos * halfmad + halfmad;\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n\n       void main(void) {\n         fragColor = vec4(texture(uTexture, uv).rgb, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}renderQuadTexture(t){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.uniform1i(this.textureLoc,0),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class Gt{constructor(t,e){this.gl=t,this.blurLevel=e;const i=[4,3.8,3.5,2.9,1.9,1.2,.7,.3],s=i[0]+i[1]+i[2]+i[3],r=i[4]+i[5]+i[6]+i[7],a=0+(i[2]+i[3])/s*2,o=2+(i[6]+i[7])/r*2;this.wds=new Float32Array([s,r,a,o]),this.wDiv=1/(2*(s+r)),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      out vec2 uv;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        uv = aPos * halfmad + halfmad;\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n       uniform vec4 texsize;\n       uniform float ed1;\n       uniform float ed2;\n       uniform float ed3;\n       uniform vec4 wds;\n       uniform float wdiv;\n\n       void main(void) {\n         float w1 = wds[0];\n         float w2 = wds[1];\n         float d1 = wds[2];\n         float d2 = wds[3];\n\n         vec2 uv2 = uv.xy;\n\n         vec3 blur =\n           ( texture(uTexture, uv2 + vec2(0.0, d1 * texsize.w) ).xyz\n           + texture(uTexture, uv2 + vec2(0.0,-d1 * texsize.w) ).xyz) * w1 +\n           ( texture(uTexture, uv2 + vec2(0.0, d2 * texsize.w) ).xyz\n           + texture(uTexture, uv2 + vec2(0.0,-d2 * texsize.w) ).xyz) * w2;\n\n         blur.xyz *= wdiv;\n\n         float t = min(min(uv.x, uv.y), 1.0 - max(uv.x, uv.y));\n         t = sqrt(t);\n         t = ed1 + ed2 * clamp(t * ed3, 0.0, 1.0);\n         blur.xyz *= t;\n\n         fragColor = vec4(blur, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLocation=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.ed1Loc=this.gl.getUniformLocation(this.shaderProgram,"ed1"),this.ed2Loc=this.gl.getUniformLocation(this.shaderProgram,"ed2"),this.ed3Loc=this.gl.getUniformLocation(this.shaderProgram,"ed3"),this.wdsLocation=this.gl.getUniformLocation(this.shaderProgram,"wds"),this.wdivLoc=this.gl.getUniformLocation(this.shaderProgram,"wdiv")}renderQuadTexture(t,e,i){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0);const s=0===this.blurLevel?e.b1ed:0;this.gl.uniform4fv(this.texsizeLocation,[i[0],i[1],1/i[0],1/i[1]]),this.gl.uniform1f(this.ed1Loc,1-s),this.gl.uniform1f(this.ed2Loc,s),this.gl.uniform1f(this.ed3Loc,5),this.gl.uniform4fv(this.wdsLocation,this.wds),this.gl.uniform1f(this.wdivLoc,this.wDiv),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class Ot{constructor(t,e){this.gl=t,this.blurLevel=e;const i=[4,3.8,3.5,2.9,1.9,1.2,.7,.3],s=i[0]+i[1],r=i[2]+i[3],a=i[4]+i[5],o=i[6]+i[7],h=0+2*i[1]/s,A=2+2*i[3]/r,n=4+2*i[5]/a,l=6+2*i[7]/o;this.ws=new Float32Array([s,r,a,o]),this.ds=new Float32Array([h,A,n,l]),this.wDiv=.5/(s+r+a+o),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"\n      #version 300 es\n      const vec2 halfmad = vec2(0.5);\n      in vec2 aPos;\n      out vec2 uv;\n      void main(void) {\n        gl_Position = vec4(aPos, 0.0, 1.0);\n        uv = aPos * halfmad + halfmad;\n      }\n      ".trim()),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n       uniform vec4 texsize;\n       uniform float scale;\n       uniform float bias;\n       uniform vec4 ws;\n       uniform vec4 ds;\n       uniform float wdiv;\n\n       void main(void) {\n         float w1 = ws[0];\n         float w2 = ws[1];\n         float w3 = ws[2];\n         float w4 = ws[3];\n         float d1 = ds[0];\n         float d2 = ds[1];\n         float d3 = ds[2];\n         float d4 = ds[3];\n\n         vec2 uv2 = uv.xy;\n\n         vec3 blur =\n           ( texture(uTexture, uv2 + vec2( d1 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d1 * texsize.z,0.0) ).xyz) * w1 +\n           ( texture(uTexture, uv2 + vec2( d2 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d2 * texsize.z,0.0) ).xyz) * w2 +\n           ( texture(uTexture, uv2 + vec2( d3 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d3 * texsize.z,0.0) ).xyz) * w3 +\n           ( texture(uTexture, uv2 + vec2( d4 * texsize.z,0.0) ).xyz\n           + texture(uTexture, uv2 + vec2(-d4 * texsize.z,0.0) ).xyz) * w4;\n\n         blur.xyz *= wdiv;\n         blur.xyz = blur.xyz * scale + bias;\n\n         fragColor = vec4(blur, 1.0);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLocation=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.scaleLoc=this.gl.getUniformLocation(this.shaderProgram,"scale"),this.biasLoc=this.gl.getUniformLocation(this.shaderProgram,"bias"),this.wsLoc=this.gl.getUniformLocation(this.shaderProgram,"ws"),this.dsLocation=this.gl.getUniformLocation(this.shaderProgram,"ds"),this.wdivLoc=this.gl.getUniformLocation(this.shaderProgram,"wdiv")}getScaleAndBias(t,e){const i=[1,1,1],s=[0,0,0];let r,a;return i[0]=1/(e[0]-t[0]),s[0]=-t[0]*i[0],r=(t[1]-t[0])/(e[0]-t[0]),a=(e[1]-t[0])/(e[0]-t[0]),i[1]=1/(a-r),s[1]=-r*i[1],r=(t[2]-t[1])/(e[1]-t[1]),a=(e[2]-t[1])/(e[1]-t[1]),i[2]=1/(a-r),s[2]=-r*i[2],{scale:i[this.blurLevel],bias:s[this.blurLevel]}}renderQuadTexture(t,e,i,s,r){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0);const{scale:a,bias:o}=this.getScaleAndBias(i,s);this.gl.uniform4fv(this.texsizeLocation,[r[0],r[1],1/r[0],1/r[1]]),this.gl.uniform1f(this.scaleLoc,a),this.gl.uniform1f(this.biasLoc,o),this.gl.uniform4fv(this.wsLoc,this.ws),this.gl.uniform4fv(this.dsLocation,this.ds),this.gl.uniform1f(this.wdivLoc,this.wDiv),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}class Wt{constructor(t,e,i,s={}){this.blurLevel=t,this.blurRatios=e,this.gl=i,this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.blurHorizontalFrameBuffer=this.gl.createFramebuffer(),this.blurVerticalFrameBuffer=this.gl.createFramebuffer(),this.blurHorizontalTexture=this.gl.createTexture(),this.blurVerticalTexture=this.gl.createTexture(),this.setupFrameBufferTextures(),this.blurHorizontal=new Ot(i,this.blurLevel,s),this.blurVertical=new Gt(i,this.blurLevel,s)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.setupFrameBufferTextures()}getTextureSize(t){let e=Math.max(this.texsizeX*t,16);e=16*Math.floor((e+3)/16);let i=Math.max(this.texsizeY*t,16);return i=4*Math.floor((i+3)/4),[e,i]}setupFrameBufferTextures(){const t=this.blurLevel>0?this.blurRatios[this.blurLevel-1]:[1,1],e=this.blurRatios[this.blurLevel],i=this.getTextureSize(t[1]),s=this.getTextureSize(e[0]);this.bindFrameBufferTexture(this.blurHorizontalFrameBuffer,this.blurHorizontalTexture,s);const r=s,a=this.getTextureSize(e[1]);this.bindFrameBufferTexture(this.blurVerticalFrameBuffer,this.blurVerticalTexture,a),this.horizontalTexsizes=[i,s],this.verticalTexsizes=[r,a]}bindFrambufferAndSetViewport(t,e){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.viewport(0,0,e[0],e[1])}bindFrameBufferTexture(t,e,i){if(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i[0],i[1],0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(i[0]*i[1]*4)),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e,0)}renderBlurTexture(t,e,i,s){this.bindFrambufferAndSetViewport(this.blurHorizontalFrameBuffer,this.horizontalTexsizes[1]),this.blurHorizontal.renderQuadTexture(t,e,i,s,this.horizontalTexsizes[0]),this.gl.bindTexture(this.gl.TEXTURE_2D,this.blurHorizontalTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(this.blurVerticalFrameBuffer,this.verticalTexsizes[1]),this.blurVertical.renderQuadTexture(this.blurHorizontalTexture,e,this.verticalTexsizes[0]),this.gl.bindTexture(this.gl.TEXTURE_2D,this.blurVerticalTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D)}}class Yt{constructor(t){this.gl=t,this.randomFn=Rt().random,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.noiseTexLQ=this.gl.createTexture(),this.noiseTexLQLite=this.gl.createTexture(),this.noiseTexMQ=this.gl.createTexture(),this.noiseTexHQ=this.gl.createTexture(),this.noiseTexVolLQ=this.gl.createTexture(),this.noiseTexVolHQ=this.gl.createTexture(),this.nTexArrLQ=Yt.createNoiseTex(256,1,this.randomFn),this.nTexArrLQLite=Yt.createNoiseTex(32,1,this.randomFn),this.nTexArrMQ=Yt.createNoiseTex(256,4,this.randomFn),this.nTexArrHQ=Yt.createNoiseTex(256,8,this.randomFn),this.nTexArrVolLQ=Yt.createNoiseVolTex(32,1,this.randomFn),this.nTexArrVolHQ=Yt.createNoiseVolTex(32,4,this.randomFn),this.bindTexture(this.noiseTexLQ,this.nTexArrLQ,256,256),this.bindTexture(this.noiseTexLQLite,this.nTexArrLQLite,32,32),this.bindTexture(this.noiseTexMQ,this.nTexArrMQ,256,256),this.bindTexture(this.noiseTexHQ,this.nTexArrHQ,256,256),this.bindTexture3D(this.noiseTexVolLQ,this.nTexArrVolLQ,32,32,32),this.bindTexture3D(this.noiseTexVolHQ,this.nTexArrVolHQ,32,32,32),this.noiseTexPointLQ=this.gl.createSampler(),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_MIN_FILTER,t.NEAREST_MIPMAP_NEAREST),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_MAG_FILTER,t.NEAREST),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_WRAP_S,t.REPEAT),t.samplerParameteri(this.noiseTexPointLQ,t.TEXTURE_WRAP_T,t.REPEAT)}bindTexture(t,e,i,s){if(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i,s,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}}bindTexture3D(t,e,i,s,r){if(this.gl.bindTexture(this.gl.TEXTURE_3D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage3D(this.gl.TEXTURE_3D,0,this.gl.RGBA,i,s,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_3D),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_R,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_3D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}}static fCubicInterpolate(t,e,i,s,r){const a=r*r,o=s-i-t+e;return o*(r*a)+(t-e-o)*a+(i-t)*r+e}static dwCubicInterpolate(t,e,i,s,r){const a=[];for(let o=0;o<4;o++){let h=Yt.fCubicInterpolate(t[o]/255,e[o]/255,i[o]/255,s[o]/255,r);h=Math.clamp(h,0,1),a[o]=255*h}return a}static createNoiseVolTex(t,e,i){const s=t*t*t,r=new Uint8Array(4*s),a=e>1?216:256,o=.5*a;for(let t=0;t<s;t++)r[4*t+0]=Math.floor(i()*a+o),r[4*t+1]=Math.floor(i()*a+o),r[4*t+2]=Math.floor(i()*a+o),r[4*t+3]=Math.floor(i()*a+o);const h=t*t,A=t;if(e>1){for(let i=0;i<t;i+=e)for(let s=0;s<t;s+=e)for(let a=0;a<t;a++)if(a%e!==0){const o=Math.floor(a/e)*e+t,n=i*h+s*A,l=[],g=[],c=[],m=[];for(let i=0;i<4;i++)l[i]=r[4*n+(o-e)%t*4+i],g[i]=r[4*n+o%t*4+i],c[i]=r[4*n+(o+e)%t*4+i],m[i]=r[4*n+(o+2*e)%t*4+i];const u=a%e/e,f=Yt.dwCubicInterpolate(l,g,c,m,u);for(let t=0;t<4;t++){r[i*h*4+s*A*4+(4*a+t)]=f[t]}}for(let i=0;i<t;i+=e)for(let s=0;s<t;s++)for(let a=0;a<t;a++)if(a%e!==0){const o=Math.floor(a/e)*e+t,n=i*h,l=[],g=[],c=[],m=[];for(let i=0;i<4;i++){const a=4*s+4*n+i;l[i]=r[(o-e)%t*A*4+a],g[i]=r[o%t*A*4+a],c[i]=r[(o+e)%t*A*4+a],m[i]=r[(o+2*e)%t*A*4+a]}const u=a%e/e,f=Yt.dwCubicInterpolate(l,g,c,m,u);for(let t=0;t<4;t++){r[a*A*4+(4*s+4*n+t)]=f[t]}}for(let i=0;i<t;i++)for(let s=0;s<t;s++)for(let a=0;a<t;a++)if(a%e!==0){const o=s*A,n=Math.floor(a/e)*e+t,l=[],g=[],c=[],m=[];for(let s=0;s<4;s++){const a=4*i+4*o+s;l[s]=r[(n-e)%t*h*4+a],g[s]=r[n%t*h*4+a],c[s]=r[(n+e)%t*h*4+a],m[s]=r[(n+2*e)%t*h*4+a]}const u=s%e/e,f=Yt.dwCubicInterpolate(l,g,c,m,u);for(let t=0;t<4;t++){r[a*h*4+(4*i+4*o+t)]=f[t]}}}return r}static createNoiseTex(t,e,i){const s=t*t,r=new Uint8Array(4*s),a=e>1?216:256,o=.5*a;for(let t=0;t<s;t++)r[4*t+0]=Math.floor(i()*a+o),r[4*t+1]=Math.floor(i()*a+o),r[4*t+2]=Math.floor(i()*a+o),r[4*t+3]=Math.floor(i()*a+o);if(e>1){for(let i=0;i<t;i+=e)for(let s=0;s<t;s++)if(s%e!==0){const a=Math.floor(s/e)*e+t,o=i*t,h=[],A=[],n=[],l=[];for(let i=0;i<4;i++)h[i]=r[4*o+(a-e)%t*4+i],A[i]=r[4*o+a%t*4+i],n[i]=r[4*o+(a+e)%t*4+i],l[i]=r[4*o+(a+2*e)%t*4+i];const g=s%e/e,c=Yt.dwCubicInterpolate(h,A,n,l,g);for(let e=0;e<4;e++)r[i*t*4+4*s+e]=c[e]}for(let i=0;i<t;i++)for(let s=0;s<t;s++)if(s%e!==0){const a=Math.floor(s/e)*e+t,o=[],h=[],A=[],n=[];for(let s=0;s<4;s++)o[s]=r[(a-e)%t*t*4+4*i+s],h[s]=r[a%t*t*4+4*i+s],A[s]=r[(a+e)%t*t*4+4*i+s],n[s]=r[(a+2*e)%t*t*4+4*i+s];const l=s%e/e,g=Yt.dwCubicInterpolate(o,h,A,n,l);for(let e=0;e<4;e++)r[s*t*4+4*i+e]=g[e]}}return r}}class Jt{constructor(t){this.gl=t,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.samplers={},this.clouds2Image=new Image,this.clouds2Image.onload=()=>{this.samplers.clouds2=this.gl.createTexture(),this.bindTexture(this.samplers.clouds2,this.clouds2Image,128,128)},this.clouds2Image.src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4RP+RXhpZgAASUkqAAgAAAAJAA8BAgAGAAAAegAAABABAgAVAAAAgAAAABIBAwABAAAAAQAAABoBBQABAAAAoAAAABsBBQABAAAAqAAAACgBAwABAAAAAgAAADIBAgAUAAAAsAAAABMCAwABAAAAAQAAAGmHBAABAAAAxAAAAGYFAABDYW5vbgBDYW5vbiBQb3dlclNob3QgUzExMAAAAAAAAAAAAAAAAEgAAAABAAAASAAAAAEAAAAyMDAyOjAxOjE5IDE3OjMzOjIwABsAmoIFAAEAAABWAwAAnYIFAAEAAABeAwAAAJAHAAQAAAAwMjEwA5ACABQAAAAOAgAABJACABQAAAAiAgAAAZEHAAQAAAABAgMAApEFAAEAAAA+AwAAAZIKAAEAAABGAwAAApIFAAEAAABOAwAABJIKAAEAAABmAwAABZIFAAEAAABuAwAABpIFAAEAAAB2AwAAB5IDAAEAAAAFAAAACZIDAAEAAAAAAAAACpIFAAEAAAB+AwAAfJIHAJoBAACGAwAAhpIHAAgBAAA2AgAAAKAHAAQAAAAwMTAwAaADAAEAAAABAAAAAqAEAAEAAACAAAAAA6AEAAEAAACAAAAABaAEAAEAAAAwBQAADqIFAAEAAAAgBQAAD6IFAAEAAAAoBQAAEKIDAAEAAAACAAAAF6IDAAEAAAACAAAAAK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pwfSbmv8ApKUARhQye2Of20lbs6o2bDkriqrsJWxW0rbVuSr99ANzXLXZ29dSlur+XlS3CdLyvRW1rWsOg55I76MWupyoT6jbvpihtxp8LD4Bj61/RJHoRq8ZmNWFvJWyrcxIjultxP7juNXdEoJouRFqT7rSvqTJXuOffOvaIT6YBJOBxnU9ogpwBjVbTrSDAkxyMc9/5q7NcSOSvbxXtr9r9r920ZqrXhYBSQdQJjQIJx+dTVup7ajSNqknPtqCcAx1lTg5qllPvxcltwj8agSnqpIQSEuqB7nB51dqYjlRLo75BP2xquu+ZckWnoNqw0StqgH2lOYUUeQPzoHM/pRM7E4HYDJ+1EEw7hRxnueB96rabFcqrkmPJa9UNoBLK+x+bng9+NU9woj0+Utb1vtObAMteiR6ae+5I8du+plWqFah0t5VKbEV1xW4uuIO5IA4Bz986z71mvbqpRbmTUaqX429sNhyO4r03BnIWOfIxn8aA3N9CsigDnyen3olFayFDk0665W4Eq1v69HlyC00raWmlBSkKzwSPtwceQdYw+L3rDWLhqggJQ41FiI2RcnBWc/MtQAABJ8eO2tAWXcl2/p3WX3S4pwpVuWySl3I/wD1pQ9erfrM2c+0i3I8sFBcQtMTkI7c7e3PvoZNcPHcCQjj371aiCPGUB5rLNfviqyKYiTU2VrbQdiXHBnIz21CqNq1WpwUzaPDMhtxsLCmkZwD747aOLwgXNHt522avZjQiLWHEEp+dsDcBt9uSM/jVFRLZ6vWBSZF2dNHZSIzzKm5jbRStSRzwUkHgZznHfVxLkyLxgH9DVdo1j6nIpK31QaoylfqMEEDCgBoHl0OU7HVUm2VpS3wpvGc8d9ak6WVGL1IdnW51Ht6NMmuO+ozMGGHMEYKSBhJAPIOO5OfGqC//h1doNVcnUOnThGUopKS0HAoc9iO/wDHjUqak0bGNxz+lQtbK3xrX//Z",this.emptyImage=new Image,this.emptyImage.onload=()=>{this.samplers.empty=this.gl.createTexture(),this.bindTexture(this.samplers.empty,this.emptyImage,1,1)},this.emptyImage.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="}bindTexture(t,e,i,s){if(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i,s,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}}loadExtraImages(t){Object.keys(t).forEach(e=>{const{data:i,width:s,height:r}=t[e];if(!this.samplers[e]){const t=new Image;t.onload=()=>{this.samplers[e]=this.gl.createTexture(),this.bindTexture(this.samplers[e],t,s,r)},t.src=i}})}getTexture(t){const e=this.samplers[t];return e||this.samplers.clouds2}}class Kt{constructor(t,e={}){this.gl=t,this.texsizeX=e.texsizeX,this.texsizeY=e.texsizeY,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions(),this.textTexture=this.gl.createTexture(),this.indexBuf=t.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.vertexBuf=this.gl.createBuffer(),this.canvas=document.createElement("canvas"),this.canvas.width=this.texsizeX,this.canvas.height=this.texsizeY,this.context2D=this.canvas.getContext("2d",{willReadFrequently:!1}),this.floatPrecision=Ut.getFragmentFloatPrecision(this.gl),this.createShader()}generateTitleTexture(t){this.context2D.clearRect(0,0,this.texsizeX,this.texsizeY),this.fontSize=Math.floor(this.texsizeX/256*16),this.fontSize=Math.max(this.fontSize,6),this.context2D.font=`italic ${this.fontSize}px Times New Roman`;let e=t,i=this.context2D.measureText(e).width;if(i>this.texsizeX){const t=this.texsizeX/i*.91;e=`${e.substring(0,Math.floor(e.length*t))}...`,i=this.context2D.measureText(e).width}this.context2D.fillStyle="#FFFFFF",this.context2D.fillText(e,(this.texsizeX-i)/2,this.texsizeY/2);const s=new Uint8Array(this.context2D.getImageData(0,0,this.texsizeX,this.texsizeY).data.buffer);this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.texsizeX,this.texsizeY,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,s),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.bindTexture(this.gl.TEXTURE_2D,null)}updateGlobals(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.canvas.width=this.texsizeX,this.canvas.height=this.texsizeY}buildPositions(){const t=2/15,e=2/7,i=[];for(let s=0;s<8;s++){const r=s*e-1;for(let e=0;e<16;e++){const s=e*t-1;i.push(s,-r,0)}}const s=[];for(let t=0;t<7;t++)for(let e=0;e<15;e++){const i=e+16*t,r=e+16*(t+1),a=e+1+16*(t+1),o=e+1+16*t;s.push(i,r,o),s.push(r,a,o)}this.vertices=new Float32Array(i),this.indices=new Uint16Array(s)}createShader(){this.shaderProgram=this.gl.createProgram();const t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n       const vec2 halfmad = vec2(0.5);\n       in vec2 aPos;\n       in vec2 aUv;\n       out vec2 uv_orig;\n       out vec2 uv;\n       void main(void) {\n         gl_Position = vec4(aPos, 0.0, 1.0);\n         uv_orig = aPos * halfmad + halfmad;\n         uv = aUv;\n       }"),this.gl.compileShader(t);const e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,`#version 300 es\n       precision ${this.floatPrecision} float;\n       precision highp int;\n       precision mediump sampler2D;\n\n       in vec2 uv_orig;\n       in vec2 uv;\n       out vec4 fragColor;\n       uniform sampler2D uTexture;\n       uniform float textColor;\n\n       void main(void) {\n         fragColor = texture(uTexture, uv) * vec4(textColor);\n       }`),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.uvLocation=this.gl.getAttribLocation(this.shaderProgram,"aUv"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.textColorLoc=this.gl.getUniformLocation(this.shaderProgram,"textColor")}generateUvs(t,e,i){const s=[];for(let i=0;i<8;i++)for(let r=0;r<16;r++){const a=2*(r/15)-1;let o=2*(.75*(i/7-.5)+.5)-1;t>=1&&(o+=1/this.texsizeY),s.push(a,e?o:-o)}const r=Math.max(0,1-1.5*t)**1.8*1.3;for(let t=0;t<8;t++)for(let e=0;e<16;e++){const a=16*t+e;s[a]+=.07*r*Math.sin(.31*i.time+.39*s[a]-1.94*s[a+1]),s[a]+=.044*r*Math.sin(.81*i.time-1.91*s[a]+.27*s[a+1]),s[a]+=.061*r*Math.sin(1.31*i.time+.61*s[a]+.74*s[a+1]),s[a+1]+=.061*r*Math.sin(.37*i.time+1.83*s[a]+.69*s[a+1]),s[a+1]+=.07*r*Math.sin(.67*i.time+.42*s[a]-1.39*s[a+1]),s[a+1]+=.087*r*Math.sin(1.07*i.time+3.55*s[a]+.89*s[a+1])}const a=1.01/(t**.21+.01);for(let t=0;t<s.length/2;t++)s[2*t]*=a,s[2*t+1]*=a*this.invAspecty,s[2*t]=(s[2*t]+1)/2,s[2*t+1]=(s[2*t+1]+1)/2;return new Float32Array(s)}renderTitle(t,e,i){this.gl.useProgram(this.shaderProgram);const s=this.generateUvs(t,e,i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.uvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.uvLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textTexture),this.gl.uniform1i(this.textureLoc,0),this.gl.uniform1f(this.textColorLoc,t**.3),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0)}}class jt{constructor(t){this.rng=Rt(),this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.vertInfoA=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)),this.vertInfoC=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)),this.createBlendPattern()}static resizeMatrixValues(t,e,i,s,r){const a=new Float32Array((s+1)*(r+1));let o=0;for(let h=0;h<r+1;h++)for(let A=0;A<s+1;A++){let n=A/r,l=h/s;n*=e+1,l*=i+1,n=Math.clamp(n,0,e-1),l=Math.clamp(l,0,i-1);const g=Math.floor(n),c=Math.floor(l),m=n-g,u=l-c,f=t[c*(e+1)+g],d=t[c*(e+1)+(g+1)],p=t[(c+1)*(e+1)+g],E=t[(c+1)*(e+1)+(g+1)];a[o]=f*(1-m)*(1-u)+d*m*(1-u)+p*(1-m)*u+E*m*u,o+=1}return a}updateGlobals(t){const e=this.mesh_width,i=this.mesh_height;this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.mesh_width===e&&this.mesh_height===i||(this.vertInfoA=jt.resizeMatrixValues(this.vertInfoA,e,i,this.mesh_width,this.mesh_height),this.vertInfoC=jt.resizeMatrixValues(this.vertInfoC,e,i,this.mesh_width,this.mesh_height))}genPlasma(t,e,i,s,r){const a=Math.floor((t+e)/2),o=Math.floor((i+s)/2);let h=this.vertInfoC[i*(this.mesh_width+1)+t],A=this.vertInfoC[i*(this.mesh_width+1)+e],n=this.vertInfoC[s*(this.mesh_width+1)+t],l=this.vertInfoC[s*(this.mesh_width+1)+e];s-i>=2&&(0===t&&(this.vertInfoC[o*(this.mesh_width+1)+t]=.5*(h+n)+(2*this.rng.random()-1)*r*this.aspecty),this.vertInfoC[o*(this.mesh_width+1)+e]=.5*(A+l)+(2*this.rng.random()-1)*r*this.aspecty),e-t>=2&&(0===i&&(this.vertInfoC[i*(this.mesh_width+1)+a]=.5*(h+A)+(2*this.rng.random()-1)*r*this.aspectx),this.vertInfoC[s*(this.mesh_width+1)+a]=.5*(n+l)+(2*this.rng.random()-1)*r*this.aspectx),s-i>=2&&e-t>=2&&(h=this.vertInfoC[o*(this.mesh_width+1)+t],A=this.vertInfoC[o*(this.mesh_width+1)+e],n=this.vertInfoC[i*(this.mesh_width+1)+a],l=this.vertInfoC[s*(this.mesh_width+1)+a],this.vertInfoC[o*(this.mesh_width+1)+a]=.25*(n+l+h+A)+(2*this.rng.random()-1)*r,this.genPlasma(t,a,i,o,.5*r),this.genPlasma(a,e,i,o,.5*r),this.genPlasma(t,a,o,s,.5*r),this.genPlasma(a,e,o,s,.5*r))}createBlendPattern(){const t=1+Math.floor(3*this.rng.random());if(0===t){let t=0;for(let e=0;e<=this.mesh_height;e++)for(let e=0;e<=this.mesh_width;e++)this.vertInfoA[t]=1,this.vertInfoC[t]=0,t+=1}else if(1===t){const t=6.28*this.rng.random(),e=Math.cos(t),i=Math.sin(t),s=.1+.2*this.rng.random(),r=1/s;let a=0;for(let t=0;t<=this.mesh_height;t++){const o=t/this.mesh_height*this.aspecty;for(let t=0;t<=this.mesh_width;t++){let h=(t/this.mesh_width*this.aspectx-.5)*e+(o-.5)*i+.5;h=(h-.5)/Math.sqrt(2)+.5,this.vertInfoA[a]=r*(1+s),this.vertInfoC[a]=r*h-r,a+=1}}}else if(2===t){const t=.12+.13*this.rng.random(),e=1/t;this.vertInfoC[0]=this.rng.random(),this.vertInfoC[this.mesh_width]=this.rng.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)]=this.rng.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)+this.mesh_width]=this.rng.random(),this.genPlasma(0,this.mesh_width,0,this.mesh_height,.25);let i=this.vertInfoC[0],s=this.vertInfoC[0],r=0;for(let t=0;t<=this.mesh_height;t++)for(let t=0;t<=this.mesh_width;t++)i>this.vertInfoC[r]&&(i=this.vertInfoC[r]),s<this.vertInfoC[r]&&(s=this.vertInfoC[r]),r+=1;const a=1/(s-i);r=0;for(let s=0;s<=this.mesh_height;s++)for(let s=0;s<=this.mesh_width;s++){const s=(this.vertInfoC[r]-i)*a;this.vertInfoA[r]=e*(1+t),this.vertInfoC[r]=e*s-e,r+=1}}else if(3===t){const t=.02+.14*this.rng.random()+.34*this.rng.random(),e=1/t,i=2*Math.floor(2*this.rng.random())-1;let s=0;for(let r=0;r<=this.mesh_height;r++){const a=(r/this.mesh_height-.5)*this.aspecty;for(let r=0;r<=this.mesh_width;r++){const o=(r/this.mesh_width-.5)*this.aspectx;let h=1.41421*Math.sqrt(o*o+a*a);-1===i&&(h=1-h),this.vertInfoA[s]=e*(1+t),this.vertInfoC[s]=e*h-e,s+=1}}}}}class Ht{constructor(t,e,i){this.gl=t,this.audio=e,this.frameNum=0,this.fps=30,this.time=0,this.presetTime=0,this.lastTime=performance.now(),this.timeHist=[0],this.timeHistMax=120,this.blending=!1,this.blendStartTime=0,this.blendProgress=0,this.blendDuration=0,this.width=i.width||1200,this.height=i.height||900,this.mesh_width=i.meshWidth||48,this.mesh_height=i.meshHeight||36,this.pixelRatio=i.pixelRatio||window.devicePixelRatio||1,this.textureRatio=i.textureRatio||1,this.outputFXAA=i.outputFXAA||!1,this.texsizeX=this.width*this.pixelRatio*this.textureRatio,this.texsizeY=this.height*this.pixelRatio*this.textureRatio,this.aspectx=this.texsizeY>this.texsizeX?this.texsizeX/this.texsizeY:1,this.aspecty=this.texsizeX>this.texsizeY?this.texsizeY/this.texsizeX:1,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=vt.range(1,33).map(t=>`q${t}`),this.ts=vt.range(1,9).map(t=>`t${t}`),this.regs=vt.range(0,100).map(t=>t<10?`reg0${t}`:`reg${t}`),this.blurRatios=[[.5,.25],[.125,.125],[.0625,.0625]],this.audioLevels=new bt(this.audio),this.prevFrameBuffer=this.gl.createFramebuffer(),this.targetFrameBuffer=this.gl.createFramebuffer(),this.prevTexture=this.gl.createTexture(),this.targetTexture=this.gl.createTexture(),this.compFrameBuffer=this.gl.createFramebuffer(),this.compTexture=this.gl.createTexture(),this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.bindFrameBufferTexture(this.prevFrameBuffer,this.prevTexture),this.bindFrameBufferTexture(this.targetFrameBuffer,this.targetTexture),this.bindFrameBufferTexture(this.compFrameBuffer,this.compTexture);const s={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.noise=new Yt(t),this.image=new Jt(t),this.warpShader=new zt(t,this.noise,this.image,s),this.compShader=new Nt(t,this.noise,this.image,s),this.outputShader=new Xt(t,s),this.prevWarpShader=new zt(t,this.noise,this.image,s),this.prevCompShader=new Nt(t,this.noise,this.image,s),this.numBlurPasses=0,this.blurShader1=new Wt(0,this.blurRatios,t,s),this.blurShader2=new Wt(1,this.blurRatios,t,s),this.blurShader3=new Wt(2,this.blurRatios,t,s),this.blurTexture1=this.blurShader1.blurVerticalTexture,this.blurTexture2=this.blurShader2.blurVerticalTexture,this.blurTexture3=this.blurShader3.blurVerticalTexture,this.basicWaveform=new Ft(t,s),this.customWaveforms=vt.range(4).map(e=>new Qt(e,t,s)),this.customShapes=vt.range(4).map(e=>new Mt(e,t,s)),this.prevCustomWaveforms=vt.range(4).map(e=>new Qt(e,t,s)),this.prevCustomShapes=vt.range(4).map(e=>new Mt(e,t,s)),this.darkenCenter=new Vt(t,s),this.innerBorder=new Dt(t,s),this.outerBorder=new Dt(t,s),this.motionVectors=new qt(t,s),this.titleText=new Kt(t,s),this.blendPattern=new jt(s),this.resampleShader=new kt(t),this.supertext={startTime:-1},this.warpUVs=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*2),this.warpColor=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*4),this.gl.clearColor(0,0,0,1),this.blankPreset=xt;const r={frame:0,time:0,fps:45,bass:1,bass_att:1,mid:1,mid_att:1,treb:1,treb_att:1};this.preset=xt,this.prevPreset=this.preset,this.presetEquationRunner=new It(this.preset,r,s),this.prevPresetEquationRunner=new It(this.prevPreset,r,s),this.preset.useWASM||(this.regVars=this.presetEquationRunner.mdVSRegs)}static getHighestBlur(t){return/sampler_blur3/.test(t)?3:/sampler_blur2/.test(t)?2:/sampler_blur1/.test(t)?1:0}loadPreset(t,e){this.blendPattern.createBlendPattern(),this.blending=!0,this.blendStartTime=this.time,this.blendDuration=e,this.blendProgress=0,this.prevPresetEquationRunner=this.presetEquationRunner,this.prevPreset=this.preset,this.preset=t,this.presetTime=this.time;const i={frame:this.frameNum,time:this.time,fps:this.fps,bass:this.audioLevels.bass,bass_att:this.audioLevels.bass_att,mid:this.audioLevels.mid,mid_att:this.audioLevels.mid_att,treb:this.audioLevels.treb,treb_att:this.audioLevels.treb_att},s={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};t.useWASM?(this.preset.globalPools.perFrame.old_wave_mode.value=this.prevPreset.baseVals.wave_mode,this.preset.baseVals.old_wave_mode=this.prevPreset.baseVals.wave_mode,this.presetEquationRunner=new yt(this.preset,i,s),this.preset.pixel_eqs_initialize_array&&this.preset.pixel_eqs_initialize_array(this.mesh_width,this.mesh_height)):(this.preset.baseVals.old_wave_mode=this.prevPreset.baseVals.wave_mode,this.presetEquationRunner=new It(this.preset,i,s),this.regVars=this.presetEquationRunner.mdVSRegs);const r=this.prevWarpShader;this.prevWarpShader=this.warpShader,this.warpShader=r;const a=this.prevCompShader;this.prevCompShader=this.compShader,this.compShader=a;const o=this.preset.warp.trim(),h=this.preset.comp.trim();this.warpShader.updateShader(o),this.compShader.updateShader(h),0===o.length?this.numBlurPasses=0:this.numBlurPasses=Ht.getHighestBlur(o),0!==h.length&&(this.numBlurPasses=Math.max(this.numBlurPasses,Ht.getHighestBlur(h)))}loadExtraImages(t){this.image.loadExtraImages(t)}setRendererSize(t,e,i){const s=this.texsizeX,r=this.texsizeY;if(this.width=t,this.height=e,this.mesh_width=i.meshWidth||this.mesh_width,this.mesh_height=i.meshHeight||this.mesh_height,this.pixelRatio=i.pixelRatio||this.pixelRatio,this.textureRatio=i.textureRatio||this.textureRatio,this.texsizeX=t*this.pixelRatio*this.textureRatio,this.texsizeY=e*this.pixelRatio*this.textureRatio,this.aspectx=this.texsizeY>this.texsizeX?this.texsizeX/this.texsizeY:1,this.aspecty=this.texsizeX>this.texsizeY?this.texsizeY/this.texsizeX:1,this.texsizeX!==s||this.texsizeY!==r){const t=this.gl.createTexture();this.bindFrameBufferTexture(this.targetFrameBuffer,t),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY),this.resampleShader.renderQuadTexture(this.targetTexture),this.targetTexture=t,this.bindFrameBufferTexture(this.prevFrameBuffer,this.prevTexture),this.bindFrameBufferTexture(this.compFrameBuffer,this.compTexture)}this.updateGlobals(),this.frameNum>0&&this.renderToScreen()}setInternalMeshSize(t,e){this.mesh_width=t,this.mesh_height=e,this.updateGlobals()}setOutputAA(t){this.outputFXAA=t}updateGlobals(){const t={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.presetEquationRunner.updateGlobals(t),this.prevPresetEquationRunner.updateGlobals(t),this.warpShader.updateGlobals(t),this.prevWarpShader.updateGlobals(t),this.compShader.updateGlobals(t),this.prevCompShader.updateGlobals(t),this.outputShader.updateGlobals(t),this.blurShader1.updateGlobals(t),this.blurShader2.updateGlobals(t),this.blurShader3.updateGlobals(t),this.basicWaveform.updateGlobals(t),this.customWaveforms.forEach(e=>e.updateGlobals(t)),this.customShapes.forEach(e=>e.updateGlobals(t)),this.prevCustomWaveforms.forEach(e=>e.updateGlobals(t)),this.prevCustomShapes.forEach(e=>e.updateGlobals(t)),this.darkenCenter.updateGlobals(t),this.innerBorder.updateGlobals(t),this.outerBorder.updateGlobals(t),this.motionVectors.updateGlobals(t),this.titleText.updateGlobals(t),this.blendPattern.updateGlobals(t),this.warpUVs=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*2),this.warpColor=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*4),this.preset.pixel_eqs_initialize_array&&this.preset.pixel_eqs_initialize_array(this.mesh_width,this.mesh_height)}calcTimeAndFPS(t){let e;if(t)e=t;else{const t=performance.now();e=(t-this.lastTime)/1e3,(e>1||e<0||this.frame<2)&&(e=1/30),this.lastTime=t}this.time+=1/this.fps,this.blending&&(this.blendProgress=(this.time-this.blendStartTime)/this.blendDuration,this.blendProgress>1&&(this.blending=!1));const i=this.timeHist[this.timeHist.length-1]+e;this.timeHist.push(i),this.timeHist.length>this.timeHistMax&&this.timeHist.shift();const s=this.timeHist.length/(i-this.timeHist[0]);if(Math.abs(s-this.fps)>3&&this.frame>this.timeHistMax)this.fps=s;else{const t=.93;this.fps=t*this.fps+(1-t)*s}}runPixelEquations(t,e,i,s){const r=this.mesh_width,a=this.mesh_height,o=r+1,h=a+1,A=this.time*e.warpanimspeed,n=1/e.warpscale,l=11.68+4*Math.cos(1.413*A+10),g=8.77+3*Math.cos(1.113*A+7),c=10.54+3*Math.cos(1.233*A+3),m=11.49+4*Math.cos(.933*A+5),u=0/this.texsizeX,f=0/this.texsizeY,d=this.aspectx,p=this.aspecty;let E=0,_=0;if(t.preset.useWASM){const r=t.preset.globalPools.perVertex;if(vt.setWasm(r,i,t.globalKeys),vt.setWasm(r,t.mdVSQAfterFrame,t.qs),r.zoom.value=e.zoom,r.zoomexp.value=e.zoomexp,r.rot.value=e.rot,r.warp.value=e.warp,r.cx.value=e.cx,r.cy.value=e.cy,r.dx.value=e.dx,r.dy.value=e.dy,r.sx.value=e.sx,r.sy.value=e.sy,t.preset.pixel_eqs_wasm(t.runVertEQs,this.mesh_width,this.mesh_height,this.time,e.warpanimspeed,e.warpscale,this.aspectx,this.aspecty),s){const e=t.preset.pixel_eqs_get_array();let i=0,s=0;for(let t=0;t<h;t++)for(let t=0;t<o;t++){const t=e[i],r=e[i+1];let a=this.blendPattern.vertInfoA[i/2]*this.blendProgress+this.blendPattern.vertInfoC[i/2];a=Math.clamp(a,0,1),this.warpUVs[i]=this.warpUVs[i]*a+t*(1-a),this.warpUVs[i+1]=this.warpUVs[i+1]*a+r*(1-a),this.warpColor[s+0]=1,this.warpColor[s+1]=1,this.warpColor[s+2]=1,this.warpColor[s+3]=a,i+=2,s+=4}}else this.warpUVs=t.preset.pixel_eqs_get_array(),this.warpColor.fill(1)}else{let i=vt.cloneVars(e),b=i.warp,x=i.zoom,v=i.zoomexp,T=i.cx,w=i.cy,S=i.sx,P=i.sy,R=i.dx,I=i.dy,y=i.rot;for(let B=0;B<h;B++)for(let h=0;h<o;h++){const o=h/r*2-1,L=B/a*2-1,U=Math.sqrt(o*o*d*d+L*L*p*p);if(t.runVertEQs){let s;s=B===a/2&&h===r/2?0:vt.atan2(L*p,o*d),i.x=.5*o*d+.5,i.y=-.5*L*p+.5,i.rad=U,i.ang=s,i.zoom=e.zoom,i.zoomexp=e.zoomexp,i.rot=e.rot,i.warp=e.warp,i.cx=e.cx,i.cy=e.cy,i.dx=e.dx,i.dy=e.dy,i.sx=e.sx,i.sy=e.sy,i=t.runPixelEquations(i),b=i.warp,x=i.zoom,v=i.zoomexp,T=i.cx,w=i.cy,S=i.sx,P=i.sy,R=i.dx,I=i.dy,y=i.rot}const C=1/x**(v**(2*U-1));let F=.5*o*d*C+.5,Q=.5*-L*p*C+.5;F=(F-T)/S+T,Q=(Q-w)/P+w,0!==b&&(F+=.0035*b*Math.sin(.333*A+n*(o*l-L*m)),Q+=.0035*b*Math.cos(.375*A-n*(o*c+L*g)),F+=.0035*b*Math.cos(.753*A-n*(o*g-L*c)),Q+=.0035*b*Math.sin(.825*A+n*(o*l+L*m)));const M=F-T,D=Q-w,V=Math.cos(y),q=Math.sin(y);if(F=M*V-D*q+T,Q=M*q+D*V+w,F-=R,Q-=I,F=(F-.5)/d+.5,Q=(Q-.5)/p+.5,F+=u,Q+=f,s){let t=this.blendPattern.vertInfoA[E/2]*this.blendProgress+this.blendPattern.vertInfoC[E/2];t=Math.clamp(t,0,1),this.warpUVs[E]=this.warpUVs[E]*t+F*(1-t),this.warpUVs[E+1]=this.warpUVs[E+1]*t+Q*(1-t),this.warpColor[_+0]=1,this.warpColor[_+1]=1,this.warpColor[_+2]=1,this.warpColor[_+3]=t}else this.warpUVs[E]=F,this.warpUVs[E+1]=Q,this.warpColor[_+0]=1,this.warpColor[_+1]=1,this.warpColor[_+2]=1,this.warpColor[_+3]=1;E+=2,_+=4}this.mdVSVertex=i}}static mixFrameEquations(t,e,i){const s=.5-.5*Math.cos(t*Math.PI),r=1-s,a=.5,o=vt.cloneVars(e);return o.decay=s*e.decay+r*i.decay,o.wave_a=s*e.wave_a+r*i.wave_a,o.wave_r=s*e.wave_r+r*i.wave_r,o.wave_g=s*e.wave_g+r*i.wave_g,o.wave_b=s*e.wave_b+r*i.wave_b,o.wave_x=s*e.wave_x+r*i.wave_x,o.wave_y=s*e.wave_y+r*i.wave_y,o.wave_mystery=s*e.wave_mystery+r*i.wave_mystery,o.ob_size=s*e.ob_size+r*i.ob_size,o.ob_r=s*e.ob_r+r*i.ob_r,o.ob_g=s*e.ob_g+r*i.ob_g,o.ob_b=s*e.ob_b+r*i.ob_b,o.ob_a=s*e.ob_a+r*i.ob_a,o.ib_size=s*e.ib_size+r*i.ib_size,o.ib_r=s*e.ib_r+r*i.ib_r,o.ib_g=s*e.ib_g+r*i.ib_g,o.ib_b=s*e.ib_b+r*i.ib_b,o.ib_a=s*e.ib_a+r*i.ib_a,o.mv_x=s*e.mv_x+r*i.mv_x,o.mv_y=s*e.mv_y+r*i.mv_y,o.mv_dx=s*e.mv_dx+r*i.mv_dx,o.mv_dy=s*e.mv_dy+r*i.mv_dy,o.mv_l=s*e.mv_l+r*i.mv_l,o.mv_r=s*e.mv_r+r*i.mv_r,o.mv_g=s*e.mv_g+r*i.mv_g,o.mv_b=s*e.mv_b+r*i.mv_b,o.mv_a=s*e.mv_a+r*i.mv_a,o.echo_zoom=s*e.echo_zoom+r*i.echo_zoom,o.echo_alpha=s*e.echo_alpha+r*i.echo_alpha,o.echo_orient=s*e.echo_orient+r*i.echo_orient,o.wave_dots=s<a?i.wave_dots:e.wave_dots,o.wave_thick=s<a?i.wave_thick:e.wave_thick,o.additivewave=s<a?i.additivewave:e.additivewave,o.wave_brighten=s<a?i.wave_brighten:e.wave_brighten,o.darken_center=s<a?i.darken_center:e.darken_center,o.gammaadj=s<a?i.gammaadj:e.gammaadj,o.wrap=s<a?i.wrap:e.wrap,o.invert=s<a?i.invert:e.invert,o.brighten=s<a?i.brighten:e.brighten,o.darken=s<a?i.darken:e.darken,o.solarize=s<a?i.brighten:e.solarize,o.b1n=s*e.b1n+r*i.b1n,o.b2n=s*e.b2n+r*i.b2n,o.b3n=s*e.b3n+r*i.b3n,o.b1x=s*e.b1x+r*i.b1x,o.b2x=s*e.b2x+r*i.b2x,o.b3x=s*e.b3x+r*i.b3x,o.b1ed=s*e.b1ed+r*i.b1ed,o}static getBlurValues(t){let e=t.b1n,i=t.b2n,s=t.b3n,r=t.b1x,a=t.b2x,o=t.b3x;const h=.1;if(r-e<h){const t=.5*(e+r);e=t-.05,r=t-.05}if(a=Math.min(r,a),i=Math.max(e,i),a-i<h){const t=.5*(i+a);i=t-.05,a=t-.05}if(o=Math.min(a,o),s=Math.max(i,s),o-s<h){const t=.5*(s+o);s=t-.05,o=t-.05}return{blurMins:[e,i,s],blurMaxs:[r,a,o]}}bindFrambufferAndSetViewport(t,e,i){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.viewport(0,0,e,i)}bindFrameBufferTexture(t,e){if(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.texsizeX,this.texsizeY,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(this.texsizeX*this.texsizeY*4)),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){const t=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,t)}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e,0)}render({audioLevels:t,elapsedTime:e}={}){this.calcTimeAndFPS(e),this.frameNum+=1,t?this.audio.updateAudio(t.timeByteArray,t.timeByteArrayL,t.timeByteArrayR):this.audio.sampleAudio(),this.audioLevels.updateAudioLevels(this.fps,this.frameNum);const i={frame:this.frameNum,time:this.time,fps:this.fps,bass:this.audioLevels.bass,bass_att:this.audioLevels.bass_att,mid:this.audioLevels.mid,mid_att:this.audioLevels.mid_att,treb:this.audioLevels.treb,treb_att:this.audioLevels.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY},s=Object.assign({},i);this.prevPreset.useWASM||(s.gmegabuf=this.prevPresetEquationRunner.gmegabuf),this.preset.useWASM||(i.gmegabuf=this.presetEquationRunner.gmegabuf,Object.assign(i,this.regVars));const r=this.presetEquationRunner.runFrameEquations(i);let a;this.runPixelEquations(this.presetEquationRunner,r,i,!1),this.preset.useWASM||(Object.assign(this.regVars,vt.pick(this.mdVSVertex,this.regs)),Object.assign(i,this.regVars)),this.blending?(this.prevMDVSFrame=this.prevPresetEquationRunner.runFrameEquations(s),this.runPixelEquations(this.prevPresetEquationRunner,this.prevMDVSFrame,s,!0),a=Ht.mixFrameEquations(this.blendProgress,r,this.prevMDVSFrame)):a=r;const o=this.targetTexture;this.targetTexture=this.prevTexture,this.prevTexture=o;const h=this.targetFrameBuffer;this.targetFrameBuffer=this.prevFrameBuffer,this.prevFrameBuffer=h,this.gl.bindTexture(this.gl.TEXTURE_2D,this.prevTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.enable(this.gl.BLEND),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const{blurMins:A,blurMaxs:n}=Ht.getBlurValues(a);this.blending?(this.prevWarpShader.renderQuadTexture(!1,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,A,n,this.prevMDVSFrame,this.prevPresetEquationRunner.mdVSQAfterFrame,this.warpUVs,this.warpColor),this.warpShader.renderQuadTexture(!0,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,A,n,a,this.presetEquationRunner.mdVSQAfterFrame,this.warpUVs,this.warpColor)):this.warpShader.renderQuadTexture(!1,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,A,n,r,this.presetEquationRunner.mdVSQAfterFrame,this.warpUVs,this.warpColor),this.numBlurPasses>0&&(this.blurShader1.renderBlurTexture(this.targetTexture,r,A,n),this.numBlurPasses>1&&(this.blurShader2.renderBlurTexture(this.blurTexture1,r,A,n),this.numBlurPasses>2&&this.blurShader3.renderBlurTexture(this.blurTexture2,r,A,n)),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY)),this.motionVectors.drawMotionVectors(a,this.warpUVs),this.preset.shapes&&this.preset.shapes.length>0&&this.customShapes.forEach((t,e)=>{t.drawCustomShape(this.blending?this.blendProgress:1,i,this.presetEquationRunner,this.preset.shapes[e],this.prevTexture)}),this.preset.waves&&this.preset.waves.length>0&&this.customWaveforms.forEach((t,e)=>{t.drawCustomWaveform(this.blending?this.blendProgress:1,this.audio.timeArrayL,this.audio.timeArrayR,this.audio.freqArrayL,this.audio.freqArrayR,i,this.presetEquationRunner,this.preset.waves[e])}),this.blending&&(this.prevPreset.shapes&&this.prevPreset.shapes.length>0&&this.prevCustomShapes.forEach((t,e)=>{t.drawCustomShape(1-this.blendProgress,s,this.prevPresetEquationRunner,this.prevPreset.shapes[e],this.prevTexture)}),this.prevPreset.waves&&this.prevPreset.waves.length>0&&this.prevCustomWaveforms.forEach((t,e)=>{t.drawCustomWaveform(1-this.blendProgress,this.audio.timeArrayL,this.audio.timeArrayR,this.audio.freqArrayL,this.audio.freqArrayR,s,this.prevPresetEquationRunner,this.prevPreset.waves[e])})),this.basicWaveform.drawBasicWaveform(this.blending,this.blendProgress,this.audio.timeArrayL,this.audio.timeArrayR,a),this.darkenCenter.drawDarkenCenter(a);const l=[a.ob_r,a.ob_g,a.ob_b,a.ob_a];this.outerBorder.drawBorder(l,a.ob_size,0);const g=[a.ib_r,a.ib_g,a.ib_b,a.ib_a];if(this.innerBorder.drawBorder(g,a.ib_size,a.ob_size),this.supertext.startTime>=0){const t=(this.time-this.supertext.startTime)/this.supertext.duration;t>=1&&this.titleText.renderTitle(t,!0,i)}this.globalVars=i,this.mdVSFrame=r,this.mdVSFrameMixed=a,this.renderToScreen()}renderToScreen(){this.outputFXAA?this.bindFrambufferAndSetViewport(this.compFrameBuffer,this.texsizeX,this.texsizeY):this.bindFrambufferAndSetViewport(null,this.width,this.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.enable(this.gl.BLEND),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);const{blurMins:t,blurMaxs:e}=Ht.getBlurValues(this.mdVSFrameMixed);if(this.blending?(this.prevCompShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,t,e,this.prevMDVSFrame,this.prevPresetEquationRunner.mdVSQAfterFrame,this.warpColor),this.compShader.renderQuadTexture(!0,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,t,e,this.mdVSFrameMixed,this.presetEquationRunner.mdVSQAfterFrame,this.warpColor)):this.compShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,t,e,this.mdVSFrame,this.presetEquationRunner.mdVSQAfterFrame,this.warpColor),this.supertext.startTime>=0){const t=(this.time-this.supertext.startTime)/this.supertext.duration;this.titleText.renderTitle(t,!1,this.globalVars),t>=1&&(this.supertext.startTime=-1)}this.outputFXAA&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.compTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(null,this.width,this.height),this.outputShader.renderQuadTexture(this.compTexture))}launchSongTitleAnim(t){this.supertext={startTime:this.time,duration:1.7},this.titleText.generateTitleTexture(t)}toDataURL(){const t=new Uint8Array(this.texsizeX*this.texsizeY*4),e=this.gl.createFramebuffer(),i=this.gl.createTexture();this.bindFrameBufferTexture(e,i);const{blurMins:s,blurMaxs:r}=Ht.getBlurValues(this.mdVSFrameMixed);this.compShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,s,r,this.mdVSFrame,this.presetEquationRunner.mdVSQAfterFrame,this.warpColor),this.gl.readPixels(0,0,this.texsizeX,this.texsizeY,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),Array.from({length:this.texsizeY},(e,i)=>t.slice(i*this.texsizeX*4,(i+1)*this.texsizeX*4)).forEach((e,i)=>t.set(e,(this.texsizeY-i-1)*this.texsizeX*4));const a=document.createElement("canvas");a.width=this.texsizeX,a.height=this.texsizeY;const o=a.getContext("2d",{willReadFrequently:!1}),h=o.createImageData(this.texsizeX,this.texsizeY);return h.data.set(t),o.putImageData(h,0,0),this.gl.deleteTexture(i),this.gl.deleteFramebuffer(e),a.toDataURL()}warpBufferToDataURL(){const t=new Uint8Array(this.texsizeX*this.texsizeY*4);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.targetFrameBuffer),this.gl.readPixels(0,0,this.texsizeX,this.texsizeY,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t);const e=document.createElement("canvas");e.width=this.texsizeX,e.height=this.texsizeY;const i=e.getContext("2d",{willReadFrequently:!1}),s=i.createImageData(this.texsizeX,this.texsizeY);return s.data.set(t),i.putImageData(s,0,0),e.toDataURL()}}class Zt{constructor(t,e,i){this.opts=i,this.rng=Pt(i),this.deterministicMode=i.deterministic||i.testMode,this.audio=new _t(t);const s=i.width||1200,r=i.height||900;window.OffscreenCanvas?this.internalCanvas=new OffscreenCanvas(s,r):(this.internalCanvas=document.createElement("canvas"),this.internalCanvas.width=s,this.internalCanvas.height=r),this.gl=this.internalCanvas.getContext("webgl2",{alpha:!1,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1}),this.outputGl=e.getContext("2d",{willReadFrequently:!1}),this.baseValsDefaults={decay:.98,gammaadj:2,echo_zoom:2,echo_alpha:0,echo_orient:0,red_blue:0,brighten:0,darken:0,wrap:1,darken_center:0,solarize:0,invert:0,bmotionvectorson:1,fshader:0,b1n:0,b2n:0,b3n:0,b1x:1,b2x:1,b3x:1,b1ed:.25,wave_mode:0,additivewave:0,wave_dots:0,wave_thick:0,wave_a:.8,wave_scale:1,wave_smoothing:.75,wave_mystery:0,modwavealphabyvolume:0,modwavealphastart:.75,modwavealphaend:.95,wave_r:1,wave_g:1,wave_b:1,wave_x:.5,wave_y:.5,wave_brighten:1,mv_x:12,mv_y:9,mv_dx:0,mv_dy:0,mv_l:.9,mv_r:1,mv_g:1,mv_b:1,mv_a:1,warpanimspeed:1,warpscale:1,zoomexp:1,zoom:1,rot:0,cx:.5,cy:.5,dx:0,dy:0,warp:1,sx:1,sy:1,ob_size:.01,ob_r:0,ob_g:0,ob_b:0,ob_a:0,ib_size:.01,ib_r:.25,ib_g:.25,ib_b:.25,ib_a:0},this.shapeBaseValsDefaults={enabled:0,sides:4,additive:0,thickoutline:0,textured:0,num_inst:1,tex_zoom:1,tex_ang:0,x:.5,y:.5,rad:.1,ang:0,r:1,g:0,b:0,a:1,r2:0,g2:1,b2:0,a2:0,border_r:1,border_g:1,border_b:1,border_a:.1},this.waveBaseValsDefaults={enabled:0,samples:512,sep:0,scaling:1,smoothing:.5,r:1,g:1,b:1,a:1,spectrum:0,usedots:0,thick:0,additive:0},this.qs=vt.range(1,33).map(t=>`q${t}`),this.ts=vt.range(1,9).map(t=>`t${t}`),this.globalPerFrameVars=["old_wave_mode","frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset"],this.globalPerPixelVars=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset","x","y","rad","ang"],this.globalShapeVars=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset","instance"],this.shapeBaseVars=["x","y","rad","ang","r","g","b","a","r2","g2","b2","a2","border_r","border_g","border_b","border_a","thickoutline","textured","tex_zoom","tex_ang","additive"],this.globalWaveVars=["frame","time","fps","bass","bass_att","mid","mid_att","treb","treb_att","meshx","meshy","aspectx","aspecty","pixelsx","pixelsy","rand_start","rand_preset","x","y","sample","value1","value2"],this.renderer=new Ht(this.gl,this.audio,i)}loseGLContext(){this.gl.getExtension("WEBGL_lose_context").loseContext(),this.outputGl=null}connectAudio(t){this.audioNode=t,this.audio.connectAudio(t)}disconnectAudio(t){this.audio.disconnectAudio(t)}static overrideDefaultVars(t,e){const i={};return Object.keys(t).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)?i[s]=e[s]:i[s]=t[s]}),i}createQVars(){const t={};return this.qs.forEach(e=>{t[e]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),t}createTVars(){const t={};return this.ts.forEach(e=>{t[e]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),t}createPerFramePool(t){const e={};return Object.keys(this.baseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalPerFrameVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}createPerPixelPool(t){const e={};return Object.keys(this.baseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalPerPixelVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}createCustomShapePerFramePool(t){const e={};return Object.keys(this.shapeBaseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalShapeVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}createCustomWavePerFramePool(t){const e={};return Object.keys(this.waveBaseValsDefaults).forEach(i=>{e[i]=new WebAssembly.Global({value:"f64",mutable:!0},t[i])}),this.globalWaveVars.forEach(t=>{e[t]=new WebAssembly.Global({value:"f64",mutable:!0},0)}),e}static makeShapeResetPool(t,e,i){return e.reduce((e,s)=>({...e,[`${s}_${i}`]:t[s]}),{})}static base64ToArrayBuffer(t){for(var e=window.atob(t),i=e.length,s=new Uint8Array(i),r=0;r<i;r++)s[r]=e.charCodeAt(r);return s.buffer}async loadPreset(t,e=0){const i=JSON.parse(JSON.stringify(t));i.baseVals=Zt.overrideDefaultVars(this.baseValsDefaults,i.baseVals);for(let t=0;t<i.shapes.length;t++)i.shapes[t].baseVals=Zt.overrideDefaultVars(this.shapeBaseValsDefaults,i.shapes[t].baseVals);for(let t=0;t<i.waves.length;t++)i.waves[t].baseVals=Zt.overrideDefaultVars(this.waveBaseValsDefaults,i.waves[t].baseVals);const s=i.useJS&&!this.opts.onlyUseWASM;Object.prototype.hasOwnProperty.call(i,"init_eqs_eel")&&!s?(i.useWASM=!0,await this.loadWASMPreset(i,e)):this.opts.onlyUseWASM?console.warn("Tried to load a preset that doesn't support WASM with onlyUseWASM on"):Object.prototype.hasOwnProperty.call(i,"init_eqs_str")?this.loadJSPreset(i,e):console.warn("Tried to load a JS preset that doesn't have converted strings")}async loadWASMPreset(t,e){const i=this.createQVars(),s=this.createTVars(),r={perFrame:{...i,...this.createPerFramePool(t.baseVals)},perVertex:{...i,...this.createPerPixelPool(t.baseVals)}},a={presetInit:{pool:"perFrame",code:t.init_eqs_eel},perFrame:{pool:"perFrame",code:t.frame_eqs_eel}};""!==t.pixel_eqs_eel&&(a.perPixel={pool:"perVertex",code:t.pixel_eqs_eel});for(let e=0;e<t.shapes.length;e++)r[`shapePerFrame${e}`]={...i,...s,...this.createCustomShapePerFramePool(t.shapes[e].baseVals)},0!==t.shapes[e].baseVals.enabled&&(a[`shapes_${e}_init_eqs`]={pool:`shapePerFrame${e}`,code:t.shapes[e].init_eqs_eel},a[`shapes_${e}_frame_eqs`]={pool:`shapePerFrame${e}`,code:t.shapes[e].frame_eqs_eel});for(let e=0;e<t.waves.length;e++)0!==t.waves[e].baseVals.enabled&&(r[`wavePerFrame${e}`]={...i,...s,...this.createCustomWavePerFramePool(t.waves[e].baseVals)},a[`waves_${e}_init_eqs`]={pool:`wavePerFrame${e}`,code:t.waves[e].init_eqs_eel},a[`waves_${e}_frame_eqs`]={pool:`wavePerFrame${e}`,code:t.waves[e].frame_eqs_eel},t.waves[e].point_eqs_eel&&""!==t.waves[e].point_eqs_eel&&(a[`waves_${e}_point_eqs`]={pool:`wavePerFrame${e}`,code:t.waves[e].point_eqs_eel}));const o=await async function({pools:t,functions:e,eelVersion:i=2}){let s={};Object.entries(t).forEach(([t,e])=>{s[t]=new Set(Object.keys(e))});const r=at({pools:s,functions:e,eelVersion:i}),a=await WebAssembly.compile(r);var o=Object.assign(Object.assign({},t),{shims:j});return await WebAssembly.instantiate(a,o)}({pools:r,functions:a,eelVersion:t.version||2}),h=t=>t||(()=>{}),A=await pt.instantiate(Zt.base64ToArrayBuffer("AGFzbQEAAAABPQpgAABgAXwBfGACfHwBfGACf38AYAR/f39/AGAJf39/f3x8fHx8AGADf399AGABfwF/YAJ/fwF/YAF+AX8CuBWMAQNlbnYFYWJvcnQABAhwaXhlbEVxcwtwZXJQaXhlbEVxcwAADHBpeGVsVmFyUG9vbAR3YXJwA3wBDHBpeGVsVmFyUG9vbAR6b29tA3wBDHBpeGVsVmFyUG9vbAd6b29tZXhwA3wBDHBpeGVsVmFyUG9vbAJjeAN8AQxwaXhlbFZhclBvb2wCY3kDfAEMcGl4ZWxWYXJQb29sAnN4A3wBDHBpeGVsVmFyUG9vbAJzeQN8AQxwaXhlbFZhclBvb2wCZHgDfAEMcGl4ZWxWYXJQb29sAmR5A3wBDHBpeGVsVmFyUG9vbANyb3QDfAEMcGl4ZWxWYXJQb29sA3JhZAN8AQxwaXhlbFZhclBvb2wDYW5nA3wBDHBpeGVsVmFyUG9vbAF4A3wBDHBpeGVsVmFyUG9vbAF5A3wBCHFWYXJQb29sAnExA3wBCHFWYXJQb29sAnEyA3wBCHFWYXJQb29sAnEzA3wBCHFWYXJQb29sAnE0A3wBCHFWYXJQb29sAnE1A3wBCHFWYXJQb29sAnE2A3wBCHFWYXJQb29sAnE3A3wBCHFWYXJQb29sAnE4A3wBCHFWYXJQb29sAnE5A3wBCHFWYXJQb29sA3ExMAN8AQhxVmFyUG9vbANxMTE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perVertex.zoomexp,cx:r.perVertex.cx,cy:r.perVertex.cy,sx:r.perVertex.sx,sy:r.perVertex.sy,dx:r.perVertex.dx,dy:r.perVertex.dy,rot:r.perVertex.rot,x:r.perVertex.x,y:r.perVertex.y,ang:r.perVertex.ang,rad:r.perVertex.rad},qVarPool:i,tVarPool:s,shapePool0:Zt.makeShapeResetPool(r.shapePerFrame0,this.shapeBaseVars,0),shapePool1:Zt.makeShapeResetPool(r.shapePerFrame1,this.shapeBaseVars,1),shapePool2:Zt.makeShapeResetPool(r.shapePerFrame2,this.shapeBaseVars,2),shapePool3:Zt.makeShapeResetPool(r.shapePerFrame3,this.shapeBaseVars,3),console:{logi:t=>{console.log("logi: "+t)},logf:t=>{console.log("logf: "+t)}},env:{abort:()=>{}}});t.globalPools=r,t.init_eqs=h(o.exports.presetInit),t.frame_eqs=h(o.exports.perFrame),t.save_qs=A.exports.saveQs,t.restore_qs=A.exports.restoreQs,t.save_ts=A.exports.saveTs,t.restore_ts=A.exports.restoreTs,o.exports.perPixel&&(t.pixel_eqs=o.exports.perPixel),t.pixel_eqs_initialize_array=(e,i)=>{const s=A.exports.createFloat32Array((e+1)*(i+1)*2);t.pixel_eqs_array=s},t.pixel_eqs_get_array=()=>A.exports.__getFloat32ArrayView(t.pixel_eqs_array),t.pixel_eqs_wasm=(...e)=>A.exports.runPixelEquations(t.pixel_eqs_array,...e);for(let e=0;e<t.shapes.length;e++)0!==t.shapes[e].baseVals.enabled&&(t.shapes[e].init_eqs=h(o.exports[`shapes_${e}_init_eqs`]),t.shapes[e].frame_eqs=o.exports[`shapes_${e}_frame_eqs`],t.shapes[e].frame_eqs_save=()=>A.exports[`shape${e}_save`](),t.shapes[e].frame_eqs_restore=()=>A.exports[`shape${e}_restore`]());for(let e=0;e<t.waves.length;e++)if(0!==t.waves[e].baseVals.enabled){const i={init_eqs:h(o.exports[`waves_${e}_init_eqs`]),frame_eqs:h(o.exports[`waves_${e}_frame_eqs`])};t.waves[e].point_eqs_eel&&""!==t.waves[e].point_eqs_eel?i.point_eqs=o.exports[`waves_${e}_point_eqs`]:i.point_eqs="",t.waves[e]=Object.assign({},t.waves[e],i)}this.renderer.loadPreset(t,e)}loadJSPreset(t,e){if("function"!=typeof t.init_eqs){t.init_eqs=new Function("a",`${t.init_eqs_str} return a;`),t.frame_eqs=new Function("a",`${t.frame_eqs_str} return a;`),t.pixel_eqs_str&&""!==t.pixel_eqs_str?t.pixel_eqs=new Function("a",`${t.pixel_eqs_str} return a;`):t.pixel_eqs="";for(let e=0;e<t.shapes.length;e++)0!==t.shapes[e].baseVals.enabled&&(t.shapes[e]=Object.assign({},t.shapes[e],{init_eqs:new Function("a",`${t.shapes[e].init_eqs_str} return a;`),frame_eqs:new Function("a",`${t.shapes[e].frame_eqs_str} return a;`)}));for(let e=0;e<t.waves.length;e++)if(0!==t.waves[e].baseVals.enabled){const i={init_eqs:new Function("a",`${t.waves[e].init_eqs_str} return a;`),frame_eqs:new Function("a",`${t.waves[e].frame_eqs_str} return a;`)};t.waves[e].point_eqs_str&&""!==t.waves[e].point_eqs_str?i.point_eqs=new Function("a",`${t.waves[e].point_eqs_str} return a;`):i.point_eqs="",t.waves[e]=Object.assign({},t.waves[e],i)}}this.renderer.loadPreset(t,e)}loadExtraImages(t){this.renderer.loadExtraImages(t)}setRendererSize(t,e,i={}){this.internalCanvas.width=t,this.internalCanvas.height=e,this.renderer.setRendererSize(t,e,i)}setInternalMeshSize(t,e){this.renderer.setInternalMeshSize(t,e)}setOutputAA(t){this.renderer.setOutputAA(t)}setCanvas(t){this.outputGl=t.getContext("2d",{willReadFrequently:!1})}render(t){const e=this.renderer.render(t);return this.outputGl&&this.outputGl.drawImage(this.internalCanvas,0,0),e}launchSongTitleAnim(t){this.renderer.launchSongTitleAnim(t)}toDataURL(){return this.renderer.toDataURL()}warpBufferToDataURL(){return this.renderer.warpBufferToDataURL()}}class $t{static createVisualizer(t,e,i){return new Zt(t,e,i)}}export{$t as default};
 //# sourceMappingURL=butterchurn.min.js.map
