UNPKG

butterchurn

Version:

Butterchurn is a WebGL implementation of the Milkdrop Visualizer

1 lines 193 kB
!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=5)}([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";{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?NaN:Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(r)?NaN:t===1/0||t===-1/0?t:(t-e)*(r-s)/(i-e)+s}),t("fscale",function(t,i,s,r,a){return e[0]=Math.scale(t,i,s,r,a),e[0]}),t("clamp",function(t,e,i){return Math.min(i,Math.max(e,t))}),t("radians",function(t){return t*Math.DEG_PER_RAD}),t("degrees",function(t){return t*Math.RAD_PER_DEG})}},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){var r=e,a=i,h=s;return a<0&&(h+=a,r-=a,a=0),r<0&&(h+=r,a-=r,r=0),h>0&&t.copyWithin(r,a,h),e}},,,function(t,e,i){"use strict";i.r(e);i(1),i(2);function s(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var r=function(){function t(e,i){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.samplesIn=e,this.samplesOut=i,this.equalize=s,this.NFREQ=2*i,this.equalize&&this.initEqualizeTable(),this.initBitRevTable(),this.initCosSinTable()}var e,i,r;return e=t,(i=[{key:"initEqualizeTable",value:function(){this.equalizeArr=new Float32Array(this.samplesOut);for(var t=1/this.samplesOut,e=0;e<this.samplesOut;e++)this.equalizeArr[e]=-.02*Math.log((this.samplesOut-e)*t)}},{key:"initBitRevTable",value:function(){this.bitrevtable=new Uint16Array(this.NFREQ);for(var t=0;t<this.NFREQ;t++)this.bitrevtable[t]=t;for(var e=0,i=0;i<this.NFREQ;i++){if(e>i){var s=this.bitrevtable[i];this.bitrevtable[i]=this.bitrevtable[e],this.bitrevtable[e]=s}for(var r=this.NFREQ>>1;r>=1&&e>=r;)e-=r,r>>=1;e+=r}}},{key:"initCosSinTable",value:function(){for(var t=2,e=0;t<=this.NFREQ;)e+=1,t<<=1;this.cossintable=[new Float32Array(e),new Float32Array(e)],t=2;for(var i=0;t<=this.NFREQ;){var s=-2*Math.PI/t;this.cossintable[0][i]=Math.cos(s),this.cossintable[1][i]=Math.sin(s),i+=1,t<<=1}}},{key:"timeToFrequencyDomain",value:function(t){for(var e=new Float32Array(this.NFREQ),i=new Float32Array(this.NFREQ),s=0;s<this.NFREQ;s++){var r=this.bitrevtable[s];r<this.samplesIn?e[s]=t[r]:e[s]=0,i[s]=0}for(var a=2,h=0;a<=this.NFREQ;){for(var o=this.cossintable[0][h],n=this.cossintable[1][h],l=1,m=0,u=a>>1,g=0;g<u;g++){for(var c=g;c<this.NFREQ;c+=a){var A=c+u,f=l*e[A]-m*i[A],d=l*i[A]+m*e[A];e[A]=e[c]-f,i[A]=i[c]-d,e[c]+=f,i[c]+=d}var v=l;l=v*o-m*n,m=m*o+v*n}a<<=1,h+=1}var p=new Float32Array(this.samplesOut);if(this.equalize)for(var _=0;_<this.samplesOut;_++)p[_]=this.equalizeArr[_]*Math.sqrt(e[_]*e[_]+i[_]*i[_]);else for(var x=0;x<this.samplesOut;x++)p[x]=Math.sqrt(e[x]*e[x]+i[x]*i[x]);return p}}])&&s(e.prototype,i),r&&s(e,r),t}();function a(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var h=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.numSamps=512,this.fftSize=2*this.numSamps,this.fft=new r(this.fftSize,512,!0),e&&(this.audioContext=e,this.audible=e.createDelay(),this.analyser=e.createAnalyser(),this.analyser.smoothingTimeConstant=0,this.analyser.fftSize=this.fftSize,this.audible.connect(this.analyser),this.analyserL=e.createAnalyser(),this.analyserL.smoothingTimeConstant=0,this.analyserL.fftSize=this.fftSize,this.analyserR=e.createAnalyser(),this.analyserR.smoothingTimeConstant=0,this.analyserR.fftSize=this.fftSize,this.splitter=e.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)}var e,i,s;return e=t,(i=[{key:"sampleAudio",value:function(){this.analyser.getByteTimeDomainData(this.timeByteArray),this.analyserL.getByteTimeDomainData(this.timeByteArrayL),this.analyserR.getByteTimeDomainData(this.timeByteArrayR),this.processAudio()}},{key:"updateAudio",value:function(t,e,i){this.timeByteArray.set(t),this.timeByteArrayL.set(e),this.timeByteArrayR.set(i),this.processAudio()}},{key:"processAudio",value:function(){for(var 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)}},{key:"connectAudio",value:function(t){t.connect(this.audible)}},{key:"disconnectAudio",value:function(t){t.disconnect(this.audible)}}])&&a(e.prototype,i),s&&a(e,s),t}();function o(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var n=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.audio=e;var i=(this.audio.audioContext?this.audio.audioContext.sampleRate:44100)/this.audio.fftSize,s=Math.clamp(Math.round(20/i)-1,0,this.audio.numSamps-1),r=Math.clamp(Math.round(320/i)-1,0,this.audio.numSamps-1),a=Math.clamp(Math.round(2800/i)-1,0,this.audio.numSamps-1),h=Math.clamp(Math.round(11025/i)-1,0,this.audio.numSamps-1);this.starts=[s,r,a],this.stops=[r,a,h],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)}var e,i,s;return e=t,s=[{key:"isFiniteNumber",value:function(t){return Number.isFinite(t)&&!Number.isNaN(t)}},{key:"adjustRateToFPS",value:function(t,e,i){return Math.pow(t,e/i)}}],(i=[{key:"updateAudioLevels",value:function(e,i){if(this.audio.freqArray.length>0){var s=e;!t.isFiniteNumber(s)||s<15?s=15:s>144&&(s=144),this.imm.fill(0);for(var r=0;r<3;r++)for(var a=this.starts[r];a<this.stops[r];a++)this.imm[r]+=this.audio.freqArray[a];for(var h=0;h<3;h++){var o=void 0;o=this.imm[h]>this.avg[h]?.2:.5,o=t.adjustRateToFPS(o,30,s),this.avg[h]=this.avg[h]*o+this.imm[h]*(1-o),o=i<50?.9:.992,o=t.adjustRateToFPS(o,30,s),this.longAvg[h]=this.longAvg[h]*o+this.imm[h]*(1-o),this.longAvg[h]<.001?(this.val[h]=1,this.att[h]=1):(this.val[h]=this.imm[h]/this.longAvg[h],this.att[h]=this.avg[h]/this.longAvg[h])}}}},{key:"bass",get:function(){return this.val[0]}},{key:"bass_att",get:function(){return this.att[0]}},{key:"mid",get:function(){return this.val[1]}},{key:"mid_att",get:function(){return this.att[1]}},{key:"treb",get:function(){return this.val[2]}},{key:"treb_att",get:function(){return this.att[2]}}])&&o(e.prototype,i),s&&o(e,s),t}(),l=i(0),m=i.n(l);function u(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function g(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var c=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"atan2",value:function(t,e){var i=Math.atan2(t,e);return i<0&&(i+=2*Math.PI),i}},{key:"cloneVars",value:function(t){return Object.assign({},t)}},{key:"range",value:function(t,e){return void 0===e?u(Array(t).keys()):Array.from({length:e-t},function(e,i){return i+t})}},{key:"pick",value:function(t,e){for(var i={},s=0;s<e.length;s++){var r=e[s];i[r]=t[r]}return i}},{key:"omit",value:function(t,e){for(var i=Object.assign({},t),s=0;s<e.length;s++){delete i[e[s]]}return i}}],(i=null)&&g(e.prototype,i),s&&g(e,s),t}();function A(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var f=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.preset=e,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.qs=c.range(1,33).map(function(t){return"q".concat(t)}),this.ts=c.range(1,9).map(function(t){return"t".concat(t)}),this.regs=c.range(100).map(function(t){return t<10?"reg0".concat(t):"reg".concat(t)}),this.initializeEquations(i)}var e,i,s;return e=t,(i=[{key:"initializeEquations",value:function(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);var 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()]);var i=this.qs.concat(this.regs,Object.keys(this.mdVS)),s=this.preset.init_eqs(c.cloneVars(this.mdVS));this.mdVSQInit=c.pick(s,this.qs),this.mdVSRegs=c.pick(s,this.regs);var r=c.pick(s,Object.keys(c.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(c.omit(this.mdVSFrame,i)),this.mdVSFrameMap=c.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=c.pick(this.mdVSFrame,this.qs),this.mdVSRegs=c.pick(this.mdVSFrame,this.regs),this.mdVSWaves=[],this.mdVSTWaveInits=[],this.mdVSUserKeysWaves=[],this.mdVSFrameMapWaves=[],this.preset.waves&&this.preset.waves.length>0)for(var a=0;a<this.preset.waves.length;a++){var h=this.preset.waves[a],o=h.baseVals;if(0!==o.enabled){var n=Object.assign({},o,e),l=this.qs.concat(this.ts,this.regs,Object.keys(n));Object.assign(n,this.mdVSQAfterFrame,this.mdVSRegs),n.megabuf=new Array(1048576).fill(0),h.init_eqs&&(n=h.init_eqs(n),this.mdVSRegs=c.pick(n,this.regs),Object.assign(n,o)),this.mdVSWaves.push(n),this.mdVSTWaveInits.push(c.pick(n,this.ts)),this.mdVSUserKeysWaves.push(Object.keys(c.omit(n,l))),this.mdVSFrameMapWaves.push(c.pick(n,this.mdVSUserKeysWaves[a]))}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(var m=0;m<this.preset.shapes.length;m++){var u=this.preset.shapes[m],g=u.baseVals;if(0!==g.enabled){var A=Object.assign({},g,e),f=this.qs.concat(this.ts,this.regs,Object.keys(A));Object.assign(A,this.mdVSQAfterFrame,this.mdVSRegs),A.megabuf=new Array(1048576).fill(0),u.init_eqs&&(A=u.init_eqs(A),this.mdVSRegs=c.pick(A,this.regs),Object.assign(A,g)),this.mdVSShapes.push(A),this.mdVSTShapeInits.push(c.pick(A,this.ts)),this.mdVSUserKeysShapes.push(Object.keys(c.omit(A,f))),this.mdVSFrameMapShapes.push(c.pick(A,this.mdVSUserKeysShapes[m]))}else this.mdVSShapes.push({}),this.mdVSTShapeInits.push({}),this.mdVSUserKeysShapes.push([]),this.mdVSFrameMapShapes.push({})}}},{key:"updatePreset",value:function(t,e){this.preset=t,this.initializeEquations(e)}},{key:"updateGlobals",value:function(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}},{key:"runFrameEquations",value:function(t){this.mdVSFrame=Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSFrameMap,t),this.mdVSFrame=this.preset.frame_eqs(this.mdVSFrame),this.mdVSFrameMap=c.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=c.pick(this.mdVSFrame,this.qs)}}])&&A(e.prototype,i),s&&A(e,s),t}();function d(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var v=/uniform sampler2D sampler_(?:.+?);/g,p=/uniform sampler2D sampler_(.+?);/,_=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"getShaderParts",value:function(t){var e=t.indexOf("shader_body");if(t&&e>-1){var i=t.substring(0,e),s=t.substring(e),r=s.indexOf("{"),a=s.lastIndexOf("}");return[i,s.substring(r+1,a)]}return["",t]}},{key:"getFragmentFloatPrecision",value:function(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"}},{key:"getUserSamplers",value:function(t){var e=[],i=t.match(v);if(i&&i.length>0)for(var s=0;s<i.length;s++){var r=i[s].match(p);if(r&&r.length>0){var a=r[1];e.push({sampler:a})}}return e}}],(i=null)&&d(e.prototype,i),s&&d(e,s),t}();function x(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var b=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"smoothWave",value:function(t,e,i){for(var s,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=0,h=0,o=1,n=0;n<i-1;n++){s=o,o=Math.min(i-1,n+2);for(var l=0;l<3;l++)e[3*a+l]=t[3*n+l];if(r)for(var m=0;m<3;m++)e[3*(a+1)+m]=.5*(-.15*t[3*h+m]+1.15*t[3*n+m]+1.15*t[3*s+m]+-.15*t[3*o+m]);else{for(var u=0;u<2;u++)e[3*(a+1)+u]=.5*(-.15*t[3*h+u]+1.15*t[3*n+u]+1.15*t[3*s+u]+-.15*t[3*o+u]);e[3*(a+1)+2]=0}h=n,a+=2}for(var g=0;g<3;g++)e[3*a+g]=t[3*(i-1)+g]}},{key:"smoothWaveAndColor",value:function(t,e,i,s,r){for(var a,h=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=0,n=0,l=1,m=0;m<r-1;m++){a=l,l=Math.min(r-1,m+2);for(var u=0;u<3;u++)i[3*o+u]=t[3*m+u];if(h)for(var g=0;g<3;g++)i[3*(o+1)+g]=.5*(-.15*t[3*n+g]+1.15*t[3*m+g]+1.15*t[3*a+g]+-.15*t[3*l+g]);else{for(var c=0;c<2;c++)i[3*(o+1)+c]=.5*(-.15*t[3*n+c]+1.15*t[3*m+c]+1.15*t[3*a+c]+-.15*t[3*l+c]);i[3*(o+1)+2]=0}for(var A=0;A<4;A++)s[4*o+A]=e[4*m+A],s[4*(o+1)+A]=e[4*m+A];n=m,o+=2}for(var f=0;f<3;f++)i[3*o+f]=t[3*(r-1)+f];for(var d=0;d<4;d++)s[4*o+d]=e[4*(r-1)+d]}}],(i=null)&&x(e.prototype,i),s&&x(e,s),t}();function T(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var E=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e;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=i.texsizeX,this.texsizeY=i.texsizeY,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}var e,i,s;return e=t,s=[{key:"processWaveform",value:function(t,e){var i=[],s=e.wave_scale/128,r=e.wave_smoothing,a=s*(1-r);i.push(t[0]*s);for(var h=1;h<t.length;h++)i.push(t[h]*a+i[h-1]*r);return i}}],(i=[{key:"updateGlobals",value:function(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}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#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 }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(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 }")),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")}},{key:"generateWaveform",value:function(e,i,s,r,a){var h=a.wave_a,o=(a.bass+a.mid+a.treb)/3;if(o>-.01&&h>.001&&s.length>0){var n=t.processWaveform(s,a),l=t.processWaveform(r,a),m=Math.floor(a.wave_mode)%8,u=Math.floor(a.old_wave_mode)%8,g=2*a.wave_x-1,c=2*a.wave_y-1;this.numVert=0,this.oldNumVert=0;for(var A=e&&m!==u?2:1,f=0;f<A;f++){var d=0===f?m:u,v=a.wave_mystery;0!==d&&1!==d&&4!==d||!(v<-1||v>1)||(v=.5*v+.5,v-=Math.floor(v),v=2*(v=Math.abs(v))-1);var p=void 0,_=void 0,x=void 0;if(0===f?(_=this.positions,x=this.positions2):(_=this.oldPositions,x=this.oldPositions2),h=a.wave_a,0===d){if(a.modwavealphabyvolume>0){var T=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/T}h=Math.clamp(h,0,1);for(var E=1/((p=Math.floor(n.length/2)+1)-1),P=Math.floor((n.length-p)/2),R=0;R<p-1;R++){var L=.5+.4*l[R+P]+v,S=R*E*2*Math.PI+.2*a.time;if(R<p/10){var y=R/(.1*p);L=(1-(y=.5-.5*Math.cos(y*Math.PI)))*(.5+.4*l[R+p+P]+v)+L*y}_[3*R+0]=L*Math.cos(S)*this.aspecty+g,_[3*R+1]=L*Math.sin(S)*this.aspectx+c,_[3*R+2]=0}_[3*(p-1)+0]=_[0],_[3*(p-1)+1]=_[1],_[3*(p-1)+2]=0}else if(1===d){if(h*=1.25,a.modwavealphabyvolume>0){var w=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/w}h=Math.clamp(h,0,1),p=Math.floor(n.length/2);for(var U=0;U<p;U++){var M=.53+.43*l[U]+v,F=.5*n[U+32]*Math.PI+2.3*a.time;_[3*U+0]=M*Math.cos(F)*this.aspecty+g,_[3*U+1]=M*Math.sin(F)*this.aspectx+c,_[3*U+2]=0}}else if(2===d){if(this.texsizeX<1024?h*=.09:this.texsizeX>=1024&&this.texsizeX<2048?h*=.11:h*=.13,a.modwavealphabyvolume>0){var q=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/q}h=Math.clamp(h,0,1),p=n.length;for(var z=0;z<n.length;z++)_[3*z+0]=l[z]*this.aspecty+g,_[3*z+1]=n[(z+32)%n.length]*this.aspectx+c,_[3*z+2]=0}else if(3===d){if(this.texsizeX<1024?h*=.15:this.texsizeX>=1024&&this.texsizeX<2048?h*=.22:h*=.33,h*=1.3,h*=a.treb*a.treb,a.modwavealphabyvolume>0){var B=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/B}h=Math.clamp(h,0,1),p=n.length;for(var C=0;C<n.length;C++)_[3*C+0]=l[C]*this.aspecty+g,_[3*C+1]=n[(C+32)%n.length]*this.aspectx+c,_[3*C+2]=0}else if(4===d){if(a.modwavealphabyvolume>0){var D=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/D}h=Math.clamp(h,0,1),(p=n.length)>this.texsizeX/3&&(p=Math.floor(this.texsizeX/3));for(var V=1/p,I=Math.floor((n.length-p)/2),X=.45+.5*(.5*v+.5),k=1-X,N=0;N<p;N++){var O=2*N*V+(g-1)+.44*l[(N+25+I)%n.length],W=.47*n[N+I]+c;N>1&&(O=O*k+X*(2*_[3*(N-1)+0]-_[3*(N-2)+0]),W=W*k+X*(2*_[3*(N-1)+1]-_[3*(N-2)+1])),_[3*N+0]=O,_[3*N+1]=W,_[3*N+2]=0}}else if(5===d){if(this.texsizeX<1024?h*=.09:this.texsizeX>=1024&&this.texsizeX<2048?h*=.11:h*=.13,a.modwavealphabyvolume>0){var Q=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/Q}h=Math.clamp(h,0,1);var Y=Math.cos(.3*a.time),G=Math.sin(.3*a.time);p=n.length;for(var H=0;H<n.length;H++){var j=(H+32)%n.length,K=l[H]*n[j]+n[H]*l[j],J=l[H]*l[H]-n[j]*n[j];_[3*H+0]=(K*Y-J*G)*(this.aspecty+g),_[3*H+1]=(K*G+J*Y)*(this.aspectx+c),_[3*H+2]=0}}else if(6===d||7===d){if(a.modwavealphabyvolume>0){var Z=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/Z}h=Math.clamp(h,0,1),(p=Math.floor(n.length/2))>this.texsizeX/3&&(p=Math.floor(this.texsizeX/3));for(var $=Math.floor((n.length-p)/2),tt=.5*Math.PI*v,et=Math.cos(tt),it=Math.sin(tt),st=[g*Math.cos(tt+.5*Math.PI)-3*et,g*Math.cos(tt+.5*Math.PI)+3*et],rt=[g*Math.sin(tt+.5*Math.PI)-3*it,g*Math.sin(tt+.5*Math.PI)+3*it],at=0;at<2;at++)for(var ht=0;ht<4;ht++){var ot=void 0,nt=!1;switch(ht){case 0:st[at]>1.1&&(ot=(1.1-st[1-at])/(st[at]-st[1-at]),nt=!0);break;case 1:st[at]<-1.1&&(ot=(-1.1-st[1-at])/(st[at]-st[1-at]),nt=!0);break;case 2:rt[at]>1.1&&(ot=(1.1-rt[1-at])/(rt[at]-rt[1-at]),nt=!0);break;case 3:rt[at]<-1.1&&(ot=(-1.1-rt[1-at])/(rt[at]-rt[1-at]),nt=!0)}if(nt){var lt=st[at]-st[1-at],mt=rt[at]-rt[1-at];st[at]=st[1-at]+lt*ot,rt[at]=rt[1-at]+mt*ot}}et=(st[1]-st[0])/p,it=(rt[1]-rt[0])/p;var ut=Math.atan2(it,et),gt=Math.cos(ut+.5*Math.PI),ct=Math.sin(ut+.5*Math.PI);if(6===d)for(var At=0;At<p;At++){var ft=n[At+$];_[3*At+0]=st[0]+et*At+.25*gt*ft,_[3*At+1]=rt[0]+it*At+.25*ct*ft,_[3*At+2]=0}else if(7===d){for(var dt=Math.pow(.5*c+.5,2),vt=0;vt<p;vt++){var pt=n[vt+$];_[3*vt+0]=st[0]+et*vt+gt*(.25*pt+dt),_[3*vt+1]=rt[0]+it*vt+ct*(.25*pt+dt),_[3*vt+2]=0}for(var _t=0;_t<p;_t++){var xt=l[_t+$];x[3*_t+0]=st[0]+et*_t+gt*(.25*xt-dt),x[3*_t+1]=rt[0]+it*_t+ct*(.25*xt-dt),x[3*_t+2]=0}}}0===f?(this.positions=_,this.positions2=x,this.numVert=p,this.alpha=h):(this.oldPositions=_,this.oldPositions2=x,this.oldNumVert=p,this.oldAlpha=h)}var bt=.5-.5*Math.cos(i*Math.PI),Tt=1-bt;this.oldNumVert>0&&(h=bt*this.alpha+Tt*this.oldAlpha);var Et=Math.clamp(a.wave_r,0,1),Pt=Math.clamp(a.wave_g,0,1),Rt=Math.clamp(a.wave_b,0,1);if(0!==a.wave_brighten){var Lt=Math.max(Et,Pt,Rt);Lt>.01&&(Et/=Lt,Pt/=Lt,Rt/=Lt)}if(this.color=[Et,Pt,Rt,h],this.oldNumVert>0)if(7===m){for(var St=(this.oldNumVert-1)/(2*this.numVert),yt=0;yt<this.numVert;yt++){var wt=yt*St,Ut=Math.floor(wt),Mt=wt-Ut,Ft=this.oldPositions[3*Ut+0]*(1-Mt)+this.oldPositions[3*(Ut+1)+0]*Mt,qt=this.oldPositions[3*Ut+1]*(1-Mt)+this.oldPositions[3*(Ut+1)+1]*Mt;this.positions[3*yt+0]=this.positions[3*yt+0]*bt+Ft*Tt,this.positions[3*yt+1]=this.positions[3*yt+1]*bt+qt*Tt,this.positions[3*yt+2]=0}for(var zt=0;zt<this.numVert;zt++){var Bt=(zt+this.numVert)*St,Ct=Math.floor(Bt),Dt=Bt-Ct,Vt=this.oldPositions[3*Ct+0]*(1-Dt)+this.oldPositions[3*(Ct+1)+0]*Dt,It=this.oldPositions[3*Ct+1]*(1-Dt)+this.oldPositions[3*(Ct+1)+1]*Dt;this.positions2[3*zt+0]=this.positions2[3*zt+0]*bt+Vt*Tt,this.positions2[3*zt+1]=this.positions2[3*zt+1]*bt+It*Tt,this.positions2[3*zt+2]=0}}else if(7===u){for(var Xt=this.numVert/2,kt=(this.oldNumVert-1)/Xt,Nt=0;Nt<Xt;Nt++){var Ot=Nt*kt,Wt=Math.floor(Ot),Qt=Ot-Wt,Yt=this.oldPositions[3*Wt+0]*(1-Qt)+this.oldPositions[3*(Wt+1)+0]*Qt,Gt=this.oldPositions[3*Wt+1]*(1-Qt)+this.oldPositions[3*(Wt+1)+1]*Qt;this.positions[3*Nt+0]=this.positions[3*Nt+0]*bt+Yt*Tt,this.positions[3*Nt+1]=this.positions[3*Nt+1]*bt+Gt*Tt,this.positions[3*Nt+2]=0}for(var Ht=0;Ht<Xt;Ht++){var jt=Ht*kt,Kt=Math.floor(jt),Jt=jt-Kt,Zt=this.oldPositions2[3*Kt+0]*(1-Jt)+this.oldPositions2[3*(Kt+1)+0]*Jt,$t=this.oldPositions2[3*Kt+1]*(1-Jt)+this.oldPositions2[3*(Kt+1)+1]*Jt;this.positions2[3*Ht+0]=this.positions[3*(Ht+Xt)+0]*bt+Zt*Tt,this.positions2[3*Ht+1]=this.positions[3*(Ht+Xt)+1]*bt+$t*Tt,this.positions2[3*Ht+2]=0}}else for(var te=(this.oldNumVert-1)/this.numVert,ee=0;ee<this.numVert;ee++){var ie=ee*te,se=Math.floor(ie),re=ie-se,ae=this.oldPositions[3*se+0]*(1-re)+this.oldPositions[3*(se+1)+0]*re,he=this.oldPositions[3*se+1]*(1-re)+this.oldPositions[3*(se+1)+1]*re;this.positions[3*ee+0]=this.positions[3*ee+0]*bt+ae*Tt,this.positions[3*ee+1]=this.positions[3*ee+1]*bt+he*Tt,this.positions[3*ee+2]=0}for(var oe=0;oe<this.numVert;oe++)this.positions[3*oe+1]=-this.positions[3*oe+1];if(this.smoothedNumVert=2*this.numVert-1,b.smoothWave(this.positions,this.smoothedPositions,this.numVert),7===m||7===u){for(var ne=0;ne<this.numVert;ne++)this.positions2[3*ne+1]=-this.positions2[3*ne+1];b.smoothWave(this.positions2,this.smoothedPositions2,this.numVert)}return!0}return!1}},{key:"drawBasicWaveform",value:function(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);var a=1;0===r.wave_thick&&0===r.wave_dots||(a=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);for(var h=0!==r.wave_dots?this.gl.POINTS:this.gl.LINE_STRIP,o=0;o<a;o++){0===o?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===o?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===o?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===o&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(h,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(var n=0;n<a;n++){0===n?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===n?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===n?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===n&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(h,0,this.smoothedNumVert)}}}}}])&&T(e.prototype,i),s&&T(e,s),t}();function P(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var R=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.index=e,this.gl=i;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=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.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(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}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#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 }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(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 }")),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")}},{key:"generateWaveform",value:function(t,e,i,s,r,a,h,o){if(0!==h.baseVals.enabled&&t.length>0){var n=Object.assign({},a.mdVSWaves[this.index],a.mdVSFrameMapWaves[this.index],a.mdVSQAfterFrame,a.mdVSTWaveInits[this.index],r),l=h.frame_eqs(n);Object.prototype.hasOwnProperty.call(l,"samples")?this.samples=l.samples:this.samples=512,this.samples>512&&(this.samples=512),this.samples=Math.floor(this.samples);var m=Math.floor(l.sep),u=l.scaling,g=l.spectrum,A=l.smoothing,f=l.usedots,d=l.r,v=l.g,p=l.b,_=l.a,x=a.mdVS.wave_scale;if(this.samples-=m,this.samples>=2||0!==f&&this.samples>=1){var T=0!==g,E=(T?.15:.004)*u*x,P=T?i:t,R=T?s:e,L=T?0:Math.floor((512-this.samples)/2-m/2),S=T?0:Math.floor((512-this.samples)/2+m/2),y=T?(512-m)/this.samples:1,w=Math.pow(.98*A,.5),U=1-w;this.pointsData[0][0]=P[L],this.pointsData[1][0]=R[S];for(var M=1;M<this.samples;M++){var F=P[Math.floor(M*y+L)],q=R[Math.floor(M*y+S)];this.pointsData[0][M]=F*U+this.pointsData[0][M-1]*w,this.pointsData[1][M]=q*U+this.pointsData[1][M-1]*w}for(var z=this.samples-2;z>=0;z--)this.pointsData[0][z]=this.pointsData[0][z]*U+this.pointsData[0][z+1]*w,this.pointsData[1][z]=this.pointsData[1][z]*U+this.pointsData[1][z+1]*w;for(var B=0;B<this.samples;B++)this.pointsData[0][B]*=E,this.pointsData[1][B]*=E;for(var C=0;C<this.samples;C++){var D=this.pointsData[0][C],V=this.pointsData[1][C];l.sample=C/(this.samples-1),l.value1=D,l.value2=V,l.x=.5+D,l.y=.5+V,l.r=d,l.g=v,l.b=p,l.a=_,""!==h.point_eqs&&(l=h.point_eqs(l));var I=(2*l.x-1)*this.invAspectx,X=(-2*l.y+1)*this.invAspecty,k=l.r,N=l.g,O=l.b,W=l.a;this.positions[3*C+0]=I,this.positions[3*C+1]=X,this.positions[3*C+2]=0,this.colors[4*C+0]=k,this.colors[4*C+1]=N,this.colors[4*C+2]=O,this.colors[4*C+3]=W*o}var Q=a.mdVSUserKeysWaves[this.index],Y=c.pick(l,Q);return a.mdVSFrameMapWaves[this.index]=Y,this.mdVSWaveFrame=l,0===f&&b.smoothWaveAndColor(this.positions,this.colors,this.smoothedPositions,this.smoothedColors,this.samples),!0}}return!1}},{key:"drawCustomWaveform",value:function(t,e,i,s,r,a,h,o){if(o&&this.generateWaveform(e,i,s,r,a,h,o,t)){this.gl.useProgram(this.shaderProgram);var n,l,m,u=0!==this.mdVSWaveFrame.usedots,g=0!==this.mdVSWaveFrame.thick,c=0!==this.mdVSWaveFrame.additive;u?(n=this.positions,l=this.colors,m=this.samples):(n=this.smoothedPositions,l=this.smoothedColors,m=2*this.samples-1),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,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,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation);var A=1;u?g?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),g&&(A=4)),c?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);for(var f=u?this.gl.POINTS:this.gl.LINE_STRIP,d=0;d<A;d++){0===d?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===d?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===d?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===d&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(f,0,m)}}}}])&&P(e.prototype,i),s&&P(e,s),t}();function L(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var S=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.index=e,this.gl=i;this.positions=new Float32Array(309),this.colors=new Float32Array(412),this.uvs=new Float32Array(206),this.borderPositions=new Float32Array(306),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.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.uvVertexBuf=this.gl.createBuffer(),this.borderPositionVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.createBorderShader(),this.mainSampler=this.gl.createSampler(),i.samplerParameteri(this.mainSampler,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR),i.samplerParameteri(this.mainSampler,i.TEXTURE_MAG_FILTER,i.LINEAR),i.samplerParameteri(this.mainSampler,i.TEXTURE_WRAP_S,i.REPEAT),i.samplerParameteri(this.mainSampler,i.TEXTURE_WRAP_T,i.REPEAT)}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(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}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#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 }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(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 }")),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")}},{key:"createBorderShader",value:function(){this.borderShaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#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 }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(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 }")),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")}},{key:"drawCustomShape",value:function(t,e,i,s,r){if(0!==s.baseVals.enabled){this.setupShapeBuffers(i.mdVSFrame);for(var a=Object.assign({},i.mdVSShapes[this.index],i.mdVSFrameMapShapes[this.index],i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index],e),h=c.cloneVars(a),o=Math.clamp(a.num_inst,1,1024),n=0;n<o;n++){a.instance=n,a.x=h.x,a.y=h.y,a.rad=h.rad,a.ang=h.ang,a.r=h.r,a.g=h.g,a.b=h.b,a.a=h.a,a.r2=h.r2,a.g2=h.g2,a.b2=h.b2,a.a2=h.a2,a.border_r=h.border_r,a.border_g=h.border_g,a.border_b=h.border_b,a.border_a=h.border_a,a.thickoutline=h.thickoutline,a.textured=h.textured,a.tex_zoom=h.tex_zoom,a.tex_ang=h.tex_ang,a.additive=h.additive;var l=s.frame_eqs(a),m=l.sides;m=Math.clamp(m,3,100),m=Math.floor(m);var u=l.rad,g=l.ang,A=2*l.x-1,f=-2*l.y+1,d=l.r,v=l.g,p=l.b,_=l.a,x=l.r2,b=l.g2,T=l.b2,E=l.a2,P=l.border_r,R=l.border_g,L=l.border_b,S=l.border_a;this.borderColor=[P,R,L,S*t];var y=l.thickoutline,w=l.textured,U=l.tex_zoom,M=l.tex_ang,F=l.additive,q=this.borderColor[3]>0,z=Math.abs(w)>=1,B=Math.abs(y)>=1,C=Math.abs(F)>=1;this.positions[0]=A,this.positions[1]=f,this.positions[2]=0,this.colors[0]=d,this.colors[1]=v,this.colors[2]=p,this.colors[3]=_*t,z&&(this.uvs[0]=.5,this.uvs[1]=.5);for(var D=.25*Math.PI,V=1;V<=m+1;V++){var I=2*((V-1)/m)*Math.PI,X=I+g+D;if(this.positions[3*V+0]=A+u*Math.cos(X)*this.aspecty,this.positions[3*V+1]=f+u*Math.sin(X),this.positions[3*V+2]=0,this.colors[4*V+0]=x,this.colors[4*V+1]=b,this.colors[4*V+2]=T,this.colors[4*V+3]=E*t,z){var k=I+M+D;this.uvs[2*V+0]=.5+.5*Math.cos(k)/U*this.aspecty,this.uvs[2*V+1]=.5+.5*Math.sin(k)/U}q&&(this.borderPositions[3*(V-1)+0]=this.positions[3*V+0],this.borderPositions[3*(V-1)+1]=this.positions[3*V+1],this.borderPositions[3*(V-1)+2]=this.positions[3*V+2])}this.mdVSShapeFrame=l,this.drawCustomShapeInstance(r,m,z,q,B,C)}var N=i.mdVSUserKeysShapes[this.index],O=c.pick(this.mdVSShapeFrame,N);i.mdVSFrameMapShapes[this.index]=O}}},{key:"setupShapeBuffers",value:function(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);var e=0!==t.wrap?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)}},{key:"drawCustomShapeInstance",value:function(t,e,i,s,r,a){this.gl.useProgram(this.shaderProgram);var h=new Float32Array(this.positions.buffer,0,3*(e+2));this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,h),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation);var o=new Float32Array(this.colors.buffer,0,4*(e+2));if(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,o),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),i){var n=new Float32Array(this.uvs.buffer,0,2*(e+2));this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,n),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation)}if(this.gl.uniform1f(this.texturedLoc,i?1:0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),a?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,e+2),s){this.gl.useProgram(this.borderShaderProgram);var l=new Float32Array(this.borderPositions.buffer,0,3*(e+1));this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,l),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc),this.gl.uniform4fv(this.uBorderColorLoc,this.borderColor);for(var m=r?4:1,u=0;u<m;u++){0===u?this.gl.uniform2fv(this.thickOffsetL