web-music-score 6.0.0-pre.4 → 6.0.0-pre.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/audio/index.d.ts +1 -1
  3. package/dist/audio/index.js +1 -1
  4. package/dist/audio/index.mjs +4 -4
  5. package/dist/audio-cg/index.js +1 -1
  6. package/dist/audio-cg/index.mjs +4 -4
  7. package/dist/audio-synth/index.js +1 -1
  8. package/dist/audio-synth/index.mjs +4 -4
  9. package/dist/{chunk-6BEFVAAS.mjs → chunk-6R3N7WJC.mjs} +3 -3
  10. package/dist/{chunk-UAVXEHYM.mjs → chunk-DQFQEO6F.mjs} +4 -4
  11. package/dist/{chunk-GNFDJFUO.mjs → chunk-G3HIPFVF.mjs} +2 -2
  12. package/dist/{chunk-DVKR62RS.mjs → chunk-JP3PJICN.mjs} +3 -3
  13. package/dist/{chunk-KFBULED3.mjs → chunk-U2D4H5TI.mjs} +3 -3
  14. package/dist/{chunk-GNCSH24V.mjs → chunk-Y67RBHW2.mjs} +2 -2
  15. package/dist/core/index.js +2 -2
  16. package/dist/core/index.mjs +5 -5
  17. package/dist/iife/audio-cg.js +1 -1
  18. package/dist/iife/index.js +9 -9
  19. package/dist/{music-objects-ChAdqdR8.d.ts → music-objects-D-xO1oti.d.ts} +3 -3
  20. package/dist/{note-RVXvpfyV.d.ts → note-CJuq5aBy.d.ts} +1 -1
  21. package/dist/pieces/index.d.ts +3 -3
  22. package/dist/pieces/index.js +2 -2
  23. package/dist/pieces/index.mjs +3 -3
  24. package/dist/react-ui/index.d.ts +3 -3
  25. package/dist/react-ui/index.js +1 -1
  26. package/dist/react-ui/index.mjs +2 -2
  27. package/dist/{scale-B1M10_fu.d.ts → scale-DxGqFxlv.d.ts} +2 -2
  28. package/dist/score/index.d.ts +14 -7
  29. package/dist/score/index.js +32 -15
  30. package/dist/score/index.mjs +36 -19
  31. package/dist/{tempo-D-JF-8b_.d.ts → tempo-pCAa6qgo.d.ts} +1 -1
  32. package/dist/theory/index.d.ts +5 -5
  33. package/dist/theory/index.js +1 -1
  34. package/dist/theory/index.mjs +4 -4
  35. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- /* WebMusicScore v6.0.0-pre.4 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
- "use strict";var WebMusicScore=(()=>{var Ls=Object.defineProperty,Ag=Object.defineProperties,Cg=Object.getOwnPropertyDescriptor,_g=Object.getOwnPropertyDescriptors,vg=Object.getOwnPropertyNames,ks=Object.getOwnPropertySymbols;var iu=Object.prototype.hasOwnProperty,Zh=Object.prototype.propertyIsEnumerable;var eu=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),wg=i=>{throw TypeError(i)},Xh=Math.pow,ru=(i,t,e)=>t in i?Ls(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,O=(i,t)=>{for(var e in t||(t={}))iu.call(t,e)&&ru(i,e,t[e]);if(ks)for(var e of ks(t))Zh.call(t,e)&&ru(i,e,t[e]);return i},X=(i,t)=>Ag(i,_g(t));var Kr=(i,t)=>{var e={};for(var r in i)iu.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&ks)for(var r of ks(i))t.indexOf(r)<0&&Zh.call(i,r)&&(e[r]=i[r]);return e};var rn=(i,t)=>{for(var e in t)Ls(i,e,{get:t[e],enumerable:!0})},Sg=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of vg(t))!iu.call(i,n)&&n!==e&&Ls(i,n,{get:()=>t[n],enumerable:!(r=Cg(t,n))||r.enumerable});return i};var Ig=i=>Sg(Ls({},"__esModule",{value:!0}),i);var d=(i,t,e)=>ru(i,typeof t!="symbol"?t+"":t,e);var K=(i,t,e)=>new Promise((r,n)=>{var o=c=>{try{a(e.next(c))}catch(u){n(u)}},s=c=>{try{a(e.throw(c))}catch(u){n(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((e=e.apply(i,t)).next())}),Tg=function(i,t){this[0]=i,this[1]=t};var de=i=>{var t=i[eu("asyncIterator")],e=!1,r,n={};return t==null?(t=i[eu("iterator")](),r=o=>n[o]=s=>t[o](s)):(t=t.call(i),r=o=>n[o]=s=>{if(e){if(e=!1,o==="throw")throw s;return s}return e=!0,{done:!1,value:new Tg(new Promise(a=>{var c=t[o](s);c instanceof Object||wg("Object expected"),a(c)}),1)}}),n[eu("iterator")]=()=>n,r("next"),"throw"in t?r("throw"):n.throw=o=>{throw o},"return"in t&&r("return"),n};var d0={};rn(d0,{Audio:()=>Go,Core:()=>pu,Pieces:()=>$h,Score:()=>Wh,Theory:()=>_u});var Go={};rn(Go,{addInstrument:()=>Dv,getCurrentInstrument:()=>Ev,getInstrumentList:()=>Mv,isMuted:()=>jv,linearToDecibels:()=>ea,mute:()=>kv,playNote:()=>Ya,stop:()=>Ha,unmute:()=>Lv,useInstrument:()=>eg});var _u={};rn(_u,{AccidentalType:()=>fu,BeamGrouping:()=>Ri,Chord:()=>gu,DefaultGuitarNoteLabel:()=>WA,DefaultPitchNotation:()=>VA,DefaultTuningName:()=>gC,GuitarNoteLabel:()=>Hs,GuitarNoteLabelList:()=>UA,Interval:()=>lo,KeySignature:()=>rr,Mode:()=>mu,Note:()=>U,NoteLength:()=>ir,NoteLengthProps:()=>Tt,PitchNotation:()=>ei,PitchNotationList:()=>GA,RhythmProps:()=>Qt,Scale:()=>ii,ScaleFactory:()=>ie,ScaleType:()=>Ni,SymbolSet:()=>ti,TimeSignature:()=>ni,TimeSignatures:()=>fo,TuningNameList:()=>mo,Tuplet:()=>Gr,alterTempoSpeed:()=>Cu,getDefaultKeySignature:()=>$s,getDefaultScale:()=>aC,getDefaultTempo:()=>Js,getDefaultTimeSignature:()=>Ks,getPitchNotationName:()=>qA,getScale:()=>Pr,getScaleFactory:()=>Dl,getScaleFactoryList:()=>oC,getTempoString:()=>ta,getTuningStrings:()=>Xs,isNoteLength:()=>nr,isTupletRatio:()=>Qs,validateGuitarNoteLabel:()=>zA,validateIntervalQuality:()=>tC,validateNoteLength:()=>Br,validatePitchNotation:()=>wl,validateScaleType:()=>po,validateTuningName:()=>bu,validateTupletRatio:()=>jl});var Qh=Object.defineProperty,Ng=(i,t,e)=>t in i?Qh(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,er=(i,t)=>{for(var e in t)Qh(i,e,{get:t[e],enumerable:!0})},mt=(i,t,e)=>Ng(i,typeof t!="symbol"?t+"":t,e),Kh={};er(Kh,{assert:()=>rb,doesNotThrow:()=>Ox,doesThrow:()=>Nx,fail:()=>sb,isArray:()=>xb,isArrayOrUndefined:()=>Ab,isBigInt:()=>qb,isBoolean:()=>Mb,isBooleanOrUndefined:()=>Eb,isDeepEqual:()=>cb,isDefined:()=>db,isEmptyArray:()=>Cb,isEmptyArrayOrUndefined:()=>vb,isEmptyObject:()=>fb,isEmptyString:()=>Ib,isEmptyStringOrUndefined:()=>Ob,isEnumValue:()=>Bb,isEnumValueOrUndefined:()=>Gb,isEven:()=>vx,isFalse:()=>Lb,isFalseOrUndefined:()=>jb,isFinite:()=>Jb,isFloat:()=>tx,isFunction:()=>Pb,isFunctionOrUndefined:()=>Fb,isIncluded:()=>Ix,isIndex:()=>Tx,isInfinity:()=>dx,isInteger:()=>ex,isIntegerBetween:()=>ux,isIntegerBetweenExclusive:()=>hx,isIntegerEq:()=>nx,isIntegerGt:()=>ox,isIntegerGte:()=>sx,isIntegerLt:()=>ax,isIntegerLte:()=>cx,isIntegerOrUndefined:()=>ix,isMultipleOf:()=>wx,isNaNValue:()=>lx,isNeg:()=>gx,isNegInfinity:()=>mx,isNegZero:()=>Cx,isNonEmptyArray:()=>_b,isNonEmptyArrayOrUndefined:()=>wb,isNonEmptyString:()=>Tb,isNonEmptyStringOrUndefined:()=>Rb,isNonNeg:()=>bx,isNonNull:()=>pb,isNonPos:()=>yx,isNull:()=>hb,isNullish:()=>lb,isNumber:()=>Wb,isNumberBetween:()=>Qb,isNumberBetweenExclusive:()=>Kb,isNumberEq:()=>Yb,isNumberGt:()=>Hb,isNumberGte:()=>$b,isNumberLt:()=>Zb,isNumberLte:()=>Xb,isNumberOrUndefined:()=>zb,isNumericString:()=>Vb,isObject:()=>mb,isObjectOrUndefined:()=>yb,isOdd:()=>_x,isPlainObject:()=>gb,isPos:()=>fx,isPosInfinity:()=>px,isPosZero:()=>Ax,isPowerOfTwo:()=>Sx,isSafeInteger:()=>rx,isSafeNumber:()=>Ub,isStrictEqual:()=>ab,isString:()=>Sb,isStringOrUndefined:()=>Nb,isTrue:()=>Db,isTrueOrUndefined:()=>kb,isTypedObject:()=>bb,isUndefined:()=>ub,isZero:()=>xx,require:()=>ib,requireDefined:()=>nb,requireElement:()=>ob,setErrorClass:()=>eb});var Jh={};er(Jh,{charCount:()=>Qy,chunkString:()=>$y,insertAt:()=>Zy,isString:()=>il,makeSentenceFromPascal:()=>Ky,removeAt:()=>Xy,repeatString:()=>Hy,replaceAt:()=>cu,splitByCaps:()=>Jy,splitByChars:()=>tb,splitByStrings:()=>al,stringify:()=>Bt,toCharArray:()=>Yy});var tl={};er(tl,{deepEqual:()=>Bs,getCtorName:()=>sl,hasProperties:()=>zy,isObject:()=>Ii});var y={};er(y,{doesNotThrow:()=>Wy,doesThrow:()=>qy,isArray:()=>Le,isArrayOrUndefined:()=>qg,isBigInt:()=>cy,isBoolean:()=>Kg,isBooleanOrUndefined:()=>Jg,isDeepEqual:()=>uo,isDefined:()=>Lg,isEmptyArray:()=>Wg,isEmptyArrayOrUndefined:()=>zg,isEmptyObject:()=>Pg,isEmptyString:()=>Hg,isEmptyStringOrUndefined:()=>Xg,isEnumValue:()=>oy,isEnumValueOrUndefined:()=>sy,isEven:()=>Py,isFalse:()=>ry,isFalseOrUndefined:()=>iy,isFinite:()=>nn,isFloat:()=>by,isFunction:()=>_r,isFunctionOrUndefined:()=>ny,isIncluded:()=>Gy,isIndex:()=>Vy,isInfinity:()=>Iy,isInteger:()=>kt,isIntegerBetween:()=>nl,isIntegerBetweenExclusive:()=>Sy,isIntegerEq:()=>Cy,isIntegerGt:()=>_y,isIntegerGte:()=>au,isIntegerLt:()=>vy,isIntegerLte:()=>wy,isIntegerOrUndefined:()=>Ay,isMultipleOf:()=>Fy,isNaNValue:()=>ol,isNeg:()=>Ry,isNegInfinity:()=>Ny,isNegZero:()=>Ly,isNonEmptyArray:()=>Ug,isNonEmptyArrayOrUndefined:()=>Yg,isNonEmptyString:()=>$g,isNonEmptyStringOrUndefined:()=>Qg,isNonNeg:()=>Ey,isNonNull:()=>jg,isNonPos:()=>My,isNull:()=>Dg,isNullish:()=>kg,isNumber:()=>Dt,isNumberBetween:()=>gy,isNumberBetweenExclusive:()=>yy,isNumberEq:()=>ly,isNumberGt:()=>dy,isNumberGte:()=>py,isNumberLt:()=>my,isNumberLte:()=>fy,isNumberOrUndefined:()=>hy,isNumericString:()=>ay,isObject:()=>Ii,isObjectOrUndefined:()=>Fg,isOdd:()=>jy,isPlainObject:()=>Bg,isPos:()=>Oy,isPosInfinity:()=>Ty,isPosZero:()=>ky,isPowerOfTwo:()=>By,isSafeInteger:()=>xy,isSafeNumber:()=>uy,isStrictEqual:()=>Mg,isString:()=>il,isStringOrUndefined:()=>Zg,isTrue:()=>ty,isTrueOrUndefined:()=>ey,isTypedObject:()=>Gg,isUndefined:()=>Eg,isZero:()=>Dy,tryOr:()=>Uy});var el={};er(el,{forEachEnum:()=>Rg,getEnumEntries:()=>rl,getEnumKey:()=>Og,getEnumKeys:()=>Gs,getEnumValues:()=>su});function Gs(i){return Object.keys(i).filter(t=>isNaN(Number(t)))}function su(i){return Gs(i).map(t=>i[t])}function rl(i){return Gs(i).map(t=>[t,i[t]])}function Og(i,t){return Gs(i).find(e=>i[e]===t)}function Rg(i,t){for(let[e,r]of rl(i))t(e,r)}function Mg(i,t){return i===t}function uo(i,t){return Bs(i,t)}function Eg(i){return i===void 0}function Dg(i){return i===null}function kg(i){return i==null}function Lg(i){return i!==void 0}function jg(i){return i!==null}function Ii(i){return typeof i=="object"&&i!==null&&!Le(i)}function Pg(i){return Ii(i)&&Object.keys(i).length===0}function Fg(i){return i===void 0||Ii(i)}function Bg(i){if(!Ii(i))return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function Gg(i,t){return Ii(i)&&t.every(e=>e in i)}function Vg(i){return i instanceof Set}function Le(i){return!!i&&Object.prototype.toString.call(i)==="[object Array]"}function qg(i){return i===void 0||Le(i)}function Wg(i){return Le(i)&&i.length===0}function Ug(i){return Le(i)&&i.length>0}function zg(i){return Le(i)&&i.length===0||i===void 0}function Yg(i){return Le(i)&&i.length>0||i===void 0}function il(i){return typeof i=="string"}function Hg(i){return typeof i=="string"&&i.length===0}function $g(i){return typeof i=="string"&&i.length>0}function Zg(i){return i===void 0||typeof i=="string"}function Xg(i){return typeof i=="string"&&i.length===0||i===void 0}function Qg(i){return typeof i=="string"&&i.length>0||i===void 0}function Kg(i){return typeof i=="boolean"}function Jg(i){return i===void 0||typeof i=="boolean"}function ty(i){return i===!0}function ey(i){return i===!0||i===void 0}function ry(i){return i===!1}function iy(i){return i===!1||i===void 0}function _r(i){return typeof i=="function"}function ny(i){return i===void 0||typeof i=="function"}function oy(i,t){return su(t).some(e=>e===i)}function sy(i,t){return i===void 0||su(t).some(e=>e===i)}function ay(i){if(typeof i!="string"||i.trim()==="")return!1;let t=+i;return Number.isFinite(t)}function cy(i){return typeof i=="bigint"}function Dt(i){return typeof i=="number"}function uy(i){return Dt(i)&&Number.isSafeInteger(i)}function hy(i){return typeof i=="number"||i===void 0}function ly(i,t){return Dt(i)&&i===t}function dy(i,t){return Dt(i)&&Dt(t)&&i>t}function py(i,t){return Dt(i)&&Dt(t)&&i>=t}function my(i,t){return Dt(i)&&Dt(t)&&i<t}function fy(i,t){return Dt(i)&&Dt(t)&&i<=t}function gy(i,t,e){return Dt(i)&&Dt(t)&&Dt(e)&&i>=t&&i<=e}function yy(i,t,e){return Dt(i)&&Dt(t)&&Dt(e)&&i>t&&i<e}function nn(i){return typeof i=="number"&&Number.isFinite(i)}function by(i){return nn(i)&&!kt(i)}function kt(i){return typeof i=="number"&&nn(i)&&i===Math.trunc(i)}function xy(i){return kt(i)&&Number.isSafeInteger(i)}function Ay(i){return typeof i=="number"&&nn(i)&&i===Math.trunc(i)||i===void 0}function Cy(i,t){return kt(i)&&i===t}function _y(i,t){return kt(i)&&Dt(t)&&i>t}function au(i,t){return kt(i)&&Dt(t)&&i>=t}function vy(i,t){return kt(i)&&Dt(t)&&i<t}function wy(i,t){return kt(i)&&Dt(t)&&i<=t}function nl(i,t,e){return kt(i)&&Dt(t)&&Dt(e)&&i>=t&&i<=e}function Sy(i,t,e){return kt(i)&&Dt(t)&&Dt(e)&&i>t&&i<e}function ol(i){return typeof i=="number"&&Number.isNaN(i)}function Iy(i){return i===1/0||i===-1/0}function Ty(i){return i===1/0}function Ny(i){return i===-1/0}function Oy(i){return typeof i=="number"&&i>0}function Ry(i){return typeof i=="number"&&i<0}function My(i){return typeof i=="number"&&i<=0}function Ey(i){return typeof i=="number"&&i>=0}function Dy(i){return typeof i=="number"&&i===0}function ky(i){return typeof i=="number"&&i===0&&1/i===1/0}function Ly(i){return typeof i=="number"&&i===0&&1/i===-1/0}function jy(i){return kt(i)&&Math.abs(i)%2===1}function Py(i){return kt(i)&&i%2===0}function Fy(i,t){return typeof i=="number"&&typeof t=="number"&&i%t===0}function By(i){return kt(i)&&i>0&&(i&i-1)===0}function Gy(i,t){return Le(t)?t.includes(i):Vg(t)?t.has(i):!1}function Vy(i,t){return Le(t)?nl(i,0,t.length-1):au(i,0)}function qy(i){try{return i(),!1}catch(t){return!0}}function Wy(i){try{return i(),!0}catch(t){return!1}}function Uy(i,t){try{return i()}catch(e){return _r(t)?t():t}}function zy(i,t){return Ii(i)&&t.every(e=>e in i)}function Bs(i,t){if(i===t)return!0;if(i===null||t===null||typeof i!="object"||typeof t!="object")return!1;if(Array.isArray(i)&&Array.isArray(t))return i.length!==t.length?!1:i.every((n,o)=>Bs(n,t[o]));if(Array.isArray(i)!==Array.isArray(t))return!1;let e=Object.keys(i),r=Object.keys(t);if(e.length!==r.length)return!1;for(let n of e)if(!Object.prototype.hasOwnProperty.call(t,n)||!Bs(i[n],t[n]))return!1;return!0}function sl(i){return i===null?"null":Le(i)?"Array":typeof i!="object"?typeof i:Object.prototype.toString.call(i).slice(8,-1)||"Object"}function Yy(i){return i.split("")}function Hy(i,t){if(!kt(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(i)}function $y(i,t){if(!kt(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e}function cu(i,t,e,r){if(!kt(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!kt(t)||t<0||t+e>i.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+i.length);return i.substring(0,t)+r+i.substring(t+e)}function Zy(i,t,e){return cu(i,t,0,e)}function Xy(i,t,e){return cu(i,t,e,"")}function Qy(i,t){if(t.length!==1||i.length===0)return 0;let e=0;for(let r=0;r<i.length;r++)i[r]===t&&e++;return e}function Ky(i){if(i==="")return"";let t=i.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},n=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<i.length;o++){let s=i.charAt(o);n(s)&&r(),t+=s.toLowerCase()}return r(),e}function Bt(i,t=5,e=new WeakSet){if(i===null)return"null";if(i===void 0)return"undefined";let r=typeof i;switch(r){case"boolean":return i?"true":"false";case"number":return ol(i)?"NaN":nn(i)?i.toString():i<0?"-Infinity":"Infinity";case"bigint":return`${i}n`;case"string":return`"${i}"`;case"symbol":return i.description?`Symbol(${i.description})`:"Symbol()";case"function":return`[Function${i.name?` ${i.name}`:""}]`}if(e.has(i))return"[Circular]";if(t<=0)return"[Depth limit]";t--,e.add(i);let n=s=>Bt(s,t,e);if(Le(i)){let s=i.map(a=>n(a)).join(", ");return s.length===0?"[ ]":`[ ${s} ]`}if(ArrayBuffer.isView(i)){if(i instanceof DataView)return`DataView(${i.byteLength})`;let s=Array.from(i).map(a=>n(a)).join(", ");return`${i.constructor.name}[ ${s} ]`}if(i instanceof ArrayBuffer)return`ArrayBuffer(${i.byteLength})`;if(i instanceof Map){let s=Array.from(i.entries()).map(([a,c])=>`${n(a)} => ${n(c)}`).join(", ");return s.length===0?`Map(${i.size}){ }`:`Map(${i.size}){ ${s} }`}if(i instanceof Set){let s=Array.from(i.values()).map(a=>n(a)).join(", ");return s.length===0?`Set(${i.size}){ }`:`Set(${i.size}){ ${s} }`}if(i instanceof WeakMap)return"WeakMap{ ? }";if(i instanceof WeakSet)return"WeakSet{ ? }";if(i instanceof Date)return`Date("${i.toISOString()}")`;if(i instanceof RegExp)return i.toString();if(i instanceof Error)return`${i.name}("${i.message}")`;if(i instanceof Promise)return"Promise{ ? }";if(i instanceof URL)return`URL("${i.href}")`;if(i instanceof URLSearchParams)return`URLSearchParams("${i.toString()}")`;if(i===Math)return"Math";if(i===JSON)return"JSON";if(i===Reflect)return"Reflect";if(i===Intl)return"Intl";if(typeof(i==null?void 0:i.toString)=="function"&&i.toString!==Object.prototype.toString)try{let s=i.toString();if(!/^\[object .+\]$/.test(s))return s}catch(s){}if(r==="object"){let s=sl(i),a=Object.entries(i).map(([c,u])=>`${n(c)}: ${n(u)}`);return a.length===0?`${s}{ }`:`${s}{ ${a.join(", ")} }`}return String(i)}function Jy(i){return i.split(/(?=[A-Z])/).filter(t=>!!t)}function al(i,...t){if(t.length===0)return[i];let e=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(e.join("|"),"g");return i.split(r)}function tb(i,t){return al(i,...t.split(""))}var L=Bt,cl=Error;function eb(i){cl=i!=null?i:Error}function V(...i){let t=i.join(", ");throw new cl("Assertion Failed!"+(t===""?"":" "+t))}function rb(i,t){i||V(t)}function ib(i,t){return i==null&&V(`Expected ${L(i)} not to be nullish`,t),i}function nb(i,t){return i===void 0&&V(`Expected ${L(i)} not to be undefined`,t),i}function ob(i,t,e){return y.isIndex(i,t)||V(`Expected ${i} to be index for array ${L(t)}`,e),t[i]}function sb(i){V(i)}function ab(i,t,e){return y.isStrictEqual(i,t)||V(`Expected ${L(i)} to ne strict equal to ${t}`,e),i}function cb(i,t,e){return y.isDeepEqual(i,t)||V(`Expected ${L(i)} to deep equal with ${L(t)}`,e),i}function ub(i,t){return y.isUndefined(i)||V(`Expected ${L(i)} to be undefined`,t),i}function hb(i,t){return y.isNull(i)||V(`Expected ${L(i)} to be null`,t),i}function lb(i,t){return y.isNullish(i)||V(`Expected ${L(i)} to be null or undefined`,t),i}function db(i,t){return y.isDefined(i)||V(`Expected ${L(i)} to be defined`,t),i}function pb(i,t){return y.isNonNull(i)||V(`Expected ${L(i)} to be defined`,t),i}function mb(i,t){return y.isObject(i)||V(`Expected ${L(i)} to be object`,t),i}function fb(i,t){return y.isEmptyObject(i)||V(`Expected ${L(i)} to be empty object`,t),i}function gb(i,t){return y.isPlainObject(i)||V(`Expected ${L(i)} to be plain object`,t),i}function yb(i,t){return y.isObjectOrUndefined(i)||V(`Expected ${L(i)} to be object or undefined`,t),i}function bb(i,t,e){return y.isTypedObject(i,t)||V(`Expected ${L(i)} to have keys ${L(t)}`,e),i}function xb(i,t){return y.isArray(i)||V(`Expected ${L(i)} to be array`,t),i}function Ab(i,t){return y.isArrayOrUndefined(i)||V(`Expected ${L(i)} to be array or undefined`,t),!0}function Cb(i,t){y.isEmptyArray(i)||V(`Expected ${L(i)} to be empty array`,t)}function _b(i,t){y.isNonEmptyArray(i)||V(`Expected ${L(i)} to be non-empty array`,t)}function vb(i,t){y.isEmptyArrayOrUndefined(i)||V(`Expected ${L(i)} to be empty array or undefined`,t)}function wb(i,t){y.isNonEmptyArrayOrUndefined(i)||V(`Expected ${L(i)} to be non-empty array or undefined`,t)}function Sb(i,t){return y.isString(i)||V(`Expected ${L(i)} to be string`,t),i}function Ib(i,t){return y.isEmptyString(i)||V(`Expected ${L(i)} to be empty string`,t),i}function Tb(i,t){return y.isNonEmptyString(i)||V(`Expected ${L(i)} to be non-empty string`,t),i}function Nb(i,t){return y.isStringOrUndefined(i)||V(`Expected ${L(i)} to be string or undefined`,t),i}function Ob(i,t){return y.isEmptyStringOrUndefined(i)||V(`Expected ${L(i)} to be empty string or undefined`,t),i}function Rb(i,t){return y.isNonEmptyStringOrUndefined(i)||V(`Expected ${L(i)} to be non-empty string or undefined`,t),i}function Mb(i,t){return y.isBoolean(i)||V(`Expected ${L(i)} to be boolean`,t),i}function Eb(i,t){return y.isBooleanOrUndefined(i)||V(`Expected ${L(i)} to be boolean or undefined`,t),i}function Db(i,t){return y.isTrue(i)||V(`Expected ${L(i)} to be true`,t),i}function kb(i,t){return y.isTrueOrUndefined(i)||V(`Expected ${L(i)} to be true or undefined`,t),i}function Lb(i,t){return y.isFalse(i)||V(`Expected ${L(i)} to be false`,t),i}function jb(i,t){return y.isFalseOrUndefined(i)||V(`Expected ${L(i)} to be false or undefined`,t),i}function Pb(i,t){return y.isFunction(i)||V(`Expected ${L(i)} to be function`,t),i}function Fb(i,t){return y.isFunctionOrUndefined(i)||V(`Expected ${L(i)} to be function or undefined`,t),i}function Bb(i,t,e){return y.isEnumValue(i,t)||V(`Expected ${L(i)} to be enum val`,e),i}function Gb(i,t,e){return y.isEnumValueOrUndefined(i,t)||V(`Expected ${L(i)} to be enum val or undefined`,e),i}function Vb(i,t){return y.isNumericString(i)||V(`Expected ${L(i)} to be numeric string`,t),i}function qb(i,t){return y.isBigInt(i)||V(`Expected ${L(i)} to be BigInt`,t),i}function Wb(i,t){return y.isNumber(i)||V(`Expected ${L(i)} to be number`,t),i}function Ub(i,t){return y.isSafeNumber(i)||V(`Expected ${L(i)} to be safe number`,t),i}function zb(i,t){return y.isNumberOrUndefined(i)||V(`Expected ${L(i)} to be number or undefined`,t),i}function Yb(i,t,e){return y.isNumberEq(i,t)||V(`Expected ${L(i)} to be number equal to ${L(t)}`,e),i}function Hb(i,t,e){return y.isNumberGt(i,t)||V(`Expected ${L(i)} to be number > ${L(t)}`,e),i}function $b(i,t,e){return y.isNumberGte(i,t)||V(`Expected ${L(i)} to be number >= ${L(t)}`,e),i}function Zb(i,t,e){return y.isNumberLt(i,t)||V(`Expected ${L(i)} to be number < ${L(t)}`,e),i}function Xb(i,t,e){return y.isNumberLte(i,t)||V(`Expected ${L(i)} to be number <= ${L(t)}`,e),i}function Qb(i,t,e,r){return y.isNumberBetween(i,t,e)||V(`Expected number ${L(t)} <= ${L(i)} <= ${L(e)}`,r),i}function Kb(i,t,e,r){return y.isNumberBetweenExclusive(i,t,e)||V(`Expected number ${L(t)} < ${L(i)} < ${L(e)}`,r),i}function Jb(i,t){return y.isFinite(i)||V(`Expected ${L(i)} to be finite`,t),i}function tx(i,t){return y.isFloat(i)||V(`Expected ${L(i)} to be float`,t),i}function ex(i,t){return y.isInteger(i)||V(`Expected ${L(i)} to be integer`,t),i}function rx(i,t){return y.isSafeInteger(i)||V(`Expected ${L(i)} to be safe integer`,t),i}function ix(i,t){return y.isIntegerOrUndefined(i)||V(`Expected ${L(i)} to be integer or undefined`,t),i}function nx(i,t,e){return y.isIntegerEq(i,t)||V(`Expected ${L(i)} to be integer equal to ${L(t)}`,e),i}function ox(i,t,e){return y.isIntegerGt(i,t)||V(`Expected ${L(i)} to be integer > ${L(t)}`,e),i}function sx(i,t,e){return y.isIntegerGte(i,t)||V(`Expected ${L(i)} to be integer >= ${L(t)}`,e),i}function ax(i,t,e){return y.isIntegerLt(i,t)||V(`Expected ${L(i)} to be integer < ${L(t)}`,e),i}function cx(i,t,e){return y.isIntegerLte(i,t)||V(`Expected ${L(i)} to be integer <= ${L(t)}`,e),i}function ux(i,t,e,r){return y.isIntegerBetween(i,t,e)||V(`Expected integer ${L(t)} <= ${L(i)} <= ${L(e)}`,r),i}function hx(i,t,e,r){return y.isIntegerBetweenExclusive(i,t,e)||V(`Expected integer ${L(t)} < ${L(i)} < ${L(e)}`,r),i}function lx(i,t){return y.isNaNValue(i)||V(`Expected ${L(i)} to be NaN`,t),NaN}function dx(i,t){return y.isInfinity(i)||V(`Expected ${L(i)} to be +-Infinity`,t),i}function px(i,t){return y.isPosInfinity(i)||V(`Expected ${L(i)} to be +Infinity`,t),i}function mx(i,t){return y.isNegInfinity(i)||V(`Expected ${L(i)} to be -Infinity`,t),i}function fx(i,t){return y.isPos(i)||V(`Expected ${L(i)} to be positive (> 0)`,t),i}function gx(i,t){return y.isNeg(i)||V(`Expected ${L(i)} to be negative (< 0)`,t),i}function yx(i,t){return y.isNonPos(i)||V(`Expected ${L(i)} to be non-positive (<= 0)`,t),i}function bx(i,t){return y.isNonNeg(i)||V(`Expected ${L(i)} to be non-negative (>= 0)`,t),i}function xx(i,t){return y.isZero(i)||V(`Expected ${L(i)} to be 0`,t),i}function Ax(i,t){return y.isPosZero(i)||V(`Expected ${L(i)} to be +0`,t),i}function Cx(i,t){return y.isNegZero(i)||V(`Expected ${L(i)} to be -0`,t),i}function _x(i,t){return y.isOdd(i)||V(`Expected ${L(i)} to odd`,t),i}function vx(i,t){return y.isEven(i)||V(`Expected ${L(i)} to even`,t),i}function wx(i,t,e){return y.isMultipleOf(i,t)||V(`Expected ${L(i)} to be divisble bu ${L(t)}`,e),i}function Sx(i,t){return y.isPowerOfTwo(i)||V(`Expected ${L(i)} to be power of two`,t),i}function Ix(i,t,e){return y.isIncluded(i,t)||V(`Expected ${L(i)} to be included in ${L(t)}`,e),i}function Tx(...i){let t=i.shift(),e=y.isString(i[i.length-1])?i.pop():void 0,r=y.isArray(i[0])?i.shift():void 0;return y.isIndex(t,r)||V(r===void 0?`Expected ${t} to be index`:`Expected ${t} to be index for ${L(r)}`,e),t}function Nx(i,t){return y.doesThrow(i)||V("Expected to throw",t),!0}function Ox(i,t){return y.doesNotThrow(i)||V("Expected to throw",t),!0}var Rx={};er(Rx,{accept:()=>Lx,decline:()=>jx,erase:()=>ul,eraseAll:()=>Vx,isConsentPending:()=>kx,read:()=>Fx,readBool:()=>Gx,readInt:()=>Bx,save:()=>Px,setExpireDays:()=>Dx});var Vs="ConsentCookie",tr,co,nu=qs(Vs);tr=nu==="accept"||nu==="decline"?nu:void 0;function Mx(){return typeof document=="undefined"?[]:document.cookie.split(";").map(t=>t.trim())}function uu(i,t){let e=i+"="+t.toString()+";sameSite=Lax;";return co&&(e+="expires="+co.toUTCString()+";"),typeof document!="undefined"&&(document.cookie=e),t}function qs(i,t){let e=Mx().find(r=>r.startsWith(i+"="));return e===void 0?t:e.substring(i.length+1)}function Ex(i){typeof document!="undefined"&&(document.cookie=i+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;")}function Dx(i){co=new Date,co.setDate(co.getDate()+i)}function kx(){return tr===void 0}function Lx(){tr="accept",uu(Vs,tr)}function jx(){tr="decline",uu(Vs,tr)}function Px(i,t){return tr==="accept"&&uu(i,t),t}function Fx(i,t){var e;return tr==="accept"&&(e=qs(i,t))!=null?e:t}function Bx(i,t){if(tr==="accept"){let e=qs(i);return e===void 0?t:parseInt(e)}else return t}function Gx(i,t){if(tr==="accept"){let e=qs(i);return e===void 0?t:/true|1/i.test(e)}else return t}function ul(i){(tr==="accept"||i===Vs)&&Ex(i)}function Vx(){typeof document!="undefined"&&document.cookie.split(";").forEach(i=>ul(i.trim().split("=")[0]))}var Ws={};er(Ws,{DPI:()=>hl,FontSize:()=>ll,HostAddress:()=>Jx,IsMobileDevice:()=>Kx,IsTouchDevice:()=>Qx,PxPerMm:()=>hu,ScrollbarWidth:()=>Xx,mmToPx:()=>js,pxToMm:()=>tA,toPx:()=>eA});function qx(){try{let i=document.createElement("div");i.style.width="1in",document.body.appendChild(i);let t=i.offsetWidth;return i.remove(),t||96}catch(i){return 96}}function Wx(){try{let i=document.createElement("div");i.style.visibility="hidden",i.style.width="100px",document.body.appendChild(i);let t=i.offsetWidth;i.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",i.appendChild(e);let r=e.offsetWidth;return i.parentNode&&i.parentNode.removeChild(i),t-r}catch(i){return 0}}function Ux(){try{let i=document.createElement("div");i.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",i.appendChild(document.createTextNode("M")),document.body.appendChild(i);let t=i.offsetHeight;return document.body.removeChild(i),t}catch(i){return 16}}function zx(){if(typeof window=="undefined")return!1;if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var i=" -webkit- -moz- -o- -ms- ".split(" "),t=function(r){return window.matchMedia(r).matches},e=["(",i.join("touch-enabled),("),"heartz",")"].join("");return t(e)}function Yx(){let i=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(i)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(i.substr(0,4))}function Hx(){return typeof location=="undefined"||!location.host?"localhost":`${location.protocol}//${location.host}`}var $x=/^(mm|cm|in|inch|px|em)$/,Zx=/^([0-9\\.]+)(.*)$/,hl=qx(),hu=hl/25.4,Xx=Wx(),ll=Ux(),Qx=zx(),Kx=Yx(),Jx=Hx();function tA(i){return i/hu}function js(i){return i*hu}function eA(i){if(typeof i=="number")return i;let t=NaN,e,r=i.toString().match(Zx);if(r&&r[1]){t=parseFloat(r[1]);let n=r[2]?r[2].toLowerCase():"undefined";e=$x.test(n)?n:void 0,e||console.log("Unknown unit '"+n+"' => using 'px'.")}else t=parseFloat(i);switch(Kh.isFinite(t,"value in function toPx"),e){case"mm":return js(t);case"cm":return js(t)*10;case"in":case"inch":return js(t)*25.4;case"em":return ll*t;default:case"px":return t}}var H={};er(H,{Arr:()=>dl,Dom:()=>fl,Enum:()=>el,Math:()=>yl,Obj:()=>tl,Str:()=>Jh});var dl={};er(dl,{arrayContains:()=>cA,chunckArray:()=>uA,duplicate:()=>iA,fillArray:()=>oA,getRangeArray:()=>aA,getSequenceArray:()=>sA,isArray:()=>Le,mapRangeArray:()=>ml,mapSequenceArray:()=>pl,removeDuplicates:()=>nA,toArray:()=>rA});function rA(i){return Le(i)?i:[i]}function iA(i){var t;return(t=i==null?void 0:i.slice())!=null?t:[]}function nA(i,t){return t!==void 0?i.filter((e,r,n)=>r===n.findIndex(o=>t(e,o))):i.filter((e,r,n)=>r===n.indexOf(e))}function oA(i,t){if(!kt(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(i)}function pl(i,t){if(!kt(i)||i<0)throw new Error("mapSequenceArray: Invalid len = "+i);let e=new Array(i);for(let r=0;r<i;r++)e[r]=t(r);return e}function sA(i){return pl(i,t=>t)}function ml(i,t,e){if(!kt(i))throw new Error("mapRangeArray: Invalid start = "+t);if(!kt(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-i)+1,n=new Array(r);for(let o=0,s=i,a=Math.sign(t-i);o<r;s+=a,o++)n[o]=e(s);return n}function aA(i,t){return ml(i,t,e=>e)}function cA(i,t){return i.indexOf(t)>=0}function uA(i,t){if(!kt(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e}var fl={};er(fl,{addClass:()=>hA,appendTo:()=>bA,getButton:()=>_A,getCanvas:()=>vA,getCanvasTextWidth:()=>TA,getDimension:()=>SA,getHeight:()=>gA,getOffset:()=>pA,getPadding:()=>wA,getWidth:()=>mA,hasClass:()=>lu,injectCss:()=>NA,removeClass:()=>lA,removeFromParent:()=>xA,setHeight:()=>yA,setOffset:()=>dA,setRect:()=>CA,setVisibility:()=>AA,setWidth:()=>fA,styleLayoutChanged:()=>IA});function gl(i){var t;return typeof document=="undefined"?void 0:(t=document.getElementById(i))!=null?t:void 0}function Et(i){return i===void 0?void 0:Ws.toPx(i)}function lu(i,t){return t.length===0?!1:i.classList?i.classList.contains(t):!!i.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function hA(i,t){t.length!==0&&(i.classList?i.classList.add(t):lu(i,t)||(i.className+=" "+t))}function lA(i,t){if(t.length!==0){if(i.classList)i.classList.remove(t);else if(lu(i,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");i.className=i.className.replace(e," ")}}}function dA(i,t,e,r="px"){i.style.left=t+r,i.style.top=e+r}function pA(i){let{left:t,top:e}=i.getBoundingClientRect();if(typeof window!="undefined"&&(t+=window.pageXOffset,e+=window.pageYOffset),typeof document!="undefined"){let r=document.documentElement;t-=r.clientLeft,e-=r.clientTop}return{left:t,top:e}}function mA(i){if(i instanceof Window)return i.innerWidth;{let t=parseFloat(getComputedStyle(i,null).width.replace("px",""));return isNaN(t)?0:t}}function fA(i,t){i.style.width=t+"px"}function gA(i){if(i instanceof Window)return i.innerHeight;{let t=parseFloat(getComputedStyle(i,null).height.replace("px",""));return isNaN(t)?0:t}}function yA(i,t){i.style.height=t+"px"}function bA(i,t){t.appendChild(i)}function xA(i){i.remove()}function AA(i,t){i.style.display=t?"block":"none"}function CA(i,t,e,r,n,o="px"){i.style.left=t+o,i.style.top=e+o,i.style.width=r+o,i.style.height=n+o}function _A(i){let t=typeof i=="string"?gl(i):i;return t instanceof HTMLButtonElement?t:void 0}function vA(i){let t=typeof i=="string"?gl(i):i;return t instanceof HTMLCanvasElement?t:void 0}function wA(i){var s;if(!i)return{top:0,right:0,bottom:0,left:0};let t=Et(i.paddingTop),e=Et(i.paddingRight),r=Et(i.paddingBottom),n=Et(i.paddingLeft),o=((s=i.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[0])),r!=null||(r=Et(o[0])),n!=null||(n=Et(o[0]));break;case 2:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[1])),r!=null||(r=Et(o[0])),n!=null||(n=Et(o[1]));break;case 3:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[1])),r!=null||(r=Et(o[2])),n!=null||(n=Et(o[1]));break;case 4:default:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[1])),r!=null||(r=Et(o[2])),n!=null||(n=Et(o[3]));break}return t!=null||(t=0),e!=null||(e=0),r!=null||(r=0),n!=null||(n=0),{top:t,right:e,bottom:r,left:n}}function SA(i){let t=Et(i==null?void 0:i.left),e=Et(i==null?void 0:i.right),r=Et(i==null?void 0:i.top),n=Et(i==null?void 0:i.bottom),o=Et(i==null?void 0:i.width),s=Et(i==null?void 0:i.height);return o===void 0&&t!==void 0&&e!==void 0&&(o=e-t),s===void 0&&r!==void 0&&n!==void 0&&(s=n-r),{left:t,top:r,width:o,height:s}}function IA(i,t){return!i&&!t?!1:!i||!t?!0:i.left!==t.left||i.top!==t.top||i.right!==t.right||i.bottom!==t.bottom||i.width!==t.width||i.height!==t.height}var so;function TA(i,t){!so&&typeof document!="undefined"&&(so=document.createElement("canvas"));let e=so==null?void 0:so.getContext("2d");return e?(e.font=t,e.measureText(i).width):0}function NA(i,t){if(i===""||t===""||typeof document=="undefined"||document.getElementById(i))return;let e=document.createElement("style");e.id=i,e.textContent=t,document.head.appendChild(e)}var yl={};er(yl,{avg:()=>jA,calcNormal:()=>LA,clamp:()=>ou,cmp:()=>PA,interpolateCoord:()=>DA,interpolateY:()=>kA,isInteger:()=>kt,isNumber:()=>Dt,linearToDecibels:()=>OA,mod:()=>RA,romanize:()=>MA,sum:()=>bl,toOrdinalNumber:()=>EA});function OA(i){if(isFinite(i))return i<=0?-1/0:20*Math.log10(i);throw new Error("linearToDecibel: Invalid linearVolume = "+i)}function RA(i,t){return(i%t+t)%t}function MA(i){if(!kt(i)||i<0)throw new Error("romanize: Invalid n = "+i);for(var t=String(+i).split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",n=3;n--;)r=(e[+t.pop()+n*10]||"")+r;return Array(+t.join("")+1).join("M")+r}function EA(i){if(!kt(i))throw new Error("toOrdinalNumber: Invalid n = "+i);let t=i.toString(),e=Number(t.charAt(t.length-1));return i===1||i>=20&&e===1?t+"st":i===2||i>=20&&e===2?t+"nd":i===3||i>=20&&e===3?t+"rd":t+"th"}function DA(i,t,e,r,n){return{x:i+(e-i)*n,y:t+(r-t)*n}}function kA(i,t,e,r,n){let o=(n-i)/(e-i);return t+(r-t)*o}function ou(i,t,e){return Math.min(Math.max(i,t),e)}function LA(i,t,e,r){let n=e-i,s=-(r-t),a=n,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function bl(i){return i.reduce((t,e)=>e+t,0)}function jA(...i){return bl(i)/i.length}function PA(i,t){return i<t?-1:i>t?1:0}var ke=(i,t)=>i===t,jr=class{};var xl=class qe extends jr{constructor(...t){if(super(),mt(this,"coords"),t.length<2)throw new TypeError("Vec needs minumum two coords!");this.coords=t}static vec2(t,e){return new qe(t,e)}static vec3(t,e,r){return new qe(t,e,r)}static zero(t){if(t<2)throw new TypeError("Vec.zero requires dimension >= 2");return new qe(...Array(t).fill(0))}get dim(){return this.coords.length}get length(){return Math.hypot(...this.coords)}magnitude(){return this.length}get x(){return this.coords[0]}get y(){return this.coords[1]}get z(){if(this.coords[2]===void 0)throw new TypeError("Vec z-coord not available!");return this.coords[2]}add(...t){let e=t[0]instanceof qe?t[0].coords:t;if(this.coords.length!==e.length)throw new TypeError("Coordinate length mismatch!");return new qe(...this.coords.map((r,n)=>r+e[n]))}sub(...t){let e=t[0]instanceof qe?t[0].coords:t;if(this.coords.length!==e.length)throw new TypeError("Coordinate length mismatch!");return new qe(...this.coords.map((r,n)=>r-e[n]))}mul(t){return new qe(...this.coords.map(e=>e*t))}div(t){return new qe(...this.coords.map(e=>e/t))}dot(t){if(this.coords.length!==t.coords.length)throw new TypeError("Coordinate length mismatch!");return this.coords.reduce((e,r,n)=>e+r*t.coords[n],0)}distance(t){if(this.coords.length!==t.coords.length)throw new TypeError("Coordinate length mismatch!");return Math.hypot(...this.coords.map((e,r)=>e-t.coords[r]))}normalize(){let t=this.length;if(t===0)throw new TypeError("Cannot normalize zero-length vector!");return this.div(t)}static lerp(t,e,r){if(t.coords.length!==e.coords.length)throw new TypeError("Coordinate length mismatch!");if(!nn(r))throw new TypeError("Lerp t is not finite!");return t.add(e.sub(t).mul(r))}toLength(t){let e=this.length;return e===0?this:this.mul(t/e)}clamp(t,e,r){let n=this.length;if(n===0){if(t!==void 0){if(r&&r.coords.length!==this.coords.length)throw new TypeError("Coordinate length mismatch!");return(r&&r.length!==0?r.normalize():new qe(1,...Array(this.coords.length-1).fill(0))).mul(t)}return this}return e!==void 0&&n>e?this.normalize().mul(e):t!==void 0&&n<t?this.normalize().mul(t):this}equals(t){return this.coords.length===t.coords.length&&this.coords.every((e,r)=>e===t.coords[r])}clone(){return new qe(...this.coords)}toObject(){return{x:this.x,y:this.y,z:this.z}}[Symbol.iterator](){return this.coords[Symbol.iterator]()}toString(){return`Vec(${this.coords.join(", ")})`}},du=class Se{constructor(...t){if(mt(this,"x"),mt(this,"y"),mt(this,"width"),mt(this,"height"),t.length===0?this.x=this.y=this.width=this.height=0:t.length===2?(this.x=this.y=0,this.width=t[0],this.height=t[1]):(this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]),this.width<0||this.height<0)throw new Error("Rect width and height must be non-negative.")}set(...t){if(t.length===0?this.x=this.y=this.width=this.height=0:t.length===2?(this.x=this.y=0,this.width=t[0],this.height=t[1]):(this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]),this.width<0||this.height<0)throw new Error("Rect width and height must be non-negative.");return this}static fromPoints(t,e){let r=Math.min(t.x,e.x),n=Math.min(t.y,e.y),o=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return new Se(r,n,o,s)}static fromCenter(t,e,r,n){return new Se(t-r/2,e-n/2,r,n)}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get center(){return{x:this.centerX,y:this.centerY}}get area(){return this.width*this.height}get isEmpty(){return this.width<=0||this.height<=0}containsPoint(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}containsRect(t){return t.left>=this.left&&t.right<=this.right&&t.top>=this.top&&t.bottom<=this.bottom}intersects(t){return!(t.right<this.left||t.left>this.right||t.bottom<this.top||t.top>this.bottom)}intersectionCopy(t){let e=Math.max(this.left,t.left),r=Math.max(this.top,t.top),n=Math.min(this.right,t.right),o=Math.min(this.bottom,t.bottom);return n<=e||o<=r?new Se:new Se(e,r,n-e,o-r)}unionCopy(t){let e=Math.min(this.left,t.left),r=Math.min(this.top,t.top),n=Math.max(this.right,t.right),o=Math.max(this.bottom,t.bottom);return new Se(e,r,n-e,o-r)}insetCopy(t,e){return new Se(this.x+t,this.y+e,this.width-2*t,this.height-2*e)}inflateCopy(t,e){return new Se(this.x-t,this.y-e,this.width+2*t,this.height+2*e)}offsetInPlace(t,e){return this.x+=t,this.y+=e,this}offsetCopy(t,e){return new Se(this.x+t,this.y+e,this.width,this.height)}scaleInPlace(t,e=t){return this.x=this.centerX-this.width*t/2,this.width*=t,this.y=this.centerY-this.height*e/2,this.height*=e,this}scaleCopy(t,e=t){return this.clone().scaleInPlace(t,e)}roundCopy(){let t=Math.round(this.left),e=Math.round(this.top),r=Math.round(this.right),n=Math.round(this.bottom);return new Se(t,e,r-t,n-e)}floorCopy(){let t=Math.floor(this.left),e=Math.floor(this.top),r=Math.floor(this.right),n=Math.floor(this.bottom);return new Se(t,e,r-t,n-e)}ceilCopy(){let t=Math.ceil(this.left),e=Math.ceil(this.top),r=Math.ceil(this.right),n=Math.ceil(this.bottom);return new Se(t,e,r-t,n-e)}expandCopy(t,e){let r=Math.min(this.left,t),n=Math.min(this.top,e),o=Math.max(this.right,t),s=Math.max(this.bottom,e);return new Se(r,n,o-r,s-n)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new Se(this.x,this.y,this.width,this.height)}toString(){return`Rect(x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height})`}toAnchoredRect(){return new G(this.left,this.right,this.top,this.bottom)}},G=class wi{constructor(...t){if(mt(this,"left"),mt(this,"anchorX"),mt(this,"right"),mt(this,"top"),mt(this,"anchorY"),mt(this,"bottom"),t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid AnchoredRect args: ${t}`)}set(...t){if(t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid AnchoredRect args: ${t}`);return this}static create(t,e,r,n){return new wi(t,t+r,e,e+n)}static createCentered(t,e,r,n){return new wi(t-r/2,t,t+r/2,e-n/2,e,e+n/2)}static createSections(t,e,r,n){return new wi(-t,0,e,-r,0,n)}get centerX(){return this.left+this.width/2}get centerY(){return this.top+this.height/2}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.anchorX-this.left}get rightw(){return this.right-this.anchorX}get toph(){return this.anchorY-this.top}get bottomh(){return this.bottom-this.anchorY}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.anchorX===e.anchorX&&t.right===e.right&&t.top===e.top&&t.anchorY===e.anchorY&&t.bottom===e.bottom}equals(t){return wi.equals(this,t)}static equalsEdges(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}equalsEdges(t){return wi.equalsEdges(this,t)}clone(){return new wi(this.left,this.anchorX,this.right,this.top,this.anchorY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.anchorX+=t,this.right+=t,this.top+=e,this.anchorY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.clone().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.clone().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.anchorX=ou(this.anchorX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.anchorY=ou(this.anchorY,this.top,this.bottom),this}clipCopy(t){return this.clone().clipInPlace(t)}scaleInPlace(t,e=t){return this.left=this.anchorX-this.leftw*t,this.right=this.anchorX+this.rightw*t,this.top=this.anchorY-this.toph*e,this.bottom=this.anchorY+this.bottomh*e,this}scaleCopy(t,e=t){return this.clone().scaleInPlace(t,e)}getRect(){return this}toRect(){return new du(this.left,this.right,this.width,this.height)}toString(){return`Rect(left=${this.left}, anchorX=${this.anchorX}, right=${this.right}, top=${this.top}, anchorY=${this.anchorY}, bottom=${this.bottom})`}},Al=class extends jr{constructor(i,t=1/0){super(),mt(this,"cache"),mt(this,"next"),mt(this,"prev"),mt(this,"head"),mt(this,"tail"),mt(this,"capacity"),mt(this,"size"),mt(this,"maxKeyLength"),this.cache=Object.create(null),this.next=Object.create(null),this.prev=Object.create(null),this.head=null,this.tail=null,this.capacity=i,this.size=0,this.maxKeyLength=t}get(i){if(!(i.length>this.maxKeyLength)&&this.cache[i]!==void 0)return this.touch(i),this.cache[i]}set(i,t){if(!(i.length>this.maxKeyLength)){if(this.cache[i]!==void 0){this.cache[i]=t,this.touch(i);return}this.size>=this.capacity&&this.evict(),this.cache[i]=t,this.addToTail(i),this.size++}}touch(i){this.tail!==i&&(this.removeKey(i),this.addToTail(i))}evict(){if(this.head!==null){let i=this.head;this.removeKey(i),delete this.cache[i],this.size--}}removeKey(i){let t=this.prev[i],e=this.next[i];t!==void 0?this.next[t]=e:this.head=e!=null?e:null,e!==void 0?this.prev[e]=t:this.tail=t!=null?t:null,delete this.prev[i],delete this.next[i]}addToTail(i){this.tail!==null?(this.next[this.tail]=i,this.prev[i]=this.tail):this.head=i,this.tail=i}*keys(){for(let i=this.head;i!=null;i=this.next[i])yield i}*values(){for(let i=this.head;i!=null;i=this.next[i])yield this.cache[i]}*entries(){for(let i=this.head;i!=null;i=this.next[i])yield[i,this.cache[i]]}*[Symbol.iterator](){yield*de(this.entries())}toString(){let i=[...this.entries()];return i.length===0?"LRUCache(0){ }":`LRUCache(${i.length}){ ${i.map(t=>`${Bt(t[0])}: ${Bt(t[1])}`).join(", ")} }`}},vr=class Jr extends jr{constructor(t){if(super(),mt(this,"posVal"),mt(this,"hasPos"),mt(this,"valCount"),t instanceof Jr)this.posVal=t.posVal.slice(),this.hasPos=t.hasPos.slice(),this.valCount=t.valCount;else if(this.posVal=[],this.hasPos=[],this.valCount=0,t)for(let[e,r]of t)this.set(e,r)}static validateIndex(t){if(!au(t,0))throw new Error(`Invalid index ${t} - must be an integer >= 0!`);return t}get posLen(){return this.hasPos.length}get size(){return this.valCount}get length(){return this.hasPos.length}trimRight(){let t=this.length;for(;t>0&&this.hasPos[t-1]!==!0;)t--;t<this.length&&(this.posVal.length=this.hasPos.length=t)}isEmpty(){return this.size===0}has(t){return Jr.validateIndex(t),this.hasPos[t]===!0}set(t,e){Jr.validateIndex(t),this.hasPos[t]!==!0&&this.valCount++,this.posVal[t]=e,this.hasPos[t]=!0}get(t){return Jr.validateIndex(t),this.hasPos[t]?this.posVal[t]:void 0}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){return Jr.validateIndex(t),this.hasPos[t]?(this.posVal[t]=void 0,this.hasPos[t]=!1,this.valCount--,this.trimRight(),!0):!1}clear(){this.posVal=[],this.hasPos=[],this.valCount=0}forEach(t,e){for(let[r,n]of this.entries())t.call(e,n,r,this)}*indices(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield t)}*values(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield this.posVal[t])}*entries(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield[t,this.posVal[t]])}indicesArray(){return[...this.indices()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.indices())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Jr(this)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.entries())if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.entries())if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.entries())t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty IndexArray with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapToArray(t){let e=[];for(let[r,n]of this.entries())e.push(t(n,r));return e}map(t){let e=new Jr;for(let[r,n]of this.entries())e.set(r,t(n,r));return e}equals(t,e){if(this.size!==t.size)return!1;e!=null||(e=(n,o)=>n===o);let r=Math.max(this.posLen,t.posLen);for(let n=0;n<r;++n){let o=this.hasPos[n],s=t.hasPos[n];if(o!==s||o&&!e(this.posVal[n],t.posVal[n]))return!1}return!0}toArray(){return this.valuesArray()}toString(){let t=!0;for(let r=0;r<this.hasPos.length&&t;r++)this.hasPos[r]||(t=!1);if(t)return Bt(this.posVal.slice(0,this.hasPos.length));let e=this.entriesArray().map(([r,n])=>`${Bt(r)}: ${Bt(n)}`).join(", ");return e.length===0?"[ ]":`[ ${e} ]`}},Cl=class Ie extends jr{constructor(t){if(super(),mt(this,"posVal"),mt(this,"hasPos"),mt(this,"negVal"),mt(this,"hasNeg"),mt(this,"valCount"),t instanceof Ie)this.negVal=t.negVal.slice(),this.hasNeg=t.hasNeg.slice(),this.posVal=t.posVal.slice(),this.hasPos=t.hasPos.slice(),this.valCount=t.valCount;else if(this.negVal=[],this.hasNeg=[],this.posVal=[],this.hasPos=[],this.valCount=0,t)for(let[e,r]of t)this.set(e,r)}static toNegIndex(t){return-t-1}static validateIndex(t){if(!kt(t))throw new Error(`Invalid index ${t} - must be an integer!`);return t}get size(){return this.valCount}isEmpty(){return this.size===0}get posLen(){return this.hasPos.length}get negLen(){return this.hasNeg.length}has(t){return Ie.validateIndex(t),t>=0?this.hasPos[t]===!0:this.hasNeg[Ie.toNegIndex(t)]===!0}set(t,e){if(Ie.validateIndex(t),t>=0)this.hasPos[t]!==!0&&this.valCount++,this.posVal[t]=e,this.hasPos[t]=!0;else{let r=Ie.toNegIndex(t);this.hasNeg[r]!==!0&&this.valCount++,this.negVal[r]=e,this.hasNeg[r]=!0}}get(t){if(Ie.validateIndex(t),t>=0)return this.hasPos[t]?this.posVal[t]:void 0;{let e=Ie.toNegIndex(t);return this.hasNeg[e]?this.negVal[e]:void 0}}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){Ie.validateIndex(t);let e=t>=0,r=e?this.posVal:this.negVal,n=e?this.hasPos:this.hasNeg,o=e?t:Ie.toNegIndex(t);return n[o]?(r[o]=void 0,n[o]=!1,this.valCount--,!0):!1}clear(){this.negVal=[],this.hasNeg=[],this.posVal=[],this.hasPos=[],this.valCount=0}forEach(t,e){for(let[r,n]of this.entries())t.call(e,n,r,this)}*indices(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield Ie.toNegIndex(t));for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield t)}*values(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield this.negVal[t]);for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield this.posVal[t])}*entries(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield[Ie.toNegIndex(t),this.negVal[t]]);for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield[t,this.posVal[t]])}indicesArray(){return[...this.indices()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.indices())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Ie(this)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.entries())if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.entries())if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.entries())t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty SignedIndexArray with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapToArray(t){let e=[];for(let[r,n]of this.entries())e.push(t(n,r));return e}map(t){let e=new Ie;for(let[r,n]of this.entries())e.set(r,t(n,r));return e}equals(t,e){if(this.size!==t.size)return!1;e!=null||(e=(o,s)=>o===s);let r=Math.max(this.posLen,t.posLen);for(let o=0;o<r;++o){let s=this.hasPos[o],a=t.hasPos[o];if(s!==a||s&&!e(this.posVal[o],t.posVal[o]))return!1}let n=Math.max(this.negLen,t.negLen);for(let o=0;o<n;++o){let s=this.hasNeg[o],a=t.hasNeg[o];if(s!==a||s&&!e(this.negVal[o],t.negVal[o]))return!1}return!0}toArray(){return this.valuesArray()}toString(){let t=this.hasNeg.length===0;for(let r=0;r<this.hasPos.length&&t;r++)this.hasPos[r]||(t=!1);if(t)return Bt(this.posVal.slice(0,this.hasPos.length));let e=this.entriesArray().map(([r,n])=>`${Bt(r)}: ${Bt(n)}`).join(", ");return e.length===0?"[ ]":`[ ${e} ]`}};var ht=class ao extends jr{constructor(...t){super(),mt(this,"map"),mt(this,"keyEquals");let e=t.at(-1);this.keyEquals=_r(e)?t.pop():ke;let r=t[0];this.map=new Map(r)}static createDeep(t){return t?new ao(t,uo):new ao(uo)}has(t){if(this.keyEquals===ke||this.map.has(t))return this.map.has(t);for(let[e,r]of this.map)if(this.keyEquals(e,t))return!0;return!1}set(t,e){if(this.keyEquals===ke||this.map.has(t))return this.map.set(t,e),e;for(let r of this.map.keys())if(this.keyEquals(r,t))return this.map.set(r,e),e;return this.map.set(t,e),e}get(t){if(this.keyEquals===ke||this.map.has(t))return this.map.get(t);for(let[e,r]of this.map)if(this.keyEquals(e,t))return r}delete(t){if(this.keyEquals===ke||this.map.has(t))return this.map.delete(t);for(let e of this.map.keys())if(this.keyEquals(e,t))return this.map.delete(e);return this.map.delete(t)}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r)}return this.get(t)}clear(){this.map.clear()}get size(){return this.map.size}isEmpty(){return this.size===0}forEach(t,e){this.map.forEach((r,n)=>t.call(e,r,n,this))}*keys(){yield*de(this.map.keys())}*values(){yield*de(this.map.values())}*entries(){for(let[t,e]of this.map)yield[t,e]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.keys())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new ao(this,this.keyEquals)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.map)if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.map)if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map)t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty UniMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map)e.push(t(n,r));return e}mapValues(t){let e=new ao;for(let[r,n]of this.map)e.set(r,t(n,r));return e}toMap(){return new Map(this.map)}toString(){let t=[...this.map].map(([e,r])=>`${Bt(e)} => ${Bt(r)}`).join(", ");return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t} }`}},_l=class Ps extends jr{constructor(t){if(super(),mt(this,"map1"),mt(this,"key1Equals",ke),mt(this,"key2Equals",ke),this.map1=new ht(this.key1Equals),t instanceof Ps)for(let[e,r]of t.map1){let n=this.map1.set(e,new ht(this.key2Equals));for(let[o,s]of r)n.set(o,s)}else if(t)for(let[e,r,n]of t)this.set(e,r,n)}has(t,e){var r,n;return(n=(r=this.map1.get(t))==null?void 0:r.has(e))!=null?n:!1}set(t,e,r){return this.map1.getOrCreate(t,()=>new ht(this.key2Equals)).set(e,r)}get(t,e){var r;return(r=this.map1.get(t))==null?void 0:r.get(e)}getOrDefault(t,e,r){var n;return(n=this.get(t,e))!=null?n:r}getOrCreate(t,e,r){if(!this.has(t,e)){let n=_r(r)?r():r;return this.set(t,e,n),n}return this.get(t,e)}delete(t,e){if(e===void 0)return this.map1.delete(t);let r=this.map1.get(t);return r?r.delete(e):!1}clear(){this.map1.clear()}get size(){let t=0;for(let e of this.map1.values())t+=e.size;return t}isEmpty(){return this.size===0}forEach(t,e){this.map1.forEach((r,n)=>r.forEach((o,s)=>t.call(e,o,n,s,this)))}*keys(){for(let[t,e]of this.map1)for(let r of e.keys())yield[t,r]}*values(){for(let t of this.map1.values())for(let e of t.values())yield e}*entries(){for(let[t,e]of this.map1)for(let[r,n]of e)yield[t,r,n]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let[t,e]of this.keys())yield[t,e]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e,r]of this.entries())yield[[t,e],r]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Ps(this)}merge(t,e){for(let[r,n,o]of t.entries())this.has(r,n)&&e?this.set(r,n,e(this.get(r,n),o,r,n)):this.set(r,n,o);return this}some(t){for(let[e,r]of this.map1)for(let[n,o]of r)if(t(o,e,n))return!0;return!1}every(t){for(let[e,r]of this.map1)for(let[n,o]of r)if(!t(o,e,n))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map1)for(let[o,s]of n)t(s,r,o,this)&&e.set(r,o,s);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty BiMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[2],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u,h]=a.value;o=t(o,h,c,u)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map1)for(let[o,s]of n)e.push(t(s,r,o));return e}mapValues(t){let e=new Ps;for(let[r,n]of this.map1)for(let[o,s]of n)e.set(r,o,t(s,r,o));return e}toMap(){let t=new Map;for(let[e,r]of this.map1)for(let[n,o]of r)t.set([e,n],o);return t}toString(){let t=[];for(let[e,r]of this.map1){let n=[...r].map(([o,s])=>`${Bt(o)} => ${Bt(s)}`).join(", ");t.push(`${Bt(e)} => { ${n} }`)}return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t} }`}},Us=class Fs extends jr{constructor(t){if(super(),mt(this,"map1"),mt(this,"key1Equals",ke),mt(this,"key2Equals",ke),mt(this,"key3Equals",ke),this.map1=new ht(this.key1Equals),t instanceof Fs)for(let[e,r]of t.map1){let n=this.map1.set(e,new ht(this.key2Equals));for(let[o,s]of r)n.set(o,new ht(s,this.key3Equals))}else if(t)for(let[e,r,n,o]of t)this.set(e,r,n,o)}has(t,e,r){var n,o,s;return(s=(o=(n=this.map1.get(t))==null?void 0:n.get(e))==null?void 0:o.has(r))!=null?s:!1}set(t,e,r,n){return this.map1.getOrCreate(t,()=>new ht(this.key2Equals)).getOrCreate(e,()=>new ht(this.key3Equals)).set(r,n),n}get(t,e,r){var n,o;return(o=(n=this.map1.get(t))==null?void 0:n.get(e))==null?void 0:o.get(r)}getOrDefault(t,e,r,n){var o;return(o=this.get(t,e,r))!=null?o:n}getOrCreate(t,e,r,n){if(!this.has(t,e,r)){let o=_r(n)?n():n;return this.set(t,e,r,o),o}return this.get(t,e,r)}delete(t,e,r){var n;if(r===void 0){if(e===void 0)return this.map1.delete(t);let o=this.map1.get(t);return o?o.delete(e):!1}else{if(e===void 0)return this.map1.delete(t);let o=(n=this.map1.get(t))==null?void 0:n.get(e);return o?o.delete(r):!1}}clear(){this.map1.clear()}get size(){let t=0;for(let e of this.map1.values())for(let r of e.values())t+=r.size;return t}isEmpty(){return this.size===0}forEach(t,e){this.map1.forEach((r,n)=>r.forEach((o,s)=>o.forEach((a,c)=>t.call(e,a,n,s,c,this))))}*keys(){for(let[t,e]of this.map1)for(let[r,n]of e)for(let o of n.keys())yield[t,r,o]}*values(){for(let t of this.map1.values())for(let e of t.values())for(let r of e.values())yield r}*entries(){for(let[t,e]of this.map1)for(let[r,n]of e)for(let[o,s]of n)yield[t,r,o,s]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let[t,e,r]of this.keys())yield[t,e,r]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e,r,n]of this.entries())yield[[t,e,r],n]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Fs(this)}merge(t,e){for(let[r,n,o,s]of t.entries())this.has(r,n,o)&&e?this.set(r,n,o,e(this.get(r,n,o),s,r,n,o)):this.set(r,n,o,s);return this}some(t){for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)if(t(a,e,n,s))return!0;return!1}every(t){for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)if(!t(a,e,n,s))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)t(c,r,o,a,this)&&e.set(r,o,a,c);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty TriMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[3],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u,h,l]=a.value;o=t(o,l,c,u,h)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)e.push(t(c,r,o,a));return e}mapValues(t){let e=new Fs;for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)e.set(r,o,a,t(c,r,o,a));return e}toMap(){let t=new Map;for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)t.set([e,n,s],a);return t}toString(){let t=[];for(let[e,r]of this.map1)for(let[n,o]of r){let s=[...o].map(([a,c])=>`${Bt(a)} => ${Bt(c)}`).join(", ");t.push(`${Bt(e)} => ${Bt(n)} => { ${s} }`)}return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t.join(", ")} }`}},zs=class Si extends jr{constructor(...t){super(),mt(this,"data"),mt(this,"equals");let e=t.at(-1);this.equals=_r(e)?t.pop():ke;let r=t[0];this.data=new Set(r)}static createDeep(t){return t?new Si(t,uo):new Si(uo)}has(t){return this.equals===ke?this.data.has(t):this.some(e=>this.equals(e,t))}add(t){return this.has(t)||this.data.add(t),t}set(t,e){if(!this.equals(t,e))throw new TypeError("ValueSet.set() requires key === value.");this.add(e)}get(t){return this.has(t)?t:void 0}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){if(this.equals===ke||this.data.has(t))return this.data.delete(t);for(let e of this.values())if(this.equals(e,t))return this.data.delete(e),!0;return!1}clear(){this.data.clear()}get size(){return this.data.size}isEmpty(){return this.size===0}forEach(t,e){this.data.forEach(r=>t.call(e,r,this))}*keys(){yield*de(this.data.keys())}*values(){yield*de(this.data.values())}*entries(){yield*de(this.data.entries())}*kvKeys(){for(let t of this.keys())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.values())}clone(){let t=new Si;for(let e of this.values())t.add(e);return t}merge(t){for(let e of t.values())this.add(e);return this}some(t){for(let e of this.data)if(t(e))return!0;return!1}every(t){for(let e of this.data)if(!t(e))return!1;return!0}filter(t){let e=new Si;for(let r of this.data)t(r,this)&&e.add(r);return e}reduce(t,e){let r=this.values(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty ValueSet with no initial value!");return e}let o,s;arguments.length<2?(o=n.value,s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let c=a.value;o=t(o,c)}return o}mapValues(t){let e=new Si;for(let r of this.data)e.add(t(r));return e}mapToArray(t){let e=[];for(let r of this.values())e.push(t(r));return e}map(t){let e=new Si;for(let r of this.values())e.add(t(r));return e}toSet(){return new Set(this.data)}toArray(){return[...this.values()]}toString(){return Bt(this.data)}},FA=class extends jr{constructor(i){super(),this.base=i}isEmpty(){return this.base.isEmpty()}clear(){var i,t;(t=(i=this.base).clear)==null||t.call(i)}add(...i){let t=i.slice(0,-1),e=i[i.length-1],r=this.base.get(...t);return this.base.set(...t,r?[...r,e]:[e]),e}remove(...i){let t=i.slice(0,-1),e=i[i.length-1],r=this.base.get(...t);if(!r)return!1;let n=r.indexOf(e);return n===-1?!1:(r.splice(n,1),r.length===0&&this.base.delete(...t),!0)}getAll(...i){var t;return(t=this.base.get(...i))!=null?t:[]}*iterAll(...i){yield*de(this.getAll(...i))}*values(){for(let i of this.keys())yield*de(this.getAll(...i))}*keys(){for(let i of this.base.kvKeys())yield i}*entries(){for(let i of this.keys()){let t=this.getAll(...i);t.length>0&&(yield[i,t])}}[Symbol.iterator](){return this.entries()}toString(){let i=[];for(let t of this.keys()){let e=this.getAll(...t),r=Array.isArray(t)?Bt(t):"[ ]",n=Array.isArray(e)?Bt(e):"[ ]";i.push(`${r} => ${n}`)}return i.length===0?"MultiContainer{ }":`MultiContainer{ ${i.join(", ")} }`}};function Ys(i){return new FA(i)}var pu={};rn(pu,{MusicError:()=>N,MusicErrorType:()=>Ct,init:()=>Ti});H.Dom.injectCss("wms-custom-css",`
1
+ /* WebMusicScore v6.0.0-pre.5 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
+ "use strict";var WebMusicScore=(()=>{var Ls=Object.defineProperty,Ag=Object.defineProperties,Cg=Object.getOwnPropertyDescriptor,_g=Object.getOwnPropertyDescriptors,vg=Object.getOwnPropertyNames,ks=Object.getOwnPropertySymbols;var iu=Object.prototype.hasOwnProperty,Zh=Object.prototype.propertyIsEnumerable;var eu=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),wg=i=>{throw TypeError(i)},Xh=Math.pow,ru=(i,t,e)=>t in i?Ls(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,O=(i,t)=>{for(var e in t||(t={}))iu.call(t,e)&&ru(i,e,t[e]);if(ks)for(var e of ks(t))Zh.call(t,e)&&ru(i,e,t[e]);return i},X=(i,t)=>Ag(i,_g(t));var Kr=(i,t)=>{var e={};for(var r in i)iu.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&ks)for(var r of ks(i))t.indexOf(r)<0&&Zh.call(i,r)&&(e[r]=i[r]);return e};var rn=(i,t)=>{for(var e in t)Ls(i,e,{get:t[e],enumerable:!0})},Sg=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of vg(t))!iu.call(i,n)&&n!==e&&Ls(i,n,{get:()=>t[n],enumerable:!(r=Cg(t,n))||r.enumerable});return i};var Ig=i=>Sg(Ls({},"__esModule",{value:!0}),i);var d=(i,t,e)=>ru(i,typeof t!="symbol"?t+"":t,e);var K=(i,t,e)=>new Promise((r,n)=>{var o=c=>{try{a(e.next(c))}catch(u){n(u)}},s=c=>{try{a(e.throw(c))}catch(u){n(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((e=e.apply(i,t)).next())}),Tg=function(i,t){this[0]=i,this[1]=t};var de=i=>{var t=i[eu("asyncIterator")],e=!1,r,n={};return t==null?(t=i[eu("iterator")](),r=o=>n[o]=s=>t[o](s)):(t=t.call(i),r=o=>n[o]=s=>{if(e){if(e=!1,o==="throw")throw s;return s}return e=!0,{done:!1,value:new Tg(new Promise(a=>{var c=t[o](s);c instanceof Object||wg("Object expected"),a(c)}),1)}}),n[eu("iterator")]=()=>n,r("next"),"throw"in t?r("throw"):n.throw=o=>{throw o},"return"in t&&r("return"),n};var d0={};rn(d0,{Audio:()=>Go,Core:()=>pu,Pieces:()=>$h,Score:()=>Wh,Theory:()=>_u});var Go={};rn(Go,{addInstrument:()=>Dv,getCurrentInstrument:()=>Ev,getInstrumentList:()=>Mv,isMuted:()=>jv,linearToDecibels:()=>ea,mute:()=>kv,playNote:()=>Ya,stop:()=>Ha,unmute:()=>Lv,useInstrument:()=>eg});var _u={};rn(_u,{AccidentalType:()=>fu,BeamGrouping:()=>Ri,Chord:()=>gu,DefaultGuitarNoteLabel:()=>WA,DefaultPitchNotation:()=>VA,DefaultTuningName:()=>gC,GuitarNoteLabel:()=>Hs,GuitarNoteLabelList:()=>UA,Interval:()=>lo,KeySignature:()=>rr,Mode:()=>mu,Note:()=>U,NoteLength:()=>ir,NoteLengthProps:()=>Tt,PitchNotation:()=>ei,PitchNotationList:()=>GA,RhythmProps:()=>Qt,Scale:()=>ii,ScaleFactory:()=>ie,ScaleType:()=>Ni,SymbolSet:()=>ti,TimeSignature:()=>ni,TimeSignatures:()=>fo,TuningNameList:()=>mo,Tuplet:()=>Gr,alterTempoSpeed:()=>Cu,getDefaultKeySignature:()=>$s,getDefaultScale:()=>aC,getDefaultTempo:()=>Js,getDefaultTimeSignature:()=>Ks,getPitchNotationName:()=>qA,getScale:()=>Pr,getScaleFactory:()=>Dl,getScaleFactoryList:()=>oC,getTempoString:()=>ta,getTuningStrings:()=>Xs,isNoteLength:()=>nr,isTupletRatio:()=>Qs,validateGuitarNoteLabel:()=>zA,validateIntervalQuality:()=>tC,validateNoteLength:()=>Br,validatePitchNotation:()=>wl,validateScaleType:()=>po,validateTuningName:()=>bu,validateTupletRatio:()=>jl});var Qh=Object.defineProperty,Ng=(i,t,e)=>t in i?Qh(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,er=(i,t)=>{for(var e in t)Qh(i,e,{get:t[e],enumerable:!0})},mt=(i,t,e)=>Ng(i,typeof t!="symbol"?t+"":t,e),Kh={};er(Kh,{assert:()=>rb,doesNotThrow:()=>Ox,doesThrow:()=>Nx,fail:()=>sb,isArray:()=>xb,isArrayOrUndefined:()=>Ab,isBigInt:()=>qb,isBoolean:()=>Mb,isBooleanOrUndefined:()=>Eb,isDeepEqual:()=>cb,isDefined:()=>db,isEmptyArray:()=>Cb,isEmptyArrayOrUndefined:()=>vb,isEmptyObject:()=>fb,isEmptyString:()=>Ib,isEmptyStringOrUndefined:()=>Ob,isEnumValue:()=>Bb,isEnumValueOrUndefined:()=>Gb,isEven:()=>vx,isFalse:()=>Lb,isFalseOrUndefined:()=>jb,isFinite:()=>Jb,isFloat:()=>tx,isFunction:()=>Pb,isFunctionOrUndefined:()=>Fb,isIncluded:()=>Ix,isIndex:()=>Tx,isInfinity:()=>dx,isInteger:()=>ex,isIntegerBetween:()=>ux,isIntegerBetweenExclusive:()=>hx,isIntegerEq:()=>nx,isIntegerGt:()=>ox,isIntegerGte:()=>sx,isIntegerLt:()=>ax,isIntegerLte:()=>cx,isIntegerOrUndefined:()=>ix,isMultipleOf:()=>wx,isNaNValue:()=>lx,isNeg:()=>gx,isNegInfinity:()=>mx,isNegZero:()=>Cx,isNonEmptyArray:()=>_b,isNonEmptyArrayOrUndefined:()=>wb,isNonEmptyString:()=>Tb,isNonEmptyStringOrUndefined:()=>Rb,isNonNeg:()=>bx,isNonNull:()=>pb,isNonPos:()=>yx,isNull:()=>hb,isNullish:()=>lb,isNumber:()=>Wb,isNumberBetween:()=>Qb,isNumberBetweenExclusive:()=>Kb,isNumberEq:()=>Yb,isNumberGt:()=>Hb,isNumberGte:()=>$b,isNumberLt:()=>Zb,isNumberLte:()=>Xb,isNumberOrUndefined:()=>zb,isNumericString:()=>Vb,isObject:()=>mb,isObjectOrUndefined:()=>yb,isOdd:()=>_x,isPlainObject:()=>gb,isPos:()=>fx,isPosInfinity:()=>px,isPosZero:()=>Ax,isPowerOfTwo:()=>Sx,isSafeInteger:()=>rx,isSafeNumber:()=>Ub,isStrictEqual:()=>ab,isString:()=>Sb,isStringOrUndefined:()=>Nb,isTrue:()=>Db,isTrueOrUndefined:()=>kb,isTypedObject:()=>bb,isUndefined:()=>ub,isZero:()=>xx,require:()=>ib,requireDefined:()=>nb,requireElement:()=>ob,setErrorClass:()=>eb});var Jh={};er(Jh,{charCount:()=>Qy,chunkString:()=>$y,insertAt:()=>Zy,isString:()=>il,makeSentenceFromPascal:()=>Ky,removeAt:()=>Xy,repeatString:()=>Hy,replaceAt:()=>cu,splitByCaps:()=>Jy,splitByChars:()=>tb,splitByStrings:()=>al,stringify:()=>Bt,toCharArray:()=>Yy});var tl={};er(tl,{deepEqual:()=>Bs,getCtorName:()=>sl,hasProperties:()=>zy,isObject:()=>Ii});var y={};er(y,{doesNotThrow:()=>Wy,doesThrow:()=>qy,isArray:()=>Le,isArrayOrUndefined:()=>qg,isBigInt:()=>cy,isBoolean:()=>Kg,isBooleanOrUndefined:()=>Jg,isDeepEqual:()=>uo,isDefined:()=>Lg,isEmptyArray:()=>Wg,isEmptyArrayOrUndefined:()=>zg,isEmptyObject:()=>Pg,isEmptyString:()=>Hg,isEmptyStringOrUndefined:()=>Xg,isEnumValue:()=>oy,isEnumValueOrUndefined:()=>sy,isEven:()=>Py,isFalse:()=>ry,isFalseOrUndefined:()=>iy,isFinite:()=>nn,isFloat:()=>by,isFunction:()=>_r,isFunctionOrUndefined:()=>ny,isIncluded:()=>Gy,isIndex:()=>Vy,isInfinity:()=>Iy,isInteger:()=>kt,isIntegerBetween:()=>nl,isIntegerBetweenExclusive:()=>Sy,isIntegerEq:()=>Cy,isIntegerGt:()=>_y,isIntegerGte:()=>au,isIntegerLt:()=>vy,isIntegerLte:()=>wy,isIntegerOrUndefined:()=>Ay,isMultipleOf:()=>Fy,isNaNValue:()=>ol,isNeg:()=>Ry,isNegInfinity:()=>Ny,isNegZero:()=>Ly,isNonEmptyArray:()=>Ug,isNonEmptyArrayOrUndefined:()=>Yg,isNonEmptyString:()=>$g,isNonEmptyStringOrUndefined:()=>Qg,isNonNeg:()=>Ey,isNonNull:()=>jg,isNonPos:()=>My,isNull:()=>Dg,isNullish:()=>kg,isNumber:()=>Dt,isNumberBetween:()=>gy,isNumberBetweenExclusive:()=>yy,isNumberEq:()=>ly,isNumberGt:()=>dy,isNumberGte:()=>py,isNumberLt:()=>my,isNumberLte:()=>fy,isNumberOrUndefined:()=>hy,isNumericString:()=>ay,isObject:()=>Ii,isObjectOrUndefined:()=>Fg,isOdd:()=>jy,isPlainObject:()=>Bg,isPos:()=>Oy,isPosInfinity:()=>Ty,isPosZero:()=>ky,isPowerOfTwo:()=>By,isSafeInteger:()=>xy,isSafeNumber:()=>uy,isStrictEqual:()=>Mg,isString:()=>il,isStringOrUndefined:()=>Zg,isTrue:()=>ty,isTrueOrUndefined:()=>ey,isTypedObject:()=>Gg,isUndefined:()=>Eg,isZero:()=>Dy,tryOr:()=>Uy});var el={};er(el,{forEachEnum:()=>Rg,getEnumEntries:()=>rl,getEnumKey:()=>Og,getEnumKeys:()=>Gs,getEnumValues:()=>su});function Gs(i){return Object.keys(i).filter(t=>isNaN(Number(t)))}function su(i){return Gs(i).map(t=>i[t])}function rl(i){return Gs(i).map(t=>[t,i[t]])}function Og(i,t){return Gs(i).find(e=>i[e]===t)}function Rg(i,t){for(let[e,r]of rl(i))t(e,r)}function Mg(i,t){return i===t}function uo(i,t){return Bs(i,t)}function Eg(i){return i===void 0}function Dg(i){return i===null}function kg(i){return i==null}function Lg(i){return i!==void 0}function jg(i){return i!==null}function Ii(i){return typeof i=="object"&&i!==null&&!Le(i)}function Pg(i){return Ii(i)&&Object.keys(i).length===0}function Fg(i){return i===void 0||Ii(i)}function Bg(i){if(!Ii(i))return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function Gg(i,t){return Ii(i)&&t.every(e=>e in i)}function Vg(i){return i instanceof Set}function Le(i){return!!i&&Object.prototype.toString.call(i)==="[object Array]"}function qg(i){return i===void 0||Le(i)}function Wg(i){return Le(i)&&i.length===0}function Ug(i){return Le(i)&&i.length>0}function zg(i){return Le(i)&&i.length===0||i===void 0}function Yg(i){return Le(i)&&i.length>0||i===void 0}function il(i){return typeof i=="string"}function Hg(i){return typeof i=="string"&&i.length===0}function $g(i){return typeof i=="string"&&i.length>0}function Zg(i){return i===void 0||typeof i=="string"}function Xg(i){return typeof i=="string"&&i.length===0||i===void 0}function Qg(i){return typeof i=="string"&&i.length>0||i===void 0}function Kg(i){return typeof i=="boolean"}function Jg(i){return i===void 0||typeof i=="boolean"}function ty(i){return i===!0}function ey(i){return i===!0||i===void 0}function ry(i){return i===!1}function iy(i){return i===!1||i===void 0}function _r(i){return typeof i=="function"}function ny(i){return i===void 0||typeof i=="function"}function oy(i,t){return su(t).some(e=>e===i)}function sy(i,t){return i===void 0||su(t).some(e=>e===i)}function ay(i){if(typeof i!="string"||i.trim()==="")return!1;let t=+i;return Number.isFinite(t)}function cy(i){return typeof i=="bigint"}function Dt(i){return typeof i=="number"}function uy(i){return Dt(i)&&Number.isSafeInteger(i)}function hy(i){return typeof i=="number"||i===void 0}function ly(i,t){return Dt(i)&&i===t}function dy(i,t){return Dt(i)&&Dt(t)&&i>t}function py(i,t){return Dt(i)&&Dt(t)&&i>=t}function my(i,t){return Dt(i)&&Dt(t)&&i<t}function fy(i,t){return Dt(i)&&Dt(t)&&i<=t}function gy(i,t,e){return Dt(i)&&Dt(t)&&Dt(e)&&i>=t&&i<=e}function yy(i,t,e){return Dt(i)&&Dt(t)&&Dt(e)&&i>t&&i<e}function nn(i){return typeof i=="number"&&Number.isFinite(i)}function by(i){return nn(i)&&!kt(i)}function kt(i){return typeof i=="number"&&nn(i)&&i===Math.trunc(i)}function xy(i){return kt(i)&&Number.isSafeInteger(i)}function Ay(i){return typeof i=="number"&&nn(i)&&i===Math.trunc(i)||i===void 0}function Cy(i,t){return kt(i)&&i===t}function _y(i,t){return kt(i)&&Dt(t)&&i>t}function au(i,t){return kt(i)&&Dt(t)&&i>=t}function vy(i,t){return kt(i)&&Dt(t)&&i<t}function wy(i,t){return kt(i)&&Dt(t)&&i<=t}function nl(i,t,e){return kt(i)&&Dt(t)&&Dt(e)&&i>=t&&i<=e}function Sy(i,t,e){return kt(i)&&Dt(t)&&Dt(e)&&i>t&&i<e}function ol(i){return typeof i=="number"&&Number.isNaN(i)}function Iy(i){return i===1/0||i===-1/0}function Ty(i){return i===1/0}function Ny(i){return i===-1/0}function Oy(i){return typeof i=="number"&&i>0}function Ry(i){return typeof i=="number"&&i<0}function My(i){return typeof i=="number"&&i<=0}function Ey(i){return typeof i=="number"&&i>=0}function Dy(i){return typeof i=="number"&&i===0}function ky(i){return typeof i=="number"&&i===0&&1/i===1/0}function Ly(i){return typeof i=="number"&&i===0&&1/i===-1/0}function jy(i){return kt(i)&&Math.abs(i)%2===1}function Py(i){return kt(i)&&i%2===0}function Fy(i,t){return typeof i=="number"&&typeof t=="number"&&i%t===0}function By(i){return kt(i)&&i>0&&(i&i-1)===0}function Gy(i,t){return Le(t)?t.includes(i):Vg(t)?t.has(i):!1}function Vy(i,t){return Le(t)?nl(i,0,t.length-1):au(i,0)}function qy(i){try{return i(),!1}catch(t){return!0}}function Wy(i){try{return i(),!0}catch(t){return!1}}function Uy(i,t){try{return i()}catch(e){return _r(t)?t():t}}function zy(i,t){return Ii(i)&&t.every(e=>e in i)}function Bs(i,t){if(i===t)return!0;if(i===null||t===null||typeof i!="object"||typeof t!="object")return!1;if(Array.isArray(i)&&Array.isArray(t))return i.length!==t.length?!1:i.every((n,o)=>Bs(n,t[o]));if(Array.isArray(i)!==Array.isArray(t))return!1;let e=Object.keys(i),r=Object.keys(t);if(e.length!==r.length)return!1;for(let n of e)if(!Object.prototype.hasOwnProperty.call(t,n)||!Bs(i[n],t[n]))return!1;return!0}function sl(i){return i===null?"null":Le(i)?"Array":typeof i!="object"?typeof i:Object.prototype.toString.call(i).slice(8,-1)||"Object"}function Yy(i){return i.split("")}function Hy(i,t){if(!kt(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(i)}function $y(i,t){if(!kt(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e}function cu(i,t,e,r){if(!kt(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!kt(t)||t<0||t+e>i.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+i.length);return i.substring(0,t)+r+i.substring(t+e)}function Zy(i,t,e){return cu(i,t,0,e)}function Xy(i,t,e){return cu(i,t,e,"")}function Qy(i,t){if(t.length!==1||i.length===0)return 0;let e=0;for(let r=0;r<i.length;r++)i[r]===t&&e++;return e}function Ky(i){if(i==="")return"";let t=i.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},n=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<i.length;o++){let s=i.charAt(o);n(s)&&r(),t+=s.toLowerCase()}return r(),e}function Bt(i,t=5,e=new WeakSet){if(i===null)return"null";if(i===void 0)return"undefined";let r=typeof i;switch(r){case"boolean":return i?"true":"false";case"number":return ol(i)?"NaN":nn(i)?i.toString():i<0?"-Infinity":"Infinity";case"bigint":return`${i}n`;case"string":return`"${i}"`;case"symbol":return i.description?`Symbol(${i.description})`:"Symbol()";case"function":return`[Function${i.name?` ${i.name}`:""}]`}if(e.has(i))return"[Circular]";if(t<=0)return"[Depth limit]";t--,e.add(i);let n=s=>Bt(s,t,e);if(Le(i)){let s=i.map(a=>n(a)).join(", ");return s.length===0?"[ ]":`[ ${s} ]`}if(ArrayBuffer.isView(i)){if(i instanceof DataView)return`DataView(${i.byteLength})`;let s=Array.from(i).map(a=>n(a)).join(", ");return`${i.constructor.name}[ ${s} ]`}if(i instanceof ArrayBuffer)return`ArrayBuffer(${i.byteLength})`;if(i instanceof Map){let s=Array.from(i.entries()).map(([a,c])=>`${n(a)} => ${n(c)}`).join(", ");return s.length===0?`Map(${i.size}){ }`:`Map(${i.size}){ ${s} }`}if(i instanceof Set){let s=Array.from(i.values()).map(a=>n(a)).join(", ");return s.length===0?`Set(${i.size}){ }`:`Set(${i.size}){ ${s} }`}if(i instanceof WeakMap)return"WeakMap{ ? }";if(i instanceof WeakSet)return"WeakSet{ ? }";if(i instanceof Date)return`Date("${i.toISOString()}")`;if(i instanceof RegExp)return i.toString();if(i instanceof Error)return`${i.name}("${i.message}")`;if(i instanceof Promise)return"Promise{ ? }";if(i instanceof URL)return`URL("${i.href}")`;if(i instanceof URLSearchParams)return`URLSearchParams("${i.toString()}")`;if(i===Math)return"Math";if(i===JSON)return"JSON";if(i===Reflect)return"Reflect";if(i===Intl)return"Intl";if(typeof(i==null?void 0:i.toString)=="function"&&i.toString!==Object.prototype.toString)try{let s=i.toString();if(!/^\[object .+\]$/.test(s))return s}catch(s){}if(r==="object"){let s=sl(i),a=Object.entries(i).map(([c,u])=>`${n(c)}: ${n(u)}`);return a.length===0?`${s}{ }`:`${s}{ ${a.join(", ")} }`}return String(i)}function Jy(i){return i.split(/(?=[A-Z])/).filter(t=>!!t)}function al(i,...t){if(t.length===0)return[i];let e=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(e.join("|"),"g");return i.split(r)}function tb(i,t){return al(i,...t.split(""))}var L=Bt,cl=Error;function eb(i){cl=i!=null?i:Error}function V(...i){let t=i.join(", ");throw new cl("Assertion Failed!"+(t===""?"":" "+t))}function rb(i,t){i||V(t)}function ib(i,t){return i==null&&V(`Expected ${L(i)} not to be nullish`,t),i}function nb(i,t){return i===void 0&&V(`Expected ${L(i)} not to be undefined`,t),i}function ob(i,t,e){return y.isIndex(i,t)||V(`Expected ${i} to be index for array ${L(t)}`,e),t[i]}function sb(i){V(i)}function ab(i,t,e){return y.isStrictEqual(i,t)||V(`Expected ${L(i)} to ne strict equal to ${t}`,e),i}function cb(i,t,e){return y.isDeepEqual(i,t)||V(`Expected ${L(i)} to deep equal with ${L(t)}`,e),i}function ub(i,t){return y.isUndefined(i)||V(`Expected ${L(i)} to be undefined`,t),i}function hb(i,t){return y.isNull(i)||V(`Expected ${L(i)} to be null`,t),i}function lb(i,t){return y.isNullish(i)||V(`Expected ${L(i)} to be null or undefined`,t),i}function db(i,t){return y.isDefined(i)||V(`Expected ${L(i)} to be defined`,t),i}function pb(i,t){return y.isNonNull(i)||V(`Expected ${L(i)} to be defined`,t),i}function mb(i,t){return y.isObject(i)||V(`Expected ${L(i)} to be object`,t),i}function fb(i,t){return y.isEmptyObject(i)||V(`Expected ${L(i)} to be empty object`,t),i}function gb(i,t){return y.isPlainObject(i)||V(`Expected ${L(i)} to be plain object`,t),i}function yb(i,t){return y.isObjectOrUndefined(i)||V(`Expected ${L(i)} to be object or undefined`,t),i}function bb(i,t,e){return y.isTypedObject(i,t)||V(`Expected ${L(i)} to have keys ${L(t)}`,e),i}function xb(i,t){return y.isArray(i)||V(`Expected ${L(i)} to be array`,t),i}function Ab(i,t){return y.isArrayOrUndefined(i)||V(`Expected ${L(i)} to be array or undefined`,t),!0}function Cb(i,t){y.isEmptyArray(i)||V(`Expected ${L(i)} to be empty array`,t)}function _b(i,t){y.isNonEmptyArray(i)||V(`Expected ${L(i)} to be non-empty array`,t)}function vb(i,t){y.isEmptyArrayOrUndefined(i)||V(`Expected ${L(i)} to be empty array or undefined`,t)}function wb(i,t){y.isNonEmptyArrayOrUndefined(i)||V(`Expected ${L(i)} to be non-empty array or undefined`,t)}function Sb(i,t){return y.isString(i)||V(`Expected ${L(i)} to be string`,t),i}function Ib(i,t){return y.isEmptyString(i)||V(`Expected ${L(i)} to be empty string`,t),i}function Tb(i,t){return y.isNonEmptyString(i)||V(`Expected ${L(i)} to be non-empty string`,t),i}function Nb(i,t){return y.isStringOrUndefined(i)||V(`Expected ${L(i)} to be string or undefined`,t),i}function Ob(i,t){return y.isEmptyStringOrUndefined(i)||V(`Expected ${L(i)} to be empty string or undefined`,t),i}function Rb(i,t){return y.isNonEmptyStringOrUndefined(i)||V(`Expected ${L(i)} to be non-empty string or undefined`,t),i}function Mb(i,t){return y.isBoolean(i)||V(`Expected ${L(i)} to be boolean`,t),i}function Eb(i,t){return y.isBooleanOrUndefined(i)||V(`Expected ${L(i)} to be boolean or undefined`,t),i}function Db(i,t){return y.isTrue(i)||V(`Expected ${L(i)} to be true`,t),i}function kb(i,t){return y.isTrueOrUndefined(i)||V(`Expected ${L(i)} to be true or undefined`,t),i}function Lb(i,t){return y.isFalse(i)||V(`Expected ${L(i)} to be false`,t),i}function jb(i,t){return y.isFalseOrUndefined(i)||V(`Expected ${L(i)} to be false or undefined`,t),i}function Pb(i,t){return y.isFunction(i)||V(`Expected ${L(i)} to be function`,t),i}function Fb(i,t){return y.isFunctionOrUndefined(i)||V(`Expected ${L(i)} to be function or undefined`,t),i}function Bb(i,t,e){return y.isEnumValue(i,t)||V(`Expected ${L(i)} to be enum val`,e),i}function Gb(i,t,e){return y.isEnumValueOrUndefined(i,t)||V(`Expected ${L(i)} to be enum val or undefined`,e),i}function Vb(i,t){return y.isNumericString(i)||V(`Expected ${L(i)} to be numeric string`,t),i}function qb(i,t){return y.isBigInt(i)||V(`Expected ${L(i)} to be BigInt`,t),i}function Wb(i,t){return y.isNumber(i)||V(`Expected ${L(i)} to be number`,t),i}function Ub(i,t){return y.isSafeNumber(i)||V(`Expected ${L(i)} to be safe number`,t),i}function zb(i,t){return y.isNumberOrUndefined(i)||V(`Expected ${L(i)} to be number or undefined`,t),i}function Yb(i,t,e){return y.isNumberEq(i,t)||V(`Expected ${L(i)} to be number equal to ${L(t)}`,e),i}function Hb(i,t,e){return y.isNumberGt(i,t)||V(`Expected ${L(i)} to be number > ${L(t)}`,e),i}function $b(i,t,e){return y.isNumberGte(i,t)||V(`Expected ${L(i)} to be number >= ${L(t)}`,e),i}function Zb(i,t,e){return y.isNumberLt(i,t)||V(`Expected ${L(i)} to be number < ${L(t)}`,e),i}function Xb(i,t,e){return y.isNumberLte(i,t)||V(`Expected ${L(i)} to be number <= ${L(t)}`,e),i}function Qb(i,t,e,r){return y.isNumberBetween(i,t,e)||V(`Expected number ${L(t)} <= ${L(i)} <= ${L(e)}`,r),i}function Kb(i,t,e,r){return y.isNumberBetweenExclusive(i,t,e)||V(`Expected number ${L(t)} < ${L(i)} < ${L(e)}`,r),i}function Jb(i,t){return y.isFinite(i)||V(`Expected ${L(i)} to be finite`,t),i}function tx(i,t){return y.isFloat(i)||V(`Expected ${L(i)} to be float`,t),i}function ex(i,t){return y.isInteger(i)||V(`Expected ${L(i)} to be integer`,t),i}function rx(i,t){return y.isSafeInteger(i)||V(`Expected ${L(i)} to be safe integer`,t),i}function ix(i,t){return y.isIntegerOrUndefined(i)||V(`Expected ${L(i)} to be integer or undefined`,t),i}function nx(i,t,e){return y.isIntegerEq(i,t)||V(`Expected ${L(i)} to be integer equal to ${L(t)}`,e),i}function ox(i,t,e){return y.isIntegerGt(i,t)||V(`Expected ${L(i)} to be integer > ${L(t)}`,e),i}function sx(i,t,e){return y.isIntegerGte(i,t)||V(`Expected ${L(i)} to be integer >= ${L(t)}`,e),i}function ax(i,t,e){return y.isIntegerLt(i,t)||V(`Expected ${L(i)} to be integer < ${L(t)}`,e),i}function cx(i,t,e){return y.isIntegerLte(i,t)||V(`Expected ${L(i)} to be integer <= ${L(t)}`,e),i}function ux(i,t,e,r){return y.isIntegerBetween(i,t,e)||V(`Expected integer ${L(t)} <= ${L(i)} <= ${L(e)}`,r),i}function hx(i,t,e,r){return y.isIntegerBetweenExclusive(i,t,e)||V(`Expected integer ${L(t)} < ${L(i)} < ${L(e)}`,r),i}function lx(i,t){return y.isNaNValue(i)||V(`Expected ${L(i)} to be NaN`,t),NaN}function dx(i,t){return y.isInfinity(i)||V(`Expected ${L(i)} to be +-Infinity`,t),i}function px(i,t){return y.isPosInfinity(i)||V(`Expected ${L(i)} to be +Infinity`,t),i}function mx(i,t){return y.isNegInfinity(i)||V(`Expected ${L(i)} to be -Infinity`,t),i}function fx(i,t){return y.isPos(i)||V(`Expected ${L(i)} to be positive (> 0)`,t),i}function gx(i,t){return y.isNeg(i)||V(`Expected ${L(i)} to be negative (< 0)`,t),i}function yx(i,t){return y.isNonPos(i)||V(`Expected ${L(i)} to be non-positive (<= 0)`,t),i}function bx(i,t){return y.isNonNeg(i)||V(`Expected ${L(i)} to be non-negative (>= 0)`,t),i}function xx(i,t){return y.isZero(i)||V(`Expected ${L(i)} to be 0`,t),i}function Ax(i,t){return y.isPosZero(i)||V(`Expected ${L(i)} to be +0`,t),i}function Cx(i,t){return y.isNegZero(i)||V(`Expected ${L(i)} to be -0`,t),i}function _x(i,t){return y.isOdd(i)||V(`Expected ${L(i)} to odd`,t),i}function vx(i,t){return y.isEven(i)||V(`Expected ${L(i)} to even`,t),i}function wx(i,t,e){return y.isMultipleOf(i,t)||V(`Expected ${L(i)} to be divisble bu ${L(t)}`,e),i}function Sx(i,t){return y.isPowerOfTwo(i)||V(`Expected ${L(i)} to be power of two`,t),i}function Ix(i,t,e){return y.isIncluded(i,t)||V(`Expected ${L(i)} to be included in ${L(t)}`,e),i}function Tx(...i){let t=i.shift(),e=y.isString(i[i.length-1])?i.pop():void 0,r=y.isArray(i[0])?i.shift():void 0;return y.isIndex(t,r)||V(r===void 0?`Expected ${t} to be index`:`Expected ${t} to be index for ${L(r)}`,e),t}function Nx(i,t){return y.doesThrow(i)||V("Expected to throw",t),!0}function Ox(i,t){return y.doesNotThrow(i)||V("Expected to throw",t),!0}var Rx={};er(Rx,{accept:()=>Lx,decline:()=>jx,erase:()=>ul,eraseAll:()=>Vx,isConsentPending:()=>kx,read:()=>Fx,readBool:()=>Gx,readInt:()=>Bx,save:()=>Px,setExpireDays:()=>Dx});var Vs="ConsentCookie",tr,co,nu=qs(Vs);tr=nu==="accept"||nu==="decline"?nu:void 0;function Mx(){return typeof document=="undefined"?[]:document.cookie.split(";").map(t=>t.trim())}function uu(i,t){let e=i+"="+t.toString()+";sameSite=Lax;";return co&&(e+="expires="+co.toUTCString()+";"),typeof document!="undefined"&&(document.cookie=e),t}function qs(i,t){let e=Mx().find(r=>r.startsWith(i+"="));return e===void 0?t:e.substring(i.length+1)}function Ex(i){typeof document!="undefined"&&(document.cookie=i+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;")}function Dx(i){co=new Date,co.setDate(co.getDate()+i)}function kx(){return tr===void 0}function Lx(){tr="accept",uu(Vs,tr)}function jx(){tr="decline",uu(Vs,tr)}function Px(i,t){return tr==="accept"&&uu(i,t),t}function Fx(i,t){var e;return tr==="accept"&&(e=qs(i,t))!=null?e:t}function Bx(i,t){if(tr==="accept"){let e=qs(i);return e===void 0?t:parseInt(e)}else return t}function Gx(i,t){if(tr==="accept"){let e=qs(i);return e===void 0?t:/true|1/i.test(e)}else return t}function ul(i){(tr==="accept"||i===Vs)&&Ex(i)}function Vx(){typeof document!="undefined"&&document.cookie.split(";").forEach(i=>ul(i.trim().split("=")[0]))}var Ws={};er(Ws,{DPI:()=>hl,FontSize:()=>ll,HostAddress:()=>Jx,IsMobileDevice:()=>Kx,IsTouchDevice:()=>Qx,PxPerMm:()=>hu,ScrollbarWidth:()=>Xx,mmToPx:()=>js,pxToMm:()=>tA,toPx:()=>eA});function qx(){try{let i=document.createElement("div");i.style.width="1in",document.body.appendChild(i);let t=i.offsetWidth;return i.remove(),t||96}catch(i){return 96}}function Wx(){try{let i=document.createElement("div");i.style.visibility="hidden",i.style.width="100px",document.body.appendChild(i);let t=i.offsetWidth;i.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",i.appendChild(e);let r=e.offsetWidth;return i.parentNode&&i.parentNode.removeChild(i),t-r}catch(i){return 0}}function Ux(){try{let i=document.createElement("div");i.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",i.appendChild(document.createTextNode("M")),document.body.appendChild(i);let t=i.offsetHeight;return document.body.removeChild(i),t}catch(i){return 16}}function zx(){if(typeof window=="undefined")return!1;if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var i=" -webkit- -moz- -o- -ms- ".split(" "),t=function(r){return window.matchMedia(r).matches},e=["(",i.join("touch-enabled),("),"heartz",")"].join("");return t(e)}function Yx(){let i=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(i)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(i.substr(0,4))}function Hx(){return typeof location=="undefined"||!location.host?"localhost":`${location.protocol}//${location.host}`}var $x=/^(mm|cm|in|inch|px|em)$/,Zx=/^([0-9\\.]+)(.*)$/,hl=qx(),hu=hl/25.4,Xx=Wx(),ll=Ux(),Qx=zx(),Kx=Yx(),Jx=Hx();function tA(i){return i/hu}function js(i){return i*hu}function eA(i){if(typeof i=="number")return i;let t=NaN,e,r=i.toString().match(Zx);if(r&&r[1]){t=parseFloat(r[1]);let n=r[2]?r[2].toLowerCase():"undefined";e=$x.test(n)?n:void 0,e||console.log("Unknown unit '"+n+"' => using 'px'.")}else t=parseFloat(i);switch(Kh.isFinite(t,"value in function toPx"),e){case"mm":return js(t);case"cm":return js(t)*10;case"in":case"inch":return js(t)*25.4;case"em":return ll*t;default:case"px":return t}}var H={};er(H,{Arr:()=>dl,Dom:()=>fl,Enum:()=>el,Math:()=>yl,Obj:()=>tl,Str:()=>Jh});var dl={};er(dl,{arrayContains:()=>cA,chunckArray:()=>uA,duplicate:()=>iA,fillArray:()=>oA,getRangeArray:()=>aA,getSequenceArray:()=>sA,isArray:()=>Le,mapRangeArray:()=>ml,mapSequenceArray:()=>pl,removeDuplicates:()=>nA,toArray:()=>rA});function rA(i){return Le(i)?i:[i]}function iA(i){var t;return(t=i==null?void 0:i.slice())!=null?t:[]}function nA(i,t){return t!==void 0?i.filter((e,r,n)=>r===n.findIndex(o=>t(e,o))):i.filter((e,r,n)=>r===n.indexOf(e))}function oA(i,t){if(!kt(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(i)}function pl(i,t){if(!kt(i)||i<0)throw new Error("mapSequenceArray: Invalid len = "+i);let e=new Array(i);for(let r=0;r<i;r++)e[r]=t(r);return e}function sA(i){return pl(i,t=>t)}function ml(i,t,e){if(!kt(i))throw new Error("mapRangeArray: Invalid start = "+t);if(!kt(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-i)+1,n=new Array(r);for(let o=0,s=i,a=Math.sign(t-i);o<r;s+=a,o++)n[o]=e(s);return n}function aA(i,t){return ml(i,t,e=>e)}function cA(i,t){return i.indexOf(t)>=0}function uA(i,t){if(!kt(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e}var fl={};er(fl,{addClass:()=>hA,appendTo:()=>bA,getButton:()=>_A,getCanvas:()=>vA,getCanvasTextWidth:()=>TA,getDimension:()=>SA,getHeight:()=>gA,getOffset:()=>pA,getPadding:()=>wA,getWidth:()=>mA,hasClass:()=>lu,injectCss:()=>NA,removeClass:()=>lA,removeFromParent:()=>xA,setHeight:()=>yA,setOffset:()=>dA,setRect:()=>CA,setVisibility:()=>AA,setWidth:()=>fA,styleLayoutChanged:()=>IA});function gl(i){var t;return typeof document=="undefined"?void 0:(t=document.getElementById(i))!=null?t:void 0}function Et(i){return i===void 0?void 0:Ws.toPx(i)}function lu(i,t){return t.length===0?!1:i.classList?i.classList.contains(t):!!i.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function hA(i,t){t.length!==0&&(i.classList?i.classList.add(t):lu(i,t)||(i.className+=" "+t))}function lA(i,t){if(t.length!==0){if(i.classList)i.classList.remove(t);else if(lu(i,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");i.className=i.className.replace(e," ")}}}function dA(i,t,e,r="px"){i.style.left=t+r,i.style.top=e+r}function pA(i){let{left:t,top:e}=i.getBoundingClientRect();if(typeof window!="undefined"&&(t+=window.pageXOffset,e+=window.pageYOffset),typeof document!="undefined"){let r=document.documentElement;t-=r.clientLeft,e-=r.clientTop}return{left:t,top:e}}function mA(i){if(i instanceof Window)return i.innerWidth;{let t=parseFloat(getComputedStyle(i,null).width.replace("px",""));return isNaN(t)?0:t}}function fA(i,t){i.style.width=t+"px"}function gA(i){if(i instanceof Window)return i.innerHeight;{let t=parseFloat(getComputedStyle(i,null).height.replace("px",""));return isNaN(t)?0:t}}function yA(i,t){i.style.height=t+"px"}function bA(i,t){t.appendChild(i)}function xA(i){i.remove()}function AA(i,t){i.style.display=t?"block":"none"}function CA(i,t,e,r,n,o="px"){i.style.left=t+o,i.style.top=e+o,i.style.width=r+o,i.style.height=n+o}function _A(i){let t=typeof i=="string"?gl(i):i;return t instanceof HTMLButtonElement?t:void 0}function vA(i){let t=typeof i=="string"?gl(i):i;return t instanceof HTMLCanvasElement?t:void 0}function wA(i){var s;if(!i)return{top:0,right:0,bottom:0,left:0};let t=Et(i.paddingTop),e=Et(i.paddingRight),r=Et(i.paddingBottom),n=Et(i.paddingLeft),o=((s=i.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[0])),r!=null||(r=Et(o[0])),n!=null||(n=Et(o[0]));break;case 2:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[1])),r!=null||(r=Et(o[0])),n!=null||(n=Et(o[1]));break;case 3:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[1])),r!=null||(r=Et(o[2])),n!=null||(n=Et(o[1]));break;case 4:default:t!=null||(t=Et(o[0])),e!=null||(e=Et(o[1])),r!=null||(r=Et(o[2])),n!=null||(n=Et(o[3]));break}return t!=null||(t=0),e!=null||(e=0),r!=null||(r=0),n!=null||(n=0),{top:t,right:e,bottom:r,left:n}}function SA(i){let t=Et(i==null?void 0:i.left),e=Et(i==null?void 0:i.right),r=Et(i==null?void 0:i.top),n=Et(i==null?void 0:i.bottom),o=Et(i==null?void 0:i.width),s=Et(i==null?void 0:i.height);return o===void 0&&t!==void 0&&e!==void 0&&(o=e-t),s===void 0&&r!==void 0&&n!==void 0&&(s=n-r),{left:t,top:r,width:o,height:s}}function IA(i,t){return!i&&!t?!1:!i||!t?!0:i.left!==t.left||i.top!==t.top||i.right!==t.right||i.bottom!==t.bottom||i.width!==t.width||i.height!==t.height}var so;function TA(i,t){!so&&typeof document!="undefined"&&(so=document.createElement("canvas"));let e=so==null?void 0:so.getContext("2d");return e?(e.font=t,e.measureText(i).width):0}function NA(i,t){if(i===""||t===""||typeof document=="undefined"||document.getElementById(i))return;let e=document.createElement("style");e.id=i,e.textContent=t,document.head.appendChild(e)}var yl={};er(yl,{avg:()=>jA,calcNormal:()=>LA,clamp:()=>ou,cmp:()=>PA,interpolateCoord:()=>DA,interpolateY:()=>kA,isInteger:()=>kt,isNumber:()=>Dt,linearToDecibels:()=>OA,mod:()=>RA,romanize:()=>MA,sum:()=>bl,toOrdinalNumber:()=>EA});function OA(i){if(isFinite(i))return i<=0?-1/0:20*Math.log10(i);throw new Error("linearToDecibel: Invalid linearVolume = "+i)}function RA(i,t){return(i%t+t)%t}function MA(i){if(!kt(i)||i<0)throw new Error("romanize: Invalid n = "+i);for(var t=String(+i).split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",n=3;n--;)r=(e[+t.pop()+n*10]||"")+r;return Array(+t.join("")+1).join("M")+r}function EA(i){if(!kt(i))throw new Error("toOrdinalNumber: Invalid n = "+i);let t=i.toString(),e=Number(t.charAt(t.length-1));return i===1||i>=20&&e===1?t+"st":i===2||i>=20&&e===2?t+"nd":i===3||i>=20&&e===3?t+"rd":t+"th"}function DA(i,t,e,r,n){return{x:i+(e-i)*n,y:t+(r-t)*n}}function kA(i,t,e,r,n){let o=(n-i)/(e-i);return t+(r-t)*o}function ou(i,t,e){return Math.min(Math.max(i,t),e)}function LA(i,t,e,r){let n=e-i,s=-(r-t),a=n,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function bl(i){return i.reduce((t,e)=>e+t,0)}function jA(...i){return bl(i)/i.length}function PA(i,t){return i<t?-1:i>t?1:0}var ke=(i,t)=>i===t,jr=class{};var xl=class Ve extends jr{constructor(...t){if(super(),mt(this,"coords"),t.length<2)throw new TypeError("Vec needs minumum two coords!");this.coords=t}static vec2(t,e){return new Ve(t,e)}static vec3(t,e,r){return new Ve(t,e,r)}static zero(t){if(t<2)throw new TypeError("Vec.zero requires dimension >= 2");return new Ve(...Array(t).fill(0))}get dim(){return this.coords.length}get length(){return Math.hypot(...this.coords)}magnitude(){return this.length}get x(){return this.coords[0]}get y(){return this.coords[1]}get z(){if(this.coords[2]===void 0)throw new TypeError("Vec z-coord not available!");return this.coords[2]}add(...t){let e=t[0]instanceof Ve?t[0].coords:t;if(this.coords.length!==e.length)throw new TypeError("Coordinate length mismatch!");return new Ve(...this.coords.map((r,n)=>r+e[n]))}sub(...t){let e=t[0]instanceof Ve?t[0].coords:t;if(this.coords.length!==e.length)throw new TypeError("Coordinate length mismatch!");return new Ve(...this.coords.map((r,n)=>r-e[n]))}mul(t){return new Ve(...this.coords.map(e=>e*t))}div(t){return new Ve(...this.coords.map(e=>e/t))}dot(t){if(this.coords.length!==t.coords.length)throw new TypeError("Coordinate length mismatch!");return this.coords.reduce((e,r,n)=>e+r*t.coords[n],0)}distance(t){if(this.coords.length!==t.coords.length)throw new TypeError("Coordinate length mismatch!");return Math.hypot(...this.coords.map((e,r)=>e-t.coords[r]))}normalize(){let t=this.length;if(t===0)throw new TypeError("Cannot normalize zero-length vector!");return this.div(t)}static lerp(t,e,r){if(t.coords.length!==e.coords.length)throw new TypeError("Coordinate length mismatch!");if(!nn(r))throw new TypeError("Lerp t is not finite!");return t.add(e.sub(t).mul(r))}toLength(t){let e=this.length;return e===0?this:this.mul(t/e)}clamp(t,e,r){let n=this.length;if(n===0){if(t!==void 0){if(r&&r.coords.length!==this.coords.length)throw new TypeError("Coordinate length mismatch!");return(r&&r.length!==0?r.normalize():new Ve(1,...Array(this.coords.length-1).fill(0))).mul(t)}return this}return e!==void 0&&n>e?this.normalize().mul(e):t!==void 0&&n<t?this.normalize().mul(t):this}equals(t){return this.coords.length===t.coords.length&&this.coords.every((e,r)=>e===t.coords[r])}clone(){return new Ve(...this.coords)}toObject(){return{x:this.x,y:this.y,z:this.z}}[Symbol.iterator](){return this.coords[Symbol.iterator]()}toString(){return`Vec(${this.coords.join(", ")})`}},du=class Se{constructor(...t){if(mt(this,"x"),mt(this,"y"),mt(this,"width"),mt(this,"height"),t.length===0?this.x=this.y=this.width=this.height=0:t.length===2?(this.x=this.y=0,this.width=t[0],this.height=t[1]):(this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]),this.width<0||this.height<0)throw new Error("Rect width and height must be non-negative.")}set(...t){if(t.length===0?this.x=this.y=this.width=this.height=0:t.length===2?(this.x=this.y=0,this.width=t[0],this.height=t[1]):(this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]),this.width<0||this.height<0)throw new Error("Rect width and height must be non-negative.");return this}static fromPoints(t,e){let r=Math.min(t.x,e.x),n=Math.min(t.y,e.y),o=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return new Se(r,n,o,s)}static fromCenter(t,e,r,n){return new Se(t-r/2,e-n/2,r,n)}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get center(){return{x:this.centerX,y:this.centerY}}get area(){return this.width*this.height}get isEmpty(){return this.width<=0||this.height<=0}containsPoint(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}containsRect(t){return t.left>=this.left&&t.right<=this.right&&t.top>=this.top&&t.bottom<=this.bottom}intersects(t){return!(t.right<this.left||t.left>this.right||t.bottom<this.top||t.top>this.bottom)}intersectionCopy(t){let e=Math.max(this.left,t.left),r=Math.max(this.top,t.top),n=Math.min(this.right,t.right),o=Math.min(this.bottom,t.bottom);return n<=e||o<=r?new Se:new Se(e,r,n-e,o-r)}unionCopy(t){let e=Math.min(this.left,t.left),r=Math.min(this.top,t.top),n=Math.max(this.right,t.right),o=Math.max(this.bottom,t.bottom);return new Se(e,r,n-e,o-r)}insetCopy(t,e){return new Se(this.x+t,this.y+e,this.width-2*t,this.height-2*e)}inflateCopy(t,e){return new Se(this.x-t,this.y-e,this.width+2*t,this.height+2*e)}offsetInPlace(t,e){return this.x+=t,this.y+=e,this}offsetCopy(t,e){return new Se(this.x+t,this.y+e,this.width,this.height)}scaleInPlace(t,e=t){return this.x=this.centerX-this.width*t/2,this.width*=t,this.y=this.centerY-this.height*e/2,this.height*=e,this}scaleCopy(t,e=t){return this.clone().scaleInPlace(t,e)}roundCopy(){let t=Math.round(this.left),e=Math.round(this.top),r=Math.round(this.right),n=Math.round(this.bottom);return new Se(t,e,r-t,n-e)}floorCopy(){let t=Math.floor(this.left),e=Math.floor(this.top),r=Math.floor(this.right),n=Math.floor(this.bottom);return new Se(t,e,r-t,n-e)}ceilCopy(){let t=Math.ceil(this.left),e=Math.ceil(this.top),r=Math.ceil(this.right),n=Math.ceil(this.bottom);return new Se(t,e,r-t,n-e)}expandCopy(t,e){let r=Math.min(this.left,t),n=Math.min(this.top,e),o=Math.max(this.right,t),s=Math.max(this.bottom,e);return new Se(r,n,o-r,s-n)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new Se(this.x,this.y,this.width,this.height)}toString(){return`Rect(x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height})`}toAnchoredRect(){return new G(this.left,this.right,this.top,this.bottom)}},G=class wi{constructor(...t){if(mt(this,"left"),mt(this,"anchorX"),mt(this,"right"),mt(this,"top"),mt(this,"anchorY"),mt(this,"bottom"),t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid AnchoredRect args: ${t}`)}set(...t){if(t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid AnchoredRect args: ${t}`);return this}static create(t,e,r,n){return new wi(t,t+r,e,e+n)}static createCentered(t,e,r,n){return new wi(t-r/2,t,t+r/2,e-n/2,e,e+n/2)}static createSections(t,e,r,n){return new wi(-t,0,e,-r,0,n)}get centerX(){return this.left+this.width/2}get centerY(){return this.top+this.height/2}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.anchorX-this.left}get rightw(){return this.right-this.anchorX}get toph(){return this.anchorY-this.top}get bottomh(){return this.bottom-this.anchorY}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.anchorX===e.anchorX&&t.right===e.right&&t.top===e.top&&t.anchorY===e.anchorY&&t.bottom===e.bottom}equals(t){return wi.equals(this,t)}static equalsEdges(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}equalsEdges(t){return wi.equalsEdges(this,t)}clone(){return new wi(this.left,this.anchorX,this.right,this.top,this.anchorY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.anchorX+=t,this.right+=t,this.top+=e,this.anchorY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.clone().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.clone().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.anchorX=ou(this.anchorX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.anchorY=ou(this.anchorY,this.top,this.bottom),this}clipCopy(t){return this.clone().clipInPlace(t)}scaleInPlace(t,e=t){return this.left=this.anchorX-this.leftw*t,this.right=this.anchorX+this.rightw*t,this.top=this.anchorY-this.toph*e,this.bottom=this.anchorY+this.bottomh*e,this}scaleCopy(t,e=t){return this.clone().scaleInPlace(t,e)}getRect(){return this}toRect(){return new du(this.left,this.right,this.width,this.height)}toString(){return`Rect(left=${this.left}, anchorX=${this.anchorX}, right=${this.right}, top=${this.top}, anchorY=${this.anchorY}, bottom=${this.bottom})`}},Al=class extends jr{constructor(i,t=1/0){super(),mt(this,"cache"),mt(this,"next"),mt(this,"prev"),mt(this,"head"),mt(this,"tail"),mt(this,"capacity"),mt(this,"size"),mt(this,"maxKeyLength"),this.cache=Object.create(null),this.next=Object.create(null),this.prev=Object.create(null),this.head=null,this.tail=null,this.capacity=i,this.size=0,this.maxKeyLength=t}get(i){if(!(i.length>this.maxKeyLength)&&this.cache[i]!==void 0)return this.touch(i),this.cache[i]}set(i,t){if(!(i.length>this.maxKeyLength)){if(this.cache[i]!==void 0){this.cache[i]=t,this.touch(i);return}this.size>=this.capacity&&this.evict(),this.cache[i]=t,this.addToTail(i),this.size++}}touch(i){this.tail!==i&&(this.removeKey(i),this.addToTail(i))}evict(){if(this.head!==null){let i=this.head;this.removeKey(i),delete this.cache[i],this.size--}}removeKey(i){let t=this.prev[i],e=this.next[i];t!==void 0?this.next[t]=e:this.head=e!=null?e:null,e!==void 0?this.prev[e]=t:this.tail=t!=null?t:null,delete this.prev[i],delete this.next[i]}addToTail(i){this.tail!==null?(this.next[this.tail]=i,this.prev[i]=this.tail):this.head=i,this.tail=i}*keys(){for(let i=this.head;i!=null;i=this.next[i])yield i}*values(){for(let i=this.head;i!=null;i=this.next[i])yield this.cache[i]}*entries(){for(let i=this.head;i!=null;i=this.next[i])yield[i,this.cache[i]]}*[Symbol.iterator](){yield*de(this.entries())}toString(){let i=[...this.entries()];return i.length===0?"LRUCache(0){ }":`LRUCache(${i.length}){ ${i.map(t=>`${Bt(t[0])}: ${Bt(t[1])}`).join(", ")} }`}},vr=class Jr extends jr{constructor(t){if(super(),mt(this,"posVal"),mt(this,"hasPos"),mt(this,"valCount"),t instanceof Jr)this.posVal=t.posVal.slice(),this.hasPos=t.hasPos.slice(),this.valCount=t.valCount;else if(this.posVal=[],this.hasPos=[],this.valCount=0,t)for(let[e,r]of t)this.set(e,r)}static validateIndex(t){if(!au(t,0))throw new Error(`Invalid index ${t} - must be an integer >= 0!`);return t}get posLen(){return this.hasPos.length}get size(){return this.valCount}get length(){return this.hasPos.length}trimRight(){let t=this.length;for(;t>0&&this.hasPos[t-1]!==!0;)t--;t<this.length&&(this.posVal.length=this.hasPos.length=t)}isEmpty(){return this.size===0}has(t){return Jr.validateIndex(t),this.hasPos[t]===!0}set(t,e){Jr.validateIndex(t),this.hasPos[t]!==!0&&this.valCount++,this.posVal[t]=e,this.hasPos[t]=!0}get(t){return Jr.validateIndex(t),this.hasPos[t]?this.posVal[t]:void 0}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){return Jr.validateIndex(t),this.hasPos[t]?(this.posVal[t]=void 0,this.hasPos[t]=!1,this.valCount--,this.trimRight(),!0):!1}clear(){this.posVal=[],this.hasPos=[],this.valCount=0}forEach(t,e){for(let[r,n]of this.entries())t.call(e,n,r,this)}*indices(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield t)}*values(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield this.posVal[t])}*entries(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield[t,this.posVal[t]])}indicesArray(){return[...this.indices()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.indices())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Jr(this)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.entries())if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.entries())if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.entries())t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty IndexArray with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapToArray(t){let e=[];for(let[r,n]of this.entries())e.push(t(n,r));return e}map(t){let e=new Jr;for(let[r,n]of this.entries())e.set(r,t(n,r));return e}equals(t,e){if(this.size!==t.size)return!1;e!=null||(e=(n,o)=>n===o);let r=Math.max(this.posLen,t.posLen);for(let n=0;n<r;++n){let o=this.hasPos[n],s=t.hasPos[n];if(o!==s||o&&!e(this.posVal[n],t.posVal[n]))return!1}return!0}toArray(){return this.valuesArray()}toString(){let t=!0;for(let r=0;r<this.hasPos.length&&t;r++)this.hasPos[r]||(t=!1);if(t)return Bt(this.posVal.slice(0,this.hasPos.length));let e=this.entriesArray().map(([r,n])=>`${Bt(r)}: ${Bt(n)}`).join(", ");return e.length===0?"[ ]":`[ ${e} ]`}},Cl=class Ie extends jr{constructor(t){if(super(),mt(this,"posVal"),mt(this,"hasPos"),mt(this,"negVal"),mt(this,"hasNeg"),mt(this,"valCount"),t instanceof Ie)this.negVal=t.negVal.slice(),this.hasNeg=t.hasNeg.slice(),this.posVal=t.posVal.slice(),this.hasPos=t.hasPos.slice(),this.valCount=t.valCount;else if(this.negVal=[],this.hasNeg=[],this.posVal=[],this.hasPos=[],this.valCount=0,t)for(let[e,r]of t)this.set(e,r)}static toNegIndex(t){return-t-1}static validateIndex(t){if(!kt(t))throw new Error(`Invalid index ${t} - must be an integer!`);return t}get size(){return this.valCount}isEmpty(){return this.size===0}get posLen(){return this.hasPos.length}get negLen(){return this.hasNeg.length}has(t){return Ie.validateIndex(t),t>=0?this.hasPos[t]===!0:this.hasNeg[Ie.toNegIndex(t)]===!0}set(t,e){if(Ie.validateIndex(t),t>=0)this.hasPos[t]!==!0&&this.valCount++,this.posVal[t]=e,this.hasPos[t]=!0;else{let r=Ie.toNegIndex(t);this.hasNeg[r]!==!0&&this.valCount++,this.negVal[r]=e,this.hasNeg[r]=!0}}get(t){if(Ie.validateIndex(t),t>=0)return this.hasPos[t]?this.posVal[t]:void 0;{let e=Ie.toNegIndex(t);return this.hasNeg[e]?this.negVal[e]:void 0}}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){Ie.validateIndex(t);let e=t>=0,r=e?this.posVal:this.negVal,n=e?this.hasPos:this.hasNeg,o=e?t:Ie.toNegIndex(t);return n[o]?(r[o]=void 0,n[o]=!1,this.valCount--,!0):!1}clear(){this.negVal=[],this.hasNeg=[],this.posVal=[],this.hasPos=[],this.valCount=0}forEach(t,e){for(let[r,n]of this.entries())t.call(e,n,r,this)}*indices(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield Ie.toNegIndex(t));for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield t)}*values(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield this.negVal[t]);for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield this.posVal[t])}*entries(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield[Ie.toNegIndex(t),this.negVal[t]]);for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield[t,this.posVal[t]])}indicesArray(){return[...this.indices()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.indices())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Ie(this)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.entries())if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.entries())if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.entries())t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty SignedIndexArray with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapToArray(t){let e=[];for(let[r,n]of this.entries())e.push(t(n,r));return e}map(t){let e=new Ie;for(let[r,n]of this.entries())e.set(r,t(n,r));return e}equals(t,e){if(this.size!==t.size)return!1;e!=null||(e=(o,s)=>o===s);let r=Math.max(this.posLen,t.posLen);for(let o=0;o<r;++o){let s=this.hasPos[o],a=t.hasPos[o];if(s!==a||s&&!e(this.posVal[o],t.posVal[o]))return!1}let n=Math.max(this.negLen,t.negLen);for(let o=0;o<n;++o){let s=this.hasNeg[o],a=t.hasNeg[o];if(s!==a||s&&!e(this.negVal[o],t.negVal[o]))return!1}return!0}toArray(){return this.valuesArray()}toString(){let t=this.hasNeg.length===0;for(let r=0;r<this.hasPos.length&&t;r++)this.hasPos[r]||(t=!1);if(t)return Bt(this.posVal.slice(0,this.hasPos.length));let e=this.entriesArray().map(([r,n])=>`${Bt(r)}: ${Bt(n)}`).join(", ");return e.length===0?"[ ]":`[ ${e} ]`}};var lt=class ao extends jr{constructor(...t){super(),mt(this,"map"),mt(this,"keyEquals");let e=t.at(-1);this.keyEquals=_r(e)?t.pop():ke;let r=t[0];this.map=new Map(r)}static createDeep(t){return t?new ao(t,uo):new ao(uo)}has(t){if(this.keyEquals===ke||this.map.has(t))return this.map.has(t);for(let[e,r]of this.map)if(this.keyEquals(e,t))return!0;return!1}set(t,e){if(this.keyEquals===ke||this.map.has(t))return this.map.set(t,e),e;for(let r of this.map.keys())if(this.keyEquals(r,t))return this.map.set(r,e),e;return this.map.set(t,e),e}get(t){if(this.keyEquals===ke||this.map.has(t))return this.map.get(t);for(let[e,r]of this.map)if(this.keyEquals(e,t))return r}delete(t){if(this.keyEquals===ke||this.map.has(t))return this.map.delete(t);for(let e of this.map.keys())if(this.keyEquals(e,t))return this.map.delete(e);return this.map.delete(t)}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r)}return this.get(t)}clear(){this.map.clear()}get size(){return this.map.size}isEmpty(){return this.size===0}forEach(t,e){this.map.forEach((r,n)=>t.call(e,r,n,this))}*keys(){yield*de(this.map.keys())}*values(){yield*de(this.map.values())}*entries(){for(let[t,e]of this.map)yield[t,e]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.keys())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new ao(this,this.keyEquals)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.map)if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.map)if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map)t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty UniMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map)e.push(t(n,r));return e}mapValues(t){let e=new ao;for(let[r,n]of this.map)e.set(r,t(n,r));return e}toMap(){return new Map(this.map)}toString(){let t=[...this.map].map(([e,r])=>`${Bt(e)} => ${Bt(r)}`).join(", ");return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t} }`}},_l=class Ps extends jr{constructor(t){if(super(),mt(this,"map1"),mt(this,"key1Equals",ke),mt(this,"key2Equals",ke),this.map1=new lt(this.key1Equals),t instanceof Ps)for(let[e,r]of t.map1){let n=this.map1.set(e,new lt(this.key2Equals));for(let[o,s]of r)n.set(o,s)}else if(t)for(let[e,r,n]of t)this.set(e,r,n)}has(t,e){var r,n;return(n=(r=this.map1.get(t))==null?void 0:r.has(e))!=null?n:!1}set(t,e,r){return this.map1.getOrCreate(t,()=>new lt(this.key2Equals)).set(e,r)}get(t,e){var r;return(r=this.map1.get(t))==null?void 0:r.get(e)}getOrDefault(t,e,r){var n;return(n=this.get(t,e))!=null?n:r}getOrCreate(t,e,r){if(!this.has(t,e)){let n=_r(r)?r():r;return this.set(t,e,n),n}return this.get(t,e)}delete(t,e){if(e===void 0)return this.map1.delete(t);let r=this.map1.get(t);return r?r.delete(e):!1}clear(){this.map1.clear()}get size(){let t=0;for(let e of this.map1.values())t+=e.size;return t}isEmpty(){return this.size===0}forEach(t,e){this.map1.forEach((r,n)=>r.forEach((o,s)=>t.call(e,o,n,s,this)))}*keys(){for(let[t,e]of this.map1)for(let r of e.keys())yield[t,r]}*values(){for(let t of this.map1.values())for(let e of t.values())yield e}*entries(){for(let[t,e]of this.map1)for(let[r,n]of e)yield[t,r,n]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let[t,e]of this.keys())yield[t,e]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e,r]of this.entries())yield[[t,e],r]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Ps(this)}merge(t,e){for(let[r,n,o]of t.entries())this.has(r,n)&&e?this.set(r,n,e(this.get(r,n),o,r,n)):this.set(r,n,o);return this}some(t){for(let[e,r]of this.map1)for(let[n,o]of r)if(t(o,e,n))return!0;return!1}every(t){for(let[e,r]of this.map1)for(let[n,o]of r)if(!t(o,e,n))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map1)for(let[o,s]of n)t(s,r,o,this)&&e.set(r,o,s);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty BiMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[2],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u,l]=a.value;o=t(o,l,c,u)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map1)for(let[o,s]of n)e.push(t(s,r,o));return e}mapValues(t){let e=new Ps;for(let[r,n]of this.map1)for(let[o,s]of n)e.set(r,o,t(s,r,o));return e}toMap(){let t=new Map;for(let[e,r]of this.map1)for(let[n,o]of r)t.set([e,n],o);return t}toString(){let t=[];for(let[e,r]of this.map1){let n=[...r].map(([o,s])=>`${Bt(o)} => ${Bt(s)}`).join(", ");t.push(`${Bt(e)} => { ${n} }`)}return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t} }`}},Us=class Fs extends jr{constructor(t){if(super(),mt(this,"map1"),mt(this,"key1Equals",ke),mt(this,"key2Equals",ke),mt(this,"key3Equals",ke),this.map1=new lt(this.key1Equals),t instanceof Fs)for(let[e,r]of t.map1){let n=this.map1.set(e,new lt(this.key2Equals));for(let[o,s]of r)n.set(o,new lt(s,this.key3Equals))}else if(t)for(let[e,r,n,o]of t)this.set(e,r,n,o)}has(t,e,r){var n,o,s;return(s=(o=(n=this.map1.get(t))==null?void 0:n.get(e))==null?void 0:o.has(r))!=null?s:!1}set(t,e,r,n){return this.map1.getOrCreate(t,()=>new lt(this.key2Equals)).getOrCreate(e,()=>new lt(this.key3Equals)).set(r,n),n}get(t,e,r){var n,o;return(o=(n=this.map1.get(t))==null?void 0:n.get(e))==null?void 0:o.get(r)}getOrDefault(t,e,r,n){var o;return(o=this.get(t,e,r))!=null?o:n}getOrCreate(t,e,r,n){if(!this.has(t,e,r)){let o=_r(n)?n():n;return this.set(t,e,r,o),o}return this.get(t,e,r)}delete(t,e,r){var n;if(r===void 0){if(e===void 0)return this.map1.delete(t);let o=this.map1.get(t);return o?o.delete(e):!1}else{if(e===void 0)return this.map1.delete(t);let o=(n=this.map1.get(t))==null?void 0:n.get(e);return o?o.delete(r):!1}}clear(){this.map1.clear()}get size(){let t=0;for(let e of this.map1.values())for(let r of e.values())t+=r.size;return t}isEmpty(){return this.size===0}forEach(t,e){this.map1.forEach((r,n)=>r.forEach((o,s)=>o.forEach((a,c)=>t.call(e,a,n,s,c,this))))}*keys(){for(let[t,e]of this.map1)for(let[r,n]of e)for(let o of n.keys())yield[t,r,o]}*values(){for(let t of this.map1.values())for(let e of t.values())for(let r of e.values())yield r}*entries(){for(let[t,e]of this.map1)for(let[r,n]of e)for(let[o,s]of n)yield[t,r,o,s]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let[t,e,r]of this.keys())yield[t,e,r]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e,r,n]of this.entries())yield[[t,e,r],n]}*[Symbol.iterator](){yield*de(this.entries())}clone(){return new Fs(this)}merge(t,e){for(let[r,n,o,s]of t.entries())this.has(r,n,o)&&e?this.set(r,n,o,e(this.get(r,n,o),s,r,n,o)):this.set(r,n,o,s);return this}some(t){for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)if(t(a,e,n,s))return!0;return!1}every(t){for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)if(!t(a,e,n,s))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)t(c,r,o,a,this)&&e.set(r,o,a,c);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty TriMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[3],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u,l,h]=a.value;o=t(o,h,c,u,l)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)e.push(t(c,r,o,a));return e}mapValues(t){let e=new Fs;for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)e.set(r,o,a,t(c,r,o,a));return e}toMap(){let t=new Map;for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)t.set([e,n,s],a);return t}toString(){let t=[];for(let[e,r]of this.map1)for(let[n,o]of r){let s=[...o].map(([a,c])=>`${Bt(a)} => ${Bt(c)}`).join(", ");t.push(`${Bt(e)} => ${Bt(n)} => { ${s} }`)}return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t.join(", ")} }`}},zs=class Si extends jr{constructor(...t){super(),mt(this,"data"),mt(this,"equals");let e=t.at(-1);this.equals=_r(e)?t.pop():ke;let r=t[0];this.data=new Set(r)}static createDeep(t){return t?new Si(t,uo):new Si(uo)}has(t){return this.equals===ke?this.data.has(t):this.some(e=>this.equals(e,t))}add(t){return this.has(t)||this.data.add(t),t}set(t,e){if(!this.equals(t,e))throw new TypeError("ValueSet.set() requires key === value.");this.add(e)}get(t){return this.has(t)?t:void 0}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=_r(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){if(this.equals===ke||this.data.has(t))return this.data.delete(t);for(let e of this.values())if(this.equals(e,t))return this.data.delete(e),!0;return!1}clear(){this.data.clear()}get size(){return this.data.size}isEmpty(){return this.size===0}forEach(t,e){this.data.forEach(r=>t.call(e,r,this))}*keys(){yield*de(this.data.keys())}*values(){yield*de(this.data.values())}*entries(){yield*de(this.data.entries())}*kvKeys(){for(let t of this.keys())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*de(this.values())}clone(){let t=new Si;for(let e of this.values())t.add(e);return t}merge(t){for(let e of t.values())this.add(e);return this}some(t){for(let e of this.data)if(t(e))return!0;return!1}every(t){for(let e of this.data)if(!t(e))return!1;return!0}filter(t){let e=new Si;for(let r of this.data)t(r,this)&&e.add(r);return e}reduce(t,e){let r=this.values(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty ValueSet with no initial value!");return e}let o,s;arguments.length<2?(o=n.value,s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let c=a.value;o=t(o,c)}return o}mapValues(t){let e=new Si;for(let r of this.data)e.add(t(r));return e}mapToArray(t){let e=[];for(let r of this.values())e.push(t(r));return e}map(t){let e=new Si;for(let r of this.values())e.add(t(r));return e}toSet(){return new Set(this.data)}toArray(){return[...this.values()]}toString(){return Bt(this.data)}},FA=class extends jr{constructor(i){super(),this.base=i}isEmpty(){return this.base.isEmpty()}clear(){var i,t;(t=(i=this.base).clear)==null||t.call(i)}add(...i){let t=i.slice(0,-1),e=i[i.length-1],r=this.base.get(...t);return this.base.set(...t,r?[...r,e]:[e]),e}remove(...i){let t=i.slice(0,-1),e=i[i.length-1],r=this.base.get(...t);if(!r)return!1;let n=r.indexOf(e);return n===-1?!1:(r.splice(n,1),r.length===0&&this.base.delete(...t),!0)}getAll(...i){var t;return(t=this.base.get(...i))!=null?t:[]}*iterAll(...i){yield*de(this.getAll(...i))}*values(){for(let i of this.keys())yield*de(this.getAll(...i))}*keys(){for(let i of this.base.kvKeys())yield i}*entries(){for(let i of this.keys()){let t=this.getAll(...i);t.length>0&&(yield[i,t])}}[Symbol.iterator](){return this.entries()}toString(){let i=[];for(let t of this.keys()){let e=this.getAll(...t),r=Array.isArray(t)?Bt(t):"[ ]",n=Array.isArray(e)?Bt(e):"[ ]";i.push(`${r} => ${n}`)}return i.length===0?"MultiContainer{ }":`MultiContainer{ ${i.join(", ")} }`}};function Ys(i){return new FA(i)}var pu={};rn(pu,{MusicError:()=>N,MusicErrorType:()=>Ct,init:()=>Ti});H.Dom.injectCss("wms-custom-css",`
3
3
  /* Add custom wms-button and wms-button-group styles */
4
4
 
5
5
  .wms-button {
@@ -79,9 +79,9 @@
79
79
  border-top-right-radius: var(--ifm-button-border-radius);
80
80
  border-bottom-right-radius: var(--ifm-button-border-radius);
81
81
  }
82
- `);var Ct=(c=>(c[c.Unknown=0]="Unknown",c[c.InvalidArg=1]="InvalidArg",c[c.Note=2]="Note",c[c.Scale=3]="Scale",c[c.KeySignature=4]="KeySignature",c[c.Timesignature=5]="Timesignature",c[c.Score=6]="Score",c[c.Audio=7]="Audio",c))(Ct||{});function BA(i){return i===void 0?"":`[${Ct[i]}] `}var N=class extends Error{constructor(...e){let[r,n]=e.length===1?[0,e[0]]:e;super(BA(r)+n);d(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var vl=!1;function Ti(){vl||(vl=!0,console.log("%cWebMusicScore v6.0.0-pre.4 (iife) initialized.","background: black; color: white; padding: 2px;"))}var ti=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(ti||{}),ei=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(ei||{}),GA=H.Enum.getEnumValues(ei),VA=0;function wl(i){if(y.isEnumValue(i,ei))return i;throw new N(1,`Invalid pitchNotation: ${i}`)}function qA(i){return ei[wl(i)]}var Hs=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Hs||{}),WA="Default",UA=H.Enum.getEnumValues(Hs);function zA(i){if(y.isEnumValue(i,Hs))return i;throw new N(5,`Invalid guitarNoteLabel: ${i}`)}function Sl(i,t){return(i%t+t)%t}var Il=12,Tl=7,YA=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),HA=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Nl=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),ho=["C","D","E","F","G","A","B"],Ol=[0,2,4,5,7,9,11],Rl=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,lt=class lt{constructor(t,e,r){d(this,"diatonicClass");d(this,"accidental");d(this,"octave");if(typeof t=="number"&&typeof e=="number"&&r===void 0)lt.validateDiatonicId(t),this.diatonicClass=lt.getDiatonicClass(t),this.accidental=lt.validateAccidental(e),this.octave=lt.getOctaveFromDiatonicId(t);else if(typeof t=="number"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=lt.validateDiatonicClass(t),this.accidental=lt.validateAccidental(e),this.octave=lt.validateOctave(r);else if(typeof t=="string"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=lt.getDiatonicClass(t),this.accidental=lt.validateAccidental(e),this.octave=lt.validateOctave(r);else throw new N(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return lt.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return lt.getChromaticIdInOctave(Ol[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return lt.getChromaticClass(Ol[this.diatonicClass]+this.accidental)}get noteLetter(){return ho[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:n}=this,o=lt.getAccidentalSymbol(this.accidental,e);return t===1?n>=3?r.toLowerCase()+o+"\u2032".repeat(n-3):r.toUpperCase()+o+"\u0375".repeat(2-n):r+o+n}formatOmitOctave(t){let e=ho[this.diatonicClass],r=lt.getAccidentalSymbol(this.accidental,t);return e+r}static getNote(t){return this.noteCache.getOrCreate(t,()=>{let e=lt.parseNote(t);if(!e)throw new N(2,`Invalid note "${t}".`);if(e.octave===void 0)throw new N(2,`Invalid note "${t}" (missing octave).`);return new lt(e.noteLetter,e.accidental,e.octave)})}static isNote(t){let e=lt.parseNote(t);return e!==void 0&&e.octave!==void 0}static validateNote(t){if(this.isNote(t))return!0;throw new N(2,`Invalid note "${t}"`)}static getChromaticNote(t){return this.chromaticNoteCache.getOrCreate(t,()=>{let r=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][lt.getChromaticClass(t)].split("/")[0]+lt.getOctaveFromChromaticId(t);return lt.getNote(r)})}static getDiatonicClass(t){if(typeof t=="number")return Sl(t,7);if(typeof t=="string"&&t.length>0)return ho.indexOf(lt.validateNoteLetter(t[0]));throw new N(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-Tl)/7)}static getDiatonicIdInOctave(t,e){return lt.getDiatonicClass(t)+e*7+Tl}static getChromaticClass(t){return Sl(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-Il)/12)}static getChromaticIdInOctave(t,e){return lt.getChromaticClass(t)+e*12+Il}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.diatonicId===e.diatonicId&&t.accidental===e.accidental}static replaceAccidentalSymbols(t,e){return e===1?t.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):t.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(t){return Rl.test(t)}static parseNote(t){var c;let e=Rl.exec(t);if(!e)return;let r=lt.validateNoteLetter(e[1]),n=e[2],o=lt.validateAccidental((c=Nl.get(n))!=null?c:0),s=e[3],a=s?lt.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(t,e){let r=lt.parseNote(t);if(!r)throw new N(2,`Invalid noteName: ${t}`);let{noteLetter:n,accidental:o,octave:s}=r;return n+lt.getAccidentalSymbol(o,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?HA.get(t):YA.get(t)}static getAccidental(t){let e=Nl.get(t);if(e===void 0)throw new N(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return ho[lt.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let n=lt.getDiatonicClass(t),o=lt.getDiatonicClass(e),s=r?n<=o?1:0:n<o?1:0;return lt.getDiatonicIdInOctave(n,lt.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(y.isInteger(t))return t;throw new N(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(y.isIntegerBetween(t,0,6))return t;throw new N(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(y.isInteger(t))return t;throw new N(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(y.isIntegerBetween(t,0,11))return t;throw new N(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(ho.some(e=>e===t))return t;throw new N(2,`Invalid note: ${t}`)}static validateOctave(t){if(y.isInteger(t))return t;throw new N(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(y.isIntegerBetween(t,-2,2))return t;throw new N(2,`Invalid accidental: ${t}`)}static sort(t){return t.slice().sort(lt.compareFunc)}static removeDuplicates(t){let e=[];return t.forEach(r=>{e.find(n=>lt.equals(r,n))===void 0&&e.push(r)}),e}static compareFunc(t,e){return t.diatonicId<e.diatonicId?-1:t.diatonicId>e.diatonicId?1:t.accidental<e.accidental?-1:t.accidental>e.accidental?1:0}};d(lt,"noteCache",new ht),d(lt,"chromaticNoteCache",new ht);var U=lt;function $A(i,t){let e=U.getChromaticClass(i)-new U(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return U.validateAccidental(e)}var ZA=/^(bb?|b?|#?|x?)([0-9]*)$/;function XA(i){var n,o;let t=ZA.exec(""+i);if(!t)throw new N(4,`Invalid degree: ${i}`);let e=(o=U.getAccidental((n=t[1])!=null?n:""))!=null?o:0,r=+t[2];if(!y.isInteger(e)||e<-2||e>2||!y.isInteger(r)||r<1)throw new N(4,`Invalid degree: ${i}`);return{deg:r,acc:e}}var mu=(a=>(a[a.Ionian=1]="Ionian",a[a.Dorian=2]="Dorian",a[a.Phrygian=3]="Phrygian",a[a.Lydian=4]="Lydian",a[a.Mixolydian=5]="Mixolydian",a[a.Aeolian=6]="Aeolian",a[a.Locrian=7]="Locrian",a))(mu||{}),fu=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(fu||{});function $s(){return Pr("C","Major")}var ri=class ri{constructor(t,e){this.tonic=t;this.mode=e;d(this,"naturalScaleNotes");d(this,"accidentalByDiatonicClass");d(this,"orderedAccidentedNotes");if(!y.isEnumValue(e,mu))throw new N(4,`Invalid mode: ${e}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<e;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let n=U.getDiatonicClass(t[0]),o=U.getNote(t+"0").chromaticId;for(let c=0;c<7;n++,o+=r[c],c++){let u=new U(U.getDiatonicClass(n),$A(o,n));if(Math.abs(u.accidental)>=2)throw new N(4,"Key signature contains double accidental.");this.naturalScaleNotes[c]=u,this.accidentalByDiatonicClass[u.diatonicClass]=u.accidental}let s=this.naturalScaleNotes.filter(c=>c.accidental>0).sort((c,u)=>{let h=ri.OrderOfSharps.indexOf(c.noteLetter),l=ri.OrderOfSharps.indexOf(u.noteLetter);if(h===-1||l===-1)throw new N(4,"Unexpected note in key signature.");return h-l}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let h=ri.OrderOfFlats.indexOf(c.noteLetter),l=ri.OrderOfFlats.indexOf(u.noteLetter);if(h===-1||l===-1)throw new N(4,"Unexpected note in key signature.");return h-l});if(s.length!==0&&a.length!==0)throw new N(4,"Key Signature has both sharps and flats.");this.orderedAccidentedNotes=a.length>0?a:s}getAccidentalType(){return this.orderedAccidentedNotes.length===0?0:this.orderedAccidentedNotes[0].accidental<0?1:2}getNaturalScaleNotes(){return this.naturalScaleNotes}getAccidental(t){var e;return(e=this.accidentalByDiatonicClass[U.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=XA(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let n=this.naturalScaleNotes[(e-1)%7];return new U(n.diatonicId,n.accidental+r)}}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.tonic===e.tonic&&t.mode===e.mode}};d(ri,"OrderOfSharps","FCGDAEB"),d(ri,"OrderOfFlats","BEADGCF");var rr=ri;var QA=new ht([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),KA={1:{0:"Perfect",1:"Augmented","-1":"diminished",2:"Doubly Augmented","-2":"doubly diminished"},2:{2:"Major",1:"minor",3:"Augmented",0:"diminished",4:"Doubly Augmented","-1":"doubly diminished"},3:{4:"Major",3:"minor",5:"Augmented",2:"diminished",6:"Doubly Augmented",1:"doubly diminished"},4:{5:"Perfect",6:"Augmented",4:"diminished",7:"Doubly Augmented",3:"doubly diminished"},5:{7:"Perfect",8:"Augmented",6:"diminished",9:"Doubly Augmented",5:"doubly diminished"},6:{9:"Major",8:"minor",10:"Augmented",7:"diminished",11:"Doubly Augmented",6:"doubly diminished"},7:{11:"Major",10:"minor",12:"Augmented",9:"diminished",13:"Doubly Augmented",8:"doubly diminished"},8:{12:"Perfect",13:"Augmented",11:"diminished",14:"Doubly Augmented",10:"doubly diminished"}};function JA(i,t){for(;i<1;)i+=7,t+=12;for(;i>8;)i-=7,t-=12;let e=KA[i];if(e)return e[t]}function tC(i){if(i==="Perfect"||i==="Major"||i==="minor"||i==="Augmented"||i==="diminished"||i==="Doubly Augmented"||i==="doubly diminished")return i;throw new N(1,`Invalid interval quality: ${i}`)}function eC(i){if(y.isIntegerGte(i,1))return H.Math.toOrdinalNumber(i);throw new N(1,`Invalid interval quantity: ${i}`)}var Zs=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},lo=class i{constructor(t,e){this.note1=t;this.note2=e;d(this,"direction");d(this,"semitones");d(this,"quantity");d(this,"quality");e.diatonicId>=t.diatonicId?(this.direction=e.diatonicId===t.diatonicId?"Unison":"Ascending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId):(this.direction="Descending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId);let r=JA(this.quantity,this.semitones);if(r)this.quality=r;else throw new Zs("Unknown interval quality")}static get(t,e){try{return new i(t,e)}catch(r){if(r instanceof Zs)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":eC(this.quantity);return t+e+r}toAbbrString(){let t=this.direction==="Descending"?"\u2193":"",e=QA.getOrDefault(this.quality,"?"),r=this.quantity;return t+e+r}};function rC(i){let t=U.getDiatonicClass("CCDDEFFGGAAB"[U.getChromaticClass(i)]),e=U.getOctaveFromChromaticId(i);return U.getDiatonicIdInOctave(t,e)}var iC=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],Ni=(g=>(g.Major="Major",g.NaturalMinor="Natural Minor",g.HarmonicMinor="Harmonic Minor",g.Ionian="Ionian",g.Dorian="Dorian",g.Phrygian="Phrygian",g.Lydian="Lydian",g.Mixolydian="Mixolydian",g.Aeolian="Aeolian",g.Locrian="Locrian",g.MajorPentatonic="Major Pentatonic",g.MinorPentatonic="Minor Pentatonic",g.MajorHexatonicBlues="Major Hexatonic Blues",g.MinorHexatonicBlues="Minor Hexatonic Blues",g.HeptatonicBlues="Heptatonic Blues",g))(Ni||{});function nC(i){switch(i){case"Major":return 1;case"Natural Minor":return 6;case"Harmonic Minor":return 6;case"Ionian":return 1;case"Dorian":return 2;case"Phrygian":return 3;case"Lydian":return 4;case"Mixolydian":return 5;case"Aeolian":return 6;case"Locrian":return 7;case"Major Pentatonic":return 1;case"Minor Pentatonic":return 6;case"Major Hexatonic Blues":return 1;case"Minor Hexatonic Blues":return 6;case"Heptatonic Blues":return 1;default:throw new N(3,`Invalid scaleType: ${i}`)}}var ii=class extends rr{constructor(e,r){super(e,nC(r));this.tonic=e;this.scaleType=r;d(this,"scaleDegrees");d(this,"scaleNotes");d(this,"chromaticClassDegree");d(this,"preferredChromaticIdNoteCache",new Cl);switch(r){case"Harmonic Minor":this.scaleDegrees=[1,2,3,4,5,6,"#7"];break;case"Major Pentatonic":this.scaleDegrees=[1,2,3,5,6];break;case"Minor Pentatonic":this.scaleDegrees=[1,3,4,5,7];break;case"Major Hexatonic Blues":this.scaleDegrees=[1,2,"b3",3,5,6];break;case"Minor Hexatonic Blues":this.scaleDegrees=[1,3,4,"b5",5,7];break;case"Heptatonic Blues":this.scaleDegrees=[1,2,"b3",4,"b5",6,"b7"];break;default:this.scaleDegrees=[1,2,3,4,5,6,7];break}this.scaleNotes=this.scaleDegrees.map(n=>this.getNoteByDegree(n)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(n=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===n);return o>=0?this.scaleDegrees[o]:void 0})}static equals(e,r){return e==null&&r==null?!0:e==null||r==null?!1:e===r||e.getScaleName()===r.getScaleName()}getScaleName(e){switch(e){case 1:return U.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!y.isIntegerGte(r,1))throw new N(3,`Invalid numOctaves: ${r}`);let n=[];for(let s=1;s<=r;s++)n=[...n,...this.scaleNotes];n.push(this.scaleNotes[0]);let o=U.getNote(e).diatonicId;return n.map(s=>(o=U.findNextDiatonicIdAbove(s.diatonicId,o,!1),new U(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(e=>e.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let e=this.getScaleNotes("C4",1).map(n=>n.chromaticId),r=[];for(let n=0;n<e.length-1;n++)r.push(H.Math.mod(e[n+1]-e[n],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(e=>e===1?"H":e===2?"W":e.toString()+"H")}isScaleNote(e){return this.chromaticClassDegree[e.chromaticClass]!==void 0}isScaleRootNote(e){return String(this.chromaticClassDegree[e.chromaticClass])==="1"}getIntervalFromRootNote(e){let r=this.getScaleNotes("C0",1)[0];for(;e.chromaticId>=r.chromaticId+12;)e=new U(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new N(3,"Note is below rootNote.");let n=lo.get(r,e);if(n===void 0)throw new N(3,"Interval is undefined.");return n}getPreferredChromaticNote(e){U.validateChromaticId(e);let r=this.preferredChromaticIdNoteCache.get(e);if(r)return r;let n=U.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(l=>l.noteLetter==="C"&&l.accidental<0?new U(l.diatonicClass,l.accidental,n+1):l.noteLetter==="B"&&l.accidental>0?new U(l.diatonicClass,l.accidental,n-1):new U(l.diatonicClass,l.accidental,n)).find(l=>U.getChromaticClass(e)===l.chromaticClass),r)return this.preferredChromaticIdNoteCache.set(e,r),r;let s=rC(e),a=s-2,c=s+2,h=this.getAccidentalType()===1?[0,-1,1,-2,2]:[0,1,-1,2,-2];for(let l=0;l<h.length;l++){let p=h[l];for(let m=Math.max(0,a);m<=c;m++)if(r=new U(m,p),e===r.chromaticId)return this.preferredChromaticIdNoteCache.set(e,r),r}return r=U.getChromaticNote(e),this.preferredChromaticIdNoteCache.set(e,r),r}},ie=class{constructor(t){this.type=t;d(this,"tonicList",[]);d(this,"scaleMap",new Map);let e=[],r=[],n=[];if(iC.forEach(s=>{try{let a=new ii(s,this.type);switch(a.getAccidentalType()){case 0:e.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;n.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),e.length===0)throw new N(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...n.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(t){let e=this.scaleMap.get(t);if(e)return e;throw new N(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},Ml=[new ie("Major"),new ie("Natural Minor"),new ie("Harmonic Minor"),"- Modes -",new ie("Ionian"),new ie("Dorian"),new ie("Phrygian"),new ie("Lydian"),new ie("Mixolydian"),new ie("Aeolian"),new ie("Locrian"),"- Pentatonic -",new ie("Major Pentatonic"),new ie("Minor Pentatonic"),"- Blues -",new ie("Major Hexatonic Blues"),new ie("Minor Hexatonic Blues"),new ie("Heptatonic Blues")];function oC(){return Ml}var El=new ht;Ml.forEach(i=>{i instanceof ie&&El.set(i.getType(),i)});function Dl(i){let t=El.get(i);if(t)return t;throw new N(3,`Invalid scaleType: ${i}`)}function po(i){if(y.isEnumValue(i,Ni))return i;throw new N(3,`Invalid scaleType: "${i}"`)}function Pr(i,t){let e,r;return t!==void 0?(e=i,r=po(t)):(e=i.split(" ")[0],r=po(i.substring(e.length+1))),Dl(r).getScale(e)}var sC=Pr("C","Major");function aC(){return sC}var Fr=(i,t)=>i.chromaticClass===t.chromaticClass,cC=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(i=>U.getNote(i+"0")),uC=new vr;function hC(i){return uC.getOrCreate(i.chromaticClass,()=>{let t=cC.find(e=>Fr(e,i));if(!t)throw new N(1,`Invalid chord root note: ${i.formatOmitOctave(1)}`);return t})}function lC(i,t){let e=i.formatOmitOctave(0);return Pr(e,"Major").getNoteByDegree(t)}function dC(i){return H.Arr.removeDuplicates(i,Fr)}var pC=[{name:"5",degrees:[1,5]},{name:"",degrees:[1,3,5]},{name:"m",degrees:[1,"b3",5]},{name:"dim",degrees:[1,"b3","b5"]},{name:"aug",degrees:[1,3,"#5"]},{name:"sus2",degrees:[1,2,5]},{name:"sus4",degrees:[1,4,5]},{name:"6",degrees:[1,3,5,6]},{name:"m6",degrees:[1,"b3",5,6]},{name:"m(maj7)",degrees:[1,"b3",5,7]},{name:"7",degrees:[1,3,5,"b7"]},{name:"7\u266D5",degrees:[1,3,"b5","b7"]},{name:"7\u266F5",degrees:[1,3,"#5","b7"]},{name:"7sus2",degrees:[1,2,5,"b7"]},{name:"7sus4",degrees:[1,4,5,"b7"]},{name:"dim7",degrees:[1,"b3","b5","bb7"]},{name:"maj7",degrees:[1,3,5,7]},{name:"maj7\u266D5",degrees:[1,3,"b5",7]},{name:"maj7\u266F5",degrees:[1,3,"#5",7]},{name:"m7",degrees:[1,"b3",5,"b7"]},{name:"m7\u266D5",degrees:[1,"b3","b5","b7"]},{name:"m7\u266F5",degrees:[1,"b3","#5","b7"]},{name:"9",degrees:[1,3,5,"b7",9]},{name:"m9",degrees:[1,"b3",5,"b7",9]},{name:"7\u266F9",degrees:[1,3,5,"b7","#9"]},{name:"7\u266D9",degrees:[1,3,5,"b7","b9"]},{name:"11",degrees:[1,3,5,"b7",9,11]},{name:"m11",degrees:[1,"b3",5,"b7",9,11]},{name:"13",degrees:[1,3,5,"b7",9,11,13]},{name:"m13",degrees:[1,"b3",5,"b7",9,11,13]}];function mC(i,t){return i.degrees.every(e=>e!==t)?!0:i.degrees.length>=4&&t===5||i.degrees.length>=6&&t===9||i.degrees.length>=7&&t===11}var on=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},gu=class i{constructor(t,e,r,n){this.chordInfo=t;this.rootNote=r;d(this,"name");d(this,"notes");d(this,"omitNotes");d(this,"slashBassNote");this.name=t.name;let o=e.slice();!o.some(a=>Fr(a,n))&&o.push(n),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<t.degrees.length;a++){let c=t.degrees[a],u=this.notes[a]=lC(this.rootNote,c),h=o.findIndex(l=>Fr(l,u));if(h>=0)this.omitNotes[a]=!1,o.splice(h,1);else if(mC(t,c))this.omitNotes[a]=!0;else throw new on("Missing chord note!");Fr(n,u)&&(n=u)}if(o.length>0)if(o.every(a=>Fr(a,n)))this.slashBassNote=n;else throw new on("Got some extra notes that are not bass note!");else this.slashBassNote=Fr(n,this.rootNote)?void 0:n;if(t.name==="5"&&this.slashBassNote)throw new on("Power chord no bass note allowed!")}static getChords(t){let e=[],r=U.sort(t),n=r[0],o=dC(r);for(let s=0;s<o.length;s++){let a=hC(o[s]);pC.forEach(c=>{try{let u=new i(c,o,a,n),h=e.findIndex(l=>l.replaceWith(u));h>=0?e[h]=u:e.push(u)}catch(u){if(!(u instanceof on))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!Fr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!Fr(t.notes[e],this.notes[e])||t.omitNotes[e]!==this.omitNotes[e])return!1;return!0}toString(){let t=1,e=this.rootNote.formatOmitOctave(t),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(t):"";return e+this.name+r}getDegreeNotationString(){let t=1,e=this.slashBassNote?this.slashBassNote.formatOmitOctave(t)+" - ":"",r=this.omitNotes.map((n,o)=>this.getDegreeStr(o)+"("+(n?"-":this.getNoteStr(o))+")").join(" - ");return e+r}getOmittedDegreesString(){let t=this.omitNotes.map((e,r)=>e?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(e=>e!==void 0);return t.length>0?"Omits "+t.join(", "):""}getDegreeStr(t){return U.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var yu={list:[{name:"Standard",strings:["E2","A2","D3","G3","B3","E4"]},{name:"B Standard",strings:["B1","E2","A2","D3","F#3","B3"]},{name:"C Standard",strings:["C2","F2","A#2","D#3","G3","C4"]},{name:"D Modal",strings:["D2","A2","D3","G3","A3","D4"]},{name:"D Standard",strings:["D2","G2","C3","F3","A3","D4"]},{name:"D# Standard",strings:["D#2","G#2","C#3","F#3","A#3","D#4"]},{name:"Double Drop D",strings:["D2","A2","D3","G3","B3","D4"]},{name:"Drop B",strings:["B1","F#2","B2","E3","G#3","C#4"]},{name:"Drop C",strings:["C2","G2","C3","F3","A3","D4"]},{name:"Drop D",strings:["D2","A2","D3","G3","B3","E4"]},{name:"Low C",strings:["C2","G2","D3","G3","A3","D4"]},{name:"New Standard",strings:["C2","G2","D3","A3","E4","G4"]},{name:"Open A",strings:["E2","A2","C#3","E3","A3","E4"]},{name:"Open A Minor",strings:["E2","A2","E3","A3","C4","E4"]},{name:"Open C",strings:["C2","G2","C3","G3","C4","E4"]},{name:"Open C Minor",strings:["C2","G2","C3","G3","C4","D#4"]},{name:"Open D",strings:["D2","A2","D3","F#3","A3","D4"]},{name:"Open D Minor",strings:["D2","A2","D3","F3","A3","D4"]},{name:"Open E",strings:["E2","B2","E3","G#3","B3","E4"]},{name:"Open E Minor",strings:["E2","B2","E3","G3","B3","E4"]},{name:"Open G",strings:["D2","G2","D3","G3","B3","D4"]},{name:"Open G Minor",strings:["D2","G2","D3","G3","A#3","D4"]}]};var mo=yu.list.map(i=>i.name),gC=mo[0];function bu(i){if(mo.indexOf(i)<0)throw new N(1,`Invalid tuning name: ${i}`);return i}var kl=new Al(100);function Xs(i){let t=kl.get(i);if(!t){let e=yu.list.find(r=>r.name===i);if(!e)throw new N(1,`Invalid tuningName: ${i}`);if(t=e.strings.slice().reverse().map(r=>U.getNote(r)),!y.isIntegerEq(t.length,6))throw new N(0,`Tuning has ${t.length} strings.`);kl.set(i,t)}return t}var Ll=12,yC=1188*7*5,ir=(k=>(k.Whole="1n",k.WholeTriplet="1t",k.WholeDot="1.",k.Whole2Dots="1..",k.Whole3Dots="1...",k.Whole4Dots="1....",k.Whole5Dots="1.....",k.Whole6Dots="1......",k.Half="2n",k.HalfTriplet="2t",k.HalfDot="2.",k.Half2Dots="2..",k.Half3Dots="2...",k.Half4Dots="2....",k.Half5Dots="2.....",k.Quarter="4n",k.QuarterTriplet="4t",k.QuarterDot="4.",k.Quarter2Dots="4..",k.Quarter3Dots="4...",k.Quarter4Dots="4....",k.Eighth="8n",k.EighthTriplet="8t",k.EighthDot="8.",k.Eighth2Dots="8..",k.Eighth3Dots="8...",k.Sixteenth="16n",k.SixteenthTriplet="16t",k.SixteenthDot="16.",k.Sixteenth2Dots="16..",k.ThirtySecond="32n",k.ThirtySecondTriplet="32t",k.ThirtySecondDot="32.",k.SixtyFourth="64n",k.SixtyFourthTriplet="64t",k))(ir||{});function nr(i){return y.isEnumValue(i,ir)}function Br(i){if(nr(i))return i;throw new N(1,`Invalid noteLength: ${i}`)}var pe=class pe{constructor(t){d(this,"noteLength");d(this,"noteSize");d(this,"ticks");d(this,"flagCount");d(this,"dotCount");d(this,"maxDotCount");d(this,"isTriplet");d(this,"hasStem");d(this,"isSolid");if(this.noteLength=Br(t),this.noteSize=parseInt(t),this.isTriplet=t.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(pe.ShortestNoteSize/this.noteSize)),this.dotCount=H.Str.charCount(t,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=yC*pe.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new N(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new N(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(t){return this.cache.getOrCreate(t,()=>new pe(t))}static create(t,e=0){let r=typeof t=="number"?t:this.get(t).noteSize;return this.get(r+(y.isIntegerGte(e,1)?".".repeat(e):"n"))}static cmp(t,e){let r=t instanceof pe?t.noteSize:typeof t=="number"?t:pe.get(t).noteSize,n=e instanceof pe?e.noteSize:typeof e=="number"?e:pe.get(e).noteSize;return H.Math.cmp(n,r)}static equals(t,e){let r=t instanceof pe?t.noteSize:typeof t=="number"?t:pe.get(t).noteSize,n=e instanceof pe?e.noteSize:typeof e=="number"?e:pe.get(e).noteSize;return r===n}};d(pe,"LongestNoteSize",Math.min(...H.Enum.getEnumValues(ir).map(t=>parseInt(t)))),d(pe,"ShortestNoteSize",Math.max(...H.Enum.getEnumValues(ir).map(t=>parseInt(t)))),d(pe,"cache",new ht);var Tt=pe;function Qs(i){return y.isObject(i)&&y.isIntegerBetween(i.parts,2,Ll)&&y.isIntegerBetween(i.inTimeOf,2,Ll)}function jl(i){if(Qs(i))return i;throw new N(2,`Invalid tupletRatio ${JSON.stringify(i)}`)}var Gr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},Oi=class Oi{constructor(t,e,r){d(this,"noteLength");d(this,"noteSize");d(this,"dotCount");d(this,"tupletRatio");d(this,"ticks");d(this,"flagCount");d(this,"hasStem");d(this,"isSolidNoteHead");this.noteLength=Br(t);let n=Tt.get(t);if(this.noteSize=n.noteSize,this.ticks=n.ticks,this.flagCount=n.flagCount,this.dotCount=e!=null?e:n.dotCount,this.hasStem=n.hasStem,this.isSolidNoteHead=n.isSolid,y.isObject(r)?this.tupletRatio=jl(r):n.isTriplet?this.tupletRatio=Gr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new N(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>n.maxDotCount)throw new N(2,`Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);for(let o=this.ticks/2,s=1;s<=this.dotCount;s++,o/=2)this.ticks+=o;this.tupletRatio&&(this.ticks*=this.tupletRatio.inTimeOf/this.tupletRatio.parts)}toString(){let t=Oi.NoteSymbolMap.get(this.noteSize),e=".".repeat(this.dotCount);return t?t+e:""+this.noteSize+(e.length>0?e:"n")}static get(t,e,r){return e!==void 0||r!==void 0?new Oi(t,e,r):this.cache.getOrCreate(t,()=>new Oi(t))}static cmp(t,e){return H.Math.cmp(t.ticks,e.ticks)}static equals(t,e){return t.ticks===e.ticks}};d(Oi,"NoteSymbolMap",new vr([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),d(Oi,"cache",new ht);var Qt=Oi;var fo=(u=>(u._2_4="2/4",u._3_4="3/4",u._4_4="4/4",u._3_8="3/8",u._5_8="5/8",u._6_8="6/8",u._7_8="7/8",u._9_8="9/8",u._12_8="12/8",u))(fo||{}),Ri=(n=>(n._2_3="2-3",n._3_2="3-2",n._2_2_3="2-2-3",n._3_2_2="3-2-2",n))(Ri||{}),ni=class{constructor(...t){d(this,"beatCount");d(this,"beatSize");d(this,"beatLength");d(this,"measureTicks");d(this,"beamGroupSizes",[]);let e;if(y.isEnumValue(t[0],fo)){let o=t[0].split("/");this.beatCount=+o[0],this.beatSize=+o[1],y.isEnumValue(t[1],Ri)&&(e=t[1])}else if(y.isIntegerGte(t[0],2)&&y.isIntegerGte(t[1],2))this.beatCount=t[0],this.beatSize=t[1],y.isEnumValue(t[2],Ri)&&(e=t[2]);else throw new N(5,`Invalid args: ${t}`);if(y.isIntegerGte(this.beatCount,1)){if(!y.isIntegerGte(this.beatSize,1))throw new N(5,`Invalid beatSize: ${this.beatSize}`)}else throw new N(5,`Invalid beatCount: ${this.beatCount}`);let{noteLength:r,ticks:n}=Tt.create(this.beatSize);if(this.beatLength=r,this.measureTicks=this.beatCount*n,this.is(2,4))this.beamGroupSizes=[[2],[2]];else if(this.is(3,4))this.beamGroupSizes=[[2],[2],[2]];else if(this.is(4,4))this.beamGroupSizes=[[2,2],[2,2]];else if(this.is(3,8))this.beamGroupSizes=[[3]];else if(this.is(5,8)){if(!y.isUndefined(e)&&e!=="2-3"&&e!=="3-2")throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2"?[[3],[2]]:[[2],[3]],e=void 0}else if(this.is(6,8))this.beamGroupSizes=[[3],[3]];else if(this.is(7,8)){if(!y.isUndefined(e)&&e!=="2-2-3"&&e!=="3-2-2")throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2-2"?[[3],[2],[2]]:[[2],[2],[3]],e=void 0}else this.is(9,8)?this.beamGroupSizes=[[3],[3],[3]]:this.is(12,8)&&(this.beamGroupSizes=[[3],[3],[3],[3]]);if(this.beamGroupSizes.length===0)throw new N(5,`Unimplemented time signature "${this.toString()}".`);if(e!==void 0)throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},xu;function Ks(){return xu||(xu=new ni(4,4)),xu}var Au;function Js(){return Au||(Au={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),Au}function ta(i){return Qt.get(i.options.beatLength,i.options.dotCount).toString()+"="+i.beatsPerMinute}function Cu(i,t){return{beatsPerMinute:i.beatsPerMinute*t,options:{beatLength:i.options.beatLength,dotCount:i.options.dotCount}}}Ti();function ea(i){return!isFinite(i)||i<=0?-1/0:20*Math.log10(i)}var go="15.1.22";var vu=(i,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:i});var wu=(i,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:i});var sn=(i,t)=>({startTime:t,type:"setValue",value:i});var yo=(i,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:i});var ra=(i,t,{startTime:e,target:r,timeConstant:n})=>r+(t-r)*Math.exp((e-i)/n);var Vr=i=>i.type==="exponentialRampToValue";var Mi=i=>i.type==="linearRampToValue";var or=i=>Vr(i)||Mi(i);var an=i=>i.type==="setValue";var We=i=>i.type==="setValueCurve";var cn=(i,t,e,r)=>{let n=i[t];return n===void 0?r:or(n)||an(n)?n.value:We(n)?n.values[n.values.length-1]:ra(e,cn(i,t-1,n.startTime,r),n)};var Su=(i,t,e,r,n)=>e===void 0?[r.insertTime,n]:or(e)?[e.endTime,e.value]:an(e)?[e.startTime,e.value]:We(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,cn(i,t-1,e.startTime,n)];var bo=i=>i.type==="cancelAndHold";var xo=i=>i.type==="cancelScheduledValues";var qr=i=>bo(i)||xo(i)?i.cancelTime:Vr(i)||Mi(i)?i.endTime:i.startTime;var Iu=(i,t,e,{endTime:r,value:n})=>e===n?n:0<e&&0<n||e<0&&n<0?e*Xh(n/e,(i-t)/(r-t)):0;var Tu=(i,t,e,{endTime:r,value:n})=>e+(i-t)/(r-t)*(n-e);var Pl=(i,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?i[e]:(1-(t-e))*i[e]+(1-(r-t))*i[r]};var Fl=(i,{duration:t,startTime:e,values:r})=>{let n=(i-e)/t*(r.length-1);return Pl(r,n)};var Ao=i=>i.type==="setTarget";var Co=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=qr(t);if(bo(t)||xo(t)){let r=this._automationEvents.findIndex(o=>xo(t)&&We(o)?o.startTime+o.duration>=e:qr(o)>=e),n=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),bo(t)){let o=this._automationEvents[this._automationEvents.length-1];if(n!==void 0&&or(n)){if(o!==void 0&&Ao(o))throw new Error("The internal list is malformed.");let s=o===void 0?n.insertTime:We(o)?o.startTime+o.duration:qr(o),a=o===void 0?this._defaultValue:We(o)?o.values[o.values.length-1]:o.value,c=Vr(n)?Iu(e,s,a,n):Tu(e,s,a,n),u=Vr(n)?vu(c,e,this._currenTime):wu(c,e,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Ao(o)&&this._automationEvents.push(sn(this.getValue(e),e)),o!==void 0&&We(o)&&o.startTime+o.duration>e){let s=e-o.startTime,a=(o.values.length-1)/o.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,h=o.values.slice(0,c);if(u<1)for(let l=1;l<c;l+=1){let p=u*l%1;h[l]=o.values[l-1]*(1-p)+o.values[l]*p}this._automationEvents[this._automationEvents.length-1]=yo(h,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>qr(s)>e),n=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(n!==void 0&&We(n)&&qr(n)+n.duration>e)return!1;let o=Vr(t)?vu(t.value,t.endTime,this._currenTime):Mi(t)?wu(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(o);else{if(We(t)&&e+t.duration>qr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>qr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),n=r[0];Ao(n)&&r.unshift(sn(cn(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=r}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;let e=this._automationEvents.findIndex(s=>qr(s)>t),r=this._automationEvents[e],n=(e===-1?this._automationEvents.length:e)-1,o=this._automationEvents[n];if(o!==void 0&&Ao(o)&&(r===void 0||!or(r)||r.insertTime>t))return ra(t,cn(this._automationEvents,n-1,o.startTime,this._defaultValue),o);if(o!==void 0&&an(o)&&(r===void 0||!or(r)))return o.value;if(o!==void 0&&We(o)&&(r===void 0||!or(r)||o.startTime+o.duration>t))return t<o.startTime+o.duration?Fl(t,o):o.values[o.values.length-1];if(o!==void 0&&or(o)&&(r===void 0||!or(r)))return o.value;if(r!==void 0&&Vr(r)){let[s,a]=Su(this._automationEvents,n,o,r,this._defaultValue);return Iu(t,s,a,r)}if(r!==void 0&&Mi(r)){let[s,a]=Su(this._automationEvents,n,o,r,this._defaultValue);return Tu(t,s,a,r)}return this._defaultValue}};var Nu=i=>({cancelTime:i,type:"cancelAndHold"});var Ou=i=>({cancelTime:i,type:"cancelScheduledValues"});var Ru=(i,t)=>({endTime:t,type:"exponentialRampToValue",value:i});var Mu=(i,t)=>({endTime:t,type:"linearRampToValue",value:i});var Eu=(i,t,e)=>({startTime:t,target:i,timeConstant:e,type:"setTarget"});var Bl=()=>new DOMException("","AbortError");var Gl=i=>(t,e,[r,n,o],s)=>{i(t[n],[e,r,o],a=>a[0]===e&&a[1]===r,s)};var Vl=i=>(t,e,r)=>{let n=[];for(let o=0;o<r.numberOfInputs;o+=1)n.push(new Set);i.set(t,{activeInputs:n,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var ql=i=>(t,e)=>{i.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var wr=new WeakSet,ia=new WeakMap,un=new WeakMap,na=new WeakMap,_o=new WeakMap,hn=new WeakMap,oa=new WeakMap,vo=new WeakMap,wo=new WeakMap,So=new WeakMap;var Wl={construct(){return Wl}},Ul=i=>{try{let t=new Proxy(i,Wl);new t}catch(t){return!1}return!0};var zl=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Du=(i,t)=>{let e=[],r=i.replace(/^[\s]+/,""),n=r.match(zl);for(;n!==null;){let o=n[1].slice(1,-1),s=n[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,t).toString());e.push(s),r=r.slice(n[0].length).replace(/^[\s]+/,""),n=r.match(zl)}return[e.join(";"),r]};var Yl=i=>{if(i!==void 0&&!Array.isArray(i))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Hl=i=>{if(!Ul(i))throw new TypeError("The given value for processorCtor should be a constructor.");if(i.prototype===null||typeof i.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},$l=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>{let m=0;return(f,g,b={credentials:"omit"})=>{let x=h.get(f);if(x!==void 0&&x.has(g))return Promise.resolve();let _=u.get(f);if(_!==void 0){let S=_.get(g);if(S!==void 0)return S}let w=o(f),T=w.audioWorklet===void 0?n(g).then(([S,v])=>{let[A,C]=Du(S,v),E=`${A};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${C}
83
- })})(window,'_AWGS')`;return e(E)}).then(()=>{let S=p._AWGS.pop();if(S===void 0)throw new SyntaxError;r(w.currentTime,w.sampleRate,()=>S(class{},void 0,(v,A)=>{if(v.trim()==="")throw t();let C=wo.get(w);if(C!==void 0){if(C.has(v))throw t();Hl(A),Yl(A.parameterDescriptors),C.set(v,A)}else Hl(A),Yl(A.parameterDescriptors),wo.set(w,new Map([[v,A]]))},w.sampleRate,void 0,void 0))}):Promise.all([n(g),Promise.resolve(i(l,l))]).then(([[S,v],A])=>{let C=m+1;m=C;let[E,q]=Du(S,v),D=`${E};((AudioWorkletProcessor,registerProcessor)=>{${q}
84
- })(${A?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${A?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${A?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${C}',class extends AudioWorkletProcessor{process(){return !1}})`,j=new Blob([D],{type:"application/javascript; charset=utf-8"}),F=URL.createObjectURL(j);return w.audioWorklet.addModule(F,b).then(()=>{if(a(w))return w;let W=s(w);return W.audioWorklet.addModule(F,b).then(()=>W)}).then(W=>{if(c===null)throw new SyntaxError;try{new c(W,`__sac${C}`)}catch(Q){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(F))});return _===void 0?u.set(f,new Map([[g,T]])):_.set(g,T),T.then(()=>{let S=h.get(f);S===void 0?h.set(f,new Set([g])):S.add(g)}).finally(()=>{let S=u.get(f);S!==void 0&&S.delete(g)}),T}};var Kt=(i,t)=>{let e=i.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var oi=(i,t)=>{let e=Array.from(i).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");let[r]=e;return i.delete(r),r};var sa=(i,t,e,r)=>{let n=Kt(i,t),o=oi(n,s=>s[0]===e&&s[1]===r);return n.size===0&&i.delete(t),o};var Sr=i=>Kt(oa,i);var sr=i=>{if(wr.has(i))throw new Error("The AudioNode is already stored.");wr.add(i),Sr(i).forEach(t=>t(!0))};var aa=i=>"port"in i;var Ir=i=>{if(!wr.has(i))throw new Error("The AudioNode is not stored.");wr.delete(i),Sr(i).forEach(t=>t(!1))};var Io=(i,t)=>{!aa(i)&&t.every(e=>e.size===0)&&Ir(i)};var Zl=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>{let m=new WeakMap;return(f,g,b,x,_)=>{let{activeInputs:w,passiveInputs:T}=o(g),{outputs:S}=o(f),v=a(f),A=C=>{let E=c(g),q=c(f);if(C){let M=sa(T,f,b,x);i(w,f,M,!1),!_&&!l(f)&&e(q,E,b,x),p(g)&&sr(g)}else{let M=r(w,f,b,x);t(T,x,M,!1),!_&&!l(f)&&n(q,E,b,x);let R=s(g);if(R===0)h(g)&&Io(g,w);else{let B=m.get(g);B!==void 0&&clearTimeout(B),m.set(g,setTimeout(()=>{h(g)&&Io(g,w)},R*1e3))}}};return u(S,[g,b,x],C=>C[0]===g&&C[1]===b&&C[2]===x,!0)?(v.add(A),h(f)?i(w,f,[b,x,A],!0):t(T,x,[f,b,A],!0),!0):!1}};var Xl=i=>(t,e,[r,n,o],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[n,e,o]])):i(a,[n,e,o],c=>c[0]===n&&c[1]===e,s)};var Ql=i=>(t,e)=>{let r=i(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(r).connect(t.destination);let n=()=>{e.removeEventListener("ended",n),e.disconnect(r),r.disconnect()};e.addEventListener("ended",n)};var Kl=i=>(t,e)=>{i(t).add(e)};var bC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Jl=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),h=O(O({},bC),c),l=r(u,h),p=o(u)?t():null;super(a,!1,l,p),this._nativeAnalyserNode=l}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){let c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){let c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}};var _t=(i,t)=>i.context===t;var td=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var ln=i=>{try{i.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var Ue=()=>new DOMException("","IndexSizeError");var dn=i=>{i.getChannelData=(t=>e=>{try{return t.call(i,e)}catch(r){throw r.code===12?Ue():r}})(i.getChannelData)};var xC={numberOfChannels:1},ed=(i,t,e,r,n,o,s,a)=>{let c=null;return class rd{constructor(h){if(n===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:l,numberOfChannels:p,sampleRate:m}=O(O({},xC),h);c===null&&(c=new n(1,1,44100));let f=r!==null&&t(o,o)?new r({length:l,numberOfChannels:p,sampleRate:m}):c.createBuffer(p,l,m);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),dn(f)):t(ln,()=>ln(f))||a(f),i.add(f),f}static[Symbol.hasInstance](h){return h!==null&&typeof h=="object"&&Object.getPrototypeOf(h)===rd.prototype||i.has(h)}}};var Ht=-34028234663852886e22,Wt=-Ht;var be=i=>wr.has(i);var AC={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},id=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=O(O({},AC),h),m=n(l,p),f=s(l),g=f?t():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=e(this,f,m.playbackRate,Wt,Ht)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(u){if(this._nativeAudioBufferSourceNode.buffer=u,u!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(u){this._nativeAudioBufferSourceNode.loop=u}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(u){this._nativeAudioBufferSourceNode.loopEnd=u}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(u){this._nativeAudioBufferSourceNode.loopStart=u}get onended(){return this._onended}set onended(u){let h=typeof u=="function"?a(this,u):null;this._nativeAudioBufferSourceNode.onended=h;let l=this._nativeAudioBufferSourceNode.onended;this._onended=l!==null&&l===h?u:l}get playbackRate(){return this._playbackRate}start(u=0,h=0,l){if(this._nativeAudioBufferSourceNode.start(u,h,l),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=l===void 0?[u,h]:[u,h,l]),this.context.state!=="closed"){sr(this);let p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),be(this)&&Ir(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var nd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,h)=>K(null,null,function*(){let l=e(u),p=_t(l,h);if(!p){let m={buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value};l=t(h,m),s!==null&&l.start(...s),a!==null&&l.stop(a)}return o.set(h,l),p?yield i(h,u.playbackRate,l.playbackRate):yield r(h,u.playbackRate,l.playbackRate),yield n(u,h,l),l});return{set start(u){s=u},set stop(u){a=u},render(u,h){let l=o.get(h);return l!==void 0?Promise.resolve(l):c(u,h)}}};var od=i=>"playbackRate"in i;var sd=i=>"frequency"in i&&"gain"in i;var ad=i=>"offset"in i;var cd=i=>!("frequency"in i)&&"gain"in i;var ud=i=>"detune"in i&&"frequency"in i&&!("gain"in i);var hd=i=>"pan"in i;var ne=i=>Kt(ia,i);var si=i=>Kt(na,i);var ca=(i,t)=>{let{activeInputs:e}=ne(i);e.forEach(n=>n.forEach(([o])=>{t.includes(i)||ca(o,[...t,i])}));let r=od(i)?[i.playbackRate]:aa(i)?Array.from(i.parameters.values()):sd(i)?[i.Q,i.detune,i.frequency,i.gain]:ad(i)?[i.offset]:cd(i)?[i.gain]:ud(i)?[i.detune,i.frequency]:hd(i)?[i.pan]:[];for(let n of r){let o=si(n);o!==void 0&&o.activeInputs.forEach(([s])=>ca(s,t))}be(i)&&Ir(i)};var ai=i=>{ca(i.destination,[])};var ua=i=>i===void 0||typeof i=="number"||typeof i=="string"&&(i==="balanced"||i==="interactive"||i==="playback");var ld=(i,t,e,r,n,o,s,a,c)=>class extends i{constructor(h={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let l;try{l=new c(h)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?e():f}if(l===null)throw r();if(!ua(h.latencyHint))throw new TypeError(`The provided value '${h.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(h.sampleRate!==void 0&&l.sampleRate!==h.sampleRate)throw e();super(l,2);let{latencyHint:p}=h,{sampleRate:m}=l;if(this._baseLatency=typeof l.baseLatency=="number"?l.baseLatency:p==="balanced"?512/m:p==="interactive"||p===void 0?256/m:p==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(p*m/128)))*128/m,this._nativeAudioContext=l,c.name==="webkitAudioContext"?(this._nativeGainNode=l.createGain(),this._nativeOscillatorNode=l.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(l.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,l.state==="running"){this._state="suspended";let f=()=>{this._state==="suspended"&&(this._state=null),l.removeEventListener("statechange",f)};l.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ai(this)}))}createMediaElementSource(h){return new n(this,{mediaElement:h})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(h){return new s(this,{mediaStream:h})}createMediaStreamTrackSource(h){return new a(this,{mediaStreamTrack:h})}resume(){return this._state==="suspended"?new Promise((h,l)=>{let p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?h():this.resume().then(h,l)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(h=>{throw h===void 0||h.code===15?t():h})}suspend(){return this._nativeAudioContext.suspend().catch(h=>{throw h===void 0?t():h})}};var dd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=s(l),m=n(l,h,p),f=p?t(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}};var pd=i=>{let t=new WeakMap,e=(r,n)=>K(null,null,function*(){let o=n.destination;return t.set(n,o),yield i(r,n,o),o});return{render(r,n){let o=t.get(n);return o!==void 0?Promise.resolve(o):e(r,n)}}};var md=(i,t,e,r,n,o,s,a)=>(c,u)=>{let h=u.listener,l=()=>{let S=new Float32Array(1),v=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),A=s(u),C=!1,E=[0,0,-1,0,1,0],q=[0,0,0],M=()=>{if(C)return;C=!0;let j=r(u,256,9,0);j.onaudioprocess=({inputBuffer:F})=>{let W=[o(F,S,0),o(F,S,1),o(F,S,2),o(F,S,3),o(F,S,4),o(F,S,5)];W.some((k,it)=>k!==E[it])&&(h.setOrientation(...W),E=W);let Q=[o(F,S,6),o(F,S,7),o(F,S,8)];Q.some((k,it)=>k!==q[it])&&(h.setPosition(...Q),q=Q)},v.connect(j)},R=j=>F=>{F!==E[j]&&(E[j]=F,h.setOrientation(...E))},B=j=>F=>{F!==q[j]&&(q[j]=F,h.setPosition(...q))},D=(j,F,W)=>{let Q=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:F});Q.connect(v,0,j),Q.start(),Object.defineProperty(Q.offset,"defaultValue",{get(){return F}});let k=i({context:c},A,Q.offset,Wt,Ht);return a(k,"value",it=>()=>it.call(k),it=>pt=>{try{it.call(k,pt)}catch(At){if(At.code!==9)throw At}M(),A&&W(pt)}),k.cancelAndHoldAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.cancelAndHoldAtTime),k.cancelScheduledValues=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.cancelScheduledValues),k.exponentialRampToValueAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.exponentialRampToValueAtTime),k.linearRampToValueAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.linearRampToValueAtTime),k.setTargetAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.setTargetAtTime),k.setValueAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.setValueAtTime),k.setValueCurveAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.setValueCurveAtTime),k};return{forwardX:D(0,0,R(0)),forwardY:D(1,0,R(1)),forwardZ:D(2,-1,R(2)),positionX:D(6,0,B(0)),positionY:D(7,0,B(1)),positionZ:D(8,0,B(2)),upX:D(3,0,R(3)),upY:D(4,1,R(4)),upZ:D(5,0,R(5))}},{forwardX:p,forwardY:m,forwardZ:f,positionX:g,positionY:b,positionZ:x,upX:_,upY:w,upZ:T}=h.forwardX===void 0?l():h;return{get forwardX(){return p},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return b},get positionZ(){return x},get upX(){return _},get upY(){return w},get upZ(){return T}}};var Ei=i=>"context"in i;var ci=i=>Ei(i[0]);var ar=(i,t,e,r)=>{for(let n of i)if(e(n)){if(r)return!1;throw Error("The set contains at least one similar element.")}return i.add(t),!0};var ku=(i,t,[e,r],n)=>{ar(i,[t,e,r],o=>o[0]===t&&o[1]===e,n)};var Lu=(i,[t,e,r],n)=>{let o=i.get(t);o===void 0?i.set(t,new Set([[e,r]])):ar(o,[e,r],s=>s[0]===e,n)};var ze=i=>"inputs"in i;var pn=(i,t,e,r)=>{if(ze(t)){let n=t.inputs[r];return i.connect(n,e,0),[n,e,0]}return i.connect(t,e,r),[t,e,r]};var ju=(i,t,e)=>{for(let r of i)if(r[0]===t&&r[1]===e)return i.delete(r),r;return null};var fd=(i,t,e)=>oi(i,r=>r[0]===t&&r[1]===e);var Pu=(i,t)=>{if(!Sr(i).delete(t))throw new Error("Missing the expected event listener.")};var Fu=(i,t,e)=>{let r=Kt(i,t),n=oi(r,o=>o[0]===e);return r.size===0&&i.delete(t),n};var mn=(i,t,e,r)=>{ze(t)?i.disconnect(t.inputs[r],e,0):i.disconnect(t,e,r)};var Ot=i=>Kt(un,i);var Di=i=>Kt(_o,i);var Wr=i=>vo.has(i);var fn=i=>!wr.has(i);var Bu=(i,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=i.createScriptProcessor(256,1,1),n=i.createGain(),o=i.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=i.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(i.destination),a.connect(n),a.disconnect(n),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,h=>h===1)?e(!0):e(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(i.destination)},a.start()}});var ha=(i,t)=>{let e=new Map;for(let r of i)for(let n of r){let o=e.get(n);e.set(n,o===void 0?1:o+1)}e.forEach((r,n)=>t(n,r))};var ki=i=>"context"in i;var gd=i=>{let t=new Map;i.connect=(e=>(r,n=0,o=0)=>{let s=ki(r)?e(r,n,o):e(r,n),a=t.get(r);return a===void 0?t.set(r,[{input:o,output:n}]):a.every(c=>c.input!==o||c.output!==n)&&a.push({input:o,output:n}),s})(i.connect.bind(i)),i.disconnect=(e=>(r,n,o)=>{if(e.apply(i),r===void 0)t.clear();else if(typeof r=="number")for(let[s,a]of t){let c=a.filter(u=>u.output!==r);c.length===0?t.delete(s):t.set(s,c)}else if(t.has(r))if(n===void 0)t.delete(r);else{let s=t.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==n&&(c.input!==o||o===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{ki(s)?i.connect(s,c.output,c.input):i.connect(s,c.output)})})(i.disconnect)};var CC=(i,t,e,r)=>{let{activeInputs:n,passiveInputs:o}=si(t),{outputs:s}=ne(i),a=Sr(i),c=u=>{let h=Ot(i),l=Di(t);if(u){let p=Fu(o,i,e);ku(n,i,p,!1),!r&&!Wr(i)&&h.connect(l,e)}else{let p=fd(n,i,e);Lu(o,p,!1),!r&&!Wr(i)&&h.disconnect(l,e)}};return ar(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),be(i)?ku(n,i,[e,c],!0):Lu(o,[i,e,c],!0),!0):!1},_C=(i,t,e,r)=>{let{activeInputs:n,passiveInputs:o}=ne(t),s=ju(n[r],i,e);return s===null?[sa(o,i,e,r)[2],!1]:[s[2],!0]},vC=(i,t,e)=>{let{activeInputs:r,passiveInputs:n}=si(t),o=ju(r,i,e);return o===null?[Fu(n,i,e)[1],!1]:[o[2],!0]},Gu=(i,t,e,r,n)=>{let[o,s]=_C(i,e,r,n);if(o!==null&&(Pu(i,o),s&&!t&&!Wr(i)&&mn(Ot(i),Ot(e),r,n)),be(e)){let{activeInputs:a}=ne(e);Io(e,a)}},Vu=(i,t,e,r)=>{let[n,o]=vC(i,e,r);n!==null&&(Pu(i,n),o&&!t&&!Wr(i)&&Ot(i).disconnect(Di(e),r))},wC=(i,t)=>{let e=ne(i),r=[];for(let n of e.outputs)ci(n)?Gu(i,t,...n):Vu(i,t,...n),r.push(n[0]);return e.outputs.clear(),r},SC=(i,t,e)=>{let r=ne(i),n=[];for(let o of r.outputs)o[1]===e&&(ci(o)?Gu(i,t,...o):Vu(i,t,...o),n.push(o[0]),r.outputs.delete(o));return n},IC=(i,t,e,r,n)=>{let o=ne(i);return Array.from(o.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(n===void 0||s[2]===n)).map(s=>(ci(s)?Gu(i,t,...s):Vu(i,t,...s),o.outputs.delete(s),s[0]))},yd=(i,t,e,r,n,o,s,a,c,u,h,l,p,m,f,g)=>class extends u{constructor(x,_,w,T){super(w),this._context=x,this._nativeAudioNode=w;let S=h(x);l(S)&&e(Bu,()=>Bu(S,g))!==!0&&gd(w),un.set(this,w),oa.set(this,new Set),x.state!=="closed"&&_&&sr(this),i(this,T,w)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(x){this._nativeAudioNode.channelCount=x}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(x){this._nativeAudioNode.channelCountMode=x}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(x){this._nativeAudioNode.channelInterpretation=x}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(x,_=0,w=0){if(_<0||_>=this._nativeAudioNode.numberOfOutputs)throw n();let T=h(this._context),S=f(T);if(p(x)||m(x))throw o();if(Ei(x)){let C=Ot(x);try{let q=pn(this._nativeAudioNode,C,_,w),M=fn(this);(S||M)&&this._nativeAudioNode.disconnect(...q),this.context.state!=="closed"&&!M&&fn(x)&&sr(x)}catch(q){throw q.code===12?o():q}if(t(this,x,_,w,S)){let q=c([this],x);ha(q,r(S))}return x}let v=Di(x);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,_),(S||fn(this))&&this._nativeAudioNode.disconnect(v,_)}catch(C){throw C.code===12?o():C}if(CC(this,x,_,S)){let C=c([this],x);ha(C,r(S))}}disconnect(x,_,w){let T,S=h(this._context),v=f(S);if(x===void 0)T=wC(this,v);else if(typeof x=="number"){if(x<0||x>=this.numberOfOutputs)throw n();T=SC(this,v,x)}else{if(_!==void 0&&(_<0||_>=this.numberOfOutputs)||Ei(x)&&w!==void 0&&(w<0||w>=x.numberOfInputs))throw n();if(T=IC(this,v,x,_,w),T.length===0)throw o()}for(let A of T){let C=c([this],A);ha(C,a)}}};var bd=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>(m,f,g,b=null,x=null)=>{let _=g.value,w=new Co(_),T=f?r(w):null,S={get defaultValue(){return _},get maxValue(){return b===null?g.maxValue:b},get minValue(){return x===null?g.minValue:x},get value(){return g.value},set value(v){g.value=v,S.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")T===null&&w.flush(m.context.currentTime),w.add(n(v)),g.cancelAndHoldAtTime(v);else{let A=Array.from(w).pop();T===null&&w.flush(m.context.currentTime),w.add(n(v));let C=Array.from(w).pop();g.cancelScheduledValues(v),A!==C&&C!==void 0&&(C.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(C.value,C.endTime):C.type==="linearRampToValue"?g.linearRampToValueAtTime(C.value,C.endTime):C.type==="setValue"?g.setValueAtTime(C.value,C.startTime):C.type==="setValueCurve"&&g.setValueCurveAtTime(C.values,C.startTime,C.duration))}return S},cancelScheduledValues(v){return T===null&&w.flush(m.context.currentTime),w.add(o(v)),g.cancelScheduledValues(v),S},exponentialRampToValueAtTime(v,A){if(v===0)throw new RangeError;if(!Number.isFinite(A)||A<0)throw new RangeError;let C=m.context.currentTime;return T===null&&w.flush(C),Array.from(w).length===0&&(w.add(u(_,C)),g.setValueAtTime(_,C)),w.add(s(v,A)),g.exponentialRampToValueAtTime(v,A),S},linearRampToValueAtTime(v,A){let C=m.context.currentTime;return T===null&&w.flush(C),Array.from(w).length===0&&(w.add(u(_,C)),g.setValueAtTime(_,C)),w.add(a(v,A)),g.linearRampToValueAtTime(v,A),S},setTargetAtTime(v,A,C){return T===null&&w.flush(m.context.currentTime),w.add(c(v,A,C)),g.setTargetAtTime(v,A,C),S},setValueAtTime(v,A){return T===null&&w.flush(m.context.currentTime),w.add(u(v,A)),g.setValueAtTime(v,A),S},setValueCurveAtTime(v,A,C){let E=v instanceof Float32Array?v:new Float32Array(v);if(l!==null&&l.name==="webkitAudioContext"){let q=A+C,M=m.context.sampleRate,R=Math.ceil(A*M),B=Math.floor(q*M),D=B-R,j=new Float32Array(D);for(let W=0;W<D;W+=1){let Q=(E.length-1)/C*((R+W)/M-A),k=Math.floor(Q),it=Math.ceil(Q);j[W]=k===it?E[k]:(1-(Q-k))*E[k]+(1-(it-Q))*E[it]}T===null&&w.flush(m.context.currentTime),w.add(h(j,A,C)),g.setValueCurveAtTime(j,A,C);let F=B/M;F<q&&p(S,j[j.length-1],F),p(S,E[E.length-1],q)}else T===null&&w.flush(m.context.currentTime),w.add(h(E,A,C)),g.setValueCurveAtTime(E,A,C);return S}};return e.set(S,g),t.set(S,m),i(S,T),S};var xd=i=>({replay(t){for(let e of i)if(e.type==="exponentialRampToValue"){let{endTime:r,value:n}=e;t.exponentialRampToValueAtTime(n,r)}else if(e.type==="linearRampToValue"){let{endTime:r,value:n}=e;t.linearRampToValueAtTime(n,r)}else if(e.type==="setTarget"){let{startTime:r,target:n,timeConstant:o}=e;t.setTargetAtTime(n,r,o)}else if(e.type==="setValue"){let{startTime:r,value:n}=e;t.setValueAtTime(n,r)}else if(e.type==="setValueCurve"){let{duration:r,startTime:n,values:o}=e;t.setValueCurveAtTime(o,n,r)}else throw new Error("Can't apply an unknown automation.")}});var gn=class{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((r,n)=>t.call(e,r,n,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}};var TC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},Ad=(i,t,e,r,n,o,s,a,c,u,h,l,p,m)=>class extends t{constructor(g,b,x){var _;let w=a(g),T=c(w),S=h(O(O({},TC),x));p(S);let v=wo.get(w),A=v==null?void 0:v.get(b),C=T||w.state!=="closed"?w:(_=s(w))!==null&&_!==void 0?_:w,E=n(C,T?null:g.baseLatency,u,b,A,S),q=T?r(b,S,A):null;super(g,!0,E,q);let M=[];E.parameters.forEach((B,D)=>{let j=e(this,T,B);M.push([D,j])}),this._nativeAudioWorkletNode=E,this._onprocessorerror=null,this._parameters=new gn(M),T&&i(w,this);let{activeInputs:R}=o(this);l(E,R)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let b=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=b;let x=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=x!==null&&x===b?g:x}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function yn(i,t,e,r,n){if(typeof i.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),i.copyFromChannel(t[e],r,n);else{let o=i.getChannelData(r);if(t[e].byteLength===0)t[e]=o.slice(n,n+128);else{let s=new Float32Array(o.buffer,n*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var la=(i,t,e,r,n)=>{typeof i.copyToChannel=="function"?t[e].byteLength!==0&&i.copyToChannel(t[e],r,n):t[e].byteLength!==0&&i.getChannelData(r).set(t[e],n)};var bn=(i,t)=>{let e=[];for(let r=0;r<i;r+=1){let n=[],o=typeof t=="number"?t:t[r];for(let s=0;s<o;s+=1)n.push(new Float32Array(128));e.push(n)}return e};var Cd=(i,t)=>{let e=Kt(So,i),r=Ot(t);return Kt(e,r)};var NC=(i,t,e,r,n,o,s)=>K(null,null,function*(){let a=t===null?Math.ceil(i.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=n.reduce((b,x)=>b+x,0),h=u===0?null:e.createBuffer(u,a,e.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let l=ne(i),p=yield Cd(e,i),m=bn(r.numberOfInputs,r.channelCount),f=bn(r.numberOfOutputs,n),g=Array.from(i.parameters.keys()).reduce((b,x)=>X(O({},b),{[x]:new Float32Array(128)}),{});for(let b=0;b<a;b+=128){if(r.numberOfInputs>0&&t!==null)for(let x=0;x<r.numberOfInputs;x+=1)for(let _=0;_<r.channelCount;_+=1)yn(t,m[x],_,_,b);o.parameterDescriptors!==void 0&&t!==null&&o.parameterDescriptors.forEach(({name:x},_)=>{yn(t,g,x,c+_,b)});for(let x=0;x<r.numberOfInputs;x+=1)for(let _=0;_<n[x];_+=1)f[x][_].byteLength===0&&(f[x][_]=new Float32Array(128));try{let x=m.map((w,T)=>l.activeInputs[T].size===0?[]:w),_=s(b/e.sampleRate,e.sampleRate,()=>p.process(x,f,g));if(h!==null)for(let w=0,T=0;w<r.numberOfOutputs;w+=1){for(let S=0;S<n[w];S+=1)la(h,f[w],S,T+S,b);T+=n[w]}if(!_)break}catch(x){i.dispatchEvent(new ErrorEvent("processorerror",{colno:x.colno,filename:x.filename,lineno:x.lineno,message:x.message}));break}}return h}),_d=(i,t,e,r,n,o,s,a,c,u,h,l,p,m,f,g)=>(b,x,_)=>{let w=new WeakMap,T=null,S=(v,A)=>K(null,null,function*(){let C=h(v),E=null,q=_t(C,A),M=Array.isArray(x.outputChannelCount)?x.outputChannelCount:Array.from(x.outputChannelCount);if(l===null){let R=M.reduce((F,W)=>F+W,0),B=n(A,{channelCount:Math.max(1,R),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,R)}),D=[];for(let F=0;F<v.numberOfOutputs;F+=1)D.push(r(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:M[F]}));let j=s(A,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1});j.connect=t.bind(null,D),j.disconnect=c.bind(null,D),E=[B,D,j]}else q||(C=new l(A,b));if(w.set(A,E===null?C:E[2]),E!==null){if(T===null){if(_===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let W=v.channelCount*v.numberOfInputs,Q=_.parameterDescriptors===void 0?0:_.parameterDescriptors.length,k=W+Q;T=NC(v,k===0?null:yield K(null,null,function*(){let pt=new p(k,Math.ceil(v.context.length/128)*128,A.sampleRate),At=[],Yt=[];for(let Nt=0;Nt<x.numberOfInputs;Nt+=1)At.push(s(pt,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1})),Yt.push(n(pt,{channelCount:x.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:x.channelCount}));let Ee=yield Promise.all(Array.from(v.parameters.values()).map(Nt=>K(null,null,function*(){let ct=o(pt,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:Nt.value});return yield m(pt,Nt,ct.offset),ct}))),De=r(pt,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,W+Q)});for(let Nt=0;Nt<x.numberOfInputs;Nt+=1){At[Nt].connect(Yt[Nt]);for(let ct=0;ct<x.channelCount;ct+=1)Yt[Nt].connect(De,ct,Nt*x.channelCount+ct)}for(let[Nt,ct]of Ee.entries())ct.connect(De,0,W+Nt),ct.start(0);return De.connect(pt.destination),yield Promise.all(At.map(Nt=>f(v,pt,Nt))),g(pt)}),A,x,M,_,u)}let R=yield T,B=e(A,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[D,j,F]=E;R!==null&&(B.buffer=R,B.start(0)),B.connect(D);for(let W=0,Q=0;W<v.numberOfOutputs;W+=1){let k=j[W];for(let it=0;it<M[W];it+=1)D.connect(k,Q+it,it);Q+=M[W]}return F}if(q)for(let[R,B]of v.parameters.entries())yield i(A,B,C.parameters.get(R));else for(let[R,B]of v.parameters.entries())yield m(A,B,C.parameters.get(R));return yield f(v,A,C),C});return{render(v,A){a(A,v);let C=w.get(A);return C!==void 0?Promise.resolve(C):S(v,A)}}};var vd=(i,t,e,r,n,o,s,a,c,u,h,l,p,m,f,g,b,x,_,w)=>class extends f{constructor(S,v){super(S,v),this._nativeContext=S,this._audioWorklet=i===void 0?void 0:{addModule:(A,C)=>i(this,A,C)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new n(this)}createBuffer(S,v,A){return new e({length:v,numberOfChannels:S,sampleRate:A})}createBufferSource(){return new r(this)}createChannelMerger(S=6){return new o(this,{numberOfInputs:S})}createChannelSplitter(S=6){return new s(this,{numberOfOutputs:S})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(S=1){return new h(this,{maxDelayTime:S})}createDynamicsCompressor(){return new l(this)}createGain(){return new p(this)}createIIRFilter(S,v){return new m(this,{feedback:v,feedforward:S})}createOscillator(){return new g(this)}createPanner(){return new b(this)}createPeriodicWave(S,v,A={disableNormalization:!1}){return new x(this,X(O({},A),{imag:v,real:S}))}createStereoPanner(){return new _(this)}createWaveShaper(){return new w(this)}decodeAudioData(S,v,A){return u(this._nativeContext,S).then(C=>(typeof v=="function"&&v(C),C),C=>{throw typeof A=="function"&&A(C),C})}};var OC={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},wd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=O(O({},OC),h),m=n(l,p),f=s(l),g=f?e():null;super(u,!1,m,g),this._Q=t(this,f,m.Q,Wt,Ht),this._detune=t(this,f,m.detune,1200*Math.log2(Wt),-1200*Math.log2(Wt)),this._frequency=t(this,f,m.frequency,u.sampleRate/2,0),this._gain=t(this,f,m.gain,40*Math.log10(Wt),Ht),this._nativeBiquadFilterNode=m,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(u){this._nativeBiquadFilterNode.type=u}getFrequencyResponse(u,h,l){try{this._nativeBiquadFilterNode.getFrequencyResponse(u,h,l)}catch(p){throw p.code===11?r():p}if(u.length!==h.length||h.length!==l.length)throw r()}};var Sd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,l)}return o.set(c,u),h?(yield i(c,a.Q,u.Q),yield i(c,a.detune,u.detune),yield i(c,a.frequency,u.frequency),yield i(c,a.gain,u.gain)):(yield r(c,a.Q,u.Q),yield r(c,a.detune,u.detune),yield r(c,a.frequency,u.frequency),yield r(c,a.gain,u.gain)),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Id=(i,t)=>(e,r)=>{let n=t.get(e);if(n!==void 0)return n;let o=i.get(e);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(i.set(e,s),s.catch(()=>!1).then(a=>(i.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var RC={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Td=(i,t,e,r,n)=>class extends i{constructor(s,a){let c=r(s),u=O(O({},RC),a),h=e(c,u),l=n(c)?t():null;super(s,!1,h,l)}};var Nd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var MC={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Od=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),h=o(O(O({},MC),c)),l=e(u,h),p=n(u)?t():null;super(a,!1,l,p)}};var Rd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var Md=i=>(t,e,r)=>i(e,t,r);var Ed=i=>(t,e,r=0,n=0)=>{let o=t[r];if(o===void 0)throw i();return ki(e)?o.connect(e,0,n):o.connect(e,0)};var Dd=i=>(t,e)=>{let r=i(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),n=t.createBuffer(1,2,44100);return r.buffer=n,r.loop=!0,r.connect(e),r.start(),()=>{r.stop(),r.disconnect(e)}};var EC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},kd=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},EC),u),p=r(h,l),m=o(h),f=m?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,m,p.offset,Wt,Ht),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeConstantSourceNode.onended=u;let h=this._nativeConstantSourceNode.onended;this._onended=h!==null&&h===u?c:h}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){sr(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),be(this)&&Ir(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var Ld=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,h)=>K(null,null,function*(){let l=e(u),p=_t(l,h);if(!p){let m={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,offset:l.offset.value};l=t(h,m),s!==null&&l.start(s),a!==null&&l.stop(a)}return o.set(h,l),p?yield i(h,u.offset,l.offset):yield r(h,u.offset,l.offset),yield n(u,h,l),l});return{set start(u){s=u},set stop(u){a=u},render(u,h){let l=o.get(h);return l!==void 0?Promise.resolve(l):c(u,h)}}};var jd=i=>t=>(i[0]=t,i[0]);var DC={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Pd=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),h=O(O({},DC),c),l=e(u,h),m=n(u)?t():null;super(a,!1,l,m),this._isBufferNullified=!1,this._nativeConvolverNode=l,h.buffer!==null&&o(this,h.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){let c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var Fd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=i(s,u)}return r.set(s,a),ze(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var Bd=(i,t)=>(e,r,n)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,n)}catch(o){throw o.name==="SyntaxError"?i():o}};var Gd=()=>new DOMException("","DataCloneError");var qu=i=>{let{port1:t,port2:e}=new MessageChannel;return new Promise(r=>{let n=()=>{e.onmessage=null,t.close(),e.close(),r()};e.onmessage=()=>n();try{t.postMessage(i,[i])}catch(o){}finally{n()}})};var Vd=(i,t,e,r,n,o,s,a,c,u,h)=>(l,p)=>{let m=s(l)?l:o(l);if(n.has(p)){let f=e();return Promise.reject(f)}try{n.add(p)}catch(f){}return t(c,()=>c(m))?m.decodeAudioData(p).then(f=>(qu(p).catch(()=>{}),t(a,()=>a(f))||h(f),i.add(f),f)):new Promise((f,g)=>{let b=()=>K(null,null,function*(){try{yield qu(p)}catch(_){}}),x=_=>{g(_),b()};try{m.decodeAudioData(p,_=>{typeof _.copyFromChannel!="function"&&(u(_),dn(_)),i.add(_),b().then(()=>f(_))},_=>{x(_===null?r():_)})}catch(_){x(_)}})};var qd=(i,t,e,r,n,o,s,a)=>(c,u)=>{let h=t.get(c);if(h===void 0)throw new Error("Missing the expected cycle count.");let l=o(c.context),p=a(l);if(h===u){if(t.delete(c),!p&&s(c)){let m=r(c),{outputs:f}=e(c);for(let g of f)if(ci(g)){let b=r(g[0]);i(m,b,g[1],g[2])}else{let b=n(g[0]);m.connect(b,g[1])}}}else t.set(c,h-u)};var kC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Wd=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},kC),u),p=r(h,l),m=o(h),f=m?e(l.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,m,p.delayTime),s(this,l.maxDelayTime)}get delayTime(){return this._delayTime}};var Ud=(i,t,e,r,n)=>o=>{let s=new WeakMap,a=(c,u)=>K(null,null,function*(){let h=e(c),l=_t(h,u);if(!l){let p={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,delayTime:h.delayTime.value,maxDelayTime:o};h=t(u,p)}return s.set(u,h),l?yield i(u,c.delayTime,h.delayTime):yield r(u,c.delayTime,h.delayTime),yield n(c,u,h),h});return{render(c,u){let h=s.get(u);return h!==void 0?Promise.resolve(h):a(c,u)}}};var zd=i=>(t,e,r,n)=>i(t[n],o=>o[0]===e&&o[1]===r);var Yd=i=>(t,e)=>{i(t).delete(e)};var Hd=i=>"delayTime"in i;var $d=(i,t,e)=>function r(n,o){let s=Ei(o)?o:e(i,o);if(Hd(s))return[];if(n[0]===s)return[n];if(n.includes(s))return[];let{outputs:a}=t(s);return Array.from(a).map(c=>r([...n,s],c[0])).reduce((c,u)=>c.concat(u),[])};var da=(i,t,e)=>{let r=t[e];if(r===void 0)throw i();return r},Zd=i=>(t,e=void 0,r=void 0,n=0)=>e===void 0?t.forEach(o=>o.disconnect()):typeof e=="number"?da(i,t,e).disconnect():ki(e)?r===void 0?t.forEach(o=>o.disconnect(e)):n===void 0?da(i,t,r).disconnect(e,0):da(i,t,r).disconnect(e,0,n):r===void 0?t.forEach(o=>o.disconnect(e)):da(i,t,r).disconnect(e,0);var LC={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Xd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=O(O({},LC),h),m=r(l,p),f=s(l),g=f?e():null;super(u,!1,m,g),this._attack=t(this,f,m.attack),this._knee=t(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=t(this,f,m.ratio),this._release=t(this,f,m.release),this._threshold=t(this,f,m.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){let h=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=h,n()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(u){let h=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=u,u==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=h,n()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value=="number"?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}};var Qd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,l)}return o.set(c,u),h?(yield i(c,a.attack,u.attack),yield i(c,a.knee,u.knee),yield i(c,a.ratio,u.ratio),yield i(c,a.release,u.release),yield i(c,a.threshold,u.threshold)):(yield r(c,a.attack,u.attack),yield r(c,a.knee,u.knee),yield r(c,a.ratio,u.ratio),yield r(c,a.release,u.release),yield r(c,a.threshold,u.threshold)),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Kd=()=>new DOMException("","EncodingError");var Jd=i=>t=>new Promise((e,r)=>{if(i===null){r(new SyntaxError);return}let n=i.document.head;if(n===null)r(new SyntaxError);else{let o=i.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=i.onerror,u=()=>{i.onerror=c,URL.revokeObjectURL(a)};i.onerror=(h,l,p,m,f)=>{if(l===a||l===i.location.href&&p===1&&m===1)return u(),r(f),!1;if(c!==null)return c(h,l,p,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),e()},o.src=a,o.type="module",n.appendChild(o)}});var tp=i=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,n){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=i(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(e,o,n)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,n){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,o===void 0?null:o,n)}};var ep=i=>(t,e,r)=>{Object.defineProperties(i,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{i!==null&&(delete i.currentFrame,delete i.currentTime)}};var rp=i=>t=>K(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw i()});var jC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},ip=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),h=O(O({},jC),c),l=r(u,h),p=o(u),m=p?e():null;super(a,!1,l,m),this._gain=t(this,p,l.gain,Wt,Ht)}get gain(){return this._gain}};var np=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,l)}return o.set(c,u),h?yield i(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var op=(i,t)=>e=>t(i,e);var sp=i=>t=>{let e=i(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var ap=i=>t=>{var e;return(e=i.get(t))!==null&&e!==void 0?e:0};var cp=i=>t=>{let e=i(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var up=i=>t=>i.get(t);var Pt=()=>new DOMException("","InvalidStateError");var hp=i=>t=>{let e=i.get(t);if(e===void 0)throw Pt();return e};var lp=(i,t)=>e=>{let r=i.get(e);if(r!==void 0)return r;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new t(1,1,44100),i.set(e,r),r};var dp=i=>t=>{let e=i.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var xn=()=>new DOMException("","InvalidAccessError");var pp=i=>{i.getFrequencyResponse=(t=>(e,r,n)=>{if(e.length!==r.length||r.length!==n.length)throw xn();return t.call(i,e,r,n)})(i.getFrequencyResponse)};var PC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},mp=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),h=n(u),l=O(O({},PC),c),p=t(u,h?null:a.baseLatency,l),m=h?e(l.feedback,l.feedforward):null;super(a,!1,p,m),pp(p),this._nativeIIRFilterNode=p,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var pa=(i,t,e,r,n,o,s,a,c,u,h)=>{let l=u.length,p=a;for(let m=0;m<l;m+=1){let f=e[0]*u[m];for(let g=1;g<n;g+=1){let b=p-g&c-1;f+=e[g]*o[b],f-=i[g]*s[b]}for(let g=n;g<r;g+=1)f+=e[g]*o[p-g&c-1];for(let g=n;g<t;g+=1)f-=i[g]*s[p-g&c-1];o[p]=u[m],s[p]=f,p=p+1&c-1,h[m]=f}return p};var FC=(i,t,e,r)=>{let n=e instanceof Float64Array?e:new Float64Array(e),o=r instanceof Float64Array?r:new Float64Array(r),s=n.length,a=o.length,c=Math.min(s,a);if(n[0]!==1){for(let f=0;f<s;f+=1)o[f]/=n[0];for(let f=1;f<a;f+=1)n[f]/=n[0]}let u=32,h=new Float32Array(u),l=new Float32Array(u),p=t.createBuffer(i.numberOfChannels,i.length,i.sampleRate),m=i.numberOfChannels;for(let f=0;f<m;f+=1){let g=i.getChannelData(f),b=p.getChannelData(f);h.fill(0),l.fill(0),pa(n,s,o,a,c,h,l,0,u,g,b)}return p},fp=(i,t,e,r,n)=>(o,s)=>{let a=new WeakMap,c=null,u=(h,l)=>K(null,null,function*(){let p=null,m=t(h),f=_t(m,l);if(l.createIIRFilter===void 0?p=i(l,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(m=l.createIIRFilter(s,o)),a.set(l,p===null?m:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let b=new e(h.context.destination.channelCount,h.context.length,l.sampleRate);c=K(null,null,function*(){yield r(h,b,b.destination);let x=yield n(b);return FC(x,l,o,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(h,l,m),m});return{render(h,l){let p=a.get(l);return p!==void 0?Promise.resolve(p):u(h,l)}}};var gp=(i,t,e,r,n,o)=>s=>(a,c)=>{let u=i.get(a);if(u===void 0){if(!s&&o(a)){let h=r(a),{outputs:l}=e(a);for(let p of l)if(ci(p)){let m=r(p[0]);t(h,m,p[1],p[2])}else{let m=n(p[0]);h.disconnect(m,p[1])}}i.set(a,c)}else i.set(a,u+c)};var yp=(i,t)=>e=>{let r=i.get(e);return t(r)||t(e)};var bp=(i,t)=>e=>i.has(e)||t(e);var xp=(i,t)=>e=>i.has(e)||t(e);var Ap=(i,t)=>e=>{let r=i.get(e);return t(r)||t(e)};var Cp=i=>t=>i!==null&&t instanceof i;var _p=i=>t=>i!==null&&typeof i.AudioNode=="function"&&t instanceof i.AudioNode;var vp=i=>t=>i!==null&&typeof i.AudioParam=="function"&&t instanceof i.AudioParam;var wp=(i,t)=>e=>i(e)||t(e);var Sp=i=>t=>i!==null&&t instanceof i;var Ip=i=>i!==null&&i.isSecureContext;var Tp=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var BC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Np=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o);if(r(a))throw new TypeError;let c=O(O({},BC),s),u=t(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Op=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var Rp=(i,t,e)=>class extends i{constructor(n,o){let s=e(n),a=t(s,o);super(n,!0,a,null)}};var Mp=(i,t,e,r,n)=>class extends r{constructor(s={}){if(n===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new n(s)}catch(h){throw h.code===12&&h.message==="sampleRate is not in range"?t():h}if(a===null)throw e();if(!ua(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw t();super(a,2);let{latencyHint:c}=s,{sampleRate:u}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/u:c==="interactive"||c===void 0?256/u:c==="playback"?1024/u:Math.max(2,Math.min(128,Math.round(c*u/128)))*128/u,this._nativeAudioContext=a,n.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";let h=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",h)};a.addEventListener("statechange",h)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw i()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ai(this)}))}resume(){return this._state==="suspended"?new Promise((s,a)=>{let c=()=>{this._nativeAudioContext.removeEventListener("statechange",c),this._nativeAudioContext.state==="running"?s():this.resume().then(s,a)};this._nativeAudioContext.addEventListener("statechange",c)}):this._nativeAudioContext.resume().catch(s=>{throw s===void 0||s.code===15?i():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?i():s})}};var Ep=(i,t,e,r,n,o)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,hn.set(this,a),r(a)&&n.set(a,new Set),this._destination=new i(this,c),this._listener=t(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){let c=typeof a=="function"?o(this,a):null;this._nativeContext.onstatechange=c;let u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?a:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}};var cr=i=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=i.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var GC={numberOfChannels:1},Dp=(i,t,e,r,n)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=O(O({},GC),s),h=e(c,a,u);i(cr,()=>cr(h))||h.addEventListener("statechange",(()=>{let l=0,p=m=>{this._state==="running"&&(l>0?(h.removeEventListener("statechange",p),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):l+=1)};return p})()),super(h,c),this._length=a,this._nativeOfflineAudioContext=h,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(t()):(this._state="running",n(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,ai(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var kp=(i,t)=>(e,r,n)=>{let o=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let h=o.size===0;if(t(a))return s.call(e,a,c,u),i(o,[a,c,u],l=>l[0]===a&&l[1]===c&&l[2]===u,!0),h&&r(),a;s.call(e,a,c),i(o,[a,c],l=>l[0]===a&&l[1]===c,!0),h&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let h=o.size>0;if(a===void 0)s.apply(e),o.clear();else if(typeof a=="number"){s.call(e,a);for(let p of o)p[1]===a&&o.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of o)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&o.delete(p)}let l=o.size===0;h&&l&&n()})(e.disconnect),e};var vt=(i,t,e)=>{let r=t[e];r!==void 0&&r!==i[e]&&(i[e]=r)};var ft=(i,t)=>{vt(i,t,"channelCount"),vt(i,t,"channelCountMode"),vt(i,t,"channelInterpretation")};var Wu=i=>typeof i.getFloatTimeDomainData=="function";var Lp=i=>{i.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);i.getByteTimeDomainData(e);let r=Math.max(e.length,i.fftSize);for(let n=0;n<r;n+=1)t[n]=(e[n]-128)*.0078125;return t}};var jp=(i,t)=>(e,r)=>{let n=e.createAnalyser();if(ft(n,r),!(r.maxDecibels>r.minDecibels))throw t();return vt(n,r,"fftSize"),vt(n,r,"maxDecibels"),vt(n,r,"minDecibels"),vt(n,r,"smoothingTimeConstant"),i(Wu,()=>Wu(n))||Lp(n),n};var Pp=i=>i===null?null:i.hasOwnProperty("AudioBuffer")?i.AudioBuffer:null;var It=(i,t,e)=>{let r=t[e];r!==void 0&&r!==i[e].value&&(i[e].value=r)};var Fp=i=>{i.start=(t=>{let e=!1;return(r=0,n=0,o)=>{if(e)throw Pt();t.call(i,r,n,o),e=!0}})(i.start)};var An=i=>{i.start=(t=>(e=0,r=0,n)=>{if(typeof n=="number"&&n<0||r<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(i,e,r,n)})(i.start)};var Cn=i=>{i.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(i,e)})(i.stop)};var Bp=(i,t,e,r,n,o,s,a,c,u,h)=>(l,p)=>{let m=l.createBufferSource();return ft(m,p),It(m,p,"playbackRate"),vt(m,p,"buffer"),vt(m,p,"loop"),vt(m,p,"loopEnd"),vt(m,p,"loopStart"),t(e,()=>e(l))||Fp(m),t(r,()=>r(l))||c(m),t(n,()=>n(l))||u(m,l),t(o,()=>o(l))||An(m),t(s,()=>s(l))||h(m,l),t(a,()=>a(l))||Cn(m),i(l,m),m};var Gp=i=>i===null?null:i.hasOwnProperty("AudioContext")?i.AudioContext:i.hasOwnProperty("webkitAudioContext")?i.webkitAudioContext:null;var Vp=(i,t)=>(e,r,n)=>{let o=e.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}n&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=i(e,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>o.maxChannelCount}),s.connect(o),s};var qp=i=>i===null?null:i.hasOwnProperty("AudioWorkletNode")?i.AudioWorkletNode:null;var Wp=i=>{let{port1:t}=new MessageChannel;try{t.postMessage(i)}finally{t.close()}};var Up=(i,t,e,r,n)=>(o,s,a,c,u,h)=>{if(a!==null)try{let l=new a(o,c,h),p=new Map,m=null;if(Object.defineProperties(l,{channelCount:{get:()=>h.channelCount,set:()=>{throw i()}},channelCountMode:{get:()=>"explicit",set:()=>{throw i()}},onprocessorerror:{get:()=>m,set:f=>{typeof m=="function"&&l.removeEventListener("processorerror",m),m=typeof f=="function"?f:null,typeof m=="function"&&l.addEventListener("processorerror",m)}}}),l.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let b=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(b!==null){let x=p.get(g[1]);x!==void 0?g[1]=x:(g[1]=_=>{_.type==="error"?(Object.defineProperties(_,{type:{value:"processorerror"}}),b(_)):b(new ErrorEvent(g[0],O({},_)))},p.set(b,g[1]))}}return f.call(l,"error",g[1],g[2]),f.call(l,...g)})(l.addEventListener),l.removeEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let b=p.get(g[1]);b!==void 0&&(p.delete(g[1]),g[1]=b)}return f.call(l,"error",g[1],g[2]),f.call(l,g[0],g[1],g[2])})(l.removeEventListener),h.numberOfOutputs!==0){let f=e(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return l.connect(f).connect(o.destination),n(l,()=>f.disconnect(),()=>f.connect(o.destination))}return l}catch(l){throw l.code===11?r():l}if(u===void 0)throw r();return Wp(h),t(o,s,u,h)};var ma=(i,t)=>i===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(i*t)))));var zp=i=>new Promise((t,e)=>{let{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),n.close(),t(o)},r.onmessageerror=({data:o})=>{r.close(),n.close(),e(o)},n.postMessage(i)});var Yp=(i,t)=>K(null,null,function*(){let e=yield zp(t);return new i(e)});var Hp=(i,t,e,r)=>{let n=So.get(i);n===void 0&&(n=new WeakMap,So.set(i,n));let o=Yp(e,r);return n.set(t,o),o};var $p=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>(m,f,g,b)=>{if(b.numberOfInputs===0&&b.numberOfOutputs===0)throw c();let x=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(x.some($=>$<1))throw c();if(x.length!==b.numberOfOutputs)throw t();if(b.channelCountMode!=="explicit")throw c();let _=b.channelCount*b.numberOfInputs,w=x.reduce(($,st)=>$+st,0),T=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(_+T>6||w>6)throw c();let S=new MessageChannel,v=[],A=[];for(let $=0;$<b.numberOfInputs;$+=1)v.push(s(m,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),A.push(n(m,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let C=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:$,maxValue:st,minValue:re,name:Ft}of g.parameterDescriptors){let St=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:b.parameterData[Ft]!==void 0?b.parameterData[Ft]:$===void 0?0:$});Object.defineProperties(St.offset,{defaultValue:{get:()=>$===void 0?0:$},maxValue:{get:()=>st===void 0?Wt:st},minValue:{get:()=>re===void 0?Ht:re}}),C.push(St)}let E=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,_+T)}),q=ma(f,m.sampleRate),M=a(m,q,_+T,Math.max(1,w)),R=n(m,{channelCount:Math.max(1,w),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,w)}),B=[];for(let $=0;$<b.numberOfOutputs;$+=1)B.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:x[$]}));for(let $=0;$<b.numberOfInputs;$+=1){v[$].connect(A[$]);for(let st=0;st<b.channelCount;st+=1)A[$].connect(E,st,$*b.channelCount+st)}let D=new gn(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:$},st)=>{let re=C[st];return re.connect(E,0,_+st),re.start(0),[$,re.offset]}));E.connect(M);let j=b.channelInterpretation,F=null,W=b.numberOfOutputs===0?[M]:B,Q={get bufferSize(){return q},get channelCount(){return b.channelCount},set channelCount($){throw e()},get channelCountMode(){return b.channelCountMode},set channelCountMode($){throw e()},get channelInterpretation(){return j},set channelInterpretation($){for(let st of v)st.channelInterpretation=$;j=$},get context(){return M.context},get inputs(){return v},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},get onprocessorerror(){return F},set onprocessorerror($){typeof F=="function"&&Q.removeEventListener("processorerror",F),F=typeof $=="function"?$:null,typeof F=="function"&&Q.addEventListener("processorerror",F)},get parameters(){return D},get port(){return S.port2},addEventListener(...$){return M.addEventListener($[0],$[1],$[2])},connect:i.bind(null,W),disconnect:u.bind(null,W),dispatchEvent(...$){return M.dispatchEvent($[0])},removeEventListener(...$){return M.removeEventListener($[0],$[1],$[2])}},k=new Map;S.port1.addEventListener=($=>(...st)=>{if(st[0]==="message"){let re=typeof st[1]=="function"?st[1]:typeof st[1]=="object"&&st[1]!==null&&typeof st[1].handleEvent=="function"?st[1].handleEvent:null;if(re!==null){let Ft=k.get(st[1]);Ft!==void 0?st[1]=Ft:(st[1]=St=>{h(m.currentTime,m.sampleRate,()=>re(St))},k.set(re,st[1]))}}return $.call(S.port1,st[0],st[1],st[2])})(S.port1.addEventListener),S.port1.removeEventListener=($=>(...st)=>{if(st[0]==="message"){let re=k.get(st[1]);re!==void 0&&(k.delete(st[1]),st[1]=re)}return $.call(S.port1,st[0],st[1],st[2])})(S.port1.removeEventListener);let it=null;Object.defineProperty(S.port1,"onmessage",{get:()=>it,set:$=>{typeof it=="function"&&S.port1.removeEventListener("message",it),it=typeof $=="function"?$:null,typeof it=="function"&&(S.port1.addEventListener("message",it),S.port1.start())}}),g.prototype.port=S.port1;let pt=null;Hp(m,Q,g,b).then($=>pt=$);let Yt=bn(b.numberOfInputs,b.channelCount),Ee=bn(b.numberOfOutputs,x),De=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce(($,{name:st})=>X(O({},$),{[st]:new Float32Array(128)}),{}),Nt=!0,ct=()=>{b.numberOfOutputs>0&&M.disconnect(R);for(let $=0,st=0;$<b.numberOfOutputs;$+=1){let re=B[$];for(let Ft=0;Ft<x[$];Ft+=1)R.disconnect(re,st+Ft,Ft);st+=x[$]}},Ji=new Map;M.onaudioprocess=({inputBuffer:$,outputBuffer:st})=>{if(pt!==null){let re=l(Q);for(let Ft=0;Ft<q;Ft+=128){for(let St=0;St<b.numberOfInputs;St+=1)for(let qt=0;qt<b.channelCount;qt+=1)yn($,Yt[St],qt,qt,Ft);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:St},qt)=>{yn($,De,St,_+qt,Ft)});for(let St=0;St<b.numberOfInputs;St+=1)for(let qt=0;qt<x[St];qt+=1)Ee[St][qt].byteLength===0&&(Ee[St][qt]=new Float32Array(128));try{let St=Yt.map((Ve,Qr)=>{if(re[Qr].size>0)return Ji.set(Qr,q/128),Ve;let tu=Ji.get(Qr);return tu===void 0?[]:(Ve.every(bg=>bg.every(xg=>xg===0))&&(tu===1?Ji.delete(Qr):Ji.set(Qr,tu-1)),Ve)});Nt=h(m.currentTime+Ft/m.sampleRate,m.sampleRate,()=>pt.process(St,Ee,De));for(let Ve=0,Qr=0;Ve<b.numberOfOutputs;Ve+=1){for(let oo=0;oo<x[Ve];oo+=1)la(st,Ee[Ve],oo,Qr+oo,Ft);Qr+=x[Ve]}}catch(St){Nt=!1,Q.dispatchEvent(new ErrorEvent("processorerror",{colno:St.colno,filename:St.filename,lineno:St.lineno,message:St.message}))}if(!Nt){for(let St=0;St<b.numberOfInputs;St+=1){v[St].disconnect(A[St]);for(let qt=0;qt<b.channelCount;qt+=1)A[Ft].disconnect(E,qt,St*b.channelCount+qt)}if(g.parameterDescriptors!==void 0){let St=g.parameterDescriptors.length;for(let qt=0;qt<St;qt+=1){let Ve=C[qt];Ve.disconnect(E,0,_+qt),Ve.stop()}}E.disconnect(M),M.onaudioprocess=null,ro?ct():en();break}}}};let ro=!1,tt=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),tn=()=>M.connect(tt).connect(m.destination),en=()=>{M.disconnect(tt),tt.disconnect()},io=()=>{if(Nt){en(),b.numberOfOutputs>0&&M.connect(R);for(let $=0,st=0;$<b.numberOfOutputs;$+=1){let re=B[$];for(let Ft=0;Ft<x[$];Ft+=1)R.connect(re,st+Ft,Ft);st+=x[$]}}ro=!0},no=()=>{Nt&&(tn(),ct()),ro=!1};return tn(),p(Q,io,no)};var Uu=(i,t)=>{let e=i.createBiquadFilter();return ft(e,t),It(e,t,"Q"),It(e,t,"detune"),It(e,t,"frequency"),It(e,t,"gain"),vt(e,t,"type"),e};var Zp=(i,t)=>(e,r)=>{let n=e.createChannelMerger(r.numberOfInputs);return i!==null&&i.name==="webkitAudioContext"&&t(e,n),ft(n,r),n};var Xp=i=>{let t=i.numberOfOutputs;Object.defineProperty(i,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw Pt()}}),Object.defineProperty(i,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw Pt()}}),Object.defineProperty(i,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw Pt()}})};var _n=(i,t)=>{let e=i.createChannelSplitter(t.numberOfOutputs);return ft(e,t),Xp(e),e};var Qp=(i,t,e,r,n)=>(o,s)=>{if(o.createConstantSource===void 0)return e(o,s);let a=o.createConstantSource();return ft(a,s),It(a,s,"offset"),t(r,()=>r(o))||An(a),t(n,()=>n(o))||Cn(a),i(o,a),a};var Ye=(i,t)=>(i.connect=t.connect.bind(t),i.disconnect=t.disconnect.bind(t),i);var Kp=(i,t,e,r)=>(n,a)=>{var c=a,{offset:o}=c,s=Kr(c,["offset"]);let u=n.createBuffer(1,2,44100),h=t(n,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=e(n,X(O({},s),{gain:o})),p=u.getChannelData(0);p[0]=1,p[1]=1,h.buffer=u,h.loop=!0;let m={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(b){l.channelCount=b},get channelCountMode(){return l.channelCountMode},set channelCountMode(b){l.channelCountMode=b},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(b){l.channelInterpretation=b},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return h.onended},set onended(b){h.onended=b},addEventListener(...b){return h.addEventListener(b[0],b[1],b[2])},dispatchEvent(...b){return h.dispatchEvent(b[0])},removeEventListener(...b){return h.removeEventListener(b[0],b[1],b[2])},start(b=0){h.start.call(h,b)},stop(b=0){h.stop.call(h,b)}},f=()=>h.connect(l),g=()=>h.disconnect(l);return i(n,h),r(Ye(m,l),f,g)};var Jp=(i,t)=>(e,r)=>{let n=e.createConvolver();if(ft(n,r),r.disableNormalization===n.normalize&&(n.normalize=!r.disableNormalization),vt(n,r,"buffer"),r.channelCount>2||(t(n,"channelCount",o=>()=>o.call(n),o=>s=>{if(s>2)throw i();return o.call(n,s)}),r.channelCountMode==="max"))throw i();return t(n,"channelCountMode",o=>()=>o.call(n),o=>s=>{if(s==="max")throw i();return o.call(n,s)}),n};var zu=(i,t)=>{let e=i.createDelay(t.maxDelayTime);return ft(e,t),It(e,t,"delayTime"),e};var tm=i=>(t,e)=>{let r=t.createDynamicsCompressor();if(ft(r,e),e.channelCount>2||e.channelCountMode==="max")throw i();return It(r,e,"attack"),It(r,e,"knee"),It(r,e,"ratio"),It(r,e,"release"),It(r,e,"threshold"),r};var xe=(i,t)=>{let e=i.createGain();return ft(e,t),It(e,t,"gain"),e};var em=i=>(t,e,r)=>{if(t.createIIRFilter===void 0)return i(t,e,r);let n=t.createIIRFilter(r.feedforward,r.feedback);return ft(n,r),n};function VC(i,t){let e=t[0]*t[0]+t[1]*t[1];return[(i[0]*t[0]+i[1]*t[1])/e,(i[1]*t[0]-i[0]*t[1])/e]}function qC(i,t){return[i[0]*t[0]-i[1]*t[1],i[0]*t[1]+i[1]*t[0]]}function rm(i,t){let e=[0,0];for(let r=i.length-1;r>=0;r-=1)e=qC(e,t),e[0]+=i[r];return e}var im=(i,t,e,r)=>(n,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:h})=>{let l=ma(o,n.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),m=h instanceof Float64Array?h:new Float64Array(h),f=p.length,g=m.length,b=Math.min(f,g);if(f===0||f>20)throw r();if(p[0]===0)throw t();if(g===0||g>20)throw r();if(m[0]===0)throw t();if(p[0]!==1){for(let C=0;C<g;C+=1)m[C]/=p[0];for(let C=1;C<f;C+=1)p[C]/=p[0]}let x=e(n,l,s,s);x.channelCount=s,x.channelCountMode=a,x.channelInterpretation=c;let _=32,w=[],T=[],S=[];for(let C=0;C<s;C+=1){w.push(0);let E=new Float32Array(_),q=new Float32Array(_);E.fill(0),q.fill(0),T.push(E),S.push(q)}x.onaudioprocess=C=>{let E=C.inputBuffer,q=C.outputBuffer,M=E.numberOfChannels;for(let R=0;R<M;R+=1){let B=E.getChannelData(R),D=q.getChannelData(R);w[R]=pa(p,f,m,g,b,T[R],S[R],w[R],_,B,D)}};let v=n.sampleRate/2;return Ye({get bufferSize(){return l},get channelCount(){return x.channelCount},set channelCount(C){x.channelCount=C},get channelCountMode(){return x.channelCountMode},set channelCountMode(C){x.channelCountMode=C},get channelInterpretation(){return x.channelInterpretation},set channelInterpretation(C){x.channelInterpretation=C},get context(){return x.context},get inputs(){return[x]},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},addEventListener(...C){return x.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return x.dispatchEvent(C[0])},getFrequencyResponse(C,E,q){if(C.length!==E.length||E.length!==q.length)throw i();let M=C.length;for(let R=0;R<M;R+=1){let B=-Math.PI*(C[R]/v),D=[Math.cos(B),Math.sin(B)],j=rm(m,D),F=rm(p,D),W=VC(j,F);E[R]=Math.sqrt(W[0]*W[0]+W[1]*W[1]),q[R]=Math.atan2(W[1],W[0])}},removeEventListener(...C){return x.removeEventListener(C[0],C[1],C[2])}},x)};var nm=(i,t)=>i.createMediaElementSource(t.mediaElement);var om=(i,t)=>{let e=i.createMediaStreamDestination();return ft(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var sm=(i,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=e.slice(0,1),n=i.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(n,"mediaStream",{value:t}),n};var am=(i,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let n=new MediaStream([r]),o=e.createMediaStreamSource(n);if(r.kind!=="audio")throw i();if(t(e))throw new TypeError;return o};var cm=i=>i===null?null:i.hasOwnProperty("OfflineAudioContext")?i.OfflineAudioContext:i.hasOwnProperty("webkitOfflineAudioContext")?i.webkitOfflineAudioContext:null;var um=(i,t,e,r,n,o)=>(s,a)=>{let c=s.createOscillator();return ft(c,a),It(c,a,"detune"),It(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):vt(c,a,"type"),t(e,()=>e(s))||An(c),t(r,()=>r(s))||o(c,s),t(n,()=>n(s))||Cn(c),i(s,c),c};var hm=i=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?i(t,e):(ft(r,e),It(r,e,"orientationX"),It(r,e,"orientationY"),It(r,e,"orientationZ"),It(r,e,"positionX"),It(r,e,"positionY"),It(r,e,"positionZ"),vt(r,e,"coneInnerAngle"),vt(r,e,"coneOuterAngle"),vt(r,e,"coneOuterGain"),vt(r,e,"distanceModel"),vt(r,e,"maxDistance"),vt(r,e,"panningModel"),vt(r,e,"refDistance"),vt(r,e,"rolloffFactor"),r)};var lm=(i,t,e,r,n,o,s,a,c,u)=>(h,q)=>{var M=q,{coneInnerAngle:l,coneOuterAngle:p,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:b,orientationY:x,orientationZ:_,panningModel:w,positionX:T,positionY:S,positionZ:v,refDistance:A,rolloffFactor:C}=M,E=Kr(M,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let R=h.createPanner();if(E.channelCount>2||E.channelCountMode==="max")throw s();ft(R,E);let B={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},D=e(h,X(O({},B),{channelInterpretation:"speakers",numberOfInputs:6})),j=r(h,X(O({},E),{gain:1})),F=r(h,X(O({},B),{gain:1})),W=r(h,X(O({},B),{gain:0})),Q=r(h,X(O({},B),{gain:0})),k=r(h,X(O({},B),{gain:0})),it=r(h,X(O({},B),{gain:0})),pt=r(h,X(O({},B),{gain:0})),At=n(h,256,6,1),Yt=o(h,X(O({},B),{curve:new Float32Array([1,1]),oversample:"none"})),Ee=[b,x,_],De=[T,S,v],Nt=new Float32Array(1);At.onaudioprocess=({inputBuffer:tt})=>{let tn=[c(tt,Nt,0),c(tt,Nt,1),c(tt,Nt,2)];tn.some((io,no)=>io!==Ee[no])&&(R.setOrientation(...tn),Ee=tn);let en=[c(tt,Nt,3),c(tt,Nt,4),c(tt,Nt,5)];en.some((io,no)=>io!==De[no])&&(R.setPosition(...en),De=en)},Object.defineProperty(W.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(k.gain,"defaultValue",{get:()=>0}),Object.defineProperty(it.gain,"defaultValue",{get:()=>0}),Object.defineProperty(pt.gain,"defaultValue",{get:()=>0});let ct={get bufferSize(){},get channelCount(){return R.channelCount},set channelCount(tt){if(tt>2)throw s();j.channelCount=tt,R.channelCount=tt},get channelCountMode(){return R.channelCountMode},set channelCountMode(tt){if(tt==="max")throw s();j.channelCountMode=tt,R.channelCountMode=tt},get channelInterpretation(){return R.channelInterpretation},set channelInterpretation(tt){j.channelInterpretation=tt,R.channelInterpretation=tt},get coneInnerAngle(){return R.coneInnerAngle},set coneInnerAngle(tt){R.coneInnerAngle=tt},get coneOuterAngle(){return R.coneOuterAngle},set coneOuterAngle(tt){R.coneOuterAngle=tt},get coneOuterGain(){return R.coneOuterGain},set coneOuterGain(tt){if(tt<0||tt>1)throw t();R.coneOuterGain=tt},get context(){return R.context},get distanceModel(){return R.distanceModel},set distanceModel(tt){R.distanceModel=tt},get inputs(){return[j]},get maxDistance(){return R.maxDistance},set maxDistance(tt){if(tt<0)throw new RangeError;R.maxDistance=tt},get numberOfInputs(){return R.numberOfInputs},get numberOfOutputs(){return R.numberOfOutputs},get orientationX(){return F.gain},get orientationY(){return W.gain},get orientationZ(){return Q.gain},get panningModel(){return R.panningModel},set panningModel(tt){R.panningModel=tt},get positionX(){return k.gain},get positionY(){return it.gain},get positionZ(){return pt.gain},get refDistance(){return R.refDistance},set refDistance(tt){if(tt<0)throw new RangeError;R.refDistance=tt},get rolloffFactor(){return R.rolloffFactor},set rolloffFactor(tt){if(tt<0)throw new RangeError;R.rolloffFactor=tt},addEventListener(...tt){return j.addEventListener(tt[0],tt[1],tt[2])},dispatchEvent(...tt){return j.dispatchEvent(tt[0])},removeEventListener(...tt){return j.removeEventListener(tt[0],tt[1],tt[2])}};l!==ct.coneInnerAngle&&(ct.coneInnerAngle=l),p!==ct.coneOuterAngle&&(ct.coneOuterAngle=p),m!==ct.coneOuterGain&&(ct.coneOuterGain=m),f!==ct.distanceModel&&(ct.distanceModel=f),g!==ct.maxDistance&&(ct.maxDistance=g),b!==ct.orientationX.value&&(ct.orientationX.value=b),x!==ct.orientationY.value&&(ct.orientationY.value=x),_!==ct.orientationZ.value&&(ct.orientationZ.value=_),w!==ct.panningModel&&(ct.panningModel=w),T!==ct.positionX.value&&(ct.positionX.value=T),S!==ct.positionY.value&&(ct.positionY.value=S),v!==ct.positionZ.value&&(ct.positionZ.value=v),A!==ct.refDistance&&(ct.refDistance=A),C!==ct.rolloffFactor&&(ct.rolloffFactor=C),(Ee[0]!==1||Ee[1]!==0||Ee[2]!==0)&&R.setOrientation(...Ee),(De[0]!==0||De[1]!==0||De[2]!==0)&&R.setPosition(...De);let Ji=()=>{j.connect(R),i(j,Yt,0,0),Yt.connect(F).connect(D,0,0),Yt.connect(W).connect(D,0,1),Yt.connect(Q).connect(D,0,2),Yt.connect(k).connect(D,0,3),Yt.connect(it).connect(D,0,4),Yt.connect(pt).connect(D,0,5),D.connect(At).connect(h.destination)},ro=()=>{j.disconnect(R),a(j,Yt,0,0),Yt.disconnect(F),F.disconnect(D),Yt.disconnect(W),W.disconnect(D),Yt.disconnect(Q),Q.disconnect(D),Yt.disconnect(k),k.disconnect(D),Yt.disconnect(it),it.disconnect(D),Yt.disconnect(pt),pt.disconnect(D),D.disconnect(At),At.disconnect(h.destination)};return u(Ye(ct,R),Ji,ro)};var dm=i=>(t,{disableNormalization:e,imag:r,real:n})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=n instanceof Float32Array?n:new Float32Array(n),a=t.createPeriodicWave(s,o,{disableNormalization:e});if(Array.from(r).length<2)throw i();return a};var vn=(i,t,e,r)=>i.createScriptProcessor(t,e,r);var pm=(i,t)=>(e,r)=>{let n=r.channelCountMode;if(n==="clamped-max")throw t();if(e.createStereoPanner===void 0)return i(e,r);let o=e.createStereoPanner();return ft(o,r),It(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>n,set:s=>{if(s!==n)throw t()}}),o};var mm=(i,t,e,r,n,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},h=X(O({},u),{oversample:"none"}),l=(f,g,b,x)=>{let _=new Float32Array(16385),w=new Float32Array(16385);for(let E=0;E<16385;E+=1){let q=E/16384*c;_[E]=Math.cos(q),w[E]=Math.sin(q)}let T=e(f,X(O({},u),{gain:0})),S=r(f,X(O({},h),{curve:_})),v=r(f,X(O({},h),{curve:a})),A=e(f,X(O({},u),{gain:0})),C=r(f,X(O({},h),{curve:w}));return{connectGraph(){g.connect(T),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(A),v.connect(b),b.connect(S.inputs===void 0?S:S.inputs[0]),b.connect(C.inputs===void 0?C:C.inputs[0]),S.connect(T.gain),C.connect(A.gain),T.connect(x,0,0),A.connect(x,0,1)},disconnectGraph(){g.disconnect(T),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(A),v.disconnect(b),b.disconnect(S.inputs===void 0?S:S.inputs[0]),b.disconnect(C.inputs===void 0?C:C.inputs[0]),S.disconnect(T.gain),C.disconnect(A.gain),T.disconnect(x,0,0),A.disconnect(x,0,1)}}},p=(f,g,b,x)=>{let _=new Float32Array(16385),w=new Float32Array(16385),T=new Float32Array(16385),S=new Float32Array(16385),v=Math.floor(16385/2);for(let W=0;W<16385;W+=1)if(W>v){let Q=(W-v)/(16384-v)*c;_[W]=Math.cos(Q),w[W]=Math.sin(Q),T[W]=0,S[W]=1}else{let Q=W/(16384-v)*c;_[W]=1,w[W]=0,T[W]=Math.cos(Q),S[W]=Math.sin(Q)}let A=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),C=e(f,X(O({},u),{gain:0})),E=r(f,X(O({},h),{curve:_})),q=e(f,X(O({},u),{gain:0})),M=r(f,X(O({},h),{curve:w})),R=r(f,X(O({},h),{curve:a})),B=e(f,X(O({},u),{gain:0})),D=r(f,X(O({},h),{curve:T})),j=e(f,X(O({},u),{gain:0})),F=r(f,X(O({},h),{curve:S}));return{connectGraph(){g.connect(A),g.connect(R.inputs===void 0?R:R.inputs[0]),A.connect(C,0),A.connect(q,0),A.connect(B,1),A.connect(j,1),R.connect(b),b.connect(E.inputs===void 0?E:E.inputs[0]),b.connect(M.inputs===void 0?M:M.inputs[0]),b.connect(D.inputs===void 0?D:D.inputs[0]),b.connect(F.inputs===void 0?F:F.inputs[0]),E.connect(C.gain),M.connect(q.gain),D.connect(B.gain),F.connect(j.gain),C.connect(x,0,0),B.connect(x,0,0),q.connect(x,0,1),j.connect(x,0,1)},disconnectGraph(){g.disconnect(A),g.disconnect(R.inputs===void 0?R:R.inputs[0]),A.disconnect(C,0),A.disconnect(q,0),A.disconnect(B,1),A.disconnect(j,1),R.disconnect(b),b.disconnect(E.inputs===void 0?E:E.inputs[0]),b.disconnect(M.inputs===void 0?M:M.inputs[0]),b.disconnect(D.inputs===void 0?D:D.inputs[0]),b.disconnect(F.inputs===void 0?F:F.inputs[0]),E.disconnect(C.gain),M.disconnect(q.gain),D.disconnect(B.gain),F.disconnect(j.gain),C.disconnect(x,0,0),B.disconnect(x,0,0),q.disconnect(x,0,1),j.disconnect(x,0,1)}}},m=(f,g,b,x,_)=>{if(g===1)return l(f,b,x,_);if(g===2)return p(f,b,x,_);throw n()};return(f,w)=>{var T=w,{channelCount:g,channelCountMode:b,pan:x}=T,_=Kr(T,["channelCount","channelCountMode","pan"]);if(b==="max")throw n();let S=i(f,X(O({},_),{channelCount:1,channelCountMode:b,numberOfInputs:2})),v=e(f,X(O({},_),{channelCount:g,channelCountMode:b,gain:1})),A=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:x}),{connectGraph:C,disconnectGraph:E}=m(f,g,v,A,S);Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"maxValue",{get:()=>1}),Object.defineProperty(A.gain,"minValue",{get:()=>-1});let q={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(D){v.channelCount!==D&&(M&&E(),{connectGraph:C,disconnectGraph:E}=m(f,D,v,A,S),M&&C()),v.channelCount=D},get channelCountMode(){return v.channelCountMode},set channelCountMode(D){if(D==="clamped-max"||D==="max")throw n();v.channelCountMode=D},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(D){v.channelInterpretation=D},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return A.gain},addEventListener(...D){return v.addEventListener(D[0],D[1],D[2])},dispatchEvent(...D){return v.dispatchEvent(D[0])},removeEventListener(...D){return v.removeEventListener(D[0],D[1],D[2])}},M=!1,R=()=>{C(),M=!0},B=()=>{E(),M=!1};return o(Ye(q,S),R,B)}};var fm=(i,t,e,r,n,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return e(a,c);ft(u,c);let h=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(h!==null&&h.length<2)throw t();vt(u,{curve:h},"curve"),vt(u,c,"oversample");let l=null,p=!1;return s(u,"curve",g=>()=>g.call(u),g=>b=>(g.call(u,b),p&&(r(b)&&l===null?l=i(a,u):!r(b)&&l!==null&&(l(),l=null)),b)),n(u,()=>{p=!0,r(u.curve)&&(l=i(a,u))},()=>{p=!1,l!==null&&(l(),l=null)})};var gm=(i,t,e,r,n)=>(o,u)=>{var h=u,{curve:s,oversample:a}=h,c=Kr(h,["curve","oversample"]);let l=o.createWaveShaper(),p=o.createWaveShaper();ft(l,c),ft(p,c);let m=e(o,X(O({},c),{gain:1})),f=e(o,X(O({},c),{gain:-1})),g=e(o,X(O({},c),{gain:1})),b=e(o,X(O({},c),{gain:-1})),x=null,_=!1,w=null,T={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(A){m.channelCount=A,f.channelCount=A,l.channelCount=A,g.channelCount=A,p.channelCount=A,b.channelCount=A},get channelCountMode(){return l.channelCountMode},set channelCountMode(A){m.channelCountMode=A,f.channelCountMode=A,l.channelCountMode=A,g.channelCountMode=A,p.channelCountMode=A,b.channelCountMode=A},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(A){m.channelInterpretation=A,f.channelInterpretation=A,l.channelInterpretation=A,g.channelInterpretation=A,p.channelInterpretation=A,b.channelInterpretation=A},get context(){return l.context},get curve(){return w},set curve(A){if(A!==null&&A.length<2)throw t();if(A===null)l.curve=A,p.curve=A;else{let C=A.length,E=new Float32Array(C+2-C%2),q=new Float32Array(C+2-C%2);E[0]=A[0],q[0]=-A[C-1];let M=Math.ceil((C+1)/2),R=(C+1)/2-1;for(let B=1;B<M;B+=1){let D=B/M*R,j=Math.floor(D),F=Math.ceil(D);E[B]=j===F?A[j]:(1-(D-j))*A[j]+(1-(F-D))*A[F],q[B]=j===F?-A[C-1-j]:-((1-(D-j))*A[C-1-j])-(1-(F-D))*A[C-1-F]}E[M]=C%2===1?A[M-1]:(A[M-2]+A[M-1])/2,l.curve=E,p.curve=q}w=A,_&&(r(w)&&x===null?x=i(o,m):x!==null&&(x(),x=null))},get inputs(){return[m]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(A){l.oversample=A,p.oversample=A},addEventListener(...A){return m.addEventListener(A[0],A[1],A[2])},dispatchEvent(...A){return m.dispatchEvent(A[0])},removeEventListener(...A){return m.removeEventListener(A[0],A[1],A[2])}};s!==null&&(T.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==T.oversample&&(T.oversample=a);let S=()=>{m.connect(l).connect(g),m.connect(f).connect(p).connect(b).connect(g),_=!0,r(w)&&(x=i(o,m))},v=()=>{m.disconnect(l),l.disconnect(g),m.disconnect(f),f.disconnect(p),p.disconnect(b),b.disconnect(g),_=!1,x!==null&&(x(),x=null)};return n(Ye(T,g),S,v)};var ce=()=>new DOMException("","NotSupportedError");var WC={numberOfChannels:1},ym=(i,t,e,r,n)=>class extends i{constructor(s,a,c){let u;if(typeof s=="number"&&a!==void 0&&c!==void 0)u={length:a,numberOfChannels:s,sampleRate:c};else if(typeof s=="object")u=s;else throw new Error("The given parameters are not valid.");let{length:h,numberOfChannels:l,sampleRate:p}=O(O({},WC),u),m=r(l,h,p);t(cr,()=>cr(m))||m.addEventListener("statechange",(()=>{let f=0,g=b=>{this._state==="running"&&(f>0?(m.removeEventListener("statechange",g),b.stopImmediatePropagation(),this._waitForThePromiseToSettle(b)):f+=1)};return g})()),super(m,l),this._length=h,this._nativeOfflineAudioContext=m,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(e()):(this._state="running",n(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,ai(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var UC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},bm=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},UC),u),p=e(h,l),m=o(h),f=m?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,m,p.detune,153600,-153600),this._frequency=t(this,m,p.frequency,g,-g),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&l.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=l.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeOscillatorNode.onended=u;let h=this._nativeOscillatorNode.onended;this._onended=h!==null&&h===u?c:h}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){sr(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),be(this)&&Ir(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var xm=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(h,l)=>K(null,null,function*(){let p=e(h),m=_t(p,l);if(!m){let f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:s===null?void 0:s,type:p.type};p=t(l,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return o.set(l,p),m?(yield i(l,h.detune,p.detune),yield i(l,h.frequency,p.frequency)):(yield r(l,h.detune,p.detune),yield r(l,h.frequency,p.frequency)),yield n(h,l,p),p});return{set periodicWave(h){s=h},set start(h){a=h},set stop(h){c=h},render(h,l){let p=o.get(l);return p!==void 0?Promise.resolve(p):u(h,l)}}};var zC={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},Am=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},zC),u),p=e(h,l),m=o(h),f=m?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,m,p.orientationX,Wt,Ht),this._orientationY=t(this,m,p.orientationY,Wt,Ht),this._orientationZ=t(this,m,p.orientationZ,Wt,Ht),this._positionX=t(this,m,p.positionX,Wt,Ht),this._positionY=t(this,m,p.positionY,Wt,Ht),this._positionZ=t(this,m,p.positionZ,Wt,Ht),s(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}};var Cm=(i,t,e,r,n,o,s,a,c,u)=>()=>{let h=new WeakMap,l=null,p=(m,f)=>K(null,null,function*(){let g=null,b=o(m),x={channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation},_=X(O({},x),{coneInnerAngle:b.coneInnerAngle,coneOuterAngle:b.coneOuterAngle,coneOuterGain:b.coneOuterGain,distanceModel:b.distanceModel,maxDistance:b.maxDistance,panningModel:b.panningModel,refDistance:b.refDistance,rolloffFactor:b.rolloffFactor}),w=_t(b,f);if("bufferSize"in b)g=r(f,X(O({},x),{gain:1}));else if(!w){let T=X(O({},_),{orientationX:b.orientationX.value,orientationY:b.orientationY.value,orientationZ:b.orientationZ.value,positionX:b.positionX.value,positionY:b.positionY.value,positionZ:b.positionZ.value});b=n(f,T)}if(h.set(f,g===null?b:g),g!==null){if(l===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let M=new s(6,m.context.length,f.sampleRate),R=t(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});R.connect(M.destination),l=K(null,null,function*(){let B=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((D,j)=>K(null,null,function*(){let F=e(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:j===0?1:0});return yield a(M,D,F.offset),F})));for(let D=0;D<6;D+=1)B[D].connect(R,0,D),B[D].start(0);return u(M)})}let T=yield l,S=r(f,X(O({},x),{gain:1}));yield c(m,f,S);let v=[];for(let M=0;M<T.numberOfChannels;M+=1)v.push(T.getChannelData(M));let A=[v[0][0],v[1][0],v[2][0]],C=[v[3][0],v[4][0],v[5][0]],E=r(f,X(O({},x),{gain:1})),q=n(f,X(O({},_),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:C[0],positionY:C[1],positionZ:C[2]}));S.connect(E).connect(q.inputs[0]),q.connect(g);for(let M=128;M<T.length;M+=128){let R=[v[0][M],v[1][M],v[2][M]],B=[v[3][M],v[4][M],v[5][M]];if(R.some((D,j)=>D!==A[j])||B.some((D,j)=>D!==C[j])){A=R,C=B;let D=M/f.sampleRate;E.gain.setValueAtTime(0,D),E=r(f,X(O({},x),{gain:0})),q=n(f,X(O({},_),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:C[0],positionY:C[1],positionZ:C[2]})),E.gain.setValueAtTime(1,D),S.connect(E).connect(q.inputs[0]),q.connect(g)}}return g}return w?(yield i(f,m.orientationX,b.orientationX),yield i(f,m.orientationY,b.orientationY),yield i(f,m.orientationZ,b.orientationZ),yield i(f,m.positionX,b.positionX),yield i(f,m.positionY,b.positionY),yield i(f,m.positionZ,b.positionZ)):(yield a(f,m.orientationX,b.orientationX),yield a(f,m.orientationY,b.orientationY),yield a(f,m.orientationZ,b.orientationZ),yield a(f,m.positionX,b.positionX),yield a(f,m.positionY,b.positionY),yield a(f,m.positionZ,b.positionZ)),ze(b)?yield c(m,f,b.inputs[0]):yield c(m,f,b),b});return{render(m,f){let g=h.get(f);return g!==void 0?Promise.resolve(g):p(m,f)}}};var YC={disableNormalization:!1},_m=(i,t,e,r)=>class vm{constructor(o,s){let a=t(o),c=r(O(O({},YC),s)),u=i(a,c);return e.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===vm.prototype||e.has(o)}};var wm=(i,t)=>(e,r,n)=>(i(r).replay(n),t(r,e,n));var Sm=(i,t,e)=>(r,n,o)=>K(null,null,function*(){let s=i(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(l=>K(null,[l],function*([u,h]){let m=yield t(u).render(u,n),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&m.connect(o,h,c)}))).reduce((a,c)=>[...a,...c],[]))});var Im=(i,t,e)=>(r,n,o)=>K(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>K(null,[u],function*([a,c]){let l=yield i(a).render(a,n);e(a)||l.connect(o,c)})))});var Tm=(i,t,e,r)=>n=>i(cr,()=>cr(n))?Promise.resolve(i(r,r)).then(o=>{if(!o){let s=e(n,512,0,1);n.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>n.currentTime,s.connect(n.destination)}return n.startRendering()}):new Promise(o=>{let s=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(n.destination),n.startRendering()});var Nm=i=>(t,e)=>{i.set(t,e)};var Om=i=>(t,e)=>i.set(t,e);var Rm=(i,t,e,r,n,o,s,a)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(h=>e(h).render(h,u)))).then(()=>n(u)).then(h=>(typeof h.copyFromChannel!="function"?(s(h),dn(h)):t(o,()=>o(h))||a(h),i.add(h),h));var HC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Mm=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),h=O(O({},HC),c),l=e(u,h),p=o(u),m=p?r():null;super(a,!1,l,m),this._pan=t(this,p,l.pan)}get pan(){return this._pan}};var Em=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,l)}return o.set(c,u),h?yield i(c,a.pan,u.pan):yield r(c,a.pan,u.pan),ze(u)?yield n(a,c,u.inputs[0]):yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Dm=i=>()=>{if(i===null)return!1;try{new i({length:1,sampleRate:44100})}catch(t){return!1}return!0};var km=(i,t)=>()=>K(null,null,function*(){if(i===null)return!0;if(t===null)return!1;let e=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new t(1,128,44100),n=URL.createObjectURL(e),o=!1,s=!1;try{yield r.audioWorklet.addModule(n);let a=new i(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>o=!0,a.onprocessorerror=()=>s=!0,c.connect(a),c.start(0),yield r.startRendering(),yield new Promise(u=>setTimeout(u))}catch(a){}finally{URL.revokeObjectURL(n)}return o&&!s});var Lm=(i,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=i(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(n=>{e.oncomplete=()=>{r.disconnect(),n(e.currentTime!==0)},e.startRendering()})};var Yu=()=>new DOMException("","UnknownError");var $C={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},jm=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},$C),u),p=e(h,l),f=o(h)?r():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,s(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var Pm=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=i(s,u)}return r.set(s,a),ze(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var Fm=()=>typeof window=="undefined"?null:window;var Bm=(i,t)=>e=>{e.copyFromChannel=(r,n,o=0)=>{let s=i(o),a=i(n);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),h=r.length;for(let l=s<0?-s:0;l+s<c&&l<h;l+=1)r[l]=u[l+s]},e.copyToChannel=(r,n,o=0)=>{let s=i(o),a=i(n);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),h=r.length;for(let l=s<0?-s:0;l+s<c&&l<h;l+=1)u[l+s]=r[l]}};var Gm=i=>t=>{t.copyFromChannel=(e=>(r,n,o=0)=>{let s=i(o),a=i(n);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,n,o=0)=>{let s=i(o),a=i(n);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var Vm=i=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),i(t,"buffer",n=>()=>{let o=n.call(t);return o===r?null:o},n=>o=>n.call(t,o===null?r:o))};var qm=(i,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw i()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw i()}});let n=e.createBufferSource();t(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)n.connect(r,0,c)},()=>n.disconnect(r))};var Hu=(i,t,e)=>i.copyFromChannel===void 0?i.getChannelData(e)[0]:(i.copyFromChannel(t,e),t[0]);var $u=i=>{if(i===null)return!1;let t=i.length;return t%2!==0?i[Math.floor(t/2)]!==0:i[t/2-1]+i[t/2]!==0};var wn=(i,t,e,r)=>{let n=i;for(;!n.hasOwnProperty(t);)n=Object.getPrototypeOf(n);let{get:o,set:s}=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(i,t,{get:e(o),set:r(s)})};var Wm=i=>X(O({},i),{outputChannelCount:i.outputChannelCount!==void 0?i.outputChannelCount:i.numberOfInputs===1&&i.numberOfOutputs===1?[i.channelCount]:Array.from({length:i.numberOfOutputs},()=>1)});var Um=i=>X(O({},i),{channelCount:i.numberOfOutputs});var zm=i=>{let{imag:t,real:e}=i;return t===void 0?e===void 0?X(O({},i),{imag:[0,0],real:[0,0]}):X(O({},i),{imag:Array.from(e,()=>0),real:e}):e===void 0?X(O({},i),{imag:t,real:Array.from(t,()=>0)}):X(O({},i),{imag:t,real:e})};var Zu=(i,t,e)=>{try{i.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;Zu(i,t,e+1e-7)}};var Ym=i=>{let t=i.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var Hm=i=>{let t=i.createBufferSource(),e=i.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var $m=i=>{let t=i.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var fa=i=>{let t=i.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Xu=i=>{let t=i.createBuffer(1,1,44100),e=i.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var ga=i=>{let t=i.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var Zm=i=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(i)}finally{t.close(),e.close()}};var Xm=i=>{i.start=(t=>(e=0,r=0,n)=>{let o=i.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/i.context.sampleRate?t.call(i,e,0,0):t.call(i,e,s,n)})(i.start)};var Qu=(i,t)=>{let e=t.createGain();i.connect(e);let r=(n=>()=>{n.call(i,e),i.removeEventListener("ended",r)})(i.disconnect);i.addEventListener("ended",r),Ye(i,e),i.stop=(n=>{let o=!1;return(s=0)=>{if(o)try{n.call(i,s)}catch(a){e.gain.setValueAtTime(0,s)}else n.call(i,s),o=!0}})(i.stop)};var Li=(i,t)=>e=>{let r={value:i};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(i,e):t.handleEvent.call(i,e)};var ZC=Gl(ar),XC=Xl(ar),QC=zd(oi),Km=new WeakMap,KC=ap(Km),He=Id(new Map,new WeakMap),Tr=Fm(),Jm=jp(He,Ue),Ku=sp(ne),ue=Sm(ne,Ku,Wr),JC=td(Jm,Ot,ue),Lt=hp(hn),Ur=cm(Tr),Rt=Sp(Ur),tf=new WeakMap,ef=tp(Li),Sn=Gp(Tr),Ju=Cp(Sn),th=_p(Tr),rf=vp(Tr),To=qp(Tr),$t=yd(Vl(ia),Zl(ZC,XC,pn,QC,mn,ne,KC,Sr,Ot,ar,be,Wr,fn),He,gp(vo,mn,ne,Ot,Di,be),Ue,xn,ce,qd(pn,vo,ne,Ot,Di,Lt,be,Rt),$d(tf,ne,Kt),ef,Lt,Ju,th,rf,Rt,To),t_=Jl($t,JC,Ue,Jm,Lt,Rt);var eh=new WeakSet,Qm=Pp(Tr),nf=jd(new Uint32Array(1)),rh=Bm(nf,Ue),ih=Gm(nf),nh=ed(eh,He,ce,Qm,Ur,Dm(Qm),rh,ih);var ya=Ql(xe),of=Im(Ku,si,Wr),Nr=Md(of),In=Bp(ya,He,Ym,Hm,$m,fa,Xu,ga,Xm,Vm(wn),Qu),Or=wm(cp(si),of),e_=nd(Nr,In,Ot,Or,ue),ur=bd(ql(na),tf,_o,xd,Nu,Ou,Ru,Mu,Eu,sn,yo,Sn,Zu),r_=id($t,e_,ur,Pt,In,Lt,Rt,Li);var i_=dd($t,pd,Ue,Pt,Vp(xe,wn),Lt,Rt,ue),n_=Sd(Nr,Uu,Ot,Or,ue),ji=Om(Km),o_=wd($t,ur,n_,xn,Uu,Lt,Rt,ji),ui=kp(ar,th),s_=qm(Pt,ui),hi=Zp(Sn,s_),a_=Nd(hi,Ot,ue),c_=Td($t,a_,hi,Lt,Rt),u_=Rd(_n,Ot,ue),h_=Od($t,u_,_n,Lt,Rt,Um),l_=Kp(ya,In,xe,ui),Tn=Qp(ya,He,l_,fa,ga),d_=Ld(Nr,Tn,Ot,Or,ue),p_=kd($t,ur,d_,Tn,Lt,Rt,Li),sf=Jp(ce,wn),m_=Fd(sf,Ot,ue),f_=Pd($t,m_,sf,Lt,Rt,ji),g_=Ud(Nr,zu,Ot,Or,ue),y_=Wd($t,ur,g_,zu,Lt,Rt,ji),af=tm(ce),b_=Qd(Nr,af,Ot,Or,ue),x_=Xd($t,ur,b_,af,ce,Lt,Rt,ji),A_=np(Nr,xe,Ot,Or,ue),C_=ip($t,ur,A_,xe,Lt,Rt),__=im(xn,Pt,vn,ce),ba=Tm(He,xe,vn,Lm(xe,Ur)),v_=fp(In,Ot,Ur,ue,ba),w_=em(__),S_=mp($t,w_,v_,Lt,Rt,ji),I_=md(ur,hi,Tn,vn,ce,Hu,Rt,wn),cf=new WeakMap,oh=Ep(i_,I_,ef,Rt,cf,Li),uf=um(ya,He,fa,Xu,ga,Qu),T_=xm(Nr,uf,Ot,Or,ue),N_=bm($t,ur,uf,T_,Lt,Rt,Li),hf=Dd(In),O_=gm(hf,Pt,xe,$u,ui),xa=fm(hf,Pt,O_,$u,ui,Sn,wn),R_=lm(pn,Pt,hi,xe,vn,xa,ce,mn,Hu,ui),lf=hm(R_),M_=Cm(Nr,hi,Tn,xe,lf,Ot,Ur,Or,ue,ba),E_=Am($t,ur,lf,M_,Lt,Rt,ji),D_=dm(Ue),k_=_m(D_,Lt,new WeakSet,zm),L_=mm(hi,_n,xe,xa,ce,ui),df=pm(L_,ce),j_=Em(Nr,df,Ot,Or,ue),P_=Mm($t,ur,df,j_,Lt,Rt),F_=Pm(xa,Ot,ue),B_=jm($t,Pt,xa,F_,Lt,Rt,ji),pf=Ip(Tr),sh=ep(Tr),mf=new WeakMap,G_=lp(mf,Ur),V_=pf?$l(He,ce,Jd(Tr),sh,rp(Bl),Lt,G_,Rt,To,new WeakMap,new WeakMap,km(To,Ur),Tr):void 0,q_=wp(Ju,Rt),W_=Vd(eh,He,Gd,Kd,new WeakSet,Lt,q_,ln,cr,rh,ih),ff=vd(V_,t_,nh,r_,o_,c_,h_,p_,f_,W_,y_,x_,C_,S_,oh,N_,E_,k_,P_,B_),U_=Tp($t,nm,Lt,Rt),z_=Np($t,om,Lt,Rt),Y_=Op($t,sm,Lt,Rt),H_=am(Pt,Rt),$_=Rp($t,H_,Lt),gf=ld(ff,Pt,ce,Yu,U_,z_,Y_,$_,Sn);var ah=dp(cf),Z_=Kl(ah),yf=Ed(Ue),X_=Yd(ah),bf=Zd(Ue),xf=new WeakMap,Q_=op(xf,Kt),K_=$p(yf,Ue,Pt,hi,_n,Tn,xe,vn,ce,bf,sh,Q_,ui),J_=Up(Pt,K_,xe,ce,ui),tv=_d(Nr,yf,In,hi,_n,Tn,xe,X_,bf,sh,Ot,To,Ur,Or,ue,ba),ev=up(mf),rv=Nm(xf),ch=pf?Ad(Z_,$t,ur,tv,J_,ne,ev,Lt,Rt,To,Wm,rv,Zm,Li):void 0;var bU=Mp(Pt,ce,Yu,oh,Sn);var Af=Bd(ce,Ur),Cf=Rm(eh,He,Ku,ah,ba,ln,rh,ih),xU=Dp(He,Pt,Af,oh,Cf);var _f=ym(ff,He,Pt,Af,Cf);var vf=yp(hn,Ju),wf=bp(un,th),Sf=xp(_o,rf),If=Ap(hn,Rt);function Zt(i){return i===void 0}function rt(i){return i!==void 0}function Tf(i){return typeof i=="function"}function he(i){return typeof i=="number"}function hr(i){return Object.prototype.toString.call(i)==="[object Object]"&&i.constructor===Object}function uh(i){return typeof i=="boolean"}function Gt(i){return Array.isArray(i)}function me(i){return typeof i=="string"}function No(i){return me(i)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(i)}function Y(i,t){if(!i)throw new Error(t)}function Ut(i,t,e=1/0){if(!(t<=i&&i<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${i}`)}function Aa(i){!i.isOffline&&i.state!=="running"&&Pi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Of=!1,Nf=!1;function hh(i){Of=i}function Rf(i){Zt(i)&&Of&&!Nf&&(Nf=!0,Pi("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var Mf=console;function Ef(...i){Mf.log(...i)}function Pi(...i){Mf.warn(...i)}function Df(i){return new gf(i)}function kf(i,t,e){return new _f(i,t,e)}var fe=typeof self=="object"?self:null,Lf=fe&&(fe.hasOwnProperty("AudioContext")||fe.hasOwnProperty("webkitAudioContext"));function jf(i,t,e){return Y(rt(ch),"AudioWorkletNode only works in a secure context (https or localhost)"),new(i instanceof(fe==null?void 0:fe.BaseAudioContext)?fe==null?void 0:fe.AudioWorkletNode:ch)(i,t,e)}function ge(i,t,e,r){var n=arguments.length,o=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var a=i.length-1;a>=0;a--)(s=i[a])&&(o=(n<3?s(o):n>3?s(t,e,o):s(t,e))||o);return n>3&&o&&Object.defineProperty(t,e,o),o}function gt(i,t,e,r){function n(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(h){try{u(r.next(h))}catch(l){s(l)}}function c(h){try{u(r.throw(h))}catch(l){s(l)}}function u(h){h.done?o(h.value):n(h.value).then(a,c)}u((r=r.apply(i,t||[])).next())})}var Ca=class{constructor(t,e,r,n){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(n||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let t=new Blob([`
82
+ `);var Ct=(c=>(c[c.Unknown=0]="Unknown",c[c.InvalidArg=1]="InvalidArg",c[c.Note=2]="Note",c[c.Scale=3]="Scale",c[c.KeySignature=4]="KeySignature",c[c.Timesignature=5]="Timesignature",c[c.Score=6]="Score",c[c.Audio=7]="Audio",c))(Ct||{});function BA(i){return i===void 0?"":`[${Ct[i]}] `}var N=class extends Error{constructor(...e){let[r,n]=e.length===1?[0,e[0]]:e;super(BA(r)+n);d(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var vl=!1;function Ti(){vl||(vl=!0,console.log("%cWebMusicScore v6.0.0-pre.5 (iife) initialized.","background: black; color: white; padding: 2px;"))}var ti=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(ti||{}),ei=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(ei||{}),GA=H.Enum.getEnumValues(ei),VA=0;function wl(i){if(y.isEnumValue(i,ei))return i;throw new N(1,`Invalid pitchNotation: ${i}`)}function qA(i){return ei[wl(i)]}var Hs=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Hs||{}),WA="Default",UA=H.Enum.getEnumValues(Hs);function zA(i){if(y.isEnumValue(i,Hs))return i;throw new N(5,`Invalid guitarNoteLabel: ${i}`)}function Sl(i,t){return(i%t+t)%t}var Il=12,Tl=7,YA=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),HA=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Nl=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),ho=["C","D","E","F","G","A","B"],Ol=[0,2,4,5,7,9,11],Rl=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,dt=class dt{constructor(t,e,r){d(this,"diatonicClass");d(this,"accidental");d(this,"octave");if(typeof t=="number"&&typeof e=="number"&&r===void 0)dt.validateDiatonicId(t),this.diatonicClass=dt.getDiatonicClass(t),this.accidental=dt.validateAccidental(e),this.octave=dt.getOctaveFromDiatonicId(t);else if(typeof t=="number"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=dt.validateDiatonicClass(t),this.accidental=dt.validateAccidental(e),this.octave=dt.validateOctave(r);else if(typeof t=="string"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=dt.getDiatonicClass(t),this.accidental=dt.validateAccidental(e),this.octave=dt.validateOctave(r);else throw new N(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return dt.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return dt.getChromaticIdInOctave(Ol[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return dt.getChromaticClass(Ol[this.diatonicClass]+this.accidental)}get noteLetter(){return ho[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:n}=this,o=dt.getAccidentalSymbol(this.accidental,e);return t===1?n>=3?r.toLowerCase()+o+"\u2032".repeat(n-3):r.toUpperCase()+o+"\u0375".repeat(2-n):r+o+n}formatOmitOctave(t){let e=ho[this.diatonicClass],r=dt.getAccidentalSymbol(this.accidental,t);return e+r}static getNote(t){return this.noteCache.getOrCreate(t,()=>{let e=dt.parseNote(t);if(!e)throw new N(2,`Invalid note "${t}".`);if(e.octave===void 0)throw new N(2,`Invalid note "${t}" (missing octave).`);return new dt(e.noteLetter,e.accidental,e.octave)})}static isNote(t){let e=dt.parseNote(t);return e!==void 0&&e.octave!==void 0}static validateNote(t){if(this.isNote(t))return!0;throw new N(2,`Invalid note "${t}"`)}static getChromaticNote(t){return this.chromaticNoteCache.getOrCreate(t,()=>{let r=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][dt.getChromaticClass(t)].split("/")[0]+dt.getOctaveFromChromaticId(t);return dt.getNote(r)})}static getDiatonicClass(t){if(typeof t=="number")return Sl(t,7);if(typeof t=="string"&&t.length>0)return ho.indexOf(dt.validateNoteLetter(t[0]));throw new N(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-Tl)/7)}static getDiatonicIdInOctave(t,e){return dt.getDiatonicClass(t)+e*7+Tl}static getChromaticClass(t){return Sl(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-Il)/12)}static getChromaticIdInOctave(t,e){return dt.getChromaticClass(t)+e*12+Il}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.diatonicId===e.diatonicId&&t.accidental===e.accidental}static replaceAccidentalSymbols(t,e){return e===1?t.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):t.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(t){return Rl.test(t)}static parseNote(t){var c;let e=Rl.exec(t);if(!e)return;let r=dt.validateNoteLetter(e[1]),n=e[2],o=dt.validateAccidental((c=Nl.get(n))!=null?c:0),s=e[3],a=s?dt.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(t,e){let r=dt.parseNote(t);if(!r)throw new N(2,`Invalid noteName: ${t}`);let{noteLetter:n,accidental:o,octave:s}=r;return n+dt.getAccidentalSymbol(o,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?HA.get(t):YA.get(t)}static getAccidental(t){let e=Nl.get(t);if(e===void 0)throw new N(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return ho[dt.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let n=dt.getDiatonicClass(t),o=dt.getDiatonicClass(e),s=r?n<=o?1:0:n<o?1:0;return dt.getDiatonicIdInOctave(n,dt.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(y.isInteger(t))return t;throw new N(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(y.isIntegerBetween(t,0,6))return t;throw new N(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(y.isInteger(t))return t;throw new N(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(y.isIntegerBetween(t,0,11))return t;throw new N(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(ho.some(e=>e===t))return t;throw new N(2,`Invalid note: ${t}`)}static validateOctave(t){if(y.isInteger(t))return t;throw new N(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(y.isIntegerBetween(t,-2,2))return t;throw new N(2,`Invalid accidental: ${t}`)}static sort(t){return t.slice().sort(dt.compareFunc)}static removeDuplicates(t){let e=[];return t.forEach(r=>{e.find(n=>dt.equals(r,n))===void 0&&e.push(r)}),e}static compareFunc(t,e){return t.diatonicId<e.diatonicId?-1:t.diatonicId>e.diatonicId?1:t.accidental<e.accidental?-1:t.accidental>e.accidental?1:0}};d(dt,"noteCache",new lt),d(dt,"chromaticNoteCache",new lt);var U=dt;function $A(i,t){let e=U.getChromaticClass(i)-new U(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return U.validateAccidental(e)}var ZA=/^(bb?|b?|#?|x?)([0-9]*)$/;function XA(i){var n,o;let t=ZA.exec(""+i);if(!t)throw new N(4,`Invalid degree: ${i}`);let e=(o=U.getAccidental((n=t[1])!=null?n:""))!=null?o:0,r=+t[2];if(!y.isInteger(e)||e<-2||e>2||!y.isInteger(r)||r<1)throw new N(4,`Invalid degree: ${i}`);return{deg:r,acc:e}}var mu=(a=>(a[a.Ionian=1]="Ionian",a[a.Dorian=2]="Dorian",a[a.Phrygian=3]="Phrygian",a[a.Lydian=4]="Lydian",a[a.Mixolydian=5]="Mixolydian",a[a.Aeolian=6]="Aeolian",a[a.Locrian=7]="Locrian",a))(mu||{}),fu=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(fu||{});function $s(){return Pr("C","Major")}var ri=class ri{constructor(t,e){this.tonic=t;this.mode=e;d(this,"naturalScaleNotes");d(this,"accidentalByDiatonicClass");d(this,"orderedAccidentedNotes");if(!y.isEnumValue(e,mu))throw new N(4,`Invalid mode: ${e}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<e;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let n=U.getDiatonicClass(t[0]),o=U.getNote(t+"0").chromaticId;for(let c=0;c<7;n++,o+=r[c],c++){let u=new U(U.getDiatonicClass(n),$A(o,n));if(Math.abs(u.accidental)>=2)throw new N(4,"Key signature contains double accidental.");this.naturalScaleNotes[c]=u,this.accidentalByDiatonicClass[u.diatonicClass]=u.accidental}let s=this.naturalScaleNotes.filter(c=>c.accidental>0).sort((c,u)=>{let l=ri.OrderOfSharps.indexOf(c.noteLetter),h=ri.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new N(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=ri.OrderOfFlats.indexOf(c.noteLetter),h=ri.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new N(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new N(4,"Key Signature has both sharps and flats.");this.orderedAccidentedNotes=a.length>0?a:s}getAccidentalType(){return this.orderedAccidentedNotes.length===0?0:this.orderedAccidentedNotes[0].accidental<0?1:2}getNaturalScaleNotes(){return this.naturalScaleNotes}getAccidental(t){var e;return(e=this.accidentalByDiatonicClass[U.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=XA(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let n=this.naturalScaleNotes[(e-1)%7];return new U(n.diatonicId,n.accidental+r)}}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.tonic===e.tonic&&t.mode===e.mode}};d(ri,"OrderOfSharps","FCGDAEB"),d(ri,"OrderOfFlats","BEADGCF");var rr=ri;var QA=new lt([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),KA={1:{0:"Perfect",1:"Augmented","-1":"diminished",2:"Doubly Augmented","-2":"doubly diminished"},2:{2:"Major",1:"minor",3:"Augmented",0:"diminished",4:"Doubly Augmented","-1":"doubly diminished"},3:{4:"Major",3:"minor",5:"Augmented",2:"diminished",6:"Doubly Augmented",1:"doubly diminished"},4:{5:"Perfect",6:"Augmented",4:"diminished",7:"Doubly Augmented",3:"doubly diminished"},5:{7:"Perfect",8:"Augmented",6:"diminished",9:"Doubly Augmented",5:"doubly diminished"},6:{9:"Major",8:"minor",10:"Augmented",7:"diminished",11:"Doubly Augmented",6:"doubly diminished"},7:{11:"Major",10:"minor",12:"Augmented",9:"diminished",13:"Doubly Augmented",8:"doubly diminished"},8:{12:"Perfect",13:"Augmented",11:"diminished",14:"Doubly Augmented",10:"doubly diminished"}};function JA(i,t){for(;i<1;)i+=7,t+=12;for(;i>8;)i-=7,t-=12;let e=KA[i];if(e)return e[t]}function tC(i){if(i==="Perfect"||i==="Major"||i==="minor"||i==="Augmented"||i==="diminished"||i==="Doubly Augmented"||i==="doubly diminished")return i;throw new N(1,`Invalid interval quality: ${i}`)}function eC(i){if(y.isIntegerGte(i,1))return H.Math.toOrdinalNumber(i);throw new N(1,`Invalid interval quantity: ${i}`)}var Zs=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},lo=class i{constructor(t,e){this.note1=t;this.note2=e;d(this,"direction");d(this,"semitones");d(this,"quantity");d(this,"quality");e.diatonicId>=t.diatonicId?(this.direction=e.diatonicId===t.diatonicId?"Unison":"Ascending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId):(this.direction="Descending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId);let r=JA(this.quantity,this.semitones);if(r)this.quality=r;else throw new Zs("Unknown interval quality")}static get(t,e){try{return new i(t,e)}catch(r){if(r instanceof Zs)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":eC(this.quantity);return t+e+r}toAbbrString(){let t=this.direction==="Descending"?"\u2193":"",e=QA.getOrDefault(this.quality,"?"),r=this.quantity;return t+e+r}};function rC(i){let t=U.getDiatonicClass("CCDDEFFGGAAB"[U.getChromaticClass(i)]),e=U.getOctaveFromChromaticId(i);return U.getDiatonicIdInOctave(t,e)}var iC=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],Ni=(g=>(g.Major="Major",g.NaturalMinor="Natural Minor",g.HarmonicMinor="Harmonic Minor",g.Ionian="Ionian",g.Dorian="Dorian",g.Phrygian="Phrygian",g.Lydian="Lydian",g.Mixolydian="Mixolydian",g.Aeolian="Aeolian",g.Locrian="Locrian",g.MajorPentatonic="Major Pentatonic",g.MinorPentatonic="Minor Pentatonic",g.MajorHexatonicBlues="Major Hexatonic Blues",g.MinorHexatonicBlues="Minor Hexatonic Blues",g.HeptatonicBlues="Heptatonic Blues",g))(Ni||{});function nC(i){switch(i){case"Major":return 1;case"Natural Minor":return 6;case"Harmonic Minor":return 6;case"Ionian":return 1;case"Dorian":return 2;case"Phrygian":return 3;case"Lydian":return 4;case"Mixolydian":return 5;case"Aeolian":return 6;case"Locrian":return 7;case"Major Pentatonic":return 1;case"Minor Pentatonic":return 6;case"Major Hexatonic Blues":return 1;case"Minor Hexatonic Blues":return 6;case"Heptatonic Blues":return 1;default:throw new N(3,`Invalid scaleType: ${i}`)}}var ii=class extends rr{constructor(e,r){super(e,nC(r));this.tonic=e;this.scaleType=r;d(this,"scaleDegrees");d(this,"scaleNotes");d(this,"chromaticClassDegree");d(this,"preferredChromaticIdNoteCache",new Cl);switch(r){case"Harmonic Minor":this.scaleDegrees=[1,2,3,4,5,6,"#7"];break;case"Major Pentatonic":this.scaleDegrees=[1,2,3,5,6];break;case"Minor Pentatonic":this.scaleDegrees=[1,3,4,5,7];break;case"Major Hexatonic Blues":this.scaleDegrees=[1,2,"b3",3,5,6];break;case"Minor Hexatonic Blues":this.scaleDegrees=[1,3,4,"b5",5,7];break;case"Heptatonic Blues":this.scaleDegrees=[1,2,"b3",4,"b5",6,"b7"];break;default:this.scaleDegrees=[1,2,3,4,5,6,7];break}this.scaleNotes=this.scaleDegrees.map(n=>this.getNoteByDegree(n)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(n=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===n);return o>=0?this.scaleDegrees[o]:void 0})}static equals(e,r){return e==null&&r==null?!0:e==null||r==null?!1:e===r||e.getScaleName()===r.getScaleName()}getScaleName(e){switch(e){case 1:return U.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!y.isIntegerGte(r,1))throw new N(3,`Invalid numOctaves: ${r}`);let n=[];for(let s=1;s<=r;s++)n=[...n,...this.scaleNotes];n.push(this.scaleNotes[0]);let o=U.getNote(e).diatonicId;return n.map(s=>(o=U.findNextDiatonicIdAbove(s.diatonicId,o,!1),new U(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(e=>e.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let e=this.getScaleNotes("C4",1).map(n=>n.chromaticId),r=[];for(let n=0;n<e.length-1;n++)r.push(H.Math.mod(e[n+1]-e[n],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(e=>e===1?"H":e===2?"W":e.toString()+"H")}isScaleNote(e){return this.chromaticClassDegree[e.chromaticClass]!==void 0}isScaleRootNote(e){return String(this.chromaticClassDegree[e.chromaticClass])==="1"}getIntervalFromRootNote(e){let r=this.getScaleNotes("C0",1)[0];for(;e.chromaticId>=r.chromaticId+12;)e=new U(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new N(3,"Note is below rootNote.");let n=lo.get(r,e);if(n===void 0)throw new N(3,"Interval is undefined.");return n}getPreferredChromaticNote(e){U.validateChromaticId(e);let r=this.preferredChromaticIdNoteCache.get(e);if(r)return r;let n=U.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new U(h.diatonicClass,h.accidental,n+1):h.noteLetter==="B"&&h.accidental>0?new U(h.diatonicClass,h.accidental,n-1):new U(h.diatonicClass,h.accidental,n)).find(h=>U.getChromaticClass(e)===h.chromaticClass),r)return this.preferredChromaticIdNoteCache.set(e,r),r;let s=rC(e),a=s-2,c=s+2,l=this.getAccidentalType()===1?[0,-1,1,-2,2]:[0,1,-1,2,-2];for(let h=0;h<l.length;h++){let p=l[h];for(let m=Math.max(0,a);m<=c;m++)if(r=new U(m,p),e===r.chromaticId)return this.preferredChromaticIdNoteCache.set(e,r),r}return r=U.getChromaticNote(e),this.preferredChromaticIdNoteCache.set(e,r),r}},ie=class{constructor(t){this.type=t;d(this,"tonicList",[]);d(this,"scaleMap",new Map);let e=[],r=[],n=[];if(iC.forEach(s=>{try{let a=new ii(s,this.type);switch(a.getAccidentalType()){case 0:e.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;n.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),e.length===0)throw new N(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...n.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(t){let e=this.scaleMap.get(t);if(e)return e;throw new N(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},Ml=[new ie("Major"),new ie("Natural Minor"),new ie("Harmonic Minor"),"- Modes -",new ie("Ionian"),new ie("Dorian"),new ie("Phrygian"),new ie("Lydian"),new ie("Mixolydian"),new ie("Aeolian"),new ie("Locrian"),"- Pentatonic -",new ie("Major Pentatonic"),new ie("Minor Pentatonic"),"- Blues -",new ie("Major Hexatonic Blues"),new ie("Minor Hexatonic Blues"),new ie("Heptatonic Blues")];function oC(){return Ml}var El=new lt;Ml.forEach(i=>{i instanceof ie&&El.set(i.getType(),i)});function Dl(i){let t=El.get(i);if(t)return t;throw new N(3,`Invalid scaleType: ${i}`)}function po(i){if(y.isEnumValue(i,Ni))return i;throw new N(3,`Invalid scaleType: "${i}"`)}function Pr(i,t){let e,r;return t!==void 0?(e=i,r=po(t)):(e=i.split(" ")[0],r=po(i.substring(e.length+1))),Dl(r).getScale(e)}var sC=Pr("C","Major");function aC(){return sC}var Fr=(i,t)=>i.chromaticClass===t.chromaticClass,cC=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(i=>U.getNote(i+"0")),uC=new vr;function hC(i){return uC.getOrCreate(i.chromaticClass,()=>{let t=cC.find(e=>Fr(e,i));if(!t)throw new N(1,`Invalid chord root note: ${i.formatOmitOctave(1)}`);return t})}function lC(i,t){let e=i.formatOmitOctave(0);return Pr(e,"Major").getNoteByDegree(t)}function dC(i){return H.Arr.removeDuplicates(i,Fr)}var pC=[{name:"5",degrees:[1,5]},{name:"",degrees:[1,3,5]},{name:"m",degrees:[1,"b3",5]},{name:"dim",degrees:[1,"b3","b5"]},{name:"aug",degrees:[1,3,"#5"]},{name:"sus2",degrees:[1,2,5]},{name:"sus4",degrees:[1,4,5]},{name:"6",degrees:[1,3,5,6]},{name:"m6",degrees:[1,"b3",5,6]},{name:"m(maj7)",degrees:[1,"b3",5,7]},{name:"7",degrees:[1,3,5,"b7"]},{name:"7\u266D5",degrees:[1,3,"b5","b7"]},{name:"7\u266F5",degrees:[1,3,"#5","b7"]},{name:"7sus2",degrees:[1,2,5,"b7"]},{name:"7sus4",degrees:[1,4,5,"b7"]},{name:"dim7",degrees:[1,"b3","b5","bb7"]},{name:"maj7",degrees:[1,3,5,7]},{name:"maj7\u266D5",degrees:[1,3,"b5",7]},{name:"maj7\u266F5",degrees:[1,3,"#5",7]},{name:"m7",degrees:[1,"b3",5,"b7"]},{name:"m7\u266D5",degrees:[1,"b3","b5","b7"]},{name:"m7\u266F5",degrees:[1,"b3","#5","b7"]},{name:"9",degrees:[1,3,5,"b7",9]},{name:"m9",degrees:[1,"b3",5,"b7",9]},{name:"7\u266F9",degrees:[1,3,5,"b7","#9"]},{name:"7\u266D9",degrees:[1,3,5,"b7","b9"]},{name:"11",degrees:[1,3,5,"b7",9,11]},{name:"m11",degrees:[1,"b3",5,"b7",9,11]},{name:"13",degrees:[1,3,5,"b7",9,11,13]},{name:"m13",degrees:[1,"b3",5,"b7",9,11,13]}];function mC(i,t){return i.degrees.every(e=>e!==t)?!0:i.degrees.length>=4&&t===5||i.degrees.length>=6&&t===9||i.degrees.length>=7&&t===11}var on=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},gu=class i{constructor(t,e,r,n){this.chordInfo=t;this.rootNote=r;d(this,"name");d(this,"notes");d(this,"omitNotes");d(this,"slashBassNote");this.name=t.name;let o=e.slice();!o.some(a=>Fr(a,n))&&o.push(n),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<t.degrees.length;a++){let c=t.degrees[a],u=this.notes[a]=lC(this.rootNote,c),l=o.findIndex(h=>Fr(h,u));if(l>=0)this.omitNotes[a]=!1,o.splice(l,1);else if(mC(t,c))this.omitNotes[a]=!0;else throw new on("Missing chord note!");Fr(n,u)&&(n=u)}if(o.length>0)if(o.every(a=>Fr(a,n)))this.slashBassNote=n;else throw new on("Got some extra notes that are not bass note!");else this.slashBassNote=Fr(n,this.rootNote)?void 0:n;if(t.name==="5"&&this.slashBassNote)throw new on("Power chord no bass note allowed!")}static getChords(t){let e=[],r=U.sort(t),n=r[0],o=dC(r);for(let s=0;s<o.length;s++){let a=hC(o[s]);pC.forEach(c=>{try{let u=new i(c,o,a,n),l=e.findIndex(h=>h.replaceWith(u));l>=0?e[l]=u:e.push(u)}catch(u){if(!(u instanceof on))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!Fr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!Fr(t.notes[e],this.notes[e])||t.omitNotes[e]!==this.omitNotes[e])return!1;return!0}toString(){let t=1,e=this.rootNote.formatOmitOctave(t),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(t):"";return e+this.name+r}getDegreeNotationString(){let t=1,e=this.slashBassNote?this.slashBassNote.formatOmitOctave(t)+" - ":"",r=this.omitNotes.map((n,o)=>this.getDegreeStr(o)+"("+(n?"-":this.getNoteStr(o))+")").join(" - ");return e+r}getOmittedDegreesString(){let t=this.omitNotes.map((e,r)=>e?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(e=>e!==void 0);return t.length>0?"Omits "+t.join(", "):""}getDegreeStr(t){return U.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var yu={list:[{name:"Standard",strings:["E2","A2","D3","G3","B3","E4"]},{name:"B Standard",strings:["B1","E2","A2","D3","F#3","B3"]},{name:"C Standard",strings:["C2","F2","A#2","D#3","G3","C4"]},{name:"D Modal",strings:["D2","A2","D3","G3","A3","D4"]},{name:"D Standard",strings:["D2","G2","C3","F3","A3","D4"]},{name:"D# Standard",strings:["D#2","G#2","C#3","F#3","A#3","D#4"]},{name:"Double Drop D",strings:["D2","A2","D3","G3","B3","D4"]},{name:"Drop B",strings:["B1","F#2","B2","E3","G#3","C#4"]},{name:"Drop C",strings:["C2","G2","C3","F3","A3","D4"]},{name:"Drop D",strings:["D2","A2","D3","G3","B3","E4"]},{name:"Low C",strings:["C2","G2","D3","G3","A3","D4"]},{name:"New Standard",strings:["C2","G2","D3","A3","E4","G4"]},{name:"Open A",strings:["E2","A2","C#3","E3","A3","E4"]},{name:"Open A Minor",strings:["E2","A2","E3","A3","C4","E4"]},{name:"Open C",strings:["C2","G2","C3","G3","C4","E4"]},{name:"Open C Minor",strings:["C2","G2","C3","G3","C4","D#4"]},{name:"Open D",strings:["D2","A2","D3","F#3","A3","D4"]},{name:"Open D Minor",strings:["D2","A2","D3","F3","A3","D4"]},{name:"Open E",strings:["E2","B2","E3","G#3","B3","E4"]},{name:"Open E Minor",strings:["E2","B2","E3","G3","B3","E4"]},{name:"Open G",strings:["D2","G2","D3","G3","B3","D4"]},{name:"Open G Minor",strings:["D2","G2","D3","G3","A#3","D4"]}]};var mo=yu.list.map(i=>i.name),gC=mo[0];function bu(i){if(mo.indexOf(i)<0)throw new N(1,`Invalid tuning name: ${i}`);return i}var kl=new Al(100);function Xs(i){let t=kl.get(i);if(!t){let e=yu.list.find(r=>r.name===i);if(!e)throw new N(1,`Invalid tuningName: ${i}`);if(t=e.strings.slice().reverse().map(r=>U.getNote(r)),!y.isIntegerEq(t.length,6))throw new N(0,`Tuning has ${t.length} strings.`);kl.set(i,t)}return t}var Ll=12,yC=1188*7*5,ir=(k=>(k.Whole="1n",k.WholeTriplet="1t",k.WholeDot="1.",k.Whole2Dots="1..",k.Whole3Dots="1...",k.Whole4Dots="1....",k.Whole5Dots="1.....",k.Whole6Dots="1......",k.Half="2n",k.HalfTriplet="2t",k.HalfDot="2.",k.Half2Dots="2..",k.Half3Dots="2...",k.Half4Dots="2....",k.Half5Dots="2.....",k.Quarter="4n",k.QuarterTriplet="4t",k.QuarterDot="4.",k.Quarter2Dots="4..",k.Quarter3Dots="4...",k.Quarter4Dots="4....",k.Eighth="8n",k.EighthTriplet="8t",k.EighthDot="8.",k.Eighth2Dots="8..",k.Eighth3Dots="8...",k.Sixteenth="16n",k.SixteenthTriplet="16t",k.SixteenthDot="16.",k.Sixteenth2Dots="16..",k.ThirtySecond="32n",k.ThirtySecondTriplet="32t",k.ThirtySecondDot="32.",k.SixtyFourth="64n",k.SixtyFourthTriplet="64t",k))(ir||{});function nr(i){return y.isEnumValue(i,ir)}function Br(i){if(nr(i))return i;throw new N(1,`Invalid noteLength: ${i}`)}var pe=class pe{constructor(t){d(this,"noteLength");d(this,"noteSize");d(this,"ticks");d(this,"flagCount");d(this,"dotCount");d(this,"maxDotCount");d(this,"isTriplet");d(this,"hasStem");d(this,"isSolid");if(this.noteLength=Br(t),this.noteSize=parseInt(t),this.isTriplet=t.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(pe.ShortestNoteSize/this.noteSize)),this.dotCount=H.Str.charCount(t,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=yC*pe.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new N(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new N(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(t){return this.cache.getOrCreate(t,()=>new pe(t))}static create(t,e=0){let r=typeof t=="number"?t:this.get(t).noteSize;return this.get(r+(y.isIntegerGte(e,1)?".".repeat(e):"n"))}static cmp(t,e){let r=t instanceof pe?t.noteSize:typeof t=="number"?t:pe.get(t).noteSize,n=e instanceof pe?e.noteSize:typeof e=="number"?e:pe.get(e).noteSize;return H.Math.cmp(n,r)}static equals(t,e){let r=t instanceof pe?t.noteSize:typeof t=="number"?t:pe.get(t).noteSize,n=e instanceof pe?e.noteSize:typeof e=="number"?e:pe.get(e).noteSize;return r===n}};d(pe,"LongestNoteSize",Math.min(...H.Enum.getEnumValues(ir).map(t=>parseInt(t)))),d(pe,"ShortestNoteSize",Math.max(...H.Enum.getEnumValues(ir).map(t=>parseInt(t)))),d(pe,"cache",new lt);var Tt=pe;function Qs(i){return y.isObject(i)&&y.isIntegerBetween(i.parts,2,Ll)&&y.isIntegerBetween(i.inTimeOf,2,Ll)}function jl(i){if(Qs(i))return i;throw new N(2,`Invalid tupletRatio ${JSON.stringify(i)}`)}var Gr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},Oi=class Oi{constructor(t,e,r){d(this,"noteLength");d(this,"noteSize");d(this,"dotCount");d(this,"tupletRatio");d(this,"ticks");d(this,"flagCount");d(this,"hasStem");d(this,"isSolidNoteHead");this.noteLength=Br(t);let n=Tt.get(t);if(this.noteSize=n.noteSize,this.ticks=n.ticks,this.flagCount=n.flagCount,this.dotCount=e!=null?e:n.dotCount,this.hasStem=n.hasStem,this.isSolidNoteHead=n.isSolid,y.isObject(r)?this.tupletRatio=jl(r):n.isTriplet?this.tupletRatio=Gr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new N(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>n.maxDotCount)throw new N(2,`Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);for(let o=this.ticks/2,s=1;s<=this.dotCount;s++,o/=2)this.ticks+=o;this.tupletRatio&&(this.ticks*=this.tupletRatio.inTimeOf/this.tupletRatio.parts)}toString(){let t=Oi.NoteSymbolMap.get(this.noteSize),e=".".repeat(this.dotCount);return t?t+e:""+this.noteSize+(e.length>0?e:"n")}static get(t,e,r){return e!==void 0||r!==void 0?new Oi(t,e,r):this.cache.getOrCreate(t,()=>new Oi(t))}static cmp(t,e){return H.Math.cmp(t.ticks,e.ticks)}static equals(t,e){return t.ticks===e.ticks}};d(Oi,"NoteSymbolMap",new vr([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),d(Oi,"cache",new lt);var Qt=Oi;var fo=(u=>(u._2_4="2/4",u._3_4="3/4",u._4_4="4/4",u._3_8="3/8",u._5_8="5/8",u._6_8="6/8",u._7_8="7/8",u._9_8="9/8",u._12_8="12/8",u))(fo||{}),Ri=(n=>(n._2_3="2-3",n._3_2="3-2",n._2_2_3="2-2-3",n._3_2_2="3-2-2",n))(Ri||{}),ni=class{constructor(...t){d(this,"beatCount");d(this,"beatSize");d(this,"beatLength");d(this,"measureTicks");d(this,"beamGroupSizes",[]);let e;if(y.isEnumValue(t[0],fo)){let o=t[0].split("/");this.beatCount=+o[0],this.beatSize=+o[1],y.isEnumValue(t[1],Ri)&&(e=t[1])}else if(y.isIntegerGte(t[0],2)&&y.isIntegerGte(t[1],2))this.beatCount=t[0],this.beatSize=t[1],y.isEnumValue(t[2],Ri)&&(e=t[2]);else throw new N(5,`Invalid args: ${t}`);if(y.isIntegerGte(this.beatCount,1)){if(!y.isIntegerGte(this.beatSize,1))throw new N(5,`Invalid beatSize: ${this.beatSize}`)}else throw new N(5,`Invalid beatCount: ${this.beatCount}`);let{noteLength:r,ticks:n}=Tt.create(this.beatSize);if(this.beatLength=r,this.measureTicks=this.beatCount*n,this.is(2,4))this.beamGroupSizes=[[2],[2]];else if(this.is(3,4))this.beamGroupSizes=[[2],[2],[2]];else if(this.is(4,4))this.beamGroupSizes=[[2,2],[2,2]];else if(this.is(3,8))this.beamGroupSizes=[[3]];else if(this.is(5,8)){if(!y.isUndefined(e)&&e!=="2-3"&&e!=="3-2")throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2"?[[3],[2]]:[[2],[3]],e=void 0}else if(this.is(6,8))this.beamGroupSizes=[[3],[3]];else if(this.is(7,8)){if(!y.isUndefined(e)&&e!=="2-2-3"&&e!=="3-2-2")throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2-2"?[[3],[2],[2]]:[[2],[2],[3]],e=void 0}else this.is(9,8)?this.beamGroupSizes=[[3],[3],[3]]:this.is(12,8)&&(this.beamGroupSizes=[[3],[3],[3],[3]]);if(this.beamGroupSizes.length===0)throw new N(5,`Unimplemented time signature "${this.toString()}".`);if(e!==void 0)throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},xu;function Ks(){return xu||(xu=new ni(4,4)),xu}var Au;function Js(){return Au||(Au={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),Au}function ta(i){return Qt.get(i.options.beatLength,i.options.dotCount).toString()+"="+i.beatsPerMinute}function Cu(i,t){return{beatsPerMinute:i.beatsPerMinute*t,options:{beatLength:i.options.beatLength,dotCount:i.options.dotCount}}}Ti();function ea(i){return!isFinite(i)||i<=0?-1/0:20*Math.log10(i)}var go="15.1.22";var vu=(i,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:i});var wu=(i,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:i});var sn=(i,t)=>({startTime:t,type:"setValue",value:i});var yo=(i,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:i});var ra=(i,t,{startTime:e,target:r,timeConstant:n})=>r+(t-r)*Math.exp((e-i)/n);var Vr=i=>i.type==="exponentialRampToValue";var Mi=i=>i.type==="linearRampToValue";var or=i=>Vr(i)||Mi(i);var an=i=>i.type==="setValue";var qe=i=>i.type==="setValueCurve";var cn=(i,t,e,r)=>{let n=i[t];return n===void 0?r:or(n)||an(n)?n.value:qe(n)?n.values[n.values.length-1]:ra(e,cn(i,t-1,n.startTime,r),n)};var Su=(i,t,e,r,n)=>e===void 0?[r.insertTime,n]:or(e)?[e.endTime,e.value]:an(e)?[e.startTime,e.value]:qe(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,cn(i,t-1,e.startTime,n)];var bo=i=>i.type==="cancelAndHold";var xo=i=>i.type==="cancelScheduledValues";var qr=i=>bo(i)||xo(i)?i.cancelTime:Vr(i)||Mi(i)?i.endTime:i.startTime;var Iu=(i,t,e,{endTime:r,value:n})=>e===n?n:0<e&&0<n||e<0&&n<0?e*Xh(n/e,(i-t)/(r-t)):0;var Tu=(i,t,e,{endTime:r,value:n})=>e+(i-t)/(r-t)*(n-e);var Pl=(i,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?i[e]:(1-(t-e))*i[e]+(1-(r-t))*i[r]};var Fl=(i,{duration:t,startTime:e,values:r})=>{let n=(i-e)/t*(r.length-1);return Pl(r,n)};var Ao=i=>i.type==="setTarget";var Co=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=qr(t);if(bo(t)||xo(t)){let r=this._automationEvents.findIndex(o=>xo(t)&&qe(o)?o.startTime+o.duration>=e:qr(o)>=e),n=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),bo(t)){let o=this._automationEvents[this._automationEvents.length-1];if(n!==void 0&&or(n)){if(o!==void 0&&Ao(o))throw new Error("The internal list is malformed.");let s=o===void 0?n.insertTime:qe(o)?o.startTime+o.duration:qr(o),a=o===void 0?this._defaultValue:qe(o)?o.values[o.values.length-1]:o.value,c=Vr(n)?Iu(e,s,a,n):Tu(e,s,a,n),u=Vr(n)?vu(c,e,this._currenTime):wu(c,e,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Ao(o)&&this._automationEvents.push(sn(this.getValue(e),e)),o!==void 0&&qe(o)&&o.startTime+o.duration>e){let s=e-o.startTime,a=(o.values.length-1)/o.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,l=o.values.slice(0,c);if(u<1)for(let h=1;h<c;h+=1){let p=u*h%1;l[h]=o.values[h-1]*(1-p)+o.values[h]*p}this._automationEvents[this._automationEvents.length-1]=yo(l,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>qr(s)>e),n=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(n!==void 0&&qe(n)&&qr(n)+n.duration>e)return!1;let o=Vr(t)?vu(t.value,t.endTime,this._currenTime):Mi(t)?wu(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(o);else{if(qe(t)&&e+t.duration>qr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>qr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),n=r[0];Ao(n)&&r.unshift(sn(cn(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=r}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;let e=this._automationEvents.findIndex(s=>qr(s)>t),r=this._automationEvents[e],n=(e===-1?this._automationEvents.length:e)-1,o=this._automationEvents[n];if(o!==void 0&&Ao(o)&&(r===void 0||!or(r)||r.insertTime>t))return ra(t,cn(this._automationEvents,n-1,o.startTime,this._defaultValue),o);if(o!==void 0&&an(o)&&(r===void 0||!or(r)))return o.value;if(o!==void 0&&qe(o)&&(r===void 0||!or(r)||o.startTime+o.duration>t))return t<o.startTime+o.duration?Fl(t,o):o.values[o.values.length-1];if(o!==void 0&&or(o)&&(r===void 0||!or(r)))return o.value;if(r!==void 0&&Vr(r)){let[s,a]=Su(this._automationEvents,n,o,r,this._defaultValue);return Iu(t,s,a,r)}if(r!==void 0&&Mi(r)){let[s,a]=Su(this._automationEvents,n,o,r,this._defaultValue);return Tu(t,s,a,r)}return this._defaultValue}};var Nu=i=>({cancelTime:i,type:"cancelAndHold"});var Ou=i=>({cancelTime:i,type:"cancelScheduledValues"});var Ru=(i,t)=>({endTime:t,type:"exponentialRampToValue",value:i});var Mu=(i,t)=>({endTime:t,type:"linearRampToValue",value:i});var Eu=(i,t,e)=>({startTime:t,target:i,timeConstant:e,type:"setTarget"});var Bl=()=>new DOMException("","AbortError");var Gl=i=>(t,e,[r,n,o],s)=>{i(t[n],[e,r,o],a=>a[0]===e&&a[1]===r,s)};var Vl=i=>(t,e,r)=>{let n=[];for(let o=0;o<r.numberOfInputs;o+=1)n.push(new Set);i.set(t,{activeInputs:n,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var ql=i=>(t,e)=>{i.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var wr=new WeakSet,ia=new WeakMap,un=new WeakMap,na=new WeakMap,_o=new WeakMap,hn=new WeakMap,oa=new WeakMap,vo=new WeakMap,wo=new WeakMap,So=new WeakMap;var Wl={construct(){return Wl}},Ul=i=>{try{let t=new Proxy(i,Wl);new t}catch(t){return!1}return!0};var zl=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Du=(i,t)=>{let e=[],r=i.replace(/^[\s]+/,""),n=r.match(zl);for(;n!==null;){let o=n[1].slice(1,-1),s=n[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,t).toString());e.push(s),r=r.slice(n[0].length).replace(/^[\s]+/,""),n=r.match(zl)}return[e.join(";"),r]};var Yl=i=>{if(i!==void 0&&!Array.isArray(i))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Hl=i=>{if(!Ul(i))throw new TypeError("The given value for processorCtor should be a constructor.");if(i.prototype===null||typeof i.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},$l=(i,t,e,r,n,o,s,a,c,u,l,h,p)=>{let m=0;return(f,g,b={credentials:"omit"})=>{let x=l.get(f);if(x!==void 0&&x.has(g))return Promise.resolve();let _=u.get(f);if(_!==void 0){let S=_.get(g);if(S!==void 0)return S}let w=o(f),T=w.audioWorklet===void 0?n(g).then(([S,v])=>{let[A,C]=Du(S,v),E=`${A};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${C}
83
+ })})(window,'_AWGS')`;return e(E)}).then(()=>{let S=p._AWGS.pop();if(S===void 0)throw new SyntaxError;r(w.currentTime,w.sampleRate,()=>S(class{},void 0,(v,A)=>{if(v.trim()==="")throw t();let C=wo.get(w);if(C!==void 0){if(C.has(v))throw t();Hl(A),Yl(A.parameterDescriptors),C.set(v,A)}else Hl(A),Yl(A.parameterDescriptors),wo.set(w,new Map([[v,A]]))},w.sampleRate,void 0,void 0))}):Promise.all([n(g),Promise.resolve(i(h,h))]).then(([[S,v],A])=>{let C=m+1;m=C;let[E,q]=Du(S,v),D=`${E};((AudioWorkletProcessor,registerProcessor)=>{${q}
84
+ })(${A?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${A?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${A?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${C}',class extends AudioWorkletProcessor{process(){return !1}})`,j=new Blob([D],{type:"application/javascript; charset=utf-8"}),F=URL.createObjectURL(j);return w.audioWorklet.addModule(F,b).then(()=>{if(a(w))return w;let W=s(w);return W.audioWorklet.addModule(F,b).then(()=>W)}).then(W=>{if(c===null)throw new SyntaxError;try{new c(W,`__sac${C}`)}catch(Q){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(F))});return _===void 0?u.set(f,new Map([[g,T]])):_.set(g,T),T.then(()=>{let S=l.get(f);S===void 0?l.set(f,new Set([g])):S.add(g)}).finally(()=>{let S=u.get(f);S!==void 0&&S.delete(g)}),T}};var Kt=(i,t)=>{let e=i.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var oi=(i,t)=>{let e=Array.from(i).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");let[r]=e;return i.delete(r),r};var sa=(i,t,e,r)=>{let n=Kt(i,t),o=oi(n,s=>s[0]===e&&s[1]===r);return n.size===0&&i.delete(t),o};var Sr=i=>Kt(oa,i);var sr=i=>{if(wr.has(i))throw new Error("The AudioNode is already stored.");wr.add(i),Sr(i).forEach(t=>t(!0))};var aa=i=>"port"in i;var Ir=i=>{if(!wr.has(i))throw new Error("The AudioNode is not stored.");wr.delete(i),Sr(i).forEach(t=>t(!1))};var Io=(i,t)=>{!aa(i)&&t.every(e=>e.size===0)&&Ir(i)};var Zl=(i,t,e,r,n,o,s,a,c,u,l,h,p)=>{let m=new WeakMap;return(f,g,b,x,_)=>{let{activeInputs:w,passiveInputs:T}=o(g),{outputs:S}=o(f),v=a(f),A=C=>{let E=c(g),q=c(f);if(C){let M=sa(T,f,b,x);i(w,f,M,!1),!_&&!h(f)&&e(q,E,b,x),p(g)&&sr(g)}else{let M=r(w,f,b,x);t(T,x,M,!1),!_&&!h(f)&&n(q,E,b,x);let R=s(g);if(R===0)l(g)&&Io(g,w);else{let B=m.get(g);B!==void 0&&clearTimeout(B),m.set(g,setTimeout(()=>{l(g)&&Io(g,w)},R*1e3))}}};return u(S,[g,b,x],C=>C[0]===g&&C[1]===b&&C[2]===x,!0)?(v.add(A),l(f)?i(w,f,[b,x,A],!0):t(T,x,[f,b,A],!0),!0):!1}};var Xl=i=>(t,e,[r,n,o],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[n,e,o]])):i(a,[n,e,o],c=>c[0]===n&&c[1]===e,s)};var Ql=i=>(t,e)=>{let r=i(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(r).connect(t.destination);let n=()=>{e.removeEventListener("ended",n),e.disconnect(r),r.disconnect()};e.addEventListener("ended",n)};var Kl=i=>(t,e)=>{i(t).add(e)};var bC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Jl=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),l=O(O({},bC),c),h=r(u,l),p=o(u)?t():null;super(a,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){let c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){let c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}};var _t=(i,t)=>i.context===t;var td=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var ln=i=>{try{i.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var We=()=>new DOMException("","IndexSizeError");var dn=i=>{i.getChannelData=(t=>e=>{try{return t.call(i,e)}catch(r){throw r.code===12?We():r}})(i.getChannelData)};var xC={numberOfChannels:1},ed=(i,t,e,r,n,o,s,a)=>{let c=null;return class rd{constructor(l){if(n===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:p,sampleRate:m}=O(O({},xC),l);c===null&&(c=new n(1,1,44100));let f=r!==null&&t(o,o)?new r({length:h,numberOfChannels:p,sampleRate:m}):c.createBuffer(p,h,m);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),dn(f)):t(ln,()=>ln(f))||a(f),i.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===rd.prototype||i.has(l)}}};var Ht=-34028234663852886e22,Wt=-Ht;var be=i=>wr.has(i);var AC={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},id=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,l){let h=o(u),p=O(O({},AC),l),m=n(h,p),f=s(h),g=f?t():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=e(this,f,m.playbackRate,Wt,Ht)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(u){if(this._nativeAudioBufferSourceNode.buffer=u,u!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(u){this._nativeAudioBufferSourceNode.loop=u}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(u){this._nativeAudioBufferSourceNode.loopEnd=u}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(u){this._nativeAudioBufferSourceNode.loopStart=u}get onended(){return this._onended}set onended(u){let l=typeof u=="function"?a(this,u):null;this._nativeAudioBufferSourceNode.onended=l;let h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===l?u:h}get playbackRate(){return this._playbackRate}start(u=0,l=0,h){if(this._nativeAudioBufferSourceNode.start(u,l,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[u,l]:[u,l,h]),this.context.state!=="closed"){sr(this);let p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),be(this)&&Ir(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var nd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=e(u),p=_t(h,l);if(!p){let m={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=t(l,m),s!==null&&h.start(...s),a!==null&&h.stop(a)}return o.set(l,h),p?yield i(l,u.playbackRate,h.playbackRate):yield r(l,u.playbackRate,h.playbackRate),yield n(u,l,h),h});return{set start(u){s=u},set stop(u){a=u},render(u,l){let h=o.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var od=i=>"playbackRate"in i;var sd=i=>"frequency"in i&&"gain"in i;var ad=i=>"offset"in i;var cd=i=>!("frequency"in i)&&"gain"in i;var ud=i=>"detune"in i&&"frequency"in i&&!("gain"in i);var hd=i=>"pan"in i;var ne=i=>Kt(ia,i);var si=i=>Kt(na,i);var ca=(i,t)=>{let{activeInputs:e}=ne(i);e.forEach(n=>n.forEach(([o])=>{t.includes(i)||ca(o,[...t,i])}));let r=od(i)?[i.playbackRate]:aa(i)?Array.from(i.parameters.values()):sd(i)?[i.Q,i.detune,i.frequency,i.gain]:ad(i)?[i.offset]:cd(i)?[i.gain]:ud(i)?[i.detune,i.frequency]:hd(i)?[i.pan]:[];for(let n of r){let o=si(n);o!==void 0&&o.activeInputs.forEach(([s])=>ca(s,t))}be(i)&&Ir(i)};var ai=i=>{ca(i.destination,[])};var ua=i=>i===void 0||typeof i=="number"||typeof i=="string"&&(i==="balanced"||i==="interactive"||i==="playback");var ld=(i,t,e,r,n,o,s,a,c)=>class extends i{constructor(l={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(l)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?e():f}if(h===null)throw r();if(!ua(l.latencyHint))throw new TypeError(`The provided value '${l.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(l.sampleRate!==void 0&&h.sampleRate!==l.sampleRate)throw e();super(h,2);let{latencyHint:p}=l,{sampleRate:m}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/m:p==="interactive"||p===void 0?256/m:p==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(p*m/128)))*128/m,this._nativeAudioContext=h,c.name==="webkitAudioContext"?(this._nativeGainNode=h.createGain(),this._nativeOscillatorNode=h.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(h.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,h.state==="running"){this._state="suspended";let f=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",f)};h.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ai(this)}))}createMediaElementSource(l){return new n(this,{mediaElement:l})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(l){return new s(this,{mediaStream:l})}createMediaStreamTrackSource(l){return new a(this,{mediaStreamTrack:l})}resume(){return this._state==="suspended"?new Promise((l,h)=>{let p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?l():this.resume().then(l,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(l=>{throw l===void 0||l.code===15?t():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?t():l})}};var dd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,l){let h=o(u),p=s(h),m=n(h,l,p),f=p?t(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}};var pd=i=>{let t=new WeakMap,e=(r,n)=>K(null,null,function*(){let o=n.destination;return t.set(n,o),yield i(r,n,o),o});return{render(r,n){let o=t.get(n);return o!==void 0?Promise.resolve(o):e(r,n)}}};var md=(i,t,e,r,n,o,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let S=new Float32Array(1),v=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),A=s(u),C=!1,E=[0,0,-1,0,1,0],q=[0,0,0],M=()=>{if(C)return;C=!0;let j=r(u,256,9,0);j.onaudioprocess=({inputBuffer:F})=>{let W=[o(F,S,0),o(F,S,1),o(F,S,2),o(F,S,3),o(F,S,4),o(F,S,5)];W.some((k,it)=>k!==E[it])&&(l.setOrientation(...W),E=W);let Q=[o(F,S,6),o(F,S,7),o(F,S,8)];Q.some((k,it)=>k!==q[it])&&(l.setPosition(...Q),q=Q)},v.connect(j)},R=j=>F=>{F!==E[j]&&(E[j]=F,l.setOrientation(...E))},B=j=>F=>{F!==q[j]&&(q[j]=F,l.setPosition(...q))},D=(j,F,W)=>{let Q=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:F});Q.connect(v,0,j),Q.start(),Object.defineProperty(Q.offset,"defaultValue",{get(){return F}});let k=i({context:c},A,Q.offset,Wt,Ht);return a(k,"value",it=>()=>it.call(k),it=>pt=>{try{it.call(k,pt)}catch(At){if(At.code!==9)throw At}M(),A&&W(pt)}),k.cancelAndHoldAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.cancelAndHoldAtTime),k.cancelScheduledValues=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.cancelScheduledValues),k.exponentialRampToValueAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.exponentialRampToValueAtTime),k.linearRampToValueAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.linearRampToValueAtTime),k.setTargetAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.setTargetAtTime),k.setValueAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.setValueAtTime),k.setValueCurveAtTime=(it=>A?()=>{throw n()}:(...pt)=>{let At=it.apply(k,pt);return M(),At})(k.setValueCurveAtTime),k};return{forwardX:D(0,0,R(0)),forwardY:D(1,0,R(1)),forwardZ:D(2,-1,R(2)),positionX:D(6,0,B(0)),positionY:D(7,0,B(1)),positionZ:D(8,0,B(2)),upX:D(3,0,R(3)),upY:D(4,1,R(4)),upZ:D(5,0,R(5))}},{forwardX:p,forwardY:m,forwardZ:f,positionX:g,positionY:b,positionZ:x,upX:_,upY:w,upZ:T}=l.forwardX===void 0?h():l;return{get forwardX(){return p},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return b},get positionZ(){return x},get upX(){return _},get upY(){return w},get upZ(){return T}}};var Ei=i=>"context"in i;var ci=i=>Ei(i[0]);var ar=(i,t,e,r)=>{for(let n of i)if(e(n)){if(r)return!1;throw Error("The set contains at least one similar element.")}return i.add(t),!0};var ku=(i,t,[e,r],n)=>{ar(i,[t,e,r],o=>o[0]===t&&o[1]===e,n)};var Lu=(i,[t,e,r],n)=>{let o=i.get(t);o===void 0?i.set(t,new Set([[e,r]])):ar(o,[e,r],s=>s[0]===e,n)};var Ue=i=>"inputs"in i;var pn=(i,t,e,r)=>{if(Ue(t)){let n=t.inputs[r];return i.connect(n,e,0),[n,e,0]}return i.connect(t,e,r),[t,e,r]};var ju=(i,t,e)=>{for(let r of i)if(r[0]===t&&r[1]===e)return i.delete(r),r;return null};var fd=(i,t,e)=>oi(i,r=>r[0]===t&&r[1]===e);var Pu=(i,t)=>{if(!Sr(i).delete(t))throw new Error("Missing the expected event listener.")};var Fu=(i,t,e)=>{let r=Kt(i,t),n=oi(r,o=>o[0]===e);return r.size===0&&i.delete(t),n};var mn=(i,t,e,r)=>{Ue(t)?i.disconnect(t.inputs[r],e,0):i.disconnect(t,e,r)};var Ot=i=>Kt(un,i);var Di=i=>Kt(_o,i);var Wr=i=>vo.has(i);var fn=i=>!wr.has(i);var Bu=(i,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=i.createScriptProcessor(256,1,1),n=i.createGain(),o=i.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=i.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(i.destination),a.connect(n),a.disconnect(n),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,l=>l===1)?e(!0):e(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(i.destination)},a.start()}});var ha=(i,t)=>{let e=new Map;for(let r of i)for(let n of r){let o=e.get(n);e.set(n,o===void 0?1:o+1)}e.forEach((r,n)=>t(n,r))};var ki=i=>"context"in i;var gd=i=>{let t=new Map;i.connect=(e=>(r,n=0,o=0)=>{let s=ki(r)?e(r,n,o):e(r,n),a=t.get(r);return a===void 0?t.set(r,[{input:o,output:n}]):a.every(c=>c.input!==o||c.output!==n)&&a.push({input:o,output:n}),s})(i.connect.bind(i)),i.disconnect=(e=>(r,n,o)=>{if(e.apply(i),r===void 0)t.clear();else if(typeof r=="number")for(let[s,a]of t){let c=a.filter(u=>u.output!==r);c.length===0?t.delete(s):t.set(s,c)}else if(t.has(r))if(n===void 0)t.delete(r);else{let s=t.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==n&&(c.input!==o||o===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{ki(s)?i.connect(s,c.output,c.input):i.connect(s,c.output)})})(i.disconnect)};var CC=(i,t,e,r)=>{let{activeInputs:n,passiveInputs:o}=si(t),{outputs:s}=ne(i),a=Sr(i),c=u=>{let l=Ot(i),h=Di(t);if(u){let p=Fu(o,i,e);ku(n,i,p,!1),!r&&!Wr(i)&&l.connect(h,e)}else{let p=fd(n,i,e);Lu(o,p,!1),!r&&!Wr(i)&&l.disconnect(h,e)}};return ar(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),be(i)?ku(n,i,[e,c],!0):Lu(o,[i,e,c],!0),!0):!1},_C=(i,t,e,r)=>{let{activeInputs:n,passiveInputs:o}=ne(t),s=ju(n[r],i,e);return s===null?[sa(o,i,e,r)[2],!1]:[s[2],!0]},vC=(i,t,e)=>{let{activeInputs:r,passiveInputs:n}=si(t),o=ju(r,i,e);return o===null?[Fu(n,i,e)[1],!1]:[o[2],!0]},Gu=(i,t,e,r,n)=>{let[o,s]=_C(i,e,r,n);if(o!==null&&(Pu(i,o),s&&!t&&!Wr(i)&&mn(Ot(i),Ot(e),r,n)),be(e)){let{activeInputs:a}=ne(e);Io(e,a)}},Vu=(i,t,e,r)=>{let[n,o]=vC(i,e,r);n!==null&&(Pu(i,n),o&&!t&&!Wr(i)&&Ot(i).disconnect(Di(e),r))},wC=(i,t)=>{let e=ne(i),r=[];for(let n of e.outputs)ci(n)?Gu(i,t,...n):Vu(i,t,...n),r.push(n[0]);return e.outputs.clear(),r},SC=(i,t,e)=>{let r=ne(i),n=[];for(let o of r.outputs)o[1]===e&&(ci(o)?Gu(i,t,...o):Vu(i,t,...o),n.push(o[0]),r.outputs.delete(o));return n},IC=(i,t,e,r,n)=>{let o=ne(i);return Array.from(o.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(n===void 0||s[2]===n)).map(s=>(ci(s)?Gu(i,t,...s):Vu(i,t,...s),o.outputs.delete(s),s[0]))},yd=(i,t,e,r,n,o,s,a,c,u,l,h,p,m,f,g)=>class extends u{constructor(x,_,w,T){super(w),this._context=x,this._nativeAudioNode=w;let S=l(x);h(S)&&e(Bu,()=>Bu(S,g))!==!0&&gd(w),un.set(this,w),oa.set(this,new Set),x.state!=="closed"&&_&&sr(this),i(this,T,w)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(x){this._nativeAudioNode.channelCount=x}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(x){this._nativeAudioNode.channelCountMode=x}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(x){this._nativeAudioNode.channelInterpretation=x}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(x,_=0,w=0){if(_<0||_>=this._nativeAudioNode.numberOfOutputs)throw n();let T=l(this._context),S=f(T);if(p(x)||m(x))throw o();if(Ei(x)){let C=Ot(x);try{let q=pn(this._nativeAudioNode,C,_,w),M=fn(this);(S||M)&&this._nativeAudioNode.disconnect(...q),this.context.state!=="closed"&&!M&&fn(x)&&sr(x)}catch(q){throw q.code===12?o():q}if(t(this,x,_,w,S)){let q=c([this],x);ha(q,r(S))}return x}let v=Di(x);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,_),(S||fn(this))&&this._nativeAudioNode.disconnect(v,_)}catch(C){throw C.code===12?o():C}if(CC(this,x,_,S)){let C=c([this],x);ha(C,r(S))}}disconnect(x,_,w){let T,S=l(this._context),v=f(S);if(x===void 0)T=wC(this,v);else if(typeof x=="number"){if(x<0||x>=this.numberOfOutputs)throw n();T=SC(this,v,x)}else{if(_!==void 0&&(_<0||_>=this.numberOfOutputs)||Ei(x)&&w!==void 0&&(w<0||w>=x.numberOfInputs))throw n();if(T=IC(this,v,x,_,w),T.length===0)throw o()}for(let A of T){let C=c([this],A);ha(C,a)}}};var bd=(i,t,e,r,n,o,s,a,c,u,l,h,p)=>(m,f,g,b=null,x=null)=>{let _=g.value,w=new Co(_),T=f?r(w):null,S={get defaultValue(){return _},get maxValue(){return b===null?g.maxValue:b},get minValue(){return x===null?g.minValue:x},get value(){return g.value},set value(v){g.value=v,S.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")T===null&&w.flush(m.context.currentTime),w.add(n(v)),g.cancelAndHoldAtTime(v);else{let A=Array.from(w).pop();T===null&&w.flush(m.context.currentTime),w.add(n(v));let C=Array.from(w).pop();g.cancelScheduledValues(v),A!==C&&C!==void 0&&(C.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(C.value,C.endTime):C.type==="linearRampToValue"?g.linearRampToValueAtTime(C.value,C.endTime):C.type==="setValue"?g.setValueAtTime(C.value,C.startTime):C.type==="setValueCurve"&&g.setValueCurveAtTime(C.values,C.startTime,C.duration))}return S},cancelScheduledValues(v){return T===null&&w.flush(m.context.currentTime),w.add(o(v)),g.cancelScheduledValues(v),S},exponentialRampToValueAtTime(v,A){if(v===0)throw new RangeError;if(!Number.isFinite(A)||A<0)throw new RangeError;let C=m.context.currentTime;return T===null&&w.flush(C),Array.from(w).length===0&&(w.add(u(_,C)),g.setValueAtTime(_,C)),w.add(s(v,A)),g.exponentialRampToValueAtTime(v,A),S},linearRampToValueAtTime(v,A){let C=m.context.currentTime;return T===null&&w.flush(C),Array.from(w).length===0&&(w.add(u(_,C)),g.setValueAtTime(_,C)),w.add(a(v,A)),g.linearRampToValueAtTime(v,A),S},setTargetAtTime(v,A,C){return T===null&&w.flush(m.context.currentTime),w.add(c(v,A,C)),g.setTargetAtTime(v,A,C),S},setValueAtTime(v,A){return T===null&&w.flush(m.context.currentTime),w.add(u(v,A)),g.setValueAtTime(v,A),S},setValueCurveAtTime(v,A,C){let E=v instanceof Float32Array?v:new Float32Array(v);if(h!==null&&h.name==="webkitAudioContext"){let q=A+C,M=m.context.sampleRate,R=Math.ceil(A*M),B=Math.floor(q*M),D=B-R,j=new Float32Array(D);for(let W=0;W<D;W+=1){let Q=(E.length-1)/C*((R+W)/M-A),k=Math.floor(Q),it=Math.ceil(Q);j[W]=k===it?E[k]:(1-(Q-k))*E[k]+(1-(it-Q))*E[it]}T===null&&w.flush(m.context.currentTime),w.add(l(j,A,C)),g.setValueCurveAtTime(j,A,C);let F=B/M;F<q&&p(S,j[j.length-1],F),p(S,E[E.length-1],q)}else T===null&&w.flush(m.context.currentTime),w.add(l(E,A,C)),g.setValueCurveAtTime(E,A,C);return S}};return e.set(S,g),t.set(S,m),i(S,T),S};var xd=i=>({replay(t){for(let e of i)if(e.type==="exponentialRampToValue"){let{endTime:r,value:n}=e;t.exponentialRampToValueAtTime(n,r)}else if(e.type==="linearRampToValue"){let{endTime:r,value:n}=e;t.linearRampToValueAtTime(n,r)}else if(e.type==="setTarget"){let{startTime:r,target:n,timeConstant:o}=e;t.setTargetAtTime(n,r,o)}else if(e.type==="setValue"){let{startTime:r,value:n}=e;t.setValueAtTime(n,r)}else if(e.type==="setValueCurve"){let{duration:r,startTime:n,values:o}=e;t.setValueCurveAtTime(o,n,r)}else throw new Error("Can't apply an unknown automation.")}});var gn=class{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((r,n)=>t.call(e,r,n,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}};var TC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},Ad=(i,t,e,r,n,o,s,a,c,u,l,h,p,m)=>class extends t{constructor(g,b,x){var _;let w=a(g),T=c(w),S=l(O(O({},TC),x));p(S);let v=wo.get(w),A=v==null?void 0:v.get(b),C=T||w.state!=="closed"?w:(_=s(w))!==null&&_!==void 0?_:w,E=n(C,T?null:g.baseLatency,u,b,A,S),q=T?r(b,S,A):null;super(g,!0,E,q);let M=[];E.parameters.forEach((B,D)=>{let j=e(this,T,B);M.push([D,j])}),this._nativeAudioWorkletNode=E,this._onprocessorerror=null,this._parameters=new gn(M),T&&i(w,this);let{activeInputs:R}=o(this);h(E,R)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let b=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=b;let x=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=x!==null&&x===b?g:x}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function yn(i,t,e,r,n){if(typeof i.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),i.copyFromChannel(t[e],r,n);else{let o=i.getChannelData(r);if(t[e].byteLength===0)t[e]=o.slice(n,n+128);else{let s=new Float32Array(o.buffer,n*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var la=(i,t,e,r,n)=>{typeof i.copyToChannel=="function"?t[e].byteLength!==0&&i.copyToChannel(t[e],r,n):t[e].byteLength!==0&&i.getChannelData(r).set(t[e],n)};var bn=(i,t)=>{let e=[];for(let r=0;r<i;r+=1){let n=[],o=typeof t=="number"?t:t[r];for(let s=0;s<o;s+=1)n.push(new Float32Array(128));e.push(n)}return e};var Cd=(i,t)=>{let e=Kt(So,i),r=Ot(t);return Kt(e,r)};var NC=(i,t,e,r,n,o,s)=>K(null,null,function*(){let a=t===null?Math.ceil(i.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=n.reduce((b,x)=>b+x,0),l=u===0?null:e.createBuffer(u,a,e.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let h=ne(i),p=yield Cd(e,i),m=bn(r.numberOfInputs,r.channelCount),f=bn(r.numberOfOutputs,n),g=Array.from(i.parameters.keys()).reduce((b,x)=>X(O({},b),{[x]:new Float32Array(128)}),{});for(let b=0;b<a;b+=128){if(r.numberOfInputs>0&&t!==null)for(let x=0;x<r.numberOfInputs;x+=1)for(let _=0;_<r.channelCount;_+=1)yn(t,m[x],_,_,b);o.parameterDescriptors!==void 0&&t!==null&&o.parameterDescriptors.forEach(({name:x},_)=>{yn(t,g,x,c+_,b)});for(let x=0;x<r.numberOfInputs;x+=1)for(let _=0;_<n[x];_+=1)f[x][_].byteLength===0&&(f[x][_]=new Float32Array(128));try{let x=m.map((w,T)=>h.activeInputs[T].size===0?[]:w),_=s(b/e.sampleRate,e.sampleRate,()=>p.process(x,f,g));if(l!==null)for(let w=0,T=0;w<r.numberOfOutputs;w+=1){for(let S=0;S<n[w];S+=1)la(l,f[w],S,T+S,b);T+=n[w]}if(!_)break}catch(x){i.dispatchEvent(new ErrorEvent("processorerror",{colno:x.colno,filename:x.filename,lineno:x.lineno,message:x.message}));break}}return l}),_d=(i,t,e,r,n,o,s,a,c,u,l,h,p,m,f,g)=>(b,x,_)=>{let w=new WeakMap,T=null,S=(v,A)=>K(null,null,function*(){let C=l(v),E=null,q=_t(C,A),M=Array.isArray(x.outputChannelCount)?x.outputChannelCount:Array.from(x.outputChannelCount);if(h===null){let R=M.reduce((F,W)=>F+W,0),B=n(A,{channelCount:Math.max(1,R),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,R)}),D=[];for(let F=0;F<v.numberOfOutputs;F+=1)D.push(r(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:M[F]}));let j=s(A,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1});j.connect=t.bind(null,D),j.disconnect=c.bind(null,D),E=[B,D,j]}else q||(C=new h(A,b));if(w.set(A,E===null?C:E[2]),E!==null){if(T===null){if(_===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let W=v.channelCount*v.numberOfInputs,Q=_.parameterDescriptors===void 0?0:_.parameterDescriptors.length,k=W+Q;T=NC(v,k===0?null:yield K(null,null,function*(){let pt=new p(k,Math.ceil(v.context.length/128)*128,A.sampleRate),At=[],Yt=[];for(let Nt=0;Nt<x.numberOfInputs;Nt+=1)At.push(s(pt,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1})),Yt.push(n(pt,{channelCount:x.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:x.channelCount}));let Ee=yield Promise.all(Array.from(v.parameters.values()).map(Nt=>K(null,null,function*(){let ct=o(pt,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:Nt.value});return yield m(pt,Nt,ct.offset),ct}))),De=r(pt,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,W+Q)});for(let Nt=0;Nt<x.numberOfInputs;Nt+=1){At[Nt].connect(Yt[Nt]);for(let ct=0;ct<x.channelCount;ct+=1)Yt[Nt].connect(De,ct,Nt*x.channelCount+ct)}for(let[Nt,ct]of Ee.entries())ct.connect(De,0,W+Nt),ct.start(0);return De.connect(pt.destination),yield Promise.all(At.map(Nt=>f(v,pt,Nt))),g(pt)}),A,x,M,_,u)}let R=yield T,B=e(A,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[D,j,F]=E;R!==null&&(B.buffer=R,B.start(0)),B.connect(D);for(let W=0,Q=0;W<v.numberOfOutputs;W+=1){let k=j[W];for(let it=0;it<M[W];it+=1)D.connect(k,Q+it,it);Q+=M[W]}return F}if(q)for(let[R,B]of v.parameters.entries())yield i(A,B,C.parameters.get(R));else for(let[R,B]of v.parameters.entries())yield m(A,B,C.parameters.get(R));return yield f(v,A,C),C});return{render(v,A){a(A,v);let C=w.get(A);return C!==void 0?Promise.resolve(C):S(v,A)}}};var vd=(i,t,e,r,n,o,s,a,c,u,l,h,p,m,f,g,b,x,_,w)=>class extends f{constructor(S,v){super(S,v),this._nativeContext=S,this._audioWorklet=i===void 0?void 0:{addModule:(A,C)=>i(this,A,C)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new n(this)}createBuffer(S,v,A){return new e({length:v,numberOfChannels:S,sampleRate:A})}createBufferSource(){return new r(this)}createChannelMerger(S=6){return new o(this,{numberOfInputs:S})}createChannelSplitter(S=6){return new s(this,{numberOfOutputs:S})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(S=1){return new l(this,{maxDelayTime:S})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(S,v){return new m(this,{feedback:v,feedforward:S})}createOscillator(){return new g(this)}createPanner(){return new b(this)}createPeriodicWave(S,v,A={disableNormalization:!1}){return new x(this,X(O({},A),{imag:v,real:S}))}createStereoPanner(){return new _(this)}createWaveShaper(){return new w(this)}decodeAudioData(S,v,A){return u(this._nativeContext,S).then(C=>(typeof v=="function"&&v(C),C),C=>{throw typeof A=="function"&&A(C),C})}};var OC={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},wd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,l){let h=o(u),p=O(O({},OC),l),m=n(h,p),f=s(h),g=f?e():null;super(u,!1,m,g),this._Q=t(this,f,m.Q,Wt,Ht),this._detune=t(this,f,m.detune,1200*Math.log2(Wt),-1200*Math.log2(Wt)),this._frequency=t(this,f,m.frequency,u.sampleRate/2,0),this._gain=t(this,f,m.gain,40*Math.log10(Wt),Ht),this._nativeBiquadFilterNode=m,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(u){this._nativeBiquadFilterNode.type=u}getFrequencyResponse(u,l,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(u,l,h)}catch(p){throw p.code===11?r():p}if(u.length!==l.length||l.length!==h.length)throw r()}};var Sd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=_t(u,c);if(!l){let h={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,h)}return o.set(c,u),l?(yield i(c,a.Q,u.Q),yield i(c,a.detune,u.detune),yield i(c,a.frequency,u.frequency),yield i(c,a.gain,u.gain)):(yield r(c,a.Q,u.Q),yield r(c,a.detune,u.detune),yield r(c,a.frequency,u.frequency),yield r(c,a.gain,u.gain)),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Id=(i,t)=>(e,r)=>{let n=t.get(e);if(n!==void 0)return n;let o=i.get(e);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(i.set(e,s),s.catch(()=>!1).then(a=>(i.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var RC={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Td=(i,t,e,r,n)=>class extends i{constructor(s,a){let c=r(s),u=O(O({},RC),a),l=e(c,u),h=n(c)?t():null;super(s,!1,l,h)}};var Nd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var MC={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Od=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),l=o(O(O({},MC),c)),h=e(u,l),p=n(u)?t():null;super(a,!1,h,p)}};var Rd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var Md=i=>(t,e,r)=>i(e,t,r);var Ed=i=>(t,e,r=0,n=0)=>{let o=t[r];if(o===void 0)throw i();return ki(e)?o.connect(e,0,n):o.connect(e,0)};var Dd=i=>(t,e)=>{let r=i(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),n=t.createBuffer(1,2,44100);return r.buffer=n,r.loop=!0,r.connect(e),r.start(),()=>{r.stop(),r.disconnect(e)}};var EC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},kd=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let l=n(c),h=O(O({},EC),u),p=r(l,h),m=o(l),f=m?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,m,p.offset,Wt,Ht),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeConstantSourceNode.onended=u;let l=this._nativeConstantSourceNode.onended;this._onended=l!==null&&l===u?c:l}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){sr(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),be(this)&&Ir(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var Ld=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=e(u),p=_t(h,l);if(!p){let m={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,m),s!==null&&h.start(s),a!==null&&h.stop(a)}return o.set(l,h),p?yield i(l,u.offset,h.offset):yield r(l,u.offset,h.offset),yield n(u,l,h),h});return{set start(u){s=u},set stop(u){a=u},render(u,l){let h=o.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var jd=i=>t=>(i[0]=t,i[0]);var DC={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Pd=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),l=O(O({},DC),c),h=e(u,l),m=n(u)?t():null;super(a,!1,h,m),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&o(this,l.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){let c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var Fd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=i(s,u)}return r.set(s,a),Ue(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var Bd=(i,t)=>(e,r,n)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,n)}catch(o){throw o.name==="SyntaxError"?i():o}};var Gd=()=>new DOMException("","DataCloneError");var qu=i=>{let{port1:t,port2:e}=new MessageChannel;return new Promise(r=>{let n=()=>{e.onmessage=null,t.close(),e.close(),r()};e.onmessage=()=>n();try{t.postMessage(i,[i])}catch(o){}finally{n()}})};var Vd=(i,t,e,r,n,o,s,a,c,u,l)=>(h,p)=>{let m=s(h)?h:o(h);if(n.has(p)){let f=e();return Promise.reject(f)}try{n.add(p)}catch(f){}return t(c,()=>c(m))?m.decodeAudioData(p).then(f=>(qu(p).catch(()=>{}),t(a,()=>a(f))||l(f),i.add(f),f)):new Promise((f,g)=>{let b=()=>K(null,null,function*(){try{yield qu(p)}catch(_){}}),x=_=>{g(_),b()};try{m.decodeAudioData(p,_=>{typeof _.copyFromChannel!="function"&&(u(_),dn(_)),i.add(_),b().then(()=>f(_))},_=>{x(_===null?r():_)})}catch(_){x(_)}})};var qd=(i,t,e,r,n,o,s,a)=>(c,u)=>{let l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=o(c.context),p=a(h);if(l===u){if(t.delete(c),!p&&s(c)){let m=r(c),{outputs:f}=e(c);for(let g of f)if(ci(g)){let b=r(g[0]);i(m,b,g[1],g[2])}else{let b=n(g[0]);m.connect(b,g[1])}}}else t.set(c,l-u)};var kC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Wd=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let l=n(c),h=O(O({},kC),u),p=r(l,h),m=o(l),f=m?e(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,m,p.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var Ud=(i,t,e,r,n)=>o=>{let s=new WeakMap,a=(c,u)=>K(null,null,function*(){let l=e(c),h=_t(l,u);if(!h){let p={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=t(u,p)}return s.set(u,l),h?yield i(u,c.delayTime,l.delayTime):yield r(u,c.delayTime,l.delayTime),yield n(c,u,l),l});return{render(c,u){let l=s.get(u);return l!==void 0?Promise.resolve(l):a(c,u)}}};var zd=i=>(t,e,r,n)=>i(t[n],o=>o[0]===e&&o[1]===r);var Yd=i=>(t,e)=>{i(t).delete(e)};var Hd=i=>"delayTime"in i;var $d=(i,t,e)=>function r(n,o){let s=Ei(o)?o:e(i,o);if(Hd(s))return[];if(n[0]===s)return[n];if(n.includes(s))return[];let{outputs:a}=t(s);return Array.from(a).map(c=>r([...n,s],c[0])).reduce((c,u)=>c.concat(u),[])};var da=(i,t,e)=>{let r=t[e];if(r===void 0)throw i();return r},Zd=i=>(t,e=void 0,r=void 0,n=0)=>e===void 0?t.forEach(o=>o.disconnect()):typeof e=="number"?da(i,t,e).disconnect():ki(e)?r===void 0?t.forEach(o=>o.disconnect(e)):n===void 0?da(i,t,r).disconnect(e,0):da(i,t,r).disconnect(e,0,n):r===void 0?t.forEach(o=>o.disconnect(e)):da(i,t,r).disconnect(e,0);var LC={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Xd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,l){let h=o(u),p=O(O({},LC),l),m=r(h,p),f=s(h),g=f?e():null;super(u,!1,m,g),this._attack=t(this,f,m.attack),this._knee=t(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=t(this,f,m.ratio),this._release=t(this,f,m.release),this._threshold=t(this,f,m.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){let l=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=l,n()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(u){let l=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=u,u==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=l,n()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value=="number"?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}};var Qd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=_t(u,c);if(!l){let h={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,h)}return o.set(c,u),l?(yield i(c,a.attack,u.attack),yield i(c,a.knee,u.knee),yield i(c,a.ratio,u.ratio),yield i(c,a.release,u.release),yield i(c,a.threshold,u.threshold)):(yield r(c,a.attack,u.attack),yield r(c,a.knee,u.knee),yield r(c,a.ratio,u.ratio),yield r(c,a.release,u.release),yield r(c,a.threshold,u.threshold)),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Kd=()=>new DOMException("","EncodingError");var Jd=i=>t=>new Promise((e,r)=>{if(i===null){r(new SyntaxError);return}let n=i.document.head;if(n===null)r(new SyntaxError);else{let o=i.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=i.onerror,u=()=>{i.onerror=c,URL.revokeObjectURL(a)};i.onerror=(l,h,p,m,f)=>{if(h===a||h===i.location.href&&p===1&&m===1)return u(),r(f),!1;if(c!==null)return c(l,h,p,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),e()},o.src=a,o.type="module",n.appendChild(o)}});var tp=i=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,n){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=i(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(e,o,n)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,n){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,o===void 0?null:o,n)}};var ep=i=>(t,e,r)=>{Object.defineProperties(i,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{i!==null&&(delete i.currentFrame,delete i.currentTime)}};var rp=i=>t=>K(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw i()});var jC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},ip=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),l=O(O({},jC),c),h=r(u,l),p=o(u),m=p?e():null;super(a,!1,h,m),this._gain=t(this,p,h.gain,Wt,Ht)}get gain(){return this._gain}};var np=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=_t(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,h)}return o.set(c,u),l?yield i(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var op=(i,t)=>e=>t(i,e);var sp=i=>t=>{let e=i(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var ap=i=>t=>{var e;return(e=i.get(t))!==null&&e!==void 0?e:0};var cp=i=>t=>{let e=i(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var up=i=>t=>i.get(t);var Pt=()=>new DOMException("","InvalidStateError");var hp=i=>t=>{let e=i.get(t);if(e===void 0)throw Pt();return e};var lp=(i,t)=>e=>{let r=i.get(e);if(r!==void 0)return r;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new t(1,1,44100),i.set(e,r),r};var dp=i=>t=>{let e=i.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var xn=()=>new DOMException("","InvalidAccessError");var pp=i=>{i.getFrequencyResponse=(t=>(e,r,n)=>{if(e.length!==r.length||r.length!==n.length)throw xn();return t.call(i,e,r,n)})(i.getFrequencyResponse)};var PC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},mp=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),l=n(u),h=O(O({},PC),c),p=t(u,l?null:a.baseLatency,h),m=l?e(h.feedback,h.feedforward):null;super(a,!1,p,m),pp(p),this._nativeIIRFilterNode=p,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var pa=(i,t,e,r,n,o,s,a,c,u,l)=>{let h=u.length,p=a;for(let m=0;m<h;m+=1){let f=e[0]*u[m];for(let g=1;g<n;g+=1){let b=p-g&c-1;f+=e[g]*o[b],f-=i[g]*s[b]}for(let g=n;g<r;g+=1)f+=e[g]*o[p-g&c-1];for(let g=n;g<t;g+=1)f-=i[g]*s[p-g&c-1];o[p]=u[m],s[p]=f,p=p+1&c-1,l[m]=f}return p};var FC=(i,t,e,r)=>{let n=e instanceof Float64Array?e:new Float64Array(e),o=r instanceof Float64Array?r:new Float64Array(r),s=n.length,a=o.length,c=Math.min(s,a);if(n[0]!==1){for(let f=0;f<s;f+=1)o[f]/=n[0];for(let f=1;f<a;f+=1)n[f]/=n[0]}let u=32,l=new Float32Array(u),h=new Float32Array(u),p=t.createBuffer(i.numberOfChannels,i.length,i.sampleRate),m=i.numberOfChannels;for(let f=0;f<m;f+=1){let g=i.getChannelData(f),b=p.getChannelData(f);l.fill(0),h.fill(0),pa(n,s,o,a,c,l,h,0,u,g,b)}return p},fp=(i,t,e,r,n)=>(o,s)=>{let a=new WeakMap,c=null,u=(l,h)=>K(null,null,function*(){let p=null,m=t(l),f=_t(m,h);if(h.createIIRFilter===void 0?p=i(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(m=h.createIIRFilter(s,o)),a.set(h,p===null?m:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let b=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=K(null,null,function*(){yield r(l,b,b.destination);let x=yield n(b);return FC(x,h,o,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(l,h,m),m});return{render(l,h){let p=a.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var gp=(i,t,e,r,n,o)=>s=>(a,c)=>{let u=i.get(a);if(u===void 0){if(!s&&o(a)){let l=r(a),{outputs:h}=e(a);for(let p of h)if(ci(p)){let m=r(p[0]);t(l,m,p[1],p[2])}else{let m=n(p[0]);l.disconnect(m,p[1])}}i.set(a,c)}else i.set(a,u+c)};var yp=(i,t)=>e=>{let r=i.get(e);return t(r)||t(e)};var bp=(i,t)=>e=>i.has(e)||t(e);var xp=(i,t)=>e=>i.has(e)||t(e);var Ap=(i,t)=>e=>{let r=i.get(e);return t(r)||t(e)};var Cp=i=>t=>i!==null&&t instanceof i;var _p=i=>t=>i!==null&&typeof i.AudioNode=="function"&&t instanceof i.AudioNode;var vp=i=>t=>i!==null&&typeof i.AudioParam=="function"&&t instanceof i.AudioParam;var wp=(i,t)=>e=>i(e)||t(e);var Sp=i=>t=>i!==null&&t instanceof i;var Ip=i=>i!==null&&i.isSecureContext;var Tp=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var BC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Np=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o);if(r(a))throw new TypeError;let c=O(O({},BC),s),u=t(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Op=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var Rp=(i,t,e)=>class extends i{constructor(n,o){let s=e(n),a=t(s,o);super(n,!0,a,null)}};var Mp=(i,t,e,r,n)=>class extends r{constructor(s={}){if(n===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new n(s)}catch(l){throw l.code===12&&l.message==="sampleRate is not in range"?t():l}if(a===null)throw e();if(!ua(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw t();super(a,2);let{latencyHint:c}=s,{sampleRate:u}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/u:c==="interactive"||c===void 0?256/u:c==="playback"?1024/u:Math.max(2,Math.min(128,Math.round(c*u/128)))*128/u,this._nativeAudioContext=a,n.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";let l=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",l)};a.addEventListener("statechange",l)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw i()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ai(this)}))}resume(){return this._state==="suspended"?new Promise((s,a)=>{let c=()=>{this._nativeAudioContext.removeEventListener("statechange",c),this._nativeAudioContext.state==="running"?s():this.resume().then(s,a)};this._nativeAudioContext.addEventListener("statechange",c)}):this._nativeAudioContext.resume().catch(s=>{throw s===void 0||s.code===15?i():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?i():s})}};var Ep=(i,t,e,r,n,o)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,hn.set(this,a),r(a)&&n.set(a,new Set),this._destination=new i(this,c),this._listener=t(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){let c=typeof a=="function"?o(this,a):null;this._nativeContext.onstatechange=c;let u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?a:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}};var cr=i=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=i.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var GC={numberOfChannels:1},Dp=(i,t,e,r,n)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=O(O({},GC),s),l=e(c,a,u);i(cr,()=>cr(l))||l.addEventListener("statechange",(()=>{let h=0,p=m=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",p),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):h+=1)};return p})()),super(l,c),this._length=a,this._nativeOfflineAudioContext=l,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(t()):(this._state="running",n(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,ai(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var kp=(i,t)=>(e,r,n)=>{let o=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let l=o.size===0;if(t(a))return s.call(e,a,c,u),i(o,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(e,a,c),i(o,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let l=o.size>0;if(a===void 0)s.apply(e),o.clear();else if(typeof a=="number"){s.call(e,a);for(let p of o)p[1]===a&&o.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of o)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&o.delete(p)}let h=o.size===0;l&&h&&n()})(e.disconnect),e};var vt=(i,t,e)=>{let r=t[e];r!==void 0&&r!==i[e]&&(i[e]=r)};var ft=(i,t)=>{vt(i,t,"channelCount"),vt(i,t,"channelCountMode"),vt(i,t,"channelInterpretation")};var Wu=i=>typeof i.getFloatTimeDomainData=="function";var Lp=i=>{i.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);i.getByteTimeDomainData(e);let r=Math.max(e.length,i.fftSize);for(let n=0;n<r;n+=1)t[n]=(e[n]-128)*.0078125;return t}};var jp=(i,t)=>(e,r)=>{let n=e.createAnalyser();if(ft(n,r),!(r.maxDecibels>r.minDecibels))throw t();return vt(n,r,"fftSize"),vt(n,r,"maxDecibels"),vt(n,r,"minDecibels"),vt(n,r,"smoothingTimeConstant"),i(Wu,()=>Wu(n))||Lp(n),n};var Pp=i=>i===null?null:i.hasOwnProperty("AudioBuffer")?i.AudioBuffer:null;var It=(i,t,e)=>{let r=t[e];r!==void 0&&r!==i[e].value&&(i[e].value=r)};var Fp=i=>{i.start=(t=>{let e=!1;return(r=0,n=0,o)=>{if(e)throw Pt();t.call(i,r,n,o),e=!0}})(i.start)};var An=i=>{i.start=(t=>(e=0,r=0,n)=>{if(typeof n=="number"&&n<0||r<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(i,e,r,n)})(i.start)};var Cn=i=>{i.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(i,e)})(i.stop)};var Bp=(i,t,e,r,n,o,s,a,c,u,l)=>(h,p)=>{let m=h.createBufferSource();return ft(m,p),It(m,p,"playbackRate"),vt(m,p,"buffer"),vt(m,p,"loop"),vt(m,p,"loopEnd"),vt(m,p,"loopStart"),t(e,()=>e(h))||Fp(m),t(r,()=>r(h))||c(m),t(n,()=>n(h))||u(m,h),t(o,()=>o(h))||An(m),t(s,()=>s(h))||l(m,h),t(a,()=>a(h))||Cn(m),i(h,m),m};var Gp=i=>i===null?null:i.hasOwnProperty("AudioContext")?i.AudioContext:i.hasOwnProperty("webkitAudioContext")?i.webkitAudioContext:null;var Vp=(i,t)=>(e,r,n)=>{let o=e.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}n&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=i(e,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>o.maxChannelCount}),s.connect(o),s};var qp=i=>i===null?null:i.hasOwnProperty("AudioWorkletNode")?i.AudioWorkletNode:null;var Wp=i=>{let{port1:t}=new MessageChannel;try{t.postMessage(i)}finally{t.close()}};var Up=(i,t,e,r,n)=>(o,s,a,c,u,l)=>{if(a!==null)try{let h=new a(o,c,l),p=new Map,m=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw i()}},channelCountMode:{get:()=>"explicit",set:()=>{throw i()}},onprocessorerror:{get:()=>m,set:f=>{typeof m=="function"&&h.removeEventListener("processorerror",m),m=typeof f=="function"?f:null,typeof m=="function"&&h.addEventListener("processorerror",m)}}}),h.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let b=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(b!==null){let x=p.get(g[1]);x!==void 0?g[1]=x:(g[1]=_=>{_.type==="error"?(Object.defineProperties(_,{type:{value:"processorerror"}}),b(_)):b(new ErrorEvent(g[0],O({},_)))},p.set(b,g[1]))}}return f.call(h,"error",g[1],g[2]),f.call(h,...g)})(h.addEventListener),h.removeEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let b=p.get(g[1]);b!==void 0&&(p.delete(g[1]),g[1]=b)}return f.call(h,"error",g[1],g[2]),f.call(h,g[0],g[1],g[2])})(h.removeEventListener),l.numberOfOutputs!==0){let f=e(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(o.destination),n(h,()=>f.disconnect(),()=>f.connect(o.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return Wp(l),t(o,s,u,l)};var ma=(i,t)=>i===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(i*t)))));var zp=i=>new Promise((t,e)=>{let{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),n.close(),t(o)},r.onmessageerror=({data:o})=>{r.close(),n.close(),e(o)},n.postMessage(i)});var Yp=(i,t)=>K(null,null,function*(){let e=yield zp(t);return new i(e)});var Hp=(i,t,e,r)=>{let n=So.get(i);n===void 0&&(n=new WeakMap,So.set(i,n));let o=Yp(e,r);return n.set(t,o),o};var $p=(i,t,e,r,n,o,s,a,c,u,l,h,p)=>(m,f,g,b)=>{if(b.numberOfInputs===0&&b.numberOfOutputs===0)throw c();let x=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(x.some($=>$<1))throw c();if(x.length!==b.numberOfOutputs)throw t();if(b.channelCountMode!=="explicit")throw c();let _=b.channelCount*b.numberOfInputs,w=x.reduce(($,st)=>$+st,0),T=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(_+T>6||w>6)throw c();let S=new MessageChannel,v=[],A=[];for(let $=0;$<b.numberOfInputs;$+=1)v.push(s(m,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),A.push(n(m,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let C=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:$,maxValue:st,minValue:re,name:Ft}of g.parameterDescriptors){let St=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:b.parameterData[Ft]!==void 0?b.parameterData[Ft]:$===void 0?0:$});Object.defineProperties(St.offset,{defaultValue:{get:()=>$===void 0?0:$},maxValue:{get:()=>st===void 0?Wt:st},minValue:{get:()=>re===void 0?Ht:re}}),C.push(St)}let E=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,_+T)}),q=ma(f,m.sampleRate),M=a(m,q,_+T,Math.max(1,w)),R=n(m,{channelCount:Math.max(1,w),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,w)}),B=[];for(let $=0;$<b.numberOfOutputs;$+=1)B.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:x[$]}));for(let $=0;$<b.numberOfInputs;$+=1){v[$].connect(A[$]);for(let st=0;st<b.channelCount;st+=1)A[$].connect(E,st,$*b.channelCount+st)}let D=new gn(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:$},st)=>{let re=C[st];return re.connect(E,0,_+st),re.start(0),[$,re.offset]}));E.connect(M);let j=b.channelInterpretation,F=null,W=b.numberOfOutputs===0?[M]:B,Q={get bufferSize(){return q},get channelCount(){return b.channelCount},set channelCount($){throw e()},get channelCountMode(){return b.channelCountMode},set channelCountMode($){throw e()},get channelInterpretation(){return j},set channelInterpretation($){for(let st of v)st.channelInterpretation=$;j=$},get context(){return M.context},get inputs(){return v},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},get onprocessorerror(){return F},set onprocessorerror($){typeof F=="function"&&Q.removeEventListener("processorerror",F),F=typeof $=="function"?$:null,typeof F=="function"&&Q.addEventListener("processorerror",F)},get parameters(){return D},get port(){return S.port2},addEventListener(...$){return M.addEventListener($[0],$[1],$[2])},connect:i.bind(null,W),disconnect:u.bind(null,W),dispatchEvent(...$){return M.dispatchEvent($[0])},removeEventListener(...$){return M.removeEventListener($[0],$[1],$[2])}},k=new Map;S.port1.addEventListener=($=>(...st)=>{if(st[0]==="message"){let re=typeof st[1]=="function"?st[1]:typeof st[1]=="object"&&st[1]!==null&&typeof st[1].handleEvent=="function"?st[1].handleEvent:null;if(re!==null){let Ft=k.get(st[1]);Ft!==void 0?st[1]=Ft:(st[1]=St=>{l(m.currentTime,m.sampleRate,()=>re(St))},k.set(re,st[1]))}}return $.call(S.port1,st[0],st[1],st[2])})(S.port1.addEventListener),S.port1.removeEventListener=($=>(...st)=>{if(st[0]==="message"){let re=k.get(st[1]);re!==void 0&&(k.delete(st[1]),st[1]=re)}return $.call(S.port1,st[0],st[1],st[2])})(S.port1.removeEventListener);let it=null;Object.defineProperty(S.port1,"onmessage",{get:()=>it,set:$=>{typeof it=="function"&&S.port1.removeEventListener("message",it),it=typeof $=="function"?$:null,typeof it=="function"&&(S.port1.addEventListener("message",it),S.port1.start())}}),g.prototype.port=S.port1;let pt=null;Hp(m,Q,g,b).then($=>pt=$);let Yt=bn(b.numberOfInputs,b.channelCount),Ee=bn(b.numberOfOutputs,x),De=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce(($,{name:st})=>X(O({},$),{[st]:new Float32Array(128)}),{}),Nt=!0,ct=()=>{b.numberOfOutputs>0&&M.disconnect(R);for(let $=0,st=0;$<b.numberOfOutputs;$+=1){let re=B[$];for(let Ft=0;Ft<x[$];Ft+=1)R.disconnect(re,st+Ft,Ft);st+=x[$]}},Ji=new Map;M.onaudioprocess=({inputBuffer:$,outputBuffer:st})=>{if(pt!==null){let re=h(Q);for(let Ft=0;Ft<q;Ft+=128){for(let St=0;St<b.numberOfInputs;St+=1)for(let qt=0;qt<b.channelCount;qt+=1)yn($,Yt[St],qt,qt,Ft);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:St},qt)=>{yn($,De,St,_+qt,Ft)});for(let St=0;St<b.numberOfInputs;St+=1)for(let qt=0;qt<x[St];qt+=1)Ee[St][qt].byteLength===0&&(Ee[St][qt]=new Float32Array(128));try{let St=Yt.map((Ge,Qr)=>{if(re[Qr].size>0)return Ji.set(Qr,q/128),Ge;let tu=Ji.get(Qr);return tu===void 0?[]:(Ge.every(bg=>bg.every(xg=>xg===0))&&(tu===1?Ji.delete(Qr):Ji.set(Qr,tu-1)),Ge)});Nt=l(m.currentTime+Ft/m.sampleRate,m.sampleRate,()=>pt.process(St,Ee,De));for(let Ge=0,Qr=0;Ge<b.numberOfOutputs;Ge+=1){for(let oo=0;oo<x[Ge];oo+=1)la(st,Ee[Ge],oo,Qr+oo,Ft);Qr+=x[Ge]}}catch(St){Nt=!1,Q.dispatchEvent(new ErrorEvent("processorerror",{colno:St.colno,filename:St.filename,lineno:St.lineno,message:St.message}))}if(!Nt){for(let St=0;St<b.numberOfInputs;St+=1){v[St].disconnect(A[St]);for(let qt=0;qt<b.channelCount;qt+=1)A[Ft].disconnect(E,qt,St*b.channelCount+qt)}if(g.parameterDescriptors!==void 0){let St=g.parameterDescriptors.length;for(let qt=0;qt<St;qt+=1){let Ge=C[qt];Ge.disconnect(E,0,_+qt),Ge.stop()}}E.disconnect(M),M.onaudioprocess=null,ro?ct():en();break}}}};let ro=!1,tt=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),tn=()=>M.connect(tt).connect(m.destination),en=()=>{M.disconnect(tt),tt.disconnect()},io=()=>{if(Nt){en(),b.numberOfOutputs>0&&M.connect(R);for(let $=0,st=0;$<b.numberOfOutputs;$+=1){let re=B[$];for(let Ft=0;Ft<x[$];Ft+=1)R.connect(re,st+Ft,Ft);st+=x[$]}}ro=!0},no=()=>{Nt&&(tn(),ct()),ro=!1};return tn(),p(Q,io,no)};var Uu=(i,t)=>{let e=i.createBiquadFilter();return ft(e,t),It(e,t,"Q"),It(e,t,"detune"),It(e,t,"frequency"),It(e,t,"gain"),vt(e,t,"type"),e};var Zp=(i,t)=>(e,r)=>{let n=e.createChannelMerger(r.numberOfInputs);return i!==null&&i.name==="webkitAudioContext"&&t(e,n),ft(n,r),n};var Xp=i=>{let t=i.numberOfOutputs;Object.defineProperty(i,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw Pt()}}),Object.defineProperty(i,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw Pt()}}),Object.defineProperty(i,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw Pt()}})};var _n=(i,t)=>{let e=i.createChannelSplitter(t.numberOfOutputs);return ft(e,t),Xp(e),e};var Qp=(i,t,e,r,n)=>(o,s)=>{if(o.createConstantSource===void 0)return e(o,s);let a=o.createConstantSource();return ft(a,s),It(a,s,"offset"),t(r,()=>r(o))||An(a),t(n,()=>n(o))||Cn(a),i(o,a),a};var ze=(i,t)=>(i.connect=t.connect.bind(t),i.disconnect=t.disconnect.bind(t),i);var Kp=(i,t,e,r)=>(n,a)=>{var c=a,{offset:o}=c,s=Kr(c,["offset"]);let u=n.createBuffer(1,2,44100),l=t(n,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=e(n,X(O({},s),{gain:o})),p=u.getChannelData(0);p[0]=1,p[1]=1,l.buffer=u,l.loop=!0;let m={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(b){h.channelCount=b},get channelCountMode(){return h.channelCountMode},set channelCountMode(b){h.channelCountMode=b},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(b){h.channelInterpretation=b},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return l.onended},set onended(b){l.onended=b},addEventListener(...b){return l.addEventListener(b[0],b[1],b[2])},dispatchEvent(...b){return l.dispatchEvent(b[0])},removeEventListener(...b){return l.removeEventListener(b[0],b[1],b[2])},start(b=0){l.start.call(l,b)},stop(b=0){l.stop.call(l,b)}},f=()=>l.connect(h),g=()=>l.disconnect(h);return i(n,l),r(ze(m,h),f,g)};var Jp=(i,t)=>(e,r)=>{let n=e.createConvolver();if(ft(n,r),r.disableNormalization===n.normalize&&(n.normalize=!r.disableNormalization),vt(n,r,"buffer"),r.channelCount>2||(t(n,"channelCount",o=>()=>o.call(n),o=>s=>{if(s>2)throw i();return o.call(n,s)}),r.channelCountMode==="max"))throw i();return t(n,"channelCountMode",o=>()=>o.call(n),o=>s=>{if(s==="max")throw i();return o.call(n,s)}),n};var zu=(i,t)=>{let e=i.createDelay(t.maxDelayTime);return ft(e,t),It(e,t,"delayTime"),e};var tm=i=>(t,e)=>{let r=t.createDynamicsCompressor();if(ft(r,e),e.channelCount>2||e.channelCountMode==="max")throw i();return It(r,e,"attack"),It(r,e,"knee"),It(r,e,"ratio"),It(r,e,"release"),It(r,e,"threshold"),r};var xe=(i,t)=>{let e=i.createGain();return ft(e,t),It(e,t,"gain"),e};var em=i=>(t,e,r)=>{if(t.createIIRFilter===void 0)return i(t,e,r);let n=t.createIIRFilter(r.feedforward,r.feedback);return ft(n,r),n};function VC(i,t){let e=t[0]*t[0]+t[1]*t[1];return[(i[0]*t[0]+i[1]*t[1])/e,(i[1]*t[0]-i[0]*t[1])/e]}function qC(i,t){return[i[0]*t[0]-i[1]*t[1],i[0]*t[1]+i[1]*t[0]]}function rm(i,t){let e=[0,0];for(let r=i.length-1;r>=0;r-=1)e=qC(e,t),e[0]+=i[r];return e}var im=(i,t,e,r)=>(n,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=ma(o,n.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),m=l instanceof Float64Array?l:new Float64Array(l),f=p.length,g=m.length,b=Math.min(f,g);if(f===0||f>20)throw r();if(p[0]===0)throw t();if(g===0||g>20)throw r();if(m[0]===0)throw t();if(p[0]!==1){for(let C=0;C<g;C+=1)m[C]/=p[0];for(let C=1;C<f;C+=1)p[C]/=p[0]}let x=e(n,h,s,s);x.channelCount=s,x.channelCountMode=a,x.channelInterpretation=c;let _=32,w=[],T=[],S=[];for(let C=0;C<s;C+=1){w.push(0);let E=new Float32Array(_),q=new Float32Array(_);E.fill(0),q.fill(0),T.push(E),S.push(q)}x.onaudioprocess=C=>{let E=C.inputBuffer,q=C.outputBuffer,M=E.numberOfChannels;for(let R=0;R<M;R+=1){let B=E.getChannelData(R),D=q.getChannelData(R);w[R]=pa(p,f,m,g,b,T[R],S[R],w[R],_,B,D)}};let v=n.sampleRate/2;return ze({get bufferSize(){return h},get channelCount(){return x.channelCount},set channelCount(C){x.channelCount=C},get channelCountMode(){return x.channelCountMode},set channelCountMode(C){x.channelCountMode=C},get channelInterpretation(){return x.channelInterpretation},set channelInterpretation(C){x.channelInterpretation=C},get context(){return x.context},get inputs(){return[x]},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},addEventListener(...C){return x.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return x.dispatchEvent(C[0])},getFrequencyResponse(C,E,q){if(C.length!==E.length||E.length!==q.length)throw i();let M=C.length;for(let R=0;R<M;R+=1){let B=-Math.PI*(C[R]/v),D=[Math.cos(B),Math.sin(B)],j=rm(m,D),F=rm(p,D),W=VC(j,F);E[R]=Math.sqrt(W[0]*W[0]+W[1]*W[1]),q[R]=Math.atan2(W[1],W[0])}},removeEventListener(...C){return x.removeEventListener(C[0],C[1],C[2])}},x)};var nm=(i,t)=>i.createMediaElementSource(t.mediaElement);var om=(i,t)=>{let e=i.createMediaStreamDestination();return ft(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var sm=(i,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=e.slice(0,1),n=i.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(n,"mediaStream",{value:t}),n};var am=(i,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let n=new MediaStream([r]),o=e.createMediaStreamSource(n);if(r.kind!=="audio")throw i();if(t(e))throw new TypeError;return o};var cm=i=>i===null?null:i.hasOwnProperty("OfflineAudioContext")?i.OfflineAudioContext:i.hasOwnProperty("webkitOfflineAudioContext")?i.webkitOfflineAudioContext:null;var um=(i,t,e,r,n,o)=>(s,a)=>{let c=s.createOscillator();return ft(c,a),It(c,a,"detune"),It(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):vt(c,a,"type"),t(e,()=>e(s))||An(c),t(r,()=>r(s))||o(c,s),t(n,()=>n(s))||Cn(c),i(s,c),c};var hm=i=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?i(t,e):(ft(r,e),It(r,e,"orientationX"),It(r,e,"orientationY"),It(r,e,"orientationZ"),It(r,e,"positionX"),It(r,e,"positionY"),It(r,e,"positionZ"),vt(r,e,"coneInnerAngle"),vt(r,e,"coneOuterAngle"),vt(r,e,"coneOuterGain"),vt(r,e,"distanceModel"),vt(r,e,"maxDistance"),vt(r,e,"panningModel"),vt(r,e,"refDistance"),vt(r,e,"rolloffFactor"),r)};var lm=(i,t,e,r,n,o,s,a,c,u)=>(l,q)=>{var M=q,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:b,orientationY:x,orientationZ:_,panningModel:w,positionX:T,positionY:S,positionZ:v,refDistance:A,rolloffFactor:C}=M,E=Kr(M,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let R=l.createPanner();if(E.channelCount>2||E.channelCountMode==="max")throw s();ft(R,E);let B={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},D=e(l,X(O({},B),{channelInterpretation:"speakers",numberOfInputs:6})),j=r(l,X(O({},E),{gain:1})),F=r(l,X(O({},B),{gain:1})),W=r(l,X(O({},B),{gain:0})),Q=r(l,X(O({},B),{gain:0})),k=r(l,X(O({},B),{gain:0})),it=r(l,X(O({},B),{gain:0})),pt=r(l,X(O({},B),{gain:0})),At=n(l,256,6,1),Yt=o(l,X(O({},B),{curve:new Float32Array([1,1]),oversample:"none"})),Ee=[b,x,_],De=[T,S,v],Nt=new Float32Array(1);At.onaudioprocess=({inputBuffer:tt})=>{let tn=[c(tt,Nt,0),c(tt,Nt,1),c(tt,Nt,2)];tn.some((io,no)=>io!==Ee[no])&&(R.setOrientation(...tn),Ee=tn);let en=[c(tt,Nt,3),c(tt,Nt,4),c(tt,Nt,5)];en.some((io,no)=>io!==De[no])&&(R.setPosition(...en),De=en)},Object.defineProperty(W.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(k.gain,"defaultValue",{get:()=>0}),Object.defineProperty(it.gain,"defaultValue",{get:()=>0}),Object.defineProperty(pt.gain,"defaultValue",{get:()=>0});let ct={get bufferSize(){},get channelCount(){return R.channelCount},set channelCount(tt){if(tt>2)throw s();j.channelCount=tt,R.channelCount=tt},get channelCountMode(){return R.channelCountMode},set channelCountMode(tt){if(tt==="max")throw s();j.channelCountMode=tt,R.channelCountMode=tt},get channelInterpretation(){return R.channelInterpretation},set channelInterpretation(tt){j.channelInterpretation=tt,R.channelInterpretation=tt},get coneInnerAngle(){return R.coneInnerAngle},set coneInnerAngle(tt){R.coneInnerAngle=tt},get coneOuterAngle(){return R.coneOuterAngle},set coneOuterAngle(tt){R.coneOuterAngle=tt},get coneOuterGain(){return R.coneOuterGain},set coneOuterGain(tt){if(tt<0||tt>1)throw t();R.coneOuterGain=tt},get context(){return R.context},get distanceModel(){return R.distanceModel},set distanceModel(tt){R.distanceModel=tt},get inputs(){return[j]},get maxDistance(){return R.maxDistance},set maxDistance(tt){if(tt<0)throw new RangeError;R.maxDistance=tt},get numberOfInputs(){return R.numberOfInputs},get numberOfOutputs(){return R.numberOfOutputs},get orientationX(){return F.gain},get orientationY(){return W.gain},get orientationZ(){return Q.gain},get panningModel(){return R.panningModel},set panningModel(tt){R.panningModel=tt},get positionX(){return k.gain},get positionY(){return it.gain},get positionZ(){return pt.gain},get refDistance(){return R.refDistance},set refDistance(tt){if(tt<0)throw new RangeError;R.refDistance=tt},get rolloffFactor(){return R.rolloffFactor},set rolloffFactor(tt){if(tt<0)throw new RangeError;R.rolloffFactor=tt},addEventListener(...tt){return j.addEventListener(tt[0],tt[1],tt[2])},dispatchEvent(...tt){return j.dispatchEvent(tt[0])},removeEventListener(...tt){return j.removeEventListener(tt[0],tt[1],tt[2])}};h!==ct.coneInnerAngle&&(ct.coneInnerAngle=h),p!==ct.coneOuterAngle&&(ct.coneOuterAngle=p),m!==ct.coneOuterGain&&(ct.coneOuterGain=m),f!==ct.distanceModel&&(ct.distanceModel=f),g!==ct.maxDistance&&(ct.maxDistance=g),b!==ct.orientationX.value&&(ct.orientationX.value=b),x!==ct.orientationY.value&&(ct.orientationY.value=x),_!==ct.orientationZ.value&&(ct.orientationZ.value=_),w!==ct.panningModel&&(ct.panningModel=w),T!==ct.positionX.value&&(ct.positionX.value=T),S!==ct.positionY.value&&(ct.positionY.value=S),v!==ct.positionZ.value&&(ct.positionZ.value=v),A!==ct.refDistance&&(ct.refDistance=A),C!==ct.rolloffFactor&&(ct.rolloffFactor=C),(Ee[0]!==1||Ee[1]!==0||Ee[2]!==0)&&R.setOrientation(...Ee),(De[0]!==0||De[1]!==0||De[2]!==0)&&R.setPosition(...De);let Ji=()=>{j.connect(R),i(j,Yt,0,0),Yt.connect(F).connect(D,0,0),Yt.connect(W).connect(D,0,1),Yt.connect(Q).connect(D,0,2),Yt.connect(k).connect(D,0,3),Yt.connect(it).connect(D,0,4),Yt.connect(pt).connect(D,0,5),D.connect(At).connect(l.destination)},ro=()=>{j.disconnect(R),a(j,Yt,0,0),Yt.disconnect(F),F.disconnect(D),Yt.disconnect(W),W.disconnect(D),Yt.disconnect(Q),Q.disconnect(D),Yt.disconnect(k),k.disconnect(D),Yt.disconnect(it),it.disconnect(D),Yt.disconnect(pt),pt.disconnect(D),D.disconnect(At),At.disconnect(l.destination)};return u(ze(ct,R),Ji,ro)};var dm=i=>(t,{disableNormalization:e,imag:r,real:n})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=n instanceof Float32Array?n:new Float32Array(n),a=t.createPeriodicWave(s,o,{disableNormalization:e});if(Array.from(r).length<2)throw i();return a};var vn=(i,t,e,r)=>i.createScriptProcessor(t,e,r);var pm=(i,t)=>(e,r)=>{let n=r.channelCountMode;if(n==="clamped-max")throw t();if(e.createStereoPanner===void 0)return i(e,r);let o=e.createStereoPanner();return ft(o,r),It(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>n,set:s=>{if(s!==n)throw t()}}),o};var mm=(i,t,e,r,n,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=X(O({},u),{oversample:"none"}),h=(f,g,b,x)=>{let _=new Float32Array(16385),w=new Float32Array(16385);for(let E=0;E<16385;E+=1){let q=E/16384*c;_[E]=Math.cos(q),w[E]=Math.sin(q)}let T=e(f,X(O({},u),{gain:0})),S=r(f,X(O({},l),{curve:_})),v=r(f,X(O({},l),{curve:a})),A=e(f,X(O({},u),{gain:0})),C=r(f,X(O({},l),{curve:w}));return{connectGraph(){g.connect(T),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(A),v.connect(b),b.connect(S.inputs===void 0?S:S.inputs[0]),b.connect(C.inputs===void 0?C:C.inputs[0]),S.connect(T.gain),C.connect(A.gain),T.connect(x,0,0),A.connect(x,0,1)},disconnectGraph(){g.disconnect(T),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(A),v.disconnect(b),b.disconnect(S.inputs===void 0?S:S.inputs[0]),b.disconnect(C.inputs===void 0?C:C.inputs[0]),S.disconnect(T.gain),C.disconnect(A.gain),T.disconnect(x,0,0),A.disconnect(x,0,1)}}},p=(f,g,b,x)=>{let _=new Float32Array(16385),w=new Float32Array(16385),T=new Float32Array(16385),S=new Float32Array(16385),v=Math.floor(16385/2);for(let W=0;W<16385;W+=1)if(W>v){let Q=(W-v)/(16384-v)*c;_[W]=Math.cos(Q),w[W]=Math.sin(Q),T[W]=0,S[W]=1}else{let Q=W/(16384-v)*c;_[W]=1,w[W]=0,T[W]=Math.cos(Q),S[W]=Math.sin(Q)}let A=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),C=e(f,X(O({},u),{gain:0})),E=r(f,X(O({},l),{curve:_})),q=e(f,X(O({},u),{gain:0})),M=r(f,X(O({},l),{curve:w})),R=r(f,X(O({},l),{curve:a})),B=e(f,X(O({},u),{gain:0})),D=r(f,X(O({},l),{curve:T})),j=e(f,X(O({},u),{gain:0})),F=r(f,X(O({},l),{curve:S}));return{connectGraph(){g.connect(A),g.connect(R.inputs===void 0?R:R.inputs[0]),A.connect(C,0),A.connect(q,0),A.connect(B,1),A.connect(j,1),R.connect(b),b.connect(E.inputs===void 0?E:E.inputs[0]),b.connect(M.inputs===void 0?M:M.inputs[0]),b.connect(D.inputs===void 0?D:D.inputs[0]),b.connect(F.inputs===void 0?F:F.inputs[0]),E.connect(C.gain),M.connect(q.gain),D.connect(B.gain),F.connect(j.gain),C.connect(x,0,0),B.connect(x,0,0),q.connect(x,0,1),j.connect(x,0,1)},disconnectGraph(){g.disconnect(A),g.disconnect(R.inputs===void 0?R:R.inputs[0]),A.disconnect(C,0),A.disconnect(q,0),A.disconnect(B,1),A.disconnect(j,1),R.disconnect(b),b.disconnect(E.inputs===void 0?E:E.inputs[0]),b.disconnect(M.inputs===void 0?M:M.inputs[0]),b.disconnect(D.inputs===void 0?D:D.inputs[0]),b.disconnect(F.inputs===void 0?F:F.inputs[0]),E.disconnect(C.gain),M.disconnect(q.gain),D.disconnect(B.gain),F.disconnect(j.gain),C.disconnect(x,0,0),B.disconnect(x,0,0),q.disconnect(x,0,1),j.disconnect(x,0,1)}}},m=(f,g,b,x,_)=>{if(g===1)return h(f,b,x,_);if(g===2)return p(f,b,x,_);throw n()};return(f,w)=>{var T=w,{channelCount:g,channelCountMode:b,pan:x}=T,_=Kr(T,["channelCount","channelCountMode","pan"]);if(b==="max")throw n();let S=i(f,X(O({},_),{channelCount:1,channelCountMode:b,numberOfInputs:2})),v=e(f,X(O({},_),{channelCount:g,channelCountMode:b,gain:1})),A=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:x}),{connectGraph:C,disconnectGraph:E}=m(f,g,v,A,S);Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"maxValue",{get:()=>1}),Object.defineProperty(A.gain,"minValue",{get:()=>-1});let q={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(D){v.channelCount!==D&&(M&&E(),{connectGraph:C,disconnectGraph:E}=m(f,D,v,A,S),M&&C()),v.channelCount=D},get channelCountMode(){return v.channelCountMode},set channelCountMode(D){if(D==="clamped-max"||D==="max")throw n();v.channelCountMode=D},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(D){v.channelInterpretation=D},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return A.gain},addEventListener(...D){return v.addEventListener(D[0],D[1],D[2])},dispatchEvent(...D){return v.dispatchEvent(D[0])},removeEventListener(...D){return v.removeEventListener(D[0],D[1],D[2])}},M=!1,R=()=>{C(),M=!0},B=()=>{E(),M=!1};return o(ze(q,S),R,B)}};var fm=(i,t,e,r,n,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return e(a,c);ft(u,c);let l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw t();vt(u,{curve:l},"curve"),vt(u,c,"oversample");let h=null,p=!1;return s(u,"curve",g=>()=>g.call(u),g=>b=>(g.call(u,b),p&&(r(b)&&h===null?h=i(a,u):!r(b)&&h!==null&&(h(),h=null)),b)),n(u,()=>{p=!0,r(u.curve)&&(h=i(a,u))},()=>{p=!1,h!==null&&(h(),h=null)})};var gm=(i,t,e,r,n)=>(o,u)=>{var l=u,{curve:s,oversample:a}=l,c=Kr(l,["curve","oversample"]);let h=o.createWaveShaper(),p=o.createWaveShaper();ft(h,c),ft(p,c);let m=e(o,X(O({},c),{gain:1})),f=e(o,X(O({},c),{gain:-1})),g=e(o,X(O({},c),{gain:1})),b=e(o,X(O({},c),{gain:-1})),x=null,_=!1,w=null,T={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(A){m.channelCount=A,f.channelCount=A,h.channelCount=A,g.channelCount=A,p.channelCount=A,b.channelCount=A},get channelCountMode(){return h.channelCountMode},set channelCountMode(A){m.channelCountMode=A,f.channelCountMode=A,h.channelCountMode=A,g.channelCountMode=A,p.channelCountMode=A,b.channelCountMode=A},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(A){m.channelInterpretation=A,f.channelInterpretation=A,h.channelInterpretation=A,g.channelInterpretation=A,p.channelInterpretation=A,b.channelInterpretation=A},get context(){return h.context},get curve(){return w},set curve(A){if(A!==null&&A.length<2)throw t();if(A===null)h.curve=A,p.curve=A;else{let C=A.length,E=new Float32Array(C+2-C%2),q=new Float32Array(C+2-C%2);E[0]=A[0],q[0]=-A[C-1];let M=Math.ceil((C+1)/2),R=(C+1)/2-1;for(let B=1;B<M;B+=1){let D=B/M*R,j=Math.floor(D),F=Math.ceil(D);E[B]=j===F?A[j]:(1-(D-j))*A[j]+(1-(F-D))*A[F],q[B]=j===F?-A[C-1-j]:-((1-(D-j))*A[C-1-j])-(1-(F-D))*A[C-1-F]}E[M]=C%2===1?A[M-1]:(A[M-2]+A[M-1])/2,h.curve=E,p.curve=q}w=A,_&&(r(w)&&x===null?x=i(o,m):x!==null&&(x(),x=null))},get inputs(){return[m]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(A){h.oversample=A,p.oversample=A},addEventListener(...A){return m.addEventListener(A[0],A[1],A[2])},dispatchEvent(...A){return m.dispatchEvent(A[0])},removeEventListener(...A){return m.removeEventListener(A[0],A[1],A[2])}};s!==null&&(T.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==T.oversample&&(T.oversample=a);let S=()=>{m.connect(h).connect(g),m.connect(f).connect(p).connect(b).connect(g),_=!0,r(w)&&(x=i(o,m))},v=()=>{m.disconnect(h),h.disconnect(g),m.disconnect(f),f.disconnect(p),p.disconnect(b),b.disconnect(g),_=!1,x!==null&&(x(),x=null)};return n(ze(T,g),S,v)};var ce=()=>new DOMException("","NotSupportedError");var WC={numberOfChannels:1},ym=(i,t,e,r,n)=>class extends i{constructor(s,a,c){let u;if(typeof s=="number"&&a!==void 0&&c!==void 0)u={length:a,numberOfChannels:s,sampleRate:c};else if(typeof s=="object")u=s;else throw new Error("The given parameters are not valid.");let{length:l,numberOfChannels:h,sampleRate:p}=O(O({},WC),u),m=r(h,l,p);t(cr,()=>cr(m))||m.addEventListener("statechange",(()=>{let f=0,g=b=>{this._state==="running"&&(f>0?(m.removeEventListener("statechange",g),b.stopImmediatePropagation(),this._waitForThePromiseToSettle(b)):f+=1)};return g})()),super(m,h),this._length=l,this._nativeOfflineAudioContext=m,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(e()):(this._state="running",n(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,ai(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var UC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},bm=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let l=n(c),h=O(O({},UC),u),p=e(l,h),m=o(l),f=m?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,m,p.detune,153600,-153600),this._frequency=t(this,m,p.frequency,g,-g),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&h.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=h.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeOscillatorNode.onended=u;let l=this._nativeOscillatorNode.onended;this._onended=l!==null&&l===u?c:l}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){sr(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),be(this)&&Ir(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var xm=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(l,h)=>K(null,null,function*(){let p=e(l),m=_t(p,h);if(!m){let f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:s===null?void 0:s,type:p.type};p=t(h,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return o.set(h,p),m?(yield i(h,l.detune,p.detune),yield i(h,l.frequency,p.frequency)):(yield r(h,l.detune,p.detune),yield r(h,l.frequency,p.frequency)),yield n(l,h,p),p});return{set periodicWave(l){s=l},set start(l){a=l},set stop(l){c=l},render(l,h){let p=o.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var zC={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},Am=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let l=n(c),h=O(O({},zC),u),p=e(l,h),m=o(l),f=m?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,m,p.orientationX,Wt,Ht),this._orientationY=t(this,m,p.orientationY,Wt,Ht),this._orientationZ=t(this,m,p.orientationZ,Wt,Ht),this._positionX=t(this,m,p.positionX,Wt,Ht),this._positionY=t(this,m,p.positionY,Wt,Ht),this._positionZ=t(this,m,p.positionZ,Wt,Ht),s(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}};var Cm=(i,t,e,r,n,o,s,a,c,u)=>()=>{let l=new WeakMap,h=null,p=(m,f)=>K(null,null,function*(){let g=null,b=o(m),x={channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation},_=X(O({},x),{coneInnerAngle:b.coneInnerAngle,coneOuterAngle:b.coneOuterAngle,coneOuterGain:b.coneOuterGain,distanceModel:b.distanceModel,maxDistance:b.maxDistance,panningModel:b.panningModel,refDistance:b.refDistance,rolloffFactor:b.rolloffFactor}),w=_t(b,f);if("bufferSize"in b)g=r(f,X(O({},x),{gain:1}));else if(!w){let T=X(O({},_),{orientationX:b.orientationX.value,orientationY:b.orientationY.value,orientationZ:b.orientationZ.value,positionX:b.positionX.value,positionY:b.positionY.value,positionZ:b.positionZ.value});b=n(f,T)}if(l.set(f,g===null?b:g),g!==null){if(h===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let M=new s(6,m.context.length,f.sampleRate),R=t(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});R.connect(M.destination),h=K(null,null,function*(){let B=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((D,j)=>K(null,null,function*(){let F=e(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:j===0?1:0});return yield a(M,D,F.offset),F})));for(let D=0;D<6;D+=1)B[D].connect(R,0,D),B[D].start(0);return u(M)})}let T=yield h,S=r(f,X(O({},x),{gain:1}));yield c(m,f,S);let v=[];for(let M=0;M<T.numberOfChannels;M+=1)v.push(T.getChannelData(M));let A=[v[0][0],v[1][0],v[2][0]],C=[v[3][0],v[4][0],v[5][0]],E=r(f,X(O({},x),{gain:1})),q=n(f,X(O({},_),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:C[0],positionY:C[1],positionZ:C[2]}));S.connect(E).connect(q.inputs[0]),q.connect(g);for(let M=128;M<T.length;M+=128){let R=[v[0][M],v[1][M],v[2][M]],B=[v[3][M],v[4][M],v[5][M]];if(R.some((D,j)=>D!==A[j])||B.some((D,j)=>D!==C[j])){A=R,C=B;let D=M/f.sampleRate;E.gain.setValueAtTime(0,D),E=r(f,X(O({},x),{gain:0})),q=n(f,X(O({},_),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:C[0],positionY:C[1],positionZ:C[2]})),E.gain.setValueAtTime(1,D),S.connect(E).connect(q.inputs[0]),q.connect(g)}}return g}return w?(yield i(f,m.orientationX,b.orientationX),yield i(f,m.orientationY,b.orientationY),yield i(f,m.orientationZ,b.orientationZ),yield i(f,m.positionX,b.positionX),yield i(f,m.positionY,b.positionY),yield i(f,m.positionZ,b.positionZ)):(yield a(f,m.orientationX,b.orientationX),yield a(f,m.orientationY,b.orientationY),yield a(f,m.orientationZ,b.orientationZ),yield a(f,m.positionX,b.positionX),yield a(f,m.positionY,b.positionY),yield a(f,m.positionZ,b.positionZ)),Ue(b)?yield c(m,f,b.inputs[0]):yield c(m,f,b),b});return{render(m,f){let g=l.get(f);return g!==void 0?Promise.resolve(g):p(m,f)}}};var YC={disableNormalization:!1},_m=(i,t,e,r)=>class vm{constructor(o,s){let a=t(o),c=r(O(O({},YC),s)),u=i(a,c);return e.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===vm.prototype||e.has(o)}};var wm=(i,t)=>(e,r,n)=>(i(r).replay(n),t(r,e,n));var Sm=(i,t,e)=>(r,n,o)=>K(null,null,function*(){let s=i(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>K(null,[h],function*([u,l]){let m=yield t(u).render(u,n),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&m.connect(o,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var Im=(i,t,e)=>(r,n,o)=>K(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>K(null,[u],function*([a,c]){let h=yield i(a).render(a,n);e(a)||h.connect(o,c)})))});var Tm=(i,t,e,r)=>n=>i(cr,()=>cr(n))?Promise.resolve(i(r,r)).then(o=>{if(!o){let s=e(n,512,0,1);n.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>n.currentTime,s.connect(n.destination)}return n.startRendering()}):new Promise(o=>{let s=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(n.destination),n.startRendering()});var Nm=i=>(t,e)=>{i.set(t,e)};var Om=i=>(t,e)=>i.set(t,e);var Rm=(i,t,e,r,n,o,s,a)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(l=>e(l).render(l,u)))).then(()=>n(u)).then(l=>(typeof l.copyFromChannel!="function"?(s(l),dn(l)):t(o,()=>o(l))||a(l),i.add(l),l));var HC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Mm=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),l=O(O({},HC),c),h=e(u,l),p=o(u),m=p?r():null;super(a,!1,h,m),this._pan=t(this,p,h.pan)}get pan(){return this._pan}};var Em=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=_t(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,h)}return o.set(c,u),l?yield i(c,a.pan,u.pan):yield r(c,a.pan,u.pan),Ue(u)?yield n(a,c,u.inputs[0]):yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Dm=i=>()=>{if(i===null)return!1;try{new i({length:1,sampleRate:44100})}catch(t){return!1}return!0};var km=(i,t)=>()=>K(null,null,function*(){if(i===null)return!0;if(t===null)return!1;let e=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new t(1,128,44100),n=URL.createObjectURL(e),o=!1,s=!1;try{yield r.audioWorklet.addModule(n);let a=new i(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>o=!0,a.onprocessorerror=()=>s=!0,c.connect(a),c.start(0),yield r.startRendering(),yield new Promise(u=>setTimeout(u))}catch(a){}finally{URL.revokeObjectURL(n)}return o&&!s});var Lm=(i,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=i(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(n=>{e.oncomplete=()=>{r.disconnect(),n(e.currentTime!==0)},e.startRendering()})};var Yu=()=>new DOMException("","UnknownError");var $C={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},jm=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let l=n(c),h=O(O({},$C),u),p=e(l,h),f=o(l)?r():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,s(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var Pm=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>K(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=i(s,u)}return r.set(s,a),Ue(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var Fm=()=>typeof window=="undefined"?null:window;var Bm=(i,t)=>e=>{e.copyFromChannel=(r,n,o=0)=>{let s=i(o),a=i(n);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)r[h]=u[h+s]},e.copyToChannel=(r,n,o=0)=>{let s=i(o),a=i(n);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)u[h+s]=r[h]}};var Gm=i=>t=>{t.copyFromChannel=(e=>(r,n,o=0)=>{let s=i(o),a=i(n);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,n,o=0)=>{let s=i(o),a=i(n);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var Vm=i=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),i(t,"buffer",n=>()=>{let o=n.call(t);return o===r?null:o},n=>o=>n.call(t,o===null?r:o))};var qm=(i,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw i()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw i()}});let n=e.createBufferSource();t(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)n.connect(r,0,c)},()=>n.disconnect(r))};var Hu=(i,t,e)=>i.copyFromChannel===void 0?i.getChannelData(e)[0]:(i.copyFromChannel(t,e),t[0]);var $u=i=>{if(i===null)return!1;let t=i.length;return t%2!==0?i[Math.floor(t/2)]!==0:i[t/2-1]+i[t/2]!==0};var wn=(i,t,e,r)=>{let n=i;for(;!n.hasOwnProperty(t);)n=Object.getPrototypeOf(n);let{get:o,set:s}=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(i,t,{get:e(o),set:r(s)})};var Wm=i=>X(O({},i),{outputChannelCount:i.outputChannelCount!==void 0?i.outputChannelCount:i.numberOfInputs===1&&i.numberOfOutputs===1?[i.channelCount]:Array.from({length:i.numberOfOutputs},()=>1)});var Um=i=>X(O({},i),{channelCount:i.numberOfOutputs});var zm=i=>{let{imag:t,real:e}=i;return t===void 0?e===void 0?X(O({},i),{imag:[0,0],real:[0,0]}):X(O({},i),{imag:Array.from(e,()=>0),real:e}):e===void 0?X(O({},i),{imag:t,real:Array.from(t,()=>0)}):X(O({},i),{imag:t,real:e})};var Zu=(i,t,e)=>{try{i.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;Zu(i,t,e+1e-7)}};var Ym=i=>{let t=i.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var Hm=i=>{let t=i.createBufferSource(),e=i.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var $m=i=>{let t=i.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var fa=i=>{let t=i.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Xu=i=>{let t=i.createBuffer(1,1,44100),e=i.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var ga=i=>{let t=i.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var Zm=i=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(i)}finally{t.close(),e.close()}};var Xm=i=>{i.start=(t=>(e=0,r=0,n)=>{let o=i.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/i.context.sampleRate?t.call(i,e,0,0):t.call(i,e,s,n)})(i.start)};var Qu=(i,t)=>{let e=t.createGain();i.connect(e);let r=(n=>()=>{n.call(i,e),i.removeEventListener("ended",r)})(i.disconnect);i.addEventListener("ended",r),ze(i,e),i.stop=(n=>{let o=!1;return(s=0)=>{if(o)try{n.call(i,s)}catch(a){e.gain.setValueAtTime(0,s)}else n.call(i,s),o=!0}})(i.stop)};var Li=(i,t)=>e=>{let r={value:i};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(i,e):t.handleEvent.call(i,e)};var ZC=Gl(ar),XC=Xl(ar),QC=zd(oi),Km=new WeakMap,KC=ap(Km),Ye=Id(new Map,new WeakMap),Tr=Fm(),Jm=jp(Ye,We),Ku=sp(ne),ue=Sm(ne,Ku,Wr),JC=td(Jm,Ot,ue),Lt=hp(hn),Ur=cm(Tr),Rt=Sp(Ur),tf=new WeakMap,ef=tp(Li),Sn=Gp(Tr),Ju=Cp(Sn),th=_p(Tr),rf=vp(Tr),To=qp(Tr),$t=yd(Vl(ia),Zl(ZC,XC,pn,QC,mn,ne,KC,Sr,Ot,ar,be,Wr,fn),Ye,gp(vo,mn,ne,Ot,Di,be),We,xn,ce,qd(pn,vo,ne,Ot,Di,Lt,be,Rt),$d(tf,ne,Kt),ef,Lt,Ju,th,rf,Rt,To),t_=Jl($t,JC,We,Jm,Lt,Rt);var eh=new WeakSet,Qm=Pp(Tr),nf=jd(new Uint32Array(1)),rh=Bm(nf,We),ih=Gm(nf),nh=ed(eh,Ye,ce,Qm,Ur,Dm(Qm),rh,ih);var ya=Ql(xe),of=Im(Ku,si,Wr),Nr=Md(of),In=Bp(ya,Ye,Ym,Hm,$m,fa,Xu,ga,Xm,Vm(wn),Qu),Or=wm(cp(si),of),e_=nd(Nr,In,Ot,Or,ue),ur=bd(ql(na),tf,_o,xd,Nu,Ou,Ru,Mu,Eu,sn,yo,Sn,Zu),r_=id($t,e_,ur,Pt,In,Lt,Rt,Li);var i_=dd($t,pd,We,Pt,Vp(xe,wn),Lt,Rt,ue),n_=Sd(Nr,Uu,Ot,Or,ue),ji=Om(Km),o_=wd($t,ur,n_,xn,Uu,Lt,Rt,ji),ui=kp(ar,th),s_=qm(Pt,ui),hi=Zp(Sn,s_),a_=Nd(hi,Ot,ue),c_=Td($t,a_,hi,Lt,Rt),u_=Rd(_n,Ot,ue),h_=Od($t,u_,_n,Lt,Rt,Um),l_=Kp(ya,In,xe,ui),Tn=Qp(ya,Ye,l_,fa,ga),d_=Ld(Nr,Tn,Ot,Or,ue),p_=kd($t,ur,d_,Tn,Lt,Rt,Li),sf=Jp(ce,wn),m_=Fd(sf,Ot,ue),f_=Pd($t,m_,sf,Lt,Rt,ji),g_=Ud(Nr,zu,Ot,Or,ue),y_=Wd($t,ur,g_,zu,Lt,Rt,ji),af=tm(ce),b_=Qd(Nr,af,Ot,Or,ue),x_=Xd($t,ur,b_,af,ce,Lt,Rt,ji),A_=np(Nr,xe,Ot,Or,ue),C_=ip($t,ur,A_,xe,Lt,Rt),__=im(xn,Pt,vn,ce),ba=Tm(Ye,xe,vn,Lm(xe,Ur)),v_=fp(In,Ot,Ur,ue,ba),w_=em(__),S_=mp($t,w_,v_,Lt,Rt,ji),I_=md(ur,hi,Tn,vn,ce,Hu,Rt,wn),cf=new WeakMap,oh=Ep(i_,I_,ef,Rt,cf,Li),uf=um(ya,Ye,fa,Xu,ga,Qu),T_=xm(Nr,uf,Ot,Or,ue),N_=bm($t,ur,uf,T_,Lt,Rt,Li),hf=Dd(In),O_=gm(hf,Pt,xe,$u,ui),xa=fm(hf,Pt,O_,$u,ui,Sn,wn),R_=lm(pn,Pt,hi,xe,vn,xa,ce,mn,Hu,ui),lf=hm(R_),M_=Cm(Nr,hi,Tn,xe,lf,Ot,Ur,Or,ue,ba),E_=Am($t,ur,lf,M_,Lt,Rt,ji),D_=dm(We),k_=_m(D_,Lt,new WeakSet,zm),L_=mm(hi,_n,xe,xa,ce,ui),df=pm(L_,ce),j_=Em(Nr,df,Ot,Or,ue),P_=Mm($t,ur,df,j_,Lt,Rt),F_=Pm(xa,Ot,ue),B_=jm($t,Pt,xa,F_,Lt,Rt,ji),pf=Ip(Tr),sh=ep(Tr),mf=new WeakMap,G_=lp(mf,Ur),V_=pf?$l(Ye,ce,Jd(Tr),sh,rp(Bl),Lt,G_,Rt,To,new WeakMap,new WeakMap,km(To,Ur),Tr):void 0,q_=wp(Ju,Rt),W_=Vd(eh,Ye,Gd,Kd,new WeakSet,Lt,q_,ln,cr,rh,ih),ff=vd(V_,t_,nh,r_,o_,c_,h_,p_,f_,W_,y_,x_,C_,S_,oh,N_,E_,k_,P_,B_),U_=Tp($t,nm,Lt,Rt),z_=Np($t,om,Lt,Rt),Y_=Op($t,sm,Lt,Rt),H_=am(Pt,Rt),$_=Rp($t,H_,Lt),gf=ld(ff,Pt,ce,Yu,U_,z_,Y_,$_,Sn);var ah=dp(cf),Z_=Kl(ah),yf=Ed(We),X_=Yd(ah),bf=Zd(We),xf=new WeakMap,Q_=op(xf,Kt),K_=$p(yf,We,Pt,hi,_n,Tn,xe,vn,ce,bf,sh,Q_,ui),J_=Up(Pt,K_,xe,ce,ui),tv=_d(Nr,yf,In,hi,_n,Tn,xe,X_,bf,sh,Ot,To,Ur,Or,ue,ba),ev=up(mf),rv=Nm(xf),ch=pf?Ad(Z_,$t,ur,tv,J_,ne,ev,Lt,Rt,To,Wm,rv,Zm,Li):void 0;var bU=Mp(Pt,ce,Yu,oh,Sn);var Af=Bd(ce,Ur),Cf=Rm(eh,Ye,Ku,ah,ba,ln,rh,ih),xU=Dp(Ye,Pt,Af,oh,Cf);var _f=ym(ff,Ye,Pt,Af,Cf);var vf=yp(hn,Ju),wf=bp(un,th),Sf=xp(_o,rf),If=Ap(hn,Rt);function Zt(i){return i===void 0}function rt(i){return i!==void 0}function Tf(i){return typeof i=="function"}function he(i){return typeof i=="number"}function hr(i){return Object.prototype.toString.call(i)==="[object Object]"&&i.constructor===Object}function uh(i){return typeof i=="boolean"}function Gt(i){return Array.isArray(i)}function me(i){return typeof i=="string"}function No(i){return me(i)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(i)}function Y(i,t){if(!i)throw new Error(t)}function Ut(i,t,e=1/0){if(!(t<=i&&i<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${i}`)}function Aa(i){!i.isOffline&&i.state!=="running"&&Pi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Of=!1,Nf=!1;function hh(i){Of=i}function Rf(i){Zt(i)&&Of&&!Nf&&(Nf=!0,Pi("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var Mf=console;function Ef(...i){Mf.log(...i)}function Pi(...i){Mf.warn(...i)}function Df(i){return new gf(i)}function kf(i,t,e){return new _f(i,t,e)}var fe=typeof self=="object"?self:null,Lf=fe&&(fe.hasOwnProperty("AudioContext")||fe.hasOwnProperty("webkitAudioContext"));function jf(i,t,e){return Y(rt(ch),"AudioWorkletNode only works in a secure context (https or localhost)"),new(i instanceof(fe==null?void 0:fe.BaseAudioContext)?fe==null?void 0:fe.AudioWorkletNode:ch)(i,t,e)}function ge(i,t,e,r){var n=arguments.length,o=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var a=i.length-1;a>=0;a--)(s=i[a])&&(o=(n<3?s(o):n>3?s(t,e,o):s(t,e))||o);return n>3&&o&&Object.defineProperty(t,e,o),o}function yt(i,t,e,r){function n(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(h){s(h)}}function c(l){try{u(r.throw(l))}catch(h){s(h)}}function u(l){l.done?o(l.value):n(l.value).then(a,c)}u((r=r.apply(i,t||[])).next())})}var Ca=class{constructor(t,e,r,n){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(n||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let t=new Blob([`
85
85
  // the initial timeout time
86
86
  let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
87
87
  // onmessage callback
@@ -96,7 +96,7 @@
96
96
  }
97
97
  // call tick initially
98
98
  tick();
99
- `],{type:"text/javascript"}),e=URL.createObjectURL(t),r=new Worker(e);r.onmessage=this._callback.bind(this),this._worker=r}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}};function lr(i){return Sf(i)}function Rr(i){return wf(i)}function Nn(i){return If(i)}function li(i){return vf(i)}function Pf(i){return i instanceof nh}function ov(i,t){return i==="value"||lr(t)||Rr(t)||Pf(t)}function $e(i,...t){if(!t.length)return i;let e=t.shift();if(hr(i)&&hr(e))for(let r in e)ov(r,e[r])?i[r]=e[r]:hr(e[r])?(i[r]||Object.assign(i,{[r]:{}}),$e(i[r],e[r])):Object.assign(i,{[r]:e[r]});return $e(i,...t)}function Ff(i,t){return i.length===t.length&&i.every((e,r)=>t[r]===e)}function I(i,t,e=[],r){let n={},o=Array.from(t);if(hr(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(i,a))||($e(n,{[r]:o[0]}),e.splice(e.indexOf(r),1),o.shift())),o.length===1&&hr(o[0]))$e(n,o[0]);else for(let s=0;s<e.length;s++)rt(o[s])&&(n[e[s]]=o[s]);return $e(i,n)}function Bf(i){return i.constructor.getDefaults()}function je(i,t){return Zt(i)?t:i}function dr(i,t){return t.forEach(e=>{Reflect.has(i,e)&&delete i[e]}),i}var oe=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||fe&&this.toString()===fe.TONE_DEBUG_CLASS)&&Ef(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};oe.version=go;function zr(i,t){return i>t+1e-6}function Oo(i,t){return zr(i,t)||Ae(i,t)}function Fi(i,t){return i+1e-6<t}function Ae(i,t){return Math.abs(i-t)<1e-6}function lh(i,t,e){return Math.max(Math.min(i,e),t)}var Jt=class i extends oe{constructor(){super(),this.name="Timeline",this._timeline=[];let t=I(i.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(Y(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){let e=this._timeline[this.length-1];Y(Oo(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{let e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){let e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){let r=this._search(t,e);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){let r=this._search(t,e);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(t){let e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];let r=this._search(t);return r-1>=0?this._timeline[r-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Ae(this._timeline[e].time,t)){for(let r=e;r>=0&&Ae(this._timeline[r].time,t);r--)e=r;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&Oo(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){let e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){let e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let r=0,n=this._timeline.length,o=n;if(n>0&&this._timeline[n-1][e]<=t)return n-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(Ae(a[e],t)){for(let u=s;u<this._timeline.length;u++){let h=this._timeline[u];if(Ae(h[e],t))s=u;else break}return s}else{if(Fi(a[e],t)&&zr(c[e],t))return s;zr(a[e],t)?o=s:r=s+1}}return-1}_iterate(t,e=0,r=this._timeline.length-1){this._timeline.slice(e,r+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){let r=this._search(t);return r!==-1&&this._iterate(e,0,r),this}forEachAfter(t,e){let r=this._search(t);return this._iterate(e,r+1),this}forEachBetween(t,e,r){let n=this._search(t),o=this._search(e);return n!==-1&&o!==-1?(this._timeline[n].time!==t&&(n+=1),this._timeline[o].time===e&&(o-=1),this._iterate(r,n,o)):n===-1&&this._iterate(r,0,o),this}forEachFrom(t,e){let r=this._search(t);for(;r>=0&&this._timeline[r].time>=t;)r--;return this._iterate(e,r+1),this}forEachAtTime(t,e){let r=this._search(t);if(r!==-1&&Ae(this._timeline[r].time,t)){let n=r;for(let o=r;o>=0&&Ae(this._timeline[o].time,t);o--)n=o;this._iterate(o=>{e(o)},n,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Gf=[];function di(i){Gf.push(i)}function Vf(i){Gf.forEach(t=>t(i))}var qf=[];function pi(i){qf.push(i)}function Wf(i){qf.forEach(t=>t(i))}var mi=class i extends oe{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(n=>{Zt(this._events)&&(this._events={}),this._events.hasOwnProperty(n)||(this._events[n]=[]),this._events[n].push(e)}),this}once(t,e){let r=(...n)=>{e(...n),this.off(t,r)};return this.on(t,r),this}off(t,e){return t.split(/\W+/).forEach(n=>{if(Zt(this._events)&&(this._events={}),this._events.hasOwnProperty(n))if(Zt(e))this._events[n]=[];else{let o=this._events[n];for(let s=o.length-1;s>=0;s--)o[s]===e&&o.splice(s,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){let r=this._events[t].slice(0);for(let n=0,o=r.length;n<o;n++)r[n].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(i.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var On=class extends mi{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var Bi=class i extends On{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Jt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=I(i.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=Df({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new Ca(this.emit.bind(this,"tick"),r.clockSource,r.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Vf(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,r){return this._context.createBuffer(t,e,r)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,r){return this._context.createPeriodicWave(t,e,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return Y(li(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return Y(li(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return Y(li(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){Y(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Y(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Y(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Y(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return jf(this.rawContext,t,e)}addAudioWorkletModule(t){return gt(this,void 0,void 0,function*(){Y(rt(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return gt(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return li(this._context)?this._context.resume():Promise.resolve()}close(){return gt(this,void 0,void 0,function*(){li(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Wf(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{let e=this._context.createBuffer(1,128,this._context.sampleRate),r=e.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=t;let n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants.set(t,n),n}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){let t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:r+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){let r=++this._timeoutIds,n=()=>{let o=this.now();this._timeouts.add({callback:()=>{t(),n()},id:r,time:o+e})};return n(),r}};var _a=class extends On{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,r){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return gt(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};function z(i,t){Gt(t)?t.forEach(e=>z(i,e)):Object.defineProperty(i,t,{enumerable:!0,writable:!1})}function Gi(i,t){Gt(t)?t.forEach(e=>Gi(i,e)):Object.defineProperty(i,t,{writable:!0})}var nt=()=>{};var zt=class i extends oe{constructor(){super(),this.name="ToneAudioBuffer",this.onload=nt;let t=I(i.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,me(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:nt,onload:nt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Xt().sampleRate}set(t){return t instanceof i?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return gt(this,void 0,void 0,function*(){let e=i.load(t).then(r=>{this.set(r),this.onload(this)});i.downloads.push(e);try{yield e}finally{let r=i.downloads.indexOf(e);i.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Gt(t)&&t[0].length>0,r=e?t.length:1,n=e?t[0].length:t.length,o=Xt(),s=o.createBuffer(r,n,o.sampleRate),a=!e&&r===1?[t]:t;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(t){if(he(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let n=0;n<r;n++){let o=this.toArray(n);for(let s=0;s<o.length;s++)e[s]+=o[s]}e=e.map(n=>n/r),this.fromArray(e)}return this}toArray(t){if(he(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let r=0;r<this.numberOfChannels;r++)e[r]=this.getChannelData(r);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){Y(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),n=Math.floor(e*this.sampleRate);Y(r<n,"The start time must be less than the end time");let o=n-r,s=Xt().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,n),a);return new i(s)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new i().fromArray(t)}static fromUrl(t){return gt(this,void 0,void 0,function*(){return yield new i().load(t)})}static load(t){return gt(this,void 0,void 0,function*(){let e=i.baseUrl===""||i.baseUrl.endsWith("/")?i.baseUrl:i.baseUrl+"/",r=yield fetch(e+t);if(!r.ok)throw new Error(`could not load url: ${t}`);let n=yield r.arrayBuffer();return yield Xt().decodeAudioData(n)})}static supportsType(t){let e=t.split("."),r=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return gt(this,void 0,void 0,function*(){for(yield Promise.resolve();i.downloads.length;)yield i.downloads[0]})}};zt.baseUrl="";zt.downloads=[];var pr=class extends Bi{constructor(){super({clockSource:"offline",context:Nn(arguments[0])?arguments[0]:kf(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Nn(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Nn(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return gt(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;let r=Math.floor(this.sampleRate/128);t&&e%r===0&&(yield new Promise(n=>setTimeout(n,1)))}})}render(){return gt(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);let e=yield this._context.startRendering();return new zt(e)})}close(){return Promise.resolve()}};var Uf=new _a,Rn=Uf;function Xt(){return Rn===Uf&&Lf&&dh(new Bi),Rn}function dh(i,t=!1){t&&Rn.dispose(),li(i)?Rn=new Bi(i):Nn(i)?Rn=new pr(i):Rn=i}if(fe&&!fe.TONE_SILENCE_LOGGING){let i="v";go==="dev"&&(i="");let t=` * Tone.js ${i}${go} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function Mn(i){return Math.pow(10,i/20)}function En(i){return 20*(Math.log(i)/Math.LN10)}function Vi(i){return Math.pow(2,i/12)}var va=440;function zf(){return va}function Yf(i){va=i}function mr(i){return Math.round(ph(i))}function ph(i){return 69+12*Math.log2(i/va)}function Ro(i){return va*Math.pow(2,(i-69)/12)}var wa=class i extends oe{constructor(t,e,r){super(),this.defaultUnits="s",this._val=e,this._units=r,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{let r=parseInt(t,10),n=e==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*n:this._beatsToUnits(4/r)*n},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{let e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,r)=>{let n=0;return t&&t!=="0"&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(n+=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(n+=this._beatsToUnits(parseFloat(r)/4)),n},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof i&&this.fromType(this._val),Zt(this._val))return this._noArg();if(me(this._val)&&Zt(this._units)){for(let t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(hr(this._val)){let t=0;for(let e in this._val)if(rt(this._val[e])){let r=this._val[e],n=new this.constructor(this.context,e).valueOf()*r;t+=n}return t}if(rt(this._units)){let t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return me(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var Pe=class i extends wa{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let e=new i(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){let r=new this.constructor(this.context,t).valueOf(),n=this.valueOf(),a=Math.round(n/r)*r-n;return n+a*e}toNotation(){let t=this.toSeconds(),e=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],n=new i(this.context,e[0]).toSeconds();return e.forEach(o=>{let s=new i(this.context,o).toSeconds();Math.abs(s-t)<Math.abs(n-t)&&(r=o,n=s)}),r}toBarsBeatsSixteenths(){let t=this._beatsToUnits(1),e=this.valueOf()/t;e=parseFloat(e.toFixed(4));let r=Math.floor(e/this._getTimeSignature()),n=e%1*4;e=Math.floor(e)%this._getTimeSignature();let o=n.toString();return o.length>3&&(n=parseFloat(parseFloat(o).toFixed(3))),[r,e,n].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return mr(this.toFrequency())}_now(){return this.context.now()}};var Ce=class i extends Pe{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return zf()}static set A4(t){Yf(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:i.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let n=sv[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?n:i.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,r){let n=1;return t&&t!=="0"&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(n*=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(n*=this._beatsToUnits(parseFloat(r)/4)),n}}})}transpose(t){return new i(this.context,this.valueOf()*Vi(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return mr(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/i.A4),r=Math.round(12*e)+57,n=Math.floor(r/12);return n<0&&(r+=-12*n),av[r%12]+n.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return Ro(t)}static ftom(t){return mr(t)}},sv={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},av=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var Ze=class extends Pe{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var te=class i extends oe{constructor(){super();let t=I(i.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Xt()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return Rf(t),new Pe(this.context,t).toSeconds()}toFrequency(t){return new Ce(this.context,t).toFrequency()}toTicks(t){return new Ze(this.context,t).toTicks()}_getPartialProperties(t){let e=this.get();return Object.keys(e).forEach(r=>{Zt(t[r])&&delete e[r]}),e}get(){let t=Bf(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){let r=this[e];rt(r)&&rt(r.value)&&rt(r.setValueAtTime)?t[e]=r.value:r instanceof i?t[e]=r._getPartialProperties(t[e]):Gt(r)||he(r)||me(r)||uh(r)?t[e]=r:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&rt(this[e])&&(this[e]&&rt(this[e].value)&&rt(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof i?this[e].set(t[e]):this[e]=t[e])}),this}};var Mr=class extends Jt{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){let e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,r){return Ut(e,0),this.add(Object.assign({},r,{state:t,time:e})),this}getLastState(t,e){let r=this._search(e);for(let n=r;n>=0;n--){let o=this._timeline[n];if(o.state===t)return o}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let n=r;n<this._timeline.length;n++){let o=this._timeline[n];if(o.state===t)return o}}};var ut=class i extends te{constructor(){let t=I(i.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,Y(rt(t.param)&&(lr(t.param)||t.param instanceof i),"param must be an AudioParam");!lr(t.param);)t.param=t.param._param;this._swappable=rt(t.swappable)?t.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new Jt(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,rt(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(te.getDefaults(),{convert:!0,units:"number"})}get value(){let t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return rt(this._minValue)?this._minValue:this.units==="time"||this.units==="frequency"||this.units==="normalRange"||this.units==="positive"||this.units==="transportTime"||this.units==="ticks"||this.units==="bpm"||this.units==="hertz"||this.units==="samples"?0:this.units==="audioRange"?-1:this.units==="decibels"?-1/0:this._param.minValue}get maxValue(){return rt(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return rt(this.maxValue)&&rt(this.minValue)&&Ut(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?Mn(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?En(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),n=this._fromType(t);return Y(isFinite(n)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this.log(this.units,"setValueAtTime",t,r),this._events.add({time:r,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,r),this}getValueAtTime(t){let e=Math.max(this.toSeconds(t),0),r=this._events.getAfter(e),n=this._events.get(e),o=this._initialValue;if(n===null)o=this._initialValue;else if(n.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(n.time),a;s===null?a=this._initialValue:a=s.value,n.type==="setTargetAtTime"&&(o=this._exponentialApproach(n.time,a,n.value,n.constant,e))}else if(r===null)o=n.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=n.value;if(n.type==="setTargetAtTime"){let a=this._events.getBefore(n.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(n.time,s,r.time,r.value,e):o=this._exponentialInterpolate(n.time,s,r.time,r.value,e)}else o=n.value;return this._toType(o)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){let r=this._fromType(t),n=this.toSeconds(e);return Y(isFinite(r)&&isFinite(n),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this._events.add({time:n,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",t,n),this._param.linearRampToValueAtTime(r,n),this}exponentialRampToValueAtTime(t,e){let r=this._fromType(t);r=Ae(r,0)?this._minOutput:r,this._assertRange(r);let n=this.toSeconds(e);return Y(isFinite(r)&&isFinite(n),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:n,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",t,n),this._param.exponentialRampToValueAtTime(r,n),this}exponentialRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(t,r+this.toSeconds(e)),this}linearRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(t,r+this.toSeconds(e)),this}targetRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(t,r,e),this}exponentialApproachValueAtTime(t,e,r){e=this.toSeconds(e),r=this.toSeconds(r);let n=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(t,e,n),this.cancelAndHoldAtTime(e+r*.9),this.linearRampToValueAtTime(t,e+r),this}setTargetAtTime(t,e,r){let n=this._fromType(t);Y(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(e);return this._assertRange(n),Y(isFinite(n)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:n}),this.log(this.units,"setTargetAtTime",t,o,r),this._param.setTargetAtTime(n,o,r),this}setValueCurveAtTime(t,e,r,n=1){r=this.toSeconds(r),e=this.toSeconds(e);let o=this._fromType(t[0])*n;this.setValueAtTime(this._toType(o),e);let s=r/(t.length-1);for(let a=1;a<t.length;a++){let c=this._fromType(t[a])*n;this.linearRampToValueAtTime(this._toType(c),e+a*s)}return this}cancelScheduledValues(t){let e=this.toSeconds(t);return Y(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){let e=this.toSeconds(t),r=this._fromType(this.getValueAtTime(e));Y(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let n=this._events.get(e),o=this._events.getAfter(e);return n&&Ae(n.time,e)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),e)),this._events.add({time:e,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,e),this}rampTo(t,e=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,r):this.linearRampTo(t,e,r),this}apply(t){let e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);let r=this._events.get(e);if(r&&r.type==="setTargetAtTime"){let n=this._events.getAfter(r.time),o=n?n.time:e+2,s=(o-e)/10;for(let a=e;a<o;a+=s)t.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,n=>{n.type==="cancelScheduledValues"?t.cancelScheduledValues(n.time):n.type==="setTargetAtTime"?t.setTargetAtTime(n.value,n.time,n.constant):t[n.type](n.value,n.time)}),this}setParam(t){Y(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,r,n,o){return r+(e-r)*Math.exp(-(o-t)/n)}_linearInterpolate(t,e,r,n,o){return e+(n-e)*((o-t)/(r-t))}_exponentialInterpolate(t,e,r,n,o){return e*Math.pow(n/e,(o-t)/(r-t))}};var P=class i extends te{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return rt(this.input)?lr(this.input)||this.input instanceof ut?1:this.input.numberOfInputs:0}get numberOfOutputs(){return rt(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return rt(t)&&(t instanceof i||Rr(t))}_getInternalNodes(){let t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(r=>{r.channelCount=t.channelCount,r.channelCountMode=t.channelCountMode,r.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){let t=this._getInternalNodes();Y(t.length>0,"ToneAudioNode does not have any internal nodes");let e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,r=0){return le(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Pi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return Hf(this,t,e,r),this}chain(...t){return Xe(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),rt(this.input)&&(this.input instanceof i?this.input.dispose():Rr(this.input)&&this.input.disconnect()),rt(this.output)&&(this.output instanceof i?this.output.dispose():Rr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Xe(...i){let t=i.shift();i.reduce((e,r)=>(e instanceof P?e.connect(r):Rr(e)&&le(e,r),r),t)}function le(i,t,e=0,r=0){for(Y(rt(i),"Cannot connect from undefined node"),Y(rt(t),"Cannot connect to undefined node"),(t instanceof P||Rr(t))&&Y(t.numberOfInputs>0,"Cannot connect to node with no inputs"),Y(i.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof P||t instanceof ut;)rt(t.input)&&(t=t.input);for(;i instanceof P;)rt(i.output)&&(i=i.output);lr(t)?i.connect(t,e):i.connect(t,e,r)}function Hf(i,t,e=0,r=0){if(rt(t))for(;t instanceof P;)t=t.input;for(;!Rr(i);)rt(i.output)&&(i=i.output);lr(t)?i.disconnect(t,e):Rr(t)?i.disconnect(t,e,r):i.disconnect()}var Z=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new ut({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),z(this,"gain")}static getDefaults(){return Object.assign(P.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}};var fr=class extends P{constructor(t){super(t),this.onended=nt,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Z({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let r=this.toSeconds(e);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(P.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:nt})}_startGain(t,e=1){Y(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=t+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+r):this._gainNode.gain.exponentialApproachValueAtTime(e,t,r)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Y(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==nt&&(this.onended(this),this.onended=nt,!this.context.isOffline)){let t=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Y(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=nt,this}};var Mo=class i extends fr{constructor(){let t=I(i.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),le(this._source,this._gainNode),this.offset=new ut({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(fr.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var et=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new Mo({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(P.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,r=0){return Dn(this,t,e,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,r){return this._param.exponentialRampTo(t,e,r),this}linearRampTo(t,e,r){return this._param.linearRampTo(t,e,r),this}targetRampTo(t,e,r){return this._param.targetRampTo(t,e,r),this}exponentialApproachValueAtTime(t,e,r){return this._param.exponentialApproachValueAtTime(t,e,r),this}setTargetAtTime(t,e,r){return this._param.setTargetAtTime(t,e,r),this}setValueCurveAtTime(t,e,r,n){return this._param.setValueCurveAtTime(t,e,r,n),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,r){return this._param.rampTo(t,e,r),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}};function Dn(i,t,e,r){(t instanceof ut||lr(t)||t instanceof et&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof et&&(t.overridden=!0)),le(i,t,e,r)}var Sa=class i extends ut{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Jt(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(ut.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let n=this._fromType(t),o=this._events.get(e),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+e,u=this._exponentialApproach(o.time,o.value,n,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){let r=this.toSeconds(e);super.setValueAtTime(t,e);let n=this._events.get(r),o=this._events.previousEvent(n),s=this._getTicksUntilEvent(o,r);return n.ticks=Math.max(s,0),this}linearRampToValueAtTime(t,e){let r=this.toSeconds(e);super.linearRampToValueAtTime(t,e);let n=this._events.get(r),o=this._events.previousEvent(n),s=this._getTicksUntilEvent(o,r);return n.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);let r=this._fromType(t),n=this._events.get(e),o=Math.round(Math.max((e-n.time)*10,1)),s=(e-n.time)/o;for(let a=0;a<=o;a++){let c=s*a+n.time,u=this._exponentialInterpolate(n.time,n.value,e,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Zt(t.ticks)){let s=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(s,t.time)}let r=this._fromType(this.getValueAtTime(t.time)),n=this._fromType(this.getValueAtTime(e)),o=this._events.get(e);return o&&o.time===e&&o.type==="setValueAtTime"&&(n=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(r+n)+t.ticks}getTicksAtTime(t){let e=this.toSeconds(t),r=this._events.get(e);return Math.max(this._getTicksUntilEvent(r,e),0)}getDurationOfTicks(t,e){let r=this.toSeconds(e),n=this.getTicksAtTime(e);return this.getTimeOfTick(n+t)-r}getTimeOfTick(t){let e=this._events.get(t,"ticks"),r=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&r&&r.type==="linearRampToValueAtTime"&&e.value!==r.value){let n=this._fromType(this.getValueAtTime(e.time)),s=(this._fromType(this.getValueAtTime(r.time))-n)/(r.time-e.time),a=Math.sqrt(Math.pow(n,2)-2*s*(e.ticks-t)),c=(-n+a)/s,u=(-n-a)/s;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){let r=this.toSeconds(e),n=this.toSeconds(t),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+n)-o}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){let e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}};var Ia=class i extends et{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new Sa({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(et.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}};var Ta=class i extends te{constructor(){let t=I(i.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new Mr,this._tickOffset=new Jt,this._ticksAtTime=new Jt,this._secondsAtTime=new Jt,this.frequency=new Ia({context:this.context,units:t.units,value:t.frequency}),z(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},te.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){let r=this.toSeconds(t);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),rt(e)&&this.setTicksAtTime(e,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(t){let e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){let r=this._state.get(e);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){let e=this.toSeconds(t),r=this._state.getLastState("stopped",e),n=this._ticksAtTime.get(e),o={state:"paused",time:e};this._state.add(o);let s=n||r,a=n?n.ticks:0,c=null;return this._state.forEachBetween(s.time,e+this.sampleTime,u=>{let h=s.time,l=this._tickOffset.get(u.time);l&&l.time>=s.time&&(a=l.ticks,h=l.time),s.state==="started"&&u.state!=="started"&&(a+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(h),u.time!==o.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(o),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){let e=this.now(),r=this.frequency.timeToTicks(t,e);this.setTicksAtTime(r,e)}getSecondsAtTime(t){t=this.toSeconds(t);let e=this._state.getLastState("stopped",t),r={state:"paused",time:t};this._state.add(r);let n=this._secondsAtTime.get(t),o=n||e,s=n?n.seconds:0,a=null;return this._state.forEachBetween(o.time,t+this.sampleTime,c=>{let u=o.time,h=this._tickOffset.get(c.time);h&&h.time>=o.time&&(s=h.seconds,u=h.time),o.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),o=c}),this._state.remove(r),a&&this._secondsAtTime.add(a),s}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){let r=this._tickOffset.get(e),n=this._state.get(e),o=Math.max(r.time,n.time),s=this.frequency.getTicksAtTime(o)+t-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,r){let n=this._state.get(t);this._state.forEachBetween(t,e,s=>{n&&n.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(n.time,t),s.time-this.sampleTime,r),n=s});let o=null;if(n&&n.state==="started"){let s=Math.max(n.time,t),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(n.time),u=a-c,h=Math.ceil(u)-u;h=Ae(h,1)?0:h;let l=this.frequency.getTimeOfTick(a+h);for(;l<e;){try{r(l,Math.round(this.getTicksAtTime(l)))}catch(p){o=p;break}l+=this.frequency.getDurationOfTicks(1,l)}}if(o)throw o;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var kn=class i extends te{constructor(){let t=I(i.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=nt,this._lastUpdate=0,this._state=new Mr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Ta({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,z(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(te.getDefaults(),{callback:nt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){Aa(this.context);let r=this.toSeconds(t);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,e),r<this._lastUpdate&&this.emit("start",r,e)),this}stop(t){let e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){let r=this.toSeconds(e),n=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(n+t,r)}_loop(){let t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,r=>{switch(r.state){case"started":let n=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,n);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(t,e,(r,n)=>{this.callback(r,n)}))}getStateAtTime(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};mi.mixin(kn);var Qe=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new Z({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,z(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var mh=class i extends P{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Qe({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Xe(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),Xe(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};di(i=>{i.destination=new mh({context:i})});pi(i=>{i.destination.dispose()});var fh=class extends P{constructor(){super(...arguments),this.name="Listener",this.positionX=new ut({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ut({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ut({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ut({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ut({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ut({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ut({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ut({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ut({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(P.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}};di(i=>{i.listener=new fh({context:i})});pi(i=>{i.listener.dispose()});var Ln=class i extends oe{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=I(i.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let r=t.urls[e];this.add(e,r,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:nt,onload:nt,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Y(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,r=nt,n=nt){return me(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new zt(this.baseUrl+e,r,n))):this._buffers.set(t.toString(),new zt(e,r,n)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var Eo=class i extends Ce{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return mr(super._frequencyToUnits(t))}_ticksToUnits(t){return mr(super._ticksToUnits(t))}_beatsToUnits(t){return mr(super._beatsToUnits(t))}_secondsToUnits(t){return mr(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return Ro(this.toMidi())}transpose(t){return new i(this.context,this.toMidi()+t)}};var Fe=class extends Ze{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var gh=class extends te{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Jt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){let t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};di(i=>{i.draw=new gh({context:i})});pi(i=>{i.draw.dispose()});var Na=class extends oe{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Y(rt(t.time),"Events must have a time property"),Y(rt(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new yh(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){let e=[];this._root.search(t.time,e);for(let r of e)if(r.event===t){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{let e=t.getBalance(),r,n=null;if(e>0)if(t.left.right===null)r=t.left,r.right=t.right,n=r;else{for(r=t.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,n=r.parent,r.left=t.left,r.right=t.right)}else if(t.right.left===null)r=t.right,r.left=t.left,n=r;else{for(r=t.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,n=r.parent,r.left=t.left,r.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=r:t.parent.right=r:this._setRoot(r),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){let e=t.parent,r=t.isLeftChild(),n=t.right;n&&(t.right=n.left,n.left=t),e!==null?r?e.left=n:e.right=n:this._setRoot(n)}_rotateRight(t){let e=t.parent,r=t.isLeftChild(),n=t.left;n&&(t.left=n.right,n.right=t),e!==null?r?e.left=n:e.right=n:this._setRoot(n)}_rebalance(t){let e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){let e=[];if(this._root.search(t,e),e.length>0){let r=e[0];for(let n=1;n<e.length;n++)e[n].low>r.low&&(r=e[n]);return r.event}}return null}forEach(t){if(this._root!==null){let e=[];this._root.traverse(r=>e.push(r)),e.forEach(r=>{r.event&&t(r.event)})}return this}forEachAtTime(t,e){if(this._root!==null){let r=[];this._root.search(t,r),r.forEach(n=>{n.event&&e(n.event)})}return this}forEachFrom(t,e){if(this._root!==null){let r=[];this._root.searchAfter(t,r),r.forEach(n=>{n.event&&e(n.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}},yh=class{constructor(t,e,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var Oa=class extends oe{constructor(t){super(),this.name="TimelineValue",this._timeline=new Jt({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){let e=this._timeline.get(t);return e?e.value:this._initialValue}};var ye=class i extends P{constructor(){super(I(i.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return Dn(this,t,e,r),this}};var Te=class i extends ye{constructor(){let t=I(i.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Gt(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Tf(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(et.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let n=0,o=e;n<o;n++){let s=n/(o-1)*2-1;r[n]=t(s,n)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){let e=["none","2x","4x"].some(r=>r.includes(t));Y(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var jn=class i extends ye{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new Te({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ye.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var Yr=class i{constructor(t,e){this.id=i._eventId++,this._remainderTime=0;let r=Object.assign(i.getDefaults(),e);this.transport=t,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:nt,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){let e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};Yr._eventId=0;var Ra=class i extends Yr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(i.getDefaults(),e);this.duration=r.duration,this._interval=r.interval,this._nextTick=r.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Yr.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return Fi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Fe(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){Fi(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Fe(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let e=this.transport.getTicksAtTime(t);zr(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}};var Ma=class i extends te{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Oa(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Jt,this._repeatedEvents=new Na,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new kn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),z(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(te.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){let r=e%(this._swingTicks*2)/(this._swingTicks*2),n=Math.sin(r*Math.PI)*this._swingAmount;t+=new Fe(this.context,this._swingTicks*2/3).toSeconds()*n}hh(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),hh(!1)}schedule(t,e){let r=new Yr(this,{callback:t,time:new Ze(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,n=1/0){let o=new Ra(this,{callback:t,duration:new Pe(this.context,n).toTicks(),interval:new Pe(this.context,e).toTicks(),time:new Ze(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(t,e){let r=new Yr(this,{callback:t,once:!0,time:new Ze(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){let e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){let e=this.toTicks(t);return this._timeline.forEachFrom(e,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(e,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new Fe(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let r;return rt(e)&&(r=this.toTicks(e)),this._clock.start(t,r),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Gt(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Pe(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Pe(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Fe(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){let t=this.now(),e=this._clock.getTicksAtTime(t);return new Fe(this.context,e).toBarsBeatsSixteenths()}set position(t){let e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){let e=this.now(),r=this._clock.frequency.timeToTicks(t,e);this.ticks=r}get progress(){if(this.loop){let t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){let e=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(e),n=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,e),o=e+n;this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{let e=this.now(),r=this.getTicksAtTime(e),n=t-r%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){let r=this.now(),n=this.bpm,o=1/(60/n.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/o,u=new Z(c),h=new jn(-1),l=new Z(c);n.chain(u,h,l),n=l,o=1/o,s=[u,h,l]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/o:e=0);let a=new Z(e);return n.connect(a),a.connect(t._param),s.push(a),this._syncedSignals.push({initial:t.value,nodes:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){let r=this._syncedSignals[e];r.signal===t&&(r.nodes.forEach(n=>n.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Gi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};mi.mixin(Ma);di(i=>{i.transport=new Ma({context:i})});pi(i=>{i.transport.dispose()});var wt=class extends P{constructor(t){super(t),this.input=void 0,this._state=new Mr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=nt,this._syncedStop=nt,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Qe({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,z(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,onstop:nt,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,r){let n=Zt(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(n=this._clampToCurrentTime(n),!this._synced&&this._state.getValueAtTime(n)==="started")Y(zr(n,this._state.get(n).time),"Start time must be strictly greater than previous start time"),this._state.cancel(n),this._state.setStateAtTime("started",n),this.log("restart",n),this.restart(n,e,r);else if(this.log("start",n),this._state.setStateAtTime("started",n),this._synced){let o=this._state.get(n);o&&(o.offset=this.toSeconds(je(e,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,e,r)},n);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>n&&this._syncedStart(this.now(),this.context.transport.seconds)}else Aa(this.context),this._start(n,e,r);return this}stop(t){let e=Zt(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||rt(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{let r=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(r)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,r){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(zr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let n=e-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-n),this._start(t,this.toSeconds(r.offset)+n,o)}}},this._syncedStop=t=>{let e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=nt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var Er=class i extends fr{constructor(){let t=I(i.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,le(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ut({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new zt(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(fr.getDefaults(),{url:new zt,loop:!1,loopEnd:0,loopStart:0,onload:nt,onerror:nt,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,r,n=1){Y(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(t);this._startGain(o,n),this.loop?e=je(e,this.loopStart):e=je(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;Oo(s,a)&&(s=(s-c)%u+c),Ae(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Fi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),rt(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var qi=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(wt.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Y(t in $f,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,this.state==="started")){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){let e=$f[this._type];this._source=new Er({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},Pn=44100*5,bh=2,Hr={brown:null,pink:null,white:null},$f={get brown(){if(!Hr.brown){let i=[];for(let t=0;t<bh;t++){let e=new Float32Array(Pn);i[t]=e;let r=0;for(let n=0;n<Pn;n++){let o=Math.random()*2-1;e[n]=(r+.02*o)/1.02,r=e[n],e[n]*=3.5}}Hr.brown=new zt().fromArray(i)}return Hr.brown},get pink(){if(!Hr.pink){let i=[];for(let t=0;t<bh;t++){let e=new Float32Array(Pn);i[t]=e;let r,n,o,s,a,c,u;r=n=o=s=a=c=u=0;for(let h=0;h<Pn;h++){let l=Math.random()*2-1;r=.99886*r+l*.0555179,n=.99332*n+l*.0750759,o=.969*o+l*.153852,s=.8665*s+l*.3104856,a=.55*a+l*.5329522,c=-.7616*c-l*.016898,e[h]=r+n+o+s+a+c+u+l*.5362,e[h]*=.11,u=l*.115926}}Hr.pink=new zt().fromArray(i)}return Hr.pink},get white(){if(!Hr.white){let i=[];for(let t=0;t<bh;t++){let e=new Float32Array(Pn);i[t]=e;for(let r=0;r<Pn;r++)e[r]=Math.random()*2-1}Hr.white=new zt().fromArray(i)}return Hr.white}};function Ne(i,t){return gt(this,void 0,void 0,function*(){let e=t/i.context.sampleRate,r=new pr(1,e,i.context.sampleRate);return new i.constructor(Object.assign(i.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var Do=class i extends fr{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],le(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new ut({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new ut({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),z(this,["frequency","detune"])}static getDefaults(){return Object.assign(fr.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Vt=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),z(this,"frequency"),this.detune=new et({context:this.context,units:"cents",value:t.detune}),z(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!=="custom"&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(wt.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){let e=this.toSeconds(t),r=new Do({context:this.context,onended:()=>this.onstop(this)});this._oscillator=r,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){let e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){let e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return i._periodicWaveCache.find(e=>e.phase===this._phase&&Ff(e.partials,this._partials));{let t=i._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;let e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let r=this._getCachedPeriodicWave();if(rt(r)){let{partials:n,wave:o}=r;this._wave=o,this._partials=n,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[n,o]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(n,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),i._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:n,type:this._type,wave:this._wave}),i._periodicWaveCache.length>100&&i._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){Ut(t,0);let e=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(e=r[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{let n=new Float32Array(t);this._partials.forEach((o,s)=>n[s]=o),this._partials=Array.from(n),this.type=this._type}}_getRealImaginary(t,e){let n=2048,o=new Float32Array(n),s=new Float32Array(n),a=1;if(t==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,n=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=c[1],a=Math.max(a,2),n=a):this._partialCount=0,this._partials=[]}for(let c=1;c<n;++c){let u=2/(c*Math.PI),h;switch(t){case"sine":h=c<=a?1:0,this._partials[c-1]=h;break;case"square":h=c&1?2*u:0,this._partials[c-1]=h;break;case"sawtooth":h=u*(c&1?1:-1),this._partials[c-1]=h;break;case"triangle":c&1?h=2*(u*u)*(c-1>>1&1?-1:1):h=0,this._partials[c-1]=h;break;case"custom":h=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}h!==0?(o[c]=-h*Math.sin(e*c),s[c]=h*Math.cos(e*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(t,e,r){let n=0,o=t.length;for(let s=0;s<o;s++)n+=t[s]*Math.cos(s*r)+e[s]*Math.sin(s*r);return n}getInitialValue(){let[t,e]=this._getRealImaginary(this._type,0),r=0,n=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(t,e,s/o*n),r);return lh(-this._inverseFFT(t,e,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Vt._periodicWaveCache=[];var Fn=class extends ye{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Te({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var ee=class i extends et{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Z({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(et.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var ko=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new Fn({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Vt({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Vt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new ee({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),z(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Vt.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}};var Bn=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Vt({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Vt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new ee({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new ee({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),z(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Vt.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var Wi=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new Te({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new et({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Vt({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),z(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(wt.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var Lo=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,z(this,["frequency","detune"])}static getDefaults(){return Object.assign(Vt.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){let e=-t/2,r=t/(this._oscillators.length-1);this._forEach((n,o)=>n.detune.value=e+r*o)}}get count(){return this._oscillators.length}set count(t){if(Ut(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Vt({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):nt});this.type==="custom"&&(r.partials=this._partials),this.frequency.connect(r.frequency),this.detune.connect(r.detune),r.detune.overridden=!1,r.connect(this.output),this._oscillators[e]=r}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,r)=>e.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var jo=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new ee({context:this.context,value:2}),this._pulse=new Wi({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Vt({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),z(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(wt.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var Zf={am:ko,fat:Lo,fm:Bn,oscillator:Vt,pulse:Wi,pwm:jo},Ui=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),z(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Vt.getDefaults(),Bn.getDefaults(),ko.getDefaults(),Lo.getDefaults(),Wi.getDefaults(),jo.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;let e=Zf[t],r=this.now();if(this._oscillator){let n=this._oscillator;n.stop(r),this.context.setTimeout(()=>n.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(r)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof Zf[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(t){this._getOscType(this._oscillator,"fat")&&he(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&he(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&me(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return gt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function Da(i,t=1/0){let e=new WeakMap;return function(r,n){Reflect.defineProperty(r,n,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Ut(o,i,t),e.set(this,o)}})}}function Oe(i,t=1/0){let e=new WeakMap;return function(r,n){Reflect.defineProperty(r,n,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Ut(this.toSeconds(o),i,t),e.set(this,o)}})}}var Po=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new zt({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(wt.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:nt,onerror:nt,playbackRate:1,reverse:!1})}load(t){return gt(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=nt){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,r){return super.start(t,e,r),this}_start(t,e,r){this._loop?e=je(e,this._loopStart):e=je(e,0);let n=this.toSeconds(e),o=r;r=je(r,Math.max(this._buffer.duration-n,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new Er({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Zt(o)?a.start(t,n):a.start(t,n,s-this.toSeconds(this.fadeOut))}_stop(t){let e=this.toSeconds(t);this._activeSources.forEach(r=>r.stop(e))}restart(t,e,r){return super.restart(t,e,r),this}_restart(t,e,r){var n;(n=[...this._activeSources].pop())===null||n===void 0||n.stop(t),this._start(t,e,r)}seek(t,e){let r=this.toSeconds(e);if(this._state.getValueAtTime(r)==="started"){let n=this.toSeconds(t);this._stop(r),this._start(r,n)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Ut(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&Ut(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){let e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;let e=this.now(),r=this._state.getNextState("stopped",e);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(n=>n.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};ge([Oe(0)],Po.prototype,"fadeIn",void 0);ge([Oe(0)],Po.prototype,"fadeOut",void 0);var ka=class extends ye{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Te({context:this.context,mapping:t=>Math.abs(t)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var _e=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new et({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(P.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(me(t))return t;{let r;for(r in La)if(La[r][e]===t)return r;return t}}_setCurve(t,e,r){if(me(r)&&Reflect.has(La,r)){let n=La[r];hr(n)?t!=="_decayCurve"&&(this[t]=n[e]):this[t]=n}else if(Gt(r)&&t!=="_decayCurve")this[t]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let n=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(t);if(s>0){let a=1/n;n=(1-s)/a}if(n<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,n,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,n,t);else{this._sig.cancelAndHoldAtTime(t);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=s&&s<=a[c]){a=this._attackCurve.slice(c),a[0]=s;break}this._sig.setValueCurveAtTime(a,t,n,e)}if(o&&this.sustain<1){let a=e*this.sustain,c=t+n;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);let e=this.getValueAtTime(t);if(e>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,t):(Y(Gt(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,r,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,r=1){return e=this.toSeconds(e),this.triggerAttack(e,r),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,r=0){return Dn(this,t,e,r),this}asArray(){return gt(this,arguments,void 0,function*(t=1024){let e=t/this.context.sampleRate,r=new pr(1,e,this.context.sampleRate),n=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=n+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(e*(n+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};ge([Oe(0)],_e.prototype,"attack",void 0);ge([Oe(0)],_e.prototype,"decay",void 0);ge([Da(0,1)],_e.prototype,"sustain",void 0);ge([Oe(0)],_e.prototype,"release",void 0);var La=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let n=[],o=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*o-Math.PI/2)+1;n[t]=p/10+e*.83}n[127]=1;let s=[],a=5;for(t=0;t<128;t++)s[t]=Math.ceil(t/127*a)/a;let c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));let u=[];for(t=0;t<128;t++){e=t/127;let p=Math.pow(e,3)*4+.2,m=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(m*(1-e))}function h(p){let m=new Array(p.length);for(let f=0;f<p.length;f++)m[f]=1-p[f];return m}function l(p){return p.slice(0).reverse()}return{bounce:{In:h(u),Out:u},cosine:{In:r,Out:l(r)},exponential:"exponential",linear:"linear",ripple:{In:n,Out:h(n)},sine:{In:c,Out:h(c)},step:{In:s,Out:h(s)}}})();var Be=class i extends P{constructor(){let t=I(i.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new Qe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,z(this,"volume")}static getDefaults(){return Object.assign(P.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){let r=this["_original_"+t]=this[t];this[t]=(...n)=>{let o=n[e],s=this.context.transport.schedule(a=>{n[e]=a,r.apply(this,n)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,r,n){let o=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,o,n),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var Re=class i extends Be{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,onsilence:nt,portamento:0})}triggerAttack(t,e,r=1){this.log("triggerAttack",t,e,r);let n=this.toSeconds(e);return this._triggerEnvelopeAttack(n,r),this.setNote(t,n),this}triggerRelease(t){this.log("triggerRelease",t);let e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){let r=this.toSeconds(e),n=t instanceof Ce?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(n,o,r)}else this.frequency.setValueAtTime(n,r);return this}};ge([Oe(0)],Re.prototype,"portamento",void 0);var Gn=class i extends _e{constructor(){super(I(i.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Z({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}};var Dr=class i extends Re{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new Ui(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Gn(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),z(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Re.getDefaults(),{envelope:Object.assign(dr(_e.getDefaults(),Object.keys(P.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(dr(Ui.getDefaults(),[...Object.keys(wt.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+r+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var Fo=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ut({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new ut({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new ut({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new ut({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(P.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Y(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){let e=new Float32Array(t);for(let s=0;s<t;s++){let c=Math.pow(s/t,2)*19980+20;e[s]=c}let r=new Float32Array(t),n=new Float32Array(t),o=this.context.createBiquadFilter();return o.type=this.type,o.Q.value=this.Q.value,o.frequency.value=this.frequency.value,o.gain.value=this.gain.value,o.getFrequencyResponse(e,r,n),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var $r=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new et({context:this.context,units:"positive",value:t.Q}),this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),this.gain=new et({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,z(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(P.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Y(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._type=t,this._filters.forEach(r=>r.type=t)}get rolloff(){return this._rolloff}set rolloff(t){let e=he(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],n=r.indexOf(e);Y(n!==-1,`rolloff can only be ${r.join(", ")}`),n+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(n);for(let o=0;o<n;o++){let s=new Fo({context:this.context});s.type=this._type,this.frequency.connect(s.frequency),this.detune.connect(s.detune),this.Q.connect(s.Q),this.gain.connect(s.gain),this._filters[o]=s}this._internalChannels=this._filters,Xe(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new Fo({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),r=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((o,s)=>r[s]*=o)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),Gi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var ja=class i extends Dr{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,z(this,["oscillator","envelope"])}static getDefaults(){return $e(Re.getDefaults(),Dr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){let r=this.toSeconds(e),n=this.toFrequency(t instanceof Ce?t.toFrequency():t),o=n*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(n,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};ge([Da(0)],ja.prototype,"octaves",void 0);ge([Oe(0)],ja.prototype,"pitchDecay",void 0);var Xf=new Set;function qn(i){Xf.add(i)}function Pa(i,t){let e=`registerProcessor("${i}", ${t})`;Xf.add(e)}var hv=`
99
+ `],{type:"text/javascript"}),e=URL.createObjectURL(t),r=new Worker(e);r.onmessage=this._callback.bind(this),this._worker=r}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}};function lr(i){return Sf(i)}function Rr(i){return wf(i)}function Nn(i){return If(i)}function li(i){return vf(i)}function Pf(i){return i instanceof nh}function ov(i,t){return i==="value"||lr(t)||Rr(t)||Pf(t)}function He(i,...t){if(!t.length)return i;let e=t.shift();if(hr(i)&&hr(e))for(let r in e)ov(r,e[r])?i[r]=e[r]:hr(e[r])?(i[r]||Object.assign(i,{[r]:{}}),He(i[r],e[r])):Object.assign(i,{[r]:e[r]});return He(i,...t)}function Ff(i,t){return i.length===t.length&&i.every((e,r)=>t[r]===e)}function I(i,t,e=[],r){let n={},o=Array.from(t);if(hr(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(i,a))||(He(n,{[r]:o[0]}),e.splice(e.indexOf(r),1),o.shift())),o.length===1&&hr(o[0]))He(n,o[0]);else for(let s=0;s<e.length;s++)rt(o[s])&&(n[e[s]]=o[s]);return He(i,n)}function Bf(i){return i.constructor.getDefaults()}function je(i,t){return Zt(i)?t:i}function dr(i,t){return t.forEach(e=>{Reflect.has(i,e)&&delete i[e]}),i}var oe=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||fe&&this.toString()===fe.TONE_DEBUG_CLASS)&&Ef(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};oe.version=go;function zr(i,t){return i>t+1e-6}function Oo(i,t){return zr(i,t)||Ae(i,t)}function Fi(i,t){return i+1e-6<t}function Ae(i,t){return Math.abs(i-t)<1e-6}function lh(i,t,e){return Math.max(Math.min(i,e),t)}var Jt=class i extends oe{constructor(){super(),this.name="Timeline",this._timeline=[];let t=I(i.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(Y(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){let e=this._timeline[this.length-1];Y(Oo(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{let e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){let e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){let r=this._search(t,e);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){let r=this._search(t,e);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(t){let e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];let r=this._search(t);return r-1>=0?this._timeline[r-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Ae(this._timeline[e].time,t)){for(let r=e;r>=0&&Ae(this._timeline[r].time,t);r--)e=r;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&Oo(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){let e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){let e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let r=0,n=this._timeline.length,o=n;if(n>0&&this._timeline[n-1][e]<=t)return n-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(Ae(a[e],t)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(Ae(l[e],t))s=u;else break}return s}else{if(Fi(a[e],t)&&zr(c[e],t))return s;zr(a[e],t)?o=s:r=s+1}}return-1}_iterate(t,e=0,r=this._timeline.length-1){this._timeline.slice(e,r+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){let r=this._search(t);return r!==-1&&this._iterate(e,0,r),this}forEachAfter(t,e){let r=this._search(t);return this._iterate(e,r+1),this}forEachBetween(t,e,r){let n=this._search(t),o=this._search(e);return n!==-1&&o!==-1?(this._timeline[n].time!==t&&(n+=1),this._timeline[o].time===e&&(o-=1),this._iterate(r,n,o)):n===-1&&this._iterate(r,0,o),this}forEachFrom(t,e){let r=this._search(t);for(;r>=0&&this._timeline[r].time>=t;)r--;return this._iterate(e,r+1),this}forEachAtTime(t,e){let r=this._search(t);if(r!==-1&&Ae(this._timeline[r].time,t)){let n=r;for(let o=r;o>=0&&Ae(this._timeline[o].time,t);o--)n=o;this._iterate(o=>{e(o)},n,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Gf=[];function di(i){Gf.push(i)}function Vf(i){Gf.forEach(t=>t(i))}var qf=[];function pi(i){qf.push(i)}function Wf(i){qf.forEach(t=>t(i))}var mi=class i extends oe{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(n=>{Zt(this._events)&&(this._events={}),this._events.hasOwnProperty(n)||(this._events[n]=[]),this._events[n].push(e)}),this}once(t,e){let r=(...n)=>{e(...n),this.off(t,r)};return this.on(t,r),this}off(t,e){return t.split(/\W+/).forEach(n=>{if(Zt(this._events)&&(this._events={}),this._events.hasOwnProperty(n))if(Zt(e))this._events[n]=[];else{let o=this._events[n];for(let s=o.length-1;s>=0;s--)o[s]===e&&o.splice(s,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){let r=this._events[t].slice(0);for(let n=0,o=r.length;n<o;n++)r[n].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(i.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var On=class extends mi{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var Bi=class i extends On{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Jt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=I(i.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=Df({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new Ca(this.emit.bind(this,"tick"),r.clockSource,r.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Vf(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,r){return this._context.createBuffer(t,e,r)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,r){return this._context.createPeriodicWave(t,e,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return Y(li(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return Y(li(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return Y(li(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){Y(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Y(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Y(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Y(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return jf(this.rawContext,t,e)}addAudioWorkletModule(t){return yt(this,void 0,void 0,function*(){Y(rt(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return yt(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return li(this._context)?this._context.resume():Promise.resolve()}close(){return yt(this,void 0,void 0,function*(){li(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Wf(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{let e=this._context.createBuffer(1,128,this._context.sampleRate),r=e.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=t;let n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants.set(t,n),n}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){let t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:r+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){let r=++this._timeoutIds,n=()=>{let o=this.now();this._timeouts.add({callback:()=>{t(),n()},id:r,time:o+e})};return n(),r}};var _a=class extends On{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,r){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return yt(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};function z(i,t){Gt(t)?t.forEach(e=>z(i,e)):Object.defineProperty(i,t,{enumerable:!0,writable:!1})}function Gi(i,t){Gt(t)?t.forEach(e=>Gi(i,e)):Object.defineProperty(i,t,{writable:!0})}var nt=()=>{};var zt=class i extends oe{constructor(){super(),this.name="ToneAudioBuffer",this.onload=nt;let t=I(i.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,me(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:nt,onload:nt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Xt().sampleRate}set(t){return t instanceof i?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return yt(this,void 0,void 0,function*(){let e=i.load(t).then(r=>{this.set(r),this.onload(this)});i.downloads.push(e);try{yield e}finally{let r=i.downloads.indexOf(e);i.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Gt(t)&&t[0].length>0,r=e?t.length:1,n=e?t[0].length:t.length,o=Xt(),s=o.createBuffer(r,n,o.sampleRate),a=!e&&r===1?[t]:t;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(t){if(he(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let n=0;n<r;n++){let o=this.toArray(n);for(let s=0;s<o.length;s++)e[s]+=o[s]}e=e.map(n=>n/r),this.fromArray(e)}return this}toArray(t){if(he(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let r=0;r<this.numberOfChannels;r++)e[r]=this.getChannelData(r);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){Y(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),n=Math.floor(e*this.sampleRate);Y(r<n,"The start time must be less than the end time");let o=n-r,s=Xt().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,n),a);return new i(s)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new i().fromArray(t)}static fromUrl(t){return yt(this,void 0,void 0,function*(){return yield new i().load(t)})}static load(t){return yt(this,void 0,void 0,function*(){let e=i.baseUrl===""||i.baseUrl.endsWith("/")?i.baseUrl:i.baseUrl+"/",r=yield fetch(e+t);if(!r.ok)throw new Error(`could not load url: ${t}`);let n=yield r.arrayBuffer();return yield Xt().decodeAudioData(n)})}static supportsType(t){let e=t.split("."),r=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return yt(this,void 0,void 0,function*(){for(yield Promise.resolve();i.downloads.length;)yield i.downloads[0]})}};zt.baseUrl="";zt.downloads=[];var pr=class extends Bi{constructor(){super({clockSource:"offline",context:Nn(arguments[0])?arguments[0]:kf(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Nn(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Nn(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return yt(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;let r=Math.floor(this.sampleRate/128);t&&e%r===0&&(yield new Promise(n=>setTimeout(n,1)))}})}render(){return yt(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);let e=yield this._context.startRendering();return new zt(e)})}close(){return Promise.resolve()}};var Uf=new _a,Rn=Uf;function Xt(){return Rn===Uf&&Lf&&dh(new Bi),Rn}function dh(i,t=!1){t&&Rn.dispose(),li(i)?Rn=new Bi(i):Nn(i)?Rn=new pr(i):Rn=i}if(fe&&!fe.TONE_SILENCE_LOGGING){let i="v";go==="dev"&&(i="");let t=` * Tone.js ${i}${go} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function Mn(i){return Math.pow(10,i/20)}function En(i){return 20*(Math.log(i)/Math.LN10)}function Vi(i){return Math.pow(2,i/12)}var va=440;function zf(){return va}function Yf(i){va=i}function mr(i){return Math.round(ph(i))}function ph(i){return 69+12*Math.log2(i/va)}function Ro(i){return va*Math.pow(2,(i-69)/12)}var wa=class i extends oe{constructor(t,e,r){super(),this.defaultUnits="s",this._val=e,this._units=r,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{let r=parseInt(t,10),n=e==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*n:this._beatsToUnits(4/r)*n},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{let e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,r)=>{let n=0;return t&&t!=="0"&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(n+=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(n+=this._beatsToUnits(parseFloat(r)/4)),n},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof i&&this.fromType(this._val),Zt(this._val))return this._noArg();if(me(this._val)&&Zt(this._units)){for(let t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(hr(this._val)){let t=0;for(let e in this._val)if(rt(this._val[e])){let r=this._val[e],n=new this.constructor(this.context,e).valueOf()*r;t+=n}return t}if(rt(this._units)){let t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return me(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var Pe=class i extends wa{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let e=new i(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){let r=new this.constructor(this.context,t).valueOf(),n=this.valueOf(),a=Math.round(n/r)*r-n;return n+a*e}toNotation(){let t=this.toSeconds(),e=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],n=new i(this.context,e[0]).toSeconds();return e.forEach(o=>{let s=new i(this.context,o).toSeconds();Math.abs(s-t)<Math.abs(n-t)&&(r=o,n=s)}),r}toBarsBeatsSixteenths(){let t=this._beatsToUnits(1),e=this.valueOf()/t;e=parseFloat(e.toFixed(4));let r=Math.floor(e/this._getTimeSignature()),n=e%1*4;e=Math.floor(e)%this._getTimeSignature();let o=n.toString();return o.length>3&&(n=parseFloat(parseFloat(o).toFixed(3))),[r,e,n].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return mr(this.toFrequency())}_now(){return this.context.now()}};var Ce=class i extends Pe{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return zf()}static set A4(t){Yf(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:i.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let n=sv[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?n:i.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,r){let n=1;return t&&t!=="0"&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(n*=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(n*=this._beatsToUnits(parseFloat(r)/4)),n}}})}transpose(t){return new i(this.context,this.valueOf()*Vi(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return mr(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/i.A4),r=Math.round(12*e)+57,n=Math.floor(r/12);return n<0&&(r+=-12*n),av[r%12]+n.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return Ro(t)}static ftom(t){return mr(t)}},sv={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},av=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var $e=class extends Pe{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var te=class i extends oe{constructor(){super();let t=I(i.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Xt()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return Rf(t),new Pe(this.context,t).toSeconds()}toFrequency(t){return new Ce(this.context,t).toFrequency()}toTicks(t){return new $e(this.context,t).toTicks()}_getPartialProperties(t){let e=this.get();return Object.keys(e).forEach(r=>{Zt(t[r])&&delete e[r]}),e}get(){let t=Bf(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){let r=this[e];rt(r)&&rt(r.value)&&rt(r.setValueAtTime)?t[e]=r.value:r instanceof i?t[e]=r._getPartialProperties(t[e]):Gt(r)||he(r)||me(r)||uh(r)?t[e]=r:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&rt(this[e])&&(this[e]&&rt(this[e].value)&&rt(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof i?this[e].set(t[e]):this[e]=t[e])}),this}};var Mr=class extends Jt{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){let e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,r){return Ut(e,0),this.add(Object.assign({},r,{state:t,time:e})),this}getLastState(t,e){let r=this._search(e);for(let n=r;n>=0;n--){let o=this._timeline[n];if(o.state===t)return o}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let n=r;n<this._timeline.length;n++){let o=this._timeline[n];if(o.state===t)return o}}};var ut=class i extends te{constructor(){let t=I(i.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,Y(rt(t.param)&&(lr(t.param)||t.param instanceof i),"param must be an AudioParam");!lr(t.param);)t.param=t.param._param;this._swappable=rt(t.swappable)?t.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new Jt(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,rt(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(te.getDefaults(),{convert:!0,units:"number"})}get value(){let t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return rt(this._minValue)?this._minValue:this.units==="time"||this.units==="frequency"||this.units==="normalRange"||this.units==="positive"||this.units==="transportTime"||this.units==="ticks"||this.units==="bpm"||this.units==="hertz"||this.units==="samples"?0:this.units==="audioRange"?-1:this.units==="decibels"?-1/0:this._param.minValue}get maxValue(){return rt(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return rt(this.maxValue)&&rt(this.minValue)&&Ut(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?Mn(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?En(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),n=this._fromType(t);return Y(isFinite(n)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this.log(this.units,"setValueAtTime",t,r),this._events.add({time:r,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,r),this}getValueAtTime(t){let e=Math.max(this.toSeconds(t),0),r=this._events.getAfter(e),n=this._events.get(e),o=this._initialValue;if(n===null)o=this._initialValue;else if(n.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(n.time),a;s===null?a=this._initialValue:a=s.value,n.type==="setTargetAtTime"&&(o=this._exponentialApproach(n.time,a,n.value,n.constant,e))}else if(r===null)o=n.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=n.value;if(n.type==="setTargetAtTime"){let a=this._events.getBefore(n.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(n.time,s,r.time,r.value,e):o=this._exponentialInterpolate(n.time,s,r.time,r.value,e)}else o=n.value;return this._toType(o)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){let r=this._fromType(t),n=this.toSeconds(e);return Y(isFinite(r)&&isFinite(n),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this._events.add({time:n,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",t,n),this._param.linearRampToValueAtTime(r,n),this}exponentialRampToValueAtTime(t,e){let r=this._fromType(t);r=Ae(r,0)?this._minOutput:r,this._assertRange(r);let n=this.toSeconds(e);return Y(isFinite(r)&&isFinite(n),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:n,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",t,n),this._param.exponentialRampToValueAtTime(r,n),this}exponentialRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(t,r+this.toSeconds(e)),this}linearRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(t,r+this.toSeconds(e)),this}targetRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(t,r,e),this}exponentialApproachValueAtTime(t,e,r){e=this.toSeconds(e),r=this.toSeconds(r);let n=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(t,e,n),this.cancelAndHoldAtTime(e+r*.9),this.linearRampToValueAtTime(t,e+r),this}setTargetAtTime(t,e,r){let n=this._fromType(t);Y(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(e);return this._assertRange(n),Y(isFinite(n)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:n}),this.log(this.units,"setTargetAtTime",t,o,r),this._param.setTargetAtTime(n,o,r),this}setValueCurveAtTime(t,e,r,n=1){r=this.toSeconds(r),e=this.toSeconds(e);let o=this._fromType(t[0])*n;this.setValueAtTime(this._toType(o),e);let s=r/(t.length-1);for(let a=1;a<t.length;a++){let c=this._fromType(t[a])*n;this.linearRampToValueAtTime(this._toType(c),e+a*s)}return this}cancelScheduledValues(t){let e=this.toSeconds(t);return Y(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){let e=this.toSeconds(t),r=this._fromType(this.getValueAtTime(e));Y(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let n=this._events.get(e),o=this._events.getAfter(e);return n&&Ae(n.time,e)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),e)),this._events.add({time:e,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,e),this}rampTo(t,e=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,r):this.linearRampTo(t,e,r),this}apply(t){let e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);let r=this._events.get(e);if(r&&r.type==="setTargetAtTime"){let n=this._events.getAfter(r.time),o=n?n.time:e+2,s=(o-e)/10;for(let a=e;a<o;a+=s)t.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,n=>{n.type==="cancelScheduledValues"?t.cancelScheduledValues(n.time):n.type==="setTargetAtTime"?t.setTargetAtTime(n.value,n.time,n.constant):t[n.type](n.value,n.time)}),this}setParam(t){Y(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,r,n,o){return r+(e-r)*Math.exp(-(o-t)/n)}_linearInterpolate(t,e,r,n,o){return e+(n-e)*((o-t)/(r-t))}_exponentialInterpolate(t,e,r,n,o){return e*Math.pow(n/e,(o-t)/(r-t))}};var P=class i extends te{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return rt(this.input)?lr(this.input)||this.input instanceof ut?1:this.input.numberOfInputs:0}get numberOfOutputs(){return rt(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return rt(t)&&(t instanceof i||Rr(t))}_getInternalNodes(){let t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(r=>{r.channelCount=t.channelCount,r.channelCountMode=t.channelCountMode,r.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){let t=this._getInternalNodes();Y(t.length>0,"ToneAudioNode does not have any internal nodes");let e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,r=0){return le(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Pi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return Hf(this,t,e,r),this}chain(...t){return Ze(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),rt(this.input)&&(this.input instanceof i?this.input.dispose():Rr(this.input)&&this.input.disconnect()),rt(this.output)&&(this.output instanceof i?this.output.dispose():Rr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Ze(...i){let t=i.shift();i.reduce((e,r)=>(e instanceof P?e.connect(r):Rr(e)&&le(e,r),r),t)}function le(i,t,e=0,r=0){for(Y(rt(i),"Cannot connect from undefined node"),Y(rt(t),"Cannot connect to undefined node"),(t instanceof P||Rr(t))&&Y(t.numberOfInputs>0,"Cannot connect to node with no inputs"),Y(i.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof P||t instanceof ut;)rt(t.input)&&(t=t.input);for(;i instanceof P;)rt(i.output)&&(i=i.output);lr(t)?i.connect(t,e):i.connect(t,e,r)}function Hf(i,t,e=0,r=0){if(rt(t))for(;t instanceof P;)t=t.input;for(;!Rr(i);)rt(i.output)&&(i=i.output);lr(t)?i.disconnect(t,e):Rr(t)?i.disconnect(t,e,r):i.disconnect()}var Z=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new ut({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),z(this,"gain")}static getDefaults(){return Object.assign(P.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}};var fr=class extends P{constructor(t){super(t),this.onended=nt,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Z({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let r=this.toSeconds(e);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(P.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:nt})}_startGain(t,e=1){Y(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=t+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+r):this._gainNode.gain.exponentialApproachValueAtTime(e,t,r)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Y(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==nt&&(this.onended(this),this.onended=nt,!this.context.isOffline)){let t=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Y(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=nt,this}};var Mo=class i extends fr{constructor(){let t=I(i.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),le(this._source,this._gainNode),this.offset=new ut({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(fr.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var et=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new Mo({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(P.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,r=0){return Dn(this,t,e,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,r){return this._param.exponentialRampTo(t,e,r),this}linearRampTo(t,e,r){return this._param.linearRampTo(t,e,r),this}targetRampTo(t,e,r){return this._param.targetRampTo(t,e,r),this}exponentialApproachValueAtTime(t,e,r){return this._param.exponentialApproachValueAtTime(t,e,r),this}setTargetAtTime(t,e,r){return this._param.setTargetAtTime(t,e,r),this}setValueCurveAtTime(t,e,r,n){return this._param.setValueCurveAtTime(t,e,r,n),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,r){return this._param.rampTo(t,e,r),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}};function Dn(i,t,e,r){(t instanceof ut||lr(t)||t instanceof et&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof et&&(t.overridden=!0)),le(i,t,e,r)}var Sa=class i extends ut{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Jt(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(ut.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let n=this._fromType(t),o=this._events.get(e),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+e,u=this._exponentialApproach(o.time,o.value,n,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){let r=this.toSeconds(e);super.setValueAtTime(t,e);let n=this._events.get(r),o=this._events.previousEvent(n),s=this._getTicksUntilEvent(o,r);return n.ticks=Math.max(s,0),this}linearRampToValueAtTime(t,e){let r=this.toSeconds(e);super.linearRampToValueAtTime(t,e);let n=this._events.get(r),o=this._events.previousEvent(n),s=this._getTicksUntilEvent(o,r);return n.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);let r=this._fromType(t),n=this._events.get(e),o=Math.round(Math.max((e-n.time)*10,1)),s=(e-n.time)/o;for(let a=0;a<=o;a++){let c=s*a+n.time,u=this._exponentialInterpolate(n.time,n.value,e,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Zt(t.ticks)){let s=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(s,t.time)}let r=this._fromType(this.getValueAtTime(t.time)),n=this._fromType(this.getValueAtTime(e)),o=this._events.get(e);return o&&o.time===e&&o.type==="setValueAtTime"&&(n=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(r+n)+t.ticks}getTicksAtTime(t){let e=this.toSeconds(t),r=this._events.get(e);return Math.max(this._getTicksUntilEvent(r,e),0)}getDurationOfTicks(t,e){let r=this.toSeconds(e),n=this.getTicksAtTime(e);return this.getTimeOfTick(n+t)-r}getTimeOfTick(t){let e=this._events.get(t,"ticks"),r=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&r&&r.type==="linearRampToValueAtTime"&&e.value!==r.value){let n=this._fromType(this.getValueAtTime(e.time)),s=(this._fromType(this.getValueAtTime(r.time))-n)/(r.time-e.time),a=Math.sqrt(Math.pow(n,2)-2*s*(e.ticks-t)),c=(-n+a)/s,u=(-n-a)/s;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){let r=this.toSeconds(e),n=this.toSeconds(t),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+n)-o}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){let e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}};var Ia=class i extends et{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new Sa({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(et.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}};var Ta=class i extends te{constructor(){let t=I(i.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new Mr,this._tickOffset=new Jt,this._ticksAtTime=new Jt,this._secondsAtTime=new Jt,this.frequency=new Ia({context:this.context,units:t.units,value:t.frequency}),z(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},te.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){let r=this.toSeconds(t);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),rt(e)&&this.setTicksAtTime(e,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(t){let e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){let r=this._state.get(e);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){let e=this.toSeconds(t),r=this._state.getLastState("stopped",e),n=this._ticksAtTime.get(e),o={state:"paused",time:e};this._state.add(o);let s=n||r,a=n?n.ticks:0,c=null;return this._state.forEachBetween(s.time,e+this.sampleTime,u=>{let l=s.time,h=this._tickOffset.get(u.time);h&&h.time>=s.time&&(a=h.ticks,l=h.time),s.state==="started"&&u.state!=="started"&&(a+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(l),u.time!==o.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(o),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){let e=this.now(),r=this.frequency.timeToTicks(t,e);this.setTicksAtTime(r,e)}getSecondsAtTime(t){t=this.toSeconds(t);let e=this._state.getLastState("stopped",t),r={state:"paused",time:t};this._state.add(r);let n=this._secondsAtTime.get(t),o=n||e,s=n?n.seconds:0,a=null;return this._state.forEachBetween(o.time,t+this.sampleTime,c=>{let u=o.time,l=this._tickOffset.get(c.time);l&&l.time>=o.time&&(s=l.seconds,u=l.time),o.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),o=c}),this._state.remove(r),a&&this._secondsAtTime.add(a),s}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){let r=this._tickOffset.get(e),n=this._state.get(e),o=Math.max(r.time,n.time),s=this.frequency.getTicksAtTime(o)+t-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,r){let n=this._state.get(t);this._state.forEachBetween(t,e,s=>{n&&n.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(n.time,t),s.time-this.sampleTime,r),n=s});let o=null;if(n&&n.state==="started"){let s=Math.max(n.time,t),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(n.time),u=a-c,l=Math.ceil(u)-u;l=Ae(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<e;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(p){o=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(o)throw o;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var kn=class i extends te{constructor(){let t=I(i.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=nt,this._lastUpdate=0,this._state=new Mr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Ta({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,z(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(te.getDefaults(),{callback:nt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){Aa(this.context);let r=this.toSeconds(t);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,e),r<this._lastUpdate&&this.emit("start",r,e)),this}stop(t){let e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){let r=this.toSeconds(e),n=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(n+t,r)}_loop(){let t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,r=>{switch(r.state){case"started":let n=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,n);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(t,e,(r,n)=>{this.callback(r,n)}))}getStateAtTime(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};mi.mixin(kn);var Xe=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new Z({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,z(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var mh=class i extends P{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Xe({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Ze(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),Ze(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};di(i=>{i.destination=new mh({context:i})});pi(i=>{i.destination.dispose()});var fh=class extends P{constructor(){super(...arguments),this.name="Listener",this.positionX=new ut({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ut({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ut({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ut({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ut({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ut({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ut({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ut({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ut({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(P.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}};di(i=>{i.listener=new fh({context:i})});pi(i=>{i.listener.dispose()});var Ln=class i extends oe{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=I(i.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let r=t.urls[e];this.add(e,r,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:nt,onload:nt,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Y(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,r=nt,n=nt){return me(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new zt(this.baseUrl+e,r,n))):this._buffers.set(t.toString(),new zt(e,r,n)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var Eo=class i extends Ce{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return mr(super._frequencyToUnits(t))}_ticksToUnits(t){return mr(super._ticksToUnits(t))}_beatsToUnits(t){return mr(super._beatsToUnits(t))}_secondsToUnits(t){return mr(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return Ro(this.toMidi())}transpose(t){return new i(this.context,this.toMidi()+t)}};var Fe=class extends $e{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var gh=class extends te{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Jt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){let t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};di(i=>{i.draw=new gh({context:i})});pi(i=>{i.draw.dispose()});var Na=class extends oe{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Y(rt(t.time),"Events must have a time property"),Y(rt(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new yh(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){let e=[];this._root.search(t.time,e);for(let r of e)if(r.event===t){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{let e=t.getBalance(),r,n=null;if(e>0)if(t.left.right===null)r=t.left,r.right=t.right,n=r;else{for(r=t.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,n=r.parent,r.left=t.left,r.right=t.right)}else if(t.right.left===null)r=t.right,r.left=t.left,n=r;else{for(r=t.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,n=r.parent,r.left=t.left,r.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=r:t.parent.right=r:this._setRoot(r),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){let e=t.parent,r=t.isLeftChild(),n=t.right;n&&(t.right=n.left,n.left=t),e!==null?r?e.left=n:e.right=n:this._setRoot(n)}_rotateRight(t){let e=t.parent,r=t.isLeftChild(),n=t.left;n&&(t.left=n.right,n.right=t),e!==null?r?e.left=n:e.right=n:this._setRoot(n)}_rebalance(t){let e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){let e=[];if(this._root.search(t,e),e.length>0){let r=e[0];for(let n=1;n<e.length;n++)e[n].low>r.low&&(r=e[n]);return r.event}}return null}forEach(t){if(this._root!==null){let e=[];this._root.traverse(r=>e.push(r)),e.forEach(r=>{r.event&&t(r.event)})}return this}forEachAtTime(t,e){if(this._root!==null){let r=[];this._root.search(t,r),r.forEach(n=>{n.event&&e(n.event)})}return this}forEachFrom(t,e){if(this._root!==null){let r=[];this._root.searchAfter(t,r),r.forEach(n=>{n.event&&e(n.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}},yh=class{constructor(t,e,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var Oa=class extends oe{constructor(t){super(),this.name="TimelineValue",this._timeline=new Jt({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){let e=this._timeline.get(t);return e?e.value:this._initialValue}};var ye=class i extends P{constructor(){super(I(i.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return Dn(this,t,e,r),this}};var Te=class i extends ye{constructor(){let t=I(i.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Gt(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Tf(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(et.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let n=0,o=e;n<o;n++){let s=n/(o-1)*2-1;r[n]=t(s,n)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){let e=["none","2x","4x"].some(r=>r.includes(t));Y(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var jn=class i extends ye{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new Te({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ye.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var Yr=class i{constructor(t,e){this.id=i._eventId++,this._remainderTime=0;let r=Object.assign(i.getDefaults(),e);this.transport=t,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:nt,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){let e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};Yr._eventId=0;var Ra=class i extends Yr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(i.getDefaults(),e);this.duration=r.duration,this._interval=r.interval,this._nextTick=r.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Yr.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return Fi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Fe(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){Fi(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Fe(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let e=this.transport.getTicksAtTime(t);zr(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}};var Ma=class i extends te{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Oa(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Jt,this._repeatedEvents=new Na,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new kn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),z(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(te.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){let r=e%(this._swingTicks*2)/(this._swingTicks*2),n=Math.sin(r*Math.PI)*this._swingAmount;t+=new Fe(this.context,this._swingTicks*2/3).toSeconds()*n}hh(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),hh(!1)}schedule(t,e){let r=new Yr(this,{callback:t,time:new $e(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,n=1/0){let o=new Ra(this,{callback:t,duration:new Pe(this.context,n).toTicks(),interval:new Pe(this.context,e).toTicks(),time:new $e(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(t,e){let r=new Yr(this,{callback:t,once:!0,time:new $e(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){let e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){let e=this.toTicks(t);return this._timeline.forEachFrom(e,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(e,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new Fe(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let r;return rt(e)&&(r=this.toTicks(e)),this._clock.start(t,r),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Gt(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Pe(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Pe(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Fe(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){let t=this.now(),e=this._clock.getTicksAtTime(t);return new Fe(this.context,e).toBarsBeatsSixteenths()}set position(t){let e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){let e=this.now(),r=this._clock.frequency.timeToTicks(t,e);this.ticks=r}get progress(){if(this.loop){let t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){let e=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(e),n=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,e),o=e+n;this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{let e=this.now(),r=this.getTicksAtTime(e),n=t-r%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){let r=this.now(),n=this.bpm,o=1/(60/n.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/o,u=new Z(c),l=new jn(-1),h=new Z(c);n.chain(u,l,h),n=h,o=1/o,s=[u,l,h]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/o:e=0);let a=new Z(e);return n.connect(a),a.connect(t._param),s.push(a),this._syncedSignals.push({initial:t.value,nodes:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){let r=this._syncedSignals[e];r.signal===t&&(r.nodes.forEach(n=>n.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Gi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};mi.mixin(Ma);di(i=>{i.transport=new Ma({context:i})});pi(i=>{i.transport.dispose()});var wt=class extends P{constructor(t){super(t),this.input=void 0,this._state=new Mr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=nt,this._syncedStop=nt,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Xe({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,z(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,onstop:nt,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,r){let n=Zt(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(n=this._clampToCurrentTime(n),!this._synced&&this._state.getValueAtTime(n)==="started")Y(zr(n,this._state.get(n).time),"Start time must be strictly greater than previous start time"),this._state.cancel(n),this._state.setStateAtTime("started",n),this.log("restart",n),this.restart(n,e,r);else if(this.log("start",n),this._state.setStateAtTime("started",n),this._synced){let o=this._state.get(n);o&&(o.offset=this.toSeconds(je(e,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,e,r)},n);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>n&&this._syncedStart(this.now(),this.context.transport.seconds)}else Aa(this.context),this._start(n,e,r);return this}stop(t){let e=Zt(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||rt(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{let r=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(r)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,r){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(zr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let n=e-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-n),this._start(t,this.toSeconds(r.offset)+n,o)}}},this._syncedStop=t=>{let e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=nt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var Er=class i extends fr{constructor(){let t=I(i.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,le(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ut({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new zt(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(fr.getDefaults(),{url:new zt,loop:!1,loopEnd:0,loopStart:0,onload:nt,onerror:nt,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,r,n=1){Y(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(t);this._startGain(o,n),this.loop?e=je(e,this.loopStart):e=je(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;Oo(s,a)&&(s=(s-c)%u+c),Ae(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Fi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),rt(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var qi=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(wt.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Y(t in $f,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,this.state==="started")){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){let e=$f[this._type];this._source=new Er({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},Pn=44100*5,bh=2,Hr={brown:null,pink:null,white:null},$f={get brown(){if(!Hr.brown){let i=[];for(let t=0;t<bh;t++){let e=new Float32Array(Pn);i[t]=e;let r=0;for(let n=0;n<Pn;n++){let o=Math.random()*2-1;e[n]=(r+.02*o)/1.02,r=e[n],e[n]*=3.5}}Hr.brown=new zt().fromArray(i)}return Hr.brown},get pink(){if(!Hr.pink){let i=[];for(let t=0;t<bh;t++){let e=new Float32Array(Pn);i[t]=e;let r,n,o,s,a,c,u;r=n=o=s=a=c=u=0;for(let l=0;l<Pn;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,n=.99332*n+h*.0750759,o=.969*o+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,e[l]=r+n+o+s+a+c+u+h*.5362,e[l]*=.11,u=h*.115926}}Hr.pink=new zt().fromArray(i)}return Hr.pink},get white(){if(!Hr.white){let i=[];for(let t=0;t<bh;t++){let e=new Float32Array(Pn);i[t]=e;for(let r=0;r<Pn;r++)e[r]=Math.random()*2-1}Hr.white=new zt().fromArray(i)}return Hr.white}};function Ne(i,t){return yt(this,void 0,void 0,function*(){let e=t/i.context.sampleRate,r=new pr(1,e,i.context.sampleRate);return new i.constructor(Object.assign(i.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var Do=class i extends fr{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],le(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new ut({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new ut({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),z(this,["frequency","detune"])}static getDefaults(){return Object.assign(fr.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Vt=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),z(this,"frequency"),this.detune=new et({context:this.context,units:"cents",value:t.detune}),z(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!=="custom"&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(wt.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){let e=this.toSeconds(t),r=new Do({context:this.context,onended:()=>this.onstop(this)});this._oscillator=r,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){let e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){let e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return i._periodicWaveCache.find(e=>e.phase===this._phase&&Ff(e.partials,this._partials));{let t=i._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;let e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let r=this._getCachedPeriodicWave();if(rt(r)){let{partials:n,wave:o}=r;this._wave=o,this._partials=n,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[n,o]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(n,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),i._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:n,type:this._type,wave:this._wave}),i._periodicWaveCache.length>100&&i._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){Ut(t,0);let e=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(e=r[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{let n=new Float32Array(t);this._partials.forEach((o,s)=>n[s]=o),this._partials=Array.from(n),this.type=this._type}}_getRealImaginary(t,e){let n=2048,o=new Float32Array(n),s=new Float32Array(n),a=1;if(t==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,n=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=c[1],a=Math.max(a,2),n=a):this._partialCount=0,this._partials=[]}for(let c=1;c<n;++c){let u=2/(c*Math.PI),l;switch(t){case"sine":l=c<=a?1:0,this._partials[c-1]=l;break;case"square":l=c&1?2*u:0,this._partials[c-1]=l;break;case"sawtooth":l=u*(c&1?1:-1),this._partials[c-1]=l;break;case"triangle":c&1?l=2*(u*u)*(c-1>>1&1?-1:1):l=0,this._partials[c-1]=l;break;case"custom":l=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}l!==0?(o[c]=-l*Math.sin(e*c),s[c]=l*Math.cos(e*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(t,e,r){let n=0,o=t.length;for(let s=0;s<o;s++)n+=t[s]*Math.cos(s*r)+e[s]*Math.sin(s*r);return n}getInitialValue(){let[t,e]=this._getRealImaginary(this._type,0),r=0,n=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(t,e,s/o*n),r);return lh(-this._inverseFFT(t,e,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Vt._periodicWaveCache=[];var Fn=class extends ye{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Te({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var ee=class i extends et{constructor(){let t=I(i.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Z({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(et.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var ko=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new Fn({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Vt({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Vt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new ee({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),z(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Vt.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}};var Bn=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Vt({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Vt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new ee({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new ee({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),z(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Vt.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var Wi=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new Te({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new et({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Vt({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),z(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(wt.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var Lo=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,z(this,["frequency","detune"])}static getDefaults(){return Object.assign(Vt.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){let e=-t/2,r=t/(this._oscillators.length-1);this._forEach((n,o)=>n.detune.value=e+r*o)}}get count(){return this._oscillators.length}set count(t){if(Ut(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Vt({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):nt});this.type==="custom"&&(r.partials=this._partials),this.frequency.connect(r.frequency),this.detune.connect(r.detune),r.detune.overridden=!1,r.connect(this.output),this._oscillators[e]=r}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,r)=>e.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var jo=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new ee({context:this.context,value:2}),this._pulse=new Wi({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Vt({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),z(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(wt.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var Zf={am:ko,fat:Lo,fm:Bn,oscillator:Vt,pulse:Wi,pwm:jo},Ui=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),z(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Vt.getDefaults(),Bn.getDefaults(),ko.getDefaults(),Lo.getDefaults(),Wi.getDefaults(),jo.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;let e=Zf[t],r=this.now();if(this._oscillator){let n=this._oscillator;n.stop(r),this.context.setTimeout(()=>n.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(r)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof Zf[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(t){this._getOscType(this._oscillator,"fat")&&he(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&he(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&me(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return yt(this,arguments,void 0,function*(t=1024){return Ne(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function Da(i,t=1/0){let e=new WeakMap;return function(r,n){Reflect.defineProperty(r,n,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Ut(o,i,t),e.set(this,o)}})}}function Oe(i,t=1/0){let e=new WeakMap;return function(r,n){Reflect.defineProperty(r,n,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Ut(this.toSeconds(o),i,t),e.set(this,o)}})}}var Po=class i extends wt{constructor(){let t=I(i.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new zt({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(wt.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:nt,onerror:nt,playbackRate:1,reverse:!1})}load(t){return yt(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=nt){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,r){return super.start(t,e,r),this}_start(t,e,r){this._loop?e=je(e,this._loopStart):e=je(e,0);let n=this.toSeconds(e),o=r;r=je(r,Math.max(this._buffer.duration-n,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new Er({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Zt(o)?a.start(t,n):a.start(t,n,s-this.toSeconds(this.fadeOut))}_stop(t){let e=this.toSeconds(t);this._activeSources.forEach(r=>r.stop(e))}restart(t,e,r){return super.restart(t,e,r),this}_restart(t,e,r){var n;(n=[...this._activeSources].pop())===null||n===void 0||n.stop(t),this._start(t,e,r)}seek(t,e){let r=this.toSeconds(e);if(this._state.getValueAtTime(r)==="started"){let n=this.toSeconds(t);this._stop(r),this._start(r,n)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Ut(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&Ut(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){let e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;let e=this.now(),r=this._state.getNextState("stopped",e);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(n=>n.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};ge([Oe(0)],Po.prototype,"fadeIn",void 0);ge([Oe(0)],Po.prototype,"fadeOut",void 0);var ka=class extends ye{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Te({context:this.context,mapping:t=>Math.abs(t)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var _e=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new et({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(P.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(me(t))return t;{let r;for(r in La)if(La[r][e]===t)return r;return t}}_setCurve(t,e,r){if(me(r)&&Reflect.has(La,r)){let n=La[r];hr(n)?t!=="_decayCurve"&&(this[t]=n[e]):this[t]=n}else if(Gt(r)&&t!=="_decayCurve")this[t]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let n=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(t);if(s>0){let a=1/n;n=(1-s)/a}if(n<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,n,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,n,t);else{this._sig.cancelAndHoldAtTime(t);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=s&&s<=a[c]){a=this._attackCurve.slice(c),a[0]=s;break}this._sig.setValueCurveAtTime(a,t,n,e)}if(o&&this.sustain<1){let a=e*this.sustain,c=t+n;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);let e=this.getValueAtTime(t);if(e>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,t):(Y(Gt(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,r,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,r=1){return e=this.toSeconds(e),this.triggerAttack(e,r),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,r=0){return Dn(this,t,e,r),this}asArray(){return yt(this,arguments,void 0,function*(t=1024){let e=t/this.context.sampleRate,r=new pr(1,e,this.context.sampleRate),n=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=n+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(e*(n+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};ge([Oe(0)],_e.prototype,"attack",void 0);ge([Oe(0)],_e.prototype,"decay",void 0);ge([Da(0,1)],_e.prototype,"sustain",void 0);ge([Oe(0)],_e.prototype,"release",void 0);var La=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let n=[],o=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*o-Math.PI/2)+1;n[t]=p/10+e*.83}n[127]=1;let s=[],a=5;for(t=0;t<128;t++)s[t]=Math.ceil(t/127*a)/a;let c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));let u=[];for(t=0;t<128;t++){e=t/127;let p=Math.pow(e,3)*4+.2,m=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(m*(1-e))}function l(p){let m=new Array(p.length);for(let f=0;f<p.length;f++)m[f]=1-p[f];return m}function h(p){return p.slice(0).reverse()}return{bounce:{In:l(u),Out:u},cosine:{In:r,Out:h(r)},exponential:"exponential",linear:"linear",ripple:{In:n,Out:l(n)},sine:{In:c,Out:l(c)},step:{In:s,Out:l(s)}}})();var Be=class i extends P{constructor(){let t=I(i.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new Xe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,z(this,"volume")}static getDefaults(){return Object.assign(P.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){let r=this["_original_"+t]=this[t];this[t]=(...n)=>{let o=n[e],s=this.context.transport.schedule(a=>{n[e]=a,r.apply(this,n)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,r,n){let o=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,o,n),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var Re=class i extends Be{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,onsilence:nt,portamento:0})}triggerAttack(t,e,r=1){this.log("triggerAttack",t,e,r);let n=this.toSeconds(e);return this._triggerEnvelopeAttack(n,r),this.setNote(t,n),this}triggerRelease(t){this.log("triggerRelease",t);let e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){let r=this.toSeconds(e),n=t instanceof Ce?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(n,o,r)}else this.frequency.setValueAtTime(n,r);return this}};ge([Oe(0)],Re.prototype,"portamento",void 0);var Gn=class i extends _e{constructor(){super(I(i.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Z({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}};var Dr=class i extends Re{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new Ui(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Gn(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),z(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Re.getDefaults(),{envelope:Object.assign(dr(_e.getDefaults(),Object.keys(P.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(dr(Ui.getDefaults(),[...Object.keys(wt.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+r+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var Fo=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ut({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new ut({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new ut({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new ut({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(P.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Y(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){let e=new Float32Array(t);for(let s=0;s<t;s++){let c=Math.pow(s/t,2)*19980+20;e[s]=c}let r=new Float32Array(t),n=new Float32Array(t),o=this.context.createBiquadFilter();return o.type=this.type,o.Q.value=this.Q.value,o.frequency.value=this.frequency.value,o.gain.value=this.gain.value,o.getFrequencyResponse(e,r,n),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var $r=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new et({context:this.context,units:"positive",value:t.Q}),this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),this.gain=new et({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,z(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(P.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Y(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._type=t,this._filters.forEach(r=>r.type=t)}get rolloff(){return this._rolloff}set rolloff(t){let e=he(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],n=r.indexOf(e);Y(n!==-1,`rolloff can only be ${r.join(", ")}`),n+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(n);for(let o=0;o<n;o++){let s=new Fo({context:this.context});s.type=this._type,this.frequency.connect(s.frequency),this.detune.connect(s.detune),this.Q.connect(s.Q),this.gain.connect(s.gain),this._filters[o]=s}this._internalChannels=this._filters,Ze(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new Fo({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),r=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((o,s)=>r[s]*=o)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),Gi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var ja=class i extends Dr{constructor(){let t=I(i.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,z(this,["oscillator","envelope"])}static getDefaults(){return He(Re.getDefaults(),Dr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){let r=this.toSeconds(e),n=this.toFrequency(t instanceof Ce?t.toFrequency():t),o=n*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(n,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};ge([Da(0)],ja.prototype,"octaves",void 0);ge([Oe(0)],ja.prototype,"pitchDecay",void 0);var Xf=new Set;function qn(i){Xf.add(i)}function Pa(i,t){let e=`registerProcessor("${i}", ${t})`;Xf.add(e)}var hv=`
100
100
  /**
101
101
  * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
102
102
  */
@@ -267,7 +267,7 @@
267
267
  return delayedSample;
268
268
  }
269
269
  }
270
- `;Pa(Qf,pv);var Fa=class i extends Be{constructor(){let t=I(i.getDefaults(),arguments,["voice","options"]);super(t),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=n=>this.releaseAll(n),Y(!he(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");let e=t.voice.getDefaults();this.options=Object.assign(e,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();let r=this._voices.indexOf(this._dummyVoice);this._voices.splice(r,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(Be.getDefaults(),{maxPolyphony:32,options:{},voice:Dr})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);let e=this._activeVoices.findIndex(r=>r.voice===t);this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return Y(t instanceof Re,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}else Pi("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){let t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,r){t.forEach(n=>{let o=new Eo(this.context,n).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(n,e,r),this._activeVoices.push({midi:o,voice:s,released:!1}),this.log("triggerAttack",n,e))})}_triggerRelease(t,e){t.forEach(r=>{let n=new Eo(this.context,r).toMidi(),o=this._activeVoices.find(({midi:s,released:a})=>s===n&&!a);o&&(o.voice.triggerRelease(e),o.released=!0,this.log("triggerRelease",r,e))})}_scheduleEvent(t,e,r,n){Y(!this.disposed,"Synth was already disposed"),r<=this.now()?t==="attack"?this._triggerAttack(e,r,n):this._triggerRelease(e,r):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(t,e,r,n)},r-this.now())}triggerAttack(t,e,r){Array.isArray(t)||(t=[t]);let n=this.toSeconds(e);return this._scheduleEvent("attack",t,n,r),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);let r=this.toSeconds(e);return this._scheduleEvent("release",t,r),this}triggerAttackRelease(t,e,r,n){let o=this.toSeconds(r);if(this.triggerAttack(t,o,n),Gt(e)){Y(Gt(t),"If the duration is an array, the notes must also be an array"),t=t;for(let s=0;s<t.length;s++){let a=e[Math.min(s,e.length-1)],c=this.toSeconds(a);Y(c>0,"The duration must be greater than 0"),this.triggerRelease(t[s],o+c)}}else{let s=this.toSeconds(e);Y(s>0,"The duration must be greater than 0"),this.triggerRelease(t,o+s)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}set(t){let e=dr(t,["onsilence","context"]);return this.options=$e(this.options,e),this._voices.forEach(r=>r.set(e)),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){let e=this.toSeconds(t);return this._activeVoices.forEach(({voice:r})=>{r.triggerRelease(e)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(t=>t.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}};var Ba=class i extends Be{constructor(){let t=I(i.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map;let e={};Object.keys(t.urls).forEach(r=>{let n=parseInt(r,10);if(Y(No(r)||he(n)&&isFinite(n),`url key is neither a note or midi pitch: ${r}`),No(r)){let o=new Ce(this.context,r).toMidi();e[o]=t.urls[r]}else he(n)&&isFinite(n)&&(e[n]=t.urls[n])}),this._buffers=new Ln({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(Be.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:nt,onerror:nt,release:.1,urls:{}})}_findClosest(t){let r=0;for(;r<96;){if(this._buffers.has(t+r))return-r;if(this._buffers.has(t-r))return r;r++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,r=1){return this.log("triggerAttack",t,e,r),Array.isArray(t)||(t=[t]),t.forEach(n=>{let o=ph(new Ce(this.context,n).toFrequency()),s=Math.round(o),a=o-s,c=this._findClosest(s),u=s-c,h=this._buffers.get(u),l=Vi(c+a),p=new Er({url:h,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:l}).connect(this.output);p.start(e,0,h.duration/l,r),Gt(this._activeSources.get(s))||this._activeSources.set(s,[]),this._activeSources.get(s).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(s)){let m=this._activeSources.get(s),f=m.indexOf(p);f!==-1&&m.splice(f,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(r=>{let n=new Ce(this.context,r).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){let o=this._activeSources.get(n);e=this.toSeconds(e),o.forEach(s=>{s.stop(e)}),this._activeSources.set(n,[])}}),this}releaseAll(t){let e=this.toSeconds(t);return this._activeSources.forEach(r=>{for(;r.length;)r.shift().stop(e)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,r,n=1){let o=this.toSeconds(r);return this.triggerAttack(t,o,n),Gt(e)?(Y(Gt(t),"notes must be an array when duration is array"),t.forEach((s,a)=>{let c=e[Math.min(a,e.length-1)];this.triggerRelease(s,o+this.toSeconds(c))})):this.triggerRelease(t,o+this.toSeconds(e)),this}add(t,e,r){if(Y(No(t)||isFinite(t),`note must be a pitch or midi: ${t}`),No(t)){let n=new Ce(this.context,t).toMidi();this._buffers.add(n,e,r)}else this._buffers.add(t,e,r);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(e=>e.dispose())}),this._activeSources.clear(),this}};ge([Oe(0)],Ba.prototype,"attack",void 0);ge([Oe(0)],Ba.prototype,"release",void 0);var Wn=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new ka({context:this.context}),this.a=new Z({context:this.context,gain:0}),this.b=new Z({context:this.context,gain:0}),this.output=new Z({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new et({context:this.context,units:"normalRange",value:t.fade}),z(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",le(this._split,this.a.gain,0),le(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign(P.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}};var Me=class extends P{constructor(t){super(t),this.name="Effect",this._dryWet=new Wn({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Z({context:this.context}),this.effectReturn=new Z({context:this.context}),this.input=new Z({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],z(this,"wet")}static getDefaults(){return Object.assign(P.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};var Bo=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ut({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",z(this,"pan")}static getDefaults(){return Object.assign(P.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var Jf="bit-crusher",Av=`
270
+ `;Pa(Qf,pv);var Fa=class i extends Be{constructor(){let t=I(i.getDefaults(),arguments,["voice","options"]);super(t),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=n=>this.releaseAll(n),Y(!he(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");let e=t.voice.getDefaults();this.options=Object.assign(e,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();let r=this._voices.indexOf(this._dummyVoice);this._voices.splice(r,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(Be.getDefaults(),{maxPolyphony:32,options:{},voice:Dr})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);let e=this._activeVoices.findIndex(r=>r.voice===t);this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return Y(t instanceof Re,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}else Pi("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){let t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,r){t.forEach(n=>{let o=new Eo(this.context,n).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(n,e,r),this._activeVoices.push({midi:o,voice:s,released:!1}),this.log("triggerAttack",n,e))})}_triggerRelease(t,e){t.forEach(r=>{let n=new Eo(this.context,r).toMidi(),o=this._activeVoices.find(({midi:s,released:a})=>s===n&&!a);o&&(o.voice.triggerRelease(e),o.released=!0,this.log("triggerRelease",r,e))})}_scheduleEvent(t,e,r,n){Y(!this.disposed,"Synth was already disposed"),r<=this.now()?t==="attack"?this._triggerAttack(e,r,n):this._triggerRelease(e,r):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(t,e,r,n)},r-this.now())}triggerAttack(t,e,r){Array.isArray(t)||(t=[t]);let n=this.toSeconds(e);return this._scheduleEvent("attack",t,n,r),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);let r=this.toSeconds(e);return this._scheduleEvent("release",t,r),this}triggerAttackRelease(t,e,r,n){let o=this.toSeconds(r);if(this.triggerAttack(t,o,n),Gt(e)){Y(Gt(t),"If the duration is an array, the notes must also be an array"),t=t;for(let s=0;s<t.length;s++){let a=e[Math.min(s,e.length-1)],c=this.toSeconds(a);Y(c>0,"The duration must be greater than 0"),this.triggerRelease(t[s],o+c)}}else{let s=this.toSeconds(e);Y(s>0,"The duration must be greater than 0"),this.triggerRelease(t,o+s)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}set(t){let e=dr(t,["onsilence","context"]);return this.options=He(this.options,e),this._voices.forEach(r=>r.set(e)),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){let e=this.toSeconds(t);return this._activeVoices.forEach(({voice:r})=>{r.triggerRelease(e)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(t=>t.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}};var Ba=class i extends Be{constructor(){let t=I(i.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map;let e={};Object.keys(t.urls).forEach(r=>{let n=parseInt(r,10);if(Y(No(r)||he(n)&&isFinite(n),`url key is neither a note or midi pitch: ${r}`),No(r)){let o=new Ce(this.context,r).toMidi();e[o]=t.urls[r]}else he(n)&&isFinite(n)&&(e[n]=t.urls[n])}),this._buffers=new Ln({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(Be.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:nt,onerror:nt,release:.1,urls:{}})}_findClosest(t){let r=0;for(;r<96;){if(this._buffers.has(t+r))return-r;if(this._buffers.has(t-r))return r;r++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,r=1){return this.log("triggerAttack",t,e,r),Array.isArray(t)||(t=[t]),t.forEach(n=>{let o=ph(new Ce(this.context,n).toFrequency()),s=Math.round(o),a=o-s,c=this._findClosest(s),u=s-c,l=this._buffers.get(u),h=Vi(c+a),p=new Er({url:l,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);p.start(e,0,l.duration/h,r),Gt(this._activeSources.get(s))||this._activeSources.set(s,[]),this._activeSources.get(s).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(s)){let m=this._activeSources.get(s),f=m.indexOf(p);f!==-1&&m.splice(f,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(r=>{let n=new Ce(this.context,r).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){let o=this._activeSources.get(n);e=this.toSeconds(e),o.forEach(s=>{s.stop(e)}),this._activeSources.set(n,[])}}),this}releaseAll(t){let e=this.toSeconds(t);return this._activeSources.forEach(r=>{for(;r.length;)r.shift().stop(e)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,r,n=1){let o=this.toSeconds(r);return this.triggerAttack(t,o,n),Gt(e)?(Y(Gt(t),"notes must be an array when duration is array"),t.forEach((s,a)=>{let c=e[Math.min(a,e.length-1)];this.triggerRelease(s,o+this.toSeconds(c))})):this.triggerRelease(t,o+this.toSeconds(e)),this}add(t,e,r){if(Y(No(t)||isFinite(t),`note must be a pitch or midi: ${t}`),No(t)){let n=new Ce(this.context,t).toMidi();this._buffers.add(n,e,r)}else this._buffers.add(t,e,r);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(e=>e.dispose())}),this._activeSources.clear(),this}};ge([Oe(0)],Ba.prototype,"attack",void 0);ge([Oe(0)],Ba.prototype,"release",void 0);var Wn=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new ka({context:this.context}),this.a=new Z({context:this.context,gain:0}),this.b=new Z({context:this.context,gain:0}),this.output=new Z({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new et({context:this.context,units:"normalRange",value:t.fade}),z(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",le(this._split,this.a.gain,0),le(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign(P.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}};var Me=class extends P{constructor(t){super(t),this.name="Effect",this._dryWet=new Wn({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Z({context:this.context}),this.effectReturn=new Z({context:this.context}),this.input=new Z({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],z(this,"wet")}static getDefaults(){return Object.assign(P.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};var Bo=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ut({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",z(this,"pan")}static getDefaults(){return Object.assign(P.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var Jf="bit-crusher",Av=`
271
271
  class BitCrusherWorklet extends SingleIOProcessor {
272
272
 
273
273
  static get parameterDescriptors() {
@@ -286,8 +286,8 @@
286
286
  return val;
287
287
  }
288
288
  }
289
- `;Pa(Jf,Av);var fi=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(P.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var qrt=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var Xrt=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var qa=class i extends Me{constructor(){let t=I(i.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Ut(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Ut(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Me.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Ut(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Ut(t,0),this._preDelay=t,this.generate()}generate(){return gt(this,void 0,void 0,function*(){let t=this.ready,e=new pr(2,this._decay+this._preDelay,this.context.sampleRate),r=new qi({context:e}),n=new qi({context:e}),o=new fi({context:e});r.connect(o,0,0),n.connect(o,0,1);let s=new Z({context:e}).toDestination();o.connect(s),r.start(0),n.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=e.render();return this.ready=a.then(nt),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var Un=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new Z({context:this.context}),i._allSolos.has(this.context)||i._allSolos.set(this.context,new Set),i._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(P.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),i._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){i._soloed.has(this.context)||i._soloed.set(this.context,new Set),i._soloed.get(this.context).add(this)}_removeSolo(){i._soloed.has(this.context)&&i._soloed.get(this.context).delete(this)}_isSoloed(){return i._soloed.has(this.context)&&i._soloed.get(this.context).has(this)}_noSolos(){return!i._soloed.has(this.context)||i._soloed.has(this.context)&&i._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),i._allSolos.get(this.context).delete(this),this._removeSolo(),this}};Un._allSolos=new Map;Un._soloed=new Map;var Wa=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new Bo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Qe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,z(this,["pan","volume"])}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var vh=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new Un({solo:t.solo,context:this.context}),this._panVol=this.output=new Wa({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),z(this,["pan","volume"])}static getDefaults(){return Object.assign(P.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return i.buses.has(t)||i.buses.set(t,new Z({context:this.context})),i.buses.get(t)}send(t,e=0){let r=this._getBus(t),n=new Z({context:this.context,units:"decibels",gain:e});return this.connect(n),n.connect(r),n}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};vh.buses=new Map;var jat=Xt().transport;var Pat=Xt().destination,Fat=Xt().destination;var Bat=Xt().listener;var Gat=Xt().draw;var Vat=Xt();var wh=class{constructor(){d(this,"audioSource");try{let t=new qa({decay:3,wet:.4}).toDestination(),e=new $r(800,"lowpass").connect(t);this.audioSource=new Fa(Dr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(e)}catch(t){this.audioSource=void 0,console.error(t)}}getName(){return"Synthesizer"}playNote(t,e,r){try{this.audioSource&&(this.audioSource.volume.value=ea(r),this.audioSource.triggerAttackRelease(t,e))}catch(n){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},Sh=new wh;Ti();function Nv(i){return typeof i=="string"?i:(typeof i=="number"&&(i=U.getChromaticNote(i)),i.format(0,0))}var Ua=[Sh],zn=Sh,Ov=(function(t,e,r){var o;let n=parseInt((o=r.split("/")[1])!=null?o:"4");return 60*(1/t)/(e*(1/n))})(2,80,"4/4"),Rv=1,za=!1;function Mv(){return Ua.map(i=>i.getName())}function Ev(){return zn.getName()}function Dv(i){(y.isArray(i)?i:[i]).forEach(t=>{if(!H.Obj.hasProperties(t,["getName","playNote","stop"])||!y.isFunction(t.getName)||!y.isFunction(t.playNote)||!y.isFunction(t.stop))throw new N(7,"Invalid instrument object: "+t);Ua.some(e=>e.getName()===t.getName())?console.warn(`Instrument "${t.getName()}" already added!`):Ua.push(t),eg(t.getName())})}function eg(i){if(i===zn.getName())return;zn.stop();let t=Ua.find(e=>e.getName()===i);t&&(zn=t)}function Ya(i,t,e){za||zn.playNote(Nv(i),t!=null?t:Ov,e!=null?e:Rv)}function Ha(){zn.stop()}function kv(){Ha(),za=!0}function Lv(){za=!1}function jv(){return za}var Wh={};rn(Wh,{Annotation:()=>$n,Arpeggio:()=>gi,Clef:()=>zi,Connective:()=>yi,DocumentBuilder:()=>Cr,DynamicsAnnotation:()=>Yo,Fermata:()=>zo,Label:()=>$o,LyricsAlign:()=>Uo,LyricsHyphen:()=>Hn,MAccidental:()=>Xo,MArpeggio:()=>rs,MBarLineLeft:()=>ps,MBarLineRight:()=>ds,MBeamGroup:()=>ys,MConnective:()=>Cs,MDocument:()=>Xr,MEnding:()=>fs,MExtensionLine:()=>As,MFermata:()=>xs,MHeader:()=>Os,MImage:()=>Zo,MLyrics:()=>_s,MMeasure:()=>ws,MNoteGroup:()=>os,MPlaybackButtons:()=>qh,MPlayer:()=>to,MRenderContext:()=>Vh,MRest:()=>is,MRhythmColumn:()=>cs,MScoreRow:()=>Ns,MScoreRowGroup:()=>Ts,MSpecialText:()=>us,MStaff:()=>Ss,MStaffBarLine:()=>ms,MStaffBeamGroup:()=>bs,MStaffNoteGroup:()=>ss,MStaffRest:()=>ns,MStaffSignature:()=>ts,MTab:()=>Is,MTabNoteGroup:()=>as,MTabRhythm:()=>vs,MTabSignature:()=>es,MText:()=>Qo,MusicInterface:()=>bt,Navigation:()=>br,NoteAnchor:()=>Ke,Paint:()=>Zr,PlayState:()=>Xa,ScoreEvent:()=>Ms,ScoreObjectEvent:()=>Hi,ScoreStaffPosEvent:()=>Yi,StaffPreset:()=>Yn,Stem:()=>gr,TempoAnnotation:()=>Ho,TieType:()=>yr,VerticalPosition:()=>Wo,colorKey:()=>xr,getStringNumbers:()=>$a,getVerseNumbers:()=>rg,getVoiceIds:()=>se,isStringNumber:()=>qo,isVerseNumber:()=>Za,isVoiceId:()=>Ge,validateStringNumber:()=>Pv,validateVerseNumber:()=>Fv,validateVoiceId:()=>Vo});var Yn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(Yn||{}),zi=(e=>(e.G="G",e.F="F",e))(zi||{});function se(){return[0,1,2,3]}function Ge(i){return y.isIncluded(i,se())}function Vo(i){if(Ge(i))return i;throw new N(6,`Voice id ${i} is invalid!`)}function $a(){return[1,2,3,4,5,6]}function qo(i){return y.isIncluded(i,$a())}function Pv(i){if(qo(i))return i;throw new N(6,`String number ${i} is invalid!`)}function rg(){return[1,2,3]}function Za(i){return y.isIncluded(i,rg())}function Fv(i){if(Za(i))return i;throw new N(6,`Verse number ${i} is invalid!`)}var gr=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(gr||{}),gi=(e=>(e.Up="up",e.Down="down",e))(gi||{}),yr=(e=>(e.Stub="stub",e.ToMeasureEnd="toMeasureEnd",e))(yr||{}),Ke=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(Ke||{}),yi=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(yi||{}),Wo=(n=>(n.Auto="auto",n.Above="above",n.Below="below",n.Both="both",n))(Wo||{}),Uo=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(Uo||{}),Hn=(e=>(e.Hyphen="-",e.Extender="---",e))(Hn||{}),zo=(e=>(e.AtNote="atNote",e.AtMeasureEnd="atMeasureEnd",e))(zo||{}),br=(l=>(l.DC_al_Fine="D.C. al Fine",l.DC_al_Coda="D.C. al Coda",l.DS_al_Fine="D.S. al Fine",l.DS_al_Coda="D.S. al Coda",l.Coda="Coda",l.toCoda="toCoda",l.Segno="Segno",l.Fine="Fine",l.StartRepeat="startRepeat",l.EndRepeat="endRepeat",l.Ending="ending",l))(br||{}),$n=(e=>(e.Dynamics="dynamics",e.Tempo="tempo",e))($n||{}),Yo=(p=>(p.cresc="cresc.",p.decresc="decresc.",p.dim="dim.",p.ppp="ppp",p.pp="pp",p.p="p",p.mp="mp",p.m="m",p.mf="mf",p.f="f",p.ff="ff",p.fff="fff",p))(Yo||{}),Ho=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(Ho||{}),$o=(e=>(e.Note="note",e.Chord="chord",e))($o||{}),Xa=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(Xa||{});var Qa=class{constructor(t){d(this,"head");d(this,"tail");this.head=t,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(t){this.tail.push(t)}detachTail(t){let e=this.tail.indexOf(t);e>=0&&this.tail.splice(e,1)}},J=class{constructor(t){this.parent=t;d(this,"anchoredLayoutObjects",[]);d(this,"link");d(this,"userData",{});d(this,"rect",new G);d(this,"needRectUpdate",!0)}getParent(){return this.parent}requestRectUpdate(){this.needRectUpdate=!0}updateRect(){}forceRectUpdate(){this.needRectUpdate=!0,this.updateRect(),this.needRectUpdate=!1}getRect(){return this.needRectUpdate&&this.forceRectUpdate(),this.rect}offsetX(t){this.offset(t,0)}offsetY(t){this.offset(0,t)}setLeft(t){this.offset(t-this.getRect().left,0)}setRight(t){this.offset(t-this.getRect().right,0)}setTop(t){this.offset(0,t-this.getRect().top)}setBottom(t){this.offset(0,t-this.getRect().bottom)}setAnchor(t,e){this.offset(t-this.getRect().anchorX,e-this.getRect().anchorY)}setAnchorX(t){this.offset(t-this.getRect().anchorX,0)}setAnchorY(t){this.offset(0,t-this.getRect().anchorY)}setCenter(t,e){this.offset(t-this.getRect().centerX,e-this.getRect().centerY)}setCenterX(t){this.offset(t-this.getRect().centerX,0)}setCenterY(t){this.offset(0,t-this.getRect().centerY)}getShapeRects(){return[this.rect]}addAnchoredLayoutObject(t){this.anchoredLayoutObjects.push(t)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(t){this.link=t}getLink(){return this.link}isLinked(){return this.link!==null}};var ig={DrawDebugRects:!1,DisableBeams:!1},at={DocumentScale:1,MinStaffWidth:75,MinColumnsWidth:10,ColumnWidthScale:1.7,PostMeasureBreakWidth:10,NoteDotSpace:.5,NoteAccSpace:.5,NoteHeadWidth:2,NoteHeadHeight:1.3,DiamondNoteHeadSize:1.8,DotSize:.8,StemHeight:7,FlagWidth:1.5,FlagHeight:4,FlagSeparation:2,BeamSeparation:1.25,BeamAngleFactor:.5,BeamThickness:4,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var ng="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYAAACCe+v6AAADHXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZZRcu0mDIbfWUWXgCSExHIwmJnu4C6/Pxg7J2kyTdv7GJhjsJCF0CfZJ5y//hzhDzRK5iGpeS45R7RUUuGKicerHetKMa3ratL2Gr2Xh5L3AkMkU/O6LbzlJ+SY074vexO69W9D94QqZvq2UOuWH+/lxzbI/tHQ9kDo2jn2/cA2JLw9Std92x7l4vbuaH2fGYqXyN9+SYyzZrKEa+JolgvmzjEZ4tmno6NxWYb0CugjuO9vVYZPfApJxFUkXV7K/IlUjBlXrAYokhhuFMK5UFbgI1DCBXha9kY1PsF8jc1bjL5o3zlWxCbjnMov1J7xQ97k/HnePLOdBg81z3tB3mON+Rk/lZPehu4Fefbh1529PTu/k4vE9BqK8Ip7jO5jHRqnqCkjFnkf6j7KmkHvmFFcT2V0izkgax2T2Qu6xxobcqrHhko7MC/EoDsoUadKg841NmpwMfHJhpG5BZYldEAq3GQmQ5qdBpsU6eLImHblkPDjC61ty9qukcceYieoMsEY4ZH/3MN3FceYtUQU/YoT0gJ+8axOeBEJ+OcANTCgsYOqK8B3/9gm18lMV5gdB6zxCJeJQ+ktuWSBFigqxgsyWd8GECJsrXCGBARiJlHK8MiYjQiBdACqcJ0l8QECpModTnISyYCD6sDeeMZoqbLyJcZbVVJAsWYUrYNQBayUFPljyZFDVUWTqmY1dS1as+RZeTlbnq/namLJ1LIZ3tlWrLp4cvXs5u7Fa+EieH1rQZ0WL6XUik0rLFc8XaFQ68GHHOnQIx92+FHCURvSp6WmLTdr3kqrnbt0FHjP3br30utJJ1LpTKee+bTTz3LWgVQbMtLQkYeF4aOM+lCjXbYf+7+gRpsaL1JT0R5qkJrdJmi+TnQyAzFOBOAGaiCGxJ7MolNKPMlNZvgeoSqU4aROOJ0mMRBMJ7EOethtcoHr7+EWzBc3/r/kwkT3TXJ/5/YZtT6/Em0Ru8pwBjUKqg/rp1f2Oj+vX47hnxS+O/4Y+jH0Y+jrcYwROv51hb8AKbCqdGIdCl0AAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDQBzFX1O1UqoOdhBxyFCd7OAH0rFUsQgWSluhVQeTS7+gSUOS4uIouBYc/FisOrg46+rgKgiCHyCuLk6KLlLi/5JCi1gPjvvx7t7j7h0gNCpMNXuigKpZRioeE7O5VdH3ij74MYgpRCRm6on0YgZdx9c9PHy9C/Os7uf+HANK3mSARySOMt2wiDeI5zYtnfM+cZCVJIX4nHjSoAsSP3JddvmNc9FhgWcGjUxqnjhILBY7WO5gVjJU4lnikKJqlC9kXVY4b3FWKzXWuid/YSCvraS5TnMMcSwhgSREyKihjAoshGnVSDGRov1YF/+o40+SSyZXGYwcC6hCheT4wf/gd7dmYWbaTQrEgN4X2/4YB3y7QLNu29/Htt08AbzPwJXW9lcbQOST9HpbCx0BQ9vAxXVbk/eAyx1g5EmXDMmRvDSFQgF4P6NvygHDt4B/ze2ttY/TByBDXS3fAAeHwESRste7vLu/s7d/z7T6+wEMNXLkxtwRywAADzRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDA3ODVjMzYtNDAxZC00YTZlLTkxODctMDQ1NTI4MmM0ZGY2IgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjhiZTJkYzc1LTVlYjQtNDk0Yy1iNWRlLWQ2MzZkNzZhNjI2YiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmU3YWE0MWNhLTNiYjMtNGU5Yi05NDQxLTllNTNmZTJiZjM5ZiIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IldpbmRvd3MiCiAgIEdJTVA6VGltZVN0YW1wPSIxNjg2NDA4NjA5MzE2NDM4IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzQiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIgogICB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzOjA2OjEwVDE3OjUwOjA5KzAzOjAwIgogICB4bXA6TW9kaWZ5RGF0ZT0iMjAyMzowNjoxMFQxNzo1MDowOSswMzowMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjI3MzY2YmY0LWVkZDMtNDE5OC05NjJhLWU5ZTM5MTBlNThiZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOC0yMlQwMjo1NTozNiIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NjVlMTM3OS0wZDlmLTQ5ODItYWQ3MC05MzhjOWMzOWE0ZjMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjItMDktMTFUMTY6MzU6MDAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MTBmYmEwYTMtOTI5Yi00NTRlLThjNGMtOGVkOGM4YWJhZGRjIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEwVDE3OjUwOjA5Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Ppn4NIQAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgoOMgm5WlWBAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAACHtJREFUeNrtnXuQVmMcxz+77cauTWUpbGSVu2w3BpnUEBq3chkmBjGayG1GBuNWLtUgw5SJkBkjl4QKg1wyQyarK0lRSlstU20bWam9+OM8O3P6vc8553nOe97tnO18Z84f57zP7XvOc/ndnueFfQx5e6neUmAI0B3oDPwD/AJ8Dvzcml5we+Al4D+gyeOaB1S0BrLHAut9iLqvf4ERSSZbBmwwJOu+RieV8JwQZJuARjXWE4WBIck2X38AByaJ8MwsCTcBTyWFbCFQFwHhv4DiKBqUn2PCPYEin9+bgI3AUuBPn3TtgMuT8IWv8vlq7wLdRPrTgPke6d9JAuFbPBo/3UfKK1TCh8yzIQmEb/cYjx0C8pUDuzV5D477GN6mefY+UBuQby0wV/O8U9wJr9E8W2iY92vNs45xJ6zTfKoN827UPNsdd8K1SlJyo8Awb7XhEIkVYYAVmjXVBPtr1uyqJBBeLu5LDPMdppkPdiaRcHvDfKeJ+++SIFoCLBP3R1toWW58lhQFogiodwkPlYZf1y1w/AcclCQVcYWQtILwqiA8M2lGgDcFgSN90nbXiJUXRdWQ/BYiLMdxH5+0k8VavRb4JGmEl4j7vh7pRgDni2fj1RyQKBwiuqjui/Un015dBbQloXCbaTdrZuUajTp4IwnGbEHmKPX8QmCHhuwC9p4rKBI8IghdB0zCsT1Lsg0+4zwxuEiQqqcVmGWDlAETk+zSJE9Ublyjuqof2TrgxKQT7anMNSZfd1iSiZYCUwy+avP1dJLJXglsxdyV8hHQJolEDwBewc5v9J3Klzj0xYnTsCG7W4mdicMdwC7CeQaPTBLRAjUxZeMKvSwpZPcDPghBUGpE45JAthjH92NLdiUwSDz7NO5k24YkuwTHGZYvtKMtcSabD7wVguy37OkilU7v8rgSfjoE2c816+wkkebKOJK9NgTZ2Wpykxgu0k2IG9lTcMIBbchOx9tTWKHpBbFBoZpwbMi+iL9FtEC8wG1xIvyQJdlJhuVWinzd4kD2cJxYZlOyky3KfkHkvSoOhF+2IPu8Zdk3x82O1QV96JDumhJSu5KB4XsVEwzJziCcy2Z/8UK3K5G1PZnhDi2iBW02IDvPY501xY8BuvJ6JcY+AQzAPCDGGucZkF2GefiCxFk4AWoN2K0AG4HHiSBATWJqQMXr1Qxui3Jlv8o2nHiHIl4UFeF1+G/ACOMGuZVoYqfd12qgX7ZkuwZUMjyEoWBaxETd1y5gVDaEr/YpfGqIyW9ODsm6r7FhCY/z6T625tTpLUS2+bo3DOHZHoVdYFnOqBYmG3rbz1JNQbZ2p2MsZfAor604G8OMsUVTyEBLwjMsv4r7vkapl28AH+PEWNqu1++ZNjRPk3mFJdnjDBu4HBipVoUGsewVaGb6fjgRPSsMSQ8wNb/KjA9bEp5osIzcLUitEml6BNQxxGPoWVtROmoynmFJ+CefRvytxFaJt0W6GwwtqE8GkA56cZSSGVxiI74FhTUM9ch3f0irCerleNU3wbZL2xrJzwhp+hks0s6PaBitMsnsXk7WWlY8xKPi7fjvOZI94x/sHOQFPobGw+U4kHBvrrDVRrw2RE4L6C3V7Ln3sBg43qLeeuAxj996BxHeJCYxm2i4Gh8RMwjL/BpqgA/VpKgTgnwJuzdXtbWUWpZpntUCiwwlPDf6WBLeBSzWPO8URFjuHOthUWm1ptJFaizZErb9wvJjNaMkiLDck2CrYD8n7k13hUrCvUIYB3Vdui6I8FI1qzbjUstKXwe+EV3aBKtE40pwjsKwwQEeuoEv4d3ALNf9ycCpFpU24ngRVrvkYNN8y7Ps1rqlb3MQYXCc3m7YytOb1FCYa2lhzHbiqjAoU4s2GoG+D+Fg85VGijq/ssh7qEboqLGZB6QDvBLHdZpLnK6R0EzlgNs0hGfZVJ6v1lV3ARNzTLhYo0sfY5h3sYWy4ole7Blh16ismrnEStFok/ou05BdR8iA1QfJDN2/PoeEZZTQkwZL0RoN4bvCNiCPzONlGpVJNBe7Tu4TdX1h2bbmmLCCbMfWAvTew6iDQy/QzLReZJ/RtKk+pFiagXZqmdCdyzGG8J5Eic6aOuSe4yK8A+RGRfn2/SqqwdmbVBZBPX/gHbh2MfAbEbtbTAQEr7itehyX6DDCn6zyCZlhUHcoTc7Ltj2WHKNcLexBRvaFaqxdr0Q/k2OixmNudN9uo+BEMcsOAB4AzrXIU6vUxlrVU3YqJaMEOELZoUzW0PeBezz04JyjN07o0mZy7zD7EjiTmKAQOAfHJlyJ/xmWtsHlo1UPCI28FnoBJym9urtaYspwdrOUKkmprerC/6pl7lel/HdxlTORBB/7aIJnLSQuK40orlisUWRaNXpoxnHX1ky4DZlhTkNbc5duwAlNjLRb58f8Ky/e1wgv2dcmrr6aiSur3agFOWxsL6XM91a6crUSCWfi+H9NoDtEsIKY7YI52sNQ4D5uZpBFeTKMamScyJqeFL4L8yOjfhB5x8Rp0ppoaPEoBF4j86A/HerEfUlcCB8GXGGRvqPSZYPQIeAF7DXC/bE3fJsY2eWsvCEuhMtC9oouAROgPPxveVwIN4TM53f08tnifgfmh/nmnPC6kPk2+fx2k7ifpWb4WKAT9mG+foFvMqqvkRj+pYntFp0HPMrZj8wg1VieEd8Tc6NdFXr3TCFOgLc77TZifE7AaAOyv+MY9iS64pxBK7vyJXHWcLy8eu4T0dybo9vhBMBMJvMwwEbgzqSodnfhvxOtDieQzOv3ncRkE7UNytV4tJ295+LsnUgsugKPAt/jvQm7DmcX2+Bcj7eWRjFwAo4rtYOa1avUMrSTFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIgL8D6ed2EKeJMaTAAAAAElFTkSuQmCC";var og="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABGCAYAAACQRffVAAADInpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7VdbktwgDPznFDkCkgCJ4/AwVblBjp8GY+/OZFPZPD7yMVADWIiWUEt2jTu+fR3uCxplTi5EtZRT8mghh8wFC/Nnq2skH9a4mrS9R49yF9LeYIhkap6Pmbf8gBxr2s95G6FL/wK6FlSwim8bpWx5fZTXDcj2DLQ3hE7Lvu8DG0h4exTO57Y9Stn04Wp93xmKp8jefkGUU0ykAWNgr5oy1sY+KOLZp6PcznP31S7B9XypMnziQ0g8RpFweinzJ1IwJ4wk4qA4hUXiGlmWGTiUEG4Fbj6BR/F3MN/H5i1GP2mfuZaHkXFM5XdXu+envOn147y5VzsN3JU3lvaGPNLq0z1/KKd4AV0bctvh95at3ZYf5ENWdt3Nvad7jG5jXRq3KCEhFmlf6rrKWkGvziiuUwldfXLANSxmz+jmi2/Iqe4bKq1inYnB/aBAnQoNOtbcqMHFwAcrZubmWJbQQFLmhlQgCbPTYJUsXQwp0c4cEr59oWU2L3ONzHfnO0GVCWCEI3/c3WcVx5i1ROTtjBM8g188qxNeeAL9c4IaGKGxgxpXgK/+3CavAgbjCrPhgsVXd0LUSG/JJYvoSW/EfFY9ad8ACBFMRzhDAgZ8IomU4JEyKxECaSCowHWWwBUMUIzc4SQHkQRyUB2wjTNKS5Ujn2K8VSU4FGsSBTdZCsgKISJ/NBhyqESJIcaYokaLOZYkaVZeSprm67moaNCoSVXNadZiYsGiJVMzy1YyZ8HrO2bUabaccykwWoBccLpAoZTKVWqosaaq1Wp2tTSkTwstttS0WcutdO7SUeA9de3Wcy8HHUilIxzxSIceduSjDKTakBFGHGmoGzbyKDdrtMv2uf8Ga7RZ48XUVNSbNUhVLwiar5M4OQNjHAiEK1gDY0jsyZk3CoEnc5MzfI9QFZHhZJzkdJqMgcFwEMdBN3ebOcfl3/Dm1BZv/LfMuUndJ5n7kbePWOvzK9EWY2cZzqB6QfVh/7DCVubn9aez+5XCZ+cX0AvoBfQCegG9gP57oIEPJ/4Bue+bLIaQwqExNwAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNAHMVfU7UiFQeLijhkqE4WREUcSxWLYKG0FVp1MLn0Q2jSkKS4OAquBQc/FqsOLs66OrgKguAHiKuLk6KLlPi/pNAixoPjfry797h7Bwj1MlPNjiigapaRisfEbG5FDLyiC0EMYgIDEjP1RHohA8/xdQ8fX+8iPMv73J+jV8mbDPCJxFGmGxbxOvHMpqVz3icOsZKkEJ8Tjxt0QeJHrssuv3EuOizwzJCRSc0Rh4jFYhvLbcxKhko8TRxWVI3yhazLCuctzmq5ypr35C8M5rXlNNdpjiCORSSQhAgZVWygDAsRWjVSTKRoP+bhH3b8SXLJ5NoAI8c8KlAhOX7wP/jdrVmYmnSTgjGg88W2P0aBwC7QqNn297FtN04A/zNwpbX8lTow+0l6raWFj4C+beDiuqXJe8DlDjD0pEuG5Eh+mkKhALyf0TflgP5boGfV7a25j9MHIENdLd0AB4fAWJGy1zze3d3e279nmv39ANCccsygwwDVAAAQE2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDo0MDc4NWMzNi00MDFkLTRhNmUtOTE4Ny0wNDU1MjgyYzRkZjYiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Nzg3YjYxN2YtMjg1MS00YzhlLTg2MTYtZWM3NGMwYzYwMWVlIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZTdhYTQxY2EtM2JiMy00ZTliLTk0NDEtOWU1M2ZlMmJmMzlmIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iV2luZG93cyIKICAgR0lNUDpUaW1lU3RhbXA9IjE2ODY2MTM5NDcxOTU2ODAiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zNCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiCiAgIHhtcDpNZXRhZGF0YURhdGU9IjIwMjM6MDY6MTNUMDI6NTI6MjUrMDM6MDAiCiAgIHhtcDpNb2RpZnlEYXRlPSIyMDIzOjA2OjEzVDAyOjUyOjI1KzAzOjAwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MjczNjZiZjQtZWRkMy00MTk4LTk2MmEtZTllMzkxMGU1OGJlIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIyLTA4LTIyVDAyOjU1OjM2Ii8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjk2NWUxMzc5LTBkOWYtNDk4Mi1hZDcwLTkzOGM5YzM5YTRmMyIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOS0xMVQxNjozNTowMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMGZiYTBhMy05MjliLTQ1NGUtOGM0Yy04ZWQ4YzhhYmFkZGMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMDYtMTBUMTc6NTA6MDkiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDBmYjM4YTMtZjZiMi00NjQ1LTliMTYtMjlhNWE0ODZlMjhhIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEzVDAyOjUyOjI3Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/PsIRrtIAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgwXNBsqJURsAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAABF9JREFUeNrtmluIF1Ucxz9/E8P1VnnJ9dJWC4Frmq2JJmqolGEILoQvK2gZeXlRCSm1Fx9UEsJQERWsXhRftECs0Gq70EK9ZHlbFyHbds3VVXFX91+7664P81tYhpnfmft//st84TzMzDm/8/vOnPO7nYEMGTJkyJAhQ4YMGSJBLkJZw4FyYAIwDHgU+A9oAxqBv4C7xfyySoBlwKfAFaAb6DG0euAzoAoYXCxEnwH2A60eCGrtFrALGJNWokNEwY6QRO2tFXgPGJAmss8DlyImam/fASPTQHaeGJueBFod8FQhrfSLwM+ynDX8L1/oV+BP4LZY58eBUUAlMB94ycPSvQTMERmJ4jGgwYPh2Qg84VFmGbAP6DTI/aoQS/lzg1JfA2MDyn4ZuGaQvyZJspUGv3oKGBhyjmeBJmWOmxLMJIITiiIXIgwaZgFdylxbDeNHANXAZmAVUBpEiScNe2xRxC/3Y2WuRmUlLRHD1rd/HljvV4F3FAVqYlhNo4B7Pl/wdPEMbmOq/ShwRBH0Vkxb6LAy536fW64HuOpn8vOKoLKYCC9Q5rzs0L/JQxDjyYPkgHYXAW0xGslByrLuFuPUFw0eCI92mmiAQ4LgZoEbYyTcAZxVPsJk271ag7x6cWueCLvhfsyu8LzybKLtersUF9ywxe2BnXBnAZOUJuXZeNv1OSki3LLdzwPrgONuguw+7g7wAHjEoW+vEagAXgeelr1yUSZoCUn4hvJsqMO9byRaWyLGtFkiwOtBJnYzBKcVg/ZuSMIrlHl3RrWMnFK1OqX/q8oXOAisDqFLVxL7xonw9yHk7Q5RoxpuyLdjI3wmhLzBwMqAY0ck4SGcCNeKIQqKOTF84RtxEu4BPgohc2QM467HSRjgqBL5mBDUPU1Rnl1JwqBNUuJqrW0M+OLdYuk8Cdas38Rf4b3FR0HP/nLdZNYaioKbxSVuA6ZGQfoNvNWlO6VvEKxW5O5yGbNc4ml7ZrUtCtLjgGMSdjop9Q+wMIT8GoXwKw79ZxrKUG9r+a8flMoyr5AA4ybwo1QgggYHpZJ6Ou3Ta5IpddvufwEsVWQ2xFisCI1Nypf6RMmsIql4JI0S8bFuSs9UvmCgikeh8b6i8C/KuKOYD+VShzGSwLsprRnByYYYoSqNhE8qCv/kYfxrYjT7jmuPIC+PBWsVsl1YRzBeE45qqWGtwjo1SR0WoZ8a7KAfYa5h7/2OVaPuF1gqtS83srclpi565IAP0c+b7wOz+wPZckOc3Jt0LC52oiXABx7y6VasGnfRYgiwwRAu9raGqPLXQmAGcADvvyN+m9bgXnP4i4E9wN8+KiJ5WQG5QilumnioJP9lwHPANKw/fF7A+fxJw2ms/y9SFdiPBf4Vn9hJNL8T/iFxbyoxgej+m6zBOtnLpXlvhiXcDOyVJV8UCEL4KnBI/OnAtBP0q+ADMTq/SfshrdUFr4TzwJdY9d57WIdYzRIk1GMdeXSQIUOGDBmSwUMtd8u2ArdcUAAAAABJRU5ErkJggg==";var Bv=new ht([[0,ng],[1,og]]),Gv=i=>Bv.getOrDefault(i,""),Vv=new _l;function qv(i,t){return!i&&!t?!0:!i||!t?!1:i.scoreRow===t.scoreRow&&i.diatonicId===t.diatonicId}function Wv(i,t){return!i&&!t?!0:!i||!t?!1:i.length===t.length&&i.every((e,r)=>e===t[r])}var Ka=class{constructor(t){this.mi=t;d(this,"devicePixelRatio");d(this,"fontSize");d(this,"unitSize");d(this,"_lineWidth");d(this,"scoreEventListener");d(this,"canvas");d(this,"ctx");d(this,"mdoc");d(this,"paint",Zr.default);d(this,"cursorRect");d(this,"mousePos");d(this,"curStaffPos");d(this,"curObjects");d(this,"hilightedStaffPos");d(this,"hilightedObj");d(this,"usingTouch",!1);d(this,"onClickFn");d(this,"onMouseMoveFn");d(this,"onMouseLeaveFn");d(this,"onTouchEndFn");this.devicePixelRatio=typeof window!="undefined"?window.devicePixelRatio:1,this.fontSize=Ws.FontSize*at.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this._lineWidth=this.unitSize*.2,this.onClickFn=this.onClick.bind(this),this.onMouseMoveFn=this.onMouseMove.bind(this),this.onMouseLeaveFn=this.onMouseLeave.bind(this),this.onTouchEndFn=this.onTouchEnd.bind(this)}getMusicInterface(){return this.mi}get doc(){var t;return(t=this.mdoc)==null?void 0:t.getMusicObject()}getImageAsset(t,e){var r;return e!=null||(e=""),(r=Vv.getOrCreate(t,e,()=>{let n={src:Gv(t),color:e,loaded:!1,colorized:!1},o=new Image;return o.src=n.src,o.onload=()=>{n.img=o,this.onImageLoaded(n)},o.onerror=()=>{console.error("Failed to load image: "+n.src)},n}))==null?void 0:r.img}forceDraw(){var t;(t=this.doc)==null||t.requestFullLayout(),this.draw()}onImageLoaded(t){if(t.loaded||!t.img)return;let e=this.paint.getColor(t.color);if(t.colorized||e===""||e==="black"||e==="#000"||e==="#0000"||e==="#000000"||e==="#00000000"){this.forceDraw(),t.loaded=!0;return}let[r,n,o,s]=Zr.colorNameToRGBA(e),a=40;if(typeof document=="undefined"){console.error("Failed to colorize image: document is undefined.");return}let c=document.createElement("canvas");c.width=t.img.width,c.height=t.img.height;let u=c.getContext("2d");if(u==null){console.error("Failed to colorize image: ctx = null.");return}u.drawImage(t.img,0,0);let h=u.getImageData(0,0,c.width,c.height),l=h.data;for(let p=0;p<l.length;p+=4){let m=l[p],f=l[p+1],g=l[p+2];l[p+3]!==0&&m<a&&f<a&&g<a&&(l[p+0]=r,l[p+1]=n,l[p+2]=o)}u.putImageData(h,0,0),t.img.src=c.toDataURL("image/png"),t.img.onload=()=>{t.colorized=!0,this.onImageLoaded(t)},t.img.onerror=()=>{console.error("Failed to colorize image.")}}setDocument(t){if(this.mdoc===t)return;this.updateCursorRect(void 0);let e=this.mdoc;this.mdoc=t,e&&e.getMusicObject().setRenderContext(void 0),t&&t.getMusicObject().setRenderContext(this)}setPaint(t){this.paint=t!=null?t:Zr.default}getPaint(){return this.paint}setCanvas(t){var e,r;this.canvas!==t&&(this.canvas&&(this.canvas.removeEventListener("click",this.onClickFn),this.canvas.removeEventListener("mousemove",this.onMouseMoveFn),this.canvas.removeEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.removeEventListener("touchend",this.onTouchEndFn)),this.canvas=t,this.canvas.addEventListener("click",this.onClickFn),this.canvas.addEventListener("mousemove",this.onMouseMoveFn),this.canvas.addEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.addEventListener("touchend",this.onTouchEndFn),this.canvas.style.position="relative"),this.ctx=(r=(e=this.canvas)==null?void 0:e.getContext("2d"))!=null?r:void 0}setScoreEventListener(t){this.scoreEventListener=t}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(t){return new xl(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!qv(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new Yi("leave",this.getMusicInterface(),n.getMusicInterface(),o))}if(r&&t&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=t;this.scoreEventListener(new Yi("enter",this.getMusicInterface(),n.getMusicInterface(),o))}if(e&&t&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=t;this.scoreEventListener(new Yi("click",this.getMusicInterface(),n.getMusicInterface(),o))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!Wv(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new Hi("leave",this.getMusicInterface(),this.curObjects.map(n=>n.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Hi("enter",this.getMusicInterface(),t.map(n=>n.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Hi("click",this.getMusicInterface(),t.map(n=>n.getMusicInterface()))),this.curObjects=t,r}onClick(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),this.scoreEventListener)){let r=e.pick(this.mousePos.x,this.mousePos.y),n=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(n,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),!this.usingTouch)){let r=e.pick(this.mousePos.x,this.mousePos.y),n=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(n,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(t){if(!this.needMouseInput())return;this.mousePos=void 0;let e=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(e||r)&&this.draw()}onTouchEnd(t){this.usingTouch=!0}hilightObject(t){this.hilightedObj=t}hilightStaffPos(t){this.hilightedStaffPos=t}updateCursorRect(t){this.cursorRect=t,this.draw()}updateCanvasSize(){let{canvas:t,doc:e}=this;if(t&&e){let r=e.getRect(),n=r.width+1,o=r.height+1;t.width=n,t.height=o,t.style.width=n/this.devicePixelRatio+"px",t.style.height=o/this.devicePixelRatio+"px"}}draw(){try{let{doc:t}=this;t&&(t.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),t.drawContent())}catch(t){console.error("Render failed!",t)}}drawHilightStaffPosRect(){let{mousePos:t,hilightedStaffPos:e,unitSize:r}=this;if(!e)return;let{scoreRow:n,diatonicId:o}=e,s=n.getStaff(o);s&&(this.fillColor(this.paint.colors["hilight.staffpos"]),this.fillRect(s.row.getRect().left,s.getDiatonicIdY(o)-r,s.row.getRect().width,2*r),t!==void 0&&this.drawLedgerLines(s,o,t.x))}drawHilightObjectRect(){let{hilightedObj:t}=this;if(!t)return;let e=t.getRect();this.lineColor(this.paint.colors["hilight.object"]),this.strokeRect(e.left,e.top,e.width,e.height)}drawPlayCursor(){let{cursorRect:t}=this;t&&this.color(this.paint.colors["play.cursor"]).lineWidth(2).strokeLine(t.centerX,t.top,t.centerX,t.bottom)}txFromScreenCoord(t){return t.mul(this.devicePixelRatio)}txToScreenCoord(t){return t.div(this.devicePixelRatio)}clearCanvas(){this.ctx&&(this.ctx.canvas.style.background=this.getPaint().colors.background,this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height))}drawDebugRect(t){ig.DrawDebugRects&&this.color("red").lineWidth(1).strokeRect(t.left,t.top,t.width,t.height)}drawLedgerLines(t,e,r){let{unitSize:n}=this,o=n*at.LedgerLineWidth;if(e>=t.topLineDiatonicId+2){for(let s=t.topLineDiatonicId+2;s<=e;s+=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}else if(e<=t.bottomLineDiatonicId-2){for(let s=t.bottomLineDiatonicId-2;s>=e;s-=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}}getRestRect(t){let{unitSize:e}=this,{flagCount:r}=Tt.get(Br(t+"n")),n=0,o=0,s=0,a=0;if(Tt.equals(t,"1n"))n=e,o=e,s=0,a=e;else if(Tt.equals(t,"2n"))n=e,o=e,s=e,a=0;else if(Tt.equals(t,"4n"))n=e*1,o=e*1,s=e*3.2,a=e*3;else{let c=1-r%2;n=e*(1+r*.25),o=e*(1+r*.125),s=e*(.5+r-c),a=e*(1+r+c)}return new G(-n,0,o,-s,0,a)}drawRest(t,e,r){let{unitSize:n}=this,{flagCount:o}=Tt.get(Br(t+"n"));if(Tt.equals(t,"1n"))this.fillRect(e-n,r,n*2,n);else if(Tt.equals(t,"2n"))this.fillRect(e-n,r-n,n*2,n);else if(Tt.equals(t,"4n"))this.beginPath(),this.moveTo(e-n*.6,r-n*3.2),this.lineTo(e+n*.7,r-n*1.5),this.quadraticCurveTo(e-n*.8,r-n*.5,e+n*1,r+n*1.5),this.lineTo(e-n*1,r-n*.75),this.quadraticCurveTo(e+n*.2,r-n*1.5,e-n*.6,r-n*3.2),this.moveTo(e+n*1,r+n*1.5),this.quadraticCurveTo(e-n*.8,r+n*1,e-n*.2,r+n*2.8),this.bezierCurveTo(e-n*1.8,r+n*1.5,e-n*.6,r-n*.2,e+n*.9,r+n*1.5),this.fill(),this.stroke();else if(o>0){let s=1-o%2,a=u=>e+(-u*.25+.5)*n,c=u=>r+(u+s)*n;this.beginPath(),this.moveTo(a(1+o),c(1+o)),this.lineTo(a(-.5-o),c(-.5-o)),this.stroke();for(let u=0;u<o;u++){let h=o-u*2;this.beginPath(),this.moveTo(a(h-2.5),c(h-2.5)),this.quadraticCurveTo(a(h-.5)+n*.25,c(h-1.5),a(h-1.5)-n*1.5,c(h-1.5)),this.stroke(),this.beginPath(),this.arc(a(h-2)-n*1.5,c(h-2),n*.5,0,Math.PI*2),this.fill()}}}drawFlag(t,e){let r=t.left,o=t.right-r,s=e==="up"?t.top:t.bottom,a=e==="up"?t.bottom:t.top;this.beginPath(),this.moveTo(r,s),this.bezierCurveTo(r,s*.75+a*.25,r+o*1.5,s*.5+a*.5,r+o*.5,a),this.stroke()}color(t){return this.ctx&&(this.ctx.strokeStyle=this.ctx.fillStyle=this.paint.getColor(t)),this}lineColor(t){return this.ctx&&(this.ctx.strokeStyle=this.paint.getColor(t)),this}fillColor(t){return this.ctx&&(this.ctx.fillStyle=this.paint.getColor(t)),this}lineWidth(t){return this.ctx&&(this.ctx.lineWidth=this._lineWidth*(t!=null?t:1)),this}font(t){return this.ctx&&(this.ctx.font=t),this}beginPath(){return this.ctx&&this.ctx.beginPath(),this}stroke(){return this.ctx&&this.ctx.stroke(),this}fill(){return this.ctx&&this.ctx.fill(),this}moveTo(t,e){return this.ctx&&this.ctx.moveTo(t,e),this}lineTo(t,e){return this.ctx&&this.ctx.lineTo(t,e),this}bezierCurveTo(t,e,r,n,o,s){return this.ctx&&this.ctx.bezierCurveTo(t,e,r,n,o,s),this}quadraticCurveTo(t,e,r,n){return this.ctx&&this.ctx.quadraticCurveTo(t,e,r,n),this}fillRect(t,e,r,n){return this.ctx&&this.ctx.fillRect(t,e,r,n),this}setLineDash(t){return this.ctx&&this.ctx.setLineDash(t),this}drawImage(t,e,r,n,o){return this.ctx&&this.ctx.drawImage(t,e,r,n,o),this}ellipse(t,e,r,n,o,s,a){return this.ctx&&this.ctx.ellipse(t,e,r,n,o,s,a),this}clip(){return this.ctx&&this.ctx.clip(),this}save(){return this.ctx&&this.ctx.save(),this}restore(){return this.ctx&&this.ctx.restore(),this}rect(t,e,r,n){return this.ctx&&this.ctx.rect(t,e,r,n),this}scale(t,e){return this.ctx&&this.ctx.scale(t,e),this}strokeRect(t,e,r,n){return this.ctx&&this.ctx.strokeRect(t,e,r,n),this}fillText(t,e,r){return this.ctx&&this.ctx.fillText(t,e,r),this}getTextWidth(t,e){if(this.ctx){let r=this.ctx.font;this.ctx.font=e;let n=this.ctx.measureText(t);return this.ctx.font=r,n.width}else return H.Dom.getCanvasTextWidth(t,e)}arc(t,e,r,n,o){return this.ctx&&this.ctx.arc(t,e,r,n,o),this}fillCircle(t,e,r){return this.ctx?(this.ctx.beginPath(),this.ctx.arc(t,e,r,0,2*Math.PI),this.ctx.fill(),this):this}strokeLine(t,e,r,n){return this.ctx?(this.ctx.beginPath(),this.ctx.moveTo(t,e),this.ctx.lineTo(r,n),this.ctx.stroke(),this):this}strokePartialLine(t,e,r,n,o,s){if(!this.ctx)return this;let a=t+(r-t)*o,c=e+(n-e)*o,u=t+(r-t)*s,h=e+(n-e)*s;return this.ctx.beginPath(),this.ctx.moveTo(a,c),this.ctx.lineTo(u,h),this.ctx.stroke(),this}drawBracket(t,e){if(!this.ctx)return this;let{left:r,right:n,width:o,top:s,bottom:a,height:c,anchorY:u}=t;switch([")","]","}",">"].includes(e)&&([r,n,o]=[n,r,-o]),e){case"(":case")":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.bezierCurveTo(r-o*.2,s+c*.3,r-o*.2,s+c*.7,n,a),this.ctx.stroke();break;case"{":case"}":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.bezierCurveTo(r+o*.1,s,r+o*.8,u,r,u),this.ctx.moveTo(n,a),this.ctx.bezierCurveTo(r+o*.1,a,r+o*.8,u,r,u),this.ctx.stroke();break;case"[":case"]":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.lineTo(r,s),this.ctx.lineTo(r,a),this.ctx.lineTo(n,a),this.ctx.stroke();break;case"<":case">":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.lineTo(r,u),this.ctx.lineTo(n,a),this.ctx.stroke();break}return this}};var Ja=class{constructor(t){this.measure=t;d(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(n=>n.diatonicClass===U.getDiatonicClass(t));return r?r.accidental:void 0}setAccidental(t){this.accidentalByDiatonicId[t.diatonicId]=t.accidental}needAccidental(t){var r,n;let e=(n=(r=this.accidentalByDiatonicId[t.diatonicId])!=null?r:this.getAccidentalFromKeySignature(t.diatonicId))!=null?n:0;return t.accidental!==e}};var tc=class extends J{constructor(e,r,n,o,s){super(e);this.image=r;this.anchorX=n;this.anchorY=o;this.imageScale=s;d(this,"mi");this.mi=new Zo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:n,image:o,imageScale:s}=this,{unitSize:a}=e;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=G.createSections(c*r,c*(1-r),u*n,u*(1-n))}catch(c){this.rect=new G}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=this.rect;e.drawDebugRect(r),e.drawImage(this.image,r.anchorX-r.leftw,r.anchorY-r.toph,r.width,r.height)}};var $i=class extends J{constructor(e,r,n,o="black"){super(e);this.diatonicId=r;this.accidental=n;this.color=o;d(this,"mi");this.mi=new Xo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;switch(this.accidental){case-2:this.rect=G.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=G.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=G.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=G.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=G.createSections(r*1,r*1,r*1,r*1);break;default:throw new N(6,"Invalid accidental value: "+this.accidental)}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect);let{unitSize:r}=e,{accidental:n}=this,o=this.rect.anchorX,s=this.rect.anchorY;e.color(this.color);let a=(c,u)=>{e.lineWidth(1).beginPath().moveTo(c-r*.75,u-r*4).lineTo(c-r*.75,u+r*1.1).bezierCurveTo(c+r*.75,u-r*0,c+r*.75,u-r*2.2,c-r*.75,u-r*.5).stroke()};n===-2?(a(o-r*.5,s),a(o+r*.5,s)):n===-1&&a(o,s),n===0?e.beginPath().lineWidth(1).moveTo(o-r*.5,s-r*2.2).lineTo(o-r*.5,s+r*1).moveTo(o+r*.5,s+r*2.2).lineTo(o+r*.5,s-r*1).stroke().beginPath().lineWidth(2).moveTo(o-r*.5,s+r*1).lineTo(o+r*.5,s+r*.6).moveTo(o+r*.5,s-r*1).lineTo(o-r*.5,s-r*.6).stroke():n===1?e.lineWidth(1).beginPath().moveTo(o-r*.3,s-r*1.6).lineTo(o-r*.3,s+r*2).moveTo(o+r*.3,s-r*2).lineTo(o+r*.3,s+r*1.6).stroke().lineWidth(2).beginPath().moveTo(o-r*.75,s-r*.5).lineTo(o+r*.75,s-r*.9).moveTo(o-r*.75,s+r*.9).lineTo(o+r*.75,s+r*.5).stroke():n===2&&e.lineWidth(1).beginPath().moveTo(o-r*.75,s-r*.75).lineTo(o+r*.75,s+r*.75).moveTo(o-r*.75,s+r*.75).lineTo(o+r*.75,s-r*.75).stroke().fillRect(o-r*1,s-r*1,r*.7,r*.7).fillRect(o+r*.3,s-r*1,r*.7,r*.7).fillRect(o-r*1,s+r*.3,r*.7,r*.7).fillRect(o+r*.3,s+r*.3,r*.7,r*.7)}};var Uv=.5,ot=class extends J{constructor(e,r,n,o){var a,c,u,h,l,p;super(e);this.anchorX=n;this.anchorY=o;d(this,"text");d(this,"scale");d(this,"color");d(this,"bold");d(this,"italic");d(this,"boxed");d(this,"padding");d(this,"bgcolor");d(this,"font","");d(this,"textLines");d(this,"lineWidths",[]);d(this,"lineHeight",0);d(this,"mi");let s=typeof r=="string"?{text:r}:r;this.text=s.text,this.scale=(a=s.scale)!=null?a:1,this.color=(c=s.color)!=null?c:"black",this.bold=(u=s.bold)!=null?u:!1,this.italic=(h=s.italic)!=null?h:!1,this.boxed=(l=s.boxed)!=null?l:!1,this.padding=(p=s.padding)!=null?p:this.boxed?Uv:0,this.bgcolor=s.bgcolor,(!isFinite(this.padding)||this.padding<0)&&(this.padding=0),this.textLines=this.text.split(`
290
- `),this.textLines.length===0&&(this.textLines=[""]),this.rect=new G,this.mi=new Qo(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{scale:r,anchorX:n,anchorY:o,bold:s,italic:a}=this,c=e.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(p=>e.getTextWidth(p,this.font)),this.lineHeight=c;let u=this.padding*e.unitSize,h=u+Math.max(...this.lineWidths)+u,l=u+this.lineHeight*this.textLines.length+u;(this.boxed==="square"||this.boxed==="circle")&&(l=h=Math.max(l,h)),this.rect=G.createSections(h*n,h*(1-n),l*o,l*(1-o))}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){var b;e.drawDebugRect(this.rect),e.lineWidth(1).font(this.font);let{rect:r,padding:n,lineHeight:o,lineWidths:s,anchorX:a,anchorY:c,italic:u}=this;this.bgcolor!==void 0&&(e.save(),e.fillColor((b=this.bgcolor)!=null?b:"black"),e.beginPath(),e.fillRect(r.left,r.top,r.width,r.height),e.fill(),e.restore());let l=this.textLines.length*o,p=-o*(u?.25:.2),m=n*e.unitSize,f=(r.left+m)*(1-a)+(r.right-m)*a,g=(r.top+m)*(1-c)+(r.bottom-m)*c;switch(e.color(this.color),this.textLines.forEach((x,_)=>{let w=f-s[_]*a,T=g-l*c+o*(_+1)+p;e.fillText(x,w,T)}),this.boxed){case"square":case"rectangle":e.strokeRect(r.left,r.top,r.width,r.height);break;case"circle":case"ellipse":e.beginPath(),e.ellipse(r.centerX,r.centerY,r.width/2,r.height/2,0,0,2*Math.PI),e.stroke();break}}};var Ko=class extends J{constructor(e,r){super(e);this.measure=e;this.staff=r;d(this,"clefImage");d(this,"eightBelowClef");d(this,"measureNumber");d(this,"ksNeutralizeAccidentals",[]);d(this,"ksNewAccidentals",[]);d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new ts(this)}get doc(){return this.measure.doc}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let n=e.getPaint().getColor("staff.signature.clef");["black","#000","#000000"].includes(n)&&(n="");let o=e.getImageAsset(this.staff.clefImageAsset,n);this.clefImage=o?new tc(this,o,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new ot(this,{text:"8",color:n},.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(e){if(e){let r="staff.signature.measurenum",n=this.measure.getMeasureNumber().toString();this.measureNumber=new ot(this,{text:n,color:r},0,1)}else this.measureNumber=void 0}updateKeySignature(e){if(e){let{measure:r}=this,n="staff.signature.key",o=r.getPrevMeasure(),s=o?o.getKeySignature():void 0,a=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],s&&!rr.equals(a,s)&&s.getOrderedAccidentalNotes().forEach(c=>{this.ksNeutralizeAccidentals.push(new $i(this,this.getAccidentalDiatonicId(c),0,n))}),a.getOrderedAccidentalNotes().forEach(c=>{this.ksNewAccidentals.push(new $i(this,this.getAccidentalDiatonicId(c),c.accidental,n))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),n="staff.signature.time",o=r.beatCount.toString();this.beatCountText=new ot(this,{text:o,color:n,scale:1.4},.5,.5);let s=r.beatSize.toString();this.beatSizeText=new ot(this,{text:s,color:n,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r="staff.signature.tempo",n=ta(this.measure.getTempo());this.tempoText=new ot(this,{text:n,color:r},.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(e){let{clef:r}=this.staff.staffConfig,n;if(r==="G"?e.accidental>0?n=this.staff.bottomLineDiatonicId+3:e.accidental<0&&(n=this.staff.bottomLineDiatonicId+1):r==="F"&&(e.accidental>0?n=this.staff.bottomLineDiatonicId+1:e.accidental<0&&(n=this.staff.bottomLineDiatonicId-1)),n!==void 0)return U.findNextDiatonicIdAbove(e.diatonicId,n,!1);throw new N(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.eightBelowClef){let n=this.eightBelowClef.pick(e,r);if(n.length>0)return[this,...n]}if(this.clefImage){let n=this.clefImage.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.ksNeutralizeAccidentals.length;n++){let o=this.ksNeutralizeAccidentals[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.ksNewAccidentals.length;n++){let o=this.ksNewAccidentals[n].pick(e,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let n=this.beatCountText.pick(e,r);if(n.length>0)return[this,...n]}if(this.beatSizeText){let n=this.beatSizeText.pick(e,r);if(n.length>0)return[this,...n]}if(this.tempoText){let n=this.tempoText.pick(e,r);if(n.length>0)return[this,...n]}if(this.measureNumber){let n=this.measureNumber.pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){var u,h,l,p,m,f;let{unitSize:r}=e,{staff:n}=this,o=r,s=0;if(this.rect=new G,this.clefImage&&(s+=o,this.clefImage.layout(e),this.clefImage.setAnchor(s,n.getDiatonicIdY(n.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let g=this.clefImage.getRect();this.eightBelowClef.layout(e),this.eightBelowClef.setCenterX(g.centerX),this.eightBelowClef.setTop(Math.max(g.anchorY+g.height*.3,n.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}this.measureNumber&&(this.measureNumber.layout(e),this.measureNumber.setLeft(0),this.measureNumber.setBottom(Math.min(n.getTopLineY(),this.clefImage?this.clefImage.getRect().top:n.getTopLineY())),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),this.ksNeutralizeAccidentals.length>0&&(s+=o,this.ksNeutralizeAccidentals.forEach(g=>{g.layout(e),g.setLeft(s),g.setAnchorY(n.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(g=>{g.layout(e),g.setLeft(s),g.setAnchorY(n.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right}));let a=s;(u=this.beatCountText)==null||u.layout(e),(h=this.beatSizeText)==null||h.layout(e);let c=Math.max((p=(l=this.beatCountText)==null?void 0:l.getRect().width)!=null?p:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.setCenter(s+c/2+o,n.getDiatonicIdY(n.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.setCenter(s+c/2+o,n.getDiatonicIdY(n.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText&&(this.tempoText.layout(e),this.tempoText.setCenterX(s),this.tempoText.setBottom(n.getTopLineY()),this.clefImage&&G.overlap(this.clefImage.getRect(),this.tempoText.getRect())&&this.tempoText.setBottom(this.clefImage.getRect().top),[...this.ksNeutralizeAccidentals,...this.ksNewAccidentals].forEach(g=>{this.tempoText&&G.overlap(g.getRect(),this.tempoText.getRect())&&this.tempoText.setBottom(g.getRect().top)}),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){var n,o,s,a,c,u;(n=this.clefImage)==null||n.offset(e,r),(o=this.eightBelowClef)==null||o.offset(e,r),(s=this.measureNumber)==null||s.offset(e,r),this.ksNeutralizeAccidentals.forEach(h=>h.offset(e,r)),this.ksNewAccidentals.forEach(h=>h.offset(e,r)),(a=this.beatCountText)==null||a.offset(e,r),(c=this.beatSizeText)==null||c.offset(e,r),(u=this.tempoText)==null||u.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,n,o,s,a,c;(r=this.clefImage)==null||r.draw(e),(n=this.eightBelowClef)==null||n.draw(e),(o=this.measureNumber)==null||o.draw(e),this.ksNeutralizeAccidentals.forEach(u=>u.draw(e)),this.ksNewAccidentals.forEach(u=>u.draw(e)),(s=this.beatCountText)==null||s.draw(e),(a=this.beatSizeText)==null||a.draw(e),(c=this.tempoText)==null||c.draw(e)}},Jo=class extends J{constructor(e,r){super(e);this.measure=e;this.tab=r;d(this,"measureNumber");d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new es(this)}getMusicInterface(){return this.mi}get doc(){return this.measure.doc}updateMeasureNumber(e){if(e){let r="tab.signature.measurenum",n=this.measure.getMeasureNumber().toString();this.measureNumber=new ot(this,{text:n,color:r},0,1)}else this.measureNumber=void 0}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),n="tab.signature.time",o=r.beatCount.toString();this.beatCountText=new ot(this,{text:o,color:n,scale:1.4},.5,.5);let s=r.beatSize.toString();this.beatSizeText=new ot(this,{text:s,color:n,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r="tab.signature.tempo",n=ta(this.measure.getTempo());this.tempoText=new ot(this,{text:n,color:r},0,1)}else this.tempoText=void 0}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.beatCountText){let n=this.beatCountText.pick(e,r);if(n.length>0)return[this,...n]}if(this.beatSizeText){let n=this.beatSizeText.pick(e,r);if(n.length>0)return[this,...n]}if(this.tempoText){let n=this.tempoText.pick(e,r);if(n.length>0)return[this,...n]}if(this.measureNumber){let n=this.measureNumber.pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){var u,h,l,p,m,f;let{unitSize:r}=e,{tab:n}=this,o=r,s=0,a=n.getTopLineY();this.rect=new G,this.measureNumber&&(this.measureNumber.layout(e),this.measureNumber.setLeft(0),this.measureNumber.setBottom(a),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),(u=this.beatCountText)==null||u.layout(e),(h=this.beatSizeText)==null||h.layout(e);let c=Math.max((p=(l=this.beatCountText)==null?void 0:l.getRect().width)!=null?p:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.setCenter(0+c/2+o,n.getRect().anchorY-this.beatCountText.getRect().bottomh),this.rect.expandInPlace(this.beatCountText.getRect())),this.beatSizeText&&(this.beatSizeText.setCenter(0+c/2+o,n.getRect().anchorY+this.beatSizeText.getRect().toph),this.rect.expandInPlace(this.beatSizeText.getRect())),this.tempoText&&(this.tempoText.layout(e),this.tempoText.setLeft(s+r*2),this.tempoText.setBottom(a),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){var n,o,s,a;(n=this.measureNumber)==null||n.offset(e,r),(o=this.beatCountText)==null||o.offset(e,r),(s=this.beatSizeText)==null||s.offset(e,r),(a=this.tempoText)==null||a.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,n,o,s;(r=this.measureNumber)==null||r.draw(e),(n=this.beatCountText)==null||n.draw(e),(o=this.beatSizeText)==null||o.draw(e),(s=this.tempoText)==null||s.draw(e)}};var ec=class extends J{constructor(e,r,n){super(e);this.col=e;this.line=r;this.arpeggioDir=n;d(this,"topArrowHeight",0);d(this,"bottomArrowHeight",0);d(this,"cycleHeight",0);d(this,"numCycles",0);d(this,"color","black");d(this,"mi");this.mi=new rs(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let n=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-n)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new G(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r,topArrowHeight:n,bottomArrowHeight:o}=this;e.drawDebugRect(this.rect),e.color(this.color),e.lineWidth(2),e.beginPath();for(let s=0,a=r.top+n;s<this.numCycles;s++,a+=this.cycleHeight)e.moveTo(r.anchorX,a),e.quadraticCurveTo(r.left,a+this.cycleHeight/4,r.anchorX,a+this.cycleHeight/2),e.quadraticCurveTo(r.right,a+this.cycleHeight*3/4,r.anchorX,a+this.cycleHeight);e.stroke(),n>0&&(e.beginPath(),e.moveTo(r.anchorX,r.top),e.lineTo(r.right,r.top+n),e.lineTo(r.left,r.top+n),e.fill()),o>0&&(e.beginPath(),e.moveTo(r.anchorX,r.bottom),e.lineTo(r.left,r.bottom-o),e.lineTo(r.right,r.bottom-o),e.fill())}};function zv(i){return typeof i=="number"?U.getChromaticNote(i).diatonicId:typeof i=="string"?U.getNote(i).diatonicId:i instanceof U?i.diatonicId:void 0}var rc=class extends J{constructor(e,r){super(e);this.staff=e;this.rest=r;d(this,"restRect",new G);d(this,"dotRects",[]);d(this,"mi");e.addObject(this),this.mi=new ns(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){this.restRect.offsetInPlace(e,r),this.dotRects.forEach(n=>n.offsetInPlace(e,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.clone(),this.dotRects.forEach(e=>this.rect.expandInPlace(e))}},Zn=class Zn extends J{constructor(e,r,n,o,s){var c,u,h,l;super(e);this.col=e;this.voiceId=r;this.options=o;d(this,"color");d(this,"hide");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"setDiatonicId");d(this,"runningDiatonicId");d(this,"runningStemDir");d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"mi");this.setDiatonicId=(u=zv((c=this.options)==null?void 0:c.staffPos))!=null?u:Zn.UndefinedDiatonicId;let a=this.row.getStaves().filter(p=>p.containsVoiceId(this.voiceId));this.setDiatonicId!==Zn.UndefinedDiatonicId&&a.length>0&&a[0].isSpace(this.setDiatonicId)&&(this.setDiatonicId+=this.setDiatonicId>=a[0].middleLineDiatonicId?1:-1),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.color=(h=o==null?void 0:o.color)!=null?h:"staff.rest",this.hide=(l=o==null?void 0:o.hide)!=null?l:!1,this.oldStyleTriplet=s===void 0&&Tt.get(n).isTriplet,this.rhythmProps=Qt.get(n,void 0,(s!=null?s:this.oldStyleTriplet)?Gr.Triplet:void 0),this.mi=new is(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get noteLength(){return this.rhythmProps.noteLength}getDiatonicId(e){return this.runningDiatonicId===Zn.UndefinedDiatonicId?e?Tt.equals(this.noteLength,"1n")?e.middleLineDiatonicId+2:e.middleLineDiatonicId:U.getNote("G4").diatonicId:this.runningDiatonicId}get stemDir(){return this.runningStemDir}updateRunningArguments(e,r,n){this.runningDiatonicId=e,this.runningStemDir=r}getStaticObjects(e){let r=[];return this.staffObjects.forEach(n=>{n.staff===e&&r.push(n)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{let r=e.staff,n=e.getRect().anchorX,o=this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().anchorY-o);return{staff:r,x:n,y:o,stemHeight:s}})}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof rc&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case 1:return 1;case 2:return-1;case 4:return-1;case 8:return-1;case 16:return-1;case 32:return-3;case 64:return-3;default:throw new N(6,`Get rest dot vertical displacement: Invalid note size: ${e}`)}}updateAccidentalState(e){}layout(e,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:n}=e,{noteSize:o,dotCount:s}=this.rhythmProps;this.row.getStaves().forEach(a=>{let c=this.getDiatonicId(a);if(!a.containsDiatonicId(c)||!a.containsVoiceId(this.voiceId))return;let u=new rc(a,this);u.restRect=e.getRestRect(o);for(let h=0;h<s;h++){let l=at.DotSize*n,p=u.restRect.rightw+(at.RestDotSpace+at.DotSize*n)+h*at.DotSize*n*1.5,m=this.getRestDotVerticalDisplacement(o)*n;u.dotRects.push(G.createCentered(p,m,l,l))}u.setAnchor(0,a.getDiatonicIdY(c)),this.staffObjects.push(u),this.measure.addStaticObject(a,u)})}updateRect(){if(this.staffObjects.length===0)this.rect=new G;else if(this.rect=this.staffObjects[0].getRect().clone(),this.staffObjects.length>1)for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){if(this.staffObjects.length===0)return;e.drawDebugRect(this.getRect());let{noteSize:r}=this.rhythmProps;e.color(this.color).lineWidth(1),this.staffObjects.forEach(n=>{let{dotRects:o,restRect:s}=n;e.drawRest(r,s.anchorX,s.anchorY),o.forEach(a=>e.fillCircle(a.anchorX,a.anchorY,a.width/2))})}};d(Zn,"UndefinedDiatonicId",1/0);var ae=Zn;function Yv(i){return y.isEnumValue(i,gi)?i:i===!0?"up":void 0}function Hv(i,t){let e=H.Arr.isArray(t)?t:t!==void 0?[t]:[],r=i.map((n,o)=>({note:n,string:e[o]}));return r=H.Arr.removeDuplicates(r,(n,o)=>U.equals(n.note,o.note)).sort((n,o)=>U.compareFunc(n.note,o.note)),{sortedNotes:r.map(n=>n.note),sortedStrings:r.every(n=>n.string===void 0)?void 0:r.map(n=>n.string)}}var ic=class extends J{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;d(this,"noteHeadRects",[]);d(this,"dotRects",[]);d(this,"accidentals",[]);d(this,"stemTip");d(this,"stemBase");d(this,"flagRects",[]);d(this,"prevTopNoteY",0);d(this,"prevBottomNoteY",0);d(this,"mi");this.mi=new ss(this)}getMusicInterface(){return this.mi}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.accidentals.length;n++){let o=this.accidentals[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].clone(),this.noteHeadRects.forEach(e=>this.rect.expandInPlace(e)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(e=>this.rect.expandInPlace(e)),this.flagRects.forEach(e=>this.rect.expandInPlace(e)),this.accidentals.forEach(e=>this.rect.expandInPlace(e.getRect()))}getRect(){let e=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.anchorY||this.prevBottomNoteY!==e.anchorY)&&(this.prevTopNoteY=r.anchorY,this.prevBottomNoteY=e.anchorY,this.requestRectUpdate()),super.getRect()}offset(e,r){var n,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(e,r)),this.dotRects.forEach(s=>s.offsetInPlace(e,r)),this.accidentals.forEach(s=>s.offset(e,r)),(n=this.stemTip)==null||n.offsetInPlace(e,r),(o=this.stemBase)==null||o.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},Ih=class extends J{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;d(this,"fretNumbers",[]);d(this,"mi");this.mi=new as(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().clone(),this.fretNumbers.forEach(e=>this.rect.expandInPlace(e.getRect()))}offset(e,r){this.fretNumbers.forEach(n=>n.offset(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},xt=class i extends J{constructor(e,r,n,o,s,a){var h,l,p;super(e);this.col=e;this.voiceId=r;this.notes=n;this.options=s;d(this,"setDiatonicId");d(this,"setStringsNumbers");d(this,"runningDiatonicId");d(this,"runningStemDir");d(this,"runningStringNumbers");d(this,"color");d(this,"staccato");d(this,"diamond");d(this,"arpeggio");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"startConnnectives",[]);d(this,"runningConnectives",[]);d(this,"leftBeamCount",0);d(this,"rightBeamCount",0);d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"tabObjects",[]);d(this,"isNoteDisplaced");d(this,"mi");if(!y.isIntegerGte(n.length,1))throw new N(6,"Cannot create note group object because notes array is empty.");let{sortedNotes:c,sortedStrings:u}=Hv(n,s==null?void 0:s.string);this.notes=c,this.setStringsNumbers=u,this.isNoteDisplaced=this.notes.map(()=>!1),this.setDiatonicId=Math.round((this.minDiatonicId+this.maxDiatonicId)/2),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.runningStringNumbers=[],this.color=(h=s==null?void 0:s.color)!=null?h:"staff.note",this.staccato=(l=s==null?void 0:s.staccato)!=null?l:!1,this.diamond=(p=s==null?void 0:s.diamond)!=null?p:!1,this.arpeggio=Yv(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&Tt.get(o).isTriplet,this.rhythmProps=Qt.get(o,void 0,(a!=null?a:this.oldStyleTriplet)?Gr.Triplet:void 0),this.mi=new os(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get minDiatonicId(){return this.notes[0].diatonicId}get maxDiatonicId(){return this.notes[this.notes.length-1].diatonicId}getDiatonicId(e){return this.runningDiatonicId}get stemDir(){return this.runningStemDir}setNoteDisplacement(e,r){let n=this.notes.indexOf(e);n>=0&&(this.isNoteDisplaced[n]=r)}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof jt||e.containsDiatonicId(this.runningDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective==="tie")throw new N(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective==="slur")throw new N(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(e),this.doc.addConnectiveProps(e)}updateRunningArguments(e,r,n){this.runningDiatonicId=e===ae.UndefinedDiatonicId?this.setDiatonicId:e,this.runningStemDir=r,this.runningStringNumbers=n}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.tabObjects.length;n++){let o=this.tabObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,n,o,s){var a;if(r instanceof Mt){if(n<0||n>=this.notes.length)throw new N(6,"Invalid noteIndex: "+n);let c=this.staffObjects.find(S=>S.staff===r);if(!c||n<0||n>=c.noteHeadRects.length){let S=this.getRect();return{x:S.anchorX,y:S.bottom}}let u=c.noteHeadRects[n],h=c.stemTip,l=this.stemDir,p=h!==void 0,m=p?l==="up"?"right":"left":void 0,f=u.height/2,g=u.anchorX,b=u.anchorY,x=u.left-f,_=u.right+f,w=u.top-f,T=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!p&&(o=l==="up"?"above":"below"),o){case"center":return s==="left"?{x:_,y:b}:{x,y:b};case"above":return!p||l==="down"?{x:g,y:w}:{x:s==="left"&&m==="right"?_:s==="right"&&m==="left"?x:g,y:w};case"below":return!p||l==="up"?{x:g,y:T}:{x:s==="left"&&m==="right"?_:s==="right"&&m==="left"?x:g,y:T};case"stemTip":return{x:g,y:h.anchorY+(l==="up"?-f:f)};default:throw new N(6,"Invalid noteAnchor: "+o)}}else if(r instanceof jt){let c=(a=this.tabObjects.find(m=>m.tab===r))==null?void 0:a.fretNumbers[n];if(!c)return{x:0,y:0};let u=c.getRect(),h=s==="right"?u.left:u.right,l,p=.9;if(e.connective==="slide"){let m=e.noteGroups[0].getFretNumber(r,0),f=e.noteGroups[1].getFretNumber(r,0),g=m===void 0||f===void 0||m<=f;s==="left"?l=(g?u.anchorY+u.bottomh:u.anchorY-u.toph)*p:l=(g?u.anchorY-u.toph:u.anchorY+u.bottomh)*p}else l=u.anchorY+u.bottomh*p;return{x:h,y:l}}else return{x:0,y:0}}getFretNumberString(e){return this.runningStringNumbers[e]}getFretNumber(e,r){let n=this.tabObjects.find(s=>s.tab===e),o=n==null?void 0:n.fretNumbers[r];return o?parseInt(o.getText()):void 0}getNextNoteGroup(){let e=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof i),r=e.indexOf(this);if(r<0)return;if(r<e.length-1)return e[r+1];let n=this.measure.getNextMeasure();for(;n;){let o=n.getVoiceSymbols(this.voiceId).filter(s=>s instanceof i);if(o.length>0)return o[0];n=n.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(e=>{this.runningConnectives.push(e);let r=this.getNextNoteGroup();for(;r&&e.addNoteGroup(r);)r.runningConnectives.push(e),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let e=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return e.indexOf("first")>=0?"first":e.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{var a,c,u,h;let r=e.staff,n=(c=(a=e.stemTip)==null?void 0:a.anchorX)!=null?c:e.noteHeadRects[0].anchorX,o=(h=(u=e.stemTip)==null?void 0:u.anchorY)!=null?h:this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=this.stemDir==="up"?Math.abs(e.noteHeadRects[0].anchorY-o):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].anchorY-o);return{staff:r,x:n,y:o,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{flagCount:n,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?at.BeamSeparation:at.FlagSeparation;return(at.StemHeight+Math.max(0,n-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}setLeftBeamCount(e){this.leftBeamCount=e}setRightBeamCount(e){this.rightBeamCount=e}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ic&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(n=>n.connective==="tie").map(n=>{let o=n.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(n.span==="stub"||n.span==="toMeasureEnd")return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=o[s-1];return a&&a.notes.some(c=>U.equals(c,e))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!U.equals(u,e))),s>=0&&(o=o.slice(0,s)),H.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(e){this.notes.forEach(r=>{e.needAccidental(r)&&e.setAccidental(r)})}layout(e,r){this.requestRectUpdate();let{unitSize:n}=e,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,h=at.DotSize*n,l=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadWidth)*n,p=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadHeight)*n;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.runningDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new ic(m,this),g=m,b=m;this.notes.forEach((A,C)=>{var F;let E=C===0,q=C===this.notes.length-1,M=(F=m.getActualStaff(A.diatonicId))!=null?F:m,R=this.isNoteDisplaced[C]?l*(s==="down"?-1:1):0,B=M.getDiatonicIdY(A.diatonicId),D=M.isLine(A.diatonicId);E&&s==="up"&&(g=M),q&&s==="up"&&(b=M),E&&s==="down"&&(b=M),q&&s==="down"&&(g=M);let j=f.noteHeadRects[C]=G.createCentered(R,B,l,p);if(M.addObject(j),r.needAccidental(A)){let W=f.accidentals[C]=new $i(this,A.diatonicId,A.accidental,this.color);W&&(W.layout(e),W.setAnchor(-j.leftw-n*at.NoteAccSpace-W.getRect().rightw,B)),M.addObject(W)}for(let W=0;W<a;W++){let Q=j.right+at.NoteDotSpace*n+h/2+W*h*1.5,k=B+this.getDotVerticalDisplacement(m,A.diatonicId,s)*n,it=G.createCentered(Q,k,h,h);f.dotRects.push(it),M.addObject(it)}if(this.staccato){if(s==="up"&&E){let W=R,Q=B+n*(D?3:2),k=G.createCentered(W,Q,h,h);f.dotRects.push(k),g.addObject(k)}else if(s==="down"&&q){let W=R,Q=B-n*(D?3:2),k=G.createCentered(W,Q,h,h);f.dotRects.push(k),g.addObject(k)}}});let x=f.noteHeadRects[0].anchorY,_=f.noteHeadRects[f.noteHeadRects.length-1].anchorY,w=s==="up"?l/2:-l/2,T=this.getStemHeight(e),S=s==="up"?_-T:x+T,v=s==="up"?x:_;if(u&&(f.stemTip=new G(w,w,S,S),f.stemBase=new G(w,w,v,v),b.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let A=c===0?0:at.FlagWidth*n,C=c===0?0:at.FlagHeight*n;for(let E=0;E<c;E++){let q=E*n*at.FlagSeparation,M=f.flagRects[E]=s==="up"?new G(w,w+A,S+q,S+C+q):new G(w,w+A,S-C-q,S-q);b.addObject(M)}}this.staffObjects.push(f),this.measure.addStaticObject(m,f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new Ih(m,this),g="background",b="tab.note";this.notes.forEach((x,_)=>{let w=this.runningStringNumbers[_];if(y.isIntegerBetween(w,1,6)){let T=x.chromaticId-m.getTuningStrings()[w-1].chromaticId,S=new ot(this,{text:String(T),color:b,bgcolor:g},.5,.5);S.layout(e),S.setAnchor(this.col.getRect().anchorX,m.getStringY(w-1)),f.fretNumbers.push(S)}}),f.fretNumbers.length>0&&(this.tabObjects.push(f),m.addObject(f),this.measure.addStaticObject(m,f))})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].clone();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().clone();else{this.rect=new G;return}this.staffObjects.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tabObjects.forEach(e=>this.rect.expandInPlace(e.getRect()))}setStemTipY(e,r){let n=this.staffObjects.find(o=>o.staff===e);this.hasBeamCount()&&(n!=null&&n.stemTip)&&r!==n.stemTip.anchorY&&(n.stemTip.top=n.stemTip.anchorY=n.stemTip.bottom=r,this.requestRectUpdate(),this.col.requestRectUpdate())}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.tabObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let{stemDir:r}=this,{isSolidNoteHead:n}=this.rhythmProps;this.staffObjects.forEach(o=>{o.accidentals.forEach(s=>s.draw(e)),e.color(this.color),e.lineWidth(1),o.noteHeadRects.forEach(s=>{this.diamond?n?(e.beginPath(),e.moveTo(s.anchorX,s.top),e.lineTo(s.right,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.lineTo(s.left,s.anchorY),e.lineTo(s.anchorX,s.top),e.fill()):(e.beginPath(),e.lineWidth(2.5),e.moveTo(s.anchorX,s.top),e.lineTo(s.right,s.anchorY),e.moveTo(s.left,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.stroke(),e.beginPath(),e.lineWidth(1),e.moveTo(s.right,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.moveTo(s.anchorX,s.top),e.lineTo(s.left,s.anchorY),e.stroke()):(e.beginPath(),e.ellipse(s.anchorX,s.anchorY,s.leftw,s.toph,-.3,0,Math.PI*2),n?e.fill():e.stroke())}),o.dotRects.forEach(s=>e.fillCircle(s.anchorX,s.anchorY,s.width/2)),o.stemTip&&o.stemBase&&(e.beginPath(),e.moveTo(o.stemBase.anchorX,o.stemBase.anchorY),e.lineTo(o.stemTip.anchorX,o.stemTip.anchorY),e.stroke()),o.flagRects.forEach(s=>e.drawFlag(s,r==="up"?"up":"down"))}),this.tabObjects.forEach(o=>o.fretNumbers.forEach(s=>s.draw(e)))}getDotVerticalDisplacement(e,r,n){return e.isLine(r)?n==="up"?-1:1:0}static hasSameNotes(e,r){if(e.notes.length!==r.notes.length)return!1;for(let n=0;n<e.notes.length;n++){let o=e.notes[n],s=r.notes[n];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var kr=class extends J{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;d(this,"voiceSymbol",new vr);d(this,"lyricsObject",new Us);d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"staffMinDiatonicId",new ht);d(this,"staffMaxDiatonicId",new ht);d(this,"arpeggioDir");d(this,"arpeggios",[]);d(this,"playerProps");d(this,"needLayout",!0);d(this,"shapeRects",[]);d(this,"mi");this.playerProps=new Xn(this),this.mi=new cs(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let e=this.measure.getColumns().indexOf(this);if(e>=0&&e<this.measure.getColumnCount())return this.measure.getColumn(e+1);throw new N(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let e=this.getNextColumnInMeasure();return e||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let e=this.getNextColumnInMeasure(),r=this.positionTicks,n=e?e.positionTicks:this.measure.getConsumedTicks();return Math.max(0,n-r)}getShapeRects(){return this.forceRectUpdate(),this.shapeRects}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){let n=this.getRect().contains(e,r);for(let o=0;o<this.voiceSymbol.length;o++){let s=this.voiceSymbol.get(o);if(s instanceof ae){let a=s.pick(e,r);if(a.length>0)return n?[this,...a]:a}}if(!n)return[];for(let o=0;o<this.voiceSymbol.length;o++){let s=this.voiceSymbol.get(o);if(s instanceof xt){let a=s.pick(e,r);if(a.length>0)return[this,...a]}}for(let o=0;o<this.arpeggios.length;o++){let s=this.arpeggios[o].pick(e,r);if(s.length>0)return[this,...s]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:"up"}setVoiceSymbol(e,r){Vo(e),this.voiceSymbol.set(e,r),r instanceof ae&&!r.hide?this.row.getStaves().forEach(n=>{let o=r.getDiatonicId(n);this.minDiatonicId=this.minDiatonicId===void 0?o:Math.min(this.minDiatonicId,o),this.maxDiatonicId=this.maxDiatonicId===void 0?o:Math.max(this.maxDiatonicId,o)}):r instanceof xt&&(this.minDiatonicId=this.minDiatonicId===void 0?r.notes[0].diatonicId:Math.min(this.minDiatonicId,r.notes[0].diatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.notes[r.notes.length-1].diatonicId:Math.max(this.maxDiatonicId,r.notes[r.notes.length-1].diatonicId),r.arpeggio!==void 0&&(this.arpeggioDir=r.arpeggio),this.updateNoteDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(e){return this.voiceSymbol.get(e)}getLyricsObject(e,r,n){return this.lyricsObject.get(e,r,n)}addLyricsObject(e){this.lyricsObject.set(e.verse,e.line,e.vpos,e)}updateNoteDisplacements(){let e=[];this.voiceSymbol.forEach(n=>{n instanceof xt&&n.notes.forEach(o=>{n.setNoteDisplacement(o,!1),e.push({noteGroup:n,note:o})})});let r=(n,o)=>{let s=U.compareFunc(n.note,o.note);return s===0?n.noteGroup.stemDir===o.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1:s};if(e.sort(r),!(e.length<2)){for(let n=0;n<e.length;n++){let o=e[n],s=e[n+1];s&&o.note.diatonicId===s.note.diatonicId&&(o.isDisplaced=s.isDisplaced=!1)}for(let n=0;n<e.length;n++){let o=e[n-1],s=e[n],a=e[n+1];s.isDisplaced===void 0&&(o&&s.note.diatonicId-o.note.diatonicId<=1?s.isDisplaced=!o.isDisplaced:a&&a.note.diatonicId-s.note.diatonicId<=1&&(s.isDisplaced=!a.isDisplaced))}e.forEach(n=>{var o;return n.noteGroup.setNoteDisplacement(n.note,(o=n.isDisplaced)!=null?o:!1)})}}isEmpty(){return this.voiceSymbol.size===0||this.voiceSymbol.every(e=>e.isEmpty())}getPlayerNotes(){let e=[];function r(n,o,s,a){if(o<=0)return;e.some(u=>n.diatonicId===u.note.diatonicId&&n.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||e.push({note:n,ticks:o,staccato:s,slur:a})}return se().forEach(n=>{let o=this.getVoiceSymbol(n);if(o instanceof xt){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),e.sort((n,o)=>U.compareFunc(n.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;let{row:n}=this;this.rect=new G,this.requestRectUpdate();let o=0,s=0;if(this.voiceSymbol.forEach(h=>{h.layout(e,r);let l=h.getRect();o=Math.max(o,l.leftw),s=Math.max(s,l.rightw)}),this.arpeggioDir!==void 0){this.arpeggios=n.getNotationLines().map(l=>new ec(this,l,this.getArpeggioDir())),this.arpeggios.forEach(l=>l.layout(e));let h=this.arpeggios.map(l=>l.getRect().width).reduce((l,p)=>Math.max(l,p))+e.unitSize;this.arpeggios.forEach(l=>{l.setAnchor(-o-h/2,l.line.getRect().anchorY),l.line.addObject(l),this.measure.addStaticObject(l.line,l)}),o+=h}else this.arpeggios=[];let a=this.voiceSymbol.mapToArray(h=>h.rhythmProps.noteSize),c=Math.min(8,Math.max(1,...a)),u=Math.ceil(8/c)*at.NoteHeadWidth*e.unitSize*.75;o=Math.max(o,u/2),s=Math.max(s,u/2),o*=at.ColumnWidthScale,s*=at.ColumnWidthScale,this.rect.left=-o,this.rect.anchorX=0,this.rect.right=s,this.requestRectUpdate(),this.voiceSymbol.forEach(h=>h.updateAccidentalState(r)),this.row.getStaves().forEach(h=>{let l,p;this.voiceSymbol.forEach(m=>{if(m.visibleInStaff(h)){if(m instanceof xt)l=l===void 0?m.minDiatonicId:Math.min(l,m.minDiatonicId),p=p===void 0?m.maxDiatonicId:Math.max(p,m.maxDiatonicId);else if(m instanceof ae){let f=m.getDiatonicId(h);l=l===void 0?f:Math.min(l,f),p=p===void 0?f:Math.max(p,f)}}}),l!==void 0?this.staffMinDiatonicId.set(h,l):this.staffMinDiatonicId.delete(h),p!==void 0?this.staffMaxDiatonicId.set(h,p):this.staffMaxDiatonicId.delete(h)})}layoutReserveSpace(e){let r=this.measure.getColumns(),n=e.unitSize;this.getAnchoredLayoutObjects().forEach(o=>{if(o.layoutGroup.reserveSpace){let s=r.indexOf(this);if(s<0)return;let a=o.getRect().leftw-this.getRect().leftw;if(a>0){let u=r[s-1];u&&u.getAnchoredLayoutObjects().forEach(h=>{if(h.layoutGroupId===o.layoutGroupId){let l=h.getRect().rightw-u.getRect().rightw;this.rect.left-=Math.max(l+a,0)+n,this.requestRectUpdate()}})}let c=o.getRect().rightw-this.getRect().rightw;if(c>0){let u=r[s+1];u&&u.getAnchoredLayoutObjects().forEach(h=>{if(h.layoutGroupId===o.layoutGroupId){let l=h.getRect().leftw-u.getRect().leftw;this.rect.right+=Math.max(c+l,0)+n,this.requestRectUpdate()}})}}})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(e=>e!==void 0).mapToArray(e=>e.getRect().clone()),...this.arpeggios.map(e=>e.getRect().clone())],this.rect.top=Math.min(...this.shapeRects.map(e=>e.top)),this.rect.bottom=Math.max(...this.shapeRects.map(e=>e.bottom)),this.rect.anchorY=(this.rect.top+this.rect.bottom)/2}offset(e,r){this.voiceSymbol.forEach(n=>n.offset(e,0)),this.arpeggios.forEach(n=>n.offset(e,0)),this.shapeRects.forEach(n=>n.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.color("staff.frame"),this.row.getStaves().forEach(r=>{let n=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);n!==void 0&&e.drawLedgerLines(r,n,this.getRect().anchorX),o!==void 0&&e.drawLedgerLines(r,o,this.getRect().anchorX)}),this.voiceSymbol.forEach(r=>r.draw(e)),this.arpeggios.forEach(r=>r.draw(e))}};var Lr=class Lr extends J{constructor(e,r,n="black"){super(e);this.text=r;this.color=n;d(this,"components",[]);d(this,"mi");switch(this.text){case Lr.Coda:this.components=[new ot(this,{text:"\u{1D10C}",scale:1.7,color:n},.5,.3),new ot(this,{text:" Coda",color:n},0,1)];break;case Lr.toCoda:this.components=[new ot(this,{text:"toCoda ",color:n},1,1),new ot(this,{text:"\u{1D10C}",scale:1.7,color:n},.5,.3)];break;case Lr.Segno:this.components=[new ot(this,{text:"\u{1D10B}",scale:1.1,color:n},.5,1)];break;default:this.components=[];break}this.mi=new us(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){switch(this.text){case Lr.Coda:{let r=this.components[0],n=this.components[1];r.layout(e),n.layout(e),r.setAnchorY(n.getRect().centerY),n.setLeft(r.getRect().right),this.rect=new G(r.getRect().left,r.getRect().anchorX,n.getRect().right,n.getRect().top,n.getRect().anchorY,n.getRect().bottom);break}case Lr.toCoda:{let r=this.components[0],n=this.components[1];r.layout(e),n.layout(e),n.setAnchorY(r.getRect().centerY),r.setRight(n.getRect().left),this.rect=new G(r.getRect().left,n.getRect().anchorX,n.getRect().right,r.getRect().top,r.getRect().anchorY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(e),this.rect=r.getRect().clone();break}}}offset(e,r){this.components.forEach(n=>n.offset(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(e))}};d(Lr,"toCoda","\u{1D10C} toCoda"),d(Lr,"Coda","Coda \u{1D10C}"),d(Lr,"Segno","\u{1D10B}");var ve=Lr;function Nh(i){return i instanceof ot||i instanceof ve?i.getText():i instanceof bi?"[measure]":""}var Th=class{constructor(t){this.startColumn=t;d(this,"columnRange");d(this,"stopObject");this.columnRange=[t]}get endColumn(){return this.columnRange[this.columnRange.length-1]}addColumn(t){this.endColumn!==t&&this.columnRange.push(t)}setStopObject(t){this.stopObject=t}},nc=class nc extends Qa{constructor(e,r,n,o,s,a){super(e.musicObj);this.headObj=e;d(this,"length");d(this,"visible");d(this,"lineStyle");d(this,"linePos");d(this,"startColumn");this.length=n+1,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r}isVisible(){return this.visible}getLineStyle(){return this.lineStyle}getLinePos(){return this.linePos}whatStopped(e){let r=e.measure,n=r.getColumns(),o=e.getAnchoredLayoutObjects().filter(s=>s!==this.headObj&&s.layoutGroupId===this.headObj.layoutGroupId).map(s=>s.musicObj).filter(s=>s instanceof ot||s instanceof ve)[0];return o||(e===n[n.length-1]&&r.hasEndSection()||r.hasEndSong()||nc.StopNavigations.some(s=>r.hasNavigation(s))?r.getBarLineRight():void 0)}getRange(){let{startColumn:e,length:r}=this,n=e,o=new Th(n),s=r;for(;;){if(s<=0)return o;let a=this.whatStopped(n);if(a!==void 0)return o.setStopObject(a),o;if(s-=n.getTicksToNextColumn(),n=n.getNextColumn(),!n)return o;s>0&&o.addColumn(n)}}};d(nc,"StopNavigations",["endRepeat","ending"]);var Zi=nc;function hs(i){switch(i){case"D.C. al Coda":return"D.C. al Coda";case"D.C. al Fine":return"D.C. al Fine";case"D.S. al Coda":return"D.S. al Coda";case"D.S. al Fine":return"D.S. al Fine";case"Fine":return"Fine";case"Segno":return ve.Segno;case"Coda":return ve.Coda;case"toCoda":return ve.toCoda;default:return i[0].toUpperCase()+i.substring(1)}}function ls(i){if(/^(p+|f+|m|mp|mf)$/.test(i)){let t=.5-H.Str.charCount(i,"p")*.1+H.Str.charCount(i,"f")*.1;return H.Math.clamp(t,0,1)}else return}function sg(i){return y.isEnumValue(i,Yo)?"dynamics":y.isEnumValue(i,Ho)?"tempo":void 0}function ag(i,t){return typeof window=="undefined"?void 0:window.setTimeout(i,t)}function cg(i){typeof window!="undefined"&&window.clearTimeout(i)}var $v=2,Zv=2,Xv=.5,Qv=.5;function Kv(i,t){let e=Qt.get(t.options.beatLength,t.options.dotCount).ticks,r=t.beatsPerMinute*e;return 60*i/r}function Oh(){return ls("m")}function Jv(i){return i*1.25}var t0=.5,Xn=class{constructor(t){this.col=t;d(this,"speed");d(this,"volume");this.speed=1,this.volume=Oh()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=Oh()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=H.Math.clamp(this.getSpeed(),.1,10);return Cu(this.measure.getTempo(),t)}setVolume(t){this.volume=t}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:t}=this;if(t instanceof Ar)return this.measure.getMeasureTicks()/2;{let r=se().map(n=>t.getVoiceSymbol(n)).filter(n=>!!n).map(n=>n.rhythmProps.ticks);return r.length===0?0:H.Math.sum(r)/r.length}}},oc=class i{constructor(){d(this,"playTimer");d(this,"playPos");d(this,"playState",2);d(this,"doc");d(this,"cursorPositionChangeListener");d(this,"playStateChnageListener");d(this,"playerColumnSequence",[])}setDocument(t){this.doc=t,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(t){this.cursorPositionChangeListener=t}setPlayStateChnageListener(t){this.playStateChnageListener=t}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let t=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==t&&(this.playStateChnageListener&&this.playStateChnageListener(t),this.playState=t)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let t=[],e=this.doc.getFirstMeasure(),r=e,n,o=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=i.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation("startRepeat")&&(r=e),e.hasNavigation("Segno")&&(n=e),s&&e.hasNavigation("toCoda"))for(;e&&!e.hasNavigation("Coda");)e=e.getNextMeasure();else if(o&&e.hasNavigation("Fine"))e=void 0;else if(e.hasNavigation("D.C. al Coda"))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.C. al Fine"))o=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.S. al Coda"))s=!0,e=n;else if(e.hasNavigation("D.S. al Fine"))o=!0,e=n;else if(e.hasNavigation("endRepeat")){let u=e.getPassCount(),h=e.getEndRepeatPlayCount()-1,l=((a=e.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=h||l?e=r:e=e.getNextMeasure()}else e.hasEndSong()?e=void 0:e=e.getNextMeasure()}return t}collectPlayerColumnSequence(){let t=this.collectPlayerMeasureSequence(),e=[];for(let r=0;r<t.length;r++){let n=t[r];e=e.concat(n.getColumns()),n.hasFermata(n.getBarLineRight())&&e.push(n.getBarLineRight())}return e}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let t=1,e=Oh(),r=new ht,n=new ht,o=(a,c)=>r.getOrCreate(a,[]).push(c),s=(a,c)=>n.getOrCreate(a,[]).push(c);this.playerColumnSequence.forEach(a=>{if(!(a instanceof kr))return;a.getAnchoredLayoutObjects().forEach(h=>{let l=Nh(h.musicObj),p;if(l==="a tempo")t=1;else if((p=ls(l))!==void 0)e=p;else if(h.musicObj.getLink()instanceof Zi){let f=h.musicObj.getLink().getRange(),g=f.stopObject?Nh(f.stopObject):"",b=H.Math.sum(f.columnRange.map(x=>x.getTicksToNextColumn()));switch(l){case"accel.":{let x=t,_=x*$v,w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),o(T,x+(_-x)*w/b)});break}case"rit.":{let x=t,_=x/Zv,w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),o(T,x+(_-x)*w/b)});break}case"cresc.":{let x=e,_=x+Xv;f.stopObject&&(p=ls(g))!==void 0&&p>x&&(_=p);let w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),s(T,x+(_-x)*w/b)});break}case"decresc.":case"dim.":{let x=e,_=x-Qv;f.stopObject&&(p=ls(g))!==void 0&&p<x&&(_=p);let w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),s(T,x+(_-x)*w/b)});break}}}});let c=r.getOrDefault(a,[]);c.length>0&&(t=H.Math.sum(c)/c.length);let u=n.getOrDefault(a,[]);u.length>0&&(e=H.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(t),a.getPlayerProps().setVolume(e)})}static getMeasureByEndingPassage(t,e){for(let r=t;;r=r.getNextMeasure()){let n=r==null?void 0:r.getEnding();if(n&&n.hasPassage(e))return r;let o=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!o||o.hasNavigation("startRepeat"))return}}playStep(){if(this.notifyCursorPositionChanged(),this.notifyPlayStateChanged(),this.playPos===void 0){this.stop();return}let t=this.playerColumnSequence[this.playPos];if(!t){this.stop();return}let e=(s,a)=>{let c=Kv(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),n=t.getPlayerProps().getFermataHoldTicks(),o;t instanceof Ar?o=e(n,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?Qt.get("32n").ticks*c:0,h=e(a.ticks+n-u,r);if(h>0){a.staccato&&(h=Math.min(e(Qt.get("8n").ticks,r)/2,h/2));let l=Jv(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(l*=t0),u>0){let p=e(u,r);ag(()=>Ya(a.note,h,l),p*1e3)}else Ya(a.note,h,l)}}),o=e(t.getTicksToNextColumn()+n,r)),this.playTimer=ag(()=>this.playStep(),o*1e3),this.playPos=this.getNextPlayPosition(this.playPos),this.notifyPlayStateChanged()}play(){if(this.playState===0)this.stop();else if(this.playState===1){this.playStep();return}let{doc:t}=this;if(!t)return;t.getFirstMeasure()?(this.playPos=0,this.playStep()):this.playPos=void 0,this.notifyPlayStateChanged()}pause(){this.playTimer&&(cg(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}stop(){this.playPos=void 0,this.playTimer&&(cg(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}getNextPlayPosition(t){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let t=this.playerColumnSequence[this.playPos];if(!t)return;let e=t.measure,r=t.getRect().anchorX,{top:n,height:o}=e.row.getRect();return new du(r,n,0,o)}};var Rh=class extends J{constructor(e,r,n){super(r);this.barLine=e;this.line=r;this.rowGroup=n;d(this,"vlines",[]);d(this,"dots",[]);d(this,"mi");r.addObject(this),this.mi=new ms(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=new G(0,0,this.line.getTopLineY(),this.line.getBottomLineY()),this.vlines.forEach(e=>this.rect.expandInPlace(new G(e.left,e.left+e.width,this.rect.top,this.rect.bottom))),this.dots.forEach(e=>this.rect.expandInPlace(new G(e.x-e.r,e.x+e.r,e.y-e.r,e.y+e.r)))}offset(e,r){this.vlines.forEach(n=>n.left+=e),this.dots.forEach(n=>{n.x+=e,n.y+=r}),this.rect.offsetInPlace(e,r)}},sc=class extends J{constructor(e){super(e);this.measure=e;d(this,"notationLineObjects",[]);d(this,"notationLineObjectsByGrp",new ht);d(this,"barLineType",0)}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.notationLineObjects.length;n++){let o=this.notationLineObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}layout(e){this.requestRectUpdate(),this.barLineType=this.solveBarLineType();let{unitSize:r,_lineWidth:n}=e,{measure:o,barLineType:s}=this,{row:a}=o,c=n,u=.7*r,h=.7*r,p=at.DotSize*r/2;this.notationLineObjects=[],this.notationLineObjectsByGrp.clear(),a.getRowGroups().forEach(m=>{m.lines.forEach(f=>{let g=new Rh(this,f,m);this.notationLineObjects.push(g),this.notationLineObjectsByGrp.getOrCreate(m,[]).push(g);let b,x,_=(T,S)=>{g.vlines.push({left:T,width:S})},w=T=>{for(let S=-1;S<=1;S+=2){let v=b+S*x;g.dots.push({x:T,y:v,r:p})}};switch(f instanceof Mt?(b=f.getMiddleLineY(),x=f.getDiatonicSpacing()):(b=(f.getBottomLineY()+f.getTopLineY())/2,x=(f.getBottomLineY()-f.getTopLineY())/6),s){case 0:break;case 1:_(-c,c);break;case 2:_(-c-h-c,c),_(-c,c);break;case 3:_(-c-h-u,c),_(-u,u);break;case 4:_(0,u),_(u+h,c),w(u+h+c+h+p);break;case 5:_(-c-h-u,c),_(-u,u),w(-c-h-u-h-p);break;case 6:_(-u/2,u),_(-u/2-h-c,c),_(u/2+h,c),w(-u/2-h-c-h-p),w(u/2+h+c+h+p);break}g.forceRectUpdate()})})}updateRect(){if(this.notationLineObjects.length>0){this.rect=this.notationLineObjects[0].getRect().clone();for(let e=1;e<this.notationLineObjects.length;e++)this.rect.expandInPlace(this.notationLineObjects[e].getRect())}else this.rect=new G}offset(e,r){this.notationLineObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){this.barLineType!==0&&(e.drawDebugRect(this.getRect()),this.notationLineObjects.forEach(r=>{r.vlines.forEach(n=>r.line.drawVerticalLine(e,n.left,n.width)),r.dots.forEach(n=>e.fillCircle(n.x,n.y,n.r))}))}},xi=class extends sc{constructor(e){super(e);d(this,"mi");this.mi=new ps(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation("startRepeat")?r&&r.row===e.row&&r.hasNavigation("endRepeat")?0:4:0}},Ar=class extends sc{constructor(e){super(e);d(this,"playerProps");d(this,"mi");this.playerProps=new Xn(this),this.mi=new ds(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation("endRepeat")?r&&r.row===e.row&&r.hasNavigation("startRepeat")?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var Xi=class extends J{constructor(e,r,n){super(e);this.measure=e;this.color=r;this.passages=n;d(this,"endingText");d(this,"shapeRects",[]);d(this,"mi");if(this.mi=new fs(this),y.isIntegerGte(n.length,1)){if(!this.passages.every(s=>y.isIntegerGte(s,1)))throw new N(6,"Invalid passages: "+this.passages)}else throw new N(6,"Passages is empty.");this.passages.sort((s,a)=>s-a);let o=this.passages.map(s=>s+".").join("");this.endingText=new ot(this,{text:o,color:r},0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:e}=this,r=e.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||e.hasNavigation("endRepeat")||e.isLastMeasure()}hasPassage(e){return this.passages.some(r=>r===e)}getHighestPassage(){return Math.max(0,...this.passages)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new G,this.shapeRects=[this.rect.clone()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:n}=this;this.endingText.layout(e);let o=this.endingText.getRect(),s=n.getColumnsContentRect(),a=o.height;this.rect=new G(s.left+r,s.right-r,-a,0),this.endingText.setLeft(this.rect.left+r/2),this.endingText.setBottom(this.rect.bottom),this.shapeRects=[new G(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new G(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new G(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().clone()]}offset(e,r){this.endingText.offset(e,r),this.shapeRects.forEach(n=>n.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this;e.drawDebugRect(this.rect),e.color(this.color).lineWidth(1),e.beginPath(),e.moveTo(r.left,r.bottom),e.lineTo(r.left,r.top),e.lineTo(r.right,r.top),this.isSingleMeasureEnding()&&e.lineTo(r.right,r.bottom),e.stroke(),this.endingText.draw(e)}};var e0=(i,t)=>{let e=at.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=i/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),i/r*e}},gs=class{constructor(t,e,r,n,o){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=n;this.y=o;d(this,"topBeamsHeight",0);d(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new G(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},Mh=class extends J{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;d(this,"tupletNumber");d(this,"tupletNumberOffsetY",0);d(this,"points",[]);d(this,"mi");e.addObject(this),this.mi=new bs(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var n;this.points.forEach(o=>o.offset(e,0)),(n=this.tupletNumber)==null||n.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().clone():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().clone()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Ai=class{constructor(t,e){this.beamGroup=t;this.message=e}},Qi=class i extends J{constructor(e,r){super(e[0].measure);this.symbols=e;this.tupletRatio=r;d(this,"mi");d(this,"type");d(this,"staffObjects",[]);this.mi=new ys(this);let n=r?"Tuplet":"BeamGroup";if(e.every(o=>o.measure===e[0].measure)){if(e.length<2)throw new N(6,`${n} needs minimum 2 symbols, but ${e.length} given.`)}else throw new N(6,`All ${n} symbols are not in same measure.`);if(r!==void 0){let o=e.length<3||e.some(s=>!(s instanceof xt))||e.some(s=>s.rhythmProps.flagCount!==e[0].rhythmProps.flagCount);e.length>=3&&e[0]instanceof xt&&e[e.length-1]instanceof xt&&e[0].rhythmProps.flagCount===e[e.length-1].rhythmProps.flagCount&&(o=!1),e.some(s=>Tt.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,this.setTupletBeamCounts()}else this.type=0,this.setBeamCounts();if(e.every(o=>o.getBeamGroup()===void 0))e.forEach(o=>o.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new N(6,`Cannot add ${n} because some symbol already has one.`);if(this.type===0&&this.symbols.filter(o=>o instanceof xt).some((o,s)=>{let a=s===0,c=s===this.symbols.length-1;if(a&&o.getRightBeamCount()===0||c&&o.getLeftBeamCount()===0||!a&&!c&&(o.getLeftBeamCount()===0||o.getRightBeamCount()===0))throw new Ai(this,"Beam has zero left or right beam count!")}),e.some(o=>o.voiceId!==e[0].voiceId))throw this.type===0?new Ai(this,"Beam symbols have different voiceId."):new N(6,"Tuplet symbols have different voiceId.");e[0].row.getStaves().forEach(o=>{o.getActualStaff(e[0].getDiatonicId(o))&&o.containsVoiceId(e[0].voiceId)&&e.forEach(s=>{let a=o.getActualStaff(s.getDiatonicId(o));if(!a||!a.containsVoiceId(s.voiceId))throw new Ai(this,"Some of beam or tuplet symbols are not visible!")})})}get stemDir(){return this.symbols[0].stemDir}get showTupletRatio(){var e;return((e=this.tupletRatio)==null?void 0:e.showRatio)===!0}static createBeam(e){if(e.length>1&&e.every(r=>!r.hasTuplet()))try{return new i(e,void 0),!0}catch(r){if(r instanceof Ai)r.beamGroup.detach();else throw r}return!1}static createOldStyleTriplet(e){try{let r=e.slice(0,2),n=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(n[0]*2===n[1]||n[1]*2===n[0]))return new i(r,Gr.Triplet),2;let o=e.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);if(o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0]))return new i(o,Gr.Triplet),3}catch(r){if(r instanceof Ai)console.error(r.message),r.beamGroup.detach();else throw r}return 0}static createTuplet(e,r){try{new i(e,r)}catch(n){if(n instanceof Ai)console.error(n.message),n.beamGroup.detach();else throw n}}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(e=>e.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getTupletRatioText(){var e,r,n;return this.showTupletRatio?String((e=this.tupletRatio)==null?void 0:e.parts)+":"+String((r=this.tupletRatio)==null?void 0:r.inTimeOf):String((n=this.tupletRatio)==null?void 0:n.parts)}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get color(){return this.symbols[0].color}layout(e){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let{unitSize:n}=e,{stemDir:o,type:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var B,D;if(!c)return;let h=a.map(j=>{var F;return(F=j[u])==null?void 0:F.x}),l=a.map(j=>{var F;return(F=j[u])==null?void 0:F.y}),p=a.map(j=>{var F;return(F=j[u])==null?void 0:F.staff}),m=a.map(j=>{var F;return(F=j[u])==null?void 0:F.stemHeight}),f=r[0],g=h[0],b=l[0],x=p[0],_=r[r.length-1],w=h[h.length-1],T=l[l.length-1],S=p[l.length-1];if(g===void 0||b===void 0||x===void 0||w===void 0||T===void 0||S===void 0)return;let v=(B=m[0])!=null?B:0,A=(D=m[m.length-1])!=null?D:0;if(s!==2){let j=v<A?Math.sqrt(A-v):0,F=A<v?Math.sqrt(v-A):0;o==="up"&&(j*=-1,F*=-1),j!==0&&(b+=j,l[0]+=j),F!==0&&(T+=F,l[l.length-1]+=F)}let C=n*2*(o==="up"?-1:1),E=(T+b)/2,q=e0(w-g,T-b)/2;b=E-q,T=E+q;let M=0;l.forEach((j,F)=>{let W=h[F];if(W!==void 0&&j!==void 0){let Q=H.Math.interpolateY(g,b,w,T,W),k=j-Q;o==="up"&&k<0?M=Math.min(M,k):o==="down"&&k>0&&(M=Math.max(M,k))}}),b+=M,T+=M,l=l.map(j=>j===void 0?void 0:j+M);let R=new Mh(c,this);if(s===2){let j=n/(w-g),F=H.Math.interpolateCoord(g,b+C,w,T+C,-j),W=H.Math.interpolateCoord(g,b+C,w,T+C,1+j);R.points.push(new gs(x,this,f,F.x,F.y)),R.points.push(new gs(S,this,_,W.x,W.y)),R.tupletNumberOffsetY=0}else if(s===0||s===1){M*=.5;let j=e._lineWidth*at.BeamThickness,F=W=>{let Q=r[W];if(Q instanceof xt){let k=Q instanceof xt?Math.max(Q.getLeftBeamCount(),Q.getRightBeamCount()):0;return at.BeamSeparation*n*(o==="up"?k-1:0)}else return 0};r.forEach((W,Q)=>{let k=p[Q],it=h[Q],pt=l[Q];if(k&&it!==void 0&&pt!==void 0){let At=new gs(k,this,W,it,pt);switch(o){case"up":At.topBeamsHeight=j/2,At.bottomBeamsHeight=j/2+F(Q);break;case"down":At.topBeamsHeight=j/2+F(Q),At.bottomBeamsHeight=j/2;break}R.points.push(At)}}),R.tupletNumberOffsetY=C}this.isTuplet()&&(R.tupletNumber=new ot(this,this.getTupletRatioText(),.5,.5),R.tupletNumber.layout(e),R.tupletNumber.offset((g+w)/2,(b+T)/2+R.tupletNumberOffsetY)),R.points.length>=2&&this.staffObjects.push(R)})}updateRect(){if(this.staffObjects.length===0)this.rect=new G;else{this.staffObjects.forEach(e=>e.updateRect()),this.rect=this.staffObjects[0].getRect().clone();for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}}updateStemTips(){this.staffObjects.forEach(e=>{let r=e.points[0],n=e.points[e.points.length-1];this.type!==2&&e.points.forEach(o=>{o.symbol instanceof xt&&(o!==r&&o!==n&&(o.y=H.Math.interpolateY(r.x,r.y,n.x,n.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),e.tupletNumber&&e.tupletNumber.setAnchorY((r.y+n.y)/2+e.tupletNumberOffsetY)})}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r}=e,{stemDir:n,color:o,type:s}=this;if(s===2){e.color(o).lineWidth(1);let a=(n==="up"?1:-1)*r;this.staffObjects.forEach(c=>{let{x:u,y:h}=c.points[0],{x:l,y:p}=c.points[c.points.length-1];if(c.tupletNumber){let m=c.tupletNumber.getRect().width/(l-u)*1.2,f=H.Math.interpolateCoord(u,h,l,p,.5-m/2),g=H.Math.interpolateCoord(u,h,l,p,.5+m/2);e.strokeLine(u,h,f.x,f.y),e.strokeLine(g.x,g.y,l,p)}else e.strokeLine(u,h,l,p);e.strokeLine(u,h,u,h+a),e.strokeLine(l,p,l,p+a)})}else(s===0||s===1)&&(e.color(o).lineWidth(at.BeamThickness),this.staffObjects.forEach(a=>{let c=a.points.filter(f=>f.symbol instanceof xt),{x:u,y:h}=c[0],{x:l,y:p}=c[c.length-1],m=at.BeamSeparation*r*(n==="up"?1:-1)*(1+.5*Math.abs(Math.atan2(p-h,l-u)));for(let f=0;f<c.length-1;f++){let{x:g,y:b,symbol:x}=c[f],{x:_,y:w,symbol:T}=c[f+1],S=x.getRightBeamCount(),v=T.getLeftBeamCount();for(let A=0;A<Math.max(S,v);A++)A<S&&A<v?e.strokeLine(g,b,_,w):S>v?e.strokePartialLine(g,b,_,w,0,.25):v>S&&e.strokePartialLine(g,b,_,w,.75,1),b+=m,w+=m}}));this.staffObjects.forEach(a=>{var c;return(c=a.tupletNumber)==null?void 0:c.draw(e)})}setBeamCounts(){let e=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:h,noteSize:l,dotCount:p}=s.rhythmProps;return a>0&&h>0&&u>0&&p===0&&c*Math.pow(2,u)===l},r=this.symbols.filter(o=>o instanceof xt);for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&(a.rhythmProps.flagCount===s.rhythmProps.flagCount||e(a,s)||e(s,a)?s.setLeftBeamCount(s.rhythmProps.flagCount):s.setLeftBeamCount(Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount))),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||e(c,s)||e(s,c)?s.setRightBeamCount(s.rhythmProps.flagCount):s.setRightBeamCount(Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount))))}let n;do{n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&s.getLeftBeamCount()!==s.rhythmProps.flagCount&&s.getRightBeamCount()!==s.rhythmProps.flagCount&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&a.getRightBeamCount()>0&&(a.setRightBeamCount(0),n=!0),c&&c.getLeftBeamCount()>0&&(c.setLeftBeamCount(0),n=!0))}}while(n)}setTupletBeamCounts(){let e=this.getType(),r=this.getSymbols();e===1?r.forEach((n,o)=>{n instanceof xt&&(n.setLeftBeamCount(o===0?0:n.rhythmProps.flagCount),n.setRightBeamCount(o===r.length-1?0:n.rhythmProps.flagCount))}):e===2&&r.forEach(n=>{n instanceof xt&&(n.setLeftBeamCount(0),n.setRightBeamCount(0))})}};var Ci=class extends J{constructor(e,r,n){super(e);this.pos=r;this.color=n;d(this,"mi");this.mi=new xs(this)}getMusicInterface(){return this.mi}static getFermataPositions(e){let{measure:r}=e,{row:n}=r;return n.getTopStaff()!==n.getBottomStaff()?[0,1]:[0]}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,n=r*4,o=r*3;this.rect=new G(-n/2,n/2,-o,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{unitSize:r}=e,n=this.pos===1,o=(n?r:-r)*.7,s=this.rect.left,a=this.rect.right,c=(n?this.rect.bottom:this.rect.top)+o,u=(n?this.rect.top:this.rect.bottom)+o,h=u-c;e.drawDebugRect(this.rect),e.color(this.color).lineWidth(1),e.beginPath(),e.moveTo(s,u),e.bezierCurveTo(s,c,a,c,a,u),e.bezierCurveTo(a,c+h/5,s,c+h/5,s,u),e.stroke(),e.fill();let l=h/6;e.fillCircle((s+a)/2,u-l,Math.abs(l))}};function r0(i){return i instanceof ot||i instanceof ve}function hg(i){return i instanceof Ar||i instanceof ot||i instanceof ve}var Qn=class extends J{constructor(e,r,n,o){super(e);this.measure=e;this.line=r;this.extension=n;this.cols=o;d(this,"mi");n.addTail(this),this.mi=new As(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(e){let r=this.cols[0];if(r0(r))return r.getRect().right+e.unitSize;if(r instanceof xi)return r.getRect().anchorX;if(r instanceof kr){let n=r.measure.getColumns();if(r===n[0])return r.measure.getRect().left}return r.getRect().right}getLineRight(e){let r=this.cols[this.cols.length-1];if(hg(r))return r.getRect().left-e.unitSize;if(r instanceof kr){let n=r.measure.getColumns();if(r===n[n.length-1])return r.measure.getRect().right;let o=r.getNextColumn();if(o&&o.measure===r.measure)return(r.getRect().right+o.getRect().left)/2}return r.getRect().anchorX}layoutFitToMeasure(e){let r=e.unitSize,n=this.getLineLeft(e),o=this.getLineRight(e);[n,o]=[Math.min(n,o),Math.max(n,o)],this.rect=new G(n,o,-r/2,r/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new G}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this,n=this.extension.headObj.musicObj,o=String(n.userData["extension-color"]);this.extension.getLineStyle()==="dashed"&&e.setLineDash([7,3]),e.color(o).lineWidth(1),e.strokeLine(r.left,r.anchorY,r.right,r.anchorY),e.setLineDash([]);let s=this.extension.getTails(),a=s[s.length-1];if(this===a&&!hg(this.cols[this.cols.length-1])){let c=r.anchorY>this.line.getRect().anchorY?-e.unitSize:e.unitSize;e.strokeLine(r.right,r.anchorY,r.right,r.anchorY+c)}}};var Ki=class extends J{constructor(e,r,n,o,s,...a){var c;super(n);this.connectiveProps=e;this.measure=n;d(this,"lx",0);d(this,"ly",0);d(this,"rx",0);d(this,"ry",0);d(this,"cp1x",0);d(this,"cp1y",0);d(this,"cp2x",0);d(this,"cp2y",0);d(this,"arcHeight",0);d(this,"line");d(this,"leftNoteGroup");d(this,"leftNoteId");d(this,"rightNoteGroup");d(this,"rightNoteId");d(this,"tieType");d(this,"mi");this.line=(c=this.measure.row.findMatchingLine(r))!=null?c:r,this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof xt&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):y.isEnumValue(a[0],yr)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new Cs(this)}getMusicInterface(){return this.mi}get doc(){return this.measure.doc}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,{measure:n,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:h}=this,{noteAnchor:l,arcDir:p}=h,{row:m}=n,f=m.getPrevRow(),g=m.getNextRow(),b=m.getConnectivesContentRect(),x,_;x=s.getConnectiveAnchorPoint(h,o,a,l,"left"),c!==void 0&&u!==void 0?_=c.getConnectiveAnchorPoint(h,o,u,l,"right"):_=this.tieType==="toMeasureEnd"?{x:n.getColumnsContentRect().right,y:x.y}:{x:x.x+r*at.StubTieLength,y:x.y};let w,T,S,v;if(c===void 0)w=x.x,T=x.y,S=_.x,v=_.y;else if(s.row===m&&c.row===m)w=x.x,T=x.y,S=_.x,v=_.y;else if(s.row===f&&c.row===m){let R=f.getConnectivesContentRect().right-x.x,B=_.x-b.left;w=b.left,T=x.y+(_.y-x.y)*R/(R+B),S=_.x,v=_.y}else if(s.row===m&&c.row===g){let M=g.getConnectivesContentRect(),R=b.right-x.x,B=_.x-M.left;w=x.x,T=x.y,S=b.right,v=x.y+(_.y-x.y)*R/(R+B)}else throw new N(6,"Cannot layout connective object because no valid left and right note groups.");let C=(p==="up"?-1:1)*r*Math.log2(S-w)/3;this.lx=w,this.ly=T,this.rx=S,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:C;let{nx:E,ny:q}=H.Math.calcNormal(w,T,S,v);this.cp1x=w*.7+S*.3+E*this.arcHeight,this.cp1y=T*.7+v*.3+q*this.arcHeight,this.cp2x=w*.3+S*.7+E*this.arcHeight,this.cp2y=T*.3+v*.7+q*this.arcHeight,this.rect=new G(Math.min(this.lx,this.cp1x,this.cp2x,this.rx),Math.max(this.lx,this.cp1x,this.cp2x,this.rx),Math.min(this.ly,this.cp1y,this.cp2y,this.ry),Math.max(this.ly,this.cp1y,this.cp2y,this.ry)),this.line.addObject(this)}offset(e,r){this.lx+=e,this.ly+=r,this.rx+=e,this.ry+=r,this.cp1x+=e,this.cp1y+=r,this.cp2x+=e,this.cp2y+=r,this.rect.offsetInPlace(e,r)}draw(e){if(this.rightNoteGroup!==void 0){if(this.leftNoteGroup.measure!==this.rightNoteGroup.measure){if(this.leftNoteGroup.row.getNextRow()!==this.rightNoteGroup.row){if(this.measure!==this.rightNoteGroup.measure)return}}}let{rect:r}=this,{_lineWidth:n}=e;e.drawDebugRect(r);let o=n*1.5,s=n*.25;e.color(this.line instanceof jt?"tab.connective":"staff.connective"),e.lineWidth(1),this.arcHeight===0?(e.beginPath(),e.moveTo(this.lx,this.ly),e.lineTo(this.rx,this.ry),e.stroke()):(e.beginPath(),e.moveTo(this.lx,this.ly-s),e.bezierCurveTo(this.cp1x,this.cp1y-o,this.cp2x,this.cp2y-o,this.rx,this.ry-s),e.lineTo(this.rx,this.ry+s),e.bezierCurveTo(this.cp2x,this.cp2y+o,this.cp1x,this.cp1y+o,this.lx,this.ly+s),e.fill())}};var Kn=class{constructor(t,e,r,n){this.connective=t;this.span=e;this.noteAnchor=r;d(this,"noteGroups");d(this,"arcDir","down");this.noteGroups=[n]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(t){let{stemDir:e}=this.noteGroups[0],{hasStem:r}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=e==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=e==="up"||!r?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor="center":this.connective==="slide"?this.noteAnchor="center":this.arcDir==="up"?this.noteAnchor="above":this.noteAnchor="below";else if(this.noteAnchor==="center"){let n=t instanceof Mt?t:void 0,o=this.noteGroups[0].getDiatonicId(n);this.arcDir=!n||o<n.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(t=>{t.measure.removeConnectiveObjects(),t.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){if(this.noteGroups.length===0)return;this.getStartNoteGroup().collectConnectiveProps();let{connective:t,span:e}=this;this.noteGroups[0].row.getNotationLines().forEach(r=>{if(this.computeParams(r),t==="tie"){if(y.isEnumValue(e,yr)){let n=this.noteGroups[0];for(let o=0;o<n.notes.length;o++)this.createObjConnectiveWithTieType(r,n,o,e)}else if(this.noteGroups.length>=2)for(let n=0;n<this.noteGroups.length-1;n++){let o=this.noteGroups[n],s=this.noteGroups[n+1];o.notes.forEach((a,c)=>{let u=s.notes.findIndex(h=>U.equals(h,a));u>=0&&this.createObjConnective(r,o,c,s,u)})}}else if(t==="slur"){if(typeof e=="number"&&e>=2&&this.noteGroups.length===e){let n=this.noteGroups[0],o=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,n,0,o,0)}}else if(t==="slide"&&this.noteGroups.length>=2)for(let n=0;n<this.noteGroups.length-1;n++){let o=this.noteGroups[n],s=this.noteGroups[n+1];this.createObjConnective(r,o,0,s,0)}})}createObjConnectiveWithTieType(t,e,r,n){if(e.enableConnective(t))t instanceof Mt?new Ki(this,t,e.measure,e,r,n):t instanceof jt&&e.getFretNumberString(r)!==void 0&&new Ki(this,t,e.measure,e,r,n);else return}createObjConnective(t,e,r,n,o){let s=(a,c,u,h,l)=>{if(c.enableConnective(t)&&h.enableConnective(t)){if(t instanceof Mt)new Ki(this,t,a,c,u,h,l);else if(t instanceof jt){let p=c.getFretNumberString(u),m=h.getFretNumberString(l);p!==void 0&&m!==void 0&&(p===m||this.connective==="slur")&&new Ki(this,t,a,c,u,h,l)}}else return};if(e.measure===n.measure)s(e.measure,e,r,n,o);else if(e.measure.getNextMeasure()===n.measure)s(e.measure,e,r,n,o),s(n.measure,e,r,n,o);else throw new N(6,"Cannot create connective because it is jumping measures.")}};var ac=class extends J{constructor(e,r,n,o,s,a,c){super(e);this.col=e;this.verse=r;this.line=n;this.vpos=o;d(this,"nextLyricsObject");d(this,"rhythmProps");d(this,"color","black");d(this,"hyphen");d(this,"text");d(this,"mi");this.rhythmProps=Qt.get(s);let u=(c==null?void 0:c.align)==="left"?0:(c==null?void 0:c.align)==="right"?1:.5;this.hyphen=y.isEnumValue(c==null?void 0:c.hyphen,Hn)?c==null?void 0:c.hyphen:void 0,this.text=new ot(this,{text:a,color:this.color,scale:.8},u,0),this.rect=this.text.getRect().clone(),this.mi=new _s(this)}getMusicInterface(){return this.mi}get measure(){return this.col.measure}getText(){return this.text.getText()}setNextLyricsObject(e){this.nextLyricsObject=e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layout(e){this.text.layout(e),this.rect=this.text.getRect().clone()}offset(e,r){this.text.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r;if(this.text.draw(e),this.hyphen!==void 0){e.color(this.color).lineWidth(1);let n=this.getRect(),o=(r=this.nextLyricsObject)==null?void 0:r.getRect(),s=e.unitSize*1.5,a=o?(o.left-n.right)*.85:s,c=this.hyphen==="-"?Math.min(s,a):a;if(c>0){let u=o?(n.right+o.left)/2:n.right+c/.85,h=n.centerY;e.moveTo(u-c/2,h),e.lineTo(u+c/2,h),e.stroke()}}}};var Jn=class extends J{constructor(e,r){super(e);this.measure=e;this.tab=r;d(this,"voiceId");d(this,"mi");d(this,"tupletPartsTextObjMap",new ht);this.voiceId=se().filter(n=>r.containsVoiceId(n)),this.rect=new G,this.mi=new vs(this)}getMusicInterface(){return this.mi}get doc(){return this.measure.doc}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let r=this.measure.getColumns(),n=se().map(o=>H.Math.sum(r.map(s=>s.getVoiceSymbol(o)?1:0)));this.voiceId.sort((o,s)=>H.Math.cmp(n[o],n[s])),this.rect=new G}hasTuplets(){return this.measure.getBeamGroups().some(e=>e.isTuplet())}layoutFitToMeasure(e){let{unitSize:r,fontSize:n}=e,{measure:o}=this,s=o.getColumnsContentRect(),a=r*5;this.rect.left=s.left,this.rect.anchorX=s.centerX,this.rect.right=s.right,this.rect.top=this.hasTuplets()?-n:0,this.rect.anchorY=0,this.rect.bottom=a}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),e.lineWidth(1);let{unitSize:r,fontSize:n}=e,o=r,s=r,a=r*.25,{bottom:c,anchorY:u}=this.getRect(),h=u,l=c,p=this.measure.getColumns();for(let m=0;m<p.length;m++){let f=p[m],g=this.voiceId.map(_=>f.getVoiceSymbol(_)).find(_=>_!==void 0);if(!g)continue;let b=g.getBeamGroup(),x=b?b.getSymbols():[g];for(let _=0;_<x.length;_++){let w=x[_],T=x[_+1],S=w.col.getRect().anchorX;if(w instanceof xt){if(e.lineWidth(1),e.color("tab.note"),w.rhythmProps.noteSize>=2&&(e.lineWidth(w.rhythmProps.noteSize===4?2:1),e.strokeLine(S,l,S,h)),x.length===1)for(let v=0;v<w.rhythmProps.flagCount;v++)e.drawFlag(new G(S,S+o,h+v*o,h+(v+2)*o),"up");for(let v=0;v<w.rhythmProps.dotCount;v++)e.fillCircle(S+s*(v+1),l-a,a)}else if(w instanceof ae){e.lineWidth(1),e.color("tab.rest");let v=S,A=(h+l)/2,C=.65;e.save(),e.scale(C,C),e.drawRest(w.rhythmProps.noteSize,v/C,A/C),e.restore();for(let E=0;E<w.rhythmProps.dotCount;E++)v+=s*1.5,e.fillCircle(v,A+s,a)}if(T){let v=w,A=T,C=v.col.getRect().anchorX,E=A.col.getRect().anchorX,q=v.hasTuplet()?1:v instanceof xt?v.getRightBeamCount():1,M=A.hasTuplet()?1:A instanceof xt?A.getLeftBeamCount():1,R=Math.max(q,M);e.color("tab.note"),e.lineWidth(2);for(let B=0;B<R;B++){let D=M>q&&B>=q?.75:0,j=q>M&&B>=M?.25:1;e.strokePartialLine(C,h+B*o,E,h+B*o,D,j)}e.lineWidth(1);for(let B=0;B<v.rhythmProps.dotCount;B++)e.fillCircle(C+s*(B+1),l-a,a);for(let B=0;B<A.rhythmProps.dotCount;B++)e.fillCircle(E+s*(B+1),l-a,a)}if(b&&b.isTuplet()){e.color("tab.note");let v=(x[0].col.getRect().anchorX+x[x.length-1].col.getRect().anchorX)/2,A=b.getTupletRatioText(),C=this.tupletPartsTextObjMap.get(A);C||(this.tupletPartsTextObjMap.set(A,C=new ot(this,{text:A,scale:.75},.5,.5)),C.layout(e)),C.setCenter(v,h-n/2),C.draw(e)}x.length>1&&(m=p.indexOf(x[x.length-1].col),m<0&&(m=p.length))}}}};function i0(i){switch(i){case"bottom":return .8;case"middle":return .5}}function n0(i){if(typeof i=="string"&&(i=[i]),y.isArray(i)){let t=0;for(let e=0;e<i.length;){let r=i[e],n=i[e+1];if(typeof r=="string"){e++;let o=Qt.get(r).ticks;typeof n=="number"&&(e++,o*=n),t+=o}else e++}return t}else return i}function o0(i){switch(i){case 1:return 8;case 2:return 9;case 3:return 10;default:throw new N(0,"VerseNumber is not 1, 2 or 3.")}}var Eh=class{constructor(){d(this,"tabTuning_0",0);d(this,"signature_1",0);d(this,"leftBarLine_2",0);d(this,"padding_3",0);d(this,"columnsMin_4",0);d(this,"padding_5",0);d(this,"rightBarLine_6",0)}get leftSolid(){return this.tabTuning_0+this.signature_1+this.leftBarLine_2+this.padding_3}get columnsMin(){return this.columnsMin_4}get rightSolid(){return this.padding_5+this.rightBarLine_6}},bi=class extends J{constructor(e,r){super(e);this.row=e;this.options=r;d(this,"prevMeasure");d(this,"nextMeasure");d(this,"keySignature",$s());d(this,"timeSignature",Ks());d(this,"tempo",Js());d(this,"alterKeySignature");d(this,"alterTimeSignature");d(this,"alterTempo");d(this,"signatures",[]);d(this,"tabStringNotes",[]);d(this,"barLineLeft");d(this,"columns",[]);d(this,"barLineRight");d(this,"connectives",[]);d(this,"beamGroups",[]);d(this,"measureId");d(this,"regions",new Eh);d(this,"needLayout",!0);d(this,"voiceSymbols",Ys(new vr));d(this,"lastAddedRhythmColumn");d(this,"lastAddedRhythmSymbol");d(this,"addExtensionTo",[]);d(this,"layoutObjects",[]);d(this,"postMeasureBreakWidth",0);d(this,"passCount",0);d(this,"needBeamsUpdate",!0);d(this,"navigationSet",new zs);d(this,"isEndSong",!1);d(this,"isEndSection",!1);d(this,"endRepeatPlayCount",2);d(this,"endRepeatPlayCountText");d(this,"staticObjectsCache",new ht);d(this,"lyricsObjectsCache",new Us);d(this,"mi");this.mi=new ws(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new xi(this),this.barLineRight=new Ar(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo(),this.row.getTabs().forEach(n=>{this.addLayoutObject(new Jn(this,n),n,0,0)})}getMusicInterface(){return this.mi}get doc(){return this.row.doc}isPartialMeasure(){return this.getConsumedTicks()<this.getMeasureTicks()}isUpBeat(){return this===this.doc.getFirstMeasure()}resetPassCount(){this.passCount=0}incPassCount(){this.passCount++}getPassCount(){return this.passCount}updateRunningArguments(e){var n;e!=null||(e=[]);let r=H.Math.sum(se().map(o=>this.getVoiceSymbols(o).length>0?1:0));se().forEach(o=>{var h;let s=()=>{let l=this.row.getStaves().filter(m=>m.containsVoiceId(o)),p=this.row.getTabs().filter(m=>m.containsVoiceId(o));return l.length>0?l[0].middleLineDiatonicId:p.length>0?p[0].getTuningStrings()[3].diatonicId:U.getNote("G4").diatonicId},a=()=>"auto",c=()=>[],u=(h=e[o])!=null?h:e[o]={diatonicId:s(),stemDir:a(),stringNumbers:c()};this.getVoiceSymbols(o).forEach((l,p,m)=>{var b,x;if(l.setDiatonicId===ae.UndefinedDiatonicId?r<2&&(u.diatonicId=ae.UndefinedDiatonicId):u.diatonicId=l.setDiatonicId,l instanceof xt)switch(l.setStringsNumbers&&(u.stringNumbers=l.setStringsNumbers),(b=l.options)==null?void 0:b.stem){case"up":case"up":u.stemDir="up";break;case"down":case"down":u.stemDir="down";break;case"auto":case"auto":u.stemDir="auto";break}let f=(x=l.getBeamGroup())==null?void 0:x.getSymbols(),g;f===void 0?g=u.stemDir==="auto"?this.row.solveAutoStemDir([l]):u.stemDir:l===f[0]?g=u.stemDir==="auto"?this.row.solveAutoStemDir(f):u.stemDir:g=f[0].stemDir,l.updateRunningArguments(u.diatonicId,g,u.stringNumbers)})}),(n=this.getNextMeasure())==null||n.updateRunningArguments(e)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.signatures.length;n++){let o=this.signatures[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.tabStringNotes.length;n++){let o=this.tabStringNotes[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.columns.length;n++){let o=this.columns[n].pick(e,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let n=this.barLineLeft.pick(e,r);if(n.length>0)return[this,...n]}if(this.barLineRight){let n=this.barLineRight.pick(e,r);if(n.length>0)return[this,...n]}if(this.endRepeatPlayCountText){let n=this.endRepeatPlayCountText.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.connectives.length;n++){let o=this.connectives[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.beamGroups.length;n++){let o=this.beamGroups[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.layoutObjects.length;n++){let o=this.layoutObjects[n].musicObj.pick(e,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let e=this.doc.getFirstMeasure();return e&&e.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(e){return this.getColumns()[e]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}isFirstMeasureInRow(){return this===this.row.getFirstMeasure()}isLastMeasureInRow(){return this===this.row.getLastMeasure()}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...e){var r;if((r=this.getPrevMeasure())==null||r.endSection(),e[0]instanceof rr)this.alterKeySignature=e[0];else if(e[0]instanceof ii)this.alterKeySignature=e[0];else if(y.isNonEmptyString(e[0])){if(e.length===1)this.alterKeySignature=Pr(e[0]);else if(e.length===2)try{let n=""+e[0],o=po(""+e[1]);this.alterKeySignature=Pr(n,o)}catch(n){throw new N(6,"Cannot set key signature because invalid args: "+e)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:$s(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(e){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=e,this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:Ks(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r){var n;if((n=this.getPrevMeasure())==null||n.endSection(),r===void 0)this.alterTempo={beatsPerMinute:e};else{let o=Tt.get(r).dotCount,s={beatLength:Br(r),dotCount:o>0?o:void 0};this.alterTempo={beatsPerMinute:e,options:s}}this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:Js(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,n,o;this.alterTempo.options?(n=this.alterTempo.options.beatLength,o=(e=this.alterTempo.options.dotCount)!=null?e:0):this.alterTimeSignature?(n=this.alterTimeSignature.beatLength,o=0):(n=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:n,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,n,o){let s=new uc(e,r,n,o);return this.layoutObjects.push(s),this.requestLayout(),this.requestRectUpdate(),s}forEachStaffGroup(e,r,n){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&n(o[a],c);else if(typeof a=="string"&&a.length>0){let h=o.filter(l=>l.name===a);if(h.forEach(l=>n(l,c)),h.length===0){let l=this.doc.getStaffGroup(a);if(l&&!u.includes(a)){let p=[...u,a];(y.isArray(l.staffsTabsAndGroups)?l.staffsTabsAndGroups:[l.staffsTabsAndGroups]).forEach(m=>{switch(l.verticalPosition){case"above":s(m,0,p);break;case"below":s(m,1,p);break;case"both":s(m,0,p),s(m,1,p);break;case"auto":s(m,r,p);break}})}}}};e===void 0?o.length>=2&&o[0]instanceof Mt&&o[1]instanceof Mt&&o[0].staffConfig.grandId!==void 0&&o[0].staffConfig.grandId===o[1].staffConfig.grandId?s(r===1?1:0,r):s(0,r):y.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let n=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!n)throw new N(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(o,s)=>{let a=o instanceof jt?"staff.element.fermata":"tab.element.fermata";this.addLayoutObject(new Ci(n,s,a),o,1,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof Ci&&r.anchor===e)}addNavigation(e,r,...n){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new N(6,"Cannot add ending beasure measure already has one.");let s=this,a=n;o={createObj:c=>{let u=c instanceof jt?"staff.element.navigation":"tab.element.navigation";return new Xi(s,u,a)},layoutGroupId:4,defaultVerticalPos:0};break;case"D.C. al Coda":case"D.C. al Fine":case"D.S. al Coda":case"D.S. al Fine":{let c=this.barLineRight,u=hs(r);o={createObj:h=>{let l=h instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ot(c,{text:u,color:l},1,1)},layoutGroupId:3,defaultVerticalPos:0},this.addNavigation(e,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=hs(r);o={createObj:h=>{let l=h instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ot(c,{text:u,color:l},1,1)},layoutGroupId:3,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=hs(r);o={createObj:h=>{let l=h instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ve(c,u,l)},layoutGroupId:3,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=hs(r);o={createObj:h=>{let l=h instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ve(c,u,l)},layoutGroupId:3,defaultVerticalPos:0};break}case"endRepeat":if(n.length===0)this.endRepeatPlayCount=2;else if(y.isIntegerGte(n[0],2))this.endRepeatPlayCount=n[0];else throw new N(6,"Invalid end repeat play count (should be 2 or greater integer): "+n[0]);if(this.endRepeatPlayCount!==2){let u={text:`${this.endRepeatPlayCount}x`,scale:.8,color:"staff.frame"};this.endRepeatPlayCountText=new ot(this,u,.5,1)}break}o&&this.forEachStaffGroup(e,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(s),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,n){let o=this.lastAddedRhythmColumn;if(o){if(n.length===0)throw new N(6,"Cannot add annotation because annotation text is empty.")}else throw new N(6,"Cannot add annotation because anchor is undefined.");let s={text:n},a,c,u;switch(r){case"dynamics":a=6,c=0,s.italic=!0,u="bottom";break;case"tempo":a=5,c=0,s.italic=!0,u="bottom";break}let h=.5,l=i0(u);this.disableExtension(),this.forEachStaffGroup(e,c,(p,m)=>{let f=p instanceof jt?"tab.element.annotation":"staff.element.annotation";s.color=f;let g=new ot(o,s,h,l),b=this.addLayoutObject(g,p,a,m);this.enableExtension(b,f)})}addLabel(e,r,n){let o=this.lastAddedRhythmColumn;if(o){if(n.length===0)throw new N(6,"Cannot add label because label text is empty.")}else throw new N(6,"Cannot add label because anchor is undefined.");let s={text:n},a,c;switch(r){case"note":a=2,c=1;break;case"chord":a=7,c=0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,h)=>{let l=u instanceof jt?"staff.element.label":"tab.element.label";s.color=l;let p=new ot(o,s,.5,1),m=this.addLayoutObject(p,u,a,h);this.enableExtension(m,l)})}addConnective(e,...r){let n=this.lastAddedRhythmSymbol;if(!(n instanceof xt))throw new N(6,"Connective can be added to note group only.");if(e==="tie"){let o=y.isInteger(r[0])||y.isEnumValue(r[0],yr)?r[0]:2,s=y.isEnumValue(r[1],Ke)?r[1]:"auto";n.startConnective(new Kn("tie",o,s,n))}else if(e==="slur"){let o=y.isInteger(r[0])?r[0]:2,s=y.isEnumValue(r[1],Ke)?r[1]:"auto";n.startConnective(new Kn("slur",o,s,n))}else if(e==="slide"){let o=y.isEnumValue(r[0],Ke)?r[0]:"auto";n.startConnective(new Kn("slide",2,o,n))}}addExtension(e,r){if(this.addExtensionTo.forEach(n=>{let{layoutObj:o,color:s}=n,{musicObj:a}=o;a.userData["extension-color"]=s;let c=a.getParent();if(a instanceof ot&&c instanceof kr){let u="dashed",h="bottom",l=new Zi(o,c,n0(e),r,u,h);a.setLink(l)}else throw new N(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionTo.length===0)throw new N(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(e,r){this.addExtensionTo.push({layoutObj:e,color:r})}disableExtension(){this.addExtensionTo=[]}getEnding(){return this.layoutObjects.map(e=>e.musicObj).find(e=>e instanceof Xi)}getEndRepeatPlayCount(){return this.endRepeatPlayCount}endSong(){this.isEndSong=!0,this.requestLayout(),this.disableExtension()}hasEndSong(){return this.isEndSong}endSection(){this.isEndSection=!0,this.requestLayout(),this.disableExtension()}hasEndSection(){return this.isEndSection}endRow(){this.doc.requestNewRow(),this.disableExtension()}addRhythmSymbol(e){let{col:r,voiceId:n}=e;r.setVoiceSymbol(n,e),this.voiceSymbols.add(n,e),e.oldStyleTriplet&&this.createOldStyleTriplets(n),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=r,this.lastAddedRhythmSymbol=e}addNoteGroup(e,r,n,o,s){let a=r.map(h=>typeof h=="string"?U.getNote(h):h),c=this.getRhythmColumn(e),u=new xt(c,e,a,n,o,s);return this.addRhythmSymbol(u),u}addRest(e,r,n,o){let s=this.getRhythmColumn(e),a=new ae(s,e,r,n,o);return this.addRhythmSymbol(a),a}addLyrics(e,r,n,o,s){this.forEachStaffGroup(e,1,(a,c)=>{var p;let u=this.getRhythmColumn({verse:r,line:a,vpos:c}),h=new ac(u,r,a,c,Br(n),o,s);u.addLyricsObject(h);let l=this.lyricsObjectsCache.getOrCreate(a,c,r,[]);l.push(h),l.sort((m,f)=>H.Math.cmp(m.col.positionTicks,f.col.positionTicks)),(p=h.measure.getPrevLyricsObject(h))==null||p.setNextLyricsObject(h),this.addLayoutObject(h,a,o0(r),c),this.lastAddedRhythmColumn=u})}getRhythmColumn(e){let r=0;for(let n=this.columns.length-1;n>=0&&r===0;n--){let o=this.columns[n],s=typeof e=="number"?o.getVoiceSymbol(e):o.getLyricsObject(e.verse,e.line,e.vpos);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let n=0;n<=this.columns.length;n++){let o=this.columns[n];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new kr(this,r);return this.columns.splice(n,0,s),s}}throw new N(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(n=>{se().forEach(o=>{let s=n.getVoiceSymbol(o);s&&(e===void 0||e===o)&&(r=Math.max(r,n.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new G(this.barLineLeft.getRect().anchorX,this.barLineRight.getRect().anchorX,this.getRect().top,this.getRect().bottom)}getLeftSolidWidth(){return this.regions.leftSolid}getMinColumnsWidth(){return this.regions.columnsMin}getRightSolidWidth(){return this.regions.rightSolid}getTotalSolidWidth(){return this.getLeftSolidWidth()+this.getRightSolidWidth()}getMinWidth(){return this.getLeftSolidWidth()+this.getMinColumnsWidth()+this.getRightSolidWidth()}getStaffLineLeft(){let e=this.getPrevMeasure();return e&&e.row===this.row&&!e.hasPostMeasureBreak()?e.getStaffLineRight():this.getRect().left+this.regions.tabTuning_0}getStaffLineRight(){return this.barLineRight.getRect().anchorX}getPrevLyricsObject(e){var c;let{line:r,verse:n,vpos:o}=e,s=this.lyricsObjectsCache.getOrDefault(r,o,n,[]),a=s.indexOf(e);if(a>0)return s[a-1];if(a===0){let u=(c=e.measure.getPrevMeasure())==null?void 0:c.lyricsObjectsCache.get(r,o,n);if(u&&u.length>0)return u[u.length-1]}}getStaticObjects(e){let r=this.layoutObjects.filter(o=>o.line===e&&o.isPositionResolved()).map(o=>o.musicObj),n=r.length>0?[...this.staticObjectsCache.getOrDefault(e,[]),...r]:this.staticObjectsCache.getOrDefault(e,[]);return n.forEach(o=>o.getRect()),n}addStaticObject(e,r){this.staticObjectsCache.getOrCreate(e,[]).push(r)}removeLayoutObjects(e){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===e){let n=r.musicObj.getLink();return n&&n.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(e){this.connectives.push(e),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(e=>{let{musicObj:r,measure:n,layoutGroupId:o,verticalPos:s,line:a}=e;if(r.getLink()instanceof Zi){let c=r.getLink();if(c.getHead()!==r||(c.getTails().forEach(l=>n.removeLayoutObjects(l)),!c.isVisible()))return;let u=c.getRange(),h=u.columnRange.slice();for(let l=!0;h.length>1;l=!1){let{measure:p}=h[0],m=h.findIndex(_=>_.measure!==p),f=h.splice(0,m>0?m:h.length);if(f.length<2)continue;let g=p.row.findMatchingLine(a);if(!g)continue;let b=h.length===0,x=[...l?[r]:[],...f,...b&&u.stopObject?[u.stopObject]:[]];p.addLayoutObject(new Qn(p,g,c,x),g,o,s)}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);for(let n=0;n<r.length;)if(r[n].oldStyleTriplet){let o=Qi.createOldStyleTriplet(r.slice(n,n+3));n+=o===0?1:o}else n++;this.requestLayout()}getBeamGroups(){return this.beamGroups}createBeams(){if(!this.needBeamsUpdate)return;this.beamGroups=this.beamGroups.filter(r=>r.isTuplet()?!0:(r.detach(),!1));let e=this.getTimeSignature();!this.needBeamsUpdate||e.beamGroupSizes.length===0||(se().forEach(r=>{let n=this.getVoiceSymbols(r).slice();if(n.length<2)return;let o=this.isUpBeat()?Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()):0,s=0;for(let a=0;a<e.beamGroupSizes.length;a++){let c=e.beamGroupSizes[a],u=[c];c.length>1&&u.unshift([H.Math.sum(c)]);let h=!1,l=s;for(;u.length>0&&!h;){let p=u.shift();s=l,p.forEach(m=>{let f=m*Tt.get("8n").ticks,g=s+f,b=n.filter(_=>{let w=o+_.col.positionTicks,T=w+_.rhythmProps.ticks;return w>=s&&T<=g});H.Math.sum(b.map(_=>_.rhythmProps.ticks))===f&&b.every(_=>_ instanceof xt)&&(b.every(_=>_.rhythmProps.flagCount===1)||u.length===0)&&Qi.createBeam(b)&&(h=!0),s+=f})}}}),this.needBeamsUpdate=!1,this.requestLayout())}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return this.voiceSymbols.getAll(e)}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(se().filter(r=>this.getConsumedTicks(r)>0));return}else if(y.isArray(e)){e.forEach(r=>this.completeRests(r));return}else{Vo(e);let r=this.getMeasureTicks(),n=this.getConsumedTicks(e),o=r-n,s=[];for(;o>0;)for(let a=Tt.LongestNoteSize;a<=Tt.ShortestNoteSize;a*=2){let c=Tt.create(a).noteLength;for(let u=Tt.get(c).maxDotCount;u>=0;u--){let h=Qt.get(c,u);for(;h.ticks<=o;)s.push(h),o-=h.ticks}}s.reverse().forEach(a=>this.addRest(e,Tt.create(a.noteLength,a.dotCount).noteLength))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?at.PostMeasureBreakWidth*r:0;let n=this.isFirstMeasureInRow(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.regions.tabTuning_0=n&&this.row.hasTab?r*4:0;let s=n||o,a=this.options.showNumber===!1?!1:this.options.showNumber===!0||n&&!this.row.isFirstRow(),c=n||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,h=!!this.alterTempo;this.signatures=[],this.row.getNotationLines().forEach((f,g)=>{if(f instanceof Mt&&(s||a||c||u||h)){let b=this.signatures.filter(_=>_ instanceof Ko).find(_=>_.staff===f),x=b!=null?b:new Ko(this,f);x.staff.addObject(x),x.updateClefImage(e,s),x.updateMeasureNumber(a&&g===0),x.updateKeySignature(c),x.updateTimeSignature(u),x.updateTempo(h&&g===0),x.layout(e),this.signatures.push(x)}else if(f instanceof jt&&(a||u||h)){let b=this.signatures.filter(_=>_ instanceof Jo).find(_=>_.tab===f),x=b!=null?b:new Jo(this,f);x.tab.addObject(x),x.updateMeasureNumber(a&&g===0),x.updateTimeSignature(u),x.updateTempo(h&&g===0),x.layout(e),this.signatures.push(x)}}),this.tabStringNotes.length=0,this.isFirstMeasureInRow()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let b=f.getTuningStrings()[g].format(1,1),x=new ot(this,{text:b,scale:.8,color:"tab.tuning"},1,.5);x.layout(e),x.setRight(this.regions.tabTuning_0*.8),x.setCenterY(f.getStringY(g)),this.tabStringNotes.push(x),f.addObject(x)}}),this.barLineLeft.layout(e);let l=new Ja(this);this.columns.forEach(f=>f.layout(e,l)),this.columns.forEach(f=>f.layoutReserveSpace(e)),this.barLineRight.layout(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(e),this.layoutObjects.forEach(f=>f.layout(e));let p=e.unitSize;this.regions.signature_1=Math.max(0,...this.signatures.map(f=>f.getRect().width)),this.regions.leftBarLine_2=this.barLineLeft.getRect().width,this.regions.padding_3=p,this.regions.columnsMin_4=Math.max(at.MinColumnsWidth*r,this.columns.map(f=>f.getRect().width).reduce((f,g)=>f+g,0)),this.regions.padding_5=p,this.regions.rightBarLine_6=this.barLineRight.getRect().width}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new G,this.rect.anchorX=this.rect.left+r/2,this.rect.right=this.rect.left+r,this.signatures.forEach(l=>{l.setLeft(this.rect.left+this.regions.tabTuning_0),l.setAnchorY(this.rect.anchorY)});let n=Math.max(0,...this.signatures.map(l=>l.getRect().width));this.barLineLeft.setLeft(this.rect.left+this.regions.tabTuning_0+n),this.barLineLeft.setAnchorY(this.rect.anchorY),this.barLineRight.setRight(this.rect.right),this.barLineRight.setAnchorY(this.rect.anchorY),this.endRepeatPlayCountText&&(this.endRepeatPlayCountText.setCenterX(this.barLineRight.getRect().left),this.endRepeatPlayCountText.setBottom(this.barLineRight.getRect().top));let o=this.rect.left+this.regions.leftSolid,a=this.rect.right-this.regions.rightSolid-o,c=this.regions.columnsMin,u=a/c,h=o;this.columns.forEach(l=>{let p=l.getRect(),m=h+p.leftw*u;l.setAnchor(m,this.rect.anchorY),h+=p.width*u}),se().forEach(l=>{let p=this.getVoiceSymbols(l),m=p.length===1&&p[0]instanceof ae?p[0]:void 0;!m||se().map(g=>m.col.getVoiceSymbol(g)).filter(g=>g!==void 0&&g!==m).length===0||m.setAnchorX(this.getColumnsContentRect().centerX)})}layoutConnectives(e){this.needLayout&&this.connectives.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(e){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}alignStemsToBeams(){this.beamGroups.forEach(e=>e.updateStemTips())}layoutDone(){this.columns.forEach(e=>e.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(e=>e.getRect().top),...this.tabStringNotes.map(e=>e.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(e=>e.getRect().top),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(e=>e.getRect().bottom),...this.tabStringNotes.map(e=>e.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(e=>e.getRect().bottom),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().bottom)),this.isLastMeasureInRow()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(e=>e.isPositionResolved()&&e.musicObj instanceof Ci).map(e=>e.musicObj.getRect().right))),this.row.getNotationLines().forEach(e=>{this.rect.top=Math.min(this.rect.top,e.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,e.calcBottom())}),this.row.requestRectUpdate()}offset(e,r){this.signatures.forEach(n=>n.offset(e,0)),this.tabStringNotes.forEach(n=>n.offset(e,0)),this.barLineLeft.offset(e,r),this.columns.forEach(n=>n.offset(e,r)),this.barLineRight.offset(e,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(e,r),this.connectives.forEach(n=>n.offset(e,0)),this.beamGroups.forEach(n=>n.offset(e,r)),this.layoutObjects.forEach(n=>n.offset(e,0)),this.rect.offsetInPlace(e,r),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect()),e.lineWidth(1);let r=this.getStaffLineLeft(),n=this.getStaffLineRight(),o=(s,a)=>e.color(a).strokeLine(r,s,n,s);this.row.getNotationLines().forEach(s=>{if(s instanceof Mt)for(let a=s.bottomLineDiatonicId;a<=s.topLineDiatonicId;a+=2)o(s.getDiatonicIdY(a),"staff.frame");else if(s instanceof jt)for(let a=0;a<6;a++)o(s.getStringY(a),"tab.frame")}),this.isFirstMeasureInRow()&&this.row.getNotationLines().length===1&&this.row.getTabs().forEach(s=>{if(s.getRowGroup().hasBrace)return;let c=this.getStaffLineLeft(),u=s.getTopLineY(),h=s.getBottomLineY();e.color("tab.frame").lineWidth(1).strokeLine(c,u,c,h)}),this.signatures.forEach(s=>s.draw(e)),this.tabStringNotes.forEach(s=>s.draw(e)),this.barLineLeft.draw(e),this.columns.forEach(s=>s.draw(e)),this.barLineRight.draw(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(e),this.connectives.forEach(s=>s.draw(e)),this.layoutObjects.forEach(s=>s.musicObj.draw(e)),this.beamGroups.forEach(s=>s.draw(e))}};var cc=(l=>(l[l.TabRhythm=0]="TabRhythm",l[l.Fermata=1]="Fermata",l[l.NoteLabel=2]="NoteLabel",l[l.Navigation=3]="Navigation",l[l.Ending=4]="Ending",l[l.TempoAnnotation=5]="TempoAnnotation",l[l.DynamicsAnnotation=6]="DynamicsAnnotation",l[l.ChordLabel=7]="ChordLabel",l[l.LyricsVerse1=8]="LyricsVerse1",l[l.LyricsVerse2=9]="LyricsVerse2",l[l.LyricsVerse3=10]="LyricsVerse3",l))(cc||{}),Dh=new ht([[0,{rowAlign:!0}],[1,{reserveSpace:!0}],[2,{reserveSpace:!0}],[3,{rowAlign:!0}],[4,{rowAlign:!0,padding:2}],[5,{rowAlign:!0,padding:2}],[6,{rowAlign:!0,padding:2}],[7,{reserveSpace:!0,rowAlign:!0}],[8,{reserveSpace:!0,rowAlign:!0}],[9,{reserveSpace:!0,rowAlign:!0}],[10,{reserveSpace:!0,rowAlign:!0}]]);function s0(i){for(;i;){if(i instanceof bi)return i;i=i.getParent()}throw new N(6,"Parent measure is required but not found!")}var hc=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},uc=class{constructor(t,e,r,n){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=n;d(this,"anchor");d(this,"measure");d(this,"row");d(this,"layoutGroup");d(this,"positionResolved",!0);this.measure=s0(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new N(6,"Parent music object is required as an anchor.");this.anchor=o,this.anchor.addAnchoredLayoutObject(this),this.layoutGroup=this.line.getLayoutGroup(r),this.layoutGroup.add(this)}resetPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(t){let{musicObj:e,measure:r,verticalPos:n,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=t.unitSize*2,u=n===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,h=r.getStaticObjects(o),l=e.getShapeRects();return h.forEach(p=>{let m=p.getShapeRects();l.forEach(f=>{m.forEach(g=>{G.overlapX(f,g)&&(u=n===1?Math.max(u,g.bottom+f.toph+f.anchorY):Math.min(u,g.top-f.bottomh-f.anchorY))})})}),u}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}setAnchorY(t){this.musicObj.setAnchorY(t)}getRect(){return this.musicObj.getRect()}},lc=class{constructor(t){this.layoutGroupId=t;d(this,"layoutObject",Ys(new vr));d(this,"rowAlign");d(this,"reserveSpace");d(this,"padding");var e,r,n,o;this.rowAlign=((e=Dh.get(t))==null?void 0:e.rowAlign)===!0,this.reserveSpace=((r=Dh.get(t))==null?void 0:r.reserveSpace)===!0,this.padding=(o=(n=Dh.get(t))==null?void 0:n.padding)!=null?o:0}getLayoutObjects(t){return this.layoutObject.getAll(t)}add(t){this.layoutObject.add(t.verticalPos,t)}remove(t){this.layoutObject.remove(t.verticalPos,t)}layout(t){for(let e of this.layoutObject.values())e.resetPositionResolved(),e.musicObj.layout(t)}getPadding(t){return this.padding*t.unitSize}};var dc=class extends J{constructor(e){super(e);this.row=e;d(this,"objects",[]);d(this,"layoutGroups",new ht)}getRowGroup(){return this.row.getRowGroupByLineId(this.id)}addObject(e){this.objects.push(e)}removeObjects(){this.objects.length=0}getLayoutGroup(e){return this.layoutGroups.getOrCreate(e,()=>new lc(e))}resetLayoutGroups(e){this.layoutGroups.forEach(r=>r.layout(e))}layoutLayoutGroups(e){for(let r of H.Enum.getEnumValues(cc)){let n=this.getLayoutGroup(r);n&&(this.layoutLayoutGroup(e,n,0),this.layoutLayoutGroup(e,n,1))}}setObjectY(e,r){r!==void 0&&(e.setAnchorY(r-e.getRect().anchorY),e.setPositionResolved())}alignObjectsY(e,r,n){let o=r.filter(u=>!u.isPositionResolved()&&u.verticalPos===n);if(o.length===0)return;let s=n===1?1:-1,a=o.map(u=>u.resolveClosestToStaffY(e)+u.layoutGroup.getPadding(e)*s),c=n===1?Math.max(...a):Math.min(...a);o.forEach(u=>this.setObjectY(u,c))}layoutLayoutGroup(e,r,n){let o=r.getLayoutObjects(n).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof Xi||a instanceof Qn||a instanceof Jn?a.layoutFitToMeasure(e):a.setAnchorX(c.getRect().anchorX)}),r.rowAlign?this.alignObjectsY(e,o,n):o.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=o.filter(h=>c.some(l=>l===h.musicObj));this.alignObjectsY(e,u,n)}else this.alignObjectsY(e,[s],n)})}drawVerticalLine(e,r,n,o=!1){e.color(this.getConfig().type==="tab"?"tab.frame":"staff.frame");let s=this.row.getNotationLines().indexOf(this),a=s>=0?this.row.getNotationLines()[s+1]:void 0,c=this.getRowGroup().lines.length>1,u=this instanceof Mt&&this.isGrandTreble(),h=this.getTopLineY(),l=a&&(o||c||u)?a.getTopLineY():this.getBottomLineY();e.fillRect(r,h,n,l-h)}},Mt=class extends dc{constructor(e,r,n){super(e);this.staffConfig=r;this.id=n;d(this,"clefImageAsset");d(this,"clefLineDiatonicId");d(this,"topLineDiatonicId");d(this,"middleLineDiatonicId");d(this,"bottomLineDiatonicId");d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"joinedGrandStaff");d(this,"topLineY",0);d(this,"bottomLineY",0);d(this,"mi");let o=(s,a)=>U.getNote(s).diatonicId-(a?7:0);if(r.clef==="G")this.clefImageAsset=0,this.clefLineDiatonicId=o("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2;else if(r.clef==="F")this.clefImageAsset=1,this.clefLineDiatonicId=o("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2;else throw new N(6,`Invalid staffConfig.clef ${r.clef}.`);this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(o(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(o(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new Ss(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var e;return(e=this.staffConfig.name)!=null?e:""}getConfig(){return this.staffConfig}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(e){e!==this&&(this.joinedGrandStaff=e)}isGrandTreble(){return this.joinedGrandStaff!==void 0&&this.staffConfig.clef==="G"}isGrandBass(){return this.joinedGrandStaff!==void 0&&this.staffConfig.clef==="F"}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(e){return U.validateDiatonicId(e),(this.minDiatonicId===void 0||e>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||e<=this.maxDiatonicId)}getDiatonicIdY(e){if(this.containsDiatonicId(e))return this.bottomLineY+(this.bottomLineDiatonicId-e)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff.getDiatonicIdY(e);throw new N(6,"Staff does not contain diatonicId "+e)}getActualStaff(e){if(this.containsDiatonicId(e))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff;throw new N(6,"Staff does not contain diatonicId "+e)}getDiatonicIdAt(e){let r=Math.round(this.bottomLineDiatonicId-(e-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(e){return e%2===this.middleLineDiatonicId%2}isSpace(e){return e%2!==this.middleLineDiatonicId%2}containsVoiceId(e){return y.isUndefined(this.staffConfig.voiceId)||H.Arr.toArray(this.staffConfig.voiceId).includes(e)}calcTop(){let e=this.topLineY;if(this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),n=this.getDiatonicIdY(this.maxDiatonicId-1);e=Math.min(e,r-Math.abs(n-r)+1)}return e}calcBottom(){let e=this.bottomLineY;if(this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),n=this.getDiatonicIdY(this.minDiatonicId+1);e=Math.max(e,r+Math.abs(n-r)-1)}return e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,n=r*at.StaffHeight;this.topLineY=-n/2,this.bottomLineY=n/2,this.rect=new G(0,0,this.topLineY,this.bottomLineY)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(n=>{n.offsetInPlace?n.offsetInPlace(0,r):n.offset&&n.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}},jt=class extends dc{constructor(e,r,n){super(e);this.tabConfig=r;this.id=n;d(this,"top",0);d(this,"bottom",0);d(this,"tuningName");d(this,"tuningStrings");d(this,"mi");y.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>U.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=bu(r.tuning),this.tuningStrings=Xs(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=Xs(this.tuningName)),this.mi=new Is(this)}getMusicInterface(){return this.mi}get name(){var e;return(e=this.tabConfig.name)!=null?e:""}getConfig(){return this.tabConfig}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(e){return this.top+(this.bottom-this.top)/6*(e+.5)}getTopStringY(){return this.getStringY(0)}getBottomStringY(){return this.getStringY(5)}getTopLineY(){return this.getTopStringY()}getBottomLineY(){return this.getBottomStringY()}getTop(){return this.top}getBottom(){return this.bottom}containsVoiceId(e){return y.isUndefined(this.tabConfig.voiceId)||H.Arr.toArray(this.tabConfig.voiceId).includes(e)}containsDiatonicId(e){return!0}calcTop(){let{top:e}=this;return this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),e}calcBottom(){let{bottom:e}=this;return this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,n=r*at.TabHeight;this.top=-n/2,this.bottom=n/2,this.rect=new G(0,0,this.top,this.bottom)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.top+=r,this.bottom+=r,this.objects.forEach(n=>{n.offsetInPlace?n.offsetInPlace(0,r):n.offset&&n.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}};function a0(i){let t=(i.startsWith("!{")?i.substring(2):i.startsWith("!")?i.substring(1):i).trim(),e=i.startsWith("!"),r=i.startsWith("!{");return{instrName:t,hideInstr:e,hideBrace:r}}var pc=class extends J{constructor(e){var s;super(e[0].row);this.lines=e;d(this,"space",0);d(this,"instrument");d(this,"hasBrace");d(this,"instrText");d(this,"braceRect",new G);d(this,"mi");let r="rowgroup.instrument",n=a0((s=e[0].getConfig().instrument)!=null?s:"");this.instrument=n.instrName,this.hasBrace=n.hideBrace?!1:this.hasInstrument&&e.length>=2;let o=n.hideInstr?"":this.instrument;this.instrText=new ot(this,{text:o,color:r,scale:1},1,.5),this.mi=new Ts(this)}getMusicInterface(){return this.mi}get row(){return this.lines[0].row}get hasInstrument(){return this.instrument.length>0}hasNotationLine(e){return this.lines.includes(e)}pick(e,r){if(!this.getRect().contains(e,r))return[];let n=this.instrText.pick(e,r);return n.length>0?[this,...n]:[this]}updateRect(){this.instrText.setRight(this.braceRect.left-this.space),this.instrText.setCenterY(this.braceRect.anchorY),this.rect=this.instrText.getRect().clone().expandInPlace(this.braceRect)}layout(e){this.space=e.unitSize,this.instrText.layout(e),this.braceRect=new G(-(this.hasBrace?e.unitSize*5:0),0,0,0),this.forceRectUpdate()}layoutToNotationLines(){this.braceRect.top=this.lines[0].getTopLineY(),this.braceRect.bottom=this.lines[this.lines.length-1].getBottomLineY(),this.braceRect.anchorY=this.braceRect.centerY,this.forceRectUpdate()}offset(e,r){this.instrText.offset(e,r),this.braceRect.offsetInPlace(e,r),this.rect.offsetInPlace(e,r)}draw(e){if(this.instrText.draw(e),this.hasBrace){let r=this.braceRect;e.color("rowgroup.frame").lineWidth(1).drawBracket(r,"{")}}};var mc=class{constructor(){d(this,"instrWidth",0);d(this,"staffWidth",0)}resetWidths(){this.instrWidth=this.staffWidth=0}addRowInstrWidth(t){this.instrWidth=Math.max(this.instrWidth,t)}addRowstaffWidth(t){this.staffWidth=Math.max(this.staffWidth,t)}get instrLeft(){return 0}get instrRight(){return this.instrWidth}get staffLeft(){return this.instrRight}get staffRight(){return this.staffLeft+this.staffWidth}get left(){return this.instrLeft}get right(){return this.staffRight}get width(){return this.instrWidth+this.staffWidth}},fc=class extends J{constructor(e,r,n){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=n;d(this,"nextRow");d(this,"notationLines");d(this,"rowGroups");d(this,"staves");d(this,"tabs");d(this,"measures",[]);d(this,"rowGroupByLine");d(this,"needLayout",!0);d(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(s=>s instanceof Mt),this.tabs=this.notationLines.filter(s=>s instanceof jt);let o=[];for(let s=0;s<this.notationLines.length;s++){let a=this.notationLines[s],c=o[o.length-1];c===void 0||c[0].getConfig().instrument===void 0||c[0].getConfig().instrument!==a.getConfig().instrument?o.push([a]):c.push(a)}this.rowGroups=o.filter(s=>s.length>0).map(s=>new pc(s)),this.rowGroupByLine=this.notationLines.map(s=>this.rowGroups.find(a=>a.lines.includes(s))),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new Ns(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,n)=>r.type==="staff"?new Mt(this,r,n):new jt(this,r,n));for(let r=0;r<e.length-1;r++){let n=e[r],o=e[r+1];n instanceof Mt&&o instanceof Mt&&n.staffConfig.grandId!==void 0&&n.staffConfig.grandId===o.staffConfig.grandId&&(n.joinGrandStaff(o),o.joinGrandStaff(n))}return e}getNotationLines(){return this.notationLines}getRowGroups(){return this.rowGroups}getRowGroupByLineId(e){return this.rowGroupByLine[e]}findMatchingLine(e){return e.row===this?e:this.notationLines.find(r=>H.Obj.deepEqual(e.row.scoreConfig,r.row.scoreConfig)&&e.id===r.id||y.isNonEmptyString(e.getConfig().name)&&e.getConfig().name===r.getConfig().name&&e.getConfig().type===r.getConfig().type)}get regions(){return this.doc.regions}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let e=this.staves[0];if(e)return e;throw new N(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new N(6,"Bottom staff is required!")}getStaff(e){U.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let n=this.notationLines[r];if(n instanceof Mt&&n.containsDiatonicId(e))return n}}resetLayoutGroups(e){this.notationLines.forEach(r=>r.resetLayoutGroups(e))}layoutLayoutGroups(e){this.notationLines.forEach(r=>r.layoutLayoutGroups(e))}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.measures.length;n++){let o=this.measures[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.rowGroups.length;n++){let o=this.rowGroups[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.notationLines.length;n++){let o=this.notationLines[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),n=r?r.getColumnsContentRect().left:e.left;return new G(n,(n+e.right)/2,e.right,e.top,e.anchorY,e.bottom)}getDiatonicIdAt(e){for(let r=0;r<this.notationLines.length;r++){let n=this.notationLines[r],o=n instanceof Mt?n.getDiatonicIdAt(e):void 0;if(o!==void 0)return o}}addMeasure(e){this.measures.push(e)}getMeasures(){return this.measures}isFirstRow(){return this===this.doc.getFirstRow()}isLastRow(){return this===this.doc.getLastRow()}getPrevRow(){return this.prevRow}getNextRow(){return this.nextRow}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}solveAutoStemDir(e){if(e.length===0)return"up";{let r=e[0].voiceId,n=e.filter(u=>u instanceof xt).map(u=>u.setDiatonicId),o=e.filter(u=>u instanceof ae&&u.setDiatonicId!==ae.UndefinedDiatonicId).map(u=>u.setDiatonicId);if(n.length===0&&o.length===0)return"up";let s=n.length>0?n:o,a=Math.floor(H.Math.avg(...s)),c=this.getStaves().filter(u=>u.containsVoiceId(r)&&u.containsDiatonicId(a));return c.length>0?a>=c[0].middleLineDiatonicId?"down":"up":"up"}}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(e){if(!this.needLayout)return;this.requestRectUpdate(),this.notationLines.forEach(n=>{n.removeObjects(),n.layoutHeight(e)}),this.rowGroups.forEach(n=>{n.layout(e),this.regions.addRowInstrWidth(n.getRect().width)}),this.measures.forEach(n=>n.layout(e));let r=this.measures.map(n=>n.getMinWidth()+n.getPostMeasureBreakWidth()).reduce((n,o)=>n+o);this.regions.addRowstaffWidth(r)}layoutStretch(e){if(!this.needLayout)return;this.rect=new G(this.regions.left,this.regions.right,0,0),this.notationLines.forEach(a=>a.layoutWidth(e)),this.rowGroups.forEach(a=>a.setRight(this.regions.instrRight));let r=this.regions.staffWidth,n=0;this.measures.forEach(a=>{r-=a.getTotalSolidWidth()+a.getPostMeasureBreakWidth(),n+=a.getMinColumnsWidth()});let o=r/n,s=this.regions.staffLeft;this.measures.forEach(a=>{let c=a.getTotalSolidWidth()+a.getMinColumnsWidth()*o;a.layoutWidth(e,c);let u=a.getRect();a.setLeft(s),a.setAnchorY(0),s+=u.width,s+=a.getPostMeasureBreakWidth()}),this.measures.forEach(a=>{a.layoutConnectives(e),a.layoutBeams(e)})}updateRect(){var a;let e=this.regions.left,r=this.regions.right,n=0,o=0,s=(a=this.getLastMeasure())==null?void 0:a.getBarLineRight().getAnchoredLayoutObjects().map(c=>c.musicObj).find(c=>c instanceof Ci);s&&(r=Math.max(r,s.getRect().right)),this.measures.length>0&&(n=Math.min(...this.measures.map(c=>c.getRect().top)),o=Math.max(...this.measures.map(c=>c.getRect().bottom))),this.rect=new G(e,r,n,o)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutSetNotationLines(e){let{unitSize:r}=e;for(let n=1;n<this.notationLines.length;n++){let o=this.notationLines[n-1],s=this.notationLines[n];if(o instanceof Mt&&s instanceof Mt&&o.staffConfig.grandId!==void 0&&o.staffConfig.grandId===s.staffConfig.grandId){let a=o.getBottomLineY()-s.getTopLineY()+r*6;s.offsetY(a)}else{let a=o.calcBottom()-s.calcTop()+r*3;s.offsetY(a)}}this.measures.forEach(n=>{n.requestRectUpdate(),n.getBarLineLeft().requestRectUpdate(),n.getBarLineRight().requestRectUpdate(),n.getColumns().forEach(o=>{o.requestRectUpdate(),se().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.rowGroups.forEach(n=>n.layoutToNotationLines()),this.alignStemsToBeams(),this.requestRectUpdate()}layoutDone(){this.measures.forEach(e=>e.layoutDone()),this.needLayout=!1}offset(e,r){this.measures.forEach(n=>n.offset(e,r)),this.rect.offsetInPlace(e,r),this.notationLines.forEach(n=>n.offset(e,r)),this.rowGroups.forEach(n=>n.offset(e,r))}getStaffLineLeft(){var e;return(e=this.getFirstMeasure())==null?void 0:e.getStaffLineLeft()}draw(e){e.drawDebugRect(this.getRect());let{left:r,top:n,width:o,height:s}=this.getRect(),a=e._lineWidth;e.save(),e.rect(r-a,n,o+2*a,s),e.clip(),this.measures.forEach(u=>u.draw(e)),this.notationLines.forEach(u=>u.draw(e));let c=this.getStaffLineLeft();c!==void 0&&this.notationLines.length>1&&this.notationLines.forEach(u=>u.drawVerticalLine(e,c,e._lineWidth,!0)),this.rowGroups.forEach(u=>u.draw(e)),e.restore()}};var gc=class extends J{constructor(e,r,n,o){super(e);this.doc=e;this.title=r;this.composer=n;this.arranger=o;d(this,"titleText");d(this,"composerText");d(this,"arrangerText");d(this,"mi");this.mi=new Os(this),this.titleText=this.title?new ot(this,{text:this.title,color:"header.title",scale:2},.5,0):void 0,this.composerText=this.composer?new ot(this,{text:this.composer,color:"header.composer"},1,0):void 0,this.arrangerText=this.arranger?new ot(this,{text:"Arr.: "+this.arranger,color:"header.arranger"},1,0):void 0}getMusicInterface(){return this.mi}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.titleText){let n=this.titleText.pick(e,r);if(n)return[this,...n]}if(this.composerText){let n=this.composerText.pick(e,r);if(n)return[this,...n]}if(this.arrangerText){let n=this.arrangerText.pick(e,r);if(n)return[this,...n]}return[this]}layout(e){let r=0,n=this.doc.regions.staffLeft,o=this.doc.regions.staffRight;this.rect=new G(n,o,0,0),this.titleText&&(this.titleText.layout(e),this.titleText.setCenterX((n+o)/2),this.titleText.setTop(r),r+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(e),this.composerText.setRight(o),this.composerText.setTop(r),r+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(e),this.arrangerText.setRight(o),this.arrangerText.setTop(r),r+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(e,r){this.titleText&&this.titleText.offset(e,r),this.composerText&&this.composerText.offset(e,r),this.arrangerText&&this.arrangerText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.titleText&&this.titleText.draw(e),this.composerText&&this.composerText.draw(e),this.arrangerText&&this.arrangerText.draw(e)}};var yc=class extends J{constructor(){super(void 0);d(this,"needLayout",!0);d(this,"ctx");d(this,"regions",new mc);d(this,"rows",[]);d(this,"measures",[]);d(this,"measuresPerRow",1/0);d(this,"curScoreConfig",[{type:"staff",clef:"G"}]);d(this,"header");d(this,"newRowRequested",!1);d(this,"allConnectiveProps",[]);d(this,"staffGroups",new ht);d(this,"mi");this.mi=new Xr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(y.isEnumValue(e,Yn))switch(e){default:case"treble":this.curScoreConfig=[{type:"staff",clef:"G"}];break;case"bass":this.curScoreConfig=[{type:"staff",clef:"F"}];break;case"grand":this.curScoreConfig=[{type:"staff",clef:"G",grandId:"grand1"},{type:"staff",clef:"F",grandId:"grand1"}];break;case"guitarTreble":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case"guitarTab":this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case"guitarCombined":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else y.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0,n=[];r<this.curScoreConfig.length;){let o=this.curScoreConfig[r],s=this.curScoreConfig[r+1];if(o&&s&&o.type==="staff"&&s.type==="staff"&&o.grandId!==void 0&&o.grandId===s.grandId){if(n.includes(o.grandId))throw new N(6,`Grand staff error: grandId "${o.grandId}" already used!`);if(o.clef!=="G")throw new N(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(s.clef!=="F")throw new N(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(o.isOctaveDown||s.isOctaveDown)throw new N(6,"Grand staff error: cannot use isOctaveDown option!");n.push(o.grandId),o.minNote="C4",s.maxNote="B3",r+=2}else{if(o&&o.type==="staff"&&o.grandId!==void 0)throw new N(6,`Grand staff error: invalid use of grandId "${o.grandId}"!`);r++}}this.requestNewRow()}setMeasuresPerRow(e){this.measuresPerRow=e}addConnectiveProps(e){this.allConnectiveProps.push(e)}setRenderContext(e){if(this.ctx===e)return;let r=this.ctx;this.ctx=e,r&&r.setDocument(void 0),e&&e.setDocument(this.mi),this.requestFullLayout()}setHeader(e,r,n){this.header=new gc(this,e,r,n),this.requestLayout()}getTitle(){var e;return(e=this.header)==null?void 0:e.title}getComposer(){var e;return(e=this.header)==null?void 0:e.composer}getArranger(){var e;return(e=this.header)==null?void 0:e.arranger}hasSingleMeasure(){return this.measures.length===1}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}addNewRow(e){let r=new fc(this,e,this.curScoreConfig);return this.rows.push(r),r}getFirstRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[0]}getLastRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[this.rows.length-1]}getRows(){return this.rows}getMeasures(){return this.measures}requestNewRow(){this.newRowRequested=!0}addMeasure(e){let r=this.rows[this.rows.length-1];(!r||this.newRowRequested&&r.getMeasures().length>0||r.getMeasures().length>=this.measuresPerRow)&&(r=this.addNewRow(r),this.newRowRequested=!1);let n=new bi(r,e);return this.measures.push(n),r.addMeasure(n),this.requestLayout(),n}addStaffGroup(e,r,n){this.staffGroups.set(e,new hc(e,r,n))}getStaffGroup(e){return this.staffGroups.get(e)}getVoiceSymbols(e){let r=[];return this.forEachMeasure(n=>r=r.concat(n.getVoiceSymbols(e))),r}removeLayoutObjects(e){this.forEachMeasure(r=>r.removeLayoutObjects(e))}forEachMeasure(e){let r=this.getFirstMeasure();for(;r;)e(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(e=>e.resetPassCount())}updateCursorRect(e){this.ctx&&this.ctx.updateCursorRect(e)}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(e=>e.requestLayout()),this.forEachMeasure(e=>{e.getColumns().forEach(r=>r.requestLayout()),e.requestLayout()}),this.requestLayout()}layout(){var n;if(!this.needLayout)return;let{ctx:e}=this;if(!e)return;let{unitSize:r}=e;this.forEachMeasure(o=>o.createBeams()),(n=this.getFirstMeasure())==null||n.updateRunningArguments(),this.forEachMeasure(o=>o.createExtensions()),this.allConnectiveProps.forEach(o=>o.removeConnectives()),this.allConnectiveProps.forEach(o=>o.createConnectives()),this.rows.forEach(o=>o.resetLayoutGroups(e)),this.regions.resetWidths(),this.regions.addRowstaffWidth(at.MinStaffWidth*r),this.rows.forEach(o=>o.layout(e)),this.rows.forEach(o=>o.layoutStretch(e)),this.rows.forEach(o=>o.layoutLayoutGroups(e)),this.rows.forEach(o=>o.layoutSetNotationLines(e)),this.rect=new G,this.header&&(this.header.layout(e),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(o=>{o.setLeft(0),o.setTop(this.rect.bottom+r*2),this.rect.expandInPlace(o.getRect())}),this.rows.forEach(o=>o.layoutDone()),this.needLayout=!1}offset(e,r){}drawContent(){let{ctx:e}=this;e&&(this.rows.forEach(r=>r.draw(e)),this.header&&this.header.draw(e))}pickStaffPosAt(e,r){if(this.rect.contains(e,r))for(let n=0;n<this.rows.length;n++){let o=this.rows[n];if(!o.hasStaff||!o.getRect().contains(e,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.header){let n=this.header.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.rows.length;n++){let o=this.rows[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}};var mg="";function yt(i,...t){let e=t.map(r=>JSON.stringify(r)).join(", ");mg=`DocumentBuilder.${i}(${e})`}function dt(...i){i.forEach(t=>{if(!t)throw new N(6,mg)})}function fg(i,t){if(!i)throw new N(6,t)}function _i(i,t,e){fg(!y.isTypedObject(i,[t]),e)}function gg(i){dt(y.isObject(i),y.isStringOrUndefined(i.name),y.isUndefined(i.voiceId)||Ge(i.voiceId)||y.isArray(i.voiceId)&&i.voiceId.every(t=>Ge(t))),_i(i,"voiceIds","Baseconfig.voiceIds was removed. Use BaseConfig.voiceId instead."),y.isArray(i.voiceId)&&(i.voiceId=H.Arr.removeDuplicates(i.voiceId)),dt(y.isStringOrUndefined(i.instrument))}function lg(i){gg(i),dt(y.isObject(i),y.isStrictEqual(i.type,"staff"),y.isEnumValue(i.clef,zi),y.isBooleanOrUndefined(i.isOctaveDown),y.isUndefined(i.minNote)||U.isNote(i.minNote),y.isUndefined(i.maxNote)||U.isNote(i.maxNote),y.isStringOrUndefined(i.grandId)),_i(i,"isGrand","StaffConfig.isGrand was removed. Use StaffConfig.grandId instead.")}function dg(i){gg(i),dt(y.isObject(i),y.isStrictEqual(i.type,"tab"),y.isUndefined(i.tuning)||y.isString(i.tuning)&&y.isIncluded(i.tuning,mo)||y.isArray(i.tuning)&&y.isStrictEqual(i.tuning.length,$a().length&&i.tuning.every(t=>U.isNote(t))))}function bc(i){dt(y.isObject(i),y.isEnumValueOrUndefined(i.stem,gr),y.isStringOrUndefined(i.color),y.isBooleanOrUndefined(i.arpeggio)||y.isEnumValue(i.arpeggio,gi),y.isBooleanOrUndefined(i.staccato),y.isBooleanOrUndefined(i.diamond),y.isUndefined(i.string)||qo(i.string)||y.isEmptyArray(i.string)||y.isNonEmptyArray(i.string)&&i.string.every(t=>qo(t))),_i(i,"dotted","NoteOptions.dotted was removed."),_i(i,"triplet","NoteOptions.triplet was removed."),_i(i,"tieSpan",'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)'),_i(i,"slurSpan",'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)')}function pg(i){dt(y.isObject(i),y.isStringOrUndefined(i.staffPos)||y.isInteger(i.staffPos)||i.staffPos instanceof U,y.isStringOrUndefined(i.color),y.isBooleanOrUndefined(i.hide)),_i(i,"dotted","RestOptions.dotted was removed."),_i(i,"triplet","RestOptions.triplet was removed.")}function c0(i){dt(y.isObject(i),y.isEnumValueOrUndefined(i.align,Uo),y.isEnumValueOrUndefined(i.hyphen,Hn))}function u0(i){dt(y.isObject(i),y.isBooleanOrUndefined(i.showNumber))}function Rs(i){dt(y.isStringOrUndefined(i)||y.isIntegerGte(i,0)||y.isNonEmptyArray(i)&&i.every(t=>y.isString(t)||y.isIntegerGte(t,0)))}var xc=class xc{constructor(){d(this,"doc");d(this,"currentLyricsAlign","center");this.doc=new yc}setScoreConfiguration(t){return yt("setScoreConfiguration",t),y.isEnumValue(t,Yn)?this.doc.setScoreConfiguration(t):y.isObject(t)&&t.type==="staff"?(lg(t),this.doc.setScoreConfiguration(t)):y.isObject(t)&&t.type==="tab"?(dg(t),this.doc.setScoreConfiguration(t)):y.isNonEmptyArray(t)?(t.forEach(e=>{y.isObject(e)&&e.type==="staff"?lg(e):y.isObject(e)&&e.type==="tab"?dg(e):dt(!1)}),this.doc.setScoreConfiguration(t)):dt(!1),this}getMeasure(){var t;return(t=this.doc.getLastMeasure())!=null?t:this.doc.addMeasure(xc.DefaultMeasureOptions)}getDocument(){return this.getMeasure(),this.doc.getMusicInterface()}setHeader(t,e,r){return yt("setHeader",t,e,r),dt(y.isStringOrUndefined(t),y.isStringOrUndefined(e),y.isStringOrUndefined(r)),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return yt("setMeasuresPerRow",t),dt(y.isIntegerGte(t,1)||y.isPosInfinity(t)),this.doc.setMeasuresPerRow(t),this}addMeasure(t){return yt("addMeasure",t),t!=null||(t={}),u0(t),this.doc.addMeasure(t),this}setKeySignature(...t){return yt("setKeySignature",...t),dt(t[0]instanceof ii||t[0]instanceof rr||y.isNonEmptyString(t[0])&&y.isEnumValueOrUndefined(t[1],Ni)),this.getMeasure().setKeySignature(...t),this}setTimeSignature(...t){return yt("setTimeSignature",...t),t[0]instanceof ni?this.getMeasure().setTimeSignature(t[0]):y.isEnumValue(t[0],fo)&&y.isEnumValueOrUndefined(t[1],Ri)?this.getMeasure().setTimeSignature(new ni(t[0],t[1])):y.isIntegerGte(t[0],1)&&y.isIntegerGte(t[1],1)&&y.isEnumValueOrUndefined(t[2],Ri)?this.getMeasure().setTimeSignature(new ni(t[0],t[1],t[2])):dt(!1),this}setTempo(t,e){return yt("setTempo",t,e),dt(y.isIntegerGte(t,1),y.isUndefined(e)||nr(e)),this.getMeasure().setTempo(t,e),this}addNote(t,e,r,n){if(yt("addNote",t,e,r,n),dt(Ge(t),e instanceof U||y.isNonEmptyString(e)||y.isArray(e)&&e.every(o=>o instanceof U||y.isNonEmptyString(o)),nr(r)),n!=null||(n={}),bc(n),y.isArray(e)){let o=n.string;e.forEach((s,a)=>{n.string=y.isArray(o)?o[a]:o,this.getMeasure().addNoteGroup(t,[s],r,n)})}else this.getMeasure().addNoteGroup(t,[e],r,n);return this}addChord(t,e,r,n){return yt("addChord",t,e,r,n),dt(Ge(t),y.isNonEmptyArray(e)&&e.every(o=>o instanceof U||y.isNonEmptyString(o)),nr(r)),n!=null||(n={}),bc(n),this.getMeasure().addNoteGroup(t,e,r,n),this}addRest(t,e,r){return yt("addRest",t,e,r),dt(Ge(t),nr(e)),r!=null||(r={}),pg(r),this.getMeasure().addRest(t,e,r),this}addTuplet(t,e,r){yt("addTuplet",t,e),dt(Ge(t),y.isFunction(r),Qs(e)&&y.isBooleanOrUndefined(e.showRatio));let n=[],o={addNote:(s,a,c)=>{if(yt("addTuplet => addNote",s,a,c),dt(s instanceof U||y.isNonEmptyString(s)||y.isArray(s)&&s.every(u=>u instanceof U||y.isNonEmptyString(u)),nr(a)),c!=null||(c={}),bc(c),y.isArray(s)){let u=c.string;s.forEach((h,l)=>{c.string=y.isArray(u)?u[l]:u;let p=this.getMeasure().addNoteGroup(t,[h],a,c,e);n.push(p)})}else{let u=this.getMeasure().addNoteGroup(t,[s],a,c,e);n.push(u)}return o},addChord:(s,a,c)=>{yt("addTuplet => addChord",s,a,c),dt(y.isNonEmptyArray(s)&&s.every(h=>h instanceof U||y.isNonEmptyString(h)),nr(a)),c!=null||(c={}),bc(c);let u=this.getMeasure().addNoteGroup(t,s,a,c,e);return n.push(u),o},addRest:(s,a)=>{yt("addTuplet => addRest",s,a),dt(nr(s)),a!=null||(a={}),pg(a);let c=this.getMeasure().addRest(t,s,a,e);return n.push(c),o}};return r(o),Qi.createTuplet(n,e),this}addLyricsInternal(t,e,r,n,o){var s;return Rs(t),dt(Za(e),y.isEnumValue(r,ir),y.isString(n)||y.isArray(n)&&n.every(a=>y.isString(a))),o!=null||(o={}),c0(o),o.align!==void 0?this.currentLyricsAlign=o.align:(s=o.align)!=null||(o.align=this.currentLyricsAlign),y.isArray(n)?n.forEach(a=>this.getMeasure().addLyrics(t,e,r,a,o)):this.getMeasure().addLyrics(t,e,r,n,o),this}addLyrics(t,e,r,n){return yt("addLyrics",t,e,r,n),this.addLyricsInternal(void 0,t,e,r!=null?r:"",n)}addLyricsTo(t,e,r,n,o){return yt("addLyricsTo",e,r,n,o),this.addLyricsInternal(t,e,r,n!=null?n:"",o)}addFermataInternal(t,e){return Rs(t),dt(y.isEnumValue(e,zo)),this.getMeasure().addFermata(t,e),this}addFermata(t="atNote"){return yt("addFermata",t),this.addFermataInternal(void 0,t)}addFermataTo(t,e="atNote"){return yt("addFermataTo",t,e),this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return Rs(t),dt(y.isStrictEqual(e,"endRepeat")&&y.isStrictEqual(r.length,1)||y.isStrictEqual(e,"ending")&&y.isIntegerGte(r.length,1)&&r.every(n=>y.isIntegerGte(n,1))||y.isEnumValue(e,br)&&y.isEmptyArray(r)),this.getMeasure().addNavigation(t,e,...r),this}addNavigation(t,...e){return yt("addNavigation",t,...e),this.addNavigationInternal(void 0,t,...e)}addNavigationTo(t,e,...r){return yt("addNavigationTo",t,e,...r),this.addNavigationInternal(t,e,...r)}addAnnotationInternal(t,e,r){if(e!=null||(e=sg(r)),e===void 0)throw new N(6,`Annotation text "${r}" is not known annotation.`);return Rs(t),dt(y.isEnumValue(e,$n),y.isNonEmptyString(r)),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(...t){return yt("addAnnotation",...t),t.length===1?this.addAnnotationInternal(void 0,void 0,t[0]):this.addAnnotationInternal(void 0,t[0],t[1])}addAnnotationTo(t,...e){return yt("addAnnotationTo",t,...e),e.length===1?this.addAnnotationInternal(t,void 0,e[0]):this.addAnnotationInternal(t,e[0],e[1])}addLabelInternal(t,e,r){return Rs(t),dt(y.isEnumValue(e,$o),y.isNonEmptyString(r)),this.getMeasure().addLabel(t,e,r),this}addLabel(t,e){return yt("addLabel",t,e),this.addLabelInternal(void 0,t,e)}addLabelTo(t,e,r){return yt("addLabelTo",t,e,r),this.addLabelInternal(t,e,r)}addConnective(t,...e){if(yt("addConnective",t,...e),dt(y.isEnumValue(t,yi)),t==="tie"){dt(y.isIntegerOrUndefined(e[0])||y.isEnumValue(e[0],yr)),dt(y.isEnumValueOrUndefined(e[1],Ke));let r=e[0],n=e[1];this.getMeasure().addConnective(t,r,n)}else if(t==="slur"){dt(y.isIntegerOrUndefined(e[0])),dt(y.isEnumValueOrUndefined(e[1],Ke));let r=e[0],n=e[1];this.getMeasure().addConnective(t,r,n)}else if(t==="slide"){dt(y.isEnumValueOrUndefined(e[0],Ke));let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t){yt("addExtension"),fg(y.isFunctionOrUndefined(t),"addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");let e=0,r=!0,n={notes:(o,s)=>(yt("addExtension.notes",o,s),dt(nr(o)),dt(y.isUndefined(s)||y.isNumber(s)&&s>=0),e+=Qt.get(o).ticks*(s!=null?s:1),n),measures:o=>(yt("addExtension.measures",o),dt(y.isNumber(o)&&o>=1),e+=this.getMeasure().getMeasureTicks()*o,n),infinity:()=>(yt("addExtension.infinity"),e=1/0,n),hide:()=>(yt("addExtension.hide"),r=!1,n)};return t?t(n):e=1/0,this.getMeasure().addExtension(e,r),this}addStaffGroup(t,e,r="auto"){return yt("addStaffGroup",t,e,r),dt(y.isNonEmptyString(t),y.isNonEmptyString(e)||y.isIntegerGte(e,0)||y.isNonEmptyArray(e)&&e.every(n=>y.isNonEmptyString(n)||y.isIntegerGte(n,0)),y.isEnumValue(r,Wo)),this.doc.addStaffGroup(t,e,r),this}endSong(){return yt("endSong"),this.getMeasure().endSong(),this}endSection(){return yt("endSection"),this.getMeasure().endSection(),this}endRow(){var t;return yt("endRow"),(t=this.doc.getLastMeasure())==null||t.endRow(),this}completeRests(t){return yt("completeRests",t),dt(y.isUndefined(t)||Ge(t)||y.isArray(t)&&t.every(e=>Ge(e))),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){yt("addScaleArpeggio",t,e,r),dt(y.isNonEmptyString(e),y.isIntegerGte(r,1));let n=this.getMeasure().getTimeSignature(),o=t.getScaleNotes(e,r);for(let s=0;s<o.length;s++){s%n.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,n.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}};d(xc,"DefaultMeasureOptions",{});var Cr=xc;var Ms=class{constructor(t){this.type=t}},Yi=class extends Ms{constructor(e,r,n,o){super(e);this.renderContext=r;this.scoreRow=n;this.diatonicId=o}},Hi=class extends Ms{constructor(e,r,n){super(e);this.renderContext=r;this.objects=n;if(arguments.length===0)throw new N(6,"Empty array in score object event!")}get topObject(){return this.objects[this.objects.length-1]}findObject(e){return this.objects.find(r=>e(r))}};function kh(i,t,e){if(!i)throw new N(6,`Invalid arg: ${t} = ${e}`)}function Lh(i){if(i instanceof Mt||i instanceof jt)return i.getMusicInterface();throw new N(6,"Notation line not staff nor tab.")}var bt=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},Ac=class Ac extends bt{constructor(e){super(Ac.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};d(Ac,"Name","Accidental");var Xo=Ac,Cc=class Cc extends bt{constructor(e){super(Cc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Cc,"Name","Connective");var Cs=Cc,_c=class _c extends bt{constructor(e){super(_c.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return Lh(this.obj.line)}};d(_c,"Name","Arpeggio");var rs=_c,vc=class vc extends bt{constructor(e){super(vc.Name);this.obj=e}getMusicObject(){return this.obj}};d(vc,"Name","BeamGroup");var ys=vc,wc=class wc extends bt{constructor(e){super(wc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(wc,"Name","StaffBeamGroup");var bs=wc,Sc=class Sc extends bt{constructor(e){super(Sc.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}getRows(){return this.obj.getRows().map(e=>e.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}play(e){return kh(y.isFunctionOrUndefined(e),"playStateChangeListener",e),new to(this,e).play()}};d(Sc,"Name","Document");var Xr=Sc,Ic=class Ic extends bt{constructor(e){super(Ic.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return kh(y.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};d(Ic,"Name","Ending");var fs=Ic,Tc=class Tc extends bt{constructor(e){super(Tc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Tc,"Name","Fermata");var xs=Tc,Nc=class Nc extends bt{constructor(e){super(Nc.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};d(Nc,"Name","Header");var Os=Nc,Oc=class Oc extends bt{constructor(e){super(Oc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Oc,"Name","Image");var Zo=Oc,Rc=class Rc extends bt{constructor(e){super(Rc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};d(Rc,"Name","Measure");var ws=Rc,Mc=class Mc extends bt{constructor(e){super(Mc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Mc,"Name","BarLineRight");var ds=Mc,Ec=class Ec extends bt{constructor(e){super(Ec.Name);this.obj=e}getMusicObject(){return this.obj}};d(Ec,"Name","BarLineLeft");var ps=Ec,Dc=class Dc extends bt{constructor(e){super(Dc.Name);this.obj=e}getMusicObject(){return this.obj}getBarLine(){let e=this.obj.barLine;if(e instanceof xi||e instanceof Ar)return e.getMusicInterface();throw new N(6,"Bar line not left nor right.")}getNotationLine(){return Lh(this.obj.line)}};d(Dc,"Name","StaffBarLine");var ms=Dc,kc=class kc extends bt{constructor(e){super(kc.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(kc,"Name","NoteGroup");var os=kc,Lc=class Lc extends bt{constructor(e){super(Lc.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Lc,"Name","StaffNoteGroup");var ss=Lc,jc=class jc extends bt{constructor(e){super(jc.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getTab(){return this.obj.tab.getMusicInterface()}};d(jc,"Name","TabNoteGroup");var as=jc,Pc=class Pc extends bt{constructor(e){super(Pc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Pc,"Name","Rest");var is=Pc,Fc=class Fc extends bt{constructor(e){super(Fc.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}getRhythmColumn(){return this.getRest().getRhythmColumn()}getMeasure(){return this.getRest().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Fc,"Name","StaffRest");var ns=Fc,Bc=class Bc extends bt{constructor(e){super(Bc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return kh(Ge(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Bc,"Name","RhythmColumn");var cs=Bc,Gc=class Gc extends bt{constructor(e){super(Gc.Name);this.obj=e}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(e=>Lh(e))}};d(Gc,"Name","ScoreRow");var Ns=Gc,Vc=class Vc extends bt{constructor(e){super(Vc.Name);this.obj=e}getMusicObject(){return this.obj}getInstrument(){return this.obj.instrument}};d(Vc,"Name","ScoreRowGroup");var Ts=Vc,qc=class qc extends bt{constructor(e){super(qc.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(qc,"Name","Staff");var Ss=qc,Wc=class Wc extends bt{constructor(e){super(Wc.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Wc,"Name","Tab");var Is=Wc,Uc=class Uc extends bt{constructor(e){super(Uc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(Uc,"Name","StaffSignature");var ts=Uc,zc=class zc extends bt{constructor(e){super(zc.Name);this.obj=e}getMusicObject(){return this.obj}getTab(){return this.obj.tab.getMusicInterface()}};d(zc,"Name","TabSignature");var es=zc,Yc=class Yc extends bt{constructor(e){super(Yc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasure(){return this.obj.measure.getMusicInterface()}getTab(){return this.obj.tab.getMusicInterface()}};d(Yc,"Name","TabRhythm");var vs=Yc,Hc=class Hc extends bt{constructor(e){super(Hc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Hc,"Name","SpecialText");var us=Hc,$c=class $c extends bt{constructor(e){super($c.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d($c,"Name","Text");var Qo=$c,Zc=class Zc extends bt{constructor(e){super(Zc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Zc,"Name","Lyrics");var _s=Zc,Xc=class Xc extends bt{constructor(e){super(Xc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Xc,"Name","ExtensionLine");var As=Xc;var Qc;(function(i){i.AliceBlue="aliceblue",i.AntiqueWhite="antiquewhite",i.Aqua="aqua",i.Aquamarine="aquamarine",i.Azure="azure",i.Beige="beige",i.Bisque="bisque",i.Black="black",i.BlanchedAlmond="blanchedalmond",i.Blue="blue",i.BlueViolet="blueviolet",i.Brown="brown",i.BurlyWood="burlywood",i.CadetBlue="cadetblue",i.Chartreuse="chartreuse",i.Chocolate="chocolate",i.Coral="coral",i.CornflowerBlue="cornflowerblue",i.CornSilk="cornsilk",i.Crimson="crimson",i.Cyan="cyan",i.DarkBlue="darkblue",i.DarkCyan="darkcyan",i.DarkGoldenRod="darkgoldenrod",i.DarkGray="darkgray",i.DarkGreen="darkgreen",i.DarkGrey="darkgrey",i.DarkKhaki="darkkhaki",i.DarkMagenta="darkmagenta",i.DarkOliveGreen="darkolivegreen",i.DarkOrange="darkorange",i.DarkOrchid="darkorchid",i.DarkRed="darkred",i.DarkSalmon="darksalmon",i.DarkSeaGreen="darkseagreen",i.DarkSlateBlue="darkslateblue",i.DarkSlateGray="darkslategray",i.DarkSlateGrey="darkslategrey",i.DarkTurquoise="darkturquoise",i.DarkViolet="darkviolet",i.DeepPink="deeppink",i.DeepSkyBlue="deepskyblue",i.DimGray="dimgray",i.DimGrey="dimgrey",i.DodgerBlue="dodgerblue",i.FireBrick="firebrick",i.FloralWhite="floralwhite",i.ForestGreen="forestgreen",i.Fuchsia="fuchsia",i.Gainsboro="gainsboro",i.GhostWhite="ghostwhite",i.Gold="gold",i.GoldenRod="goldenrod",i.Gray="gray",i.Green="green",i.GreenYellow="greenyellow",i.Grey="grey",i.Honeydew="honeydew",i.HotPink="hotpink",i.IndianRed="indianred",i.Indigo="indigo",i.Ivory="ivory",i.Khaki="khaki",i.Lavender="lavender",i.LavenderBlush="lavenderblush",i.LawnGreen="lawngreen",i.LemonChiffon="lemonchiffon",i.LightBlue="lightblue",i.LightCoral="lightcoral",i.LightCyan="lightcyan",i.LightGoldenRodYellow="lightgoldenrodyellow",i.LightGray="lightgray",i.LightGreen="lightgreen",i.LightGrey="lightgrey",i.LightPink="lightpink",i.LightSalmon="lightsalmon",i.LightSeaGreen="lightseagreen",i.LightSkyBlue="lightskyblue",i.LightSlateGray="lightslategray",i.LightSlateGrey="lightslategrey",i.LightSteelBlue="lightsteelblue",i.LightYellow="lightyellow",i.Lime="lime",i.LimeGreen="limegreen",i.Linen="linen",i.Magenta="magenta",i.Maroon="maroon",i.MediumAquamarine="mediumaquamarine",i.MediumBlue="mediumblue",i.MediumOrchid="mediumorchid",i.MediumPurple="mediumpurple",i.MediumSeaGreen="mediumseagreen",i.MediumSlateBlue="mediumslateblue",i.MediumSpringGreen="mediumspringgreen",i.MediumTurquoise="mediumturquoise",i.MediumVioletRed="mediumvioletred",i.MidnightBlue="midnightblue",i.MintCream="mintcream",i.MistyRose="mistyrose",i.Moccasin="moccasin",i.NavajoWhite="navajowhite",i.Navy="navy",i.OldLace="oldlace",i.Olive="olive",i.OliveDrab="olivedrab",i.Orange="orange",i.OrangeRed="orangered",i.Orchid="orchid",i.PaleGoldenRod="palegoldenrod",i.PaleGreen="palegreen",i.PaleTurquoise="paleturquoise",i.PaleVioletRed="palevioletred",i.PapayaWhip="papayawhip",i.PeachPuff="peachpuff",i.Peru="peru",i.Pink="pink",i.Plum="plum",i.PowderBlue="powderblue",i.Purple="purple",i.RebeccaPurple="rebeccapurple",i.Red="red",i.RosyBrown="rosybrown",i.RoyalBlue="royalblue",i.SaddleBrown="saddlebrown",i.Salmon="salmon",i.SandyBrown="sandybrown",i.SeaGreen="seagreen",i.SeaShell="seashell",i.Sienna="sienna",i.Silver="silver",i.SkyBlue="skyblue",i.SlateBlue="slateblue",i.SlateGray="slategray",i.SlateGrey="slategrey",i.Snow="snow",i.SpringGreen="springgreen",i.SteelBlue="steelblue",i.Tan="tan",i.Teal="teal",i.Thistle="thistle",i.Tomato="tomato",i.Turquoise="turquoise",i.Violet="violet",i.Wheat="wheat",i.White="white",i.WhiteSmoke="whitesmoke",i.Yellow="yellow",i.YellowGreen="yellowgreen"})(Qc=Qc||(Qc={}));var vi;(function(i){i.Hex="hex",i.RGB="rgb",i.Array="array"})(vi=vi||(vi={}));var jh={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(let i in jh)Object.freeze(jh[i]);var yg=Object.freeze(jh);var Ph=yg;var Fh={hash:!0,lowercase:!1,short:!1};function Bh(i,t){let e=O(O({},Fh),t),{hash:r,lowercase:n,short:o}=e,s=i.map(a=>{let c=a.toString(16);return c=c.length===1?`0${c}`:c,c}).join("");if(o){let a=[...s];a[0]===a[1]&&a[2]===a[3]&&a[4]===a[5]&&(s=`${a[0]}${a[2]}${a[4]}`)}return s=n?s.toLowerCase():s.toUpperCase(),r&&(s=`#${s}`),s}function Gh(i,t=1){return t=Math.min(1,Math.max(0,t)),t<1?`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${t})`:`rgb(${i[0]}, ${i[1]}, ${i[2]})`}var h0=X(O({},Fh),{fallback:!0,alpha:1,format:vi.Hex});function Kc(i,t={}){let e=O(O({},h0),t),{fallback:r,format:n,hash:o,lowercase:s,short:a,alpha:c}=e;i=`${i}`;let u=i.toLowerCase().replaceAll(/[^a-z]/g,""),h=Ph[u];if(!h){if(!r)throw new Error(`no matching color found for '${i}'`);let l=i.toLowerCase().replaceAll(/[^\da-f]/g,"");h=(l.length<=3?[l.slice(0,1).repeat(2),l.slice(1,2).repeat(2),l.slice(2,3).repeat(2)]:[l.slice(0,2),l.slice(2,4),l.slice(4,6)]).map(p=>Number.parseInt(p.length<2?`${"0".repeat(2-p.length)}${p}`:p,16))}switch(n){case vi.Array:return[...h];case vi.RGB:return Gh(h,c);default:return Bh(h,{hash:o,lowercase:s,short:a})}}var Jc=i=>i.toLowerCase();function xr(i){return i}var eo=class eo{constructor(){d(this,"colors",{"hilight.staffpos":"#55cc55","hilight.object":"#55cc55","play.cursor":"#44aa44",background:"white","header.title":"black","header.composer":"black","header.arranger":"black","rowgroup.instrument":"black","rowgroup.frame":"black","staff.frame":"black","staff.note":"black","staff.rest":"black","staff.lyrics":"black","staff.connective":"black","staff.signature.clef":"black","staff.signature.key":"black","staff.signature.time":"black","staff.signature.tempo":"black","staff.signature.measurenum":"black","staff.element.fermata":"black","staff.element.annotation":"black","staff.element.navigation":"black","staff.element.label":"black","tab.frame":"black","tab.note":"black","tab.rest":"black","tab.lyrics":"black","tab.connective":"black","tab.tuning":"black","tab.signature.clef":"black","tab.signature.key":"black","tab.signature.time":"black","tab.signature.tempo":"black","tab.signature.measurenum":"black","tab.element.fermata":"black","tab.element.annotation":"black","tab.element.navigation":"black","tab.element.label":"black"})}setColor(t,e){if(t==="all"){for(let c of Object.keys(this.colors))c!=="background"&&c!=="hilight.object"&&c!=="hilight.staffpos"&&c!=="play.cursor"&&(this.colors[c]=e||"black");return}let r=typeof t=="string"&&Jc(t)==="background"||y.isArray(t)&&t.length===1&&Jc(t[0])==="background",n=e||(r?"white":"black");if(r){this.colors.background=n;return}if(typeof t=="string"&&t in this.colors){this.colors[t]=n;return}let o=y.isArray(t)?t:t.split(".");if(o.length===0)return;let s=o.map(Jc),a=!1;for(let c of Object.keys(this.colors)){let u=c.split(".").map(Jc);s.every(l=>u.includes(l))&&(this.colors[c]=n,a=!0)}a||console.error(`Color attrs ${H.Str.stringify(o)} did not match any color.`)}getColor(t){var e;return(e=this.colors[t])!=null?e:t}getColorCode(t){return eo.colorNameToCode(this.getColor(t))}getColorRGBA(t){return eo.colorNameToRGBA(this.getColor(t))}static colorNameToCode(t){return Kc(t)}static colorNameToRGBA(t,e=1){let r=Kc(t).replace("#",""),n=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),s=parseInt(r.slice(4,6),16),a=Math.round(e*255);return[n,o,s,a]}};d(eo,"default",new eo);var Zr=eo;function Je(i,t,e){if(!i)throw new N(6,`Invalid arg: ${t} = ${e}`)}function Es(i,t){if(i==null)throw new TypeError(t);return i}var Ds=class Ds{constructor(t,e){d(this,"player");Je(t instanceof Xr,"doc",t),Je(y.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new oc,this.player.setDocument(t.getMusicObject()),this.player.setCursorPositionChangeListener(r=>{t.getMusicObject().updateCursorRect(r)}),e&&this.player.setPlayStateChnageListener(e)}static stopAll(){this.currentlyPlaying.forEach(t=>t.stop()),Ha()}play(){return Ds.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),Ds.currentlyPlaying.delete(this),this}};d(Ds,"currentlyPlaying",new zs);var to=Ds,Vh=class{constructor(){d(this,"ctx");this.ctx=new Ka(this)}setPaint(t){return Je(y.isUndefined(t)||t instanceof Zr,"paint",t),this.ctx.setPaint(t),this}setDocument(t){return Je(y.isUndefined(t)||t instanceof Xr,"doc",t),this.ctx.setDocument(t),this}setCanvas(t){return t=Es(H.Dom.getCanvas(t),typeof t=="string"?"Cannot set render canvas because invalid canvas id: "+t:"Cannot set render canvas because given canvas is undefined."),this.ctx.setCanvas(t),this}setScoreEventListener(t){Je(y.isFunctionOrUndefined(t),"scoreEventListener",t),this.ctx.setScoreEventListener(t)}hilightObject(t){this.ctx.hilightObject(t==null?void 0:t.getMusicObject())}hilightStaffPos(t){this.ctx.hilightStaffPos(t?{scoreRow:t.scoreRow.getMusicObject(),diatonicId:t.diatonicId}:void 0)}draw(){try{this.ctx.draw()}catch(t){console.log("Draw failed in music render context!",t)}}},we=class we{constructor(){d(this,"playButton");d(this,"stopButton");d(this,"playStopButton");d(this,"pauseButton");d(this,"onPlay");d(this,"onStop");d(this,"onPlayStop");d(this,"onPause");d(this,"playLabel","Play");d(this,"stopLabel","Stop");d(this,"pauseLabel","Pause");d(this,"playState",2);d(this,"player");this.onPlay=()=>{var t;return(t=this.player)==null?void 0:t.play()},this.onStop=()=>{var t;return(t=this.player)==null?void 0:t.stop()},this.onPlayStop=()=>{var t,e;this.playState===0?(t=this.player)==null||t.stop():(e=this.player)==null||e.play()},this.onPause=()=>{var t;return(t=this.player)==null?void 0:t.pause()},this.updateButtons()}setDocument(t){return Je(y.isUndefined(t)||t instanceof Xr,"doc",t),this.onStop(),t?this.player=new to(t,e=>{this.playState=e,this.updateButtons()}):this.player=void 0,this.updateButtons(),this}detachDocument(){this.setDocument(void 0)}updateButtons(){this.playButton&&(this.playButton.disabled=this.player?this.playState===0:!0,this.playButton.innerText=this.playLabel),this.stopButton&&(this.stopButton.disabled=this.player?this.playState===2:!0,this.stopButton.innerText=this.stopLabel),this.playStopButton&&(this.playStopButton.disabled=!this.player,this.playStopButton.innerText=this.playState===0?this.stopLabel:this.playLabel),this.pauseButton&&(this.pauseButton.disabled=this.player?this.playState!==0:!0,this.pauseButton.innerText=this.pauseLabel)}setPlayButton(t,e){return Je(y.isStringOrUndefined(e),"btnLabel",e),we.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=Es(H.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",we.removeOnClickListeners(this.playButton,"all"),we.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return Je(y.isStringOrUndefined(e),"btnLabel",e),we.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=Es(H.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",we.removeOnClickListeners(this.stopButton,"all"),we.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return Je(y.isStringOrUndefined(e),"playLabel",e),Je(y.isStringOrUndefined(r),"stopLabel",r),we.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=Es(H.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",we.removeOnClickListeners(this.playStopButton,"all"),we.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return Je(y.isStringOrUndefined(e),"btnLabel",e),we.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=Es(H.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",we.removeOnClickListeners(this.pauseButton,"all"),we.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(!t)return;let r=this.savedOnClickListeners.getOrDefault(t,[]);r=r.filter(n=>e===n||e==="all"?(t.removeEventListener("click",n),!1):!0),this.savedOnClickListeners.set(t,r)}static addOnClickListener(t,e){Je(y.isFunction(e),"onClick",e),t.addEventListener("click",e),this.savedOnClickListeners.getOrCreate(t,[]).push(e)}};d(we,"savedOnClickListeners",new ht);var qh=we;Ti();var $h={};rn($h,{createAll:()=>l0,createAndanteByDiabelli:()=>Uh,createCanonInD:()=>zh,createFrereJacques:()=>Yh,createGreensleeves:()=>Hh});function Uh(){return new Cr().setScoreConfiguration("guitarTreble").setHeader("Andante","A. Diabelli").addMeasure().setKeySignature("D","Major").setTimeSignature("3/4").setTempo(80).addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n",{stem:"up"}).addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.",{stem:"down"}).addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").endRow().addMeasure().addNote(0,"D4","8n",{string:3}).addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","8n").addNote(0,"A4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n").addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.").addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).addNavigation("endRepeat").addMeasure().addRest(0,"8n",{staffPos:"D4"}).addAnnotation("dynamics","f").addNote(0,"D4","8n").addNote(0,"E4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"B3","8n").addNote(1,"E2","2.").endRow().addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"E4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","p").addNote(0,"E3","8n").addNote(0,"D#3","8n").addConnective("slur",2,"below").addNote(0,"E3","8n").addNote(0,"F#3","8n").addNote(0,"G#3","8n").addNote(1,"E2","2.").addMeasure().addNote(0,"A3","8n").addConnective("slur",2,"below").addNote(0,"G#3","8n").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","f").addNote(0,"G4","8n").addNote(0,"A4","8n").addConnective("slur",2,"below").addNote(0,"G4","8n").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","ff").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).endSong().getDocument()}function zh(){return new Cr().setHeader("Canon in D","Pachelbel").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0,instrument:"Piano"},{type:"staff",clef:"F",voiceId:1,instrument:"Piano"}]).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").setTempo(50,"2n").completeRests(0).addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).completeRests(0).addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().completeRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).completeRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["F#5","E5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","C#5"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().addNote(0,["B4","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addNote(0,["B4","C#5"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addChord(0,["F#5","D5"],"2n").addChord(0,["E5","C#5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).addChord(0,["D5","B4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").endRow().addMeasure({showNumber:!1}).addChord(0,["B4","G4"],"2n").addChord(0,["A4","F#4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addChord(0,["B4","G4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["D4","F#4","A4","G4"],"4n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","D4","F#4","E4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","D4","A4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","B4","A4","G4"],"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["F#4","D4","E4","C#5"],"4n").addNote(1,["D3","A2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","F#5","A5","A4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B4","G4","A4","F#4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5"],"4n").addRest(0,"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D5","C#5","D5","D4"],"8n").addNote(0,["C#4","A4","E4","F#4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5","B4"],"8n").addNote(0,["C#5","F#5","A5","B5"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["G5","F#5","E5","G5"],"8n").addNote(0,["F#5","E5","D5","C#5"],"8n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["B4","A4","G4","F#4"],"8n").addNote(0,["E4","G4","F#4","E4"],"8n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D4","E4","F#4","G4"],"8n").addNote(0,["A4","E4","A4","G4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","B4","A4","G4"],"8n").addNote(0,["A4","G4","F#4","E4"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","B4","C#5"],"8n").addNote(0,["D5","C#5","B4","A4"],"8n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","F#4","E4","B4"],"8n").addNote(0,["A4","B4","A4","G4"],"8n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"F#4","4n").addNote(0,"F#5","4n").addNote(0,"E5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(0,"F#5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B5","A5"],"2n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["B5","C#6"],"2n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D6","D5"],"4n").addNote(0,"C#5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"B4","4n").addNote(0,"D5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"D5","2n").addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","F#5","E5","A5"],"4n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,["A5","A4","B4","C#5"],"16n").addNote(0,["D5","E5","F#5","G5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["F#4","G4"],"16n").addNote(0,["A4","B4","A4","G4"],"16n").addNote(0,["A4","F#4","G4","A4"],"16n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"G4","8n").addNote(0,["F#4","E4"],"16n").addNote(0,["F#4","E4","D4","E4"],"16n").addNote(0,["F#4","G4","A4","B4"],"16n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"B4","8n").addNote(0,["C#5","D5"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(0,["E5","F#5","G5","A5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["E5","D5"],"16n").addNote(0,["E5","C#5","D5","E5"],"16n").addNote(0,["F#5","E5","D5","C#5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"D5","8n").addNote(0,["B4","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["D4","E4"],"16n").addNote(0,["F#4","G4","F#4","E4"],"16n").addNote(0,["F#4","D5","C#5","D5"],"16n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"B4","8n").addNote(0,["A4","G4"],"16n").addNote(0,["A4","G4","F#4","G4"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["C#5","B4"],"16n").addNote(0,["C#5","D5","E5","D5"],"16n").addNote(0,["C#5","D5","B4","C#5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNavigation("startRepeat").addNote(0,"D5","4.").addNote(0,"A5","8n").addNote(0,["A5","B5","A5","G5"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","4.").addNote(0,"F#5","8n").addNote(0,["F#5","G5","F#5","E5"],"8n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"D5","4.").addNote(0,"D5","8n").addNote(0,["D5","A5"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","C5","B5","C5"],"8n").addNote(0,"C#5","2n").addNote(1,["G2","A2"],"2n").addNavigation("endRepeat").addMeasure().addNote(0,"D5","1n").addNote(1,"D3","1n").getDocument()}function Yh(){return new Cr().setHeader("Fr\xE8re Jacques","Traditional").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0,instrument:"!{Piano"},{type:"staff",clef:"F",voiceId:1,instrument:"!{Piano"}]).setMeasuresPerRow(2).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").addNote(0,"D4","4n",{stem:"up"}).addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addRest(1,"1n",{staffPos:"F3"}).addMeasure().addNote(0,"D4","4n").addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addRest(1,"1n",{staffPos:"F3"}).addMeasure().addNavigation("startRepeat").addNote(0,"F#4","4n").addLyrics(1,"4n","Bro",{hyphen:"-"}).addNote(0,"G4","4n").addLyrics(1,"4n","ther").addNote(0,"A4","2n").addLyrics(1,"4n","John?").addNote(1,"D3","4n",{stem:"down"}).addLyricsTo(1,1,"4n","Are").addNote(1,"E3","4n").addLyricsTo(1,1,"4n","you").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","sleep",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing?").addMeasure().addNote(0,"F#4","4n").addLyrics(1,"4n","Bro",{hyphen:"-"}).addNote(0,"G4","4n").addLyrics(1,"4n","ther").addNote(0,"A4","2n").addLyrics(1,"4n","John?").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","Are").addNote(1,"E3","4n").addLyricsTo(1,1,"4n","you").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","sleep",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing?").addMeasure().addNote(0,"A4","8n").addLyrics(1,"8n","Morn",{hyphen:"-"}).addNote(0,"B4","8n").addLyrics(1,"8n","ing").addNote(0,"A4","8n").addLyrics(1,"8n","bells").addNote(0,"G4","8n").addLyrics(1,"8n","are").addNote(0,"F#4","4n").addLyrics(1,"4n","ring",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing!").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","Bro",{hyphen:"-"}).addNote(1,"G3","4n").addLyricsTo(1,1,"4n","ther").addNote(1,"A3","2n").addLyricsTo(1,1,"2n","John?").addMeasure().addNote(0,"A4","8n").addLyrics(1,"8n","Morn",{hyphen:"-"}).addNote(0,"B4","8n").addLyrics(1,"8n","ing").addNote(0,"A4","8n").addLyrics(1,"8n","bells").addNote(0,"G4","8n").addLyrics(1,"8n","are").addNote(0,"F#4","4n").addLyrics(1,"4n","ring",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing!").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","Bro",{hyphen:"-"}).addNote(1,"G3","4n").addLyricsTo(1,1,"4n","ther").addNote(1,"A3","2n").addLyricsTo(1,1,"2n","John?").addMeasure().addNote(0,"D4","4n").addLyrics(1,"4n","Ding").addChord(0,["C#4","A4"],"4n").addLyrics(1,"4n","ding").addNote(0,"D4","4n").addLyrics(1,"4n","dong!").addRest(0,"4n").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","Morn",{hyphen:"-"}).addNote(1,"B3","8n").addLyricsTo(1,1,"8n","ing").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","bells").addNote(1,"G3","8n").addLyricsTo(1,1,"8n","are").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","ring",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing!").addMeasure().addNote(0,"D4","4n").addLyrics(1,"4n","Ding").addChord(0,["C#4","A4"],"4n").addLyrics(1,"4n","ding").addNote(0,"D4","4n").addLyrics(1,"4n","dong!").addRest(0,"4n").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","Morn",{hyphen:"-"}).addNote(1,"B3","8n").addLyricsTo(1,1,"8n","ing").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","bells").addNote(1,"G3","8n").addLyricsTo(1,1,"8n","are").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","ring",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing!").addMeasure().setMeasuresPerRow(4).addNote(0,"D4","4n").addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","Ding").addChord(1,["C#3","A3"],"4n").addLyricsTo(1,1,"4n","ding").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","dong!").addRest(1,"4n").addMeasure().addNavigation("endRepeat").addNote(0,"D4","4n").addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","Ding").addChord(1,["C#3","A3"],"4n").addLyricsTo(1,1,"4n","ding").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","dong!").addRest(1,"4n").addMeasure().addNote(0,"F#4","4n").addLyrics(1,"4n","YES").addNote(0,"D4","4n").addLyrics(1,"4n","I'm").addNote(0,"F#4","4n").addLyrics(1,"4n","SLEEP",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ING").addNote(1,"A3","4n").addNote(1,"F#3","4n").addNote(1,"A3","4n").addNote(1,"F#3","4n").addMeasure().addNote(0,"A3","4n").addLyrics(1,"4n","Please").addNote(0,"C#4","8n").addLyrics(1,"8n","GO").addNote(0,"C#4","8n").addLyrics(1,"8n","A",{hyphen:"-"}).addNote(0,"D4","2n").addLyrics(1,"4n","WAY!").addNote(1,"D3","4n").addNote(1,"E3","4n").addNote(1,"F#3","2n").getDocument()}function Hh(){return new Cr().setScoreConfiguration("guitarTreble").setHeader("Greensleeves").addMeasure().setKeySignature("C","Major").setTimeSignature("6/8").setTempo(140).addNote(0,"A3","8n").addMeasure().addNavigation("startRepeat").addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4n").addNote(0,"A3","8n").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").endRow().addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").endRow().addMeasure().addChord(0,["C3","E3","G3","C4","G4"],"4.",{arpeggio:"up",stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addRest(1,"4.",{hide:!0}).addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4.").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","8n").addNote(1,"E3","8n").endRow().addMeasure().addNote(0,"G4","4.",{stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","8n").addNote(1,"C4","8n").addNote(1,"C3","8n").addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNavigation("ending",1).addNavigation("endRepeat").addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").addMeasure().addNavigation("ending",2).addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addFermata().addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").getDocument()}function l0(){return[Uh(),zh(),Yh(),Hh()]}return Ig(d0);})();
289
+ `;Pa(Jf,Av);var fi=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(P.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var qrt=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var Xrt=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var qa=class i extends Me{constructor(){let t=I(i.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Ut(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Ut(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Me.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Ut(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Ut(t,0),this._preDelay=t,this.generate()}generate(){return yt(this,void 0,void 0,function*(){let t=this.ready,e=new pr(2,this._decay+this._preDelay,this.context.sampleRate),r=new qi({context:e}),n=new qi({context:e}),o=new fi({context:e});r.connect(o,0,0),n.connect(o,0,1);let s=new Z({context:e}).toDestination();o.connect(s),r.start(0),n.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=e.render();return this.ready=a.then(nt),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var Un=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new Z({context:this.context}),i._allSolos.has(this.context)||i._allSolos.set(this.context,new Set),i._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(P.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),i._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){i._soloed.has(this.context)||i._soloed.set(this.context,new Set),i._soloed.get(this.context).add(this)}_removeSolo(){i._soloed.has(this.context)&&i._soloed.get(this.context).delete(this)}_isSoloed(){return i._soloed.has(this.context)&&i._soloed.get(this.context).has(this)}_noSolos(){return!i._soloed.has(this.context)||i._soloed.has(this.context)&&i._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),i._allSolos.get(this.context).delete(this),this._removeSolo(),this}};Un._allSolos=new Map;Un._soloed=new Map;var Wa=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new Bo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Xe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,z(this,["pan","volume"])}static getDefaults(){return Object.assign(P.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var vh=class i extends P{constructor(){let t=I(i.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new Un({solo:t.solo,context:this.context}),this._panVol=this.output=new Wa({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),z(this,["pan","volume"])}static getDefaults(){return Object.assign(P.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return i.buses.has(t)||i.buses.set(t,new Z({context:this.context})),i.buses.get(t)}send(t,e=0){let r=this._getBus(t),n=new Z({context:this.context,units:"decibels",gain:e});return this.connect(n),n.connect(r),n}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};vh.buses=new Map;var jat=Xt().transport;var Pat=Xt().destination,Fat=Xt().destination;var Bat=Xt().listener;var Gat=Xt().draw;var Vat=Xt();var wh=class{constructor(){d(this,"audioSource");try{let t=new qa({decay:3,wet:.4}).toDestination(),e=new $r(800,"lowpass").connect(t);this.audioSource=new Fa(Dr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(e)}catch(t){this.audioSource=void 0,console.error(t)}}getName(){return"Synthesizer"}playNote(t,e,r){try{this.audioSource&&(this.audioSource.volume.value=ea(r),this.audioSource.triggerAttackRelease(t,e))}catch(n){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},Sh=new wh;Ti();function Nv(i){return typeof i=="string"?i:(typeof i=="number"&&(i=U.getChromaticNote(i)),i.format(0,0))}var Ua=[Sh],zn=Sh,Ov=(function(t,e,r){var o;let n=parseInt((o=r.split("/")[1])!=null?o:"4");return 60*(1/t)/(e*(1/n))})(2,80,"4/4"),Rv=1,za=!1;function Mv(){return Ua.map(i=>i.getName())}function Ev(){return zn.getName()}function Dv(i){(y.isArray(i)?i:[i]).forEach(t=>{if(!H.Obj.hasProperties(t,["getName","playNote","stop"])||!y.isFunction(t.getName)||!y.isFunction(t.playNote)||!y.isFunction(t.stop))throw new N(7,"Invalid instrument object: "+t);Ua.some(e=>e.getName()===t.getName())?console.warn(`Instrument "${t.getName()}" already added!`):Ua.push(t),eg(t.getName())})}function eg(i){if(i===zn.getName())return;zn.stop();let t=Ua.find(e=>e.getName()===i);t&&(zn=t)}function Ya(i,t,e){za||zn.playNote(Nv(i),t!=null?t:Ov,e!=null?e:Rv)}function Ha(){zn.stop()}function kv(){Ha(),za=!0}function Lv(){za=!1}function jv(){return za}var Wh={};rn(Wh,{Annotation:()=>$n,Arpeggio:()=>gi,Clef:()=>zi,Connective:()=>yi,DocumentBuilder:()=>Cr,DynamicsAnnotation:()=>Yo,Fermata:()=>zo,Label:()=>$o,LyricsAlign:()=>Uo,LyricsHyphen:()=>Hn,MAccidental:()=>Xo,MArpeggio:()=>rs,MBarLineLeft:()=>ps,MBarLineRight:()=>ds,MBeamGroup:()=>ys,MConnective:()=>Cs,MDocument:()=>Xr,MEnding:()=>fs,MExtensionLine:()=>As,MFermata:()=>xs,MHeader:()=>Os,MImage:()=>Zo,MLyrics:()=>_s,MMeasure:()=>ws,MNoteGroup:()=>os,MPlaybackButtons:()=>qh,MPlayer:()=>to,MRenderContext:()=>Vh,MRest:()=>is,MRhythmColumn:()=>cs,MScoreRow:()=>Ns,MScoreRowGroup:()=>Ts,MSpecialText:()=>us,MStaff:()=>Ss,MStaffBarLine:()=>ms,MStaffBeamGroup:()=>bs,MStaffNoteGroup:()=>ss,MStaffRest:()=>ns,MStaffSignature:()=>ts,MTab:()=>Is,MTabNoteGroup:()=>as,MTabRhythm:()=>vs,MTabSignature:()=>es,MText:()=>Qo,MusicInterface:()=>bt,Navigation:()=>br,NoteAnchor:()=>Ke,Paint:()=>Zr,PlayState:()=>Xa,ScoreEvent:()=>Ms,ScoreObjectEvent:()=>Hi,ScoreStaffPosEvent:()=>Yi,StaffPreset:()=>Yn,Stem:()=>gr,TempoAnnotation:()=>Ho,TieType:()=>yr,VerticalPosition:()=>Wo,colorKey:()=>xr,getStringNumbers:()=>$a,getVerseNumbers:()=>rg,getVoiceIds:()=>se,isStringNumber:()=>qo,isVerseNumber:()=>Za,isVoiceId:()=>Qe,validateStringNumber:()=>Pv,validateVerseNumber:()=>Fv,validateVoiceId:()=>Vo});var Yn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(Yn||{}),zi=(e=>(e.G="G",e.F="F",e))(zi||{});function se(){return[0,1,2,3]}function Qe(i){return y.isIncluded(i,se())}function Vo(i){if(Qe(i))return i;throw new N(6,`Voice id ${i} is invalid!`)}function $a(){return[1,2,3,4,5,6]}function qo(i){return y.isIncluded(i,$a())}function Pv(i){if(qo(i))return i;throw new N(6,`String number ${i} is invalid!`)}function rg(){return[1,2,3]}function Za(i){return y.isIncluded(i,rg())}function Fv(i){if(Za(i))return i;throw new N(6,`Verse number ${i} is invalid!`)}var gr=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(gr||{}),gi=(e=>(e.Up="up",e.Down="down",e))(gi||{}),yr=(e=>(e.Stub="stub",e.ToMeasureEnd="toMeasureEnd",e))(yr||{}),Ke=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(Ke||{}),yi=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(yi||{}),Wo=(n=>(n.Auto="auto",n.Above="above",n.Below="below",n.Both="both",n))(Wo||{}),Uo=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(Uo||{}),Hn=(e=>(e.Hyphen="-",e.Extender="---",e))(Hn||{}),zo=(e=>(e.AtNote="atNote",e.AtMeasureEnd="atMeasureEnd",e))(zo||{}),br=(h=>(h.DC_al_Fine="D.C. al Fine",h.DC_al_Coda="D.C. al Coda",h.DS_al_Fine="D.S. al Fine",h.DS_al_Coda="D.S. al Coda",h.Coda="Coda",h.toCoda="toCoda",h.Segno="Segno",h.Fine="Fine",h.StartRepeat="startRepeat",h.EndRepeat="endRepeat",h.Ending="ending",h))(br||{}),$n=(e=>(e.Dynamics="dynamics",e.Tempo="tempo",e))($n||{}),Yo=(p=>(p.cresc="cresc.",p.decresc="decresc.",p.dim="dim.",p.ppp="ppp",p.pp="pp",p.p="p",p.mp="mp",p.m="m",p.mf="mf",p.f="f",p.ff="ff",p.fff="fff",p))(Yo||{}),Ho=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(Ho||{}),$o=(e=>(e.Note="note",e.Chord="chord",e))($o||{}),Xa=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(Xa||{});var Qa=class{constructor(t){d(this,"head");d(this,"tail");this.head=t,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(t){this.tail.push(t)}detachTail(t){let e=this.tail.indexOf(t);e>=0&&this.tail.splice(e,1)}},J=class{constructor(t){this.parent=t;d(this,"anchoredLayoutObjects",[]);d(this,"link");d(this,"userData",{});d(this,"rect",new G);d(this,"needRectUpdate",!0)}getParent(){return this.parent}requestRectUpdate(){this.needRectUpdate=!0}updateRect(){}forceRectUpdate(){this.needRectUpdate=!0,this.updateRect(),this.needRectUpdate=!1}getRect(){return this.needRectUpdate&&this.forceRectUpdate(),this.rect}offsetX(t){this.offset(t,0)}offsetY(t){this.offset(0,t)}setLeft(t){this.offset(t-this.getRect().left,0)}setRight(t){this.offset(t-this.getRect().right,0)}setTop(t){this.offset(0,t-this.getRect().top)}setBottom(t){this.offset(0,t-this.getRect().bottom)}setAnchor(t,e){this.offset(t-this.getRect().anchorX,e-this.getRect().anchorY)}setAnchorX(t){this.offset(t-this.getRect().anchorX,0)}setAnchorY(t){this.offset(0,t-this.getRect().anchorY)}setCenter(t,e){this.offset(t-this.getRect().centerX,e-this.getRect().centerY)}setCenterX(t){this.offset(t-this.getRect().centerX,0)}setCenterY(t){this.offset(0,t-this.getRect().centerY)}getShapeRects(){return[this.rect]}addAnchoredLayoutObject(t){this.anchoredLayoutObjects.push(t)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(t){this.link=t}getLink(){return this.link}isLinked(){return this.link!==null}};var ig={DrawDebugRects:!1,DisableBeams:!1},at={DocumentScale:1,MinStaffWidth:75,MinColumnsWidth:10,ColumnWidthScale:1.7,PostMeasureBreakWidth:10,NoteDotSpace:.5,NoteAccSpace:.5,NoteHeadWidth:2,NoteHeadHeight:1.3,DiamondNoteHeadSize:1.8,DotSize:.8,StemHeight:7,FlagWidth:1.5,FlagHeight:4,FlagSeparation:2,BeamSeparation:1.25,BeamAngleFactor:.5,BeamThickness:4,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var ng="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYAAACCe+v6AAADHXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZZRcu0mDIbfWUWXgCSExHIwmJnu4C6/Pxg7J2kyTdv7GJhjsJCF0CfZJ5y//hzhDzRK5iGpeS45R7RUUuGKicerHetKMa3ratL2Gr2Xh5L3AkMkU/O6LbzlJ+SY074vexO69W9D94QqZvq2UOuWH+/lxzbI/tHQ9kDo2jn2/cA2JLw9Std92x7l4vbuaH2fGYqXyN9+SYyzZrKEa+JolgvmzjEZ4tmno6NxWYb0CugjuO9vVYZPfApJxFUkXV7K/IlUjBlXrAYokhhuFMK5UFbgI1DCBXha9kY1PsF8jc1bjL5o3zlWxCbjnMov1J7xQ97k/HnePLOdBg81z3tB3mON+Rk/lZPehu4Fefbh1529PTu/k4vE9BqK8Ip7jO5jHRqnqCkjFnkf6j7KmkHvmFFcT2V0izkgax2T2Qu6xxobcqrHhko7MC/EoDsoUadKg841NmpwMfHJhpG5BZYldEAq3GQmQ5qdBpsU6eLImHblkPDjC61ty9qukcceYieoMsEY4ZH/3MN3FceYtUQU/YoT0gJ+8axOeBEJ+OcANTCgsYOqK8B3/9gm18lMV5gdB6zxCJeJQ+ktuWSBFigqxgsyWd8GECJsrXCGBARiJlHK8MiYjQiBdACqcJ0l8QECpModTnISyYCD6sDeeMZoqbLyJcZbVVJAsWYUrYNQBayUFPljyZFDVUWTqmY1dS1as+RZeTlbnq/namLJ1LIZ3tlWrLp4cvXs5u7Fa+EieH1rQZ0WL6XUik0rLFc8XaFQ68GHHOnQIx92+FHCURvSp6WmLTdr3kqrnbt0FHjP3br30utJJ1LpTKee+bTTz3LWgVQbMtLQkYeF4aOM+lCjXbYf+7+gRpsaL1JT0R5qkJrdJmi+TnQyAzFOBOAGaiCGxJ7MolNKPMlNZvgeoSqU4aROOJ0mMRBMJ7EOethtcoHr7+EWzBc3/r/kwkT3TXJ/5/YZtT6/Em0Ru8pwBjUKqg/rp1f2Oj+vX47hnxS+O/4Y+jH0Y+jrcYwROv51hb8AKbCqdGIdCl0AAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDQBzFX1O1UqoOdhBxyFCd7OAH0rFUsQgWSluhVQeTS7+gSUOS4uIouBYc/FisOrg46+rgKgiCHyCuLk6KLlLi/5JCi1gPjvvx7t7j7h0gNCpMNXuigKpZRioeE7O5VdH3ij74MYgpRCRm6on0YgZdx9c9PHy9C/Os7uf+HANK3mSARySOMt2wiDeI5zYtnfM+cZCVJIX4nHjSoAsSP3JddvmNc9FhgWcGjUxqnjhILBY7WO5gVjJU4lnikKJqlC9kXVY4b3FWKzXWuid/YSCvraS5TnMMcSwhgSREyKihjAoshGnVSDGRov1YF/+o40+SSyZXGYwcC6hCheT4wf/gd7dmYWbaTQrEgN4X2/4YB3y7QLNu29/Htt08AbzPwJXW9lcbQOST9HpbCx0BQ9vAxXVbk/eAyx1g5EmXDMmRvDSFQgF4P6NvygHDt4B/ze2ttY/TByBDXS3fAAeHwESRste7vLu/s7d/z7T6+wEMNXLkxtwRywAADzRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDA3ODVjMzYtNDAxZC00YTZlLTkxODctMDQ1NTI4MmM0ZGY2IgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjhiZTJkYzc1LTVlYjQtNDk0Yy1iNWRlLWQ2MzZkNzZhNjI2YiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmU3YWE0MWNhLTNiYjMtNGU5Yi05NDQxLTllNTNmZTJiZjM5ZiIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IldpbmRvd3MiCiAgIEdJTVA6VGltZVN0YW1wPSIxNjg2NDA4NjA5MzE2NDM4IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzQiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIgogICB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzOjA2OjEwVDE3OjUwOjA5KzAzOjAwIgogICB4bXA6TW9kaWZ5RGF0ZT0iMjAyMzowNjoxMFQxNzo1MDowOSswMzowMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjI3MzY2YmY0LWVkZDMtNDE5OC05NjJhLWU5ZTM5MTBlNThiZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOC0yMlQwMjo1NTozNiIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NjVlMTM3OS0wZDlmLTQ5ODItYWQ3MC05MzhjOWMzOWE0ZjMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjItMDktMTFUMTY6MzU6MDAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MTBmYmEwYTMtOTI5Yi00NTRlLThjNGMtOGVkOGM4YWJhZGRjIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEwVDE3OjUwOjA5Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Ppn4NIQAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgoOMgm5WlWBAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAACHtJREFUeNrtnXuQVmMcxz+77cauTWUpbGSVu2w3BpnUEBq3chkmBjGayG1GBuNWLtUgw5SJkBkjl4QKg1wyQyarK0lRSlstU20bWam9+OM8O3P6vc8553nOe97tnO18Z84f57zP7XvOc/ndnueFfQx5e6neUmAI0B3oDPwD/AJ8Dvzcml5we+Al4D+gyeOaB1S0BrLHAut9iLqvf4ERSSZbBmwwJOu+RieV8JwQZJuARjXWE4WBIck2X38AByaJ8MwsCTcBTyWFbCFQFwHhv4DiKBqUn2PCPYEin9+bgI3AUuBPn3TtgMuT8IWv8vlq7wLdRPrTgPke6d9JAuFbPBo/3UfKK1TCh8yzIQmEb/cYjx0C8pUDuzV5D477GN6mefY+UBuQby0wV/O8U9wJr9E8W2iY92vNs45xJ6zTfKoN827UPNsdd8K1SlJyo8Awb7XhEIkVYYAVmjXVBPtr1uyqJBBeLu5LDPMdppkPdiaRcHvDfKeJ+++SIFoCLBP3R1toWW58lhQFogiodwkPlYZf1y1w/AcclCQVcYWQtILwqiA8M2lGgDcFgSN90nbXiJUXRdWQ/BYiLMdxH5+0k8VavRb4JGmEl4j7vh7pRgDni2fj1RyQKBwiuqjui/Un015dBbQloXCbaTdrZuUajTp4IwnGbEHmKPX8QmCHhuwC9p4rKBI8IghdB0zCsT1Lsg0+4zwxuEiQqqcVmGWDlAETk+zSJE9Ublyjuqof2TrgxKQT7anMNSZfd1iSiZYCUwy+avP1dJLJXglsxdyV8hHQJolEDwBewc5v9J3Klzj0xYnTsCG7W4mdicMdwC7CeQaPTBLRAjUxZeMKvSwpZPcDPghBUGpE45JAthjH92NLdiUwSDz7NO5k24YkuwTHGZYvtKMtcSabD7wVguy37OkilU7v8rgSfjoE2c816+wkkebKOJK9NgTZ2Wpykxgu0k2IG9lTcMIBbchOx9tTWKHpBbFBoZpwbMi+iL9FtEC8wG1xIvyQJdlJhuVWinzd4kD2cJxYZlOyky3KfkHkvSoOhF+2IPu8Zdk3x82O1QV96JDumhJSu5KB4XsVEwzJziCcy2Z/8UK3K5G1PZnhDi2iBW02IDvPY501xY8BuvJ6JcY+AQzAPCDGGucZkF2GefiCxFk4AWoN2K0AG4HHiSBATWJqQMXr1Qxui3Jlv8o2nHiHIl4UFeF1+G/ACOMGuZVoYqfd12qgX7ZkuwZUMjyEoWBaxETd1y5gVDaEr/YpfGqIyW9ODsm6r7FhCY/z6T625tTpLUS2+bo3DOHZHoVdYFnOqBYmG3rbz1JNQbZ2p2MsZfAor604G8OMsUVTyEBLwjMsv4r7vkapl28AH+PEWNqu1++ZNjRPk3mFJdnjDBu4HBipVoUGsewVaGb6fjgRPSsMSQ8wNb/KjA9bEp5osIzcLUitEml6BNQxxGPoWVtROmoynmFJ+CefRvytxFaJt0W6GwwtqE8GkA56cZSSGVxiI74FhTUM9ch3f0irCerleNU3wbZL2xrJzwhp+hks0s6PaBitMsnsXk7WWlY8xKPi7fjvOZI94x/sHOQFPobGw+U4kHBvrrDVRrw2RE4L6C3V7Ln3sBg43qLeeuAxj996BxHeJCYxm2i4Gh8RMwjL/BpqgA/VpKgTgnwJuzdXtbWUWpZpntUCiwwlPDf6WBLeBSzWPO8URFjuHOthUWm1ptJFaizZErb9wvJjNaMkiLDck2CrYD8n7k13hUrCvUIYB3Vdui6I8FI1qzbjUstKXwe+EV3aBKtE40pwjsKwwQEeuoEv4d3ALNf9ycCpFpU24ngRVrvkYNN8y7Ps1rqlb3MQYXCc3m7YytOb1FCYa2lhzHbiqjAoU4s2GoG+D+Fg85VGijq/ssh7qEboqLGZB6QDvBLHdZpLnK6R0EzlgNs0hGfZVJ6v1lV3ARNzTLhYo0sfY5h3sYWy4ole7Blh16ismrnEStFok/ou05BdR8iA1QfJDN2/PoeEZZTQkwZL0RoN4bvCNiCPzONlGpVJNBe7Tu4TdX1h2bbmmLCCbMfWAvTew6iDQy/QzLReZJ/RtKk+pFiagXZqmdCdyzGG8J5Eic6aOuSe4yK8A+RGRfn2/SqqwdmbVBZBPX/gHbh2MfAbEbtbTAQEr7itehyX6DDCn6zyCZlhUHcoTc7Ltj2WHKNcLexBRvaFaqxdr0Q/k2OixmNudN9uo+BEMcsOAB4AzrXIU6vUxlrVU3YqJaMEOELZoUzW0PeBezz04JyjN07o0mZy7zD7EjiTmKAQOAfHJlyJ/xmWtsHlo1UPCI28FnoBJym9urtaYspwdrOUKkmprerC/6pl7lel/HdxlTORBB/7aIJnLSQuK40orlisUWRaNXpoxnHX1ky4DZlhTkNbc5duwAlNjLRb58f8Ky/e1wgv2dcmrr6aiSur3agFOWxsL6XM91a6crUSCWfi+H9NoDtEsIKY7YI52sNQ4D5uZpBFeTKMamScyJqeFL4L8yOjfhB5x8Rp0ppoaPEoBF4j86A/HerEfUlcCB8GXGGRvqPSZYPQIeAF7DXC/bE3fJsY2eWsvCEuhMtC9oouAROgPPxveVwIN4TM53f08tnifgfmh/nmnPC6kPk2+fx2k7ifpWb4WKAT9mG+foFvMqqvkRj+pYntFp0HPMrZj8wg1VieEd8Tc6NdFXr3TCFOgLc77TZifE7AaAOyv+MY9iS64pxBK7vyJXHWcLy8eu4T0dybo9vhBMBMJvMwwEbgzqSodnfhvxOtDieQzOv3ncRkE7UNytV4tJ295+LsnUgsugKPAt/jvQm7DmcX2+Bcj7eWRjFwAo4rtYOa1avUMrSTFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIgL8D6ed2EKeJMaTAAAAAElFTkSuQmCC";var og="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABGCAYAAACQRffVAAADInpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7VdbktwgDPznFDkCkgCJ4/AwVblBjp8GY+/OZFPZPD7yMVADWIiWUEt2jTu+fR3uCxplTi5EtZRT8mghh8wFC/Nnq2skH9a4mrS9R49yF9LeYIhkap6Pmbf8gBxr2s95G6FL/wK6FlSwim8bpWx5fZTXDcj2DLQ3hE7Lvu8DG0h4exTO57Y9Stn04Wp93xmKp8jefkGUU0ykAWNgr5oy1sY+KOLZp6PcznP31S7B9XypMnziQ0g8RpFweinzJ1IwJ4wk4qA4hUXiGlmWGTiUEG4Fbj6BR/F3MN/H5i1GP2mfuZaHkXFM5XdXu+envOn147y5VzsN3JU3lvaGPNLq0z1/KKd4AV0bctvh95at3ZYf5ENWdt3Nvad7jG5jXRq3KCEhFmlf6rrKWkGvziiuUwldfXLANSxmz+jmi2/Iqe4bKq1inYnB/aBAnQoNOtbcqMHFwAcrZubmWJbQQFLmhlQgCbPTYJUsXQwp0c4cEr59oWU2L3ONzHfnO0GVCWCEI3/c3WcVx5i1ROTtjBM8g188qxNeeAL9c4IaGKGxgxpXgK/+3CavAgbjCrPhgsVXd0LUSG/JJYvoSW/EfFY9ad8ACBFMRzhDAgZ8IomU4JEyKxECaSCowHWWwBUMUIzc4SQHkQRyUB2wjTNKS5Ujn2K8VSU4FGsSBTdZCsgKISJ/NBhyqESJIcaYokaLOZYkaVZeSprm67moaNCoSVXNadZiYsGiJVMzy1YyZ8HrO2bUabaccykwWoBccLpAoZTKVWqosaaq1Wp2tTSkTwstttS0WcutdO7SUeA9de3Wcy8HHUilIxzxSIceduSjDKTakBFGHGmoGzbyKDdrtMv2uf8Ga7RZ48XUVNSbNUhVLwiar5M4OQNjHAiEK1gDY0jsyZk3CoEnc5MzfI9QFZHhZJzkdJqMgcFwEMdBN3ebOcfl3/Dm1BZv/LfMuUndJ5n7kbePWOvzK9EWY2cZzqB6QfVh/7DCVubn9aez+5XCZ+cX0AvoBfQCegG9gP57oIEPJ/4Bue+bLIaQwqExNwAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNAHMVfU7UiFQeLijhkqE4WREUcSxWLYKG0FVp1MLn0Q2jSkKS4OAquBQc/FqsOLs66OrgKguAHiKuLk6KLlPi/pNAixoPjfry797h7Bwj1MlPNjiigapaRisfEbG5FDLyiC0EMYgIDEjP1RHohA8/xdQ8fX+8iPMv73J+jV8mbDPCJxFGmGxbxOvHMpqVz3icOsZKkEJ8Tjxt0QeJHrssuv3EuOizwzJCRSc0Rh4jFYhvLbcxKhko8TRxWVI3yhazLCuctzmq5ypr35C8M5rXlNNdpjiCORSSQhAgZVWygDAsRWjVSTKRoP+bhH3b8SXLJ5NoAI8c8KlAhOX7wP/jdrVmYmnSTgjGg88W2P0aBwC7QqNn297FtN04A/zNwpbX8lTow+0l6raWFj4C+beDiuqXJe8DlDjD0pEuG5Eh+mkKhALyf0TflgP5boGfV7a25j9MHIENdLd0AB4fAWJGy1zze3d3e279nmv39ANCccsygwwDVAAAQE2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDo0MDc4NWMzNi00MDFkLTRhNmUtOTE4Ny0wNDU1MjgyYzRkZjYiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Nzg3YjYxN2YtMjg1MS00YzhlLTg2MTYtZWM3NGMwYzYwMWVlIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZTdhYTQxY2EtM2JiMy00ZTliLTk0NDEtOWU1M2ZlMmJmMzlmIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iV2luZG93cyIKICAgR0lNUDpUaW1lU3RhbXA9IjE2ODY2MTM5NDcxOTU2ODAiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zNCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiCiAgIHhtcDpNZXRhZGF0YURhdGU9IjIwMjM6MDY6MTNUMDI6NTI6MjUrMDM6MDAiCiAgIHhtcDpNb2RpZnlEYXRlPSIyMDIzOjA2OjEzVDAyOjUyOjI1KzAzOjAwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MjczNjZiZjQtZWRkMy00MTk4LTk2MmEtZTllMzkxMGU1OGJlIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIyLTA4LTIyVDAyOjU1OjM2Ii8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjk2NWUxMzc5LTBkOWYtNDk4Mi1hZDcwLTkzOGM5YzM5YTRmMyIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOS0xMVQxNjozNTowMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMGZiYTBhMy05MjliLTQ1NGUtOGM0Yy04ZWQ4YzhhYmFkZGMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMDYtMTBUMTc6NTA6MDkiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDBmYjM4YTMtZjZiMi00NjQ1LTliMTYtMjlhNWE0ODZlMjhhIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEzVDAyOjUyOjI3Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/PsIRrtIAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgwXNBsqJURsAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAABF9JREFUeNrtmluIF1Ucxz9/E8P1VnnJ9dJWC4Frmq2JJmqolGEILoQvK2gZeXlRCSm1Fx9UEsJQERWsXhRftECs0Gq70EK9ZHlbFyHbds3VVXFX91+7664P81tYhpnfmft//st84TzMzDm/8/vOnPO7nYEMGTJkyJAhQ4YMGSJBLkJZw4FyYAIwDHgU+A9oAxqBv4C7xfyySoBlwKfAFaAb6DG0euAzoAoYXCxEnwH2A60eCGrtFrALGJNWokNEwY6QRO2tFXgPGJAmss8DlyImam/fASPTQHaeGJueBFod8FQhrfSLwM+ynDX8L1/oV+BP4LZY58eBUUAlMB94ycPSvQTMERmJ4jGgwYPh2Qg84VFmGbAP6DTI/aoQS/lzg1JfA2MDyn4ZuGaQvyZJspUGv3oKGBhyjmeBJmWOmxLMJIITiiIXIgwaZgFdylxbDeNHANXAZmAVUBpEiScNe2xRxC/3Y2WuRmUlLRHD1rd/HljvV4F3FAVqYlhNo4B7Pl/wdPEMbmOq/ShwRBH0Vkxb6LAy536fW64HuOpn8vOKoLKYCC9Q5rzs0L/JQxDjyYPkgHYXAW0xGslByrLuFuPUFw0eCI92mmiAQ4LgZoEbYyTcAZxVPsJk271ag7x6cWueCLvhfsyu8LzybKLtersUF9ywxe2BnXBnAZOUJuXZeNv1OSki3LLdzwPrgONuguw+7g7wAHjEoW+vEagAXgeelr1yUSZoCUn4hvJsqMO9byRaWyLGtFkiwOtBJnYzBKcVg/ZuSMIrlHl3RrWMnFK1OqX/q8oXOAisDqFLVxL7xonw9yHk7Q5RoxpuyLdjI3wmhLzBwMqAY0ck4SGcCNeKIQqKOTF84RtxEu4BPgohc2QM467HSRjgqBL5mBDUPU1Rnl1JwqBNUuJqrW0M+OLdYuk8Cdas38Rf4b3FR0HP/nLdZNYaioKbxSVuA6ZGQfoNvNWlO6VvEKxW5O5yGbNc4ml7ZrUtCtLjgGMSdjop9Q+wMIT8GoXwKw79ZxrKUG9r+a8flMoyr5AA4ybwo1QgggYHpZJ6Ou3Ta5IpddvufwEsVWQ2xFisCI1Nypf6RMmsIql4JI0S8bFuSs9UvmCgikeh8b6i8C/KuKOYD+VShzGSwLsprRnByYYYoSqNhE8qCv/kYfxrYjT7jmuPIC+PBWsVsl1YRzBeE45qqWGtwjo1SR0WoZ8a7KAfYa5h7/2OVaPuF1gqtS83srclpi565IAP0c+b7wOz+wPZckOc3Jt0LC52oiXABx7y6VasGnfRYgiwwRAu9raGqPLXQmAGcADvvyN+m9bgXnP4i4E9wN8+KiJ5WQG5QilumnioJP9lwHPANKw/fF7A+fxJw2ms/y9SFdiPBf4Vn9hJNL8T/iFxbyoxgej+m6zBOtnLpXlvhiXcDOyVJV8UCEL4KnBI/OnAtBP0q+ADMTq/SfshrdUFr4TzwJdY9d57WIdYzRIk1GMdeXSQIUOGDBmSwUMtd8u2ArdcUAAAAABJRU5ErkJggg==";var Bv=new lt([[0,ng],[1,og]]),Gv=i=>Bv.getOrDefault(i,""),Vv=new _l;function qv(i,t){return!i&&!t?!0:!i||!t?!1:i.scoreRow===t.scoreRow&&i.diatonicId===t.diatonicId}function Wv(i,t){return!i&&!t?!0:!i||!t?!1:i.length===t.length&&i.every((e,r)=>e===t[r])}var Ka=class{constructor(t){this.mi=t;d(this,"devicePixelRatio");d(this,"fontSize");d(this,"unitSize");d(this,"_lineWidth");d(this,"scoreEventListener");d(this,"canvas");d(this,"ctx");d(this,"mdoc");d(this,"paint",Zr.default);d(this,"cursorRect");d(this,"mousePos");d(this,"curStaffPos");d(this,"curObjects");d(this,"hilightedStaffPos");d(this,"hilightedObj");d(this,"usingTouch",!1);d(this,"onClickFn");d(this,"onMouseMoveFn");d(this,"onMouseLeaveFn");d(this,"onTouchEndFn");this.devicePixelRatio=typeof window!="undefined"?window.devicePixelRatio:1,this.fontSize=Ws.FontSize*at.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this._lineWidth=this.unitSize*.2,this.onClickFn=this.onClick.bind(this),this.onMouseMoveFn=this.onMouseMove.bind(this),this.onMouseLeaveFn=this.onMouseLeave.bind(this),this.onTouchEndFn=this.onTouchEnd.bind(this)}getMusicInterface(){return this.mi}get doc(){var t;return(t=this.mdoc)==null?void 0:t.getMusicObject()}getImageAsset(t,e){var r;return e!=null||(e=""),(r=Vv.getOrCreate(t,e,()=>{let n={src:Gv(t),color:e,loaded:!1,colorized:!1},o=new Image;return o.src=n.src,o.onload=()=>{n.img=o,this.onImageLoaded(n)},o.onerror=()=>{console.error("Failed to load image: "+n.src)},n}))==null?void 0:r.img}forceDraw(){var t;(t=this.doc)==null||t.requestFullLayout(),this.draw()}onImageLoaded(t){if(t.loaded||!t.img)return;let e=this.paint.getColor(t.color);if(t.colorized||e===""||e==="black"||e==="#000"||e==="#0000"||e==="#000000"||e==="#00000000"){this.forceDraw(),t.loaded=!0;return}let[r,n,o,s]=Zr.colorNameToRGBA(e),a=40;if(typeof document=="undefined"){console.error("Failed to colorize image: document is undefined.");return}let c=document.createElement("canvas");c.width=t.img.width,c.height=t.img.height;let u=c.getContext("2d");if(u==null){console.error("Failed to colorize image: ctx = null.");return}u.drawImage(t.img,0,0);let l=u.getImageData(0,0,c.width,c.height),h=l.data;for(let p=0;p<h.length;p+=4){let m=h[p],f=h[p+1],g=h[p+2];h[p+3]!==0&&m<a&&f<a&&g<a&&(h[p+0]=r,h[p+1]=n,h[p+2]=o)}u.putImageData(l,0,0),t.img.src=c.toDataURL("image/png"),t.img.onload=()=>{t.colorized=!0,this.onImageLoaded(t)},t.img.onerror=()=>{console.error("Failed to colorize image.")}}setDocument(t){if(this.mdoc===t)return;this.updateCursorRect(void 0);let e=this.mdoc;this.mdoc=t,e&&e.getMusicObject().setRenderContext(void 0),t&&t.getMusicObject().setRenderContext(this)}setPaint(t){this.paint=t!=null?t:Zr.default}getPaint(){return this.paint}setCanvas(t){var e,r;this.canvas!==t&&(this.canvas&&(this.canvas.removeEventListener("click",this.onClickFn),this.canvas.removeEventListener("mousemove",this.onMouseMoveFn),this.canvas.removeEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.removeEventListener("touchend",this.onTouchEndFn)),this.canvas=t,this.canvas.addEventListener("click",this.onClickFn),this.canvas.addEventListener("mousemove",this.onMouseMoveFn),this.canvas.addEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.addEventListener("touchend",this.onTouchEndFn),this.canvas.style.position="relative"),this.ctx=(r=(e=this.canvas)==null?void 0:e.getContext("2d"))!=null?r:void 0}setScoreEventListener(t){this.scoreEventListener=t}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(t){return new xl(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!qv(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new Yi("leave",this.getMusicInterface(),n.getMusicInterface(),o))}if(r&&t&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=t;this.scoreEventListener(new Yi("enter",this.getMusicInterface(),n.getMusicInterface(),o))}if(e&&t&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=t;this.scoreEventListener(new Yi("click",this.getMusicInterface(),n.getMusicInterface(),o))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!Wv(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new Hi("leave",this.getMusicInterface(),this.curObjects.map(n=>n.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Hi("enter",this.getMusicInterface(),t.map(n=>n.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Hi("click",this.getMusicInterface(),t.map(n=>n.getMusicInterface()))),this.curObjects=t,r}onClick(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),this.scoreEventListener)){let r=e.pick(this.mousePos.x,this.mousePos.y),n=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(n,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),!this.usingTouch)){let r=e.pick(this.mousePos.x,this.mousePos.y),n=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(n,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(t){if(!this.needMouseInput())return;this.mousePos=void 0;let e=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(e||r)&&this.draw()}onTouchEnd(t){this.usingTouch=!0}hilightObject(t){this.hilightedObj=t}hilightStaffPos(t){this.hilightedStaffPos=t}updateCursorRect(t){this.cursorRect=t,this.draw()}updateCanvasSize(){let{canvas:t,doc:e}=this;if(t&&e){let r=e.getRect(),n=r.width+1,o=r.height+1;t.width=n,t.height=o,t.style.width=n/this.devicePixelRatio+"px",t.style.height=o/this.devicePixelRatio+"px"}}draw(){try{let{doc:t}=this;t&&(t.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),t.drawContent())}catch(t){console.error("Render failed!",t)}}drawHilightStaffPosRect(){let{mousePos:t,hilightedStaffPos:e,unitSize:r}=this;if(!e)return;let{scoreRow:n,diatonicId:o}=e,s=n.getStaff(o);s&&(this.fillColor(this.paint.colors["hilight.staffpos"]),this.fillRect(s.row.getRect().left,s.getDiatonicIdY(o)-r,s.row.getRect().width,2*r),t!==void 0&&this.drawLedgerLines(s,o,t.x))}drawHilightObjectRect(){let{hilightedObj:t}=this;if(!t)return;let e=t.getRect();this.lineColor(this.paint.colors["hilight.object"]),this.strokeRect(e.left,e.top,e.width,e.height)}drawPlayCursor(){let{cursorRect:t}=this;t&&this.color(this.paint.colors["play.cursor"]).lineWidth(2).strokeLine(t.centerX,t.top,t.centerX,t.bottom)}txFromScreenCoord(t){return t.mul(this.devicePixelRatio)}txToScreenCoord(t){return t.div(this.devicePixelRatio)}clearCanvas(){this.ctx&&(this.ctx.canvas.style.background=this.getPaint().colors.background,this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height))}drawDebugRect(t){ig.DrawDebugRects&&this.color("red").lineWidth(1).strokeRect(t.left,t.top,t.width,t.height)}drawLedgerLines(t,e,r){let{unitSize:n}=this,o=n*at.LedgerLineWidth;if(e>=t.topLineDiatonicId+2){for(let s=t.topLineDiatonicId+2;s<=e;s+=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}else if(e<=t.bottomLineDiatonicId-2){for(let s=t.bottomLineDiatonicId-2;s>=e;s-=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}}getRestRect(t){let{unitSize:e}=this,{flagCount:r}=Tt.get(Br(t+"n")),n=0,o=0,s=0,a=0;if(Tt.equals(t,"1n"))n=e,o=e,s=0,a=e;else if(Tt.equals(t,"2n"))n=e,o=e,s=e,a=0;else if(Tt.equals(t,"4n"))n=e*1,o=e*1,s=e*3.2,a=e*3;else{let c=1-r%2;n=e*(1+r*.25),o=e*(1+r*.125),s=e*(.5+r-c),a=e*(1+r+c)}return new G(-n,0,o,-s,0,a)}drawRest(t,e,r){let{unitSize:n}=this,{flagCount:o}=Tt.get(Br(t+"n"));if(Tt.equals(t,"1n"))this.fillRect(e-n,r,n*2,n);else if(Tt.equals(t,"2n"))this.fillRect(e-n,r-n,n*2,n);else if(Tt.equals(t,"4n"))this.beginPath(),this.moveTo(e-n*.6,r-n*3.2),this.lineTo(e+n*.7,r-n*1.5),this.quadraticCurveTo(e-n*.8,r-n*.5,e+n*1,r+n*1.5),this.lineTo(e-n*1,r-n*.75),this.quadraticCurveTo(e+n*.2,r-n*1.5,e-n*.6,r-n*3.2),this.moveTo(e+n*1,r+n*1.5),this.quadraticCurveTo(e-n*.8,r+n*1,e-n*.2,r+n*2.8),this.bezierCurveTo(e-n*1.8,r+n*1.5,e-n*.6,r-n*.2,e+n*.9,r+n*1.5),this.fill(),this.stroke();else if(o>0){let s=1-o%2,a=u=>e+(-u*.25+.5)*n,c=u=>r+(u+s)*n;this.beginPath(),this.moveTo(a(1+o),c(1+o)),this.lineTo(a(-.5-o),c(-.5-o)),this.stroke();for(let u=0;u<o;u++){let l=o-u*2;this.beginPath(),this.moveTo(a(l-2.5),c(l-2.5)),this.quadraticCurveTo(a(l-.5)+n*.25,c(l-1.5),a(l-1.5)-n*1.5,c(l-1.5)),this.stroke(),this.beginPath(),this.arc(a(l-2)-n*1.5,c(l-2),n*.5,0,Math.PI*2),this.fill()}}}drawFlag(t,e){let r=t.left,o=t.right-r,s=e==="up"?t.top:t.bottom,a=e==="up"?t.bottom:t.top;this.beginPath(),this.moveTo(r,s),this.bezierCurveTo(r,s*.75+a*.25,r+o*1.5,s*.5+a*.5,r+o*.5,a),this.stroke()}color(t){return this.ctx&&(this.ctx.strokeStyle=this.ctx.fillStyle=this.paint.getColor(t)),this}lineColor(t){return this.ctx&&(this.ctx.strokeStyle=this.paint.getColor(t)),this}fillColor(t){return this.ctx&&(this.ctx.fillStyle=this.paint.getColor(t)),this}lineWidth(t){return this.ctx&&(this.ctx.lineWidth=this._lineWidth*(t!=null?t:1)),this}font(t){return this.ctx&&(this.ctx.font=t),this}beginPath(){return this.ctx&&this.ctx.beginPath(),this}stroke(){return this.ctx&&this.ctx.stroke(),this}fill(){return this.ctx&&this.ctx.fill(),this}moveTo(t,e){return this.ctx&&this.ctx.moveTo(t,e),this}lineTo(t,e){return this.ctx&&this.ctx.lineTo(t,e),this}bezierCurveTo(t,e,r,n,o,s){return this.ctx&&this.ctx.bezierCurveTo(t,e,r,n,o,s),this}quadraticCurveTo(t,e,r,n){return this.ctx&&this.ctx.quadraticCurveTo(t,e,r,n),this}fillRect(t,e,r,n){return this.ctx&&this.ctx.fillRect(t,e,r,n),this}setLineDash(t){return this.ctx&&this.ctx.setLineDash(t),this}drawImage(t,e,r,n,o){return this.ctx&&this.ctx.drawImage(t,e,r,n,o),this}ellipse(t,e,r,n,o,s,a){return this.ctx&&this.ctx.ellipse(t,e,r,n,o,s,a),this}clip(){return this.ctx&&this.ctx.clip(),this}save(){return this.ctx&&this.ctx.save(),this}restore(){return this.ctx&&this.ctx.restore(),this}rect(t,e,r,n){return this.ctx&&this.ctx.rect(t,e,r,n),this}scale(t,e){return this.ctx&&this.ctx.scale(t,e),this}strokeRect(t,e,r,n){return this.ctx&&this.ctx.strokeRect(t,e,r,n),this}fillText(t,e,r){return this.ctx&&this.ctx.fillText(t,e,r),this}getTextWidth(t,e){if(this.ctx){let r=this.ctx.font;this.ctx.font=e;let n=this.ctx.measureText(t);return this.ctx.font=r,n.width}else return H.Dom.getCanvasTextWidth(t,e)}arc(t,e,r,n,o){return this.ctx&&this.ctx.arc(t,e,r,n,o),this}fillCircle(t,e,r){return this.ctx?(this.ctx.beginPath(),this.ctx.arc(t,e,r,0,2*Math.PI),this.ctx.fill(),this):this}strokeLine(t,e,r,n){return this.ctx?(this.ctx.beginPath(),this.ctx.moveTo(t,e),this.ctx.lineTo(r,n),this.ctx.stroke(),this):this}strokePartialLine(t,e,r,n,o,s){if(!this.ctx)return this;let a=t+(r-t)*o,c=e+(n-e)*o,u=t+(r-t)*s,l=e+(n-e)*s;return this.ctx.beginPath(),this.ctx.moveTo(a,c),this.ctx.lineTo(u,l),this.ctx.stroke(),this}drawBracket(t,e){if(!this.ctx)return this;let{left:r,right:n,width:o,top:s,bottom:a,height:c,anchorY:u}=t;switch([")","]","}",">"].includes(e)&&([r,n,o]=[n,r,-o]),e){case"(":case")":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.bezierCurveTo(r-o*.2,s+c*.3,r-o*.2,s+c*.7,n,a),this.ctx.stroke();break;case"{":case"}":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.bezierCurveTo(r+o*.1,s,r+o*.8,u,r,u),this.ctx.moveTo(n,a),this.ctx.bezierCurveTo(r+o*.1,a,r+o*.8,u,r,u),this.ctx.stroke();break;case"[":case"]":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.lineTo(r,s),this.ctx.lineTo(r,a),this.ctx.lineTo(n,a),this.ctx.stroke();break;case"<":case">":this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.lineTo(r,u),this.ctx.lineTo(n,a),this.ctx.stroke();break}return this}};var Ja=class{constructor(t){this.measure=t;d(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(n=>n.diatonicClass===U.getDiatonicClass(t));return r?r.accidental:void 0}setAccidental(t){this.accidentalByDiatonicId[t.diatonicId]=t.accidental}needAccidental(t){var r,n;let e=(n=(r=this.accidentalByDiatonicId[t.diatonicId])!=null?r:this.getAccidentalFromKeySignature(t.diatonicId))!=null?n:0;return t.accidental!==e}};var tc=class extends J{constructor(e,r,n,o,s){super(e);this.image=r;this.anchorX=n;this.anchorY=o;this.imageScale=s;d(this,"mi");this.mi=new Zo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:n,image:o,imageScale:s}=this,{unitSize:a}=e;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=G.createSections(c*r,c*(1-r),u*n,u*(1-n))}catch(c){this.rect=new G}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=this.rect;e.drawDebugRect(r),e.drawImage(this.image,r.anchorX-r.leftw,r.anchorY-r.toph,r.width,r.height)}};var $i=class extends J{constructor(e,r,n,o="black"){super(e);this.diatonicId=r;this.accidental=n;this.color=o;d(this,"mi");this.mi=new Xo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;switch(this.accidental){case-2:this.rect=G.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=G.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=G.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=G.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=G.createSections(r*1,r*1,r*1,r*1);break;default:throw new N(6,"Invalid accidental value: "+this.accidental)}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect);let{unitSize:r}=e,{accidental:n}=this,o=this.rect.anchorX,s=this.rect.anchorY;e.color(this.color);let a=(c,u)=>{e.lineWidth(1).beginPath().moveTo(c-r*.75,u-r*4).lineTo(c-r*.75,u+r*1.1).bezierCurveTo(c+r*.75,u-r*0,c+r*.75,u-r*2.2,c-r*.75,u-r*.5).stroke()};n===-2?(a(o-r*.5,s),a(o+r*.5,s)):n===-1&&a(o,s),n===0?e.beginPath().lineWidth(1).moveTo(o-r*.5,s-r*2.2).lineTo(o-r*.5,s+r*1).moveTo(o+r*.5,s+r*2.2).lineTo(o+r*.5,s-r*1).stroke().beginPath().lineWidth(2).moveTo(o-r*.5,s+r*1).lineTo(o+r*.5,s+r*.6).moveTo(o+r*.5,s-r*1).lineTo(o-r*.5,s-r*.6).stroke():n===1?e.lineWidth(1).beginPath().moveTo(o-r*.3,s-r*1.6).lineTo(o-r*.3,s+r*2).moveTo(o+r*.3,s-r*2).lineTo(o+r*.3,s+r*1.6).stroke().lineWidth(2).beginPath().moveTo(o-r*.75,s-r*.5).lineTo(o+r*.75,s-r*.9).moveTo(o-r*.75,s+r*.9).lineTo(o+r*.75,s+r*.5).stroke():n===2&&e.lineWidth(1).beginPath().moveTo(o-r*.75,s-r*.75).lineTo(o+r*.75,s+r*.75).moveTo(o-r*.75,s+r*.75).lineTo(o+r*.75,s-r*.75).stroke().fillRect(o-r*1,s-r*1,r*.7,r*.7).fillRect(o+r*.3,s-r*1,r*.7,r*.7).fillRect(o-r*1,s+r*.3,r*.7,r*.7).fillRect(o+r*.3,s+r*.3,r*.7,r*.7)}};var Uv=.5,ot=class extends J{constructor(e,r,n,o){var a,c,u,l,h,p;super(e);this.anchorX=n;this.anchorY=o;d(this,"text");d(this,"scale");d(this,"color");d(this,"bold");d(this,"italic");d(this,"boxed");d(this,"padding");d(this,"bgcolor");d(this,"font","");d(this,"textLines");d(this,"lineWidths",[]);d(this,"lineHeight",0);d(this,"mi");let s=typeof r=="string"?{text:r}:r;this.text=s.text,this.scale=(a=s.scale)!=null?a:1,this.color=(c=s.color)!=null?c:"black",this.bold=(u=s.bold)!=null?u:!1,this.italic=(l=s.italic)!=null?l:!1,this.boxed=(h=s.boxed)!=null?h:!1,this.padding=(p=s.padding)!=null?p:this.boxed?Uv:0,this.bgcolor=s.bgcolor,(!isFinite(this.padding)||this.padding<0)&&(this.padding=0),this.textLines=this.text.split(`
290
+ `),this.textLines.length===0&&(this.textLines=[""]),this.rect=new G,this.mi=new Qo(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{scale:r,anchorX:n,anchorY:o,bold:s,italic:a}=this,c=e.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(p=>e.getTextWidth(p,this.font)),this.lineHeight=c;let u=this.padding*e.unitSize,l=u+Math.max(...this.lineWidths)+u,h=u+this.lineHeight*this.textLines.length+u;(this.boxed==="square"||this.boxed==="circle")&&(h=l=Math.max(h,l)),this.rect=G.createSections(l*n,l*(1-n),h*o,h*(1-o))}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){var b;e.drawDebugRect(this.rect),e.lineWidth(1).font(this.font);let{rect:r,padding:n,lineHeight:o,lineWidths:s,anchorX:a,anchorY:c,italic:u}=this;this.bgcolor!==void 0&&(e.save(),e.fillColor((b=this.bgcolor)!=null?b:"black"),e.beginPath(),e.fillRect(r.left,r.top,r.width,r.height),e.fill(),e.restore());let h=this.textLines.length*o,p=-o*(u?.25:.2),m=n*e.unitSize,f=(r.left+m)*(1-a)+(r.right-m)*a,g=(r.top+m)*(1-c)+(r.bottom-m)*c;switch(e.color(this.color),this.textLines.forEach((x,_)=>{let w=f-s[_]*a,T=g-h*c+o*(_+1)+p;e.fillText(x,w,T)}),this.boxed){case"square":case"rectangle":e.strokeRect(r.left,r.top,r.width,r.height);break;case"circle":case"ellipse":e.beginPath(),e.ellipse(r.centerX,r.centerY,r.width/2,r.height/2,0,0,2*Math.PI),e.stroke();break}}};var Ko=class extends J{constructor(e,r){super(e);this.measure=e;this.staff=r;d(this,"clefImage");d(this,"eightBelowClef");d(this,"measureNumber");d(this,"ksNeutralizeAccidentals",[]);d(this,"ksNewAccidentals",[]);d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new ts(this)}get doc(){return this.measure.doc}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let n=e.getPaint().getColor("staff.signature.clef");["black","#000","#000000"].includes(n)&&(n="");let o=e.getImageAsset(this.staff.clefImageAsset,n);this.clefImage=o?new tc(this,o,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new ot(this,{text:"8",color:n},.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(e){if(e){let r="staff.signature.measurenum",n=this.measure.getMeasureNumber().toString();this.measureNumber=new ot(this,{text:n,color:r},0,1)}else this.measureNumber=void 0}updateKeySignature(e){if(e){let{measure:r}=this,n="staff.signature.key",o=r.getPrevMeasure(),s=o?o.getKeySignature():void 0,a=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],s&&!rr.equals(a,s)&&s.getOrderedAccidentalNotes().forEach(c=>{this.ksNeutralizeAccidentals.push(new $i(this,this.getAccidentalDiatonicId(c),0,n))}),a.getOrderedAccidentalNotes().forEach(c=>{this.ksNewAccidentals.push(new $i(this,this.getAccidentalDiatonicId(c),c.accidental,n))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),n="staff.signature.time",o=r.beatCount.toString();this.beatCountText=new ot(this,{text:o,color:n,scale:1.4},.5,.5);let s=r.beatSize.toString();this.beatSizeText=new ot(this,{text:s,color:n,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r="staff.signature.tempo",n=ta(this.measure.getTempo());this.tempoText=new ot(this,{text:n,color:r},.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(e){let{clef:r}=this.staff.staffConfig,n;if(r==="G"?e.accidental>0?n=this.staff.bottomLineDiatonicId+3:e.accidental<0&&(n=this.staff.bottomLineDiatonicId+1):r==="F"&&(e.accidental>0?n=this.staff.bottomLineDiatonicId+1:e.accidental<0&&(n=this.staff.bottomLineDiatonicId-1)),n!==void 0)return U.findNextDiatonicIdAbove(e.diatonicId,n,!1);throw new N(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.eightBelowClef){let n=this.eightBelowClef.pick(e,r);if(n.length>0)return[this,...n]}if(this.clefImage){let n=this.clefImage.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.ksNeutralizeAccidentals.length;n++){let o=this.ksNeutralizeAccidentals[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.ksNewAccidentals.length;n++){let o=this.ksNewAccidentals[n].pick(e,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let n=this.beatCountText.pick(e,r);if(n.length>0)return[this,...n]}if(this.beatSizeText){let n=this.beatSizeText.pick(e,r);if(n.length>0)return[this,...n]}if(this.tempoText){let n=this.tempoText.pick(e,r);if(n.length>0)return[this,...n]}if(this.measureNumber){let n=this.measureNumber.pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){var u,l,h,p,m,f;let{unitSize:r}=e,{staff:n}=this,o=r,s=0;if(this.rect=new G,this.clefImage&&(s+=o,this.clefImage.layout(e),this.clefImage.setAnchor(s,n.getDiatonicIdY(n.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let g=this.clefImage.getRect();this.eightBelowClef.layout(e),this.eightBelowClef.setCenterX(g.centerX),this.eightBelowClef.setTop(Math.max(g.anchorY+g.height*.3,n.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}this.measureNumber&&(this.measureNumber.layout(e),this.measureNumber.setLeft(0),this.measureNumber.setBottom(Math.min(n.getTopLineY(),this.clefImage?this.clefImage.getRect().top:n.getTopLineY())),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),this.ksNeutralizeAccidentals.length>0&&(s+=o,this.ksNeutralizeAccidentals.forEach(g=>{g.layout(e),g.setLeft(s),g.setAnchorY(n.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(g=>{g.layout(e),g.setLeft(s),g.setAnchorY(n.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right}));let a=s;(u=this.beatCountText)==null||u.layout(e),(l=this.beatSizeText)==null||l.layout(e);let c=Math.max((p=(h=this.beatCountText)==null?void 0:h.getRect().width)!=null?p:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.setCenter(s+c/2+o,n.getDiatonicIdY(n.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.setCenter(s+c/2+o,n.getDiatonicIdY(n.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText&&(this.tempoText.layout(e),this.tempoText.setCenterX(s),this.tempoText.setBottom(n.getTopLineY()),this.clefImage&&G.overlap(this.clefImage.getRect(),this.tempoText.getRect())&&this.tempoText.setBottom(this.clefImage.getRect().top),[...this.ksNeutralizeAccidentals,...this.ksNewAccidentals].forEach(g=>{this.tempoText&&G.overlap(g.getRect(),this.tempoText.getRect())&&this.tempoText.setBottom(g.getRect().top)}),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){var n,o,s,a,c,u;(n=this.clefImage)==null||n.offset(e,r),(o=this.eightBelowClef)==null||o.offset(e,r),(s=this.measureNumber)==null||s.offset(e,r),this.ksNeutralizeAccidentals.forEach(l=>l.offset(e,r)),this.ksNewAccidentals.forEach(l=>l.offset(e,r)),(a=this.beatCountText)==null||a.offset(e,r),(c=this.beatSizeText)==null||c.offset(e,r),(u=this.tempoText)==null||u.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,n,o,s,a,c;(r=this.clefImage)==null||r.draw(e),(n=this.eightBelowClef)==null||n.draw(e),(o=this.measureNumber)==null||o.draw(e),this.ksNeutralizeAccidentals.forEach(u=>u.draw(e)),this.ksNewAccidentals.forEach(u=>u.draw(e)),(s=this.beatCountText)==null||s.draw(e),(a=this.beatSizeText)==null||a.draw(e),(c=this.tempoText)==null||c.draw(e)}},Jo=class extends J{constructor(e,r){super(e);this.measure=e;this.tab=r;d(this,"measureNumber");d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new es(this)}getMusicInterface(){return this.mi}get doc(){return this.measure.doc}updateMeasureNumber(e){if(e){let r="tab.signature.measurenum",n=this.measure.getMeasureNumber().toString();this.measureNumber=new ot(this,{text:n,color:r},0,1)}else this.measureNumber=void 0}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),n="tab.signature.time",o=r.beatCount.toString();this.beatCountText=new ot(this,{text:o,color:n,scale:1.4},.5,.5);let s=r.beatSize.toString();this.beatSizeText=new ot(this,{text:s,color:n,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r="tab.signature.tempo",n=ta(this.measure.getTempo());this.tempoText=new ot(this,{text:n,color:r},0,1)}else this.tempoText=void 0}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.beatCountText){let n=this.beatCountText.pick(e,r);if(n.length>0)return[this,...n]}if(this.beatSizeText){let n=this.beatSizeText.pick(e,r);if(n.length>0)return[this,...n]}if(this.tempoText){let n=this.tempoText.pick(e,r);if(n.length>0)return[this,...n]}if(this.measureNumber){let n=this.measureNumber.pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){var u,l,h,p,m,f;let{unitSize:r}=e,{tab:n}=this,o=r,s=0,a=n.getTopLineY();this.rect=new G,this.measureNumber&&(this.measureNumber.layout(e),this.measureNumber.setLeft(0),this.measureNumber.setBottom(a),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),(u=this.beatCountText)==null||u.layout(e),(l=this.beatSizeText)==null||l.layout(e);let c=Math.max((p=(h=this.beatCountText)==null?void 0:h.getRect().width)!=null?p:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.setCenter(0+c/2+o,n.getRect().anchorY-this.beatCountText.getRect().bottomh),this.rect.expandInPlace(this.beatCountText.getRect())),this.beatSizeText&&(this.beatSizeText.setCenter(0+c/2+o,n.getRect().anchorY+this.beatSizeText.getRect().toph),this.rect.expandInPlace(this.beatSizeText.getRect())),this.tempoText&&(this.tempoText.layout(e),this.tempoText.setLeft(s+r*2),this.tempoText.setBottom(a),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){var n,o,s,a;(n=this.measureNumber)==null||n.offset(e,r),(o=this.beatCountText)==null||o.offset(e,r),(s=this.beatSizeText)==null||s.offset(e,r),(a=this.tempoText)==null||a.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,n,o,s;(r=this.measureNumber)==null||r.draw(e),(n=this.beatCountText)==null||n.draw(e),(o=this.beatSizeText)==null||o.draw(e),(s=this.tempoText)==null||s.draw(e)}};var ec=class extends J{constructor(e,r,n){super(e);this.col=e;this.line=r;this.arpeggioDir=n;d(this,"topArrowHeight",0);d(this,"bottomArrowHeight",0);d(this,"cycleHeight",0);d(this,"numCycles",0);d(this,"color","black");d(this,"mi");this.mi=new rs(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let n=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-n)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new G(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r,topArrowHeight:n,bottomArrowHeight:o}=this;e.drawDebugRect(this.rect),e.color(this.color),e.lineWidth(2),e.beginPath();for(let s=0,a=r.top+n;s<this.numCycles;s++,a+=this.cycleHeight)e.moveTo(r.anchorX,a),e.quadraticCurveTo(r.left,a+this.cycleHeight/4,r.anchorX,a+this.cycleHeight/2),e.quadraticCurveTo(r.right,a+this.cycleHeight*3/4,r.anchorX,a+this.cycleHeight);e.stroke(),n>0&&(e.beginPath(),e.moveTo(r.anchorX,r.top),e.lineTo(r.right,r.top+n),e.lineTo(r.left,r.top+n),e.fill()),o>0&&(e.beginPath(),e.moveTo(r.anchorX,r.bottom),e.lineTo(r.left,r.bottom-o),e.lineTo(r.right,r.bottom-o),e.fill())}};function zv(i){return typeof i=="number"?U.getChromaticNote(i).diatonicId:typeof i=="string"?U.getNote(i).diatonicId:i instanceof U?i.diatonicId:void 0}var rc=class extends J{constructor(e,r){super(e);this.staff=e;this.rest=r;d(this,"restRect",new G);d(this,"dotRects",[]);d(this,"mi");e.addObject(this),this.mi=new ns(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){this.restRect.offsetInPlace(e,r),this.dotRects.forEach(n=>n.offsetInPlace(e,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.clone(),this.dotRects.forEach(e=>this.rect.expandInPlace(e))}},Zn=class Zn extends J{constructor(e,r,n,o,s){var c,u,l,h;super(e);this.col=e;this.voiceId=r;this.options=o;d(this,"color");d(this,"hide");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"setDiatonicId");d(this,"runningDiatonicId");d(this,"runningStemDir");d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"mi");this.setDiatonicId=(u=zv((c=this.options)==null?void 0:c.staffPos))!=null?u:Zn.UndefinedDiatonicId;let a=this.row.getStaves().filter(p=>p.containsVoiceId(this.voiceId));this.setDiatonicId!==Zn.UndefinedDiatonicId&&a.length>0&&a[0].isSpace(this.setDiatonicId)&&(this.setDiatonicId+=this.setDiatonicId>=a[0].middleLineDiatonicId?1:-1),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.color=(l=o==null?void 0:o.color)!=null?l:"staff.rest",this.hide=(h=o==null?void 0:o.hide)!=null?h:!1,this.oldStyleTriplet=s===void 0&&Tt.get(n).isTriplet,this.rhythmProps=Qt.get(n,void 0,(s!=null?s:this.oldStyleTriplet)?Gr.Triplet:void 0),this.mi=new is(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get noteLength(){return this.rhythmProps.noteLength}getDiatonicId(e){return this.runningDiatonicId===Zn.UndefinedDiatonicId?e?Tt.equals(this.noteLength,"1n")?e.middleLineDiatonicId+2:e.middleLineDiatonicId:U.getNote("G4").diatonicId:this.runningDiatonicId}get stemDir(){return this.runningStemDir}updateRunningArguments(e,r,n){this.runningDiatonicId=e,this.runningStemDir=r}getStaticObjects(e){let r=[];return this.staffObjects.forEach(n=>{n.staff===e&&r.push(n)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{let r=e.staff,n=e.getRect().anchorX,o=this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().anchorY-o);return{staff:r,x:n,y:o,stemHeight:s}})}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof rc&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case 1:return 1;case 2:return-1;case 4:return-1;case 8:return-1;case 16:return-1;case 32:return-3;case 64:return-3;default:throw new N(6,`Get rest dot vertical displacement: Invalid note size: ${e}`)}}updateAccidentalState(e){}layout(e,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:n}=e,{noteSize:o,dotCount:s}=this.rhythmProps;this.row.getStaves().forEach(a=>{let c=this.getDiatonicId(a);if(!a.containsDiatonicId(c)||!a.containsVoiceId(this.voiceId))return;let u=new rc(a,this);u.restRect=e.getRestRect(o);for(let l=0;l<s;l++){let h=at.DotSize*n,p=u.restRect.rightw+(at.RestDotSpace+at.DotSize*n)+l*at.DotSize*n*1.5,m=this.getRestDotVerticalDisplacement(o)*n;u.dotRects.push(G.createCentered(p,m,h,h))}u.setAnchor(0,a.getDiatonicIdY(c)),this.staffObjects.push(u),this.measure.addStaticObject(a,u)})}updateRect(){if(this.staffObjects.length===0)this.rect=new G;else if(this.rect=this.staffObjects[0].getRect().clone(),this.staffObjects.length>1)for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){if(this.staffObjects.length===0)return;e.drawDebugRect(this.getRect());let{noteSize:r}=this.rhythmProps;e.color(this.color).lineWidth(1),this.staffObjects.forEach(n=>{let{dotRects:o,restRect:s}=n;e.drawRest(r,s.anchorX,s.anchorY),o.forEach(a=>e.fillCircle(a.anchorX,a.anchorY,a.width/2))})}};d(Zn,"UndefinedDiatonicId",1/0);var ae=Zn;function Yv(i){return y.isEnumValue(i,gi)?i:i===!0?"up":void 0}function Hv(i,t){let e=H.Arr.isArray(t)?t:t!==void 0?[t]:[],r=i.map((n,o)=>({note:n,string:e[o]}));return r=H.Arr.removeDuplicates(r,(n,o)=>U.equals(n.note,o.note)).sort((n,o)=>U.compareFunc(n.note,o.note)),{sortedNotes:r.map(n=>n.note),sortedStrings:r.every(n=>n.string===void 0)?void 0:r.map(n=>n.string)}}var ic=class extends J{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;d(this,"noteHeadRects",[]);d(this,"dotRects",[]);d(this,"accidentals",[]);d(this,"stemTip");d(this,"stemBase");d(this,"flagRects",[]);d(this,"prevTopNoteY",0);d(this,"prevBottomNoteY",0);d(this,"mi");this.mi=new ss(this)}getMusicInterface(){return this.mi}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.accidentals.length;n++){let o=this.accidentals[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].clone(),this.noteHeadRects.forEach(e=>this.rect.expandInPlace(e)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(e=>this.rect.expandInPlace(e)),this.flagRects.forEach(e=>this.rect.expandInPlace(e)),this.accidentals.forEach(e=>this.rect.expandInPlace(e.getRect()))}getRect(){let e=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.anchorY||this.prevBottomNoteY!==e.anchorY)&&(this.prevTopNoteY=r.anchorY,this.prevBottomNoteY=e.anchorY,this.requestRectUpdate()),super.getRect()}offset(e,r){var n,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(e,r)),this.dotRects.forEach(s=>s.offsetInPlace(e,r)),this.accidentals.forEach(s=>s.offset(e,r)),(n=this.stemTip)==null||n.offsetInPlace(e,r),(o=this.stemBase)==null||o.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},Ih=class extends J{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;d(this,"fretNumbers",[]);d(this,"mi");this.mi=new as(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().clone(),this.fretNumbers.forEach(e=>this.rect.expandInPlace(e.getRect()))}offset(e,r){this.fretNumbers.forEach(n=>n.offset(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},xt=class i extends J{constructor(e,r,n,o,s,a){var l,h,p;super(e);this.col=e;this.voiceId=r;this.notes=n;this.options=s;d(this,"setDiatonicId");d(this,"setStringsNumbers");d(this,"runningDiatonicId");d(this,"runningStemDir");d(this,"runningStringNumbers");d(this,"color");d(this,"staccato");d(this,"diamond");d(this,"arpeggio");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"startConnnectives",[]);d(this,"runningConnectives",[]);d(this,"leftBeamCount",0);d(this,"rightBeamCount",0);d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"tabObjects",[]);d(this,"isNoteDisplaced");d(this,"mi");if(!y.isIntegerGte(n.length,1))throw new N(6,"Cannot create note group object because notes array is empty.");let{sortedNotes:c,sortedStrings:u}=Hv(n,s==null?void 0:s.string);this.notes=c,this.setStringsNumbers=u,this.isNoteDisplaced=this.notes.map(()=>!1),this.setDiatonicId=Math.round((this.minDiatonicId+this.maxDiatonicId)/2),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.runningStringNumbers=[],this.color=(l=s==null?void 0:s.color)!=null?l:"staff.note",this.staccato=(h=s==null?void 0:s.staccato)!=null?h:!1,this.diamond=(p=s==null?void 0:s.diamond)!=null?p:!1,this.arpeggio=Yv(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&Tt.get(o).isTriplet,this.rhythmProps=Qt.get(o,void 0,(a!=null?a:this.oldStyleTriplet)?Gr.Triplet:void 0),this.mi=new os(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get minDiatonicId(){return this.notes[0].diatonicId}get maxDiatonicId(){return this.notes[this.notes.length-1].diatonicId}getDiatonicId(e){return this.runningDiatonicId}get stemDir(){return this.runningStemDir}setNoteDisplacement(e,r){let n=this.notes.indexOf(e);n>=0&&(this.isNoteDisplaced[n]=r)}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof jt||e.containsDiatonicId(this.runningDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective==="tie")throw new N(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective==="slur")throw new N(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(e),this.doc.addConnectiveProps(e)}updateRunningArguments(e,r,n){this.runningDiatonicId=e===ae.UndefinedDiatonicId?this.setDiatonicId:e,this.runningStemDir=r,this.runningStringNumbers=n}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.tabObjects.length;n++){let o=this.tabObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,n,o,s){var a;if(r instanceof Mt){if(n<0||n>=this.notes.length)throw new N(6,"Invalid noteIndex: "+n);let c=this.staffObjects.find(S=>S.staff===r);if(!c||n<0||n>=c.noteHeadRects.length){let S=this.getRect();return{x:S.anchorX,y:S.bottom}}let u=c.noteHeadRects[n],l=c.stemTip,h=this.stemDir,p=l!==void 0,m=p?h==="up"?"right":"left":void 0,f=u.height/2,g=u.anchorX,b=u.anchorY,x=u.left-f,_=u.right+f,w=u.top-f,T=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!p&&(o=h==="up"?"above":"below"),o){case"center":return s==="left"?{x:_,y:b}:{x,y:b};case"above":return!p||h==="down"?{x:g,y:w}:{x:s==="left"&&m==="right"?_:s==="right"&&m==="left"?x:g,y:w};case"below":return!p||h==="up"?{x:g,y:T}:{x:s==="left"&&m==="right"?_:s==="right"&&m==="left"?x:g,y:T};case"stemTip":return{x:g,y:l.anchorY+(h==="up"?-f:f)};default:throw new N(6,"Invalid noteAnchor: "+o)}}else if(r instanceof jt){let c=(a=this.tabObjects.find(m=>m.tab===r))==null?void 0:a.fretNumbers[n];if(!c)return{x:0,y:0};let u=c.getRect(),l=s==="right"?u.left:u.right,h,p=.9;if(e.connective==="slide"){let m=e.noteGroups[0].getFretNumber(r,0),f=e.noteGroups[1].getFretNumber(r,0),g=m===void 0||f===void 0||m<=f;s==="left"?h=(g?u.anchorY+u.bottomh:u.anchorY-u.toph)*p:h=(g?u.anchorY-u.toph:u.anchorY+u.bottomh)*p}else h=u.anchorY+u.bottomh*p;return{x:l,y:h}}else return{x:0,y:0}}getFretNumberString(e){return this.runningStringNumbers[e]}getFretNumber(e,r){let n=this.tabObjects.find(s=>s.tab===e),o=n==null?void 0:n.fretNumbers[r];return o?parseInt(o.getText()):void 0}getNextNoteGroup(){let e=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof i),r=e.indexOf(this);if(r<0)return;if(r<e.length-1)return e[r+1];let n=this.measure.getNextMeasure();for(;n;){let o=n.getVoiceSymbols(this.voiceId).filter(s=>s instanceof i);if(o.length>0)return o[0];n=n.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(e=>{this.runningConnectives.push(e);let r=this.getNextNoteGroup();for(;r&&e.addNoteGroup(r);)r.runningConnectives.push(e),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let e=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return e.indexOf("first")>=0?"first":e.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{var a,c,u,l;let r=e.staff,n=(c=(a=e.stemTip)==null?void 0:a.anchorX)!=null?c:e.noteHeadRects[0].anchorX,o=(l=(u=e.stemTip)==null?void 0:u.anchorY)!=null?l:this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=this.stemDir==="up"?Math.abs(e.noteHeadRects[0].anchorY-o):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].anchorY-o);return{staff:r,x:n,y:o,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{flagCount:n,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?at.BeamSeparation:at.FlagSeparation;return(at.StemHeight+Math.max(0,n-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}setLeftBeamCount(e){this.leftBeamCount=e}setRightBeamCount(e){this.rightBeamCount=e}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ic&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(n=>n.connective==="tie").map(n=>{let o=n.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(n.span==="stub"||n.span==="toMeasureEnd")return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=o[s-1];return a&&a.notes.some(c=>U.equals(c,e))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!U.equals(u,e))),s>=0&&(o=o.slice(0,s)),H.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(e){this.notes.forEach(r=>{e.needAccidental(r)&&e.setAccidental(r)})}layout(e,r){this.requestRectUpdate();let{unitSize:n}=e,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,l=at.DotSize*n,h=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadWidth)*n,p=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadHeight)*n;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.runningDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new ic(m,this),g=m,b=m;this.notes.forEach((A,C)=>{var F;let E=C===0,q=C===this.notes.length-1,M=(F=m.getActualStaff(A.diatonicId))!=null?F:m,R=this.isNoteDisplaced[C]?h*(s==="down"?-1:1):0,B=M.getDiatonicIdY(A.diatonicId),D=M.isLine(A.diatonicId);E&&s==="up"&&(g=M),q&&s==="up"&&(b=M),E&&s==="down"&&(b=M),q&&s==="down"&&(g=M);let j=f.noteHeadRects[C]=G.createCentered(R,B,h,p);if(M.addObject(j),r.needAccidental(A)){let W=f.accidentals[C]=new $i(this,A.diatonicId,A.accidental,this.color);W&&(W.layout(e),W.setAnchor(-j.leftw-n*at.NoteAccSpace-W.getRect().rightw,B)),M.addObject(W)}for(let W=0;W<a;W++){let Q=j.right+at.NoteDotSpace*n+l/2+W*l*1.5,k=B+this.getDotVerticalDisplacement(m,A.diatonicId,s)*n,it=G.createCentered(Q,k,l,l);f.dotRects.push(it),M.addObject(it)}if(this.staccato){if(s==="up"&&E){let W=R,Q=B+n*(D?3:2),k=G.createCentered(W,Q,l,l);f.dotRects.push(k),g.addObject(k)}else if(s==="down"&&q){let W=R,Q=B-n*(D?3:2),k=G.createCentered(W,Q,l,l);f.dotRects.push(k),g.addObject(k)}}});let x=f.noteHeadRects[0].anchorY,_=f.noteHeadRects[f.noteHeadRects.length-1].anchorY,w=s==="up"?h/2:-h/2,T=this.getStemHeight(e),S=s==="up"?_-T:x+T,v=s==="up"?x:_;if(u&&(f.stemTip=new G(w,w,S,S),f.stemBase=new G(w,w,v,v),b.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let A=c===0?0:at.FlagWidth*n,C=c===0?0:at.FlagHeight*n;for(let E=0;E<c;E++){let q=E*n*at.FlagSeparation,M=f.flagRects[E]=s==="up"?new G(w,w+A,S+q,S+C+q):new G(w,w+A,S-C-q,S-q);b.addObject(M)}}this.staffObjects.push(f),this.measure.addStaticObject(m,f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new Ih(m,this),g="background",b="tab.note";this.notes.forEach((x,_)=>{let w=this.runningStringNumbers[_];if(y.isIntegerBetween(w,1,6)){let T=x.chromaticId-m.getTuningStrings()[w-1].chromaticId,S=new ot(this,{text:String(T),color:b,bgcolor:g},.5,.5);S.layout(e),S.setAnchor(this.col.getRect().anchorX,m.getStringY(w-1)),f.fretNumbers.push(S)}}),f.fretNumbers.length>0&&(this.tabObjects.push(f),m.addObject(f),this.measure.addStaticObject(m,f))})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].clone();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().clone();else{this.rect=new G;return}this.staffObjects.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tabObjects.forEach(e=>this.rect.expandInPlace(e.getRect()))}setStemTipY(e,r){let n=this.staffObjects.find(o=>o.staff===e);this.hasBeamCount()&&(n!=null&&n.stemTip)&&r!==n.stemTip.anchorY&&(n.stemTip.top=n.stemTip.anchorY=n.stemTip.bottom=r,this.requestRectUpdate(),this.col.requestRectUpdate())}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.tabObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let{stemDir:r}=this,{isSolidNoteHead:n}=this.rhythmProps;this.staffObjects.forEach(o=>{o.accidentals.forEach(s=>s.draw(e)),e.color(this.color),e.lineWidth(1),o.noteHeadRects.forEach(s=>{this.diamond?n?(e.beginPath(),e.moveTo(s.anchorX,s.top),e.lineTo(s.right,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.lineTo(s.left,s.anchorY),e.lineTo(s.anchorX,s.top),e.fill()):(e.beginPath(),e.lineWidth(2.5),e.moveTo(s.anchorX,s.top),e.lineTo(s.right,s.anchorY),e.moveTo(s.left,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.stroke(),e.beginPath(),e.lineWidth(1),e.moveTo(s.right,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.moveTo(s.anchorX,s.top),e.lineTo(s.left,s.anchorY),e.stroke()):(e.beginPath(),e.ellipse(s.anchorX,s.anchorY,s.leftw,s.toph,-.3,0,Math.PI*2),n?e.fill():e.stroke())}),o.dotRects.forEach(s=>e.fillCircle(s.anchorX,s.anchorY,s.width/2)),o.stemTip&&o.stemBase&&(e.beginPath(),e.moveTo(o.stemBase.anchorX,o.stemBase.anchorY),e.lineTo(o.stemTip.anchorX,o.stemTip.anchorY),e.stroke()),o.flagRects.forEach(s=>e.drawFlag(s,r==="up"?"up":"down"))}),this.tabObjects.forEach(o=>o.fretNumbers.forEach(s=>s.draw(e)))}getDotVerticalDisplacement(e,r,n){return e.isLine(r)?n==="up"?-1:1:0}static hasSameNotes(e,r){if(e.notes.length!==r.notes.length)return!1;for(let n=0;n<e.notes.length;n++){let o=e.notes[n],s=r.notes[n];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var kr=class extends J{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;d(this,"voiceSymbol",new vr);d(this,"lyricsObject",new Us);d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"staffMinDiatonicId",new lt);d(this,"staffMaxDiatonicId",new lt);d(this,"arpeggioDir");d(this,"arpeggios",[]);d(this,"playerProps");d(this,"needLayout",!0);d(this,"shapeRects",[]);d(this,"mi");this.playerProps=new Xn(this),this.mi=new cs(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let e=this.measure.getColumns().indexOf(this);if(e>=0&&e<this.measure.getColumnCount())return this.measure.getColumn(e+1);throw new N(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let e=this.getNextColumnInMeasure();return e||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let e=this.getNextColumnInMeasure(),r=this.positionTicks,n=e?e.positionTicks:this.measure.getConsumedTicks();return Math.max(0,n-r)}getShapeRects(){return this.forceRectUpdate(),this.shapeRects}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){let n=this.getRect().contains(e,r);for(let o=0;o<this.voiceSymbol.length;o++){let s=this.voiceSymbol.get(o);if(s instanceof ae){let a=s.pick(e,r);if(a.length>0)return n?[this,...a]:a}}if(!n)return[];for(let o=0;o<this.voiceSymbol.length;o++){let s=this.voiceSymbol.get(o);if(s instanceof xt){let a=s.pick(e,r);if(a.length>0)return[this,...a]}}for(let o=0;o<this.arpeggios.length;o++){let s=this.arpeggios[o].pick(e,r);if(s.length>0)return[this,...s]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:"up"}setVoiceSymbol(e,r){Vo(e),this.voiceSymbol.set(e,r),r instanceof ae&&!r.hide?this.row.getStaves().forEach(n=>{let o=r.getDiatonicId(n);this.minDiatonicId=this.minDiatonicId===void 0?o:Math.min(this.minDiatonicId,o),this.maxDiatonicId=this.maxDiatonicId===void 0?o:Math.max(this.maxDiatonicId,o)}):r instanceof xt&&(this.minDiatonicId=this.minDiatonicId===void 0?r.notes[0].diatonicId:Math.min(this.minDiatonicId,r.notes[0].diatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.notes[r.notes.length-1].diatonicId:Math.max(this.maxDiatonicId,r.notes[r.notes.length-1].diatonicId),r.arpeggio!==void 0&&(this.arpeggioDir=r.arpeggio),this.updateNoteDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(e){return this.voiceSymbol.get(e)}getLyricsObject(e,r,n){return this.lyricsObject.get(e,r,n)}addLyricsObject(e){this.lyricsObject.set(e.verse,e.line,e.vpos,e)}updateNoteDisplacements(){let e=[];this.voiceSymbol.forEach(n=>{n instanceof xt&&n.notes.forEach(o=>{n.setNoteDisplacement(o,!1),e.push({noteGroup:n,note:o})})});let r=(n,o)=>{let s=U.compareFunc(n.note,o.note);return s===0?n.noteGroup.stemDir===o.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1:s};if(e.sort(r),!(e.length<2)){for(let n=0;n<e.length;n++){let o=e[n],s=e[n+1];s&&o.note.diatonicId===s.note.diatonicId&&(o.isDisplaced=s.isDisplaced=!1)}for(let n=0;n<e.length;n++){let o=e[n-1],s=e[n],a=e[n+1];s.isDisplaced===void 0&&(o&&s.note.diatonicId-o.note.diatonicId<=1?s.isDisplaced=!o.isDisplaced:a&&a.note.diatonicId-s.note.diatonicId<=1&&(s.isDisplaced=!a.isDisplaced))}e.forEach(n=>{var o;return n.noteGroup.setNoteDisplacement(n.note,(o=n.isDisplaced)!=null?o:!1)})}}isEmpty(){return this.voiceSymbol.size===0||this.voiceSymbol.every(e=>e.isEmpty())}getPlayerNotes(){let e=[];function r(n,o,s,a){if(o<=0)return;e.some(u=>n.diatonicId===u.note.diatonicId&&n.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||e.push({note:n,ticks:o,staccato:s,slur:a})}return se().forEach(n=>{let o=this.getVoiceSymbol(n);if(o instanceof xt){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),e.sort((n,o)=>U.compareFunc(n.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;let{row:n}=this;this.rect=new G,this.requestRectUpdate();let o=0,s=0;if(this.voiceSymbol.forEach(l=>{l.layout(e,r);let h=l.getRect();o=Math.max(o,h.leftw),s=Math.max(s,h.rightw)}),this.arpeggioDir!==void 0){this.arpeggios=n.getNotationLines().map(h=>new ec(this,h,this.getArpeggioDir())),this.arpeggios.forEach(h=>h.layout(e));let l=this.arpeggios.map(h=>h.getRect().width).reduce((h,p)=>Math.max(h,p))+e.unitSize;this.arpeggios.forEach(h=>{h.setAnchor(-o-l/2,h.line.getRect().anchorY),h.line.addObject(h),this.measure.addStaticObject(h.line,h)}),o+=l}else this.arpeggios=[];let a=this.voiceSymbol.mapToArray(l=>l.rhythmProps.noteSize),c=Math.min(8,Math.max(1,...a)),u=Math.ceil(8/c)*at.NoteHeadWidth*e.unitSize*.75;o=Math.max(o,u/2),s=Math.max(s,u/2),o*=at.ColumnWidthScale,s*=at.ColumnWidthScale,this.rect.left=-o,this.rect.anchorX=0,this.rect.right=s,this.requestRectUpdate(),this.voiceSymbol.forEach(l=>l.updateAccidentalState(r)),this.row.getStaves().forEach(l=>{let h,p;this.voiceSymbol.forEach(m=>{if(m.visibleInStaff(l)){if(m instanceof xt)h=h===void 0?m.minDiatonicId:Math.min(h,m.minDiatonicId),p=p===void 0?m.maxDiatonicId:Math.max(p,m.maxDiatonicId);else if(m instanceof ae){let f=m.getDiatonicId(l);h=h===void 0?f:Math.min(h,f),p=p===void 0?f:Math.max(p,f)}}}),h!==void 0?this.staffMinDiatonicId.set(l,h):this.staffMinDiatonicId.delete(l),p!==void 0?this.staffMaxDiatonicId.set(l,p):this.staffMaxDiatonicId.delete(l)})}layoutReserveSpace(e){let r=this.measure.getColumns(),n=e.unitSize;this.getAnchoredLayoutObjects().forEach(o=>{if(o.layoutGroup.reserveSpace){let s=r.indexOf(this);if(s<0)return;let a=o.getRect().leftw-this.getRect().leftw;if(a>0){let u=r[s-1];u&&u.getAnchoredLayoutObjects().forEach(l=>{if(l.layoutGroupId===o.layoutGroupId){let h=l.getRect().rightw-u.getRect().rightw;this.rect.left-=Math.max(h+a,0)+n,this.requestRectUpdate()}})}let c=o.getRect().rightw-this.getRect().rightw;if(c>0){let u=r[s+1];u&&u.getAnchoredLayoutObjects().forEach(l=>{if(l.layoutGroupId===o.layoutGroupId){let h=l.getRect().leftw-u.getRect().leftw;this.rect.right+=Math.max(c+h,0)+n,this.requestRectUpdate()}})}}})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(e=>e!==void 0).mapToArray(e=>e.getRect().clone()),...this.arpeggios.map(e=>e.getRect().clone())],this.rect.top=Math.min(...this.shapeRects.map(e=>e.top)),this.rect.bottom=Math.max(...this.shapeRects.map(e=>e.bottom)),this.rect.anchorY=(this.rect.top+this.rect.bottom)/2}offset(e,r){this.voiceSymbol.forEach(n=>n.offset(e,0)),this.arpeggios.forEach(n=>n.offset(e,0)),this.shapeRects.forEach(n=>n.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.color("staff.frame"),this.row.getStaves().forEach(r=>{let n=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);n!==void 0&&e.drawLedgerLines(r,n,this.getRect().anchorX),o!==void 0&&e.drawLedgerLines(r,o,this.getRect().anchorX)}),this.voiceSymbol.forEach(r=>r.draw(e)),this.arpeggios.forEach(r=>r.draw(e))}};var Lr=class Lr extends J{constructor(e,r,n="black"){super(e);this.text=r;this.color=n;d(this,"components",[]);d(this,"mi");switch(this.text){case Lr.Coda:this.components=[new ot(this,{text:"\u{1D10C}",scale:1.7,color:n},.5,.3),new ot(this,{text:" Coda",color:n},0,1)];break;case Lr.toCoda:this.components=[new ot(this,{text:"toCoda ",color:n},1,1),new ot(this,{text:"\u{1D10C}",scale:1.7,color:n},.5,.3)];break;case Lr.Segno:this.components=[new ot(this,{text:"\u{1D10B}",scale:1.1,color:n},.5,1)];break;default:this.components=[];break}this.mi=new us(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){switch(this.text){case Lr.Coda:{let r=this.components[0],n=this.components[1];r.layout(e),n.layout(e),r.setAnchorY(n.getRect().centerY),n.setLeft(r.getRect().right),this.rect=new G(r.getRect().left,r.getRect().anchorX,n.getRect().right,n.getRect().top,n.getRect().anchorY,n.getRect().bottom);break}case Lr.toCoda:{let r=this.components[0],n=this.components[1];r.layout(e),n.layout(e),n.setAnchorY(r.getRect().centerY),r.setRight(n.getRect().left),this.rect=new G(r.getRect().left,n.getRect().anchorX,n.getRect().right,r.getRect().top,r.getRect().anchorY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(e),this.rect=r.getRect().clone();break}}}offset(e,r){this.components.forEach(n=>n.offset(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(e))}};d(Lr,"toCoda","\u{1D10C} toCoda"),d(Lr,"Coda","Coda \u{1D10C}"),d(Lr,"Segno","\u{1D10B}");var ve=Lr;function Nh(i){return i instanceof ot||i instanceof ve?i.getText():i instanceof bi?"[measure]":""}var Th=class{constructor(t){this.startColumn=t;d(this,"columnRange");d(this,"stopObject");this.columnRange=[t]}get endColumn(){return this.columnRange[this.columnRange.length-1]}addColumn(t){this.endColumn!==t&&this.columnRange.push(t)}setStopObject(t){this.stopObject=t}},nc=class nc extends Qa{constructor(e,r,n,o,s,a){super(e.musicObj);this.headObj=e;d(this,"length");d(this,"visible");d(this,"lineStyle");d(this,"linePos");d(this,"startColumn");this.length=n+1,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r}isVisible(){return this.visible}getLineStyle(){return this.lineStyle}getLinePos(){return this.linePos}whatStopped(e){let r=e.measure,n=r.getColumns(),o=e.getAnchoredLayoutObjects().filter(s=>s!==this.headObj&&s.layoutGroupId===this.headObj.layoutGroupId).map(s=>s.musicObj).filter(s=>s instanceof ot||s instanceof ve)[0];return o||(e===n[n.length-1]&&r.hasEndSection()||r.hasEndSong()||nc.StopNavigations.some(s=>r.hasNavigation(s))?r.getBarLineRight():void 0)}getRange(){let{startColumn:e,length:r}=this,n=e,o=new Th(n),s=r;for(;;){if(s<=0)return o;let a=this.whatStopped(n);if(a!==void 0)return o.setStopObject(a),o;if(s-=n.getTicksToNextColumn(),n=n.getNextColumn(),!n)return o;s>0&&o.addColumn(n)}}};d(nc,"StopNavigations",["endRepeat","ending"]);var Zi=nc;function hs(i){switch(i){case"D.C. al Coda":return"D.C. al Coda";case"D.C. al Fine":return"D.C. al Fine";case"D.S. al Coda":return"D.S. al Coda";case"D.S. al Fine":return"D.S. al Fine";case"Fine":return"Fine";case"Segno":return ve.Segno;case"Coda":return ve.Coda;case"toCoda":return ve.toCoda;default:return i[0].toUpperCase()+i.substring(1)}}function ls(i){if(/^(p+|f+|m|mp|mf)$/.test(i)){let t=.5-H.Str.charCount(i,"p")*.1+H.Str.charCount(i,"f")*.1;return H.Math.clamp(t,0,1)}else return}function sg(i){return y.isEnumValue(i,Yo)?"dynamics":y.isEnumValue(i,Ho)?"tempo":void 0}function ag(i,t){return typeof window=="undefined"?void 0:window.setTimeout(i,t)}function cg(i){typeof window!="undefined"&&window.clearTimeout(i)}var $v=2,Zv=2,Xv=.5,Qv=.5;function Kv(i,t){let e=Qt.get(t.options.beatLength,t.options.dotCount).ticks,r=t.beatsPerMinute*e;return 60*i/r}function Oh(){return ls("m")}function Jv(i){return i*1.25}var t0=.5,Xn=class{constructor(t){this.col=t;d(this,"speed");d(this,"volume");this.speed=1,this.volume=Oh()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=Oh()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=H.Math.clamp(this.getSpeed(),.1,10);return Cu(this.measure.getTempo(),t)}setVolume(t){this.volume=t}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:t}=this;if(t instanceof Ar)return this.measure.getMeasureTicks()/2;{let r=se().map(n=>t.getVoiceSymbol(n)).filter(n=>!!n).map(n=>n.rhythmProps.ticks);return r.length===0?0:H.Math.sum(r)/r.length}}},oc=class i{constructor(){d(this,"playTimer");d(this,"playPos");d(this,"playState",2);d(this,"doc");d(this,"cursorPositionChangeListener");d(this,"playStateChnageListener");d(this,"playerColumnSequence",[])}setDocument(t){this.doc=t,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(t){this.cursorPositionChangeListener=t}setPlayStateChnageListener(t){this.playStateChnageListener=t}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let t=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==t&&(this.playStateChnageListener&&this.playStateChnageListener(t),this.playState=t)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let t=[],e=this.doc.getFirstMeasure(),r=e,n,o=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=i.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation("startRepeat")&&(r=e),e.hasNavigation("Segno")&&(n=e),s&&e.hasNavigation("toCoda"))for(;e&&!e.hasNavigation("Coda");)e=e.getNextMeasure();else if(o&&e.hasNavigation("Fine"))e=void 0;else if(e.hasNavigation("D.C. al Coda"))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.C. al Fine"))o=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.S. al Coda"))s=!0,e=n;else if(e.hasNavigation("D.S. al Fine"))o=!0,e=n;else if(e.hasNavigation("endRepeat")){let u=e.getPassCount(),l=e.getEndRepeatPlayCount()-1,h=((a=e.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=l||h?e=r:e=e.getNextMeasure()}else e.hasEndSong()?e=void 0:e=e.getNextMeasure()}return t}collectPlayerColumnSequence(){let t=this.collectPlayerMeasureSequence(),e=[];for(let r=0;r<t.length;r++){let n=t[r];e=e.concat(n.getColumns()),n.hasFermata(n.getBarLineRight())&&e.push(n.getBarLineRight())}return e}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let t=1,e=Oh(),r=new lt,n=new lt,o=(a,c)=>r.getOrCreate(a,[]).push(c),s=(a,c)=>n.getOrCreate(a,[]).push(c);this.playerColumnSequence.forEach(a=>{if(!(a instanceof kr))return;a.getAnchoredLayoutObjects().forEach(l=>{let h=Nh(l.musicObj),p;if(h==="a tempo")t=1;else if((p=ls(h))!==void 0)e=p;else if(l.musicObj.getLink()instanceof Zi){let f=l.musicObj.getLink().getRange(),g=f.stopObject?Nh(f.stopObject):"",b=H.Math.sum(f.columnRange.map(x=>x.getTicksToNextColumn()));switch(h){case"accel.":{let x=t,_=x*$v,w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),o(T,x+(_-x)*w/b)});break}case"rit.":{let x=t,_=x/Zv,w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),o(T,x+(_-x)*w/b)});break}case"cresc.":{let x=e,_=x+Xv;f.stopObject&&(p=ls(g))!==void 0&&p>x&&(_=p);let w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),s(T,x+(_-x)*w/b)});break}case"decresc.":case"dim.":{let x=e,_=x-Qv;f.stopObject&&(p=ls(g))!==void 0&&p<x&&(_=p);let w=0;f.columnRange.forEach(T=>{w+=T.getTicksToNextColumn(),s(T,x+(_-x)*w/b)});break}}}});let c=r.getOrDefault(a,[]);c.length>0&&(t=H.Math.sum(c)/c.length);let u=n.getOrDefault(a,[]);u.length>0&&(e=H.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(t),a.getPlayerProps().setVolume(e)})}static getMeasureByEndingPassage(t,e){for(let r=t;;r=r.getNextMeasure()){let n=r==null?void 0:r.getEnding();if(n&&n.hasPassage(e))return r;let o=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!o||o.hasNavigation("startRepeat"))return}}playStep(){if(this.notifyCursorPositionChanged(),this.notifyPlayStateChanged(),this.playPos===void 0){this.stop();return}let t=this.playerColumnSequence[this.playPos];if(!t){this.stop();return}let e=(s,a)=>{let c=Kv(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),n=t.getPlayerProps().getFermataHoldTicks(),o;t instanceof Ar?o=e(n,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?Qt.get("32n").ticks*c:0,l=e(a.ticks+n-u,r);if(l>0){a.staccato&&(l=Math.min(e(Qt.get("8n").ticks,r)/2,l/2));let h=Jv(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=t0),u>0){let p=e(u,r);ag(()=>Ya(a.note,l,h),p*1e3)}else Ya(a.note,l,h)}}),o=e(t.getTicksToNextColumn()+n,r)),this.playTimer=ag(()=>this.playStep(),o*1e3),this.playPos=this.getNextPlayPosition(this.playPos),this.notifyPlayStateChanged()}play(){if(this.playState===0)this.stop();else if(this.playState===1){this.playStep();return}let{doc:t}=this;if(!t)return;t.getFirstMeasure()?(this.playPos=0,this.playStep()):this.playPos=void 0,this.notifyPlayStateChanged()}pause(){this.playTimer&&(cg(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}stop(){this.playPos=void 0,this.playTimer&&(cg(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}getNextPlayPosition(t){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let t=this.playerColumnSequence[this.playPos];if(!t)return;let e=t.measure,r=t.getRect().anchorX,{top:n,height:o}=e.row.getRect();return new du(r,n,0,o)}};var Rh=class extends J{constructor(e,r,n){super(r);this.barLine=e;this.line=r;this.rowGroup=n;d(this,"vlines",[]);d(this,"dots",[]);d(this,"mi");r.addObject(this),this.mi=new ms(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=new G(0,0,this.line.getTopLineY(),this.line.getBottomLineY()),this.vlines.forEach(e=>this.rect.expandInPlace(new G(e.left,e.left+e.width,this.rect.top,this.rect.bottom))),this.dots.forEach(e=>this.rect.expandInPlace(new G(e.x-e.r,e.x+e.r,e.y-e.r,e.y+e.r)))}offset(e,r){this.vlines.forEach(n=>n.left+=e),this.dots.forEach(n=>{n.x+=e,n.y+=r}),this.rect.offsetInPlace(e,r)}},sc=class extends J{constructor(e){super(e);this.measure=e;d(this,"notationLineObjects",[]);d(this,"notationLineObjectsByGrp",new lt);d(this,"barLineType",0)}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.notationLineObjects.length;n++){let o=this.notationLineObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}layout(e){this.requestRectUpdate(),this.barLineType=this.solveBarLineType();let{unitSize:r,_lineWidth:n}=e,{measure:o,barLineType:s}=this,{row:a}=o,c=n,u=.7*r,l=.7*r,p=at.DotSize*r/2;this.notationLineObjects=[],this.notationLineObjectsByGrp.clear(),a.getRowGroups().forEach(m=>{m.lines.forEach(f=>{let g=new Rh(this,f,m);this.notationLineObjects.push(g),this.notationLineObjectsByGrp.getOrCreate(m,[]).push(g);let b,x,_=(T,S)=>{g.vlines.push({left:T,width:S})},w=T=>{for(let S=-1;S<=1;S+=2){let v=b+S*x;g.dots.push({x:T,y:v,r:p})}};switch(f instanceof Mt?(b=f.getMiddleLineY(),x=f.getDiatonicSpacing()):(b=(f.getBottomLineY()+f.getTopLineY())/2,x=(f.getBottomLineY()-f.getTopLineY())/6),s){case 0:break;case 1:_(-c,c);break;case 2:_(-c-l-c,c),_(-c,c);break;case 3:_(-c-l-u,c),_(-u,u);break;case 4:_(0,u),_(u+l,c),w(u+l+c+l+p);break;case 5:_(-c-l-u,c),_(-u,u),w(-c-l-u-l-p);break;case 6:_(-u/2,u),_(-u/2-l-c,c),_(u/2+l,c),w(-u/2-l-c-l-p),w(u/2+l+c+l+p);break}g.forceRectUpdate()})})}updateRect(){if(this.notationLineObjects.length>0){this.rect=this.notationLineObjects[0].getRect().clone();for(let e=1;e<this.notationLineObjects.length;e++)this.rect.expandInPlace(this.notationLineObjects[e].getRect())}else this.rect=new G}offset(e,r){this.notationLineObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){this.barLineType!==0&&(e.drawDebugRect(this.getRect()),this.notationLineObjects.forEach(r=>{r.vlines.forEach(n=>r.line.drawVerticalLine(e,n.left,n.width)),r.dots.forEach(n=>e.fillCircle(n.x,n.y,n.r))}))}},xi=class extends sc{constructor(e){super(e);d(this,"mi");this.mi=new ps(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation("startRepeat")?r&&r.row===e.row&&r.hasNavigation("endRepeat")?0:4:0}},Ar=class extends sc{constructor(e){super(e);d(this,"playerProps");d(this,"mi");this.playerProps=new Xn(this),this.mi=new ds(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation("endRepeat")?r&&r.row===e.row&&r.hasNavigation("startRepeat")?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var Xi=class extends J{constructor(e,r,n){super(e);this.measure=e;this.color=r;this.passages=n;d(this,"endingText");d(this,"shapeRects",[]);d(this,"mi");if(this.mi=new fs(this),y.isIntegerGte(n.length,1)){if(!this.passages.every(s=>y.isIntegerGte(s,1)))throw new N(6,"Invalid passages: "+this.passages)}else throw new N(6,"Passages is empty.");this.passages.sort((s,a)=>s-a);let o=this.passages.map(s=>s+".").join("");this.endingText=new ot(this,{text:o,color:r},0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:e}=this,r=e.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||e.hasNavigation("endRepeat")||e.isLastMeasure()}hasPassage(e){return this.passages.some(r=>r===e)}getHighestPassage(){return Math.max(0,...this.passages)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new G,this.shapeRects=[this.rect.clone()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:n}=this;this.endingText.layout(e);let o=this.endingText.getRect(),s=n.getColumnsContentRect(),a=o.height;this.rect=new G(s.left+r,s.right-r,-a,0),this.endingText.setLeft(this.rect.left+r/2),this.endingText.setBottom(this.rect.bottom),this.shapeRects=[new G(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new G(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new G(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().clone()]}offset(e,r){this.endingText.offset(e,r),this.shapeRects.forEach(n=>n.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this;e.drawDebugRect(this.rect),e.color(this.color).lineWidth(1),e.beginPath(),e.moveTo(r.left,r.bottom),e.lineTo(r.left,r.top),e.lineTo(r.right,r.top),this.isSingleMeasureEnding()&&e.lineTo(r.right,r.bottom),e.stroke(),this.endingText.draw(e)}};var e0=(i,t)=>{let e=at.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=i/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),i/r*e}},gs=class{constructor(t,e,r,n,o){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=n;this.y=o;d(this,"topBeamsHeight",0);d(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new G(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},Mh=class extends J{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;d(this,"tupletNumber");d(this,"tupletNumberOffsetY",0);d(this,"points",[]);d(this,"mi");e.addObject(this),this.mi=new bs(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var n;this.points.forEach(o=>o.offset(e,0)),(n=this.tupletNumber)==null||n.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().clone():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().clone()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Ai=class{constructor(t,e){this.beamGroup=t;this.message=e}},Qi=class i extends J{constructor(e,r){super(e[0].measure);this.symbols=e;this.tupletRatio=r;d(this,"mi");d(this,"type");d(this,"staffObjects",[]);this.mi=new ys(this);let n=r?"Tuplet":"BeamGroup";if(e.every(o=>o.measure===e[0].measure)){if(e.length<2)throw new N(6,`${n} needs minimum 2 symbols, but ${e.length} given.`)}else throw new N(6,`All ${n} symbols are not in same measure.`);if(r!==void 0){let o=e.length<3||e.some(s=>!(s instanceof xt))||e.some(s=>s.rhythmProps.flagCount!==e[0].rhythmProps.flagCount);e.length>=3&&e[0]instanceof xt&&e[e.length-1]instanceof xt&&e[0].rhythmProps.flagCount===e[e.length-1].rhythmProps.flagCount&&(o=!1),e.some(s=>Tt.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,this.setTupletBeamCounts()}else this.type=0,this.setBeamCounts();if(e.every(o=>o.getBeamGroup()===void 0))e.forEach(o=>o.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new N(6,`Cannot add ${n} because some symbol already has one.`);if(this.type===0&&this.symbols.filter(o=>o instanceof xt).some((o,s)=>{let a=s===0,c=s===this.symbols.length-1;if(a&&o.getRightBeamCount()===0||c&&o.getLeftBeamCount()===0||!a&&!c&&(o.getLeftBeamCount()===0||o.getRightBeamCount()===0))throw new Ai(this,"Beam has zero left or right beam count!")}),e.some(o=>o.voiceId!==e[0].voiceId))throw this.type===0?new Ai(this,"Beam symbols have different voiceId."):new N(6,"Tuplet symbols have different voiceId.");e[0].row.getStaves().forEach(o=>{o.getActualStaff(e[0].getDiatonicId(o))&&o.containsVoiceId(e[0].voiceId)&&e.forEach(s=>{let a=o.getActualStaff(s.getDiatonicId(o));if(!a||!a.containsVoiceId(s.voiceId))throw new Ai(this,"Some of beam or tuplet symbols are not visible!")})})}get stemDir(){return this.symbols[0].stemDir}get showTupletRatio(){var e;return((e=this.tupletRatio)==null?void 0:e.showRatio)===!0}static createBeam(e){if(e.length>1&&e.every(r=>!r.hasTuplet()))try{return new i(e,void 0),!0}catch(r){if(r instanceof Ai)r.beamGroup.detach();else throw r}return!1}static createOldStyleTriplet(e){try{let r=e.slice(0,2),n=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(n[0]*2===n[1]||n[1]*2===n[0]))return new i(r,Gr.Triplet),2;let o=e.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);if(o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0]))return new i(o,Gr.Triplet),3}catch(r){if(r instanceof Ai)console.error(r.message),r.beamGroup.detach();else throw r}return 0}static createTuplet(e,r){try{new i(e,r)}catch(n){if(n instanceof Ai)console.error(n.message),n.beamGroup.detach();else throw n}}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(e=>e.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getTupletRatioText(){var e,r,n;return this.showTupletRatio?String((e=this.tupletRatio)==null?void 0:e.parts)+":"+String((r=this.tupletRatio)==null?void 0:r.inTimeOf):String((n=this.tupletRatio)==null?void 0:n.parts)}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get color(){return this.symbols[0].color}layout(e){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let{unitSize:n}=e,{stemDir:o,type:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var B,D;if(!c)return;let l=a.map(j=>{var F;return(F=j[u])==null?void 0:F.x}),h=a.map(j=>{var F;return(F=j[u])==null?void 0:F.y}),p=a.map(j=>{var F;return(F=j[u])==null?void 0:F.staff}),m=a.map(j=>{var F;return(F=j[u])==null?void 0:F.stemHeight}),f=r[0],g=l[0],b=h[0],x=p[0],_=r[r.length-1],w=l[l.length-1],T=h[h.length-1],S=p[h.length-1];if(g===void 0||b===void 0||x===void 0||w===void 0||T===void 0||S===void 0)return;let v=(B=m[0])!=null?B:0,A=(D=m[m.length-1])!=null?D:0;if(s!==2){let j=v<A?Math.sqrt(A-v):0,F=A<v?Math.sqrt(v-A):0;o==="up"&&(j*=-1,F*=-1),j!==0&&(b+=j,h[0]+=j),F!==0&&(T+=F,h[h.length-1]+=F)}let C=n*2*(o==="up"?-1:1),E=(T+b)/2,q=e0(w-g,T-b)/2;b=E-q,T=E+q;let M=0;h.forEach((j,F)=>{let W=l[F];if(W!==void 0&&j!==void 0){let Q=H.Math.interpolateY(g,b,w,T,W),k=j-Q;o==="up"&&k<0?M=Math.min(M,k):o==="down"&&k>0&&(M=Math.max(M,k))}}),b+=M,T+=M,h=h.map(j=>j===void 0?void 0:j+M);let R=new Mh(c,this);if(s===2){let j=n/(w-g),F=H.Math.interpolateCoord(g,b+C,w,T+C,-j),W=H.Math.interpolateCoord(g,b+C,w,T+C,1+j);R.points.push(new gs(x,this,f,F.x,F.y)),R.points.push(new gs(S,this,_,W.x,W.y)),R.tupletNumberOffsetY=0}else if(s===0||s===1){M*=.5;let j=e._lineWidth*at.BeamThickness,F=W=>{let Q=r[W];if(Q instanceof xt){let k=Q instanceof xt?Math.max(Q.getLeftBeamCount(),Q.getRightBeamCount()):0;return at.BeamSeparation*n*(o==="up"?k-1:0)}else return 0};r.forEach((W,Q)=>{let k=p[Q],it=l[Q],pt=h[Q];if(k&&it!==void 0&&pt!==void 0){let At=new gs(k,this,W,it,pt);switch(o){case"up":At.topBeamsHeight=j/2,At.bottomBeamsHeight=j/2+F(Q);break;case"down":At.topBeamsHeight=j/2+F(Q),At.bottomBeamsHeight=j/2;break}R.points.push(At)}}),R.tupletNumberOffsetY=C}this.isTuplet()&&(R.tupletNumber=new ot(this,this.getTupletRatioText(),.5,.5),R.tupletNumber.layout(e),R.tupletNumber.offset((g+w)/2,(b+T)/2+R.tupletNumberOffsetY)),R.points.length>=2&&this.staffObjects.push(R)})}updateRect(){if(this.staffObjects.length===0)this.rect=new G;else{this.staffObjects.forEach(e=>e.updateRect()),this.rect=this.staffObjects[0].getRect().clone();for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}}updateStemTips(){this.staffObjects.forEach(e=>{let r=e.points[0],n=e.points[e.points.length-1];this.type!==2&&e.points.forEach(o=>{o.symbol instanceof xt&&(o!==r&&o!==n&&(o.y=H.Math.interpolateY(r.x,r.y,n.x,n.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),e.tupletNumber&&e.tupletNumber.setAnchorY((r.y+n.y)/2+e.tupletNumberOffsetY)})}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r}=e,{stemDir:n,color:o,type:s}=this;if(s===2){e.color(o).lineWidth(1);let a=(n==="up"?1:-1)*r;this.staffObjects.forEach(c=>{let{x:u,y:l}=c.points[0],{x:h,y:p}=c.points[c.points.length-1];if(c.tupletNumber){let m=c.tupletNumber.getRect().width/(h-u)*1.2,f=H.Math.interpolateCoord(u,l,h,p,.5-m/2),g=H.Math.interpolateCoord(u,l,h,p,.5+m/2);e.strokeLine(u,l,f.x,f.y),e.strokeLine(g.x,g.y,h,p)}else e.strokeLine(u,l,h,p);e.strokeLine(u,l,u,l+a),e.strokeLine(h,p,h,p+a)})}else(s===0||s===1)&&(e.color(o).lineWidth(at.BeamThickness),this.staffObjects.forEach(a=>{let c=a.points.filter(f=>f.symbol instanceof xt),{x:u,y:l}=c[0],{x:h,y:p}=c[c.length-1],m=at.BeamSeparation*r*(n==="up"?1:-1)*(1+.5*Math.abs(Math.atan2(p-l,h-u)));for(let f=0;f<c.length-1;f++){let{x:g,y:b,symbol:x}=c[f],{x:_,y:w,symbol:T}=c[f+1],S=x.getRightBeamCount(),v=T.getLeftBeamCount();for(let A=0;A<Math.max(S,v);A++)A<S&&A<v?e.strokeLine(g,b,_,w):S>v?e.strokePartialLine(g,b,_,w,0,.25):v>S&&e.strokePartialLine(g,b,_,w,.75,1),b+=m,w+=m}}));this.staffObjects.forEach(a=>{var c;return(c=a.tupletNumber)==null?void 0:c.draw(e)})}setBeamCounts(){let e=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:l,noteSize:h,dotCount:p}=s.rhythmProps;return a>0&&l>0&&u>0&&p===0&&c*Math.pow(2,u)===h},r=this.symbols.filter(o=>o instanceof xt);for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&(a.rhythmProps.flagCount===s.rhythmProps.flagCount||e(a,s)||e(s,a)?s.setLeftBeamCount(s.rhythmProps.flagCount):s.setLeftBeamCount(Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount))),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||e(c,s)||e(s,c)?s.setRightBeamCount(s.rhythmProps.flagCount):s.setRightBeamCount(Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount))))}let n;do{n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&s.getLeftBeamCount()!==s.rhythmProps.flagCount&&s.getRightBeamCount()!==s.rhythmProps.flagCount&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&a.getRightBeamCount()>0&&(a.setRightBeamCount(0),n=!0),c&&c.getLeftBeamCount()>0&&(c.setLeftBeamCount(0),n=!0))}}while(n)}setTupletBeamCounts(){let e=this.getType(),r=this.getSymbols();e===1?r.forEach((n,o)=>{n instanceof xt&&(n.setLeftBeamCount(o===0?0:n.rhythmProps.flagCount),n.setRightBeamCount(o===r.length-1?0:n.rhythmProps.flagCount))}):e===2&&r.forEach(n=>{n instanceof xt&&(n.setLeftBeamCount(0),n.setRightBeamCount(0))})}};var Ci=class extends J{constructor(e,r,n){super(e);this.pos=r;this.color=n;d(this,"mi");this.mi=new xs(this)}getMusicInterface(){return this.mi}static getFermataPositions(e){let{measure:r}=e,{row:n}=r;return n.getTopStaff()!==n.getBottomStaff()?[0,1]:[0]}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,n=r*4,o=r*3;this.rect=new G(-n/2,n/2,-o,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{unitSize:r}=e,n=this.pos===1,o=(n?r:-r)*.7,s=this.rect.left,a=this.rect.right,c=(n?this.rect.bottom:this.rect.top)+o,u=(n?this.rect.top:this.rect.bottom)+o,l=u-c;e.drawDebugRect(this.rect),e.color(this.color).lineWidth(1),e.beginPath(),e.moveTo(s,u),e.bezierCurveTo(s,c,a,c,a,u),e.bezierCurveTo(a,c+l/5,s,c+l/5,s,u),e.stroke(),e.fill();let h=l/6;e.fillCircle((s+a)/2,u-h,Math.abs(h))}};function r0(i){return i instanceof ot||i instanceof ve}function hg(i){return i instanceof Ar||i instanceof ot||i instanceof ve}var Qn=class extends J{constructor(e,r,n,o){super(e);this.measure=e;this.line=r;this.extension=n;this.cols=o;d(this,"mi");n.addTail(this),this.mi=new As(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(e){let r=this.cols[0];if(r0(r))return r.getRect().right+e.unitSize;if(r instanceof xi)return r.getRect().anchorX;if(r instanceof kr){let n=r.measure.getColumns();if(r===n[0])return r.measure.getRect().left}return r.getRect().right}getLineRight(e){let r=this.cols[this.cols.length-1];if(hg(r))return r.getRect().left-e.unitSize;if(r instanceof kr){let n=r.measure.getColumns();if(r===n[n.length-1])return r.measure.getRect().right;let o=r.getNextColumn();if(o&&o.measure===r.measure)return(r.getRect().right+o.getRect().left)/2}return r.getRect().anchorX}layoutFitToMeasure(e){let r=e.unitSize,n=this.getLineLeft(e),o=this.getLineRight(e);[n,o]=[Math.min(n,o),Math.max(n,o)],this.rect=new G(n,o,-r/2,r/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new G}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this,n=this.extension.headObj.musicObj,o=String(n.userData["extension-color"]);this.extension.getLineStyle()==="dashed"&&e.setLineDash([7,3]),e.color(o).lineWidth(1),e.strokeLine(r.left,r.anchorY,r.right,r.anchorY),e.setLineDash([]);let s=this.extension.getTails(),a=s[s.length-1];if(this===a&&!hg(this.cols[this.cols.length-1])){let c=r.anchorY>this.line.getRect().anchorY?-e.unitSize:e.unitSize;e.strokeLine(r.right,r.anchorY,r.right,r.anchorY+c)}}};var Ki=class extends J{constructor(e,r,n,o,s,...a){var c;super(n);this.connectiveProps=e;this.measure=n;d(this,"lx",0);d(this,"ly",0);d(this,"rx",0);d(this,"ry",0);d(this,"cp1x",0);d(this,"cp1y",0);d(this,"cp2x",0);d(this,"cp2y",0);d(this,"arcHeight",0);d(this,"line");d(this,"leftNoteGroup");d(this,"leftNoteId");d(this,"rightNoteGroup");d(this,"rightNoteId");d(this,"tieType");d(this,"mi");this.line=(c=this.measure.row.findMatchingLine(r))!=null?c:r,this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof xt&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):y.isEnumValue(a[0],yr)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new Cs(this)}getMusicInterface(){return this.mi}get doc(){return this.measure.doc}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,{measure:n,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:p}=l,{row:m}=n,f=m.getPrevRow(),g=m.getNextRow(),b=m.getConnectivesContentRect(),x,_;x=s.getConnectiveAnchorPoint(l,o,a,h,"left"),c!==void 0&&u!==void 0?_=c.getConnectiveAnchorPoint(l,o,u,h,"right"):_=this.tieType==="toMeasureEnd"?{x:n.getColumnsContentRect().right,y:x.y}:{x:x.x+r*at.StubTieLength,y:x.y};let w,T,S,v;if(c===void 0)w=x.x,T=x.y,S=_.x,v=_.y;else if(s.row===m&&c.row===m)w=x.x,T=x.y,S=_.x,v=_.y;else if(s.row===f&&c.row===m){let R=f.getConnectivesContentRect().right-x.x,B=_.x-b.left;w=b.left,T=x.y+(_.y-x.y)*R/(R+B),S=_.x,v=_.y}else if(s.row===m&&c.row===g){let M=g.getConnectivesContentRect(),R=b.right-x.x,B=_.x-M.left;w=x.x,T=x.y,S=b.right,v=x.y+(_.y-x.y)*R/(R+B)}else throw new N(6,"Cannot layout connective object because no valid left and right note groups.");let C=(p==="up"?-1:1)*r*Math.log2(S-w)/3;this.lx=w,this.ly=T,this.rx=S,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:C;let{nx:E,ny:q}=H.Math.calcNormal(w,T,S,v);this.cp1x=w*.7+S*.3+E*this.arcHeight,this.cp1y=T*.7+v*.3+q*this.arcHeight,this.cp2x=w*.3+S*.7+E*this.arcHeight,this.cp2y=T*.3+v*.7+q*this.arcHeight,this.rect=new G(Math.min(this.lx,this.cp1x,this.cp2x,this.rx),Math.max(this.lx,this.cp1x,this.cp2x,this.rx),Math.min(this.ly,this.cp1y,this.cp2y,this.ry),Math.max(this.ly,this.cp1y,this.cp2y,this.ry)),this.line.addObject(this)}offset(e,r){this.lx+=e,this.ly+=r,this.rx+=e,this.ry+=r,this.cp1x+=e,this.cp1y+=r,this.cp2x+=e,this.cp2y+=r,this.rect.offsetInPlace(e,r)}draw(e){if(this.rightNoteGroup!==void 0){if(this.leftNoteGroup.measure!==this.rightNoteGroup.measure){if(this.leftNoteGroup.row.getNextRow()!==this.rightNoteGroup.row){if(this.measure!==this.rightNoteGroup.measure)return}}}let{rect:r}=this,{_lineWidth:n}=e;e.drawDebugRect(r);let o=n*1.5,s=n*.25;e.color(this.line instanceof jt?"tab.connective":"staff.connective"),e.lineWidth(1),this.arcHeight===0?(e.beginPath(),e.moveTo(this.lx,this.ly),e.lineTo(this.rx,this.ry),e.stroke()):(e.beginPath(),e.moveTo(this.lx,this.ly-s),e.bezierCurveTo(this.cp1x,this.cp1y-o,this.cp2x,this.cp2y-o,this.rx,this.ry-s),e.lineTo(this.rx,this.ry+s),e.bezierCurveTo(this.cp2x,this.cp2y+o,this.cp1x,this.cp1y+o,this.lx,this.ly+s),e.fill())}};var Kn=class{constructor(t,e,r,n){this.connective=t;this.span=e;this.noteAnchor=r;d(this,"noteGroups");d(this,"arcDir","down");this.noteGroups=[n]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(t){let{stemDir:e}=this.noteGroups[0],{hasStem:r}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=e==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=e==="up"||!r?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor="center":this.connective==="slide"?this.noteAnchor="center":this.arcDir==="up"?this.noteAnchor="above":this.noteAnchor="below";else if(this.noteAnchor==="center"){let n=t instanceof Mt?t:void 0,o=this.noteGroups[0].getDiatonicId(n);this.arcDir=!n||o<n.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(t=>{t.measure.removeConnectiveObjects(),t.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){if(this.noteGroups.length===0)return;this.getStartNoteGroup().collectConnectiveProps();let{connective:t,span:e}=this;this.noteGroups[0].row.getNotationLines().forEach(r=>{if(this.computeParams(r),t==="tie"){if(y.isEnumValue(e,yr)){let n=this.noteGroups[0];for(let o=0;o<n.notes.length;o++)this.createObjConnectiveWithTieType(r,n,o,e)}else if(this.noteGroups.length>=2)for(let n=0;n<this.noteGroups.length-1;n++){let o=this.noteGroups[n],s=this.noteGroups[n+1];o.notes.forEach((a,c)=>{let u=s.notes.findIndex(l=>U.equals(l,a));u>=0&&this.createObjConnective(r,o,c,s,u)})}}else if(t==="slur"){if(typeof e=="number"&&e>=2&&this.noteGroups.length===e){let n=this.noteGroups[0],o=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,n,0,o,0)}}else if(t==="slide"&&this.noteGroups.length>=2)for(let n=0;n<this.noteGroups.length-1;n++){let o=this.noteGroups[n],s=this.noteGroups[n+1];this.createObjConnective(r,o,0,s,0)}})}createObjConnectiveWithTieType(t,e,r,n){if(e.enableConnective(t))t instanceof Mt?new Ki(this,t,e.measure,e,r,n):t instanceof jt&&e.getFretNumberString(r)!==void 0&&new Ki(this,t,e.measure,e,r,n);else return}createObjConnective(t,e,r,n,o){let s=(a,c,u,l,h)=>{if(c.enableConnective(t)&&l.enableConnective(t)){if(t instanceof Mt)new Ki(this,t,a,c,u,l,h);else if(t instanceof jt){let p=c.getFretNumberString(u),m=l.getFretNumberString(h);p!==void 0&&m!==void 0&&(p===m||this.connective==="slur")&&new Ki(this,t,a,c,u,l,h)}}else return};if(e.measure===n.measure)s(e.measure,e,r,n,o);else if(e.measure.getNextMeasure()===n.measure)s(e.measure,e,r,n,o),s(n.measure,e,r,n,o);else throw new N(6,"Cannot create connective because it is jumping measures.")}};var ac=class extends J{constructor(e,r,n,o,s,a,c){super(e);this.col=e;this.verse=r;this.line=n;this.vpos=o;d(this,"nextLyricsObject");d(this,"rhythmProps");d(this,"color","black");d(this,"hyphen");d(this,"text");d(this,"mi");this.rhythmProps=Qt.get(s);let u=(c==null?void 0:c.align)==="left"?0:(c==null?void 0:c.align)==="right"?1:.5;this.hyphen=y.isEnumValue(c==null?void 0:c.hyphen,Hn)?c==null?void 0:c.hyphen:void 0,this.text=new ot(this,{text:a,color:this.color,scale:.8},u,0),this.rect=this.text.getRect().clone(),this.mi=new _s(this)}getMusicInterface(){return this.mi}get measure(){return this.col.measure}getText(){return this.text.getText()}setNextLyricsObject(e){this.nextLyricsObject=e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layout(e){this.text.layout(e),this.rect=this.text.getRect().clone()}offset(e,r){this.text.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r;if(this.text.draw(e),this.hyphen!==void 0){e.color(this.color).lineWidth(1);let n=this.getRect(),o=(r=this.nextLyricsObject)==null?void 0:r.getRect(),s=e.unitSize*1.5,a=o?(o.left-n.right)*.85:s,c=this.hyphen==="-"?Math.min(s,a):a;if(c>0){let u=o?(n.right+o.left)/2:n.right+c/.85,l=n.centerY;e.moveTo(u-c/2,l),e.lineTo(u+c/2,l),e.stroke()}}}};var Jn=class extends J{constructor(e,r){super(e);this.measure=e;this.tab=r;d(this,"voiceId");d(this,"mi");d(this,"tupletPartsTextObjMap",new lt);this.voiceId=se().filter(n=>r.containsVoiceId(n)),this.rect=new G,this.mi=new vs(this)}getMusicInterface(){return this.mi}get doc(){return this.measure.doc}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let r=this.measure.getColumns(),n=se().map(o=>H.Math.sum(r.map(s=>s.getVoiceSymbol(o)?1:0)));this.voiceId.sort((o,s)=>H.Math.cmp(n[o],n[s])),this.rect=new G}hasTuplets(){return this.measure.getBeamGroups().some(e=>e.isTuplet())}layoutFitToMeasure(e){let{unitSize:r,fontSize:n}=e,{measure:o}=this,s=o.getColumnsContentRect(),a=r*5;this.rect.left=s.left,this.rect.anchorX=s.centerX,this.rect.right=s.right,this.rect.top=this.hasTuplets()?-n:0,this.rect.anchorY=0,this.rect.bottom=a}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),e.lineWidth(1);let{unitSize:r,fontSize:n}=e,o=r,s=r,a=r*.25,{bottom:c,anchorY:u}=this.getRect(),l=u,h=c,p=this.measure.getColumns();for(let m=0;m<p.length;m++){let f=p[m],g=this.voiceId.map(_=>f.getVoiceSymbol(_)).find(_=>_!==void 0);if(!g)continue;let b=g.getBeamGroup(),x=b?b.getSymbols():[g];for(let _=0;_<x.length;_++){let w=x[_],T=x[_+1],S=w.col.getRect().anchorX;if(w instanceof xt){if(e.lineWidth(1),e.color("tab.note"),w.rhythmProps.noteSize>=2&&(e.lineWidth(w.rhythmProps.noteSize===4?2:1),e.strokeLine(S,h,S,l)),x.length===1)for(let v=0;v<w.rhythmProps.flagCount;v++)e.drawFlag(new G(S,S+o,l+v*o,l+(v+2)*o),"up");for(let v=0;v<w.rhythmProps.dotCount;v++)e.fillCircle(S+s*(v+1),h-a,a)}else if(w instanceof ae){e.lineWidth(1),e.color("tab.rest");let v=S,A=(l+h)/2,C=.65;e.save(),e.scale(C,C),e.drawRest(w.rhythmProps.noteSize,v/C,A/C),e.restore();for(let E=0;E<w.rhythmProps.dotCount;E++)v+=s*1.5,e.fillCircle(v,A+s,a)}if(T){let v=w,A=T,C=v.col.getRect().anchorX,E=A.col.getRect().anchorX,q=v.hasTuplet()?1:v instanceof xt?v.getRightBeamCount():1,M=A.hasTuplet()?1:A instanceof xt?A.getLeftBeamCount():1,R=Math.max(q,M);e.color("tab.note"),e.lineWidth(2);for(let B=0;B<R;B++){let D=M>q&&B>=q?.75:0,j=q>M&&B>=M?.25:1;e.strokePartialLine(C,l+B*o,E,l+B*o,D,j)}e.lineWidth(1);for(let B=0;B<v.rhythmProps.dotCount;B++)e.fillCircle(C+s*(B+1),h-a,a);for(let B=0;B<A.rhythmProps.dotCount;B++)e.fillCircle(E+s*(B+1),h-a,a)}if(b&&b.isTuplet()){e.color("tab.note");let v=(x[0].col.getRect().anchorX+x[x.length-1].col.getRect().anchorX)/2,A=b.getTupletRatioText(),C=this.tupletPartsTextObjMap.get(A);C||(this.tupletPartsTextObjMap.set(A,C=new ot(this,{text:A,scale:.75},.5,.5)),C.layout(e)),C.setCenter(v,l-n/2),C.draw(e)}x.length>1&&(m=p.indexOf(x[x.length-1].col),m<0&&(m=p.length))}}}};function i0(i){switch(i){case"bottom":return .8;case"middle":return .5}}function n0(i){if(typeof i=="string"&&(i=[i]),y.isArray(i)){let t=0;for(let e=0;e<i.length;){let r=i[e],n=i[e+1];if(typeof r=="string"){e++;let o=Qt.get(r).ticks;typeof n=="number"&&(e++,o*=n),t+=o}else e++}return t}else return i}function o0(i){switch(i){case 1:return 8;case 2:return 9;case 3:return 10;default:throw new N(0,"VerseNumber is not 1, 2 or 3.")}}var Eh=class{constructor(){d(this,"tabTuning_0",0);d(this,"signature_1",0);d(this,"leftBarLine_2",0);d(this,"padding_3",0);d(this,"columnsMin_4",0);d(this,"padding_5",0);d(this,"rightBarLine_6",0)}get leftSolid(){return this.tabTuning_0+this.signature_1+this.leftBarLine_2+this.padding_3}get columnsMin(){return this.columnsMin_4}get rightSolid(){return this.padding_5+this.rightBarLine_6}},bi=class extends J{constructor(e,r){super(e);this.row=e;this.options=r;d(this,"prevMeasure");d(this,"nextMeasure");d(this,"keySignature",$s());d(this,"timeSignature",Ks());d(this,"tempo",Js());d(this,"alterKeySignature");d(this,"alterTimeSignature");d(this,"alterTempo");d(this,"signatures",[]);d(this,"tabStringNotes",[]);d(this,"barLineLeft");d(this,"columns",[]);d(this,"barLineRight");d(this,"connectives",[]);d(this,"beamGroups",[]);d(this,"measureId");d(this,"regions",new Eh);d(this,"needLayout",!0);d(this,"voiceSymbols",Ys(new vr));d(this,"lastAddedRhythmColumn");d(this,"lastAddedRhythmSymbol");d(this,"addExtensionTo",[]);d(this,"layoutObjects",[]);d(this,"postMeasureBreakWidth",0);d(this,"passCount",0);d(this,"needBeamsUpdate",!0);d(this,"navigationSet",new zs);d(this,"isEndSong",!1);d(this,"isEndSection",!1);d(this,"endRepeatPlayCount",2);d(this,"endRepeatPlayCountText");d(this,"staticObjectsCache",new lt);d(this,"lyricsObjectsCache",new Us);d(this,"mi");this.mi=new ws(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new xi(this),this.barLineRight=new Ar(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo(),this.row.getTabs().forEach(n=>{this.addLayoutObject(new Jn(this,n),n,0,0)})}getMusicInterface(){return this.mi}get doc(){return this.row.doc}isPartialMeasure(){return this.getConsumedTicks()<this.getMeasureTicks()}isUpBeat(){return this===this.doc.getFirstMeasure()}resetPassCount(){this.passCount=0}incPassCount(){this.passCount++}getPassCount(){return this.passCount}updateRunningArguments(e){var n;e!=null||(e=[]);let r=H.Math.sum(se().map(o=>this.getVoiceSymbols(o).length>0?1:0));se().forEach(o=>{var l;let s=()=>{let h=this.row.getStaves().filter(m=>m.containsVoiceId(o)),p=this.row.getTabs().filter(m=>m.containsVoiceId(o));return h.length>0?h[0].middleLineDiatonicId:p.length>0?p[0].getTuningStrings()[3].diatonicId:U.getNote("G4").diatonicId},a=()=>"auto",c=()=>[],u=(l=e[o])!=null?l:e[o]={diatonicId:s(),stemDir:a(),stringNumbers:c()};this.getVoiceSymbols(o).forEach((h,p,m)=>{var b,x;if(h.setDiatonicId===ae.UndefinedDiatonicId?r<2&&(u.diatonicId=ae.UndefinedDiatonicId):u.diatonicId=h.setDiatonicId,h instanceof xt)switch(h.setStringsNumbers&&(u.stringNumbers=h.setStringsNumbers),(b=h.options)==null?void 0:b.stem){case"up":case"up":u.stemDir="up";break;case"down":case"down":u.stemDir="down";break;case"auto":case"auto":u.stemDir="auto";break}let f=(x=h.getBeamGroup())==null?void 0:x.getSymbols(),g;f===void 0?g=u.stemDir==="auto"?this.row.solveAutoStemDir([h]):u.stemDir:h===f[0]?g=u.stemDir==="auto"?this.row.solveAutoStemDir(f):u.stemDir:g=f[0].stemDir,h.updateRunningArguments(u.diatonicId,g,u.stringNumbers)})}),(n=this.getNextMeasure())==null||n.updateRunningArguments(e)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.signatures.length;n++){let o=this.signatures[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.tabStringNotes.length;n++){let o=this.tabStringNotes[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.columns.length;n++){let o=this.columns[n].pick(e,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let n=this.barLineLeft.pick(e,r);if(n.length>0)return[this,...n]}if(this.barLineRight){let n=this.barLineRight.pick(e,r);if(n.length>0)return[this,...n]}if(this.endRepeatPlayCountText){let n=this.endRepeatPlayCountText.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.connectives.length;n++){let o=this.connectives[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.beamGroups.length;n++){let o=this.beamGroups[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.layoutObjects.length;n++){let o=this.layoutObjects[n].musicObj.pick(e,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let e=this.doc.getFirstMeasure();return e&&e.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(e){return this.getColumns()[e]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}isFirstMeasureInRow(){return this===this.row.getFirstMeasure()}isLastMeasureInRow(){return this===this.row.getLastMeasure()}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...e){var r;if((r=this.getPrevMeasure())==null||r.endSection(),e[0]instanceof rr)this.alterKeySignature=e[0];else if(e[0]instanceof ii)this.alterKeySignature=e[0];else if(y.isNonEmptyString(e[0])){if(e.length===1)this.alterKeySignature=Pr(e[0]);else if(e.length===2)try{let n=""+e[0],o=po(""+e[1]);this.alterKeySignature=Pr(n,o)}catch(n){throw new N(6,"Cannot set key signature because invalid args: "+e)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:$s(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(e){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=e,this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:Ks(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r){var n;if((n=this.getPrevMeasure())==null||n.endSection(),r===void 0)this.alterTempo={beatsPerMinute:e};else{let o=Tt.get(r).dotCount,s={beatLength:Br(r),dotCount:o>0?o:void 0};this.alterTempo={beatsPerMinute:e,options:s}}this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:Js(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,n,o;this.alterTempo.options?(n=this.alterTempo.options.beatLength,o=(e=this.alterTempo.options.dotCount)!=null?e:0):this.alterTimeSignature?(n=this.alterTimeSignature.beatLength,o=0):(n=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:n,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,n,o){let s=new uc(e,r,n,o);return this.layoutObjects.push(s),this.requestLayout(),this.requestRectUpdate(),s}forEachStaffGroup(e,r,n){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&n(o[a],c);else if(typeof a=="string"&&a.length>0){let l=o.filter(h=>h.name===a);if(l.forEach(h=>n(h,c)),l.length===0){let h=this.doc.getStaffGroup(a);if(h&&!u.includes(a)){let p=[...u,a];(y.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(m=>{switch(h.verticalPosition){case"above":s(m,0,p);break;case"below":s(m,1,p);break;case"both":s(m,0,p),s(m,1,p);break;case"auto":s(m,r,p);break}})}}}};e===void 0?o.length>=2&&o[0]instanceof Mt&&o[1]instanceof Mt&&o[0].staffConfig.grandId!==void 0&&o[0].staffConfig.grandId===o[1].staffConfig.grandId?s(r===1?1:0,r):s(0,r):y.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let n=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!n)throw new N(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(o,s)=>{let a=o instanceof jt?"staff.element.fermata":"tab.element.fermata";this.addLayoutObject(new Ci(n,s,a),o,1,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof Ci&&r.anchor===e)}addNavigation(e,r,...n){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new N(6,"Cannot add ending beasure measure already has one.");let s=this,a=n;o={createObj:c=>{let u=c instanceof jt?"staff.element.navigation":"tab.element.navigation";return new Xi(s,u,a)},layoutGroupId:4,defaultVerticalPos:0};break;case"D.C. al Coda":case"D.C. al Fine":case"D.S. al Coda":case"D.S. al Fine":{let c=this.barLineRight,u=hs(r);o={createObj:l=>{let h=l instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ot(c,{text:u,color:h},1,1)},layoutGroupId:3,defaultVerticalPos:0},this.addNavigation(e,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=hs(r);o={createObj:l=>{let h=l instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ot(c,{text:u,color:h},1,1)},layoutGroupId:3,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=hs(r);o={createObj:l=>{let h=l instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ve(c,u,h)},layoutGroupId:3,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=hs(r);o={createObj:l=>{let h=l instanceof jt?"staff.element.navigation":"tab.element.navigation";return new ve(c,u,h)},layoutGroupId:3,defaultVerticalPos:0};break}case"endRepeat":if(n.length===0)this.endRepeatPlayCount=2;else if(y.isIntegerGte(n[0],2))this.endRepeatPlayCount=n[0];else throw new N(6,"Invalid end repeat play count (should be 2 or greater integer): "+n[0]);if(this.endRepeatPlayCount!==2){let u={text:`${this.endRepeatPlayCount}x`,scale:.8,color:"staff.frame"};this.endRepeatPlayCountText=new ot(this,u,.5,1)}break}o&&this.forEachStaffGroup(e,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(s),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,n){let o=this.lastAddedRhythmColumn;if(o){if(n.length===0)throw new N(6,"Cannot add annotation because annotation text is empty.")}else throw new N(6,"Cannot add annotation because anchor is undefined.");let s={text:n},a,c,u;switch(r){case"dynamics":a=6,c=0,s.italic=!0,u="bottom";break;case"tempo":a=5,c=0,s.italic=!0,u="bottom";break}let l=.5,h=i0(u);this.disableExtension(),this.forEachStaffGroup(e,c,(p,m)=>{let f=p instanceof jt?"tab.element.annotation":"staff.element.annotation";s.color=f;let g=new ot(o,s,l,h),b=this.addLayoutObject(g,p,a,m);this.enableExtension(b,f)})}addLabel(e,r,n){let o=this.lastAddedRhythmColumn;if(o){if(n.length===0)throw new N(6,"Cannot add label because label text is empty.")}else throw new N(6,"Cannot add label because anchor is undefined.");let s={text:n},a,c;switch(r){case"note":a=2,c=1;break;case"chord":a=7,c=0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,l)=>{let h=u instanceof jt?"staff.element.label":"tab.element.label";s.color=h;let p=new ot(o,s,.5,1),m=this.addLayoutObject(p,u,a,l);this.enableExtension(m,h)})}addConnective(e,...r){let n=this.lastAddedRhythmSymbol;if(!(n instanceof xt))throw new N(6,"Connective can be added to note group only.");if(e==="tie"){let o=y.isInteger(r[0])||y.isEnumValue(r[0],yr)?r[0]:2,s=y.isEnumValue(r[1],Ke)?r[1]:"auto";n.startConnective(new Kn("tie",o,s,n))}else if(e==="slur"){let o=y.isInteger(r[0])?r[0]:2,s=y.isEnumValue(r[1],Ke)?r[1]:"auto";n.startConnective(new Kn("slur",o,s,n))}else if(e==="slide"){let o=y.isEnumValue(r[0],Ke)?r[0]:"auto";n.startConnective(new Kn("slide",2,o,n))}}addExtension(e,r){if(this.addExtensionTo.forEach(n=>{let{layoutObj:o,color:s}=n,{musicObj:a}=o;a.userData["extension-color"]=s;let c=a.getParent();if(a instanceof ot&&c instanceof kr){let u="dashed",l="bottom",h=new Zi(o,c,n0(e),r,u,l);a.setLink(h)}else throw new N(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionTo.length===0)throw new N(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(e,r){this.addExtensionTo.push({layoutObj:e,color:r})}disableExtension(){this.addExtensionTo=[]}getEnding(){return this.layoutObjects.map(e=>e.musicObj).find(e=>e instanceof Xi)}getEndRepeatPlayCount(){return this.endRepeatPlayCount}endSong(){this.isEndSong=!0,this.requestLayout(),this.disableExtension()}hasEndSong(){return this.isEndSong}endSection(){this.isEndSection=!0,this.requestLayout(),this.disableExtension()}hasEndSection(){return this.isEndSection}endRow(){this.doc.requestNewRow(),this.disableExtension()}addRhythmSymbol(e){let{col:r,voiceId:n}=e;r.setVoiceSymbol(n,e),this.voiceSymbols.add(n,e),e.oldStyleTriplet&&this.createOldStyleTriplets(n),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=r,this.lastAddedRhythmSymbol=e}addNoteGroup(e,r,n,o,s){let a=r.map(l=>typeof l=="string"?U.getNote(l):l),c=this.getRhythmColumn(e),u=new xt(c,e,a,n,o,s);return this.addRhythmSymbol(u),u}addRest(e,r,n,o){let s=this.getRhythmColumn(e),a=new ae(s,e,r,n,o);return this.addRhythmSymbol(a),a}addLyrics(e,r,n,o,s){this.forEachStaffGroup(e,1,(a,c)=>{var p;let u=this.getRhythmColumn({verse:r,line:a,vpos:c}),l=new ac(u,r,a,c,Br(n),o,s);u.addLyricsObject(l);let h=this.lyricsObjectsCache.getOrCreate(a,c,r,[]);h.push(l),h.sort((m,f)=>H.Math.cmp(m.col.positionTicks,f.col.positionTicks)),(p=l.measure.getPrevLyricsObject(l))==null||p.setNextLyricsObject(l),this.addLayoutObject(l,a,o0(r),c),this.lastAddedRhythmColumn=u})}getRhythmColumn(e){let r=0;for(let n=this.columns.length-1;n>=0&&r===0;n--){let o=this.columns[n],s=typeof e=="number"?o.getVoiceSymbol(e):o.getLyricsObject(e.verse,e.line,e.vpos);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let n=0;n<=this.columns.length;n++){let o=this.columns[n];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new kr(this,r);return this.columns.splice(n,0,s),s}}throw new N(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(n=>{se().forEach(o=>{let s=n.getVoiceSymbol(o);s&&(e===void 0||e===o)&&(r=Math.max(r,n.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new G(this.barLineLeft.getRect().anchorX,this.barLineRight.getRect().anchorX,this.getRect().top,this.getRect().bottom)}getLeftSolidWidth(){return this.regions.leftSolid}getMinColumnsWidth(){return this.regions.columnsMin}getRightSolidWidth(){return this.regions.rightSolid}getTotalSolidWidth(){return this.getLeftSolidWidth()+this.getRightSolidWidth()}getMinWidth(){return this.getLeftSolidWidth()+this.getMinColumnsWidth()+this.getRightSolidWidth()}getStaffLineLeft(){let e=this.getPrevMeasure();return e&&e.row===this.row&&!e.hasPostMeasureBreak()?e.getStaffLineRight():this.getRect().left+this.regions.tabTuning_0}getStaffLineRight(){return this.barLineRight.getRect().anchorX}getPrevLyricsObject(e){var c;let{line:r,verse:n,vpos:o}=e,s=this.lyricsObjectsCache.getOrDefault(r,o,n,[]),a=s.indexOf(e);if(a>0)return s[a-1];if(a===0){let u=(c=e.measure.getPrevMeasure())==null?void 0:c.lyricsObjectsCache.get(r,o,n);if(u&&u.length>0)return u[u.length-1]}}getStaticObjects(e){let r=this.layoutObjects.filter(o=>o.line===e&&o.isPositionResolved()).map(o=>o.musicObj),n=r.length>0?[...this.staticObjectsCache.getOrDefault(e,[]),...r]:this.staticObjectsCache.getOrDefault(e,[]);return n.forEach(o=>o.getRect()),n}addStaticObject(e,r){this.staticObjectsCache.getOrCreate(e,[]).push(r)}removeLayoutObjects(e){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===e){let n=r.musicObj.getLink();return n&&n.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(e){this.connectives.push(e),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(e=>{let{musicObj:r,measure:n,layoutGroupId:o,verticalPos:s,line:a}=e;if(r.getLink()instanceof Zi){let c=r.getLink();if(c.getHead()!==r||(c.getTails().forEach(h=>n.removeLayoutObjects(h)),!c.isVisible()))return;let u=c.getRange(),l=u.columnRange.slice();for(let h=!0;l.length>1;h=!1){let{measure:p}=l[0],m=l.findIndex(_=>_.measure!==p),f=l.splice(0,m>0?m:l.length);if(f.length<2)continue;let g=p.row.findMatchingLine(a);if(!g)continue;let b=l.length===0,x=[...h?[r]:[],...f,...b&&u.stopObject?[u.stopObject]:[]];p.addLayoutObject(new Qn(p,g,c,x),g,o,s)}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);for(let n=0;n<r.length;)if(r[n].oldStyleTriplet){let o=Qi.createOldStyleTriplet(r.slice(n,n+3));n+=o===0?1:o}else n++;this.requestLayout()}getBeamGroups(){return this.beamGroups}createBeams(){if(!this.needBeamsUpdate)return;this.beamGroups=this.beamGroups.filter(r=>r.isTuplet()?!0:(r.detach(),!1));let e=this.getTimeSignature();!this.needBeamsUpdate||e.beamGroupSizes.length===0||(se().forEach(r=>{let n=this.getVoiceSymbols(r).slice();if(n.length<2)return;let o=this.isUpBeat()?Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()):0,s=0;for(let a=0;a<e.beamGroupSizes.length;a++){let c=e.beamGroupSizes[a],u=[c];c.length>1&&u.unshift([H.Math.sum(c)]);let l=!1,h=s;for(;u.length>0&&!l;){let p=u.shift();s=h,p.forEach(m=>{let f=m*Tt.get("8n").ticks,g=s+f,b=n.filter(_=>{let w=o+_.col.positionTicks,T=w+_.rhythmProps.ticks;return w>=s&&T<=g});H.Math.sum(b.map(_=>_.rhythmProps.ticks))===f&&b.every(_=>_ instanceof xt)&&(b.every(_=>_.rhythmProps.flagCount===1)||u.length===0)&&Qi.createBeam(b)&&(l=!0),s+=f})}}}),this.needBeamsUpdate=!1,this.requestLayout())}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return this.voiceSymbols.getAll(e)}fillWithRests(...e){if(e.length===0){this.getConsumedTicks()===0?this.fillWithRests(0):this.fillWithRests(...se().filter(r=>this.getConsumedTicks(r)>0));return}else if(e.length>1){e.forEach(r=>this.fillWithRests(r));return}else{let r=e[0];Vo(r);let n=this.getMeasureTicks(),o=this.getConsumedTicks(r),s=n-o,a=[];for(;s>0;)for(let c=Tt.LongestNoteSize;c<=Tt.ShortestNoteSize;c*=2){let u=Tt.create(c).noteLength;for(let l=Tt.get(u).maxDotCount;l>=0;l--){let h=Qt.get(u,l);for(;h.ticks<=s;)a.push(h),s-=h.ticks}}a.reverse().forEach(c=>this.addRest(r,Tt.create(c.noteLength,c.dotCount).noteLength))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?at.PostMeasureBreakWidth*r:0;let n=this.isFirstMeasureInRow(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.regions.tabTuning_0=n&&this.row.hasTab?r*4:0;let s=n||o,a=this.options.showNumber===!1?!1:this.options.showNumber===!0||n&&!this.row.isFirstRow(),c=n||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;this.signatures=[],this.row.getNotationLines().forEach((f,g)=>{if(f instanceof Mt&&(s||a||c||u||l)){let b=this.signatures.filter(_=>_ instanceof Ko).find(_=>_.staff===f),x=b!=null?b:new Ko(this,f);x.staff.addObject(x),x.updateClefImage(e,s),x.updateMeasureNumber(a&&g===0),x.updateKeySignature(c),x.updateTimeSignature(u),x.updateTempo(l&&g===0),x.layout(e),this.signatures.push(x)}else if(f instanceof jt&&(a||u||l)){let b=this.signatures.filter(_=>_ instanceof Jo).find(_=>_.tab===f),x=b!=null?b:new Jo(this,f);x.tab.addObject(x),x.updateMeasureNumber(a&&g===0),x.updateTimeSignature(u),x.updateTempo(l&&g===0),x.layout(e),this.signatures.push(x)}}),this.tabStringNotes.length=0,this.isFirstMeasureInRow()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let b=f.getTuningStrings()[g].format(1,1),x=new ot(this,{text:b,scale:.8,color:"tab.tuning"},1,.5);x.layout(e),x.setRight(this.regions.tabTuning_0*.8),x.setCenterY(f.getStringY(g)),this.tabStringNotes.push(x),f.addObject(x)}}),this.barLineLeft.layout(e);let h=new Ja(this);this.columns.forEach(f=>f.layout(e,h)),this.columns.forEach(f=>f.layoutReserveSpace(e)),this.barLineRight.layout(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(e),this.layoutObjects.forEach(f=>f.layout(e));let p=e.unitSize;this.regions.signature_1=Math.max(0,...this.signatures.map(f=>f.getRect().width)),this.regions.leftBarLine_2=this.barLineLeft.getRect().width,this.regions.padding_3=p,this.regions.columnsMin_4=Math.max(at.MinColumnsWidth*r,this.columns.map(f=>f.getRect().width).reduce((f,g)=>f+g,0)),this.regions.padding_5=p,this.regions.rightBarLine_6=this.barLineRight.getRect().width}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new G,this.rect.anchorX=this.rect.left+r/2,this.rect.right=this.rect.left+r,this.signatures.forEach(h=>{h.setLeft(this.rect.left+this.regions.tabTuning_0),h.setAnchorY(this.rect.anchorY)});let n=Math.max(0,...this.signatures.map(h=>h.getRect().width));this.barLineLeft.setLeft(this.rect.left+this.regions.tabTuning_0+n),this.barLineLeft.setAnchorY(this.rect.anchorY),this.barLineRight.setRight(this.rect.right),this.barLineRight.setAnchorY(this.rect.anchorY),this.endRepeatPlayCountText&&(this.endRepeatPlayCountText.setCenterX(this.barLineRight.getRect().left),this.endRepeatPlayCountText.setBottom(this.barLineRight.getRect().top));let o=this.rect.left+this.regions.leftSolid,a=this.rect.right-this.regions.rightSolid-o,c=this.regions.columnsMin,u=a/c,l=o;this.columns.forEach(h=>{let p=h.getRect(),m=l+p.leftw*u;h.setAnchor(m,this.rect.anchorY),l+=p.width*u}),se().forEach(h=>{let p=this.getVoiceSymbols(h),m=p.length===1&&p[0]instanceof ae?p[0]:void 0;!m||se().map(g=>m.col.getVoiceSymbol(g)).filter(g=>g!==void 0&&g!==m).length===0||m.setAnchorX(this.getColumnsContentRect().centerX)})}layoutConnectives(e){this.needLayout&&this.connectives.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(e){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}alignStemsToBeams(){this.beamGroups.forEach(e=>e.updateStemTips())}layoutDone(){this.columns.forEach(e=>e.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(e=>e.getRect().top),...this.tabStringNotes.map(e=>e.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(e=>e.getRect().top),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(e=>e.getRect().bottom),...this.tabStringNotes.map(e=>e.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(e=>e.getRect().bottom),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().bottom)),this.isLastMeasureInRow()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(e=>e.isPositionResolved()&&e.musicObj instanceof Ci).map(e=>e.musicObj.getRect().right))),this.row.getNotationLines().forEach(e=>{this.rect.top=Math.min(this.rect.top,e.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,e.calcBottom())}),this.row.requestRectUpdate()}offset(e,r){this.signatures.forEach(n=>n.offset(e,0)),this.tabStringNotes.forEach(n=>n.offset(e,0)),this.barLineLeft.offset(e,r),this.columns.forEach(n=>n.offset(e,r)),this.barLineRight.offset(e,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(e,r),this.connectives.forEach(n=>n.offset(e,0)),this.beamGroups.forEach(n=>n.offset(e,r)),this.layoutObjects.forEach(n=>n.offset(e,0)),this.rect.offsetInPlace(e,r),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect()),e.lineWidth(1);let r=this.getStaffLineLeft(),n=this.getStaffLineRight(),o=(s,a)=>e.color(a).strokeLine(r,s,n,s);this.row.getNotationLines().forEach(s=>{if(s instanceof Mt)for(let a=s.bottomLineDiatonicId;a<=s.topLineDiatonicId;a+=2)o(s.getDiatonicIdY(a),"staff.frame");else if(s instanceof jt)for(let a=0;a<6;a++)o(s.getStringY(a),"tab.frame")}),this.isFirstMeasureInRow()&&this.row.getNotationLines().length===1&&this.row.getTabs().forEach(s=>{if(s.getRowGroup().hasBrace)return;let c=this.getStaffLineLeft(),u=s.getTopLineY(),l=s.getBottomLineY();e.color("tab.frame").lineWidth(1).strokeLine(c,u,c,l)}),this.signatures.forEach(s=>s.draw(e)),this.tabStringNotes.forEach(s=>s.draw(e)),this.barLineLeft.draw(e),this.columns.forEach(s=>s.draw(e)),this.barLineRight.draw(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(e),this.connectives.forEach(s=>s.draw(e)),this.layoutObjects.forEach(s=>s.musicObj.draw(e)),this.beamGroups.forEach(s=>s.draw(e))}};var cc=(h=>(h[h.TabRhythm=0]="TabRhythm",h[h.Fermata=1]="Fermata",h[h.NoteLabel=2]="NoteLabel",h[h.Navigation=3]="Navigation",h[h.Ending=4]="Ending",h[h.TempoAnnotation=5]="TempoAnnotation",h[h.DynamicsAnnotation=6]="DynamicsAnnotation",h[h.ChordLabel=7]="ChordLabel",h[h.LyricsVerse1=8]="LyricsVerse1",h[h.LyricsVerse2=9]="LyricsVerse2",h[h.LyricsVerse3=10]="LyricsVerse3",h))(cc||{}),Dh=new lt([[0,{rowAlign:!0}],[1,{reserveSpace:!0}],[2,{reserveSpace:!0}],[3,{rowAlign:!0}],[4,{rowAlign:!0,padding:2}],[5,{rowAlign:!0,padding:2}],[6,{rowAlign:!0,padding:2}],[7,{reserveSpace:!0,rowAlign:!0}],[8,{reserveSpace:!0,rowAlign:!0}],[9,{reserveSpace:!0,rowAlign:!0}],[10,{reserveSpace:!0,rowAlign:!0}]]);function s0(i){for(;i;){if(i instanceof bi)return i;i=i.getParent()}throw new N(6,"Parent measure is required but not found!")}var hc=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},uc=class{constructor(t,e,r,n){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=n;d(this,"anchor");d(this,"measure");d(this,"row");d(this,"layoutGroup");d(this,"positionResolved",!0);this.measure=s0(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new N(6,"Parent music object is required as an anchor.");this.anchor=o,this.anchor.addAnchoredLayoutObject(this),this.layoutGroup=this.line.getLayoutGroup(r),this.layoutGroup.add(this)}resetPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(t){let{musicObj:e,measure:r,verticalPos:n,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=t.unitSize*2,u=n===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,l=r.getStaticObjects(o),h=e.getShapeRects();return l.forEach(p=>{let m=p.getShapeRects();h.forEach(f=>{m.forEach(g=>{G.overlapX(f,g)&&(u=n===1?Math.max(u,g.bottom+f.toph+f.anchorY):Math.min(u,g.top-f.bottomh-f.anchorY))})})}),u}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}setAnchorY(t){this.musicObj.setAnchorY(t)}getRect(){return this.musicObj.getRect()}},lc=class{constructor(t){this.layoutGroupId=t;d(this,"layoutObject",Ys(new vr));d(this,"rowAlign");d(this,"reserveSpace");d(this,"padding");var e,r,n,o;this.rowAlign=((e=Dh.get(t))==null?void 0:e.rowAlign)===!0,this.reserveSpace=((r=Dh.get(t))==null?void 0:r.reserveSpace)===!0,this.padding=(o=(n=Dh.get(t))==null?void 0:n.padding)!=null?o:0}getLayoutObjects(t){return this.layoutObject.getAll(t)}add(t){this.layoutObject.add(t.verticalPos,t)}remove(t){this.layoutObject.remove(t.verticalPos,t)}layout(t){for(let e of this.layoutObject.values())e.resetPositionResolved(),e.musicObj.layout(t)}getPadding(t){return this.padding*t.unitSize}};var dc=class extends J{constructor(e){super(e);this.row=e;d(this,"objects",[]);d(this,"layoutGroups",new lt)}getRowGroup(){return this.row.getRowGroupByLineId(this.id)}addObject(e){this.objects.push(e)}removeObjects(){this.objects.length=0}getLayoutGroup(e){return this.layoutGroups.getOrCreate(e,()=>new lc(e))}resetLayoutGroups(e){this.layoutGroups.forEach(r=>r.layout(e))}layoutLayoutGroups(e){for(let r of H.Enum.getEnumValues(cc)){let n=this.getLayoutGroup(r);n&&(this.layoutLayoutGroup(e,n,0),this.layoutLayoutGroup(e,n,1))}}setObjectY(e,r){r!==void 0&&(e.setAnchorY(r-e.getRect().anchorY),e.setPositionResolved())}alignObjectsY(e,r,n){let o=r.filter(u=>!u.isPositionResolved()&&u.verticalPos===n);if(o.length===0)return;let s=n===1?1:-1,a=o.map(u=>u.resolveClosestToStaffY(e)+u.layoutGroup.getPadding(e)*s),c=n===1?Math.max(...a):Math.min(...a);o.forEach(u=>this.setObjectY(u,c))}layoutLayoutGroup(e,r,n){let o=r.getLayoutObjects(n).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof Xi||a instanceof Qn||a instanceof Jn?a.layoutFitToMeasure(e):a.setAnchorX(c.getRect().anchorX)}),r.rowAlign?this.alignObjectsY(e,o,n):o.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=o.filter(l=>c.some(h=>h===l.musicObj));this.alignObjectsY(e,u,n)}else this.alignObjectsY(e,[s],n)})}drawVerticalLine(e,r,n,o=!1){e.color(this.getConfig().type==="tab"?"tab.frame":"staff.frame");let s=this.row.getNotationLines().indexOf(this),a=s>=0?this.row.getNotationLines()[s+1]:void 0,c=this.getRowGroup().lines.length>1,u=this instanceof Mt&&this.isGrandTreble(),l=this.getTopLineY(),h=a&&(o||c||u)?a.getTopLineY():this.getBottomLineY();e.fillRect(r,l,n,h-l)}},Mt=class extends dc{constructor(e,r,n){super(e);this.staffConfig=r;this.id=n;d(this,"clefImageAsset");d(this,"clefLineDiatonicId");d(this,"topLineDiatonicId");d(this,"middleLineDiatonicId");d(this,"bottomLineDiatonicId");d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"joinedGrandStaff");d(this,"topLineY",0);d(this,"bottomLineY",0);d(this,"mi");let o=(s,a)=>U.getNote(s).diatonicId-(a?7:0);if(r.clef==="G")this.clefImageAsset=0,this.clefLineDiatonicId=o("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2;else if(r.clef==="F")this.clefImageAsset=1,this.clefLineDiatonicId=o("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2;else throw new N(6,`Invalid staffConfig.clef ${r.clef}.`);this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(o(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(o(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new Ss(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var e;return(e=this.staffConfig.name)!=null?e:""}getConfig(){return this.staffConfig}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(e){e!==this&&(this.joinedGrandStaff=e)}isGrandTreble(){return this.joinedGrandStaff!==void 0&&this.staffConfig.clef==="G"}isGrandBass(){return this.joinedGrandStaff!==void 0&&this.staffConfig.clef==="F"}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(e){return U.validateDiatonicId(e),(this.minDiatonicId===void 0||e>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||e<=this.maxDiatonicId)}getDiatonicIdY(e){if(this.containsDiatonicId(e))return this.bottomLineY+(this.bottomLineDiatonicId-e)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff.getDiatonicIdY(e);throw new N(6,"Staff does not contain diatonicId "+e)}getActualStaff(e){if(this.containsDiatonicId(e))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff;throw new N(6,"Staff does not contain diatonicId "+e)}getDiatonicIdAt(e){let r=Math.round(this.bottomLineDiatonicId-(e-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(e){return e%2===this.middleLineDiatonicId%2}isSpace(e){return e%2!==this.middleLineDiatonicId%2}containsVoiceId(e){return y.isUndefined(this.staffConfig.voiceId)||H.Arr.toArray(this.staffConfig.voiceId).includes(e)}calcTop(){let e=this.topLineY;if(this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),n=this.getDiatonicIdY(this.maxDiatonicId-1);e=Math.min(e,r-Math.abs(n-r)+1)}return e}calcBottom(){let e=this.bottomLineY;if(this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),n=this.getDiatonicIdY(this.minDiatonicId+1);e=Math.max(e,r+Math.abs(n-r)-1)}return e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,n=r*at.StaffHeight;this.topLineY=-n/2,this.bottomLineY=n/2,this.rect=new G(0,0,this.topLineY,this.bottomLineY)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(n=>{n.offsetInPlace?n.offsetInPlace(0,r):n.offset&&n.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}},jt=class extends dc{constructor(e,r,n){super(e);this.tabConfig=r;this.id=n;d(this,"top",0);d(this,"bottom",0);d(this,"tuningName");d(this,"tuningStrings");d(this,"mi");y.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>U.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=bu(r.tuning),this.tuningStrings=Xs(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=Xs(this.tuningName)),this.mi=new Is(this)}getMusicInterface(){return this.mi}get name(){var e;return(e=this.tabConfig.name)!=null?e:""}getConfig(){return this.tabConfig}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(e){return this.top+(this.bottom-this.top)/6*(e+.5)}getTopStringY(){return this.getStringY(0)}getBottomStringY(){return this.getStringY(5)}getTopLineY(){return this.getTopStringY()}getBottomLineY(){return this.getBottomStringY()}getTop(){return this.top}getBottom(){return this.bottom}containsVoiceId(e){return y.isUndefined(this.tabConfig.voiceId)||H.Arr.toArray(this.tabConfig.voiceId).includes(e)}containsDiatonicId(e){return!0}calcTop(){let{top:e}=this;return this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),e}calcBottom(){let{bottom:e}=this;return this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,n=r*at.TabHeight;this.top=-n/2,this.bottom=n/2,this.rect=new G(0,0,this.top,this.bottom)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.top+=r,this.bottom+=r,this.objects.forEach(n=>{n.offsetInPlace?n.offsetInPlace(0,r):n.offset&&n.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}};function a0(i){let t=(i.startsWith("!{")?i.substring(2):i.startsWith("!")?i.substring(1):i).trim(),e=i.startsWith("!"),r=i.startsWith("!{");return{instrName:t,hideInstr:e,hideBrace:r}}var pc=class extends J{constructor(e){var s;super(e[0].row);this.lines=e;d(this,"space",0);d(this,"instrument");d(this,"hasBrace");d(this,"instrText");d(this,"braceRect",new G);d(this,"mi");let r="rowgroup.instrument",n=a0((s=e[0].getConfig().instrument)!=null?s:"");this.instrument=n.instrName,this.hasBrace=n.hideBrace?!1:this.hasInstrument&&e.length>=2;let o=n.hideInstr?"":this.instrument;this.instrText=new ot(this,{text:o,color:r,scale:1},1,.5),this.mi=new Ts(this)}getMusicInterface(){return this.mi}get row(){return this.lines[0].row}get hasInstrument(){return this.instrument.length>0}hasNotationLine(e){return this.lines.includes(e)}pick(e,r){if(!this.getRect().contains(e,r))return[];let n=this.instrText.pick(e,r);return n.length>0?[this,...n]:[this]}updateRect(){this.instrText.setRight(this.braceRect.left-this.space),this.instrText.setCenterY(this.braceRect.anchorY),this.rect=this.instrText.getRect().clone().expandInPlace(this.braceRect)}layout(e){this.space=e.unitSize,this.instrText.layout(e),this.braceRect=new G(-(this.hasBrace?e.unitSize*5:0),0,0,0),this.forceRectUpdate()}layoutToNotationLines(){this.braceRect.top=this.lines[0].getTopLineY(),this.braceRect.bottom=this.lines[this.lines.length-1].getBottomLineY(),this.braceRect.anchorY=this.braceRect.centerY,this.forceRectUpdate()}offset(e,r){this.instrText.offset(e,r),this.braceRect.offsetInPlace(e,r),this.rect.offsetInPlace(e,r)}draw(e){if(this.instrText.draw(e),this.hasBrace){let r=this.braceRect;e.color("rowgroup.frame").lineWidth(1).drawBracket(r,"{")}}};var mc=class{constructor(){d(this,"instrWidth",0);d(this,"staffWidth",0)}resetWidths(){this.instrWidth=this.staffWidth=0}addRowInstrWidth(t){this.instrWidth=Math.max(this.instrWidth,t)}addRowstaffWidth(t){this.staffWidth=Math.max(this.staffWidth,t)}get instrLeft(){return 0}get instrRight(){return this.instrWidth}get staffLeft(){return this.instrRight}get staffRight(){return this.staffLeft+this.staffWidth}get left(){return this.instrLeft}get right(){return this.staffRight}get width(){return this.instrWidth+this.staffWidth}},fc=class extends J{constructor(e,r,n){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=n;d(this,"nextRow");d(this,"notationLines");d(this,"rowGroups");d(this,"staves");d(this,"tabs");d(this,"measures",[]);d(this,"rowGroupByLine");d(this,"needLayout",!0);d(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(s=>s instanceof Mt),this.tabs=this.notationLines.filter(s=>s instanceof jt);let o=[];for(let s=0;s<this.notationLines.length;s++){let a=this.notationLines[s],c=o[o.length-1];c===void 0||c[0].getConfig().instrument===void 0||c[0].getConfig().instrument!==a.getConfig().instrument?o.push([a]):c.push(a)}this.rowGroups=o.filter(s=>s.length>0).map(s=>new pc(s)),this.rowGroupByLine=this.notationLines.map(s=>this.rowGroups.find(a=>a.lines.includes(s))),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new Ns(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,n)=>r.type==="staff"?new Mt(this,r,n):new jt(this,r,n));for(let r=0;r<e.length-1;r++){let n=e[r],o=e[r+1];n instanceof Mt&&o instanceof Mt&&n.staffConfig.grandId!==void 0&&n.staffConfig.grandId===o.staffConfig.grandId&&(n.joinGrandStaff(o),o.joinGrandStaff(n))}return e}getNotationLines(){return this.notationLines}getRowGroups(){return this.rowGroups}getRowGroupByLineId(e){return this.rowGroupByLine[e]}findMatchingLine(e){return e.row===this?e:this.notationLines.find(r=>H.Obj.deepEqual(e.row.scoreConfig,r.row.scoreConfig)&&e.id===r.id||y.isNonEmptyString(e.getConfig().name)&&e.getConfig().name===r.getConfig().name&&e.getConfig().type===r.getConfig().type)}get regions(){return this.doc.regions}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let e=this.staves[0];if(e)return e;throw new N(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new N(6,"Bottom staff is required!")}getStaff(e){U.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let n=this.notationLines[r];if(n instanceof Mt&&n.containsDiatonicId(e))return n}}resetLayoutGroups(e){this.notationLines.forEach(r=>r.resetLayoutGroups(e))}layoutLayoutGroups(e){this.notationLines.forEach(r=>r.layoutLayoutGroups(e))}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.measures.length;n++){let o=this.measures[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.rowGroups.length;n++){let o=this.rowGroups[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.notationLines.length;n++){let o=this.notationLines[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),n=r?r.getColumnsContentRect().left:e.left;return new G(n,(n+e.right)/2,e.right,e.top,e.anchorY,e.bottom)}getDiatonicIdAt(e){for(let r=0;r<this.notationLines.length;r++){let n=this.notationLines[r],o=n instanceof Mt?n.getDiatonicIdAt(e):void 0;if(o!==void 0)return o}}addMeasure(e){this.measures.push(e)}getMeasures(){return this.measures}isFirstRow(){return this===this.doc.getFirstRow()}isLastRow(){return this===this.doc.getLastRow()}getPrevRow(){return this.prevRow}getNextRow(){return this.nextRow}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}solveAutoStemDir(e){if(e.length===0)return"up";{let r=e[0].voiceId,n=e.filter(u=>u instanceof xt).map(u=>u.setDiatonicId),o=e.filter(u=>u instanceof ae&&u.setDiatonicId!==ae.UndefinedDiatonicId).map(u=>u.setDiatonicId);if(n.length===0&&o.length===0)return"up";let s=n.length>0?n:o,a=Math.floor(H.Math.avg(...s)),c=this.getStaves().filter(u=>u.containsVoiceId(r)&&u.containsDiatonicId(a));return c.length>0?a>=c[0].middleLineDiatonicId?"down":"up":"up"}}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(e){if(!this.needLayout)return;this.requestRectUpdate(),this.notationLines.forEach(n=>{n.removeObjects(),n.layoutHeight(e)}),this.rowGroups.forEach(n=>{n.layout(e),this.regions.addRowInstrWidth(n.getRect().width)}),this.measures.forEach(n=>n.layout(e));let r=this.measures.map(n=>n.getMinWidth()+n.getPostMeasureBreakWidth()).reduce((n,o)=>n+o);this.regions.addRowstaffWidth(r)}layoutStretch(e){if(!this.needLayout)return;this.rect=new G(this.regions.left,this.regions.right,0,0),this.notationLines.forEach(a=>a.layoutWidth(e)),this.rowGroups.forEach(a=>a.setRight(this.regions.instrRight));let r=this.regions.staffWidth,n=0;this.measures.forEach(a=>{r-=a.getTotalSolidWidth()+a.getPostMeasureBreakWidth(),n+=a.getMinColumnsWidth()});let o=r/n,s=this.regions.staffLeft;this.measures.forEach(a=>{let c=a.getTotalSolidWidth()+a.getMinColumnsWidth()*o;a.layoutWidth(e,c);let u=a.getRect();a.setLeft(s),a.setAnchorY(0),s+=u.width,s+=a.getPostMeasureBreakWidth()}),this.measures.forEach(a=>{a.layoutConnectives(e),a.layoutBeams(e)})}updateRect(){var a;let e=this.regions.left,r=this.regions.right,n=0,o=0,s=(a=this.getLastMeasure())==null?void 0:a.getBarLineRight().getAnchoredLayoutObjects().map(c=>c.musicObj).find(c=>c instanceof Ci);s&&(r=Math.max(r,s.getRect().right)),this.measures.length>0&&(n=Math.min(...this.measures.map(c=>c.getRect().top)),o=Math.max(...this.measures.map(c=>c.getRect().bottom))),this.rect=new G(e,r,n,o)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutSetNotationLines(e){let{unitSize:r}=e;for(let n=1;n<this.notationLines.length;n++){let o=this.notationLines[n-1],s=this.notationLines[n];if(o instanceof Mt&&s instanceof Mt&&o.staffConfig.grandId!==void 0&&o.staffConfig.grandId===s.staffConfig.grandId){let a=o.getBottomLineY()-s.getTopLineY()+r*6;s.offsetY(a)}else{let a=o.calcBottom()-s.calcTop()+r*3;s.offsetY(a)}}this.measures.forEach(n=>{n.requestRectUpdate(),n.getBarLineLeft().requestRectUpdate(),n.getBarLineRight().requestRectUpdate(),n.getColumns().forEach(o=>{o.requestRectUpdate(),se().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.rowGroups.forEach(n=>n.layoutToNotationLines()),this.alignStemsToBeams(),this.requestRectUpdate()}layoutDone(){this.measures.forEach(e=>e.layoutDone()),this.needLayout=!1}offset(e,r){this.measures.forEach(n=>n.offset(e,r)),this.rect.offsetInPlace(e,r),this.notationLines.forEach(n=>n.offset(e,r)),this.rowGroups.forEach(n=>n.offset(e,r))}getStaffLineLeft(){var e;return(e=this.getFirstMeasure())==null?void 0:e.getStaffLineLeft()}draw(e){e.drawDebugRect(this.getRect());let{left:r,top:n,width:o,height:s}=this.getRect(),a=e._lineWidth;e.save(),e.rect(r-a,n,o+2*a,s),e.clip(),this.measures.forEach(u=>u.draw(e)),this.notationLines.forEach(u=>u.draw(e));let c=this.getStaffLineLeft();c!==void 0&&this.notationLines.length>1&&this.notationLines.forEach(u=>u.drawVerticalLine(e,c,e._lineWidth,!0)),this.rowGroups.forEach(u=>u.draw(e)),e.restore()}};var gc=class extends J{constructor(e,r,n,o){super(e);this.doc=e;this.title=r;this.composer=n;this.arranger=o;d(this,"titleText");d(this,"composerText");d(this,"arrangerText");d(this,"mi");this.mi=new Os(this),this.titleText=this.title?new ot(this,{text:this.title,color:"header.title",scale:2},.5,0):void 0,this.composerText=this.composer?new ot(this,{text:this.composer,color:"header.composer"},1,0):void 0,this.arrangerText=this.arranger?new ot(this,{text:"Arr.: "+this.arranger,color:"header.arranger"},1,0):void 0}getMusicInterface(){return this.mi}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.titleText){let n=this.titleText.pick(e,r);if(n)return[this,...n]}if(this.composerText){let n=this.composerText.pick(e,r);if(n)return[this,...n]}if(this.arrangerText){let n=this.arrangerText.pick(e,r);if(n)return[this,...n]}return[this]}layout(e){let r=0,n=this.doc.regions.staffLeft,o=this.doc.regions.staffRight;this.rect=new G(n,o,0,0),this.titleText&&(this.titleText.layout(e),this.titleText.setCenterX((n+o)/2),this.titleText.setTop(r),r+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(e),this.composerText.setRight(o),this.composerText.setTop(r),r+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(e),this.arrangerText.setRight(o),this.arrangerText.setTop(r),r+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(e,r){this.titleText&&this.titleText.offset(e,r),this.composerText&&this.composerText.offset(e,r),this.arrangerText&&this.arrangerText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.titleText&&this.titleText.draw(e),this.composerText&&this.composerText.draw(e),this.arrangerText&&this.arrangerText.draw(e)}};var yc=class extends J{constructor(){super(void 0);d(this,"needLayout",!0);d(this,"ctx");d(this,"regions",new mc);d(this,"rows",[]);d(this,"measures",[]);d(this,"measuresPerRow",1/0);d(this,"curScoreConfig",[{type:"staff",clef:"G"}]);d(this,"header");d(this,"newRowRequested",!1);d(this,"allConnectiveProps",[]);d(this,"staffGroups",new lt);d(this,"mi");this.mi=new Xr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(y.isEnumValue(e,Yn))switch(e){default:case"treble":this.curScoreConfig=[{type:"staff",clef:"G"}];break;case"bass":this.curScoreConfig=[{type:"staff",clef:"F"}];break;case"grand":this.curScoreConfig=[{type:"staff",clef:"G",grandId:"grand1"},{type:"staff",clef:"F",grandId:"grand1"}];break;case"guitarTreble":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case"guitarTab":this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case"guitarCombined":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else y.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0,n=[];r<this.curScoreConfig.length;){let o=this.curScoreConfig[r],s=this.curScoreConfig[r+1];if(o&&s&&o.type==="staff"&&s.type==="staff"&&o.grandId!==void 0&&o.grandId===s.grandId){if(n.includes(o.grandId))throw new N(6,`Grand staff error: grandId "${o.grandId}" already used!`);if(o.clef!=="G")throw new N(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(s.clef!=="F")throw new N(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(o.isOctaveDown||s.isOctaveDown)throw new N(6,"Grand staff error: cannot use isOctaveDown option!");n.push(o.grandId),o.minNote="C4",s.maxNote="B3",r+=2}else{if(o&&o.type==="staff"&&o.grandId!==void 0)throw new N(6,`Grand staff error: invalid use of grandId "${o.grandId}"!`);r++}}this.requestNewRow()}setMeasuresPerRow(e){this.measuresPerRow=e}addConnectiveProps(e){this.allConnectiveProps.push(e)}setRenderContext(e){if(this.ctx===e)return;let r=this.ctx;this.ctx=e,r&&r.setDocument(void 0),e&&e.setDocument(this.mi),this.requestFullLayout()}setHeader(e,r,n){this.header=new gc(this,e,r,n),this.requestLayout()}getTitle(){var e;return(e=this.header)==null?void 0:e.title}getComposer(){var e;return(e=this.header)==null?void 0:e.composer}getArranger(){var e;return(e=this.header)==null?void 0:e.arranger}hasSingleMeasure(){return this.measures.length===1}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}addNewRow(e){let r=new fc(this,e,this.curScoreConfig);return this.rows.push(r),r}getFirstRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[0]}getLastRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[this.rows.length-1]}getRows(){return this.rows}getMeasures(){return this.measures}requestNewRow(){this.newRowRequested=!0}addMeasure(e){let r=this.rows[this.rows.length-1];(!r||this.newRowRequested&&r.getMeasures().length>0||r.getMeasures().length>=this.measuresPerRow)&&(r=this.addNewRow(r),this.newRowRequested=!1);let n=new bi(r,e);return this.measures.push(n),r.addMeasure(n),this.requestLayout(),n}addStaffGroup(e,r,n){this.staffGroups.set(e,new hc(e,r,n))}getStaffGroup(e){return this.staffGroups.get(e)}getVoiceSymbols(e){let r=[];return this.forEachMeasure(n=>r=r.concat(n.getVoiceSymbols(e))),r}removeLayoutObjects(e){this.forEachMeasure(r=>r.removeLayoutObjects(e))}forEachMeasure(e){let r=this.getFirstMeasure();for(;r;)e(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(e=>e.resetPassCount())}updateCursorRect(e){this.ctx&&this.ctx.updateCursorRect(e)}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(e=>e.requestLayout()),this.forEachMeasure(e=>{e.getColumns().forEach(r=>r.requestLayout()),e.requestLayout()}),this.requestLayout()}layout(){var n;if(!this.needLayout)return;let{ctx:e}=this;if(!e)return;let{unitSize:r}=e;this.forEachMeasure(o=>o.createBeams()),(n=this.getFirstMeasure())==null||n.updateRunningArguments(),this.forEachMeasure(o=>o.createExtensions()),this.allConnectiveProps.forEach(o=>o.removeConnectives()),this.allConnectiveProps.forEach(o=>o.createConnectives()),this.rows.forEach(o=>o.resetLayoutGroups(e)),this.regions.resetWidths(),this.regions.addRowstaffWidth(at.MinStaffWidth*r),this.rows.forEach(o=>o.layout(e)),this.rows.forEach(o=>o.layoutStretch(e)),this.rows.forEach(o=>o.layoutLayoutGroups(e)),this.rows.forEach(o=>o.layoutSetNotationLines(e)),this.rect=new G,this.header&&(this.header.layout(e),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(o=>{o.setLeft(0),o.setTop(this.rect.bottom+r*2),this.rect.expandInPlace(o.getRect())}),this.rows.forEach(o=>o.layoutDone()),this.needLayout=!1}offset(e,r){}drawContent(){let{ctx:e}=this;e&&(this.rows.forEach(r=>r.draw(e)),this.header&&this.header.draw(e))}pickStaffPosAt(e,r){if(this.rect.contains(e,r))for(let n=0;n<this.rows.length;n++){let o=this.rows[n];if(!o.hasStaff||!o.getRect().contains(e,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.header){let n=this.header.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.rows.length;n++){let o=this.rows[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}};var mg="";function gt(i,...t){let e=t.map(r=>JSON.stringify(r)).join(", ");mg=`DocumentBuilder.${i}(${e})`}function ht(...i){i.forEach(t=>{if(!t)throw new N(6,mg)})}function fg(i,t){if(!i)throw new N(6,t)}function _i(i,t,e){fg(!y.isTypedObject(i,[t]),e)}function gg(i){ht(y.isObject(i),y.isStringOrUndefined(i.name),y.isUndefined(i.voiceId)||Qe(i.voiceId)||y.isArray(i.voiceId)&&i.voiceId.every(t=>Qe(t))),_i(i,"voiceIds","Baseconfig.voiceIds was removed. Use BaseConfig.voiceId instead."),y.isArray(i.voiceId)&&(i.voiceId=H.Arr.removeDuplicates(i.voiceId)),ht(y.isStringOrUndefined(i.instrument))}function lg(i){gg(i),ht(y.isObject(i),y.isStrictEqual(i.type,"staff"),y.isEnumValue(i.clef,zi),y.isBooleanOrUndefined(i.isOctaveDown),y.isUndefined(i.minNote)||U.isNote(i.minNote),y.isUndefined(i.maxNote)||U.isNote(i.maxNote),y.isStringOrUndefined(i.grandId)),_i(i,"isGrand","StaffConfig.isGrand was removed. Use StaffConfig.grandId instead.")}function dg(i){gg(i),ht(y.isObject(i),y.isStrictEqual(i.type,"tab"),y.isUndefined(i.tuning)||y.isString(i.tuning)&&y.isIncluded(i.tuning,mo)||y.isArray(i.tuning)&&y.isStrictEqual(i.tuning.length,$a().length&&i.tuning.every(t=>U.isNote(t))))}function bc(i){ht(y.isObject(i),y.isEnumValueOrUndefined(i.stem,gr),y.isStringOrUndefined(i.color),y.isBooleanOrUndefined(i.arpeggio)||y.isEnumValue(i.arpeggio,gi),y.isBooleanOrUndefined(i.staccato),y.isBooleanOrUndefined(i.diamond),y.isUndefined(i.string)||qo(i.string)||y.isEmptyArray(i.string)||y.isNonEmptyArray(i.string)&&i.string.every(t=>qo(t))),_i(i,"dotted","NoteOptions.dotted was removed."),_i(i,"triplet","NoteOptions.triplet was removed."),_i(i,"tieSpan",'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)'),_i(i,"slurSpan",'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)')}function pg(i){ht(y.isObject(i),y.isStringOrUndefined(i.staffPos)||y.isInteger(i.staffPos)||i.staffPos instanceof U,y.isStringOrUndefined(i.color),y.isBooleanOrUndefined(i.hide)),_i(i,"dotted","RestOptions.dotted was removed."),_i(i,"triplet","RestOptions.triplet was removed.")}function c0(i){ht(y.isObject(i),y.isEnumValueOrUndefined(i.align,Uo),y.isEnumValueOrUndefined(i.hyphen,Hn))}function u0(i){ht(y.isObject(i),y.isBooleanOrUndefined(i.showNumber))}function Rs(i){ht(y.isStringOrUndefined(i)||y.isIntegerGte(i,0)||y.isNonEmptyArray(i)&&i.every(t=>y.isString(t)||y.isIntegerGte(t,0)))}var xc=class xc{constructor(){d(this,"doc");d(this,"currentLyricsAlign","center");this.doc=new yc}setScoreConfiguration(t){return gt("setScoreConfiguration",t),y.isEnumValue(t,Yn)?this.doc.setScoreConfiguration(t):y.isObject(t)&&t.type==="staff"?(lg(t),this.doc.setScoreConfiguration(t)):y.isObject(t)&&t.type==="tab"?(dg(t),this.doc.setScoreConfiguration(t)):y.isNonEmptyArray(t)?(t.forEach(e=>{y.isObject(e)&&e.type==="staff"?lg(e):y.isObject(e)&&e.type==="tab"?dg(e):ht(!1)}),this.doc.setScoreConfiguration(t)):ht(!1),this}getMeasure(){var t;return(t=this.doc.getLastMeasure())!=null?t:this.doc.addMeasure(xc.DefaultMeasureOptions)}getDocument(){return this.getMeasure(),this.doc.getMusicInterface()}setHeader(t,e,r){return gt("setHeader",t,e,r),ht(y.isStringOrUndefined(t),y.isStringOrUndefined(e),y.isStringOrUndefined(r)),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return gt("setMeasuresPerRow",t),ht(y.isIntegerGte(t,1)||y.isPosInfinity(t)),this.doc.setMeasuresPerRow(t),this}addMeasure(t){return gt("addMeasure",t),t!=null||(t={}),u0(t),this.doc.addMeasure(t),this}setKeySignature(...t){return gt("setKeySignature",...t),ht(t[0]instanceof ii||t[0]instanceof rr||y.isNonEmptyString(t[0])&&y.isEnumValueOrUndefined(t[1],Ni)),this.getMeasure().setKeySignature(...t),this}setTimeSignature(...t){return gt("setTimeSignature",...t),t[0]instanceof ni?this.getMeasure().setTimeSignature(t[0]):y.isEnumValue(t[0],fo)&&y.isEnumValueOrUndefined(t[1],Ri)?this.getMeasure().setTimeSignature(new ni(t[0],t[1])):y.isIntegerGte(t[0],1)&&y.isIntegerGte(t[1],1)&&y.isEnumValueOrUndefined(t[2],Ri)?this.getMeasure().setTimeSignature(new ni(t[0],t[1],t[2])):ht(!1),this}setTempo(t,e){return gt("setTempo",t,e),ht(y.isIntegerGte(t,1),y.isUndefined(e)||nr(e)),this.getMeasure().setTempo(t,e),this}addNote(t,e,r,n){if(gt("addNote",t,e,r,n),ht(Qe(t),e instanceof U||y.isNonEmptyString(e)||y.isArray(e)&&e.every(o=>o instanceof U||y.isNonEmptyString(o)),nr(r)),n!=null||(n={}),bc(n),y.isArray(e)){let o=n.string;e.forEach((s,a)=>{n.string=y.isArray(o)?o[a]:o,this.getMeasure().addNoteGroup(t,[s],r,n)})}else this.getMeasure().addNoteGroup(t,[e],r,n);return this}addChord(t,e,r,n){return gt("addChord",t,e,r,n),ht(Qe(t),y.isNonEmptyArray(e)&&e.every(o=>o instanceof U||y.isNonEmptyString(o)),nr(r)),n!=null||(n={}),bc(n),this.getMeasure().addNoteGroup(t,e,r,n),this}addRest(t,e,r){return gt("addRest",t,e,r),ht(Qe(t),nr(e)),r!=null||(r={}),pg(r),this.getMeasure().addRest(t,e,r),this}addTuplet(t,e,r){gt("addTuplet",t,e),ht(Qe(t),y.isFunction(r),Qs(e)&&y.isBooleanOrUndefined(e.showRatio));let n=[],o={addNote:(s,a,c)=>{if(gt("addTuplet => addNote",s,a,c),ht(s instanceof U||y.isNonEmptyString(s)||y.isArray(s)&&s.every(u=>u instanceof U||y.isNonEmptyString(u)),nr(a)),c!=null||(c={}),bc(c),y.isArray(s)){let u=c.string;s.forEach((l,h)=>{c.string=y.isArray(u)?u[h]:u;let p=this.getMeasure().addNoteGroup(t,[l],a,c,e);n.push(p)})}else{let u=this.getMeasure().addNoteGroup(t,[s],a,c,e);n.push(u)}return o},addChord:(s,a,c)=>{gt("addTuplet => addChord",s,a,c),ht(y.isNonEmptyArray(s)&&s.every(l=>l instanceof U||y.isNonEmptyString(l)),nr(a)),c!=null||(c={}),bc(c);let u=this.getMeasure().addNoteGroup(t,s,a,c,e);return n.push(u),o},addRest:(s,a)=>{gt("addTuplet => addRest",s,a),ht(nr(s)),a!=null||(a={}),pg(a);let c=this.getMeasure().addRest(t,s,a,e);return n.push(c),o}};return r(o),Qi.createTuplet(n,e),this}addLyricsInternal(t,e,r,n,o){var s;return Rs(t),ht(Za(e),y.isEnumValue(r,ir),y.isString(n)||y.isArray(n)&&n.every(a=>y.isString(a))),o!=null||(o={}),c0(o),o.align!==void 0?this.currentLyricsAlign=o.align:(s=o.align)!=null||(o.align=this.currentLyricsAlign),y.isArray(n)?n.forEach(a=>this.getMeasure().addLyrics(t,e,r,a,o)):this.getMeasure().addLyrics(t,e,r,n,o),this}addLyrics(t,e,r,n){return gt("addLyrics",t,e,r,n),this.addLyricsInternal(void 0,t,e,r!=null?r:"",n)}addLyricsTo(t,e,r,n,o){return gt("addLyricsTo",e,r,n,o),this.addLyricsInternal(t,e,r,n!=null?n:"",o)}addFermataInternal(t,e){return Rs(t),ht(y.isEnumValue(e,zo)),this.getMeasure().addFermata(t,e),this}addFermata(t="atNote"){return gt("addFermata",t),this.addFermataInternal(void 0,t)}addFermataTo(t,e="atNote"){return gt("addFermataTo",t,e),this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return Rs(t),ht(y.isStrictEqual(e,"endRepeat")&&y.isStrictEqual(r.length,1)||y.isStrictEqual(e,"ending")&&y.isIntegerGte(r.length,1)&&r.every(n=>y.isIntegerGte(n,1))||y.isEnumValue(e,br)&&y.isEmptyArray(r)),this.getMeasure().addNavigation(t,e,...r),this}addNavigation(t,...e){return gt("addNavigation",t,...e),this.addNavigationInternal(void 0,t,...e)}addNavigationTo(t,e,...r){return gt("addNavigationTo",t,e,...r),this.addNavigationInternal(t,e,...r)}addAnnotationInternal(t,e,r){if(e!=null||(e=sg(r)),e===void 0)throw new N(6,`Annotation text "${r}" is not known annotation.`);return Rs(t),ht(y.isEnumValue(e,$n),y.isNonEmptyString(r)),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(...t){return gt("addAnnotation",...t),t.length===1?this.addAnnotationInternal(void 0,void 0,t[0]):this.addAnnotationInternal(void 0,t[0],t[1])}addAnnotationTo(t,...e){return gt("addAnnotationTo",t,...e),e.length===1?this.addAnnotationInternal(t,void 0,e[0]):this.addAnnotationInternal(t,e[0],e[1])}addLabelInternal(t,e,r){return Rs(t),ht(y.isEnumValue(e,$o),y.isNonEmptyString(r)),this.getMeasure().addLabel(t,e,r),this}addLabel(t,e){return gt("addLabel",t,e),this.addLabelInternal(void 0,t,e)}addLabelTo(t,e,r){return gt("addLabelTo",t,e,r),this.addLabelInternal(t,e,r)}addConnective(t,...e){if(gt("addConnective",t,...e),ht(y.isEnumValue(t,yi)),t==="tie"){ht(y.isIntegerOrUndefined(e[0])||y.isEnumValue(e[0],yr)),ht(y.isEnumValueOrUndefined(e[1],Ke));let r=e[0],n=e[1];this.getMeasure().addConnective(t,r,n)}else if(t==="slur"){ht(y.isIntegerOrUndefined(e[0])),ht(y.isEnumValueOrUndefined(e[1],Ke));let r=e[0],n=e[1];this.getMeasure().addConnective(t,r,n)}else if(t==="slide"){ht(y.isEnumValueOrUndefined(e[0],Ke));let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t){gt("addExtension"),fg(y.isFunctionOrUndefined(t),"addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");let e=0,r=!0,n={notes:(o,s)=>(gt("addExtension.notes",o,s),ht(nr(o)),ht(y.isUndefined(s)||y.isNumber(s)&&s>=0),e+=Qt.get(o).ticks*(s!=null?s:1),n),measures:o=>(gt("addExtension.measures",o),ht(y.isNumber(o)&&o>=1),e+=this.getMeasure().getMeasureTicks()*o,n),infinity:()=>(gt("addExtension.infinity"),e=1/0,n),hide:()=>(gt("addExtension.hide"),r=!1,n)};return t?t(n):e=1/0,this.getMeasure().addExtension(e,r),this}addStaffGroup(t,e,r="auto"){return gt("addStaffGroup",t,e,r),ht(y.isNonEmptyString(t),y.isNonEmptyString(e)||y.isIntegerGte(e,0)||y.isNonEmptyArray(e)&&e.every(n=>y.isNonEmptyString(n)||y.isIntegerGte(n,0)),y.isEnumValue(r,Wo)),this.doc.addStaffGroup(t,e,r),this}endSong(){return gt("endSong"),this.getMeasure().endSong(),this}endSection(){return gt("endSection"),this.getMeasure().endSection(),this}endRow(){var t;return gt("endRow"),(t=this.doc.getLastMeasure())==null||t.endRow(),this}fillWithRests(...t){return gt("fillWithRests",...t),ht(y.isArray(t)&&(t.length===0||t.every(e=>Qe(e)))),this.getMeasure().fillWithRests(...t),this}addScaleArpeggio(t,e,r){gt("addScaleArpeggio",t,e,r),ht(y.isNonEmptyString(e),y.isIntegerGte(r,1));let n=this.getMeasure().getTimeSignature(),o=t.getScaleNotes(e,r);for(let s=0;s<o.length;s++){s%n.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,n.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}repeat(t,e){gt("repeat",e),ht(y.isIntegerGte(t,0),y.isFunction(e));for(let r=0;r<t;r++)e(this);return this}};d(xc,"DefaultMeasureOptions",{});var Cr=xc;var Ms=class{constructor(t){this.type=t}},Yi=class extends Ms{constructor(e,r,n,o){super(e);this.renderContext=r;this.scoreRow=n;this.diatonicId=o}},Hi=class extends Ms{constructor(e,r,n){super(e);this.renderContext=r;this.objects=n;if(arguments.length===0)throw new N(6,"Empty array in score object event!")}get topObject(){return this.objects[this.objects.length-1]}findObject(e){return this.objects.find(r=>e(r))}};function kh(i,t,e){if(!i)throw new N(6,`Invalid arg: ${t} = ${e}`)}function Lh(i){if(i instanceof Mt||i instanceof jt)return i.getMusicInterface();throw new N(6,"Notation line not staff nor tab.")}var bt=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},Ac=class Ac extends bt{constructor(e){super(Ac.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};d(Ac,"Name","Accidental");var Xo=Ac,Cc=class Cc extends bt{constructor(e){super(Cc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Cc,"Name","Connective");var Cs=Cc,_c=class _c extends bt{constructor(e){super(_c.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return Lh(this.obj.line)}};d(_c,"Name","Arpeggio");var rs=_c,vc=class vc extends bt{constructor(e){super(vc.Name);this.obj=e}getMusicObject(){return this.obj}};d(vc,"Name","BeamGroup");var ys=vc,wc=class wc extends bt{constructor(e){super(wc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(wc,"Name","StaffBeamGroup");var bs=wc,Sc=class Sc extends bt{constructor(e){super(Sc.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}getRows(){return this.obj.getRows().map(e=>e.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}play(e){return kh(y.isFunctionOrUndefined(e),"playStateChangeListener",e),new to(this,e).play()}};d(Sc,"Name","Document");var Xr=Sc,Ic=class Ic extends bt{constructor(e){super(Ic.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return kh(y.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};d(Ic,"Name","Ending");var fs=Ic,Tc=class Tc extends bt{constructor(e){super(Tc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Tc,"Name","Fermata");var xs=Tc,Nc=class Nc extends bt{constructor(e){super(Nc.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};d(Nc,"Name","Header");var Os=Nc,Oc=class Oc extends bt{constructor(e){super(Oc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Oc,"Name","Image");var Zo=Oc,Rc=class Rc extends bt{constructor(e){super(Rc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};d(Rc,"Name","Measure");var ws=Rc,Mc=class Mc extends bt{constructor(e){super(Mc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Mc,"Name","BarLineRight");var ds=Mc,Ec=class Ec extends bt{constructor(e){super(Ec.Name);this.obj=e}getMusicObject(){return this.obj}};d(Ec,"Name","BarLineLeft");var ps=Ec,Dc=class Dc extends bt{constructor(e){super(Dc.Name);this.obj=e}getMusicObject(){return this.obj}getBarLine(){let e=this.obj.barLine;if(e instanceof xi||e instanceof Ar)return e.getMusicInterface();throw new N(6,"Bar line not left nor right.")}getNotationLine(){return Lh(this.obj.line)}};d(Dc,"Name","StaffBarLine");var ms=Dc,kc=class kc extends bt{constructor(e){super(kc.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(kc,"Name","NoteGroup");var os=kc,Lc=class Lc extends bt{constructor(e){super(Lc.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Lc,"Name","StaffNoteGroup");var ss=Lc,jc=class jc extends bt{constructor(e){super(jc.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getTab(){return this.obj.tab.getMusicInterface()}};d(jc,"Name","TabNoteGroup");var as=jc,Pc=class Pc extends bt{constructor(e){super(Pc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Pc,"Name","Rest");var is=Pc,Fc=class Fc extends bt{constructor(e){super(Fc.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}getRhythmColumn(){return this.getRest().getRhythmColumn()}getMeasure(){return this.getRest().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Fc,"Name","StaffRest");var ns=Fc,Bc=class Bc extends bt{constructor(e){super(Bc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return kh(Qe(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Bc,"Name","RhythmColumn");var cs=Bc,Gc=class Gc extends bt{constructor(e){super(Gc.Name);this.obj=e}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(e=>Lh(e))}};d(Gc,"Name","ScoreRow");var Ns=Gc,Vc=class Vc extends bt{constructor(e){super(Vc.Name);this.obj=e}getMusicObject(){return this.obj}getInstrument(){return this.obj.instrument}};d(Vc,"Name","ScoreRowGroup");var Ts=Vc,qc=class qc extends bt{constructor(e){super(qc.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(qc,"Name","Staff");var Ss=qc,Wc=class Wc extends bt{constructor(e){super(Wc.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Wc,"Name","Tab");var Is=Wc,Uc=class Uc extends bt{constructor(e){super(Uc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(Uc,"Name","StaffSignature");var ts=Uc,zc=class zc extends bt{constructor(e){super(zc.Name);this.obj=e}getMusicObject(){return this.obj}getTab(){return this.obj.tab.getMusicInterface()}};d(zc,"Name","TabSignature");var es=zc,Yc=class Yc extends bt{constructor(e){super(Yc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasure(){return this.obj.measure.getMusicInterface()}getTab(){return this.obj.tab.getMusicInterface()}};d(Yc,"Name","TabRhythm");var vs=Yc,Hc=class Hc extends bt{constructor(e){super(Hc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Hc,"Name","SpecialText");var us=Hc,$c=class $c extends bt{constructor(e){super($c.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d($c,"Name","Text");var Qo=$c,Zc=class Zc extends bt{constructor(e){super(Zc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Zc,"Name","Lyrics");var _s=Zc,Xc=class Xc extends bt{constructor(e){super(Xc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Xc,"Name","ExtensionLine");var As=Xc;var Qc;(function(i){i.AliceBlue="aliceblue",i.AntiqueWhite="antiquewhite",i.Aqua="aqua",i.Aquamarine="aquamarine",i.Azure="azure",i.Beige="beige",i.Bisque="bisque",i.Black="black",i.BlanchedAlmond="blanchedalmond",i.Blue="blue",i.BlueViolet="blueviolet",i.Brown="brown",i.BurlyWood="burlywood",i.CadetBlue="cadetblue",i.Chartreuse="chartreuse",i.Chocolate="chocolate",i.Coral="coral",i.CornflowerBlue="cornflowerblue",i.CornSilk="cornsilk",i.Crimson="crimson",i.Cyan="cyan",i.DarkBlue="darkblue",i.DarkCyan="darkcyan",i.DarkGoldenRod="darkgoldenrod",i.DarkGray="darkgray",i.DarkGreen="darkgreen",i.DarkGrey="darkgrey",i.DarkKhaki="darkkhaki",i.DarkMagenta="darkmagenta",i.DarkOliveGreen="darkolivegreen",i.DarkOrange="darkorange",i.DarkOrchid="darkorchid",i.DarkRed="darkred",i.DarkSalmon="darksalmon",i.DarkSeaGreen="darkseagreen",i.DarkSlateBlue="darkslateblue",i.DarkSlateGray="darkslategray",i.DarkSlateGrey="darkslategrey",i.DarkTurquoise="darkturquoise",i.DarkViolet="darkviolet",i.DeepPink="deeppink",i.DeepSkyBlue="deepskyblue",i.DimGray="dimgray",i.DimGrey="dimgrey",i.DodgerBlue="dodgerblue",i.FireBrick="firebrick",i.FloralWhite="floralwhite",i.ForestGreen="forestgreen",i.Fuchsia="fuchsia",i.Gainsboro="gainsboro",i.GhostWhite="ghostwhite",i.Gold="gold",i.GoldenRod="goldenrod",i.Gray="gray",i.Green="green",i.GreenYellow="greenyellow",i.Grey="grey",i.Honeydew="honeydew",i.HotPink="hotpink",i.IndianRed="indianred",i.Indigo="indigo",i.Ivory="ivory",i.Khaki="khaki",i.Lavender="lavender",i.LavenderBlush="lavenderblush",i.LawnGreen="lawngreen",i.LemonChiffon="lemonchiffon",i.LightBlue="lightblue",i.LightCoral="lightcoral",i.LightCyan="lightcyan",i.LightGoldenRodYellow="lightgoldenrodyellow",i.LightGray="lightgray",i.LightGreen="lightgreen",i.LightGrey="lightgrey",i.LightPink="lightpink",i.LightSalmon="lightsalmon",i.LightSeaGreen="lightseagreen",i.LightSkyBlue="lightskyblue",i.LightSlateGray="lightslategray",i.LightSlateGrey="lightslategrey",i.LightSteelBlue="lightsteelblue",i.LightYellow="lightyellow",i.Lime="lime",i.LimeGreen="limegreen",i.Linen="linen",i.Magenta="magenta",i.Maroon="maroon",i.MediumAquamarine="mediumaquamarine",i.MediumBlue="mediumblue",i.MediumOrchid="mediumorchid",i.MediumPurple="mediumpurple",i.MediumSeaGreen="mediumseagreen",i.MediumSlateBlue="mediumslateblue",i.MediumSpringGreen="mediumspringgreen",i.MediumTurquoise="mediumturquoise",i.MediumVioletRed="mediumvioletred",i.MidnightBlue="midnightblue",i.MintCream="mintcream",i.MistyRose="mistyrose",i.Moccasin="moccasin",i.NavajoWhite="navajowhite",i.Navy="navy",i.OldLace="oldlace",i.Olive="olive",i.OliveDrab="olivedrab",i.Orange="orange",i.OrangeRed="orangered",i.Orchid="orchid",i.PaleGoldenRod="palegoldenrod",i.PaleGreen="palegreen",i.PaleTurquoise="paleturquoise",i.PaleVioletRed="palevioletred",i.PapayaWhip="papayawhip",i.PeachPuff="peachpuff",i.Peru="peru",i.Pink="pink",i.Plum="plum",i.PowderBlue="powderblue",i.Purple="purple",i.RebeccaPurple="rebeccapurple",i.Red="red",i.RosyBrown="rosybrown",i.RoyalBlue="royalblue",i.SaddleBrown="saddlebrown",i.Salmon="salmon",i.SandyBrown="sandybrown",i.SeaGreen="seagreen",i.SeaShell="seashell",i.Sienna="sienna",i.Silver="silver",i.SkyBlue="skyblue",i.SlateBlue="slateblue",i.SlateGray="slategray",i.SlateGrey="slategrey",i.Snow="snow",i.SpringGreen="springgreen",i.SteelBlue="steelblue",i.Tan="tan",i.Teal="teal",i.Thistle="thistle",i.Tomato="tomato",i.Turquoise="turquoise",i.Violet="violet",i.Wheat="wheat",i.White="white",i.WhiteSmoke="whitesmoke",i.Yellow="yellow",i.YellowGreen="yellowgreen"})(Qc=Qc||(Qc={}));var vi;(function(i){i.Hex="hex",i.RGB="rgb",i.Array="array"})(vi=vi||(vi={}));var jh={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(let i in jh)Object.freeze(jh[i]);var yg=Object.freeze(jh);var Ph=yg;var Fh={hash:!0,lowercase:!1,short:!1};function Bh(i,t){let e=O(O({},Fh),t),{hash:r,lowercase:n,short:o}=e,s=i.map(a=>{let c=a.toString(16);return c=c.length===1?`0${c}`:c,c}).join("");if(o){let a=[...s];a[0]===a[1]&&a[2]===a[3]&&a[4]===a[5]&&(s=`${a[0]}${a[2]}${a[4]}`)}return s=n?s.toLowerCase():s.toUpperCase(),r&&(s=`#${s}`),s}function Gh(i,t=1){return t=Math.min(1,Math.max(0,t)),t<1?`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${t})`:`rgb(${i[0]}, ${i[1]}, ${i[2]})`}var h0=X(O({},Fh),{fallback:!0,alpha:1,format:vi.Hex});function Kc(i,t={}){let e=O(O({},h0),t),{fallback:r,format:n,hash:o,lowercase:s,short:a,alpha:c}=e;i=`${i}`;let u=i.toLowerCase().replaceAll(/[^a-z]/g,""),l=Ph[u];if(!l){if(!r)throw new Error(`no matching color found for '${i}'`);let h=i.toLowerCase().replaceAll(/[^\da-f]/g,"");l=(h.length<=3?[h.slice(0,1).repeat(2),h.slice(1,2).repeat(2),h.slice(2,3).repeat(2)]:[h.slice(0,2),h.slice(2,4),h.slice(4,6)]).map(p=>Number.parseInt(p.length<2?`${"0".repeat(2-p.length)}${p}`:p,16))}switch(n){case vi.Array:return[...l];case vi.RGB:return Gh(l,c);default:return Bh(l,{hash:o,lowercase:s,short:a})}}var Jc=i=>i.toLowerCase();function xr(i){return i}var eo=class eo{constructor(){d(this,"colors",{"hilight.staffpos":"#55cc55","hilight.object":"#55cc55","play.cursor":"#44aa44",background:"white","header.title":"black","header.composer":"black","header.arranger":"black","rowgroup.instrument":"black","rowgroup.frame":"black","staff.frame":"black","staff.note":"black","staff.rest":"black","staff.lyrics":"black","staff.connective":"black","staff.signature.clef":"black","staff.signature.key":"black","staff.signature.time":"black","staff.signature.tempo":"black","staff.signature.measurenum":"black","staff.element.fermata":"black","staff.element.annotation":"black","staff.element.navigation":"black","staff.element.label":"black","tab.frame":"black","tab.note":"black","tab.rest":"black","tab.lyrics":"black","tab.connective":"black","tab.tuning":"black","tab.signature.clef":"black","tab.signature.key":"black","tab.signature.time":"black","tab.signature.tempo":"black","tab.signature.measurenum":"black","tab.element.fermata":"black","tab.element.annotation":"black","tab.element.navigation":"black","tab.element.label":"black"})}setColor(t,e){if(t==="all"){for(let c of Object.keys(this.colors))c!=="background"&&c!=="hilight.object"&&c!=="hilight.staffpos"&&c!=="play.cursor"&&(this.colors[c]=e||"black");return}let r=typeof t=="string"&&Jc(t)==="background"||y.isArray(t)&&t.length===1&&Jc(t[0])==="background",n=e||(r?"white":"black");if(r){this.colors.background=n;return}if(typeof t=="string"&&t in this.colors){this.colors[t]=n;return}let o=y.isArray(t)?t:t.split(".");if(o.length===0)return;let s=o.map(Jc),a=!1;for(let c of Object.keys(this.colors)){let u=c.split(".").map(Jc);s.every(h=>u.includes(h))&&(this.colors[c]=n,a=!0)}a||console.error(`Color attrs ${H.Str.stringify(o)} did not match any color.`)}getColor(t){var e;return(e=this.colors[t])!=null?e:t}getColorCode(t){return eo.colorNameToCode(this.getColor(t))}getColorRGBA(t){return eo.colorNameToRGBA(this.getColor(t))}static colorNameToCode(t){return Kc(t)}static colorNameToRGBA(t,e=1){let r=Kc(t).replace("#",""),n=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),s=parseInt(r.slice(4,6),16),a=Math.round(e*255);return[n,o,s,a]}};d(eo,"default",new eo);var Zr=eo;function Je(i,t,e){if(!i)throw new N(6,`Invalid arg: ${t} = ${e}`)}function Es(i,t){if(i==null)throw new TypeError(t);return i}var Ds=class Ds{constructor(t,e){d(this,"player");Je(t instanceof Xr,"doc",t),Je(y.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new oc,this.player.setDocument(t.getMusicObject()),this.player.setCursorPositionChangeListener(r=>{t.getMusicObject().updateCursorRect(r)}),e&&this.player.setPlayStateChnageListener(e)}static stopAll(){this.currentlyPlaying.forEach(t=>t.stop()),Ha()}play(){return Ds.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),Ds.currentlyPlaying.delete(this),this}};d(Ds,"currentlyPlaying",new zs);var to=Ds,Vh=class{constructor(){d(this,"ctx");this.ctx=new Ka(this)}setPaint(t){return Je(y.isUndefined(t)||t instanceof Zr,"paint",t),this.ctx.setPaint(t),this}setDocument(t){return Je(y.isUndefined(t)||t instanceof Xr,"doc",t),this.ctx.setDocument(t),this}setCanvas(t){return t=Es(H.Dom.getCanvas(t),typeof t=="string"?"Cannot set render canvas because invalid canvas id: "+t:"Cannot set render canvas because given canvas is undefined."),this.ctx.setCanvas(t),this}setScoreEventListener(t){Je(y.isFunctionOrUndefined(t),"scoreEventListener",t),this.ctx.setScoreEventListener(t)}hilightObject(t){this.ctx.hilightObject(t==null?void 0:t.getMusicObject())}hilightStaffPos(t){this.ctx.hilightStaffPos(t?{scoreRow:t.scoreRow.getMusicObject(),diatonicId:t.diatonicId}:void 0)}draw(){try{this.ctx.draw()}catch(t){console.log("Draw failed in music render context!",t)}}},we=class we{constructor(){d(this,"playButton");d(this,"stopButton");d(this,"playStopButton");d(this,"pauseButton");d(this,"onPlay");d(this,"onStop");d(this,"onPlayStop");d(this,"onPause");d(this,"playLabel","Play");d(this,"stopLabel","Stop");d(this,"pauseLabel","Pause");d(this,"playState",2);d(this,"player");this.onPlay=()=>{var t;return(t=this.player)==null?void 0:t.play()},this.onStop=()=>{var t;return(t=this.player)==null?void 0:t.stop()},this.onPlayStop=()=>{var t,e;this.playState===0?(t=this.player)==null||t.stop():(e=this.player)==null||e.play()},this.onPause=()=>{var t;return(t=this.player)==null?void 0:t.pause()},this.updateButtons()}setDocument(t){return Je(y.isUndefined(t)||t instanceof Xr,"doc",t),this.onStop(),t?this.player=new to(t,e=>{this.playState=e,this.updateButtons()}):this.player=void 0,this.updateButtons(),this}detachDocument(){this.setDocument(void 0)}updateButtons(){this.playButton&&(this.playButton.disabled=this.player?this.playState===0:!0,this.playButton.innerText=this.playLabel),this.stopButton&&(this.stopButton.disabled=this.player?this.playState===2:!0,this.stopButton.innerText=this.stopLabel),this.playStopButton&&(this.playStopButton.disabled=!this.player,this.playStopButton.innerText=this.playState===0?this.stopLabel:this.playLabel),this.pauseButton&&(this.pauseButton.disabled=this.player?this.playState!==0:!0,this.pauseButton.innerText=this.pauseLabel)}setPlayButton(t,e){return Je(y.isStringOrUndefined(e),"btnLabel",e),we.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=Es(H.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",we.removeOnClickListeners(this.playButton,"all"),we.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return Je(y.isStringOrUndefined(e),"btnLabel",e),we.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=Es(H.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",we.removeOnClickListeners(this.stopButton,"all"),we.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return Je(y.isStringOrUndefined(e),"playLabel",e),Je(y.isStringOrUndefined(r),"stopLabel",r),we.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=Es(H.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",we.removeOnClickListeners(this.playStopButton,"all"),we.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return Je(y.isStringOrUndefined(e),"btnLabel",e),we.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=Es(H.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",we.removeOnClickListeners(this.pauseButton,"all"),we.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(!t)return;let r=this.savedOnClickListeners.getOrDefault(t,[]);r=r.filter(n=>e===n||e==="all"?(t.removeEventListener("click",n),!1):!0),this.savedOnClickListeners.set(t,r)}static addOnClickListener(t,e){Je(y.isFunction(e),"onClick",e),t.addEventListener("click",e),this.savedOnClickListeners.getOrCreate(t,[]).push(e)}};d(we,"savedOnClickListeners",new lt);var qh=we;Ti();var $h={};rn($h,{createAll:()=>l0,createAndanteByDiabelli:()=>Uh,createCanonInD:()=>zh,createFrereJacques:()=>Yh,createGreensleeves:()=>Hh});function Uh(){return new Cr().setScoreConfiguration("guitarTreble").setHeader("Andante","A. Diabelli").addMeasure().setKeySignature("D","Major").setTimeSignature("3/4").setTempo(80).addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n",{stem:"up"}).addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.",{stem:"down"}).addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").endRow().addMeasure().addNote(0,"D4","8n",{string:3}).addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","8n").addNote(0,"A4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n").addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.").addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).addNavigation("endRepeat").addMeasure().addRest(0,"8n",{staffPos:"D4"}).addAnnotation("dynamics","f").addNote(0,"D4","8n").addNote(0,"E4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"B3","8n").addNote(1,"E2","2.").endRow().addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"E4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","p").addNote(0,"E3","8n").addNote(0,"D#3","8n").addConnective("slur",2,"below").addNote(0,"E3","8n").addNote(0,"F#3","8n").addNote(0,"G#3","8n").addNote(1,"E2","2.").addMeasure().addNote(0,"A3","8n").addConnective("slur",2,"below").addNote(0,"G#3","8n").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","f").addNote(0,"G4","8n").addNote(0,"A4","8n").addConnective("slur",2,"below").addNote(0,"G4","8n").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","ff").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).endSong().getDocument()}function zh(){return new Cr().setHeader("Canon in D","Pachelbel").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0,instrument:"Piano"},{type:"staff",clef:"F",voiceId:1,instrument:"Piano"}]).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").setTempo(50,"2n").fillWithRests(0).addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).fillWithRests(0).addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().fillWithRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).fillWithRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["F#5","E5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","C#5"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().addNote(0,["B4","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addNote(0,["B4","C#5"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addChord(0,["F#5","D5"],"2n").addChord(0,["E5","C#5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).addChord(0,["D5","B4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").endRow().addMeasure({showNumber:!1}).addChord(0,["B4","G4"],"2n").addChord(0,["A4","F#4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addChord(0,["B4","G4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["D4","F#4","A4","G4"],"4n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","D4","F#4","E4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","D4","A4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","B4","A4","G4"],"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["F#4","D4","E4","C#5"],"4n").addNote(1,["D3","A2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","F#5","A5","A4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B4","G4","A4","F#4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5"],"4n").addRest(0,"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D5","C#5","D5","D4"],"8n").addNote(0,["C#4","A4","E4","F#4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5","B4"],"8n").addNote(0,["C#5","F#5","A5","B5"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["G5","F#5","E5","G5"],"8n").addNote(0,["F#5","E5","D5","C#5"],"8n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["B4","A4","G4","F#4"],"8n").addNote(0,["E4","G4","F#4","E4"],"8n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D4","E4","F#4","G4"],"8n").addNote(0,["A4","E4","A4","G4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","B4","A4","G4"],"8n").addNote(0,["A4","G4","F#4","E4"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","B4","C#5"],"8n").addNote(0,["D5","C#5","B4","A4"],"8n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","F#4","E4","B4"],"8n").addNote(0,["A4","B4","A4","G4"],"8n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"F#4","4n").addNote(0,"F#5","4n").addNote(0,"E5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(0,"F#5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B5","A5"],"2n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["B5","C#6"],"2n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D6","D5"],"4n").addNote(0,"C#5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"B4","4n").addNote(0,"D5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"D5","2n").addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","F#5","E5","A5"],"4n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,["A5","A4","B4","C#5"],"16n").addNote(0,["D5","E5","F#5","G5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["F#4","G4"],"16n").addNote(0,["A4","B4","A4","G4"],"16n").addNote(0,["A4","F#4","G4","A4"],"16n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"G4","8n").addNote(0,["F#4","E4"],"16n").addNote(0,["F#4","E4","D4","E4"],"16n").addNote(0,["F#4","G4","A4","B4"],"16n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"B4","8n").addNote(0,["C#5","D5"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(0,["E5","F#5","G5","A5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["E5","D5"],"16n").addNote(0,["E5","C#5","D5","E5"],"16n").addNote(0,["F#5","E5","D5","C#5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"D5","8n").addNote(0,["B4","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["D4","E4"],"16n").addNote(0,["F#4","G4","F#4","E4"],"16n").addNote(0,["F#4","D5","C#5","D5"],"16n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"B4","8n").addNote(0,["A4","G4"],"16n").addNote(0,["A4","G4","F#4","G4"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["C#5","B4"],"16n").addNote(0,["C#5","D5","E5","D5"],"16n").addNote(0,["C#5","D5","B4","C#5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNavigation("startRepeat").addNote(0,"D5","4.").addNote(0,"A5","8n").addNote(0,["A5","B5","A5","G5"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","4.").addNote(0,"F#5","8n").addNote(0,["F#5","G5","F#5","E5"],"8n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"D5","4.").addNote(0,"D5","8n").addNote(0,["D5","A5"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","C5","B5","C5"],"8n").addNote(0,"C#5","2n").addNote(1,["G2","A2"],"2n").addNavigation("endRepeat").addMeasure().addNote(0,"D5","1n").addNote(1,"D3","1n").getDocument()}function Yh(){return new Cr().setHeader("Fr\xE8re Jacques","Traditional").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0,instrument:"!{Piano"},{type:"staff",clef:"F",voiceId:1,instrument:"!{Piano"}]).setMeasuresPerRow(2).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").addNote(0,"D4","4n",{stem:"up"}).addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addRest(1,"1n",{staffPos:"F3"}).addMeasure().addNote(0,"D4","4n").addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addRest(1,"1n",{staffPos:"F3"}).addMeasure().addNavigation("startRepeat").addNote(0,"F#4","4n").addLyrics(1,"4n","Bro",{hyphen:"-"}).addNote(0,"G4","4n").addLyrics(1,"4n","ther").addNote(0,"A4","2n").addLyrics(1,"4n","John?").addNote(1,"D3","4n",{stem:"down"}).addLyricsTo(1,1,"4n","Are").addNote(1,"E3","4n").addLyricsTo(1,1,"4n","you").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","sleep",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing?").addMeasure().addNote(0,"F#4","4n").addLyrics(1,"4n","Bro",{hyphen:"-"}).addNote(0,"G4","4n").addLyrics(1,"4n","ther").addNote(0,"A4","2n").addLyrics(1,"4n","John?").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","Are").addNote(1,"E3","4n").addLyricsTo(1,1,"4n","you").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","sleep",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing?").addMeasure().addNote(0,"A4","8n").addLyrics(1,"8n","Morn",{hyphen:"-"}).addNote(0,"B4","8n").addLyrics(1,"8n","ing").addNote(0,"A4","8n").addLyrics(1,"8n","bells").addNote(0,"G4","8n").addLyrics(1,"8n","are").addNote(0,"F#4","4n").addLyrics(1,"4n","ring",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing!").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","Bro",{hyphen:"-"}).addNote(1,"G3","4n").addLyricsTo(1,1,"4n","ther").addNote(1,"A3","2n").addLyricsTo(1,1,"2n","John?").addMeasure().addNote(0,"A4","8n").addLyrics(1,"8n","Morn",{hyphen:"-"}).addNote(0,"B4","8n").addLyrics(1,"8n","ing").addNote(0,"A4","8n").addLyrics(1,"8n","bells").addNote(0,"G4","8n").addLyrics(1,"8n","are").addNote(0,"F#4","4n").addLyrics(1,"4n","ring",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing!").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","Bro",{hyphen:"-"}).addNote(1,"G3","4n").addLyricsTo(1,1,"4n","ther").addNote(1,"A3","2n").addLyricsTo(1,1,"2n","John?").addMeasure().addNote(0,"D4","4n").addLyrics(1,"4n","Ding").addChord(0,["C#4","A4"],"4n").addLyrics(1,"4n","ding").addNote(0,"D4","4n").addLyrics(1,"4n","dong!").addRest(0,"4n").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","Morn",{hyphen:"-"}).addNote(1,"B3","8n").addLyricsTo(1,1,"8n","ing").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","bells").addNote(1,"G3","8n").addLyricsTo(1,1,"8n","are").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","ring",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing!").addMeasure().addNote(0,"D4","4n").addLyrics(1,"4n","Ding").addChord(0,["C#4","A4"],"4n").addLyrics(1,"4n","ding").addNote(0,"D4","4n").addLyrics(1,"4n","dong!").addRest(0,"4n").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","Morn",{hyphen:"-"}).addNote(1,"B3","8n").addLyricsTo(1,1,"8n","ing").addNote(1,"A3","8n").addLyricsTo(1,1,"8n","bells").addNote(1,"G3","8n").addLyricsTo(1,1,"8n","are").addNote(1,"F#3","4n").addLyricsTo(1,1,"4n","ring",{hyphen:"-"}).addNote(1,"D3","4n").addLyricsTo(1,1,"4n","ing!").addMeasure().setMeasuresPerRow(4).addNote(0,"D4","4n").addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","Ding").addChord(1,["C#3","A3"],"4n").addLyricsTo(1,1,"4n","ding").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","dong!").addRest(1,"4n").addMeasure().addNavigation("endRepeat").addNote(0,"D4","4n").addLyrics(1,"4n","Are").addNote(0,"E4","4n").addLyrics(1,"4n","you").addNote(0,"F#4","4n").addLyrics(1,"4n","sleep",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ing?").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","Ding").addChord(1,["C#3","A3"],"4n").addLyricsTo(1,1,"4n","ding").addNote(1,"D3","4n").addLyricsTo(1,1,"4n","dong!").addRest(1,"4n").addMeasure().addNote(0,"F#4","4n").addLyrics(1,"4n","YES").addNote(0,"D4","4n").addLyrics(1,"4n","I'm").addNote(0,"F#4","4n").addLyrics(1,"4n","SLEEP",{hyphen:"-"}).addNote(0,"D4","4n").addLyrics(1,"4n","ING").addNote(1,"A3","4n").addNote(1,"F#3","4n").addNote(1,"A3","4n").addNote(1,"F#3","4n").addMeasure().addNote(0,"A3","4n").addLyrics(1,"4n","Please").addNote(0,"C#4","8n").addLyrics(1,"8n","GO").addNote(0,"C#4","8n").addLyrics(1,"8n","A",{hyphen:"-"}).addNote(0,"D4","2n").addLyrics(1,"4n","WAY!").addNote(1,"D3","4n").addNote(1,"E3","4n").addNote(1,"F#3","2n").getDocument()}function Hh(){return new Cr().setScoreConfiguration("guitarTreble").setHeader("Greensleeves").addMeasure().setKeySignature("C","Major").setTimeSignature("6/8").setTempo(140).addNote(0,"A3","8n").addMeasure().addNavigation("startRepeat").addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4n").addNote(0,"A3","8n").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").endRow().addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").endRow().addMeasure().addChord(0,["C3","E3","G3","C4","G4"],"4.",{arpeggio:"up",stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addRest(1,"4.",{hide:!0}).addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4.").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","8n").addNote(1,"E3","8n").endRow().addMeasure().addNote(0,"G4","4.",{stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","8n").addNote(1,"C4","8n").addNote(1,"C3","8n").addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNavigation("ending",1).addNavigation("endRepeat").addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").addMeasure().addNavigation("ending",2).addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addFermata().addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").getDocument()}function l0(){return[Uh(),zh(),Yh(),Hh()]}return Ig(d0);})();
291
291
  /*! Bundled license information:
292
292
 
293
293
  @tspro/ts-utils-lib/dist/index.mjs: