securityos/node_modules/butterchurn/dist/butterchurn.min.js

2 lines
240 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("butterchurn",[],e):"object"==typeof exports?exports.butterchurn=e():t.butterchurn=e()}(window,(function(){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(s,r,function(e){return t[e]}.bind(null,r));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=24)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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},e.flatten=function(t){return[].concat.apply([],t)},e.times=function(t,e){return new Array(t).fill(null).map((t,i)=>e(i))},e.repeat=function(t,e){return new Array(t).fill(e).join("")};e.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}},e.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}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s={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}};e.default=s},function(t,e,i){"use strict";var s=this&&this.__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(e,"__esModule",{value:!0});const r=s(i(21)),o=i(0);function a(t){const e=new Uint8Array(8);return r.write(e,t),e}function h(t){const e=[];do{let i=127&t;0!==(t>>>=7)&&(i|=128),e.push(i)}while(0!==t);return e}function A(t){let e=[],i=0,s=Math.ceil(Math.log2(Math.abs(t))),r=t<0,o=!0;for(;o;)i=127&t,t>>=7,r&&(t|=-(1<<s-7)),0==t&&0==(64&i)||-1==t&&64==(64&i)?o=!1:i|=128,e.push(i);return e}e.MAGIC=[0,97,115,109],e.WASM_VERSION=[1,0,0,0],e.EPSILON=1e-5,e.SECTION={TYPE:1,IMPORT:2,FUNC:3,MEMORY:5,GLOBAL:6,EXPORT:7,CODE:10},e.EXPORT_TYPE={FUNC:0,TABLE:1,MEMORY:2,GLOBAL:3},e.op={block:t=>[2,t],loop:t=>[3,t],if:t=>[4,t],else:5,end:11,br_if:t=>[13,...h(t)],call:t=>[16,...h(t)],drop:26,select:27,local_get:t=>[32,...h(t)],local_set:t=>[33,...h(t)],local_tee:t=>[34,...h(t)],global_get:t=>[35,...h(t)],global_set:t=>[36,...h(t)],f64_load:(t,e)=>[43,...h(t),...h(e)],f64_store:(t,e)=>[57,...h(t),...h(e)],i32_const:t=>[65,...A(t)],f64_const:t=>[68,...a(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},e.VAL_TYPE={i32:127,i64:126,f32:125,f64:124},e.MUTABILITY={const:0,var:1},e.BLOCK={void:64,i32:127,i64:126,f32:125,f64:124},e.FUNCTION_TYPE=96,e.MEMORY_IDX=2,e.GLOBAL_TYPE=3,e.TYPE_IDX=0,e.IS_ZEROISH=[e.op.f64_abs,...e.op.f64_const(e.EPSILON),e.op.f64_lt],e.IS_NOT_ZEROISH=[e.op.f64_abs,...e.op.f64_const(e.EPSILON),e.op.f64_gt],e.encodef64=a,e.encodeString=t=>[t.length].concat(t.split("").map(t=>t.charCodeAt(0))),e.unsignedLEB128=h,e.signedLEB128=A,e.encodeFlatVector=t=>h(t.length).concat(t),e.encodeNestedVector=t=>h(t.length).concat(o.flatten(t)),e.encodeSection=function(t,i){if(0===i.length)return[];const s=e.encodeFlatVector(e.encodeNestedVector(i));return s.unshift(t),s}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.MAX_LOOP_COUNT=1048576,e.BUFFER_SIZE=8388608,e.WASM_MEMORY_SIZE=Math.ceil(8*e.BUFFER_SIZE*2/65536)},function(t,e,i){var s;void 0===(s=function(){return{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"}}.apply(e,[]))||(t.exports=s)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=i(14),r=i(15),o=i(19),a=i(6);function h(t,e){const i=s.getLoc(e,t.first_column),r=s.getLoc(e,t.last_column);return{first_column:i.column,last_column:r.column,first_line:i.line,last_line:r.line}}e.parse=function(t){const[e,i]=s.preProcess(t);try{const s=r.parse(e);return o.mapAst(s,e=>{if(1!==e.loc.first_line||1!=e.loc.last_line)throw a.createCompilerError("Unexpected multiline",e.loc,t);return Object.assign(Object.assign({},e),{loc:h(e.loc,i)})})}catch(e){if(null==e.hash)throw e;throw a.createUserError("Parse Error: "+e.message.split("\n")[3],h(e.hash.loc,i),t)}}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=i(0);function r(t,e,i=1){const r=Math.max(t.first_line-1-i,0),o=t.last_line+i,a=e.split("\n").slice(r,o).map((e,i)=>{const s=i+r+1;return`${s>=t.first_line&&s<=t.last_line?">":" "} ${s} | ${e}`});if(t.first_line===t.last_line){const e=s.repeat(t.first_column," "),i=s.repeat(t.last_column-t.first_column,"^"),o=t.first_line-r;a.splice(o,0,` | ${e}${i}`)}return a.join("\n")}e.printLoc=r;class o extends Error{constructor(t,e,i){super(t),this.sourceContext=r(e,i),this.loc=e}}class a extends o{}e.createUserError=function(t,e,i){return new a(t,e,i)},e.createCompilerError=function(t,e,i){return new o(t,e,i)}},function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},r=this&&this.__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(e,"__esModule",{value:!0});const o=i(5),a=i(20),h=i(2),A=s(i(1)),n=r(i(0)),l=i(8),c=i(3);e.compileModule=function({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 g=new n.ScopedIdMap;r.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=>h.VAL_TYPE.f64),returns:[h.VAL_TYPE.f64],name:t})),u=[],f=[];Object.entries(e).forEach(([e,{pool:r,code:A}])=>{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: `+n.formatList(i)+".")}const c=s?A:o.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 p=[],d={resolveVar:t=>/^reg\d\d$/.test(t)?g.get(null,t):g.get(r,t),resolveLocal:t=>(p.push(t),p.length-1),resolveFunc:t=>{const e=m.findIndex(e=>e.name===t);if(-1!==e){const s=h.op.call(e);return"rand"===t&&1===i?[...s,h.op.f64_floor]:s}if(null==l.localFuncMap[t])return null;let s=u.indexOf(t);return-1===s&&(u.push(t),s=u.length-1),h.op.call(s+m.length)},rawSource:A},_=a.emit(c,d);f.push({binary:_,exportName:e,args:[],returns:[],localVariables:p})});const p=u.map(t=>{const e=l.localFuncMap[t];if(null==e)throw new Error(`Undefined local function "${t}"`);return e}),d=t=>[...t.args,"|",...t.returns].join("-"),_=[],E=new Map;function b(t){const e=d(t),i=E.get(e);if(null==i)throw new Error("Failed to get a type index for key "+e);return i}[...m,...p,...f].forEach(t=>{const e=d(t);E.has(e)||(_.push([h.FUNCTION_TYPE,...h.encodeFlatVector(t.args),...h.encodeFlatVector(t.returns)]),E.set(e,_.length-1))});const x=[...r.map(([t,e])=>[...h.encodeString(t),...h.encodeString(e),h.GLOBAL_TYPE,h.VAL_TYPE.f64,h.MUTABILITY.var]),...m.map((t,e)=>{const i=b(t);return[...h.encodeString("shims"),...h.encodeString(t.name),h.TYPE_IDX,...h.unsignedLEB128(i)]})],v=[...p,...f].map(t=>{const e=b(t);return h.unsignedLEB128(e)}),T=[[1,...h.unsignedLEB128(c.WASM_MEMORY_SIZE),...h.unsignedLEB128(c.WASM_MEMORY_SIZE)]],S=g.size()-r.length,P=n.times(S,()=>[h.VAL_TYPE.f64,h.MUTABILITY.var,...h.op.f64_const(0),h.op.end]),w=[...f].map((t,e)=>{const i=e+m.length+p.length;return[...h.encodeString(t.exportName),h.EXPORT_TYPE.FUNC,...h.unsignedLEB128(i)]}),I=[...p,...f].map(t=>{var e;const i=(null!==(e=t.localVariables)&&void 0!==e?e:[]).map(t=>[...h.unsignedLEB128(1),t]);return h.encodeFlatVector([...h.encodeNestedVector(i),...t.binary,h.op.end])});return new Uint8Array([...h.MAGIC,...h.WASM_VERSION,...h.encodeSection(h.SECTION.TYPE,_),...h.encodeSection(h.SECTION.IMPORT,x),...h.encodeSection(h.SECTION.FUNC,v),...h.encodeSection(h.SECTION.MEMORY,T),...h.encodeSection(h.SECTION.GLOBAL,P),...h.encodeSection(h.SECTION.EXPORT,w),...h.encodeSection(h.SECTION.CODE,I)])}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=i(2),r=i(3);e.localFuncMap={sqr:{args:[s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],binary:[...s.op.local_get(0),...s.op.local_get(0),s.op.f64_mul]},bor:{args:[s.VAL_TYPE.f64,s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],binary:[...s.op.local_get(0),...s.IS_NOT_ZEROISH,...s.op.local_get(1),...s.IS_NOT_ZEROISH,s.op.i32_or,...s.op.i32_const(0),s.op.i32_ne,s.op.f64_convert_i32_s]},band:{args:[s.VAL_TYPE.f64,s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],binary:[...s.op.local_get(0),...s.IS_NOT_ZEROISH,...s.op.local_get(1),...s.IS_NOT_ZEROISH,s.op.i32_and,...s.op.i32_const(0),s.op.i32_ne,s.op.f64_convert_i32_s]},sign:{args:[s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],binary:[...s.op.f64_const(0),...s.op.local_get(0),s.op.f64_lt,...s.op.local_get(0),...s.op.f64_const(0),s.op.f64_lt,s.op.i32_sub,s.op.f64_convert_i32_s]},mod:{args:[s.VAL_TYPE.f64,s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],localVariables:[s.VAL_TYPE.i32],binary:[...s.op.local_get(1),s.op.i32_trunc_f64_s,...s.op.local_tee(2),...s.op.i32_const(0),s.op.i32_ne,...s.op.if(s.BLOCK.f64),...s.op.local_get(0),s.op.i32_trunc_f64_s,...s.op.local_get(2),s.op.i32_rem_s,s.op.f64_convert_i32_s,s.op.else,...s.op.f64_const(0),s.op.end]},bitwiseOr:{args:[s.VAL_TYPE.f64,s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],binary:[...s.op.local_get(0),s.op.i64_trunc_s_f64,...s.op.local_get(1),s.op.i64_trunc_s_f64,s.op.i64_or,s.op.f64_convert_i64_s]},bitwiseAnd:{args:[s.VAL_TYPE.f64,s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],binary:[...s.op.local_get(0),s.op.i64_trunc_s_f64,...s.op.local_get(1),s.op.i64_trunc_s_f64,s.op.i64_and,s.op.f64_convert_i64_s]},div:{args:[s.VAL_TYPE.f64,s.VAL_TYPE.f64],returns:[s.VAL_TYPE.f64],localVariables:[s.VAL_TYPE.i32],binary:[...s.op.local_get(1),...s.op.f64_const(0),s.op.f64_ne,...s.op.if(s.BLOCK.f64),...s.op.local_get(0),...s.op.local_get(1),s.op.f64_div,s.op.else,...s.op.f64_const(0),s.op.end]},_getBufferIndex:{args:[s.VAL_TYPE.f64],returns:[s.VAL_TYPE.i32],localVariables:[s.VAL_TYPE.f64,s.VAL_TYPE.i32],binary:[...s.op.f64_const(s.EPSILON),...s.op.local_get(0),s.op.f64_add,...s.op.local_tee(1),s.op.i32_trunc_f64_s,...s.op.local_set(2),...s.op.i32_const(-1),...s.op.local_get(2),...s.op.i32_const(8),s.op.i32_mul,...s.op.local_get(2),...s.op.i32_const(0),s.op.i32_lt_s,...s.op.local_get(2),...s.op.i32_const(r.BUFFER_SIZE-1),s.op.i32_gt_s,s.op.i32_or,s.op.select]}}},function(t,e){t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(5);e.parse=r.parse;const o=i(7);e.compileModule=o.compileModule;const a=s(i(1));e.shims=a.default;const h=i(22);e.loadModule=h.loadModule},function(t,e){t.exports=()=>"AGFzbQEAAAABPQpgAABgAXwBfGACfHwBfGACf38AYAR/f39/AGAJf39/f3x8fHx8AGADf399AGABfwF/YAJ/fwF/YAF+AX8CuBWMAQNlbnYFYWJvcnQABAhwaXhlbEVxcwtwZXJQaXhlbEVxcwAADHBpeGVsVmFyUG9vbAR3YXJwA3wBDHBpeGVsVmFyUG9vbAR6b29tA3wBDHBpeGVsVmFyUG9vbAd6b29tZXhwA3wBDHBpeGVsVmFyUG9vbAJjeAN8AQxwaXhlbFZhclBvb2wCY3kDfAEMcGl4ZWxWYXJQb29sAnN4A3wBDHBpeGVsVmFyUG9vbAJzeQN8AQxwaXhlbFZhclBvb2wCZHgDfAEMcGl4ZWxWYXJQb29sAmR5A3wBDHBpeGVsVmFyUG9vbANyb3QDfAEMcGl4ZWxWYXJQb29sA3JhZAN8AQxwaXhlbFZhclBvb2wDYW5nA3wBDHBpeGVsVmFyUG9vbAF4A3wBDHBpeGVsVmFyUG9vbAF5A3wBCHFWYXJQb29sAnExA3wBCHFWYXJQb29sAnEyA3wBCHFWYXJQb29sAnEzA3wBCHFWYXJQb29sAnE0A3wBCHFWYXJQb29sAnE1A3wBCHFWYXJQb29sAnE2A3wBCHFWYXJQb29sAnE3A3wBCHFWYXJQb29sAnE4A3wBCHFWYXJQb29sAnE5A3wBCHFWYXJQb29sA3ExMAN8AQhxVmFyUG9vbANxMTEDfAEIcVZhclBvb2wDcTEyA3wBCHFWYXJQb29sA3ExMwN8AQhxVmFyUG9vbANxMTQDfAEIcVZhclBvb2wDcTE1A3wBCHFWYXJQb29sA3ExNgN8AQhxVmFyUG9vbANxMTcDfAEIcVZhclBvb2wDcTE4A3wBCHFWYXJQb29sA3ExOQN8AQhxVmFyUG9vbANxMjADfAEIcVZhclBvb2wDcTIxA3wBCHFWYXJQb29sA3EyMgN8AQhxVmFyUG9vbANxMjMDfAEIcVZhclBvb2wDc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UyX3NhdmUAFQ5zaGFwZTJfcmVzdG9yZQAWC3NoYXBlM19zYXZlABcOc2hhcGUzX3Jlc3RvcmUAGAgBGQraQRi0AQEGfyAAQez///8DSwRAAAsgAEEQaiICQfz///8DSwRAAAsjkAIhBiOQAkEEaiIEIAJBE2pBcHFBBGsiB2oiAj8AIgVBEHRBD2pBcHEiA0sEQCAFIAIgA2tB//8DakGAgHxxQRB2IgMgAyAFSBtAAEEASARAIANAAEEASARAAAsLCyACJJACIAYgBzYCACAEQQRrIgJBADYCBCACQQA2AgggAiABNgIMIAIgADYCECAEQRBqC7sCAQF/AkAgAUUNACAAQQA6AAAgACABakEEayICQQA6AAMgAUECTQ0AIABBADoAASAAQQA6AAIgAkEAOgACIAJBADoAASABQQZNDQAgAEEAOgADIAJBADoAACABQQhNDQAgAEEAIABrQQNxIgJqIgBBADYCACAAIAEgAmtBfHEiAmpBHGsiAUEANgIYIAJBCE0NACAAQQA2AgQgAEEANgIIIAFBADYCECABQQA2AhQgAkEYTQ0AIABBADYCDCAAQQA2AhAgAEEANgIUIABBADYCGCABQQA2AgAgAUEANgIEIAFBADYCCCABQQA2AgwgACAAQQRxQRhqIgFqIQAgAiABayEBA0AgAUEgTwRAIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGCABQSBrIQEgAEEgaiEADAELCwsLdwECfwJ/QQxBAxACIgFFBEBBDEECEAIhAQsgAQtBADYCACABQQA2AgQgAUEANgIIIABB/////wBLBEBBoAhB0AhBEkE5EAAACyAAQQJ0IgBBABACIgIgABADIAEoAgAaIAEgAjYCACABIAI2AgQgASAANgIIIAELuwQDAX8KfgF8IABC////////////AINCNIhClQh9IgVCBoenQQN0QYAJaiIBKQMAIQcgASkDCCEEIAEpAxAhAiAFQj+DIgVCAFIEQAJ+IAcgBYYgBELAACAFfSIDiIQhByAEIAWGIAIgA4iEIQQgAiAFhiABKQMYIAOIhAshAgsgAEL/////////B4NCgICAgICAgAiEIgVC/////w+DIgMgBEIgiCIIfiAEQv////8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ASN5JP8BI3okgAIjeySBAiN8JIICI30kgwIjfiSEAiN/JIUCI4ABJIYCI4EBJIcCI4IBJIgCI4MBJIkCI4QBJIoCI4UBJIsCI4YBJIwCI4cBJI0CI4gBJI4CI4kBJI8CC3UAI/sBJHUj/AEkdiP9ASR3I/4BJHgj/wEkeSOAAiR6I4ECJHsjggIkfCODAiR9I4QCJH4jhQIkfyOGAiSAASOHAiSBASOIAiSCASOJAiSDASOKAiSEASOLAiSFASOMAiSGASONAiSHASOOAiSIASOPAiSJAQsIAEHMCiSQAgsLvAIDAEGMCAsvLAAAAAEAAAAAAAAAAQAAABwAAABJAG4AdgBhAGwAaQBkACAAbABlAG4AZwB0AGgAQbwICzk8AAAAAQAAAAAAAAABAAAAJgAAAH4AbABpAGIALwBhAHIAcgBhAHkAYgB1AGYAZgBlAHIALgB0AHMAQYAJC8ABboP5ogAAAADRVyf8KRVETpmVYtvA3TT1q2NR/kGQQzw6biS3YcW73uouSQbg0k1CHOsd/hyS0Qn1NYLoPqcpsSZwnOmERLsuOdaROUF+X7SLX4Sc9DlTg/+X+B87KPm9ixEv7w+YBd7PfjZtH20KWmY/Rk+3Ccsnx7ondS3qX573OQc9e/Hl67Ff+2vqklKKRjADVghdjR8gvM/wq2t7/GGR46kdNvSaX4WZZQgb5l6A2P+NQGigFFcVBgYxJ3NN"},function(t,e,i){"use strict";{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,o){return e[0]=Math.scale(t,i,s,r,o),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}))}},function(t,e){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(t){return Math.abs(t)<1e-5?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(t,e){var i=1+Math.exp(-t*e);return Math.abs(i)>1e-5?1/i:0},window.bor=function(t,e){return Math.abs(t)>1e-5||Math.abs(e)>1e-5?1:0},window.band=function(t,e){return Math.abs(t)>1e-5&&Math.abs(e)>1e-5?1:0},window.equal=function(t,e){return Math.abs(t-e)<1e-5?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(t,e,i){return Math.abs(t)>1e-5?e:i},window.memcpy=function(t,e,i,s){let r=e,o=i,a=s;return o<0&&(a+=o,r-=o,o=0),r<0&&(a+=r,o-=r,r=0),a>0&&t.copyWithin(r,o,a),e}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.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}},e.preProcess=function(t){const e=[];let i=1,s="",r=0,o=!1,a=!1,h=!1;for(let A=0;A<t.length;A++){const n=t[A];if(h){const t=s.length+1,o=A-r+1;e.push({destCol:t,srcCol:o,srcLine:i}),h=!1}"\n"===n?(o=!1,i++,r=A+1,h=!0):"\r"===n&&"\n"===t[A+1]?(A++,o=!1,i++,r=A+1,h=!0):a&&"*"===n&&"/"===t[A+1]?(a=!1,A++,h=!0):"\\"===n&&"\\"===t[A+1]||"/"===n&&"/"===t[A+1]?(o=!0,A++):"/"===n&&"*"===t[A+1]?(a=!0,A++):o||a||(s+=n)}return[s,e]}},function(t,e,i){let s=i(16);t.exports={parse:s.parse}},function(t,e,i){(function(t,s){var r=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],o=[1,14],a=[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],p=[1,28],d=[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,o,a){var h=o.length-1;switch(r){case 1:return{type:"SCRIPT",body:[o[h-1]],loc:this._$};case 2:return{type:"SCRIPT",body:o[h-1],loc:this._$};case 3:return{type:"SCRIPT",body:[],loc:this._$};case 6:this.$=[o[h-1]];break;case 7:this.$=o[h-2].concat([o[h-1]]);break;case 8:this.$=o[h];break;case 9:this.$=o[h-1].concat([o[h]]);break;case 10:this.$={type:"EXPRESSION_BLOCK",body:o[h],loc:this._$};break;case 11:this.$={type:"IDENTIFIER",value:o[h].toLowerCase(),loc:this._$};break;case 14:this.$=[o[h]];break;case 15:this.$=o[h-2].concat([o[h]]);break;case 16:this.$={type:"CALL_EXPRESSION",callee:o[h-2],arguments:[],loc:this._$};break;case 17:this.$={type:"CALL_EXPRESSION",callee:o[h-3],arguments:o[h-1],loc:this._$};break;case 18:this.$={type:"LOGICAL_EXPRESSION",left:o[h-2],right:o[h],operator:o[h-1],loc:this._$};break;case 19:case 20:this.$={type:"ASSIGNMENT_EXPRESSION",left:o[h-2],operator:o[h-1],right:o[h],loc:this._$};break;case 21:this.$=Number(o[h]);break;case 22:this.$=Number(o[h-1]);break;case 23:this.$=Number(o[h-2]+o[h-1]+o[h]);break;case 24:this.$=Number("0"+o[h-1]+o[h]);break;case 25:this.$=0;break;case 26:this.$={type:"NUMBER_LITERAL",value:o[h],loc:this._$};break;case 27:case 28:case 29:this.$={type:"UNARY_EXPRESSION",value:o[h],operator:o[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:o[h-2],right:o[h],operator:o[h-1],loc:this._$};break;case 41:case 47:this.$=o[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:o,29:a,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:p,37:d,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:o,29:a,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:p,37:d,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:o,29:a,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:o,29:a,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:o,29:a,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:p,37:d,38:_}),t(P,[2,27],{20:n,32:g,33:m,34:u,35:f,36:p,37:d}),t(P,[2,28],{20:n,32:g,33:m,34:u,35:f,36:p,37:d}),t(P,[2,29],{20:n,32:g,33:m,34:u,35:f,36:p,37:d}),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:p,37:d}),t(P,[2,31],{20:n,32:g,33:m,34:u,35:f,36:p,37:d}),t(w,[2,32],{20:n,34:u,35:f,36:p,37:d}),t(w,[2,33],{20:n,34:u,35:f,36:p,37:d}),t(I,[2,34],{20:n,35:f,36:p}),t(R,[2,35],{20:n}),t(R,[2,36],{20:n}),t(I,[2,37],{20:n,35:f,36:p}),t(y,[2,38],{20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:p,37:d,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:p,37:d,38:_}),t(y,[2,19],{20:n,28:l,29:c,32:g,33:m,34:u,35:f,36:p,37:d,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:p,37:d,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:o,29:a,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=[],o=this.table,a="",h=0,A=0,n=0,l=2,c=1,g=r.slice.call(arguments,1),m=Object.create(this.lexer),u={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(u.yy[f]=this.yy[f]);m.setInput(t,u.yy),u.yy.lexer=m,u.yy.parser=this,void 0===m.yylloc&&(m.yylloc={});var p=m.yylloc;r.push(p);var d=m.options&&m.options.ranges;"function"==typeof u.yy.parseError?this.parseError=u.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,E,b,x,v,T,S,P,w,I=function(){var t;return"number"!=typeof(t=m.lex()||c)&&(t=e.symbols_[t]||t),t},R={};;){if(b=i[i.length-1],this.defaultActions[b]?x=this.defaultActions[b]:(null==_&&(_=I()),x=o[b]&&o[b][_]),void 0===x||!x.length||!x[0]){var y="";for(T in w=[],o[b])this.terminals_[T]&&T>l&&w.push("'"+this.terminals_[T]+"'");y=m.showPosition?"Parse error on line "+(h+1)+":\n"+m.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(h+1)+": Unexpected "+(_==c?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(y,{text:m.match,token:this.terminals_[_]||_,line:m.yylineno,loc:p,expected:w})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+_);switch(x[0]){case 1:i.push(_),s.push(m.yytext),r.push(m.yylloc),i.push(x[1]),_=null,E?(_=E,E=null):(A=m.yyleng,a=m.yytext,h=m.yylineno,p=m.yylloc,n>0&&n--);break;case 2:if(S=this.productions_[x[1]][1],R.$=s[s.length-S],R._$={first_line:r[r.length-(S||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(S||1)].first_column,last_column:r[r.length-1].last_column},d&&(R._$.range=[r[r.length-(S||1)].range[0],r[r.length-1].range[1]]),void 0!==(v=this.performAction.apply(R,[a,A,h,u.yy,x[1],s,r].concat(g))))return v;S&&(i=i.slice(0,-1*S*2),s=s.slice(0,-1*S),r=r.slice(0,-1*S)),i.push(this.productions_[x[1]][0]),s.push(R.$),r.push(R._$),P=o[i[i.length-2]][i[i.length-1]],i.push(P);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 o in r)this[o]=r[o];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(),o=0;o<r.length;o++)if((i=this._input.match(this.rules[r[o]]))&&(!e||i[0].length>e[0].length)){if(e=i,s=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,r[o])))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}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=()=>{},i.c[i.s]===t&&e.main(s.argv.slice(1))}).call(this,i(17)(t),i(18))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){var i,s,r=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function h(t){if(i===setTimeout)return setTimeout(t,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:o}catch(t){i=o}try{s="function"==typeof clearTimeout?clearTimeout:a}catch(t){s=a}}();var A,n=[],l=!1,c=-1;function g(){l&&A&&(l=!1,A.length?n=A.concat(n):c=-1,n.length&&m())}function m(){if(!l){var t=h(g);l=!0;for(var e=n.length;e;){for(A=n,n=[];++c<e;)A&&A[c].run();c=-1,e=n.length}A=null,l=!1,function(t){if(s===clearTimeout)return clearTimeout(t);if((s===a||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(t);try{s(t)}catch(e){try{return s.call(null,t)}catch(e){return s.call(this,t)}}}(t)}}function u(t,e){this.fun=t,this.array=e}function f(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];n.push(new u(t,e)),1!==n.length||l||h(m)},u.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=f,r.addListener=f,r.once=f,r.off=f,r.removeListener=f,r.removeAllListeners=f,r.emit=f,r.prependListener=f,r.prependOnceListener=f,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});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"}]};e.mapAst=function t(e,i){const r=s[e.type];let o=e;if(null==r)throw new Error("Unknown children definition for "+e.type);return r.forEach(s=>{if("NODE"===s.type){const r=e[s.key],a=t(r,i);a!==r&&(o=Object.assign(Object.assign({},o),{[s.key]:a}))}else if("ARRAY"===s.type){const r=e[s.key],a=r.map(e=>t(e,i));r.some((t,e)=>t!==a[e])&&(o=Object.assign(Object.assign({},o),{[s.key]:a}))}}),i(o)}},function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(2),o=s(i(1)),a=i(6),h=i(8),A=i(0),n=i(3);function l(t,e){var i,s,m;switch(t.type){case"SCRIPT":{const i=t.body.map((t,i)=>[...l(t,e),r.op.drop]);return A.flatten(i)}case"EXPRESSION_BLOCK":return c(t.body,e);case"BINARY_EXPRESSION":{const i=l(t.left,e),s=l(t.right,e),o={"+":[r.op.f64_add],"-":[r.op.f64_sub],"*":[r.op.f64_mul],"/":e.resolveFunc("div"),"%":e.resolveFunc("mod"),"|":e.resolveFunc("bitwiseOr"),"&":e.resolveFunc("bitwiseAnd"),"^":e.resolveFunc("pow"),"==":[r.op.f64_sub,...r.IS_ZEROISH,r.op.f64_convert_i32_s],"!=":[r.op.f64_sub,...r.IS_NOT_ZEROISH,r.op.f64_convert_i32_s],"<":[r.op.f64_lt,r.op.f64_convert_i32_s],">":[r.op.f64_gt,r.op.f64_convert_i32_s],"<=":[r.op.f64_le,r.op.f64_convert_i32_s],">=":[r.op.f64_ge,r.op.f64_convert_i32_s]}[t.operator];if(null==o)throw a.createCompilerError("Unknown binary expression operator "+t.operator,t.loc,e.rawSource);return[...i,...s,...o]}case"CALL_EXPRESSION":{const s=t.callee.value,m=t.arguments,u=i=>{if(m.length<i)throw a.createUserError(`Too few arguments passed to \`${s}()\`. Expected ${i} but only got ${m.length}.`,t.loc,e.rawSource);if(m.length>i)throw a.createUserError(`Too many arguments passed to \`${s}()\`. Expected ${i} but got ${m.length}.`,m[i].loc,e.rawSource)};switch(s){case"exec2":return u(2),c(t.arguments,e);case"exec3":return u(3),c(t.arguments,e);case"if":u(3);const[o,h,A]=t.arguments;return function(t,e,i,s){return[...l(t,s),...r.IS_NOT_ZEROISH,...r.op.if(r.BLOCK.f64),...l(e,s),r.op.else,...l(i,s),r.op.end]}(o,h,A,e);case"while":return u(1),function(t,e){const i=l(t,e),s=e.resolveLocal(r.VAL_TYPE.i32);return[...r.op.i32_const(0),...r.op.local_set(s),...r.op.loop(r.BLOCK.void),...r.op.local_get(s),...r.op.i32_const(1),r.op.i32_add,...r.op.local_tee(s),...r.op.i32_const(n.MAX_LOOP_COUNT),r.op.i32_lt_u,...i,...r.IS_NOT_ZEROISH,r.op.i32_and,...r.op.br_if(0),r.op.end,...r.op.f64_const(0)]}(t.arguments[0],e);case"loop":return u(2),function(t,e,i){const s=l(e,i),o=i.resolveLocal(r.VAL_TYPE.i32);return[...r.op.block(r.BLOCK.void),...l(t,i),r.op.i32_trunc_f64_s,...r.op.local_tee(o),...r.op.i32_const(0),r.op.i32_le_s,...r.op.br_if(1),...r.op.loop(r.BLOCK.void),...s,r.op.drop,...r.op.local_get(o),...r.op.i32_const(1),r.op.i32_sub,...r.op.local_tee(o),...r.op.i32_const(0),r.op.i32_ne,...r.op.br_if(0),r.op.end,r.op.end,...r.op.f64_const(0)]}(t.arguments[0],t.arguments[1],e);case"megabuf":case"gmegabuf":u(1);const m=e.resolveLocal(r.VAL_TYPE.i32);return[...l(t.arguments[0],e),...null!==(i=e.resolveFunc("_getBufferIndex"))&&void 0!==i?i:[],...r.op.local_tee(m),...r.op.i32_const(-1),r.op.i32_ne,...r.op.if(r.BLOCK.f64),...r.op.local_get(m),...r.op.f64_load(3,g(s)),r.op.else,...r.op.f64_const(0),r.op.end];case"assign":u(2);const f=t.arguments[0];if("IDENTIFIER"!=f.type)throw a.createUserError("Expected the first argument of `assign()` to be an identifier.",f.loc,e.rawSource);const p=e.resolveVar(f.value);return[...l(t.arguments[1],e),...r.op.global_set(p),...r.op.global_get(p)]}const f=A.flatten(t.arguments.map(t=>l(t,e)));switch(s){case"abs":return u(1),[...f,r.op.f64_abs];case"sqrt":return u(1),[...f,r.op.f64_abs,r.op.f64_sqrt];case"int":return u(1),[...f,r.op.f64_floor];case"min":return u(2),[...f,r.op.f64_min];case"max":return u(2),[...f,r.op.f64_max];case"above":return u(2),[...f,r.op.f64_gt,r.op.f64_convert_i32_s];case"below":return u(2),[...f,r.op.f64_lt,r.op.f64_convert_i32_s];case"equal":return u(2),[...f,r.op.f64_sub,...r.IS_ZEROISH,r.op.f64_convert_i32_s];case"bnot":return u(1),[...f,...r.IS_ZEROISH,r.op.f64_convert_i32_s];case"floor":return u(1),[...f,r.op.f64_floor];case"ceil":return u(1),[...f,r.op.f64_ceil]}const p=e.resolveFunc(s);if(null==p||s.startsWith("_"))throw a.createUserError(`"${s}" is not defined.`,t.callee.loc,e.rawSource);if(null!=o.default[s])u(o.default[s].length);else{if(null==h.localFuncMap[s])throw a.createCompilerError(`Missing arity information for the function \`${s}()\``,t.callee.loc,e.rawSource);u(h.localFuncMap[s].args.length)}return[...f,...p]}case"ASSIGNMENT_EXPRESSION":{const{left:i}=t,o=l(t.right,e),h=function(t,e){const i={"+=":[r.op.f64_add],"-=":[r.op.f64_sub],"*=":[r.op.f64_mul],"/=":[r.op.f64_div],"%=":e.resolveFunc("mod"),"=":null}[t.operator];if(void 0===i)throw a.createCompilerError(`Unknown assignment operator "${t.operator}"`,t.loc,e.rawSource);return i}(t,e);if("IDENTIFIER"===i.type){const t=e.resolveVar(i.value),s=r.op.global_get(t),a=r.op.global_set(t);return null===h?[...o,...a,...s]:[...s,...o,...h,...a,...s]}if("CALL_EXPRESSION"!==i.type)throw a.createCompilerError("Unexpected left hand side type for assignment: "+i.type,t.loc,e.rawSource);const A=e.resolveLocal(r.VAL_TYPE.i32);if(1!==i.arguments.length)throw a.createUserError(`Expected 1 argument when assinging to a buffer but got ${i.arguments.length}.`,0===i.arguments.length?i.loc:i.arguments[1].loc,e.rawSource);const n=i.callee.value;if("gmegabuf"!==n&&"megabuf"!==n)throw a.createUserError("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.",i.callee.loc,e.rawSource);const c=g(n);if(null===h){const t=e.resolveLocal(r.VAL_TYPE.i32),a=e.resolveLocal(r.VAL_TYPE.f64);return[...o,...r.op.local_set(a),...l(i.arguments[0],e),...null!==(s=e.resolveFunc("_getBufferIndex"))&&void 0!==s?s:[],...r.op.local_tee(t),...r.op.i32_const(0),r.op.i32_lt_s,...r.op.if(r.BLOCK.f64),...r.op.f64_const(0),r.op.else,...r.op.local_get(t),...r.op.local_tee(A),...r.op.local_get(a),...r.op.f64_store(3,c),...r.op.local_get(a),r.op.end]}const u=e.resolveLocal(r.VAL_TYPE.i32),f=e.resolveLocal(r.VAL_TYPE.i32),p=e.resolveLocal(r.VAL_TYPE.f64),d=e.resolveLocal(r.VAL_TYPE.f64);return[...o,...r.op.local_set(p),...l(i.arguments[0],e),...null!==(m=e.resolveFunc("_getBufferIndex"))&&void 0!==m?m:[],...r.op.local_tee(u),...r.op.i32_const(-1),r.op.i32_ne,...r.op.local_tee(f),...r.op.if(r.BLOCK.f64),...r.op.local_get(u),...r.op.f64_load(3,c),r.op.else,...r.op.f64_const(0),r.op.end,...r.op.local_get(p),...h,...r.op.local_tee(d),...r.op.local_get(f),...r.op.if(r.BLOCK.void),...r.op.local_get(u),...r.op.local_get(d),...r.op.f64_store(3,c),r.op.end]}case"LOGICAL_EXPRESSION":{const i=l(t.left,e),s=l(t.right,e),o={"&&":{comparison:r.IS_ZEROISH,shortCircutValue:0},"||":{comparison:r.IS_NOT_ZEROISH,shortCircutValue:1}}[t.operator];if(null==o)throw a.createCompilerError("Unknown logical expression operator "+t.operator,t.loc,e.rawSource);const{comparison:h,shortCircutValue:A}=o;return[...i,...h,...r.op.if(r.BLOCK.f64),...r.op.f64_const(A),r.op.else,...s,...r.IS_NOT_ZEROISH,r.op.f64_convert_i32_s,r.op.end]}case"UNARY_EXPRESSION":{const i=l(t.value,e),s={"-":[r.op.f64_neg],"+":[],"!":[...r.IS_ZEROISH,r.op.f64_convert_i32_s]}[t.operator];if(null==s)throw a.createCompilerError("Unknown logical unary operator "+t.operator,t.loc,e.rawSource);return[...i,...s]}case"IDENTIFIER":const u=t.value;return r.op.global_get(e.resolveVar(u));case"NUMBER_LITERAL":return r.op.f64_const(t.value);default:throw a.createCompilerError("Unknown AST node type "+t.type,t.loc,e.rawSource)}}function c(t,e){const i=t.map((t,i)=>l(t,e));return A.flatten(A.arrayJoin(i,[r.op.drop]))}function g(t){switch(t){case"gmegabuf":return 8*n.BUFFER_SIZE;case"megabuf":return 0}}e.emit=l},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.write=function(t,e){let i=52;var s,r,o,a=64-i-1,h=(1<<a)-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*(o=Math.pow(2,-s))<1&&(s--,o*=2),(e+=s+A>=1?n/o:n*Math.pow(2,1-A))*o>=2&&(s++,o/=2),s+A>=h?(r=0,s=h):s+A>=1?(r=(e*o-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,a+=i;a>0;t[0+l]=255&s,l+=1,s/=256,a-=8);t[0+l-1]|=128*c}},function(t,e,i){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=s(i(1)),o=i(7);e.loadModule=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 a=o.compileModule({pools:s,functions:e,eelVersion:i}),h=await WebAssembly.compile(a);var A=Object.assign(Object.assign({},t),{shims:r.default});return await WebAssembly.instantiate(h,A)}},,function(t,e,i){"use strict";i.r(e),i.d(e,"default",(function(){return $}));i(12),i(13);var s=i(9),r=i.n(s),o=i(10);const a="undefined"!=typeof BigUint64Array,h=Symbol(),A=new TextDecoder("utf-16le");function n(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):A.decode(s)}function l(t){const e={};function i(t,e){return t?n(t.buffer,e):"<yet unknown>"}const s=t.env=t.env||{};return s.abort=s.abort||function(t,r,o,a){const h=e.memory||s.memory;throw Error(`abort: ${i(h,t)} at ${i(h,r)}:${o}:${a}`)},s.trace=s.trace||function(t,r,...o){const a=e.memory||s.memory;console.log(`trace: ${i(a,t)}${r?" ":""}${o.slice(0,r).join(", ")}`)},s.seed=s.seed||Date.now,t.Math=t.Math||Math,t.Date=t.Date||Date,e}function c(t,e){const i=e.exports,s=i.memory,r=i.table,o=i.__new,h=i.__retain,A=i.__rtti_base||-1;function l(t){const e=function(t){const e=new Uint32Array(s.buffer);if((t>>>=0)>=e[A>>>2])throw Error("invalid id: "+t);return e[(A+4>>>2)+2*t]}(t);if(!(7&e))throw Error(`not an array: ${t}, flags=${e}`);return e}function c(t){const e=new Uint32Array(s.buffer);if((t>>>=0)>=e[A>>>2])throw Error("invalid id: "+t);return e[(A+4>>>2)+2*t+1]}function g(t){return 31-Math.clz32(t>>>6&31)}function m(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 u(t){const e=new Uint32Array(s.buffer),i=l(e[t+-8>>>2]),r=g(i);let o=4&i?t:e[t+4>>>2];const a=2&i?e[t+12>>>2]:e[o+-4>>>2]>>>r;return m(r,2048&i,4096&i).subarray(o>>>=r,o+a)}function f(t,e,i){return new t(d(t,e,i))}function d(t,e,i){const r=s.buffer,o=new Uint32Array(r),a=o[i+4>>>2];return new t(r,a,o[a+-4>>>2]>>>e)}function _(e,i,s){t["__get"+i]=f.bind(null,e,s),t[`__get${i}View`]=d.bind(null,e,s)}return t.__newString=function(t){if(null==t)return 0;const e=t.length,i=o(e<<1,1),r=new Uint16Array(s.buffer);for(var a=0,h=i>>>1;a<e;++a)r[h+a]=t.charCodeAt(a);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 n(e,t)},t.__newArray=function(t,e){const i=l(t),r=g(i),a=e.length,A=o(a<<r,4&i?t:0);let n;if(4&i)n=A;else{const e=o(2&i?16:12,t),l=new Uint32Array(s.buffer);l[e+0>>>2]=h(A),l[e+4>>>2]=A,l[e+8>>>2]=a<<r,2&i&&(l[e+12>>>2]=a),n=e}const c=m(r,2048&i,4096&i);if(16384&i)for(let t=0;t<a;++t)c[(A>>>r)+t]=h(e[t]);else c.set(e,A>>>r);return n},t.__getArrayView=u,t.__getArray=function(t){const e=u(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=>{_(t,t.name,31-Math.clz32(t.BYTES_PER_ELEMENT))}),a&&[BigUint64Array,BigInt64Array].forEach(t=>{_(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[A>>>2])do{if(r==e)return!0;r=c(r)}while(r);return!1},t.memory=t.memory||s,t.table=t.table||r,p(i,t)}function g(t){return"undefined"!=typeof Response&&t instanceof Response}function m(t){return t instanceof WebAssembly.Module}async function u(t,e={}){if(g(t=await t))return f(t,e);const i=m(t)?t:await WebAssembly.compile(t),s=l(e),r=await WebAssembly.instantiate(i,e);return{module:i,instance:r,exports:c(s,r)}}async function f(t,e={}){if(!WebAssembly.instantiateStreaming)return u(g(t=await t)?t.arrayBuffer():t,e);const i=l(e),s=await WebAssembly.instantiateStreaming(t,e),r=c(i,s.instance);return{...s,exports:r}}function p(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 o=s.split("."),a=e;for(;o.length>1;){let t=o.shift();Object.prototype.hasOwnProperty.call(a,t)||(a[t]={}),a=a[t]}let A=o[0],n=A.indexOf("#");if(n>=0){const e=A.substring(0,n),o=a[e];if(void 0===o||!o.prototype){const t=function(...e){return t.wrap(t.prototype.constructor(0,...e))};t.prototype={valueOf(){return this[h]}},t.wrap=function(e){return Object.create(t.prototype,{[h]:{value:e,writable:!1}})},o&&Object.getOwnPropertyNames(o).forEach(e=>Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))),a[e]=t}if(A=A.substring(n+1),a=a[e].prototype,/^(get|set):/.test(A)){if(!Object.prototype.hasOwnProperty.call(a,A=A.substring(4))){let e=t[s.replace("set:","get:")],i=t[s.replace("get:","set:")];Object.defineProperty(a,A,{get(){return e(this[h])},set(t){i(this[h],t)},enumerable:!0})}}else"constructor"===A?(a[A]=(...t)=>(i(t.length),r(...t))).original=r:(a[A]=function(...t){return i(t.length),r(this[h],...t)}).original=r}else/^(get|set):/.test(A)?Object.prototype.hasOwnProperty.call(a,A=A.substring(4))||Object.defineProperty(a,A,{get:t[s.replace("set:","get:")],set:t[s.replace("get:","set:")],enumerable:!0}):"function"==typeof r&&r!==i?(a[A]=(...t)=>(i(t.length),r(...t))).original=r:a[A]=r}return e}var d={instantiate:u,instantiateSync:function(t,e={}){const i=m(t)?t:new WebAssembly.Module(t),s=l(e),r=new WebAssembly.Instance(i,e);return{module:i,instance:r,exports:c(s,r)}},instantiateStreaming:f,demangle:p};class _{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],o=this.cossintable[1][r];let a=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=a*e[s]-h*i[s],o=a*i[s]+h*e[s];e[s]=e[t]-r,i[s]=i[t]-o,e[t]+=r,i[t]+=o}const n=a;a=n*t-h*o,h=h*t+n*o}s<<=1,r+=1}const o=new Float32Array(this.samplesOut);if(this.equalize)for(let t=0;t<this.samplesOut;t++)o[t]=this.equalizeArr[t]*Math.sqrt(e[t]*e[t]+i[t]*i[t]);else for(let t=0;t<this.samplesOut;t++)o[t]=Math.sqrt(e[t]*e[t]+i[t]*i[t]);return o}}class E{constructor(t){this.numSamps=512,this.fftSize=2*this.numSamps,this.fft=new _(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 b{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),o=Math.clamp(Math.round(2800/i)-1,0,this.audio.numSamps-1),a=Math.clamp(Math.round(11025/i)-1,0,this.audio.numSamps-1);this.starts=[s,r,o],this.stops=[r,o,a],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;!b.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=b.adjustRateToFPS(s,30,i),this.avg[t]=this.avg[t]*s+this.imm[t]*(1-s),s=e<50?.9:.992,s=b.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])}}}}var x=i(4),v=i.n(x);class T{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 S{constructor(t,e,i){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=T.range(1,33).map(t=>"q"+t),this.ts=T.range(1,9).map(t=>"t"+t),this.regs=T.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([Math.random(),Math.random(),Math.random(),Math.random()]),this.mdVS.rand_preset=new Float32Array([Math.random(),Math.random(),Math.random(),Math.random()]);const i=this.qs.concat(this.regs,Object.keys(this.mdVS)),s=this.preset.init_eqs(T.cloneVars(this.mdVS));this.mdVSQInit=T.pick(s,this.qs),this.mdVSRegs=T.pick(s,this.regs);const r=T.pick(s,Object.keys(T.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(T.omit(this.mdVSFrame,i)),this.mdVSFrameMap=T.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=T.pick(this.mdVSFrame,this.qs),this.mdVSRegs=T.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 o=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=T.pick(r,this.regs),Object.assign(r,s)),this.mdVSWaves.push(r),this.mdVSTWaveInits.push(T.pick(r,this.ts)),this.mdVSUserKeysWaves.push(Object.keys(T.omit(r,o))),this.mdVSFrameMapWaves.push(T.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 o=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=T.pick(r,this.regs),Object.assign(r,s)),this.mdVSShapes.push(r),this.mdVSTShapeInits.push(T.pick(r,this.ts)),this.mdVSUserKeysShapes.push(Object.keys(T.omit(r,o))),this.mdVSFrameMapShapes.push(T.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=T.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=T.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 P{constructor(t,e,i){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=T.range(1,33).map(t=>"q"+t),this.ts=T.range(1,9).map(t=>"t"+t),this.regs=T.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 T.pickWasm(this.preset.globalPools[t],this.qs)}getTVars(t){return T.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),T.setWasm(this.preset.globalPools.perFrame,this.mdVS,Object.keys(this.mdVS)),this.rand_start=new Float32Array([Math.random(),Math.random(),Math.random(),Math.random()]),this.rand_preset=new Float32Array([Math.random(),Math.random(),Math.random(),Math.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?(T.setWasm(this.preset.globalPools["wavePerFrame"+t],i,Object.keys(i)),e.init_eqs&&(e.init_eqs(),T.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?(T.setWasm(this.preset.globalPools["shapePerFrame"+t],i,Object.keys(i)),e.init_eqs&&(e.init_eqs(),T.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){T.setWasm(this.preset.globalPools.perFrame,this.mdVS,this.frameKeys),T.setWasm(this.preset.globalPools.perFrame,this.mdVSQInit,this.qs),T.setWasm(this.preset.globalPools.perFrame,t,this.globalKeys),this.preset.frame_eqs(),this.preset.save_qs(),this.mdVSQAfterFrame=this.getQVars("perFrame");const e=T.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 T.setWasm(this.preset.globalPools["wavePerFrame"+t],i,this.waveFrameInputKeys),T.setWasm(this.preset.globalPools["wavePerFrame"+t],this.mdVSQAfterFrame,this.qs),T.setWasm(this.preset.globalPools["wavePerFrame"+t],this.mdVSTWaveInits[t],this.ts),T.setWasm(this.preset.globalPools["wavePerFrame"+t],e,this.globalKeys),this.preset.waves[t].frame_eqs(),T.pickWasm(this.preset.globalPools["wavePerFrame"+t],this.waveFrameKeys)}}const w=/uniform sampler2D sampler_(?:.+?);/g,I=/uniform sampler2D sampler_(.+?);/;class R{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("{"),o=s.lastIndexOf("}");return[i,s.substring(r+1,o)]}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(w);if(i&&i.length>0)for(let t=0;t<i.length;t++){const s=i[t].match(I);if(s&&s.length>0){const t=s[1];e.push({sampler:t})}}return e}}class y{static smoothWave(t,e,i,s=!1){let r,o=0,a=0,h=1;for(let A=0;A<i-1;A++){r=h,h=Math.min(i-1,A+2);for(let i=0;i<3;i++)e[3*o+i]=t[3*A+i];if(s)for(let i=0;i<3;i++)e[3*(o+1)+i]=.5*(-.15*t[3*a+i]+1.15*t[3*A+i]+1.15*t[3*r+i]+-.15*t[3*h+i]);else{for(let i=0;i<2;i++)e[3*(o+1)+i]=.5*(-.15*t[3*a+i]+1.15*t[3*A+i]+1.15*t[3*r+i]+-.15*t[3*h+i]);e[3*(o+1)+2]=0}a=A,o+=2}for(let s=0;s<3;s++)e[3*o+s]=t[3*(i-1)+s]}static smoothWaveAndColor(t,e,i,s,r,o=!1){let a,h=0,A=0,n=1;for(let l=0;l<r-1;l++){a=n,n=Math.min(r-1,l+2);for(let e=0;e<3;e++)i[3*h+e]=t[3*l+e];if(o)for(let e=0;e<3;e++)i[3*(h+1)+e]=.5*(-.15*t[3*A+e]+1.15*t[3*l+e]+1.15*t[3*a+e]+-.15*t[3*n+e]);else{for(let e=0;e<2;e++)i[3*(h+1)+e]=.5*(-.15*t[3*A+e]+1.15*t[3*l+e]+1.15*t[3*a+e]+-.15*t[3*n+e]);i[3*(h+1)+2]=0}for(let t=0;t<4;t++)s[4*h+t]=e[4*l+t],s[4*(h+1)+t]=e[4*l+t];A=l,h+=2}for(let e=0;e<3;e++)i[3*h+e]=t[3*(r-1)+e];for(let t=0;t<4;t++)s[4*h+t]=e[4*(r-1)+t]}}class B{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=R.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,o=s*(1-r);i.push(t[0]*s);for(let e=1;e<t.length;e++)i.push(t[e]*o+i[e-1]*r);return i}generateWaveform(t,e,i,s,r){let o=r.wave_a;const a=(r.bass+r.mid+r.treb)/3;if(a>-.01&&o>.001&&i.length>0){const h=B.processWaveform(i,r),A=B.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),o=r.wave_a,0===e){if(r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,0,1),i=Math.floor(h.length/2)+1;const t=1/(i-1),e=Math.floor((h.length-i)/2);for(let o=0;o<i-1;o++){let a=.5+.4*A[o+e]+u;const h=o*t*2*Math.PI+.2*r.time;if(o<i/10){let t=o/(.1*i);t=.5-.5*Math.cos(t*Math.PI);a=(1-t)*(.5+.4*A[o+i+e]+u)+a*t}s[3*o+0]=a*Math.cos(h)*this.aspecty+c,s[3*o+1]=a*Math.sin(h)*this.aspectx+g,s[3*o+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(o*=1.25,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,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?o*=.09:this.texsizeX>=1024&&this.texsizeX<2048?o*=.11:o*=.13,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,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?o*=.15:this.texsizeX>=1024&&this.texsizeX<2048?o*=.22:o*=.33,o*=1.3,o*=r.treb*r.treb,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,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;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,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],o=.47*h[r+e]+g;r>1&&(i=i*l+n*(2*s[3*(r-1)+0]-s[3*(r-2)+0]),o=o*l+n*(2*s[3*(r-1)+1]-s[3*(r-2)+1])),s[3*r+0]=i,s[3*r+1]=o,s[3*r+2]=0}}else if(5===e){if(this.texsizeX<1024?o*=.09:this.texsizeX>=1024&&this.texsizeX<2048?o*=.11:o*=.13,r.modwavealphabyvolume>0){const t=r.modwavealphaend-r.modwavealphastart;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,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,o=A[i]*h[r]+h[i]*A[r],a=A[i]*A[i]-h[r]*h[r];s[3*i+0]=(o*t-a*e)*(this.aspecty+c),s[3*i+1]=(o*e+a*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;o*=(a-r.modwavealphastart)/t}o=Math.clamp(o,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 p=[c*Math.cos(n+.5*Math.PI)-3*l,c*Math.cos(n+.5*Math.PI)+3*l],d=[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:p[t]>1.1&&(i=(1.1-p[1-t])/(p[t]-p[1-t]),s=!0);break;case 1:p[t]<-1.1&&(i=(-1.1-p[1-t])/(p[t]-p[1-t]),s=!0);break;case 2:d[t]>1.1&&(i=(1.1-d[1-t])/(d[t]-d[1-t]),s=!0);break;case 3:d[t]<-1.1&&(i=(-1.1-d[1-t])/(d[t]-d[1-t]),s=!0)}if(s){const e=p[t]-p[1-t],s=d[t]-d[1-t];p[t]=p[1-t]+e*i,d[t]=d[1-t]+s*i}}l=(p[1]-p[0])/i,f=(d[1]-d[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]=p[0]+l*e+.25*E*i,s[3*e+1]=d[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]=p[0]+l*r+E*(.25*i+e),s[3*r+1]=d[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]=p[0]+l*s+E*(.25*i-e),m[3*s+1]=d[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=o):(this.oldPositions=s,this.oldPositions2=m,this.oldNumVert=i,this.oldAlpha=o)}const u=.5-.5*Math.cos(e*Math.PI),f=1-u;this.oldNumVert>0&&(o=u*this.alpha+f*this.oldAlpha);let p=Math.clamp(r.wave_r,0,1),d=Math.clamp(r.wave_g,0,1),_=Math.clamp(r.wave_b,0,1);if(0!==r.wave_brighten){const t=Math.max(p,d,_);t>.01&&(p/=t,d/=t,_/=t)}if(this.color=[p,d,_,o],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,o=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,a=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+o*f,this.positions[3*e+1]=this.positions[3*e+1]*u+a*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,o=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,a=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+o*f,this.positions2[3*e+1]=this.positions2[3*e+1]*u+a*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,o=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,a=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+o*f,this.positions[3*i+1]=this.positions[3*i+1]*u+a*f,this.positions[3*i+2]=0}for(let i=0;i<t;i++){const s=i*e,r=Math.floor(s),o=s-r,a=this.oldPositions2[3*r+0]*(1-o)+this.oldPositions2[3*(r+1)+0]*o,h=this.oldPositions2[3*r+1]*(1-o)+this.oldPositions2[3*(r+1)+1]*o;this.positions2[3*i+0]=this.positions[3*(i+t)+0]*u+a*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,o=this.oldPositions[3*s+0]*(1-r)+this.oldPositions[3*(s+1)+0]*r,a=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+o*f,this.positions[3*e+1]=this.positions[3*e+1]*u+a*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,y.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];y.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 L{constructor(t,e,i){this.index=t,this.gl=e;this.pointsData=[new Float32Array(512),new Float32Array(512)],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=R.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,o,a,h){if(0!==a.baseVals.enabled&&t.length>0){let A;if(o.preset.useWASM)A=o.runWaveFrameEquations(this.index,r);else{const t=Object.assign({},o.mdVSWaves[this.index],o.mdVSFrameMapWaves[this.index],o.mdVSQAfterFrame,o.mdVSTWaveInits[this.index],r);A=o.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=o.preset.waves[this.index].baseVals,c=Math.floor(A.sep),g=A.scaling,m=A.spectrum,u=A.smoothing,f=l.usedots,p=A.r,d=A.g,_=A.b,E=A.a,b=o.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,S=r?s:e,P=r?0:Math.floor((n-this.samples)/2-c/2),w=r?0:Math.floor((n-this.samples)/2+c/2),I=r?(n-c)/this.samples:1,R=(.98*u)**.5,B=1-R;this.pointsData[0][0]=v[P],this.pointsData[1][0]=S[w];for(let t=1;t<this.samples;t++){const e=v[Math.floor(t*I+P)],i=S[Math.floor(t*I+w)];this.pointsData[0][t]=e*B+this.pointsData[0][t-1]*R,this.pointsData[1][t]=i*B+this.pointsData[1][t-1]*R}for(let t=this.samples-2;t>=0;t--)this.pointsData[0][t]=this.pointsData[0][t]*B+this.pointsData[0][t+1]*R,this.pointsData[1][t]=this.pointsData[1][t]*B+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(o.preset.useWASM){const t=o.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=p,t.g.value=d,t.b.value=_,t.a.value=E,a.point_eqs&&o.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=p,A.g=d,A.b=_,A.a=E,""!==a.point_eqs&&(A=o.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(o.preset.useWASM)A.usedots=f,A.thick=l.thick,A.additive=l.additive;else{const t=o.mdVSUserKeysWaves[this.index],e=T.pick(A,t);o.mdVSFrameMapWaves[this.index]=e}return this.mdVSWaveFrame=A,0===f&&y.smoothWaveAndColor(this.positions,this.colors,this.smoothedPositions,this.smoothedColors,this.samples),!0}}return!1}drawCustomWaveform(t,e,i,s,r,o,a,h){if(h&&this.generateWaveform(e,i,s,r,o,a,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,o;t?(s=this.positions,r=this.colors,o=this.samples):(s=this.smoothedPositions,r=this.smoothedColors,o=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 a=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&&(a=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<a;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,o)}}}}class C{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=R.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,o=i.preset.globalPools["shapePerFrame"+this.index];T.setWasm(o,e,i.globalKeys),i.preset.shapes[this.index].frame_eqs||i.preset.restore_qs(),T.setWasm(o,i.mdVSTShapeInits[this.index],i.ts),i.preset.save_ts(),o.x.value=s.x,o.y.value=s.y,o.rad.value=s.rad,o.ang.value=s.ang,o.r.value=s.r,o.g.value=s.g,o.b.value=s.b,o.a.value=s.a,o.r2.value=s.r2,o.g2.value=s.g2,o.b2.value=s.b2,o.a2.value=s.a2,o.border_r.value=s.border_r,o.border_g.value=s.border_g,o.border_b.value=s.border_b,o.border_a.value=s.border_a,o.thickoutline.value=s.thickoutline,o.textured.value=s.textured,o.tex_zoom.value=s.tex_zoom,o.tex_ang.value=s.tex_ang,o.additive.value=s.additive,i.preset.shapes[this.index].frame_eqs_save();const a=Math.clamp(s.num_inst,1,1024);for(let e=0;e<a;e++){o.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=o.sides.value;s=Math.clamp(s,3,100),s=Math.floor(s);const a=o.rad.value,h=o.ang.value,A=2*o.x.value-1,n=-2*o.y.value+1,l=o.r.value,c=o.g.value,g=o.b.value,m=o.a.value,u=o.r2.value,f=o.g2.value,p=o.b2.value,d=o.a2.value,_=o.border_r.value,E=o.border_g.value,b=o.border_b.value,x=o.border_a.value;this.borderColor=[_,E,b,x*t];const v=o.thickoutline.value,T=o.textured.value,S=o.tex_zoom.value,P=o.tex_ang.value,w=o.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+a*Math.cos(r)*this.aspecty,this.positions[3*e+1]=n+a*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]=p,this.colors[4*e+3]=d*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 o=i.preset.shapes[this.index].baseVals,a=Math.clamp(o.num_inst,1,1024);for(let e=0;e<a;e++){let a;s.instance=e,s.x=o.x,s.y=o.y,s.rad=o.rad,s.ang=o.ang,s.r=o.r,s.g=o.g,s.b=o.b,s.a=o.a,s.r2=o.r2,s.g2=o.g2,s.b2=o.b2,s.a2=o.a2,s.border_r=o.border_r,s.border_g=o.border_g,s.border_b=o.border_b,s.border_a=o.border_a,s.thickoutline=o.thickoutline,s.textured=o.textured,s.tex_zoom=o.tex_zoom,s.tex_ang=o.tex_ang,s.additive=o.additive,""!==i.preset.shapes[this.index].frame_eqs_str?(s=Object.assign(s,i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index]),a=i.runShapeFrameEquations(this.index,s)):a=s;let h=a.sides;h=Math.clamp(h,3,100),h=Math.floor(h);const A=a.rad,n=a.ang,l=2*a.x-1,c=-2*a.y+1,g=a.r,m=a.g,u=a.b,f=a.a,p=a.r2,d=a.g2,_=a.b2,E=a.a2,b=a.border_r,x=a.border_g,v=a.border_b,T=a.border_a;this.borderColor=[b,x,v,T*t];const S=a.thickoutline,P=a.textured,w=a.tex_zoom,I=a.tex_ang,R=a.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]=p,this.colors[4*e+1]=d,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=a,this.drawCustomShapeInstance(r,h,B,y,L,C)}const h=i.mdVSUserKeysShapes[this.index],A=T.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,o){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),o?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 U{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=R.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,o=s/2,a=i/2,h=e/2+a,A=a*t,n=a*s,l=h*t,c=h*s;let g=[-r+A,-o+c,0],m=[-r+A,o-c,0],u=[-r+l,o-c,0],f=[-r+l,-o+c,0];return this.addTriangle(0,f,m,g),this.addTriangle(9,f,u,m),g=[r-A,-o+c,0],m=[r-A,o-c,0],u=[r-l,o-c,0],f=[r-l,-o+c,0],this.addTriangle(18,g,m,f),this.addTriangle(27,m,u,f),g=[-r+A,-o+n,0],m=[-r+A,c-o,0],u=[r-A,c-o,0],f=[r-A,-o+n,0],this.addTriangle(36,f,m,g),this.addTriangle(45,f,u,m),g=[-r+A,o-n,0],m=[-r+A,o-c,0],u=[r-A,o-c,0],f=[r-A,o-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 M{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=R.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(){this.positions=new Float32Array([0,0,0,-.05*this.aspecty,0,0,0,-.05,0,.05*this.aspecty,0,0,0,.05,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 F{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=R.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,o=Math.floor(e*this.mesh_width),a=e*this.mesh_width-o,h=o+1,A=s+1,n=this.mesh_width+1;let l,c;return l=t[2*(s*n+o)+0]*(1-a)*(1-r),c=t[2*(s*n+o)+1]*(1-a)*(1-r),l+=t[2*(s*n+h)+0]*a*(1-r),c+=t[2*(s*n+h)+1]*a*(1-r),l+=t[2*(A*n+o)+0]*(1-a)*r,c+=t[2*(A*n+o)+1]*(1-a)*r,l+=t[2*(A*n+h)+0]*a*r,c+=t[2*(A*n+h)+1]*a*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 o=t.mv_x-s,a=t.mv_y-r;s>this.maxX&&(s=this.maxX,o=0),r>this.maxY&&(r=this.maxY,a=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+a+.25-1);if(i-=A,i>1e-4&&i<.9999)for(let t=0;t<s;t++){let r=(t+.25)/(s+o+.25-1);if(r+=h,r>1e-4&&r<.9999){const t=this.getMotionDir(e,r,i);let s=t[0],o=t[1],a=s-r,h=o-i;a*=n,h*=n;let A=Math.sqrt(a*a+h*h);A<l&&A>1e-8?(A=l/A,a*=A,h*=A):(a=l,a=l),s=r+a,o=i+h;const c=2*r-1,g=2*i-1,m=2*s-1,u=2*o-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 Q{constructor(t,e,i,s={}){this.gl=t,this.noise=e,this.image=i,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=R.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,o=2/e,a=[];for(let t=0;t<s;t++){const e=t*o-1;for(let t=0;t<i;t++){const i=t*r-1;a.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),o=e+1+i*(s+1),a=e+1+i*s;h.push(t,r,a),h.push(r,o,a)}this.vertices=new Float32Array(a),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=R.getShaderParts(t);i=s[0],e=s[1]}e=e.replace(/texture2D/g,"texture"),e=e.replace(/texture3D/g,"texture"),this.userTextures=R.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],o=e[0],a=e[1],h=e[2],A=o-i,n=i,l=a-s,c=s,g=h-r,m=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,o),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,a),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,o,a,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([Math.random(),Math.random(),Math.random(),Math.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(o,a),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 V{constructor(t,e,i,s={}){this.gl=t,this.noise=e,this.image=i,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=R.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,o=2/e,a=[];for(let t=0;t<s;t++){const e=t*o-1;for(let t=0;t<i;t++){const i=t*r-1;a.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),o=e+1+i*(s+1),a=e+1+i*s;h.push(t,r,a),h.push(r,o,a)}this.vertices=new Float32Array(a),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=R.getShaderParts(t);i=s[0],e=s[1]}e=e.replace(/texture2D/g,"texture"),e=e.replace(/texture3D/g,"texture"),this.userTextures=R.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],o=e[0],a=e[1],h=e[2],A=o-i,n=i,l=a-s,c=s,g=h-r,m=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,o),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,a),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=V.generateHueBase(e),r=this.compWidth+1,o=this.compHeight+1,a=new Float32Array(r*o*4);let h=0;for(let e=0;e<o;e++)for(let o=0;o<r;o++){let r=o/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,o=A-e;l=i[4*(e*(this.mesh_width+1)+t)+3]*(1-s)*(1-o)+i[4*(e*(this.mesh_width+1)+(t+1))+3]*s*(1-o)+i[4*((e+1)*(this.mesh_width+1)+t)+3]*(1-s)*o+i[4*((e+1)*(this.mesh_width+1)+(t+1))+3]*s*o}a[h+0]=n[0],a[h+1]=n[1],a[h+2]=n[2],a[h+3]=l,h+=4}return a}renderQuadTexture(t,e,i,s,r,o,a,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([Math.random(),Math.random(),Math.random(),Math.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(o,a),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 D{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=R.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 q{constructor(t){this.gl=t,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=R.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 z{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],o=0+(i[2]+i[3])/s*2,a=2+(i[6]+i[7])/r*2;this.wds=new Float32Array([s,r,o,a]),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=R.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 N{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],o=i[4]+i[5],a=i[6]+i[7],h=0+2*i[1]/s,A=2+2*i[3]/r,n=4+2*i[5]/o,l=6+2*i[7]/a;this.ws=new Float32Array([s,r,o,a]),this.ds=new Float32Array([h,A,n,l]),this.wDiv=.5/(s+r+o+a),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=R.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,o;return i[0]=1/(e[0]-t[0]),s[0]=-t[0]*i[0],r=(t[1]-t[0])/(e[0]-t[0]),o=(e[1]-t[0])/(e[0]-t[0]),i[1]=1/(o-r),s[1]=-r*i[1],r=(t[2]-t[1])/(e[1]-t[1]),o=(e[2]-t[1])/(e[1]-t[1]),i[2]=1/(o-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:o,bias:a}=this.getScaleAndBias(i,s);this.gl.uniform4fv(this.texsizeLocation,[r[0],r[1],1/r[0],1/r[1]]),this.gl.uniform1f(this.scaleLoc,o),this.gl.uniform1f(this.biasLoc,a),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 X{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 N(i,this.blurLevel,s),this.blurVertical=new z(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,o=this.getTextureSize(e[1]);this.bindFrameBufferTexture(this.blurVerticalFrameBuffer,this.blurVerticalTexture,o),this.horizontalTexsizes=[i,s],this.verticalTexsizes=[r,o]}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 O{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.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=O.createNoiseTex(256,1),this.nTexArrLQLite=O.createNoiseTex(32,1),this.nTexArrMQ=O.createNoiseTex(256,4),this.nTexArrHQ=O.createNoiseTex(256,8),this.nTexArrVolLQ=O.createNoiseVolTex(32,1),this.nTexArrVolHQ=O.createNoiseVolTex(32,4),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 o=r*r,a=s-i-t+e;return a*(r*o)+(t-e-a)*o+(i-t)*r+e}static dwCubicInterpolate(t,e,i,s,r){const o=[];for(let a=0;a<4;a++){let h=O.fCubicInterpolate(t[a]/255,e[a]/255,i[a]/255,s[a]/255,r);h=Math.clamp(h,0,1),o[a]=255*h}return o}static createNoiseVolTex(t,e){const i=t*t*t,s=new Uint8Array(4*i),r=e>1?216:256,o=.5*r;for(let t=0;t<i;t++)s[4*t+0]=Math.floor(Math.random()*r+o),s[4*t+1]=Math.floor(Math.random()*r+o),s[4*t+2]=Math.floor(Math.random()*r+o),s[4*t+3]=Math.floor(Math.random()*r+o);const a=t*t,h=t;if(e>1){for(let i=0;i<t;i+=e)for(let r=0;r<t;r+=e)for(let o=0;o<t;o++)if(o%e!=0){const A=Math.floor(o/e)*e+t,n=i*a+r*h,l=[],c=[],g=[],m=[];for(let i=0;i<4;i++)l[i]=s[4*n+(A-e)%t*4+i],c[i]=s[4*n+A%t*4+i],g[i]=s[4*n+(A+e)%t*4+i],m[i]=s[4*n+(A+2*e)%t*4+i];const u=o%e/e,f=O.dwCubicInterpolate(l,c,g,m,u);for(let t=0;t<4;t++){s[i*a*4+r*h*4+(4*o+t)]=f[t]}}for(let i=0;i<t;i+=e)for(let r=0;r<t;r++)for(let o=0;o<t;o++)if(o%e!=0){const A=Math.floor(o/e)*e+t,n=i*a,l=[],c=[],g=[],m=[];for(let i=0;i<4;i++){const o=4*r+4*n+i;l[i]=s[(A-e)%t*h*4+o],c[i]=s[A%t*h*4+o],g[i]=s[(A+e)%t*h*4+o],m[i]=s[(A+2*e)%t*h*4+o]}const u=o%e/e,f=O.dwCubicInterpolate(l,c,g,m,u);for(let t=0;t<4;t++){s[o*h*4+(4*r+4*n+t)]=f[t]}}for(let i=0;i<t;i++)for(let r=0;r<t;r++)for(let o=0;o<t;o++)if(o%e!=0){const A=r*h,n=Math.floor(o/e)*e+t,l=[],c=[],g=[],m=[];for(let r=0;r<4;r++){const o=4*i+4*A+r;l[r]=s[(n-e)%t*a*4+o],c[r]=s[n%t*a*4+o],g[r]=s[(n+e)%t*a*4+o],m[r]=s[(n+2*e)%t*a*4+o]}const u=r%e/e,f=O.dwCubicInterpolate(l,c,g,m,u);for(let t=0;t<4;t++){s[o*a*4+(4*i+4*A+t)]=f[t]}}}return s}static createNoiseTex(t,e){const i=t*t,s=new Uint8Array(4*i),r=e>1?216:256,o=.5*r;for(let t=0;t<i;t++)s[4*t+0]=Math.floor(Math.random()*r+o),s[4*t+1]=Math.floor(Math.random()*r+o),s[4*t+2]=Math.floor(Math.random()*r+o),s[4*t+3]=Math.floor(Math.random()*r+o);if(e>1){for(let i=0;i<t;i+=e)for(let r=0;r<t;r++)if(r%e!=0){const o=Math.floor(r/e)*e+t,a=i*t,h=[],A=[],n=[],l=[];for(let i=0;i<4;i++)h[i]=s[4*a+(o-e)%t*4+i],A[i]=s[4*a+o%t*4+i],n[i]=s[4*a+(o+e)%t*4+i],l[i]=s[4*a+(o+2*e)%t*4+i];const c=r%e/e,g=O.dwCubicInterpolate(h,A,n,l,c);for(let e=0;e<4;e++)s[i*t*4+4*r+e]=g[e]}for(let i=0;i<t;i++)for(let r=0;r<t;r++)if(r%e!=0){const o=Math.floor(r/e)*e+t,a=[],h=[],A=[],n=[];for(let r=0;r<4;r++)a[r]=s[(o-e)%t*t*4+4*i+r],h[r]=s[o%t*t*4+4*i+r],A[r]=s[(o+e)%t*t*4+4*i+r],n[r]=s[(o+2*e)%t*t*4+4*i+r];const l=r%e/e,c=O.dwCubicInterpolate(a,h,A,n,l);for(let e=0;e<4;e++)s[r*t*4+4*i+e]=c[e]}}return s}}class k{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+AwAAfJIHAJoBAACGAwAAhpIHAAgBAAA2AgAAAKAHAAQAAAAwMTAwAaADAAEAAAABAAAAAqAEAAEAAACAAAAAA6AEAAEAAACAAAAABaAEAAEAAAAwBQAADqIFAAEAAAAgBQAAD6IFAAEAAAAoBQAAEKIDAAEAAAACAAAAF6IDAAEAAAACAAAAAKMHAAEAAAADAAAAAAAAADIwMDI6MDE6MTkgMTc6MzM6MjAAMjAwMjowMToxOSAxNzozMzoyMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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JOBxnU9ogpwBjVbTrSDAkxyMc9/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 G{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"),this.floatPrecision=R.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=[];for(let e=0;e<8;e++){const i=e*(2/7)-1;for(let e=0;e<16;e++){const s=e*(2/15)-1;t.push(s,-i,0)}}const e=[];for(let t=0;t<7;t++)for(let i=0;i<15;i++){const s=i+16*t,r=i+16*(t+1),o=i+1+16*(t+1),a=i+1+16*t;e.push(s,r,a),e.push(r,o,a)}this.vertices=new Float32Array(t),this.indices=new Uint16Array(e)}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 o=2*(r/15)-1;let a=2*(.75*(i/7-.5)+.5)-1;t>=1&&(a+=1/this.texsizeY),s.push(o,e?a:-a)}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 o=16*t+e;s[o]+=.07*r*Math.sin(.31*i.time+.39*s[o]-1.94*s[o+1]),s[o]+=.044*r*Math.sin(.81*i.time-1.91*s[o]+.27*s[o+1]),s[o]+=.061*r*Math.sin(1.31*i.time+.61*s[o]+.74*s[o+1]),s[o+1]+=.061*r*Math.sin(.37*i.time+1.83*s[o]+.69*s[o+1]),s[o+1]+=.07*r*Math.sin(.67*i.time+.42*s[o]-1.39*s[o+1]),s[o+1]+=.087*r*Math.sin(1.07*i.time+3.55*s[o]+.89*s[o+1])}const o=1.01/(t**.21+.01);for(let t=0;t<s.length/2;t++)s[2*t]*=o,s[2*t+1]*=o*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 Y{constructor(t){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 o=new Float32Array((s+1)*(r+1));let a=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],p=t[g*(e+1)+(c+1)],d=t[(g+1)*(e+1)+c],_=t[(g+1)*(e+1)+(c+1)];o[a]=f*(1-m)*(1-u)+p*m*(1-u)+d*(1-m)*u+_*m*u,a+=1}return o}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=Y.resizeMatrixValues(this.vertInfoA,e,i,this.mesh_width,this.mesh_height),this.vertInfoC=Y.resizeMatrixValues(this.vertInfoC,e,i,this.mesh_width,this.mesh_height))}genPlasma(t,e,i,s,r){const o=Math.floor((t+e)/2),a=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[a*(this.mesh_width+1)+t]=.5*(h+n)+(2*Math.random()-1)*r*this.aspecty),this.vertInfoC[a*(this.mesh_width+1)+e]=.5*(A+l)+(2*Math.random()-1)*r*this.aspecty),e-t>=2&&(0===i&&(this.vertInfoC[i*(this.mesh_width+1)+o]=.5*(h+A)+(2*Math.random()-1)*r*this.aspectx),this.vertInfoC[s*(this.mesh_width+1)+o]=.5*(n+l)+(2*Math.random()-1)*r*this.aspectx),s-i>=2&&e-t>=2&&(h=this.vertInfoC[a*(this.mesh_width+1)+t],A=this.vertInfoC[a*(this.mesh_width+1)+e],n=this.vertInfoC[i*(this.mesh_width+1)+o],l=this.vertInfoC[s*(this.mesh_width+1)+o],this.vertInfoC[a*(this.mesh_width+1)+o]=.25*(n+l+h+A)+(2*Math.random()-1)*r,this.genPlasma(t,o,i,a,.5*r),this.genPlasma(o,e,i,a,.5*r),this.genPlasma(t,o,a,s,.5*r),this.genPlasma(o,e,a,s,.5*r))}createBlendPattern(){const t=1+Math.floor(3*Math.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*Math.random(),e=Math.cos(t),i=Math.sin(t),s=.1+.2*Math.random(),r=1/s;let o=0;for(let t=0;t<=this.mesh_height;t++){const a=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+(a-.5)*i+.5;h=(h-.5)/Math.sqrt(2)+.5,this.vertInfoA[o]=r*(1+s),this.vertInfoC[o]=r*h-r,o+=1}}}else if(2===t){const t=.12+.13*Math.random(),e=1/t;this.vertInfoC[0]=Math.random(),this.vertInfoC[this.mesh_width]=Math.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)]=Math.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)+this.mesh_width]=Math.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 o=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)*o;this.vertInfoA[r]=e*(1+t),this.vertInfoC[r]=e*s-e,r+=1}}else if(3===t){const t=.02+.14*Math.random()+.34*Math.random(),e=1/t,i=2*Math.floor(2*Math.random())-1;let s=0;for(let r=0;r<=this.mesh_height;r++){const o=(r/this.mesh_height-.5)*this.aspecty;for(let r=0;r<=this.mesh_width;r++){const a=(r/this.mesh_width-.5)*this.aspectx;let h=1.41421*Math.sqrt(a*a+o*o);-1===i&&(h=1-h),this.vertInfoA[s]=e*(1+t),this.vertInfoC[s]=e*h-e,s+=1}}}}}class W{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=T.range(1,33).map(t=>"q"+t),this.ts=T.range(1,9).map(t=>"t"+t),this.regs=T.range(0,100).map(t=>t<10?"reg0"+t:"reg"+t),this.blurRatios=[[.5,.25],[.125,.125],[.0625,.0625]],this.audioLevels=new b(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 O(t),this.image=new k(t),this.warpShader=new Q(t,this.noise,this.image,s),this.compShader=new V(t,this.noise,this.image,s),this.outputShader=new D(t,s),this.prevWarpShader=new Q(t,this.noise,this.image,s),this.prevCompShader=new V(t,this.noise,this.image,s),this.numBlurPasses=0,this.blurShader1=new X(0,this.blurRatios,t,s),this.blurShader2=new X(1,this.blurRatios,t,s),this.blurShader3=new X(2,this.blurRatios,t,s),this.blurTexture1=this.blurShader1.blurVerticalTexture,this.blurTexture2=this.blurShader2.blurVerticalTexture,this.blurTexture3=this.blurShader3.blurVerticalTexture,this.basicWaveform=new B(t,s),this.customWaveforms=T.range(4).map(e=>new L(e,t,s)),this.customShapes=T.range(4).map(e=>new C(e,t,s)),this.prevCustomWaveforms=T.range(4).map(e=>new L(e,t,s)),this.prevCustomShapes=T.range(4).map(e=>new C(e,t,s)),this.darkenCenter=new M(t,s),this.innerBorder=new U(t,s),this.outerBorder=new U(t,s),this.motionVectors=new F(t,s),this.titleText=new G(t,s),this.blendPattern=new Y(s),this.resampleShader=new q(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=v.a;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=v.a,this.prevPreset=this.preset,this.presetEquationRunner=new S(this.preset,r,s),this.prevPresetEquationRunner=new S(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 P(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 S(this.preset,i,s),this.regVars=this.presetEquationRunner.mdVSRegs);const r=this.prevWarpShader;this.prevWarpShader=this.warpShader,this.warpShader=r;const o=this.prevCompShader;this.prevCompShader=this.compShader,this.compShader=o;const a=this.preset.warp.trim(),h=this.preset.comp.trim();this.warpShader.updateShader(a),this.compShader.updateShader(h),0===a.length?this.numBlurPasses=0:this.numBlurPasses=W.getHighestBlur(a),0!==h.length&&(this.numBlurPasses=Math.max(this.numBlurPasses,W.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,o=this.mesh_height,a=r+1,h=o+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,p=this.aspectx,d=this.aspecty;let _=0,E=0;if(t.preset.useWASM){const r=t.preset.globalPools.perVertex;if(T.setWasm(r,i,t.globalKeys),T.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<a;t++){const t=e[i],r=e[i+1];let o=this.blendPattern.vertInfoA[i/2]*this.blendProgress+this.blendPattern.vertInfoC[i/2];o=Math.clamp(o,0,1),this.warpUVs[i]=this.warpUVs[i]*o+t*(1-o),this.warpUVs[i+1]=this.warpUVs[i+1]*o+r*(1-o),this.warpColor[s+0]=1,this.warpColor[s+1]=1,this.warpColor[s+2]=1,this.warpColor[s+3]=o,i+=2,s+=4}}else this.warpUVs=t.preset.pixel_eqs_get_array(),this.warpColor.fill(1)}else{let i=T.cloneVars(e),b=i.warp,x=i.zoom,v=i.zoomexp,S=i.cx,P=i.cy,w=i.sx,I=i.sy,R=i.dx,y=i.dy,B=i.rot;for(let L=0;L<h;L++)for(let h=0;h<a;h++){const a=h/r*2-1,C=L/o*2-1,U=Math.sqrt(a*a*p*p+C*C*d*d);if(t.runVertEQs){let s;s=L===o/2&&h===r/2?0:T.atan2(C*d,a*p),i.x=.5*a*p+.5,i.y=-.5*C*d+.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,S=i.cx,P=i.cy,w=i.sx,I=i.sy,R=i.dx,y=i.dy,B=i.rot}const M=1/x**(v**(2*U-1));let F=.5*a*p*M+.5,Q=.5*-C*d*M+.5;F=(F-S)/w+S,Q=(Q-P)/I+P,0!==b&&(F+=.0035*b*Math.sin(.333*A+n*(a*l-C*m)),Q+=.0035*b*Math.cos(.375*A-n*(a*g+C*c)),F+=.0035*b*Math.cos(.753*A-n*(a*c-C*g)),Q+=.0035*b*Math.sin(.825*A+n*(a*l+C*m)));const V=F-S,D=Q-P,q=Math.cos(B),z=Math.sin(B);if(F=V*q-D*z+S,Q=V*z+D*q+P,F-=R,Q-=y,F=(F-.5)/p+.5,Q=(Q-.5)/d+.5,F+=u,Q+=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+F*(1-t),this.warpUVs[_+1]=this.warpUVs[_+1]*t+Q*(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[_]=F,this.warpUVs[_+1]=Q,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,o=T.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<.5?i.wave_dots:e.wave_dots,o.wave_thick=s<.5?i.wave_thick:e.wave_thick,o.additivewave=s<.5?i.additivewave:e.additivewave,o.wave_brighten=s<.5?i.wave_brighten:e.wave_brighten,o.darken_center=s<.5?i.darken_center:e.darken_center,o.gammaadj=s<.5?i.gammaadj:e.gammaadj,o.wrap=s<.5?i.wrap:e.wrap,o.invert=s<.5?i.invert:e.invert,o.brighten=s<.5?i.brighten:e.brighten,o.darken=s<.5?i.darken:e.darken,o.solarize=s<.5?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,o=t.b2x,a=t.b3x;if(r-e<.1){const t=.5*(e+r);e=t-.05,r=t-.05}if(o=Math.min(r,o),i=Math.max(e,i),o-i<.1){const t=.5*(i+o);i=t-.05,o=t-.05}if(a=Math.min(o,a),s=Math.max(i,s),a-s<.1){const t=.5*(s+a);s=t-.05,a=t-.05}return{blurMins:[e,i,s],blurMaxs:[r,o,a]}}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 o;this.runPixelEquations(this.presetEquationRunner,r,i,!1),this.preset.useWASM||(Object.assign(this.regVars,T.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),o=W.mixFrameEquations(this.blendProgress,r,this.prevMDVSFrame)):o=r;const a=this.targetTexture;this.targetTexture=this.prevTexture,this.prevTexture=a;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}=W.getBlurValues(o);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,o,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(o,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,o),this.darkenCenter.drawDarkenCenter(o);const l=[o.ob_r,o.ob_g,o.ob_b,o.ob_a];this.outerBorder.drawBorder(l,o.ob_size,0);const c=[o.ib_r,o.ib_g,o.ib_b,o.ib_a];if(this.innerBorder.drawBorder(c,o.ib_size,o.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=o,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}=W.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}=W.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 o=document.createElement("canvas");o.width=this.texsizeX,o.height=this.texsizeY;const a=o.getContext("2d"),h=a.createImageData(this.texsizeX,this.texsizeY);return h.data.set(t),a.putImageData(h,0,0),this.gl.deleteTexture(i),this.gl.deleteFramebuffer(e),o.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"),s=i.createImageData(this.texsizeX,this.texsizeY);return s.data.set(t),i.putImageData(s,0,0),e.toDataURL()}}var j=i(11),J=i.n(j);function K(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function H(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?K(Object(i),!0).forEach((function(e){r()(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):K(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}class Z{constructor(t,e,i){this.opts=i,this.audio=new E(t);const s=i.width||1200,r=i.height||900;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"),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=T.range(1,33).map(t=>"q"+t),this.ts=T.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 W(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)=>H(H({},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=Z.overrideDefaultVars(this.baseValsDefaults,i.baseVals);for(let t=0;t<i.shapes.length;t++)i.shapes[t].baseVals=Z.overrideDefaultVars(this.shapeBaseValsDefaults,i.shapes[t].baseVals);for(let t=0;t<i.waves.length;t++)i.waves[t].baseVals=Z.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:H(H({},i),this.createPerFramePool(t.baseVals)),perVertex:H(H({},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]=H(H(H({},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]=H(H(H({},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 h=await Object(o.loadModule)({pools:r,functions:a,eelVersion:t.version||2}),A=t=>t||(()=>{}),n=await d.instantiate(Z.base64ToArrayBuffer(J()()),{pixelEqs:{perPixelEqs:A(h.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:Z.makeShapeResetPool(r.shapePerFrame0,this.shapeBaseVars,0),shapePool1:Z.makeShapeResetPool(r.shapePerFrame1,this.shapeBaseVars,1),shapePool2:Z.makeShapeResetPool(r.shapePerFrame2,this.shapeBaseVars,2),shapePool3:Z.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=A(h.exports.presetInit),t.frame_eqs=A(h.exports.perFrame),t.save_qs=n.exports.saveQs,t.restore_qs=n.exports.restoreQs,t.save_ts=n.exports.saveTs,t.restore_ts=n.exports.restoreTs,h.exports.perPixel&&(t.pixel_eqs=h.exports.perPixel),t.pixel_eqs_initialize_array=(e,i)=>{const s=n.exports.createFloat32Array((e+1)*(i+1)*2);t.pixel_eqs_array=s},t.pixel_eqs_get_array=()=>n.exports.__getFloat32ArrayView(t.pixel_eqs_array),t.pixel_eqs_wasm=(...e)=>n.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=A(h.exports[`shapes_${e}_init_eqs`]),t.shapes[e].frame_eqs=h.exports[`shapes_${e}_frame_eqs`],t.shapes[e].frame_eqs_save=()=>n.exports[`shape${e}_save`](),t.shapes[e].frame_eqs_restore=()=>n.exports[`shape${e}_restore`]());for(let e=0;e<t.waves.length;e++)if(0!==t.waves[e].baseVals.enabled){const i={init_eqs:A(h.exports[`waves_${e}_init_eqs`]),frame_eqs:A(h.exports[`waves_${e}_frame_eqs`])};t.waves[e].point_eqs_eel&&""!==t.waves[e].point_eqs_eel?i.point_eqs=h.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")}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 ${static createVisualizer(t,e,i){return new Z(t,e,i)}}}])}));
//# sourceMappingURL=butterchurn.min.js.map