diff --git a/assets/index-373f6d0c.js b/assets/index-b1eec9e9.js
similarity index 97%
rename from assets/index-373f6d0c.js
rename to assets/index-b1eec9e9.js
index 949c290..3005006 100644
--- a/assets/index-373f6d0c.js
+++ b/assets/index-b1eec9e9.js
@@ -571,7 +571,7 @@ To change the tempo, use the bpm(number) function. The transport is con
Let's study two very simple rhythmic functions, mod(n: ...number[]) and onbeat(...n:number[]). They are both easy to understand and powerful enough to get you to play your first rhythms.
-- beat(...n: number[]): this function will return true every _n_ beats. The value 1 will return true at the beginning of each beat. Floating point numbers like 0.5 or 0.25 are also accepted. Multiple values can be passed to beat to generate more complex rhythms.
+- beat(...n: number[]): return true every _n_ beats. The value 1 will return true at the beginning of each beat. Floating point numbers like 0.5 or 0.25 are also accepted. Multiple values can be passed to beat to generate more complex rhythms.
${e("Using different mod values",`
// This code is alternating between different mod values
@@ -594,7 +594,6 @@ flip(3) :: beat(1/6) :: blip(800).pan(r(0,1)).out();
beat([1,0.75].beat(2)) :: blip([50, 100].beat(2)).pan(r(0,1)).out();
`,!1)}
-
- pulse(...n: number[]): faster version of the beat function. Instead of returning true for every beat, this function is returning true every _n_ clock ticks! It can be used to generate very unexpected rhythms.
${e("Intriguing rhythms",`
@@ -609,6 +608,14 @@ pulse([48, 24, 16].beat(4)) :: sound('linnhats').out()
beat(1)::snd(['bd', '808oh'].beat(1)).out()
`,!1)};
+- bar(...n: number[]): return true every _n_ bars.
+
+${e("Four beats per bar: proof",`
+bar(1)::sound('kick').out()
+beat(1)::sound('hat').speed(2).out()
+`,!0)}
+
+
- onbeat(...n: number[]): The onbeat function allows you to lock on to a specific beat from the clock to execute code. It can accept multiple arguments. It's usage is very straightforward and not hard to understand. You can pass either integers or floating point numbers. By default, topos is using a 4/4 bar meaning that you can target any of these beats (or in-between) with this function.
${e("Some simple yet detailed rhythms",`
@@ -2599,7 +2606,7 @@ I won't teach you how to play with Hydra. You can find some great resources on t
`+c.line+" | "+_+`
`+m+" | "+t("",l.column-1," ")+t("",I,"^")}else s+=`
at `+u}return s},e.buildMessage=function(i,s){var a={literal:function(_){return'"'+l(_.text)+'"'},class:function(_){var v=_.parts.map(function(I){return Array.isArray(I)?c(I[0])+"-"+c(I[1]):c(I)});return"["+(_.inverted?"^":"")+v.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(_){return _.description}};function o(_){return _.charCodeAt(0).toString(16).toUpperCase()}function l(_){return _.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(v){return"\\x0"+o(v)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(v){return"\\x"+o(v)})}function c(_){return _.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(v){return"\\x0"+o(v)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(v){return"\\x"+o(v)})}function u(_){return a[_.type](_)}function p(_){var v=_.map(u),I,R;if(v.sort(),v.length>0){for(I=1,R=1;I",R="@",x=":",$="/",Z="(",f=")",E="[:",S="]",N="[",k="{",L="}",M="+",G="*",te="%",re="^",ne="&",ee=">>",B="<<",Q="_",j="?",K="!",ue="r",le="#",Ee="b",De="iii",xe="ii",be="iv",Ne="i",ce="vii",Le="vi",Xe="v",Be=/^[0-9]/,tt=/^[ \n\r\t]/,rt=/^[a-z]/,ft=/^[a-z_]/,vt=/^[a-z_0-9]/,mt=/^[mklpdcwyhnqaefsxtgujzo]/,At=/^[a-zA-Z0-9]/,Nt=/^[a-zA-Z0-9\-*+]/,Rn=/^[A-G]/,qe=/^[bs]/,rn=st("-",!1),Ze=Kn([["0","9"]],!1,!1),ke=st(".",!1),en=Hs("whitespace"),Zt=Kn([" ",`
-`,"\r"," "],!1,!1),an=st(",",!1),H=st("|",!1),he=Kn([["a","z"]],!1,!1),Ie=Kn([["a","z"],"_"],!1,!1),we=Kn([["a","z"],"_",["0","9"]],!1,!1),Je=st("<",!1),ye=st(">",!1),Ht=st("@",!1),lt=st(":",!1),yt=Kn(["m","k","l","p","d","c","w","y","h","n","q","a","e","f","s","x","t","g","u","j","z","o"],!1,!1),zn=st("/",!1),dt=st("(",!1),Kt=st(")",!1),Tt=st("[:",!1),Ue=st("]",!1),Fn=st("[",!1),Yr=st("{",!1),ct=st("}",!1),Hn=st("+",!1),Nn=st("*",!1),Ii=st("%",!1),wn=st("^",!1),Wt=st("&",!1),yr=st(">>",!1),ta=st("<<",!1),li=st("_",!1),na=st("?",!1),cr=st("!",!1),ci=st("r",!1),Ar=Kn([["a","z"],["A","Z"],["0","9"]],!1,!1),jt=st("#",!1),ui=st("b",!1),di=Kn([["a","z"],["A","Z"],["0","9"],"-","*","+"],!1,!1),q=Kn([["A","G"]],!1,!1),ie=Kn(["b","s"],!1,!1),de=st("iii",!1),_e=st("ii",!1),Ae=st("iv",!1),Qe=st("i",!1),Me=st("vii",!1),Ct=st("vi",!1),Dn=st("v",!1),Wn=function(T){return T.filter(w=>w)},Da=function(){return parseFloat($n())},ra=function(){return parseInt($n())},xs=function(){return parseInt($n())},Xn=function(){},ks=function(T){return Ut(n3,{sound:T})},xa=function(){return $n()},ka=function(T){return Ut(Ro,{items:T})},Ls=function(T){return T},La=function(T,w){return Ut(r3,{item:T,sound:w})},Ms=function(T,w){return Ut(i3,{item:T,soundIndex:w})},Ma=function(T){return T},Yn=function(){return VP[$n()]},Ps=function(T,w){return T/w},Bs=function(T){return T.filter(w=>w)},Pa=function(T){return Ut(Ro,{items:T})},Ba=function(T,w){return w?Ut(OE,{item:T,times:w}):Ut(EE,{items:T})},Us=function(T){return T},Ua=function(T,w,P){return Ut(c3,{left:T,operation:w,right:P})},Fs=function(T,w){return Ut(l3,{items:T,times:w})},Fa=function(T){return Ut(RI,{items:T})},Ys=function(T){return T.map(w=>typeof w=="number"?w:void 0)},$s=function(){return Math.ceil(AI($n()))},ur=function(T){var w=T.filter(P=>P).map(P=>Ut(ni,{pitch:P[0]},P.toString()));return Ut(EE,{items:w})},Ot=function(T){return T},Gs=function(T){return T},Ri=function(){},Qs=function(T){return Ut(Ro,{items:T})},pi=function(T){return Ut(s3,{octave:T})},qs=function(){return $n().split("").reduce((T,w)=>T+(w==="^"?1:-1),0)},Ni=function(){return Ut(Pc,{seededRandom:s.seededRandom})},Ya=function(T,w){return Ut(Pc,{min:T,max:w,seededRandom:s.seededRandom})},$a=function(T,w){return Ut(OE,{item:T,times:w})},Vs=function(T){return Ut(o3,{duration:T})},wi=function(T){return T},Ga=function(T){return Ut(qm,{duration:T})},Di=function(T,w,P,X){const oe=T?s.nodeOptions.octave+T:s.nodeOptions.octave;return Ut(ni,{duration:w,pitch:X,pitchOctave:oe,add:P})},xi=function(T){return T.reduce((w,P)=>w+(P==="#"?1:-1),0)},Qa=function(T,w,P){return Ut(Ra,{pitches:[T].concat(w),inversion:P})},ia=function(){return $n()},hi=function(T){return T},gn=function(){return $n()},qa=function(T,w,P,X,oe){const ve=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",ht=s.nodeOptions.key?s.nodeOptions.key:"C",hr=S3(X,P,ve,T,w),Ks=w||s.nodeOptions.duration,vR=T?s.nodeOptions.octave+T:s.nodeOptions.octave;return Ut(Ra,{duration:Ks,chordOctave:vR,pitches:hr,chordName:X,inversion:oe,scaleName:ve,key:ht})},Zn=function(T,w,P){const X=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",oe=s.nodeOptions.key?s.nodeOptions.key:"C";return Ut(a3,{roman:T,chordName:w,inversion:P,scaleName:X,key:oe})},aa=function(T){const w=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",P=s.nodeOptions.key?s.nodeOptions.key:"C",X=I3(T,P,w);return Ut(ni,{pitch:X.pc,add:X.add,scaleName:w,key:P})},A=0,He=0,Va=[{line:1,column:1}],dr=0,zs=[],Oe=0,ge={},sa;if("startRule"in s){if(!(s.startRule in l))throw new Error(`Can't start parsing from rule "`+s.startRule+'".');c=l[s.startRule]}function $n(){return i.substring(He,A)}function ul(){return d(He,A)}function st(T,w){return{type:"literal",text:T,ignoreCase:w}}function Kn(T,w,P){return{type:"class",parts:T,inverted:w,ignoreCase:P}}function dl(){return{type:"end"}}function Hs(T){return{type:"other",description:T}}function pl(T){var w=Va[T],P;if(w)return w;for(P=T-1;!Va[P];)P--;for(w=Va[P],w={line:w.line,column:w.column};Pdr&&(dr=A,zs=[]),zs.push(T))}function g(T,w,P){return new e(e.buildMessage(T,w),T,w,P)}function O(){var T,w,P=A*56+0,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=Xt(),w!==a&&(He=T,w=Wn(w)),T=w,ge[P]={nextPos:A,result:T},T)}function C(){var T,w,P,X,oe,ve,ht,hr=A*56+1,Ks=ge[hr];if(Ks)return A=Ks.nextPos,Ks.result;for(T=A,w=A,i.charCodeAt(A)===45?(P=u,A++):(P=a,Oe===0&&h(rn)),P===a&&(P=null),X=[],Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze));oe!==a;)X.push(oe),Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze));if(i.charCodeAt(A)===46?(oe=p,A++):(oe=a,Oe===0&&h(ke)),oe!==a){if(ve=[],Be.test(i.charAt(A))?(ht=i.charAt(A),A++):(ht=a,Oe===0&&h(Ze)),ht!==a)for(;ht!==a;)ve.push(ht),Be.test(i.charAt(A))?(ht=i.charAt(A),A++):(ht=a,Oe===0&&h(Ze));else ve=a;ve!==a?(P=[P,X,oe,ve],w=P):(A=w,w=a)}else A=w,w=a;if(w===a)if(w=A,i.charCodeAt(A)===46?(P=p,A++):(P=a,Oe===0&&h(ke)),P!==a){if(X=[],Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze)),oe!==a)for(;oe!==a;)X.push(oe),Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze));else X=a;X!==a?(P=[P,X],w=P):(A=w,w=a)}else A=w,w=a;return w!==a&&(He=T,w=Da()),T=w,ge[hr]={nextPos:A,result:T},T}function y(){var T,w,P=A*56+2,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,i.charCodeAt(A)===45?A++:Oe===0&&h(rn),Be.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(Ze)),w!==a?(He=T,T=ra()):(A=T,T=a),ge[P]={nextPos:A,result:T},T)}function D(){var T,w,P,X=A*56+3,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,i.charCodeAt(A)===45?A++:Oe===0&&h(rn),w=[],Be.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(Ze)),P!==a)for(;P!==a;)w.push(P),Be.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(Ze));else w=a;return w!==a?(He=T,T=xs()):(A=T,T=a),ge[X]={nextPos:A,result:T},T}function F(){var T,w,P=A*56+4,X=ge[P];return X?(A=X.nextPos,X.result):(Oe++,T=A,tt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(Zt)),w!==a&&(He=T,w=Xn()),T=w,Oe--,T===a&&(w=a,Oe===0&&h(en)),ge[P]={nextPos:A,result:T},T)}function U(){var T,w,P=A*56+8,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=W(),w!==a&&(He=T,w=ks(w)),T=w,ge[P]={nextPos:A,result:T},T)}function W(){var T,w,P,X,oe,ve=A*56+10,ht=ge[ve];if(ht)return A=ht.nextPos,ht.result;if(T=A,rt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(he)),w!==a){if(P=[],ft.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(Ie)),X!==a)for(;X!==a;)P.push(X),ft.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(Ie));else P=a;if(P!==a){for(X=[],vt.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(we));oe!==a;)X.push(oe),vt.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(we));He=T,T=xa()}else A=T,T=a}else A=T,T=a;return ge[ve]={nextPos:A,result:T},T}function z(){var T,w=A*56+11,P=ge[w];return P?(A=P.nextPos,P.result):(T=pe(),T===a&&(T=fe()),ge[w]={nextPos:A,result:T},T)}function pe(){var T,w,P,X,oe=A*56+12,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,i.charCodeAt(A)===60?(w=v,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=z(),X!==a)for(;X!==a;)P.push(X),X=z();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(He=T,T=ka(P)):(A=T,T=a)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function fe(){var T,w=A*56+13,P=ge[w];return P?(A=P.nextPos,P.result):(T=W(),T===a&&(T=pe(),T===a&&(T=F())),ge[w]={nextPos:A,result:T},T)}function se(){var T,w,P,X=A*56+14,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===64?(w=R,A++):(w=a,Oe===0&&h(Ht)),w!==a?(P=z(),P!==a?(He=T,T=Ls(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function ae(){var T,w=A*56+15,P=ge[w];return P?(A=P.nextPos,P.result):(T=sn(),T===a&&(T=it(),T===a&&(T=qt(),T===a&&(T=lu(),T===a&&(T=Qt())))),ge[w]={nextPos:A,result:T},T)}function Ce(){var T,w,P,X=A*56+16,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,w=ae(),w===a&&(w=Zs()),w!==a?(P=se(),P!==a?(He=T,T=La(w,P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function Se(){var T,w,P,X=A*56+17,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,w=Ce(),w===a&&(w=ae(),w===a&&(w=Zs())),w!==a?(P=Ve(),P!==a?(He=T,T=Ms(w,P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function Ve(){var T,w,P,X=A*56+18,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===58?(w=x,A++):(w=a,Oe===0&&h(lt)),w!==a?(P=wt(),P!==a?(He=T,T=Ma(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function je(){var T,w,P=A*56+19,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,mt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(yt)),w!==a&&(He=T,w=Yn()),T=w,ge[P]={nextPos:A,result:T},T)}function Fe(){var T,w=A*56+20,P=ge[w];return P?(A=P.nextPos,P.result):(T=It(),T===a&&(T=C(),T===a&&(T=je())),ge[w]={nextPos:A,result:T},T)}function It(){var T,w,P,X,oe=A*56+21,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,w=D(),w!==a?(i.charCodeAt(A)===47?(P=$,A++):(P=a,Oe===0&&h(zn)),P!==a?(X=D(),X!==a?(He=T,T=Ps(w,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function Xt(){var T,w,P,X=A*56+22,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],P=C_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=sn(),P===a&&(P=qt(),P===a&&(P=it(),P===a&&(P=Qt(),P===a&&(P=Zs(),P===a&&(P=lu())))))))),P!==a)for(;P!==a;)w.push(P),P=C_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=sn(),P===a&&(P=qt(),P===a&&(P=it(),P===a&&(P=Qt(),P===a&&(P=Zs(),P===a&&(P=lu()))))))));else w=a;return w!==a&&(He=T,w=Bs(w)),T=w,ge[X]={nextPos:A,result:T},T}function wt(){var T,w=A*56+23,P=ge[w];return P?(A=P.nextPos,P.result):(T=F(),T===a&&(T=D(),T===a&&(T=T_(),T===a&&(T=uu(),T===a&&(T=tn(),T===a&&(T=b_()))))),ge[w]={nextPos:A,result:T},T)}function tn(){var T,w,P,X,oe=A*56+24,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,i.charCodeAt(A)===60?(w=v,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=wt(),X!==a)for(;X!==a;)P.push(X),X=wt();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(He=T,T=Pa(P)):(A=T,T=a)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function it(){var T,w,P,X,oe,ve=A*56+25,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,i.charCodeAt(A)===40?(w=Z,A++):(w=a,Oe===0&&h(dt)),w!==a?(i.charCodeAt(A)===58?A++:Oe===0&&h(lt),P=Xt(),P!==a?(X=pt(),X===a&&(X=null),i.charCodeAt(A)===41?(oe=f,A++):(oe=a,Oe===0&&h(Kt)),oe!==a?(He=T,T=Ba(P,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function pt(){var T,w,P,X=A*56+26,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===58?(w=x,A++):(w=a,Oe===0&&h(lt)),w!==a?(P=D(),P!==a?(He=T,T=Us(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function sn(){var T,w,P,X,oe=A*56+27,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,w=it(),w!==a?(P=v_(),P!==a?(X=it(),X!==a?(He=T,T=Ua(w,P,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function Qt(){var T,w,P,X,oe,ve=A*56+28,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,i.substr(A,2)===E?(w=E,A+=2):(w=a,Oe===0&&h(Tt)),w!==a?(P=Xt(),P!==a?(X=pt(),X===a&&(X=null),i.charCodeAt(A)===93?(oe=S,A++):(oe=a,Oe===0&&h(Ue)),oe!==a?(He=T,T=Fs(P,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function qt(){var T,w,P,X,oe=A*56+29,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===91?(w=N,A++):(w=a,Oe===0&&h(Fn)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===93?(X=S,A++):(X=a,Oe===0&&h(Ue)),X!==a?(He=T,T=Fa(P)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function pr(){var T,w=A*56+30,P=ge[w];return P?(A=P.nextPos,P.result):(T=D(),T===a&&(T=y()),ge[w]={nextPos:A,result:T},T)}function Ws(){var T,w,P,X=A*56+31,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],P=hl(),P===a&&(P=pr()),P!==a)for(;P!==a;)w.push(P),P=hl(),P===a&&(P=pr());else w=a;return w!==a&&(He=T,w=Ys(w)),T=w,ge[X]={nextPos:A,result:T},T}function hl(){var T,w,P,X,oe=A*56+32,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===40?A++:Oe===0&&h(dt),w=pr(),w!==a?(P=v_(),P!==a?(X=Ws(),X!==a?(i.charCodeAt(A)===41?A++:Oe===0&&h(Kt),He=T,T=$s()):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function Xs(){var T,w,P,X,oe=A*56+33,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Yr)),w!==a){if(P=[],X=Ws(),X===a&&(X=F()),X!==a)for(;X!==a;)P.push(X),X=Ws(),X===a&&(X=F());else P=a;P!==a?(i.charCodeAt(A)===125?(X=L,A++):(X=a,Oe===0&&h(ct)),X!==a?(He=T,T=ur(P)):(A=T,T=a)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function b_(){var T,w,P,X,oe=A*56+34,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Yr)),w!==a?(P=D(),P===a&&(P=uu()),P!==a?(i.charCodeAt(A)===125?(X=L,A++):(X=a,Oe===0&&h(ct)),X!==a?(He=T,T=Ot(P)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function v_(){var T,w=A*56+35,P=ge[w];return P?(A=P.nextPos,P.result):(i.charCodeAt(A)===43?(T=M,A++):(T=a,Oe===0&&h(Hn)),T===a&&(i.charCodeAt(A)===45?(T=u,A++):(T=a,Oe===0&&h(rn)),T===a&&(i.charCodeAt(A)===42?(T=G,A++):(T=a,Oe===0&&h(Nn)),T===a&&(i.charCodeAt(A)===47?(T=$,A++):(T=a,Oe===0&&h(zn)),T===a&&(i.charCodeAt(A)===37?(T=te,A++):(T=a,Oe===0&&h(Ii)),T===a&&(i.charCodeAt(A)===94?(T=re,A++):(T=a,Oe===0&&h(wn)),T===a&&(i.charCodeAt(A)===124?(T=_,A++):(T=a,Oe===0&&h(H)),T===a&&(i.charCodeAt(A)===38?(T=ne,A++):(T=a,Oe===0&&h(Wt)),T===a&&(i.substr(A,2)===ee?(T=ee,A+=2):(T=a,Oe===0&&h(yr)),T===a&&(i.substr(A,2)===B?(T=B,A+=2):(T=a,Oe===0&&h(ta))))))))))),ge[w]={nextPos:A,result:T},T)}function Zs(){var T,w,P=A*56+36,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=gR(),w===a&&(w=ER(),w===a&&(w=OR(),w===a&&(w=bR(),w===a&&(w=U(),w===a&&(w=SR(),w===a&&(w=fl(),w===a&&(w=hR(),w===a&&(w=F(),w===a&&(w=fR(),w===a&&(w=it(),w===a&&(w=Xs(),w===a&&(w=pR())))))))))))),w!==a&&(He=T,w=Gs(w)),T=w,ge[P]={nextPos:A,result:T},T)}function pR(){var T,w,P=A*56+37,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,i.charCodeAt(A)===124?(w=_,A++):(w=a,Oe===0&&h(H)),w!==a&&(He=T,w=Ri()),T=w,ge[P]={nextPos:A,result:T},T)}function lu(){var T,w,P,X,oe=A*56+38,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===60?(w=v,A++):(w=a,Oe===0&&h(Je)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(He=T,T=Qs(P)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function hR(){var T,w,P=A*56+39,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=cu(),w!==a&&(He=T,w=pi(w)),T=w,ge[P]={nextPos:A,result:T},T)}function cu(){var T,w,P,X=A*56+40,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],i.charCodeAt(A)===94?(P=re,A++):(P=a,Oe===0&&h(wn)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===94?(P=re,A++):(P=a,Oe===0&&h(wn)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li)));else w=a;return w!==a&&(He=T,w=qs()),T=w,ge[X]={nextPos:A,result:T},T}function T_(){var T,w,P=A*56+41,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,i.charCodeAt(A)===63?(w=j,A++):(w=a,Oe===0&&h(na)),w!==a&&(He=T,w=Ni()),T=w,ge[P]={nextPos:A,result:T},T)}function uu(){var T,w,P,X,oe,ve,ht=A*56+42,hr=ge[ht];return hr?(A=hr.nextPos,hr.result):(T=A,i.charCodeAt(A)===40?(w=Z,A++):(w=a,Oe===0&&h(dt)),w!==a?(P=D(),P!==a?(i.charCodeAt(A)===44?(X=m,A++):(X=a,Oe===0&&h(an)),X!==a?(oe=D(),oe!==a?(i.charCodeAt(A)===41?(ve=f,A++):(ve=a,Oe===0&&h(Kt)),ve!==a?(He=T,T=Ya(P,oe)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[ht]={nextPos:A,result:T},T)}function C_(){var T,w,P,X,oe=A*56+43,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,w=Se(),w===a&&(w=Ce(),w===a&&(w=ae(),w===a&&(w=Zs()))),w!==a?(i.charCodeAt(A)===33?(P=K,A++):(P=a,Oe===0&&h(cr)),P!==a?(X=D(),X!==a?(He=T,T=$a(w,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function fR(){var T,w,P=A*56+44,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=Fe(),w!==a&&(He=T,w=Vs(w)),T=w,ge[P]={nextPos:A,result:T},T)}function mR(){var T,w,P,X=A*56+45,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,w=Fe(),w!==a?(i.charCodeAt(A)===94?(P=re,A++):(P=a,Oe===0&&h(wn)),P!==a?(He=T,T=wi(w)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function gR(){var T,w,P,X,oe,ve=A*56+46,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,w=mR(),w===a&&(w=null),i.charCodeAt(A)===114?(P=ue,A++):(P=a,Oe===0&&h(ci)),P!==a?(X=A,Oe++,At.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ar)),Oe--,oe===a?X=void 0:(A=X,X=a),X!==a?(He=T,T=Ga(w)):(A=T,T=a)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function fl(){var T,w,P,X,oe,ve=A*56+47,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,w=cu(),w===a&&(w=null),P=Fe(),P===a&&(P=null),X=_R(),X===a&&(X=null),oe=y(),oe===a&&(oe=T_(),oe===a&&(oe=uu(),oe===a&&(oe=b_()))),oe!==a?(He=T,T=Di(w,P,X,oe)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function _R(){var T,w,P,X=A*56+48,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(jt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(jt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui)));else w=a;return w!==a&&(He=T,w=xi(w)),T=w,ge[X]={nextPos:A,result:T},T}function SR(){var T,w,P,X,oe=A*56+49,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,w=fl(),w!==a){if(P=[],X=fl(),X!==a)for(;X!==a;)P.push(X),X=fl();else P=a;P!==a?(X=du(),X===a&&(X=null),He=T,T=Qa(w,P,X)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function y_(){var T,w,P,X=A*56+50,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],Nt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di)),P!==a)for(;P!==a;)w.push(P),Nt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di));else w=a;return w!==a&&(He=T,w=ia()),T=w,ge[X]={nextPos:A,result:T},T}function du(){var T,w,P,X=A*56+51,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===37?(w=te,A++):(w=a,Oe===0&&h(Ii)),w!==a?(P=D(),P!==a?(He=T,T=hi(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function A_(){var T,w,P=A*56+52,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,Rn.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(q)),w!==a?(qe.test(i.charAt(A))?(i.charAt(A),A++):Oe===0&&h(ie),He=T,T=gn()):(A=T,T=a),ge[P]={nextPos:A,result:T},T)}function OR(){var T,w,P,X,oe,ve,ht=A*56+53,hr=ge[ht];return hr?(A=hr.nextPos,hr.result):(T=A,w=cu(),w===a&&(w=null),P=Fe(),P===a&&(P=null),X=A_(),X!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(wn),oe=y_(),oe!==a?(ve=du(),ve===a&&(ve=null),He=T,T=qa(w,P,X,oe,ve)):(A=T,T=a)):(A=T,T=a),ge[ht]={nextPos:A,result:T},T)}function ER(){var T,w,P,X,oe=A*56+54,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.substr(A,3)===De?(w=De,A+=3):(w=a,Oe===0&&h(de)),w===a&&(i.substr(A,2)===xe?(w=xe,A+=2):(w=a,Oe===0&&h(_e)),w===a&&(i.substr(A,2)===be?(w=be,A+=2):(w=a,Oe===0&&h(Ae)),w===a&&(i.charCodeAt(A)===105?(w=Ne,A++):(w=a,Oe===0&&h(Qe)),w===a&&(i.substr(A,3)===ce?(w=ce,A+=3):(w=a,Oe===0&&h(Me)),w===a&&(i.substr(A,2)===Le?(w=Le,A+=2):(w=a,Oe===0&&h(Ct)),w===a&&(i.charCodeAt(A)===118?(w=Xe,A++):(w=a,Oe===0&&h(Dn)))))))),w!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(wn),P=y_(),P===a&&(P=null),X=du(),X===a&&(X=null),He=T,T=Zn(w,P,X)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function bR(){var T,w,P=A*56+55,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=A_(),w!==a&&(He=T,w=aa(w)),T=w,ge[P]={nextPos:A,result:T},T)}var I_=s.nodeOptions||{};function Ut(T,w,P=void 0){w.text=P||$n(),w.location=ul();for(var X in I_)(w[X]===void 0||w[X]===null)&&(w[X]=I_[X]);return new T(w)}if(sa=c(),sa!==a&&A===i.length)return sa;throw sa!==a&&Ae.collect("pitch"))}notes(){return this.evaluated.map(e=>e.collect("note"))}sounds(){return this.evaluated.map(e=>e.collect("sound"))}indices(){return this.evaluated.map(e=>e.collect("soundIndex"))}freqs(){return this.evaluated.map(e=>e.collect("freq"))}durations(){return this.evaluated.map(e=>e.collect("duration"))}octaves(){return this.evaluated.map(e=>e.collect("octave"))}retrograde(){return this.evaluated=this.evaluated.reverse(),this}scale(e){return this.applyOptions({scale:e}),this}key(e){return this.applyOptions({key:e}),this}octave(e){return this.applyOptions({octave:e}),this}invert(e){return this.applyOptions({inversion:e}),this}isInOptions(e,t){return this.options.nodeOptions&&this.options.nodeOptions[e]===t}atLast(){return this.index+1>=this.evaluated.length*this.redo}clone(){return ti(this)}notStarted(){return this.index<0}peek(){return this.evaluated[this.index-1||0]}hasStarted(){return this.index>=0}next(){this.index<0&&(this.index=0);const e=this.evaluated[this.index%this.evaluated.length];return this.index++,this.counter++,this.redo>0&&this.index>=this.evaluated.length*this.redo&&(this.index=0,this.evaluated=this.evaluate(this.values)),e}applyOptions(e={}){this.evaluated=this.evaluate(this.evaluated,e),this.applyTransformations()}applyTransformations(){var e;(e=this.globalOptions)!=null&&e.retrograde&&(this.evaluated=this.evaluated.reverse())}update(){return this.evaluated=this.evaluate(this.values),this.applyTransformations(),this}evaluate(e,t={}){let n=e.map(i=>i.evaluate(t)).flat(1/0).filter(i=>i!==void 0);return t.subdivisions&&(n=MI(n)),n}totalDuration(){return this.evaluated.reduce((t,n)=>t+n.collect("duration"),0)}lead(){let e=this.evaluated.findIndex(t=>t instanceof Ra);if(e>=0){for(let t=e+1;t<=this.evaluated.length;t++)if(this.evaluated[t]instanceof Ra){const n=this.evaluated[e],i=this.evaluated[t],s=N3(n.notes(),i.notes()),a=ti(i);a.voiceLeadFromNotes(s,this.options.nodeOptions),this.evaluated[t]=a,e=t}}return this}}const MI=(r,e=void 0)=>r.map(n=>{if(n instanceof RI){const i=n.evaluated.length,s=(e||n.duration)/i;return MI(n.evaluated,s)}else return n.duration=e||n.duration,n}).flat(1/0),x3=r=>{let e={};return t3.forEach(t=>{if(r[t]!==void 0){const n=r[t];e[t]=n,delete r[t]}}),e};class k3{constructor(e,t){b(this,"api");b(this,"settings");b(this,"midiAccess",null);b(this,"midiOutputs",[]);b(this,"currentOutputIndex",0);b(this,"scheduledNotes",{});b(this,"midiInputs",[]);b(this,"currentInputIndex");b(this,"bufferLength",512);b(this,"noteInputBuffer",[]);b(this,"ccInputBuffer",[]);b(this,"activeNotes",[]);b(this,"stickyNotes",[]);b(this,"lastNote");b(this,"lastCC",{});b(this,"lastNoteInChannel",{});b(this,"lastCCInChannel",{});b(this,"midiClockInputIndex");b(this,"midiClockInput");b(this,"lastTimestamp",0);b(this,"midiClockDelta",0);b(this,"lastBPM");b(this,"roundedBPM",0);b(this,"clockBuffer",[]);b(this,"clockBufferLength",24);b(this,"clockTicks",0);b(this,"clockErrorCount",0);b(this,"skipOnError",0);this.api=e,this.settings=t,this.lastBPM=e.bpm(),this.roundedBPM=this.lastBPM,this.initializeMidiAccess()}async initializeMidiAccess(){try{this.midiAccess=await navigator.requestMIDIAccess(),this.midiOutputs=Array.from(this.midiAccess.outputs.values()),this.midiOutputs.length===0&&(console.warn("No MIDI outputs available."),this.currentOutputIndex=-1),this.midiInputs=Array.from(this.midiAccess.inputs.values()),this.midiInputs.length===0?console.warn("No MIDI inputs available."):this.updateInputSelects()}catch(e){console.error("Failed to initialize MIDI:",e)}}getCurrentMidiPort(){return this.midiOutputs.length>0&&this.currentOutputIndex>=0&&this.currentOutputIndex0&&this.currentOutputIndex>=0&&this.currentOutputIndex0){const e=document.getElementById("midi-clock-input"),t=document.getElementById("default-midi-input");e.innerHTML="",t.innerHTML="";const n=document.createElement("option");n.value="-1",n.text="Internal",e.appendChild(n);const i=document.createElement("option");if(i.value="-1",i.text="None",t.appendChild(i),this.midiInputs.forEach((s,a)=>{const o=document.createElement("option");o.value=a.toString(),o.text=s.name||a.toString(),e.appendChild(o),t.appendChild(o.cloneNode(!0))}),this.settings.midi_clock_input){const s=this.getMidiInputIndex(this.settings.midi_clock_input);e.value=s.toString(),s>0&&(this.midiClockInput=this.midiInputs[s],this.registerMidiInputListener(s))}else e.value="-1";if(this.settings.default_midi_input){const s=this.getMidiInputIndex(this.settings.default_midi_input);t.value=s.toString(),s>0&&(this.currentInputIndex=s,this.registerMidiInputListener(s))}else t.value="-1";e.addEventListener("change",s=>{const a=s.target.value;if(a==="-1")this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=void 0,this.settings.midi_clock_input=void 0;else{const o=parseInt(a);this.midiClockInputIndex=o,this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=this.midiInputs[o],this.registerMidiInputListener(o),this.settings.midi_clock_input=this.midiClockInput.name||void 0}}),t.addEventListener("change",s=>{const a=s.target.value;a==="-1"?(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=void 0,this.settings.default_midi_input=void 0):(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=parseInt(a),this.registerMidiInputListener(this.currentInputIndex),this.settings.default_midi_input=this.midiInputs[this.currentInputIndex].name||void 0)})}}registerMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&!t.onmidimessage&&(t.onmidimessage=n=>{const i=n;if(t.name===this.settings.midi_clock_input&&(i.data[0]===248?this.skipOnError>0?this.skipOnError-=1:this.onMidiClock(n.timeStamp):i.data[0]===250?(console.log("MIDI start received"),this.api.stop(),this.api.play()):i.data[0]===252?(console.log("MIDI stop received"),this.api.pause()):i.data[0]===251?(console.log("MIDI continue received"),this.api.play()):i.data[0]===254&&console.log("MIDI active sensing received")),t.name===this.settings.default_midi_input){if(i.data[0]>=144&&i.data[0]<=159){const s=i.data[0]-144+1,a=i.data[1],o=i.data[2];this.lastNote={note:a,velocity:o,channel:s,timestamp:n.timeStamp},this.lastNoteInChannel[s]={note:a,velocity:o,channel:s,timestamp:n.timeStamp},this.settings.midi_channels_scripts&&this.api.script(s),this.pushToMidiInputBuffer({note:a,velocity:o,channel:s,timestamp:n.timeStamp}),this.activeNotes.push({note:a,velocity:o,channel:s,timestamp:n.timeStamp}),this.removeFromStickyNotes(a,s)||this.stickyNotes.push({note:a,velocity:o,channel:s,timestamp:n.timeStamp})}if(i.data[0]>=128&&i.data[0]<=143){const s=i.data[0]-128+1,a=i.data[1];this.removeFromActiveNotes(a,s)}if(i.data[0]>=176&&i.data[0]<=191){const s=i.data[0]-176+1,a=i.data[1],o=i.data[2];this.lastCC[a]=o,this.lastCCInChannel[s]?this.lastCCInChannel[s][a]=o:(this.lastCCInChannel[s]={},this.lastCCInChannel[s][a]=o),this.pushToMidiCCBuffer({control:a,value:o,channel:s,timestamp:n.timeStamp})}}})}}removeFromActiveNotes(e,t){const n=this.activeNotes.findIndex(i=>i.note===e&&i.channel===t);n>=0&&this.activeNotes.splice(n,1)}removeFromStickyNotes(e,t){const n=this.stickyNotes.findIndex(i=>i.note===e&&i.channel===t);return n>=0?(this.stickyNotes.splice(n,1),!0):!1}stickyNotesFromChannel(e){return this.stickyNotes.filter(t=>t.channel===e)}activeNotesFromChannel(e){return this.activeNotes.filter(t=>t.channel===e)}killActiveNotes(){this.activeNotes=[]}killActiveNotesFromChannel(e){this.activeNotes=this.activeNotes.filter(t=>t.channel!==e)}pushToMidiInputBuffer(e){this.noteInputBuffer.push(e),this.noteInputBuffer.length>this.bufferLength&&this.noteInputBuffer.shift()}pushToMidiCCBuffer(e){this.ccInputBuffer.push(e),this.ccInputBuffer.length>this.bufferLength&&this.ccInputBuffer.shift()}findNoteFromBufferInChannel(e){const t=this.noteInputBuffer.findIndex(n=>n.channel===e);if(t>=0){const n=this.noteInputBuffer[t];return this.noteInputBuffer.splice(t,1),n}else return}findCCFromBufferInChannel(e){const t=this.ccInputBuffer.findIndex(n=>n.channel===e);if(t>=0){const n=this.ccInputBuffer[t];return this.ccInputBuffer.splice(t,1),n}else return}unregisterMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&(t.onmidimessage=null)}}onMidiClock(e){if(this.clockTicks+=1,this.lastTimestamp>0)if(this.lastTimestamp===e)this.clockErrorCount+=1;else if(this.clockErrorCount>0)console.log("Timestamp error count: ",this.clockErrorCount),console.log("Current timestamp: ",e),console.log("Last timestamp: ",this.lastTimestamp),console.log("Last delta: ",this.midiClockDelta),console.log("Current delta: ",e-this.lastTimestamp),console.log("BPMs",this.clockBuffer),this.clockErrorCount=0,this.skipOnError=this.settings.midi_clock_ppqn/4,e=0;else{this.midiClockDelta=e-this.lastTimestamp,this.lastBPM=60*(1e3/this.midiClockDelta/this.settings.midi_clock_ppqn),this.clockBuffer.push(this.lastBPM),this.clockBuffer.length>this.clockBufferLength&&this.clockBuffer.shift();const t=this.estimatedBPM();t!==this.roundedBPM&&(console.log("Estimated BPM: ",t),this.api.bpm(t),this.roundedBPM=t)}this.lastTimestamp=e}estimatedBPM(){const e=this.clockBuffer.reduce((t,n)=>t+n);return Math.round(e/this.clockBuffer.length)}sendMidiClock(){if(!this.midiClockInput){const e=this.midiOutputs[this.currentOutputIndex];e&&e.send([248])}}switchMidiOutput(e){const t=this.getMidiOutputIndex(e);return t!==-1?(this.currentOutputIndex=t,!0):!1}getMidiOutputIndex(e){if(typeof e=="number")return e<0||e>=this.midiOutputs.length?(console.error(`Invalid MIDI output index. Index must be in the range 0-${this.midiOutputs.length-1}.`),this.currentOutputIndex):e;{const t=this.midiOutputs.findIndex(n=>n.name===e);return t!==-1?t:(console.error(`MIDI output "${e}" not found.`),this.currentOutputIndex)}}getMidiInputIndex(e){if(typeof e=="number")return e<0||e>=this.midiInputs.length?(console.error(`Invalid MIDI input index. Index must be in the range 0-${this.midiInputs.length-1}.`),-1):e;{const t=this.midiInputs.findIndex(n=>n.name===e);return t!==-1?t:(console.error(`MIDI input "${e}" not found.`),-1)}}listMidiOutputs(){let e="Available MIDI Outputs: ";return this.midiOutputs.forEach((t,n)=>{e+=`(${n+1}) ${t.name} `}),e}sendMidiNote(e,t,n,i,s=this.currentOutputIndex,a=void 0){typeof s=="string"&&(s=this.getMidiOutputIndex(s));const o=this.midiOutputs[s];if(e=Math.min(Math.max(e,0),127),o){const l=[144+t,e,n],c=[128+t,e,0];o.send(l),a&&this.sendPitchBend(a,t,s);const u=setTimeout(()=>{o.send(c),a&&this.sendPitchBend(8192,t,s),delete this.scheduledNotes[e]},(i-.02)*1e3);this.scheduledNotes[e]=u}else console.error("MIDI output not available.")}sendMidiOn(e,t,n,i=this.currentOutputIndex){typeof i=="string"&&(i=this.getMidiOutputIndex(i));const s=this.midiOutputs[i];if(e=Math.min(Math.max(e,0),127),s){const a=[144+t,e,n];s.send(a)}else console.error("MIDI output not available.")}sendMidiOff(e,t,n=this.currentOutputIndex){typeof n=="string"&&(n=this.getMidiOutputIndex(n));const i=this.midiOutputs[n];if(e=Math.min(Math.max(e,0),127),i){const s=[128+t,e,0];i.send(s)}else console.error("MIDI output not available.")}sendAllNotesOff(e,t=this.currentOutputIndex){typeof t=="string"&&(t=this.getMidiOutputIndex(t));const n=this.midiOutputs[t];if(n){const i=[176+e,123,0];n.send(i)}else console.error("MIDI output not available.")}sendAllSoundOff(e,t=this.currentOutputIndex){typeof t=="string"&&(t=this.getMidiOutputIndex(t));const n=this.midiOutputs[t];if(n){const i=[176+e,120,0];n.send(i)}else console.error("MIDI output not available.")}sendSysExMessage(e){const t=this.midiOutputs[this.currentOutputIndex];t?t.send(e):console.error("MIDI output not available.")}sendPitchBend(e,t,n=this.currentOutputIndex){(e<0||e>16383)&&console.error("Invalid pitch bend value. Value must be in the range 0-16383."),(t<0||t>15)&&console.error("Invalid MIDI channel. Channel must be in the range 0-15."),typeof n=="string"&&(n=this.getMidiOutputIndex(n));const i=this.midiOutputs[n];if(i){const s=e&127,a=e>>7&127;i.send([224|t,s,a])}else console.error("MIDI output not available.")}sendProgramChange(e,t){const n=this.midiOutputs[this.currentOutputIndex];n?n.send([192+t,e]):console.error("MIDI output not available.")}sendMidiControlChange(e,t,n){const i=this.midiOutputs[this.currentOutputIndex];i?i.send([176+n,e,t]):console.error("MIDI output not available.")}panic(){const e=this.midiOutputs[this.currentOutputIndex];if(e){for(const t in this.scheduledNotes){const n=this.scheduledNotes[t];clearTimeout(n),e.send([128,parseInt(t),0])}this.scheduledNotes={}}else console.error("MIDI output not available.")}}class L3{constructor(e,t,n){b(this,"min");b(this,"max");b(this,"wrap");b(this,"position");this.min=e,this.max=t,this.wrap=n,this.position=0}step(){const e=Math.floor(Math.random()*3)-1;this.position+=e,this.wrap?this.position>this.max?this.position=this.min:this.positionthis.max&&(this.position=this.max)}getPosition(){return this.position}toggleWrap(e){this.wrap=e}}class s_{constructor(e){b(this,"seedValue");b(this,"randomGen",Math.random);b(this,"app");b(this,"values",{});b(this,"evenbar",e=>this.app.clock.time_position.bar%2===0?this.modify(e):this);b(this,"even",e=>this.app.clock.time_position.beat%2===0?this.modify(e):this);b(this,"odd",e=>this.app.clock.time_position.beat%2!==0?this.modify(e):this);b(this,"odds",(e,t)=>this.randomGen()this);b(this,"almostNever",e=>this.odds(.025,e));b(this,"rarely",e=>this.odds(.1,e));b(this,"scarcely",e=>this.odds(.25,e));b(this,"sometimes",e=>this.odds(.5,e));b(this,"often",e=>this.odds(.75,e));b(this,"frequently",e=>this.odds(.9,e));b(this,"almostAlways",e=>this.odds(.985,e));b(this,"always",e=>this.modify(e));b(this,"modify",e=>e(this));b(this,"seed",e=>(this.seedValue=e.toString(),this.randomGen=this.app.api.localSeededRandom(this.seedValue),this));b(this,"clear",()=>(this.app.api.clearLocalSeed(this.seedValue),this));b(this,"apply",e=>this.modify(e));b(this,"length",e=>(this.values.length=e,this));this.app=e,this.app.api.currentSeed&&(this.randomGen=this.app.api.randomGen)}}class PI extends s_{constructor(t){super(t);b(this,"octave",t=>(this.values.octave=t,this.update(),this));b(this,"key",t=>(this.values.key=t,this.update(),this));b(this,"scale",t=>(n_(t)?(this.values.scaleName=t,this.values.parsedScale=vi(t)):this.values.parsedScale=r_(t),this.update(),this));b(this,"freq",t=>{this.values.freq=t;const n=u3(t);return n%1!==0?(this.values.note=Math.floor(n),this.values.bend=NI(n)[1]):this.values.note=n,this});b(this,"update",()=>{})}}let kn=[],M3=(r,e)=>{let t,n=[],i={lc:0,l:e||0,value:r,set(s){i.value=s,i.notify()},get(){return i.lc||i.listen(()=>{})(),i.value},notify(s){t=n;let a=!kn.length;for(let o=0;o{n===t&&(n=n.slice());let o=n.indexOf(s);~o&&(n.splice(o,2),i.lc--,i.lc||i.off())}},subscribe(s,a){let o=i.listen(s,a);return s(i.value),o},off(){}};return i},P3=(r={})=>{let e=M3(r);return e.setKey=function(t,n){typeof n>"u"?t in e.value&&(e.value={...e.value},delete e.value[t],e.notify(t)):e.value[t]!==n&&(e.value={...e.value,[t]:n},e.notify(t))},e};if(typeof DelayNode<"u"){class r extends DelayNode{constructor(t,n,i,s){super(t),n=Math.abs(n),this.delayTime.value=i;const a=t.createGain();a.gain.value=Math.min(Math.abs(s),.995),this.feedback=a.gain;const o=t.createGain();return o.gain.value=n,this.delayGain=o,this.connect(a),this.connect(o),a.connect(this),this.connect=l=>o.connect(l),this}start(t){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,t+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(e,t,n){return new r(this,e,t,n)}}var o_={};o_.generateReverb=function(r,e){for(var t=r.audioContext||new AudioContext,n=t.sampleRate,i=r.numChannels||2,s=r.decayTime*1.5,a=Math.round(r.decayTime*n),o=Math.round(s*n),l=Math.round((r.fadeInTime||0)*n),c=Math.pow(1/1e3,1/a),u=t.createBuffer(i,o,n),p=0;p{o_.generateReverb({audioContext:this,numChannels:2,decayTime:s,fadeInTime:a,lpFreqStart:o,lpFreqEnd:l},c=>{i.buffer=c}),i.duration=s,i.fade=a,i.lp=o,i.dim=l},i.generate(r,e,t,n),i});var bE={a:{freqs:[660,1120,2750,3e3,3350],gains:[1,.5012,.0708,.0631,.0126],qs:[80,90,120,130,140]},e:{freqs:[440,1800,2700,3e3,3300],gains:[1,.1995,.1259,.1,.1],qs:[70,80,100,120,120]},i:{freqs:[270,1850,2900,3350,3590],gains:[1,.0631,.0631,.0158,.0158],qs:[40,90,100,120,120]},o:{freqs:[430,820,2700,3e3,3300],gains:[1,.3162,.0501,.0794,.01995],qs:[40,80,100,120,120]},u:{freqs:[370,630,2750,3e3,3400],gains:[1,.1,.0708,.0316,.01995],qs:[40,60,100,120,120]}};if(typeof GainNode<"u"){class r extends GainNode{constructor(t,n){if(super(t),!bE[n])throw new Error("vowel: unknown vowel "+n);const{gains:i,qs:s,freqs:a}=bE[n],o=t.createGain();for(let l=0;l<5;l++){const c=t.createGain();c.gain.value=i[l];const u=t.createBiquadFilter();u.type="bandpass",u.Q.value=s[l],u.frequency.value=a[l],this.connect(u),u.connect(c),c.connect(o)}return o.gain.value=8,this.connect=l=>o.connect(l),this}}AudioContext.prototype.createVowelFilter=function(e){return new r(this,e)}}const Y3=r=>{var i;if(typeof r!="string")return[];const[e,t="",n]=((i=r.match(/^([a-gA-G])([#bsf]*)([0-9]*)$/))==null?void 0:i.slice(1))||[];return e?[e,t,n?Number(n):void 0]:[]},$3={c:0,d:2,e:4,f:5,g:7,a:9,b:11},G3={"#":1,b:-1,s:1,f:-1},iu=(r,e=3)=>{const[t,n,i=e]=Y3(r);if(!t)throw new Error('not a note: "'+r+'"');const s=$3[t.toLowerCase()],a=(n==null?void 0:n.split("").reduce((o,l)=>o+G3[l],0))||0;return(Number(i)+1)*12+s+a},BI=r=>Math.pow(2,(r-69)/12)*440,zm=(r,e,t)=>Math.min(Math.max(r,e),t),Q3=r=>12*Math.log(r/440)/Math.LN2+69,q3=(r,e)=>{if(typeof r!="object")throw new Error("valueToMidi: expected object value");let{freq:t,note:n}=r;if(typeof t=="number")return Q3(t);if(typeof n=="string")return iu(n);if(typeof n=="number")return n;if(!e)throw new Error("valueToMidi: expected freq or note to be set");return e},V3="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK";function Bc(r){const e=Bt().createGain();return e.gain.value=r,e}const l_=(r,e,t,n,i,s)=>{const a=Bt().createGain();return a.gain.setValueAtTime(0,s),a.gain.linearRampToValueAtTime(i,s+r),a.gain.linearRampToValueAtTime(t*i,s+r+e),{node:a,stop:o=>{a.gain.setValueAtTime(t*i,o),a.gain.linearRampToValueAtTime(0,o+n)}}},z3=(r,e,t,n,i,s)=>{t=Math.max(.001,t),i=Math.max(.001,i);const a=Bt().createGain();return a.gain.setValueAtTime(1e-4,s),a.gain.exponentialRampToValueAtTime(i,s+r),a.gain.exponentialRampToValueAtTime(t*i,s+r+e),{node:a,stop:o=>{a.gain.exponentialRampToValueAtTime(1e-4,o+n)}}},H3=(r,e,t,n,i,s,a,o,l)=>{const c=a-s,u=s+c,p=s+n*c;r.setValueAtTime(s,o),r.linearRampToValueAtTime(u,o+e),r.linearRampToValueAtTime(p,o+e+t),r.setValueAtTime(p,l),r.linearRampToValueAtTime(s,l+Math.max(i,.1))};function W3(r,e,t,n,i,s){const a={threshold:e??-3,ratio:t??10,knee:n??10,attack:i??.005,release:s??.05};return new DynamicsCompressorNode(r,a)}function Ku(r,e,t,n,i,s,a,o,l,c,u,p=.5){const m=r.createBiquadFilter();if(m.type=e,m.Q.value=n,m.frequency.value=t,!isNaN(l)&&l!==0){const _=l*p,v=zm(2**-_*t,0,2e4),I=zm(2**(l-_)*t,0,2e4);return H3(m.frequency,i,s,a,o,v,I,c,u),m}return m}let vE=r=>r<.5?1:1-(r-.5)/.5;function X3(r,e,t=0){const n=Bt();if(!t)return r;let i=n.createGain(),s=n.createGain();r.connect(i),e.connect(s),i.gain.value=vE(t),s.gain.value=vE(1-t);let a=n.createGain();return i.connect(a),s.connect(a),a}let Z3=r=>console.log(r);const ys=(...r)=>Z3(...r),c_=P3();function u_(r,e,t={}){c_.setKey(r,{onTrigger:e,data:t})}function TE(r){return c_.get()[r]}let ju;const Bt=()=>(ju||(ju=new AudioContext),ju);let Ul;const d_=()=>{const r=Bt();return Ul||(Ul=r.createGain(),Ul.connect(r.destination)),Ul};let Ju;function K3(){return Ju||(Ju=Bt().audioWorklet.addModule(V3),Ju)}function ed(r,e,t){const n=new AudioWorkletNode(r,e);return Object.entries(t).forEach(([i,s])=>{n.parameters.get(i).value=s}),n}async function j3(r={}){const{disableWorklets:e=!1}=r;typeof window<"u"&&(await Bt().resume(),e?console.log("disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!"):await K3().catch(t=>{console.warn("could not load AudioWorklet effects coarse, crush and shape",t)}))}async function J3(r){return new Promise(e=>{document.addEventListener("click",async function t(){await j3(r),e(),document.removeEventListener("click",t)})})}let ca={};function eB(r,e,t,n){var i;if(t=zm(t,0,.98),!ca[r]){const s=Bt().createFeedbackDelay(1,e,t);(i=s.start)==null||i.call(s,n),s.connect(d_()),ca[r]=s}return ca[r].delayTime.value!==e&&ca[r].delayTime.setValueAtTime(e,n),ca[r].feedback.value!==t&&ca[r].feedback.setValueAtTime(t,n),ca[r]}let Li={},Fl=(r,e)=>r!==void 0&&r!==e;function tB(r,e,t,n,i){if(!Li[r]){const s=Bt().createReverb(e,t,n,i);s.connect(d_()),Li[r]=s}return(Fl(e,Li[r].duration)||Fl(t,Li[r].fade)||Fl(n,Li[r].lp)||Fl(i,Li[r].dim))&&Li[r].generate(e,t,n,i),Li[r]}let ua;function nB(r=2048){if(!ua){const e=Bt().createAnalyser();e.fftSize=r,ua=e,new Float32Array(ua.frequencyBinCount)}return ua.fftSize!==r&&(ua.fftSize=r,new Float32Array(ua.frequencyBinCount)),ua}function td(r,e,t){const n=Bc(t);return r.connect(n),n.connect(e),n}const CE=async(r,e,t)=>{const n=Bt();if(typeof r!="object")throw new Error(`expected hap.value to be an object, but got "${r}". Hint: append .note() or .s() to the end`,"error");r.duration=t;let i=n.currentTime+e,{s="triangle",bank:a,source:o,gain:l=.8,postgain:c=1,ftype:u="12db",fanchor:p=.5,cutoff:m,lpenv:_,lpattack:v=.01,lpdecay:I=.01,lpsustain:R=1,lprelease:x=.01,resonance:$=1,hpenv:Z,hcutoff:f,hpattack:E=.01,hpdecay:S=.01,hpsustain:N=1,hprelease:k=.01,hresonance:L=1,bpenv:M,bandf:G,bpattack:te=.01,bpdecay:re=.01,bpsustain:ne=1,bprelease:ee=.01,bandq:B=1,coarse:Q,crush:j,shape:K,pan:ue,vowel:le,delay:Ee=0,delayfeedback:De=.5,delaytime:xe=.25,orbit:be=1,room:Ne,roomfade:ce,roomlp:Le,roomdim:Xe,roomsize:Be,velocity:tt=1,analyze:rt,fft:ft=8,compressor:vt,compressorRatio:mt,compressorKnee:At,compressorAttack:Nt,compressorRelease:Rn}=r;l*=tt;let qe=[];const rn=()=>{qe.forEach(he=>he==null?void 0:he.disconnect())};a&&s&&(s=`${a}_${s}`);let Ze;if(o)Ze=o(i,r,t);else if(TE(s)){const{onTrigger:he}=TE(s),Ie=await he(i,r,rn);Ie&&(Ze=Ie.node,Ie.stop(i+t))}else throw new Error(`sound ${s} not found! Is it loaded?`);if(!Ze)return;if(n.currentTime>i){ys("[webaudio] skip hap: still loading",n.currentTime-i);return}const ke=[];if(ke.push(Ze),ke.push(Bc(l)),m!==void 0){let he=()=>Ku(n,"lowpass",m,$,v,I,R,x,_,i,i+t,p);ke.push(he()),u==="24db"&&ke.push(he())}if(f!==void 0){let he=()=>Ku(n,"highpass",f,L,E,S,N,k,Z,i,i+t,p);ke.push(he()),u==="24db"&&ke.push(he())}if(G!==void 0){let he=()=>Ku(n,"bandpass",G,B,te,re,ne,ee,M,i,i+t,p);ke.push(he()),u==="24db"&&ke.push(he())}if(le!==void 0){const he=n.createVowelFilter(le);ke.push(he)}if(Q!==void 0&&ke.push(ed(n,"coarse-processor",{coarse:Q})),j!==void 0&&ke.push(ed(n,"crush-processor",{crush:j})),K!==void 0&&ke.push(ed(n,"shape-processor",{shape:K})),vt!==void 0&&ke.push(W3(n,vt,mt,At,Nt,Rn)),ue!==void 0){const he=n.createStereoPanner();he.pan.value=2*ue-1,ke.push(he)}const en=Bc(c);ke.push(en),en.connect(d_());let Zt;if(Ee>0&&xe>0&&De>0){const he=eB(be,xe,De,i);Zt=td(en,he,Ee)}let an;if(Ne>0){const he=tB(be,Be,ce,Le,Xe);an=td(en,he,Ne)}let H;if(rt){const he=nB(2**(ft+5));H=td(en,he,rt)}ke.slice(1).reduce((he,Ie)=>he.connect(Ie),ke[0]),qe=ke.concat([Zt,an,H])},nd={};function rB(r,e){var t=e?1e3:1024;if(r=t);return r.toFixed(1)+" "+n[i]}const iB=async(r,e,t,n,i,s,a)=>{let o=0;i!==void 0&&t!==void 0&&ys("[sampler] hap has note and freq. ignoring note","warning");let l=q3({freq:i,note:t},36);o=l-36;const c=Bt();let u;if(Array.isArray(s))u=s[e%s.length];else{const v=R=>iu(R)-l,I=Object.keys(s).filter(R=>!R.startsWith("_")).reduce((R,x,$)=>!R||Math.abs(v(x)){const i=t?`sound "${t}:${n}"`:"sample";if(r=r.replace("#","%23"),!nd[r]){ys(`[sampler] load ${i}..`,"load-sample",{url:r});const s=Date.now();nd[r]=fetch(r).then(a=>a.arrayBuffer()).then(async a=>{const o=Date.now()-s,l=rB(a.byteLength);return ys(`[sampler] load ${i}... done! loaded ${l} in ${o}ms`,"loaded-sample",{url:r}),await e.decodeAudioData(a)})}return nd[r]};function sB(r){const e=Bt(),t=e.createBuffer(r.numberOfChannels,r.length,e.sampleRate);for(let n=0;nObject.entries(r).forEach(([n,i])=>{if(typeof i=="string"&&(i=[i]),typeof i!="object")throw new Error("wrong sample map format for "+n);t=i._base||t;const s=a=>(t+a).replace("github:","https://raw.githubusercontent.com/");Array.isArray(i)?i=i.map(s):i=Object.fromEntries(Object.entries(i).map(([a,o])=>[a,(typeof o=="string"?[o]:o).map(s)])),e(n,i)});let lB={};function cB(r){const e=Object.entries(lB).find(([t])=>r.startsWith(t));if(e)return e[1]}const Gi=async(r,e=r._base||"",t={})=>{if(typeof r=="string"){const s=cB(r);if(s)return s(r);if(r.startsWith("github:")){let[o,l]=r.split("github:");l=l.endsWith("/")?l.slice(0,-1):l,r=`https://raw.githubusercontent.com/${l}/strudel.json`}if(typeof fetch!="function")return;const a=r.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(r).then(o=>o.json()).then(o=>Gi(o,e||o._base||a,t)).catch(o=>{throw console.error(o),new Error(`error loading "${r}"`)})}const{prebake:n,tag:i}=t;oB(r,(s,a)=>u_(s,(o,l,c)=>uB(o,l,c,a),{type:"sample",samples:a,baseUrl:e,prebake:n,tag:i}),e)},yE=[];async function uB(r,e,t,n,i){let{s,freq:a,unit:o,nudge:l=0,cut:c,loop:u,clip:p=void 0,n:m=0,note:_,speed:v=1,loopBegin:I=0,begin:R=0,loopEnd:x=1,end:$=1}=e;if(v===0)return;u=s.startsWith("wt_")?1:e.loop;const Z=Bt(),{attack:f=.001,decay:E=.001,sustain:S=1,release:N=.001}=e,k=r+l,L=await iB(s,m,_,v,a,n,i);if(Z.currentTime>r){ys(`[sampler] still loading sound "${s}:${m}"`,"highlight");return}if(!L){ys(`[sampler] could not load "${s}:${m}"`,"error");return}L.playbackRate.value=Math.abs(v)*L.playbackRate.value,o==="c"&&(L.playbackRate.value=L.playbackRate.value*L.buffer.duration*1);const M=R*L.buffer.duration;u&&(L.loop=!0,L.loopStart=I*L.buffer.duration-M,L.loopEnd=x*L.buffer.duration-M),L.start(k,M);const{node:G,stop:te}=l_(f,E,S,N,1,r);L.connect(G);const re=Z.createGain();G.connect(re),L.onended=function(){L.disconnect(),G.disconnect(),re.disconnect(),t()};const ne={node:re,bufferSource:L,stop:(ee,B=p===void 0&&u===void 0)=>{let Q=ee;if(B){const j=L.buffer.duration/L.playbackRate.value;Q=r+($-R)*j}L.stop(Q+N),te(Q)}};if(c!==void 0){const ee=yE[c];ee&&(ee.node.gain.setValueAtTime(1,k),ee.node.gain.linearRampToValueAtTime(0,k+.01)),yE[c]=ne}return ne}let rd={};function dB(r){const e=Bt();if(rd[r])return rd[r];const t=2*e.sampleRate,n=e.createBuffer(1,t,e.sampleRate),i=n.getChannelData(0);let s=0,a,o,l,c,u,p,m;a=o=l=c=u=p=m=0;for(let _=0;_t.stop(n)}}function pB(r,e,t){const n=UI("pink",t);return{node:X3(r,n.node,e),stop:i=>n==null?void 0:n.stop(i)}}const hB=(r,e=1,t="sine")=>{const n=Bt(),i=n.createOscillator();i.type=t,i.frequency.value=r,i.start();const s=new GainNode(n,{gain:e});return i.connect(s),{node:s,stop:a=>i.stop(a)}},fB=(r,e,t,n="sine")=>{const i=r.frequency.value*e,s=i*t;return hB(i,s,n)},AE=["sine","square","triangle","sawtooth"],mB=["pink","white","brown"];function gB(){[...AE,...mB].forEach(r=>{u_(r,(e,t,n)=>{let{attack:i=.001,decay:s=.05,sustain:a=.6,release:o=.01}=t,l;AE.includes(r)?l=SB(r,e,t):l=UI(r,e);let{node:c,stop:u,triggerRelease:p}=l;const m=Bc(.3),{node:_,stop:v}=l_(i,s,a,o,1,e);return c.onended=()=>{c.disconnect(),m.disconnect(),n()},{node:c.connect(m).connect(_),stop:I=>{v(I),p==null||p(I);let R=I+o;u(R)}}},{type:"synth",prebake:!0})})}function _B(r,e){const t=new Float32Array(r+1),n=new Float32Array(r+1),i=Bt(),s=i.createOscillator(),a={sawtooth:c=>1/c,square:c=>c%2===0?0:1/c,triangle:c=>c%2===0?0:1/(c*c)};if(!a[e])throw new Error(`unknown wave type ${e}`);t[0]=0,n[0]=0;let o=1;for(;o<=r;)t[o]=a[e](o),n[o]=0,o++;const l=i.createPeriodicWave(t,n);return s.setPeriodicWave(l),s}function SB(r,e,{n:t,note:n,freq:i,vib:s=0,vibmod:a=.5,noise:o=0,fmh:l=1,fmi:c,fmenv:u="lin",fmattack:p,fmdecay:m,fmsustain:_,fmrelease:v,fmvelocity:I,fmwave:R="sine"}){Bt();let x;!t||r==="sine"?(x=Bt().createOscillator(),x.type=r||"triangle"):x=_B(t,r),n=n||36,typeof n=="string"&&(n=iu(n)),!i&&typeof n=="number"&&(i=BI(n)),x.frequency.value=Number(i),x.start(e);let $,Z;if(c){const{node:S,stop:N}=fB(x,l,c,R);[p,m,_,v,I].find(k=>k!==void 0)?(p=p??.001,m=m??.001,_=_??1,v=v??.001,I=I??1,Z=l_(p,m,_,v,I,e),u==="exp"&&(Z=z3(p,m,_,v,I,e),Z.node.maxValue=c*2,Z.node.minValue=1e-5),S.connect(Z.node),Z.node.connect(x.frequency)):S.connect(x.frequency),$=N}let f;if(s>0){f=Bt().createOscillator(),f.frequency.value=s;const S=Bt().createGain();S.gain.value=a*100,f.connect(S),S.connect(x.detune),f.start(e)}let E;return o&&(E=pB(x,o,e)),{node:(E==null?void 0:E.node)||x,stop:S=>{f==null||f.stop(S),E==null||E.stop(S),$==null||$(S),x.stop(S)},triggerRelease:S=>{Z==null||Z.stop(S)}}}function OB(r=1,e=.05,t=220,n=0,i=0,s=.1,a=0,o=1,l=0,c=0,u=0,p=0,m=0,_=0,v=0,I=0,R=0,x=1,$=0,Z=0){let f=Math.PI*2,E=Bt().sampleRate,S=K=>K>0?1:-1,N=l*=500*f/E/E,k=t*=(1+e*2*Math.random()-e)*f/E,L=[],M=0,G=0,te=0,re=1,ne=0,ee=0,B=0,Q,j;for(n=n*E+9,$*=E,i*=E,s*=E,R*=E,c*=500*f/E**3,v*=f/E,u*=f/E,p*=E,m=m*E|0,j=n+$+i+s+R|0;te1?a>2?a>3?Math.sin((M%f)**3):Math.max(Math.min(Math.tan(M),1),-1):1-(2*M/f%2+2)%2:1-4*Math.abs(Math.round(M/f)-M/f):Math.sin(M),B=(m?1-Z+Z*Math.sin(f*te/m):1)*S(B)*Math.abs(B)**o*r*1*(tete?0:(tep&&(t+=u,k+=u,re=0),m&&!(++ne%m)&&(t=k,l=N,re||(re=1));return L}const EB=(r,e)=>{let{s:t,note:n=36,freq:i,zrand:s=0,attack:a=0,decay:o=0,sustain:l=.8,release:c=.1,curve:u=1,slide:p=0,deltaSlide:m=0,pitchJump:_=0,pitchJumpTime:v=0,lfo:I=0,znoise:R=0,zmod:x=0,zcrush:$=0,zdelay:Z=0,tremolo:f=0,duration:E=.2,zzfx:S}=r;const N=Math.max(E-a-o,0);typeof n=="string"&&(n=iu(n)),!i&&typeof n=="number"&&(i=BI(n)),t=t.replace("z_","");const k=["sine","triangle","sawtooth","tan","noise"].indexOf(t)||0;u=t==="square"?0:u;const L=OB(...S||[.25,s,i,a,N,c,k,u,p,m,_,v,I,R,x,$,Z,l,o,f]),M=Bt(),G=M.createBuffer(1,L.length,M.sampleRate);G.getChannelData(0).set(L);const te=Bt().createBufferSource();return te.buffer=G,te.start(e),{node:te}};function bB(){["zzfx","z_sine","z_sawtooth","z_triangle","z_square","z_tan","z_noise"].forEach(r=>{u_(r,(e,t,n)=>{const{node:i}=EB({s:r,...t},e);return i.onended=()=>{i.disconnect(),n()},{node:i,stop:()=>{}}},{type:"synth",prebake:!0})})}let id;const vB=()=>{};typeof window<"u"&&window.addEventListener("message",r=>{var e;r.data==="strudel-stop"?vB():(e=r.data)!=null&&e.dough&&(id==null||id.node.port.postMessage(r.data))});class Hm extends PI{constructor(t,n){super(n);b(this,"nudge");b(this,"volume",t=>this.updateValue("volume",t));b(this,"vol",this.volume);b(this,"zrand",t=>this.updateValue("zrand",t));b(this,"curve",t=>this.updateValue("curve",t));b(this,"slide",t=>this.updateValue("slide",t));b(this,"sld",this.slide);b(this,"deltaSlide",t=>this.updateValue("deltaSlide",t));b(this,"dslide",this.deltaSlide);b(this,"pitchJump",t=>this.updateValue("pitchJump",t));b(this,"pj",this.pitchJump);b(this,"pitchJumpTime",t=>this.updateValue("pitchJumpTime",t));b(this,"pjt",this.pitchJumpTime);b(this,"lfo",t=>this.updateValue("lfo",t));b(this,"noise",t=>this.updateValue("noise",t));b(this,"zmod",t=>this.updateValue("zmod",t));b(this,"zcrush",t=>this.updateValue("zcrush",t));b(this,"zdelay",t=>this.updateValue("zdelay",t));b(this,"sustainVolume",t=>this.updateValue("sustainVolume",t));b(this,"tremolo",t=>this.updateValue("tremolo",t));b(this,"dur",t=>this.updateValue("dur",t));b(this,"zzfx",t=>this.updateValue("zzfx",t));b(this,"fmi",t=>this.updateValue("fmi",t));b(this,"fmh",t=>this.updateValue("fmh",t));b(this,"fmenv",t=>this.updateValue("fmenv",t));b(this,"fmattack",t=>this.updateValue("fmattack",t));b(this,"fmatk",this.fmattack);b(this,"fmdecay",t=>this.updateValue("fmdecay",t));b(this,"fmdec",this.fmdecay);b(this,"fmsustain",t=>this.updateValue("fmsustain",t));b(this,"fmsus",this.fmsustain);b(this,"fmrelease",t=>this.updateValue("fmrelease",t));b(this,"fmrel",this.fmrelease);b(this,"fmvelocity",t=>this.updateValue("fmvelocity",t));b(this,"fmvel",this.fmvelocity);b(this,"fmwave",t=>this.updateValue("fmwave",t));b(this,"fmw",this.fmwave);b(this,"ftype",t=>this.updateValue("ftype",t));b(this,"fanchor",t=>this.updateValue("fanchor",t));b(this,"attack",t=>this.updateValue("attack",t));b(this,"atk",this.attack);b(this,"decay",t=>this.updateValue("decay",t));b(this,"dec",this.decay);b(this,"sustain",t=>this.updateValue("sustain",t));b(this,"sus",this.sustain);b(this,"release",t=>this.updateValue("release",t));b(this,"rel",this.release);b(this,"adsr",(t,n,i,s)=>(this.attack(t),this.decay(n),this.sustain(i),this.release(s),this));b(this,"lpenv",t=>this.updateValue("lpenv",t));b(this,"lpe",t=>this.updateValue("lpenv",t));b(this,"lpattack",t=>this.updateValue("lpattack",t));b(this,"lpa",this.lpattack);b(this,"lpdecay",t=>this.updateValue("lpdecay",t));b(this,"lpd",this.lpdecay);b(this,"lpsustain",t=>this.updateValue("lpsustain",t));b(this,"lps",this.lpsustain);b(this,"lprelease",t=>this.updateValue("lprelease",t));b(this,"lpr",this.lprelease);b(this,"cutoff",t=>this.updateValue("cutoff",t));b(this,"lpf",this.cutoff);b(this,"resonance",t=>this.updateValue("resonance",Math.min(Math.max(t,0),50)));b(this,"lpq",this.resonance);b(this,"lpadsr",(t,n,i,s,a)=>(this.lpenv(t),this.lpattack(n),this.lpdecay(i),this.lpsustain(s),this.lprelease(a),this));b(this,"hpenv",t=>this.updateValue("hpenv",t));b(this,"hpe",t=>this.updateValue("hpe",t));b(this,"hpattack",t=>this.updateValue("hpattack",t));b(this,"hpa",this.hpattack);b(this,"hpdecay",t=>this.updateValue("hpdecay",t));b(this,"hpd",this.hpdecay);b(this,"hpsustain",t=>this.updateValue("hpsustain",t));b(this,"hpsus",this.hpsustain);b(this,"hprelease",t=>this.updateValue("hprelease",t));b(this,"hpr",this.hprelease);b(this,"hcutoff",t=>this.updateValue("hcutoff",t));b(this,"hpf",this.hcutoff);b(this,"hresonance",t=>this.updateValue("hresonance",t));b(this,"hpq",this.hresonance);b(this,"hpadsr",(t,n,i,s,a)=>(this.hpenv(t),this.hpattack(n),this.hpdecay(i),this.hpsustain(s),this.hprelease(a),this));b(this,"bpenv",t=>this.updateValue("bpenv",t));b(this,"bpe",t=>this.updateValue("bpe",t));b(this,"bpattack",t=>this.updateValue("bpattack",t));b(this,"bpa",this.bpattack);b(this,"bpdecay",t=>this.updateValue("bpdecay",t));b(this,"bpd",this.bpdecay);b(this,"bpsustain",t=>this.updateValue("bpsustain",t));b(this,"bps",this.bpsustain);b(this,"bprelease",t=>this.updateValue("bprelease",t));b(this,"bpr",this.bprelease);b(this,"bandf",t=>this.updateValue("bandf",t));b(this,"bpf",this.bandf);b(this,"bandq",t=>this.updateValue("bandq",t));b(this,"bpq",this.bandq);b(this,"bpadsr",(t,n,i,s,a)=>(this.bpenv(t),this.bpattack(n),this.bpdecay(i),this.bpsustain(s),this.bprelease(a),this));b(this,"freq",t=>this.updateValue("freq",t));b(this,"f",this.freq);b(this,"vib",t=>this.updateValue("vib",t));b(this,"vibmod",t=>this.updateValue("vibmod",t));b(this,"fm",t=>{if(typeof t=="number")this.values.fmi=t;else{let n=t.split(":");this.values.fmi=parseFloat(n[0]),n.length>1&&(this.values.fmh=parseFloat(n[1]))}return this});b(this,"loop",t=>this.updateValue("loop",t));b(this,"loopBegin",t=>this.updateValue("loopBegin",t));b(this,"loopEnd",t=>this.updateValue("loopEnd",t));b(this,"begin",t=>this.updateValue("begin",t));b(this,"end",t=>this.updateValue("end",t));b(this,"gain",t=>this.updateValue("gain",t));b(this,"dbgain",t=>this.updateValue("gain",Math.min(Math.pow(10,t/20),10)));b(this,"db",this.dbgain);b(this,"velocity",t=>this.updateValue("velocity",t));b(this,"vel",this.velocity);b(this,"pan",t=>this.updateValue("pan",t));b(this,"sound",t=>this.updateValue("s",t));b(this,"chord",(t,...n)=>(typeof t=="string"?t=v3(t).map(s=>({note:s,freq:Kr(s)})):t instanceof Array&&typeof t[0]=="number"?t=t.map(i=>({note:i,freq:Kr(i)})):typeof t=="number"&&n.length>0&&(t=[t,...n].map(i=>({note:i,freq:Kr(i)}))),this.updateValue("chord",t)));b(this,"invert",(t=0)=>{if(this.values.chord){let n=this.values.chord.map(s=>s.note);n=t<0?[...n].reverse():n;for(let s=0;s({note:s,freq:Kr(s)}));return this.updateValue("chord",i)}else return this});b(this,"snd",this.sound);b(this,"cut",t=>this.updateValue("cut",t));b(this,"clip",t=>this.updateValue("clip",t));b(this,"n",t=>this.updateValue("n",t));b(this,"note",t=>typeof t=="string"?this.updateValue("note",Fr(t)):typeof t==null||t==null?this.updateValue("note",0).updateValue("gain",0):this.updateValue("note",t));b(this,"speed",t=>this.updateValue("speed",t));b(this,"spd",this.speed);b(this,"coarse",t=>this.updateValue("coarse",t));b(this,"crush",t=>this.updateValue("crush",t));b(this,"shape",t=>this.updateValue("shape",t));b(this,"vowel",t=>this.updateValue("vowel",t));b(this,"vow",this.vowel);b(this,"delay",t=>this.updateValue("delay",t));b(this,"del",this.delay);b(this,"delayfeedback",t=>this.updateValue("delayfeedback",t));b(this,"delayfb",this.delayfeedback);b(this,"delaytime",t=>this.updateValue("delaytime",t));b(this,"delayt",this.delaytime);b(this,"orbit",t=>this.updateValue("orbit",t));b(this,"o",this.orbit);b(this,"room",t=>this.updateValue("room",t));b(this,"rm",this.room);b(this,"roomfade",t=>this.updateValue("roomfade",t));b(this,"rfade",this.roomfade);b(this,"roomlp",t=>this.updateValue("roomlp",t));b(this,"rlp",this.roomlp);b(this,"roomdim",t=>this.updateValue("roomdim",t));b(this,"rdim",this.roomdim);b(this,"size",t=>this.updateValue("roomsize",t));b(this,"sz",this.size);b(this,"comp",t=>this.updateValue("compressor",t));b(this,"cmp",this.comp);b(this,"ratio",t=>this.updateValue("compressorRatio",t));b(this,"rt",this.ratio);b(this,"knee",t=>this.updateValue("compressorKnee",t));b(this,"kn",this.knee);b(this,"compAttack",t=>this.updateValue("compressorAttack",t));b(this,"cmpa",this.compAttack);b(this,"compRelease",t=>this.updateValue("compressorRelease",t));b(this,"cmpr",this.compRelease);b(this,"stretch",t=>(this.updateValue("unit","c"),this.updateValue("speed",1/t),this.updateValue("cut",t),this));b(this,"modify",t=>{const n=t(this);return n instanceof Object?n:(t(this.values),this.update(),this)});b(this,"update",()=>{const[t,n]=i_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.freq=Kr(t)});b(this,"out",()=>{this.values.chord?this.values.chord.forEach(t=>{const n={...this.values};n.freq=t.freq,CE(n,this.nudge,this.values.dur)}):CE(this.values,this.nudge,this.values.dur)});this.app=n,this.nudge=n.dough_nudge/100,typeof t=="string"?t.includes(":")?this.values={s:t.split(":")[0],n:t.split(":")[1],dur:n.clock.convertPulseToSecond(n.clock.ppqn)}:this.values={s:t,dur:.5}:this.values=t}updateValue(t,n){return this.values[t]=n,this}}class Wm extends PI{constructor(t,n){super(n);b(this,"midiConnection");b(this,"chord",t=>(this.values.chord=t,this));b(this,"note",t=>(this.values.note=t,this));b(this,"sustain",t=>(this.values.sustain=t,this));b(this,"channel",t=>(this.values.channel=t,this));b(this,"port",t=>(this.values.port=this.midiConnection.getMidiOutputIndex(t),this));b(this,"add",t=>(this.values.note+=t,this));b(this,"modify",t=>{const n=t(this);return n instanceof Object?n:(t(this.values),this.update(),this)});b(this,"bend",t=>(this.values.bend=t,this));b(this,"random",(t=0,n=127)=>(t=Math.min(Math.max(t,0),127),n=Math.min(Math.max(n,0),127),this.values.note=Math.floor(this.randomGen()*(n-t+1))+t,this));b(this,"update",()=>{const[t,n]=i_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.note=t,this.values.freq=Kr(t),n&&(this.values.bend=n)});b(this,"out",()=>{function t(n,i){const s=i&&i.channel?i.channel:0,a=n.values.channel?n.values.channel:s,o=n.values.velocity?n.values.velocity:100,l=i&&i.note?i.note:60,c=n.values.note?n.values.note:l,u=n.values.sustain?n.values.sustain*n.app.clock.pulse_duration*n.app.api.ppqn():n.app.clock.pulse_duration*n.app.api.ppqn(),p=n.values.bend?n.values.bend:void 0,m=n.values.port?n.midiConnection.getMidiOutputIndex(n.values.port):n.midiConnection.getCurrentMidiPortIndex();n.midiConnection.sendMidiNote(c,a,o,u,m,p)}this.values.chord?this.values.chord.forEach(n=>{t(this,n)}):t(this)});this.app=n,typeof t=="number"?this.values.note=t:this.values=t,this.midiConnection=n.api.MidiConnection}}const co=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,FI=new Set,Xm=typeof process=="object"&&process?process:{},YI=(r,e,t,n)=>{typeof Xm.emitWarning=="function"?Xm.emitWarning(r,e,t,n):console.error(`[${t}] ${e}: ${r}`)};let Uc=globalThis.AbortController,IE=globalThis.AbortSignal;var _T;if(typeof Uc>"u"){IE=class{constructor(){b(this,"onabort");b(this,"_onabort",[]);b(this,"reason");b(this,"aborted",!1)}addEventListener(n,i){this._onabort.push(i)}},Uc=class{constructor(){b(this,"signal",new IE);e()}abort(n){var i,s;if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(const a of this.signal._onabort)a(n);(s=(i=this.signal).onabort)==null||s.call(i,n)}}};let r=((_T=Xm.env)==null?void 0:_T.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{r&&(r=!1,YI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const TB=r=>!FI.has(r),Bi=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),$I=r=>Bi(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?tc:null:null;class tc extends Array{constructor(e){super(e),this.fill(0)}}var cs;const ha=class ha{constructor(e,t){b(this,"heap");b(this,"length");if(!V(ha,cs))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){const t=$I(e);if(!t)return[];We(ha,cs,!0);const n=new ha(e,t);return We(ha,cs,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};cs=new WeakMap,at(ha,cs,!1);let Zm=ha;var Nr,er,wr,Dr,us,on,xr,ln,Lt,nt,Ln,tr,Cn,fn,kr,mn,gi,_i,Lr,Mr,qi,Mn,Ko,jm,Oa,Si,jo,nr,Qc,GI,Ea,ds,Jo,Vr,Ui,zr,Fi,el,Jm,ps,nc,hs,rc,Dt,Ft,tl,eg,ba,Eo;const E_=class E_{constructor(e){at(this,Ko);at(this,Qc);at(this,Vr);at(this,zr);at(this,el);at(this,ps);at(this,hs);at(this,Dt);at(this,tl);at(this,ba);at(this,Nr,void 0);at(this,er,void 0);at(this,wr,void 0);at(this,Dr,void 0);at(this,us,void 0);b(this,"ttl");b(this,"ttlResolution");b(this,"ttlAutopurge");b(this,"updateAgeOnGet");b(this,"updateAgeOnHas");b(this,"allowStale");b(this,"noDisposeOnSet");b(this,"noUpdateTTL");b(this,"maxEntrySize");b(this,"sizeCalculation");b(this,"noDeleteOnFetchRejection");b(this,"noDeleteOnStaleGet");b(this,"allowStaleOnFetchAbort");b(this,"allowStaleOnFetchRejection");b(this,"ignoreFetchAbort");at(this,on,void 0);at(this,xr,void 0);at(this,ln,void 0);at(this,Lt,void 0);at(this,nt,void 0);at(this,Ln,void 0);at(this,tr,void 0);at(this,Cn,void 0);at(this,fn,void 0);at(this,kr,void 0);at(this,mn,void 0);at(this,gi,void 0);at(this,_i,void 0);at(this,Lr,void 0);at(this,Mr,void 0);at(this,qi,void 0);at(this,Mn,void 0);at(this,Oa,()=>{});at(this,Si,()=>{});at(this,jo,()=>{});at(this,nr,()=>!1);at(this,Ea,e=>{});at(this,ds,(e,t,n)=>{});at(this,Jo,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:l,dispose:c,disposeAfter:u,noDisposeOnSet:p,noUpdateTTL:m,maxSize:_=0,maxEntrySize:v=0,sizeCalculation:I,fetchMethod:R,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:$,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:f,ignoreFetchAbort:E}=e;if(t!==0&&!Bi(t))throw new TypeError("max option must be a nonnegative integer");const S=t?$I(t):Array;if(!S)throw new Error("invalid max value: "+t);if(We(this,Nr,t),We(this,er,_),this.maxEntrySize=v||V(this,er),this.sizeCalculation=I,this.sizeCalculation){if(!V(this,er)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(R!==void 0&&typeof R!="function")throw new TypeError("fetchMethod must be a function if specified");if(We(this,us,R),We(this,qi,!!R),We(this,ln,new Map),We(this,Lt,new Array(t).fill(void 0)),We(this,nt,new Array(t).fill(void 0)),We(this,Ln,new S(t)),We(this,tr,new S(t)),We(this,Cn,0),We(this,fn,0),We(this,kr,Zm.create(t)),We(this,on,0),We(this,xr,0),typeof c=="function"&&We(this,wr,c),typeof u=="function"?(We(this,Dr,u),We(this,mn,[])):(We(this,Dr,void 0),We(this,mn,void 0)),We(this,Mr,!!V(this,wr)),We(this,Mn,!!V(this,Dr)),this.noDisposeOnSet=!!p,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!Z,this.allowStaleOnFetchAbort=!!f,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(V(this,er)!==0&&!Bi(V(this,er)))throw new TypeError("maxSize must be a positive integer if specified");if(!Bi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");ze(this,Qc,GI).call(this)}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!$,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=Bi(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!Bi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");ze(this,Ko,jm).call(this)}if(V(this,Nr)===0&&this.ttl===0&&V(this,er)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!V(this,Nr)&&!V(this,er)){const N="LRU_CACHE_UNBOUNDED";TB(N)&&(FI.add(N),YI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",N,E_))}}static unsafeExposeInternals(e){return{starts:V(e,_i),ttls:V(e,Lr),sizes:V(e,gi),keyMap:V(e,ln),keyList:V(e,Lt),valList:V(e,nt),next:V(e,Ln),prev:V(e,tr),get head(){return V(e,Cn)},get tail(){return V(e,fn)},free:V(e,kr),isBackgroundFetch:t=>{var n;return ze(n=e,Dt,Ft).call(n,t)},backgroundFetch:(t,n,i,s)=>{var a;return ze(a=e,hs,rc).call(a,t,n,i,s)},moveToTail:t=>{var n;return ze(n=e,ba,Eo).call(n,t)},indexes:t=>{var n;return ze(n=e,Vr,Ui).call(n,t)},rindexes:t=>{var n;return ze(n=e,zr,Fi).call(n,t)},isStale:t=>{var n;return V(n=e,nr).call(n,t)}}}get max(){return V(this,Nr)}get maxSize(){return V(this,er)}get calculatedSize(){return V(this,xr)}get size(){return V(this,on)}get fetchMethod(){return V(this,us)}get dispose(){return V(this,wr)}get disposeAfter(){return V(this,Dr)}getRemainingTTL(e){return V(this,ln).has(e)?1/0:0}*entries(){for(const e of ze(this,Vr,Ui).call(this))V(this,nt)[e]!==void 0&&V(this,Lt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield[V(this,Lt)[e],V(this,nt)[e]])}*rentries(){for(const e of ze(this,zr,Fi).call(this))V(this,nt)[e]!==void 0&&V(this,Lt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield[V(this,Lt)[e],V(this,nt)[e]])}*keys(){for(const e of ze(this,Vr,Ui).call(this)){const t=V(this,Lt)[e];t!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield t)}}*rkeys(){for(const e of ze(this,zr,Fi).call(this)){const t=V(this,Lt)[e];t!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield t)}}*values(){for(const e of ze(this,Vr,Ui).call(this))V(this,nt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield V(this,nt)[e])}*rvalues(){for(const e of ze(this,zr,Fi).call(this))V(this,nt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield V(this,nt)[e])}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const n of ze(this,Vr,Ui).call(this)){const i=V(this,nt)[n],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,V(this,Lt)[n],this))return this.get(V(this,Lt)[n],t)}}forEach(e,t=this){for(const n of ze(this,Vr,Ui).call(this)){const i=V(this,nt)[n],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Lt)[n],this)}}rforEach(e,t=this){for(const n of ze(this,zr,Fi).call(this)){const i=V(this,nt)[n],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Lt)[n],this)}}purgeStale(){let e=!1;for(const t of ze(this,zr,Fi).call(this,{allowStale:!0}))V(this,nr).call(this,t)&&(this.delete(V(this,Lt)[t]),e=!0);return e}dump(){const e=[];for(const t of ze(this,Vr,Ui).call(this,{allowStale:!0})){const n=V(this,Lt)[t],i=V(this,nt)[t],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;const a={value:s};if(V(this,Lr)&&V(this,_i)){a.ttl=V(this,Lr)[t];const o=co.now()-V(this,_i)[t];a.start=Math.floor(Date.now()-o)}V(this,gi)&&(a.size=V(this,gi)[t]),e.unshift([n,a])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const i=Date.now()-n.start;n.start=co.now()-i}this.set(t,n.value,n)}}set(e,t,n={}){var m,_,v,I,R;if(t===void 0)return this.delete(e),this;const{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:l}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const u=V(this,Jo).call(this,e,t,n.size||0,o);if(this.maxEntrySize&&u>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.delete(e),this;let p=V(this,on)===0?void 0:V(this,ln).get(e);if(p===void 0)p=V(this,on)===0?V(this,fn):V(this,kr).length!==0?V(this,kr).pop():V(this,on)===V(this,Nr)?ze(this,ps,nc).call(this,!1):V(this,on),V(this,Lt)[p]=e,V(this,nt)[p]=t,V(this,ln).set(e,p),V(this,Ln)[V(this,fn)]=p,V(this,tr)[p]=V(this,fn),We(this,fn,p),ml(this,on)._++,V(this,ds).call(this,p,u,l),l&&(l.set="add"),c=!1;else{ze(this,ba,Eo).call(this,p);const x=V(this,nt)[p];if(t!==x){if(V(this,qi)&&ze(this,Dt,Ft).call(this,x)){x.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:$}=x;$!==void 0&&!a&&(V(this,Mr)&&((m=V(this,wr))==null||m.call(this,$,e,"set")),V(this,Mn)&&((_=V(this,mn))==null||_.push([$,e,"set"])))}else a||(V(this,Mr)&&((v=V(this,wr))==null||v.call(this,x,e,"set")),V(this,Mn)&&((I=V(this,mn))==null||I.push([x,e,"set"])));if(V(this,Ea).call(this,p),V(this,ds).call(this,p,u,l),V(this,nt)[p]=t,l){l.set="replace";const $=x&&ze(this,Dt,Ft).call(this,x)?x.__staleWhileFetching:x;$!==void 0&&(l.oldValue=$)}}else l&&(l.set="update")}if(i!==0&&!V(this,Lr)&&ze(this,Ko,jm).call(this),V(this,Lr)&&(c||V(this,jo).call(this,p,i,s),l&&V(this,Si).call(this,l,p)),!a&&V(this,Mn)&&V(this,mn)){const x=V(this,mn);let $;for(;$=x==null?void 0:x.shift();)(R=V(this,Dr))==null||R.call(this,...$)}return this}pop(){var e;try{for(;V(this,on);){const t=V(this,nt)[V(this,Cn)];if(ze(this,ps,nc).call(this,!0),ze(this,Dt,Ft).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(V(this,Mn)&&V(this,mn)){const t=V(this,mn);let n;for(;n=t==null?void 0:t.shift();)(e=V(this,Dr))==null||e.call(this,...n)}}}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,s=V(this,ln).get(e);if(s!==void 0){const a=V(this,nt)[s];if(ze(this,Dt,Ft).call(this,a)&&a.__staleWhileFetching===void 0)return!1;if(V(this,nr).call(this,s))i&&(i.has="stale",V(this,Si).call(this,i,s));else return n&&V(this,Oa).call(this,s),i&&(i.has="hit",V(this,Si).call(this,i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=V(this,ln).get(e);if(i!==void 0&&(n||!V(this,nr).call(this,i))){const s=V(this,nt)[i];return ze(this,Dt,Ft).call(this,s)?s.__staleWhileFetching:s}}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:I,forceRefresh:R=!1,status:x,signal:$}=t;if(!V(this,qi))return x&&(x.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:x});const Z={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:o,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:v,ignoreFetchAbort:_,status:x,signal:$};let f=V(this,ln).get(e);if(f===void 0){x&&(x.fetch="miss");const E=ze(this,hs,rc).call(this,e,f,Z,I);return E.__returned=E}else{const E=V(this,nt)[f];if(ze(this,Dt,Ft).call(this,E)){const M=n&&E.__staleWhileFetching!==void 0;return x&&(x.fetch="inflight",M&&(x.returnedStale=!0)),M?E.__staleWhileFetching:E.__returned=E}const S=V(this,nr).call(this,f);if(!R&&!S)return x&&(x.fetch="hit"),ze(this,ba,Eo).call(this,f),i&&V(this,Oa).call(this,f),x&&V(this,Si).call(this,x,f),E;const N=ze(this,hs,rc).call(this,e,f,Z,I),L=N.__staleWhileFetching!==void 0&&n;return x&&(x.fetch=S?"stale":"refresh",L&&S&&(x.returnedStale=!0)),L?N.__staleWhileFetching:N.__returned=N}}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,o=V(this,ln).get(e);if(o!==void 0){const l=V(this,nt)[o],c=ze(this,Dt,Ft).call(this,l);return a&&V(this,Si).call(this,a,o),V(this,nr).call(this,o)?(a&&(a.get="stale"),c?(a&&n&&l.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?l.__staleWhileFetching:void 0):(s||this.delete(e),a&&n&&(a.returnedStale=!0),n?l:void 0)):(a&&(a.get="hit"),c?l.__staleWhileFetching:(ze(this,ba,Eo).call(this,o),i&&V(this,Oa).call(this,o),l))}else a&&(a.get="miss")}delete(e){var n,i,s,a;let t=!1;if(V(this,on)!==0){const o=V(this,ln).get(e);if(o!==void 0)if(t=!0,V(this,on)===1)this.clear();else{V(this,Ea).call(this,o);const l=V(this,nt)[o];ze(this,Dt,Ft).call(this,l)?l.__abortController.abort(new Error("deleted")):(V(this,Mr)||V(this,Mn))&&(V(this,Mr)&&((n=V(this,wr))==null||n.call(this,l,e,"delete")),V(this,Mn)&&((i=V(this,mn))==null||i.push([l,e,"delete"]))),V(this,ln).delete(e),V(this,Lt)[o]=void 0,V(this,nt)[o]=void 0,o===V(this,fn)?We(this,fn,V(this,tr)[o]):o===V(this,Cn)?We(this,Cn,V(this,Ln)[o]):(V(this,Ln)[V(this,tr)[o]]=V(this,Ln)[o],V(this,tr)[V(this,Ln)[o]]=V(this,tr)[o]),ml(this,on)._--,V(this,kr).push(o)}}if(V(this,Mn)&&((s=V(this,mn))!=null&&s.length)){const o=V(this,mn);let l;for(;l=o==null?void 0:o.shift();)(a=V(this,Dr))==null||a.call(this,...l)}return t}clear(){var e,t,n;for(const i of ze(this,zr,Fi).call(this,{allowStale:!0})){const s=V(this,nt)[i];if(ze(this,Dt,Ft).call(this,s))s.__abortController.abort(new Error("deleted"));else{const a=V(this,Lt)[i];V(this,Mr)&&((e=V(this,wr))==null||e.call(this,s,a,"delete")),V(this,Mn)&&((t=V(this,mn))==null||t.push([s,a,"delete"]))}}if(V(this,ln).clear(),V(this,nt).fill(void 0),V(this,Lt).fill(void 0),V(this,Lr)&&V(this,_i)&&(V(this,Lr).fill(0),V(this,_i).fill(0)),V(this,gi)&&V(this,gi).fill(0),We(this,Cn,0),We(this,fn,0),V(this,kr).length=0,We(this,xr,0),We(this,on,0),V(this,Mn)&&V(this,mn)){const i=V(this,mn);let s;for(;s=i==null?void 0:i.shift();)(n=V(this,Dr))==null||n.call(this,...s)}}};Nr=new WeakMap,er=new WeakMap,wr=new WeakMap,Dr=new WeakMap,us=new WeakMap,on=new WeakMap,xr=new WeakMap,ln=new WeakMap,Lt=new WeakMap,nt=new WeakMap,Ln=new WeakMap,tr=new WeakMap,Cn=new WeakMap,fn=new WeakMap,kr=new WeakMap,mn=new WeakMap,gi=new WeakMap,_i=new WeakMap,Lr=new WeakMap,Mr=new WeakMap,qi=new WeakMap,Mn=new WeakMap,Ko=new WeakSet,jm=function(){const e=new tc(V(this,Nr)),t=new tc(V(this,Nr));We(this,Lr,e),We(this,_i,t),We(this,jo,(s,a,o=co.now())=>{if(t[s]=a!==0?o:0,e[s]=a,a!==0&&this.ttlAutopurge){const l=setTimeout(()=>{V(this,nr).call(this,s)&&this.delete(V(this,Lt)[s])},a+1);l.unref&&l.unref()}}),We(this,Oa,s=>{t[s]=e[s]!==0?co.now():0}),We(this,Si,(s,a)=>{if(e[a]){const o=e[a],l=t[a];s.ttl=o,s.start=l,s.now=n||i();const c=s.now-l;s.remainingTTL=o-c}});let n=0;const i=()=>{const s=co.now();if(this.ttlResolution>0){n=s;const a=setTimeout(()=>n=0,this.ttlResolution);a.unref&&a.unref()}return s};this.getRemainingTTL=s=>{const a=V(this,ln).get(s);if(a===void 0)return 0;const o=e[a],l=t[a];if(o===0||l===0)return 1/0;const c=(n||i())-l;return o-c},We(this,nr,s=>e[s]!==0&&t[s]!==0&&(n||i())-t[s]>e[s])},Oa=new WeakMap,Si=new WeakMap,jo=new WeakMap,nr=new WeakMap,Qc=new WeakSet,GI=function(){const e=new tc(V(this,Nr));We(this,xr,0),We(this,gi,e),We(this,Ea,t=>{We(this,xr,V(this,xr)-e[t]),e[t]=0}),We(this,Jo,(t,n,i,s)=>{if(ze(this,Dt,Ft).call(this,n))return 0;if(!Bi(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,t),!Bi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),We(this,ds,(t,n,i)=>{if(e[t]=n,V(this,er)){const s=V(this,er)-e[t];for(;V(this,xr)>s;)ze(this,ps,nc).call(this,!0)}We(this,xr,V(this,xr)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=V(this,xr))})},Ea=new WeakMap,ds=new WeakMap,Jo=new WeakMap,Vr=new WeakSet,Ui=function*({allowStale:e=this.allowStale}={}){if(V(this,on))for(let t=V(this,fn);!(!ze(this,el,Jm).call(this,t)||((e||!V(this,nr).call(this,t))&&(yield t),t===V(this,Cn)));)t=V(this,tr)[t]},zr=new WeakSet,Fi=function*({allowStale:e=this.allowStale}={}){if(V(this,on))for(let t=V(this,Cn);!(!ze(this,el,Jm).call(this,t)||((e||!V(this,nr).call(this,t))&&(yield t),t===V(this,fn)));)t=V(this,Ln)[t]},el=new WeakSet,Jm=function(e){return e!==void 0&&V(this,ln).get(V(this,Lt)[e])===e},ps=new WeakSet,nc=function(e){var s,a;const t=V(this,Cn),n=V(this,Lt)[t],i=V(this,nt)[t];return V(this,qi)&&ze(this,Dt,Ft).call(this,i)?i.__abortController.abort(new Error("evicted")):(V(this,Mr)||V(this,Mn))&&(V(this,Mr)&&((s=V(this,wr))==null||s.call(this,i,n,"evict")),V(this,Mn)&&((a=V(this,mn))==null||a.push([i,n,"evict"]))),V(this,Ea).call(this,t),e&&(V(this,Lt)[t]=void 0,V(this,nt)[t]=void 0,V(this,kr).push(t)),V(this,on)===1?(We(this,Cn,We(this,fn,0)),V(this,kr).length=0):We(this,Cn,V(this,Ln)[t]),V(this,ln).delete(n),ml(this,on)._--,t},hs=new WeakSet,rc=function(e,t,n,i){const s=t===void 0?void 0:V(this,nt)[t];if(ze(this,Dt,Ft).call(this,s))return s;const a=new Uc,{signal:o}=n;o==null||o.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});const l={signal:a.signal,options:n,context:i},c=(I,R=!1)=>{const{aborted:x}=a.signal,$=n.ignoreFetchAbort&&I!==void 0;if(n.status&&(x&&!R?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,$&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),x&&!$&&!R)return p(a.signal.reason);const Z=_;return V(this,nt)[t]===_&&(I===void 0?Z.__staleWhileFetching?V(this,nt)[t]=Z.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,I,l.options))),I},u=I=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=I),p(I)),p=I=>{const{aborted:R}=a.signal,x=R&&n.allowStaleOnFetchAbort,$=x||n.allowStaleOnFetchRejection,Z=$||n.noDeleteOnFetchRejection,f=_;if(V(this,nt)[t]===_&&(!Z||f.__staleWhileFetching===void 0?this.delete(e):x||(V(this,nt)[t]=f.__staleWhileFetching)),$)return n.status&&f.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw I},m=(I,R)=>{var $;const x=($=V(this,us))==null?void 0:$.call(this,e,s,l);x&&x instanceof Promise&&x.then(Z=>I(Z===void 0?void 0:Z),R),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(I(void 0),n.allowStaleOnFetchAbort&&(I=Z=>c(Z,!0)))})};n.status&&(n.status.fetchDispatched=!0);const _=new Promise(m).then(c,u),v=Object.assign(_,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,v,{...l.options,status:void 0}),t=V(this,ln).get(e)):V(this,nt)[t]=v,v},Dt=new WeakSet,Ft=function(e){if(!V(this,qi))return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Uc},tl=new WeakSet,eg=function(e,t){V(this,tr)[t]=e,V(this,Ln)[e]=t},ba=new WeakSet,Eo=function(e){e!==V(this,fn)&&(e===V(this,Cn)?We(this,Cn,V(this,Ln)[e]):ze(this,tl,eg).call(this,V(this,tr)[e],V(this,Ln)[e]),ze(this,tl,eg).call(this,V(this,fn),e),We(this,fn,e))};let Km=E_;const No=class No{constructor(){b(this,"_fallbackMethod",()=>No.createSkipProxy());b(this,"out",()=>{})}};b(No,"createSkipProxy",()=>{const e=new No;return new Proxy(e,{get(t,n,i){return typeof t[n]>"u"?t._fallbackMethod:t[n]},set(t,n,i,s){return!1}})});let Fc=No;const wo=class wo extends s_{constructor(t,n){super(n);b(this,"_fallbackMethod",()=>wo.createRestProxy(this.values.length,this.app));b(this,"out",()=>{});this.values.length=t}};b(wo,"createRestProxy",(t,n)=>{const i=new wo(t,n);return new Proxy(i,{get(s,a,o){return typeof s[a]>"u"?s._fallbackMethod:s[a]},set(s,a,o,l){return!1}})});let Yc=wo;class CB extends s_{constructor(t,n,i){super(i);b(this,"input");b(this,"ziffers");b(this,"initCallTime",0);b(this,"startCallTime",0);b(this,"lastCallTime",0);b(this,"waitTime",0);b(this,"startBeat",0);b(this,"played",!1);b(this,"current");b(this,"retro",!1);b(this,"index",-1);b(this,"zid","");b(this,"options",{});b(this,"skipIndex",0);b(this,"endTime",0);b(this,"next",()=>(this.current=this.ziffers.next(),this.played=!0,this.current));b(this,"pulseToSecond",t=>this.app.clock.convertPulseToSecond(t));b(this,"firstRun",()=>this.notStarted());b(this,"atTheBeginning",()=>this.skipIndex===0&&this.ziffers.index<=0);b(this,"origin",()=>this.app.clock.pulses_since_origin+1);b(this,"pulse",()=>this.app.clock.time_position.pulse);b(this,"beat",()=>this.app.clock.time_position.beat);b(this,"nextBeat",()=>this.app.clock.next_beat_in_ticks);b(this,"nextBeatInTicks",()=>this.app.clock.next_beat_in_ticks);b(this,"areWeThereYet",()=>{this.app.clock.pulses_since_origin=this.nextBeatInTicks())&&this.origin()>=this.waitTime,n=this.current&&this.pulseToSecond(this.origin())>=this.pulseToSecond(this.lastCallTime)+this.pulseToSecond(this.current.duration*4*this.app.clock.ppqn)&&this.origin()>=this.waitTime,i=t||n;return this.skipIndex=i?0:this.skipIndex+1,this.index=i?this.index+1:this.index,i&&this.notStarted()&&(this.initCallTime=this.app.clock.pulses_since_origin),this.atTheBeginning()&&(this.startCallTime=this.app.clock.pulses_since_origin),i});b(this,"lead",()=>this.voiceleading());b(this,"invert",t=>(this.atTheBeginning()&&this.ziffers.invert(t),this));b(this,"out",()=>{});this.app=i,this.input=t,this.options=n,this.ziffers=new D3(t,n)}get ticks(){return this.ziffers.duration*4*this.app.clock.ppqn}nextEndTime(){return this.startCallTime+this.ticks}updateLastCallTime(){(this.notStarted()||this.played)&&(this.lastCallTime=this.app.clock.pulses_since_origin,this.played=!1)}notStarted(){return this.ziffers.notStarted()}sound(t){if(this.areWeThereYet()){const n=this.next(),i=this.app.clock.convertPulseToSecond(n.duration*4*this.app.clock.ppqn);if(n instanceof ni){const s=n.getExisting("freq","pitch","key","scale","octave","parsedScale");return n.sound&&(t=n.sound),n.soundIndex&&(s.n=n.soundIndex),s.dur=i,new Hm(s,this.app).sound(t||"sine")}else if(n instanceof Ra){const s=n.pitches.map(o=>o.getExisting("freq","pitch","key","scale","octave","parsedScale")),a={dur:i};return t&&(a.s=t),new Hm(a,this.app).chord(s)}else if(n instanceof qm)return Yc.createRestProxy(n.duration,this.app)}else return Fc.createSkipProxy()}midi(t=void 0){if(this.areWeThereYet()){const n=this.next(),i=n.getExisting("note","pitch","bend","key","scale","octave","parsedScale");if(n instanceof ni){n.soundIndex&&(i.channel=n.soundIndex);const s=new Wm(i,this.app);return t?s.note(t):s}else{if(n instanceof qm)return Yc.createRestProxy(n.duration,this.app);if(n instanceof Ra){const s=n.midiChord();return new Wm(i,this.app).chord(s)}}}else return Fc.createSkipProxy()}scale(t){return this.atTheBeginning()&&this.ziffers.scale(t),this}key(t){return this.atTheBeginning()&&this.ziffers.key(t),this}octave(t){return this.atTheBeginning()&&this.ziffers.octave(t),this}voiceleading(){return this.atTheBeginning()&&this.ziffers.lead(),this}retrograde(){return this.atTheBeginning()&&this.ziffers.retrograde(),this}wait(t){if(this.atTheBeginning()){if(typeof t=="function"){const n=this.app.api.patternCache.get(t.name);return n&&(this.waitTime=n.nextEndTime()),this}this.waitTime=this.origin()+Math.ceil(t*4*this.app.clock.ppqn)}return this}sync(t){if(this.atTheBeginning()&&this.notStarted()){const n=this.app.clock.pulses_since_origin,i=typeof t=="function"?t.name:t;if(n>0){const s=this.app.api.patternCache.get(i);if(s){const a=s.ziffers.duration,o=s.startCallTime,l=a*4*this.app.clock.ppqn;this.waitTime=o+l}}}return this}}const yB=r=>r[0]==="{"&&r[r.length-1]==="}",uo=(r,e)=>{if(yB(r)){const t=JSON.parse(r);return JSON.stringify({...t,...e})}else return JSON.stringify({...e,text:r})},AB=r=>{String.prototype.speak=function(){const e=JSON.parse(this.valueOf());new QI({...e,text:e.text}).speak().then(()=>{}).catch(t=>{console.log("Error speaking:",t)})},String.prototype.rate=function(e){return uo(this.valueOf(),{rate:e})},String.prototype.pitch=function(e){return uo(this.valueOf(),{pitch:e})},String.prototype.lang=function(e){return uo(this.valueOf(),{lang:e})},String.prototype.volume=function(e){return uo(this.valueOf(),{volume:e})},String.prototype.voice=function(e){return uo(this.valueOf(),{voice:e})},String.prototype.z=function(e={}){return r.z(this.valueOf(),e)},String.prototype.z0=function(e={}){return r.z0(this.valueOf(),e)},String.prototype.z1=function(e={}){return r.z1(this.valueOf(),e)},String.prototype.z2=function(e={}){return r.z2(this.valueOf(),e)},String.prototype.z3=function(e={}){return r.z3(this.valueOf(),e)},String.prototype.z4=function(e={}){return r.z4(this.valueOf(),e)},String.prototype.z5=function(e={}){return r.z5(this.valueOf(),e)},String.prototype.z6=function(e={}){return r.z6(this.valueOf(),e)},String.prototype.z7=function(e={}){return r.z7(this.valueOf(),e)},String.prototype.z8=function(e={}){return r.z8(this.valueOf(),e)},String.prototype.z9=function(e={}){return r.z9(this.valueOf(),e)},String.prototype.z10=function(e={}){return r.z10(this.valueOf(),e)},String.prototype.z11=function(e={}){return r.z11(this.valueOf(),e)},String.prototype.z12=function(e={}){return r.z12(this.valueOf(),e)},String.prototype.z13=function(e={}){return r.z13(this.valueOf(),e)},String.prototype.z14=function(e={}){return r.z14(this.valueOf(),e)},String.prototype.z15=function(e={}){return r.z15(this.valueOf(),e)},String.prototype.z16=function(e={}){return r.z16(this.valueOf(),e)},String.prototype.note=function(){try{return parseInt(this.valueOf())}catch{return Fr(this.valueOf())}}};let ad;class QI{constructor(e){b(this,"speak",()=>new Promise((e,t)=>{if(this.options.text){const n=window.speechSynthesis;n.speaking&&n.cancel();const i=new SpeechSynthesisUtterance(this.options.text);i.rate=this.options.rate||1,i.pitch=this.options.pitch||1,i.volume=this.options.volume||1,this.options.voice&&(i.voice=n.getVoices()[this.options.voice]),this.options.lang&&(this.options.lang.length===2?i.lang=`${this.options.lang}-${this.options.lang.toUpperCase()}`:this.options.lang.length===5?i.lang=this.options.lang:i.lang="en-US"),i.onend=()=>{e()},i.onerror=s=>{t(s)},n.speaking?(n.cancel(),ad&&clearTimeout(ad),ad=setTimeout(()=>{n.speak(i)},200)):n.speak(i)}else t("No text provided")}));this.options=e}}async function RE(){return Promise.all([J3(),Gi("github:tidalcycles/Dirt-Samples/master").then(()=>gB()),bB(),Gi("github:Bubobubobubobubo/Dough-Fox/main"),Gi("github:Bubobubobubobubo/Dough-Samples/main"),Gi("github:Bubobubobubobubo/Dough-Amiga/main"),Gi("github:Bubobubobubobubo/Dough-Amen/main"),Gi("github:Bubobubobubobubo/Dough-Waveforms/main")])}class IB{constructor(e){b(this,"variables",{});b(this,"codeExamples",{});b(this,"counters",{});b(this,"_drunk",new L3(-100,100,!1));b(this,"randomGen",Math.random);b(this,"currentSeed");b(this,"localSeeds",new Map);b(this,"patternCache",new Km({max:1e3,ttl:1e3*60*5}));b(this,"errorTimeoutID",0);b(this,"printTimeoutID",0);b(this,"MidiConnection");b(this,"scale_aid");b(this,"load");b(this,"_loadUniverseFromInterface",e=>{this.app.loadUniverse(e),this.app.openBuffersModal()});b(this,"_deleteUniverseFromInterface",e=>{delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"_playDocExample",e=>{let t=this.app.universes[this.app.selected_universe];this.app.exampleIsPlaying=!0,t.example?t.example.candidate=e||this.app.selectedExample:(t.example={candidate:"",committed:"",evaluations:0},t.example.candidate=e||this.app.selectedExample),this.play()});b(this,"_stopDocExample",()=>{let e=this.app.universes[this.app.selected_universe];(e==null?void 0:e.example)!==void 0&&(this.app.exampleIsPlaying=!1,e.example.candidate="",e.example.committed=""),this.pause()});b(this,"_playDocExampleOnce",e=>{let t=this.app.universes[this.app.selected_universe];(t==null?void 0:t.example)!==void 0&&(t.example.candidate="",t.example.committed=""),this.play(),this.app.exampleIsPlaying=!0,FP(this.app,e)});b(this,"_all_samples",()=>c_.get());b(this,"_reportError",e=>{console.log(e),clearTimeout(this.errorTimeoutID),clearTimeout(this.printTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="color-red-800",this.app.error_line.classList.remove("hidden"),this.errorTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),2e3)});b(this,"_logMessage",e=>{console.log(e),clearTimeout(this.printTimeoutID),clearTimeout(this.errorTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="white",this.app.error_line.classList.remove("hidden"),this.printTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),4e3)});b(this,"time",()=>this.app.audioContext.currentTime);b(this,"play",()=>{this.app.setButtonHighlighting("play",!0),this.MidiConnection.sendStartMessage(),this.app.clock.start()});b(this,"pause",()=>{this.app.setButtonHighlighting("pause",!0),this.MidiConnection.sendStopMessage(),this.app.clock.pause()});b(this,"stop",()=>{this.app.setButtonHighlighting("stop",!0),this.MidiConnection.sendStopMessage(),this.app.clock.stop()});b(this,"silence",this.stop);b(this,"hush",this.stop);b(this,"warp",e=>{this.app.clock.tick=e,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e)});b(this,"beat_warp",e=>{this.app.clock.tick=e*this.app.clock.ppqn,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e*this.app.clock.ppqn)});b(this,"onmousemove",e=>{this.app._mouseX=e.pageX,this.app._mouseY=e.pageY});b(this,"mouseX",()=>this.app._mouseX);b(this,"mouseY",()=>this.app._mouseY);b(this,"noteX",()=>Math.floor(this.app._mouseX/document.body.clientWidth*127));b(this,"noteY",()=>Math.floor(this.app._mouseY/document.body.clientHeight*127));b(this,"script",(...e)=>{e.forEach(t=>{ls(this.app,this.app.universes[this.app.selected_universe].locals[t])})});b(this,"s",this.script);b(this,"delete_script",e=>{this.app.universes[this.app.selected_universe].locals[e]={candidate:"",committed:"",evaluations:0}});b(this,"cs",this.delete_script);b(this,"copy_script",(e,t)=>{this.app.universes[this.app.selected_universe].locals[t]={...this.app.universes[this.app.selected_universe].locals[e]}});b(this,"cps",this.copy_script);b(this,"copy_universe",(e,t)=>{this.app.universes[t]={...this.app.universes[e]}});b(this,"delete_universe",e=>{this.app.selected_universe===e&&(this.app.selected_universe="Default"),delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"big_bang",()=>{confirm("Are you sure you want to delete all universes?")&&(this.app.universes={...Io},this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings)),this.app.selected_universe="Default",this.app.updateKnownUniversesView()});b(this,"midi_outputs",()=>{this._logMessage(this.MidiConnection.listMidiOutputs())});b(this,"midi_output",e=>{e?this.MidiConnection.switchMidiOutput(e):console.log(this.MidiConnection.getCurrentMidiPort())});b(this,"midi",(e=60,t,n)=>(t!==void 0&&(typeof e=="number"&&(e={note:e}),e.velocity=t),n!==void 0&&(typeof e=="number"&&(e={note:e}),e.channel=n),new Wm(e,this.app)));b(this,"sysex",e=>{this.MidiConnection.sendSysExMessage(e)});b(this,"pitch_bend",(e,t)=>{this.MidiConnection.sendPitchBend(e,t)});b(this,"program_change",(e,t)=>{this.MidiConnection.sendProgramChange(e,t)});b(this,"midi_clock",()=>{this.MidiConnection.sendMidiClock()});b(this,"control_change",({control:e=20,value:t=0,channel:n=0})=>{this.MidiConnection.sendMidiControlChange(e,t,n)});b(this,"midi_panic",()=>{this.MidiConnection.panic()});b(this,"active_note_events",e=>{let t;if(e?t=this.MidiConnection.activeNotesFromChannel(e):t=this.MidiConnection.activeNotes,t.length>0)return t});b(this,"active_notes",e=>{const t=this.active_note_events(e);if(t&&t.length>0)return t.map(n=>n.note)});b(this,"kill_active_notes",()=>{this.MidiConnection.activeNotes=[]});b(this,"sticky_notes",e=>{let t;if(e?t=this.MidiConnection.stickyNotesFromChannel(e):t=this.MidiConnection.stickyNotes,t.length>0)return t.map(n=>n.note)});b(this,"kill_sticky_notes",()=>{this.MidiConnection.stickyNotes=[]});b(this,"buffer",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e)!==void 0:this.MidiConnection.noteInputBuffer.length>0);b(this,"buffer_event",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e):this.MidiConnection.noteInputBuffer.shift());b(this,"buffer_note",e=>{const t=this.buffer_event(e);return t?t.note:void 0});b(this,"last_note_event",e=>e?this.MidiConnection.lastNoteInChannel[e]:this.MidiConnection.lastNote);b(this,"last_note",e=>{const t=this.last_note_event(e);return t?t.note:60});b(this,"last_cc",(e,t)=>t?this.MidiConnection.lastCCInChannel[t]?this.MidiConnection.lastCCInChannel[t][e]:64:this.MidiConnection.lastCC[e]||64);b(this,"has_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e)!==void 0:this.MidiConnection.ccInputBuffer.length>0);b(this,"buffer_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e):this.MidiConnection.ccInputBuffer.shift());b(this,"show_scale",(e,t,n=0,i=this.MidiConnection.currentOutputIndex||0,s=!1)=>{(!this.scale_aid||t!==this.scale_aid)&&(this.hide_scale(e,t,n,i),O3(t,e).forEach(o=>{this.MidiConnection.sendMidiOn(o,n,1,i),s&&this.MidiConnection.sendAllSoundOff(n,i)}),this.scale_aid=t)});b(this,"hide_scale",(e=0,t=0,n=0,i=this.MidiConnection.currentOutputIndex||0)=>{Array.from(Array(128).keys()).forEach(a=>{this.MidiConnection.sendMidiOff(a,n,i)}),this.scale_aid=void 0});b(this,"midi_notes_off",(e=0,t=this.MidiConnection.currentOutputIndex||0)=>{this.MidiConnection.sendAllNotesOff(e,t)});b(this,"midi_sound_off",(e=0,t=this.MidiConnection.currentOutputIndex||0)=>{this.MidiConnection.sendAllSoundOff(e,t)});b(this,"generateCacheKey",(...e)=>e.map(t=>JSON.stringify(t)).join(","));b(this,"z",(e,t={},n="")=>{const i="z"+n.toString(),s=n===""?this.generateCacheKey(e,t):i;let a;return this.app.api.patternCache.has(s)&&(a=this.app.api.patternCache.get(s),a.input!==e&&(a=void 0)),a||(a=new CB(e,t,this.app),this.app.api.patternCache.set(s,a)),typeof n=="number"&&(a.zid=i),a.updateLastCallTime(),n!==""&&a.sync("z0"),a});b(this,"z0",(e,t={})=>this.z(e,t,0));b(this,"z1",(e,t={})=>this.z(e,t,1));b(this,"z2",(e,t={})=>this.z(e,t,2));b(this,"z3",(e,t={})=>this.z(e,t,3));b(this,"z4",(e,t={})=>this.z(e,t,4));b(this,"z5",(e,t={})=>this.z(e,t,5));b(this,"z6",(e,t={})=>this.z(e,t,6));b(this,"z7",(e,t={})=>this.z(e,t,7));b(this,"z8",(e,t={})=>this.z(e,t,8));b(this,"z9",(e,t={})=>this.z(e,t,9));b(this,"z10",(e,t={})=>this.z(e,t,10));b(this,"z11",(e,t={})=>this.z(e,t,11));b(this,"z12",(e,t={})=>this.z(e,t,12));b(this,"z13",(e,t={})=>this.z(e,t,13));b(this,"z14",(e,t={})=>this.z(e,t,14));b(this,"z15",(e,t={})=>this.z(e,t,15));b(this,"z16",(e,t={})=>this.z(e,t,16));b(this,"counter",(e,t,n)=>(e in this.counters?(this.counters[e].limit!==t&&(this.counters[e].value=0,this.counters[e].limit=t),this.counters[e].step!==n&&(this.counters[e].step=n??this.counters[e].step),this.counters[e].value+=this.counters[e].step,this.counters[e].limit!==void 0&&this.counters[e].value>this.counters[e].limit&&(this.counters[e].value=0)):this.counters[e]={value:0,step:n??1,limit:t},this.counters[e].value));b(this,"$",this.counter);b(this,"i",e=>e!==void 0?(this.app.universes[this.app.selected_universe].global.evaluations=e,this.app.universes[this.app.selected_universe]):this.app.universes[this.app.selected_universe].global.evaluations);b(this,"drunk",e=>e!==void 0?(this._drunk.position=e,this._drunk.getPosition()):(this._drunk.step(),this._drunk.getPosition()));b(this,"drunk_max",e=>{this._drunk.max=e});b(this,"drunk_min",e=>{this._drunk.min=e});b(this,"drunk_wrap",e=>{this._drunk.toggleWrap(e)});b(this,"variable",(e,t)=>typeof e=="string"&&t===void 0?this.variables[e]:(this.variables[e]=t,this.variables[e]));b(this,"v",this.variable);b(this,"delete_variable",e=>{delete this.variables[e]});b(this,"dv",this.delete_variable);b(this,"clear_variables",()=>{this.variables={}});b(this,"cv",this.clear_variables);b(this,"randI",(e,t)=>Math.floor(this.randomGen()*(t-e+1))+e);b(this,"rand",(e,t)=>this.randomGen()*(t-e)+e);b(this,"irand",this.randI);b(this,"rI",this.randI);b(this,"r",this.rand);b(this,"ir",this.randI);b(this,"seed",e=>{typeof e=="number"&&(e=e.toString()),this.currentSeed!==e&&(this.currentSeed=e,this.randomGen=Qm(e))});b(this,"localSeededRandom",e=>{if(typeof e=="number"&&(e=e.toString()),this.localSeeds.has(e))return this.localSeeds.get(e);const t=Qm(e);return this.localSeeds.set(e,t),t});b(this,"clearLocalSeed",(e=void 0)=>{e&&this.localSeeds.delete(e.toString()),this.localSeeds.clear()});b(this,"quantize",(e,t)=>{if(t.length===0)return e;let n=t[0];return t.forEach(i=>{Math.abs(i-e)Math.min(Math.max(e,t),n));b(this,"cmp",this.clamp);b(this,"nudge",e=>(e&&(this.app.clock.nudge=e),this.app.clock.nudge));b(this,"bpm",e=>e===void 0?this.app.clock.bpm:((e<1||e>500)&&console.log(`Setting bpm to ${e}`),this.app.clock.bpm=e,e));b(this,"tempo",this.bpm);b(this,"bpb",e=>e===void 0?this.app.clock.time_signature[0]:(e<1&&console.log(`Setting bpb to ${e}`),this.app.clock.time_signature[0]=e,e));b(this,"ppqn",e=>e===void 0?this.app.clock.ppqn:(e<1&&console.log(`Setting ppqn to ${e}`),this.app.clock.ppqn=e,e));b(this,"time_signature",(e,t)=>{this.app.clock.time_signature=[e,t]});b(this,"prob",e=>this.randomGen()*100this.randomGen()>.5);b(this,"odds",(e,t=1)=>this.randomGen()!1);b(this,"almostNever",(e=1)=>this.randomGen()<.025*this.ppqn()/(this.ppqn()*e));b(this,"rarely",(e=1)=>this.randomGen()<.1*this.ppqn()/(this.ppqn()*e));b(this,"scarcely",(e=1)=>this.randomGen()<.25*this.ppqn()/(this.ppqn()*e));b(this,"sometimes",(e=1)=>this.randomGen()<.5*this.ppqn()/(this.ppqn()*e));b(this,"often",(e=1)=>this.randomGen()<.75*this.ppqn()/(this.ppqn()*e));b(this,"frequently",(e=1)=>this.randomGen()<.9*this.ppqn()/(this.ppqn()*e));b(this,"almostAlways",(e=1)=>this.randomGen()<.985*this.ppqn()/(this.ppqn()*e));b(this,"always",(e=1)=>!0);b(this,"dice",e=>Math.floor(this.randomGen()*e)+1);b(this,"cbar",()=>this.app.clock.time_position.bar+1);b(this,"ctick",()=>this.app.clock.tick+1);b(this,"cpulse",()=>this.app.clock.time_position.pulse+1);b(this,"cbeat",()=>this.app.clock.time_position.beat+1);b(this,"ebeat",()=>this.app.clock.beats_since_origin+1);b(this,"epulse",()=>this.app.clock.pulses_since_origin+1);b(this,"nominator",()=>this.app.clock.time_signature[0]);b(this,"meter",()=>this.app.clock.time_signature[1]);b(this,"denominator",this.meter);b(this,"beat",(...e)=>e.map(n=>this.app.clock.pulses_since_origin%Math.floor(n*this.ppqn())===0).some(n=>n===!0));b(this,"b",this.beat);b(this,"pulse",(...e)=>e.map(n=>this.app.clock.pulses_since_origin%n===0).some(n=>n===!0));b(this,"flip",(e,t=50)=>{let n=e*2;const i=this.app.clock.pulses_since_origin,s=Math.floor(n*this.ppqn()),a=Math.floor(t/100*s);return i%s{let t=e*2;const n=this.app.clock.time_position.bar;return Math.floor(n/t)%2===0});b(this,"onbar",(e,t=this.app.clock.time_signature[0])=>{let n=this.app.clock.time_position.bar%t+1;return typeof e=="number"?e===n:e.some(i=>i==n)});b(this,"onbeat",(...e)=>{let t=[];return e.forEach(n=>{let i=n%this.nominator()||this.nominator(),s=Math.floor(i);s=s==0?this.nominator():s;let a=Math.floor((i-s)*this.ppqn()+1);a<=0&&(a=a+this.ppqn()*this.nominator()),t.push(s===this.cbeat()&&this.cpulse()===a)}),t.some(n=>n==!0)});b(this,"oncount",(e,t)=>{typeof e=="number"&&(e=[e]);const n=this.app.clock.pulses_since_origin;let i=[];return e.forEach(s=>{s=s<1?0:s-1;const a=Math.ceil(s*this.ppqn()),o=n%(this.ppqn()*t);return i.push(o===a)}),i.some(s=>s==!0)});b(this,"oneuclid",(e,t,n=0)=>{const s=this._euclidean_cycle(e,t,n).reduce((a,o,l)=>(o&&a.push(l+1),a),[]);return this.oncount(s,t)});b(this,"delay",(e,t)=>{setTimeout(t,e)});b(this,"delayr",(e,t,n)=>{[...Array(t).keys()].map(s=>e*s).forEach((s,a)=>{setTimeout(n,s)})});b(this,"euclid",(e,t,n,i=0)=>this._euclidean_cycle(t,n,i)[e%n]);b(this,"ec",this.euclid);b(this,"rhythm",(e,t,n,i=0)=>this.beat(e)&&this._euclidean_cycle(t,n,i).beat(e));b(this,"bin",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return i[e%i.length]});b(this,"binrhythm",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return this.beat(e)&&i.beat(e)});b(this,"line",(e,t,n=1)=>{const i=[];if(t>e&&n>0||tMath.sin(this.app.clock.ctx.currentTime*Math.PI*2*e)+t);b(this,"usine",(e=1,t=0)=>(this.sine(e,t)+1)/2);b(this,"saw",(e=1,t=0)=>this.app.clock.ctx.currentTime*e%1*2-1+t);b(this,"usaw",(e=1,t=0)=>(this.saw(e,t)+1)/2);b(this,"triangle",(e=1,t=0)=>Math.abs(this.saw(e,t))*2-1);b(this,"utriangle",(e=1,t=0)=>(this.triangle(e,t)+1)/2);b(this,"square",(e=1,t=0,n=.5)=>{const i=1/e;return(Date.now()/1e3+t)%i/i(this.square(e,t,n)+1)/2);b(this,"noise",()=>this.randomGen()*2-1);b(this,"min",(...e)=>Math.min(...e));b(this,"max",(...e)=>Math.max(...e));b(this,"mean",(...e)=>e.reduce((n,i)=>n+i,0)/e.length);b(this,"limit",(e,t,n)=>Math.min(Math.max(e,t),n));b(this,"abs",Math.abs);b(this,"speak",(e,t="en-US",n=0,i=1,s=1)=>{new QI({text:e,lang:t,voice:n,rate:i,pitch:s}).speak().then(()=>{}).catch(o=>{console.log(o)})});b(this,"stop_hydra",()=>{this.app.hydra.hush()});b(this,"sound",e=>new Hm(e,this.app));b(this,"snd",this.sound);b(this,"samples",Gi);b(this,"log",e=>{console.log(e),this._logMessage(e)});b(this,"scale",a_);b(this,"rate",e=>{});b(this,"divseq",(...e)=>{const t=e[0],n=e.slice(1),i=this.app.clock.pulses_since_origin,s=Math.floor(i/Math.floor(t*this.ppqn()));return n[s%n.length]});b(this,"seqbeat",(...e)=>e[this.app.clock.time_position.beat%e.length]);b(this,"seqbar",(...e)=>e[(this.app.clock.time_position.bar+1)%e.length]);b(this,"shuffle",e=>e.sort(()=>this.randomGen()-.5));b(this,"reverse",e=>e.reverse());b(this,"rotate",e=>t=>t.slice(e,t.length).concat(t.slice(0,e)));b(this,"repeat",e=>t=>t.flatMap(n=>Array(e).fill(n)));b(this,"repeatOdd",e=>t=>t.flatMap((n,i)=>i%2===0?Array(e).fill(n):n));b(this,"repeatEven",e=>t=>t.flatMap((n,i)=>i%2!==0?Array(e).fill(n):n));b(this,"palindrome",e=>e.concat(e.slice(0,e.length-1).reverse()));this.app=e,this.MidiConnection=new k3(this,e.settings)}transmission(){return this.MidiConnection.activeNotes.length>0}_euclidean_cycle(e,t,n=0){if(e==t)return Array.from({length:t},()=>!0);function i(o,l){const c=o.length,u=(l+1)%c;return o[l]>o[u]}if(e>=t)return[!0];const s=Array.from({length:t},(o,l)=>(e*(l-1)%t+t)%t);let a=s.map((o,l)=>i(s,l));return n!=0&&(a=a.slice(n).concat(a.slice(0,n))),a}}const RB=r=>{Array.prototype.square=function(){return this.map(e=>e*e)},Array.prototype.sometimes=function(e){return r.randomGen()<.5?e(this):this},Array.prototype.apply=function(e){return e(this)},Array.prototype.sqrt=function(){if(this.some(e=>e<0))throw new Error("Cannot take square root of negative number");return this.map(e=>Math.sqrt(e))},Array.prototype.add=function(e){return this.map(t=>t+e)},Array.prototype.sub=function(e){return this.map(t=>t-e)},Array.prototype.mult=function(e){return this.map(t=>t*e)},Array.prototype.div=function(e){if(e===0)throw new Error("Division by zero");return this.map(t=>t/e)},Array.prototype.pick=function(){return this[Math.floor(r.randomGen()*this.length)]},Array.prototype.gen=function(e,t,n){return n<1?[]:Array.from({length:n},()=>Math.floor(r.randomGen()*(t-e+1))+e)},Array.prototype.bar=function(e=1){return e===1?this[r.app.clock.time_position.bar%this.length]:this[Math.floor(r.app.clock.time_position.bar/e)%this.length]},Array.prototype.beat=function(e=1){const t=e,n=r.app.clock.pulses_since_origin,i=Math.floor(n/Math.floor(t*r.ppqn()));return this[i%this.length]},Array.prototype.b=Array.prototype.beat,Array.prototype.shuffle=function(){let e=this.length,t;for(;e!==0;)t=Math.floor(r.randomGen()*e),e--,[this[e],this[t]]=[this[t],this[e]];return this},Array.prototype.rotate=function(e){const t=this.length;if(e<0)e=t+e%t;else if(e>0)e=e%t;else return this;const n=this.splice(-e,e);return this.unshift(...n),this},Array.prototype.unique=function(){const e=new Set;let t=0;for(let n=0;n100)throw new Error("Amount should be between 0 and 100");if(this.length<=1)return this;for(let t=0;t1)this.splice(t,1);else return this;else t++;return this},Array.prototype.repeat=function(e=1){if(e<1)throw new Error("Amount should be at least 1");let t=[];for(let n=0;n(i%s+s)%s,n=DI(Ds(r));return this.map(i=>{const s=Math.floor(i/n.length)*12;return n[t(i,n.length)]+e+s})};Array.prototype.scaleArp=function(r="major",e=0){const t=DI(Ds(r));let n=[];e=e>t.length?t.length:e,e=e==0?t.length:e;for(let i=0;i>1|(Pt&21845)<<1;Mi=(Mi&52428)>>2|(Mi&13107)<<2,Mi=(Mi&61680)>>4|(Mi&3855)<<4,rg[Pt]=((Mi&65280)>>8|(Mi&255)<<8)>>1}var ri=function(r,e,t){for(var n=r.length,i=0,s=new lr(e);i>l]=c}else for(o=new lr(n),i=0;i>15-r[i]);return o},Ji=new En(288);for(var Pt=0;Pt<144;++Pt)Ji[Pt]=8;for(var Pt=144;Pt<256;++Pt)Ji[Pt]=9;for(var Pt=256;Pt<280;++Pt)Ji[Pt]=7;for(var Pt=280;Pt<288;++Pt)Ji[Pt]=8;var Wo=new En(32);for(var Pt=0;Pt<32;++Pt)Wo[Pt]=5;var wB=ri(Ji,9,0),DB=ri(Ji,9,1),xB=ri(Wo,5,0),kB=ri(Wo,5,1),sd=function(r){for(var e=r[0],t=1;te&&(e=r[t]);return e},Rr=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},od=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},h_=function(r){return(r+7)/8|0},f_=function(r,e,t){(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length);var n=new En(t-e);return n.set(r.subarray(e,t)),n},LB=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Gn=function(r,e,t){var n=new Error(e||LB[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Gn),!t)throw n;return n},m_=function(r,e,t,n){var i=r.length,s=n?n.length:0;if(!i||e.f&&!e.l)return t||new En(0);var a=!t||e.i!=2,o=e.i;t||(t=new En(i*3));var l=function(Be){var tt=t.length;if(Be>tt){var rt=new En(Math.max(tt*2,Be));rt.set(t),t=rt}},c=e.f||0,u=e.p||0,p=e.b||0,m=e.l,_=e.d,v=e.m,I=e.n,R=i*8;do{if(!m){c=Rr(r,u,1);var x=Rr(r,u+1,3);if(u+=3,x)if(x==1)m=DB,_=kB,v=9,I=5;else if(x==2){var E=Rr(r,u,31)+257,S=Rr(r,u+10,15)+4,N=E+Rr(r,u+5,31)+1;u+=14;for(var k=new En(N),L=new En(19),M=0;M>4;if($<16)k[M++]=$;else{var ee=0,B=0;for($==16?(B=3+Rr(r,u,3),u+=2,ee=k[M-1]):$==17?(B=3+Rr(r,u,7),u+=3):$==18&&(B=11+Rr(r,u,127),u+=7);B--;)k[M++]=ee}}var Q=k.subarray(0,E),j=k.subarray(E);v=sd(Q),I=sd(j),m=ri(Q,v,1),_=ri(j,I,1)}else Gn(1);else{var $=h_(u)+4,Z=r[$-4]|r[$-3]<<8,f=$+Z;if(f>i){o&&Gn(0);break}a&&l(p+Z),t.set(r.subarray($,f),p),e.b=p+=Z,e.p=u=f*8,e.f=c;continue}if(u>R){o&&Gn(0);break}}a&&l(p+131072);for(var K=(1<>4;if(u+=ee&15,u>R){o&&Gn(0);break}if(ee||Gn(2),Ee<256)t[p++]=Ee;else if(Ee==256){le=u,m=null;break}else{var De=Ee-254;if(Ee>264){var M=Ee-257,xe=au[M];De=Rr(r,u,(1<>4;be||Gn(3),u+=be&15;var j=NB[Ne];if(Ne>3){var xe=su[Ne];j+=od(r,u)&(1<R){o&&Gn(0);break}a&&l(p+131072);var ce=p+De;if(p>8},po=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},ld=function(r,e){for(var t=[],n=0;nm&&(m=s[n].s);var _=new lr(m+1),v=ig(t[u-1],_,0);if(v>e){var n=0,I=0,R=v-e,x=1<e)I+=x-(1<>=R;I>0;){var Z=s[n].s;_[Z]=0&&I;--n){var f=s[n].s;_[f]==e&&(--_[f],++I)}v=e}return{t:new En(_),l:v}},ig=function(r,e,t){return r.s==-1?Math.max(ig(r.l,e,t+1),ig(r.r,e,t+1)):e[r.s]=t},wE=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new lr(++e),n=0,i=r[0],s=1,a=function(l){t[n++]=l},o=1;o<=e;++o)if(r[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=r[o]}return{c:t.subarray(0,n),n:e}},ho=function(r,e){for(var t=0,n=0;n>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var s=0;s4&&!M[tg[te-1]];--te);var re=c+5<<3,ne=ho(i,Ji)+ho(s,Wo)+a,ee=ho(i,m)+ho(s,I)+a+14+3*te+ho(N,M)+2*N[16]+3*N[17]+7*N[18];if(l>=0&&re<=ne&&re<=ee)return WI(e,u,r.subarray(l,l+c));var B,Q,j,K;if(fi(e,u,1+(ee15&&(fi(e,u,De[k]>>5&127),u+=De[k]>>12)}}else B=wB,Q=Ji,j=xB,K=Wo;for(var k=0;k255){var xe=be>>18&31;po(e,u,B[xe+257]),u+=Q[xe+257],xe>7&&(fi(e,u,be>>23&31),u+=au[xe]);var Ne=be&31;po(e,u,j[Ne]),u+=K[Ne],Ne>3&&(po(e,u,be>>5&8191),u+=su[Ne])}else po(e,u,B[be]),u+=Q[be]}return po(e,u,B[256]),u+Q[256]},MB=new p_([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),XI=new En(0),PB=function(r,e,t,n,i,s){var a=s.z||r.length,o=new En(n+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(n,o.length-i),c=s.l,u=(s.r||0)&7;if(e){u&&(l[0]=s.r>>3);for(var p=MB[e-1],m=p>>13,_=p&8191,v=(1<7e3||M>24576)&&(B>423||!c)){u=DE(r,l,0,f,E,S,k,M,te,L-te,u),M=N=k=0,te=L;for(var Q=0;Q<286;++Q)E[Q]=0;for(var Q=0;Q<30;++Q)S[Q]=0}var j=2,K=0,ue=_,le=ne-ee&32767;if(B>2&&re==Z(L-le))for(var Ee=Math.min(m,B)-1,De=Math.min(32767,L),xe=Math.min(258,B);le<=De&&--ue&&ne!=ee;){if(r[L+j]==r[L+j-le]){for(var be=0;bej){if(j=be,K=le,be>Ee)break;for(var Ne=Math.min(le,be-2),ce=0,Q=0;Qce&&(ce=Be,ee=Le)}}}ne=ee,ee=I[ne],le+=ne-ee&32767}if(K){f[M++]=268435456|ng[j]<<18|NE[K];var tt=ng[j]&31,rt=NE[K]&31;k+=au[tt]+su[rt],++E[257+tt],++S[rt],G=L+j,++N}else f[M++]=r[L],++E[r[L]]}}for(L=Math.max(L,G);L=a&&(l[u/8|0]=c,ft=a),u=WI(l,u+1,r.subarray(L,ft))}s.i=a}return f_(o,0,n+h_(u)+i)},BB=function(){for(var r=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;r[e]=t}return r}(),UB=function(){var r=-1;return{p:function(e){for(var t=r,n=0;n>>8;r=t},d:function(){return~r}}},FB=function(r,e,t,n,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new En(s.length+r.length);a.set(s),a.set(r,s.length),r=a,i.w=s.length}return PB(r,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+e.mem,t,n,i)},ag=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},YB=function(r,e){var t=e.filename;if(r[0]=31,r[1]=139,r[2]=8,r[8]=e.level<2?4:e.level==9?2:0,r[9]=3,e.mtime!=0&&ag(r,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){r[3]=8;for(var n=0;n<=t.length;++n)r[n+10]=t.charCodeAt(n)}},$B=function(r){(r[0]!=31||r[1]!=139||r[2]!=8)&&Gn(6,"invalid gzip data");var e=r[3],t=10;e&4&&(t+=(r[10]|r[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!r[t++]);return t+(e&2)},GB=function(r){var e=r.length;return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0},QB=function(r){return 10+(r.filename?r.filename.length+1:0)},qB=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Gn(6,"invalid zlib data"),(r[1]>>5&1)==+!e&&Gn(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function VB(r,e){return m_(r,{i:2},e&&e.out,e&&e.dictionary)}function zB(r,e){e||(e={});var t=UB(),n=r.length;t.p(r);var i=FB(r,e,QB(e),8),s=i.length;return YB(i,e),ag(i,s-8,t.d()),ag(i,s-4,n),i}function HB(r,e){var t=$B(r);return t+8>r.length&&Gn(6,"invalid gzip data"),m_(r.subarray(t,-8),{i:2},e&&e.out||new En(GB(r)),e&&e.dictionary)}function WB(r,e){return m_(r.subarray(qB(r,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function XB(r,e){return r[0]==31&&r[1]==139&&r[2]==8?HB(r,e):(r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31?VB(r,e):WB(r,e)}var sg=typeof TextDecoder<"u"&&new TextDecoder,ZB=0;try{sg.decode(XI,{stream:!0}),ZB=1}catch{}var KB=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:f_(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function jB(r,e){if(e){for(var t="",n=0;n (GFM Style)",type:"boolean"},requireSpaceBeforeHeadingText:{defaultValue:!1,describe:"Makes adding a space between `#` and the header text mandatory (GFM Style)",type:"boolean"},ghMentions:{defaultValue:!1,describe:"Enables github @mentions",type:"boolean"},ghMentionsLink:{defaultValue:"https://github.com/{u}",describe:"Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",type:"string"},encodeEmails:{defaultValue:!0,describe:"Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",type:"boolean"},openLinksInNewWindow:{defaultValue:!1,describe:"Open all links in new windows",type:"boolean"},backslashEscapesHTMLTags:{defaultValue:!1,describe:"Support for HTML Tag escaping. ex: foo
",type:"boolean"},emoji:{defaultValue:!1,describe:"Enable emoji support. Ex: `this is a :smile: emoji`",type:"boolean"},underline:{defaultValue:!1,describe:"Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `` and ``",type:"boolean"},ellipsis:{defaultValue:!0,describe:"Replaces three dots with the ellipsis unicode character",type:"boolean"},completeHTMLDocument:{defaultValue:!1,describe:"Outputs a complete html document, including ``, `` and `` tags",type:"boolean"},metadata:{defaultValue:!1,describe:"Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).",type:"boolean"},splitAdjacentBlockquotes:{defaultValue:!1,describe:"Split adjacent blockquote blocks",type:"boolean"}};if(f===!1)return JSON.parse(JSON.stringify(E));var S={};for(var N in E)E.hasOwnProperty(N)&&(S[N]=E[N].defaultValue);return S}function t(){var f=e(!0),E={};for(var S in f)f.hasOwnProperty(S)&&(E[S]=!0);return E}var n={},i={},s={},a=e(!0),o="vanilla",l={github:{omitExtraWLInCodeBlocks:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,disableForced4SpacesIndentedSublists:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghCompatibleHeaderId:!0,ghMentions:!0,backslashEscapesHTMLTags:!0,emoji:!0,splitAdjacentBlockquotes:!0},original:{noHeaderId:!0,ghCodeBlocks:!1},ghost:{omitExtraWLInCodeBlocks:!0,parseImgDimensions:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,smoothLivePreview:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghMentions:!1,encodeEmails:!0},vanilla:e(!0),allOn:t()};n.helper={},n.extensions={},n.setOption=function(f,E){return a[f]=E,this},n.getOption=function(f){return a[f]},n.getOptions=function(){return a},n.resetOptions=function(){a=e(!0)},n.setFlavor=function(f){if(!l.hasOwnProperty(f))throw Error(f+" flavor was not found");n.resetOptions();var E=l[f];o=f;for(var S in E)E.hasOwnProperty(S)&&(a[S]=E[S])},n.getFlavor=function(){return o},n.getFlavorOptions=function(f){if(l.hasOwnProperty(f))return l[f]},n.getDefaultOptions=function(f){return e(f)},n.subParser=function(f,E){if(n.helper.isString(f))if(typeof E<"u")i[f]=E;else{if(i.hasOwnProperty(f))return i[f];throw Error("SubParser named "+f+" not registered!")}},n.extension=function(f,E){if(!n.helper.isString(f))throw Error("Extension 'name' must be a string");if(f=n.helper.stdExtName(f),n.helper.isUndefined(E)){if(!s.hasOwnProperty(f))throw Error("Extension named "+f+" is not registered!");return s[f]}else{typeof E=="function"&&(E=E()),n.helper.isArray(E)||(E=[E]);var S=c(E,f);if(S.valid)s[f]=E;else throw Error(S.error)}},n.getAllExtensions=function(){return s},n.removeExtension=function(f){delete s[f]},n.resetExtensions=function(){s={}};function c(f,E){var S=E?"Error in "+E+" extension->":"Error in unnamed extension",N={valid:!0,error:""};n.helper.isArray(f)||(f=[f]);for(var k=0;k"u"},n.helper.forEach=function(f,E){if(n.helper.isUndefined(f))throw new Error("obj param is required");if(n.helper.isUndefined(E))throw new Error("callback param is required");if(!n.helper.isFunction(E))throw new Error("callback param must be a function/closure");if(typeof f.forEach=="function")f.forEach(E);else if(n.helper.isArray(f))for(var S=0;S").replace(/&/g,"&")};var p=function(f,E,S,N){var k=N||"",L=k.indexOf("g")>-1,M=new RegExp(E+"|"+S,"g"+k.replace(/g/g,"")),G=new RegExp(E,k.replace(/g/g,"")),te=[],re,ne,ee,B,Q;do for(re=0;ee=M.exec(f);)if(G.test(ee[0]))re++||(ne=M.lastIndex,B=ne-ee[0].length);else if(re&&!--re){Q=ee.index+ee[0].length;var j={left:{start:B,end:ne},match:{start:ne,end:ee.index},right:{start:ee.index,end:Q},wholeMatch:{start:B,end:Q}};if(te.push(j),!L)return te}while(re&&(M.lastIndex=ne));return te};n.helper.matchRecursiveRegExp=function(f,E,S,N){for(var k=p(f,E,S,N),L=[],M=0;M0){var re=[];M[0].wholeMatch.start!==0&&re.push(f.slice(0,M[0].wholeMatch.start));for(var ne=0;ne=0?N+(S||0):N},n.helper.splitAtIndex=function(f,E){if(!n.helper.isString(f))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";return[f.substring(0,E),f.substring(E)]},n.helper.encodeEmailAddress=function(f){var E=[function(S){return""+S.charCodeAt(0)+";"},function(S){return""+S.charCodeAt(0).toString(16)+";"},function(S){return S}];return f=f.replace(/./g,function(S){if(S==="@")S=E[Math.floor(Math.random()*2)](S);else{var N=Math.random();S=N>.9?E[2](S):N>.45?E[1](S):E[0](S)}return S}),f},n.helper.padEnd=function(E,S,N){return S=S>>0,N=String(N||" "),E.length>S?String(E):(S=S-E.length,S>N.length&&(N+=N.repeat(S/N.length)),String(E)+N.slice(0,S))},typeof console>"u"&&(console={warn:function(f){alert(f)},log:function(f){alert(f)},error:function(f){throw f}}),n.helper.regexes={asteriskDashAndColon:/([*_:~])/g},n.helper.emojis={"+1":"👍","-1":"👎",100:"💯",1234:"🔢","1st_place_medal":"🥇","2nd_place_medal":"🥈","3rd_place_medal":"🥉","8ball":"🎱",a:"🅰️",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈️",alarm_clock:"⏰",alembic:"⚗️",alien:"👽",ambulance:"🚑",amphora:"🏺",anchor:"⚓️",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒️",aries:"♈️",arrow_backward:"◀️",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇️",arrow_down_small:"🔽",arrow_forward:"▶️",arrow_heading_down:"⤵️",arrow_heading_up:"⤴️",arrow_left:"⬅️",arrow_lower_left:"↙️",arrow_lower_right:"↘️",arrow_right:"➡️",arrow_right_hook:"↪️",arrow_up:"⬆️",arrow_up_down:"↕️",arrow_up_small:"🔼",arrow_upper_left:"↖️",arrow_upper_right:"↗️",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",artificial_satellite:"🛰",astonished:"😲",athletic_shoe:"👟",atm:"🏧",atom_symbol:"⚛️",avocado:"🥑",b:"🅱️",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",bacon:"🥓",badminton:"🏸",baggage_claim:"🛄",baguette_bread:"🥖",balance_scale:"⚖️",balloon:"🎈",ballot_box:"🗳",ballot_box_with_check:"☑️",bamboo:"🎍",banana:"🍌",bangbang:"‼️",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾️",basketball:"🏀",basketball_man:"⛹️",basketball_woman:"⛹️♀️",bat:"🦇",bath:"🛀",bathtub:"🛁",battery:"🔋",beach_umbrella:"🏖",bear:"🐻",bed:"🛏",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bellhop_bell:"🛎",bento:"🍱",biking_man:"🚴",bike:"🚲",biking_woman:"🚴♀️",bikini:"👙",biohazard:"☣️",bird:"🐦",birthday:"🎂",black_circle:"⚫️",black_flag:"🏴",black_heart:"🖤",black_joker:"🃏",black_large_square:"⬛️",black_medium_small_square:"◾️",black_medium_square:"◼️",black_nib:"✒️",black_small_square:"▪️",black_square_button:"🔲",blonde_man:"👱",blonde_woman:"👱♀️",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵️",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bowing_man:"🙇",bow_and_arrow:"🏹",bowing_woman:"🙇♀️",bowling:"🎳",boxing_glove:"🥊",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",building_construction:"🏗",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",burrito:"🌯",bus:"🚌",business_suit_levitating:"🕴",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",butterfly:"🦋",cactus:"🌵",cake:"🍰",calendar:"📆",call_me_hand:"🤙",calling:"📲",camel:"🐫",camera:"📷",camera_flash:"📸",camping:"🏕",cancer:"♋️",candle:"🕯",candy:"🍬",canoe:"🛶",capital_abcd:"🔠",capricorn:"♑️",car:"🚗",card_file_box:"🗃",card_index:"📇",card_index_dividers:"🗂",carousel_horse:"🎠",carrot:"🥕",cat:"🐱",cat2:"🐈",cd:"💿",chains:"⛓",champagne:"🍾",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cheese:"🧀",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chipmunk:"🐿",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪️",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cityscape:"🏙",cl:"🆑",clamp:"🗜",clap:"👏",clapper:"🎬",classical_building:"🏛",clinking_glasses:"🥂",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁️",cloud_with_lightning:"🌩",cloud_with_lightning_and_rain:"⛈",cloud_with_rain:"🌧",cloud_with_snow:"🌨",clown_face:"🤡",clubs:"♣️",cocktail:"🍸",coffee:"☕️",coffin:"⚰️",cold_sweat:"😰",comet:"☄️",computer:"💻",computer_mouse:"🖱",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗️",construction:"🚧",construction_worker_man:"👷",construction_worker_woman:"👷♀️",control_knobs:"🎛",convenience_store:"🏪",cookie:"🍪",cool:"🆒",policeman:"👮",copyright:"©️",corn:"🌽",couch_and_lamp:"🛋",couple:"👫",couple_with_heart_woman_man:"💑",couple_with_heart_man_man:"👨❤️👨",couple_with_heart_woman_woman:"👩❤️👩",couplekiss_man_man:"👨❤️💋👨",couplekiss_man_woman:"💏",couplekiss_woman_woman:"👩❤️💋👩",cow:"🐮",cow2:"🐄",cowboy_hat_face:"🤠",crab:"🦀",crayon:"🖍",credit_card:"💳",crescent_moon:"🌙",cricket:"🏏",crocodile:"🐊",croissant:"🥐",crossed_fingers:"🤞",crossed_flags:"🎌",crossed_swords:"⚔️",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cucumber:"🥒",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",dagger:"🗡",dancer:"💃",dancing_women:"👯",dancing_men:"👯♂️",dango:"🍡",dark_sunglasses:"🕶",dart:"🎯",dash:"💨",date:"📅",deciduous_tree:"🌳",deer:"🦌",department_store:"🏬",derelict_house:"🏚",desert:"🏜",desert_island:"🏝",desktop_computer:"🖥",male_detective:"🕵️",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦️",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dove:"🕊",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",drooling_face:"🤤",droplet:"💧",drum:"🥁",duck:"🦆",dvd:"📀","e-mail":"📧",eagle:"🦅",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight_pointed_black_star:"✴️",eight_spoked_asterisk:"✳️",electric_plug:"🔌",elephant:"🐘",email:"✉️",end:"🔚",envelope_with_arrow:"📩",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗️",expressionless:"😑",eye:"👁",eye_speech_bubble:"👁🗨",eyeglasses:"👓",eyes:"👀",face_with_head_bandage:"🤕",face_with_thermometer:"🤒",fist_oncoming:"👊",factory:"🏭",fallen_leaf:"🍂",family_man_woman_boy:"👪",family_man_boy:"👨👦",family_man_boy_boy:"👨👦👦",family_man_girl:"👨👧",family_man_girl_boy:"👨👧👦",family_man_girl_girl:"👨👧👧",family_man_man_boy:"👨👨👦",family_man_man_boy_boy:"👨👨👦👦",family_man_man_girl:"👨👨👧",family_man_man_girl_boy:"👨👨👧👦",family_man_man_girl_girl:"👨👨👧👧",family_man_woman_boy_boy:"👨👩👦👦",family_man_woman_girl:"👨👩👧",family_man_woman_girl_boy:"👨👩👧👦",family_man_woman_girl_girl:"👨👩👧👧",family_woman_boy:"👩👦",family_woman_boy_boy:"👩👦👦",family_woman_girl:"👩👧",family_woman_girl_boy:"👩👧👦",family_woman_girl_girl:"👩👧👧",family_woman_woman_boy:"👩👩👦",family_woman_woman_boy_boy:"👩👩👦👦",family_woman_woman_girl:"👩👩👧",family_woman_woman_girl_boy:"👩👩👧👦",family_woman_woman_girl_girl:"👩👩👧👧",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",female_detective:"🕵️♀️",ferris_wheel:"🎡",ferry:"⛴",field_hockey:"🏑",file_cabinet:"🗄",file_folder:"📁",film_projector:"📽",film_strip:"🎞",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist_raised:"✊",fist_left:"🤛",fist_right:"🤜",flags:"🎏",flashlight:"🔦",fleur_de_lis:"⚜️",flight_arrival:"🛬",flight_departure:"🛫",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",fog:"🌫",foggy:"🌁",football:"🏈",footprints:"👣",fork_and_knife:"🍴",fountain:"⛲️",fountain_pen:"🖋",four_leaf_clover:"🍀",fox_face:"🦊",framed_picture:"🖼",free:"🆓",fried_egg:"🍳",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",frowning_face:"☹️",frowning_man:"🙍♂️",frowning_woman:"🙍",middle_finger:"🖕",fuelpump:"⛽️",full_moon:"🌕",full_moon_with_face:"🌝",funeral_urn:"⚱️",game_die:"🎲",gear:"⚙️",gem:"💎",gemini:"♊️",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goal_net:"🥅",goat:"🐐",golf:"⛳️",golfing_man:"🏌️",golfing_woman:"🏌️♀️",gorilla:"🦍",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",green_salad:"🥗",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guardswoman:"💂♀️",guitar:"🎸",gun:"🔫",haircut_woman:"💇",haircut_man:"💇♂️",hamburger:"🍔",hammer:"🔨",hammer_and_pick:"⚒",hammer_and_wrench:"🛠",hamster:"🐹",hand:"✋",handbag:"👜",handshake:"🤝",hankey:"💩",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔️",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_heart_exclamation:"❣️",heavy_minus_sign:"➖",heavy_multiplication_x:"✖️",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",hole:"🕳",honey_pot:"🍯",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hot_pepper:"🌶",hotdog:"🌭",hotel:"🏨",hotsprings:"♨️",hourglass:"⌛️",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",houses:"🏘",hugs:"🤗",hushed:"😯",ice_cream:"🍨",ice_hockey:"🏒",ice_skate:"⛸",icecream:"🍦",id:"🆔",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",tipping_hand_woman:"💁",information_source:"ℹ️",innocent:"😇",interrobang:"⁉️",iphone:"📱",izakaya_lantern:"🏮",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",joystick:"🕹",kaaba:"🕋",key:"🔑",keyboard:"⌨️",keycap_ten:"🔟",kick_scooter:"🛴",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",kiwi_fruit:"🥝",koala:"🐨",koko:"🈁",label:"🏷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",latin_cross:"✝️",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔️",leftwards_arrow_with_hook:"↩️",lemon:"🍋",leo:"♌️",leopard:"🐆",level_slider:"🎚",libra:"♎️",light_rail:"🚈",link:"🔗",lion:"🦁",lips:"👄",lipstick:"💄",lizard:"🦎",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loud_sound:"🔊",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",lying_face:"🤥",m:"Ⓜ️",mag:"🔍",mag_right:"🔎",mahjong:"🀄️",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_artist:"👨🎨",man_astronaut:"👨🚀",man_cartwheeling:"🤸♂️",man_cook:"👨🍳",man_dancing:"🕺",man_facepalming:"🤦♂️",man_factory_worker:"👨🏭",man_farmer:"👨🌾",man_firefighter:"👨🚒",man_health_worker:"👨⚕️",man_in_tuxedo:"🤵",man_judge:"👨⚖️",man_juggling:"🤹♂️",man_mechanic:"👨🔧",man_office_worker:"👨💼",man_pilot:"👨✈️",man_playing_handball:"🤾♂️",man_playing_water_polo:"🤽♂️",man_scientist:"👨🔬",man_shrugging:"🤷♂️",man_singer:"👨🎤",man_student:"👨🎓",man_teacher:"👨🏫",man_technologist:"👨💻",man_with_gua_pi_mao:"👲",man_with_turban:"👳",tangerine:"🍊",mans_shoe:"👞",mantelpiece_clock:"🕰",maple_leaf:"🍁",martial_arts_uniform:"🥋",mask:"😷",massage_woman:"💆",massage_man:"💆♂️",meat_on_bone:"🍖",medal_military:"🎖",medal_sports:"🏅",mega:"📣",melon:"🍈",memo:"📝",men_wrestling:"🤼♂️",menorah:"🕎",mens:"🚹",metal:"🤘",metro:"🚇",microphone:"🎤",microscope:"🔬",milk_glass:"🥛",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_mouth_face:"🤑",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",moon:"🌔",mortar_board:"🎓",mosque:"🕌",motor_boat:"🛥",motor_scooter:"🛵",motorcycle:"🏍",motorway:"🛣",mount_fuji:"🗻",mountain:"⛰",mountain_biking_man:"🚵",mountain_biking_woman:"🚵♀️",mountain_cableway:"🚠",mountain_railway:"🚞",mountain_snow:"🏔",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",mrs_claus:"🤶",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",national_park:"🏞",nauseated_face:"🤢",necktie:"👔",negative_squared_cross_mark:"❎",nerd_face:"🤓",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",newspaper_roll:"🗞",next_track_button:"⏭",ng:"🆖",no_good_man:"🙅♂️",no_good_woman:"🙅",night_with_stars:"🌃",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔️",no_entry_sign:"🚫",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕️",o2:"🅾️",ocean:"🌊",octopus:"🐙",oden:"🍢",office:"🏢",oil_drum:"🛢",ok:"🆗",ok_hand:"👌",ok_man:"🙆♂️",ok_woman:"🙆",old_key:"🗝",older_man:"👴",older_woman:"👵",om:"🕉",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",open_umbrella:"☂️",ophiuchus:"⛎",orange_book:"📙",orthodox_cross:"☦️",outbox_tray:"📤",owl:"🦉",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",paintbrush:"🖌",palm_tree:"🌴",pancakes:"🥞",panda_face:"🐼",paperclip:"📎",paperclips:"🖇",parasol_on_ground:"⛱",parking:"🅿️",part_alternation_mark:"〽️",partly_sunny:"⛅️",passenger_ship:"🛳",passport_control:"🛂",pause_button:"⏸",peace_symbol:"☮️",peach:"🍑",peanuts:"🥜",pear:"🍐",pen:"🖊",pencil2:"✏️",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_fencing:"🤺",pouting_woman:"🙎",phone:"☎️",pick:"⛏",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",ping_pong:"🏓",pisces:"♓️",pizza:"🍕",place_of_worship:"🛐",plate_with_cutlery:"🍽",play_or_pause_button:"⏯",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝️",point_up_2:"👆",police_car:"🚓",policewoman:"👮♀️",poodle:"🐩",popcorn:"🍿",post_office:"🏣",postal_horn:"📯",postbox:"📮",potable_water:"🚰",potato:"🥔",pouch:"👝",poultry_leg:"🍗",pound:"💷",rage:"😡",pouting_cat:"😾",pouting_man:"🙎♂️",pray:"🙏",prayer_beads:"📿",pregnant_woman:"🤰",previous_track_button:"⏮",prince:"🤴",princess:"👸",printer:"🖨",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",racing_car:"🏎",radio:"📻",radio_button:"🔘",radioactive:"☢️",railway_car:"🚃",railway_track:"🛤",rainbow:"🌈",rainbow_flag:"🏳️🌈",raised_back_of_hand:"🤚",raised_hand_with_fingers_splayed:"🖐",raised_hands:"🙌",raising_hand_woman:"🙋",raising_hand_man:"🙋♂️",ram:"🐏",ramen:"🍜",rat:"🐀",record_button:"⏺",recycle:"♻️",red_circle:"🔴",registered:"®️",relaxed:"☺️",relieved:"😌",reminder_ribbon:"🎗",repeat:"🔁",repeat_one:"🔂",rescue_worker_helmet:"⛑",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",rhinoceros:"🦏",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",right_anger_bubble:"🗯",ring:"💍",robot:"🤖",rocket:"🚀",rofl:"🤣",roll_eyes:"🙄",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rosette:"🏵",rotating_light:"🚨",round_pushpin:"📍",rowing_man:"🚣",rowing_woman:"🚣♀️",rugby_football:"🏉",running_man:"🏃",running_shirt_with_sash:"🎽",running_woman:"🏃♀️",sa:"🈂️",sagittarius:"♐️",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"📡",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂️",scorpion:"🦂",scorpius:"♏️",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙️",see_no_evil:"🙈",seedling:"🌱",selfie:"🤳",shallow_pan_of_food:"🥘",shamrock:"☘️",shark:"🦈",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",shield:"🛡",shinto_shrine:"⛩",ship:"🚢",shirt:"👕",shopping:"🛍",shopping_cart:"🛒",shower:"🚿",shrimp:"🦐",signal_strength:"📶",six_pointed_star:"🔯",ski:"🎿",skier:"⛷",skull:"💀",skull_and_crossbones:"☠️",sleeping:"😴",sleeping_bed:"🛌",sleepy:"😪",slightly_frowning_face:"🙁",slightly_smiling_face:"🙂",slot_machine:"🎰",small_airplane:"🛩",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",sneezing_face:"🤧",snowboarder:"🏂",snowflake:"❄️",snowman:"⛄️",snowman_with_snow:"☃️",sob:"😭",soccer:"⚽️",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠️",spaghetti:"🍝",sparkle:"❇️",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speaking_head:"🗣",speech_balloon:"💬",speedboat:"🚤",spider:"🕷",spider_web:"🕸",spiral_calendar:"🗓",spiral_notepad:"🗒",spoon:"🥄",squid:"🦑",stadium:"🏟",star:"⭐️",star2:"🌟",star_and_crescent:"☪️",star_of_david:"✡️",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",stop_button:"⏹",stop_sign:"🛑",stopwatch:"⏱",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",studio_microphone:"🎙",stuffed_flatbread:"🥙",sun_behind_large_cloud:"🌥",sun_behind_rain_cloud:"🌦",sun_behind_small_cloud:"🌤",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀️",sunrise:"🌅",sunrise_over_mountains:"🌄",surfing_man:"🏄",surfing_woman:"🏄♀️",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimming_man:"🏊",swimming_woman:"🏊♀️",symbols:"🔣",synagogue:"🕍",syringe:"💉",taco:"🌮",tada:"🎉",tanabata_tree:"🎋",taurus:"♉️",taxi:"🚕",tea:"🍵",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"⛺️",thermometer:"🌡",thinking:"🤔",thought_balloon:"💭",ticket:"🎫",tickets:"🎟",tiger:"🐯",tiger2:"🐅",timer_clock:"⏲",tipping_hand_man:"💁♂️",tired_face:"😫",tm:"™️",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tornado:"🌪",trackball:"🖲",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tulip:"🌷",tumbler_glass:"🥃",turkey:"🦃",turtle:"🐢",tv:"📺",twisted_rightwards_arrows:"🔀",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯️",u6708:"🈷️",u6709:"🈶",u6e80:"🈵",u7121:"🈚️",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔️",unamused:"😒",underage:"🔞",unicorn:"🦄",unlock:"🔓",up:"🆙",upside_down_face:"🙃",v:"✌️",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍️",volcano:"🌋",volleyball:"🏐",vs:"🆚",vulcan_salute:"🖖",walking_man:"🚶",walking_woman:"🚶♀️",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠️",wastebasket:"🗑",watch:"⌚️",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰️",waxing_crescent_moon:"🌒",wc:"🚾",weary:"😩",wedding:"💒",weight_lifting_man:"🏋️",weight_lifting_woman:"🏋️♀️",whale:"🐳",whale2:"🐋",wheel_of_dharma:"☸️",wheelchair:"♿️",white_check_mark:"✅",white_circle:"⚪️",white_flag:"🏳️",white_flower:"💮",white_large_square:"⬜️",white_medium_small_square:"◽️",white_medium_square:"◻️",white_small_square:"▫️",white_square_button:"🔳",wilted_flower:"🥀",wind_chime:"🎐",wind_face:"🌬",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",woman_artist:"👩🎨",woman_astronaut:"👩🚀",woman_cartwheeling:"🤸♀️",woman_cook:"👩🍳",woman_facepalming:"🤦♀️",woman_factory_worker:"👩🏭",woman_farmer:"👩🌾",woman_firefighter:"👩🚒",woman_health_worker:"👩⚕️",woman_judge:"👩⚖️",woman_juggling:"🤹♀️",woman_mechanic:"👩🔧",woman_office_worker:"👩💼",woman_pilot:"👩✈️",woman_playing_handball:"🤾♀️",woman_playing_water_polo:"🤽♀️",woman_scientist:"👩🔬",woman_shrugging:"🤷♀️",woman_singer:"👩🎤",woman_student:"👩🎓",woman_teacher:"👩🏫",woman_technologist:"👩💻",woman_with_turban:"👳♀️",womans_clothes:"👚",womans_hat:"👒",women_wrestling:"🤼♀️",womens:"🚺",world_map:"🗺",worried:"😟",wrench:"🔧",writing_hand:"✍️",x:"❌",yellow_heart:"💛",yen:"💴",yin_yang:"☯️",yum:"😋",zap:"⚡️",zipper_mouth_face:"🤐",zzz:"💤",octocat:'
',showdown:`S`},n.Converter=function(f){var E={},S=[],N=[],k={},L=o,M={parsed:{},raw:"",format:""};G();function G(){f=f||{};for(var B in a)a.hasOwnProperty(B)&&(E[B]=a[B]);if(typeof f=="object")for(var Q in f)f.hasOwnProperty(Q)&&(E[Q]=f[Q]);else throw Error("Converter expects the passed parameter to be an object, but "+typeof f+" was passed instead.");E.extensions&&n.helper.forEach(E.extensions,te)}function te(B,Q){if(Q=Q||null,n.helper.isString(B))if(B=n.helper.stdExtName(B),Q=B,n.extensions[B]){console.warn("DEPRECATION WARNING: "+B+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),re(n.extensions[B],B);return}else if(!n.helper.isUndefined(s[B]))B=s[B];else throw Error('Extension "'+B+'" could not be loaded. It was either not found or is not a valid extension.');typeof B=="function"&&(B=B()),n.helper.isArray(B)||(B=[B]);var j=c(B,Q);if(!j.valid)throw Error(j.error);for(var K=0;K",!1),Ht=st("@",!1),lt=st(":",!1),yt=Kn(["m","k","l","p","d","c","w","y","h","n","q","a","e","f","s","x","t","g","u","j","z","o"],!1,!1),zn=st("/",!1),dt=st("(",!1),Kt=st(")",!1),Tt=st("[:",!1),Ue=st("]",!1),Fn=st("[",!1),Yr=st("{",!1),ct=st("}",!1),Hn=st("+",!1),Nn=st("*",!1),Ii=st("%",!1),wn=st("^",!1),Wt=st("&",!1),yr=st(">>",!1),ta=st("<<",!1),li=st("_",!1),na=st("?",!1),cr=st("!",!1),ci=st("r",!1),Ar=Kn([["a","z"],["A","Z"],["0","9"]],!1,!1),jt=st("#",!1),ui=st("b",!1),di=Kn([["a","z"],["A","Z"],["0","9"],"-","*","+"],!1,!1),q=Kn([["A","G"]],!1,!1),ie=Kn(["b","s"],!1,!1),de=st("iii",!1),_e=st("ii",!1),Ae=st("iv",!1),Qe=st("i",!1),Me=st("vii",!1),Ct=st("vi",!1),Dn=st("v",!1),Wn=function(T){return T.filter(w=>w)},Da=function(){return parseFloat($n())},ra=function(){return parseInt($n())},xs=function(){return parseInt($n())},Xn=function(){},ks=function(T){return Ut(n3,{sound:T})},xa=function(){return $n()},ka=function(T){return Ut(Ro,{items:T})},Ls=function(T){return T},La=function(T,w){return Ut(r3,{item:T,sound:w})},Ms=function(T,w){return Ut(i3,{item:T,soundIndex:w})},Ma=function(T){return T},Yn=function(){return VP[$n()]},Ps=function(T,w){return T/w},Bs=function(T){return T.filter(w=>w)},Pa=function(T){return Ut(Ro,{items:T})},Ba=function(T,w){return w?Ut(OE,{item:T,times:w}):Ut(EE,{items:T})},Us=function(T){return T},Ua=function(T,w,P){return Ut(c3,{left:T,operation:w,right:P})},Fs=function(T,w){return Ut(l3,{items:T,times:w})},Fa=function(T){return Ut(RI,{items:T})},Ys=function(T){return T.map(w=>typeof w=="number"?w:void 0)},$s=function(){return Math.ceil(AI($n()))},ur=function(T){var w=T.filter(P=>P).map(P=>Ut(ni,{pitch:P[0]},P.toString()));return Ut(EE,{items:w})},Ot=function(T){return T},Gs=function(T){return T},Ri=function(){},Qs=function(T){return Ut(Ro,{items:T})},pi=function(T){return Ut(s3,{octave:T})},qs=function(){return $n().split("").reduce((T,w)=>T+(w==="^"?1:-1),0)},Ni=function(){return Ut(Pc,{seededRandom:s.seededRandom})},Ya=function(T,w){return Ut(Pc,{min:T,max:w,seededRandom:s.seededRandom})},$a=function(T,w){return Ut(OE,{item:T,times:w})},Vs=function(T){return Ut(o3,{duration:T})},wi=function(T){return T},Ga=function(T){return Ut(qm,{duration:T})},Di=function(T,w,P,X){const oe=T?s.nodeOptions.octave+T:s.nodeOptions.octave;return Ut(ni,{duration:w,pitch:X,pitchOctave:oe,add:P})},xi=function(T){return T.reduce((w,P)=>w+(P==="#"?1:-1),0)},Qa=function(T,w,P){return Ut(Ra,{pitches:[T].concat(w),inversion:P})},ia=function(){return $n()},hi=function(T){return T},gn=function(){return $n()},qa=function(T,w,P,X,oe){const ve=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",ht=s.nodeOptions.key?s.nodeOptions.key:"C",hr=S3(X,P,ve,T,w),Ks=w||s.nodeOptions.duration,vR=T?s.nodeOptions.octave+T:s.nodeOptions.octave;return Ut(Ra,{duration:Ks,chordOctave:vR,pitches:hr,chordName:X,inversion:oe,scaleName:ve,key:ht})},Zn=function(T,w,P){const X=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",oe=s.nodeOptions.key?s.nodeOptions.key:"C";return Ut(a3,{roman:T,chordName:w,inversion:P,scaleName:X,key:oe})},aa=function(T){const w=s.nodeOptions.scaleName?s.nodeOptions.scaleName:"MAJOR",P=s.nodeOptions.key?s.nodeOptions.key:"C",X=I3(T,P,w);return Ut(ni,{pitch:X.pc,add:X.add,scaleName:w,key:P})},A=0,He=0,Va=[{line:1,column:1}],dr=0,zs=[],Oe=0,ge={},sa;if("startRule"in s){if(!(s.startRule in l))throw new Error(`Can't start parsing from rule "`+s.startRule+'".');c=l[s.startRule]}function $n(){return i.substring(He,A)}function ul(){return d(He,A)}function st(T,w){return{type:"literal",text:T,ignoreCase:w}}function Kn(T,w,P){return{type:"class",parts:T,inverted:w,ignoreCase:P}}function dl(){return{type:"end"}}function Hs(T){return{type:"other",description:T}}function pl(T){var w=Va[T],P;if(w)return w;for(P=T-1;!Va[P];)P--;for(w=Va[P],w={line:w.line,column:w.column};Pdr&&(dr=A,zs=[]),zs.push(T))}function g(T,w,P){return new e(e.buildMessage(T,w),T,w,P)}function O(){var T,w,P=A*56+0,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=Xt(),w!==a&&(He=T,w=Wn(w)),T=w,ge[P]={nextPos:A,result:T},T)}function C(){var T,w,P,X,oe,ve,ht,hr=A*56+1,Ks=ge[hr];if(Ks)return A=Ks.nextPos,Ks.result;for(T=A,w=A,i.charCodeAt(A)===45?(P=u,A++):(P=a,Oe===0&&h(rn)),P===a&&(P=null),X=[],Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze));oe!==a;)X.push(oe),Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze));if(i.charCodeAt(A)===46?(oe=p,A++):(oe=a,Oe===0&&h(ke)),oe!==a){if(ve=[],Be.test(i.charAt(A))?(ht=i.charAt(A),A++):(ht=a,Oe===0&&h(Ze)),ht!==a)for(;ht!==a;)ve.push(ht),Be.test(i.charAt(A))?(ht=i.charAt(A),A++):(ht=a,Oe===0&&h(Ze));else ve=a;ve!==a?(P=[P,X,oe,ve],w=P):(A=w,w=a)}else A=w,w=a;if(w===a)if(w=A,i.charCodeAt(A)===46?(P=p,A++):(P=a,Oe===0&&h(ke)),P!==a){if(X=[],Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze)),oe!==a)for(;oe!==a;)X.push(oe),Be.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ze));else X=a;X!==a?(P=[P,X],w=P):(A=w,w=a)}else A=w,w=a;return w!==a&&(He=T,w=Da()),T=w,ge[hr]={nextPos:A,result:T},T}function y(){var T,w,P=A*56+2,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,i.charCodeAt(A)===45?A++:Oe===0&&h(rn),Be.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(Ze)),w!==a?(He=T,T=ra()):(A=T,T=a),ge[P]={nextPos:A,result:T},T)}function D(){var T,w,P,X=A*56+3,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,i.charCodeAt(A)===45?A++:Oe===0&&h(rn),w=[],Be.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(Ze)),P!==a)for(;P!==a;)w.push(P),Be.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(Ze));else w=a;return w!==a?(He=T,T=xs()):(A=T,T=a),ge[X]={nextPos:A,result:T},T}function F(){var T,w,P=A*56+4,X=ge[P];return X?(A=X.nextPos,X.result):(Oe++,T=A,tt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(Zt)),w!==a&&(He=T,w=Xn()),T=w,Oe--,T===a&&(w=a,Oe===0&&h(en)),ge[P]={nextPos:A,result:T},T)}function U(){var T,w,P=A*56+8,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=W(),w!==a&&(He=T,w=ks(w)),T=w,ge[P]={nextPos:A,result:T},T)}function W(){var T,w,P,X,oe,ve=A*56+10,ht=ge[ve];if(ht)return A=ht.nextPos,ht.result;if(T=A,rt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(he)),w!==a){if(P=[],ft.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(Ie)),X!==a)for(;X!==a;)P.push(X),ft.test(i.charAt(A))?(X=i.charAt(A),A++):(X=a,Oe===0&&h(Ie));else P=a;if(P!==a){for(X=[],vt.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(we));oe!==a;)X.push(oe),vt.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(we));He=T,T=xa()}else A=T,T=a}else A=T,T=a;return ge[ve]={nextPos:A,result:T},T}function z(){var T,w=A*56+11,P=ge[w];return P?(A=P.nextPos,P.result):(T=pe(),T===a&&(T=fe()),ge[w]={nextPos:A,result:T},T)}function pe(){var T,w,P,X,oe=A*56+12,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,i.charCodeAt(A)===60?(w=v,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=z(),X!==a)for(;X!==a;)P.push(X),X=z();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(He=T,T=ka(P)):(A=T,T=a)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function fe(){var T,w=A*56+13,P=ge[w];return P?(A=P.nextPos,P.result):(T=W(),T===a&&(T=pe(),T===a&&(T=F())),ge[w]={nextPos:A,result:T},T)}function se(){var T,w,P,X=A*56+14,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===64?(w=R,A++):(w=a,Oe===0&&h(Ht)),w!==a?(P=z(),P!==a?(He=T,T=Ls(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function ae(){var T,w=A*56+15,P=ge[w];return P?(A=P.nextPos,P.result):(T=sn(),T===a&&(T=it(),T===a&&(T=qt(),T===a&&(T=lu(),T===a&&(T=Qt())))),ge[w]={nextPos:A,result:T},T)}function Ce(){var T,w,P,X=A*56+16,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,w=ae(),w===a&&(w=Zs()),w!==a?(P=se(),P!==a?(He=T,T=La(w,P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function Se(){var T,w,P,X=A*56+17,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,w=Ce(),w===a&&(w=ae(),w===a&&(w=Zs())),w!==a?(P=Ve(),P!==a?(He=T,T=Ms(w,P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function Ve(){var T,w,P,X=A*56+18,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===58?(w=x,A++):(w=a,Oe===0&&h(lt)),w!==a?(P=wt(),P!==a?(He=T,T=Ma(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function je(){var T,w,P=A*56+19,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,mt.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(yt)),w!==a&&(He=T,w=Yn()),T=w,ge[P]={nextPos:A,result:T},T)}function Fe(){var T,w=A*56+20,P=ge[w];return P?(A=P.nextPos,P.result):(T=It(),T===a&&(T=C(),T===a&&(T=je())),ge[w]={nextPos:A,result:T},T)}function It(){var T,w,P,X,oe=A*56+21,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,w=D(),w!==a?(i.charCodeAt(A)===47?(P=$,A++):(P=a,Oe===0&&h(zn)),P!==a?(X=D(),X!==a?(He=T,T=Ps(w,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function Xt(){var T,w,P,X=A*56+22,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],P=C_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=sn(),P===a&&(P=qt(),P===a&&(P=it(),P===a&&(P=Qt(),P===a&&(P=Zs(),P===a&&(P=lu())))))))),P!==a)for(;P!==a;)w.push(P),P=C_(),P===a&&(P=Se(),P===a&&(P=Ce(),P===a&&(P=sn(),P===a&&(P=qt(),P===a&&(P=it(),P===a&&(P=Qt(),P===a&&(P=Zs(),P===a&&(P=lu()))))))));else w=a;return w!==a&&(He=T,w=Bs(w)),T=w,ge[X]={nextPos:A,result:T},T}function wt(){var T,w=A*56+23,P=ge[w];return P?(A=P.nextPos,P.result):(T=F(),T===a&&(T=D(),T===a&&(T=T_(),T===a&&(T=uu(),T===a&&(T=tn(),T===a&&(T=b_()))))),ge[w]={nextPos:A,result:T},T)}function tn(){var T,w,P,X,oe=A*56+24,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,i.charCodeAt(A)===60?(w=v,A++):(w=a,Oe===0&&h(Je)),w!==a){if(P=[],X=wt(),X!==a)for(;X!==a;)P.push(X),X=wt();else P=a;P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(He=T,T=Pa(P)):(A=T,T=a)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function it(){var T,w,P,X,oe,ve=A*56+25,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,i.charCodeAt(A)===40?(w=Z,A++):(w=a,Oe===0&&h(dt)),w!==a?(i.charCodeAt(A)===58?A++:Oe===0&&h(lt),P=Xt(),P!==a?(X=pt(),X===a&&(X=null),i.charCodeAt(A)===41?(oe=f,A++):(oe=a,Oe===0&&h(Kt)),oe!==a?(He=T,T=Ba(P,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function pt(){var T,w,P,X=A*56+26,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===58?(w=x,A++):(w=a,Oe===0&&h(lt)),w!==a?(P=D(),P!==a?(He=T,T=Us(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function sn(){var T,w,P,X,oe=A*56+27,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,w=it(),w!==a?(P=v_(),P!==a?(X=it(),X!==a?(He=T,T=Ua(w,P,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function Qt(){var T,w,P,X,oe,ve=A*56+28,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,i.substr(A,2)===E?(w=E,A+=2):(w=a,Oe===0&&h(Tt)),w!==a?(P=Xt(),P!==a?(X=pt(),X===a&&(X=null),i.charCodeAt(A)===93?(oe=S,A++):(oe=a,Oe===0&&h(Ue)),oe!==a?(He=T,T=Fs(P,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function qt(){var T,w,P,X,oe=A*56+29,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===91?(w=N,A++):(w=a,Oe===0&&h(Fn)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===93?(X=S,A++):(X=a,Oe===0&&h(Ue)),X!==a?(He=T,T=Fa(P)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function pr(){var T,w=A*56+30,P=ge[w];return P?(A=P.nextPos,P.result):(T=D(),T===a&&(T=y()),ge[w]={nextPos:A,result:T},T)}function Ws(){var T,w,P,X=A*56+31,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],P=hl(),P===a&&(P=pr()),P!==a)for(;P!==a;)w.push(P),P=hl(),P===a&&(P=pr());else w=a;return w!==a&&(He=T,w=Ys(w)),T=w,ge[X]={nextPos:A,result:T},T}function hl(){var T,w,P,X,oe=A*56+32,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===40?A++:Oe===0&&h(dt),w=pr(),w!==a?(P=v_(),P!==a?(X=Ws(),X!==a?(i.charCodeAt(A)===41?A++:Oe===0&&h(Kt),He=T,T=$s()):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function Xs(){var T,w,P,X,oe=A*56+33,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Yr)),w!==a){if(P=[],X=Ws(),X===a&&(X=F()),X!==a)for(;X!==a;)P.push(X),X=Ws(),X===a&&(X=F());else P=a;P!==a?(i.charCodeAt(A)===125?(X=L,A++):(X=a,Oe===0&&h(ct)),X!==a?(He=T,T=ur(P)):(A=T,T=a)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function b_(){var T,w,P,X,oe=A*56+34,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===123?(w=k,A++):(w=a,Oe===0&&h(Yr)),w!==a?(P=D(),P===a&&(P=uu()),P!==a?(i.charCodeAt(A)===125?(X=L,A++):(X=a,Oe===0&&h(ct)),X!==a?(He=T,T=Ot(P)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function v_(){var T,w=A*56+35,P=ge[w];return P?(A=P.nextPos,P.result):(i.charCodeAt(A)===43?(T=M,A++):(T=a,Oe===0&&h(Hn)),T===a&&(i.charCodeAt(A)===45?(T=u,A++):(T=a,Oe===0&&h(rn)),T===a&&(i.charCodeAt(A)===42?(T=G,A++):(T=a,Oe===0&&h(Nn)),T===a&&(i.charCodeAt(A)===47?(T=$,A++):(T=a,Oe===0&&h(zn)),T===a&&(i.charCodeAt(A)===37?(T=te,A++):(T=a,Oe===0&&h(Ii)),T===a&&(i.charCodeAt(A)===94?(T=re,A++):(T=a,Oe===0&&h(wn)),T===a&&(i.charCodeAt(A)===124?(T=_,A++):(T=a,Oe===0&&h(H)),T===a&&(i.charCodeAt(A)===38?(T=ne,A++):(T=a,Oe===0&&h(Wt)),T===a&&(i.substr(A,2)===ee?(T=ee,A+=2):(T=a,Oe===0&&h(yr)),T===a&&(i.substr(A,2)===B?(T=B,A+=2):(T=a,Oe===0&&h(ta))))))))))),ge[w]={nextPos:A,result:T},T)}function Zs(){var T,w,P=A*56+36,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=gR(),w===a&&(w=ER(),w===a&&(w=OR(),w===a&&(w=bR(),w===a&&(w=U(),w===a&&(w=SR(),w===a&&(w=fl(),w===a&&(w=hR(),w===a&&(w=F(),w===a&&(w=fR(),w===a&&(w=it(),w===a&&(w=Xs(),w===a&&(w=pR())))))))))))),w!==a&&(He=T,w=Gs(w)),T=w,ge[P]={nextPos:A,result:T},T)}function pR(){var T,w,P=A*56+37,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,i.charCodeAt(A)===124?(w=_,A++):(w=a,Oe===0&&h(H)),w!==a&&(He=T,w=Ri()),T=w,ge[P]={nextPos:A,result:T},T)}function lu(){var T,w,P,X,oe=A*56+38,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.charCodeAt(A)===60?(w=v,A++):(w=a,Oe===0&&h(Je)),w!==a?(P=Xt(),P!==a?(i.charCodeAt(A)===62?(X=I,A++):(X=a,Oe===0&&h(ye)),X!==a?(He=T,T=Qs(P)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function hR(){var T,w,P=A*56+39,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=cu(),w!==a&&(He=T,w=pi(w)),T=w,ge[P]={nextPos:A,result:T},T)}function cu(){var T,w,P,X=A*56+40,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],i.charCodeAt(A)===94?(P=re,A++):(P=a,Oe===0&&h(wn)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===94?(P=re,A++):(P=a,Oe===0&&h(wn)),P===a&&(i.charCodeAt(A)===95?(P=Q,A++):(P=a,Oe===0&&h(li)));else w=a;return w!==a&&(He=T,w=qs()),T=w,ge[X]={nextPos:A,result:T},T}function T_(){var T,w,P=A*56+41,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,i.charCodeAt(A)===63?(w=j,A++):(w=a,Oe===0&&h(na)),w!==a&&(He=T,w=Ni()),T=w,ge[P]={nextPos:A,result:T},T)}function uu(){var T,w,P,X,oe,ve,ht=A*56+42,hr=ge[ht];return hr?(A=hr.nextPos,hr.result):(T=A,i.charCodeAt(A)===40?(w=Z,A++):(w=a,Oe===0&&h(dt)),w!==a?(P=D(),P!==a?(i.charCodeAt(A)===44?(X=m,A++):(X=a,Oe===0&&h(an)),X!==a?(oe=D(),oe!==a?(i.charCodeAt(A)===41?(ve=f,A++):(ve=a,Oe===0&&h(Kt)),ve!==a?(He=T,T=Ya(P,oe)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[ht]={nextPos:A,result:T},T)}function C_(){var T,w,P,X,oe=A*56+43,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,w=Se(),w===a&&(w=Ce(),w===a&&(w=ae(),w===a&&(w=Zs()))),w!==a?(i.charCodeAt(A)===33?(P=K,A++):(P=a,Oe===0&&h(cr)),P!==a?(X=D(),X!==a?(He=T,T=$a(w,X)):(A=T,T=a)):(A=T,T=a)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function fR(){var T,w,P=A*56+44,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=Fe(),w!==a&&(He=T,w=Vs(w)),T=w,ge[P]={nextPos:A,result:T},T)}function mR(){var T,w,P,X=A*56+45,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,w=Fe(),w!==a?(i.charCodeAt(A)===94?(P=re,A++):(P=a,Oe===0&&h(wn)),P!==a?(He=T,T=wi(w)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function gR(){var T,w,P,X,oe,ve=A*56+46,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,w=mR(),w===a&&(w=null),i.charCodeAt(A)===114?(P=ue,A++):(P=a,Oe===0&&h(ci)),P!==a?(X=A,Oe++,At.test(i.charAt(A))?(oe=i.charAt(A),A++):(oe=a,Oe===0&&h(Ar)),Oe--,oe===a?X=void 0:(A=X,X=a),X!==a?(He=T,T=Ga(w)):(A=T,T=a)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function fl(){var T,w,P,X,oe,ve=A*56+47,ht=ge[ve];return ht?(A=ht.nextPos,ht.result):(T=A,w=cu(),w===a&&(w=null),P=Fe(),P===a&&(P=null),X=_R(),X===a&&(X=null),oe=y(),oe===a&&(oe=T_(),oe===a&&(oe=uu(),oe===a&&(oe=b_()))),oe!==a?(He=T,T=Di(w,P,X,oe)):(A=T,T=a),ge[ve]={nextPos:A,result:T},T)}function _R(){var T,w,P,X=A*56+48,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(jt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui))),P!==a)for(;P!==a;)w.push(P),i.charCodeAt(A)===35?(P=le,A++):(P=a,Oe===0&&h(jt)),P===a&&(i.charCodeAt(A)===98?(P=Ee,A++):(P=a,Oe===0&&h(ui)));else w=a;return w!==a&&(He=T,w=xi(w)),T=w,ge[X]={nextPos:A,result:T},T}function SR(){var T,w,P,X,oe=A*56+49,ve=ge[oe];if(ve)return A=ve.nextPos,ve.result;if(T=A,w=fl(),w!==a){if(P=[],X=fl(),X!==a)for(;X!==a;)P.push(X),X=fl();else P=a;P!==a?(X=du(),X===a&&(X=null),He=T,T=Qa(w,P,X)):(A=T,T=a)}else A=T,T=a;return ge[oe]={nextPos:A,result:T},T}function y_(){var T,w,P,X=A*56+50,oe=ge[X];if(oe)return A=oe.nextPos,oe.result;if(T=A,w=[],Nt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di)),P!==a)for(;P!==a;)w.push(P),Nt.test(i.charAt(A))?(P=i.charAt(A),A++):(P=a,Oe===0&&h(di));else w=a;return w!==a&&(He=T,w=ia()),T=w,ge[X]={nextPos:A,result:T},T}function du(){var T,w,P,X=A*56+51,oe=ge[X];return oe?(A=oe.nextPos,oe.result):(T=A,i.charCodeAt(A)===37?(w=te,A++):(w=a,Oe===0&&h(Ii)),w!==a?(P=D(),P!==a?(He=T,T=hi(P)):(A=T,T=a)):(A=T,T=a),ge[X]={nextPos:A,result:T},T)}function A_(){var T,w,P=A*56+52,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,Rn.test(i.charAt(A))?(w=i.charAt(A),A++):(w=a,Oe===0&&h(q)),w!==a?(qe.test(i.charAt(A))?(i.charAt(A),A++):Oe===0&&h(ie),He=T,T=gn()):(A=T,T=a),ge[P]={nextPos:A,result:T},T)}function OR(){var T,w,P,X,oe,ve,ht=A*56+53,hr=ge[ht];return hr?(A=hr.nextPos,hr.result):(T=A,w=cu(),w===a&&(w=null),P=Fe(),P===a&&(P=null),X=A_(),X!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(wn),oe=y_(),oe!==a?(ve=du(),ve===a&&(ve=null),He=T,T=qa(w,P,X,oe,ve)):(A=T,T=a)):(A=T,T=a),ge[ht]={nextPos:A,result:T},T)}function ER(){var T,w,P,X,oe=A*56+54,ve=ge[oe];return ve?(A=ve.nextPos,ve.result):(T=A,i.substr(A,3)===De?(w=De,A+=3):(w=a,Oe===0&&h(de)),w===a&&(i.substr(A,2)===xe?(w=xe,A+=2):(w=a,Oe===0&&h(_e)),w===a&&(i.substr(A,2)===be?(w=be,A+=2):(w=a,Oe===0&&h(Ae)),w===a&&(i.charCodeAt(A)===105?(w=Ne,A++):(w=a,Oe===0&&h(Qe)),w===a&&(i.substr(A,3)===ce?(w=ce,A+=3):(w=a,Oe===0&&h(Me)),w===a&&(i.substr(A,2)===Le?(w=Le,A+=2):(w=a,Oe===0&&h(Ct)),w===a&&(i.charCodeAt(A)===118?(w=Xe,A++):(w=a,Oe===0&&h(Dn)))))))),w!==a?(i.charCodeAt(A)===94?A++:Oe===0&&h(wn),P=y_(),P===a&&(P=null),X=du(),X===a&&(X=null),He=T,T=Zn(w,P,X)):(A=T,T=a),ge[oe]={nextPos:A,result:T},T)}function bR(){var T,w,P=A*56+55,X=ge[P];return X?(A=X.nextPos,X.result):(T=A,w=A_(),w!==a&&(He=T,w=aa(w)),T=w,ge[P]={nextPos:A,result:T},T)}var I_=s.nodeOptions||{};function Ut(T,w,P=void 0){w.text=P||$n(),w.location=ul();for(var X in I_)(w[X]===void 0||w[X]===null)&&(w[X]=I_[X]);return new T(w)}if(sa=c(),sa!==a&&A===i.length)return sa;throw sa!==a&&Ae.collect("pitch"))}notes(){return this.evaluated.map(e=>e.collect("note"))}sounds(){return this.evaluated.map(e=>e.collect("sound"))}indices(){return this.evaluated.map(e=>e.collect("soundIndex"))}freqs(){return this.evaluated.map(e=>e.collect("freq"))}durations(){return this.evaluated.map(e=>e.collect("duration"))}octaves(){return this.evaluated.map(e=>e.collect("octave"))}retrograde(){return this.evaluated=this.evaluated.reverse(),this}scale(e){return this.applyOptions({scale:e}),this}key(e){return this.applyOptions({key:e}),this}octave(e){return this.applyOptions({octave:e}),this}invert(e){return this.applyOptions({inversion:e}),this}isInOptions(e,t){return this.options.nodeOptions&&this.options.nodeOptions[e]===t}atLast(){return this.index+1>=this.evaluated.length*this.redo}clone(){return ti(this)}notStarted(){return this.index<0}peek(){return this.evaluated[this.index-1||0]}hasStarted(){return this.index>=0}next(){this.index<0&&(this.index=0);const e=this.evaluated[this.index%this.evaluated.length];return this.index++,this.counter++,this.redo>0&&this.index>=this.evaluated.length*this.redo&&(this.index=0,this.evaluated=this.evaluate(this.values)),e}applyOptions(e={}){this.evaluated=this.evaluate(this.evaluated,e),this.applyTransformations()}applyTransformations(){var e;(e=this.globalOptions)!=null&&e.retrograde&&(this.evaluated=this.evaluated.reverse())}update(){return this.evaluated=this.evaluate(this.values),this.applyTransformations(),this}evaluate(e,t={}){let n=e.map(i=>i.evaluate(t)).flat(1/0).filter(i=>i!==void 0);return t.subdivisions&&(n=MI(n)),n}totalDuration(){return this.evaluated.reduce((t,n)=>t+n.collect("duration"),0)}lead(){let e=this.evaluated.findIndex(t=>t instanceof Ra);if(e>=0){for(let t=e+1;t<=this.evaluated.length;t++)if(this.evaluated[t]instanceof Ra){const n=this.evaluated[e],i=this.evaluated[t],s=N3(n.notes(),i.notes()),a=ti(i);a.voiceLeadFromNotes(s,this.options.nodeOptions),this.evaluated[t]=a,e=t}}return this}}const MI=(r,e=void 0)=>r.map(n=>{if(n instanceof RI){const i=n.evaluated.length,s=(e||n.duration)/i;return MI(n.evaluated,s)}else return n.duration=e||n.duration,n}).flat(1/0),x3=r=>{let e={};return t3.forEach(t=>{if(r[t]!==void 0){const n=r[t];e[t]=n,delete r[t]}}),e};class k3{constructor(e,t){b(this,"api");b(this,"settings");b(this,"midiAccess",null);b(this,"midiOutputs",[]);b(this,"currentOutputIndex",0);b(this,"scheduledNotes",{});b(this,"midiInputs",[]);b(this,"currentInputIndex");b(this,"bufferLength",512);b(this,"noteInputBuffer",[]);b(this,"ccInputBuffer",[]);b(this,"activeNotes",[]);b(this,"stickyNotes",[]);b(this,"lastNote");b(this,"lastCC",{});b(this,"lastNoteInChannel",{});b(this,"lastCCInChannel",{});b(this,"midiClockInputIndex");b(this,"midiClockInput");b(this,"lastTimestamp",0);b(this,"midiClockDelta",0);b(this,"lastBPM");b(this,"roundedBPM",0);b(this,"clockBuffer",[]);b(this,"clockBufferLength",24);b(this,"clockTicks",0);b(this,"clockErrorCount",0);b(this,"skipOnError",0);this.api=e,this.settings=t,this.lastBPM=e.bpm(),this.roundedBPM=this.lastBPM,this.initializeMidiAccess()}async initializeMidiAccess(){try{this.midiAccess=await navigator.requestMIDIAccess(),this.midiOutputs=Array.from(this.midiAccess.outputs.values()),this.midiOutputs.length===0&&(console.warn("No MIDI outputs available."),this.currentOutputIndex=-1),this.midiInputs=Array.from(this.midiAccess.inputs.values()),this.midiInputs.length===0?console.warn("No MIDI inputs available."):this.updateInputSelects()}catch(e){console.error("Failed to initialize MIDI:",e)}}getCurrentMidiPort(){return this.midiOutputs.length>0&&this.currentOutputIndex>=0&&this.currentOutputIndex0&&this.currentOutputIndex>=0&&this.currentOutputIndex0){const e=document.getElementById("midi-clock-input"),t=document.getElementById("default-midi-input");e.innerHTML="",t.innerHTML="";const n=document.createElement("option");n.value="-1",n.text="Internal",e.appendChild(n);const i=document.createElement("option");if(i.value="-1",i.text="None",t.appendChild(i),this.midiInputs.forEach((s,a)=>{const o=document.createElement("option");o.value=a.toString(),o.text=s.name||a.toString(),e.appendChild(o),t.appendChild(o.cloneNode(!0))}),this.settings.midi_clock_input){const s=this.getMidiInputIndex(this.settings.midi_clock_input);e.value=s.toString(),s>0&&(this.midiClockInput=this.midiInputs[s],this.registerMidiInputListener(s))}else e.value="-1";if(this.settings.default_midi_input){const s=this.getMidiInputIndex(this.settings.default_midi_input);t.value=s.toString(),s>0&&(this.currentInputIndex=s,this.registerMidiInputListener(s))}else t.value="-1";e.addEventListener("change",s=>{const a=s.target.value;if(a==="-1")this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=void 0,this.settings.midi_clock_input=void 0;else{const o=parseInt(a);this.midiClockInputIndex=o,this.midiClockInput&&this.midiClockInputIndex!=this.currentInputIndex&&(this.midiClockInput.onmidimessage=null),this.midiClockInput=this.midiInputs[o],this.registerMidiInputListener(o),this.settings.midi_clock_input=this.midiClockInput.name||void 0}}),t.addEventListener("change",s=>{const a=s.target.value;a==="-1"?(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=void 0,this.settings.default_midi_input=void 0):(this.currentInputIndex&&this.currentInputIndex!=this.midiClockInputIndex&&this.unregisterMidiInputListener(this.currentInputIndex),this.currentInputIndex=parseInt(a),this.registerMidiInputListener(this.currentInputIndex),this.settings.default_midi_input=this.midiInputs[this.currentInputIndex].name||void 0)})}}registerMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&!t.onmidimessage&&(t.onmidimessage=n=>{const i=n;if(t.name===this.settings.midi_clock_input&&(i.data[0]===248?this.skipOnError>0?this.skipOnError-=1:this.onMidiClock(n.timeStamp):i.data[0]===250?(console.log("MIDI start received"),this.api.stop(),this.api.play()):i.data[0]===252?(console.log("MIDI stop received"),this.api.pause()):i.data[0]===251?(console.log("MIDI continue received"),this.api.play()):i.data[0]===254&&console.log("MIDI active sensing received")),t.name===this.settings.default_midi_input){if(i.data[0]>=144&&i.data[0]<=159){const s=i.data[0]-144+1,a=i.data[1],o=i.data[2];this.lastNote={note:a,velocity:o,channel:s,timestamp:n.timeStamp},this.lastNoteInChannel[s]={note:a,velocity:o,channel:s,timestamp:n.timeStamp},this.settings.midi_channels_scripts&&this.api.script(s),this.pushToMidiInputBuffer({note:a,velocity:o,channel:s,timestamp:n.timeStamp}),this.activeNotes.push({note:a,velocity:o,channel:s,timestamp:n.timeStamp}),this.removeFromStickyNotes(a,s)||this.stickyNotes.push({note:a,velocity:o,channel:s,timestamp:n.timeStamp})}if(i.data[0]>=128&&i.data[0]<=143){const s=i.data[0]-128+1,a=i.data[1];this.removeFromActiveNotes(a,s)}if(i.data[0]>=176&&i.data[0]<=191){const s=i.data[0]-176+1,a=i.data[1],o=i.data[2];this.lastCC[a]=o,this.lastCCInChannel[s]?this.lastCCInChannel[s][a]=o:(this.lastCCInChannel[s]={},this.lastCCInChannel[s][a]=o),this.pushToMidiCCBuffer({control:a,value:o,channel:s,timestamp:n.timeStamp})}}})}}removeFromActiveNotes(e,t){const n=this.activeNotes.findIndex(i=>i.note===e&&i.channel===t);n>=0&&this.activeNotes.splice(n,1)}removeFromStickyNotes(e,t){const n=this.stickyNotes.findIndex(i=>i.note===e&&i.channel===t);return n>=0?(this.stickyNotes.splice(n,1),!0):!1}stickyNotesFromChannel(e){return this.stickyNotes.filter(t=>t.channel===e)}activeNotesFromChannel(e){return this.activeNotes.filter(t=>t.channel===e)}killActiveNotes(){this.activeNotes=[]}killActiveNotesFromChannel(e){this.activeNotes=this.activeNotes.filter(t=>t.channel!==e)}pushToMidiInputBuffer(e){this.noteInputBuffer.push(e),this.noteInputBuffer.length>this.bufferLength&&this.noteInputBuffer.shift()}pushToMidiCCBuffer(e){this.ccInputBuffer.push(e),this.ccInputBuffer.length>this.bufferLength&&this.ccInputBuffer.shift()}findNoteFromBufferInChannel(e){const t=this.noteInputBuffer.findIndex(n=>n.channel===e);if(t>=0){const n=this.noteInputBuffer[t];return this.noteInputBuffer.splice(t,1),n}else return}findCCFromBufferInChannel(e){const t=this.ccInputBuffer.findIndex(n=>n.channel===e);if(t>=0){const n=this.ccInputBuffer[t];return this.ccInputBuffer.splice(t,1),n}else return}unregisterMidiInputListener(e){if(e!==void 0){const t=this.midiInputs[e];t&&(t.onmidimessage=null)}}onMidiClock(e){if(this.clockTicks+=1,this.lastTimestamp>0)if(this.lastTimestamp===e)this.clockErrorCount+=1;else if(this.clockErrorCount>0)console.log("Timestamp error count: ",this.clockErrorCount),console.log("Current timestamp: ",e),console.log("Last timestamp: ",this.lastTimestamp),console.log("Last delta: ",this.midiClockDelta),console.log("Current delta: ",e-this.lastTimestamp),console.log("BPMs",this.clockBuffer),this.clockErrorCount=0,this.skipOnError=this.settings.midi_clock_ppqn/4,e=0;else{this.midiClockDelta=e-this.lastTimestamp,this.lastBPM=60*(1e3/this.midiClockDelta/this.settings.midi_clock_ppqn),this.clockBuffer.push(this.lastBPM),this.clockBuffer.length>this.clockBufferLength&&this.clockBuffer.shift();const t=this.estimatedBPM();t!==this.roundedBPM&&(console.log("Estimated BPM: ",t),this.api.bpm(t),this.roundedBPM=t)}this.lastTimestamp=e}estimatedBPM(){const e=this.clockBuffer.reduce((t,n)=>t+n);return Math.round(e/this.clockBuffer.length)}sendMidiClock(){if(!this.midiClockInput){const e=this.midiOutputs[this.currentOutputIndex];e&&e.send([248])}}switchMidiOutput(e){const t=this.getMidiOutputIndex(e);return t!==-1?(this.currentOutputIndex=t,!0):!1}getMidiOutputIndex(e){if(typeof e=="number")return e<0||e>=this.midiOutputs.length?(console.error(`Invalid MIDI output index. Index must be in the range 0-${this.midiOutputs.length-1}.`),this.currentOutputIndex):e;{const t=this.midiOutputs.findIndex(n=>n.name===e);return t!==-1?t:(console.error(`MIDI output "${e}" not found.`),this.currentOutputIndex)}}getMidiInputIndex(e){if(typeof e=="number")return e<0||e>=this.midiInputs.length?(console.error(`Invalid MIDI input index. Index must be in the range 0-${this.midiInputs.length-1}.`),-1):e;{const t=this.midiInputs.findIndex(n=>n.name===e);return t!==-1?t:(console.error(`MIDI input "${e}" not found.`),-1)}}listMidiOutputs(){let e="Available MIDI Outputs: ";return this.midiOutputs.forEach((t,n)=>{e+=`(${n+1}) ${t.name} `}),e}sendMidiNote(e,t,n,i,s=this.currentOutputIndex,a=void 0){typeof s=="string"&&(s=this.getMidiOutputIndex(s));const o=this.midiOutputs[s];if(e=Math.min(Math.max(e,0),127),o){const l=[144+t,e,n],c=[128+t,e,0];o.send(l),a&&this.sendPitchBend(a,t,s);const u=setTimeout(()=>{o.send(c),a&&this.sendPitchBend(8192,t,s),delete this.scheduledNotes[e]},(i-.02)*1e3);this.scheduledNotes[e]=u}else console.error("MIDI output not available.")}sendMidiOn(e,t,n,i=this.currentOutputIndex){typeof i=="string"&&(i=this.getMidiOutputIndex(i));const s=this.midiOutputs[i];if(e=Math.min(Math.max(e,0),127),s){const a=[144+t,e,n];s.send(a)}else console.error("MIDI output not available.")}sendMidiOff(e,t,n=this.currentOutputIndex){typeof n=="string"&&(n=this.getMidiOutputIndex(n));const i=this.midiOutputs[n];if(e=Math.min(Math.max(e,0),127),i){const s=[128+t,e,0];i.send(s)}else console.error("MIDI output not available.")}sendAllNotesOff(e,t=this.currentOutputIndex){typeof t=="string"&&(t=this.getMidiOutputIndex(t));const n=this.midiOutputs[t];if(n){const i=[176+e,123,0];n.send(i)}else console.error("MIDI output not available.")}sendAllSoundOff(e,t=this.currentOutputIndex){typeof t=="string"&&(t=this.getMidiOutputIndex(t));const n=this.midiOutputs[t];if(n){const i=[176+e,120,0];n.send(i)}else console.error("MIDI output not available.")}sendSysExMessage(e){const t=this.midiOutputs[this.currentOutputIndex];t?t.send(e):console.error("MIDI output not available.")}sendPitchBend(e,t,n=this.currentOutputIndex){(e<0||e>16383)&&console.error("Invalid pitch bend value. Value must be in the range 0-16383."),(t<0||t>15)&&console.error("Invalid MIDI channel. Channel must be in the range 0-15."),typeof n=="string"&&(n=this.getMidiOutputIndex(n));const i=this.midiOutputs[n];if(i){const s=e&127,a=e>>7&127;i.send([224|t,s,a])}else console.error("MIDI output not available.")}sendProgramChange(e,t){const n=this.midiOutputs[this.currentOutputIndex];n?n.send([192+t,e]):console.error("MIDI output not available.")}sendMidiControlChange(e,t,n){const i=this.midiOutputs[this.currentOutputIndex];i?i.send([176+n,e,t]):console.error("MIDI output not available.")}panic(){const e=this.midiOutputs[this.currentOutputIndex];if(e){for(const t in this.scheduledNotes){const n=this.scheduledNotes[t];clearTimeout(n),e.send([128,parseInt(t),0])}this.scheduledNotes={}}else console.error("MIDI output not available.")}}class L3{constructor(e,t,n){b(this,"min");b(this,"max");b(this,"wrap");b(this,"position");this.min=e,this.max=t,this.wrap=n,this.position=0}step(){const e=Math.floor(Math.random()*3)-1;this.position+=e,this.wrap?this.position>this.max?this.position=this.min:this.positionthis.max&&(this.position=this.max)}getPosition(){return this.position}toggleWrap(e){this.wrap=e}}class s_{constructor(e){b(this,"seedValue");b(this,"randomGen",Math.random);b(this,"app");b(this,"values",{});b(this,"evenbar",e=>this.app.clock.time_position.bar%2===0?this.modify(e):this);b(this,"even",e=>this.app.clock.time_position.beat%2===0?this.modify(e):this);b(this,"odd",e=>this.app.clock.time_position.beat%2!==0?this.modify(e):this);b(this,"odds",(e,t)=>this.randomGen()this);b(this,"almostNever",e=>this.odds(.025,e));b(this,"rarely",e=>this.odds(.1,e));b(this,"scarcely",e=>this.odds(.25,e));b(this,"sometimes",e=>this.odds(.5,e));b(this,"often",e=>this.odds(.75,e));b(this,"frequently",e=>this.odds(.9,e));b(this,"almostAlways",e=>this.odds(.985,e));b(this,"always",e=>this.modify(e));b(this,"modify",e=>e(this));b(this,"seed",e=>(this.seedValue=e.toString(),this.randomGen=this.app.api.localSeededRandom(this.seedValue),this));b(this,"clear",()=>(this.app.api.clearLocalSeed(this.seedValue),this));b(this,"apply",e=>this.modify(e));b(this,"length",e=>(this.values.length=e,this));this.app=e,this.app.api.currentSeed&&(this.randomGen=this.app.api.randomGen)}}class PI extends s_{constructor(t){super(t);b(this,"octave",t=>(this.values.octave=t,this.update(),this));b(this,"key",t=>(this.values.key=t,this.update(),this));b(this,"scale",t=>(n_(t)?(this.values.scaleName=t,this.values.parsedScale=vi(t)):this.values.parsedScale=r_(t),this.update(),this));b(this,"freq",t=>{this.values.freq=t;const n=u3(t);return n%1!==0?(this.values.note=Math.floor(n),this.values.bend=NI(n)[1]):this.values.note=n,this});b(this,"update",()=>{})}}let kn=[],M3=(r,e)=>{let t,n=[],i={lc:0,l:e||0,value:r,set(s){i.value=s,i.notify()},get(){return i.lc||i.listen(()=>{})(),i.value},notify(s){t=n;let a=!kn.length;for(let o=0;o{n===t&&(n=n.slice());let o=n.indexOf(s);~o&&(n.splice(o,2),i.lc--,i.lc||i.off())}},subscribe(s,a){let o=i.listen(s,a);return s(i.value),o},off(){}};return i},P3=(r={})=>{let e=M3(r);return e.setKey=function(t,n){typeof n>"u"?t in e.value&&(e.value={...e.value},delete e.value[t],e.notify(t)):e.value[t]!==n&&(e.value={...e.value,[t]:n},e.notify(t))},e};if(typeof DelayNode<"u"){class r extends DelayNode{constructor(t,n,i,s){super(t),n=Math.abs(n),this.delayTime.value=i;const a=t.createGain();a.gain.value=Math.min(Math.abs(s),.995),this.feedback=a.gain;const o=t.createGain();return o.gain.value=n,this.delayGain=o,this.connect(a),this.connect(o),a.connect(this),this.connect=l=>o.connect(l),this}start(t){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,t+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(e,t,n){return new r(this,e,t,n)}}var o_={};o_.generateReverb=function(r,e){for(var t=r.audioContext||new AudioContext,n=t.sampleRate,i=r.numChannels||2,s=r.decayTime*1.5,a=Math.round(r.decayTime*n),o=Math.round(s*n),l=Math.round((r.fadeInTime||0)*n),c=Math.pow(1/1e3,1/a),u=t.createBuffer(i,o,n),p=0;p{o_.generateReverb({audioContext:this,numChannels:2,decayTime:s,fadeInTime:a,lpFreqStart:o,lpFreqEnd:l},c=>{i.buffer=c}),i.duration=s,i.fade=a,i.lp=o,i.dim=l},i.generate(r,e,t,n),i});var bE={a:{freqs:[660,1120,2750,3e3,3350],gains:[1,.5012,.0708,.0631,.0126],qs:[80,90,120,130,140]},e:{freqs:[440,1800,2700,3e3,3300],gains:[1,.1995,.1259,.1,.1],qs:[70,80,100,120,120]},i:{freqs:[270,1850,2900,3350,3590],gains:[1,.0631,.0631,.0158,.0158],qs:[40,90,100,120,120]},o:{freqs:[430,820,2700,3e3,3300],gains:[1,.3162,.0501,.0794,.01995],qs:[40,80,100,120,120]},u:{freqs:[370,630,2750,3e3,3400],gains:[1,.1,.0708,.0316,.01995],qs:[40,60,100,120,120]}};if(typeof GainNode<"u"){class r extends GainNode{constructor(t,n){if(super(t),!bE[n])throw new Error("vowel: unknown vowel "+n);const{gains:i,qs:s,freqs:a}=bE[n],o=t.createGain();for(let l=0;l<5;l++){const c=t.createGain();c.gain.value=i[l];const u=t.createBiquadFilter();u.type="bandpass",u.Q.value=s[l],u.frequency.value=a[l],this.connect(u),u.connect(c),c.connect(o)}return o.gain.value=8,this.connect=l=>o.connect(l),this}}AudioContext.prototype.createVowelFilter=function(e){return new r(this,e)}}const Y3=r=>{var i;if(typeof r!="string")return[];const[e,t="",n]=((i=r.match(/^([a-gA-G])([#bsf]*)([0-9]*)$/))==null?void 0:i.slice(1))||[];return e?[e,t,n?Number(n):void 0]:[]},$3={c:0,d:2,e:4,f:5,g:7,a:9,b:11},G3={"#":1,b:-1,s:1,f:-1},iu=(r,e=3)=>{const[t,n,i=e]=Y3(r);if(!t)throw new Error('not a note: "'+r+'"');const s=$3[t.toLowerCase()],a=(n==null?void 0:n.split("").reduce((o,l)=>o+G3[l],0))||0;return(Number(i)+1)*12+s+a},BI=r=>Math.pow(2,(r-69)/12)*440,zm=(r,e,t)=>Math.min(Math.max(r,e),t),Q3=r=>12*Math.log(r/440)/Math.LN2+69,q3=(r,e)=>{if(typeof r!="object")throw new Error("valueToMidi: expected object value");let{freq:t,note:n}=r;if(typeof t=="number")return Q3(t);if(typeof n=="string")return iu(n);if(typeof n=="number")return n;if(!e)throw new Error("valueToMidi: expected freq or note to be set");return e},V3="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK";function Bc(r){const e=Bt().createGain();return e.gain.value=r,e}const l_=(r,e,t,n,i,s)=>{const a=Bt().createGain();return a.gain.setValueAtTime(0,s),a.gain.linearRampToValueAtTime(i,s+r),a.gain.linearRampToValueAtTime(t*i,s+r+e),{node:a,stop:o=>{a.gain.setValueAtTime(t*i,o),a.gain.linearRampToValueAtTime(0,o+n)}}},z3=(r,e,t,n,i,s)=>{t=Math.max(.001,t),i=Math.max(.001,i);const a=Bt().createGain();return a.gain.setValueAtTime(1e-4,s),a.gain.exponentialRampToValueAtTime(i,s+r),a.gain.exponentialRampToValueAtTime(t*i,s+r+e),{node:a,stop:o=>{a.gain.exponentialRampToValueAtTime(1e-4,o+n)}}},H3=(r,e,t,n,i,s,a,o,l)=>{const c=a-s,u=s+c,p=s+n*c;r.setValueAtTime(s,o),r.linearRampToValueAtTime(u,o+e),r.linearRampToValueAtTime(p,o+e+t),r.setValueAtTime(p,l),r.linearRampToValueAtTime(s,l+Math.max(i,.1))};function W3(r,e,t,n,i,s){const a={threshold:e??-3,ratio:t??10,knee:n??10,attack:i??.005,release:s??.05};return new DynamicsCompressorNode(r,a)}function Ku(r,e,t,n,i,s,a,o,l,c,u,p=.5){const m=r.createBiquadFilter();if(m.type=e,m.Q.value=n,m.frequency.value=t,!isNaN(l)&&l!==0){const _=l*p,v=zm(2**-_*t,0,2e4),I=zm(2**(l-_)*t,0,2e4);return H3(m.frequency,i,s,a,o,v,I,c,u),m}return m}let vE=r=>r<.5?1:1-(r-.5)/.5;function X3(r,e,t=0){const n=Bt();if(!t)return r;let i=n.createGain(),s=n.createGain();r.connect(i),e.connect(s),i.gain.value=vE(t),s.gain.value=vE(1-t);let a=n.createGain();return i.connect(a),s.connect(a),a}let Z3=r=>console.log(r);const ys=(...r)=>Z3(...r),c_=P3();function u_(r,e,t={}){c_.setKey(r,{onTrigger:e,data:t})}function TE(r){return c_.get()[r]}let ju;const Bt=()=>(ju||(ju=new AudioContext),ju);let Ul;const d_=()=>{const r=Bt();return Ul||(Ul=r.createGain(),Ul.connect(r.destination)),Ul};let Ju;function K3(){return Ju||(Ju=Bt().audioWorklet.addModule(V3),Ju)}function ed(r,e,t){const n=new AudioWorkletNode(r,e);return Object.entries(t).forEach(([i,s])=>{n.parameters.get(i).value=s}),n}async function j3(r={}){const{disableWorklets:e=!1}=r;typeof window<"u"&&(await Bt().resume(),e?console.log("disableWorklets: AudioWorklet effects coarse, crush and shape are skipped!"):await K3().catch(t=>{console.warn("could not load AudioWorklet effects coarse, crush and shape",t)}))}async function J3(r){return new Promise(e=>{document.addEventListener("click",async function t(){await j3(r),e(),document.removeEventListener("click",t)})})}let ca={};function eB(r,e,t,n){var i;if(t=zm(t,0,.98),!ca[r]){const s=Bt().createFeedbackDelay(1,e,t);(i=s.start)==null||i.call(s,n),s.connect(d_()),ca[r]=s}return ca[r].delayTime.value!==e&&ca[r].delayTime.setValueAtTime(e,n),ca[r].feedback.value!==t&&ca[r].feedback.setValueAtTime(t,n),ca[r]}let Li={},Fl=(r,e)=>r!==void 0&&r!==e;function tB(r,e,t,n,i){if(!Li[r]){const s=Bt().createReverb(e,t,n,i);s.connect(d_()),Li[r]=s}return(Fl(e,Li[r].duration)||Fl(t,Li[r].fade)||Fl(n,Li[r].lp)||Fl(i,Li[r].dim))&&Li[r].generate(e,t,n,i),Li[r]}let ua;function nB(r=2048){if(!ua){const e=Bt().createAnalyser();e.fftSize=r,ua=e,new Float32Array(ua.frequencyBinCount)}return ua.fftSize!==r&&(ua.fftSize=r,new Float32Array(ua.frequencyBinCount)),ua}function td(r,e,t){const n=Bc(t);return r.connect(n),n.connect(e),n}const CE=async(r,e,t)=>{const n=Bt();if(typeof r!="object")throw new Error(`expected hap.value to be an object, but got "${r}". Hint: append .note() or .s() to the end`,"error");r.duration=t;let i=n.currentTime+e,{s="triangle",bank:a,source:o,gain:l=.8,postgain:c=1,ftype:u="12db",fanchor:p=.5,cutoff:m,lpenv:_,lpattack:v=.01,lpdecay:I=.01,lpsustain:R=1,lprelease:x=.01,resonance:$=1,hpenv:Z,hcutoff:f,hpattack:E=.01,hpdecay:S=.01,hpsustain:N=1,hprelease:k=.01,hresonance:L=1,bpenv:M,bandf:G,bpattack:te=.01,bpdecay:re=.01,bpsustain:ne=1,bprelease:ee=.01,bandq:B=1,coarse:Q,crush:j,shape:K,pan:ue,vowel:le,delay:Ee=0,delayfeedback:De=.5,delaytime:xe=.25,orbit:be=1,room:Ne,roomfade:ce,roomlp:Le,roomdim:Xe,roomsize:Be,velocity:tt=1,analyze:rt,fft:ft=8,compressor:vt,compressorRatio:mt,compressorKnee:At,compressorAttack:Nt,compressorRelease:Rn}=r;l*=tt;let qe=[];const rn=()=>{qe.forEach(he=>he==null?void 0:he.disconnect())};a&&s&&(s=`${a}_${s}`);let Ze;if(o)Ze=o(i,r,t);else if(TE(s)){const{onTrigger:he}=TE(s),Ie=await he(i,r,rn);Ie&&(Ze=Ie.node,Ie.stop(i+t))}else throw new Error(`sound ${s} not found! Is it loaded?`);if(!Ze)return;if(n.currentTime>i){ys("[webaudio] skip hap: still loading",n.currentTime-i);return}const ke=[];if(ke.push(Ze),ke.push(Bc(l)),m!==void 0){let he=()=>Ku(n,"lowpass",m,$,v,I,R,x,_,i,i+t,p);ke.push(he()),u==="24db"&&ke.push(he())}if(f!==void 0){let he=()=>Ku(n,"highpass",f,L,E,S,N,k,Z,i,i+t,p);ke.push(he()),u==="24db"&&ke.push(he())}if(G!==void 0){let he=()=>Ku(n,"bandpass",G,B,te,re,ne,ee,M,i,i+t,p);ke.push(he()),u==="24db"&&ke.push(he())}if(le!==void 0){const he=n.createVowelFilter(le);ke.push(he)}if(Q!==void 0&&ke.push(ed(n,"coarse-processor",{coarse:Q})),j!==void 0&&ke.push(ed(n,"crush-processor",{crush:j})),K!==void 0&&ke.push(ed(n,"shape-processor",{shape:K})),vt!==void 0&&ke.push(W3(n,vt,mt,At,Nt,Rn)),ue!==void 0){const he=n.createStereoPanner();he.pan.value=2*ue-1,ke.push(he)}const en=Bc(c);ke.push(en),en.connect(d_());let Zt;if(Ee>0&&xe>0&&De>0){const he=eB(be,xe,De,i);Zt=td(en,he,Ee)}let an;if(Ne>0){const he=tB(be,Be,ce,Le,Xe);an=td(en,he,Ne)}let H;if(rt){const he=nB(2**(ft+5));H=td(en,he,rt)}ke.slice(1).reduce((he,Ie)=>he.connect(Ie),ke[0]),qe=ke.concat([Zt,an,H])},nd={};function rB(r,e){var t=e?1e3:1024;if(r=t);return r.toFixed(1)+" "+n[i]}const iB=async(r,e,t,n,i,s,a)=>{let o=0;i!==void 0&&t!==void 0&&ys("[sampler] hap has note and freq. ignoring note","warning");let l=q3({freq:i,note:t},36);o=l-36;const c=Bt();let u;if(Array.isArray(s))u=s[e%s.length];else{const v=R=>iu(R)-l,I=Object.keys(s).filter(R=>!R.startsWith("_")).reduce((R,x,$)=>!R||Math.abs(v(x)){const i=t?`sound "${t}:${n}"`:"sample";if(r=r.replace("#","%23"),!nd[r]){ys(`[sampler] load ${i}..`,"load-sample",{url:r});const s=Date.now();nd[r]=fetch(r).then(a=>a.arrayBuffer()).then(async a=>{const o=Date.now()-s,l=rB(a.byteLength);return ys(`[sampler] load ${i}... done! loaded ${l} in ${o}ms`,"loaded-sample",{url:r}),await e.decodeAudioData(a)})}return nd[r]};function sB(r){const e=Bt(),t=e.createBuffer(r.numberOfChannels,r.length,e.sampleRate);for(let n=0;nObject.entries(r).forEach(([n,i])=>{if(typeof i=="string"&&(i=[i]),typeof i!="object")throw new Error("wrong sample map format for "+n);t=i._base||t;const s=a=>(t+a).replace("github:","https://raw.githubusercontent.com/");Array.isArray(i)?i=i.map(s):i=Object.fromEntries(Object.entries(i).map(([a,o])=>[a,(typeof o=="string"?[o]:o).map(s)])),e(n,i)});let lB={};function cB(r){const e=Object.entries(lB).find(([t])=>r.startsWith(t));if(e)return e[1]}const Gi=async(r,e=r._base||"",t={})=>{if(typeof r=="string"){const s=cB(r);if(s)return s(r);if(r.startsWith("github:")){let[o,l]=r.split("github:");l=l.endsWith("/")?l.slice(0,-1):l,r=`https://raw.githubusercontent.com/${l}/strudel.json`}if(typeof fetch!="function")return;const a=r.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(r).then(o=>o.json()).then(o=>Gi(o,e||o._base||a,t)).catch(o=>{throw console.error(o),new Error(`error loading "${r}"`)})}const{prebake:n,tag:i}=t;oB(r,(s,a)=>u_(s,(o,l,c)=>uB(o,l,c,a),{type:"sample",samples:a,baseUrl:e,prebake:n,tag:i}),e)},yE=[];async function uB(r,e,t,n,i){let{s,freq:a,unit:o,nudge:l=0,cut:c,loop:u,clip:p=void 0,n:m=0,note:_,speed:v=1,loopBegin:I=0,begin:R=0,loopEnd:x=1,end:$=1}=e;if(v===0)return;u=s.startsWith("wt_")?1:e.loop;const Z=Bt(),{attack:f=.001,decay:E=.001,sustain:S=1,release:N=.001}=e,k=r+l,L=await iB(s,m,_,v,a,n,i);if(Z.currentTime>r){ys(`[sampler] still loading sound "${s}:${m}"`,"highlight");return}if(!L){ys(`[sampler] could not load "${s}:${m}"`,"error");return}L.playbackRate.value=Math.abs(v)*L.playbackRate.value,o==="c"&&(L.playbackRate.value=L.playbackRate.value*L.buffer.duration*1);const M=R*L.buffer.duration;u&&(L.loop=!0,L.loopStart=I*L.buffer.duration-M,L.loopEnd=x*L.buffer.duration-M),L.start(k,M);const{node:G,stop:te}=l_(f,E,S,N,1,r);L.connect(G);const re=Z.createGain();G.connect(re),L.onended=function(){L.disconnect(),G.disconnect(),re.disconnect(),t()};const ne={node:re,bufferSource:L,stop:(ee,B=p===void 0&&u===void 0)=>{let Q=ee;if(B){const j=L.buffer.duration/L.playbackRate.value;Q=r+($-R)*j}L.stop(Q+N),te(Q)}};if(c!==void 0){const ee=yE[c];ee&&(ee.node.gain.setValueAtTime(1,k),ee.node.gain.linearRampToValueAtTime(0,k+.01)),yE[c]=ne}return ne}let rd={};function dB(r){const e=Bt();if(rd[r])return rd[r];const t=2*e.sampleRate,n=e.createBuffer(1,t,e.sampleRate),i=n.getChannelData(0);let s=0,a,o,l,c,u,p,m;a=o=l=c=u=p=m=0;for(let _=0;_t.stop(n)}}function pB(r,e,t){const n=UI("pink",t);return{node:X3(r,n.node,e),stop:i=>n==null?void 0:n.stop(i)}}const hB=(r,e=1,t="sine")=>{const n=Bt(),i=n.createOscillator();i.type=t,i.frequency.value=r,i.start();const s=new GainNode(n,{gain:e});return i.connect(s),{node:s,stop:a=>i.stop(a)}},fB=(r,e,t,n="sine")=>{const i=r.frequency.value*e,s=i*t;return hB(i,s,n)},AE=["sine","square","triangle","sawtooth"],mB=["pink","white","brown"];function gB(){[...AE,...mB].forEach(r=>{u_(r,(e,t,n)=>{let{attack:i=.001,decay:s=.05,sustain:a=.6,release:o=.01}=t,l;AE.includes(r)?l=SB(r,e,t):l=UI(r,e);let{node:c,stop:u,triggerRelease:p}=l;const m=Bc(.3),{node:_,stop:v}=l_(i,s,a,o,1,e);return c.onended=()=>{c.disconnect(),m.disconnect(),n()},{node:c.connect(m).connect(_),stop:I=>{v(I),p==null||p(I);let R=I+o;u(R)}}},{type:"synth",prebake:!0})})}function _B(r,e){const t=new Float32Array(r+1),n=new Float32Array(r+1),i=Bt(),s=i.createOscillator(),a={sawtooth:c=>1/c,square:c=>c%2===0?0:1/c,triangle:c=>c%2===0?0:1/(c*c)};if(!a[e])throw new Error(`unknown wave type ${e}`);t[0]=0,n[0]=0;let o=1;for(;o<=r;)t[o]=a[e](o),n[o]=0,o++;const l=i.createPeriodicWave(t,n);return s.setPeriodicWave(l),s}function SB(r,e,{n:t,note:n,freq:i,vib:s=0,vibmod:a=.5,noise:o=0,fmh:l=1,fmi:c,fmenv:u="lin",fmattack:p,fmdecay:m,fmsustain:_,fmrelease:v,fmvelocity:I,fmwave:R="sine"}){Bt();let x;!t||r==="sine"?(x=Bt().createOscillator(),x.type=r||"triangle"):x=_B(t,r),n=n||36,typeof n=="string"&&(n=iu(n)),!i&&typeof n=="number"&&(i=BI(n)),x.frequency.value=Number(i),x.start(e);let $,Z;if(c){const{node:S,stop:N}=fB(x,l,c,R);[p,m,_,v,I].find(k=>k!==void 0)?(p=p??.001,m=m??.001,_=_??1,v=v??.001,I=I??1,Z=l_(p,m,_,v,I,e),u==="exp"&&(Z=z3(p,m,_,v,I,e),Z.node.maxValue=c*2,Z.node.minValue=1e-5),S.connect(Z.node),Z.node.connect(x.frequency)):S.connect(x.frequency),$=N}let f;if(s>0){f=Bt().createOscillator(),f.frequency.value=s;const S=Bt().createGain();S.gain.value=a*100,f.connect(S),S.connect(x.detune),f.start(e)}let E;return o&&(E=pB(x,o,e)),{node:(E==null?void 0:E.node)||x,stop:S=>{f==null||f.stop(S),E==null||E.stop(S),$==null||$(S),x.stop(S)},triggerRelease:S=>{Z==null||Z.stop(S)}}}function OB(r=1,e=.05,t=220,n=0,i=0,s=.1,a=0,o=1,l=0,c=0,u=0,p=0,m=0,_=0,v=0,I=0,R=0,x=1,$=0,Z=0){let f=Math.PI*2,E=Bt().sampleRate,S=K=>K>0?1:-1,N=l*=500*f/E/E,k=t*=(1+e*2*Math.random()-e)*f/E,L=[],M=0,G=0,te=0,re=1,ne=0,ee=0,B=0,Q,j;for(n=n*E+9,$*=E,i*=E,s*=E,R*=E,c*=500*f/E**3,v*=f/E,u*=f/E,p*=E,m=m*E|0,j=n+$+i+s+R|0;te1?a>2?a>3?Math.sin((M%f)**3):Math.max(Math.min(Math.tan(M),1),-1):1-(2*M/f%2+2)%2:1-4*Math.abs(Math.round(M/f)-M/f):Math.sin(M),B=(m?1-Z+Z*Math.sin(f*te/m):1)*S(B)*Math.abs(B)**o*r*1*(tete?0:(tep&&(t+=u,k+=u,re=0),m&&!(++ne%m)&&(t=k,l=N,re||(re=1));return L}const EB=(r,e)=>{let{s:t,note:n=36,freq:i,zrand:s=0,attack:a=0,decay:o=0,sustain:l=.8,release:c=.1,curve:u=1,slide:p=0,deltaSlide:m=0,pitchJump:_=0,pitchJumpTime:v=0,lfo:I=0,znoise:R=0,zmod:x=0,zcrush:$=0,zdelay:Z=0,tremolo:f=0,duration:E=.2,zzfx:S}=r;const N=Math.max(E-a-o,0);typeof n=="string"&&(n=iu(n)),!i&&typeof n=="number"&&(i=BI(n)),t=t.replace("z_","");const k=["sine","triangle","sawtooth","tan","noise"].indexOf(t)||0;u=t==="square"?0:u;const L=OB(...S||[.25,s,i,a,N,c,k,u,p,m,_,v,I,R,x,$,Z,l,o,f]),M=Bt(),G=M.createBuffer(1,L.length,M.sampleRate);G.getChannelData(0).set(L);const te=Bt().createBufferSource();return te.buffer=G,te.start(e),{node:te}};function bB(){["zzfx","z_sine","z_sawtooth","z_triangle","z_square","z_tan","z_noise"].forEach(r=>{u_(r,(e,t,n)=>{const{node:i}=EB({s:r,...t},e);return i.onended=()=>{i.disconnect(),n()},{node:i,stop:()=>{}}},{type:"synth",prebake:!0})})}let id;const vB=()=>{};typeof window<"u"&&window.addEventListener("message",r=>{var e;r.data==="strudel-stop"?vB():(e=r.data)!=null&&e.dough&&(id==null||id.node.port.postMessage(r.data))});class Hm extends PI{constructor(t,n){super(n);b(this,"nudge");b(this,"volume",t=>this.updateValue("volume",t));b(this,"vol",this.volume);b(this,"zrand",t=>this.updateValue("zrand",t));b(this,"curve",t=>this.updateValue("curve",t));b(this,"slide",t=>this.updateValue("slide",t));b(this,"sld",this.slide);b(this,"deltaSlide",t=>this.updateValue("deltaSlide",t));b(this,"dslide",this.deltaSlide);b(this,"pitchJump",t=>this.updateValue("pitchJump",t));b(this,"pj",this.pitchJump);b(this,"pitchJumpTime",t=>this.updateValue("pitchJumpTime",t));b(this,"pjt",this.pitchJumpTime);b(this,"lfo",t=>this.updateValue("lfo",t));b(this,"noise",t=>this.updateValue("noise",t));b(this,"zmod",t=>this.updateValue("zmod",t));b(this,"zcrush",t=>this.updateValue("zcrush",t));b(this,"zdelay",t=>this.updateValue("zdelay",t));b(this,"sustainVolume",t=>this.updateValue("sustainVolume",t));b(this,"tremolo",t=>this.updateValue("tremolo",t));b(this,"dur",t=>this.updateValue("dur",t));b(this,"zzfx",t=>this.updateValue("zzfx",t));b(this,"fmi",t=>this.updateValue("fmi",t));b(this,"fmh",t=>this.updateValue("fmh",t));b(this,"fmenv",t=>this.updateValue("fmenv",t));b(this,"fmattack",t=>this.updateValue("fmattack",t));b(this,"fmatk",this.fmattack);b(this,"fmdecay",t=>this.updateValue("fmdecay",t));b(this,"fmdec",this.fmdecay);b(this,"fmsustain",t=>this.updateValue("fmsustain",t));b(this,"fmsus",this.fmsustain);b(this,"fmrelease",t=>this.updateValue("fmrelease",t));b(this,"fmrel",this.fmrelease);b(this,"fmvelocity",t=>this.updateValue("fmvelocity",t));b(this,"fmvel",this.fmvelocity);b(this,"fmwave",t=>this.updateValue("fmwave",t));b(this,"fmw",this.fmwave);b(this,"ftype",t=>this.updateValue("ftype",t));b(this,"fanchor",t=>this.updateValue("fanchor",t));b(this,"attack",t=>this.updateValue("attack",t));b(this,"atk",this.attack);b(this,"decay",t=>this.updateValue("decay",t));b(this,"dec",this.decay);b(this,"sustain",t=>this.updateValue("sustain",t));b(this,"sus",this.sustain);b(this,"release",t=>this.updateValue("release",t));b(this,"rel",this.release);b(this,"adsr",(t,n,i,s)=>(this.attack(t),this.decay(n),this.sustain(i),this.release(s),this));b(this,"lpenv",t=>this.updateValue("lpenv",t));b(this,"lpe",t=>this.updateValue("lpenv",t));b(this,"lpattack",t=>this.updateValue("lpattack",t));b(this,"lpa",this.lpattack);b(this,"lpdecay",t=>this.updateValue("lpdecay",t));b(this,"lpd",this.lpdecay);b(this,"lpsustain",t=>this.updateValue("lpsustain",t));b(this,"lps",this.lpsustain);b(this,"lprelease",t=>this.updateValue("lprelease",t));b(this,"lpr",this.lprelease);b(this,"cutoff",t=>this.updateValue("cutoff",t));b(this,"lpf",this.cutoff);b(this,"resonance",t=>this.updateValue("resonance",Math.min(Math.max(t,0),50)));b(this,"lpq",this.resonance);b(this,"lpadsr",(t,n,i,s,a)=>(this.lpenv(t),this.lpattack(n),this.lpdecay(i),this.lpsustain(s),this.lprelease(a),this));b(this,"hpenv",t=>this.updateValue("hpenv",t));b(this,"hpe",t=>this.updateValue("hpe",t));b(this,"hpattack",t=>this.updateValue("hpattack",t));b(this,"hpa",this.hpattack);b(this,"hpdecay",t=>this.updateValue("hpdecay",t));b(this,"hpd",this.hpdecay);b(this,"hpsustain",t=>this.updateValue("hpsustain",t));b(this,"hpsus",this.hpsustain);b(this,"hprelease",t=>this.updateValue("hprelease",t));b(this,"hpr",this.hprelease);b(this,"hcutoff",t=>this.updateValue("hcutoff",t));b(this,"hpf",this.hcutoff);b(this,"hresonance",t=>this.updateValue("hresonance",t));b(this,"hpq",this.hresonance);b(this,"hpadsr",(t,n,i,s,a)=>(this.hpenv(t),this.hpattack(n),this.hpdecay(i),this.hpsustain(s),this.hprelease(a),this));b(this,"bpenv",t=>this.updateValue("bpenv",t));b(this,"bpe",t=>this.updateValue("bpe",t));b(this,"bpattack",t=>this.updateValue("bpattack",t));b(this,"bpa",this.bpattack);b(this,"bpdecay",t=>this.updateValue("bpdecay",t));b(this,"bpd",this.bpdecay);b(this,"bpsustain",t=>this.updateValue("bpsustain",t));b(this,"bps",this.bpsustain);b(this,"bprelease",t=>this.updateValue("bprelease",t));b(this,"bpr",this.bprelease);b(this,"bandf",t=>this.updateValue("bandf",t));b(this,"bpf",this.bandf);b(this,"bandq",t=>this.updateValue("bandq",t));b(this,"bpq",this.bandq);b(this,"bpadsr",(t,n,i,s,a)=>(this.bpenv(t),this.bpattack(n),this.bpdecay(i),this.bpsustain(s),this.bprelease(a),this));b(this,"freq",t=>this.updateValue("freq",t));b(this,"f",this.freq);b(this,"vib",t=>this.updateValue("vib",t));b(this,"vibmod",t=>this.updateValue("vibmod",t));b(this,"fm",t=>{if(typeof t=="number")this.values.fmi=t;else{let n=t.split(":");this.values.fmi=parseFloat(n[0]),n.length>1&&(this.values.fmh=parseFloat(n[1]))}return this});b(this,"loop",t=>this.updateValue("loop",t));b(this,"loopBegin",t=>this.updateValue("loopBegin",t));b(this,"loopEnd",t=>this.updateValue("loopEnd",t));b(this,"begin",t=>this.updateValue("begin",t));b(this,"end",t=>this.updateValue("end",t));b(this,"gain",t=>this.updateValue("gain",t));b(this,"dbgain",t=>this.updateValue("gain",Math.min(Math.pow(10,t/20),10)));b(this,"db",this.dbgain);b(this,"velocity",t=>this.updateValue("velocity",t));b(this,"vel",this.velocity);b(this,"pan",t=>this.updateValue("pan",t));b(this,"sound",t=>this.updateValue("s",t));b(this,"chord",(t,...n)=>(typeof t=="string"?t=v3(t).map(s=>({note:s,freq:Kr(s)})):t instanceof Array&&typeof t[0]=="number"?t=t.map(i=>({note:i,freq:Kr(i)})):typeof t=="number"&&n.length>0&&(t=[t,...n].map(i=>({note:i,freq:Kr(i)}))),this.updateValue("chord",t)));b(this,"invert",(t=0)=>{if(this.values.chord){let n=this.values.chord.map(s=>s.note);n=t<0?[...n].reverse():n;for(let s=0;s({note:s,freq:Kr(s)}));return this.updateValue("chord",i)}else return this});b(this,"snd",this.sound);b(this,"cut",t=>this.updateValue("cut",t));b(this,"clip",t=>this.updateValue("clip",t));b(this,"n",t=>this.updateValue("n",t));b(this,"note",t=>typeof t=="string"?this.updateValue("note",Fr(t)):typeof t==null||t==null?this.updateValue("note",0).updateValue("gain",0):this.updateValue("note",t));b(this,"speed",t=>this.updateValue("speed",t));b(this,"spd",this.speed);b(this,"coarse",t=>this.updateValue("coarse",t));b(this,"crush",t=>this.updateValue("crush",t));b(this,"shape",t=>this.updateValue("shape",t));b(this,"vowel",t=>this.updateValue("vowel",t));b(this,"vow",this.vowel);b(this,"delay",t=>this.updateValue("delay",t));b(this,"del",this.delay);b(this,"delayfeedback",t=>this.updateValue("delayfeedback",t));b(this,"delayfb",this.delayfeedback);b(this,"delaytime",t=>this.updateValue("delaytime",t));b(this,"delayt",this.delaytime);b(this,"orbit",t=>this.updateValue("orbit",t));b(this,"o",this.orbit);b(this,"room",t=>this.updateValue("room",t));b(this,"rm",this.room);b(this,"roomfade",t=>this.updateValue("roomfade",t));b(this,"rfade",this.roomfade);b(this,"roomlp",t=>this.updateValue("roomlp",t));b(this,"rlp",this.roomlp);b(this,"roomdim",t=>this.updateValue("roomdim",t));b(this,"rdim",this.roomdim);b(this,"size",t=>this.updateValue("roomsize",t));b(this,"sz",this.size);b(this,"comp",t=>this.updateValue("compressor",t));b(this,"cmp",this.comp);b(this,"ratio",t=>this.updateValue("compressorRatio",t));b(this,"rt",this.ratio);b(this,"knee",t=>this.updateValue("compressorKnee",t));b(this,"kn",this.knee);b(this,"compAttack",t=>this.updateValue("compressorAttack",t));b(this,"cmpa",this.compAttack);b(this,"compRelease",t=>this.updateValue("compressorRelease",t));b(this,"cmpr",this.compRelease);b(this,"stretch",t=>(this.updateValue("unit","c"),this.updateValue("speed",1/t),this.updateValue("cut",t),this));b(this,"modify",t=>{const n=t(this);return n instanceof Object?n:(t(this.values),this.update(),this)});b(this,"update",()=>{const[t,n]=i_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.freq=Kr(t)});b(this,"out",()=>{this.values.chord?this.values.chord.forEach(t=>{const n={...this.values};n.freq=t.freq,CE(n,this.nudge,this.values.dur)}):CE(this.values,this.nudge,this.values.dur)});this.app=n,this.nudge=n.dough_nudge/100,typeof t=="string"?t.includes(":")?this.values={s:t.split(":")[0],n:t.split(":")[1],dur:n.clock.convertPulseToSecond(n.clock.ppqn)}:this.values={s:t,dur:.5}:this.values=t}updateValue(t,n){return this.values[t]=n,this}}class Wm extends PI{constructor(t,n){super(n);b(this,"midiConnection");b(this,"chord",t=>(this.values.chord=t,this));b(this,"note",t=>(this.values.note=t,this));b(this,"sustain",t=>(this.values.sustain=t,this));b(this,"channel",t=>(this.values.channel=t,this));b(this,"port",t=>(this.values.port=this.midiConnection.getMidiOutputIndex(t),this));b(this,"add",t=>(this.values.note+=t,this));b(this,"modify",t=>{const n=t(this);return n instanceof Object?n:(t(this.values),this.update(),this)});b(this,"bend",t=>(this.values.bend=t,this));b(this,"random",(t=0,n=127)=>(t=Math.min(Math.max(t,0),127),n=Math.min(Math.max(n,0),127),this.values.note=Math.floor(this.randomGen()*(n-t+1))+t,this));b(this,"update",()=>{const[t,n]=i_(this.values.key||"C4",this.values.pitch||0,this.values.parsedScale||"MAJOR",this.values.octave||0);this.values.note=t,this.values.freq=Kr(t),n&&(this.values.bend=n)});b(this,"out",()=>{function t(n,i){const s=i&&i.channel?i.channel:0,a=n.values.channel?n.values.channel:s,o=n.values.velocity?n.values.velocity:100,l=i&&i.note?i.note:60,c=n.values.note?n.values.note:l,u=n.values.sustain?n.values.sustain*n.app.clock.pulse_duration*n.app.api.ppqn():n.app.clock.pulse_duration*n.app.api.ppqn(),p=n.values.bend?n.values.bend:void 0,m=n.values.port?n.midiConnection.getMidiOutputIndex(n.values.port):n.midiConnection.getCurrentMidiPortIndex();n.midiConnection.sendMidiNote(c,a,o,u,m,p)}this.values.chord?this.values.chord.forEach(n=>{t(this,n)}):t(this)});this.app=n,typeof t=="number"?this.values.note=t:this.values=t,this.midiConnection=n.api.MidiConnection}}const co=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,FI=new Set,Xm=typeof process=="object"&&process?process:{},YI=(r,e,t,n)=>{typeof Xm.emitWarning=="function"?Xm.emitWarning(r,e,t,n):console.error(`[${t}] ${e}: ${r}`)};let Uc=globalThis.AbortController,IE=globalThis.AbortSignal;var _T;if(typeof Uc>"u"){IE=class{constructor(){b(this,"onabort");b(this,"_onabort",[]);b(this,"reason");b(this,"aborted",!1)}addEventListener(n,i){this._onabort.push(i)}},Uc=class{constructor(){b(this,"signal",new IE);e()}abort(n){var i,s;if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(const a of this.signal._onabort)a(n);(s=(i=this.signal).onabort)==null||s.call(i,n)}}};let r=((_T=Xm.env)==null?void 0:_T.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const e=()=>{r&&(r=!1,YI("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const TB=r=>!FI.has(r),Bi=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),$I=r=>Bi(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?tc:null:null;class tc extends Array{constructor(e){super(e),this.fill(0)}}var cs;const ha=class ha{constructor(e,t){b(this,"heap");b(this,"length");if(!V(ha,cs))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){const t=$I(e);if(!t)return[];We(ha,cs,!0);const n=new ha(e,t);return We(ha,cs,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};cs=new WeakMap,at(ha,cs,!1);let Zm=ha;var Nr,er,wr,Dr,us,on,xr,ln,Lt,nt,Ln,tr,Cn,fn,kr,mn,gi,_i,Lr,Mr,qi,Mn,Ko,jm,Oa,Si,jo,nr,Qc,GI,Ea,ds,Jo,Vr,Ui,zr,Fi,el,Jm,ps,nc,hs,rc,Dt,Ft,tl,eg,ba,Eo;const E_=class E_{constructor(e){at(this,Ko);at(this,Qc);at(this,Vr);at(this,zr);at(this,el);at(this,ps);at(this,hs);at(this,Dt);at(this,tl);at(this,ba);at(this,Nr,void 0);at(this,er,void 0);at(this,wr,void 0);at(this,Dr,void 0);at(this,us,void 0);b(this,"ttl");b(this,"ttlResolution");b(this,"ttlAutopurge");b(this,"updateAgeOnGet");b(this,"updateAgeOnHas");b(this,"allowStale");b(this,"noDisposeOnSet");b(this,"noUpdateTTL");b(this,"maxEntrySize");b(this,"sizeCalculation");b(this,"noDeleteOnFetchRejection");b(this,"noDeleteOnStaleGet");b(this,"allowStaleOnFetchAbort");b(this,"allowStaleOnFetchRejection");b(this,"ignoreFetchAbort");at(this,on,void 0);at(this,xr,void 0);at(this,ln,void 0);at(this,Lt,void 0);at(this,nt,void 0);at(this,Ln,void 0);at(this,tr,void 0);at(this,Cn,void 0);at(this,fn,void 0);at(this,kr,void 0);at(this,mn,void 0);at(this,gi,void 0);at(this,_i,void 0);at(this,Lr,void 0);at(this,Mr,void 0);at(this,qi,void 0);at(this,Mn,void 0);at(this,Oa,()=>{});at(this,Si,()=>{});at(this,jo,()=>{});at(this,nr,()=>!1);at(this,Ea,e=>{});at(this,ds,(e,t,n)=>{});at(this,Jo,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:l,dispose:c,disposeAfter:u,noDisposeOnSet:p,noUpdateTTL:m,maxSize:_=0,maxEntrySize:v=0,sizeCalculation:I,fetchMethod:R,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:$,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:f,ignoreFetchAbort:E}=e;if(t!==0&&!Bi(t))throw new TypeError("max option must be a nonnegative integer");const S=t?$I(t):Array;if(!S)throw new Error("invalid max value: "+t);if(We(this,Nr,t),We(this,er,_),this.maxEntrySize=v||V(this,er),this.sizeCalculation=I,this.sizeCalculation){if(!V(this,er)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(R!==void 0&&typeof R!="function")throw new TypeError("fetchMethod must be a function if specified");if(We(this,us,R),We(this,qi,!!R),We(this,ln,new Map),We(this,Lt,new Array(t).fill(void 0)),We(this,nt,new Array(t).fill(void 0)),We(this,Ln,new S(t)),We(this,tr,new S(t)),We(this,Cn,0),We(this,fn,0),We(this,kr,Zm.create(t)),We(this,on,0),We(this,xr,0),typeof c=="function"&&We(this,wr,c),typeof u=="function"?(We(this,Dr,u),We(this,mn,[])):(We(this,Dr,void 0),We(this,mn,void 0)),We(this,Mr,!!V(this,wr)),We(this,Mn,!!V(this,Dr)),this.noDisposeOnSet=!!p,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!Z,this.allowStaleOnFetchAbort=!!f,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(V(this,er)!==0&&!Bi(V(this,er)))throw new TypeError("maxSize must be a positive integer if specified");if(!Bi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");ze(this,Qc,GI).call(this)}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!$,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=Bi(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!Bi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");ze(this,Ko,jm).call(this)}if(V(this,Nr)===0&&this.ttl===0&&V(this,er)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!V(this,Nr)&&!V(this,er)){const N="LRU_CACHE_UNBOUNDED";TB(N)&&(FI.add(N),YI("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",N,E_))}}static unsafeExposeInternals(e){return{starts:V(e,_i),ttls:V(e,Lr),sizes:V(e,gi),keyMap:V(e,ln),keyList:V(e,Lt),valList:V(e,nt),next:V(e,Ln),prev:V(e,tr),get head(){return V(e,Cn)},get tail(){return V(e,fn)},free:V(e,kr),isBackgroundFetch:t=>{var n;return ze(n=e,Dt,Ft).call(n,t)},backgroundFetch:(t,n,i,s)=>{var a;return ze(a=e,hs,rc).call(a,t,n,i,s)},moveToTail:t=>{var n;return ze(n=e,ba,Eo).call(n,t)},indexes:t=>{var n;return ze(n=e,Vr,Ui).call(n,t)},rindexes:t=>{var n;return ze(n=e,zr,Fi).call(n,t)},isStale:t=>{var n;return V(n=e,nr).call(n,t)}}}get max(){return V(this,Nr)}get maxSize(){return V(this,er)}get calculatedSize(){return V(this,xr)}get size(){return V(this,on)}get fetchMethod(){return V(this,us)}get dispose(){return V(this,wr)}get disposeAfter(){return V(this,Dr)}getRemainingTTL(e){return V(this,ln).has(e)?1/0:0}*entries(){for(const e of ze(this,Vr,Ui).call(this))V(this,nt)[e]!==void 0&&V(this,Lt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield[V(this,Lt)[e],V(this,nt)[e]])}*rentries(){for(const e of ze(this,zr,Fi).call(this))V(this,nt)[e]!==void 0&&V(this,Lt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield[V(this,Lt)[e],V(this,nt)[e]])}*keys(){for(const e of ze(this,Vr,Ui).call(this)){const t=V(this,Lt)[e];t!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield t)}}*rkeys(){for(const e of ze(this,zr,Fi).call(this)){const t=V(this,Lt)[e];t!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield t)}}*values(){for(const e of ze(this,Vr,Ui).call(this))V(this,nt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield V(this,nt)[e])}*rvalues(){for(const e of ze(this,zr,Fi).call(this))V(this,nt)[e]!==void 0&&!ze(this,Dt,Ft).call(this,V(this,nt)[e])&&(yield V(this,nt)[e])}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const n of ze(this,Vr,Ui).call(this)){const i=V(this,nt)[n],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,V(this,Lt)[n],this))return this.get(V(this,Lt)[n],t)}}forEach(e,t=this){for(const n of ze(this,Vr,Ui).call(this)){const i=V(this,nt)[n],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Lt)[n],this)}}rforEach(e,t=this){for(const n of ze(this,zr,Fi).call(this)){const i=V(this,nt)[n],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,V(this,Lt)[n],this)}}purgeStale(){let e=!1;for(const t of ze(this,zr,Fi).call(this,{allowStale:!0}))V(this,nr).call(this,t)&&(this.delete(V(this,Lt)[t]),e=!0);return e}dump(){const e=[];for(const t of ze(this,Vr,Ui).call(this,{allowStale:!0})){const n=V(this,Lt)[t],i=V(this,nt)[t],s=ze(this,Dt,Ft).call(this,i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;const a={value:s};if(V(this,Lr)&&V(this,_i)){a.ttl=V(this,Lr)[t];const o=co.now()-V(this,_i)[t];a.start=Math.floor(Date.now()-o)}V(this,gi)&&(a.size=V(this,gi)[t]),e.unshift([n,a])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const i=Date.now()-n.start;n.start=co.now()-i}this.set(t,n.value,n)}}set(e,t,n={}){var m,_,v,I,R;if(t===void 0)return this.delete(e),this;const{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:l}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const u=V(this,Jo).call(this,e,t,n.size||0,o);if(this.maxEntrySize&&u>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.delete(e),this;let p=V(this,on)===0?void 0:V(this,ln).get(e);if(p===void 0)p=V(this,on)===0?V(this,fn):V(this,kr).length!==0?V(this,kr).pop():V(this,on)===V(this,Nr)?ze(this,ps,nc).call(this,!1):V(this,on),V(this,Lt)[p]=e,V(this,nt)[p]=t,V(this,ln).set(e,p),V(this,Ln)[V(this,fn)]=p,V(this,tr)[p]=V(this,fn),We(this,fn,p),ml(this,on)._++,V(this,ds).call(this,p,u,l),l&&(l.set="add"),c=!1;else{ze(this,ba,Eo).call(this,p);const x=V(this,nt)[p];if(t!==x){if(V(this,qi)&&ze(this,Dt,Ft).call(this,x)){x.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:$}=x;$!==void 0&&!a&&(V(this,Mr)&&((m=V(this,wr))==null||m.call(this,$,e,"set")),V(this,Mn)&&((_=V(this,mn))==null||_.push([$,e,"set"])))}else a||(V(this,Mr)&&((v=V(this,wr))==null||v.call(this,x,e,"set")),V(this,Mn)&&((I=V(this,mn))==null||I.push([x,e,"set"])));if(V(this,Ea).call(this,p),V(this,ds).call(this,p,u,l),V(this,nt)[p]=t,l){l.set="replace";const $=x&&ze(this,Dt,Ft).call(this,x)?x.__staleWhileFetching:x;$!==void 0&&(l.oldValue=$)}}else l&&(l.set="update")}if(i!==0&&!V(this,Lr)&&ze(this,Ko,jm).call(this),V(this,Lr)&&(c||V(this,jo).call(this,p,i,s),l&&V(this,Si).call(this,l,p)),!a&&V(this,Mn)&&V(this,mn)){const x=V(this,mn);let $;for(;$=x==null?void 0:x.shift();)(R=V(this,Dr))==null||R.call(this,...$)}return this}pop(){var e;try{for(;V(this,on);){const t=V(this,nt)[V(this,Cn)];if(ze(this,ps,nc).call(this,!0),ze(this,Dt,Ft).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(V(this,Mn)&&V(this,mn)){const t=V(this,mn);let n;for(;n=t==null?void 0:t.shift();)(e=V(this,Dr))==null||e.call(this,...n)}}}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,s=V(this,ln).get(e);if(s!==void 0){const a=V(this,nt)[s];if(ze(this,Dt,Ft).call(this,a)&&a.__staleWhileFetching===void 0)return!1;if(V(this,nr).call(this,s))i&&(i.has="stale",V(this,Si).call(this,i,s));else return n&&V(this,Oa).call(this,s),i&&(i.has="hit",V(this,Si).call(this,i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=V(this,ln).get(e);if(i!==void 0&&(n||!V(this,nr).call(this,i))){const s=V(this,nt)[i];return ze(this,Dt,Ft).call(this,s)?s.__staleWhileFetching:s}}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:I,forceRefresh:R=!1,status:x,signal:$}=t;if(!V(this,qi))return x&&(x.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:x});const Z={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:o,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:v,ignoreFetchAbort:_,status:x,signal:$};let f=V(this,ln).get(e);if(f===void 0){x&&(x.fetch="miss");const E=ze(this,hs,rc).call(this,e,f,Z,I);return E.__returned=E}else{const E=V(this,nt)[f];if(ze(this,Dt,Ft).call(this,E)){const M=n&&E.__staleWhileFetching!==void 0;return x&&(x.fetch="inflight",M&&(x.returnedStale=!0)),M?E.__staleWhileFetching:E.__returned=E}const S=V(this,nr).call(this,f);if(!R&&!S)return x&&(x.fetch="hit"),ze(this,ba,Eo).call(this,f),i&&V(this,Oa).call(this,f),x&&V(this,Si).call(this,x,f),E;const N=ze(this,hs,rc).call(this,e,f,Z,I),L=N.__staleWhileFetching!==void 0&&n;return x&&(x.fetch=S?"stale":"refresh",L&&S&&(x.returnedStale=!0)),L?N.__staleWhileFetching:N.__returned=N}}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,o=V(this,ln).get(e);if(o!==void 0){const l=V(this,nt)[o],c=ze(this,Dt,Ft).call(this,l);return a&&V(this,Si).call(this,a,o),V(this,nr).call(this,o)?(a&&(a.get="stale"),c?(a&&n&&l.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?l.__staleWhileFetching:void 0):(s||this.delete(e),a&&n&&(a.returnedStale=!0),n?l:void 0)):(a&&(a.get="hit"),c?l.__staleWhileFetching:(ze(this,ba,Eo).call(this,o),i&&V(this,Oa).call(this,o),l))}else a&&(a.get="miss")}delete(e){var n,i,s,a;let t=!1;if(V(this,on)!==0){const o=V(this,ln).get(e);if(o!==void 0)if(t=!0,V(this,on)===1)this.clear();else{V(this,Ea).call(this,o);const l=V(this,nt)[o];ze(this,Dt,Ft).call(this,l)?l.__abortController.abort(new Error("deleted")):(V(this,Mr)||V(this,Mn))&&(V(this,Mr)&&((n=V(this,wr))==null||n.call(this,l,e,"delete")),V(this,Mn)&&((i=V(this,mn))==null||i.push([l,e,"delete"]))),V(this,ln).delete(e),V(this,Lt)[o]=void 0,V(this,nt)[o]=void 0,o===V(this,fn)?We(this,fn,V(this,tr)[o]):o===V(this,Cn)?We(this,Cn,V(this,Ln)[o]):(V(this,Ln)[V(this,tr)[o]]=V(this,Ln)[o],V(this,tr)[V(this,Ln)[o]]=V(this,tr)[o]),ml(this,on)._--,V(this,kr).push(o)}}if(V(this,Mn)&&((s=V(this,mn))!=null&&s.length)){const o=V(this,mn);let l;for(;l=o==null?void 0:o.shift();)(a=V(this,Dr))==null||a.call(this,...l)}return t}clear(){var e,t,n;for(const i of ze(this,zr,Fi).call(this,{allowStale:!0})){const s=V(this,nt)[i];if(ze(this,Dt,Ft).call(this,s))s.__abortController.abort(new Error("deleted"));else{const a=V(this,Lt)[i];V(this,Mr)&&((e=V(this,wr))==null||e.call(this,s,a,"delete")),V(this,Mn)&&((t=V(this,mn))==null||t.push([s,a,"delete"]))}}if(V(this,ln).clear(),V(this,nt).fill(void 0),V(this,Lt).fill(void 0),V(this,Lr)&&V(this,_i)&&(V(this,Lr).fill(0),V(this,_i).fill(0)),V(this,gi)&&V(this,gi).fill(0),We(this,Cn,0),We(this,fn,0),V(this,kr).length=0,We(this,xr,0),We(this,on,0),V(this,Mn)&&V(this,mn)){const i=V(this,mn);let s;for(;s=i==null?void 0:i.shift();)(n=V(this,Dr))==null||n.call(this,...s)}}};Nr=new WeakMap,er=new WeakMap,wr=new WeakMap,Dr=new WeakMap,us=new WeakMap,on=new WeakMap,xr=new WeakMap,ln=new WeakMap,Lt=new WeakMap,nt=new WeakMap,Ln=new WeakMap,tr=new WeakMap,Cn=new WeakMap,fn=new WeakMap,kr=new WeakMap,mn=new WeakMap,gi=new WeakMap,_i=new WeakMap,Lr=new WeakMap,Mr=new WeakMap,qi=new WeakMap,Mn=new WeakMap,Ko=new WeakSet,jm=function(){const e=new tc(V(this,Nr)),t=new tc(V(this,Nr));We(this,Lr,e),We(this,_i,t),We(this,jo,(s,a,o=co.now())=>{if(t[s]=a!==0?o:0,e[s]=a,a!==0&&this.ttlAutopurge){const l=setTimeout(()=>{V(this,nr).call(this,s)&&this.delete(V(this,Lt)[s])},a+1);l.unref&&l.unref()}}),We(this,Oa,s=>{t[s]=e[s]!==0?co.now():0}),We(this,Si,(s,a)=>{if(e[a]){const o=e[a],l=t[a];s.ttl=o,s.start=l,s.now=n||i();const c=s.now-l;s.remainingTTL=o-c}});let n=0;const i=()=>{const s=co.now();if(this.ttlResolution>0){n=s;const a=setTimeout(()=>n=0,this.ttlResolution);a.unref&&a.unref()}return s};this.getRemainingTTL=s=>{const a=V(this,ln).get(s);if(a===void 0)return 0;const o=e[a],l=t[a];if(o===0||l===0)return 1/0;const c=(n||i())-l;return o-c},We(this,nr,s=>e[s]!==0&&t[s]!==0&&(n||i())-t[s]>e[s])},Oa=new WeakMap,Si=new WeakMap,jo=new WeakMap,nr=new WeakMap,Qc=new WeakSet,GI=function(){const e=new tc(V(this,Nr));We(this,xr,0),We(this,gi,e),We(this,Ea,t=>{We(this,xr,V(this,xr)-e[t]),e[t]=0}),We(this,Jo,(t,n,i,s)=>{if(ze(this,Dt,Ft).call(this,n))return 0;if(!Bi(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,t),!Bi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),We(this,ds,(t,n,i)=>{if(e[t]=n,V(this,er)){const s=V(this,er)-e[t];for(;V(this,xr)>s;)ze(this,ps,nc).call(this,!0)}We(this,xr,V(this,xr)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=V(this,xr))})},Ea=new WeakMap,ds=new WeakMap,Jo=new WeakMap,Vr=new WeakSet,Ui=function*({allowStale:e=this.allowStale}={}){if(V(this,on))for(let t=V(this,fn);!(!ze(this,el,Jm).call(this,t)||((e||!V(this,nr).call(this,t))&&(yield t),t===V(this,Cn)));)t=V(this,tr)[t]},zr=new WeakSet,Fi=function*({allowStale:e=this.allowStale}={}){if(V(this,on))for(let t=V(this,Cn);!(!ze(this,el,Jm).call(this,t)||((e||!V(this,nr).call(this,t))&&(yield t),t===V(this,fn)));)t=V(this,Ln)[t]},el=new WeakSet,Jm=function(e){return e!==void 0&&V(this,ln).get(V(this,Lt)[e])===e},ps=new WeakSet,nc=function(e){var s,a;const t=V(this,Cn),n=V(this,Lt)[t],i=V(this,nt)[t];return V(this,qi)&&ze(this,Dt,Ft).call(this,i)?i.__abortController.abort(new Error("evicted")):(V(this,Mr)||V(this,Mn))&&(V(this,Mr)&&((s=V(this,wr))==null||s.call(this,i,n,"evict")),V(this,Mn)&&((a=V(this,mn))==null||a.push([i,n,"evict"]))),V(this,Ea).call(this,t),e&&(V(this,Lt)[t]=void 0,V(this,nt)[t]=void 0,V(this,kr).push(t)),V(this,on)===1?(We(this,Cn,We(this,fn,0)),V(this,kr).length=0):We(this,Cn,V(this,Ln)[t]),V(this,ln).delete(n),ml(this,on)._--,t},hs=new WeakSet,rc=function(e,t,n,i){const s=t===void 0?void 0:V(this,nt)[t];if(ze(this,Dt,Ft).call(this,s))return s;const a=new Uc,{signal:o}=n;o==null||o.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});const l={signal:a.signal,options:n,context:i},c=(I,R=!1)=>{const{aborted:x}=a.signal,$=n.ignoreFetchAbort&&I!==void 0;if(n.status&&(x&&!R?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,$&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),x&&!$&&!R)return p(a.signal.reason);const Z=_;return V(this,nt)[t]===_&&(I===void 0?Z.__staleWhileFetching?V(this,nt)[t]=Z.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,I,l.options))),I},u=I=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=I),p(I)),p=I=>{const{aborted:R}=a.signal,x=R&&n.allowStaleOnFetchAbort,$=x||n.allowStaleOnFetchRejection,Z=$||n.noDeleteOnFetchRejection,f=_;if(V(this,nt)[t]===_&&(!Z||f.__staleWhileFetching===void 0?this.delete(e):x||(V(this,nt)[t]=f.__staleWhileFetching)),$)return n.status&&f.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw I},m=(I,R)=>{var $;const x=($=V(this,us))==null?void 0:$.call(this,e,s,l);x&&x instanceof Promise&&x.then(Z=>I(Z===void 0?void 0:Z),R),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(I(void 0),n.allowStaleOnFetchAbort&&(I=Z=>c(Z,!0)))})};n.status&&(n.status.fetchDispatched=!0);const _=new Promise(m).then(c,u),v=Object.assign(_,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,v,{...l.options,status:void 0}),t=V(this,ln).get(e)):V(this,nt)[t]=v,v},Dt=new WeakSet,Ft=function(e){if(!V(this,qi))return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Uc},tl=new WeakSet,eg=function(e,t){V(this,tr)[t]=e,V(this,Ln)[e]=t},ba=new WeakSet,Eo=function(e){e!==V(this,fn)&&(e===V(this,Cn)?We(this,Cn,V(this,Ln)[e]):ze(this,tl,eg).call(this,V(this,tr)[e],V(this,Ln)[e]),ze(this,tl,eg).call(this,V(this,fn),e),We(this,fn,e))};let Km=E_;const No=class No{constructor(){b(this,"_fallbackMethod",()=>No.createSkipProxy());b(this,"out",()=>{})}};b(No,"createSkipProxy",()=>{const e=new No;return new Proxy(e,{get(t,n,i){return typeof t[n]>"u"?t._fallbackMethod:t[n]},set(t,n,i,s){return!1}})});let Fc=No;const wo=class wo extends s_{constructor(t,n){super(n);b(this,"_fallbackMethod",()=>wo.createRestProxy(this.values.length,this.app));b(this,"out",()=>{});this.values.length=t}};b(wo,"createRestProxy",(t,n)=>{const i=new wo(t,n);return new Proxy(i,{get(s,a,o){return typeof s[a]>"u"?s._fallbackMethod:s[a]},set(s,a,o,l){return!1}})});let Yc=wo;class CB extends s_{constructor(t,n,i){super(i);b(this,"input");b(this,"ziffers");b(this,"initCallTime",0);b(this,"startCallTime",0);b(this,"lastCallTime",0);b(this,"waitTime",0);b(this,"startBeat",0);b(this,"played",!1);b(this,"current");b(this,"retro",!1);b(this,"index",-1);b(this,"zid","");b(this,"options",{});b(this,"skipIndex",0);b(this,"endTime",0);b(this,"next",()=>(this.current=this.ziffers.next(),this.played=!0,this.current));b(this,"pulseToSecond",t=>this.app.clock.convertPulseToSecond(t));b(this,"firstRun",()=>this.notStarted());b(this,"atTheBeginning",()=>this.skipIndex===0&&this.ziffers.index<=0);b(this,"origin",()=>this.app.clock.pulses_since_origin+1);b(this,"pulse",()=>this.app.clock.time_position.pulse);b(this,"beat",()=>this.app.clock.time_position.beat);b(this,"nextBeat",()=>this.app.clock.next_beat_in_ticks);b(this,"nextBeatInTicks",()=>this.app.clock.next_beat_in_ticks);b(this,"areWeThereYet",()=>{this.app.clock.pulses_since_origin=this.nextBeatInTicks())&&this.origin()>=this.waitTime,n=this.current&&this.pulseToSecond(this.origin())>=this.pulseToSecond(this.lastCallTime)+this.pulseToSecond(this.current.duration*4*this.app.clock.ppqn)&&this.origin()>=this.waitTime,i=t||n;return this.skipIndex=i?0:this.skipIndex+1,this.index=i?this.index+1:this.index,i&&this.notStarted()&&(this.initCallTime=this.app.clock.pulses_since_origin),this.atTheBeginning()&&(this.startCallTime=this.app.clock.pulses_since_origin),i});b(this,"lead",()=>this.voiceleading());b(this,"invert",t=>(this.atTheBeginning()&&this.ziffers.invert(t),this));b(this,"out",()=>{});this.app=i,this.input=t,this.options=n,this.ziffers=new D3(t,n)}get ticks(){return this.ziffers.duration*4*this.app.clock.ppqn}nextEndTime(){return this.startCallTime+this.ticks}updateLastCallTime(){(this.notStarted()||this.played)&&(this.lastCallTime=this.app.clock.pulses_since_origin,this.played=!1)}notStarted(){return this.ziffers.notStarted()}sound(t){if(this.areWeThereYet()){const n=this.next(),i=this.app.clock.convertPulseToSecond(n.duration*4*this.app.clock.ppqn);if(n instanceof ni){const s=n.getExisting("freq","pitch","key","scale","octave","parsedScale");return n.sound&&(t=n.sound),n.soundIndex&&(s.n=n.soundIndex),s.dur=i,new Hm(s,this.app).sound(t||"sine")}else if(n instanceof Ra){const s=n.pitches.map(o=>o.getExisting("freq","pitch","key","scale","octave","parsedScale")),a={dur:i};return t&&(a.s=t),new Hm(a,this.app).chord(s)}else if(n instanceof qm)return Yc.createRestProxy(n.duration,this.app)}else return Fc.createSkipProxy()}midi(t=void 0){if(this.areWeThereYet()){const n=this.next(),i=n.getExisting("note","pitch","bend","key","scale","octave","parsedScale");if(n instanceof ni){n.soundIndex&&(i.channel=n.soundIndex);const s=new Wm(i,this.app);return t?s.note(t):s}else{if(n instanceof qm)return Yc.createRestProxy(n.duration,this.app);if(n instanceof Ra){const s=n.midiChord();return new Wm(i,this.app).chord(s)}}}else return Fc.createSkipProxy()}scale(t){return this.atTheBeginning()&&this.ziffers.scale(t),this}key(t){return this.atTheBeginning()&&this.ziffers.key(t),this}octave(t){return this.atTheBeginning()&&this.ziffers.octave(t),this}voiceleading(){return this.atTheBeginning()&&this.ziffers.lead(),this}retrograde(){return this.atTheBeginning()&&this.ziffers.retrograde(),this}wait(t){if(this.atTheBeginning()){if(typeof t=="function"){const n=this.app.api.patternCache.get(t.name);return n&&(this.waitTime=n.nextEndTime()),this}this.waitTime=this.origin()+Math.ceil(t*4*this.app.clock.ppqn)}return this}sync(t){if(this.atTheBeginning()&&this.notStarted()){const n=this.app.clock.pulses_since_origin,i=typeof t=="function"?t.name:t;if(n>0){const s=this.app.api.patternCache.get(i);if(s){const a=s.ziffers.duration,o=s.startCallTime,l=a*4*this.app.clock.ppqn;this.waitTime=o+l}}}return this}}const yB=r=>r[0]==="{"&&r[r.length-1]==="}",uo=(r,e)=>{if(yB(r)){const t=JSON.parse(r);return JSON.stringify({...t,...e})}else return JSON.stringify({...e,text:r})},AB=r=>{String.prototype.speak=function(){const e=JSON.parse(this.valueOf());new QI({...e,text:e.text}).speak().then(()=>{}).catch(t=>{console.log("Error speaking:",t)})},String.prototype.rate=function(e){return uo(this.valueOf(),{rate:e})},String.prototype.pitch=function(e){return uo(this.valueOf(),{pitch:e})},String.prototype.lang=function(e){return uo(this.valueOf(),{lang:e})},String.prototype.volume=function(e){return uo(this.valueOf(),{volume:e})},String.prototype.voice=function(e){return uo(this.valueOf(),{voice:e})},String.prototype.z=function(e={}){return r.z(this.valueOf(),e)},String.prototype.z0=function(e={}){return r.z0(this.valueOf(),e)},String.prototype.z1=function(e={}){return r.z1(this.valueOf(),e)},String.prototype.z2=function(e={}){return r.z2(this.valueOf(),e)},String.prototype.z3=function(e={}){return r.z3(this.valueOf(),e)},String.prototype.z4=function(e={}){return r.z4(this.valueOf(),e)},String.prototype.z5=function(e={}){return r.z5(this.valueOf(),e)},String.prototype.z6=function(e={}){return r.z6(this.valueOf(),e)},String.prototype.z7=function(e={}){return r.z7(this.valueOf(),e)},String.prototype.z8=function(e={}){return r.z8(this.valueOf(),e)},String.prototype.z9=function(e={}){return r.z9(this.valueOf(),e)},String.prototype.z10=function(e={}){return r.z10(this.valueOf(),e)},String.prototype.z11=function(e={}){return r.z11(this.valueOf(),e)},String.prototype.z12=function(e={}){return r.z12(this.valueOf(),e)},String.prototype.z13=function(e={}){return r.z13(this.valueOf(),e)},String.prototype.z14=function(e={}){return r.z14(this.valueOf(),e)},String.prototype.z15=function(e={}){return r.z15(this.valueOf(),e)},String.prototype.z16=function(e={}){return r.z16(this.valueOf(),e)},String.prototype.note=function(){try{return parseInt(this.valueOf())}catch{return Fr(this.valueOf())}}};let ad;class QI{constructor(e){b(this,"speak",()=>new Promise((e,t)=>{if(this.options.text){const n=window.speechSynthesis;n.speaking&&n.cancel();const i=new SpeechSynthesisUtterance(this.options.text);i.rate=this.options.rate||1,i.pitch=this.options.pitch||1,i.volume=this.options.volume||1,this.options.voice&&(i.voice=n.getVoices()[this.options.voice]),this.options.lang&&(this.options.lang.length===2?i.lang=`${this.options.lang}-${this.options.lang.toUpperCase()}`:this.options.lang.length===5?i.lang=this.options.lang:i.lang="en-US"),i.onend=()=>{e()},i.onerror=s=>{t(s)},n.speaking?(n.cancel(),ad&&clearTimeout(ad),ad=setTimeout(()=>{n.speak(i)},200)):n.speak(i)}else t("No text provided")}));this.options=e}}async function RE(){return Promise.all([J3(),Gi("github:tidalcycles/Dirt-Samples/master").then(()=>gB()),bB(),Gi("github:Bubobubobubobubo/Dough-Fox/main"),Gi("github:Bubobubobubobubo/Dough-Samples/main"),Gi("github:Bubobubobubobubo/Dough-Amiga/main"),Gi("github:Bubobubobubobubo/Dough-Amen/main"),Gi("github:Bubobubobubobubo/Dough-Waveforms/main")])}class IB{constructor(e){b(this,"variables",{});b(this,"codeExamples",{});b(this,"counters",{});b(this,"_drunk",new L3(-100,100,!1));b(this,"randomGen",Math.random);b(this,"currentSeed");b(this,"localSeeds",new Map);b(this,"patternCache",new Km({max:1e3,ttl:1e3*60*5}));b(this,"errorTimeoutID",0);b(this,"printTimeoutID",0);b(this,"MidiConnection");b(this,"scale_aid");b(this,"load");b(this,"_loadUniverseFromInterface",e=>{this.app.loadUniverse(e),this.app.openBuffersModal()});b(this,"_deleteUniverseFromInterface",e=>{delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"_playDocExample",e=>{let t=this.app.universes[this.app.selected_universe];this.app.exampleIsPlaying=!0,t.example?t.example.candidate=e||this.app.selectedExample:(t.example={candidate:"",committed:"",evaluations:0},t.example.candidate=e||this.app.selectedExample),this.play()});b(this,"_stopDocExample",()=>{let e=this.app.universes[this.app.selected_universe];(e==null?void 0:e.example)!==void 0&&(this.app.exampleIsPlaying=!1,e.example.candidate="",e.example.committed=""),this.pause()});b(this,"_playDocExampleOnce",e=>{let t=this.app.universes[this.app.selected_universe];(t==null?void 0:t.example)!==void 0&&(t.example.candidate="",t.example.committed=""),this.play(),this.app.exampleIsPlaying=!0,FP(this.app,e)});b(this,"_all_samples",()=>c_.get());b(this,"_reportError",e=>{console.log(e),clearTimeout(this.errorTimeoutID),clearTimeout(this.printTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="color-red-800",this.app.error_line.classList.remove("hidden"),this.errorTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),2e3)});b(this,"_logMessage",e=>{console.log(e),clearTimeout(this.printTimeoutID),clearTimeout(this.errorTimeoutID),this.app.error_line.innerHTML=e,this.app.error_line.style.color="white",this.app.error_line.classList.remove("hidden"),this.printTimeoutID=setTimeout(()=>this.app.error_line.classList.add("hidden"),4e3)});b(this,"time",()=>this.app.audioContext.currentTime);b(this,"play",()=>{this.app.setButtonHighlighting("play",!0),this.MidiConnection.sendStartMessage(),this.app.clock.start()});b(this,"pause",()=>{this.app.setButtonHighlighting("pause",!0),this.MidiConnection.sendStopMessage(),this.app.clock.pause()});b(this,"stop",()=>{this.app.setButtonHighlighting("stop",!0),this.MidiConnection.sendStopMessage(),this.app.clock.stop()});b(this,"silence",this.stop);b(this,"hush",this.stop);b(this,"warp",e=>{this.app.clock.tick=e,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e)});b(this,"beat_warp",e=>{this.app.clock.tick=e*this.app.clock.ppqn,this.app.clock.time_position=this.app.clock.convertTicksToTimeposition(e*this.app.clock.ppqn)});b(this,"onmousemove",e=>{this.app._mouseX=e.pageX,this.app._mouseY=e.pageY});b(this,"mouseX",()=>this.app._mouseX);b(this,"mouseY",()=>this.app._mouseY);b(this,"noteX",()=>Math.floor(this.app._mouseX/document.body.clientWidth*127));b(this,"noteY",()=>Math.floor(this.app._mouseY/document.body.clientHeight*127));b(this,"script",(...e)=>{e.forEach(t=>{ls(this.app,this.app.universes[this.app.selected_universe].locals[t])})});b(this,"s",this.script);b(this,"delete_script",e=>{this.app.universes[this.app.selected_universe].locals[e]={candidate:"",committed:"",evaluations:0}});b(this,"cs",this.delete_script);b(this,"copy_script",(e,t)=>{this.app.universes[this.app.selected_universe].locals[t]={...this.app.universes[this.app.selected_universe].locals[e]}});b(this,"cps",this.copy_script);b(this,"copy_universe",(e,t)=>{this.app.universes[t]={...this.app.universes[e]}});b(this,"delete_universe",e=>{this.app.selected_universe===e&&(this.app.selected_universe="Default"),delete this.app.universes[e],this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings),this.app.updateKnownUniversesView()});b(this,"big_bang",()=>{confirm("Are you sure you want to delete all universes?")&&(this.app.universes={...Io},this.app.settings.saveApplicationToLocalStorage(this.app.universes,this.app.settings)),this.app.selected_universe="Default",this.app.updateKnownUniversesView()});b(this,"midi_outputs",()=>{this._logMessage(this.MidiConnection.listMidiOutputs())});b(this,"midi_output",e=>{e?this.MidiConnection.switchMidiOutput(e):console.log(this.MidiConnection.getCurrentMidiPort())});b(this,"midi",(e=60,t,n)=>(t!==void 0&&(typeof e=="number"&&(e={note:e}),e.velocity=t),n!==void 0&&(typeof e=="number"&&(e={note:e}),e.channel=n),new Wm(e,this.app)));b(this,"sysex",e=>{this.MidiConnection.sendSysExMessage(e)});b(this,"pitch_bend",(e,t)=>{this.MidiConnection.sendPitchBend(e,t)});b(this,"program_change",(e,t)=>{this.MidiConnection.sendProgramChange(e,t)});b(this,"midi_clock",()=>{this.MidiConnection.sendMidiClock()});b(this,"control_change",({control:e=20,value:t=0,channel:n=0})=>{this.MidiConnection.sendMidiControlChange(e,t,n)});b(this,"midi_panic",()=>{this.MidiConnection.panic()});b(this,"active_note_events",e=>{let t;if(e?t=this.MidiConnection.activeNotesFromChannel(e):t=this.MidiConnection.activeNotes,t.length>0)return t});b(this,"active_notes",e=>{const t=this.active_note_events(e);if(t&&t.length>0)return t.map(n=>n.note)});b(this,"kill_active_notes",()=>{this.MidiConnection.activeNotes=[]});b(this,"sticky_notes",e=>{let t;if(e?t=this.MidiConnection.stickyNotesFromChannel(e):t=this.MidiConnection.stickyNotes,t.length>0)return t.map(n=>n.note)});b(this,"kill_sticky_notes",()=>{this.MidiConnection.stickyNotes=[]});b(this,"buffer",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e)!==void 0:this.MidiConnection.noteInputBuffer.length>0);b(this,"buffer_event",e=>e?this.MidiConnection.findNoteFromBufferInChannel(e):this.MidiConnection.noteInputBuffer.shift());b(this,"buffer_note",e=>{const t=this.buffer_event(e);return t?t.note:void 0});b(this,"last_note_event",e=>e?this.MidiConnection.lastNoteInChannel[e]:this.MidiConnection.lastNote);b(this,"last_note",e=>{const t=this.last_note_event(e);return t?t.note:60});b(this,"last_cc",(e,t)=>t?this.MidiConnection.lastCCInChannel[t]?this.MidiConnection.lastCCInChannel[t][e]:64:this.MidiConnection.lastCC[e]||64);b(this,"has_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e)!==void 0:this.MidiConnection.ccInputBuffer.length>0);b(this,"buffer_cc",e=>e?this.MidiConnection.findCCFromBufferInChannel(e):this.MidiConnection.ccInputBuffer.shift());b(this,"show_scale",(e,t,n=0,i=this.MidiConnection.currentOutputIndex||0,s=!1)=>{(!this.scale_aid||t!==this.scale_aid)&&(this.hide_scale(e,t,n,i),O3(t,e).forEach(o=>{this.MidiConnection.sendMidiOn(o,n,1,i),s&&this.MidiConnection.sendAllSoundOff(n,i)}),this.scale_aid=t)});b(this,"hide_scale",(e=0,t=0,n=0,i=this.MidiConnection.currentOutputIndex||0)=>{Array.from(Array(128).keys()).forEach(a=>{this.MidiConnection.sendMidiOff(a,n,i)}),this.scale_aid=void 0});b(this,"midi_notes_off",(e=0,t=this.MidiConnection.currentOutputIndex||0)=>{this.MidiConnection.sendAllNotesOff(e,t)});b(this,"midi_sound_off",(e=0,t=this.MidiConnection.currentOutputIndex||0)=>{this.MidiConnection.sendAllSoundOff(e,t)});b(this,"generateCacheKey",(...e)=>e.map(t=>JSON.stringify(t)).join(","));b(this,"z",(e,t={},n="")=>{const i="z"+n.toString(),s=n===""?this.generateCacheKey(e,t):i;let a;return this.app.api.patternCache.has(s)&&(a=this.app.api.patternCache.get(s),a.input!==e&&(a=void 0)),a||(a=new CB(e,t,this.app),this.app.api.patternCache.set(s,a)),typeof n=="number"&&(a.zid=i),a.updateLastCallTime(),n!==""&&a.sync("z0"),a});b(this,"z0",(e,t={})=>this.z(e,t,0));b(this,"z1",(e,t={})=>this.z(e,t,1));b(this,"z2",(e,t={})=>this.z(e,t,2));b(this,"z3",(e,t={})=>this.z(e,t,3));b(this,"z4",(e,t={})=>this.z(e,t,4));b(this,"z5",(e,t={})=>this.z(e,t,5));b(this,"z6",(e,t={})=>this.z(e,t,6));b(this,"z7",(e,t={})=>this.z(e,t,7));b(this,"z8",(e,t={})=>this.z(e,t,8));b(this,"z9",(e,t={})=>this.z(e,t,9));b(this,"z10",(e,t={})=>this.z(e,t,10));b(this,"z11",(e,t={})=>this.z(e,t,11));b(this,"z12",(e,t={})=>this.z(e,t,12));b(this,"z13",(e,t={})=>this.z(e,t,13));b(this,"z14",(e,t={})=>this.z(e,t,14));b(this,"z15",(e,t={})=>this.z(e,t,15));b(this,"z16",(e,t={})=>this.z(e,t,16));b(this,"counter",(e,t,n)=>(e in this.counters?(this.counters[e].limit!==t&&(this.counters[e].value=0,this.counters[e].limit=t),this.counters[e].step!==n&&(this.counters[e].step=n??this.counters[e].step),this.counters[e].value+=this.counters[e].step,this.counters[e].limit!==void 0&&this.counters[e].value>this.counters[e].limit&&(this.counters[e].value=0)):this.counters[e]={value:0,step:n??1,limit:t},this.counters[e].value));b(this,"$",this.counter);b(this,"i",e=>e!==void 0?(this.app.universes[this.app.selected_universe].global.evaluations=e,this.app.universes[this.app.selected_universe]):this.app.universes[this.app.selected_universe].global.evaluations);b(this,"drunk",e=>e!==void 0?(this._drunk.position=e,this._drunk.getPosition()):(this._drunk.step(),this._drunk.getPosition()));b(this,"drunk_max",e=>{this._drunk.max=e});b(this,"drunk_min",e=>{this._drunk.min=e});b(this,"drunk_wrap",e=>{this._drunk.toggleWrap(e)});b(this,"variable",(e,t)=>typeof e=="string"&&t===void 0?this.variables[e]:(this.variables[e]=t,this.variables[e]));b(this,"v",this.variable);b(this,"delete_variable",e=>{delete this.variables[e]});b(this,"dv",this.delete_variable);b(this,"clear_variables",()=>{this.variables={}});b(this,"cv",this.clear_variables);b(this,"randI",(e,t)=>Math.floor(this.randomGen()*(t-e+1))+e);b(this,"rand",(e,t)=>this.randomGen()*(t-e)+e);b(this,"irand",this.randI);b(this,"rI",this.randI);b(this,"r",this.rand);b(this,"ir",this.randI);b(this,"seed",e=>{typeof e=="number"&&(e=e.toString()),this.currentSeed!==e&&(this.currentSeed=e,this.randomGen=Qm(e))});b(this,"localSeededRandom",e=>{if(typeof e=="number"&&(e=e.toString()),this.localSeeds.has(e))return this.localSeeds.get(e);const t=Qm(e);return this.localSeeds.set(e,t),t});b(this,"clearLocalSeed",(e=void 0)=>{e&&this.localSeeds.delete(e.toString()),this.localSeeds.clear()});b(this,"quantize",(e,t)=>{if(t.length===0)return e;let n=t[0];return t.forEach(i=>{Math.abs(i-e)Math.min(Math.max(e,t),n));b(this,"cmp",this.clamp);b(this,"nudge",e=>(e&&(this.app.clock.nudge=e),this.app.clock.nudge));b(this,"bpm",e=>e===void 0?this.app.clock.bpm:((e<1||e>500)&&console.log(`Setting bpm to ${e}`),this.app.clock.bpm=e,e));b(this,"tempo",this.bpm);b(this,"bpb",e=>e===void 0?this.app.clock.time_signature[0]:(e<1&&console.log(`Setting bpb to ${e}`),this.app.clock.time_signature[0]=e,e));b(this,"ppqn",e=>e===void 0?this.app.clock.ppqn:(e<1&&console.log(`Setting ppqn to ${e}`),this.app.clock.ppqn=e,e));b(this,"time_signature",(e,t)=>{this.app.clock.time_signature=[e,t]});b(this,"prob",e=>this.randomGen()*100this.randomGen()>.5);b(this,"odds",(e,t=1)=>this.randomGen()!1);b(this,"almostNever",(e=1)=>this.randomGen()<.025*this.ppqn()/(this.ppqn()*e));b(this,"rarely",(e=1)=>this.randomGen()<.1*this.ppqn()/(this.ppqn()*e));b(this,"scarcely",(e=1)=>this.randomGen()<.25*this.ppqn()/(this.ppqn()*e));b(this,"sometimes",(e=1)=>this.randomGen()<.5*this.ppqn()/(this.ppqn()*e));b(this,"often",(e=1)=>this.randomGen()<.75*this.ppqn()/(this.ppqn()*e));b(this,"frequently",(e=1)=>this.randomGen()<.9*this.ppqn()/(this.ppqn()*e));b(this,"almostAlways",(e=1)=>this.randomGen()<.985*this.ppqn()/(this.ppqn()*e));b(this,"always",(e=1)=>!0);b(this,"dice",e=>Math.floor(this.randomGen()*e)+1);b(this,"cbar",()=>this.app.clock.time_position.bar+1);b(this,"ctick",()=>this.app.clock.tick+1);b(this,"cpulse",()=>this.app.clock.time_position.pulse+1);b(this,"cbeat",()=>this.app.clock.time_position.beat+1);b(this,"ebeat",()=>this.app.clock.beats_since_origin+1);b(this,"epulse",()=>this.app.clock.pulses_since_origin+1);b(this,"nominator",()=>this.app.clock.time_signature[0]);b(this,"meter",()=>this.app.clock.time_signature[1]);b(this,"denominator",this.meter);b(this,"beat",(...e)=>e.map(n=>this.app.clock.pulses_since_origin%Math.floor(n*this.ppqn())===0).some(n=>n===!0));b(this,"b",this.beat);b(this,"bar",(...e)=>e.map(n=>this.app.clock.pulses_since_origin%Math.floor(n*this.ppqn()*this.app.clock.time_signature[1])===0).some(n=>n===!0));b(this,"B",this.bar);b(this,"pulse",(...e)=>e.map(n=>this.app.clock.pulses_since_origin%n===0).some(n=>n===!0));b(this,"flip",(e,t=50)=>{let n=e*2;const i=this.app.clock.pulses_since_origin,s=Math.floor(n*this.ppqn()),a=Math.floor(t/100*s);return i%s{let t=e*2;const n=this.app.clock.time_position.bar;return Math.floor(n/t)%2===0});b(this,"onbar",(e,t=this.app.clock.time_signature[0])=>{let n=this.app.clock.time_position.bar%t+1;return typeof e=="number"?e===n:e.some(i=>i==n)});b(this,"onbeat",(...e)=>{let t=[];return e.forEach(n=>{let i=n%this.nominator()||this.nominator(),s=Math.floor(i);s=s==0?this.nominator():s;let a=Math.floor((i-s)*this.ppqn()+1);a<=0&&(a=a+this.ppqn()*this.nominator()),t.push(s===this.cbeat()&&this.cpulse()===a)}),t.some(n=>n==!0)});b(this,"oncount",(e,t)=>{typeof e=="number"&&(e=[e]);const n=this.app.clock.pulses_since_origin;let i=[];return e.forEach(s=>{s=s<1?0:s-1;const a=Math.ceil(s*this.ppqn()),o=n%(this.ppqn()*t);return i.push(o===a)}),i.some(s=>s==!0)});b(this,"oneuclid",(e,t,n=0)=>{const s=this._euclidean_cycle(e,t,n).reduce((a,o,l)=>(o&&a.push(l+1),a),[]);return this.oncount(s,t)});b(this,"delay",(e,t)=>{setTimeout(t,e)});b(this,"delayr",(e,t,n)=>{[...Array(t).keys()].map(s=>e*s).forEach((s,a)=>{setTimeout(n,s)})});b(this,"euclid",(e,t,n,i=0)=>this._euclidean_cycle(t,n,i)[e%n]);b(this,"ec",this.euclid);b(this,"rhythm",(e,t,n,i=0)=>this.beat(e)&&this._euclidean_cycle(t,n,i).beat(e));b(this,"bin",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return i[e%i.length]});b(this,"binrhythm",(e,t)=>{let i=t.toString(2).split("").map(s=>s==="1");return this.beat(e)&&i.beat(e)});b(this,"line",(e,t,n=1)=>{const i=[];if(t>e&&n>0||tMath.sin(this.app.clock.ctx.currentTime*Math.PI*2*e)+t);b(this,"usine",(e=1,t=0)=>(this.sine(e,t)+1)/2);b(this,"saw",(e=1,t=0)=>this.app.clock.ctx.currentTime*e%1*2-1+t);b(this,"usaw",(e=1,t=0)=>(this.saw(e,t)+1)/2);b(this,"triangle",(e=1,t=0)=>Math.abs(this.saw(e,t))*2-1);b(this,"utriangle",(e=1,t=0)=>(this.triangle(e,t)+1)/2);b(this,"square",(e=1,t=0,n=.5)=>{const i=1/e;return(Date.now()/1e3+t)%i/i(this.square(e,t,n)+1)/2);b(this,"noise",()=>this.randomGen()*2-1);b(this,"min",(...e)=>Math.min(...e));b(this,"max",(...e)=>Math.max(...e));b(this,"mean",(...e)=>e.reduce((n,i)=>n+i,0)/e.length);b(this,"limit",(e,t,n)=>Math.min(Math.max(e,t),n));b(this,"abs",Math.abs);b(this,"speak",(e,t="en-US",n=0,i=1,s=1)=>{new QI({text:e,lang:t,voice:n,rate:i,pitch:s}).speak().then(()=>{}).catch(o=>{console.log(o)})});b(this,"stop_hydra",()=>{this.app.hydra.hush()});b(this,"sound",e=>new Hm(e,this.app));b(this,"snd",this.sound);b(this,"samples",Gi);b(this,"log",e=>{console.log(e),this._logMessage(e)});b(this,"scale",a_);b(this,"rate",e=>{});b(this,"divseq",(...e)=>{const t=e[0],n=e.slice(1),i=this.app.clock.pulses_since_origin,s=Math.floor(i/Math.floor(t*this.ppqn()));return n[s%n.length]});b(this,"seqbeat",(...e)=>e[this.app.clock.time_position.beat%e.length]);b(this,"seqbar",(...e)=>e[(this.app.clock.time_position.bar+1)%e.length]);b(this,"shuffle",e=>e.sort(()=>this.randomGen()-.5));b(this,"reverse",e=>e.reverse());b(this,"rotate",e=>t=>t.slice(e,t.length).concat(t.slice(0,e)));b(this,"repeat",e=>t=>t.flatMap(n=>Array(e).fill(n)));b(this,"repeatOdd",e=>t=>t.flatMap((n,i)=>i%2===0?Array(e).fill(n):n));b(this,"repeatEven",e=>t=>t.flatMap((n,i)=>i%2!==0?Array(e).fill(n):n));b(this,"palindrome",e=>e.concat(e.slice(0,e.length-1).reverse()));this.app=e,this.MidiConnection=new k3(this,e.settings)}transmission(){return this.MidiConnection.activeNotes.length>0}_euclidean_cycle(e,t,n=0){if(e==t)return Array.from({length:t},()=>!0);function i(o,l){const c=o.length,u=(l+1)%c;return o[l]>o[u]}if(e>=t)return[!0];const s=Array.from({length:t},(o,l)=>(e*(l-1)%t+t)%t);let a=s.map((o,l)=>i(s,l));return n!=0&&(a=a.slice(n).concat(a.slice(0,n))),a}}const RB=r=>{Array.prototype.square=function(){return this.map(e=>e*e)},Array.prototype.sometimes=function(e){return r.randomGen()<.5?e(this):this},Array.prototype.apply=function(e){return e(this)},Array.prototype.sqrt=function(){if(this.some(e=>e<0))throw new Error("Cannot take square root of negative number");return this.map(e=>Math.sqrt(e))},Array.prototype.add=function(e){return this.map(t=>t+e)},Array.prototype.sub=function(e){return this.map(t=>t-e)},Array.prototype.mult=function(e){return this.map(t=>t*e)},Array.prototype.div=function(e){if(e===0)throw new Error("Division by zero");return this.map(t=>t/e)},Array.prototype.pick=function(){return this[Math.floor(r.randomGen()*this.length)]},Array.prototype.gen=function(e,t,n){return n<1?[]:Array.from({length:n},()=>Math.floor(r.randomGen()*(t-e+1))+e)},Array.prototype.bar=function(e=1){return e===1?this[r.app.clock.time_position.bar%this.length]:this[Math.floor(r.app.clock.time_position.bar/e)%this.length]},Array.prototype.beat=function(e=1){const t=e,n=r.app.clock.pulses_since_origin,i=Math.floor(n/Math.floor(t*r.ppqn()));return this[i%this.length]},Array.prototype.b=Array.prototype.beat,Array.prototype.shuffle=function(){let e=this.length,t;for(;e!==0;)t=Math.floor(r.randomGen()*e),e--,[this[e],this[t]]=[this[t],this[e]];return this},Array.prototype.rotate=function(e){const t=this.length;if(e<0)e=t+e%t;else if(e>0)e=e%t;else return this;const n=this.splice(-e,e);return this.unshift(...n),this},Array.prototype.unique=function(){const e=new Set;let t=0;for(let n=0;n100)throw new Error("Amount should be between 0 and 100");if(this.length<=1)return this;for(let t=0;t1)this.splice(t,1);else return this;else t++;return this},Array.prototype.repeat=function(e=1){if(e<1)throw new Error("Amount should be at least 1");let t=[];for(let n=0;n(i%s+s)%s,n=DI(Ds(r));return this.map(i=>{const s=Math.floor(i/n.length)*12;return n[t(i,n.length)]+e+s})};Array.prototype.scaleArp=function(r="major",e=0){const t=DI(Ds(r));let n=[];e=e>t.length?t.length:e,e=e==0?t.length:e;for(let i=0;i>1|(Pt&21845)<<1;Mi=(Mi&52428)>>2|(Mi&13107)<<2,Mi=(Mi&61680)>>4|(Mi&3855)<<4,rg[Pt]=((Mi&65280)>>8|(Mi&255)<<8)>>1}var ri=function(r,e,t){for(var n=r.length,i=0,s=new lr(e);i>l]=c}else for(o=new lr(n),i=0;i>15-r[i]);return o},Ji=new En(288);for(var Pt=0;Pt<144;++Pt)Ji[Pt]=8;for(var Pt=144;Pt<256;++Pt)Ji[Pt]=9;for(var Pt=256;Pt<280;++Pt)Ji[Pt]=7;for(var Pt=280;Pt<288;++Pt)Ji[Pt]=8;var Wo=new En(32);for(var Pt=0;Pt<32;++Pt)Wo[Pt]=5;var wB=ri(Ji,9,0),DB=ri(Ji,9,1),xB=ri(Wo,5,0),kB=ri(Wo,5,1),sd=function(r){for(var e=r[0],t=1;te&&(e=r[t]);return e},Rr=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},od=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},h_=function(r){return(r+7)/8|0},f_=function(r,e,t){(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length);var n=new En(t-e);return n.set(r.subarray(e,t)),n},LB=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Gn=function(r,e,t){var n=new Error(e||LB[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Gn),!t)throw n;return n},m_=function(r,e,t,n){var i=r.length,s=n?n.length:0;if(!i||e.f&&!e.l)return t||new En(0);var a=!t||e.i!=2,o=e.i;t||(t=new En(i*3));var l=function(Be){var tt=t.length;if(Be>tt){var rt=new En(Math.max(tt*2,Be));rt.set(t),t=rt}},c=e.f||0,u=e.p||0,p=e.b||0,m=e.l,_=e.d,v=e.m,I=e.n,R=i*8;do{if(!m){c=Rr(r,u,1);var x=Rr(r,u+1,3);if(u+=3,x)if(x==1)m=DB,_=kB,v=9,I=5;else if(x==2){var E=Rr(r,u,31)+257,S=Rr(r,u+10,15)+4,N=E+Rr(r,u+5,31)+1;u+=14;for(var k=new En(N),L=new En(19),M=0;M>4;if($<16)k[M++]=$;else{var ee=0,B=0;for($==16?(B=3+Rr(r,u,3),u+=2,ee=k[M-1]):$==17?(B=3+Rr(r,u,7),u+=3):$==18&&(B=11+Rr(r,u,127),u+=7);B--;)k[M++]=ee}}var Q=k.subarray(0,E),j=k.subarray(E);v=sd(Q),I=sd(j),m=ri(Q,v,1),_=ri(j,I,1)}else Gn(1);else{var $=h_(u)+4,Z=r[$-4]|r[$-3]<<8,f=$+Z;if(f>i){o&&Gn(0);break}a&&l(p+Z),t.set(r.subarray($,f),p),e.b=p+=Z,e.p=u=f*8,e.f=c;continue}if(u>R){o&&Gn(0);break}}a&&l(p+131072);for(var K=(1<>4;if(u+=ee&15,u>R){o&&Gn(0);break}if(ee||Gn(2),Ee<256)t[p++]=Ee;else if(Ee==256){le=u,m=null;break}else{var De=Ee-254;if(Ee>264){var M=Ee-257,xe=au[M];De=Rr(r,u,(1<>4;be||Gn(3),u+=be&15;var j=NB[Ne];if(Ne>3){var xe=su[Ne];j+=od(r,u)&(1<R){o&&Gn(0);break}a&&l(p+131072);var ce=p+De;if(p>8},po=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},ld=function(r,e){for(var t=[],n=0;nm&&(m=s[n].s);var _=new lr(m+1),v=ig(t[u-1],_,0);if(v>e){var n=0,I=0,R=v-e,x=1<e)I+=x-(1<>=R;I>0;){var Z=s[n].s;_[Z]=0&&I;--n){var f=s[n].s;_[f]==e&&(--_[f],++I)}v=e}return{t:new En(_),l:v}},ig=function(r,e,t){return r.s==-1?Math.max(ig(r.l,e,t+1),ig(r.r,e,t+1)):e[r.s]=t},wE=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new lr(++e),n=0,i=r[0],s=1,a=function(l){t[n++]=l},o=1;o<=e;++o)if(r[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=r[o]}return{c:t.subarray(0,n),n:e}},ho=function(r,e){for(var t=0,n=0;n>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var s=0;s4&&!M[tg[te-1]];--te);var re=c+5<<3,ne=ho(i,Ji)+ho(s,Wo)+a,ee=ho(i,m)+ho(s,I)+a+14+3*te+ho(N,M)+2*N[16]+3*N[17]+7*N[18];if(l>=0&&re<=ne&&re<=ee)return WI(e,u,r.subarray(l,l+c));var B,Q,j,K;if(fi(e,u,1+(ee15&&(fi(e,u,De[k]>>5&127),u+=De[k]>>12)}}else B=wB,Q=Ji,j=xB,K=Wo;for(var k=0;k255){var xe=be>>18&31;po(e,u,B[xe+257]),u+=Q[xe+257],xe>7&&(fi(e,u,be>>23&31),u+=au[xe]);var Ne=be&31;po(e,u,j[Ne]),u+=K[Ne],Ne>3&&(po(e,u,be>>5&8191),u+=su[Ne])}else po(e,u,B[be]),u+=Q[be]}return po(e,u,B[256]),u+Q[256]},MB=new p_([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),XI=new En(0),PB=function(r,e,t,n,i,s){var a=s.z||r.length,o=new En(n+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(n,o.length-i),c=s.l,u=(s.r||0)&7;if(e){u&&(l[0]=s.r>>3);for(var p=MB[e-1],m=p>>13,_=p&8191,v=(1<7e3||M>24576)&&(B>423||!c)){u=DE(r,l,0,f,E,S,k,M,te,L-te,u),M=N=k=0,te=L;for(var Q=0;Q<286;++Q)E[Q]=0;for(var Q=0;Q<30;++Q)S[Q]=0}var j=2,K=0,ue=_,le=ne-ee&32767;if(B>2&&re==Z(L-le))for(var Ee=Math.min(m,B)-1,De=Math.min(32767,L),xe=Math.min(258,B);le<=De&&--ue&&ne!=ee;){if(r[L+j]==r[L+j-le]){for(var be=0;bej){if(j=be,K=le,be>Ee)break;for(var Ne=Math.min(le,be-2),ce=0,Q=0;Qce&&(ce=Be,ee=Le)}}}ne=ee,ee=I[ne],le+=ne-ee&32767}if(K){f[M++]=268435456|ng[j]<<18|NE[K];var tt=ng[j]&31,rt=NE[K]&31;k+=au[tt]+su[rt],++E[257+tt],++S[rt],G=L+j,++N}else f[M++]=r[L],++E[r[L]]}}for(L=Math.max(L,G);L=a&&(l[u/8|0]=c,ft=a),u=WI(l,u+1,r.subarray(L,ft))}s.i=a}return f_(o,0,n+h_(u)+i)},BB=function(){for(var r=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;r[e]=t}return r}(),UB=function(){var r=-1;return{p:function(e){for(var t=r,n=0;n>>8;r=t},d:function(){return~r}}},FB=function(r,e,t,n,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new En(s.length+r.length);a.set(s),a.set(r,s.length),r=a,i.w=s.length}return PB(r,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+e.mem,t,n,i)},ag=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},YB=function(r,e){var t=e.filename;if(r[0]=31,r[1]=139,r[2]=8,r[8]=e.level<2?4:e.level==9?2:0,r[9]=3,e.mtime!=0&&ag(r,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){r[3]=8;for(var n=0;n<=t.length;++n)r[n+10]=t.charCodeAt(n)}},$B=function(r){(r[0]!=31||r[1]!=139||r[2]!=8)&&Gn(6,"invalid gzip data");var e=r[3],t=10;e&4&&(t+=(r[10]|r[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!r[t++]);return t+(e&2)},GB=function(r){var e=r.length;return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0},QB=function(r){return 10+(r.filename?r.filename.length+1:0)},qB=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Gn(6,"invalid zlib data"),(r[1]>>5&1)==+!e&&Gn(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function VB(r,e){return m_(r,{i:2},e&&e.out,e&&e.dictionary)}function zB(r,e){e||(e={});var t=UB(),n=r.length;t.p(r);var i=FB(r,e,QB(e),8),s=i.length;return YB(i,e),ag(i,s-8,t.d()),ag(i,s-4,n),i}function HB(r,e){var t=$B(r);return t+8>r.length&&Gn(6,"invalid gzip data"),m_(r.subarray(t,-8),{i:2},e&&e.out||new En(GB(r)),e&&e.dictionary)}function WB(r,e){return m_(r.subarray(qB(r,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function XB(r,e){return r[0]==31&&r[1]==139&&r[2]==8?HB(r,e):(r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31?VB(r,e):WB(r,e)}var sg=typeof TextDecoder<"u"&&new TextDecoder,ZB=0;try{sg.decode(XI,{stream:!0}),ZB=1}catch{}var KB=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:f_(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function jB(r,e){if(e){for(var t="",n=0;n (GFM Style)",type:"boolean"},requireSpaceBeforeHeadingText:{defaultValue:!1,describe:"Makes adding a space between `#` and the header text mandatory (GFM Style)",type:"boolean"},ghMentions:{defaultValue:!1,describe:"Enables github @mentions",type:"boolean"},ghMentionsLink:{defaultValue:"https://github.com/{u}",describe:"Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",type:"string"},encodeEmails:{defaultValue:!0,describe:"Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",type:"boolean"},openLinksInNewWindow:{defaultValue:!1,describe:"Open all links in new windows",type:"boolean"},backslashEscapesHTMLTags:{defaultValue:!1,describe:"Support for HTML Tag escaping. ex: foo
",type:"boolean"},emoji:{defaultValue:!1,describe:"Enable emoji support. Ex: `this is a :smile: emoji`",type:"boolean"},underline:{defaultValue:!1,describe:"Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `` and ``",type:"boolean"},ellipsis:{defaultValue:!0,describe:"Replaces three dots with the ellipsis unicode character",type:"boolean"},completeHTMLDocument:{defaultValue:!1,describe:"Outputs a complete html document, including ``, `` and `` tags",type:"boolean"},metadata:{defaultValue:!1,describe:"Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).",type:"boolean"},splitAdjacentBlockquotes:{defaultValue:!1,describe:"Split adjacent blockquote blocks",type:"boolean"}};if(f===!1)return JSON.parse(JSON.stringify(E));var S={};for(var N in E)E.hasOwnProperty(N)&&(S[N]=E[N].defaultValue);return S}function t(){var f=e(!0),E={};for(var S in f)f.hasOwnProperty(S)&&(E[S]=!0);return E}var n={},i={},s={},a=e(!0),o="vanilla",l={github:{omitExtraWLInCodeBlocks:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,disableForced4SpacesIndentedSublists:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghCompatibleHeaderId:!0,ghMentions:!0,backslashEscapesHTMLTags:!0,emoji:!0,splitAdjacentBlockquotes:!0},original:{noHeaderId:!0,ghCodeBlocks:!1},ghost:{omitExtraWLInCodeBlocks:!0,parseImgDimensions:!0,simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0,smoothLivePreview:!0,simpleLineBreaks:!0,requireSpaceBeforeHeadingText:!0,ghMentions:!1,encodeEmails:!0},vanilla:e(!0),allOn:t()};n.helper={},n.extensions={},n.setOption=function(f,E){return a[f]=E,this},n.getOption=function(f){return a[f]},n.getOptions=function(){return a},n.resetOptions=function(){a=e(!0)},n.setFlavor=function(f){if(!l.hasOwnProperty(f))throw Error(f+" flavor was not found");n.resetOptions();var E=l[f];o=f;for(var S in E)E.hasOwnProperty(S)&&(a[S]=E[S])},n.getFlavor=function(){return o},n.getFlavorOptions=function(f){if(l.hasOwnProperty(f))return l[f]},n.getDefaultOptions=function(f){return e(f)},n.subParser=function(f,E){if(n.helper.isString(f))if(typeof E<"u")i[f]=E;else{if(i.hasOwnProperty(f))return i[f];throw Error("SubParser named "+f+" not registered!")}},n.extension=function(f,E){if(!n.helper.isString(f))throw Error("Extension 'name' must be a string");if(f=n.helper.stdExtName(f),n.helper.isUndefined(E)){if(!s.hasOwnProperty(f))throw Error("Extension named "+f+" is not registered!");return s[f]}else{typeof E=="function"&&(E=E()),n.helper.isArray(E)||(E=[E]);var S=c(E,f);if(S.valid)s[f]=E;else throw Error(S.error)}},n.getAllExtensions=function(){return s},n.removeExtension=function(f){delete s[f]},n.resetExtensions=function(){s={}};function c(f,E){var S=E?"Error in "+E+" extension->":"Error in unnamed extension",N={valid:!0,error:""};n.helper.isArray(f)||(f=[f]);for(var k=0;k"u"},n.helper.forEach=function(f,E){if(n.helper.isUndefined(f))throw new Error("obj param is required");if(n.helper.isUndefined(E))throw new Error("callback param is required");if(!n.helper.isFunction(E))throw new Error("callback param must be a function/closure");if(typeof f.forEach=="function")f.forEach(E);else if(n.helper.isArray(f))for(var S=0;S").replace(/&/g,"&")};var p=function(f,E,S,N){var k=N||"",L=k.indexOf("g")>-1,M=new RegExp(E+"|"+S,"g"+k.replace(/g/g,"")),G=new RegExp(E,k.replace(/g/g,"")),te=[],re,ne,ee,B,Q;do for(re=0;ee=M.exec(f);)if(G.test(ee[0]))re++||(ne=M.lastIndex,B=ne-ee[0].length);else if(re&&!--re){Q=ee.index+ee[0].length;var j={left:{start:B,end:ne},match:{start:ne,end:ee.index},right:{start:ee.index,end:Q},wholeMatch:{start:B,end:Q}};if(te.push(j),!L)return te}while(re&&(M.lastIndex=ne));return te};n.helper.matchRecursiveRegExp=function(f,E,S,N){for(var k=p(f,E,S,N),L=[],M=0;M0){var re=[];M[0].wholeMatch.start!==0&&re.push(f.slice(0,M[0].wholeMatch.start));for(var ne=0;ne=0?N+(S||0):N},n.helper.splitAtIndex=function(f,E){if(!n.helper.isString(f))throw"InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string";return[f.substring(0,E),f.substring(E)]},n.helper.encodeEmailAddress=function(f){var E=[function(S){return""+S.charCodeAt(0)+";"},function(S){return""+S.charCodeAt(0).toString(16)+";"},function(S){return S}];return f=f.replace(/./g,function(S){if(S==="@")S=E[Math.floor(Math.random()*2)](S);else{var N=Math.random();S=N>.9?E[2](S):N>.45?E[1](S):E[0](S)}return S}),f},n.helper.padEnd=function(E,S,N){return S=S>>0,N=String(N||" "),E.length>S?String(E):(S=S-E.length,S>N.length&&(N+=N.repeat(S/N.length)),String(E)+N.slice(0,S))},typeof console>"u"&&(console={warn:function(f){alert(f)},log:function(f){alert(f)},error:function(f){throw f}}),n.helper.regexes={asteriskDashAndColon:/([*_:~])/g},n.helper.emojis={"+1":"👍","-1":"👎",100:"💯",1234:"🔢","1st_place_medal":"🥇","2nd_place_medal":"🥈","3rd_place_medal":"🥉","8ball":"🎱",a:"🅰️",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈️",alarm_clock:"⏰",alembic:"⚗️",alien:"👽",ambulance:"🚑",amphora:"🏺",anchor:"⚓️",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒️",aries:"♈️",arrow_backward:"◀️",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇️",arrow_down_small:"🔽",arrow_forward:"▶️",arrow_heading_down:"⤵️",arrow_heading_up:"⤴️",arrow_left:"⬅️",arrow_lower_left:"↙️",arrow_lower_right:"↘️",arrow_right:"➡️",arrow_right_hook:"↪️",arrow_up:"⬆️",arrow_up_down:"↕️",arrow_up_small:"🔼",arrow_upper_left:"↖️",arrow_upper_right:"↗️",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",artificial_satellite:"🛰",astonished:"😲",athletic_shoe:"👟",atm:"🏧",atom_symbol:"⚛️",avocado:"🥑",b:"🅱️",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",bacon:"🥓",badminton:"🏸",baggage_claim:"🛄",baguette_bread:"🥖",balance_scale:"⚖️",balloon:"🎈",ballot_box:"🗳",ballot_box_with_check:"☑️",bamboo:"🎍",banana:"🍌",bangbang:"‼️",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾️",basketball:"🏀",basketball_man:"⛹️",basketball_woman:"⛹️♀️",bat:"🦇",bath:"🛀",bathtub:"🛁",battery:"🔋",beach_umbrella:"🏖",bear:"🐻",bed:"🛏",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bellhop_bell:"🛎",bento:"🍱",biking_man:"🚴",bike:"🚲",biking_woman:"🚴♀️",bikini:"👙",biohazard:"☣️",bird:"🐦",birthday:"🎂",black_circle:"⚫️",black_flag:"🏴",black_heart:"🖤",black_joker:"🃏",black_large_square:"⬛️",black_medium_small_square:"◾️",black_medium_square:"◼️",black_nib:"✒️",black_small_square:"▪️",black_square_button:"🔲",blonde_man:"👱",blonde_woman:"👱♀️",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵️",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bowing_man:"🙇",bow_and_arrow:"🏹",bowing_woman:"🙇♀️",bowling:"🎳",boxing_glove:"🥊",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",building_construction:"🏗",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",burrito:"🌯",bus:"🚌",business_suit_levitating:"🕴",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",butterfly:"🦋",cactus:"🌵",cake:"🍰",calendar:"📆",call_me_hand:"🤙",calling:"📲",camel:"🐫",camera:"📷",camera_flash:"📸",camping:"🏕",cancer:"♋️",candle:"🕯",candy:"🍬",canoe:"🛶",capital_abcd:"🔠",capricorn:"♑️",car:"🚗",card_file_box:"🗃",card_index:"📇",card_index_dividers:"🗂",carousel_horse:"🎠",carrot:"🥕",cat:"🐱",cat2:"🐈",cd:"💿",chains:"⛓",champagne:"🍾",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cheese:"🧀",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chipmunk:"🐿",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪️",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cityscape:"🏙",cl:"🆑",clamp:"🗜",clap:"👏",clapper:"🎬",classical_building:"🏛",clinking_glasses:"🥂",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁️",cloud_with_lightning:"🌩",cloud_with_lightning_and_rain:"⛈",cloud_with_rain:"🌧",cloud_with_snow:"🌨",clown_face:"🤡",clubs:"♣️",cocktail:"🍸",coffee:"☕️",coffin:"⚰️",cold_sweat:"😰",comet:"☄️",computer:"💻",computer_mouse:"🖱",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗️",construction:"🚧",construction_worker_man:"👷",construction_worker_woman:"👷♀️",control_knobs:"🎛",convenience_store:"🏪",cookie:"🍪",cool:"🆒",policeman:"👮",copyright:"©️",corn:"🌽",couch_and_lamp:"🛋",couple:"👫",couple_with_heart_woman_man:"💑",couple_with_heart_man_man:"👨❤️👨",couple_with_heart_woman_woman:"👩❤️👩",couplekiss_man_man:"👨❤️💋👨",couplekiss_man_woman:"💏",couplekiss_woman_woman:"👩❤️💋👩",cow:"🐮",cow2:"🐄",cowboy_hat_face:"🤠",crab:"🦀",crayon:"🖍",credit_card:"💳",crescent_moon:"🌙",cricket:"🏏",crocodile:"🐊",croissant:"🥐",crossed_fingers:"🤞",crossed_flags:"🎌",crossed_swords:"⚔️",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cucumber:"🥒",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",dagger:"🗡",dancer:"💃",dancing_women:"👯",dancing_men:"👯♂️",dango:"🍡",dark_sunglasses:"🕶",dart:"🎯",dash:"💨",date:"📅",deciduous_tree:"🌳",deer:"🦌",department_store:"🏬",derelict_house:"🏚",desert:"🏜",desert_island:"🏝",desktop_computer:"🖥",male_detective:"🕵️",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦️",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dove:"🕊",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",drooling_face:"🤤",droplet:"💧",drum:"🥁",duck:"🦆",dvd:"📀","e-mail":"📧",eagle:"🦅",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight_pointed_black_star:"✴️",eight_spoked_asterisk:"✳️",electric_plug:"🔌",elephant:"🐘",email:"✉️",end:"🔚",envelope_with_arrow:"📩",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗️",expressionless:"😑",eye:"👁",eye_speech_bubble:"👁🗨",eyeglasses:"👓",eyes:"👀",face_with_head_bandage:"🤕",face_with_thermometer:"🤒",fist_oncoming:"👊",factory:"🏭",fallen_leaf:"🍂",family_man_woman_boy:"👪",family_man_boy:"👨👦",family_man_boy_boy:"👨👦👦",family_man_girl:"👨👧",family_man_girl_boy:"👨👧👦",family_man_girl_girl:"👨👧👧",family_man_man_boy:"👨👨👦",family_man_man_boy_boy:"👨👨👦👦",family_man_man_girl:"👨👨👧",family_man_man_girl_boy:"👨👨👧👦",family_man_man_girl_girl:"👨👨👧👧",family_man_woman_boy_boy:"👨👩👦👦",family_man_woman_girl:"👨👩👧",family_man_woman_girl_boy:"👨👩👧👦",family_man_woman_girl_girl:"👨👩👧👧",family_woman_boy:"👩👦",family_woman_boy_boy:"👩👦👦",family_woman_girl:"👩👧",family_woman_girl_boy:"👩👧👦",family_woman_girl_girl:"👩👧👧",family_woman_woman_boy:"👩👩👦",family_woman_woman_boy_boy:"👩👩👦👦",family_woman_woman_girl:"👩👩👧",family_woman_woman_girl_boy:"👩👩👧👦",family_woman_woman_girl_girl:"👩👩👧👧",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",female_detective:"🕵️♀️",ferris_wheel:"🎡",ferry:"⛴",field_hockey:"🏑",file_cabinet:"🗄",file_folder:"📁",film_projector:"📽",film_strip:"🎞",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist_raised:"✊",fist_left:"🤛",fist_right:"🤜",flags:"🎏",flashlight:"🔦",fleur_de_lis:"⚜️",flight_arrival:"🛬",flight_departure:"🛫",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",fog:"🌫",foggy:"🌁",football:"🏈",footprints:"👣",fork_and_knife:"🍴",fountain:"⛲️",fountain_pen:"🖋",four_leaf_clover:"🍀",fox_face:"🦊",framed_picture:"🖼",free:"🆓",fried_egg:"🍳",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",frowning_face:"☹️",frowning_man:"🙍♂️",frowning_woman:"🙍",middle_finger:"🖕",fuelpump:"⛽️",full_moon:"🌕",full_moon_with_face:"🌝",funeral_urn:"⚱️",game_die:"🎲",gear:"⚙️",gem:"💎",gemini:"♊️",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goal_net:"🥅",goat:"🐐",golf:"⛳️",golfing_man:"🏌️",golfing_woman:"🏌️♀️",gorilla:"🦍",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",green_salad:"🥗",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guardswoman:"💂♀️",guitar:"🎸",gun:"🔫",haircut_woman:"💇",haircut_man:"💇♂️",hamburger:"🍔",hammer:"🔨",hammer_and_pick:"⚒",hammer_and_wrench:"🛠",hamster:"🐹",hand:"✋",handbag:"👜",handshake:"🤝",hankey:"💩",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔️",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_heart_exclamation:"❣️",heavy_minus_sign:"➖",heavy_multiplication_x:"✖️",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",hole:"🕳",honey_pot:"🍯",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hot_pepper:"🌶",hotdog:"🌭",hotel:"🏨",hotsprings:"♨️",hourglass:"⌛️",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",houses:"🏘",hugs:"🤗",hushed:"😯",ice_cream:"🍨",ice_hockey:"🏒",ice_skate:"⛸",icecream:"🍦",id:"🆔",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",tipping_hand_woman:"💁",information_source:"ℹ️",innocent:"😇",interrobang:"⁉️",iphone:"📱",izakaya_lantern:"🏮",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",joystick:"🕹",kaaba:"🕋",key:"🔑",keyboard:"⌨️",keycap_ten:"🔟",kick_scooter:"🛴",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",kiwi_fruit:"🥝",koala:"🐨",koko:"🈁",label:"🏷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",latin_cross:"✝️",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔️",leftwards_arrow_with_hook:"↩️",lemon:"🍋",leo:"♌️",leopard:"🐆",level_slider:"🎚",libra:"♎️",light_rail:"🚈",link:"🔗",lion:"🦁",lips:"👄",lipstick:"💄",lizard:"🦎",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loud_sound:"🔊",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",lying_face:"🤥",m:"Ⓜ️",mag:"🔍",mag_right:"🔎",mahjong:"🀄️",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_artist:"👨🎨",man_astronaut:"👨🚀",man_cartwheeling:"🤸♂️",man_cook:"👨🍳",man_dancing:"🕺",man_facepalming:"🤦♂️",man_factory_worker:"👨🏭",man_farmer:"👨🌾",man_firefighter:"👨🚒",man_health_worker:"👨⚕️",man_in_tuxedo:"🤵",man_judge:"👨⚖️",man_juggling:"🤹♂️",man_mechanic:"👨🔧",man_office_worker:"👨💼",man_pilot:"👨✈️",man_playing_handball:"🤾♂️",man_playing_water_polo:"🤽♂️",man_scientist:"👨🔬",man_shrugging:"🤷♂️",man_singer:"👨🎤",man_student:"👨🎓",man_teacher:"👨🏫",man_technologist:"👨💻",man_with_gua_pi_mao:"👲",man_with_turban:"👳",tangerine:"🍊",mans_shoe:"👞",mantelpiece_clock:"🕰",maple_leaf:"🍁",martial_arts_uniform:"🥋",mask:"😷",massage_woman:"💆",massage_man:"💆♂️",meat_on_bone:"🍖",medal_military:"🎖",medal_sports:"🏅",mega:"📣",melon:"🍈",memo:"📝",men_wrestling:"🤼♂️",menorah:"🕎",mens:"🚹",metal:"🤘",metro:"🚇",microphone:"🎤",microscope:"🔬",milk_glass:"🥛",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_mouth_face:"🤑",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",moon:"🌔",mortar_board:"🎓",mosque:"🕌",motor_boat:"🛥",motor_scooter:"🛵",motorcycle:"🏍",motorway:"🛣",mount_fuji:"🗻",mountain:"⛰",mountain_biking_man:"🚵",mountain_biking_woman:"🚵♀️",mountain_cableway:"🚠",mountain_railway:"🚞",mountain_snow:"🏔",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",mrs_claus:"🤶",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",national_park:"🏞",nauseated_face:"🤢",necktie:"👔",negative_squared_cross_mark:"❎",nerd_face:"🤓",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",newspaper_roll:"🗞",next_track_button:"⏭",ng:"🆖",no_good_man:"🙅♂️",no_good_woman:"🙅",night_with_stars:"🌃",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔️",no_entry_sign:"🚫",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕️",o2:"🅾️",ocean:"🌊",octopus:"🐙",oden:"🍢",office:"🏢",oil_drum:"🛢",ok:"🆗",ok_hand:"👌",ok_man:"🙆♂️",ok_woman:"🙆",old_key:"🗝",older_man:"👴",older_woman:"👵",om:"🕉",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",open_umbrella:"☂️",ophiuchus:"⛎",orange_book:"📙",orthodox_cross:"☦️",outbox_tray:"📤",owl:"🦉",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",paintbrush:"🖌",palm_tree:"🌴",pancakes:"🥞",panda_face:"🐼",paperclip:"📎",paperclips:"🖇",parasol_on_ground:"⛱",parking:"🅿️",part_alternation_mark:"〽️",partly_sunny:"⛅️",passenger_ship:"🛳",passport_control:"🛂",pause_button:"⏸",peace_symbol:"☮️",peach:"🍑",peanuts:"🥜",pear:"🍐",pen:"🖊",pencil2:"✏️",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_fencing:"🤺",pouting_woman:"🙎",phone:"☎️",pick:"⛏",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",ping_pong:"🏓",pisces:"♓️",pizza:"🍕",place_of_worship:"🛐",plate_with_cutlery:"🍽",play_or_pause_button:"⏯",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝️",point_up_2:"👆",police_car:"🚓",policewoman:"👮♀️",poodle:"🐩",popcorn:"🍿",post_office:"🏣",postal_horn:"📯",postbox:"📮",potable_water:"🚰",potato:"🥔",pouch:"👝",poultry_leg:"🍗",pound:"💷",rage:"😡",pouting_cat:"😾",pouting_man:"🙎♂️",pray:"🙏",prayer_beads:"📿",pregnant_woman:"🤰",previous_track_button:"⏮",prince:"🤴",princess:"👸",printer:"🖨",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",racing_car:"🏎",radio:"📻",radio_button:"🔘",radioactive:"☢️",railway_car:"🚃",railway_track:"🛤",rainbow:"🌈",rainbow_flag:"🏳️🌈",raised_back_of_hand:"🤚",raised_hand_with_fingers_splayed:"🖐",raised_hands:"🙌",raising_hand_woman:"🙋",raising_hand_man:"🙋♂️",ram:"🐏",ramen:"🍜",rat:"🐀",record_button:"⏺",recycle:"♻️",red_circle:"🔴",registered:"®️",relaxed:"☺️",relieved:"😌",reminder_ribbon:"🎗",repeat:"🔁",repeat_one:"🔂",rescue_worker_helmet:"⛑",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",rhinoceros:"🦏",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",right_anger_bubble:"🗯",ring:"💍",robot:"🤖",rocket:"🚀",rofl:"🤣",roll_eyes:"🙄",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rosette:"🏵",rotating_light:"🚨",round_pushpin:"📍",rowing_man:"🚣",rowing_woman:"🚣♀️",rugby_football:"🏉",running_man:"🏃",running_shirt_with_sash:"🎽",running_woman:"🏃♀️",sa:"🈂️",sagittarius:"♐️",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"📡",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂️",scorpion:"🦂",scorpius:"♏️",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙️",see_no_evil:"🙈",seedling:"🌱",selfie:"🤳",shallow_pan_of_food:"🥘",shamrock:"☘️",shark:"🦈",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",shield:"🛡",shinto_shrine:"⛩",ship:"🚢",shirt:"👕",shopping:"🛍",shopping_cart:"🛒",shower:"🚿",shrimp:"🦐",signal_strength:"📶",six_pointed_star:"🔯",ski:"🎿",skier:"⛷",skull:"💀",skull_and_crossbones:"☠️",sleeping:"😴",sleeping_bed:"🛌",sleepy:"😪",slightly_frowning_face:"🙁",slightly_smiling_face:"🙂",slot_machine:"🎰",small_airplane:"🛩",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",sneezing_face:"🤧",snowboarder:"🏂",snowflake:"❄️",snowman:"⛄️",snowman_with_snow:"☃️",sob:"😭",soccer:"⚽️",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠️",spaghetti:"🍝",sparkle:"❇️",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speaking_head:"🗣",speech_balloon:"💬",speedboat:"🚤",spider:"🕷",spider_web:"🕸",spiral_calendar:"🗓",spiral_notepad:"🗒",spoon:"🥄",squid:"🦑",stadium:"🏟",star:"⭐️",star2:"🌟",star_and_crescent:"☪️",star_of_david:"✡️",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",stop_button:"⏹",stop_sign:"🛑",stopwatch:"⏱",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",studio_microphone:"🎙",stuffed_flatbread:"🥙",sun_behind_large_cloud:"🌥",sun_behind_rain_cloud:"🌦",sun_behind_small_cloud:"🌤",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀️",sunrise:"🌅",sunrise_over_mountains:"🌄",surfing_man:"🏄",surfing_woman:"🏄♀️",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimming_man:"🏊",swimming_woman:"🏊♀️",symbols:"🔣",synagogue:"🕍",syringe:"💉",taco:"🌮",tada:"🎉",tanabata_tree:"🎋",taurus:"♉️",taxi:"🚕",tea:"🍵",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"⛺️",thermometer:"🌡",thinking:"🤔",thought_balloon:"💭",ticket:"🎫",tickets:"🎟",tiger:"🐯",tiger2:"🐅",timer_clock:"⏲",tipping_hand_man:"💁♂️",tired_face:"😫",tm:"™️",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tornado:"🌪",trackball:"🖲",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tulip:"🌷",tumbler_glass:"🥃",turkey:"🦃",turtle:"🐢",tv:"📺",twisted_rightwards_arrows:"🔀",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯️",u6708:"🈷️",u6709:"🈶",u6e80:"🈵",u7121:"🈚️",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔️",unamused:"😒",underage:"🔞",unicorn:"🦄",unlock:"🔓",up:"🆙",upside_down_face:"🙃",v:"✌️",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍️",volcano:"🌋",volleyball:"🏐",vs:"🆚",vulcan_salute:"🖖",walking_man:"🚶",walking_woman:"🚶♀️",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠️",wastebasket:"🗑",watch:"⌚️",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰️",waxing_crescent_moon:"🌒",wc:"🚾",weary:"😩",wedding:"💒",weight_lifting_man:"🏋️",weight_lifting_woman:"🏋️♀️",whale:"🐳",whale2:"🐋",wheel_of_dharma:"☸️",wheelchair:"♿️",white_check_mark:"✅",white_circle:"⚪️",white_flag:"🏳️",white_flower:"💮",white_large_square:"⬜️",white_medium_small_square:"◽️",white_medium_square:"◻️",white_small_square:"▫️",white_square_button:"🔳",wilted_flower:"🥀",wind_chime:"🎐",wind_face:"🌬",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",woman_artist:"👩🎨",woman_astronaut:"👩🚀",woman_cartwheeling:"🤸♀️",woman_cook:"👩🍳",woman_facepalming:"🤦♀️",woman_factory_worker:"👩🏭",woman_farmer:"👩🌾",woman_firefighter:"👩🚒",woman_health_worker:"👩⚕️",woman_judge:"👩⚖️",woman_juggling:"🤹♀️",woman_mechanic:"👩🔧",woman_office_worker:"👩💼",woman_pilot:"👩✈️",woman_playing_handball:"🤾♀️",woman_playing_water_polo:"🤽♀️",woman_scientist:"👩🔬",woman_shrugging:"🤷♀️",woman_singer:"👩🎤",woman_student:"👩🎓",woman_teacher:"👩🏫",woman_technologist:"👩💻",woman_with_turban:"👳♀️",womans_clothes:"👚",womans_hat:"👒",women_wrestling:"🤼♀️",womens:"🚺",world_map:"🗺",worried:"😟",wrench:"🔧",writing_hand:"✍️",x:"❌",yellow_heart:"💛",yen:"💴",yin_yang:"☯️",yum:"😋",zap:"⚡️",zipper_mouth_face:"🤐",zzz:"💤",octocat:'
',showdown:`S`},n.Converter=function(f){var E={},S=[],N=[],k={},L=o,M={parsed:{},raw:"",format:""};G();function G(){f=f||{};for(var B in a)a.hasOwnProperty(B)&&(E[B]=a[B]);if(typeof f=="object")for(var Q in f)f.hasOwnProperty(Q)&&(E[Q]=f[Q]);else throw Error("Converter expects the passed parameter to be an object, but "+typeof f+" was passed instead.");E.extensions&&n.helper.forEach(E.extensions,te)}function te(B,Q){if(Q=Q||null,n.helper.isString(B))if(B=n.helper.stdExtName(B),Q=B,n.extensions[B]){console.warn("DEPRECATION WARNING: "+B+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),re(n.extensions[B],B);return}else if(!n.helper.isUndefined(s[B]))B=s[B];else throw Error('Extension "'+B+'" could not be loaded. It was either not found or is not a valid extension.');typeof B=="function"&&(B=B()),n.helper.isArray(B)||(B=[B]);var j=c(B,Q);if(!j.valid)throw Error(j.error);for(var K=0;K
-
+