@tspro/web-music-score 5.1.0 → 5.2.0

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 (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +4 -4
  3. package/dist/audio/index.d.ts +1 -1
  4. package/dist/audio/index.js +2 -2
  5. package/dist/audio/index.mjs +4 -4
  6. package/dist/audio-cg/index.js +1 -1
  7. package/dist/audio-cg/index.mjs +3 -3
  8. package/dist/audio-synth/index.js +1 -1
  9. package/dist/audio-synth/index.mjs +3 -3
  10. package/dist/{chunk-ROPTZBKD.mjs → chunk-6S5BDSCM.mjs} +2 -2
  11. package/dist/{chunk-2EQHSQWO.mjs → chunk-LC5JMIVF.mjs} +2 -2
  12. package/dist/{chunk-QVYFIK3L.mjs → chunk-XUGM7SCC.mjs} +3 -3
  13. package/dist/core/index.js +2 -2
  14. package/dist/core/index.mjs +3 -3
  15. package/dist/{guitar-CaZJDA05.d.ts → guitar-BsSayRsH.d.ts} +1 -1
  16. package/dist/iife/audio-cg.global.js +9 -2
  17. package/dist/iife/index.global.js +11 -11
  18. package/dist/{music-objects-DTDFSro0.d.mts → music-objects-CB05XryE.d.mts} +3 -9
  19. package/dist/{music-objects-CMdYZeC6.d.ts → music-objects-CwPOlqFi.d.ts} +5 -11
  20. package/dist/{note-eA2xPPiG.d.ts → note-CgCIBwvR.d.ts} +1 -1
  21. package/dist/pieces/index.d.mts +1 -1
  22. package/dist/pieces/index.d.ts +3 -3
  23. package/dist/pieces/index.js +1 -1
  24. package/dist/pieces/index.mjs +2 -2
  25. package/dist/react-ui/index.d.mts +1 -1
  26. package/dist/react-ui/index.d.ts +5 -5
  27. package/dist/react-ui/index.js +1 -1
  28. package/dist/react-ui/index.mjs +2 -2
  29. package/dist/{scale-DGx3tJH4.d.ts → scale-CBW4eTz7.d.ts} +2 -2
  30. package/dist/score/index.d.mts +2 -2
  31. package/dist/score/index.d.ts +5 -5
  32. package/dist/score/index.js +153 -88
  33. package/dist/score/index.mjs +155 -90
  34. package/dist/{tempo-GrstpD9G.d.ts → tempo-DMt3iwz9.d.ts} +1 -1
  35. package/dist/theory/index.d.ts +6 -6
  36. package/dist/theory/index.js +1 -1
  37. package/dist/theory/index.mjs +3 -3
  38. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
- "use strict";var WebMusicScore=(()=>{var ns=Object.defineProperty,Jm=Object.defineProperties,$m=Object.getOwnPropertyDescriptor,tf=Object.getOwnPropertyDescriptors,ef=Object.getOwnPropertyNames,is=Object.getOwnPropertySymbols;var lc=Object.prototype.hasOwnProperty,Wu=Object.prototype.propertyIsEnumerable;var Uu=Math.pow,uc=(n,e,t)=>e in n?ns(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))lc.call(e,t)&&uc(n,t,e[t]);if(is)for(var t of is(e))Wu.call(e,t)&&uc(n,t,e[t]);return n},X=(n,e)=>Jm(n,tf(e));var Mr=(n,e)=>{var t={};for(var r in n)lc.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&is)for(var r of is(n))e.indexOf(r)<0&&Wu.call(n,r)&&(t[r]=n[r]);return t};var Oi=(n,e)=>{for(var t in e)ns(n,t,{get:e[t],enumerable:!0})},rf=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ef(e))!lc.call(n,i)&&i!==t&&ns(n,i,{get:()=>e[i],enumerable:!(r=$m(e,i))||r.enumerable});return n};var nf=n=>rf(ns({},"__esModule",{value:!0}),n);var p=(n,e,t)=>uc(n,typeof e!="symbol"?e+"":e,t);var K=(n,e,t)=>new Promise((r,i)=>{var o=c=>{try{a(t.next(c))}catch(u){i(u)}},s=c=>{try{a(t.throw(c))}catch(u){i(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((t=t.apply(n,e)).next())});var uA={};Oi(uA,{Audio:()=>mo,Core:()=>gc,Pieces:()=>qu,Score:()=>Gu,Theory:()=>wc});var mo={};Oi(mo,{addInstrument:()=>Tx,getCurrentInstrument:()=>wx,getInstrumentList:()=>Sx,isMuted:()=>Rx,linearToDecibels:()=>ms,mute:()=>Nx,playNote:()=>oa,stop:()=>sa,unmute:()=>Ox,useInstrument:()=>Fm});var wc={};Oi(wc,{AccidentalType:()=>bc,BeamGrouping:()=>ii,Chord:()=>xc,DefaultGuitarNoteLabel:()=>jg,DefaultHandedness:()=>cy,DefaultPitchNotation:()=>kg,DefaultTuningName:()=>ly,GuitarNoteLabel:()=>ss,GuitarNoteLabelList:()=>Pg,Handedness:()=>Cc,Interval:()=>Bn,KeySignature:()=>Fe,Mode:()=>yc,Note:()=>U,NoteLength:()=>Zt,NoteLengthProps:()=>_t,PitchNotation:()=>Er,PitchNotationList:()=>Eg,RhythmProps:()=>Gt,Scale:()=>Lr,ScaleFactory:()=>Ht,ScaleType:()=>ei,SymbolSet:()=>Dr,TimeSignature:()=>jr,TimeSignatures:()=>qn,TuningNameList:()=>Gn,Tuplet:()=>gr,alterTempoSpeed:()=>Sc,getDefaultKeySignature:()=>as,getDefaultScale:()=>ty,getDefaultTempo:()=>ds,getDefaultTimeSignature:()=>hs,getPitchNotationName:()=>Lg,getScale:()=>mr,getScaleFactory:()=>yl,getScaleFactoryList:()=>Jg,getTempoString:()=>ps,getTuningStrings:()=>us,validateGuitarNoteLabel:()=>Fg,validateHandedness:()=>uy,validateIntervalQuality:()=>Hg,validateNoteLength:()=>Ae,validatePitchNotation:()=>cl,validateScaleType:()=>Vn,validateTuningName:()=>_c,validateTupletRatio:()=>ls});var Yu=Object.defineProperty,of=(n,e,t)=>e in n?Yu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,pr=(n,e)=>{for(var t in e)Yu(n,t,{get:e[t],enumerable:!0})},er=(n,e,t)=>of(n,typeof e!="symbol"?e+"":e,t),A={};pr(A,{Arr:()=>Hu,Dom:()=>Ku,Enum:()=>Ju,Is:()=>$u,Map:()=>el,Math:()=>Zu,Obj:()=>rl,Str:()=>nl});var Hu={};pr(Hu,{arrayContains:()=>vf,chunckArray:()=>If,duplicate:()=>yf,fillArray:()=>Af,getRangeArray:()=>_f,getSequenceArray:()=>Cf,isArray:()=>dc,mapRangeArray:()=>Qu,mapSequenceArray:()=>Xu,removeDuplicates:()=>bf,removeDuplicatesCmp:()=>xf,toArray:()=>gf});var Zu={};pr(Zu,{calcNormal:()=>pf,clamp:()=>df,cmp:()=>ff,interpolateCoord:()=>lf,interpolateY:()=>hf,isInteger:()=>Te,linearToDecibels:()=>sf,mod:()=>af,romanize:()=>cf,sum:()=>mf,toOrdinalNumber:()=>uf});function Te(n){return typeof n=="number"&&isFinite(n)&&n===Math.trunc(n)}function sf(n){if(isFinite(n))return n<=0?-1/0:20*Math.log10(n);throw new Error("linearToDecibel: Invalid linearVolume = "+n)}function af(n,e){return(n%e+e)%e}function cf(n){if(!Te(n)||n<0)throw new Error("romanize: Invalid n = "+n);for(var e=String(+n).split(""),t=["","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="",i=3;i--;)r=(t[+e.pop()+i*10]||"")+r;return Array(+e.join("")+1).join("M")+r}function uf(n){if(!Te(n))throw new Error("toOrdinalNumber: Invalid n = "+n);let e=n.toString(),t=Number(e.charAt(e.length-1));return n===1||n>=20&&t===1?e+"st":n===2||n>=20&&t===2?e+"nd":n===3||n>=20&&t===3?e+"rd":e+"th"}function lf(n,e,t,r,i){return{x:n+(t-n)*i,y:e+(r-e)*i}}function hf(n,e,t,r,i){let o=(i-n)/(t-n);return e+(r-e)*o}function df(n,e,t){return Math.min(Math.max(n,e),t)}function pf(n,e,t,r){let i=t-n,s=-(r-e),a=i,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function mf(n){return n.reduce((e,t)=>t+e,0)}function ff(n,e){return n<e?-1:n>e?1:0}function dc(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function gf(n){return dc(n)?n:[n]}function yf(n){return n===void 0?n:n.slice()}function bf(n){return n.filter((e,t,r)=>r.indexOf(e)===t)}function xf(n,e){return n.filter((t,r,i)=>r===i.findIndex(o=>e(t,o)))}function Af(n,e){if(!Te(e)||e<0)throw new Error("fillArray: Invalid fillCount = "+e);return new Array(e).fill(n)}function Xu(n,e){if(!Te(n)||n<0)throw new Error("mapSequenceArray: Invalid len = "+n);let t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r);return t}function Cf(n){return Xu(n,e=>e)}function Qu(n,e,t){if(!Te(n))throw new Error("mapRangeArray: Invalid start = "+e);if(!Te(e))throw new Error("mapRangeArray: Invalid end = "+e);let r=Math.abs(e-n)+1,i=new Array(r);for(let o=0,s=n,a=Math.sign(e-n);o<r;s+=a,o++)i[o]=t(s);return i}function _f(n,e){return Qu(n,e,t=>t)}function vf(n,e){return n.indexOf(e)>=0}function If(n,e){if(!Te(e)||e<1)throw new Error("chunckArray: Invalid chunckSize = "+e);let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}var Ku={};pr(Ku,{addClass:()=>Sf,appendTo:()=>Ef,getButton:()=>Pf,getCanvas:()=>Ff,getCanvasTextWidth:()=>qf,getDimension:()=>Vf,getHeight:()=>Mf,getOffset:()=>Nf,getPadding:()=>Bf,getWidth:()=>Of,hasClass:()=>pc,removeClass:()=>wf,removeFromParent:()=>kf,setHeight:()=>Df,setOffset:()=>Tf,setRect:()=>jf,setVisibility:()=>Lf,setWidth:()=>Rf,styleLayoutChanged:()=>Gf});var Ju={};pr(Ju,{getEnumValues:()=>os});function os(n){return Object.keys(n).filter(e=>Number.isNaN(Number(e))).map(e=>n[e])}var hc;(n=>{let e=Error;function t(y){e=y!=null?y:Error}n.setErrorClass=t;function r(y,T){throw new e("Assertion Error: "+y+(T?" "+T:""))}function i(y){return typeof y=="number"&&isFinite(y)&&y===Math.trunc(y)}function o(y){return typeof y=="number"}function s(y,T){y||r(T!=null?T:"Assertion failed!")}n.assert=s;function a(y,T,E="value"){if(!os(T).some(R=>R===y))throw new TypeError(`Invalid ${E} enum value: ${y}`)}n.assertEnum=a;function c(y){r(y!=null?y:"Interrupted!")}n.interrupt=c;function u(y,T){return i(y)||r(`Expected ${y} to be integer.`,T),y}n.int=u;function l(y,T,E){return y!==T&&r(`Expected ${y} to equal ${T}.`,E),y}n.eq=l;function h(y,T,E){return i(y)&&o(T)&&y===T||r(`Expected ${y} to be integer equal to ${T}.`,E),y}n.int_eq=h;function d(y,T,E){return i(y)&&o(T)&&y<T||r(`Expected ${y} to be integer less than ${T}.`,E),y}n.int_lt=d;function m(y,T,E){return i(y)&&o(T)&&y<=T||r(`Expected ${y} to be integer less than or equal to ${T}.`,E),y}n.int_lte=m;function f(y,T,E){return i(y)&&o(T)&&y>T||r(`Expected ${y} to be integer greater than ${T}.`,E),y}n.int_gt=f;function g(y,T,E){return i(y)&&o(T)&&y>=T||r(`Expected ${y} to be integer greater than or equal to ${T}.`,E),y}n.int_gte=g;function b(y,T,E,R){return i(y)&&o(T)&&o(E)&&y>=T&&y<=E||r(`Expected ${y} to be integer between ${T} and ${E}.`,R),y}n.int_between=b;function x(y,T){return i(y)&&y%2===1||r(`Expected ${y} to be odd number.`,T),y}n.odd=x;function I(y,T){return i(y)&&y%2===0||r(`Expected ${y} to be even number.`,T),y}n.even=I;function w(y,T,E){if(!T.some(R=>R===y)){let R=T.map(M=>String(M)).join(", ");r(`Expected ${y} to be in group [${R}].`,E)}return y}n.in_group=w;function S(y,T){return o(y)&&isFinite(y)||r(`Expected ${y} to be finite number.`,T),y}n.finite=S;function _(y,T,E){return i(T)&&T>=0&&T<y.length||r(`Expected ${T} to be array index in bounds [0..${y.length-1}].`,E),T}n.array_id=_;function v(y,T,E){return y[_(y,T,E)]}n.array_elem=v;function C(y,T){if(y===void 0)r("Required value is undefined.",T);else return y}n.require=C})(hc||(hc={}));var Pn;(n=>{function e(){let d=document.createElement("div");d.style.width="1in",document.body.appendChild(d);let m=d.offsetWidth;return d.remove(),m||96}function t(){try{let d=document.createElement("div");d.style.visibility="hidden",d.style.width="100px",document.body.appendChild(d);let m=d.offsetWidth;d.style.overflow="scroll";let f=document.createElement("div");f.style.width="100%",d.appendChild(f);let g=f.offsetWidth;return d.parentNode&&d.parentNode.removeChild(d),m-g}catch(d){return 0}}function r(){let d=document.createElement("div");d.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",d.appendChild(document.createTextNode("M")),document.body.appendChild(d);let m=d.offsetHeight;return document.body.removeChild(d),m}function i(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var d=" -webkit- -moz- -o- -ms- ".split(" "),m=function(g){return window.matchMedia(g).matches},f=["(",d.join("touch-enabled),("),"heartz",")"].join("");return m(f)}function o(){let d=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(d)||/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(d.substr(0,4))}function s(){return location.protocol+"//"+location.host}let a=/^(mm|cm|in|inch|px|em)$/,c=/^([0-9\\.]+)(.*)$/;n.DPI=e(),n.PxPerMm=n.DPI/25.4,n.ScrollbarWidth=t(),n.FontSize=r(),n.IsTouchDevice=i(),n.IsMobileDevice=o(),n.HostAddress=s();function u(d){return d/n.PxPerMm}n.pxToMm=u;function l(d){return d*n.PxPerMm}n.mmToPx=l;function h(d){if(typeof d=="number")return d;let m=NaN,f,g=d.toString().match(c);if(g&&g[1]){m=parseFloat(g[1]);let b=g[2]?g[2].toLowerCase():"undefined";f=a.test(b)?b:void 0,f||console.log("Unknown unit '"+b+"' => using 'px'.")}else m=parseFloat(d);switch(hc.finite(m,"value in function toPx"),f){case"mm":return l(m);case"cm":return l(m)*10;case"in":case"inch":return l(m)*25.4;case"em":return n.FontSize*m;default:case"px":return m}}n.toPx=h})(Pn||(Pn={}));function St(n){return n===void 0?void 0:Pn.toPx(n)}function pc(n,e){return e.length===0?!1:n.classList?n.classList.contains(e):!!n.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))}function Sf(n,e){e.length!==0&&(n.classList?n.classList.add(e):pc(n,e)||(n.className+=" "+e))}function wf(n,e){if(e.length!==0){if(n.classList)n.classList.remove(e);else if(pc(n,e)){var t=new RegExp("(\\s|^)"+e+"(\\s|$)");n.className=n.className.replace(t," ")}}}function Tf(n,e,t,r="px"){n.style.left=e+r,n.style.top=t+r}function Nf(n){let e=n.getBoundingClientRect(),t=document.documentElement;return{top:e.top+window.pageYOffset-t.clientTop,left:e.left+window.pageXOffset-t.clientLeft}}function Of(n){if(n instanceof Window)return n.innerWidth;{let e=parseFloat(getComputedStyle(n,null).width.replace("px",""));return isNaN(e)?0:e}}function Rf(n,e){n.style.width=e+"px"}function Mf(n){if(n instanceof Window)return n.innerHeight;{let e=parseFloat(getComputedStyle(n,null).height.replace("px",""));return isNaN(e)?0:e}}function Df(n,e){n.style.height=e+"px"}function Ef(n,e){e.appendChild(n)}function kf(n){n.remove()}function Lf(n,e){n.style.display=e?"block":"none"}function jf(n,e,t,r,i,o="px"){n.style.left=e+o,n.style.top=t+o,n.style.width=r+o,n.style.height=i+o}function Pf(n){let e=typeof n=="string"?document.getElementById(n):n;return e instanceof HTMLButtonElement?e:void 0}function Ff(n){let e=typeof n=="string"?document.getElementById(n):n;return e instanceof HTMLCanvasElement?e:void 0}function Bf(n){var s;if(!n)return{top:0,right:0,bottom:0,left:0};let e=St(n.paddingTop),t=St(n.paddingRight),r=St(n.paddingBottom),i=St(n.paddingLeft),o=((s=n.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:e!=null||(e=St(o[0])),t!=null||(t=St(o[0])),r!=null||(r=St(o[0])),i!=null||(i=St(o[0]));break;case 2:e!=null||(e=St(o[0])),t!=null||(t=St(o[1])),r!=null||(r=St(o[0])),i!=null||(i=St(o[1]));break;case 3:e!=null||(e=St(o[0])),t!=null||(t=St(o[1])),r!=null||(r=St(o[2])),i!=null||(i=St(o[1]));break;case 4:default:e!=null||(e=St(o[0])),t!=null||(t=St(o[1])),r!=null||(r=St(o[2])),i!=null||(i=St(o[3]));break}return e!=null||(e=0),t!=null||(t=0),r!=null||(r=0),i!=null||(i=0),{top:e,right:t,bottom:r,left:i}}function Vf(n){let e=St(n==null?void 0:n.left),t=St(n==null?void 0:n.right),r=St(n==null?void 0:n.top),i=St(n==null?void 0:n.bottom),o=St(n==null?void 0:n.width),s=St(n==null?void 0:n.height);return o===void 0&&e!==void 0&&t!==void 0&&(o=t-e),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:e,top:r,width:o,height:s}}function Gf(n,e){return!n&&!e?!1:!n||!e?!0:n.left!==e.left||n.top!==e.top||n.right!==e.right||n.bottom!==e.bottom||n.width!==e.width||n.height!==e.height}var Ln;function qf(n,e){Ln!=null||(Ln=document.createElement("canvas"));let t=Ln.getContext("2d");return t?(t.font=e,t.measureText(n).width):0}var $u={};pr($u,{isArray:()=>Jr,isArrayOrUndefined:()=>Hf,isBoolean:()=>ng,isBooleanOrUndefined:()=>og,isEmptyArray:()=>Zf,isEmptyArrayOrUndefined:()=>Qf,isEmptyString:()=>$f,isEmptyStringOrUndefined:()=>rg,isEnumValue:()=>cg,isEnumValueOrUndefined:()=>ug,isFinite:()=>mc,isFunction:()=>sg,isFunctionOrUndefined:()=>ag,isInfinity:()=>Ag,isInteger:()=>$r,isIntegerBetween:()=>bg,isIntegerEq:()=>pg,isIntegerGt:()=>mg,isIntegerGte:()=>fg,isIntegerLt:()=>gg,isIntegerLte:()=>yg,isIntegerOrUndefined:()=>dg,isNaNValue:()=>xg,isNegInfinity:()=>_g,isNonEmptyArray:()=>Xf,isNonEmptyArrayOrUndefined:()=>Kf,isNonEmptyString:()=>tg,isNonEmptyStringOrUndefined:()=>ig,isNull:()=>Uf,isNullish:()=>zf,isNumber:()=>lg,isNumberOrUndefined:()=>hg,isObject:()=>tl,isObjectOrUndefined:()=>Yf,isPosInfinity:()=>Cg,isString:()=>Jf,isStringOrUndefined:()=>eg,isUndefined:()=>Wf});function Wf(n){return n===void 0}function Uf(n){return n===null}function zf(n){return n==null}function tl(n){return typeof n=="object"&&n!==null&&!Jr(n)}function Yf(n){return n===void 0||tl(n)}function Jr(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function Hf(n){return n===void 0||Jr(n)}function Zf(n){return Jr(n)&&n.length===0}function Xf(n){return Jr(n)&&n.length>0}function Qf(n){return Jr(n)&&n.length===0||n===void 0}function Kf(n){return Jr(n)&&n.length>0||n===void 0}function Jf(n){return typeof n=="string"}function $f(n){return typeof n=="string"&&n.length===0}function tg(n){return typeof n=="string"&&n.length>0}function eg(n){return n===void 0||typeof n=="string"}function rg(n){return typeof n=="string"&&n.length===0||n===void 0}function ig(n){return typeof n=="string"&&n.length>0||n===void 0}function ng(n){return typeof n=="boolean"}function og(n){return n===void 0||typeof n=="boolean"}function sg(n){return typeof n=="function"}function ag(n){return n===void 0||typeof n=="function"}function cg(n,e,t="value"){return os(e).some(r=>r===n)}function ug(n,e,t="value"){return n===void 0||os(e).some(r=>r===n)}function lg(n){return typeof n=="number"}function hg(n){return typeof n=="number"||n===void 0}function mc(n){return typeof n=="number"&&Number.isFinite(n)}function $r(n){return typeof n=="number"&&mc(n)&&n===Math.trunc(n)}function dg(n){return typeof n=="number"&&mc(n)&&n===Math.trunc(n)||n===void 0}function pg(n,e){return $r(n)&&n===e}function mg(n,e){return $r(n)&&n>e}function fg(n,e){return $r(n)&&n>=e}function gg(n,e){return $r(n)&&n<e}function yg(n,e){return $r(n)&&n<=e}function bg(n,e,t){return $r(n)&&n>=e&&n<=t}function xg(n){return typeof n=="number"&&Number.isNaN(n)}function Ag(n){return typeof n=="number"&&Math.abs(n)===1/0}function Cg(n){return typeof n=="number"&&n===1/0}function _g(n){return typeof n=="number"&&n===-1/0}var el={};pr(el,{getMapKeys:()=>vg});function vg(n){let e=[];return n.forEach((t,r)=>e.push(r)),e}var rl={};pr(rl,{hasProperties:()=>Ig,isObject:()=>il});function il(n){return typeof n=="object"&&n!==null&&!dc(n)}function Ig(n,e){return il(n)&&e.every(t=>t in n)}var nl={};pr(nl,{charCount:()=>Rg,chunkString:()=>Tg,insertAt:()=>Ng,makeSentenceFromPascal:()=>Mg,removeAt:()=>Og,repeatString:()=>wg,replaceAt:()=>fc,toCharArray:()=>Sg});function Sg(n){return n.split("")}function wg(n,e){if(!Te(e)||e<0)throw new Error("repeatStr: Invalid repeatCount = "+e);return new Array(e+1).join(n)}function Tg(n,e){if(!Te(e)||e<1)throw new Error("chunckString: Invalid chuckSize = "+e);let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function fc(n,e,t,r){if(!Te(t)||t<0)throw new Error("replaceAt: Invalid removeCount = "+t);if(!Te(e)||e<0||e+t>n.length)throw new Error("replaceAt: Invalid pos = "+e+", removeCount = "+t+", str.length = "+n.length);return n.substring(0,e)+r+n.substring(e+t)}function Ng(n,e,t){return fc(n,e,0,t)}function Og(n,e,t){return fc(n,e,t,"")}function Rg(n,e){if(e.length!==1||n.length===0)return 0;let t=0;for(let r=0;r<n.length;r++)n[r]===e&&t++;return t}function Mg(n){if(n==="")return"";let e=n.charAt(0),t="",r=()=>{e!==""&&(t===""?t+=e.charAt(0).toUpperCase()+e.substring(1):t+=" "+e,e="")},i=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<n.length;o++){let s=n.charAt(o);i(s)&&r(),e+=s.toLowerCase()}return r(),t}var zu;(n=>{let e="ConsentCookie",t;(S=>{S.Accept="accept",S.Decline="decline"})(t||(t={}));let r,i,o=d(e);r=o==="accept"||o==="decline"?o:void 0;function s(S){i=new Date,i.setDate(i.getDate()+S)}n.setExpireDays=s;function a(){return r===void 0}n.isConsentPending=a;function c(){r="accept",h(e,r)}n.accept=c;function u(){r="decline",h(e,r)}n.decline=u;function l(){return document.cookie.split(";").map(_=>_.trim())}function h(S,_){let v=S+"="+_.toString()+";sameSite=Lax;";return i&&(v+="expires="+i.toUTCString()+";"),document.cookie=v,_}function d(S,_){let v=l().find(C=>C.startsWith(S+"="));return v===void 0?_:v.substring(S.length+1)}function m(S){document.cookie=S+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(S,_){return r==="accept"&&h(S,_),_}n.save=f;function g(S,_){return r==="accept"&&d(S,_)||_}n.read=g;function b(S,_){if(r==="accept"){let v=d(S);return v===void 0?_:parseInt(v)}else return _}n.readInt=b;function x(S,_){if(r==="accept"){let v=d(S);return v===void 0?_:/true|1/i.test(v)}else return _}n.readBool=x;function I(S){(r==="accept"||S===e)&&m(S)}n.erase=I;function w(){document.cookie.split(";").forEach(S=>I(S.trim().split("=")[0]))}n.eraseAll=w})(zu||(zu={}));var ol=class jn{constructor(e,t){er(this,"x"),er(this,"y"),this.x=e!=null?e:0,this.y=t!=null?t:0}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}add(e){return new jn(this.x+e.x,this.y+e.y)}sub(e){return new jn(this.x-e.x,this.y-e.y)}mul(e){return new jn(this.x*e,this.y*e)}div(e){return new jn(this.x/e,this.y/e)}},sl=class{constructor(n,e=1/0){er(this,"cache"),er(this,"next"),er(this,"prev"),er(this,"head"),er(this,"tail"),er(this,"capacity"),er(this,"size"),er(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=n,this.size=0,this.maxKeyLength=e}get(n){if(!(n.length>this.maxKeyLength)&&this.cache[n]!==void 0)return this.touch(n),this.cache[n]}set(n,e){if(!(n.length>this.maxKeyLength)){if(this.cache[n]!==void 0){this.cache[n]=e,this.touch(n);return}this.size>=this.capacity&&this.evict(),this.cache[n]=e,this.addToTail(n),this.size++}}touch(n){this.tail!==n&&(this.removeKey(n),this.addToTail(n))}evict(){if(this.head!==null){let n=this.head;this.removeKey(n),delete this.cache[n],this.size--}}removeKey(n){let e=this.prev[n],t=this.next[n];e!==void 0?this.next[e]=t:this.head=t!=null?t:null,t!==void 0?this.prev[t]=e:this.tail=e!=null?e:null,delete this.prev[n],delete this.next[n]}addToTail(n){this.tail!==null?(this.next[this.tail]=n,this.prev[n]=this.tail):this.head=n,this.tail=n}};var gc={};Oi(gc,{MusicError:()=>O,MusicErrorType:()=>dt,init:()=>ti});var dt=(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))(dt||{});function Dg(n){return n===void 0?"":`[${dt[n]}] `}var O=class extends Error{constructor(...t){let[r,i]=t.length===1?[0,t[0]]:t;super(Dg(r)+i);p(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var al=!1;function ti(){al||(al=!0,console.log("%cWebMusicScore v5.1.0 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Dr=(t=>(t[t.Ascii=0]="Ascii",t[t.Unicode=1]="Unicode",t))(Dr||{}),Er=(t=>(t[t.Scientific=0]="Scientific",t[t.Helmholtz=1]="Helmholtz",t))(Er||{}),Eg=A.Enum.getEnumValues(Er),kg=0;function cl(n){if(A.Is.isEnumValue(n,Er))return n;throw new O(1,`Invalid pitchNotation: ${n}`)}function Lg(n){return Er[cl(n)]}var ss=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(ss||{}),jg="Default",Pg=A.Enum.getEnumValues(ss);function Fg(n){if(A.Is.isEnumValue(n,ss))return n;throw new O(5,`Invalid guitarNoteLabel: ${n}`)}function ul(n,e){return(n%e+e)%e}var ll=12,hl=7,Bg=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),Vg=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),dl=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),Fn=["C","D","E","F","G","A","B"],pl=[0,2,4,5,7,9,11],ml=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,at=class at{constructor(e,t,r){p(this,"diatonicClass");p(this,"accidental");p(this,"octave");if(typeof e=="number"&&typeof t=="number"&&r===void 0)at.validateDiatonicId(e),this.diatonicClass=at.getDiatonicClass(e),this.accidental=at.validateAccidental(t),this.octave=at.getOctaveFromDiatonicId(e);else if(typeof e=="number"&&typeof t=="number"&&typeof r=="number")this.diatonicClass=at.validateDiatonicClass(e),this.accidental=at.validateAccidental(t),this.octave=at.validateOctave(r);else if(typeof e=="string"&&typeof t=="number"&&typeof r=="number")this.diatonicClass=at.getDiatonicClass(e),this.accidental=at.validateAccidental(t),this.octave=at.validateOctave(r);else throw new O(2,`Invalid args: ${e}, ${t}, ${r}`)}get diatonicId(){return at.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return at.getChromaticIdInOctave(pl[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return at.getChromaticClass(pl[this.diatonicClass]+this.accidental)}get noteLetter(){return Fn[this.diatonicClass]}format(e,t){let{noteLetter:r,octave:i}=this,o=at.getAccidentalSymbol(this.accidental,t);return e===1?i>=3?r.toLowerCase()+o+"\u2032".repeat(i-3):r.toUpperCase()+o+"\u0375".repeat(2-i):r+o+i}formatOmitOctave(e){let t=Fn[this.diatonicClass],r=at.getAccidentalSymbol(this.accidental,e);return t+r}static getNote(e){let t=this.noteByNameCache.get(e);if(t===void 0){let r=at.parseNote(e);if(!r)throw new O(2,`Invalid noteName: ${e}`);if(r.octave===void 0)throw new O(2,"Octave is required for note.");t=new at(r.noteLetter,r.accidental,r.octave),this.noteByNameCache.set(e,t)}return t}static getChromaticNote(e){let t=this.chromaticNoteCache.get(e);if(t===void 0){let i=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][at.getChromaticClass(e)].split("/")[0]+at.getOctaveFromChromaticId(e),o=at.parseNote(i);if(!o)throw new O(2,`Invalid noteName: ${i}`);if(o.octave===void 0)throw new O(2,"Octave is required for note.");t=new at(o.noteLetter,o.accidental,o.octave),this.chromaticNoteCache.set(e,t)}return t}static getDiatonicClass(e){if(typeof e=="number")return ul(e,7);if(typeof e=="string"&&e.length>0)return Fn.indexOf(at.validateNoteLetter(e[0]));throw new O(2,`Invalid arg: ${e}`)}static getOctaveFromDiatonicId(e){return Math.floor((e-hl)/7)}static getDiatonicIdInOctave(e,t){return at.getDiatonicClass(e)+t*7+hl}static getChromaticClass(e){return ul(e,12)}static getOctaveFromChromaticId(e){return Math.floor((e-ll)/12)}static getChromaticIdInOctave(e,t){return at.getChromaticClass(e)+t*12+ll}static equals(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.diatonicId===t.diatonicId&&e.accidental===t.accidental}static replaceAccidentalSymbols(e,t){return t===1?e.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):e.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(e){return ml.test(e)}static parseNote(e){var c;let t=ml.exec(e);if(!t)return;let r=at.validateNoteLetter(t[1]),i=t[2],o=at.validateAccidental((c=dl.get(i))!=null?c:0),s=t[3],a=s?at.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(e,t){let r=at.parseNote(e);if(!r)throw new O(2,`Invalid noteName: ${e}`);let{noteLetter:i,accidental:o,octave:s}=r;return i+at.getAccidentalSymbol(o,t)+(s!=null?s:"")}static getAccidentalSymbol(e,t){return t===1?Vg.get(e):Bg.get(e)}static getAccidental(e){let t=dl.get(e);if(t===void 0)throw new O(2,`Invalid accidental: ${e}`);return t}static getNoteLetter(e){return Fn[at.getDiatonicClass(e)]}static findNextDiatonicIdAbove(e,t,r){let i=at.getDiatonicClass(e),o=at.getDiatonicClass(t),s=r?i<=o?1:0:i<o?1:0;return at.getDiatonicIdInOctave(i,at.getOctaveFromDiatonicId(t)+s)}static validateDiatonicId(e){if(A.Is.isInteger(e))return e;throw new O(2,`Invalid diatonicId: ${e}`)}static validateDiatonicClass(e){if(A.Is.isIntegerBetween(e,0,6))return e;throw new O(2,`Invalid diatonicClass: ${e}`)}static validateChromaticId(e){if(A.Is.isInteger(e))return e;throw new O(2,`Invalid chromaticId: ${e}`)}static validatechromaticClass(e){if(A.Is.isIntegerBetween(e,0,11))return e;throw new O(2,`Invalid chromaticClass: ${e}`)}static validateNoteLetter(e){if(Fn.some(t=>t===e))return e;throw new O(2,`Invalid note: ${e}`)}static validateOctave(e){if(A.Is.isInteger(e))return e;throw new O(2,`Invalid octave: ${e}`)}static validateAccidental(e){if(A.Is.isIntegerBetween(e,-2,2))return e;throw new O(2,`Invalid accidental: ${e}`)}static sort(e){return e.slice().sort(at.compareFunc)}static removeDuplicates(e){let t=[];return e.forEach(r=>{t.find(i=>at.equals(r,i))===void 0&&t.push(r)}),t}static compareFunc(e,t){return e.diatonicId<t.diatonicId?-1:e.diatonicId>t.diatonicId?1:e.accidental<t.accidental?-1:e.accidental>t.accidental?1:0}};p(at,"noteByNameCache",new Map),p(at,"chromaticNoteCache",new Map);var U=at;function Gg(n,e){let t=U.getChromaticClass(n)-new U(e,0).chromaticClass;for(;t>2;)t-=12;for(;t<-2;)t+=12;return U.validateAccidental(t)}var qg=/^(bb?|b?|#?|x?)([0-9]*)$/;function Wg(n){var i,o;let e=qg.exec(""+n);if(!e)throw new O(4,`Invalid degree: ${n}`);let t=(o=U.getAccidental((i=e[1])!=null?i:""))!=null?o:0,r=+e[2];if(!A.Is.isInteger(t)||t<-2||t>2||!A.Is.isInteger(r)||r<1)throw new O(4,`Invalid degree: ${n}`);return{deg:r,acc:t}}var yc=(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))(yc||{}),bc=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(bc||{});function as(){return mr("C","Major")}var kr=class kr{constructor(e,t){this.tonic=e;this.mode=t;p(this,"naturalScaleNotes");p(this,"accidentalByDiatonicClass");p(this,"orderedAccidentedNotes");if(!A.Is.isEnumValue(t,yc))throw new O(4,`Invalid mode: ${t}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<t;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let i=U.getDiatonicClass(e[0]),o=U.getNote(e+"0").chromaticId;for(let c=0;c<7;i++,o+=r[c],c++){let u=new U(U.getDiatonicClass(i),Gg(o,i));if(Math.abs(u.accidental)>=2)throw new O(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=kr.OrderOfSharps.indexOf(c.noteLetter),h=kr.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=kr.OrderOfFlats.indexOf(c.noteLetter),h=kr.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new O(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(e){var t;return(t=this.accidentalByDiatonicClass[U.getDiatonicClass(e)])!=null?t:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(e){let{deg:t,acc:r}=Wg(e);if(r===0)return this.naturalScaleNotes[(t-1)%7];{let i=this.naturalScaleNotes[(t-1)%7];return new U(i.diatonicId,i.accidental+r)}}static equals(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.tonic===t.tonic&&e.mode===t.mode}};p(kr,"OrderOfSharps","FCGDAEB"),p(kr,"OrderOfFlats","BEADGCF");var Fe=kr;var Ug=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),zg={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 Yg(n,e){for(;n<1;)n+=7,e+=12;for(;n>8;)n-=7,e-=12;let t=zg[n];if(t)return t[e]}function Hg(n){if(n==="Perfect"||n==="Major"||n==="minor"||n==="Augmented"||n==="diminished"||n==="Doubly Augmented"||n==="doubly diminished")return n;throw new O(1,`Invalid interval quality: ${n}`)}function Zg(n){if(A.Is.isIntegerGte(n,1))return A.Math.toOrdinalNumber(n);throw new O(1,`Invalid interval quantity: ${n}`)}var cs=class extends Error{constructor(t){super(t);this.msg=t;this.name="InvalidInterval"}},Bn=class n{constructor(e,t){this.note1=e;this.note2=t;p(this,"direction");p(this,"semitones");p(this,"quantity");p(this,"quality");t.diatonicId>=e.diatonicId?(this.direction=t.diatonicId===e.diatonicId?"Unison":"Ascending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId):(this.direction="Descending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId);let r=Yg(this.quantity,this.semitones);if(r)this.quality=r;else throw new cs("Unknown interval quality")}static get(e,t){try{return new n(e,t)}catch(r){if(r instanceof cs)return;throw r}}toString(){let e=this.direction==="Unison"?"":this.direction+" ",t=this.quality+" ",r=this.direction==="Unison"?"Unison":Zg(this.quantity);return e+t+r}toAbbrString(){var i;let e=this.direction==="Descending"?"\u2193":"",t=(i=Ug.get(this.quality))!=null?i:"?",r=this.quantity;return e+t+r}};function Xg(n){let e=U.getDiatonicClass("CCDDEFFGGAAB"[U.getChromaticClass(n)]),t=U.getOctaveFromChromaticId(n);return U.getDiatonicIdInOctave(e,t)}var Qg=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],ei=(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))(ei||{});function Kg(n){switch(n){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 O(3,`Invalid scaleType: ${n}`)}}var Lr=class extends Fe{constructor(t,r){super(t,Kg(r));this.tonic=t;this.scaleType=r;p(this,"scaleDegrees");p(this,"scaleNotes");p(this,"chromaticClassDegree");p(this,"preferredChromaticNoteCache",new Map);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(i=>this.getNoteByDegree(i)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(i=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===i);return o>=0?this.scaleDegrees[o]:void 0})}static equals(t,r){return t==null&&r==null?!0:t==null||r==null?!1:t===r||t.getScaleName()===r.getScaleName()}getScaleName(t){switch(t){case 1:return U.getScientificNoteName(this.tonic,t)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(t,r){if(!A.Is.isIntegerGte(r,1))throw new O(3,`Invalid numOctaves: ${r}`);let i=[];for(let s=1;s<=r;s++)i=[...i,...this.scaleNotes];i.push(this.scaleNotes[0]);let o=U.getNote(t).diatonicId;return i.map(s=>(o=U.findNextDiatonicIdAbove(s.diatonicId,o,!1),new U(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(t=>t.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let t=this.getScaleNotes("C4",1).map(i=>i.chromaticId),r=[];for(let i=0;i<t.length-1;i++)r.push(A.Math.mod(t[i+1]-t[i],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(t=>t===1?"H":t===2?"W":t.toString()+"H")}isScaleNote(t){return this.chromaticClassDegree[t.chromaticClass]!==void 0}isScaleRootNote(t){return String(this.chromaticClassDegree[t.chromaticClass])==="1"}getIntervalFromRootNote(t){let r=this.getScaleNotes("C0",1)[0];for(;t.chromaticId>=r.chromaticId+12;)t=new U(t.diatonicClass,t.accidental,t.octave-1);if(t.chromaticId<r.chromaticId)throw new O(3,"Note is below rootNote.");let i=Bn.get(r,t);if(i===void 0)throw new O(3,"Interval is undefined.");return i}getPreferredChromaticNote(t){U.validateChromaticId(t);let r=this.preferredChromaticNoteCache.get(t);if(r)return r;let i=U.getOctaveFromChromaticId(t);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new U(h.diatonicClass,h.accidental,i+1):h.noteLetter==="B"&&h.accidental>0?new U(h.diatonicClass,h.accidental,i-1):new U(h.diatonicClass,h.accidental,i)).find(h=>U.getChromaticClass(t)===h.chromaticClass),r)return this.preferredChromaticNoteCache.set(t,r),r;let s=Xg(t),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 d=l[h];for(let m=Math.max(0,a);m<=c;m++)if(r=new U(m,d),t===r.chromaticId)return this.preferredChromaticNoteCache.set(t,r),r}return r=U.getChromaticNote(t),this.preferredChromaticNoteCache.set(t,r),r}},Ht=class{constructor(e){this.type=e;p(this,"tonicList",[]);p(this,"scaleMap",new Map);let t=[],r=[],i=[];if(Qg.forEach(s=>{try{let a=new Lr(s,this.type);switch(a.getAccidentalType()){case 0:t.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;i.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),t.length===0)throw new O(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...t.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...i.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(e){let t=this.scaleMap.get(e);if(t)return t;throw new O(3,`Invalid scale: ${e} ${this.type}`)}hasScale(e){return this.scaleMap.get(e)!==void 0}},fl=[new Ht("Major"),new Ht("Natural Minor"),new Ht("Harmonic Minor"),"- Modes -",new Ht("Ionian"),new Ht("Dorian"),new Ht("Phrygian"),new Ht("Lydian"),new Ht("Mixolydian"),new Ht("Aeolian"),new Ht("Locrian"),"- Pentatonic -",new Ht("Major Pentatonic"),new Ht("Minor Pentatonic"),"- Blues -",new Ht("Major Hexatonic Blues"),new Ht("Minor Hexatonic Blues"),new Ht("Heptatonic Blues")];function Jg(){return fl}var gl=new Map;fl.forEach(n=>{n instanceof Ht&&gl.set(n.getType(),n)});function yl(n){let e=gl.get(n);if(e)return e;throw new O(3,`Invalid scaleType: ${n}`)}function Vn(n){if(A.Is.isEnumValue(n,ei))return n;throw new O(3,`Invalid scaleType: "${n}"`)}function mr(n,e){let t,r;return e!==void 0?(t=n,r=Vn(e)):(t=n.split(" ")[0],r=Vn(n.substring(t.length+1))),yl(r).getScale(t)}var $g=mr("C","Major");function ty(){return $g}var fr=(n,e)=>n.chromaticClass===e.chromaticClass,ey=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(n=>U.getNote(n+"0")),bl=new Map;function ry(n){let e=n.chromaticClass,t=bl.get(e);if(!t){if(t=ey.find(r=>fr(r,n)),!t)throw new O(1,`Invalid chord root note: ${n.formatOmitOctave(1)}`);bl.set(e,t)}return t}function iy(n,e){let t=n.formatOmitOctave(0);return mr(t,"Major").getNoteByDegree(e)}function ny(n){return A.Arr.removeDuplicatesCmp(n,fr)}var oy=[{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 sy(n,e){return n.degrees.every(t=>t!==e)?!0:n.degrees.length>=4&&e===5||n.degrees.length>=6&&e===9||n.degrees.length>=7&&e===11}var Ri=class extends Error{constructor(t){super(t);this.msg=t;this.name="InvalidChordException"}},xc=class n{constructor(e,t,r,i){this.chordInfo=e;this.rootNote=r;p(this,"name");p(this,"notes");p(this,"omitNotes");p(this,"slashBassNote");this.name=e.name;let o=t.slice();!o.some(a=>fr(a,i))&&o.push(i),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<e.degrees.length;a++){let c=e.degrees[a],u=this.notes[a]=iy(this.rootNote,c),l=o.findIndex(h=>fr(h,u));if(l>=0)this.omitNotes[a]=!1,o.splice(l,1);else if(sy(e,c))this.omitNotes[a]=!0;else throw new Ri("Missing chord note!");fr(i,u)&&(i=u)}if(o.length>0)if(o.every(a=>fr(a,i)))this.slashBassNote=i;else throw new Ri("Got some extra notes that are not bass note!");else this.slashBassNote=fr(i,this.rootNote)?void 0:i;if(e.name==="5"&&this.slashBassNote)throw new Ri("Power chord no bass note allowed!")}static getChords(e){let t=[],r=U.sort(e),i=r[0],o=ny(r);for(let s=0;s<o.length;s++){let a=ry(o[s]);oy.forEach(c=>{try{let u=new n(c,o,a,i),l=t.findIndex(h=>h.replaceWith(u));l>=0?t[l]=u:t.push(u)}catch(u){if(!(u instanceof Ri))throw u}})}return t}replaceWith(e){if(e.notes.length<this.notes.length)return!1;if(e.slashBassNote&&this.slashBassNote&&!fr(e.slashBassNote,this.slashBassNote)||e.slashBassNote&&!this.slashBassNote||!e.slashBassNote&&this.slashBassNote)return!1;for(let t=0;t<this.notes.length;t++)if(!fr(e.notes[t],this.notes[t])||e.omitNotes[t]!==this.omitNotes[t])return!1;return!0}toString(){let e=1,t=this.rootNote.formatOmitOctave(e),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(e):"";return t+this.name+r}getDegreeNotationString(){let e=1,t=this.slashBassNote?this.slashBassNote.formatOmitOctave(e)+" - ":"",r=this.omitNotes.map((i,o)=>this.getDegreeStr(o)+"("+(i?"-":this.getNoteStr(o))+")").join(" - ");return t+r}getOmittedDegreesString(){let e=this.omitNotes.map((t,r)=>t?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(t=>t!==void 0);return e.length>0?"Omits "+e.join(", "):""}getDegreeStr(e){return U.replaceAccidentalSymbols(""+this.chordInfo.degrees[e],1)}getNoteStr(e){return this.notes[e].formatOmitOctave(1)}};var Ac={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 Cc=(t=>(t[t.RightHanded=0]="RightHanded",t[t.LeftHanded=1]="LeftHanded",t))(Cc||{}),cy=0;function uy(n){if(A.Is.isEnumValue(n,Cc))return n;throw new O(1,`Invalid handedness: ${n}`)}var Gn=Ac.list.map(n=>n.name),ly=Gn[0];function _c(n){if(Gn.indexOf(n)<0)throw new O(1,`Invalid tuning name: ${n}`);return n}var xl=new sl(100);function us(n){let e=xl.get(n);if(!e){let t=Ac.list.find(r=>r.name===n);if(!t)throw new O(1,`Invalid tuningName: ${n}`);if(e=t.strings.slice().reverse().map(r=>U.getNote(r)),!A.Is.isIntegerEq(e.length,6))throw new O(0,`Tuning has ${e.length} strings.`);xl.set(n,e)}return e}var Al=12,hy=1188*7*5,Zt=(V=>(V.Whole="1n",V.WholeTriplet="1t",V.WholeDot="1.",V.Whole2Dots="1..",V.Whole12Dots="1..",V.Whole3Dots="1...",V.Whole4Dots="1....",V.Whole5Dots="1.....",V.Whole6Dots="1......",V.Half="2n",V.HalfTriplet="2t",V.HalfDot="2.",V.Half2Dots="2..",V.Half3Dots="2...",V.Half4Dots="2....",V.Half5Dots="2.....",V.Quarter="4n",V.QuarterTriplet="4t",V.QuarterDot="4.",V.Quarter2Dots="4..",V.Quarter3Dots="4...",V.Quarter4Dots="4....",V.Eighth="8n",V.EighthTriplet="8t",V.EighthDot="8.",V.Eighth2Dots="8..",V.Eighth3Dots="8...",V.Sixteenth="16n",V.SixteenthTriplet="16t",V.SixteenthDot="16.",V.Sixteenth2Dots="16..",V.ThirtySecond="32n",V.ThirtySecondTriplet="32t",V.ThirtySecondDot="32.",V.SixtyFourth="64n",V.SixtyFourthTriplet="64t",V))(Zt||{});function Ae(n){if(A.Is.isEnumValue(n,Zt))return n;throw new O(1,`Invalid noteLength: ${n}`)}var re=class re{constructor(e){p(this,"noteLength");p(this,"noteSize");p(this,"ticks");p(this,"flagCount");p(this,"dotCount");p(this,"maxDotCount");p(this,"isTriplet");p(this,"hasStem");p(this,"isSolid");if(this.noteLength=Ae(e),this.noteSize=parseInt(e),this.isTriplet=e.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(re.ShortestNoteSize/this.noteSize)),this.dotCount=A.Str.charCount(e,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=hy*re.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new O(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new O(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(e){let t=this.cache.get(e);return t||this.cache.set(e,t=new re(e)),t}static create(e,t=0){let r=typeof e=="number"?e:this.get(e).noteSize;return this.get(r+(A.Is.isIntegerGte(t,1)?".".repeat(t):"n"))}static cmp(e,t){let r=e instanceof re?e.noteSize:typeof e=="number"?e:re.get(e).noteSize,i=t instanceof re?t.noteSize:typeof t=="number"?t:re.get(t).noteSize;return A.Math.cmp(i,r)}static equals(e,t){let r=e instanceof re?e.noteSize:typeof e=="number"?e:re.get(e).noteSize,i=t instanceof re?t.noteSize:typeof t=="number"?t:re.get(t).noteSize;return r===i}};p(re,"LongestNoteSize",Math.min(...A.Enum.getEnumValues(Zt).map(e=>parseInt(e)))),p(re,"ShortestNoteSize",Math.max(...A.Enum.getEnumValues(Zt).map(e=>parseInt(e)))),p(re,"cache",new Map);var _t=re;function ls(n){if(A.Is.isObject(n)&&A.Is.isIntegerBetween(n.parts,2,Al)&&A.Is.isIntegerBetween(n.inTimeOf,2,Al))return n;throw new O(2,`Invalid tupletRatio ${JSON.stringify(n)}`)}var gr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},ri=class ri{constructor(e,t,r){p(this,"noteLength");p(this,"noteSize");p(this,"dotCount");p(this,"tupletRatio");p(this,"ticks");p(this,"flagCount");p(this,"hasStem");p(this,"isSolidNoteHead");this.noteLength=Ae(e);let i=_t.get(e);if(this.noteSize=i.noteSize,this.ticks=i.ticks,this.flagCount=i.flagCount,this.dotCount=t!=null?t:i.dotCount,this.hasStem=i.hasStem,this.isSolidNoteHead=i.isSolid,A.Is.isObject(r)?this.tupletRatio=ls(r):i.isTriplet?this.tupletRatio=gr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new O(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>i.maxDotCount)throw new O(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 e=ri.NoteSymbolMap.get(this.noteSize),t=".".repeat(this.dotCount);return e?e+t:""+this.noteSize+(t.length>0?t:"n")}static get(e,t,r){if(t!==void 0||r!==void 0)return new ri(e,t,r);{let i=this.cache.get(e);return i||this.cache.set(e,i=new ri(e)),i}}static cmp(e,t){return A.Math.cmp(e.ticks,t.ticks)}static equals(e,t){return e.ticks===t.ticks}};p(ri,"NoteSymbolMap",new Map([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),p(ri,"cache",new Map);var Gt=ri;var qn=(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))(qn||{}),ii=(i=>(i._2_3="2-3",i._3_2="3-2",i._2_2_3="2-2-3",i._3_2_2="3-2-2",i))(ii||{}),jr=class{constructor(...e){p(this,"beatCount");p(this,"beatSize");p(this,"beatLength");p(this,"measureTicks");p(this,"beamGroupSizes",[]);let t;if(A.Is.isEnumValue(e[0],qn)){let o=e[0].split("/");this.beatCount=+o[0],this.beatSize=+o[1],A.Is.isEnumValue(e[1],ii)&&(t=e[1])}else if(A.Is.isIntegerGte(e[0],2)&&A.Is.isIntegerGte(e[1],2))this.beatCount=e[0],this.beatSize=e[1],A.Is.isEnumValue(e[2],ii)&&(t=e[2]);else throw new O(5,`Invalid args: ${e}`);if(A.Is.isIntegerGte(this.beatCount,1)){if(!A.Is.isIntegerGte(this.beatSize,1))throw new O(5,`Invalid beatSize: ${this.beatSize}`)}else throw new O(5,`Invalid beatCount: ${this.beatCount}`);let{noteLength:r,ticks:i}=_t.create(this.beatSize);if(this.beatLength=r,this.measureTicks=this.beatCount*i,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(!A.Is.isUndefined(t)&&t!=="2-3"&&t!=="3-2")throw new O(5,`Invalid beam grouping "${t}" for time signature "${this.toString()}".`);this.beamGroupSizes=t==="3-2"?[[3],[2]]:[[2],[3]],t=void 0}else if(this.is(6,8))this.beamGroupSizes=[[3],[3]];else if(this.is(7,8)){if(!A.Is.isUndefined(t)&&t!=="2-2-3"&&t!=="3-2-2")throw new O(5,`Invalid beam grouping "${t}" for time signature "${this.toString()}".`);this.beamGroupSizes=t==="3-2-2"?[[3],[2],[2]]:[[2],[2],[3]],t=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 O(5,`Unimplemented time signature "${this.toString()}".`);if(t!==void 0)throw new O(5,`Invalid beam grouping "${t}" for time signature "${this.toString()}".`)}is(e,t){return this.beatCount===e&&this.beatSize===t}toString(){return this.beatCount+"/"+this.beatSize}},vc;function hs(){return vc||(vc=new jr(4,4)),vc}var Ic;function ds(){return Ic||(Ic={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),Ic}function ps(n){return Gt.get(n.options.beatLength,n.options.dotCount).toString()+"="+n.beatsPerMinute}function Sc(n,e){return{beatsPerMinute:n.beatsPerMinute*e,options:{beatLength:n.options.beatLength,dotCount:n.options.dotCount}}}ti();function ms(n){return!isFinite(n)||n<=0?-1/0:20*Math.log10(n)}var Wn="15.1.22";var Tc=(n,e,t)=>({endTime:e,insertTime:t,type:"exponentialRampToValue",value:n});var Nc=(n,e,t)=>({endTime:e,insertTime:t,type:"linearRampToValue",value:n});var Mi=(n,e)=>({startTime:e,type:"setValue",value:n});var Un=(n,e,t)=>({duration:t,startTime:e,type:"setValueCurve",values:n});var fs=(n,e,{startTime:t,target:r,timeConstant:i})=>r+(e-r)*Math.exp((t-n)/i);var yr=n=>n.type==="exponentialRampToValue";var ni=n=>n.type==="linearRampToValue";var Be=n=>yr(n)||ni(n);var Di=n=>n.type==="setValue";var Ne=n=>n.type==="setValueCurve";var Ei=(n,e,t,r)=>{let i=n[e];return i===void 0?r:Be(i)||Di(i)?i.value:Ne(i)?i.values[i.values.length-1]:fs(t,Ei(n,e-1,i.startTime,r),i)};var Oc=(n,e,t,r,i)=>t===void 0?[r.insertTime,i]:Be(t)?[t.endTime,t.value]:Di(t)?[t.startTime,t.value]:Ne(t)?[t.startTime+t.duration,t.values[t.values.length-1]]:[t.startTime,Ei(n,e-1,t.startTime,i)];var zn=n=>n.type==="cancelAndHold";var Yn=n=>n.type==="cancelScheduledValues";var br=n=>zn(n)||Yn(n)?n.cancelTime:yr(n)||ni(n)?n.endTime:n.startTime;var Rc=(n,e,t,{endTime:r,value:i})=>t===i?i:0<t&&0<i||t<0&&i<0?t*Uu(i/t,(n-e)/(r-e)):0;var Mc=(n,e,t,{endTime:r,value:i})=>t+(n-e)/(r-e)*(i-t);var Cl=(n,e)=>{let t=Math.floor(e),r=Math.ceil(e);return t===r?n[t]:(1-(e-t))*n[t]+(1-(r-e))*n[r]};var _l=(n,{duration:e,startTime:t,values:r})=>{let i=(n-t)/e*(r.length-1);return Cl(r,i)};var Hn=n=>n.type==="setTarget";var Zn=class{constructor(e){this._automationEvents=[],this._currenTime=0,this._defaultValue=e}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(e){let t=br(e);if(zn(e)||Yn(e)){let r=this._automationEvents.findIndex(o=>Yn(e)&&Ne(o)?o.startTime+o.duration>=t:br(o)>=t),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),zn(e)){let o=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Be(i)){if(o!==void 0&&Hn(o))throw new Error("The internal list is malformed.");let s=o===void 0?i.insertTime:Ne(o)?o.startTime+o.duration:br(o),a=o===void 0?this._defaultValue:Ne(o)?o.values[o.values.length-1]:o.value,c=yr(i)?Rc(t,s,a,i):Mc(t,s,a,i),u=yr(i)?Tc(c,t,this._currenTime):Nc(c,t,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Hn(o)&&this._automationEvents.push(Mi(this.getValue(t),t)),o!==void 0&&Ne(o)&&o.startTime+o.duration>t){let s=t-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 d=u*h%1;l[h]=o.values[h-1]*(1-d)+o.values[h]*d}this._automationEvents[this._automationEvents.length-1]=Un(l,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>br(s)>t),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&Ne(i)&&br(i)+i.duration>t)return!1;let o=yr(e)?Tc(e.value,e.endTime,this._currenTime):ni(e)?Nc(e.value,t,this._currenTime):e;if(r===-1)this._automationEvents.push(o);else{if(Ne(e)&&t+e.duration>br(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(e){let t=this._automationEvents.findIndex(r=>br(r)>e);if(t>1){let r=this._automationEvents.slice(t-1),i=r[0];Hn(i)&&r.unshift(Mi(Ei(this._automationEvents,t-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=r}}getValue(e){if(this._automationEvents.length===0)return this._defaultValue;let t=this._automationEvents.findIndex(s=>br(s)>e),r=this._automationEvents[t],i=(t===-1?this._automationEvents.length:t)-1,o=this._automationEvents[i];if(o!==void 0&&Hn(o)&&(r===void 0||!Be(r)||r.insertTime>e))return fs(e,Ei(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(o!==void 0&&Di(o)&&(r===void 0||!Be(r)))return o.value;if(o!==void 0&&Ne(o)&&(r===void 0||!Be(r)||o.startTime+o.duration>e))return e<o.startTime+o.duration?_l(e,o):o.values[o.values.length-1];if(o!==void 0&&Be(o)&&(r===void 0||!Be(r)))return o.value;if(r!==void 0&&yr(r)){let[s,a]=Oc(this._automationEvents,i,o,r,this._defaultValue);return Rc(e,s,a,r)}if(r!==void 0&&ni(r)){let[s,a]=Oc(this._automationEvents,i,o,r,this._defaultValue);return Mc(e,s,a,r)}return this._defaultValue}};var Dc=n=>({cancelTime:n,type:"cancelAndHold"});var Ec=n=>({cancelTime:n,type:"cancelScheduledValues"});var kc=(n,e)=>({endTime:e,type:"exponentialRampToValue",value:n});var Lc=(n,e)=>({endTime:e,type:"linearRampToValue",value:n});var jc=(n,e,t)=>({startTime:e,target:n,timeConstant:t,type:"setTarget"});var vl=()=>new DOMException("","AbortError");var Il=n=>(e,t,[r,i,o],s)=>{n(e[i],[t,r,o],a=>a[0]===t&&a[1]===r,s)};var Sl=n=>(e,t,r)=>{let i=[];for(let o=0;o<r.numberOfInputs;o+=1)i.push(new Set);n.set(e,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:t})};var wl=n=>(e,t)=>{n.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:t})};var rr=new WeakSet,gs=new WeakMap,ki=new WeakMap,ys=new WeakMap,Xn=new WeakMap,Li=new WeakMap,bs=new WeakMap,Qn=new WeakMap,Kn=new WeakMap,Jn=new WeakMap;var Tl={construct(){return Tl}},Nl=n=>{try{let e=new Proxy(n,Tl);new e}catch(e){return!1}return!0};var Ol=/^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]*);?/,Pc=(n,e)=>{let t=[],r=n.replace(/^[\s]+/,""),i=r.match(Ol);for(;i!==null;){let o=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,e).toString());t.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(Ol)}return[t.join(";"),r]};var Rl=n=>{if(n!==void 0&&!Array.isArray(n))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Ml=n=>{if(!Nl(n))throw new TypeError("The given value for processorCtor should be a constructor.");if(n.prototype===null||typeof n.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},Dl=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>{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 I=u.get(f);if(I!==void 0){let _=I.get(g);if(_!==void 0)return _}let w=o(f),S=w.audioWorklet===void 0?i(g).then(([_,v])=>{let[C,y]=Pc(_,v),T=`${C};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${y}
3
- })})(window,'_AWGS')`;return t(T)}).then(()=>{let _=d._AWGS.pop();if(_===void 0)throw new SyntaxError;r(w.currentTime,w.sampleRate,()=>_(class{},void 0,(v,C)=>{if(v.trim()==="")throw e();let y=Kn.get(w);if(y!==void 0){if(y.has(v))throw e();Ml(C),Rl(C.parameterDescriptors),y.set(v,C)}else Ml(C),Rl(C.parameterDescriptors),Kn.set(w,new Map([[v,C]]))},w.sampleRate,void 0,void 0))}):Promise.all([i(g),Promise.resolve(n(h,h))]).then(([[_,v],C])=>{let y=m+1;m=y;let[T,E]=Pc(_,v),L=`${T};((AudioWorkletProcessor,registerProcessor)=>{${E}
4
- })(${C?"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{${C?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${C?"":"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${y}',class extends AudioWorkletProcessor{process(){return !1}})`,k=new Blob([L],{type:"application/javascript; charset=utf-8"}),P=URL.createObjectURL(k);return w.audioWorklet.addModule(P,b).then(()=>{if(a(w))return w;let G=s(w);return G.audioWorklet.addModule(P,b).then(()=>G)}).then(G=>{if(c===null)throw new SyntaxError;try{new c(G,`__sac${y}`)}catch(Q){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(P))});return I===void 0?u.set(f,new Map([[g,S]])):I.set(g,S),S.then(()=>{let _=l.get(f);_===void 0?l.set(f,new Set([g])):_.add(g)}).finally(()=>{let _=u.get(f);_!==void 0&&_.delete(g)}),S}};var qt=(n,e)=>{let t=n.get(e);if(t===void 0)throw new Error("A value with the given key could not be found.");return t};var Pr=(n,e)=>{let t=Array.from(n).filter(e);if(t.length>1)throw Error("More than one element was found.");if(t.length===0)throw Error("No element was found.");let[r]=t;return n.delete(r),r};var xs=(n,e,t,r)=>{let i=qt(n,e),o=Pr(i,s=>s[0]===t&&s[1]===r);return i.size===0&&n.delete(e),o};var ir=n=>qt(bs,n);var Ve=n=>{if(rr.has(n))throw new Error("The AudioNode is already stored.");rr.add(n),ir(n).forEach(e=>e(!0))};var As=n=>"port"in n;var nr=n=>{if(!rr.has(n))throw new Error("The AudioNode is not stored.");rr.delete(n),ir(n).forEach(e=>e(!1))};var $n=(n,e)=>{!As(n)&&e.every(t=>t.size===0)&&nr(n)};var El=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>{let m=new WeakMap;return(f,g,b,x,I)=>{let{activeInputs:w,passiveInputs:S}=o(g),{outputs:_}=o(f),v=a(f),C=y=>{let T=c(g),E=c(f);if(y){let R=xs(S,f,b,x);n(w,f,R,!1),!I&&!h(f)&&t(E,T,b,x),d(g)&&Ve(g)}else{let R=r(w,f,b,x);e(S,x,R,!1),!I&&!h(f)&&i(E,T,b,x);let M=s(g);if(M===0)l(g)&&$n(g,w);else{let q=m.get(g);q!==void 0&&clearTimeout(q),m.set(g,setTimeout(()=>{l(g)&&$n(g,w)},M*1e3))}}};return u(_,[g,b,x],y=>y[0]===g&&y[1]===b&&y[2]===x,!0)?(v.add(C),l(f)?n(w,f,[b,x,C],!0):e(S,x,[f,b,C],!0),!0):!1}};var kl=n=>(e,t,[r,i,o],s)=>{let a=e.get(r);a===void 0?e.set(r,new Set([[i,t,o]])):n(a,[i,t,o],c=>c[0]===i&&c[1]===t,s)};var Ll=n=>(e,t)=>{let r=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});t.connect(r).connect(e.destination);let i=()=>{t.removeEventListener("ended",i),t.disconnect(r),r.disconnect()};t.addEventListener("ended",i)};var jl=n=>(e,t)=>{n(e).add(t)};var dy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Pl=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},dy),c),h=r(u,l),d=o(u)?e():null;super(a,!1,h,d),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,t()}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,t()}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 mt=(n,e)=>n.context===e;var Fl=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!mt(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=n(s,u)}return r.set(s,a),yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var ji=n=>{try{n.copyToChannel(new Float32Array(1),0,-1)}catch(e){return!1}return!0};var Oe=()=>new DOMException("","IndexSizeError");var Pi=n=>{n.getChannelData=(e=>t=>{try{return e.call(n,t)}catch(r){throw r.code===12?Oe():r}})(n.getChannelData)};var py={numberOfChannels:1},Bl=(n,e,t,r,i,o,s,a)=>{let c=null;return class Vl{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:d,sampleRate:m}=D(D({},py),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&e(o,o)?new r({length:h,numberOfChannels:d,sampleRate:m}):c.createBuffer(d,h,m);if(f.numberOfChannels===0)throw t();return typeof f.copyFromChannel!="function"?(s(f),Pi(f)):e(ji,()=>ji(f))||a(f),n.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===Vl.prototype||n.has(l)}}};var Pt=-34028234663852886e22,Et=-Pt;var ae=n=>rr.has(n);var my={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},Gl=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},my),l),m=i(h,d),f=s(h),g=f?e():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=d.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=t(this,f,m.playbackRate,Et,Pt)}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"){Ve(this);let d=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",d),ae(this)&&nr(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",d)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var ql=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=t(u),d=mt(h,l);if(!d){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=e(l,m),s!==null&&h.start(...s),a!==null&&h.stop(a)}return o.set(l,h),d?yield n(l,u.playbackRate,h.playbackRate):yield r(l,u.playbackRate,h.playbackRate),yield i(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 Wl=n=>"playbackRate"in n;var Ul=n=>"frequency"in n&&"gain"in n;var zl=n=>"offset"in n;var Yl=n=>!("frequency"in n)&&"gain"in n;var Hl=n=>"detune"in n&&"frequency"in n&&!("gain"in n);var Zl=n=>"pan"in n;var Xt=n=>qt(gs,n);var Fr=n=>qt(ys,n);var Cs=(n,e)=>{let{activeInputs:t}=Xt(n);t.forEach(i=>i.forEach(([o])=>{e.includes(n)||Cs(o,[...e,n])}));let r=Wl(n)?[n.playbackRate]:As(n)?Array.from(n.parameters.values()):Ul(n)?[n.Q,n.detune,n.frequency,n.gain]:zl(n)?[n.offset]:Yl(n)?[n.gain]:Hl(n)?[n.detune,n.frequency]:Zl(n)?[n.pan]:[];for(let i of r){let o=Fr(i);o!==void 0&&o.activeInputs.forEach(([s])=>Cs(s,e))}ae(n)&&nr(n)};var Br=n=>{Cs(n.destination,[])};var _s=n=>n===void 0||typeof n=="number"||typeof n=="string"&&(n==="balanced"||n==="interactive"||n==="playback");var Xl=(n,e,t,r,i,o,s,a,c)=>class extends n{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"?t():f}if(h===null)throw r();if(!_s(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 t();super(h,2);let{latencyHint:d}=l,{sampleRate:m}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:d==="balanced"?512/m:d==="interactive"||d===void 0?256/m:d==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(d*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 e()}):(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()),Br(this)}))}createMediaElementSource(l){return new i(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 d=()=>{this._nativeAudioContext.removeEventListener("statechange",d),this._nativeAudioContext.state==="running"?l():this.resume().then(l,h)};this._nativeAudioContext.addEventListener("statechange",d)}):this._nativeAudioContext.resume().catch(l=>{throw l===void 0||l.code===15?e():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?e():l})}};var Ql=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=s(h),m=i(h,l,d),f=d?e(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=d,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw t();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 Kl=n=>{let e=new WeakMap,t=(r,i)=>K(null,null,function*(){let o=i.destination;return e.set(i,o),yield n(r,i,o),o});return{render(r,i){let o=e.get(i);return o!==void 0?Promise.resolve(o):t(r,i)}}};var Jl=(n,e,t,r,i,o,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let _=new Float32Array(1),v=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),C=s(u),y=!1,T=[0,0,-1,0,1,0],E=[0,0,0],R=()=>{if(y)return;y=!0;let k=r(u,256,9,0);k.onaudioprocess=({inputBuffer:P})=>{let G=[o(P,_,0),o(P,_,1),o(P,_,2),o(P,_,3),o(P,_,4),o(P,_,5)];G.some((Y,V)=>Y!==T[V])&&(l.setOrientation(...G),T=G);let Q=[o(P,_,6),o(P,_,7),o(P,_,8)];Q.some((Y,V)=>Y!==E[V])&&(l.setPosition(...Q),E=Q)},v.connect(k)},M=k=>P=>{P!==T[k]&&(T[k]=P,l.setOrientation(...T))},q=k=>P=>{P!==E[k]&&(E[k]=P,l.setPosition(...E))},L=(k,P,G)=>{let Q=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P});Q.connect(v,0,k),Q.start(),Object.defineProperty(Q.offset,"defaultValue",{get(){return P}});let Y=n({context:c},C,Q.offset,Et,Pt);return a(Y,"value",V=>()=>V.call(Y),V=>ut=>{try{V.call(Y,ut)}catch(At){if(At.code!==9)throw At}R(),C&&G(ut)}),Y.cancelAndHoldAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.cancelAndHoldAtTime),Y.cancelScheduledValues=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.cancelScheduledValues),Y.exponentialRampToValueAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.exponentialRampToValueAtTime),Y.linearRampToValueAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.linearRampToValueAtTime),Y.setTargetAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.setTargetAtTime),Y.setValueAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.setValueAtTime),Y.setValueCurveAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let At=V.apply(Y,ut);return R(),At})(Y.setValueCurveAtTime),Y};return{forwardX:L(0,0,M(0)),forwardY:L(1,0,M(1)),forwardZ:L(2,-1,M(2)),positionX:L(6,0,q(0)),positionY:L(7,0,q(1)),positionZ:L(8,0,q(2)),upX:L(3,0,M(3)),upY:L(4,1,M(4)),upZ:L(5,0,M(5))}},{forwardX:d,forwardY:m,forwardZ:f,positionX:g,positionY:b,positionZ:x,upX:I,upY:w,upZ:S}=l.forwardX===void 0?h():l;return{get forwardX(){return d},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return b},get positionZ(){return x},get upX(){return I},get upY(){return w},get upZ(){return S}}};var oi=n=>"context"in n;var Vr=n=>oi(n[0]);var Ge=(n,e,t,r)=>{for(let i of n)if(t(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return n.add(e),!0};var Fc=(n,e,[t,r],i)=>{Ge(n,[e,t,r],o=>o[0]===e&&o[1]===t,i)};var Bc=(n,[e,t,r],i)=>{let o=n.get(e);o===void 0?n.set(e,new Set([[t,r]])):Ge(o,[t,r],s=>s[0]===t,i)};var Re=n=>"inputs"in n;var Fi=(n,e,t,r)=>{if(Re(e)){let i=e.inputs[r];return n.connect(i,t,0),[i,t,0]}return n.connect(e,t,r),[e,t,r]};var Vc=(n,e,t)=>{for(let r of n)if(r[0]===e&&r[1]===t)return n.delete(r),r;return null};var $l=(n,e,t)=>Pr(n,r=>r[0]===e&&r[1]===t);var Gc=(n,e)=>{if(!ir(n).delete(e))throw new Error("Missing the expected event listener.")};var qc=(n,e,t)=>{let r=qt(n,e),i=Pr(r,o=>o[0]===t);return r.size===0&&n.delete(e),i};var Bi=(n,e,t,r)=>{Re(e)?n.disconnect(e.inputs[r],t,0):n.disconnect(e,t,r)};var vt=n=>qt(ki,n);var si=n=>qt(Xn,n);var xr=n=>Qn.has(n);var Vi=n=>!rr.has(n);var Wc=(n,e)=>new Promise(t=>{if(e!==null)t(!0);else{let r=n.createScriptProcessor(256,1,1),i=n.createGain(),o=n.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=n.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(n.destination),a.connect(i),a.disconnect(i),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,l=>l===1)?t(!0):t(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(n.destination)},a.start()}});var vs=(n,e)=>{let t=new Map;for(let r of n)for(let i of r){let o=t.get(i);t.set(i,o===void 0?1:o+1)}t.forEach((r,i)=>e(i,r))};var ai=n=>"context"in n;var th=n=>{let e=new Map;n.connect=(t=>(r,i=0,o=0)=>{let s=ai(r)?t(r,i,o):t(r,i),a=e.get(r);return a===void 0?e.set(r,[{input:o,output:i}]):a.every(c=>c.input!==o||c.output!==i)&&a.push({input:o,output:i}),s})(n.connect.bind(n)),n.disconnect=(t=>(r,i,o)=>{if(t.apply(n),r===void 0)e.clear();else if(typeof r=="number")for(let[s,a]of e){let c=a.filter(u=>u.output!==r);c.length===0?e.delete(s):e.set(s,c)}else if(e.has(r))if(i===void 0)e.delete(r);else{let s=e.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==i&&(c.input!==o||o===void 0));a.length===0?e.delete(r):e.set(r,a)}}for(let[s,a]of e)a.forEach(c=>{ai(s)?n.connect(s,c.output,c.input):n.connect(s,c.output)})})(n.disconnect)};var fy=(n,e,t,r)=>{let{activeInputs:i,passiveInputs:o}=Fr(e),{outputs:s}=Xt(n),a=ir(n),c=u=>{let l=vt(n),h=si(e);if(u){let d=qc(o,n,t);Fc(i,n,d,!1),!r&&!xr(n)&&l.connect(h,t)}else{let d=$l(i,n,t);Bc(o,d,!1),!r&&!xr(n)&&l.disconnect(h,t)}};return Ge(s,[e,t],u=>u[0]===e&&u[1]===t,!0)?(a.add(c),ae(n)?Fc(i,n,[t,c],!0):Bc(o,[n,t,c],!0),!0):!1},gy=(n,e,t,r)=>{let{activeInputs:i,passiveInputs:o}=Xt(e),s=Vc(i[r],n,t);return s===null?[xs(o,n,t,r)[2],!1]:[s[2],!0]},yy=(n,e,t)=>{let{activeInputs:r,passiveInputs:i}=Fr(e),o=Vc(r,n,t);return o===null?[qc(i,n,t)[1],!1]:[o[2],!0]},Uc=(n,e,t,r,i)=>{let[o,s]=gy(n,t,r,i);if(o!==null&&(Gc(n,o),s&&!e&&!xr(n)&&Bi(vt(n),vt(t),r,i)),ae(t)){let{activeInputs:a}=Xt(t);$n(t,a)}},zc=(n,e,t,r)=>{let[i,o]=yy(n,t,r);i!==null&&(Gc(n,i),o&&!e&&!xr(n)&&vt(n).disconnect(si(t),r))},by=(n,e)=>{let t=Xt(n),r=[];for(let i of t.outputs)Vr(i)?Uc(n,e,...i):zc(n,e,...i),r.push(i[0]);return t.outputs.clear(),r},xy=(n,e,t)=>{let r=Xt(n),i=[];for(let o of r.outputs)o[1]===t&&(Vr(o)?Uc(n,e,...o):zc(n,e,...o),i.push(o[0]),r.outputs.delete(o));return i},Ay=(n,e,t,r,i)=>{let o=Xt(n);return Array.from(o.outputs).filter(s=>s[0]===t&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Vr(s)?Uc(n,e,...s):zc(n,e,...s),o.outputs.delete(s),s[0]))},eh=(n,e,t,r,i,o,s,a,c,u,l,h,d,m,f,g)=>class extends u{constructor(x,I,w,S){super(w),this._context=x,this._nativeAudioNode=w;let _=l(x);h(_)&&t(Wc,()=>Wc(_,g))!==!0&&th(w),ki.set(this,w),bs.set(this,new Set),x.state!=="closed"&&I&&Ve(this),n(this,S,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,I=0,w=0){if(I<0||I>=this._nativeAudioNode.numberOfOutputs)throw i();let S=l(this._context),_=f(S);if(d(x)||m(x))throw o();if(oi(x)){let y=vt(x);try{let E=Fi(this._nativeAudioNode,y,I,w),R=Vi(this);(_||R)&&this._nativeAudioNode.disconnect(...E),this.context.state!=="closed"&&!R&&Vi(x)&&Ve(x)}catch(E){throw E.code===12?o():E}if(e(this,x,I,w,_)){let E=c([this],x);vs(E,r(_))}return x}let v=si(x);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,I),(_||Vi(this))&&this._nativeAudioNode.disconnect(v,I)}catch(y){throw y.code===12?o():y}if(fy(this,x,I,_)){let y=c([this],x);vs(y,r(_))}}disconnect(x,I,w){let S,_=l(this._context),v=f(_);if(x===void 0)S=by(this,v);else if(typeof x=="number"){if(x<0||x>=this.numberOfOutputs)throw i();S=xy(this,v,x)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||oi(x)&&w!==void 0&&(w<0||w>=x.numberOfInputs))throw i();if(S=Ay(this,v,x,I,w),S.length===0)throw o()}for(let C of S){let y=c([this],C);vs(y,a)}}};var rh=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>(m,f,g,b=null,x=null)=>{let I=g.value,w=new Zn(I),S=f?r(w):null,_={get defaultValue(){return I},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,_.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")S===null&&w.flush(m.context.currentTime),w.add(i(v)),g.cancelAndHoldAtTime(v);else{let C=Array.from(w).pop();S===null&&w.flush(m.context.currentTime),w.add(i(v));let y=Array.from(w).pop();g.cancelScheduledValues(v),C!==y&&y!==void 0&&(y.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(y.value,y.endTime):y.type==="linearRampToValue"?g.linearRampToValueAtTime(y.value,y.endTime):y.type==="setValue"?g.setValueAtTime(y.value,y.startTime):y.type==="setValueCurve"&&g.setValueCurveAtTime(y.values,y.startTime,y.duration))}return _},cancelScheduledValues(v){return S===null&&w.flush(m.context.currentTime),w.add(o(v)),g.cancelScheduledValues(v),_},exponentialRampToValueAtTime(v,C){if(v===0)throw new RangeError;if(!Number.isFinite(C)||C<0)throw new RangeError;let y=m.context.currentTime;return S===null&&w.flush(y),Array.from(w).length===0&&(w.add(u(I,y)),g.setValueAtTime(I,y)),w.add(s(v,C)),g.exponentialRampToValueAtTime(v,C),_},linearRampToValueAtTime(v,C){let y=m.context.currentTime;return S===null&&w.flush(y),Array.from(w).length===0&&(w.add(u(I,y)),g.setValueAtTime(I,y)),w.add(a(v,C)),g.linearRampToValueAtTime(v,C),_},setTargetAtTime(v,C,y){return S===null&&w.flush(m.context.currentTime),w.add(c(v,C,y)),g.setTargetAtTime(v,C,y),_},setValueAtTime(v,C){return S===null&&w.flush(m.context.currentTime),w.add(u(v,C)),g.setValueAtTime(v,C),_},setValueCurveAtTime(v,C,y){let T=v instanceof Float32Array?v:new Float32Array(v);if(h!==null&&h.name==="webkitAudioContext"){let E=C+y,R=m.context.sampleRate,M=Math.ceil(C*R),q=Math.floor(E*R),L=q-M,k=new Float32Array(L);for(let G=0;G<L;G+=1){let Q=(T.length-1)/y*((M+G)/R-C),Y=Math.floor(Q),V=Math.ceil(Q);k[G]=Y===V?T[Y]:(1-(Q-Y))*T[Y]+(1-(V-Q))*T[V]}S===null&&w.flush(m.context.currentTime),w.add(l(k,C,y)),g.setValueCurveAtTime(k,C,y);let P=q/R;P<E&&d(_,k[k.length-1],P),d(_,T[T.length-1],E)}else S===null&&w.flush(m.context.currentTime),w.add(l(T,C,y)),g.setValueCurveAtTime(T,C,y);return _}};return t.set(_,g),e.set(_,m),n(_,S),_};var ih=n=>({replay(e){for(let t of n)if(t.type==="exponentialRampToValue"){let{endTime:r,value:i}=t;e.exponentialRampToValueAtTime(i,r)}else if(t.type==="linearRampToValue"){let{endTime:r,value:i}=t;e.linearRampToValueAtTime(i,r)}else if(t.type==="setTarget"){let{startTime:r,target:i,timeConstant:o}=t;e.setTargetAtTime(i,r,o)}else if(t.type==="setValue"){let{startTime:r,value:i}=t;e.setValueAtTime(i,r)}else if(t.type==="setValueCurve"){let{duration:r,startTime:i,values:o}=t;e.setValueCurveAtTime(o,i,r)}else throw new Error("Can't apply an unknown automation.")}});var Gi=class{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((r,i)=>e.call(t,r,i,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}};var Cy={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},nh=(n,e,t,r,i,o,s,a,c,u,l,h,d,m)=>class extends e{constructor(g,b,x){var I;let w=a(g),S=c(w),_=l(D(D({},Cy),x));d(_);let v=Kn.get(w),C=v==null?void 0:v.get(b),y=S||w.state!=="closed"?w:(I=s(w))!==null&&I!==void 0?I:w,T=i(y,S?null:g.baseLatency,u,b,C,_),E=S?r(b,_,C):null;super(g,!0,T,E);let R=[];T.parameters.forEach((q,L)=>{let k=t(this,S,q);R.push([L,k])}),this._nativeAudioWorkletNode=T,this._onprocessorerror=null,this._parameters=new Gi(R),S&&n(w,this);let{activeInputs:M}=o(this);h(T,M)}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 qi(n,e,t,r,i){if(typeof n.copyFromChannel=="function")e[t].byteLength===0&&(e[t]=new Float32Array(128)),n.copyFromChannel(e[t],r,i);else{let o=n.getChannelData(r);if(e[t].byteLength===0)e[t]=o.slice(i,i+128);else{let s=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[t].set(s)}}}var Is=(n,e,t,r,i)=>{typeof n.copyToChannel=="function"?e[t].byteLength!==0&&n.copyToChannel(e[t],r,i):e[t].byteLength!==0&&n.getChannelData(r).set(e[t],i)};var Wi=(n,e)=>{let t=[];for(let r=0;r<n;r+=1){let i=[],o=typeof e=="number"?e:e[r];for(let s=0;s<o;s+=1)i.push(new Float32Array(128));t.push(i)}return t};var oh=(n,e)=>{let t=qt(Jn,n),r=vt(e);return qt(t,r)};var _y=(n,e,t,r,i,o,s)=>K(null,null,function*(){let a=e===null?Math.ceil(n.context.length/128)*128:e.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((b,x)=>b+x,0),l=u===0?null:t.createBuffer(u,a,t.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let h=Xt(n),d=yield oh(t,n),m=Wi(r.numberOfInputs,r.channelCount),f=Wi(r.numberOfOutputs,i),g=Array.from(n.parameters.keys()).reduce((b,x)=>X(D({},b),{[x]:new Float32Array(128)}),{});for(let b=0;b<a;b+=128){if(r.numberOfInputs>0&&e!==null)for(let x=0;x<r.numberOfInputs;x+=1)for(let I=0;I<r.channelCount;I+=1)qi(e,m[x],I,I,b);o.parameterDescriptors!==void 0&&e!==null&&o.parameterDescriptors.forEach(({name:x},I)=>{qi(e,g,x,c+I,b)});for(let x=0;x<r.numberOfInputs;x+=1)for(let I=0;I<i[x];I+=1)f[x][I].byteLength===0&&(f[x][I]=new Float32Array(128));try{let x=m.map((w,S)=>h.activeInputs[S].size===0?[]:w),I=s(b/t.sampleRate,t.sampleRate,()=>d.process(x,f,g));if(l!==null)for(let w=0,S=0;w<r.numberOfOutputs;w+=1){for(let _=0;_<i[w];_+=1)Is(l,f[w],_,S+_,b);S+=i[w]}if(!I)break}catch(x){n.dispatchEvent(new ErrorEvent("processorerror",{colno:x.colno,filename:x.filename,lineno:x.lineno,message:x.message}));break}}return l}),sh=(n,e,t,r,i,o,s,a,c,u,l,h,d,m,f,g)=>(b,x,I)=>{let w=new WeakMap,S=null,_=(v,C)=>K(null,null,function*(){let y=l(v),T=null,E=mt(y,C),R=Array.isArray(x.outputChannelCount)?x.outputChannelCount:Array.from(x.outputChannelCount);if(h===null){let M=R.reduce((P,G)=>P+G,0),q=i(C,{channelCount:Math.max(1,M),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,M)}),L=[];for(let P=0;P<v.numberOfOutputs;P+=1)L.push(r(C,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:R[P]}));let k=s(C,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1});k.connect=e.bind(null,L),k.disconnect=c.bind(null,L),T=[q,L,k]}else E||(y=new h(C,b));if(w.set(C,T===null?y:T[2]),T!==null){if(S===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(d===null)throw new Error("Missing the native OfflineAudioContext constructor.");let G=v.channelCount*v.numberOfInputs,Q=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,Y=G+Q;S=_y(v,Y===0?null:yield K(null,null,function*(){let ut=new d(Y,Math.ceil(v.context.length/128)*128,C.sampleRate),At=[],jt=[];for(let Ct=0;Ct<x.numberOfInputs;Ct+=1)At.push(s(ut,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1})),jt.push(i(ut,{channelCount:x.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:x.channelCount}));let be=yield Promise.all(Array.from(v.parameters.values()).map(Ct=>K(null,null,function*(){let ot=o(ut,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:Ct.value});return yield m(ut,Ct,ot.offset),ot}))),xe=r(ut,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,G+Q)});for(let Ct=0;Ct<x.numberOfInputs;Ct+=1){At[Ct].connect(jt[Ct]);for(let ot=0;ot<x.channelCount;ot+=1)jt[Ct].connect(xe,ot,Ct*x.channelCount+ot)}for(let[Ct,ot]of be.entries())ot.connect(xe,0,G+Ct),ot.start(0);return xe.connect(ut.destination),yield Promise.all(At.map(Ct=>f(v,ut,Ct))),g(ut)}),C,x,R,I,u)}let M=yield S,q=t(C,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[L,k,P]=T;M!==null&&(q.buffer=M,q.start(0)),q.connect(L);for(let G=0,Q=0;G<v.numberOfOutputs;G+=1){let Y=k[G];for(let V=0;V<R[G];V+=1)L.connect(Y,Q+V,V);Q+=R[G]}return P}if(E)for(let[M,q]of v.parameters.entries())yield n(C,q,y.parameters.get(M));else for(let[M,q]of v.parameters.entries())yield m(C,q,y.parameters.get(M));return yield f(v,C,y),y});return{render(v,C){a(C,v);let y=w.get(C);return y!==void 0?Promise.resolve(y):_(v,C)}}};var ah=(n,e,t,r,i,o,s,a,c,u,l,h,d,m,f,g,b,x,I,w)=>class extends f{constructor(_,v){super(_,v),this._nativeContext=_,this._audioWorklet=n===void 0?void 0:{addModule:(C,y)=>n(this,C,y)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(_,v,C){return new t({length:v,numberOfChannels:_,sampleRate:C})}createBufferSource(){return new r(this)}createChannelMerger(_=6){return new o(this,{numberOfInputs:_})}createChannelSplitter(_=6){return new s(this,{numberOfOutputs:_})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(_=1){return new l(this,{maxDelayTime:_})}createDynamicsCompressor(){return new h(this)}createGain(){return new d(this)}createIIRFilter(_,v){return new m(this,{feedback:v,feedforward:_})}createOscillator(){return new g(this)}createPanner(){return new b(this)}createPeriodicWave(_,v,C={disableNormalization:!1}){return new x(this,X(D({},C),{imag:v,real:_}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new w(this)}decodeAudioData(_,v,C){return u(this._nativeContext,_).then(y=>(typeof v=="function"&&v(y),y),y=>{throw typeof C=="function"&&C(y),y})}};var vy={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},ch=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},vy),l),m=i(h,d),f=s(h),g=f?t():null;super(u,!1,m,g),this._Q=e(this,f,m.Q,Et,Pt),this._detune=e(this,f,m.detune,1200*Math.log2(Et),-1200*Math.log2(Et)),this._frequency=e(this,f,m.frequency,u.sampleRate/2,0),this._gain=e(this,f,m.gain,40*Math.log10(Et),Pt),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(d){throw d.code===11?r():d}if(u.length!==l.length||l.length!==h.length)throw r()}};var uh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=mt(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=e(c,h)}return o.set(c,u),l?(yield n(c,a.Q,u.Q),yield n(c,a.detune,u.detune),yield n(c,a.frequency,u.frequency),yield n(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 i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var lh=(n,e)=>(t,r)=>{let i=e.get(t);if(i!==void 0)return i;let o=n.get(t);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(n.set(t,s),s.catch(()=>!1).then(a=>(n.delete(t),e.set(t,a),a))):(e.set(t,s),s)}catch(s){return e.set(t,!1),!1}};var Iy={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},hh=(n,e,t,r,i)=>class extends n{constructor(s,a){let c=r(s),u=D(D({},Iy),a),l=t(c,u),h=i(c)?e():null;super(s,!1,l,h)}};var dh=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!mt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=n(s,u)}return r.set(s,a),yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Sy={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},ph=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=o(D(D({},Sy),c)),h=t(u,l),d=i(u)?e():null;super(a,!1,h,d)}};var mh=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!mt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=n(s,u)}return r.set(s,a),yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var fh=n=>(e,t,r)=>n(t,e,r);var gh=n=>(e,t,r=0,i=0)=>{let o=e[r];if(o===void 0)throw n();return ai(t)?o.connect(t,0,i):o.connect(t,0)};var yh=n=>(e,t)=>{let r=n(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return r.buffer=i,r.loop=!0,r.connect(t),r.start(),()=>{r.stop(),r.disconnect(t)}};var wy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},bh=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},wy),u),d=r(l,h),m=o(l),f=m?t():null;super(c,!1,d,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=d,this._offset=e(this,m,d.offset,Et,Pt),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"){Ve(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),ae(this)&&nr(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var xh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=t(u),d=mt(h,l);if(!d){let m={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(l,m),s!==null&&h.start(s),a!==null&&h.stop(a)}return o.set(l,h),d?yield n(l,u.offset,h.offset):yield r(l,u.offset,h.offset),yield i(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 Ah=n=>e=>(n[0]=e,n[0]);var Ty={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Ch=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=D(D({},Ty),c),h=t(u,l),m=i(u)?e():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 _h=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!mt(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=n(s,u)}return r.set(s,a),Re(a)?yield t(o,s,a.inputs[0]):yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var vh=(n,e)=>(t,r,i)=>{if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(t,r,i)}catch(o){throw o.name==="SyntaxError"?n():o}};var Ih=()=>new DOMException("","DataCloneError");var Yc=n=>{let{port1:e,port2:t}=new MessageChannel;return new Promise(r=>{let i=()=>{t.onmessage=null,e.close(),t.close(),r()};t.onmessage=()=>i();try{e.postMessage(n,[n])}catch(o){}finally{i()}})};var Sh=(n,e,t,r,i,o,s,a,c,u,l)=>(h,d)=>{let m=s(h)?h:o(h);if(i.has(d)){let f=t();return Promise.reject(f)}try{i.add(d)}catch(f){}return e(c,()=>c(m))?m.decodeAudioData(d).then(f=>(Yc(d).catch(()=>{}),e(a,()=>a(f))||l(f),n.add(f),f)):new Promise((f,g)=>{let b=()=>K(null,null,function*(){try{yield Yc(d)}catch(I){}}),x=I=>{g(I),b()};try{m.decodeAudioData(d,I=>{typeof I.copyFromChannel!="function"&&(u(I),Pi(I)),n.add(I),b().then(()=>f(I))},I=>{x(I===null?r():I)})}catch(I){x(I)}})};var wh=(n,e,t,r,i,o,s,a)=>(c,u)=>{let l=e.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=o(c.context),d=a(h);if(l===u){if(e.delete(c),!d&&s(c)){let m=r(c),{outputs:f}=t(c);for(let g of f)if(Vr(g)){let b=r(g[0]);n(m,b,g[1],g[2])}else{let b=i(g[0]);m.connect(b,g[1])}}}else e.set(c,l-u)};var Ny={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Th=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Ny),u),d=r(l,h),m=o(l),f=m?t(h.maxDelayTime):null;super(c,!1,d,f),this._delayTime=e(this,m,d.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var Nh=(n,e,t,r,i)=>o=>{let s=new WeakMap,a=(c,u)=>K(null,null,function*(){let l=t(c),h=mt(l,u);if(!h){let d={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=e(u,d)}return s.set(u,l),h?yield n(u,c.delayTime,l.delayTime):yield r(u,c.delayTime,l.delayTime),yield i(c,u,l),l});return{render(c,u){let l=s.get(u);return l!==void 0?Promise.resolve(l):a(c,u)}}};var Oh=n=>(e,t,r,i)=>n(e[i],o=>o[0]===t&&o[1]===r);var Rh=n=>(e,t)=>{n(e).delete(t)};var Mh=n=>"delayTime"in n;var Dh=(n,e,t)=>function r(i,o){let s=oi(o)?o:t(n,o);if(Mh(s))return[];if(i[0]===s)return[i];if(i.includes(s))return[];let{outputs:a}=e(s);return Array.from(a).map(c=>r([...i,s],c[0])).reduce((c,u)=>c.concat(u),[])};var Ss=(n,e,t)=>{let r=e[t];if(r===void 0)throw n();return r},Eh=n=>(e,t=void 0,r=void 0,i=0)=>t===void 0?e.forEach(o=>o.disconnect()):typeof t=="number"?Ss(n,e,t).disconnect():ai(t)?r===void 0?e.forEach(o=>o.disconnect(t)):i===void 0?Ss(n,e,r).disconnect(t,0):Ss(n,e,r).disconnect(t,0,i):r===void 0?e.forEach(o=>o.disconnect(t)):Ss(n,e,r).disconnect(t,0);var Oy={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},kh=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},Oy),l),m=r(h,d),f=s(h),g=f?t():null;super(u,!1,m,g),this._attack=e(this,f,m.attack),this._knee=e(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=e(this,f,m.ratio),this._release=e(this,f,m.release),this._threshold=e(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,i()}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,i()}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 Lh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=mt(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=e(c,h)}return o.set(c,u),l?(yield n(c,a.attack,u.attack),yield n(c,a.knee,u.knee),yield n(c,a.ratio,u.ratio),yield n(c,a.release,u.release),yield n(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 i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var jh=()=>new DOMException("","EncodingError");var Ph=n=>e=>new Promise((t,r)=>{if(n===null){r(new SyntaxError);return}let i=n.document.head;if(i===null)r(new SyntaxError);else{let o=n.document.createElement("script"),s=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(s),c=n.onerror,u=()=>{n.onerror=c,URL.revokeObjectURL(a)};n.onerror=(l,h,d,m,f)=>{if(h===a||h===n.location.href&&d===1&&m===1)return u(),r(f),!1;if(c!==null)return c(l,h,d,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),t()},o.src=a,o.type="module",i.appendChild(o)}});var Fh=n=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,r,i){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=n(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(t,o,i)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,r,i){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(t,o===void 0?null:o,i)}};var Bh=n=>(e,t,r)=>{Object.defineProperties(n,{currentFrame:{configurable:!0,get(){return Math.round(e*t)}},currentTime:{configurable:!0,get(){return e}}});try{return r()}finally{n!==null&&(delete n.currentFrame,delete n.currentTime)}};var Vh=n=>e=>K(null,null,function*(){try{let t=yield fetch(e);if(t.ok)return[yield t.text(),t.url]}catch(t){}throw n()});var Ry={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Gh=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},Ry),c),h=r(u,l),d=o(u),m=d?t():null;super(a,!1,h,m),this._gain=e(this,d,h.gain,Et,Pt)}get gain(){return this._gain}};var qh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=mt(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=e(c,h)}return o.set(c,u),l?yield n(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Wh=(n,e)=>t=>e(n,t);var Uh=n=>e=>{let t=n(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return t.renderer};var zh=n=>e=>{var t;return(t=n.get(e))!==null&&t!==void 0?t:0};var Yh=n=>e=>{let t=n(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return t.renderer};var Hh=n=>e=>n.get(e);var Nt=()=>new DOMException("","InvalidStateError");var Zh=n=>e=>{let t=n.get(e);if(t===void 0)throw Nt();return t};var Xh=(n,e)=>t=>{let r=n.get(t);if(r!==void 0)return r;if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new e(1,1,44100),n.set(t,r),r};var Qh=n=>e=>{let t=n.get(e);if(t===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return t};var Ui=()=>new DOMException("","InvalidAccessError");var Kh=n=>{n.getFrequencyResponse=(e=>(t,r,i)=>{if(t.length!==r.length||r.length!==i.length)throw Ui();return e.call(n,t,r,i)})(n.getFrequencyResponse)};var My={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Jh=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=i(u),h=D(D({},My),c),d=e(u,l?null:a.baseLatency,h),m=l?t(h.feedback,h.feedforward):null;super(a,!1,d,m),Kh(d),this._nativeIIRFilterNode=d,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var ws=(n,e,t,r,i,o,s,a,c,u,l)=>{let h=u.length,d=a;for(let m=0;m<h;m+=1){let f=t[0]*u[m];for(let g=1;g<i;g+=1){let b=d-g&c-1;f+=t[g]*o[b],f-=n[g]*s[b]}for(let g=i;g<r;g+=1)f+=t[g]*o[d-g&c-1];for(let g=i;g<e;g+=1)f-=n[g]*s[d-g&c-1];o[d]=u[m],s[d]=f,d=d+1&c-1,l[m]=f}return d};var Dy=(n,e,t,r)=>{let i=t instanceof Float64Array?t:new Float64Array(t),o=r instanceof Float64Array?r:new Float64Array(r),s=i.length,a=o.length,c=Math.min(s,a);if(i[0]!==1){for(let f=0;f<s;f+=1)o[f]/=i[0];for(let f=1;f<a;f+=1)i[f]/=i[0]}let u=32,l=new Float32Array(u),h=new Float32Array(u),d=e.createBuffer(n.numberOfChannels,n.length,n.sampleRate),m=n.numberOfChannels;for(let f=0;f<m;f+=1){let g=n.getChannelData(f),b=d.getChannelData(f);l.fill(0),h.fill(0),ws(i,s,o,a,c,l,h,0,u,g,b)}return d},$h=(n,e,t,r,i)=>(o,s)=>{let a=new WeakMap,c=null,u=(l,h)=>K(null,null,function*(){let d=null,m=e(l),f=mt(m,h);if(h.createIIRFilter===void 0?d=n(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,d===null?m:d),d!==null){if(c===null){if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");let b=new t(l.context.destination.channelCount,l.context.length,h.sampleRate);c=K(null,null,function*(){yield r(l,b,b.destination);let x=yield i(b);return Dy(x,h,o,s)})}let g=yield c;return d.buffer=g,d.start(0),d}return yield r(l,h,m),m});return{render(l,h){let d=a.get(h);return d!==void 0?Promise.resolve(d):u(l,h)}}};var td=(n,e,t,r,i,o)=>s=>(a,c)=>{let u=n.get(a);if(u===void 0){if(!s&&o(a)){let l=r(a),{outputs:h}=t(a);for(let d of h)if(Vr(d)){let m=r(d[0]);e(l,m,d[1],d[2])}else{let m=i(d[0]);l.disconnect(m,d[1])}}n.set(a,c)}else n.set(a,u+c)};var ed=(n,e)=>t=>{let r=n.get(t);return e(r)||e(t)};var rd=(n,e)=>t=>n.has(t)||e(t);var id=(n,e)=>t=>n.has(t)||e(t);var nd=(n,e)=>t=>{let r=n.get(t);return e(r)||e(t)};var od=n=>e=>n!==null&&e instanceof n;var sd=n=>e=>n!==null&&typeof n.AudioNode=="function"&&e instanceof n.AudioNode;var ad=n=>e=>n!==null&&typeof n.AudioParam=="function"&&e instanceof n.AudioParam;var cd=(n,e)=>t=>n(t)||e(t);var ud=n=>e=>n!==null&&e instanceof n;var ld=n=>n!==null&&n.isSecureContext;var hd=(n,e,t,r)=>class extends n{constructor(o,s){let a=t(o),c=e(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var Ey={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},dd=(n,e,t,r)=>class extends n{constructor(o,s){let a=t(o);if(r(a))throw new TypeError;let c=D(D({},Ey),s),u=e(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var pd=(n,e,t,r)=>class extends n{constructor(o,s){let a=t(o),c=e(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var md=(n,e,t)=>class extends n{constructor(i,o){let s=t(i),a=e(s,o);super(i,!0,a,null)}};var fd=(n,e,t,r,i)=>class extends r{constructor(s={}){if(i===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new i(s)}catch(l){throw l.code===12&&l.message==="sampleRate is not in range"?e():l}if(a===null)throw t();if(!_s(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 e();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,i.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 n()}):(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()),Br(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?n():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?n():s})}};var gd=(n,e,t,r,i,o)=>class extends t{constructor(a,c){super(a),this._nativeContext=a,Li.set(this,a),r(a)&&i.set(a,new Set),this._destination=new n(this,c),this._listener=e(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 qe=n=>{let e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let t=n.decodeAudioData(e.buffer,()=>{});return t===void 0?!1:(t.catch(()=>{}),!0)}catch(t){}return!1};var ky={numberOfChannels:1},yd=(n,e,t,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=D(D({},ky),s),l=t(c,a,u);n(qe,()=>qe(l))||l.addEventListener("statechange",(()=>{let h=0,d=m=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",d),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):h+=1)};return d})()),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(e()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Br(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var bd=(n,e)=>(t,r,i)=>{let o=new Set;return t.connect=(s=>(a,c=0,u=0)=>{let l=o.size===0;if(e(a))return s.call(t,a,c,u),n(o,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(t,a,c),n(o,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(t.connect),t.disconnect=(s=>(a,c,u)=>{let l=o.size>0;if(a===void 0)s.apply(t),o.clear();else if(typeof a=="number"){s.call(t,a);for(let d of o)d[1]===a&&o.delete(d)}else{e(a)?s.call(t,a,c,u):s.call(t,a,c);for(let d of o)d[0]===a&&(c===void 0||d[1]===c)&&(u===void 0||d[2]===u)&&o.delete(d)}let h=o.size===0;l&&h&&i()})(t.disconnect),t};var ft=(n,e,t)=>{let r=e[t];r!==void 0&&r!==n[t]&&(n[t]=r)};var lt=(n,e)=>{ft(n,e,"channelCount"),ft(n,e,"channelCountMode"),ft(n,e,"channelInterpretation")};var Hc=n=>typeof n.getFloatTimeDomainData=="function";var xd=n=>{n.getFloatTimeDomainData=e=>{let t=new Uint8Array(e.length);n.getByteTimeDomainData(t);let r=Math.max(t.length,n.fftSize);for(let i=0;i<r;i+=1)e[i]=(t[i]-128)*.0078125;return e}};var Ad=(n,e)=>(t,r)=>{let i=t.createAnalyser();if(lt(i,r),!(r.maxDecibels>r.minDecibels))throw e();return ft(i,r,"fftSize"),ft(i,r,"maxDecibels"),ft(i,r,"minDecibels"),ft(i,r,"smoothingTimeConstant"),n(Hc,()=>Hc(i))||xd(i),i};var Cd=n=>n===null?null:n.hasOwnProperty("AudioBuffer")?n.AudioBuffer:null;var bt=(n,e,t)=>{let r=e[t];r!==void 0&&r!==n[t].value&&(n[t].value=r)};var _d=n=>{n.start=(e=>{let t=!1;return(r=0,i=0,o)=>{if(t)throw Nt();e.call(n,r,i,o),t=!0}})(n.start)};var zi=n=>{n.start=(e=>(t=0,r=0,i)=>{if(typeof i=="number"&&i<0||r<0||t<0)throw new RangeError("The parameters can't be negative.");e.call(n,t,r,i)})(n.start)};var Yi=n=>{n.stop=(e=>(t=0)=>{if(t<0)throw new RangeError("The parameter can't be negative.");e.call(n,t)})(n.stop)};var vd=(n,e,t,r,i,o,s,a,c,u,l)=>(h,d)=>{let m=h.createBufferSource();return lt(m,d),bt(m,d,"playbackRate"),ft(m,d,"buffer"),ft(m,d,"loop"),ft(m,d,"loopEnd"),ft(m,d,"loopStart"),e(t,()=>t(h))||_d(m),e(r,()=>r(h))||c(m),e(i,()=>i(h))||u(m,h),e(o,()=>o(h))||zi(m),e(s,()=>s(h))||l(m,h),e(a,()=>a(h))||Yi(m),n(h,m),m};var Id=n=>n===null?null:n.hasOwnProperty("AudioContext")?n.AudioContext:n.hasOwnProperty("webkitAudioContext")?n.webkitAudioContext:null;var Sd=(n,e)=>(t,r,i)=>{let o=t.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}i&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=n(t,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return e(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),e(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),e(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 wd=n=>n===null?null:n.hasOwnProperty("AudioWorkletNode")?n.AudioWorkletNode:null;var Td=n=>{let{port1:e}=new MessageChannel;try{e.postMessage(n)}finally{e.close()}};var Nd=(n,e,t,r,i)=>(o,s,a,c,u,l)=>{if(a!==null)try{let h=new a(o,c,l),d=new Map,m=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw n()}},channelCountMode:{get:()=>"explicit",set:()=>{throw n()}},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=d.get(g[1]);x!==void 0?g[1]=x:(g[1]=I=>{I.type==="error"?(Object.defineProperties(I,{type:{value:"processorerror"}}),b(I)):b(new ErrorEvent(g[0],D({},I)))},d.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=d.get(g[1]);b!==void 0&&(d.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=t(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(o.destination),i(h,()=>f.disconnect(),()=>f.connect(o.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return Td(l),e(o,s,u,l)};var Ts=(n,e)=>n===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(n*e)))));var Od=n=>new Promise((e,t)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),i.close(),e(o)},r.onmessageerror=({data:o})=>{r.close(),i.close(),t(o)},i.postMessage(n)});var Rd=(n,e)=>K(null,null,function*(){let t=yield Od(e);return new n(t)});var Md=(n,e,t,r)=>{let i=Jn.get(n);i===void 0&&(i=new WeakMap,Jn.set(n,i));let o=Rd(t,r);return i.set(e,o),o};var Dd=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>(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(H=>H<1))throw c();if(x.length!==b.numberOfOutputs)throw e();if(b.channelCountMode!=="explicit")throw c();let I=b.channelCount*b.numberOfInputs,w=x.reduce((H,it)=>H+it,0),S=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+S>6||w>6)throw c();let _=new MessageChannel,v=[],C=[];for(let H=0;H<b.numberOfInputs;H+=1)v.push(s(m,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),C.push(i(m,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let y=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:H,maxValue:it,minValue:Yt,name:Ot}of g.parameterDescriptors){let yt=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:b.parameterData[Ot]!==void 0?b.parameterData[Ot]:H===void 0?0:H});Object.defineProperties(yt.offset,{defaultValue:{get:()=>H===void 0?0:H},maxValue:{get:()=>it===void 0?Et:it},minValue:{get:()=>Yt===void 0?Pt:Yt}}),y.push(yt)}let T=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+S)}),E=Ts(f,m.sampleRate),R=a(m,E,I+S,Math.max(1,w)),M=i(m,{channelCount:Math.max(1,w),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,w)}),q=[];for(let H=0;H<b.numberOfOutputs;H+=1)q.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:x[H]}));for(let H=0;H<b.numberOfInputs;H+=1){v[H].connect(C[H]);for(let it=0;it<b.channelCount;it+=1)C[H].connect(T,it,H*b.channelCount+it)}let L=new Gi(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:H},it)=>{let Yt=y[it];return Yt.connect(T,0,I+it),Yt.start(0),[H,Yt.offset]}));T.connect(R);let k=b.channelInterpretation,P=null,G=b.numberOfOutputs===0?[R]:q,Q={get bufferSize(){return E},get channelCount(){return b.channelCount},set channelCount(H){throw t()},get channelCountMode(){return b.channelCountMode},set channelCountMode(H){throw t()},get channelInterpretation(){return k},set channelInterpretation(H){for(let it of v)it.channelInterpretation=H;k=H},get context(){return R.context},get inputs(){return v},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},get onprocessorerror(){return P},set onprocessorerror(H){typeof P=="function"&&Q.removeEventListener("processorerror",P),P=typeof H=="function"?H:null,typeof P=="function"&&Q.addEventListener("processorerror",P)},get parameters(){return L},get port(){return _.port2},addEventListener(...H){return R.addEventListener(H[0],H[1],H[2])},connect:n.bind(null,G),disconnect:u.bind(null,G),dispatchEvent(...H){return R.dispatchEvent(H[0])},removeEventListener(...H){return R.removeEventListener(H[0],H[1],H[2])}},Y=new Map;_.port1.addEventListener=(H=>(...it)=>{if(it[0]==="message"){let Yt=typeof it[1]=="function"?it[1]:typeof it[1]=="object"&&it[1]!==null&&typeof it[1].handleEvent=="function"?it[1].handleEvent:null;if(Yt!==null){let Ot=Y.get(it[1]);Ot!==void 0?it[1]=Ot:(it[1]=yt=>{l(m.currentTime,m.sampleRate,()=>Yt(yt))},Y.set(Yt,it[1]))}}return H.call(_.port1,it[0],it[1],it[2])})(_.port1.addEventListener),_.port1.removeEventListener=(H=>(...it)=>{if(it[0]==="message"){let Yt=Y.get(it[1]);Yt!==void 0&&(Y.delete(it[1]),it[1]=Yt)}return H.call(_.port1,it[0],it[1],it[2])})(_.port1.removeEventListener);let V=null;Object.defineProperty(_.port1,"onmessage",{get:()=>V,set:H=>{typeof V=="function"&&_.port1.removeEventListener("message",V),V=typeof H=="function"?H:null,typeof V=="function"&&(_.port1.addEventListener("message",V),_.port1.start())}}),g.prototype.port=_.port1;let ut=null;Md(m,Q,g,b).then(H=>ut=H);let jt=Wi(b.numberOfInputs,b.channelCount),be=Wi(b.numberOfOutputs,x),xe=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((H,{name:it})=>X(D({},H),{[it]:new Float32Array(128)}),{}),Ct=!0,ot=()=>{b.numberOfOutputs>0&&R.disconnect(M);for(let H=0,it=0;H<b.numberOfOutputs;H+=1){let Yt=q[H];for(let Ot=0;Ot<x[H];Ot+=1)M.disconnect(Yt,it+Ot,Ot);it+=x[H]}},wi=new Map;R.onaudioprocess=({inputBuffer:H,outputBuffer:it})=>{if(ut!==null){let Yt=h(Q);for(let Ot=0;Ot<E;Ot+=128){for(let yt=0;yt<b.numberOfInputs;yt+=1)for(let Dt=0;Dt<b.channelCount;Dt+=1)qi(H,jt[yt],Dt,Dt,Ot);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:yt},Dt)=>{qi(H,xe,yt,I+Dt,Ot)});for(let yt=0;yt<b.numberOfInputs;yt+=1)for(let Dt=0;Dt<x[yt];Dt+=1)be[yt][Dt].byteLength===0&&(be[yt][Dt]=new Float32Array(128));try{let yt=jt.map((we,Rr)=>{if(Yt[Rr].size>0)return wi.set(Rr,E/128),we;let cc=wi.get(Rr);return cc===void 0?[]:(we.every(Qm=>Qm.every(Km=>Km===0))&&(cc===1?wi.delete(Rr):wi.set(Rr,cc-1)),we)});Ct=l(m.currentTime+Ot/m.sampleRate,m.sampleRate,()=>ut.process(yt,be,xe));for(let we=0,Rr=0;we<b.numberOfOutputs;we+=1){for(let kn=0;kn<x[we];kn+=1)Is(it,be[we],kn,Rr+kn,Ot);Rr+=x[we]}}catch(yt){Ct=!1,Q.dispatchEvent(new ErrorEvent("processorerror",{colno:yt.colno,filename:yt.filename,lineno:yt.lineno,message:yt.message}))}if(!Ct){for(let yt=0;yt<b.numberOfInputs;yt+=1){v[yt].disconnect(C[yt]);for(let Dt=0;Dt<b.channelCount;Dt+=1)C[Ot].disconnect(T,Dt,yt*b.channelCount+Dt)}if(g.parameterDescriptors!==void 0){let yt=g.parameterDescriptors.length;for(let Dt=0;Dt<yt;Dt+=1){let we=y[Dt];we.disconnect(T,0,I+Dt),we.stop()}}T.disconnect(R),R.onaudioprocess=null,Mn?ot():Ni();break}}}};let Mn=!1,J=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Ti=()=>R.connect(J).connect(m.destination),Ni=()=>{R.disconnect(J),J.disconnect()},Dn=()=>{if(Ct){Ni(),b.numberOfOutputs>0&&R.connect(M);for(let H=0,it=0;H<b.numberOfOutputs;H+=1){let Yt=q[H];for(let Ot=0;Ot<x[H];Ot+=1)M.connect(Yt,it+Ot,Ot);it+=x[H]}}Mn=!0},En=()=>{Ct&&(Ti(),ot()),Mn=!1};return Ti(),d(Q,Dn,En)};var Zc=(n,e)=>{let t=n.createBiquadFilter();return lt(t,e),bt(t,e,"Q"),bt(t,e,"detune"),bt(t,e,"frequency"),bt(t,e,"gain"),ft(t,e,"type"),t};var Ed=(n,e)=>(t,r)=>{let i=t.createChannelMerger(r.numberOfInputs);return n!==null&&n.name==="webkitAudioContext"&&e(t,i),lt(i,r),i};var kd=n=>{let e=n.numberOfOutputs;Object.defineProperty(n,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Nt()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:t=>{if(t!=="explicit")throw Nt()}}),Object.defineProperty(n,"channelInterpretation",{get:()=>"discrete",set:t=>{if(t!=="discrete")throw Nt()}})};var Hi=(n,e)=>{let t=n.createChannelSplitter(e.numberOfOutputs);return lt(t,e),kd(t),t};var Ld=(n,e,t,r,i)=>(o,s)=>{if(o.createConstantSource===void 0)return t(o,s);let a=o.createConstantSource();return lt(a,s),bt(a,s,"offset"),e(r,()=>r(o))||zi(a),e(i,()=>i(o))||Yi(a),n(o,a),a};var Me=(n,e)=>(n.connect=e.connect.bind(e),n.disconnect=e.disconnect.bind(e),n);var jd=(n,e,t,r)=>(i,a)=>{var c=a,{offset:o}=c,s=Mr(c,["offset"]);let u=i.createBuffer(1,2,44100),l=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=t(i,X(D({},s),{gain:o})),d=u.getChannelData(0);d[0]=1,d[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 n(i,l),r(Me(m,h),f,g)};var Pd=(n,e)=>(t,r)=>{let i=t.createConvolver();if(lt(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),ft(i,r,"buffer"),r.channelCount>2||(e(i,"channelCount",o=>()=>o.call(i),o=>s=>{if(s>2)throw n();return o.call(i,s)}),r.channelCountMode==="max"))throw n();return e(i,"channelCountMode",o=>()=>o.call(i),o=>s=>{if(s==="max")throw n();return o.call(i,s)}),i};var Xc=(n,e)=>{let t=n.createDelay(e.maxDelayTime);return lt(t,e),bt(t,e,"delayTime"),t};var Fd=n=>(e,t)=>{let r=e.createDynamicsCompressor();if(lt(r,t),t.channelCount>2||t.channelCountMode==="max")throw n();return bt(r,t,"attack"),bt(r,t,"knee"),bt(r,t,"ratio"),bt(r,t,"release"),bt(r,t,"threshold"),r};var ce=(n,e)=>{let t=n.createGain();return lt(t,e),bt(t,e,"gain"),t};var Bd=n=>(e,t,r)=>{if(e.createIIRFilter===void 0)return n(e,t,r);let i=e.createIIRFilter(r.feedforward,r.feedback);return lt(i,r),i};function Ly(n,e){let t=e[0]*e[0]+e[1]*e[1];return[(n[0]*e[0]+n[1]*e[1])/t,(n[1]*e[0]-n[0]*e[1])/t]}function jy(n,e){return[n[0]*e[0]-n[1]*e[1],n[0]*e[1]+n[1]*e[0]]}function Vd(n,e){let t=[0,0];for(let r=n.length-1;r>=0;r-=1)t=jy(t,e),t[0]+=n[r];return t}var Gd=(n,e,t,r)=>(i,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=Ts(o,i.sampleRate),d=u instanceof Float64Array?u:new Float64Array(u),m=l instanceof Float64Array?l:new Float64Array(l),f=d.length,g=m.length,b=Math.min(f,g);if(f===0||f>20)throw r();if(d[0]===0)throw e();if(g===0||g>20)throw r();if(m[0]===0)throw e();if(d[0]!==1){for(let y=0;y<g;y+=1)m[y]/=d[0];for(let y=1;y<f;y+=1)d[y]/=d[0]}let x=t(i,h,s,s);x.channelCount=s,x.channelCountMode=a,x.channelInterpretation=c;let I=32,w=[],S=[],_=[];for(let y=0;y<s;y+=1){w.push(0);let T=new Float32Array(I),E=new Float32Array(I);T.fill(0),E.fill(0),S.push(T),_.push(E)}x.onaudioprocess=y=>{let T=y.inputBuffer,E=y.outputBuffer,R=T.numberOfChannels;for(let M=0;M<R;M+=1){let q=T.getChannelData(M),L=E.getChannelData(M);w[M]=ws(d,f,m,g,b,S[M],_[M],w[M],I,q,L)}};let v=i.sampleRate/2;return Me({get bufferSize(){return h},get channelCount(){return x.channelCount},set channelCount(y){x.channelCount=y},get channelCountMode(){return x.channelCountMode},set channelCountMode(y){x.channelCountMode=y},get channelInterpretation(){return x.channelInterpretation},set channelInterpretation(y){x.channelInterpretation=y},get context(){return x.context},get inputs(){return[x]},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},addEventListener(...y){return x.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return x.dispatchEvent(y[0])},getFrequencyResponse(y,T,E){if(y.length!==T.length||T.length!==E.length)throw n();let R=y.length;for(let M=0;M<R;M+=1){let q=-Math.PI*(y[M]/v),L=[Math.cos(q),Math.sin(q)],k=Vd(m,L),P=Vd(d,L),G=Ly(k,P);T[M]=Math.sqrt(G[0]*G[0]+G[1]*G[1]),E[M]=Math.atan2(G[1],G[0])}},removeEventListener(...y){return x.removeEventListener(y[0],y[1],y[2])}},x)};var qd=(n,e)=>n.createMediaElementSource(e.mediaElement);var Wd=(n,e)=>{let t=n.createMediaStreamDestination();return lt(t,e),t.numberOfOutputs===1&&Object.defineProperty(t,"numberOfOutputs",{get:()=>0}),t};var Ud=(n,{mediaStream:e})=>{let t=e.getAudioTracks();t.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=t.slice(0,1),i=n.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:e}),i};var zd=(n,e)=>(t,{mediaStreamTrack:r})=>{if(typeof t.createMediaStreamTrackSource=="function")return t.createMediaStreamTrackSource(r);let i=new MediaStream([r]),o=t.createMediaStreamSource(i);if(r.kind!=="audio")throw n();if(e(t))throw new TypeError;return o};var Yd=n=>n===null?null:n.hasOwnProperty("OfflineAudioContext")?n.OfflineAudioContext:n.hasOwnProperty("webkitOfflineAudioContext")?n.webkitOfflineAudioContext:null;var Hd=(n,e,t,r,i,o)=>(s,a)=>{let c=s.createOscillator();return lt(c,a),bt(c,a,"detune"),bt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):ft(c,a,"type"),e(t,()=>t(s))||zi(c),e(r,()=>r(s))||o(c,s),e(i,()=>i(s))||Yi(c),n(s,c),c};var Zd=n=>(e,t)=>{let r=e.createPanner();return r.orientationX===void 0?n(e,t):(lt(r,t),bt(r,t,"orientationX"),bt(r,t,"orientationY"),bt(r,t,"orientationZ"),bt(r,t,"positionX"),bt(r,t,"positionY"),bt(r,t,"positionZ"),ft(r,t,"coneInnerAngle"),ft(r,t,"coneOuterAngle"),ft(r,t,"coneOuterGain"),ft(r,t,"distanceModel"),ft(r,t,"maxDistance"),ft(r,t,"panningModel"),ft(r,t,"refDistance"),ft(r,t,"rolloffFactor"),r)};var Xd=(n,e,t,r,i,o,s,a,c,u)=>(l,E)=>{var R=E,{coneInnerAngle:h,coneOuterAngle:d,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:b,orientationY:x,orientationZ:I,panningModel:w,positionX:S,positionY:_,positionZ:v,refDistance:C,rolloffFactor:y}=R,T=Mr(R,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let M=l.createPanner();if(T.channelCount>2||T.channelCountMode==="max")throw s();lt(M,T);let q={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},L=t(l,X(D({},q),{channelInterpretation:"speakers",numberOfInputs:6})),k=r(l,X(D({},T),{gain:1})),P=r(l,X(D({},q),{gain:1})),G=r(l,X(D({},q),{gain:0})),Q=r(l,X(D({},q),{gain:0})),Y=r(l,X(D({},q),{gain:0})),V=r(l,X(D({},q),{gain:0})),ut=r(l,X(D({},q),{gain:0})),At=i(l,256,6,1),jt=o(l,X(D({},q),{curve:new Float32Array([1,1]),oversample:"none"})),be=[b,x,I],xe=[S,_,v],Ct=new Float32Array(1);At.onaudioprocess=({inputBuffer:J})=>{let Ti=[c(J,Ct,0),c(J,Ct,1),c(J,Ct,2)];Ti.some((Dn,En)=>Dn!==be[En])&&(M.setOrientation(...Ti),be=Ti);let Ni=[c(J,Ct,3),c(J,Ct,4),c(J,Ct,5)];Ni.some((Dn,En)=>Dn!==xe[En])&&(M.setPosition(...Ni),xe=Ni)},Object.defineProperty(G.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Y.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ut.gain,"defaultValue",{get:()=>0});let ot={get bufferSize(){},get channelCount(){return M.channelCount},set channelCount(J){if(J>2)throw s();k.channelCount=J,M.channelCount=J},get channelCountMode(){return M.channelCountMode},set channelCountMode(J){if(J==="max")throw s();k.channelCountMode=J,M.channelCountMode=J},get channelInterpretation(){return M.channelInterpretation},set channelInterpretation(J){k.channelInterpretation=J,M.channelInterpretation=J},get coneInnerAngle(){return M.coneInnerAngle},set coneInnerAngle(J){M.coneInnerAngle=J},get coneOuterAngle(){return M.coneOuterAngle},set coneOuterAngle(J){M.coneOuterAngle=J},get coneOuterGain(){return M.coneOuterGain},set coneOuterGain(J){if(J<0||J>1)throw e();M.coneOuterGain=J},get context(){return M.context},get distanceModel(){return M.distanceModel},set distanceModel(J){M.distanceModel=J},get inputs(){return[k]},get maxDistance(){return M.maxDistance},set maxDistance(J){if(J<0)throw new RangeError;M.maxDistance=J},get numberOfInputs(){return M.numberOfInputs},get numberOfOutputs(){return M.numberOfOutputs},get orientationX(){return P.gain},get orientationY(){return G.gain},get orientationZ(){return Q.gain},get panningModel(){return M.panningModel},set panningModel(J){M.panningModel=J},get positionX(){return Y.gain},get positionY(){return V.gain},get positionZ(){return ut.gain},get refDistance(){return M.refDistance},set refDistance(J){if(J<0)throw new RangeError;M.refDistance=J},get rolloffFactor(){return M.rolloffFactor},set rolloffFactor(J){if(J<0)throw new RangeError;M.rolloffFactor=J},addEventListener(...J){return k.addEventListener(J[0],J[1],J[2])},dispatchEvent(...J){return k.dispatchEvent(J[0])},removeEventListener(...J){return k.removeEventListener(J[0],J[1],J[2])}};h!==ot.coneInnerAngle&&(ot.coneInnerAngle=h),d!==ot.coneOuterAngle&&(ot.coneOuterAngle=d),m!==ot.coneOuterGain&&(ot.coneOuterGain=m),f!==ot.distanceModel&&(ot.distanceModel=f),g!==ot.maxDistance&&(ot.maxDistance=g),b!==ot.orientationX.value&&(ot.orientationX.value=b),x!==ot.orientationY.value&&(ot.orientationY.value=x),I!==ot.orientationZ.value&&(ot.orientationZ.value=I),w!==ot.panningModel&&(ot.panningModel=w),S!==ot.positionX.value&&(ot.positionX.value=S),_!==ot.positionY.value&&(ot.positionY.value=_),v!==ot.positionZ.value&&(ot.positionZ.value=v),C!==ot.refDistance&&(ot.refDistance=C),y!==ot.rolloffFactor&&(ot.rolloffFactor=y),(be[0]!==1||be[1]!==0||be[2]!==0)&&M.setOrientation(...be),(xe[0]!==0||xe[1]!==0||xe[2]!==0)&&M.setPosition(...xe);let wi=()=>{k.connect(M),n(k,jt,0,0),jt.connect(P).connect(L,0,0),jt.connect(G).connect(L,0,1),jt.connect(Q).connect(L,0,2),jt.connect(Y).connect(L,0,3),jt.connect(V).connect(L,0,4),jt.connect(ut).connect(L,0,5),L.connect(At).connect(l.destination)},Mn=()=>{k.disconnect(M),a(k,jt,0,0),jt.disconnect(P),P.disconnect(L),jt.disconnect(G),G.disconnect(L),jt.disconnect(Q),Q.disconnect(L),jt.disconnect(Y),Y.disconnect(L),jt.disconnect(V),V.disconnect(L),jt.disconnect(ut),ut.disconnect(L),L.disconnect(At),At.disconnect(l.destination)};return u(Me(ot,M),wi,Mn)};var Qd=n=>(e,{disableNormalization:t,imag:r,real:i})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(s,o,{disableNormalization:t});if(Array.from(r).length<2)throw n();return a};var Zi=(n,e,t,r)=>n.createScriptProcessor(e,t,r);var Kd=(n,e)=>(t,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw e();if(t.createStereoPanner===void 0)return n(t,r);let o=t.createStereoPanner();return lt(o,r),bt(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw e()}}),o};var Jd=(n,e,t,r,i,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=X(D({},u),{oversample:"none"}),h=(f,g,b,x)=>{let I=new Float32Array(16385),w=new Float32Array(16385);for(let T=0;T<16385;T+=1){let E=T/16384*c;I[T]=Math.cos(E),w[T]=Math.sin(E)}let S=t(f,X(D({},u),{gain:0})),_=r(f,X(D({},l),{curve:I})),v=r(f,X(D({},l),{curve:a})),C=t(f,X(D({},u),{gain:0})),y=r(f,X(D({},l),{curve:w}));return{connectGraph(){g.connect(S),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(C),v.connect(b),b.connect(_.inputs===void 0?_:_.inputs[0]),b.connect(y.inputs===void 0?y:y.inputs[0]),_.connect(S.gain),y.connect(C.gain),S.connect(x,0,0),C.connect(x,0,1)},disconnectGraph(){g.disconnect(S),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(C),v.disconnect(b),b.disconnect(_.inputs===void 0?_:_.inputs[0]),b.disconnect(y.inputs===void 0?y:y.inputs[0]),_.disconnect(S.gain),y.disconnect(C.gain),S.disconnect(x,0,0),C.disconnect(x,0,1)}}},d=(f,g,b,x)=>{let I=new Float32Array(16385),w=new Float32Array(16385),S=new Float32Array(16385),_=new Float32Array(16385),v=Math.floor(16385/2);for(let G=0;G<16385;G+=1)if(G>v){let Q=(G-v)/(16384-v)*c;I[G]=Math.cos(Q),w[G]=Math.sin(Q),S[G]=0,_[G]=1}else{let Q=G/(16384-v)*c;I[G]=1,w[G]=0,S[G]=Math.cos(Q),_[G]=Math.sin(Q)}let C=e(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),y=t(f,X(D({},u),{gain:0})),T=r(f,X(D({},l),{curve:I})),E=t(f,X(D({},u),{gain:0})),R=r(f,X(D({},l),{curve:w})),M=r(f,X(D({},l),{curve:a})),q=t(f,X(D({},u),{gain:0})),L=r(f,X(D({},l),{curve:S})),k=t(f,X(D({},u),{gain:0})),P=r(f,X(D({},l),{curve:_}));return{connectGraph(){g.connect(C),g.connect(M.inputs===void 0?M:M.inputs[0]),C.connect(y,0),C.connect(E,0),C.connect(q,1),C.connect(k,1),M.connect(b),b.connect(T.inputs===void 0?T:T.inputs[0]),b.connect(R.inputs===void 0?R:R.inputs[0]),b.connect(L.inputs===void 0?L:L.inputs[0]),b.connect(P.inputs===void 0?P:P.inputs[0]),T.connect(y.gain),R.connect(E.gain),L.connect(q.gain),P.connect(k.gain),y.connect(x,0,0),q.connect(x,0,0),E.connect(x,0,1),k.connect(x,0,1)},disconnectGraph(){g.disconnect(C),g.disconnect(M.inputs===void 0?M:M.inputs[0]),C.disconnect(y,0),C.disconnect(E,0),C.disconnect(q,1),C.disconnect(k,1),M.disconnect(b),b.disconnect(T.inputs===void 0?T:T.inputs[0]),b.disconnect(R.inputs===void 0?R:R.inputs[0]),b.disconnect(L.inputs===void 0?L:L.inputs[0]),b.disconnect(P.inputs===void 0?P:P.inputs[0]),T.disconnect(y.gain),R.disconnect(E.gain),L.disconnect(q.gain),P.disconnect(k.gain),y.disconnect(x,0,0),q.disconnect(x,0,0),E.disconnect(x,0,1),k.disconnect(x,0,1)}}},m=(f,g,b,x,I)=>{if(g===1)return h(f,b,x,I);if(g===2)return d(f,b,x,I);throw i()};return(f,w)=>{var S=w,{channelCount:g,channelCountMode:b,pan:x}=S,I=Mr(S,["channelCount","channelCountMode","pan"]);if(b==="max")throw i();let _=n(f,X(D({},I),{channelCount:1,channelCountMode:b,numberOfInputs:2})),v=t(f,X(D({},I),{channelCount:g,channelCountMode:b,gain:1})),C=t(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:x}),{connectGraph:y,disconnectGraph:T}=m(f,g,v,C,_);Object.defineProperty(C.gain,"defaultValue",{get:()=>0}),Object.defineProperty(C.gain,"maxValue",{get:()=>1}),Object.defineProperty(C.gain,"minValue",{get:()=>-1});let E={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(L){v.channelCount!==L&&(R&&T(),{connectGraph:y,disconnectGraph:T}=m(f,L,v,C,_),R&&y()),v.channelCount=L},get channelCountMode(){return v.channelCountMode},set channelCountMode(L){if(L==="clamped-max"||L==="max")throw i();v.channelCountMode=L},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(L){v.channelInterpretation=L},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return C.gain},addEventListener(...L){return v.addEventListener(L[0],L[1],L[2])},dispatchEvent(...L){return v.dispatchEvent(L[0])},removeEventListener(...L){return v.removeEventListener(L[0],L[1],L[2])}},R=!1,M=()=>{y(),R=!0},q=()=>{T(),R=!1};return o(Me(E,_),M,q)}};var $d=(n,e,t,r,i,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return t(a,c);lt(u,c);let l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw e();ft(u,{curve:l},"curve"),ft(u,c,"oversample");let h=null,d=!1;return s(u,"curve",g=>()=>g.call(u),g=>b=>(g.call(u,b),d&&(r(b)&&h===null?h=n(a,u):!r(b)&&h!==null&&(h(),h=null)),b)),i(u,()=>{d=!0,r(u.curve)&&(h=n(a,u))},()=>{d=!1,h!==null&&(h(),h=null)})};var tp=(n,e,t,r,i)=>(o,u)=>{var l=u,{curve:s,oversample:a}=l,c=Mr(l,["curve","oversample"]);let h=o.createWaveShaper(),d=o.createWaveShaper();lt(h,c),lt(d,c);let m=t(o,X(D({},c),{gain:1})),f=t(o,X(D({},c),{gain:-1})),g=t(o,X(D({},c),{gain:1})),b=t(o,X(D({},c),{gain:-1})),x=null,I=!1,w=null,S={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(C){m.channelCount=C,f.channelCount=C,h.channelCount=C,g.channelCount=C,d.channelCount=C,b.channelCount=C},get channelCountMode(){return h.channelCountMode},set channelCountMode(C){m.channelCountMode=C,f.channelCountMode=C,h.channelCountMode=C,g.channelCountMode=C,d.channelCountMode=C,b.channelCountMode=C},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(C){m.channelInterpretation=C,f.channelInterpretation=C,h.channelInterpretation=C,g.channelInterpretation=C,d.channelInterpretation=C,b.channelInterpretation=C},get context(){return h.context},get curve(){return w},set curve(C){if(C!==null&&C.length<2)throw e();if(C===null)h.curve=C,d.curve=C;else{let y=C.length,T=new Float32Array(y+2-y%2),E=new Float32Array(y+2-y%2);T[0]=C[0],E[0]=-C[y-1];let R=Math.ceil((y+1)/2),M=(y+1)/2-1;for(let q=1;q<R;q+=1){let L=q/R*M,k=Math.floor(L),P=Math.ceil(L);T[q]=k===P?C[k]:(1-(L-k))*C[k]+(1-(P-L))*C[P],E[q]=k===P?-C[y-1-k]:-((1-(L-k))*C[y-1-k])-(1-(P-L))*C[y-1-P]}T[R]=y%2===1?C[R-1]:(C[R-2]+C[R-1])/2,h.curve=T,d.curve=E}w=C,I&&(r(w)&&x===null?x=n(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(C){h.oversample=C,d.oversample=C},addEventListener(...C){return m.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return m.dispatchEvent(C[0])},removeEventListener(...C){return m.removeEventListener(C[0],C[1],C[2])}};s!==null&&(S.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==S.oversample&&(S.oversample=a);let _=()=>{m.connect(h).connect(g),m.connect(f).connect(d).connect(b).connect(g),I=!0,r(w)&&(x=n(o,m))},v=()=>{m.disconnect(h),h.disconnect(g),m.disconnect(f),f.disconnect(d),d.disconnect(b),b.disconnect(g),I=!1,x!==null&&(x(),x=null)};return i(Me(S,g),_,v)};var Jt=()=>new DOMException("","NotSupportedError");var Py={numberOfChannels:1},ep=(n,e,t,r,i)=>class extends n{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:d}=D(D({},Py),u),m=r(h,l,d);e(qe,()=>qe(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(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Br(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var Fy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},rp=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Fy),u),d=t(l,h),m=o(l),f=m?r():null,g=c.sampleRate/2;super(c,!1,d,f),this._detune=e(this,m,d.detune,153600,-153600),this._frequency=e(this,m,d.frequency,g,-g),this._nativeOscillatorNode=d,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"){Ve(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),ae(this)&&nr(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var ip=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(l,h)=>K(null,null,function*(){let d=t(l),m=mt(d,h);if(!m){let f={channelCount:d.channelCount,channelCountMode:d.channelCountMode,channelInterpretation:d.channelInterpretation,detune:d.detune.value,frequency:d.frequency.value,periodicWave:s===null?void 0:s,type:d.type};d=e(h,f),a!==null&&d.start(a),c!==null&&d.stop(c)}return o.set(h,d),m?(yield n(h,l.detune,d.detune),yield n(h,l.frequency,d.frequency)):(yield r(h,l.detune,d.detune),yield r(h,l.frequency,d.frequency)),yield i(l,h,d),d});return{set periodicWave(l){s=l},set start(l){a=l},set stop(l){c=l},render(l,h){let d=o.get(h);return d!==void 0?Promise.resolve(d):u(l,h)}}};var By={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},np=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},By),u),d=t(l,h),m=o(l),f=m?r():null;super(c,!1,d,f),this._nativePannerNode=d,this._orientationX=e(this,m,d.orientationX,Et,Pt),this._orientationY=e(this,m,d.orientationY,Et,Pt),this._orientationZ=e(this,m,d.orientationZ,Et,Pt),this._positionX=e(this,m,d.positionX,Et,Pt),this._positionY=e(this,m,d.positionY,Et,Pt),this._positionZ=e(this,m,d.positionZ,Et,Pt),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 op=(n,e,t,r,i,o,s,a,c,u)=>()=>{let l=new WeakMap,h=null,d=(m,f)=>K(null,null,function*(){let g=null,b=o(m),x={channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation},I=X(D({},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=mt(b,f);if("bufferSize"in b)g=r(f,X(D({},x),{gain:1}));else if(!w){let S=X(D({},I),{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=i(f,S)}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 R=new s(6,m.context.length,f.sampleRate),M=e(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});M.connect(R.destination),h=K(null,null,function*(){let q=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((L,k)=>K(null,null,function*(){let P=t(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:k===0?1:0});return yield a(R,L,P.offset),P})));for(let L=0;L<6;L+=1)q[L].connect(M,0,L),q[L].start(0);return u(R)})}let S=yield h,_=r(f,X(D({},x),{gain:1}));yield c(m,f,_);let v=[];for(let R=0;R<S.numberOfChannels;R+=1)v.push(S.getChannelData(R));let C=[v[0][0],v[1][0],v[2][0]],y=[v[3][0],v[4][0],v[5][0]],T=r(f,X(D({},x),{gain:1})),E=i(f,X(D({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:y[0],positionY:y[1],positionZ:y[2]}));_.connect(T).connect(E.inputs[0]),E.connect(g);for(let R=128;R<S.length;R+=128){let M=[v[0][R],v[1][R],v[2][R]],q=[v[3][R],v[4][R],v[5][R]];if(M.some((L,k)=>L!==C[k])||q.some((L,k)=>L!==y[k])){C=M,y=q;let L=R/f.sampleRate;T.gain.setValueAtTime(0,L),T=r(f,X(D({},x),{gain:0})),E=i(f,X(D({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:y[0],positionY:y[1],positionZ:y[2]})),T.gain.setValueAtTime(1,L),_.connect(T).connect(E.inputs[0]),E.connect(g)}}return g}return w?(yield n(f,m.orientationX,b.orientationX),yield n(f,m.orientationY,b.orientationY),yield n(f,m.orientationZ,b.orientationZ),yield n(f,m.positionX,b.positionX),yield n(f,m.positionY,b.positionY),yield n(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)),Re(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):d(m,f)}}};var Vy={disableNormalization:!1},sp=(n,e,t,r)=>class ap{constructor(o,s){let a=e(o),c=r(D(D({},Vy),s)),u=n(a,c);return t.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===ap.prototype||t.has(o)}};var cp=(n,e)=>(t,r,i)=>(n(r).replay(i),e(r,t,i));var up=(n,e,t)=>(r,i,o)=>K(null,null,function*(){let s=n(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>K(null,[h],function*([u,l]){let m=yield e(u).render(u,i),f=r.context.destination;!t(u)&&(r!==f||!t(r))&&m.connect(o,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var lp=(n,e,t)=>(r,i,o)=>K(null,null,function*(){let s=e(r);yield Promise.all(Array.from(s.activeInputs).map(u=>K(null,[u],function*([a,c]){let h=yield n(a).render(a,i);t(a)||h.connect(o,c)})))});var hp=(n,e,t,r)=>i=>n(qe,()=>qe(i))?Promise.resolve(n(r,r)).then(o=>{if(!o){let s=t(i,512,0,1);i.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>i.currentTime,s.connect(i.destination)}return i.startRendering()}):new Promise(o=>{let s=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var dp=n=>(e,t)=>{n.set(e,t)};var pp=n=>(e,t)=>n.set(e,t);var mp=(n,e,t,r,i,o,s,a)=>(c,u)=>t(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(l=>t(l).render(l,u)))).then(()=>i(u)).then(l=>(typeof l.copyFromChannel!="function"?(s(l),Pi(l)):e(o,()=>o(l))||a(l),n.add(l),l));var Gy={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},fp=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},Gy),c),h=t(u,l),d=o(u),m=d?r():null;super(a,!1,h,m),this._pan=e(this,d,h.pan)}get pan(){return this._pan}};var gp=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=mt(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=e(c,h)}return o.set(c,u),l?yield n(c,a.pan,u.pan):yield r(c,a.pan,u.pan),Re(u)?yield i(a,c,u.inputs[0]):yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var yp=n=>()=>{if(n===null)return!1;try{new n({length:1,sampleRate:44100})}catch(e){return!1}return!0};var bp=(n,e)=>()=>K(null,null,function*(){if(n===null)return!0;if(e===null)return!1;let t=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 e(1,128,44100),i=URL.createObjectURL(t),o=!1,s=!1;try{yield r.audioWorklet.addModule(i);let a=new n(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(i)}return o&&!s});var xp=(n,e)=>()=>{if(e===null)return Promise.resolve(!1);let t=new e(1,1,44100),r=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{t.oncomplete=()=>{r.disconnect(),i(t.currentTime!==0)},t.startRendering()})};var Qc=()=>new DOMException("","UnknownError");var qy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Ap=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},qy),u),d=t(l,h),f=o(l)?r():null;super(c,!0,d,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=d,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 e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var Cp=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!mt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=n(s,u)}return r.set(s,a),Re(a)?yield t(o,s,a.inputs[0]):yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var _p=()=>typeof window=="undefined"?null:window;var vp=(n,e)=>t=>{t.copyFromChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=t.numberOfChannels)throw e();let c=t.length,u=t.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)r[h]=u[h+s]},t.copyToChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=t.numberOfChannels)throw e();let c=t.length,u=t.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 Ip=n=>e=>{e.copyFromChannel=(t=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<e.length)return t.call(e,r,a,s)})(e.copyFromChannel),e.copyToChannel=(t=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<e.length)return t.call(e,r,a,s)})(e.copyToChannel)};var Sp=n=>(e,t)=>{let r=t.createBuffer(1,1,44100);e.buffer===null&&(e.buffer=r),n(e,"buffer",i=>()=>{let o=i.call(e);return o===r?null:o},i=>o=>i.call(e,o===null?r:o))};var wp=(n,e)=>(t,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw n()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw n()}});let i=t.createBufferSource();e(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(r,0,c)},()=>i.disconnect(r))};var Kc=(n,e,t)=>n.copyFromChannel===void 0?n.getChannelData(t)[0]:(n.copyFromChannel(e,t),e[0]);var Jc=n=>{if(n===null)return!1;let e=n.length;return e%2!==0?n[Math.floor(e/2)]!==0:n[e/2-1]+n[e/2]!==0};var Xi=(n,e,t,r)=>{let i=n;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);let{get:o,set:s}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(n,e,{get:t(o),set:r(s)})};var Tp=n=>X(D({},n),{outputChannelCount:n.outputChannelCount!==void 0?n.outputChannelCount:n.numberOfInputs===1&&n.numberOfOutputs===1?[n.channelCount]:Array.from({length:n.numberOfOutputs},()=>1)});var Np=n=>X(D({},n),{channelCount:n.numberOfOutputs});var Op=n=>{let{imag:e,real:t}=n;return e===void 0?t===void 0?X(D({},n),{imag:[0,0],real:[0,0]}):X(D({},n),{imag:Array.from(t,()=>0),real:t}):t===void 0?X(D({},n),{imag:e,real:Array.from(e,()=>0)}):X(D({},n),{imag:e,real:t})};var $c=(n,e,t)=>{try{n.setValueAtTime(e,t)}catch(r){if(r.code!==9)throw r;$c(n,e,t+1e-7)}};var Rp=n=>{let e=n.createBufferSource();e.start();try{e.start()}catch(t){return!0}return!1};var Mp=n=>{let e=n.createBufferSource(),t=n.createBuffer(1,1,44100);e.buffer=t;try{e.start(0,1)}catch(r){return!1}return!0};var Dp=n=>{let e=n.createBufferSource();e.start();try{e.stop()}catch(t){return!1}return!0};var Ns=n=>{let e=n.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1};var tu=n=>{let e=n.createBuffer(1,1,44100),t=n.createBufferSource();t.buffer=e,t.start(),t.stop();try{return t.stop(),!0}catch(r){return!1}};var Os=n=>{let e=n.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1};var Ep=n=>{let{port1:e,port2:t}=new MessageChannel;try{e.postMessage(n)}finally{e.close(),t.close()}};var kp=n=>{n.start=(e=>(t=0,r=0,i)=>{let o=n.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/n.context.sampleRate?e.call(n,t,0,0):e.call(n,t,s,i)})(n.start)};var eu=(n,e)=>{let t=e.createGain();n.connect(t);let r=(i=>()=>{i.call(n,t),n.removeEventListener("ended",r)})(n.disconnect);n.addEventListener("ended",r),Me(n,t),n.stop=(i=>{let o=!1;return(s=0)=>{if(o)try{i.call(n,s)}catch(a){t.gain.setValueAtTime(0,s)}else i.call(n,s),o=!0}})(n.stop)};var ci=(n,e)=>t=>{let r={value:n};return Object.defineProperties(t,{currentTarget:r,target:r}),typeof e=="function"?e.call(n,t):e.handleEvent.call(n,t)};var Wy=Il(Ge),Uy=kl(Ge),zy=Oh(Pr),jp=new WeakMap,Yy=zh(jp),De=lh(new Map,new WeakMap),or=_p(),Pp=Ad(De,Oe),ru=Uh(Xt),$t=up(Xt,ru,xr),Hy=Fl(Pp,vt,$t),wt=Zh(Li),Ar=Yd(or),It=ud(Ar),Fp=new WeakMap,Bp=Fh(ci),Qi=Id(or),iu=od(Qi),nu=sd(or),Vp=ad(or),to=wd(or),Ft=eh(Sl(gs),El(Wy,Uy,Fi,zy,Bi,Xt,Yy,ir,vt,Ge,ae,xr,Vi),De,td(Qn,Bi,Xt,vt,si,ae),Oe,Ui,Jt,wh(Fi,Qn,Xt,vt,si,wt,ae,It),Dh(Fp,Xt,qt),Bp,wt,iu,nu,Vp,It,to),Zy=Pl(Ft,Hy,Oe,Pp,wt,It);var ou=new WeakSet,Lp=Cd(or),Gp=Ah(new Uint32Array(1)),su=vp(Gp,Oe),au=Ip(Gp),cu=Bl(ou,De,Jt,Lp,Ar,yp(Lp),su,au);var Rs=Ll(ce),qp=lp(ru,Fr,xr),sr=fh(qp),Ki=vd(Rs,De,Rp,Mp,Dp,Ns,tu,Os,kp,Sp(Xi),eu),ar=cp(Yh(Fr),qp),Xy=ql(sr,Ki,vt,ar,$t),We=rh(wl(ys),Fp,Xn,ih,Dc,Ec,kc,Lc,jc,Mi,Un,Qi,$c),Qy=Gl(Ft,Xy,We,Nt,Ki,wt,It,ci);var Ky=Ql(Ft,Kl,Oe,Nt,Sd(ce,Xi),wt,It,$t),Jy=uh(sr,Zc,vt,ar,$t),ui=pp(jp),$y=ch(Ft,We,Jy,Ui,Zc,wt,It,ui),Gr=bd(Ge,nu),tb=wp(Nt,Gr),qr=Ed(Qi,tb),eb=dh(qr,vt,$t),rb=hh(Ft,eb,qr,wt,It),ib=mh(Hi,vt,$t),nb=ph(Ft,ib,Hi,wt,It,Np),ob=jd(Rs,Ki,ce,Gr),Ji=Ld(Rs,De,ob,Ns,Os),sb=xh(sr,Ji,vt,ar,$t),ab=bh(Ft,We,sb,Ji,wt,It,ci),Wp=Pd(Jt,Xi),cb=_h(Wp,vt,$t),ub=Ch(Ft,cb,Wp,wt,It,ui),lb=Nh(sr,Xc,vt,ar,$t),hb=Th(Ft,We,lb,Xc,wt,It,ui),Up=Fd(Jt),db=Lh(sr,Up,vt,ar,$t),pb=kh(Ft,We,db,Up,Jt,wt,It,ui),mb=qh(sr,ce,vt,ar,$t),fb=Gh(Ft,We,mb,ce,wt,It),gb=Gd(Ui,Nt,Zi,Jt),Ms=hp(De,ce,Zi,xp(ce,Ar)),yb=$h(Ki,vt,Ar,$t,Ms),bb=Bd(gb),xb=Jh(Ft,bb,yb,wt,It,ui),Ab=Jl(We,qr,Ji,Zi,Jt,Kc,It,Xi),zp=new WeakMap,uu=gd(Ky,Ab,Bp,It,zp,ci),Yp=Hd(Rs,De,Ns,tu,Os,eu),Cb=ip(sr,Yp,vt,ar,$t),_b=rp(Ft,We,Yp,Cb,wt,It,ci),Hp=yh(Ki),vb=tp(Hp,Nt,ce,Jc,Gr),Ds=$d(Hp,Nt,vb,Jc,Gr,Qi,Xi),Ib=Xd(Fi,Nt,qr,ce,Zi,Ds,Jt,Bi,Kc,Gr),Zp=Zd(Ib),Sb=op(sr,qr,Ji,ce,Zp,vt,Ar,ar,$t,Ms),wb=np(Ft,We,Zp,Sb,wt,It,ui),Tb=Qd(Oe),Nb=sp(Tb,wt,new WeakSet,Op),Ob=Jd(qr,Hi,ce,Ds,Jt,Gr),Xp=Kd(Ob,Jt),Rb=gp(sr,Xp,vt,ar,$t),Mb=fp(Ft,We,Xp,Rb,wt,It),Db=Cp(Ds,vt,$t),Eb=Ap(Ft,Nt,Ds,Db,wt,It,ui),Qp=ld(or),lu=Bh(or),Kp=new WeakMap,kb=Xh(Kp,Ar),Lb=Qp?Dl(De,Jt,Ph(or),lu,Vh(vl),wt,kb,It,to,new WeakMap,new WeakMap,bp(to,Ar),or):void 0,jb=cd(iu,It),Pb=Sh(ou,De,Ih,jh,new WeakSet,wt,jb,ji,qe,su,au),Jp=ah(Lb,Zy,cu,Qy,$y,rb,nb,ab,ub,Pb,hb,pb,fb,xb,uu,_b,wb,Nb,Mb,Eb),Fb=hd(Ft,qd,wt,It),Bb=dd(Ft,Wd,wt,It),Vb=pd(Ft,Ud,wt,It),Gb=zd(Nt,It),qb=md(Ft,Gb,wt),$p=Xl(Jp,Nt,Jt,Qc,Fb,Bb,Vb,qb,Qi);var hu=Qh(zp),Wb=jl(hu),tm=gh(Oe),Ub=Rh(hu),em=Eh(Oe),rm=new WeakMap,zb=Wh(rm,qt),Yb=Dd(tm,Oe,Nt,qr,Hi,Ji,ce,Zi,Jt,em,lu,zb,Gr),Hb=Nd(Nt,Yb,ce,Jt,Gr),Zb=sh(sr,tm,Ki,qr,Hi,Ji,ce,Ub,em,lu,vt,to,Ar,ar,$t,Ms),Xb=Hh(Kp),Qb=dp(rm),du=Qp?nh(Wb,Ft,We,Zb,Hb,Xt,Xb,wt,It,to,Tp,Qb,Ep,ci):void 0;var l4=fd(Nt,Jt,Qc,uu,Qi);var im=vh(Jt,Ar),nm=mp(ou,De,ru,hu,Ms,ji,su,au),h4=yd(De,Nt,im,uu,nm);var om=ep(Jp,De,Nt,im,nm);var sm=ed(Li,iu),am=rd(ki,nu),cm=id(Xn,Vp),um=nd(Li,It);function Bt(n){return n===void 0}function et(n){return n!==void 0}function lm(n){return typeof n=="function"}function te(n){return typeof n=="number"}function Ue(n){return Object.prototype.toString.call(n)==="[object Object]"&&n.constructor===Object}function pu(n){return typeof n=="boolean"}function Rt(n){return Array.isArray(n)}function ie(n){return typeof n=="string"}function eo(n){return ie(n)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(n)}function z(n,e){if(!n)throw new Error(e)}function kt(n,e,t=1/0){if(!(e<=n&&n<=t))throw new RangeError(`Value must be within [${e}, ${t}], got: ${n}`)}function Es(n){!n.isOffline&&n.state!=="running"&&li('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var dm=!1,hm=!1;function mu(n){dm=n}function pm(n){Bt(n)&&dm&&!hm&&(hm=!0,li("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var mm=console;function fm(...n){mm.log(...n)}function li(...n){mm.warn(...n)}function gm(n){return new $p(n)}function ym(n,e,t){return new om(n,e,t)}var ne=typeof self=="object"?self:null,bm=ne&&(ne.hasOwnProperty("AudioContext")||ne.hasOwnProperty("webkitAudioContext"));function xm(n,e,t){return z(et(du),"AudioWorkletNode only works in a secure context (https or localhost)"),new(n instanceof(ne==null?void 0:ne.BaseAudioContext)?ne==null?void 0:ne.AudioWorkletNode:du)(n,e,t)}function oe(n,e,t,r){var i=arguments.length,o=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(e,t,o):s(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o}function ht(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=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):i(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})}var ks=class{constructor(e,t,r,i){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let e=new Blob([`
1
+ /* WebMusicScore v5.2.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
+ "use strict";var WebMusicScore=(()=>{var os=Object.defineProperty,$m=Object.defineProperties,tf=Object.getOwnPropertyDescriptor,ef=Object.getOwnPropertyDescriptors,rf=Object.getOwnPropertyNames,ns=Object.getOwnPropertySymbols;var hc=Object.prototype.hasOwnProperty,Uu=Object.prototype.propertyIsEnumerable;var zu=Math.pow,lc=(n,e,t)=>e in n?os(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))hc.call(e,t)&&lc(n,t,e[t]);if(ns)for(var t of ns(e))Uu.call(e,t)&&lc(n,t,e[t]);return n},X=(n,e)=>$m(n,ef(e));var Mr=(n,e)=>{var t={};for(var r in n)hc.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&ns)for(var r of ns(n))e.indexOf(r)<0&&Uu.call(n,r)&&(t[r]=n[r]);return t};var Ri=(n,e)=>{for(var t in e)os(n,t,{get:e[t],enumerable:!0})},nf=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rf(e))!hc.call(n,i)&&i!==t&&os(n,i,{get:()=>e[i],enumerable:!(r=tf(e,i))||r.enumerable});return n};var of=n=>nf(os({},"__esModule",{value:!0}),n);var p=(n,e,t)=>lc(n,typeof e!="symbol"?e+"":e,t);var K=(n,e,t)=>new Promise((r,i)=>{var o=c=>{try{a(t.next(c))}catch(u){i(u)}},s=c=>{try{a(t.throw(c))}catch(u){i(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((t=t.apply(n,e)).next())});var lA={};Ri(lA,{Audio:()=>fo,Core:()=>yc,Pieces:()=>Wu,Score:()=>qu,Theory:()=>Tc});var fo={};Ri(fo,{addInstrument:()=>Nx,getCurrentInstrument:()=>Tx,getInstrumentList:()=>wx,isMuted:()=>Mx,linearToDecibels:()=>fs,mute:()=>Ox,playNote:()=>sa,stop:()=>aa,unmute:()=>Rx,useInstrument:()=>Bm});var Tc={};Ri(Tc,{AccidentalType:()=>xc,BeamGrouping:()=>ni,Chord:()=>Ac,DefaultGuitarNoteLabel:()=>Pg,DefaultHandedness:()=>uy,DefaultPitchNotation:()=>Lg,DefaultTuningName:()=>hy,GuitarNoteLabel:()=>as,GuitarNoteLabelList:()=>Fg,Handedness:()=>_c,Interval:()=>Vn,KeySignature:()=>Fe,Mode:()=>bc,Note:()=>U,NoteLength:()=>Zt,NoteLengthProps:()=>_t,PitchNotation:()=>Er,PitchNotationList:()=>kg,RhythmProps:()=>Gt,Scale:()=>Lr,ScaleFactory:()=>Ht,ScaleType:()=>ri,SymbolSet:()=>Dr,TimeSignature:()=>jr,TimeSignatures:()=>Wn,TuningNameList:()=>qn,Tuplet:()=>gr,alterTempoSpeed:()=>wc,getDefaultKeySignature:()=>cs,getDefaultScale:()=>ey,getDefaultTempo:()=>ps,getDefaultTimeSignature:()=>ds,getPitchNotationName:()=>jg,getScale:()=>mr,getScaleFactory:()=>bl,getScaleFactoryList:()=>$g,getTempoString:()=>ms,getTuningStrings:()=>ls,validateGuitarNoteLabel:()=>Bg,validateHandedness:()=>ly,validateIntervalQuality:()=>Zg,validateNoteLength:()=>Ae,validatePitchNotation:()=>ul,validateScaleType:()=>Gn,validateTuningName:()=>vc,validateTupletRatio:()=>hs});var Hu=Object.defineProperty,sf=(n,e,t)=>e in n?Hu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,pr=(n,e)=>{for(var t in e)Hu(n,t,{get:e[t],enumerable:!0})},er=(n,e,t)=>sf(n,typeof e!="symbol"?e+"":e,t),x={};pr(x,{Arr:()=>Zu,Dom:()=>Ju,Enum:()=>$u,Is:()=>tl,Map:()=>rl,Math:()=>Xu,Obj:()=>il,Str:()=>ol});var Zu={};pr(Zu,{arrayContains:()=>If,chunckArray:()=>Sf,duplicate:()=>bf,fillArray:()=>Cf,getRangeArray:()=>vf,getSequenceArray:()=>_f,isArray:()=>pc,mapRangeArray:()=>Ku,mapSequenceArray:()=>Qu,removeDuplicates:()=>xf,removeDuplicatesCmp:()=>Af,toArray:()=>yf});var Xu={};pr(Xu,{calcNormal:()=>mf,clamp:()=>pf,cmp:()=>gf,interpolateCoord:()=>hf,interpolateY:()=>df,isInteger:()=>Te,linearToDecibels:()=>af,mod:()=>cf,romanize:()=>uf,sum:()=>ff,toOrdinalNumber:()=>lf});function Te(n){return typeof n=="number"&&isFinite(n)&&n===Math.trunc(n)}function af(n){if(isFinite(n))return n<=0?-1/0:20*Math.log10(n);throw new Error("linearToDecibel: Invalid linearVolume = "+n)}function cf(n,e){return(n%e+e)%e}function uf(n){if(!Te(n)||n<0)throw new Error("romanize: Invalid n = "+n);for(var e=String(+n).split(""),t=["","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="",i=3;i--;)r=(t[+e.pop()+i*10]||"")+r;return Array(+e.join("")+1).join("M")+r}function lf(n){if(!Te(n))throw new Error("toOrdinalNumber: Invalid n = "+n);let e=n.toString(),t=Number(e.charAt(e.length-1));return n===1||n>=20&&t===1?e+"st":n===2||n>=20&&t===2?e+"nd":n===3||n>=20&&t===3?e+"rd":e+"th"}function hf(n,e,t,r,i){return{x:n+(t-n)*i,y:e+(r-e)*i}}function df(n,e,t,r,i){let o=(i-n)/(t-n);return e+(r-e)*o}function pf(n,e,t){return Math.min(Math.max(n,e),t)}function mf(n,e,t,r){let i=t-n,s=-(r-e),a=i,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function ff(n){return n.reduce((e,t)=>t+e,0)}function gf(n,e){return n<e?-1:n>e?1:0}function pc(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function yf(n){return pc(n)?n:[n]}function bf(n){return n===void 0?n:n.slice()}function xf(n){return n.filter((e,t,r)=>r.indexOf(e)===t)}function Af(n,e){return n.filter((t,r,i)=>r===i.findIndex(o=>e(t,o)))}function Cf(n,e){if(!Te(e)||e<0)throw new Error("fillArray: Invalid fillCount = "+e);return new Array(e).fill(n)}function Qu(n,e){if(!Te(n)||n<0)throw new Error("mapSequenceArray: Invalid len = "+n);let t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r);return t}function _f(n){return Qu(n,e=>e)}function Ku(n,e,t){if(!Te(n))throw new Error("mapRangeArray: Invalid start = "+e);if(!Te(e))throw new Error("mapRangeArray: Invalid end = "+e);let r=Math.abs(e-n)+1,i=new Array(r);for(let o=0,s=n,a=Math.sign(e-n);o<r;s+=a,o++)i[o]=t(s);return i}function vf(n,e){return Ku(n,e,t=>t)}function If(n,e){return n.indexOf(e)>=0}function Sf(n,e){if(!Te(e)||e<1)throw new Error("chunckArray: Invalid chunckSize = "+e);let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}var Ju={};pr(Ju,{addClass:()=>wf,appendTo:()=>kf,getButton:()=>Ff,getCanvas:()=>Bf,getCanvasTextWidth:()=>Wf,getDimension:()=>Gf,getHeight:()=>Df,getOffset:()=>Of,getPadding:()=>Vf,getWidth:()=>Rf,hasClass:()=>mc,removeClass:()=>Tf,removeFromParent:()=>Lf,setHeight:()=>Ef,setOffset:()=>Nf,setRect:()=>Pf,setVisibility:()=>jf,setWidth:()=>Mf,styleLayoutChanged:()=>qf});var $u={};pr($u,{getEnumValues:()=>ss});function ss(n){return Object.keys(n).filter(e=>Number.isNaN(Number(e))).map(e=>n[e])}var dc;(n=>{let e=Error;function t(y){e=y!=null?y:Error}n.setErrorClass=t;function r(y,T){throw new e("Assertion Error: "+y+(T?" "+T:""))}function i(y){return typeof y=="number"&&isFinite(y)&&y===Math.trunc(y)}function o(y){return typeof y=="number"}function s(y,T){y||r(T!=null?T:"Assertion failed!")}n.assert=s;function a(y,T,E="value"){if(!ss(T).some(R=>R===y))throw new TypeError(`Invalid ${E} enum value: ${y}`)}n.assertEnum=a;function c(y){r(y!=null?y:"Interrupted!")}n.interrupt=c;function u(y,T){return i(y)||r(`Expected ${y} to be integer.`,T),y}n.int=u;function l(y,T,E){return y!==T&&r(`Expected ${y} to equal ${T}.`,E),y}n.eq=l;function h(y,T,E){return i(y)&&o(T)&&y===T||r(`Expected ${y} to be integer equal to ${T}.`,E),y}n.int_eq=h;function d(y,T,E){return i(y)&&o(T)&&y<T||r(`Expected ${y} to be integer less than ${T}.`,E),y}n.int_lt=d;function m(y,T,E){return i(y)&&o(T)&&y<=T||r(`Expected ${y} to be integer less than or equal to ${T}.`,E),y}n.int_lte=m;function f(y,T,E){return i(y)&&o(T)&&y>T||r(`Expected ${y} to be integer greater than ${T}.`,E),y}n.int_gt=f;function g(y,T,E){return i(y)&&o(T)&&y>=T||r(`Expected ${y} to be integer greater than or equal to ${T}.`,E),y}n.int_gte=g;function b(y,T,E,R){return i(y)&&o(T)&&o(E)&&y>=T&&y<=E||r(`Expected ${y} to be integer between ${T} and ${E}.`,R),y}n.int_between=b;function A(y,T){return i(y)&&y%2===1||r(`Expected ${y} to be odd number.`,T),y}n.odd=A;function I(y,T){return i(y)&&y%2===0||r(`Expected ${y} to be even number.`,T),y}n.even=I;function w(y,T,E){if(!T.some(R=>R===y)){let R=T.map(M=>String(M)).join(", ");r(`Expected ${y} to be in group [${R}].`,E)}return y}n.in_group=w;function S(y,T){return o(y)&&isFinite(y)||r(`Expected ${y} to be finite number.`,T),y}n.finite=S;function _(y,T,E){return i(T)&&T>=0&&T<y.length||r(`Expected ${T} to be array index in bounds [0..${y.length-1}].`,E),T}n.array_id=_;function v(y,T,E){return y[_(y,T,E)]}n.array_elem=v;function C(y,T){if(y===void 0)r("Required value is undefined.",T);else return y}n.require=C})(dc||(dc={}));var Fn;(n=>{function e(){let d=document.createElement("div");d.style.width="1in",document.body.appendChild(d);let m=d.offsetWidth;return d.remove(),m||96}function t(){try{let d=document.createElement("div");d.style.visibility="hidden",d.style.width="100px",document.body.appendChild(d);let m=d.offsetWidth;d.style.overflow="scroll";let f=document.createElement("div");f.style.width="100%",d.appendChild(f);let g=f.offsetWidth;return d.parentNode&&d.parentNode.removeChild(d),m-g}catch(d){return 0}}function r(){let d=document.createElement("div");d.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",d.appendChild(document.createTextNode("M")),document.body.appendChild(d);let m=d.offsetHeight;return document.body.removeChild(d),m}function i(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var d=" -webkit- -moz- -o- -ms- ".split(" "),m=function(g){return window.matchMedia(g).matches},f=["(",d.join("touch-enabled),("),"heartz",")"].join("");return m(f)}function o(){let d=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(d)||/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(d.substr(0,4))}function s(){return location.protocol+"//"+location.host}let a=/^(mm|cm|in|inch|px|em)$/,c=/^([0-9\\.]+)(.*)$/;n.DPI=e(),n.PxPerMm=n.DPI/25.4,n.ScrollbarWidth=t(),n.FontSize=r(),n.IsTouchDevice=i(),n.IsMobileDevice=o(),n.HostAddress=s();function u(d){return d/n.PxPerMm}n.pxToMm=u;function l(d){return d*n.PxPerMm}n.mmToPx=l;function h(d){if(typeof d=="number")return d;let m=NaN,f,g=d.toString().match(c);if(g&&g[1]){m=parseFloat(g[1]);let b=g[2]?g[2].toLowerCase():"undefined";f=a.test(b)?b:void 0,f||console.log("Unknown unit '"+b+"' => using 'px'.")}else m=parseFloat(d);switch(dc.finite(m,"value in function toPx"),f){case"mm":return l(m);case"cm":return l(m)*10;case"in":case"inch":return l(m)*25.4;case"em":return n.FontSize*m;default:case"px":return m}}n.toPx=h})(Fn||(Fn={}));function St(n){return n===void 0?void 0:Fn.toPx(n)}function mc(n,e){return e.length===0?!1:n.classList?n.classList.contains(e):!!n.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))}function wf(n,e){e.length!==0&&(n.classList?n.classList.add(e):mc(n,e)||(n.className+=" "+e))}function Tf(n,e){if(e.length!==0){if(n.classList)n.classList.remove(e);else if(mc(n,e)){var t=new RegExp("(\\s|^)"+e+"(\\s|$)");n.className=n.className.replace(t," ")}}}function Nf(n,e,t,r="px"){n.style.left=e+r,n.style.top=t+r}function Of(n){let e=n.getBoundingClientRect(),t=document.documentElement;return{top:e.top+window.pageYOffset-t.clientTop,left:e.left+window.pageXOffset-t.clientLeft}}function Rf(n){if(n instanceof Window)return n.innerWidth;{let e=parseFloat(getComputedStyle(n,null).width.replace("px",""));return isNaN(e)?0:e}}function Mf(n,e){n.style.width=e+"px"}function Df(n){if(n instanceof Window)return n.innerHeight;{let e=parseFloat(getComputedStyle(n,null).height.replace("px",""));return isNaN(e)?0:e}}function Ef(n,e){n.style.height=e+"px"}function kf(n,e){e.appendChild(n)}function Lf(n){n.remove()}function jf(n,e){n.style.display=e?"block":"none"}function Pf(n,e,t,r,i,o="px"){n.style.left=e+o,n.style.top=t+o,n.style.width=r+o,n.style.height=i+o}function Ff(n){let e=typeof n=="string"?document.getElementById(n):n;return e instanceof HTMLButtonElement?e:void 0}function Bf(n){let e=typeof n=="string"?document.getElementById(n):n;return e instanceof HTMLCanvasElement?e:void 0}function Vf(n){var s;if(!n)return{top:0,right:0,bottom:0,left:0};let e=St(n.paddingTop),t=St(n.paddingRight),r=St(n.paddingBottom),i=St(n.paddingLeft),o=((s=n.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:e!=null||(e=St(o[0])),t!=null||(t=St(o[0])),r!=null||(r=St(o[0])),i!=null||(i=St(o[0]));break;case 2:e!=null||(e=St(o[0])),t!=null||(t=St(o[1])),r!=null||(r=St(o[0])),i!=null||(i=St(o[1]));break;case 3:e!=null||(e=St(o[0])),t!=null||(t=St(o[1])),r!=null||(r=St(o[2])),i!=null||(i=St(o[1]));break;case 4:default:e!=null||(e=St(o[0])),t!=null||(t=St(o[1])),r!=null||(r=St(o[2])),i!=null||(i=St(o[3]));break}return e!=null||(e=0),t!=null||(t=0),r!=null||(r=0),i!=null||(i=0),{top:e,right:t,bottom:r,left:i}}function Gf(n){let e=St(n==null?void 0:n.left),t=St(n==null?void 0:n.right),r=St(n==null?void 0:n.top),i=St(n==null?void 0:n.bottom),o=St(n==null?void 0:n.width),s=St(n==null?void 0:n.height);return o===void 0&&e!==void 0&&t!==void 0&&(o=t-e),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:e,top:r,width:o,height:s}}function qf(n,e){return!n&&!e?!1:!n||!e?!0:n.left!==e.left||n.top!==e.top||n.right!==e.right||n.bottom!==e.bottom||n.width!==e.width||n.height!==e.height}var jn;function Wf(n,e){jn!=null||(jn=document.createElement("canvas"));let t=jn.getContext("2d");return t?(t.font=e,t.measureText(n).width):0}var tl={};pr(tl,{isArray:()=>$r,isArrayOrUndefined:()=>Zf,isBoolean:()=>og,isBooleanOrUndefined:()=>sg,isEmptyArray:()=>Xf,isEmptyArrayOrUndefined:()=>Kf,isEmptyString:()=>tg,isEmptyStringOrUndefined:()=>ig,isEnumValue:()=>ug,isEnumValueOrUndefined:()=>lg,isFinite:()=>fc,isFunction:()=>ag,isFunctionOrUndefined:()=>cg,isInfinity:()=>Cg,isInteger:()=>ti,isIntegerBetween:()=>xg,isIntegerEq:()=>mg,isIntegerGt:()=>fg,isIntegerGte:()=>gg,isIntegerLt:()=>yg,isIntegerLte:()=>bg,isIntegerOrUndefined:()=>pg,isNaNValue:()=>Ag,isNegInfinity:()=>vg,isNonEmptyArray:()=>Qf,isNonEmptyArrayOrUndefined:()=>Jf,isNonEmptyString:()=>eg,isNonEmptyStringOrUndefined:()=>ng,isNull:()=>zf,isNullish:()=>Yf,isNumber:()=>hg,isNumberOrUndefined:()=>dg,isObject:()=>el,isObjectOrUndefined:()=>Hf,isPosInfinity:()=>_g,isString:()=>$f,isStringOrUndefined:()=>rg,isUndefined:()=>Uf});function Uf(n){return n===void 0}function zf(n){return n===null}function Yf(n){return n==null}function el(n){return typeof n=="object"&&n!==null&&!$r(n)}function Hf(n){return n===void 0||el(n)}function $r(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function Zf(n){return n===void 0||$r(n)}function Xf(n){return $r(n)&&n.length===0}function Qf(n){return $r(n)&&n.length>0}function Kf(n){return $r(n)&&n.length===0||n===void 0}function Jf(n){return $r(n)&&n.length>0||n===void 0}function $f(n){return typeof n=="string"}function tg(n){return typeof n=="string"&&n.length===0}function eg(n){return typeof n=="string"&&n.length>0}function rg(n){return n===void 0||typeof n=="string"}function ig(n){return typeof n=="string"&&n.length===0||n===void 0}function ng(n){return typeof n=="string"&&n.length>0||n===void 0}function og(n){return typeof n=="boolean"}function sg(n){return n===void 0||typeof n=="boolean"}function ag(n){return typeof n=="function"}function cg(n){return n===void 0||typeof n=="function"}function ug(n,e,t="value"){return ss(e).some(r=>r===n)}function lg(n,e,t="value"){return n===void 0||ss(e).some(r=>r===n)}function hg(n){return typeof n=="number"}function dg(n){return typeof n=="number"||n===void 0}function fc(n){return typeof n=="number"&&Number.isFinite(n)}function ti(n){return typeof n=="number"&&fc(n)&&n===Math.trunc(n)}function pg(n){return typeof n=="number"&&fc(n)&&n===Math.trunc(n)||n===void 0}function mg(n,e){return ti(n)&&n===e}function fg(n,e){return ti(n)&&n>e}function gg(n,e){return ti(n)&&n>=e}function yg(n,e){return ti(n)&&n<e}function bg(n,e){return ti(n)&&n<=e}function xg(n,e,t){return ti(n)&&n>=e&&n<=t}function Ag(n){return typeof n=="number"&&Number.isNaN(n)}function Cg(n){return typeof n=="number"&&Math.abs(n)===1/0}function _g(n){return typeof n=="number"&&n===1/0}function vg(n){return typeof n=="number"&&n===-1/0}var rl={};pr(rl,{getMapKeys:()=>Ig});function Ig(n){let e=[];return n.forEach((t,r)=>e.push(r)),e}var il={};pr(il,{hasProperties:()=>Sg,isObject:()=>nl});function nl(n){return typeof n=="object"&&n!==null&&!pc(n)}function Sg(n,e){return nl(n)&&e.every(t=>t in n)}var ol={};pr(ol,{charCount:()=>Mg,chunkString:()=>Ng,insertAt:()=>Og,makeSentenceFromPascal:()=>Dg,removeAt:()=>Rg,repeatString:()=>Tg,replaceAt:()=>gc,toCharArray:()=>wg});function wg(n){return n.split("")}function Tg(n,e){if(!Te(e)||e<0)throw new Error("repeatStr: Invalid repeatCount = "+e);return new Array(e+1).join(n)}function Ng(n,e){if(!Te(e)||e<1)throw new Error("chunckString: Invalid chuckSize = "+e);let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function gc(n,e,t,r){if(!Te(t)||t<0)throw new Error("replaceAt: Invalid removeCount = "+t);if(!Te(e)||e<0||e+t>n.length)throw new Error("replaceAt: Invalid pos = "+e+", removeCount = "+t+", str.length = "+n.length);return n.substring(0,e)+r+n.substring(e+t)}function Og(n,e,t){return gc(n,e,0,t)}function Rg(n,e,t){return gc(n,e,t,"")}function Mg(n,e){if(e.length!==1||n.length===0)return 0;let t=0;for(let r=0;r<n.length;r++)n[r]===e&&t++;return t}function Dg(n){if(n==="")return"";let e=n.charAt(0),t="",r=()=>{e!==""&&(t===""?t+=e.charAt(0).toUpperCase()+e.substring(1):t+=" "+e,e="")},i=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<n.length;o++){let s=n.charAt(o);i(s)&&r(),e+=s.toLowerCase()}return r(),t}var Yu;(n=>{let e="ConsentCookie",t;(S=>{S.Accept="accept",S.Decline="decline"})(t||(t={}));let r,i,o=d(e);r=o==="accept"||o==="decline"?o:void 0;function s(S){i=new Date,i.setDate(i.getDate()+S)}n.setExpireDays=s;function a(){return r===void 0}n.isConsentPending=a;function c(){r="accept",h(e,r)}n.accept=c;function u(){r="decline",h(e,r)}n.decline=u;function l(){return document.cookie.split(";").map(_=>_.trim())}function h(S,_){let v=S+"="+_.toString()+";sameSite=Lax;";return i&&(v+="expires="+i.toUTCString()+";"),document.cookie=v,_}function d(S,_){let v=l().find(C=>C.startsWith(S+"="));return v===void 0?_:v.substring(S.length+1)}function m(S){document.cookie=S+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(S,_){return r==="accept"&&h(S,_),_}n.save=f;function g(S,_){return r==="accept"&&d(S,_)||_}n.read=g;function b(S,_){if(r==="accept"){let v=d(S);return v===void 0?_:parseInt(v)}else return _}n.readInt=b;function A(S,_){if(r==="accept"){let v=d(S);return v===void 0?_:/true|1/i.test(v)}else return _}n.readBool=A;function I(S){(r==="accept"||S===e)&&m(S)}n.erase=I;function w(){document.cookie.split(";").forEach(S=>I(S.trim().split("=")[0]))}n.eraseAll=w})(Yu||(Yu={}));var sl=class Pn{constructor(e,t){er(this,"x"),er(this,"y"),this.x=e!=null?e:0,this.y=t!=null?t:0}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}add(e){return new Pn(this.x+e.x,this.y+e.y)}sub(e){return new Pn(this.x-e.x,this.y-e.y)}mul(e){return new Pn(this.x*e,this.y*e)}div(e){return new Pn(this.x/e,this.y/e)}},al=class{constructor(n,e=1/0){er(this,"cache"),er(this,"next"),er(this,"prev"),er(this,"head"),er(this,"tail"),er(this,"capacity"),er(this,"size"),er(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=n,this.size=0,this.maxKeyLength=e}get(n){if(!(n.length>this.maxKeyLength)&&this.cache[n]!==void 0)return this.touch(n),this.cache[n]}set(n,e){if(!(n.length>this.maxKeyLength)){if(this.cache[n]!==void 0){this.cache[n]=e,this.touch(n);return}this.size>=this.capacity&&this.evict(),this.cache[n]=e,this.addToTail(n),this.size++}}touch(n){this.tail!==n&&(this.removeKey(n),this.addToTail(n))}evict(){if(this.head!==null){let n=this.head;this.removeKey(n),delete this.cache[n],this.size--}}removeKey(n){let e=this.prev[n],t=this.next[n];e!==void 0?this.next[e]=t:this.head=t!=null?t:null,t!==void 0?this.prev[t]=e:this.tail=e!=null?e:null,delete this.prev[n],delete this.next[n]}addToTail(n){this.tail!==null?(this.next[this.tail]=n,this.prev[n]=this.tail):this.head=n,this.tail=n}};var yc={};Ri(yc,{MusicError:()=>O,MusicErrorType:()=>dt,init:()=>ei});var dt=(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))(dt||{});function Eg(n){return n===void 0?"":`[${dt[n]}] `}var O=class extends Error{constructor(...t){let[r,i]=t.length===1?[0,t[0]]:t;super(Eg(r)+i);p(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var cl=!1;function ei(){cl||(cl=!0,console.log("%cWebMusicScore v5.2.0 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Dr=(t=>(t[t.Ascii=0]="Ascii",t[t.Unicode=1]="Unicode",t))(Dr||{}),Er=(t=>(t[t.Scientific=0]="Scientific",t[t.Helmholtz=1]="Helmholtz",t))(Er||{}),kg=x.Enum.getEnumValues(Er),Lg=0;function ul(n){if(x.Is.isEnumValue(n,Er))return n;throw new O(1,`Invalid pitchNotation: ${n}`)}function jg(n){return Er[ul(n)]}var as=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(as||{}),Pg="Default",Fg=x.Enum.getEnumValues(as);function Bg(n){if(x.Is.isEnumValue(n,as))return n;throw new O(5,`Invalid guitarNoteLabel: ${n}`)}function ll(n,e){return(n%e+e)%e}var hl=12,dl=7,Vg=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),Gg=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),pl=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),Bn=["C","D","E","F","G","A","B"],ml=[0,2,4,5,7,9,11],fl=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,at=class at{constructor(e,t,r){p(this,"diatonicClass");p(this,"accidental");p(this,"octave");if(typeof e=="number"&&typeof t=="number"&&r===void 0)at.validateDiatonicId(e),this.diatonicClass=at.getDiatonicClass(e),this.accidental=at.validateAccidental(t),this.octave=at.getOctaveFromDiatonicId(e);else if(typeof e=="number"&&typeof t=="number"&&typeof r=="number")this.diatonicClass=at.validateDiatonicClass(e),this.accidental=at.validateAccidental(t),this.octave=at.validateOctave(r);else if(typeof e=="string"&&typeof t=="number"&&typeof r=="number")this.diatonicClass=at.getDiatonicClass(e),this.accidental=at.validateAccidental(t),this.octave=at.validateOctave(r);else throw new O(2,`Invalid args: ${e}, ${t}, ${r}`)}get diatonicId(){return at.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return at.getChromaticIdInOctave(ml[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return at.getChromaticClass(ml[this.diatonicClass]+this.accidental)}get noteLetter(){return Bn[this.diatonicClass]}format(e,t){let{noteLetter:r,octave:i}=this,o=at.getAccidentalSymbol(this.accidental,t);return e===1?i>=3?r.toLowerCase()+o+"\u2032".repeat(i-3):r.toUpperCase()+o+"\u0375".repeat(2-i):r+o+i}formatOmitOctave(e){let t=Bn[this.diatonicClass],r=at.getAccidentalSymbol(this.accidental,e);return t+r}static getNote(e){let t=this.noteByNameCache.get(e);if(t===void 0){let r=at.parseNote(e);if(!r)throw new O(2,`Invalid noteName: ${e}`);if(r.octave===void 0)throw new O(2,"Octave is required for note.");t=new at(r.noteLetter,r.accidental,r.octave),this.noteByNameCache.set(e,t)}return t}static getChromaticNote(e){let t=this.chromaticNoteCache.get(e);if(t===void 0){let i=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][at.getChromaticClass(e)].split("/")[0]+at.getOctaveFromChromaticId(e),o=at.parseNote(i);if(!o)throw new O(2,`Invalid noteName: ${i}`);if(o.octave===void 0)throw new O(2,"Octave is required for note.");t=new at(o.noteLetter,o.accidental,o.octave),this.chromaticNoteCache.set(e,t)}return t}static getDiatonicClass(e){if(typeof e=="number")return ll(e,7);if(typeof e=="string"&&e.length>0)return Bn.indexOf(at.validateNoteLetter(e[0]));throw new O(2,`Invalid arg: ${e}`)}static getOctaveFromDiatonicId(e){return Math.floor((e-dl)/7)}static getDiatonicIdInOctave(e,t){return at.getDiatonicClass(e)+t*7+dl}static getChromaticClass(e){return ll(e,12)}static getOctaveFromChromaticId(e){return Math.floor((e-hl)/12)}static getChromaticIdInOctave(e,t){return at.getChromaticClass(e)+t*12+hl}static equals(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.diatonicId===t.diatonicId&&e.accidental===t.accidental}static replaceAccidentalSymbols(e,t){return t===1?e.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):e.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(e){return fl.test(e)}static parseNote(e){var c;let t=fl.exec(e);if(!t)return;let r=at.validateNoteLetter(t[1]),i=t[2],o=at.validateAccidental((c=pl.get(i))!=null?c:0),s=t[3],a=s?at.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(e,t){let r=at.parseNote(e);if(!r)throw new O(2,`Invalid noteName: ${e}`);let{noteLetter:i,accidental:o,octave:s}=r;return i+at.getAccidentalSymbol(o,t)+(s!=null?s:"")}static getAccidentalSymbol(e,t){return t===1?Gg.get(e):Vg.get(e)}static getAccidental(e){let t=pl.get(e);if(t===void 0)throw new O(2,`Invalid accidental: ${e}`);return t}static getNoteLetter(e){return Bn[at.getDiatonicClass(e)]}static findNextDiatonicIdAbove(e,t,r){let i=at.getDiatonicClass(e),o=at.getDiatonicClass(t),s=r?i<=o?1:0:i<o?1:0;return at.getDiatonicIdInOctave(i,at.getOctaveFromDiatonicId(t)+s)}static validateDiatonicId(e){if(x.Is.isInteger(e))return e;throw new O(2,`Invalid diatonicId: ${e}`)}static validateDiatonicClass(e){if(x.Is.isIntegerBetween(e,0,6))return e;throw new O(2,`Invalid diatonicClass: ${e}`)}static validateChromaticId(e){if(x.Is.isInteger(e))return e;throw new O(2,`Invalid chromaticId: ${e}`)}static validatechromaticClass(e){if(x.Is.isIntegerBetween(e,0,11))return e;throw new O(2,`Invalid chromaticClass: ${e}`)}static validateNoteLetter(e){if(Bn.some(t=>t===e))return e;throw new O(2,`Invalid note: ${e}`)}static validateOctave(e){if(x.Is.isInteger(e))return e;throw new O(2,`Invalid octave: ${e}`)}static validateAccidental(e){if(x.Is.isIntegerBetween(e,-2,2))return e;throw new O(2,`Invalid accidental: ${e}`)}static sort(e){return e.slice().sort(at.compareFunc)}static removeDuplicates(e){let t=[];return e.forEach(r=>{t.find(i=>at.equals(r,i))===void 0&&t.push(r)}),t}static compareFunc(e,t){return e.diatonicId<t.diatonicId?-1:e.diatonicId>t.diatonicId?1:e.accidental<t.accidental?-1:e.accidental>t.accidental?1:0}};p(at,"noteByNameCache",new Map),p(at,"chromaticNoteCache",new Map);var U=at;function qg(n,e){let t=U.getChromaticClass(n)-new U(e,0).chromaticClass;for(;t>2;)t-=12;for(;t<-2;)t+=12;return U.validateAccidental(t)}var Wg=/^(bb?|b?|#?|x?)([0-9]*)$/;function Ug(n){var i,o;let e=Wg.exec(""+n);if(!e)throw new O(4,`Invalid degree: ${n}`);let t=(o=U.getAccidental((i=e[1])!=null?i:""))!=null?o:0,r=+e[2];if(!x.Is.isInteger(t)||t<-2||t>2||!x.Is.isInteger(r)||r<1)throw new O(4,`Invalid degree: ${n}`);return{deg:r,acc:t}}var bc=(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))(bc||{}),xc=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(xc||{});function cs(){return mr("C","Major")}var kr=class kr{constructor(e,t){this.tonic=e;this.mode=t;p(this,"naturalScaleNotes");p(this,"accidentalByDiatonicClass");p(this,"orderedAccidentedNotes");if(!x.Is.isEnumValue(t,bc))throw new O(4,`Invalid mode: ${t}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<t;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let i=U.getDiatonicClass(e[0]),o=U.getNote(e+"0").chromaticId;for(let c=0;c<7;i++,o+=r[c],c++){let u=new U(U.getDiatonicClass(i),qg(o,i));if(Math.abs(u.accidental)>=2)throw new O(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=kr.OrderOfSharps.indexOf(c.noteLetter),h=kr.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=kr.OrderOfFlats.indexOf(c.noteLetter),h=kr.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new O(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(e){var t;return(t=this.accidentalByDiatonicClass[U.getDiatonicClass(e)])!=null?t:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(e){let{deg:t,acc:r}=Ug(e);if(r===0)return this.naturalScaleNotes[(t-1)%7];{let i=this.naturalScaleNotes[(t-1)%7];return new U(i.diatonicId,i.accidental+r)}}static equals(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.tonic===t.tonic&&e.mode===t.mode}};p(kr,"OrderOfSharps","FCGDAEB"),p(kr,"OrderOfFlats","BEADGCF");var Fe=kr;var zg=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),Yg={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 Hg(n,e){for(;n<1;)n+=7,e+=12;for(;n>8;)n-=7,e-=12;let t=Yg[n];if(t)return t[e]}function Zg(n){if(n==="Perfect"||n==="Major"||n==="minor"||n==="Augmented"||n==="diminished"||n==="Doubly Augmented"||n==="doubly diminished")return n;throw new O(1,`Invalid interval quality: ${n}`)}function Xg(n){if(x.Is.isIntegerGte(n,1))return x.Math.toOrdinalNumber(n);throw new O(1,`Invalid interval quantity: ${n}`)}var us=class extends Error{constructor(t){super(t);this.msg=t;this.name="InvalidInterval"}},Vn=class n{constructor(e,t){this.note1=e;this.note2=t;p(this,"direction");p(this,"semitones");p(this,"quantity");p(this,"quality");t.diatonicId>=e.diatonicId?(this.direction=t.diatonicId===e.diatonicId?"Unison":"Ascending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId):(this.direction="Descending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId);let r=Hg(this.quantity,this.semitones);if(r)this.quality=r;else throw new us("Unknown interval quality")}static get(e,t){try{return new n(e,t)}catch(r){if(r instanceof us)return;throw r}}toString(){let e=this.direction==="Unison"?"":this.direction+" ",t=this.quality+" ",r=this.direction==="Unison"?"Unison":Xg(this.quantity);return e+t+r}toAbbrString(){var i;let e=this.direction==="Descending"?"\u2193":"",t=(i=zg.get(this.quality))!=null?i:"?",r=this.quantity;return e+t+r}};function Qg(n){let e=U.getDiatonicClass("CCDDEFFGGAAB"[U.getChromaticClass(n)]),t=U.getOctaveFromChromaticId(n);return U.getDiatonicIdInOctave(e,t)}var Kg=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],ri=(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))(ri||{});function Jg(n){switch(n){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 O(3,`Invalid scaleType: ${n}`)}}var Lr=class extends Fe{constructor(t,r){super(t,Jg(r));this.tonic=t;this.scaleType=r;p(this,"scaleDegrees");p(this,"scaleNotes");p(this,"chromaticClassDegree");p(this,"preferredChromaticNoteCache",new Map);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(i=>this.getNoteByDegree(i)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(i=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===i);return o>=0?this.scaleDegrees[o]:void 0})}static equals(t,r){return t==null&&r==null?!0:t==null||r==null?!1:t===r||t.getScaleName()===r.getScaleName()}getScaleName(t){switch(t){case 1:return U.getScientificNoteName(this.tonic,t)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(t,r){if(!x.Is.isIntegerGte(r,1))throw new O(3,`Invalid numOctaves: ${r}`);let i=[];for(let s=1;s<=r;s++)i=[...i,...this.scaleNotes];i.push(this.scaleNotes[0]);let o=U.getNote(t).diatonicId;return i.map(s=>(o=U.findNextDiatonicIdAbove(s.diatonicId,o,!1),new U(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(t=>t.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let t=this.getScaleNotes("C4",1).map(i=>i.chromaticId),r=[];for(let i=0;i<t.length-1;i++)r.push(x.Math.mod(t[i+1]-t[i],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(t=>t===1?"H":t===2?"W":t.toString()+"H")}isScaleNote(t){return this.chromaticClassDegree[t.chromaticClass]!==void 0}isScaleRootNote(t){return String(this.chromaticClassDegree[t.chromaticClass])==="1"}getIntervalFromRootNote(t){let r=this.getScaleNotes("C0",1)[0];for(;t.chromaticId>=r.chromaticId+12;)t=new U(t.diatonicClass,t.accidental,t.octave-1);if(t.chromaticId<r.chromaticId)throw new O(3,"Note is below rootNote.");let i=Vn.get(r,t);if(i===void 0)throw new O(3,"Interval is undefined.");return i}getPreferredChromaticNote(t){U.validateChromaticId(t);let r=this.preferredChromaticNoteCache.get(t);if(r)return r;let i=U.getOctaveFromChromaticId(t);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new U(h.diatonicClass,h.accidental,i+1):h.noteLetter==="B"&&h.accidental>0?new U(h.diatonicClass,h.accidental,i-1):new U(h.diatonicClass,h.accidental,i)).find(h=>U.getChromaticClass(t)===h.chromaticClass),r)return this.preferredChromaticNoteCache.set(t,r),r;let s=Qg(t),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 d=l[h];for(let m=Math.max(0,a);m<=c;m++)if(r=new U(m,d),t===r.chromaticId)return this.preferredChromaticNoteCache.set(t,r),r}return r=U.getChromaticNote(t),this.preferredChromaticNoteCache.set(t,r),r}},Ht=class{constructor(e){this.type=e;p(this,"tonicList",[]);p(this,"scaleMap",new Map);let t=[],r=[],i=[];if(Kg.forEach(s=>{try{let a=new Lr(s,this.type);switch(a.getAccidentalType()){case 0:t.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;i.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),t.length===0)throw new O(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...t.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...i.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(e){let t=this.scaleMap.get(e);if(t)return t;throw new O(3,`Invalid scale: ${e} ${this.type}`)}hasScale(e){return this.scaleMap.get(e)!==void 0}},gl=[new Ht("Major"),new Ht("Natural Minor"),new Ht("Harmonic Minor"),"- Modes -",new Ht("Ionian"),new Ht("Dorian"),new Ht("Phrygian"),new Ht("Lydian"),new Ht("Mixolydian"),new Ht("Aeolian"),new Ht("Locrian"),"- Pentatonic -",new Ht("Major Pentatonic"),new Ht("Minor Pentatonic"),"- Blues -",new Ht("Major Hexatonic Blues"),new Ht("Minor Hexatonic Blues"),new Ht("Heptatonic Blues")];function $g(){return gl}var yl=new Map;gl.forEach(n=>{n instanceof Ht&&yl.set(n.getType(),n)});function bl(n){let e=yl.get(n);if(e)return e;throw new O(3,`Invalid scaleType: ${n}`)}function Gn(n){if(x.Is.isEnumValue(n,ri))return n;throw new O(3,`Invalid scaleType: "${n}"`)}function mr(n,e){let t,r;return e!==void 0?(t=n,r=Gn(e)):(t=n.split(" ")[0],r=Gn(n.substring(t.length+1))),bl(r).getScale(t)}var ty=mr("C","Major");function ey(){return ty}var fr=(n,e)=>n.chromaticClass===e.chromaticClass,ry=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(n=>U.getNote(n+"0")),xl=new Map;function iy(n){let e=n.chromaticClass,t=xl.get(e);if(!t){if(t=ry.find(r=>fr(r,n)),!t)throw new O(1,`Invalid chord root note: ${n.formatOmitOctave(1)}`);xl.set(e,t)}return t}function ny(n,e){let t=n.formatOmitOctave(0);return mr(t,"Major").getNoteByDegree(e)}function oy(n){return x.Arr.removeDuplicatesCmp(n,fr)}var sy=[{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 ay(n,e){return n.degrees.every(t=>t!==e)?!0:n.degrees.length>=4&&e===5||n.degrees.length>=6&&e===9||n.degrees.length>=7&&e===11}var Mi=class extends Error{constructor(t){super(t);this.msg=t;this.name="InvalidChordException"}},Ac=class n{constructor(e,t,r,i){this.chordInfo=e;this.rootNote=r;p(this,"name");p(this,"notes");p(this,"omitNotes");p(this,"slashBassNote");this.name=e.name;let o=t.slice();!o.some(a=>fr(a,i))&&o.push(i),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<e.degrees.length;a++){let c=e.degrees[a],u=this.notes[a]=ny(this.rootNote,c),l=o.findIndex(h=>fr(h,u));if(l>=0)this.omitNotes[a]=!1,o.splice(l,1);else if(ay(e,c))this.omitNotes[a]=!0;else throw new Mi("Missing chord note!");fr(i,u)&&(i=u)}if(o.length>0)if(o.every(a=>fr(a,i)))this.slashBassNote=i;else throw new Mi("Got some extra notes that are not bass note!");else this.slashBassNote=fr(i,this.rootNote)?void 0:i;if(e.name==="5"&&this.slashBassNote)throw new Mi("Power chord no bass note allowed!")}static getChords(e){let t=[],r=U.sort(e),i=r[0],o=oy(r);for(let s=0;s<o.length;s++){let a=iy(o[s]);sy.forEach(c=>{try{let u=new n(c,o,a,i),l=t.findIndex(h=>h.replaceWith(u));l>=0?t[l]=u:t.push(u)}catch(u){if(!(u instanceof Mi))throw u}})}return t}replaceWith(e){if(e.notes.length<this.notes.length)return!1;if(e.slashBassNote&&this.slashBassNote&&!fr(e.slashBassNote,this.slashBassNote)||e.slashBassNote&&!this.slashBassNote||!e.slashBassNote&&this.slashBassNote)return!1;for(let t=0;t<this.notes.length;t++)if(!fr(e.notes[t],this.notes[t])||e.omitNotes[t]!==this.omitNotes[t])return!1;return!0}toString(){let e=1,t=this.rootNote.formatOmitOctave(e),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(e):"";return t+this.name+r}getDegreeNotationString(){let e=1,t=this.slashBassNote?this.slashBassNote.formatOmitOctave(e)+" - ":"",r=this.omitNotes.map((i,o)=>this.getDegreeStr(o)+"("+(i?"-":this.getNoteStr(o))+")").join(" - ");return t+r}getOmittedDegreesString(){let e=this.omitNotes.map((t,r)=>t?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(t=>t!==void 0);return e.length>0?"Omits "+e.join(", "):""}getDegreeStr(e){return U.replaceAccidentalSymbols(""+this.chordInfo.degrees[e],1)}getNoteStr(e){return this.notes[e].formatOmitOctave(1)}};var Cc={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 _c=(t=>(t[t.RightHanded=0]="RightHanded",t[t.LeftHanded=1]="LeftHanded",t))(_c||{}),uy=0;function ly(n){if(x.Is.isEnumValue(n,_c))return n;throw new O(1,`Invalid handedness: ${n}`)}var qn=Cc.list.map(n=>n.name),hy=qn[0];function vc(n){if(qn.indexOf(n)<0)throw new O(1,`Invalid tuning name: ${n}`);return n}var Al=new al(100);function ls(n){let e=Al.get(n);if(!e){let t=Cc.list.find(r=>r.name===n);if(!t)throw new O(1,`Invalid tuningName: ${n}`);if(e=t.strings.slice().reverse().map(r=>U.getNote(r)),!x.Is.isIntegerEq(e.length,6))throw new O(0,`Tuning has ${e.length} strings.`);Al.set(n,e)}return e}var Cl=12,dy=1188*7*5,Zt=(V=>(V.Whole="1n",V.WholeTriplet="1t",V.WholeDot="1.",V.Whole2Dots="1..",V.Whole12Dots="1..",V.Whole3Dots="1...",V.Whole4Dots="1....",V.Whole5Dots="1.....",V.Whole6Dots="1......",V.Half="2n",V.HalfTriplet="2t",V.HalfDot="2.",V.Half2Dots="2..",V.Half3Dots="2...",V.Half4Dots="2....",V.Half5Dots="2.....",V.Quarter="4n",V.QuarterTriplet="4t",V.QuarterDot="4.",V.Quarter2Dots="4..",V.Quarter3Dots="4...",V.Quarter4Dots="4....",V.Eighth="8n",V.EighthTriplet="8t",V.EighthDot="8.",V.Eighth2Dots="8..",V.Eighth3Dots="8...",V.Sixteenth="16n",V.SixteenthTriplet="16t",V.SixteenthDot="16.",V.Sixteenth2Dots="16..",V.ThirtySecond="32n",V.ThirtySecondTriplet="32t",V.ThirtySecondDot="32.",V.SixtyFourth="64n",V.SixtyFourthTriplet="64t",V))(Zt||{});function Ae(n){if(x.Is.isEnumValue(n,Zt))return n;throw new O(1,`Invalid noteLength: ${n}`)}var re=class re{constructor(e){p(this,"noteLength");p(this,"noteSize");p(this,"ticks");p(this,"flagCount");p(this,"dotCount");p(this,"maxDotCount");p(this,"isTriplet");p(this,"hasStem");p(this,"isSolid");if(this.noteLength=Ae(e),this.noteSize=parseInt(e),this.isTriplet=e.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(re.ShortestNoteSize/this.noteSize)),this.dotCount=x.Str.charCount(e,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=dy*re.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new O(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new O(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(e){let t=this.cache.get(e);return t||this.cache.set(e,t=new re(e)),t}static create(e,t=0){let r=typeof e=="number"?e:this.get(e).noteSize;return this.get(r+(x.Is.isIntegerGte(t,1)?".".repeat(t):"n"))}static cmp(e,t){let r=e instanceof re?e.noteSize:typeof e=="number"?e:re.get(e).noteSize,i=t instanceof re?t.noteSize:typeof t=="number"?t:re.get(t).noteSize;return x.Math.cmp(i,r)}static equals(e,t){let r=e instanceof re?e.noteSize:typeof e=="number"?e:re.get(e).noteSize,i=t instanceof re?t.noteSize:typeof t=="number"?t:re.get(t).noteSize;return r===i}};p(re,"LongestNoteSize",Math.min(...x.Enum.getEnumValues(Zt).map(e=>parseInt(e)))),p(re,"ShortestNoteSize",Math.max(...x.Enum.getEnumValues(Zt).map(e=>parseInt(e)))),p(re,"cache",new Map);var _t=re;function hs(n){if(x.Is.isObject(n)&&x.Is.isIntegerBetween(n.parts,2,Cl)&&x.Is.isIntegerBetween(n.inTimeOf,2,Cl))return n;throw new O(2,`Invalid tupletRatio ${JSON.stringify(n)}`)}var gr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},ii=class ii{constructor(e,t,r){p(this,"noteLength");p(this,"noteSize");p(this,"dotCount");p(this,"tupletRatio");p(this,"ticks");p(this,"flagCount");p(this,"hasStem");p(this,"isSolidNoteHead");this.noteLength=Ae(e);let i=_t.get(e);if(this.noteSize=i.noteSize,this.ticks=i.ticks,this.flagCount=i.flagCount,this.dotCount=t!=null?t:i.dotCount,this.hasStem=i.hasStem,this.isSolidNoteHead=i.isSolid,x.Is.isObject(r)?this.tupletRatio=hs(r):i.isTriplet?this.tupletRatio=gr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new O(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>i.maxDotCount)throw new O(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 e=ii.NoteSymbolMap.get(this.noteSize),t=".".repeat(this.dotCount);return e?e+t:""+this.noteSize+(t.length>0?t:"n")}static get(e,t,r){if(t!==void 0||r!==void 0)return new ii(e,t,r);{let i=this.cache.get(e);return i||this.cache.set(e,i=new ii(e)),i}}static cmp(e,t){return x.Math.cmp(e.ticks,t.ticks)}static equals(e,t){return e.ticks===t.ticks}};p(ii,"NoteSymbolMap",new Map([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),p(ii,"cache",new Map);var Gt=ii;var Wn=(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))(Wn||{}),ni=(i=>(i._2_3="2-3",i._3_2="3-2",i._2_2_3="2-2-3",i._3_2_2="3-2-2",i))(ni||{}),jr=class{constructor(...e){p(this,"beatCount");p(this,"beatSize");p(this,"beatLength");p(this,"measureTicks");p(this,"beamGroupSizes",[]);let t;if(x.Is.isEnumValue(e[0],Wn)){let o=e[0].split("/");this.beatCount=+o[0],this.beatSize=+o[1],x.Is.isEnumValue(e[1],ni)&&(t=e[1])}else if(x.Is.isIntegerGte(e[0],2)&&x.Is.isIntegerGte(e[1],2))this.beatCount=e[0],this.beatSize=e[1],x.Is.isEnumValue(e[2],ni)&&(t=e[2]);else throw new O(5,`Invalid args: ${e}`);if(x.Is.isIntegerGte(this.beatCount,1)){if(!x.Is.isIntegerGte(this.beatSize,1))throw new O(5,`Invalid beatSize: ${this.beatSize}`)}else throw new O(5,`Invalid beatCount: ${this.beatCount}`);let{noteLength:r,ticks:i}=_t.create(this.beatSize);if(this.beatLength=r,this.measureTicks=this.beatCount*i,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(!x.Is.isUndefined(t)&&t!=="2-3"&&t!=="3-2")throw new O(5,`Invalid beam grouping "${t}" for time signature "${this.toString()}".`);this.beamGroupSizes=t==="3-2"?[[3],[2]]:[[2],[3]],t=void 0}else if(this.is(6,8))this.beamGroupSizes=[[3],[3]];else if(this.is(7,8)){if(!x.Is.isUndefined(t)&&t!=="2-2-3"&&t!=="3-2-2")throw new O(5,`Invalid beam grouping "${t}" for time signature "${this.toString()}".`);this.beamGroupSizes=t==="3-2-2"?[[3],[2],[2]]:[[2],[2],[3]],t=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 O(5,`Unimplemented time signature "${this.toString()}".`);if(t!==void 0)throw new O(5,`Invalid beam grouping "${t}" for time signature "${this.toString()}".`)}is(e,t){return this.beatCount===e&&this.beatSize===t}toString(){return this.beatCount+"/"+this.beatSize}},Ic;function ds(){return Ic||(Ic=new jr(4,4)),Ic}var Sc;function ps(){return Sc||(Sc={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),Sc}function ms(n){return Gt.get(n.options.beatLength,n.options.dotCount).toString()+"="+n.beatsPerMinute}function wc(n,e){return{beatsPerMinute:n.beatsPerMinute*e,options:{beatLength:n.options.beatLength,dotCount:n.options.dotCount}}}ei();function fs(n){return!isFinite(n)||n<=0?-1/0:20*Math.log10(n)}var Un="15.1.22";var Nc=(n,e,t)=>({endTime:e,insertTime:t,type:"exponentialRampToValue",value:n});var Oc=(n,e,t)=>({endTime:e,insertTime:t,type:"linearRampToValue",value:n});var Di=(n,e)=>({startTime:e,type:"setValue",value:n});var zn=(n,e,t)=>({duration:t,startTime:e,type:"setValueCurve",values:n});var gs=(n,e,{startTime:t,target:r,timeConstant:i})=>r+(e-r)*Math.exp((t-n)/i);var yr=n=>n.type==="exponentialRampToValue";var oi=n=>n.type==="linearRampToValue";var Be=n=>yr(n)||oi(n);var Ei=n=>n.type==="setValue";var Ne=n=>n.type==="setValueCurve";var ki=(n,e,t,r)=>{let i=n[e];return i===void 0?r:Be(i)||Ei(i)?i.value:Ne(i)?i.values[i.values.length-1]:gs(t,ki(n,e-1,i.startTime,r),i)};var Rc=(n,e,t,r,i)=>t===void 0?[r.insertTime,i]:Be(t)?[t.endTime,t.value]:Ei(t)?[t.startTime,t.value]:Ne(t)?[t.startTime+t.duration,t.values[t.values.length-1]]:[t.startTime,ki(n,e-1,t.startTime,i)];var Yn=n=>n.type==="cancelAndHold";var Hn=n=>n.type==="cancelScheduledValues";var br=n=>Yn(n)||Hn(n)?n.cancelTime:yr(n)||oi(n)?n.endTime:n.startTime;var Mc=(n,e,t,{endTime:r,value:i})=>t===i?i:0<t&&0<i||t<0&&i<0?t*zu(i/t,(n-e)/(r-e)):0;var Dc=(n,e,t,{endTime:r,value:i})=>t+(n-e)/(r-e)*(i-t);var _l=(n,e)=>{let t=Math.floor(e),r=Math.ceil(e);return t===r?n[t]:(1-(e-t))*n[t]+(1-(r-e))*n[r]};var vl=(n,{duration:e,startTime:t,values:r})=>{let i=(n-t)/e*(r.length-1);return _l(r,i)};var Zn=n=>n.type==="setTarget";var Xn=class{constructor(e){this._automationEvents=[],this._currenTime=0,this._defaultValue=e}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(e){let t=br(e);if(Yn(e)||Hn(e)){let r=this._automationEvents.findIndex(o=>Hn(e)&&Ne(o)?o.startTime+o.duration>=t:br(o)>=t),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),Yn(e)){let o=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Be(i)){if(o!==void 0&&Zn(o))throw new Error("The internal list is malformed.");let s=o===void 0?i.insertTime:Ne(o)?o.startTime+o.duration:br(o),a=o===void 0?this._defaultValue:Ne(o)?o.values[o.values.length-1]:o.value,c=yr(i)?Mc(t,s,a,i):Dc(t,s,a,i),u=yr(i)?Nc(c,t,this._currenTime):Oc(c,t,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Zn(o)&&this._automationEvents.push(Di(this.getValue(t),t)),o!==void 0&&Ne(o)&&o.startTime+o.duration>t){let s=t-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 d=u*h%1;l[h]=o.values[h-1]*(1-d)+o.values[h]*d}this._automationEvents[this._automationEvents.length-1]=zn(l,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>br(s)>t),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&Ne(i)&&br(i)+i.duration>t)return!1;let o=yr(e)?Nc(e.value,e.endTime,this._currenTime):oi(e)?Oc(e.value,t,this._currenTime):e;if(r===-1)this._automationEvents.push(o);else{if(Ne(e)&&t+e.duration>br(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(e){let t=this._automationEvents.findIndex(r=>br(r)>e);if(t>1){let r=this._automationEvents.slice(t-1),i=r[0];Zn(i)&&r.unshift(Di(ki(this._automationEvents,t-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=r}}getValue(e){if(this._automationEvents.length===0)return this._defaultValue;let t=this._automationEvents.findIndex(s=>br(s)>e),r=this._automationEvents[t],i=(t===-1?this._automationEvents.length:t)-1,o=this._automationEvents[i];if(o!==void 0&&Zn(o)&&(r===void 0||!Be(r)||r.insertTime>e))return gs(e,ki(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(o!==void 0&&Ei(o)&&(r===void 0||!Be(r)))return o.value;if(o!==void 0&&Ne(o)&&(r===void 0||!Be(r)||o.startTime+o.duration>e))return e<o.startTime+o.duration?vl(e,o):o.values[o.values.length-1];if(o!==void 0&&Be(o)&&(r===void 0||!Be(r)))return o.value;if(r!==void 0&&yr(r)){let[s,a]=Rc(this._automationEvents,i,o,r,this._defaultValue);return Mc(e,s,a,r)}if(r!==void 0&&oi(r)){let[s,a]=Rc(this._automationEvents,i,o,r,this._defaultValue);return Dc(e,s,a,r)}return this._defaultValue}};var Ec=n=>({cancelTime:n,type:"cancelAndHold"});var kc=n=>({cancelTime:n,type:"cancelScheduledValues"});var Lc=(n,e)=>({endTime:e,type:"exponentialRampToValue",value:n});var jc=(n,e)=>({endTime:e,type:"linearRampToValue",value:n});var Pc=(n,e,t)=>({startTime:e,target:n,timeConstant:t,type:"setTarget"});var Il=()=>new DOMException("","AbortError");var Sl=n=>(e,t,[r,i,o],s)=>{n(e[i],[t,r,o],a=>a[0]===t&&a[1]===r,s)};var wl=n=>(e,t,r)=>{let i=[];for(let o=0;o<r.numberOfInputs;o+=1)i.push(new Set);n.set(e,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:t})};var Tl=n=>(e,t)=>{n.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:t})};var rr=new WeakSet,ys=new WeakMap,Li=new WeakMap,bs=new WeakMap,Qn=new WeakMap,ji=new WeakMap,xs=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,$n=new WeakMap;var Nl={construct(){return Nl}},Ol=n=>{try{let e=new Proxy(n,Nl);new e}catch(e){return!1}return!0};var Rl=/^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]*);?/,Fc=(n,e)=>{let t=[],r=n.replace(/^[\s]+/,""),i=r.match(Rl);for(;i!==null;){let o=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,e).toString());t.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(Rl)}return[t.join(";"),r]};var Ml=n=>{if(n!==void 0&&!Array.isArray(n))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Dl=n=>{if(!Ol(n))throw new TypeError("The given value for processorCtor should be a constructor.");if(n.prototype===null||typeof n.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},El=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>{let m=0;return(f,g,b={credentials:"omit"})=>{let A=l.get(f);if(A!==void 0&&A.has(g))return Promise.resolve();let I=u.get(f);if(I!==void 0){let _=I.get(g);if(_!==void 0)return _}let w=o(f),S=w.audioWorklet===void 0?i(g).then(([_,v])=>{let[C,y]=Fc(_,v),T=`${C};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${y}
3
+ })})(window,'_AWGS')`;return t(T)}).then(()=>{let _=d._AWGS.pop();if(_===void 0)throw new SyntaxError;r(w.currentTime,w.sampleRate,()=>_(class{},void 0,(v,C)=>{if(v.trim()==="")throw e();let y=Jn.get(w);if(y!==void 0){if(y.has(v))throw e();Dl(C),Ml(C.parameterDescriptors),y.set(v,C)}else Dl(C),Ml(C.parameterDescriptors),Jn.set(w,new Map([[v,C]]))},w.sampleRate,void 0,void 0))}):Promise.all([i(g),Promise.resolve(n(h,h))]).then(([[_,v],C])=>{let y=m+1;m=y;let[T,E]=Fc(_,v),L=`${T};((AudioWorkletProcessor,registerProcessor)=>{${E}
4
+ })(${C?"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{${C?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${C?"":"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${y}',class extends AudioWorkletProcessor{process(){return !1}})`,k=new Blob([L],{type:"application/javascript; charset=utf-8"}),P=URL.createObjectURL(k);return w.audioWorklet.addModule(P,b).then(()=>{if(a(w))return w;let G=s(w);return G.audioWorklet.addModule(P,b).then(()=>G)}).then(G=>{if(c===null)throw new SyntaxError;try{new c(G,`__sac${y}`)}catch(Q){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(P))});return I===void 0?u.set(f,new Map([[g,S]])):I.set(g,S),S.then(()=>{let _=l.get(f);_===void 0?l.set(f,new Set([g])):_.add(g)}).finally(()=>{let _=u.get(f);_!==void 0&&_.delete(g)}),S}};var qt=(n,e)=>{let t=n.get(e);if(t===void 0)throw new Error("A value with the given key could not be found.");return t};var Pr=(n,e)=>{let t=Array.from(n).filter(e);if(t.length>1)throw Error("More than one element was found.");if(t.length===0)throw Error("No element was found.");let[r]=t;return n.delete(r),r};var As=(n,e,t,r)=>{let i=qt(n,e),o=Pr(i,s=>s[0]===t&&s[1]===r);return i.size===0&&n.delete(e),o};var ir=n=>qt(xs,n);var Ve=n=>{if(rr.has(n))throw new Error("The AudioNode is already stored.");rr.add(n),ir(n).forEach(e=>e(!0))};var Cs=n=>"port"in n;var nr=n=>{if(!rr.has(n))throw new Error("The AudioNode is not stored.");rr.delete(n),ir(n).forEach(e=>e(!1))};var to=(n,e)=>{!Cs(n)&&e.every(t=>t.size===0)&&nr(n)};var kl=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>{let m=new WeakMap;return(f,g,b,A,I)=>{let{activeInputs:w,passiveInputs:S}=o(g),{outputs:_}=o(f),v=a(f),C=y=>{let T=c(g),E=c(f);if(y){let R=As(S,f,b,A);n(w,f,R,!1),!I&&!h(f)&&t(E,T,b,A),d(g)&&Ve(g)}else{let R=r(w,f,b,A);e(S,A,R,!1),!I&&!h(f)&&i(E,T,b,A);let M=s(g);if(M===0)l(g)&&to(g,w);else{let q=m.get(g);q!==void 0&&clearTimeout(q),m.set(g,setTimeout(()=>{l(g)&&to(g,w)},M*1e3))}}};return u(_,[g,b,A],y=>y[0]===g&&y[1]===b&&y[2]===A,!0)?(v.add(C),l(f)?n(w,f,[b,A,C],!0):e(S,A,[f,b,C],!0),!0):!1}};var Ll=n=>(e,t,[r,i,o],s)=>{let a=e.get(r);a===void 0?e.set(r,new Set([[i,t,o]])):n(a,[i,t,o],c=>c[0]===i&&c[1]===t,s)};var jl=n=>(e,t)=>{let r=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});t.connect(r).connect(e.destination);let i=()=>{t.removeEventListener("ended",i),t.disconnect(r),r.disconnect()};t.addEventListener("ended",i)};var Pl=n=>(e,t)=>{n(e).add(t)};var py={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Fl=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},py),c),h=r(u,l),d=o(u)?e():null;super(a,!1,h,d),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,t()}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,t()}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 ft=(n,e)=>n.context===e;var Bl=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!ft(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=n(s,u)}return r.set(s,a),yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Pi=n=>{try{n.copyToChannel(new Float32Array(1),0,-1)}catch(e){return!1}return!0};var Oe=()=>new DOMException("","IndexSizeError");var Fi=n=>{n.getChannelData=(e=>t=>{try{return e.call(n,t)}catch(r){throw r.code===12?Oe():r}})(n.getChannelData)};var my={numberOfChannels:1},Vl=(n,e,t,r,i,o,s,a)=>{let c=null;return class Gl{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:d,sampleRate:m}=D(D({},my),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&e(o,o)?new r({length:h,numberOfChannels:d,sampleRate:m}):c.createBuffer(d,h,m);if(f.numberOfChannels===0)throw t();return typeof f.copyFromChannel!="function"?(s(f),Fi(f)):e(Pi,()=>Pi(f))||a(f),n.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===Gl.prototype||n.has(l)}}};var Pt=-34028234663852886e22,Et=-Pt;var ae=n=>rr.has(n);var fy={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},ql=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},fy),l),m=i(h,d),f=s(h),g=f?e():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=d.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=t(this,f,m.playbackRate,Et,Pt)}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"){Ve(this);let d=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",d),ae(this)&&nr(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",d)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var Wl=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=t(u),d=ft(h,l);if(!d){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=e(l,m),s!==null&&h.start(...s),a!==null&&h.stop(a)}return o.set(l,h),d?yield n(l,u.playbackRate,h.playbackRate):yield r(l,u.playbackRate,h.playbackRate),yield i(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 Ul=n=>"playbackRate"in n;var zl=n=>"frequency"in n&&"gain"in n;var Yl=n=>"offset"in n;var Hl=n=>!("frequency"in n)&&"gain"in n;var Zl=n=>"detune"in n&&"frequency"in n&&!("gain"in n);var Xl=n=>"pan"in n;var Xt=n=>qt(ys,n);var Fr=n=>qt(bs,n);var _s=(n,e)=>{let{activeInputs:t}=Xt(n);t.forEach(i=>i.forEach(([o])=>{e.includes(n)||_s(o,[...e,n])}));let r=Ul(n)?[n.playbackRate]:Cs(n)?Array.from(n.parameters.values()):zl(n)?[n.Q,n.detune,n.frequency,n.gain]:Yl(n)?[n.offset]:Hl(n)?[n.gain]:Zl(n)?[n.detune,n.frequency]:Xl(n)?[n.pan]:[];for(let i of r){let o=Fr(i);o!==void 0&&o.activeInputs.forEach(([s])=>_s(s,e))}ae(n)&&nr(n)};var Br=n=>{_s(n.destination,[])};var vs=n=>n===void 0||typeof n=="number"||typeof n=="string"&&(n==="balanced"||n==="interactive"||n==="playback");var Ql=(n,e,t,r,i,o,s,a,c)=>class extends n{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"?t():f}if(h===null)throw r();if(!vs(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 t();super(h,2);let{latencyHint:d}=l,{sampleRate:m}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:d==="balanced"?512/m:d==="interactive"||d===void 0?256/m:d==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(d*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 e()}):(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()),Br(this)}))}createMediaElementSource(l){return new i(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 d=()=>{this._nativeAudioContext.removeEventListener("statechange",d),this._nativeAudioContext.state==="running"?l():this.resume().then(l,h)};this._nativeAudioContext.addEventListener("statechange",d)}):this._nativeAudioContext.resume().catch(l=>{throw l===void 0||l.code===15?e():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?e():l})}};var Kl=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=s(h),m=i(h,l,d),f=d?e(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=d,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw t();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 Jl=n=>{let e=new WeakMap,t=(r,i)=>K(null,null,function*(){let o=i.destination;return e.set(i,o),yield n(r,i,o),o});return{render(r,i){let o=e.get(i);return o!==void 0?Promise.resolve(o):t(r,i)}}};var $l=(n,e,t,r,i,o,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let _=new Float32Array(1),v=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),C=s(u),y=!1,T=[0,0,-1,0,1,0],E=[0,0,0],R=()=>{if(y)return;y=!0;let k=r(u,256,9,0);k.onaudioprocess=({inputBuffer:P})=>{let G=[o(P,_,0),o(P,_,1),o(P,_,2),o(P,_,3),o(P,_,4),o(P,_,5)];G.some((Y,V)=>Y!==T[V])&&(l.setOrientation(...G),T=G);let Q=[o(P,_,6),o(P,_,7),o(P,_,8)];Q.some((Y,V)=>Y!==E[V])&&(l.setPosition(...Q),E=Q)},v.connect(k)},M=k=>P=>{P!==T[k]&&(T[k]=P,l.setOrientation(...T))},q=k=>P=>{P!==E[k]&&(E[k]=P,l.setPosition(...E))},L=(k,P,G)=>{let Q=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P});Q.connect(v,0,k),Q.start(),Object.defineProperty(Q.offset,"defaultValue",{get(){return P}});let Y=n({context:c},C,Q.offset,Et,Pt);return a(Y,"value",V=>()=>V.call(Y),V=>ut=>{try{V.call(Y,ut)}catch(mt){if(mt.code!==9)throw mt}R(),C&&G(ut)}),Y.cancelAndHoldAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.cancelAndHoldAtTime),Y.cancelScheduledValues=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.cancelScheduledValues),Y.exponentialRampToValueAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.exponentialRampToValueAtTime),Y.linearRampToValueAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.linearRampToValueAtTime),Y.setTargetAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.setTargetAtTime),Y.setValueAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.setValueAtTime),Y.setValueCurveAtTime=(V=>C?()=>{throw i()}:(...ut)=>{let mt=V.apply(Y,ut);return R(),mt})(Y.setValueCurveAtTime),Y};return{forwardX:L(0,0,M(0)),forwardY:L(1,0,M(1)),forwardZ:L(2,-1,M(2)),positionX:L(6,0,q(0)),positionY:L(7,0,q(1)),positionZ:L(8,0,q(2)),upX:L(3,0,M(3)),upY:L(4,1,M(4)),upZ:L(5,0,M(5))}},{forwardX:d,forwardY:m,forwardZ:f,positionX:g,positionY:b,positionZ:A,upX:I,upY:w,upZ:S}=l.forwardX===void 0?h():l;return{get forwardX(){return d},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return b},get positionZ(){return A},get upX(){return I},get upY(){return w},get upZ(){return S}}};var si=n=>"context"in n;var Vr=n=>si(n[0]);var Ge=(n,e,t,r)=>{for(let i of n)if(t(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return n.add(e),!0};var Bc=(n,e,[t,r],i)=>{Ge(n,[e,t,r],o=>o[0]===e&&o[1]===t,i)};var Vc=(n,[e,t,r],i)=>{let o=n.get(e);o===void 0?n.set(e,new Set([[t,r]])):Ge(o,[t,r],s=>s[0]===t,i)};var Re=n=>"inputs"in n;var Bi=(n,e,t,r)=>{if(Re(e)){let i=e.inputs[r];return n.connect(i,t,0),[i,t,0]}return n.connect(e,t,r),[e,t,r]};var Gc=(n,e,t)=>{for(let r of n)if(r[0]===e&&r[1]===t)return n.delete(r),r;return null};var th=(n,e,t)=>Pr(n,r=>r[0]===e&&r[1]===t);var qc=(n,e)=>{if(!ir(n).delete(e))throw new Error("Missing the expected event listener.")};var Wc=(n,e,t)=>{let r=qt(n,e),i=Pr(r,o=>o[0]===t);return r.size===0&&n.delete(e),i};var Vi=(n,e,t,r)=>{Re(e)?n.disconnect(e.inputs[r],t,0):n.disconnect(e,t,r)};var vt=n=>qt(Li,n);var ai=n=>qt(Qn,n);var xr=n=>Kn.has(n);var Gi=n=>!rr.has(n);var Uc=(n,e)=>new Promise(t=>{if(e!==null)t(!0);else{let r=n.createScriptProcessor(256,1,1),i=n.createGain(),o=n.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=n.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(n.destination),a.connect(i),a.disconnect(i),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,l=>l===1)?t(!0):t(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(n.destination)},a.start()}});var Is=(n,e)=>{let t=new Map;for(let r of n)for(let i of r){let o=t.get(i);t.set(i,o===void 0?1:o+1)}t.forEach((r,i)=>e(i,r))};var ci=n=>"context"in n;var eh=n=>{let e=new Map;n.connect=(t=>(r,i=0,o=0)=>{let s=ci(r)?t(r,i,o):t(r,i),a=e.get(r);return a===void 0?e.set(r,[{input:o,output:i}]):a.every(c=>c.input!==o||c.output!==i)&&a.push({input:o,output:i}),s})(n.connect.bind(n)),n.disconnect=(t=>(r,i,o)=>{if(t.apply(n),r===void 0)e.clear();else if(typeof r=="number")for(let[s,a]of e){let c=a.filter(u=>u.output!==r);c.length===0?e.delete(s):e.set(s,c)}else if(e.has(r))if(i===void 0)e.delete(r);else{let s=e.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==i&&(c.input!==o||o===void 0));a.length===0?e.delete(r):e.set(r,a)}}for(let[s,a]of e)a.forEach(c=>{ci(s)?n.connect(s,c.output,c.input):n.connect(s,c.output)})})(n.disconnect)};var gy=(n,e,t,r)=>{let{activeInputs:i,passiveInputs:o}=Fr(e),{outputs:s}=Xt(n),a=ir(n),c=u=>{let l=vt(n),h=ai(e);if(u){let d=Wc(o,n,t);Bc(i,n,d,!1),!r&&!xr(n)&&l.connect(h,t)}else{let d=th(i,n,t);Vc(o,d,!1),!r&&!xr(n)&&l.disconnect(h,t)}};return Ge(s,[e,t],u=>u[0]===e&&u[1]===t,!0)?(a.add(c),ae(n)?Bc(i,n,[t,c],!0):Vc(o,[n,t,c],!0),!0):!1},yy=(n,e,t,r)=>{let{activeInputs:i,passiveInputs:o}=Xt(e),s=Gc(i[r],n,t);return s===null?[As(o,n,t,r)[2],!1]:[s[2],!0]},by=(n,e,t)=>{let{activeInputs:r,passiveInputs:i}=Fr(e),o=Gc(r,n,t);return o===null?[Wc(i,n,t)[1],!1]:[o[2],!0]},zc=(n,e,t,r,i)=>{let[o,s]=yy(n,t,r,i);if(o!==null&&(qc(n,o),s&&!e&&!xr(n)&&Vi(vt(n),vt(t),r,i)),ae(t)){let{activeInputs:a}=Xt(t);to(t,a)}},Yc=(n,e,t,r)=>{let[i,o]=by(n,t,r);i!==null&&(qc(n,i),o&&!e&&!xr(n)&&vt(n).disconnect(ai(t),r))},xy=(n,e)=>{let t=Xt(n),r=[];for(let i of t.outputs)Vr(i)?zc(n,e,...i):Yc(n,e,...i),r.push(i[0]);return t.outputs.clear(),r},Ay=(n,e,t)=>{let r=Xt(n),i=[];for(let o of r.outputs)o[1]===t&&(Vr(o)?zc(n,e,...o):Yc(n,e,...o),i.push(o[0]),r.outputs.delete(o));return i},Cy=(n,e,t,r,i)=>{let o=Xt(n);return Array.from(o.outputs).filter(s=>s[0]===t&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Vr(s)?zc(n,e,...s):Yc(n,e,...s),o.outputs.delete(s),s[0]))},rh=(n,e,t,r,i,o,s,a,c,u,l,h,d,m,f,g)=>class extends u{constructor(A,I,w,S){super(w),this._context=A,this._nativeAudioNode=w;let _=l(A);h(_)&&t(Uc,()=>Uc(_,g))!==!0&&eh(w),Li.set(this,w),xs.set(this,new Set),A.state!=="closed"&&I&&Ve(this),n(this,S,w)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(A){this._nativeAudioNode.channelCount=A}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(A){this._nativeAudioNode.channelCountMode=A}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(A){this._nativeAudioNode.channelInterpretation=A}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(A,I=0,w=0){if(I<0||I>=this._nativeAudioNode.numberOfOutputs)throw i();let S=l(this._context),_=f(S);if(d(A)||m(A))throw o();if(si(A)){let y=vt(A);try{let E=Bi(this._nativeAudioNode,y,I,w),R=Gi(this);(_||R)&&this._nativeAudioNode.disconnect(...E),this.context.state!=="closed"&&!R&&Gi(A)&&Ve(A)}catch(E){throw E.code===12?o():E}if(e(this,A,I,w,_)){let E=c([this],A);Is(E,r(_))}return A}let v=ai(A);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,I),(_||Gi(this))&&this._nativeAudioNode.disconnect(v,I)}catch(y){throw y.code===12?o():y}if(gy(this,A,I,_)){let y=c([this],A);Is(y,r(_))}}disconnect(A,I,w){let S,_=l(this._context),v=f(_);if(A===void 0)S=xy(this,v);else if(typeof A=="number"){if(A<0||A>=this.numberOfOutputs)throw i();S=Ay(this,v,A)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||si(A)&&w!==void 0&&(w<0||w>=A.numberOfInputs))throw i();if(S=Cy(this,v,A,I,w),S.length===0)throw o()}for(let C of S){let y=c([this],C);Is(y,a)}}};var ih=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>(m,f,g,b=null,A=null)=>{let I=g.value,w=new Xn(I),S=f?r(w):null,_={get defaultValue(){return I},get maxValue(){return b===null?g.maxValue:b},get minValue(){return A===null?g.minValue:A},get value(){return g.value},set value(v){g.value=v,_.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")S===null&&w.flush(m.context.currentTime),w.add(i(v)),g.cancelAndHoldAtTime(v);else{let C=Array.from(w).pop();S===null&&w.flush(m.context.currentTime),w.add(i(v));let y=Array.from(w).pop();g.cancelScheduledValues(v),C!==y&&y!==void 0&&(y.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(y.value,y.endTime):y.type==="linearRampToValue"?g.linearRampToValueAtTime(y.value,y.endTime):y.type==="setValue"?g.setValueAtTime(y.value,y.startTime):y.type==="setValueCurve"&&g.setValueCurveAtTime(y.values,y.startTime,y.duration))}return _},cancelScheduledValues(v){return S===null&&w.flush(m.context.currentTime),w.add(o(v)),g.cancelScheduledValues(v),_},exponentialRampToValueAtTime(v,C){if(v===0)throw new RangeError;if(!Number.isFinite(C)||C<0)throw new RangeError;let y=m.context.currentTime;return S===null&&w.flush(y),Array.from(w).length===0&&(w.add(u(I,y)),g.setValueAtTime(I,y)),w.add(s(v,C)),g.exponentialRampToValueAtTime(v,C),_},linearRampToValueAtTime(v,C){let y=m.context.currentTime;return S===null&&w.flush(y),Array.from(w).length===0&&(w.add(u(I,y)),g.setValueAtTime(I,y)),w.add(a(v,C)),g.linearRampToValueAtTime(v,C),_},setTargetAtTime(v,C,y){return S===null&&w.flush(m.context.currentTime),w.add(c(v,C,y)),g.setTargetAtTime(v,C,y),_},setValueAtTime(v,C){return S===null&&w.flush(m.context.currentTime),w.add(u(v,C)),g.setValueAtTime(v,C),_},setValueCurveAtTime(v,C,y){let T=v instanceof Float32Array?v:new Float32Array(v);if(h!==null&&h.name==="webkitAudioContext"){let E=C+y,R=m.context.sampleRate,M=Math.ceil(C*R),q=Math.floor(E*R),L=q-M,k=new Float32Array(L);for(let G=0;G<L;G+=1){let Q=(T.length-1)/y*((M+G)/R-C),Y=Math.floor(Q),V=Math.ceil(Q);k[G]=Y===V?T[Y]:(1-(Q-Y))*T[Y]+(1-(V-Q))*T[V]}S===null&&w.flush(m.context.currentTime),w.add(l(k,C,y)),g.setValueCurveAtTime(k,C,y);let P=q/R;P<E&&d(_,k[k.length-1],P),d(_,T[T.length-1],E)}else S===null&&w.flush(m.context.currentTime),w.add(l(T,C,y)),g.setValueCurveAtTime(T,C,y);return _}};return t.set(_,g),e.set(_,m),n(_,S),_};var nh=n=>({replay(e){for(let t of n)if(t.type==="exponentialRampToValue"){let{endTime:r,value:i}=t;e.exponentialRampToValueAtTime(i,r)}else if(t.type==="linearRampToValue"){let{endTime:r,value:i}=t;e.linearRampToValueAtTime(i,r)}else if(t.type==="setTarget"){let{startTime:r,target:i,timeConstant:o}=t;e.setTargetAtTime(i,r,o)}else if(t.type==="setValue"){let{startTime:r,value:i}=t;e.setValueAtTime(i,r)}else if(t.type==="setValueCurve"){let{duration:r,startTime:i,values:o}=t;e.setValueCurveAtTime(o,i,r)}else throw new Error("Can't apply an unknown automation.")}});var qi=class{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((r,i)=>e.call(t,r,i,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}};var _y={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},oh=(n,e,t,r,i,o,s,a,c,u,l,h,d,m)=>class extends e{constructor(g,b,A){var I;let w=a(g),S=c(w),_=l(D(D({},_y),A));d(_);let v=Jn.get(w),C=v==null?void 0:v.get(b),y=S||w.state!=="closed"?w:(I=s(w))!==null&&I!==void 0?I:w,T=i(y,S?null:g.baseLatency,u,b,C,_),E=S?r(b,_,C):null;super(g,!0,T,E);let R=[];T.parameters.forEach((q,L)=>{let k=t(this,S,q);R.push([L,k])}),this._nativeAudioWorkletNode=T,this._onprocessorerror=null,this._parameters=new qi(R),S&&n(w,this);let{activeInputs:M}=o(this);h(T,M)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let b=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=b;let A=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=A!==null&&A===b?g:A}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Wi(n,e,t,r,i){if(typeof n.copyFromChannel=="function")e[t].byteLength===0&&(e[t]=new Float32Array(128)),n.copyFromChannel(e[t],r,i);else{let o=n.getChannelData(r);if(e[t].byteLength===0)e[t]=o.slice(i,i+128);else{let s=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[t].set(s)}}}var Ss=(n,e,t,r,i)=>{typeof n.copyToChannel=="function"?e[t].byteLength!==0&&n.copyToChannel(e[t],r,i):e[t].byteLength!==0&&n.getChannelData(r).set(e[t],i)};var Ui=(n,e)=>{let t=[];for(let r=0;r<n;r+=1){let i=[],o=typeof e=="number"?e:e[r];for(let s=0;s<o;s+=1)i.push(new Float32Array(128));t.push(i)}return t};var sh=(n,e)=>{let t=qt($n,n),r=vt(e);return qt(t,r)};var vy=(n,e,t,r,i,o,s)=>K(null,null,function*(){let a=e===null?Math.ceil(n.context.length/128)*128:e.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((b,A)=>b+A,0),l=u===0?null:t.createBuffer(u,a,t.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let h=Xt(n),d=yield sh(t,n),m=Ui(r.numberOfInputs,r.channelCount),f=Ui(r.numberOfOutputs,i),g=Array.from(n.parameters.keys()).reduce((b,A)=>X(D({},b),{[A]:new Float32Array(128)}),{});for(let b=0;b<a;b+=128){if(r.numberOfInputs>0&&e!==null)for(let A=0;A<r.numberOfInputs;A+=1)for(let I=0;I<r.channelCount;I+=1)Wi(e,m[A],I,I,b);o.parameterDescriptors!==void 0&&e!==null&&o.parameterDescriptors.forEach(({name:A},I)=>{Wi(e,g,A,c+I,b)});for(let A=0;A<r.numberOfInputs;A+=1)for(let I=0;I<i[A];I+=1)f[A][I].byteLength===0&&(f[A][I]=new Float32Array(128));try{let A=m.map((w,S)=>h.activeInputs[S].size===0?[]:w),I=s(b/t.sampleRate,t.sampleRate,()=>d.process(A,f,g));if(l!==null)for(let w=0,S=0;w<r.numberOfOutputs;w+=1){for(let _=0;_<i[w];_+=1)Ss(l,f[w],_,S+_,b);S+=i[w]}if(!I)break}catch(A){n.dispatchEvent(new ErrorEvent("processorerror",{colno:A.colno,filename:A.filename,lineno:A.lineno,message:A.message}));break}}return l}),ah=(n,e,t,r,i,o,s,a,c,u,l,h,d,m,f,g)=>(b,A,I)=>{let w=new WeakMap,S=null,_=(v,C)=>K(null,null,function*(){let y=l(v),T=null,E=ft(y,C),R=Array.isArray(A.outputChannelCount)?A.outputChannelCount:Array.from(A.outputChannelCount);if(h===null){let M=R.reduce((P,G)=>P+G,0),q=i(C,{channelCount:Math.max(1,M),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,M)}),L=[];for(let P=0;P<v.numberOfOutputs;P+=1)L.push(r(C,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:R[P]}));let k=s(C,{channelCount:A.channelCount,channelCountMode:A.channelCountMode,channelInterpretation:A.channelInterpretation,gain:1});k.connect=e.bind(null,L),k.disconnect=c.bind(null,L),T=[q,L,k]}else E||(y=new h(C,b));if(w.set(C,T===null?y:T[2]),T!==null){if(S===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(d===null)throw new Error("Missing the native OfflineAudioContext constructor.");let G=v.channelCount*v.numberOfInputs,Q=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,Y=G+Q;S=vy(v,Y===0?null:yield K(null,null,function*(){let ut=new d(Y,Math.ceil(v.context.length/128)*128,C.sampleRate),mt=[],jt=[];for(let At=0;At<A.numberOfInputs;At+=1)mt.push(s(ut,{channelCount:A.channelCount,channelCountMode:A.channelCountMode,channelInterpretation:A.channelInterpretation,gain:1})),jt.push(i(ut,{channelCount:A.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:A.channelCount}));let be=yield Promise.all(Array.from(v.parameters.values()).map(At=>K(null,null,function*(){let ot=o(ut,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:At.value});return yield m(ut,At,ot.offset),ot}))),xe=r(ut,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,G+Q)});for(let At=0;At<A.numberOfInputs;At+=1){mt[At].connect(jt[At]);for(let ot=0;ot<A.channelCount;ot+=1)jt[At].connect(xe,ot,At*A.channelCount+ot)}for(let[At,ot]of be.entries())ot.connect(xe,0,G+At),ot.start(0);return xe.connect(ut.destination),yield Promise.all(mt.map(At=>f(v,ut,At))),g(ut)}),C,A,R,I,u)}let M=yield S,q=t(C,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[L,k,P]=T;M!==null&&(q.buffer=M,q.start(0)),q.connect(L);for(let G=0,Q=0;G<v.numberOfOutputs;G+=1){let Y=k[G];for(let V=0;V<R[G];V+=1)L.connect(Y,Q+V,V);Q+=R[G]}return P}if(E)for(let[M,q]of v.parameters.entries())yield n(C,q,y.parameters.get(M));else for(let[M,q]of v.parameters.entries())yield m(C,q,y.parameters.get(M));return yield f(v,C,y),y});return{render(v,C){a(C,v);let y=w.get(C);return y!==void 0?Promise.resolve(y):_(v,C)}}};var ch=(n,e,t,r,i,o,s,a,c,u,l,h,d,m,f,g,b,A,I,w)=>class extends f{constructor(_,v){super(_,v),this._nativeContext=_,this._audioWorklet=n===void 0?void 0:{addModule:(C,y)=>n(this,C,y)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(_,v,C){return new t({length:v,numberOfChannels:_,sampleRate:C})}createBufferSource(){return new r(this)}createChannelMerger(_=6){return new o(this,{numberOfInputs:_})}createChannelSplitter(_=6){return new s(this,{numberOfOutputs:_})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(_=1){return new l(this,{maxDelayTime:_})}createDynamicsCompressor(){return new h(this)}createGain(){return new d(this)}createIIRFilter(_,v){return new m(this,{feedback:v,feedforward:_})}createOscillator(){return new g(this)}createPanner(){return new b(this)}createPeriodicWave(_,v,C={disableNormalization:!1}){return new A(this,X(D({},C),{imag:v,real:_}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new w(this)}decodeAudioData(_,v,C){return u(this._nativeContext,_).then(y=>(typeof v=="function"&&v(y),y),y=>{throw typeof C=="function"&&C(y),y})}};var Iy={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},uh=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},Iy),l),m=i(h,d),f=s(h),g=f?t():null;super(u,!1,m,g),this._Q=e(this,f,m.Q,Et,Pt),this._detune=e(this,f,m.detune,1200*Math.log2(Et),-1200*Math.log2(Et)),this._frequency=e(this,f,m.frequency,u.sampleRate/2,0),this._gain=e(this,f,m.gain,40*Math.log10(Et),Pt),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(d){throw d.code===11?r():d}if(u.length!==l.length||l.length!==h.length)throw r()}};var lh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=ft(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=e(c,h)}return o.set(c,u),l?(yield n(c,a.Q,u.Q),yield n(c,a.detune,u.detune),yield n(c,a.frequency,u.frequency),yield n(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 i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var hh=(n,e)=>(t,r)=>{let i=e.get(t);if(i!==void 0)return i;let o=n.get(t);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(n.set(t,s),s.catch(()=>!1).then(a=>(n.delete(t),e.set(t,a),a))):(e.set(t,s),s)}catch(s){return e.set(t,!1),!1}};var Sy={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},dh=(n,e,t,r,i)=>class extends n{constructor(s,a){let c=r(s),u=D(D({},Sy),a),l=t(c,u),h=i(c)?e():null;super(s,!1,l,h)}};var ph=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!ft(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=n(s,u)}return r.set(s,a),yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var wy={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},mh=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=o(D(D({},wy),c)),h=t(u,l),d=i(u)?e():null;super(a,!1,h,d)}};var fh=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!ft(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=n(s,u)}return r.set(s,a),yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var gh=n=>(e,t,r)=>n(t,e,r);var yh=n=>(e,t,r=0,i=0)=>{let o=e[r];if(o===void 0)throw n();return ci(t)?o.connect(t,0,i):o.connect(t,0)};var bh=n=>(e,t)=>{let r=n(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return r.buffer=i,r.loop=!0,r.connect(t),r.start(),()=>{r.stop(),r.disconnect(t)}};var Ty={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},xh=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Ty),u),d=r(l,h),m=o(l),f=m?t():null;super(c,!1,d,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=d,this._offset=e(this,m,d.offset,Et,Pt),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"){Ve(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),ae(this)&&nr(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var Ah=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=t(u),d=ft(h,l);if(!d){let m={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(l,m),s!==null&&h.start(s),a!==null&&h.stop(a)}return o.set(l,h),d?yield n(l,u.offset,h.offset):yield r(l,u.offset,h.offset),yield i(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 Ch=n=>e=>(n[0]=e,n[0]);var Ny={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},_h=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=D(D({},Ny),c),h=t(u,l),m=i(u)?e():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 vh=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!ft(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=n(s,u)}return r.set(s,a),Re(a)?yield t(o,s,a.inputs[0]):yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Ih=(n,e)=>(t,r,i)=>{if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(t,r,i)}catch(o){throw o.name==="SyntaxError"?n():o}};var Sh=()=>new DOMException("","DataCloneError");var Hc=n=>{let{port1:e,port2:t}=new MessageChannel;return new Promise(r=>{let i=()=>{t.onmessage=null,e.close(),t.close(),r()};t.onmessage=()=>i();try{e.postMessage(n,[n])}catch(o){}finally{i()}})};var wh=(n,e,t,r,i,o,s,a,c,u,l)=>(h,d)=>{let m=s(h)?h:o(h);if(i.has(d)){let f=t();return Promise.reject(f)}try{i.add(d)}catch(f){}return e(c,()=>c(m))?m.decodeAudioData(d).then(f=>(Hc(d).catch(()=>{}),e(a,()=>a(f))||l(f),n.add(f),f)):new Promise((f,g)=>{let b=()=>K(null,null,function*(){try{yield Hc(d)}catch(I){}}),A=I=>{g(I),b()};try{m.decodeAudioData(d,I=>{typeof I.copyFromChannel!="function"&&(u(I),Fi(I)),n.add(I),b().then(()=>f(I))},I=>{A(I===null?r():I)})}catch(I){A(I)}})};var Th=(n,e,t,r,i,o,s,a)=>(c,u)=>{let l=e.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=o(c.context),d=a(h);if(l===u){if(e.delete(c),!d&&s(c)){let m=r(c),{outputs:f}=t(c);for(let g of f)if(Vr(g)){let b=r(g[0]);n(m,b,g[1],g[2])}else{let b=i(g[0]);m.connect(b,g[1])}}}else e.set(c,l-u)};var Oy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Nh=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Oy),u),d=r(l,h),m=o(l),f=m?t(h.maxDelayTime):null;super(c,!1,d,f),this._delayTime=e(this,m,d.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var Oh=(n,e,t,r,i)=>o=>{let s=new WeakMap,a=(c,u)=>K(null,null,function*(){let l=t(c),h=ft(l,u);if(!h){let d={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=e(u,d)}return s.set(u,l),h?yield n(u,c.delayTime,l.delayTime):yield r(u,c.delayTime,l.delayTime),yield i(c,u,l),l});return{render(c,u){let l=s.get(u);return l!==void 0?Promise.resolve(l):a(c,u)}}};var Rh=n=>(e,t,r,i)=>n(e[i],o=>o[0]===t&&o[1]===r);var Mh=n=>(e,t)=>{n(e).delete(t)};var Dh=n=>"delayTime"in n;var Eh=(n,e,t)=>function r(i,o){let s=si(o)?o:t(n,o);if(Dh(s))return[];if(i[0]===s)return[i];if(i.includes(s))return[];let{outputs:a}=e(s);return Array.from(a).map(c=>r([...i,s],c[0])).reduce((c,u)=>c.concat(u),[])};var ws=(n,e,t)=>{let r=e[t];if(r===void 0)throw n();return r},kh=n=>(e,t=void 0,r=void 0,i=0)=>t===void 0?e.forEach(o=>o.disconnect()):typeof t=="number"?ws(n,e,t).disconnect():ci(t)?r===void 0?e.forEach(o=>o.disconnect(t)):i===void 0?ws(n,e,r).disconnect(t,0):ws(n,e,r).disconnect(t,0,i):r===void 0?e.forEach(o=>o.disconnect(t)):ws(n,e,r).disconnect(t,0);var Ry={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Lh=(n,e,t,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},Ry),l),m=r(h,d),f=s(h),g=f?t():null;super(u,!1,m,g),this._attack=e(this,f,m.attack),this._knee=e(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=e(this,f,m.ratio),this._release=e(this,f,m.release),this._threshold=e(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,i()}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,i()}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 jh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=ft(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=e(c,h)}return o.set(c,u),l?(yield n(c,a.attack,u.attack),yield n(c,a.knee,u.knee),yield n(c,a.ratio,u.ratio),yield n(c,a.release,u.release),yield n(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 i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Ph=()=>new DOMException("","EncodingError");var Fh=n=>e=>new Promise((t,r)=>{if(n===null){r(new SyntaxError);return}let i=n.document.head;if(i===null)r(new SyntaxError);else{let o=n.document.createElement("script"),s=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(s),c=n.onerror,u=()=>{n.onerror=c,URL.revokeObjectURL(a)};n.onerror=(l,h,d,m,f)=>{if(h===a||h===n.location.href&&d===1&&m===1)return u(),r(f),!1;if(c!==null)return c(l,h,d,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),t()},o.src=a,o.type="module",i.appendChild(o)}});var Bh=n=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,r,i){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=n(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(t,o,i)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,r,i){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(t,o===void 0?null:o,i)}};var Vh=n=>(e,t,r)=>{Object.defineProperties(n,{currentFrame:{configurable:!0,get(){return Math.round(e*t)}},currentTime:{configurable:!0,get(){return e}}});try{return r()}finally{n!==null&&(delete n.currentFrame,delete n.currentTime)}};var Gh=n=>e=>K(null,null,function*(){try{let t=yield fetch(e);if(t.ok)return[yield t.text(),t.url]}catch(t){}throw n()});var My={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},qh=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},My),c),h=r(u,l),d=o(u),m=d?t():null;super(a,!1,h,m),this._gain=e(this,d,h.gain,Et,Pt)}get gain(){return this._gain}};var Wh=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=ft(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=e(c,h)}return o.set(c,u),l?yield n(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Uh=(n,e)=>t=>e(n,t);var zh=n=>e=>{let t=n(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return t.renderer};var Yh=n=>e=>{var t;return(t=n.get(e))!==null&&t!==void 0?t:0};var Hh=n=>e=>{let t=n(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return t.renderer};var Zh=n=>e=>n.get(e);var Nt=()=>new DOMException("","InvalidStateError");var Xh=n=>e=>{let t=n.get(e);if(t===void 0)throw Nt();return t};var Qh=(n,e)=>t=>{let r=n.get(t);if(r!==void 0)return r;if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new e(1,1,44100),n.set(t,r),r};var Kh=n=>e=>{let t=n.get(e);if(t===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return t};var zi=()=>new DOMException("","InvalidAccessError");var Jh=n=>{n.getFrequencyResponse=(e=>(t,r,i)=>{if(t.length!==r.length||r.length!==i.length)throw zi();return e.call(n,t,r,i)})(n.getFrequencyResponse)};var Dy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},$h=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=i(u),h=D(D({},Dy),c),d=e(u,l?null:a.baseLatency,h),m=l?t(h.feedback,h.feedforward):null;super(a,!1,d,m),Jh(d),this._nativeIIRFilterNode=d,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var Ts=(n,e,t,r,i,o,s,a,c,u,l)=>{let h=u.length,d=a;for(let m=0;m<h;m+=1){let f=t[0]*u[m];for(let g=1;g<i;g+=1){let b=d-g&c-1;f+=t[g]*o[b],f-=n[g]*s[b]}for(let g=i;g<r;g+=1)f+=t[g]*o[d-g&c-1];for(let g=i;g<e;g+=1)f-=n[g]*s[d-g&c-1];o[d]=u[m],s[d]=f,d=d+1&c-1,l[m]=f}return d};var Ey=(n,e,t,r)=>{let i=t instanceof Float64Array?t:new Float64Array(t),o=r instanceof Float64Array?r:new Float64Array(r),s=i.length,a=o.length,c=Math.min(s,a);if(i[0]!==1){for(let f=0;f<s;f+=1)o[f]/=i[0];for(let f=1;f<a;f+=1)i[f]/=i[0]}let u=32,l=new Float32Array(u),h=new Float32Array(u),d=e.createBuffer(n.numberOfChannels,n.length,n.sampleRate),m=n.numberOfChannels;for(let f=0;f<m;f+=1){let g=n.getChannelData(f),b=d.getChannelData(f);l.fill(0),h.fill(0),Ts(i,s,o,a,c,l,h,0,u,g,b)}return d},td=(n,e,t,r,i)=>(o,s)=>{let a=new WeakMap,c=null,u=(l,h)=>K(null,null,function*(){let d=null,m=e(l),f=ft(m,h);if(h.createIIRFilter===void 0?d=n(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,d===null?m:d),d!==null){if(c===null){if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");let b=new t(l.context.destination.channelCount,l.context.length,h.sampleRate);c=K(null,null,function*(){yield r(l,b,b.destination);let A=yield i(b);return Ey(A,h,o,s)})}let g=yield c;return d.buffer=g,d.start(0),d}return yield r(l,h,m),m});return{render(l,h){let d=a.get(h);return d!==void 0?Promise.resolve(d):u(l,h)}}};var ed=(n,e,t,r,i,o)=>s=>(a,c)=>{let u=n.get(a);if(u===void 0){if(!s&&o(a)){let l=r(a),{outputs:h}=t(a);for(let d of h)if(Vr(d)){let m=r(d[0]);e(l,m,d[1],d[2])}else{let m=i(d[0]);l.disconnect(m,d[1])}}n.set(a,c)}else n.set(a,u+c)};var rd=(n,e)=>t=>{let r=n.get(t);return e(r)||e(t)};var id=(n,e)=>t=>n.has(t)||e(t);var nd=(n,e)=>t=>n.has(t)||e(t);var od=(n,e)=>t=>{let r=n.get(t);return e(r)||e(t)};var sd=n=>e=>n!==null&&e instanceof n;var ad=n=>e=>n!==null&&typeof n.AudioNode=="function"&&e instanceof n.AudioNode;var cd=n=>e=>n!==null&&typeof n.AudioParam=="function"&&e instanceof n.AudioParam;var ud=(n,e)=>t=>n(t)||e(t);var ld=n=>e=>n!==null&&e instanceof n;var hd=n=>n!==null&&n.isSecureContext;var dd=(n,e,t,r)=>class extends n{constructor(o,s){let a=t(o),c=e(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var ky={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},pd=(n,e,t,r)=>class extends n{constructor(o,s){let a=t(o);if(r(a))throw new TypeError;let c=D(D({},ky),s),u=e(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var md=(n,e,t,r)=>class extends n{constructor(o,s){let a=t(o),c=e(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var fd=(n,e,t)=>class extends n{constructor(i,o){let s=t(i),a=e(s,o);super(i,!0,a,null)}};var gd=(n,e,t,r,i)=>class extends r{constructor(s={}){if(i===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new i(s)}catch(l){throw l.code===12&&l.message==="sampleRate is not in range"?e():l}if(a===null)throw t();if(!vs(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 e();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,i.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 n()}):(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()),Br(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?n():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?n():s})}};var yd=(n,e,t,r,i,o)=>class extends t{constructor(a,c){super(a),this._nativeContext=a,ji.set(this,a),r(a)&&i.set(a,new Set),this._destination=new n(this,c),this._listener=e(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 qe=n=>{let e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let t=n.decodeAudioData(e.buffer,()=>{});return t===void 0?!1:(t.catch(()=>{}),!0)}catch(t){}return!1};var Ly={numberOfChannels:1},bd=(n,e,t,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=D(D({},Ly),s),l=t(c,a,u);n(qe,()=>qe(l))||l.addEventListener("statechange",(()=>{let h=0,d=m=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",d),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):h+=1)};return d})()),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(e()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Br(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var xd=(n,e)=>(t,r,i)=>{let o=new Set;return t.connect=(s=>(a,c=0,u=0)=>{let l=o.size===0;if(e(a))return s.call(t,a,c,u),n(o,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(t,a,c),n(o,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(t.connect),t.disconnect=(s=>(a,c,u)=>{let l=o.size>0;if(a===void 0)s.apply(t),o.clear();else if(typeof a=="number"){s.call(t,a);for(let d of o)d[1]===a&&o.delete(d)}else{e(a)?s.call(t,a,c,u):s.call(t,a,c);for(let d of o)d[0]===a&&(c===void 0||d[1]===c)&&(u===void 0||d[2]===u)&&o.delete(d)}let h=o.size===0;l&&h&&i()})(t.disconnect),t};var gt=(n,e,t)=>{let r=e[t];r!==void 0&&r!==n[t]&&(n[t]=r)};var lt=(n,e)=>{gt(n,e,"channelCount"),gt(n,e,"channelCountMode"),gt(n,e,"channelInterpretation")};var Zc=n=>typeof n.getFloatTimeDomainData=="function";var Ad=n=>{n.getFloatTimeDomainData=e=>{let t=new Uint8Array(e.length);n.getByteTimeDomainData(t);let r=Math.max(t.length,n.fftSize);for(let i=0;i<r;i+=1)e[i]=(t[i]-128)*.0078125;return e}};var Cd=(n,e)=>(t,r)=>{let i=t.createAnalyser();if(lt(i,r),!(r.maxDecibels>r.minDecibels))throw e();return gt(i,r,"fftSize"),gt(i,r,"maxDecibels"),gt(i,r,"minDecibels"),gt(i,r,"smoothingTimeConstant"),n(Zc,()=>Zc(i))||Ad(i),i};var _d=n=>n===null?null:n.hasOwnProperty("AudioBuffer")?n.AudioBuffer:null;var xt=(n,e,t)=>{let r=e[t];r!==void 0&&r!==n[t].value&&(n[t].value=r)};var vd=n=>{n.start=(e=>{let t=!1;return(r=0,i=0,o)=>{if(t)throw Nt();e.call(n,r,i,o),t=!0}})(n.start)};var Yi=n=>{n.start=(e=>(t=0,r=0,i)=>{if(typeof i=="number"&&i<0||r<0||t<0)throw new RangeError("The parameters can't be negative.");e.call(n,t,r,i)})(n.start)};var Hi=n=>{n.stop=(e=>(t=0)=>{if(t<0)throw new RangeError("The parameter can't be negative.");e.call(n,t)})(n.stop)};var Id=(n,e,t,r,i,o,s,a,c,u,l)=>(h,d)=>{let m=h.createBufferSource();return lt(m,d),xt(m,d,"playbackRate"),gt(m,d,"buffer"),gt(m,d,"loop"),gt(m,d,"loopEnd"),gt(m,d,"loopStart"),e(t,()=>t(h))||vd(m),e(r,()=>r(h))||c(m),e(i,()=>i(h))||u(m,h),e(o,()=>o(h))||Yi(m),e(s,()=>s(h))||l(m,h),e(a,()=>a(h))||Hi(m),n(h,m),m};var Sd=n=>n===null?null:n.hasOwnProperty("AudioContext")?n.AudioContext:n.hasOwnProperty("webkitAudioContext")?n.webkitAudioContext:null;var wd=(n,e)=>(t,r,i)=>{let o=t.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}i&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=n(t,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return e(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),e(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),e(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 Td=n=>n===null?null:n.hasOwnProperty("AudioWorkletNode")?n.AudioWorkletNode:null;var Nd=n=>{let{port1:e}=new MessageChannel;try{e.postMessage(n)}finally{e.close()}};var Od=(n,e,t,r,i)=>(o,s,a,c,u,l)=>{if(a!==null)try{let h=new a(o,c,l),d=new Map,m=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw n()}},channelCountMode:{get:()=>"explicit",set:()=>{throw n()}},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 A=d.get(g[1]);A!==void 0?g[1]=A:(g[1]=I=>{I.type==="error"?(Object.defineProperties(I,{type:{value:"processorerror"}}),b(I)):b(new ErrorEvent(g[0],D({},I)))},d.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=d.get(g[1]);b!==void 0&&(d.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=t(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(o.destination),i(h,()=>f.disconnect(),()=>f.connect(o.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return Nd(l),e(o,s,u,l)};var Ns=(n,e)=>n===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(n*e)))));var Rd=n=>new Promise((e,t)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),i.close(),e(o)},r.onmessageerror=({data:o})=>{r.close(),i.close(),t(o)},i.postMessage(n)});var Md=(n,e)=>K(null,null,function*(){let t=yield Rd(e);return new n(t)});var Dd=(n,e,t,r)=>{let i=$n.get(n);i===void 0&&(i=new WeakMap,$n.set(n,i));let o=Md(t,r);return i.set(e,o),o};var Ed=(n,e,t,r,i,o,s,a,c,u,l,h,d)=>(m,f,g,b)=>{if(b.numberOfInputs===0&&b.numberOfOutputs===0)throw c();let A=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(A.some(H=>H<1))throw c();if(A.length!==b.numberOfOutputs)throw e();if(b.channelCountMode!=="explicit")throw c();let I=b.channelCount*b.numberOfInputs,w=A.reduce((H,it)=>H+it,0),S=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+S>6||w>6)throw c();let _=new MessageChannel,v=[],C=[];for(let H=0;H<b.numberOfInputs;H+=1)v.push(s(m,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),C.push(i(m,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let y=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:H,maxValue:it,minValue:Yt,name:Ot}of g.parameterDescriptors){let bt=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:b.parameterData[Ot]!==void 0?b.parameterData[Ot]:H===void 0?0:H});Object.defineProperties(bt.offset,{defaultValue:{get:()=>H===void 0?0:H},maxValue:{get:()=>it===void 0?Et:it},minValue:{get:()=>Yt===void 0?Pt:Yt}}),y.push(bt)}let T=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+S)}),E=Ns(f,m.sampleRate),R=a(m,E,I+S,Math.max(1,w)),M=i(m,{channelCount:Math.max(1,w),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,w)}),q=[];for(let H=0;H<b.numberOfOutputs;H+=1)q.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:A[H]}));for(let H=0;H<b.numberOfInputs;H+=1){v[H].connect(C[H]);for(let it=0;it<b.channelCount;it+=1)C[H].connect(T,it,H*b.channelCount+it)}let L=new qi(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:H},it)=>{let Yt=y[it];return Yt.connect(T,0,I+it),Yt.start(0),[H,Yt.offset]}));T.connect(R);let k=b.channelInterpretation,P=null,G=b.numberOfOutputs===0?[R]:q,Q={get bufferSize(){return E},get channelCount(){return b.channelCount},set channelCount(H){throw t()},get channelCountMode(){return b.channelCountMode},set channelCountMode(H){throw t()},get channelInterpretation(){return k},set channelInterpretation(H){for(let it of v)it.channelInterpretation=H;k=H},get context(){return R.context},get inputs(){return v},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},get onprocessorerror(){return P},set onprocessorerror(H){typeof P=="function"&&Q.removeEventListener("processorerror",P),P=typeof H=="function"?H:null,typeof P=="function"&&Q.addEventListener("processorerror",P)},get parameters(){return L},get port(){return _.port2},addEventListener(...H){return R.addEventListener(H[0],H[1],H[2])},connect:n.bind(null,G),disconnect:u.bind(null,G),dispatchEvent(...H){return R.dispatchEvent(H[0])},removeEventListener(...H){return R.removeEventListener(H[0],H[1],H[2])}},Y=new Map;_.port1.addEventListener=(H=>(...it)=>{if(it[0]==="message"){let Yt=typeof it[1]=="function"?it[1]:typeof it[1]=="object"&&it[1]!==null&&typeof it[1].handleEvent=="function"?it[1].handleEvent:null;if(Yt!==null){let Ot=Y.get(it[1]);Ot!==void 0?it[1]=Ot:(it[1]=bt=>{l(m.currentTime,m.sampleRate,()=>Yt(bt))},Y.set(Yt,it[1]))}}return H.call(_.port1,it[0],it[1],it[2])})(_.port1.addEventListener),_.port1.removeEventListener=(H=>(...it)=>{if(it[0]==="message"){let Yt=Y.get(it[1]);Yt!==void 0&&(Y.delete(it[1]),it[1]=Yt)}return H.call(_.port1,it[0],it[1],it[2])})(_.port1.removeEventListener);let V=null;Object.defineProperty(_.port1,"onmessage",{get:()=>V,set:H=>{typeof V=="function"&&_.port1.removeEventListener("message",V),V=typeof H=="function"?H:null,typeof V=="function"&&(_.port1.addEventListener("message",V),_.port1.start())}}),g.prototype.port=_.port1;let ut=null;Dd(m,Q,g,b).then(H=>ut=H);let jt=Ui(b.numberOfInputs,b.channelCount),be=Ui(b.numberOfOutputs,A),xe=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((H,{name:it})=>X(D({},H),{[it]:new Float32Array(128)}),{}),At=!0,ot=()=>{b.numberOfOutputs>0&&R.disconnect(M);for(let H=0,it=0;H<b.numberOfOutputs;H+=1){let Yt=q[H];for(let Ot=0;Ot<A[H];Ot+=1)M.disconnect(Yt,it+Ot,Ot);it+=A[H]}},Ti=new Map;R.onaudioprocess=({inputBuffer:H,outputBuffer:it})=>{if(ut!==null){let Yt=h(Q);for(let Ot=0;Ot<E;Ot+=128){for(let bt=0;bt<b.numberOfInputs;bt+=1)for(let Dt=0;Dt<b.channelCount;Dt+=1)Wi(H,jt[bt],Dt,Dt,Ot);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:bt},Dt)=>{Wi(H,xe,bt,I+Dt,Ot)});for(let bt=0;bt<b.numberOfInputs;bt+=1)for(let Dt=0;Dt<A[bt];Dt+=1)be[bt][Dt].byteLength===0&&(be[bt][Dt]=new Float32Array(128));try{let bt=jt.map((we,Rr)=>{if(Yt[Rr].size>0)return Ti.set(Rr,E/128),we;let uc=Ti.get(Rr);return uc===void 0?[]:(we.every(Km=>Km.every(Jm=>Jm===0))&&(uc===1?Ti.delete(Rr):Ti.set(Rr,uc-1)),we)});At=l(m.currentTime+Ot/m.sampleRate,m.sampleRate,()=>ut.process(bt,be,xe));for(let we=0,Rr=0;we<b.numberOfOutputs;we+=1){for(let Ln=0;Ln<A[we];Ln+=1)Ss(it,be[we],Ln,Rr+Ln,Ot);Rr+=A[we]}}catch(bt){At=!1,Q.dispatchEvent(new ErrorEvent("processorerror",{colno:bt.colno,filename:bt.filename,lineno:bt.lineno,message:bt.message}))}if(!At){for(let bt=0;bt<b.numberOfInputs;bt+=1){v[bt].disconnect(C[bt]);for(let Dt=0;Dt<b.channelCount;Dt+=1)C[Ot].disconnect(T,Dt,bt*b.channelCount+Dt)}if(g.parameterDescriptors!==void 0){let bt=g.parameterDescriptors.length;for(let Dt=0;Dt<bt;Dt+=1){let we=y[Dt];we.disconnect(T,0,I+Dt),we.stop()}}T.disconnect(R),R.onaudioprocess=null,Dn?ot():Oi();break}}}};let Dn=!1,J=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Ni=()=>R.connect(J).connect(m.destination),Oi=()=>{R.disconnect(J),J.disconnect()},En=()=>{if(At){Oi(),b.numberOfOutputs>0&&R.connect(M);for(let H=0,it=0;H<b.numberOfOutputs;H+=1){let Yt=q[H];for(let Ot=0;Ot<A[H];Ot+=1)M.connect(Yt,it+Ot,Ot);it+=A[H]}}Dn=!0},kn=()=>{At&&(Ni(),ot()),Dn=!1};return Ni(),d(Q,En,kn)};var Xc=(n,e)=>{let t=n.createBiquadFilter();return lt(t,e),xt(t,e,"Q"),xt(t,e,"detune"),xt(t,e,"frequency"),xt(t,e,"gain"),gt(t,e,"type"),t};var kd=(n,e)=>(t,r)=>{let i=t.createChannelMerger(r.numberOfInputs);return n!==null&&n.name==="webkitAudioContext"&&e(t,i),lt(i,r),i};var Ld=n=>{let e=n.numberOfOutputs;Object.defineProperty(n,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Nt()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:t=>{if(t!=="explicit")throw Nt()}}),Object.defineProperty(n,"channelInterpretation",{get:()=>"discrete",set:t=>{if(t!=="discrete")throw Nt()}})};var Zi=(n,e)=>{let t=n.createChannelSplitter(e.numberOfOutputs);return lt(t,e),Ld(t),t};var jd=(n,e,t,r,i)=>(o,s)=>{if(o.createConstantSource===void 0)return t(o,s);let a=o.createConstantSource();return lt(a,s),xt(a,s,"offset"),e(r,()=>r(o))||Yi(a),e(i,()=>i(o))||Hi(a),n(o,a),a};var Me=(n,e)=>(n.connect=e.connect.bind(e),n.disconnect=e.disconnect.bind(e),n);var Pd=(n,e,t,r)=>(i,a)=>{var c=a,{offset:o}=c,s=Mr(c,["offset"]);let u=i.createBuffer(1,2,44100),l=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=t(i,X(D({},s),{gain:o})),d=u.getChannelData(0);d[0]=1,d[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 n(i,l),r(Me(m,h),f,g)};var Fd=(n,e)=>(t,r)=>{let i=t.createConvolver();if(lt(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),gt(i,r,"buffer"),r.channelCount>2||(e(i,"channelCount",o=>()=>o.call(i),o=>s=>{if(s>2)throw n();return o.call(i,s)}),r.channelCountMode==="max"))throw n();return e(i,"channelCountMode",o=>()=>o.call(i),o=>s=>{if(s==="max")throw n();return o.call(i,s)}),i};var Qc=(n,e)=>{let t=n.createDelay(e.maxDelayTime);return lt(t,e),xt(t,e,"delayTime"),t};var Bd=n=>(e,t)=>{let r=e.createDynamicsCompressor();if(lt(r,t),t.channelCount>2||t.channelCountMode==="max")throw n();return xt(r,t,"attack"),xt(r,t,"knee"),xt(r,t,"ratio"),xt(r,t,"release"),xt(r,t,"threshold"),r};var ce=(n,e)=>{let t=n.createGain();return lt(t,e),xt(t,e,"gain"),t};var Vd=n=>(e,t,r)=>{if(e.createIIRFilter===void 0)return n(e,t,r);let i=e.createIIRFilter(r.feedforward,r.feedback);return lt(i,r),i};function jy(n,e){let t=e[0]*e[0]+e[1]*e[1];return[(n[0]*e[0]+n[1]*e[1])/t,(n[1]*e[0]-n[0]*e[1])/t]}function Py(n,e){return[n[0]*e[0]-n[1]*e[1],n[0]*e[1]+n[1]*e[0]]}function Gd(n,e){let t=[0,0];for(let r=n.length-1;r>=0;r-=1)t=Py(t,e),t[0]+=n[r];return t}var qd=(n,e,t,r)=>(i,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=Ns(o,i.sampleRate),d=u instanceof Float64Array?u:new Float64Array(u),m=l instanceof Float64Array?l:new Float64Array(l),f=d.length,g=m.length,b=Math.min(f,g);if(f===0||f>20)throw r();if(d[0]===0)throw e();if(g===0||g>20)throw r();if(m[0]===0)throw e();if(d[0]!==1){for(let y=0;y<g;y+=1)m[y]/=d[0];for(let y=1;y<f;y+=1)d[y]/=d[0]}let A=t(i,h,s,s);A.channelCount=s,A.channelCountMode=a,A.channelInterpretation=c;let I=32,w=[],S=[],_=[];for(let y=0;y<s;y+=1){w.push(0);let T=new Float32Array(I),E=new Float32Array(I);T.fill(0),E.fill(0),S.push(T),_.push(E)}A.onaudioprocess=y=>{let T=y.inputBuffer,E=y.outputBuffer,R=T.numberOfChannels;for(let M=0;M<R;M+=1){let q=T.getChannelData(M),L=E.getChannelData(M);w[M]=Ts(d,f,m,g,b,S[M],_[M],w[M],I,q,L)}};let v=i.sampleRate/2;return Me({get bufferSize(){return h},get channelCount(){return A.channelCount},set channelCount(y){A.channelCount=y},get channelCountMode(){return A.channelCountMode},set channelCountMode(y){A.channelCountMode=y},get channelInterpretation(){return A.channelInterpretation},set channelInterpretation(y){A.channelInterpretation=y},get context(){return A.context},get inputs(){return[A]},get numberOfInputs(){return A.numberOfInputs},get numberOfOutputs(){return A.numberOfOutputs},addEventListener(...y){return A.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return A.dispatchEvent(y[0])},getFrequencyResponse(y,T,E){if(y.length!==T.length||T.length!==E.length)throw n();let R=y.length;for(let M=0;M<R;M+=1){let q=-Math.PI*(y[M]/v),L=[Math.cos(q),Math.sin(q)],k=Gd(m,L),P=Gd(d,L),G=jy(k,P);T[M]=Math.sqrt(G[0]*G[0]+G[1]*G[1]),E[M]=Math.atan2(G[1],G[0])}},removeEventListener(...y){return A.removeEventListener(y[0],y[1],y[2])}},A)};var Wd=(n,e)=>n.createMediaElementSource(e.mediaElement);var Ud=(n,e)=>{let t=n.createMediaStreamDestination();return lt(t,e),t.numberOfOutputs===1&&Object.defineProperty(t,"numberOfOutputs",{get:()=>0}),t};var zd=(n,{mediaStream:e})=>{let t=e.getAudioTracks();t.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=t.slice(0,1),i=n.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:e}),i};var Yd=(n,e)=>(t,{mediaStreamTrack:r})=>{if(typeof t.createMediaStreamTrackSource=="function")return t.createMediaStreamTrackSource(r);let i=new MediaStream([r]),o=t.createMediaStreamSource(i);if(r.kind!=="audio")throw n();if(e(t))throw new TypeError;return o};var Hd=n=>n===null?null:n.hasOwnProperty("OfflineAudioContext")?n.OfflineAudioContext:n.hasOwnProperty("webkitOfflineAudioContext")?n.webkitOfflineAudioContext:null;var Zd=(n,e,t,r,i,o)=>(s,a)=>{let c=s.createOscillator();return lt(c,a),xt(c,a,"detune"),xt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):gt(c,a,"type"),e(t,()=>t(s))||Yi(c),e(r,()=>r(s))||o(c,s),e(i,()=>i(s))||Hi(c),n(s,c),c};var Xd=n=>(e,t)=>{let r=e.createPanner();return r.orientationX===void 0?n(e,t):(lt(r,t),xt(r,t,"orientationX"),xt(r,t,"orientationY"),xt(r,t,"orientationZ"),xt(r,t,"positionX"),xt(r,t,"positionY"),xt(r,t,"positionZ"),gt(r,t,"coneInnerAngle"),gt(r,t,"coneOuterAngle"),gt(r,t,"coneOuterGain"),gt(r,t,"distanceModel"),gt(r,t,"maxDistance"),gt(r,t,"panningModel"),gt(r,t,"refDistance"),gt(r,t,"rolloffFactor"),r)};var Qd=(n,e,t,r,i,o,s,a,c,u)=>(l,E)=>{var R=E,{coneInnerAngle:h,coneOuterAngle:d,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:b,orientationY:A,orientationZ:I,panningModel:w,positionX:S,positionY:_,positionZ:v,refDistance:C,rolloffFactor:y}=R,T=Mr(R,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let M=l.createPanner();if(T.channelCount>2||T.channelCountMode==="max")throw s();lt(M,T);let q={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},L=t(l,X(D({},q),{channelInterpretation:"speakers",numberOfInputs:6})),k=r(l,X(D({},T),{gain:1})),P=r(l,X(D({},q),{gain:1})),G=r(l,X(D({},q),{gain:0})),Q=r(l,X(D({},q),{gain:0})),Y=r(l,X(D({},q),{gain:0})),V=r(l,X(D({},q),{gain:0})),ut=r(l,X(D({},q),{gain:0})),mt=i(l,256,6,1),jt=o(l,X(D({},q),{curve:new Float32Array([1,1]),oversample:"none"})),be=[b,A,I],xe=[S,_,v],At=new Float32Array(1);mt.onaudioprocess=({inputBuffer:J})=>{let Ni=[c(J,At,0),c(J,At,1),c(J,At,2)];Ni.some((En,kn)=>En!==be[kn])&&(M.setOrientation(...Ni),be=Ni);let Oi=[c(J,At,3),c(J,At,4),c(J,At,5)];Oi.some((En,kn)=>En!==xe[kn])&&(M.setPosition(...Oi),xe=Oi)},Object.defineProperty(G.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Y.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ut.gain,"defaultValue",{get:()=>0});let ot={get bufferSize(){},get channelCount(){return M.channelCount},set channelCount(J){if(J>2)throw s();k.channelCount=J,M.channelCount=J},get channelCountMode(){return M.channelCountMode},set channelCountMode(J){if(J==="max")throw s();k.channelCountMode=J,M.channelCountMode=J},get channelInterpretation(){return M.channelInterpretation},set channelInterpretation(J){k.channelInterpretation=J,M.channelInterpretation=J},get coneInnerAngle(){return M.coneInnerAngle},set coneInnerAngle(J){M.coneInnerAngle=J},get coneOuterAngle(){return M.coneOuterAngle},set coneOuterAngle(J){M.coneOuterAngle=J},get coneOuterGain(){return M.coneOuterGain},set coneOuterGain(J){if(J<0||J>1)throw e();M.coneOuterGain=J},get context(){return M.context},get distanceModel(){return M.distanceModel},set distanceModel(J){M.distanceModel=J},get inputs(){return[k]},get maxDistance(){return M.maxDistance},set maxDistance(J){if(J<0)throw new RangeError;M.maxDistance=J},get numberOfInputs(){return M.numberOfInputs},get numberOfOutputs(){return M.numberOfOutputs},get orientationX(){return P.gain},get orientationY(){return G.gain},get orientationZ(){return Q.gain},get panningModel(){return M.panningModel},set panningModel(J){M.panningModel=J},get positionX(){return Y.gain},get positionY(){return V.gain},get positionZ(){return ut.gain},get refDistance(){return M.refDistance},set refDistance(J){if(J<0)throw new RangeError;M.refDistance=J},get rolloffFactor(){return M.rolloffFactor},set rolloffFactor(J){if(J<0)throw new RangeError;M.rolloffFactor=J},addEventListener(...J){return k.addEventListener(J[0],J[1],J[2])},dispatchEvent(...J){return k.dispatchEvent(J[0])},removeEventListener(...J){return k.removeEventListener(J[0],J[1],J[2])}};h!==ot.coneInnerAngle&&(ot.coneInnerAngle=h),d!==ot.coneOuterAngle&&(ot.coneOuterAngle=d),m!==ot.coneOuterGain&&(ot.coneOuterGain=m),f!==ot.distanceModel&&(ot.distanceModel=f),g!==ot.maxDistance&&(ot.maxDistance=g),b!==ot.orientationX.value&&(ot.orientationX.value=b),A!==ot.orientationY.value&&(ot.orientationY.value=A),I!==ot.orientationZ.value&&(ot.orientationZ.value=I),w!==ot.panningModel&&(ot.panningModel=w),S!==ot.positionX.value&&(ot.positionX.value=S),_!==ot.positionY.value&&(ot.positionY.value=_),v!==ot.positionZ.value&&(ot.positionZ.value=v),C!==ot.refDistance&&(ot.refDistance=C),y!==ot.rolloffFactor&&(ot.rolloffFactor=y),(be[0]!==1||be[1]!==0||be[2]!==0)&&M.setOrientation(...be),(xe[0]!==0||xe[1]!==0||xe[2]!==0)&&M.setPosition(...xe);let Ti=()=>{k.connect(M),n(k,jt,0,0),jt.connect(P).connect(L,0,0),jt.connect(G).connect(L,0,1),jt.connect(Q).connect(L,0,2),jt.connect(Y).connect(L,0,3),jt.connect(V).connect(L,0,4),jt.connect(ut).connect(L,0,5),L.connect(mt).connect(l.destination)},Dn=()=>{k.disconnect(M),a(k,jt,0,0),jt.disconnect(P),P.disconnect(L),jt.disconnect(G),G.disconnect(L),jt.disconnect(Q),Q.disconnect(L),jt.disconnect(Y),Y.disconnect(L),jt.disconnect(V),V.disconnect(L),jt.disconnect(ut),ut.disconnect(L),L.disconnect(mt),mt.disconnect(l.destination)};return u(Me(ot,M),Ti,Dn)};var Kd=n=>(e,{disableNormalization:t,imag:r,real:i})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(s,o,{disableNormalization:t});if(Array.from(r).length<2)throw n();return a};var Xi=(n,e,t,r)=>n.createScriptProcessor(e,t,r);var Jd=(n,e)=>(t,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw e();if(t.createStereoPanner===void 0)return n(t,r);let o=t.createStereoPanner();return lt(o,r),xt(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw e()}}),o};var $d=(n,e,t,r,i,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=X(D({},u),{oversample:"none"}),h=(f,g,b,A)=>{let I=new Float32Array(16385),w=new Float32Array(16385);for(let T=0;T<16385;T+=1){let E=T/16384*c;I[T]=Math.cos(E),w[T]=Math.sin(E)}let S=t(f,X(D({},u),{gain:0})),_=r(f,X(D({},l),{curve:I})),v=r(f,X(D({},l),{curve:a})),C=t(f,X(D({},u),{gain:0})),y=r(f,X(D({},l),{curve:w}));return{connectGraph(){g.connect(S),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(C),v.connect(b),b.connect(_.inputs===void 0?_:_.inputs[0]),b.connect(y.inputs===void 0?y:y.inputs[0]),_.connect(S.gain),y.connect(C.gain),S.connect(A,0,0),C.connect(A,0,1)},disconnectGraph(){g.disconnect(S),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(C),v.disconnect(b),b.disconnect(_.inputs===void 0?_:_.inputs[0]),b.disconnect(y.inputs===void 0?y:y.inputs[0]),_.disconnect(S.gain),y.disconnect(C.gain),S.disconnect(A,0,0),C.disconnect(A,0,1)}}},d=(f,g,b,A)=>{let I=new Float32Array(16385),w=new Float32Array(16385),S=new Float32Array(16385),_=new Float32Array(16385),v=Math.floor(16385/2);for(let G=0;G<16385;G+=1)if(G>v){let Q=(G-v)/(16384-v)*c;I[G]=Math.cos(Q),w[G]=Math.sin(Q),S[G]=0,_[G]=1}else{let Q=G/(16384-v)*c;I[G]=1,w[G]=0,S[G]=Math.cos(Q),_[G]=Math.sin(Q)}let C=e(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),y=t(f,X(D({},u),{gain:0})),T=r(f,X(D({},l),{curve:I})),E=t(f,X(D({},u),{gain:0})),R=r(f,X(D({},l),{curve:w})),M=r(f,X(D({},l),{curve:a})),q=t(f,X(D({},u),{gain:0})),L=r(f,X(D({},l),{curve:S})),k=t(f,X(D({},u),{gain:0})),P=r(f,X(D({},l),{curve:_}));return{connectGraph(){g.connect(C),g.connect(M.inputs===void 0?M:M.inputs[0]),C.connect(y,0),C.connect(E,0),C.connect(q,1),C.connect(k,1),M.connect(b),b.connect(T.inputs===void 0?T:T.inputs[0]),b.connect(R.inputs===void 0?R:R.inputs[0]),b.connect(L.inputs===void 0?L:L.inputs[0]),b.connect(P.inputs===void 0?P:P.inputs[0]),T.connect(y.gain),R.connect(E.gain),L.connect(q.gain),P.connect(k.gain),y.connect(A,0,0),q.connect(A,0,0),E.connect(A,0,1),k.connect(A,0,1)},disconnectGraph(){g.disconnect(C),g.disconnect(M.inputs===void 0?M:M.inputs[0]),C.disconnect(y,0),C.disconnect(E,0),C.disconnect(q,1),C.disconnect(k,1),M.disconnect(b),b.disconnect(T.inputs===void 0?T:T.inputs[0]),b.disconnect(R.inputs===void 0?R:R.inputs[0]),b.disconnect(L.inputs===void 0?L:L.inputs[0]),b.disconnect(P.inputs===void 0?P:P.inputs[0]),T.disconnect(y.gain),R.disconnect(E.gain),L.disconnect(q.gain),P.disconnect(k.gain),y.disconnect(A,0,0),q.disconnect(A,0,0),E.disconnect(A,0,1),k.disconnect(A,0,1)}}},m=(f,g,b,A,I)=>{if(g===1)return h(f,b,A,I);if(g===2)return d(f,b,A,I);throw i()};return(f,w)=>{var S=w,{channelCount:g,channelCountMode:b,pan:A}=S,I=Mr(S,["channelCount","channelCountMode","pan"]);if(b==="max")throw i();let _=n(f,X(D({},I),{channelCount:1,channelCountMode:b,numberOfInputs:2})),v=t(f,X(D({},I),{channelCount:g,channelCountMode:b,gain:1})),C=t(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:A}),{connectGraph:y,disconnectGraph:T}=m(f,g,v,C,_);Object.defineProperty(C.gain,"defaultValue",{get:()=>0}),Object.defineProperty(C.gain,"maxValue",{get:()=>1}),Object.defineProperty(C.gain,"minValue",{get:()=>-1});let E={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(L){v.channelCount!==L&&(R&&T(),{connectGraph:y,disconnectGraph:T}=m(f,L,v,C,_),R&&y()),v.channelCount=L},get channelCountMode(){return v.channelCountMode},set channelCountMode(L){if(L==="clamped-max"||L==="max")throw i();v.channelCountMode=L},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(L){v.channelInterpretation=L},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return C.gain},addEventListener(...L){return v.addEventListener(L[0],L[1],L[2])},dispatchEvent(...L){return v.dispatchEvent(L[0])},removeEventListener(...L){return v.removeEventListener(L[0],L[1],L[2])}},R=!1,M=()=>{y(),R=!0},q=()=>{T(),R=!1};return o(Me(E,_),M,q)}};var tp=(n,e,t,r,i,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return t(a,c);lt(u,c);let l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw e();gt(u,{curve:l},"curve"),gt(u,c,"oversample");let h=null,d=!1;return s(u,"curve",g=>()=>g.call(u),g=>b=>(g.call(u,b),d&&(r(b)&&h===null?h=n(a,u):!r(b)&&h!==null&&(h(),h=null)),b)),i(u,()=>{d=!0,r(u.curve)&&(h=n(a,u))},()=>{d=!1,h!==null&&(h(),h=null)})};var ep=(n,e,t,r,i)=>(o,u)=>{var l=u,{curve:s,oversample:a}=l,c=Mr(l,["curve","oversample"]);let h=o.createWaveShaper(),d=o.createWaveShaper();lt(h,c),lt(d,c);let m=t(o,X(D({},c),{gain:1})),f=t(o,X(D({},c),{gain:-1})),g=t(o,X(D({},c),{gain:1})),b=t(o,X(D({},c),{gain:-1})),A=null,I=!1,w=null,S={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(C){m.channelCount=C,f.channelCount=C,h.channelCount=C,g.channelCount=C,d.channelCount=C,b.channelCount=C},get channelCountMode(){return h.channelCountMode},set channelCountMode(C){m.channelCountMode=C,f.channelCountMode=C,h.channelCountMode=C,g.channelCountMode=C,d.channelCountMode=C,b.channelCountMode=C},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(C){m.channelInterpretation=C,f.channelInterpretation=C,h.channelInterpretation=C,g.channelInterpretation=C,d.channelInterpretation=C,b.channelInterpretation=C},get context(){return h.context},get curve(){return w},set curve(C){if(C!==null&&C.length<2)throw e();if(C===null)h.curve=C,d.curve=C;else{let y=C.length,T=new Float32Array(y+2-y%2),E=new Float32Array(y+2-y%2);T[0]=C[0],E[0]=-C[y-1];let R=Math.ceil((y+1)/2),M=(y+1)/2-1;for(let q=1;q<R;q+=1){let L=q/R*M,k=Math.floor(L),P=Math.ceil(L);T[q]=k===P?C[k]:(1-(L-k))*C[k]+(1-(P-L))*C[P],E[q]=k===P?-C[y-1-k]:-((1-(L-k))*C[y-1-k])-(1-(P-L))*C[y-1-P]}T[R]=y%2===1?C[R-1]:(C[R-2]+C[R-1])/2,h.curve=T,d.curve=E}w=C,I&&(r(w)&&A===null?A=n(o,m):A!==null&&(A(),A=null))},get inputs(){return[m]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(C){h.oversample=C,d.oversample=C},addEventListener(...C){return m.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return m.dispatchEvent(C[0])},removeEventListener(...C){return m.removeEventListener(C[0],C[1],C[2])}};s!==null&&(S.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==S.oversample&&(S.oversample=a);let _=()=>{m.connect(h).connect(g),m.connect(f).connect(d).connect(b).connect(g),I=!0,r(w)&&(A=n(o,m))},v=()=>{m.disconnect(h),h.disconnect(g),m.disconnect(f),f.disconnect(d),d.disconnect(b),b.disconnect(g),I=!1,A!==null&&(A(),A=null)};return i(Me(S,g),_,v)};var Jt=()=>new DOMException("","NotSupportedError");var Fy={numberOfChannels:1},rp=(n,e,t,r,i)=>class extends n{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:d}=D(D({},Fy),u),m=r(h,l,d);e(qe,()=>qe(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(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Br(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var By={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},ip=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},By),u),d=t(l,h),m=o(l),f=m?r():null,g=c.sampleRate/2;super(c,!1,d,f),this._detune=e(this,m,d.detune,153600,-153600),this._frequency=e(this,m,d.frequency,g,-g),this._nativeOscillatorNode=d,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"){Ve(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),ae(this)&&nr(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var np=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(l,h)=>K(null,null,function*(){let d=t(l),m=ft(d,h);if(!m){let f={channelCount:d.channelCount,channelCountMode:d.channelCountMode,channelInterpretation:d.channelInterpretation,detune:d.detune.value,frequency:d.frequency.value,periodicWave:s===null?void 0:s,type:d.type};d=e(h,f),a!==null&&d.start(a),c!==null&&d.stop(c)}return o.set(h,d),m?(yield n(h,l.detune,d.detune),yield n(h,l.frequency,d.frequency)):(yield r(h,l.detune,d.detune),yield r(h,l.frequency,d.frequency)),yield i(l,h,d),d});return{set periodicWave(l){s=l},set start(l){a=l},set stop(l){c=l},render(l,h){let d=o.get(h);return d!==void 0?Promise.resolve(d):u(l,h)}}};var Vy={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},op=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Vy),u),d=t(l,h),m=o(l),f=m?r():null;super(c,!1,d,f),this._nativePannerNode=d,this._orientationX=e(this,m,d.orientationX,Et,Pt),this._orientationY=e(this,m,d.orientationY,Et,Pt),this._orientationZ=e(this,m,d.orientationZ,Et,Pt),this._positionX=e(this,m,d.positionX,Et,Pt),this._positionY=e(this,m,d.positionY,Et,Pt),this._positionZ=e(this,m,d.positionZ,Et,Pt),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 sp=(n,e,t,r,i,o,s,a,c,u)=>()=>{let l=new WeakMap,h=null,d=(m,f)=>K(null,null,function*(){let g=null,b=o(m),A={channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation},I=X(D({},A),{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=ft(b,f);if("bufferSize"in b)g=r(f,X(D({},A),{gain:1}));else if(!w){let S=X(D({},I),{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=i(f,S)}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 R=new s(6,m.context.length,f.sampleRate),M=e(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});M.connect(R.destination),h=K(null,null,function*(){let q=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((L,k)=>K(null,null,function*(){let P=t(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:k===0?1:0});return yield a(R,L,P.offset),P})));for(let L=0;L<6;L+=1)q[L].connect(M,0,L),q[L].start(0);return u(R)})}let S=yield h,_=r(f,X(D({},A),{gain:1}));yield c(m,f,_);let v=[];for(let R=0;R<S.numberOfChannels;R+=1)v.push(S.getChannelData(R));let C=[v[0][0],v[1][0],v[2][0]],y=[v[3][0],v[4][0],v[5][0]],T=r(f,X(D({},A),{gain:1})),E=i(f,X(D({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:y[0],positionY:y[1],positionZ:y[2]}));_.connect(T).connect(E.inputs[0]),E.connect(g);for(let R=128;R<S.length;R+=128){let M=[v[0][R],v[1][R],v[2][R]],q=[v[3][R],v[4][R],v[5][R]];if(M.some((L,k)=>L!==C[k])||q.some((L,k)=>L!==y[k])){C=M,y=q;let L=R/f.sampleRate;T.gain.setValueAtTime(0,L),T=r(f,X(D({},A),{gain:0})),E=i(f,X(D({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:y[0],positionY:y[1],positionZ:y[2]})),T.gain.setValueAtTime(1,L),_.connect(T).connect(E.inputs[0]),E.connect(g)}}return g}return w?(yield n(f,m.orientationX,b.orientationX),yield n(f,m.orientationY,b.orientationY),yield n(f,m.orientationZ,b.orientationZ),yield n(f,m.positionX,b.positionX),yield n(f,m.positionY,b.positionY),yield n(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)),Re(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):d(m,f)}}};var Gy={disableNormalization:!1},ap=(n,e,t,r)=>class cp{constructor(o,s){let a=e(o),c=r(D(D({},Gy),s)),u=n(a,c);return t.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===cp.prototype||t.has(o)}};var up=(n,e)=>(t,r,i)=>(n(r).replay(i),e(r,t,i));var lp=(n,e,t)=>(r,i,o)=>K(null,null,function*(){let s=n(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>K(null,[h],function*([u,l]){let m=yield e(u).render(u,i),f=r.context.destination;!t(u)&&(r!==f||!t(r))&&m.connect(o,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var hp=(n,e,t)=>(r,i,o)=>K(null,null,function*(){let s=e(r);yield Promise.all(Array.from(s.activeInputs).map(u=>K(null,[u],function*([a,c]){let h=yield n(a).render(a,i);t(a)||h.connect(o,c)})))});var dp=(n,e,t,r)=>i=>n(qe,()=>qe(i))?Promise.resolve(n(r,r)).then(o=>{if(!o){let s=t(i,512,0,1);i.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>i.currentTime,s.connect(i.destination)}return i.startRendering()}):new Promise(o=>{let s=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var pp=n=>(e,t)=>{n.set(e,t)};var mp=n=>(e,t)=>n.set(e,t);var fp=(n,e,t,r,i,o,s,a)=>(c,u)=>t(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(l=>t(l).render(l,u)))).then(()=>i(u)).then(l=>(typeof l.copyFromChannel!="function"?(s(l),Fi(l)):e(o,()=>o(l))||a(l),n.add(l),l));var qy={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},gp=(n,e,t,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},qy),c),h=t(u,l),d=o(u),m=d?r():null;super(a,!1,h,m),this._pan=e(this,d,h.pan)}get pan(){return this._pan}};var yp=(n,e,t,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=t(a),l=ft(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=e(c,h)}return o.set(c,u),l?yield n(c,a.pan,u.pan):yield r(c,a.pan,u.pan),Re(u)?yield i(a,c,u.inputs[0]):yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var bp=n=>()=>{if(n===null)return!1;try{new n({length:1,sampleRate:44100})}catch(e){return!1}return!0};var xp=(n,e)=>()=>K(null,null,function*(){if(n===null)return!0;if(e===null)return!1;let t=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 e(1,128,44100),i=URL.createObjectURL(t),o=!1,s=!1;try{yield r.audioWorklet.addModule(i);let a=new n(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(i)}return o&&!s});var Ap=(n,e)=>()=>{if(e===null)return Promise.resolve(!1);let t=new e(1,1,44100),r=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{t.oncomplete=()=>{r.disconnect(),i(t.currentTime!==0)},t.startRendering()})};var Kc=()=>new DOMException("","UnknownError");var Wy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Cp=(n,e,t,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Wy),u),d=t(l,h),f=o(l)?r():null;super(c,!0,d,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=d,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 e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var _p=(n,e,t)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=e(o);if(!ft(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=n(s,u)}return r.set(s,a),Re(a)?yield t(o,s,a.inputs[0]):yield t(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var vp=()=>typeof window=="undefined"?null:window;var Ip=(n,e)=>t=>{t.copyFromChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=t.numberOfChannels)throw e();let c=t.length,u=t.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)r[h]=u[h+s]},t.copyToChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=t.numberOfChannels)throw e();let c=t.length,u=t.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 Sp=n=>e=>{e.copyFromChannel=(t=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<e.length)return t.call(e,r,a,s)})(e.copyFromChannel),e.copyToChannel=(t=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<e.length)return t.call(e,r,a,s)})(e.copyToChannel)};var wp=n=>(e,t)=>{let r=t.createBuffer(1,1,44100);e.buffer===null&&(e.buffer=r),n(e,"buffer",i=>()=>{let o=i.call(e);return o===r?null:o},i=>o=>i.call(e,o===null?r:o))};var Tp=(n,e)=>(t,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw n()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw n()}});let i=t.createBufferSource();e(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(r,0,c)},()=>i.disconnect(r))};var Jc=(n,e,t)=>n.copyFromChannel===void 0?n.getChannelData(t)[0]:(n.copyFromChannel(e,t),e[0]);var $c=n=>{if(n===null)return!1;let e=n.length;return e%2!==0?n[Math.floor(e/2)]!==0:n[e/2-1]+n[e/2]!==0};var Qi=(n,e,t,r)=>{let i=n;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);let{get:o,set:s}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(n,e,{get:t(o),set:r(s)})};var Np=n=>X(D({},n),{outputChannelCount:n.outputChannelCount!==void 0?n.outputChannelCount:n.numberOfInputs===1&&n.numberOfOutputs===1?[n.channelCount]:Array.from({length:n.numberOfOutputs},()=>1)});var Op=n=>X(D({},n),{channelCount:n.numberOfOutputs});var Rp=n=>{let{imag:e,real:t}=n;return e===void 0?t===void 0?X(D({},n),{imag:[0,0],real:[0,0]}):X(D({},n),{imag:Array.from(t,()=>0),real:t}):t===void 0?X(D({},n),{imag:e,real:Array.from(e,()=>0)}):X(D({},n),{imag:e,real:t})};var tu=(n,e,t)=>{try{n.setValueAtTime(e,t)}catch(r){if(r.code!==9)throw r;tu(n,e,t+1e-7)}};var Mp=n=>{let e=n.createBufferSource();e.start();try{e.start()}catch(t){return!0}return!1};var Dp=n=>{let e=n.createBufferSource(),t=n.createBuffer(1,1,44100);e.buffer=t;try{e.start(0,1)}catch(r){return!1}return!0};var Ep=n=>{let e=n.createBufferSource();e.start();try{e.stop()}catch(t){return!1}return!0};var Os=n=>{let e=n.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1};var eu=n=>{let e=n.createBuffer(1,1,44100),t=n.createBufferSource();t.buffer=e,t.start(),t.stop();try{return t.stop(),!0}catch(r){return!1}};var Rs=n=>{let e=n.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1};var kp=n=>{let{port1:e,port2:t}=new MessageChannel;try{e.postMessage(n)}finally{e.close(),t.close()}};var Lp=n=>{n.start=(e=>(t=0,r=0,i)=>{let o=n.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/n.context.sampleRate?e.call(n,t,0,0):e.call(n,t,s,i)})(n.start)};var ru=(n,e)=>{let t=e.createGain();n.connect(t);let r=(i=>()=>{i.call(n,t),n.removeEventListener("ended",r)})(n.disconnect);n.addEventListener("ended",r),Me(n,t),n.stop=(i=>{let o=!1;return(s=0)=>{if(o)try{i.call(n,s)}catch(a){t.gain.setValueAtTime(0,s)}else i.call(n,s),o=!0}})(n.stop)};var ui=(n,e)=>t=>{let r={value:n};return Object.defineProperties(t,{currentTarget:r,target:r}),typeof e=="function"?e.call(n,t):e.handleEvent.call(n,t)};var Uy=Sl(Ge),zy=Ll(Ge),Yy=Rh(Pr),Pp=new WeakMap,Hy=Yh(Pp),De=hh(new Map,new WeakMap),or=vp(),Fp=Cd(De,Oe),iu=zh(Xt),$t=lp(Xt,iu,xr),Zy=Bl(Fp,vt,$t),wt=Xh(ji),Ar=Hd(or),It=ld(Ar),Bp=new WeakMap,Vp=Bh(ui),Ki=Sd(or),nu=sd(Ki),ou=ad(or),Gp=cd(or),eo=Td(or),Ft=rh(wl(ys),kl(Uy,zy,Bi,Yy,Vi,Xt,Hy,ir,vt,Ge,ae,xr,Gi),De,ed(Kn,Vi,Xt,vt,ai,ae),Oe,zi,Jt,Th(Bi,Kn,Xt,vt,ai,wt,ae,It),Eh(Bp,Xt,qt),Vp,wt,nu,ou,Gp,It,eo),Xy=Fl(Ft,Zy,Oe,Fp,wt,It);var su=new WeakSet,jp=_d(or),qp=Ch(new Uint32Array(1)),au=Ip(qp,Oe),cu=Sp(qp),uu=Vl(su,De,Jt,jp,Ar,bp(jp),au,cu);var Ms=jl(ce),Wp=hp(iu,Fr,xr),sr=gh(Wp),Ji=Id(Ms,De,Mp,Dp,Ep,Os,eu,Rs,Lp,wp(Qi),ru),ar=up(Hh(Fr),Wp),Qy=Wl(sr,Ji,vt,ar,$t),We=ih(Tl(bs),Bp,Qn,nh,Ec,kc,Lc,jc,Pc,Di,zn,Ki,tu),Ky=ql(Ft,Qy,We,Nt,Ji,wt,It,ui);var Jy=Kl(Ft,Jl,Oe,Nt,wd(ce,Qi),wt,It,$t),$y=lh(sr,Xc,vt,ar,$t),li=mp(Pp),tb=uh(Ft,We,$y,zi,Xc,wt,It,li),Gr=xd(Ge,ou),eb=Tp(Nt,Gr),qr=kd(Ki,eb),rb=ph(qr,vt,$t),ib=dh(Ft,rb,qr,wt,It),nb=fh(Zi,vt,$t),ob=mh(Ft,nb,Zi,wt,It,Op),sb=Pd(Ms,Ji,ce,Gr),$i=jd(Ms,De,sb,Os,Rs),ab=Ah(sr,$i,vt,ar,$t),cb=xh(Ft,We,ab,$i,wt,It,ui),Up=Fd(Jt,Qi),ub=vh(Up,vt,$t),lb=_h(Ft,ub,Up,wt,It,li),hb=Oh(sr,Qc,vt,ar,$t),db=Nh(Ft,We,hb,Qc,wt,It,li),zp=Bd(Jt),pb=jh(sr,zp,vt,ar,$t),mb=Lh(Ft,We,pb,zp,Jt,wt,It,li),fb=Wh(sr,ce,vt,ar,$t),gb=qh(Ft,We,fb,ce,wt,It),yb=qd(zi,Nt,Xi,Jt),Ds=dp(De,ce,Xi,Ap(ce,Ar)),bb=td(Ji,vt,Ar,$t,Ds),xb=Vd(yb),Ab=$h(Ft,xb,bb,wt,It,li),Cb=$l(We,qr,$i,Xi,Jt,Jc,It,Qi),Yp=new WeakMap,lu=yd(Jy,Cb,Vp,It,Yp,ui),Hp=Zd(Ms,De,Os,eu,Rs,ru),_b=np(sr,Hp,vt,ar,$t),vb=ip(Ft,We,Hp,_b,wt,It,ui),Zp=bh(Ji),Ib=ep(Zp,Nt,ce,$c,Gr),Es=tp(Zp,Nt,Ib,$c,Gr,Ki,Qi),Sb=Qd(Bi,Nt,qr,ce,Xi,Es,Jt,Vi,Jc,Gr),Xp=Xd(Sb),wb=sp(sr,qr,$i,ce,Xp,vt,Ar,ar,$t,Ds),Tb=op(Ft,We,Xp,wb,wt,It,li),Nb=Kd(Oe),Ob=ap(Nb,wt,new WeakSet,Rp),Rb=$d(qr,Zi,ce,Es,Jt,Gr),Qp=Jd(Rb,Jt),Mb=yp(sr,Qp,vt,ar,$t),Db=gp(Ft,We,Qp,Mb,wt,It),Eb=_p(Es,vt,$t),kb=Cp(Ft,Nt,Es,Eb,wt,It,li),Kp=hd(or),hu=Vh(or),Jp=new WeakMap,Lb=Qh(Jp,Ar),jb=Kp?El(De,Jt,Fh(or),hu,Gh(Il),wt,Lb,It,eo,new WeakMap,new WeakMap,xp(eo,Ar),or):void 0,Pb=ud(nu,It),Fb=wh(su,De,Sh,Ph,new WeakSet,wt,Pb,Pi,qe,au,cu),$p=ch(jb,Xy,uu,Ky,tb,ib,ob,cb,lb,Fb,db,mb,gb,Ab,lu,vb,Tb,Ob,Db,kb),Bb=dd(Ft,Wd,wt,It),Vb=pd(Ft,Ud,wt,It),Gb=md(Ft,zd,wt,It),qb=Yd(Nt,It),Wb=fd(Ft,qb,wt),tm=Ql($p,Nt,Jt,Kc,Bb,Vb,Gb,Wb,Ki);var du=Kh(Yp),Ub=Pl(du),em=yh(Oe),zb=Mh(du),rm=kh(Oe),im=new WeakMap,Yb=Uh(im,qt),Hb=Ed(em,Oe,Nt,qr,Zi,$i,ce,Xi,Jt,rm,hu,Yb,Gr),Zb=Od(Nt,Hb,ce,Jt,Gr),Xb=ah(sr,em,Ji,qr,Zi,$i,ce,zb,rm,hu,vt,eo,Ar,ar,$t,Ds),Qb=Zh(Jp),Kb=pp(im),pu=Kp?oh(Ub,Ft,We,Xb,Zb,Xt,Qb,wt,It,eo,Np,Kb,kp,ui):void 0;var hq=gd(Nt,Jt,Kc,lu,Ki);var nm=Ih(Jt,Ar),om=fp(su,De,iu,du,Ds,Pi,au,cu),dq=bd(De,Nt,nm,lu,om);var sm=rp($p,De,Nt,nm,om);var am=rd(ji,nu),cm=id(Li,ou),um=nd(Qn,Gp),lm=od(ji,It);function Bt(n){return n===void 0}function et(n){return n!==void 0}function hm(n){return typeof n=="function"}function te(n){return typeof n=="number"}function Ue(n){return Object.prototype.toString.call(n)==="[object Object]"&&n.constructor===Object}function mu(n){return typeof n=="boolean"}function Rt(n){return Array.isArray(n)}function ie(n){return typeof n=="string"}function ro(n){return ie(n)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(n)}function z(n,e){if(!n)throw new Error(e)}function kt(n,e,t=1/0){if(!(e<=n&&n<=t))throw new RangeError(`Value must be within [${e}, ${t}], got: ${n}`)}function ks(n){!n.isOffline&&n.state!=="running"&&hi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var pm=!1,dm=!1;function fu(n){pm=n}function mm(n){Bt(n)&&pm&&!dm&&(dm=!0,hi("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var fm=console;function gm(...n){fm.log(...n)}function hi(...n){fm.warn(...n)}function ym(n){return new tm(n)}function bm(n,e,t){return new sm(n,e,t)}var ne=typeof self=="object"?self:null,xm=ne&&(ne.hasOwnProperty("AudioContext")||ne.hasOwnProperty("webkitAudioContext"));function Am(n,e,t){return z(et(pu),"AudioWorkletNode only works in a secure context (https or localhost)"),new(n instanceof(ne==null?void 0:ne.BaseAudioContext)?ne==null?void 0:ne.AudioWorkletNode:pu)(n,e,t)}function oe(n,e,t,r){var i=arguments.length,o=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,t,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(e,t,o):s(e,t))||o);return i>3&&o&&Object.defineProperty(e,t,o),o}function ht(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=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):i(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})}var Ls=class{constructor(e,t,r,i){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let e=new Blob([`
5
5
  // the initial timeout time
6
6
  let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
7
7
  // onmessage callback
@@ -16,7 +16,7 @@
16
16
  }
17
17
  // call tick initially
18
18
  tick();
19
- `],{type:"text/javascript"}),t=URL.createObjectURL(e),r=new Worker(t);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(e){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(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type==="worker"&&((t=this._worker)===null||t===void 0||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}};function ze(n){return cm(n)}function cr(n){return am(n)}function $i(n){return um(n)}function Wr(n){return sm(n)}function Am(n){return n instanceof cu}function $b(n,e){return n==="value"||ze(e)||cr(e)||Am(e)}function Ee(n,...e){if(!e.length)return n;let t=e.shift();if(Ue(n)&&Ue(t))for(let r in t)$b(r,t[r])?n[r]=t[r]:Ue(t[r])?(n[r]||Object.assign(n,{[r]:{}}),Ee(n[r],t[r])):Object.assign(n,{[r]:t[r]});return Ee(n,...e)}function Cm(n,e){return n.length===e.length&&n.every((t,r)=>e[r]===t)}function N(n,e,t=[],r){let i={},o=Array.from(e);if(Ue(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(n,a))||(Ee(i,{[r]:o[0]}),t.splice(t.indexOf(r),1),o.shift())),o.length===1&&Ue(o[0]))Ee(i,o[0]);else for(let s=0;s<t.length;s++)et(o[s])&&(i[t[s]]=o[s]);return Ee(n,i)}function _m(n){return n.constructor.getDefaults()}function Ce(n,e){return Bt(n)?e:n}function Ye(n,e){return e.forEach(t=>{Reflect.has(n,t)&&delete n[t]}),n}var Qt=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||ne&&this.toString()===ne.TONE_DEBUG_CLASS)&&fm(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Qt.version=Wn;function Cr(n,e){return n>e+1e-6}function ro(n,e){return Cr(n,e)||ue(n,e)}function hi(n,e){return n+1e-6<e}function ue(n,e){return Math.abs(n-e)<1e-6}function fu(n,e,t){return Math.max(Math.min(n,t),e)}var Wt=class n extends Qt{constructor(){super(),this.name="Timeline",this._timeline=[];let e=N(n.getDefaults(),arguments,["memory"]);this.memory=e.memory,this.increasing=e.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(e){if(z(Reflect.has(e,"time"),"Timeline: events must have a time attribute"),e.time=e.time.valueOf(),this.increasing&&this.length){let t=this._timeline[this.length-1];z(ro(e.time,t.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(e)}else{let t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){let t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(e){let t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t="time"){let r=this._search(e,t);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t="time"){let r=this._search(e,t);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(e){let t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];let r=this._search(e);return r-1>=0?this._timeline[r-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0)if(ue(this._timeline[t].time,e)){for(let r=t;r>=0&&ue(this._timeline[r].time,e);r--)t=r;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1);else this._timeline=[]}else this._timeline.length===1&&ro(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){let t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){let t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t="time"){if(this._timeline.length===0)return-1;let r=0,i=this._timeline.length,o=i;if(i>0&&this._timeline[i-1][t]<=e)return i-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ue(a[t],e)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ue(l[t],e))s=u;else break}return s}else{if(hi(a[t],e)&&Cr(c[t],e))return s;Cr(a[t],e)?o=s:r=s+1}}return-1}_iterate(e,t=0,r=this._timeline.length-1){this._timeline.slice(t,r+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){let r=this._search(e);return r!==-1&&this._iterate(t,0,r),this}forEachAfter(e,t){let r=this._search(e);return this._iterate(t,r+1),this}forEachBetween(e,t,r){let i=this._search(e),o=this._search(t);return i!==-1&&o!==-1?(this._timeline[i].time!==e&&(i+=1),this._timeline[o].time===t&&(o-=1),this._iterate(r,i,o)):i===-1&&this._iterate(r,0,o),this}forEachFrom(e,t){let r=this._search(e);for(;r>=0&&this._timeline[r].time>=e;)r--;return this._iterate(t,r+1),this}forEachAtTime(e,t){let r=this._search(e);if(r!==-1&&ue(this._timeline[r].time,e)){let i=r;for(let o=r;o>=0&&ue(this._timeline[o].time,e);o--)i=o;this._iterate(o=>{t(o)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var vm=[];function Ur(n){vm.push(n)}function Im(n){vm.forEach(e=>e(n))}var Sm=[];function zr(n){Sm.push(n)}function wm(n){Sm.forEach(e=>e(n))}var Yr=class n extends Qt{constructor(){super(...arguments),this.name="Emitter"}on(e,t){return e.split(/\W+/).forEach(i=>{Bt(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(t)}),this}once(e,t){let r=(...i)=>{t(...i),this.off(e,r)};return this.on(e,r),this}off(e,t){return e.split(/\W+/).forEach(i=>{if(Bt(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Bt(t))this._events[i]=[];else{let o=this._events[i];for(let s=o.length-1;s>=0;s--)o[s]===t&&o.splice(s,1)}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){let r=this._events[e].slice(0);for(let i=0,o=r.length;i<o;i++)r[i].apply(this,t)}return this}static mixin(e){["on","once","off","emit"].forEach(t=>{let r=Object.getOwnPropertyDescriptor(n.prototype,t);Object.defineProperty(e.prototype,t,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var tn=class extends Yr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var di=class n extends tn{constructor(){var e,t;super(),this.name="Context",this._constants=new Map,this._timeouts=new Wt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=N(n.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((e=arguments[0])===null||e===void 0?void 0:e.latencyHint)||""):(this._context=gm({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new ks(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[!((t=arguments[0])===null||t===void 0)&&t.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Im(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(e,t,r){return this._context.createBuffer(e,t,r)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,r){return this._context.createPeriodicWave(e,t,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(e){return z(Wr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return z(Wr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return z(Wr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}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(e){z(!this._initialized,"The listener cannot be set after initialization."),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){z(!this._initialized,"The transport cannot be set after initialization."),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){z(!this._initialized,"Draw cannot be set after initialization."),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){z(!this._initialized,"The destination cannot be set after initialization."),this._destination=e}createAudioWorkletNode(e,t){return xm(this.rawContext,e,t)}addAudioWorkletModule(e){return ht(this,void 0,void 0,function*(){z(et(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(e)),yield this._workletPromise})}workletsAreReady(){return ht(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/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 Wr(this._context)?this._context.resume():Promise.resolve()}close(){return ht(this,void 0,void 0,function*(){Wr(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&wm(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{let t=this._context.createBuffer(1,128,this._context.sampleRate),r=t.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=e;let i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=t,i.loop=!0,i.start(0),this._constants.set(e,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){let e=this.now();this._timeouts.forEachBefore(e,t=>{t.callback(),this._timeouts.remove(t)})}setTimeout(e,t){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:r+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){let r=++this._timeoutIds,i=()=>{let o=this.now();this._timeouts.add({callback:()=>{e(),i()},id:r,time:o+t})};return i(),r}};var Ls=class extends tn{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,r){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return ht(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}};function W(n,e){Rt(e)?e.forEach(t=>W(n,t)):Object.defineProperty(n,e,{enumerable:!0,writable:!1})}function pi(n,e){Rt(e)?e.forEach(t=>pi(n,t)):Object.defineProperty(n,e,{writable:!0})}var rt=()=>{};var Lt=class n extends Qt{constructor(){super(),this.name="ToneAudioBuffer",this.onload=rt;let e=N(n.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=e.reverse,this.onload=e.onload,ie(e.url)?this.load(e.url).catch(e.onerror):e.url&&this.set(e.url)}static getDefaults(){return{onerror:rt,onload:rt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Vt().sampleRate}set(e){return e instanceof n?e.loaded?this._buffer=e.get():e.onload=()=>{this.set(e),this.onload(this)}:this._buffer=e,this._reversed&&this._reverse(),this}get(){return this._buffer}load(e){return ht(this,void 0,void 0,function*(){let t=n.load(e).then(r=>{this.set(r),this.onload(this)});n.downloads.push(t);try{yield t}finally{let r=n.downloads.indexOf(t);n.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){let t=Rt(e)&&e[0].length>0,r=t?e.length:1,i=t?e[0].length:e.length,o=Vt(),s=o.createBuffer(r,i,o.sampleRate),a=!t&&r===1?[e]:e;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(e){if(te(e))this.fromArray(this.toArray(e));else{let t=new Float32Array(this.length),r=this.numberOfChannels;for(let i=0;i<r;i++){let o=this.toArray(i);for(let s=0;s<o.length;s++)t[s]+=o[s]}t=t.map(i=>i/r),this.fromArray(t)}return this}toArray(e){if(te(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{let t=[];for(let r=0;r<this.numberOfChannels;r++)t[r]=this.getChannelData(r);return t}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array(0)}slice(e,t=this.duration){z(this.loaded,"Buffer is not loaded");let r=Math.floor(e*this.sampleRate),i=Math.floor(t*this.sampleRate);z(r<i,"The start time must be less than the end time");let o=i-r,s=Vt().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,i),a);return new n(s)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).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(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(e){return new n().fromArray(e)}static fromUrl(e){return ht(this,void 0,void 0,function*(){return yield new n().load(e)})}static load(e){return ht(this,void 0,void 0,function*(){let t=n.baseUrl===""||n.baseUrl.endsWith("/")?n.baseUrl:n.baseUrl+"/",r=yield fetch(t+e);if(!r.ok)throw new Error(`could not load url: ${e}`);let i=yield r.arrayBuffer();return yield Vt().decodeAudioData(i)})}static supportsType(e){let t=e.split("."),r=t[t.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return ht(this,void 0,void 0,function*(){for(yield Promise.resolve();n.downloads.length;)yield n.downloads[0]})}};Lt.baseUrl="";Lt.downloads=[];var He=class extends di{constructor(){super({clockSource:"offline",context:$i(arguments[0])?arguments[0]:ym(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:$i(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=$i(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return ht(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,t++;let r=Math.floor(this.sampleRate/128);e&&t%r===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return ht(this,arguments,void 0,function*(e=!0){yield this.workletsAreReady(),yield this._renderClock(e);let t=yield this._context.startRendering();return new Lt(t)})}close(){return Promise.resolve()}};var Tm=new Ls,en=Tm;function Vt(){return en===Tm&&bm&&gu(new di),en}function gu(n,e=!1){e&&en.dispose(),Wr(n)?en=new di(n):$i(n)?en=new He(n):en=n}if(ne&&!ne.TONE_SILENCE_LOGGING){let n="v";Wn==="dev"&&(n="");let e=` * Tone.js ${n}${Wn} * `;console.log(`%c${e}`,"background: #000; color: #fff")}function rn(n){return Math.pow(10,n/20)}function nn(n){return 20*(Math.log(n)/Math.LN10)}function mi(n){return Math.pow(2,n/12)}var js=440;function Nm(){return js}function Om(n){js=n}function Ze(n){return Math.round(yu(n))}function yu(n){return 69+12*Math.log2(n/js)}function io(n){return js*Math.pow(2,(n-69)/12)}var Ps=class n extends Qt{constructor(e,t,r){super(),this.defaultUnits="s",this._val=t,this._units=r,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{let r=parseInt(e,10),i=t==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/r)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{let t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,r)=>{let i=0;return e&&e!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i+=this._beatsToUnits(parseFloat(t))),r&&r!=="0"&&(i+=this._beatsToUnits(parseFloat(r)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof n&&this.fromType(this._val),Bt(this._val))return this._noArg();if(ie(this._val)&&Bt(this._units)){for(let e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(Ue(this._val)){let e=0;for(let t in this._val)if(et(this._val[t])){let r=this._val[t],i=new this.constructor(this.context,t).valueOf()*r;e+=i}return e}if(et(this._units)){let e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}else return ie(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*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(e){switch(this._units=void 0,this.defaultUnits){case"s":this._val=e.toSeconds();break;case"i":this._val=e.toTicks();break;case"hz":this._val=e.toFrequency();break;case"midi":this._val=e.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var _e=class n extends Ps{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:e=>{let t=new n(this.context,e).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(t))},regexp:/^@(.+)/}})}quantize(e,t=1){let r=new this.constructor(this.context,e).valueOf(),i=this.valueOf(),a=Math.round(i/r)*r-i;return i+a*t}toNotation(){let e=this.toSeconds(),t=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);t.push(s+"n."),t.push(s+"n"),t.push(s+"t")}t.push("0");let r=t[0],i=new n(this.context,t[0]).toSeconds();return t.forEach(o=>{let s=new n(this.context,o).toSeconds();Math.abs(s-e)<Math.abs(i-e)&&(r=o,i=s)}),r}toBarsBeatsSixteenths(){let e=this._beatsToUnits(1),t=this.valueOf()/e;t=parseFloat(t.toFixed(4));let r=Math.floor(t/this._getTimeSignature()),i=t%1*4;t=Math.floor(t)%this._getTimeSignature();let o=i.toString();return o.length>3&&(i=parseFloat(parseFloat(o).toFixed(3))),[r,t,i].join(":")}toTicks(){let e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Ze(this.toFrequency())}_now(){return this.context.now()}};var le=class n extends _e{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Nm()}static set A4(e){Om(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(e){return this.defaultUnits==="midi"?e:n.mtof(e)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(e,t){let i=tx[e.toLowerCase()]+(parseInt(t,10)+1)*12;return this.defaultUnits==="midi"?i:n.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,r){let i=1;return e&&e!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i*=this._beatsToUnits(parseFloat(t))),r&&r!=="0"&&(i*=this._beatsToUnits(parseFloat(r)/4)),i}}})}transpose(e){return new n(this.context,this.valueOf()*mi(e))}harmonize(e){return e.map(t=>this.transpose(t))}toMidi(){return Ze(this.valueOf())}toNote(){let e=this.toFrequency(),t=Math.log2(e/n.A4),r=Math.round(12*t)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),ex[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return io(e)}static ftom(e){return Ze(e)}},tx={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},ex=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var ke=class extends _e{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var Ut=class n extends Qt{constructor(){super();let e=N(n.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=e.context}static getDefaults(){return{context:Vt()}}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(e){return pm(e),new _e(this.context,e).toSeconds()}toFrequency(e){return new le(this.context,e).toFrequency()}toTicks(e){return new ke(this.context,e).toTicks()}_getPartialProperties(e){let t=this.get();return Object.keys(t).forEach(r=>{Bt(e[r])&&delete t[r]}),t}get(){let e=_m(this);return Object.keys(e).forEach(t=>{if(Reflect.has(this,t)){let r=this[t];et(r)&&et(r.value)&&et(r.setValueAtTime)?e[t]=r.value:r instanceof n?e[t]=r._getPartialProperties(e[t]):Rt(r)||te(r)||ie(r)||pu(r)?e[t]=r:delete e[t]}}),e}set(e){return Object.keys(e).forEach(t=>{Reflect.has(this,t)&&et(this[t])&&(this[t]&&et(this[t].value)&&et(this[t].setValueAtTime)?this[t].value!==e[t]&&(this[t].value=e[t]):this[t]instanceof n?this[t].set(e[t]):this[t]=e[t])}),this}};var ur=class extends Wt{constructor(e="stopped"){super(),this.name="StateTimeline",this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){let t=this.get(e);return t!==null?t.state:this._initial}setStateAtTime(e,t,r){return kt(t,0),this.add(Object.assign({},r,{state:e,time:t})),this}getLastState(e,t){let r=this._search(t);for(let i=r;i>=0;i--){let o=this._timeline[i];if(o.state===e)return o}}getNextState(e,t){let r=this._search(t);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let o=this._timeline[i];if(o.state===e)return o}}};var st=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments,["param","units","convert"]);for(super(e),this.name="Param",this.overridden=!1,this._minOutput=1e-7,z(et(e.param)&&(ze(e.param)||e.param instanceof n),"param must be an AudioParam");!ze(e.param);)e.param=e.param._param;this._swappable=et(e.swappable)?e.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=e.param,this.input.connect(this._param)):this._param=this.input=e.param,this._events=new Wt(1e3),this._initialValue=this._param.defaultValue,this.units=e.units,this.convert=e.convert,this._minValue=e.minValue,this._maxValue=e.maxValue,et(e.value)&&e.value!==this._toType(this._initialValue)&&this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(Ut.getDefaults(),{convert:!0,units:"number"})}get value(){let e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return et(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 et(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return et(this.maxValue)&&et(this.minValue)&&kt(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,"time")?this.toSeconds(e):this._is(e,"decibels")?rn(e):this._is(e,"frequency")?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units==="decibels"?nn(e):e}setValueAtTime(e,t){let r=this.toSeconds(t),i=this._fromType(e);return z(isFinite(i)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",e,r),this._events.add({time:r,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,r),this}getValueAtTime(e){let t=Math.max(this.toSeconds(e),0),r=this._events.getAfter(t),i=this._events.get(t),o=this._initialValue;if(i===null)o=this._initialValue;else if(i.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(i.time),a;s===null?a=this._initialValue:a=s.value,i.type==="setTargetAtTime"&&(o=this._exponentialApproach(i.time,a,i.value,i.constant,t))}else if(r===null)o=i.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=i.value;if(i.type==="setTargetAtTime"){let a=this._events.getBefore(i.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(i.time,s,r.time,r.value,t):o=this._exponentialInterpolate(i.time,s,r.time,r.value,t)}else o=i.value;return this._toType(o)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){let r=this._fromType(e),i=this.toSeconds(t);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(r),this._events.add({time:i,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",e,i),this._param.linearRampToValueAtTime(r,i),this}exponentialRampToValueAtTime(e,t){let r=this._fromType(e);r=ue(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(t);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",e,i),this._param.exponentialRampToValueAtTime(r,i),this}exponentialRampTo(e,t,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(e,r+this.toSeconds(t)),this}linearRampTo(e,t,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(e,r+this.toSeconds(t)),this}targetRampTo(e,t,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(e,r,t),this}exponentialApproachValueAtTime(e,t,r){t=this.toSeconds(t),r=this.toSeconds(r);let i=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(e,t,i),this.cancelAndHoldAtTime(t+r*.9),this.linearRampToValueAtTime(e,t+r),this}setTargetAtTime(e,t,r){let i=this._fromType(e);z(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(t);return this._assertRange(i),z(isFinite(i)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",e,o,r),this._param.setTargetAtTime(i,o,r),this}setValueCurveAtTime(e,t,r,i=1){r=this.toSeconds(r),t=this.toSeconds(t);let o=this._fromType(e[0])*i;this.setValueAtTime(this._toType(o),t);let s=r/(e.length-1);for(let a=1;a<e.length;a++){let c=this._fromType(e[a])*i;this.linearRampToValueAtTime(this._toType(c),t+a*s)}return this}cancelScheduledValues(e){let t=this.toSeconds(e);return z(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,"cancelScheduledValues",t),this}cancelAndHoldAtTime(e){let t=this.toSeconds(e),r=this._fromType(this.getValueAtTime(t));z(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,"cancelAndHoldAtTime",t,"value="+r);let i=this._events.get(t),o=this._events.getAfter(t);return i&&ue(i.time,t)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),t):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),t)),this._events.add({time:t,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,t),this}rampTo(e,t=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(e,t,r):this.linearRampTo(e,t,r),this}apply(e){let t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);let r=this._events.get(t);if(r&&r.type==="setTargetAtTime"){let i=this._events.getAfter(r.time),o=i?i.time:t+2,s=(o-t)/10;for(let a=t;a<o;a+=s)e.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?e.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?e.setTargetAtTime(i.value,i.time,i.constant):e[i.type](i.value,i.time)}),this}setParam(e){z(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,r,i,o){return r+(t-r)*Math.exp(-(o-e)/i)}_linearInterpolate(e,t,r,i,o){return t+(i-t)*((o-e)/(r-e))}_exponentialInterpolate(e,t,r,i,o){return t*Math.pow(i/t,(o-e)/(r-e))}};var j=class n extends Ut{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return et(this.input)?ze(this.input)||this.input instanceof st?1:this.input.numberOfInputs:0}get numberOfOutputs(){return et(this.output)?this.output.numberOfOutputs:0}_isAudioNode(e){return et(e)&&(e instanceof n||cr(e))}_getInternalNodes(){let e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(r=>{r.channelCount=e.channelCount,r.channelCountMode=e.channelCountMode,r.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){let e=this._getInternalNodes();z(e.length>0,"ToneAudioNode does not have any internal nodes");let t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,r=0){return ee(this,e,t,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return li("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(e,t=0,r=0){return Rm(this,e,t,r),this}chain(...e){return Le(this,...e),this}fan(...e){return e.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),et(this.input)&&(this.input instanceof n?this.input.dispose():cr(this.input)&&this.input.disconnect()),et(this.output)&&(this.output instanceof n?this.output.dispose():cr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Le(...n){let e=n.shift();n.reduce((t,r)=>(t instanceof j?t.connect(r):cr(t)&&ee(t,r),r),e)}function ee(n,e,t=0,r=0){for(z(et(n),"Cannot connect from undefined node"),z(et(e),"Cannot connect to undefined node"),(e instanceof j||cr(e))&&z(e.numberOfInputs>0,"Cannot connect to node with no inputs"),z(n.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof j||e instanceof st;)et(e.input)&&(e=e.input);for(;n instanceof j;)et(n.output)&&(n=n.output);ze(e)?n.connect(e,t):n.connect(e,t,r)}function Rm(n,e,t=0,r=0){if(et(e))for(;e instanceof j;)e=e.input;for(;!cr(n);)et(n.output)&&(n=n.output);ze(e)?n.disconnect(e,t):cr(e)?n.disconnect(e,t,r):n.disconnect()}var Z=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["gain","units"]);super(e),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new st({context:this.context,convert:e.convert,param:this._gainNode.gain,units:e.units,value:e.gain,minValue:e.minValue,maxValue:e.maxValue}),W(this,"gain")}static getDefaults(){return Object.assign(j.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}};var Xe=class extends j{constructor(e){super(e),this.onended=rt,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(t){let r=this.toSeconds(t);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign(j.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:rt})}_startGain(e,t=1){z(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=e+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(t,e+r):this._gainNode.gain.exponentialApproachValueAtTime(t,e,r)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log("stop",e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){z(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?t*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==rt&&(this.onended(this),this.onended=rt,!this.context.isOffline)){let e=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),z(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=rt,this}};var no=class n extends Xe{constructor(){let e=N(n.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),ee(this._source,this._gainNode),this.offset=new st({context:this.context,convert:e.convert,param:this._source.offset,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(Xe.getDefaults(),{convert:!0,offset:1,units:"number"})}start(e){let t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var $=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["value","units"]);super(e),this.name="Signal",this.override=!0,this.output=this._constantSource=new no({context:this.context,convert:e.convert,offset:e.value,units:e.units,minValue:e.minValue,maxValue:e.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(j.getDefaults(),{convert:!0,units:"number",value:0})}connect(e,t=0,r=0){return on(this,e,t,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,r){return this._param.exponentialRampTo(e,t,r),this}linearRampTo(e,t,r){return this._param.linearRampTo(e,t,r),this}targetRampTo(e,t,r){return this._param.targetRampTo(e,t,r),this}exponentialApproachValueAtTime(e,t,r){return this._param.exponentialApproachValueAtTime(e,t,r),this}setTargetAtTime(e,t,r){return this._param.setTargetAtTime(e,t,r),this}setValueCurveAtTime(e,t,r,i){return this._param.setValueCurveAtTime(e,t,r,i),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,r){return this._param.rampTo(e,t,r),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}};function on(n,e,t,r){(e instanceof st||ze(e)||e instanceof $&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof $&&(e.overridden=!0)),ee(n,e,t,r)}var Fs=class n extends st{constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="TickParam",this._events=new Wt(1/0),this._multiplier=1,this._multiplier=e.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(e.value)}),this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(st.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(e,t,r){t=this.toSeconds(t),this.setRampPoint(t);let i=this._fromType(e),o=this._events.get(t),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+t,u=this._exponentialApproach(o.time,o.value,i,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(e,t){let r=this.toSeconds(t);super.setValueAtTime(e,t);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}linearRampToValueAtTime(e,t){let r=this.toSeconds(t);super.linearRampToValueAtTime(e,t);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);let r=this._fromType(e),i=this._events.get(t),o=Math.round(Math.max((t-i.time)*10,1)),s=(t-i.time)/o;for(let a=0;a<=o;a++){let c=s*a+i.time,u=this._exponentialInterpolate(i.time,i.value,t,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Bt(e.ticks)){let s=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(s,e.time)}let r=this._fromType(this.getValueAtTime(e.time)),i=this._fromType(this.getValueAtTime(t)),o=this._events.get(t);return o&&o.time===t&&o.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(r+i)+e.ticks}getTicksAtTime(e){let t=this.toSeconds(e),r=this._events.get(t);return Math.max(this._getTicksUntilEvent(r,t),0)}getDurationOfTicks(e,t){let r=this.toSeconds(t),i=this.getTicksAtTime(t);return this.getTimeOfTick(i+e)-r}getTimeOfTick(e){let t=this._events.get(e,"ticks"),r=this._events.getAfter(e,"ticks");if(t&&t.ticks===e)return t.time;if(t&&r&&r.type==="linearRampToValueAtTime"&&t.value!==r.value){let i=this._fromType(this.getValueAtTime(t.time)),s=(this._fromType(this.getValueAtTime(r.time))-i)/(r.time-t.time),a=Math.sqrt(Math.pow(i,2)-2*s*(t.ticks-e)),c=(-i+a)/s,u=(-i-a)/s;return(c>0?c:u)+t.time}else return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){let r=this.toSeconds(t),i=this.toSeconds(e),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-o}_fromType(e){return this.units==="bpm"&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units==="bpm"&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){let t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}};var Bs=class n extends ${constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="TickSignal",this.input=this._param=new Fs({context:this.context,convert:e.convert,multiplier:e.multiplier,param:this._constantSource.offset,units:e.units,value:e.value})}static getDefaults(){return Object.assign($.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}};var Vs=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments,["frequency"]);super(e),this.name="TickSource",this._state=new ur,this._tickOffset=new Wt,this._ticksAtTime=new Wt,this._secondsAtTime=new Wt,this.frequency=new Bs({context:this.context,units:e.units,value:e.frequency}),W(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Ut.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){let r=this.toSeconds(e);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),et(t)&&this.setTicksAtTime(t,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(e){let t=this.toSeconds(e);if(this._state.getValueAtTime(t)==="stopped"){let r=this._state.get(t);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){let t=this.toSeconds(e),r=this._state.getLastState("stopped",t),i=this._ticksAtTime.get(t),o={state:"paused",time:t};this._state.add(o);let s=i||r,a=i?i.ticks:0,c=null;return this._state.forEachBetween(s.time,t+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(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){let t=this.now(),r=this.frequency.timeToTicks(e,t);this.setTicksAtTime(r,t)}getSecondsAtTime(e){e=this.toSeconds(e);let t=this._state.getLastState("stopped",e),r={state:"paused",time:e};this._state.add(r);let i=this._secondsAtTime.get(e),o=i||t,s=i?i.seconds:0,a=null;return this._state.forEachBetween(o.time,e+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(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){let r=this._tickOffset.get(t),i=this._state.get(t),o=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(o)+e-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(e,t,r){let i=this._state.get(e);this._state.forEachBetween(e,t,s=>{i&&i.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(i.time,e),s.time-this.sampleTime,r),i=s});let o=null;if(i&&i.state==="started"){let s=Math.max(i.time,e),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(i.time),u=a-c,l=Math.ceil(u)-u;l=ue(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<t;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(d){o=d;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 sn=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments,["callback","frequency"]);super(e),this.name="Clock",this.callback=rt,this._lastUpdate=0,this._state=new ur("stopped"),this._boundLoop=this._loop.bind(this),this.callback=e.callback,this._tickSource=new Vs({context:this.context,frequency:e.frequency,units:e.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,W(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Ut.getDefaults(),{callback:rt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){Es(this.context);let r=this.toSeconds(e);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,t),r<this._lastUpdate&&this.emit("start",r,t)),this}stop(e){let t=this.toSeconds(e);return this.log("stop",t),this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit("stop",t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit("pause",t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){let r=this.toSeconds(t),i=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(i+e,r)}_loop(){let e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log("loop",e,t),e!==t&&(this._state.forEachBetween(e,t,r=>{switch(r.state){case"started":let i=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,i);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(e,t,(r,i)=>{this.callback(r,i)}))}getStateAtTime(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};Yr.mixin(sn);var je=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["volume"]);super(e),this.name="Volume",this.input=this.output=new Z({context:this.context,gain:e.volume,units:"decibels"}),this.volume=this.output.gain,W(this,"volume"),this._unmutedVolume=e.volume,this.mute=e.mute}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var bu=class n extends j{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="Destination",this.input=new je({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Le(this.input,this.output,this.context.rawContext.destination),this.mute=e.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),Le(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Ur(n=>{n.destination=new bu({context:n})});zr(n=>{n.destination.dispose()});var xu=class extends j{constructor(){super(...arguments),this.name="Listener",this.positionX=new st({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new st({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new st({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new st({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new st({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new st({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new st({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new st({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new st({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(j.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}};Ur(n=>{n.listener=new xu({context:n})});zr(n=>{n.listener.dispose()});var an=class n extends Qt{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let e=N(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=e.baseUrl,Object.keys(e.urls).forEach(t=>{this._loadingCount++;let r=e.urls[t];this.add(t,r,this._bufferLoaded.bind(this,e.onload),e.onerror)})}static getDefaults(){return{baseUrl:"",onerror:rt,onload:rt,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return z(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,r=rt,i=rt){return ie(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(e.toString(),new Lt(this.baseUrl+t,r,i))):this._buffers.set(e.toString(),new Lt(t,r,i)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}};var oo=class n extends le{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(e){return Ze(super._frequencyToUnits(e))}_ticksToUnits(e){return Ze(super._ticksToUnits(e))}_beatsToUnits(e){return Ze(super._beatsToUnits(e))}_secondsToUnits(e){return Ze(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return io(this.toMidi())}transpose(e){return new n(this.context,this.toMidi()+e)}};var ve=class extends ke{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var Au=class extends Ut{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Wt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){let e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};Ur(n=>{n.draw=new Au({context:n})});zr(n=>{n.draw.dispose()});var Gs=class extends Qt{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(e){z(et(e.time),"Events must have a time property"),z(et(e.duration),"Events must have a duration parameter"),e.time=e.time.valueOf();let t=new Cu(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){let t=[];this._root.search(e.time,t);for(let r of t)if(r.event===e){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,t=>this.remove(t)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent!==null?(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent)):this._setRoot(t)}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{let t=e.getBalance(),r,i=null;if(t>0)if(e.left.right===null)r=e.left,r.right=e.right,i=r;else{for(r=e.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,i=r.parent,r.left=e.left,r.right=e.right)}else if(e.right.left===null)r=e.right,r.left=e.left,i=r;else{for(r=e.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,i=r.parent,r.left=e.left,r.right=e.right)}e.parent!==null?e.isLeftChild()?e.parent.left=r:e.parent.right=r:this._setRoot(r),i&&this._rebalance(i)}e.dispose()}_rotateLeft(e){let t=e.parent,r=e.isLeftChild(),i=e.right;i&&(e.right=i.left,i.left=e),t!==null?r?t.left=i:t.right=i:this._setRoot(i)}_rotateRight(e){let t=e.parent,r=e.isLeftChild(),i=e.left;i&&(e.left=i.right,i.right=e),t!==null?r?t.left=i:t.right=i:this._setRoot(i)}_rebalance(e){let t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){let t=[];if(this._root.search(e,t),t.length>0){let r=t[0];for(let i=1;i<t.length;i++)t[i].low>r.low&&(r=t[i]);return r.event}}return null}forEach(e){if(this._root!==null){let t=[];this._root.traverse(r=>t.push(r)),t.forEach(r=>{r.event&&e(r.event)})}return this}forEachAtTime(e,t){if(this._root!==null){let r=[];this._root.search(e,r),r.forEach(i=>{i.event&&t(i.event)})}return this}forEachFrom(e,t){if(this._root!==null){let r=[];this._root.searchAfter(e,r),r.forEach(i=>{i.event&&t(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}},Cu=class{constructor(e,t,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),!(this.low>e)&&this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}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 e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left!==null?e=this.left.height+1:this.right!==null&&(e=-(this.right.height+1)),e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var qs=class extends Qt{constructor(e){super(),this.name="TimelineValue",this._timeline=new Wt({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){let t=this._timeline.get(e);return t?t.value:this._initialValue}};var se=class n extends j{constructor(){super(N(n.getDefaults(),arguments,["context"]))}connect(e,t=0,r=0){return on(this,e,t,r),this}};var pe=class n extends se{constructor(){let e=N(n.getDefaults(),arguments,["mapping","length"]);super(e),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Rt(e.mapping)||e.mapping instanceof Float32Array?this.curve=Float32Array.from(e.mapping):lm(e.mapping)&&this.setMap(e.mapping,e.length)}static getDefaults(){return Object.assign($.getDefaults(),{length:1024})}setMap(e,t=1024){let r=new Float32Array(t);for(let i=0,o=t;i<o;i++){let s=i/(o-1)*2-1;r[i]=e(s,i)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){let t=["none","2x","4x"].some(r=>r.includes(e));z(t,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var cn=class n extends se{constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="Pow",this._exponentScaler=this.input=this.output=new pe({context:this.context,mapping:this._expFunc(e.value),length:8192}),this._exponent=e.value}static getDefaults(){return Object.assign(se.getDefaults(),{value:1})}_expFunc(e){return t=>Math.pow(Math.abs(t),e)}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var _r=class n{constructor(e,t){this.id=n._eventId++,this._remainderTime=0;let r=Object.assign(n.getDefaults(),t);this.transport=e,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:rt,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){let t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};_r._eventId=0;var Ws=class n extends _r{constructor(e,t){super(e,t),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(n.getDefaults(),t);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({},_r.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return hi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new ve(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){hi(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 ve(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let t=this.transport.getTicksAtTime(e);Cr(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-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 Us=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="Transport",this._loop=new qs(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Wt,this._repeatedEvents=new Gs,this._syncedSignals=[],this._swingAmount=0,this._ppq=e.ppq,this._clock=new sn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=e.ppq,this.bpm.setValueAtTime(e.bpm,0),W(this,"bpm"),this._timeSignature=e.timeSignature,this._swingTicks=e.ppq/2}static getDefaults(){return Object.assign(Ut.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit("loopEnd",e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit("loopStart",e,this._clock.getSecondsAtTime(e)),this.emit("loop",e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!==0){let r=t%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(r*Math.PI)*this._swingAmount;e+=new ve(this.context,this._swingTicks*2/3).toSeconds()*i}mu(!0),this._timeline.forEachAtTime(t,r=>r.invoke(e)),mu(!1)}schedule(e,t){let r=new _r(this,{callback:e,time:new ke(this.context,t).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(e,t,r,i=1/0){let o=new Ws(this,{callback:e,duration:new _e(this.context,i).toTicks(),interval:new _e(this.context,t).toTicks(),time:new ke(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(e,t){let r=new _r(this,{callback:e,once:!0,time:new ke(this.context,t).toTicks()});return this._addEvent(r,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){let t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){let t=this.toTicks(e);return this._timeline.forEachFrom(t,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(t,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(e,t)=>{t=new ve(this.context,t).toSeconds(),this.emit("start",e,t)}),this._clock.on("stop",e=>{this.emit("stop",e)}),this._clock.on("pause",e=>{this.emit("pause",e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let r;return et(t)&&(r=this.toTicks(t)),this._clock.start(e,r),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)!=="started"?this.start(e):this.stop(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){Rt(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new _e(this.context,this._loopStart,"i").toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new _e(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new ve(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){let e=this.now(),t=this._clock.getTicksAtTime(e);return new ve(this.context,t).toBarsBeatsSixteenths()}set position(e){let t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){let t=this.now(),r=this._clock.frequency.timeToTicks(e,t);this.ticks=r}get progress(){if(this.loop){let e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){let t=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(t),i=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,t),o=t+i;this.emit("stop",o),this._clock.setTicksAtTime(e,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!=="started")return 0;{let t=this.now(),r=this.getTicksAtTime(t),i=e-r%e;return this._clock.nextTickTime(i,t)}}syncSignal(e,t){let r=this.now(),i=this.bpm,o=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(e.units==="time"){let c=.015625/o,u=new Z(c),l=new cn(-1),h=new Z(c);i.chain(u,l,h),i=h,o=1/o,s=[u,l,h]}t||(e.getValueAtTime(r)!==0?t=e.getValueAtTime(r)/o:t=0);let a=new Z(t);return i.connect(a),a.connect(e._param),s.push(a),this._syncedSignals.push({initial:e.value,nodes:s,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){let r=this._syncedSignals[t];r.signal===e&&(r.nodes.forEach(i=>i.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),pi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};Yr.mixin(Us);Ur(n=>{n.transport=new Us({context:n})});zr(n=>{n.transport.dispose()});var gt=class extends j{constructor(e){super(e),this.input=void 0,this._state=new ur("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=rt,this._syncedStop=rt,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new je({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,W(this,"volume"),this.onstop=e.onstop}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,onstop:rt,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(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,r){let i=Bt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")z(Cr(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,t,r);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){let o=this._state.get(i);o&&(o.offset=this.toSeconds(Ce(t,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,t,r)},i);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else Es(this.context),this._start(i,t,r);return this}stop(e){let t=Bt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)==="started"||et(this._state.getNextState("started",t))){if(this.log("stop",t),!this._synced)this._stop(t);else{let r=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(r)}this._state.cancel(t),this._state.setStateAtTime("stopped",t)}return this}restart(e,t,r){return e=this.toSeconds(e),this._state.getValueAtTime(e)==="started"&&(this._state.cancel(e),this._restart(e,t,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>{if(Cr(t,0)){let r=this._state.get(t);if(r&&r.state==="started"&&r.time!==t){let i=t-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-i),this._start(e,this.toSeconds(r.offset)+i,o)}}},this._syncedStop=e=>{let t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)==="started"&&this._stop(e)},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(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=rt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var lr=class n extends Xe{constructor(){let e=N(n.getDefaults(),arguments,["url","onload"]);super(e),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,ee(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new st({context:this.context,param:this._source.playbackRate,units:"positive",value:e.playbackRate}),this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this._buffer=new Lt(e.url,e.onload,e.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Xe.getDefaults(),{url:new Lt,loop:!1,loopEnd:0,loopStart:0,onload:rt,onerror:rt,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,r,i=1){z(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(e);this._startGain(o,i),this.loop?t=Ce(t,this.loopStart):t=Ce(t,0);let s=Math.max(this.toSeconds(t),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;ro(s,a)&&(s=(s-c)%u+c),ue(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,hi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),et(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var fi=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["type"]);super(e),this.name="Noise",this._source=null,this._playbackRate=e.playbackRate,this.type=e.type,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(gt.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(e){if(z(e in Mm,"Noise: invalid type: "+e),this._type!==e&&(this._type=e,this.state==="started")){let t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){let t=Mm[this._type];this._source=new lr({url:t,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(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&(this._source.stop(this.toSeconds(e)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},un=44100*5,_u=2,vr={brown:null,pink:null,white:null},Mm={get brown(){if(!vr.brown){let n=[];for(let e=0;e<_u;e++){let t=new Float32Array(un);n[e]=t;let r=0;for(let i=0;i<un;i++){let o=Math.random()*2-1;t[i]=(r+.02*o)/1.02,r=t[i],t[i]*=3.5}}vr.brown=new Lt().fromArray(n)}return vr.brown},get pink(){if(!vr.pink){let n=[];for(let e=0;e<_u;e++){let t=new Float32Array(un);n[e]=t;let r,i,o,s,a,c,u;r=i=o=s=a=c=u=0;for(let l=0;l<un;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,i=.99332*i+h*.0750759,o=.969*o+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,t[l]=r+i+o+s+a+c+u+h*.5362,t[l]*=.11,u=h*.115926}}vr.pink=new Lt().fromArray(n)}return vr.pink},get white(){if(!vr.white){let n=[];for(let e=0;e<_u;e++){let t=new Float32Array(un);n[e]=t;for(let r=0;r<un;r++)t[r]=Math.random()*2-1}vr.white=new Lt().fromArray(n)}return vr.white}};function me(n,e){return ht(this,void 0,void 0,function*(){let t=e/n.context.sampleRate,r=new He(1,t,n.context.sampleRate);return new n.constructor(Object.assign(n.get(),{frequency:2/t,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var so=class n extends Xe{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],ee(this._oscillator,this._gainNode),this.type=e.type,this.frequency=new st({context:this.context,param:this._oscillator.frequency,units:"frequency",value:e.frequency}),this.detune=new st({context:this.context,param:this._oscillator.detune,units:"cents",value:e.detune}),W(this,["frequency","detune"])}static getDefaults(){return Object.assign(Xe.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(e){let t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Mt=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="Oscillator",this._oscillator=null,this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),W(this,"frequency"),this.detune=new $({context:this.context,units:"cents",value:e.detune}),W(this,"detune"),this._partials=e.partials,this._partialCount=e.partialCount,this._type=e.type,e.partialCount&&e.type!=="custom"&&(this._type=this.baseType+e.partialCount.toString()),this.phase=e.phase}static getDefaults(){return Object.assign(gt.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(e){let t=this.toSeconds(e),r=new so({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(t)}_stop(e){let t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){let t=this.toSeconds(e);return this.log("restart",t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),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 n._periodicWaveCache.find(t=>t.phase===this._phase&&Cm(t.partials,this._partials));{let e=n._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=e?e.partialCount:this._partialCount,e}}get type(){return this._type}set type(e){this._type=e;let t=["sine","square","sawtooth","triangle"].indexOf(e)!==-1;if(this._phase===0&&t)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=e);else{let r=this._getCachedPeriodicWave();if(et(r)){let{partials:i,wave:o}=r;this._wave=o,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[i,o]=this._getRealImaginary(e,this._phase),s=this.context.createPeriodicWave(i,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),n._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),n._periodicWaveCache.length>100&&n._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(e){this.partialCount&&this._type!=="custom"&&e!=="custom"?this.type=e+this.partialCount:this.type=e}get partialCount(){return this._partialCount}set partialCount(e){kt(e,0);let t=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(t=r[1]),this._type!=="custom")e===0?this.type=t:this.type=t+e.toString();else{let i=new Float32Array(e);this._partials.forEach((o,s)=>i[s]=o),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(e,t){let i=2048,o=new Float32Array(i),s=new Float32Array(i),a=1;if(e==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),e=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){let u=2/(c*Math.PI),l;switch(e){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: "+e)}l!==0?(o[c]=-l*Math.sin(t*c),s[c]=l*Math.cos(t*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(e,t,r){let i=0,o=e.length;for(let s=0;s<o;s++)i+=e[s]*Math.cos(s*r)+t[s]*Math.sin(s*r);return i}getInitialValue(){let[e,t]=this._getRealImaginary(this._type,0),r=0,i=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(e,t,s/o*i),r);return fu(-this._inverseFFT(e,t,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Mt._periodicWaveCache=[];var ln=class extends se{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new pe({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var zt=class n extends ${constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Z({context:this.context,minValue:e.minValue,maxValue:e.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign($.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var ao=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="AMOscillator",this._modulationScale=new ln({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Mt({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Mt({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new zt({context:this.context,units:"positive",value:e.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),W(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Mt.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}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 hn=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="FMOscillator",this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Mt({context:this.context,detune:e.detune,frequency:0,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.detune=this._carrier.detune,this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this._modulator=new Mt({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new zt({context:this.context,units:"positive",value:e.harmonicity}),this.modulationIndex=new zt({context:this.context,units:"positive",value:e.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),W(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Mt.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var gi=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","width"]);super(e),this.name="PulseOscillator",this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new pe({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new $({context:this.context,units:"audioRange",value:e.width}),this._triangle=new Mt({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.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),W(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(gt.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var co=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","spread"]);super(e),this.name="FatOscillator",this._oscillators=[],this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this.detune=new $({context:this.context,units:"cents",value:e.detune}),this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=e.partials,this._partialCount=e.partialCount,this.count=e.count,W(this,["frequency","detune"])}static getDefaults(){return Object.assign(Mt.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){let t=-e/2,r=e/(this._oscillators.length-1);this._forEach((i,o)=>i.detune.value=t+r*o)}}get count(){return this._oscillators.length}set count(e){if(kt(e,1),this._oscillators.length!==e){this._forEach(t=>t.dispose()),this._oscillators=[];for(let t=0;t<e;t++){let r=new Mt({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):rt});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[t]=r}this.spread=this._spread,this.state==="started"&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((t,r)=>t.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type="custom",this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}};var uo=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","modulationFrequency"]);super(e),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new zt({context:this.context,value:2}),this._pulse=new gi({context:this.context,frequency:e.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Mt({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),W(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(gt.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var Dm={am:ao,fat:co,fm:hn,oscillator:Mt,pulse:gi,pwm:uo},yi=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OmniOscillator",this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this.detune=new $({context:this.context,units:"cents",value:e.detune}),W(this,["frequency","detune"]),this.set(e)}static getDefaults(){return Object.assign(Mt.getDefaults(),hn.getDefaults(),ao.getDefaults(),co.getDefaults(),gi.getDefaults(),uo.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):e==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,"type")&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;let t=Dm[e],r=this.now();if(this._oscillator){let i=this._oscillator;i.stop(r),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new t({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(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(t=this._oscillator.type),e==="fm"?this.type="fm"+t:e==="am"?this.type="am"+t:e==="fat"?this.type="fat"+t:e==="oscillator"?this.type=t:e==="pulse"?this.type="pulse":e==="pwm"&&(this.type="pwm")}_getOscType(e,t){return e instanceof Dm[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&e!=="pulse"&&e!=="pwm"&&(this._oscillator.baseType=e)}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(e){this._getOscType(this._oscillator,"fat")&&te(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,"fat")&&te(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&ie(e)&&(this._oscillator.modulationType=e)}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 ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function Ys(n,e=1/0){let t=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(o){kt(o,n,e),t.set(this,o)}})}}function fe(n,e=1/0){let t=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(o){kt(this.toSeconds(o),n,e),t.set(this,o)}})}}var lo=class n extends gt{constructor(){let e=N(n.getDefaults(),arguments,["url","onload"]);super(e),this.name="Player",this._activeSources=new Set,this._buffer=new Lt({onload:this._onload.bind(this,e.onload),onerror:e.onerror,reverse:e.reverse,url:e.url}),this.autostart=e.autostart,this._loop=e.loop,this._loopStart=e.loopStart,this._loopEnd=e.loopEnd,this._playbackRate=e.playbackRate,this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut}static getDefaults(){return Object.assign(gt.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:rt,onerror:rt,playbackRate:1,reverse:!1})}load(e){return ht(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=rt){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(e,t,r){return super.start(e,t,r),this}_start(e,t,r){this._loop?t=Ce(t,this._loopStart):t=Ce(t,0);let i=this.toSeconds(t),o=r;r=Ce(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,e=this.toSeconds(e);let a=new lr({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(e+s),this._state.setStateAtTime("stopped",e+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Bt(o)?a.start(e,i):a.start(e,i,s-this.toSeconds(this.fadeOut))}_stop(e){let t=this.toSeconds(e);this._activeSources.forEach(r=>r.stop(t))}restart(e,t,r){return super.restart(e,t,r),this}_restart(e,t,r){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(e),this._start(e,t,r)}seek(e,t){let r=this.toSeconds(t);if(this._state.getValueAtTime(r)==="started"){let i=this.toSeconds(e);this._stop(r),this._start(r,i)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&kt(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&kt(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){let t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;let t=this.now(),r=this._state.getNextState("stopped",t);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};oe([fe(0)],lo.prototype,"fadeIn",void 0);oe([fe(0)],lo.prototype,"fadeOut",void 0);var Hs=class extends se{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new pe({context:this.context,mapping:e=>Math.abs(e)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var he=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="Envelope",this._sig=new $({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve,this.decayCurve=e.decayCurve}static getDefaults(){return Object.assign(j.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(ie(e))return e;{let r;for(r in Zs)if(Zs[r][t]===e)return r;return e}}_setCurve(e,t,r){if(ie(r)&&Reflect.has(Zs,r)){let i=Zs[r];Ue(i)?e!=="_decayCurve"&&(this[e]=i[t]):this[e]=i}else if(Rt(r)&&e!=="_decayCurve")this[e]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(e){this._setCurve("_attackCurve","In",e)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(e){this._setCurve("_releaseCurve","Out",e)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(e){this._setCurve("_decayCurve","Out",e)}triggerAttack(e,t=1){this.log("triggerAttack",e,t),e=this.toSeconds(e);let i=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(e);if(s>0){let a=1/i;i=(1-s)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve==="linear")this._sig.linearRampTo(t,i,e);else if(this._attackCurve==="exponential")this._sig.targetRampTo(t,i,e);else{this._sig.cancelAndHoldAtTime(e);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,e,i,t)}if(o&&this.sustain<1){let a=t*this.sustain,c=e+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(e){this.log("triggerRelease",e),e=this.toSeconds(e);let t=this.getValueAtTime(e);if(t>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,e):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,e):(z(Rt(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,r,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,r=1){return t=this.toSeconds(t),this.triggerAttack(t,r),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}connect(e,t=0,r=0){return on(this,e,t,r),this}asArray(){return ht(this,arguments,void 0,function*(e=1024){let t=e/this.context.sampleRate,r=new He(1,t,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=i+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/a,decay:t*this.toSeconds(this.decay)/a,release:t*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(t*(i+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};oe([fe(0)],he.prototype,"attack",void 0);oe([fe(0)],he.prototype,"decay",void 0);oe([Ys(0,1)],he.prototype,"sustain",void 0);oe([fe(0)],he.prototype,"release",void 0);var Zs=(()=>{let e,t,r=[];for(e=0;e<128;e++)r[e]=Math.sin(e/127*(Math.PI/2));let i=[],o=6.4;for(e=0;e<127;e++){t=e/127;let d=Math.sin(t*(Math.PI*2)*o-Math.PI/2)+1;i[e]=d/10+t*.83}i[127]=1;let s=[],a=5;for(e=0;e<128;e++)s[e]=Math.ceil(e/127*a)/a;let c=[];for(e=0;e<128;e++)t=e/127,c[e]=.5*(1-Math.cos(Math.PI*t));let u=[];for(e=0;e<128;e++){t=e/127;let d=Math.pow(t,3)*4+.2,m=Math.cos(d*Math.PI*2*t);u[e]=Math.abs(m*(1-t))}function l(d){let m=new Array(d.length);for(let f=0;f<d.length;f++)m[f]=1-d[f];return m}function h(d){return d.slice(0).reverse()}return{bounce:{In:l(u),Out:u},cosine:{In:r,Out:h(r)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:l(i)},sine:{In:c,Out:l(c)},step:{In:s,Out:l(s)}}})();var Ie=class n extends j{constructor(){let e=N(n.getDefaults(),arguments);super(e),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=t=>this._original_triggerRelease(t),this._volume=this.output=new je({context:this.context,volume:e.volume}),this.volume=this._volume.volume,W(this,"volume")}static getDefaults(){return Object.assign(j.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 e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){let r=this["_original_"+e]=this[e];this[e]=(...i)=>{let o=i[t],s=this.context.transport.schedule(a=>{i[t]=a,r.apply(this,i)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),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(e,t,r,i){let o=this.toSeconds(r),s=this.toSeconds(t);return this.triggerAttack(e,o,i),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var ge=class n extends Ie{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.portamento=e.portamento,this.onsilence=e.onsilence}static getDefaults(){return Object.assign(Ie.getDefaults(),{detune:0,onsilence:rt,portamento:0})}triggerAttack(e,t,r=1){this.log("triggerAttack",e,t,r);let i=this.toSeconds(t);return this._triggerEnvelopeAttack(i,r),this.setNote(e,i),this}triggerRelease(e){this.log("triggerRelease",e);let t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){let r=this.toSeconds(t),i=e instanceof le?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,o,r)}else this.frequency.setValueAtTime(i,r);return this}};oe([fe(0)],ge.prototype,"portamento",void 0);var dn=class n extends he{constructor(){super(N(n.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 hr=class n extends ge{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="Synth",this.oscillator=new yi(Object.assign({context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)},e.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new dn(Object.assign({context:this.context},e.envelope)),this.oscillator.chain(this.envelope,this.output),W(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ge.getDefaults(),{envelope:Object.assign(Ye(he.getDefaults(),Object.keys(j.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ye(yi.getDefaults(),[...Object.keys(gt.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+r+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var ho=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new st({context:this.context,units:"number",value:e.Q,param:this._filter.Q}),this.frequency=new st({context:this.context,units:"frequency",value:e.frequency,param:this._filter.frequency}),this.detune=new st({context:this.context,units:"cents",value:e.detune,param:this._filter.detune}),this.gain=new st({context:this.context,units:"decibels",convert:!1,value:e.gain,param:this._filter.gain}),this.type=e.type}static getDefaults(){return Object.assign(j.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){let t=new Float32Array(e);for(let s=0;s<e;s++){let c=Math.pow(s/e,2)*19980+20;t[s]=c}let r=new Float32Array(e),i=new Float32Array(e),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(t,r,i),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var Ir=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","rolloff"]);super(e),this.name="Filter",this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new $({context:this.context,units:"positive",value:e.Q}),this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this.detune=new $({context:this.context,units:"cents",value:e.detune}),this.gain=new $({context:this.context,units:"decibels",convert:!1,value:e.gain}),this._type=e.type,this.rolloff=e.rolloff,W(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(j.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(e){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(r=>r.type=e)}get rolloff(){return this._rolloff}set rolloff(e){let t=te(e)?e:parseInt(e,10),r=[-12,-24,-48,-96],i=r.indexOf(t);z(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(i);for(let o=0;o<i;o++){let s=new ho({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,Le(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){let t=new ho({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(e).map(()=>1);return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((o,s)=>r[s]*=o)}),t.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),pi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var Xs=class n extends hr{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=e.pitchDecay,this.octaves=e.octaves,W(this,["oscillator","envelope"])}static getDefaults(){return Ee(ge.getDefaults(),hr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(e,t){let r=this.toSeconds(t),i=this.toFrequency(e instanceof le?e.toFrequency():e),o=i*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(i,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};oe([Ys(0)],Xs.prototype,"octaves",void 0);oe([fe(0)],Xs.prototype,"pitchDecay",void 0);var Em=new Set;function mn(n){Em.add(n)}function Qs(n,e){let t=`registerProcessor("${n}", ${e})`;Em.add(t)}var nx=`
19
+ `],{type:"text/javascript"}),t=URL.createObjectURL(e),r=new Worker(t);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(e){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(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type==="worker"&&((t=this._worker)===null||t===void 0||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}};function ze(n){return um(n)}function cr(n){return cm(n)}function tn(n){return lm(n)}function Wr(n){return am(n)}function Cm(n){return n instanceof uu}function tx(n,e){return n==="value"||ze(e)||cr(e)||Cm(e)}function Ee(n,...e){if(!e.length)return n;let t=e.shift();if(Ue(n)&&Ue(t))for(let r in t)tx(r,t[r])?n[r]=t[r]:Ue(t[r])?(n[r]||Object.assign(n,{[r]:{}}),Ee(n[r],t[r])):Object.assign(n,{[r]:t[r]});return Ee(n,...e)}function _m(n,e){return n.length===e.length&&n.every((t,r)=>e[r]===t)}function N(n,e,t=[],r){let i={},o=Array.from(e);if(Ue(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(n,a))||(Ee(i,{[r]:o[0]}),t.splice(t.indexOf(r),1),o.shift())),o.length===1&&Ue(o[0]))Ee(i,o[0]);else for(let s=0;s<t.length;s++)et(o[s])&&(i[t[s]]=o[s]);return Ee(n,i)}function vm(n){return n.constructor.getDefaults()}function Ce(n,e){return Bt(n)?e:n}function Ye(n,e){return e.forEach(t=>{Reflect.has(n,t)&&delete n[t]}),n}var Qt=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||ne&&this.toString()===ne.TONE_DEBUG_CLASS)&&gm(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Qt.version=Un;function Cr(n,e){return n>e+1e-6}function io(n,e){return Cr(n,e)||ue(n,e)}function di(n,e){return n+1e-6<e}function ue(n,e){return Math.abs(n-e)<1e-6}function gu(n,e,t){return Math.max(Math.min(n,t),e)}var Wt=class n extends Qt{constructor(){super(),this.name="Timeline",this._timeline=[];let e=N(n.getDefaults(),arguments,["memory"]);this.memory=e.memory,this.increasing=e.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(e){if(z(Reflect.has(e,"time"),"Timeline: events must have a time attribute"),e.time=e.time.valueOf(),this.increasing&&this.length){let t=this._timeline[this.length-1];z(io(e.time,t.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(e)}else{let t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){let t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(e){let t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t="time"){let r=this._search(e,t);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t="time"){let r=this._search(e,t);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(e){let t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];let r=this._search(e);return r-1>=0?this._timeline[r-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0)if(ue(this._timeline[t].time,e)){for(let r=t;r>=0&&ue(this._timeline[r].time,e);r--)t=r;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1);else this._timeline=[]}else this._timeline.length===1&&io(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){let t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){let t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t="time"){if(this._timeline.length===0)return-1;let r=0,i=this._timeline.length,o=i;if(i>0&&this._timeline[i-1][t]<=e)return i-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ue(a[t],e)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ue(l[t],e))s=u;else break}return s}else{if(di(a[t],e)&&Cr(c[t],e))return s;Cr(a[t],e)?o=s:r=s+1}}return-1}_iterate(e,t=0,r=this._timeline.length-1){this._timeline.slice(t,r+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){let r=this._search(e);return r!==-1&&this._iterate(t,0,r),this}forEachAfter(e,t){let r=this._search(e);return this._iterate(t,r+1),this}forEachBetween(e,t,r){let i=this._search(e),o=this._search(t);return i!==-1&&o!==-1?(this._timeline[i].time!==e&&(i+=1),this._timeline[o].time===t&&(o-=1),this._iterate(r,i,o)):i===-1&&this._iterate(r,0,o),this}forEachFrom(e,t){let r=this._search(e);for(;r>=0&&this._timeline[r].time>=e;)r--;return this._iterate(t,r+1),this}forEachAtTime(e,t){let r=this._search(e);if(r!==-1&&ue(this._timeline[r].time,e)){let i=r;for(let o=r;o>=0&&ue(this._timeline[o].time,e);o--)i=o;this._iterate(o=>{t(o)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Im=[];function Ur(n){Im.push(n)}function Sm(n){Im.forEach(e=>e(n))}var wm=[];function zr(n){wm.push(n)}function Tm(n){wm.forEach(e=>e(n))}var Yr=class n extends Qt{constructor(){super(...arguments),this.name="Emitter"}on(e,t){return e.split(/\W+/).forEach(i=>{Bt(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(t)}),this}once(e,t){let r=(...i)=>{t(...i),this.off(e,r)};return this.on(e,r),this}off(e,t){return e.split(/\W+/).forEach(i=>{if(Bt(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Bt(t))this._events[i]=[];else{let o=this._events[i];for(let s=o.length-1;s>=0;s--)o[s]===t&&o.splice(s,1)}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){let r=this._events[e].slice(0);for(let i=0,o=r.length;i<o;i++)r[i].apply(this,t)}return this}static mixin(e){["on","once","off","emit"].forEach(t=>{let r=Object.getOwnPropertyDescriptor(n.prototype,t);Object.defineProperty(e.prototype,t,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var en=class extends Yr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var pi=class n extends en{constructor(){var e,t;super(),this.name="Context",this._constants=new Map,this._timeouts=new Wt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=N(n.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((e=arguments[0])===null||e===void 0?void 0:e.latencyHint)||""):(this._context=ym({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new Ls(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[!((t=arguments[0])===null||t===void 0)&&t.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Sm(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(e,t,r){return this._context.createBuffer(e,t,r)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,r){return this._context.createPeriodicWave(e,t,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(e){return z(Wr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return z(Wr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return z(Wr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}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(e){z(!this._initialized,"The listener cannot be set after initialization."),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){z(!this._initialized,"The transport cannot be set after initialization."),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){z(!this._initialized,"Draw cannot be set after initialization."),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){z(!this._initialized,"The destination cannot be set after initialization."),this._destination=e}createAudioWorkletNode(e,t){return Am(this.rawContext,e,t)}addAudioWorkletModule(e){return ht(this,void 0,void 0,function*(){z(et(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(e)),yield this._workletPromise})}workletsAreReady(){return ht(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/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 Wr(this._context)?this._context.resume():Promise.resolve()}close(){return ht(this,void 0,void 0,function*(){Wr(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Tm(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{let t=this._context.createBuffer(1,128,this._context.sampleRate),r=t.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=e;let i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=t,i.loop=!0,i.start(0),this._constants.set(e,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){let e=this.now();this._timeouts.forEachBefore(e,t=>{t.callback(),this._timeouts.remove(t)})}setTimeout(e,t){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:r+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){let r=++this._timeoutIds,i=()=>{let o=this.now();this._timeouts.add({callback:()=>{e(),i()},id:r,time:o+t})};return i(),r}};var js=class extends en{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,r){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return ht(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}};function W(n,e){Rt(e)?e.forEach(t=>W(n,t)):Object.defineProperty(n,e,{enumerable:!0,writable:!1})}function mi(n,e){Rt(e)?e.forEach(t=>mi(n,t)):Object.defineProperty(n,e,{writable:!0})}var rt=()=>{};var Lt=class n extends Qt{constructor(){super(),this.name="ToneAudioBuffer",this.onload=rt;let e=N(n.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=e.reverse,this.onload=e.onload,ie(e.url)?this.load(e.url).catch(e.onerror):e.url&&this.set(e.url)}static getDefaults(){return{onerror:rt,onload:rt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Vt().sampleRate}set(e){return e instanceof n?e.loaded?this._buffer=e.get():e.onload=()=>{this.set(e),this.onload(this)}:this._buffer=e,this._reversed&&this._reverse(),this}get(){return this._buffer}load(e){return ht(this,void 0,void 0,function*(){let t=n.load(e).then(r=>{this.set(r),this.onload(this)});n.downloads.push(t);try{yield t}finally{let r=n.downloads.indexOf(t);n.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){let t=Rt(e)&&e[0].length>0,r=t?e.length:1,i=t?e[0].length:e.length,o=Vt(),s=o.createBuffer(r,i,o.sampleRate),a=!t&&r===1?[e]:e;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(e){if(te(e))this.fromArray(this.toArray(e));else{let t=new Float32Array(this.length),r=this.numberOfChannels;for(let i=0;i<r;i++){let o=this.toArray(i);for(let s=0;s<o.length;s++)t[s]+=o[s]}t=t.map(i=>i/r),this.fromArray(t)}return this}toArray(e){if(te(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{let t=[];for(let r=0;r<this.numberOfChannels;r++)t[r]=this.getChannelData(r);return t}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array(0)}slice(e,t=this.duration){z(this.loaded,"Buffer is not loaded");let r=Math.floor(e*this.sampleRate),i=Math.floor(t*this.sampleRate);z(r<i,"The start time must be less than the end time");let o=i-r,s=Vt().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,i),a);return new n(s)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).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(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(e){return new n().fromArray(e)}static fromUrl(e){return ht(this,void 0,void 0,function*(){return yield new n().load(e)})}static load(e){return ht(this,void 0,void 0,function*(){let t=n.baseUrl===""||n.baseUrl.endsWith("/")?n.baseUrl:n.baseUrl+"/",r=yield fetch(t+e);if(!r.ok)throw new Error(`could not load url: ${e}`);let i=yield r.arrayBuffer();return yield Vt().decodeAudioData(i)})}static supportsType(e){let t=e.split("."),r=t[t.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return ht(this,void 0,void 0,function*(){for(yield Promise.resolve();n.downloads.length;)yield n.downloads[0]})}};Lt.baseUrl="";Lt.downloads=[];var He=class extends pi{constructor(){super({clockSource:"offline",context:tn(arguments[0])?arguments[0]:bm(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:tn(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=tn(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return ht(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,t++;let r=Math.floor(this.sampleRate/128);e&&t%r===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return ht(this,arguments,void 0,function*(e=!0){yield this.workletsAreReady(),yield this._renderClock(e);let t=yield this._context.startRendering();return new Lt(t)})}close(){return Promise.resolve()}};var Nm=new js,rn=Nm;function Vt(){return rn===Nm&&xm&&yu(new pi),rn}function yu(n,e=!1){e&&rn.dispose(),Wr(n)?rn=new pi(n):tn(n)?rn=new He(n):rn=n}if(ne&&!ne.TONE_SILENCE_LOGGING){let n="v";Un==="dev"&&(n="");let e=` * Tone.js ${n}${Un} * `;console.log(`%c${e}`,"background: #000; color: #fff")}function nn(n){return Math.pow(10,n/20)}function on(n){return 20*(Math.log(n)/Math.LN10)}function fi(n){return Math.pow(2,n/12)}var Ps=440;function Om(){return Ps}function Rm(n){Ps=n}function Ze(n){return Math.round(bu(n))}function bu(n){return 69+12*Math.log2(n/Ps)}function no(n){return Ps*Math.pow(2,(n-69)/12)}var Fs=class n extends Qt{constructor(e,t,r){super(),this.defaultUnits="s",this._val=t,this._units=r,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{let r=parseInt(e,10),i=t==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/r)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{let t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,r)=>{let i=0;return e&&e!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i+=this._beatsToUnits(parseFloat(t))),r&&r!=="0"&&(i+=this._beatsToUnits(parseFloat(r)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof n&&this.fromType(this._val),Bt(this._val))return this._noArg();if(ie(this._val)&&Bt(this._units)){for(let e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(Ue(this._val)){let e=0;for(let t in this._val)if(et(this._val[t])){let r=this._val[t],i=new this.constructor(this.context,t).valueOf()*r;e+=i}return e}if(et(this._units)){let e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}else return ie(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*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(e){switch(this._units=void 0,this.defaultUnits){case"s":this._val=e.toSeconds();break;case"i":this._val=e.toTicks();break;case"hz":this._val=e.toFrequency();break;case"midi":this._val=e.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var _e=class n extends Fs{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:e=>{let t=new n(this.context,e).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(t))},regexp:/^@(.+)/}})}quantize(e,t=1){let r=new this.constructor(this.context,e).valueOf(),i=this.valueOf(),a=Math.round(i/r)*r-i;return i+a*t}toNotation(){let e=this.toSeconds(),t=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);t.push(s+"n."),t.push(s+"n"),t.push(s+"t")}t.push("0");let r=t[0],i=new n(this.context,t[0]).toSeconds();return t.forEach(o=>{let s=new n(this.context,o).toSeconds();Math.abs(s-e)<Math.abs(i-e)&&(r=o,i=s)}),r}toBarsBeatsSixteenths(){let e=this._beatsToUnits(1),t=this.valueOf()/e;t=parseFloat(t.toFixed(4));let r=Math.floor(t/this._getTimeSignature()),i=t%1*4;t=Math.floor(t)%this._getTimeSignature();let o=i.toString();return o.length>3&&(i=parseFloat(parseFloat(o).toFixed(3))),[r,t,i].join(":")}toTicks(){let e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Ze(this.toFrequency())}_now(){return this.context.now()}};var le=class n extends _e{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Om()}static set A4(e){Rm(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(e){return this.defaultUnits==="midi"?e:n.mtof(e)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(e,t){let i=ex[e.toLowerCase()]+(parseInt(t,10)+1)*12;return this.defaultUnits==="midi"?i:n.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,r){let i=1;return e&&e!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i*=this._beatsToUnits(parseFloat(t))),r&&r!=="0"&&(i*=this._beatsToUnits(parseFloat(r)/4)),i}}})}transpose(e){return new n(this.context,this.valueOf()*fi(e))}harmonize(e){return e.map(t=>this.transpose(t))}toMidi(){return Ze(this.valueOf())}toNote(){let e=this.toFrequency(),t=Math.log2(e/n.A4),r=Math.round(12*t)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),rx[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return no(e)}static ftom(e){return Ze(e)}},ex={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},rx=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var ke=class extends _e{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var Ut=class n extends Qt{constructor(){super();let e=N(n.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=e.context}static getDefaults(){return{context:Vt()}}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(e){return mm(e),new _e(this.context,e).toSeconds()}toFrequency(e){return new le(this.context,e).toFrequency()}toTicks(e){return new ke(this.context,e).toTicks()}_getPartialProperties(e){let t=this.get();return Object.keys(t).forEach(r=>{Bt(e[r])&&delete t[r]}),t}get(){let e=vm(this);return Object.keys(e).forEach(t=>{if(Reflect.has(this,t)){let r=this[t];et(r)&&et(r.value)&&et(r.setValueAtTime)?e[t]=r.value:r instanceof n?e[t]=r._getPartialProperties(e[t]):Rt(r)||te(r)||ie(r)||mu(r)?e[t]=r:delete e[t]}}),e}set(e){return Object.keys(e).forEach(t=>{Reflect.has(this,t)&&et(this[t])&&(this[t]&&et(this[t].value)&&et(this[t].setValueAtTime)?this[t].value!==e[t]&&(this[t].value=e[t]):this[t]instanceof n?this[t].set(e[t]):this[t]=e[t])}),this}};var ur=class extends Wt{constructor(e="stopped"){super(),this.name="StateTimeline",this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){let t=this.get(e);return t!==null?t.state:this._initial}setStateAtTime(e,t,r){return kt(t,0),this.add(Object.assign({},r,{state:e,time:t})),this}getLastState(e,t){let r=this._search(t);for(let i=r;i>=0;i--){let o=this._timeline[i];if(o.state===e)return o}}getNextState(e,t){let r=this._search(t);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let o=this._timeline[i];if(o.state===e)return o}}};var st=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments,["param","units","convert"]);for(super(e),this.name="Param",this.overridden=!1,this._minOutput=1e-7,z(et(e.param)&&(ze(e.param)||e.param instanceof n),"param must be an AudioParam");!ze(e.param);)e.param=e.param._param;this._swappable=et(e.swappable)?e.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=e.param,this.input.connect(this._param)):this._param=this.input=e.param,this._events=new Wt(1e3),this._initialValue=this._param.defaultValue,this.units=e.units,this.convert=e.convert,this._minValue=e.minValue,this._maxValue=e.maxValue,et(e.value)&&e.value!==this._toType(this._initialValue)&&this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(Ut.getDefaults(),{convert:!0,units:"number"})}get value(){let e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return et(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 et(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return et(this.maxValue)&&et(this.minValue)&&kt(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,"time")?this.toSeconds(e):this._is(e,"decibels")?nn(e):this._is(e,"frequency")?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units==="decibels"?on(e):e}setValueAtTime(e,t){let r=this.toSeconds(t),i=this._fromType(e);return z(isFinite(i)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",e,r),this._events.add({time:r,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,r),this}getValueAtTime(e){let t=Math.max(this.toSeconds(e),0),r=this._events.getAfter(t),i=this._events.get(t),o=this._initialValue;if(i===null)o=this._initialValue;else if(i.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(i.time),a;s===null?a=this._initialValue:a=s.value,i.type==="setTargetAtTime"&&(o=this._exponentialApproach(i.time,a,i.value,i.constant,t))}else if(r===null)o=i.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=i.value;if(i.type==="setTargetAtTime"){let a=this._events.getBefore(i.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(i.time,s,r.time,r.value,t):o=this._exponentialInterpolate(i.time,s,r.time,r.value,t)}else o=i.value;return this._toType(o)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){let r=this._fromType(e),i=this.toSeconds(t);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(r),this._events.add({time:i,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",e,i),this._param.linearRampToValueAtTime(r,i),this}exponentialRampToValueAtTime(e,t){let r=this._fromType(e);r=ue(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(t);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",e,i),this._param.exponentialRampToValueAtTime(r,i),this}exponentialRampTo(e,t,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(e,r+this.toSeconds(t)),this}linearRampTo(e,t,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(e,r+this.toSeconds(t)),this}targetRampTo(e,t,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(e,r,t),this}exponentialApproachValueAtTime(e,t,r){t=this.toSeconds(t),r=this.toSeconds(r);let i=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(e,t,i),this.cancelAndHoldAtTime(t+r*.9),this.linearRampToValueAtTime(e,t+r),this}setTargetAtTime(e,t,r){let i=this._fromType(e);z(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(t);return this._assertRange(i),z(isFinite(i)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",e,o,r),this._param.setTargetAtTime(i,o,r),this}setValueCurveAtTime(e,t,r,i=1){r=this.toSeconds(r),t=this.toSeconds(t);let o=this._fromType(e[0])*i;this.setValueAtTime(this._toType(o),t);let s=r/(e.length-1);for(let a=1;a<e.length;a++){let c=this._fromType(e[a])*i;this.linearRampToValueAtTime(this._toType(c),t+a*s)}return this}cancelScheduledValues(e){let t=this.toSeconds(e);return z(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,"cancelScheduledValues",t),this}cancelAndHoldAtTime(e){let t=this.toSeconds(e),r=this._fromType(this.getValueAtTime(t));z(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,"cancelAndHoldAtTime",t,"value="+r);let i=this._events.get(t),o=this._events.getAfter(t);return i&&ue(i.time,t)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),t):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),t)),this._events.add({time:t,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,t),this}rampTo(e,t=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(e,t,r):this.linearRampTo(e,t,r),this}apply(e){let t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);let r=this._events.get(t);if(r&&r.type==="setTargetAtTime"){let i=this._events.getAfter(r.time),o=i?i.time:t+2,s=(o-t)/10;for(let a=t;a<o;a+=s)e.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?e.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?e.setTargetAtTime(i.value,i.time,i.constant):e[i.type](i.value,i.time)}),this}setParam(e){z(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,r,i,o){return r+(t-r)*Math.exp(-(o-e)/i)}_linearInterpolate(e,t,r,i,o){return t+(i-t)*((o-e)/(r-e))}_exponentialInterpolate(e,t,r,i,o){return t*Math.pow(i/t,(o-e)/(r-e))}};var j=class n extends Ut{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return et(this.input)?ze(this.input)||this.input instanceof st?1:this.input.numberOfInputs:0}get numberOfOutputs(){return et(this.output)?this.output.numberOfOutputs:0}_isAudioNode(e){return et(e)&&(e instanceof n||cr(e))}_getInternalNodes(){let e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(r=>{r.channelCount=e.channelCount,r.channelCountMode=e.channelCountMode,r.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){let e=this._getInternalNodes();z(e.length>0,"ToneAudioNode does not have any internal nodes");let t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,r=0){return ee(this,e,t,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return hi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(e,t=0,r=0){return Mm(this,e,t,r),this}chain(...e){return Le(this,...e),this}fan(...e){return e.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),et(this.input)&&(this.input instanceof n?this.input.dispose():cr(this.input)&&this.input.disconnect()),et(this.output)&&(this.output instanceof n?this.output.dispose():cr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Le(...n){let e=n.shift();n.reduce((t,r)=>(t instanceof j?t.connect(r):cr(t)&&ee(t,r),r),e)}function ee(n,e,t=0,r=0){for(z(et(n),"Cannot connect from undefined node"),z(et(e),"Cannot connect to undefined node"),(e instanceof j||cr(e))&&z(e.numberOfInputs>0,"Cannot connect to node with no inputs"),z(n.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof j||e instanceof st;)et(e.input)&&(e=e.input);for(;n instanceof j;)et(n.output)&&(n=n.output);ze(e)?n.connect(e,t):n.connect(e,t,r)}function Mm(n,e,t=0,r=0){if(et(e))for(;e instanceof j;)e=e.input;for(;!cr(n);)et(n.output)&&(n=n.output);ze(e)?n.disconnect(e,t):cr(e)?n.disconnect(e,t,r):n.disconnect()}var Z=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["gain","units"]);super(e),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new st({context:this.context,convert:e.convert,param:this._gainNode.gain,units:e.units,value:e.gain,minValue:e.minValue,maxValue:e.maxValue}),W(this,"gain")}static getDefaults(){return Object.assign(j.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}};var Xe=class extends j{constructor(e){super(e),this.onended=rt,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(t){let r=this.toSeconds(t);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign(j.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:rt})}_startGain(e,t=1){z(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=e+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(t,e+r):this._gainNode.gain.exponentialApproachValueAtTime(t,e,r)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log("stop",e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){z(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?t*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==rt&&(this.onended(this),this.onended=rt,!this.context.isOffline)){let e=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),z(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=rt,this}};var oo=class n extends Xe{constructor(){let e=N(n.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),ee(this._source,this._gainNode),this.offset=new st({context:this.context,convert:e.convert,param:this._source.offset,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(Xe.getDefaults(),{convert:!0,offset:1,units:"number"})}start(e){let t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var $=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["value","units"]);super(e),this.name="Signal",this.override=!0,this.output=this._constantSource=new oo({context:this.context,convert:e.convert,offset:e.value,units:e.units,minValue:e.minValue,maxValue:e.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(j.getDefaults(),{convert:!0,units:"number",value:0})}connect(e,t=0,r=0){return sn(this,e,t,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,r){return this._param.exponentialRampTo(e,t,r),this}linearRampTo(e,t,r){return this._param.linearRampTo(e,t,r),this}targetRampTo(e,t,r){return this._param.targetRampTo(e,t,r),this}exponentialApproachValueAtTime(e,t,r){return this._param.exponentialApproachValueAtTime(e,t,r),this}setTargetAtTime(e,t,r){return this._param.setTargetAtTime(e,t,r),this}setValueCurveAtTime(e,t,r,i){return this._param.setValueCurveAtTime(e,t,r,i),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,r){return this._param.rampTo(e,t,r),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}};function sn(n,e,t,r){(e instanceof st||ze(e)||e instanceof $&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof $&&(e.overridden=!0)),ee(n,e,t,r)}var Bs=class n extends st{constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="TickParam",this._events=new Wt(1/0),this._multiplier=1,this._multiplier=e.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(e.value)}),this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(st.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(e,t,r){t=this.toSeconds(t),this.setRampPoint(t);let i=this._fromType(e),o=this._events.get(t),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+t,u=this._exponentialApproach(o.time,o.value,i,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(e,t){let r=this.toSeconds(t);super.setValueAtTime(e,t);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}linearRampToValueAtTime(e,t){let r=this.toSeconds(t);super.linearRampToValueAtTime(e,t);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);let r=this._fromType(e),i=this._events.get(t),o=Math.round(Math.max((t-i.time)*10,1)),s=(t-i.time)/o;for(let a=0;a<=o;a++){let c=s*a+i.time,u=this._exponentialInterpolate(i.time,i.value,t,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Bt(e.ticks)){let s=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(s,e.time)}let r=this._fromType(this.getValueAtTime(e.time)),i=this._fromType(this.getValueAtTime(t)),o=this._events.get(t);return o&&o.time===t&&o.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(r+i)+e.ticks}getTicksAtTime(e){let t=this.toSeconds(e),r=this._events.get(t);return Math.max(this._getTicksUntilEvent(r,t),0)}getDurationOfTicks(e,t){let r=this.toSeconds(t),i=this.getTicksAtTime(t);return this.getTimeOfTick(i+e)-r}getTimeOfTick(e){let t=this._events.get(e,"ticks"),r=this._events.getAfter(e,"ticks");if(t&&t.ticks===e)return t.time;if(t&&r&&r.type==="linearRampToValueAtTime"&&t.value!==r.value){let i=this._fromType(this.getValueAtTime(t.time)),s=(this._fromType(this.getValueAtTime(r.time))-i)/(r.time-t.time),a=Math.sqrt(Math.pow(i,2)-2*s*(t.ticks-e)),c=(-i+a)/s,u=(-i-a)/s;return(c>0?c:u)+t.time}else return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){let r=this.toSeconds(t),i=this.toSeconds(e),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-o}_fromType(e){return this.units==="bpm"&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units==="bpm"&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){let t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}};var Vs=class n extends ${constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="TickSignal",this.input=this._param=new Bs({context:this.context,convert:e.convert,multiplier:e.multiplier,param:this._constantSource.offset,units:e.units,value:e.value})}static getDefaults(){return Object.assign($.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}};var Gs=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments,["frequency"]);super(e),this.name="TickSource",this._state=new ur,this._tickOffset=new Wt,this._ticksAtTime=new Wt,this._secondsAtTime=new Wt,this.frequency=new Vs({context:this.context,units:e.units,value:e.frequency}),W(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Ut.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){let r=this.toSeconds(e);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),et(t)&&this.setTicksAtTime(t,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(e){let t=this.toSeconds(e);if(this._state.getValueAtTime(t)==="stopped"){let r=this._state.get(t);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){let t=this.toSeconds(e),r=this._state.getLastState("stopped",t),i=this._ticksAtTime.get(t),o={state:"paused",time:t};this._state.add(o);let s=i||r,a=i?i.ticks:0,c=null;return this._state.forEachBetween(s.time,t+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(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){let t=this.now(),r=this.frequency.timeToTicks(e,t);this.setTicksAtTime(r,t)}getSecondsAtTime(e){e=this.toSeconds(e);let t=this._state.getLastState("stopped",e),r={state:"paused",time:e};this._state.add(r);let i=this._secondsAtTime.get(e),o=i||t,s=i?i.seconds:0,a=null;return this._state.forEachBetween(o.time,e+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(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){let r=this._tickOffset.get(t),i=this._state.get(t),o=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(o)+e-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(e,t,r){let i=this._state.get(e);this._state.forEachBetween(e,t,s=>{i&&i.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(i.time,e),s.time-this.sampleTime,r),i=s});let o=null;if(i&&i.state==="started"){let s=Math.max(i.time,e),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(i.time),u=a-c,l=Math.ceil(u)-u;l=ue(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<t;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(d){o=d;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 an=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments,["callback","frequency"]);super(e),this.name="Clock",this.callback=rt,this._lastUpdate=0,this._state=new ur("stopped"),this._boundLoop=this._loop.bind(this),this.callback=e.callback,this._tickSource=new Gs({context:this.context,frequency:e.frequency,units:e.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,W(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Ut.getDefaults(),{callback:rt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){ks(this.context);let r=this.toSeconds(e);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,t),r<this._lastUpdate&&this.emit("start",r,t)),this}stop(e){let t=this.toSeconds(e);return this.log("stop",t),this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit("stop",t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit("pause",t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){let r=this.toSeconds(t),i=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(i+e,r)}_loop(){let e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log("loop",e,t),e!==t&&(this._state.forEachBetween(e,t,r=>{switch(r.state){case"started":let i=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,i);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(e,t,(r,i)=>{this.callback(r,i)}))}getStateAtTime(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};Yr.mixin(an);var je=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["volume"]);super(e),this.name="Volume",this.input=this.output=new Z({context:this.context,gain:e.volume,units:"decibels"}),this.volume=this.output.gain,W(this,"volume"),this._unmutedVolume=e.volume,this.mute=e.mute}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var xu=class n extends j{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="Destination",this.input=new je({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Le(this.input,this.output,this.context.rawContext.destination),this.mute=e.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),Le(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Ur(n=>{n.destination=new xu({context:n})});zr(n=>{n.destination.dispose()});var Au=class extends j{constructor(){super(...arguments),this.name="Listener",this.positionX=new st({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new st({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new st({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new st({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new st({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new st({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new st({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new st({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new st({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(j.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}};Ur(n=>{n.listener=new Au({context:n})});zr(n=>{n.listener.dispose()});var cn=class n extends Qt{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let e=N(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=e.baseUrl,Object.keys(e.urls).forEach(t=>{this._loadingCount++;let r=e.urls[t];this.add(t,r,this._bufferLoaded.bind(this,e.onload),e.onerror)})}static getDefaults(){return{baseUrl:"",onerror:rt,onload:rt,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return z(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,r=rt,i=rt){return ie(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(e.toString(),new Lt(this.baseUrl+t,r,i))):this._buffers.set(e.toString(),new Lt(t,r,i)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}};var so=class n extends le{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(e){return Ze(super._frequencyToUnits(e))}_ticksToUnits(e){return Ze(super._ticksToUnits(e))}_beatsToUnits(e){return Ze(super._beatsToUnits(e))}_secondsToUnits(e){return Ze(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return no(this.toMidi())}transpose(e){return new n(this.context,this.toMidi()+e)}};var ve=class extends ke{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var Cu=class extends Ut{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Wt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){let e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};Ur(n=>{n.draw=new Cu({context:n})});zr(n=>{n.draw.dispose()});var qs=class extends Qt{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(e){z(et(e.time),"Events must have a time property"),z(et(e.duration),"Events must have a duration parameter"),e.time=e.time.valueOf();let t=new _u(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){let t=[];this._root.search(e.time,t);for(let r of t)if(r.event===e){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,t=>this.remove(t)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent!==null?(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent)):this._setRoot(t)}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{let t=e.getBalance(),r,i=null;if(t>0)if(e.left.right===null)r=e.left,r.right=e.right,i=r;else{for(r=e.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,i=r.parent,r.left=e.left,r.right=e.right)}else if(e.right.left===null)r=e.right,r.left=e.left,i=r;else{for(r=e.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,i=r.parent,r.left=e.left,r.right=e.right)}e.parent!==null?e.isLeftChild()?e.parent.left=r:e.parent.right=r:this._setRoot(r),i&&this._rebalance(i)}e.dispose()}_rotateLeft(e){let t=e.parent,r=e.isLeftChild(),i=e.right;i&&(e.right=i.left,i.left=e),t!==null?r?t.left=i:t.right=i:this._setRoot(i)}_rotateRight(e){let t=e.parent,r=e.isLeftChild(),i=e.left;i&&(e.left=i.right,i.right=e),t!==null?r?t.left=i:t.right=i:this._setRoot(i)}_rebalance(e){let t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){let t=[];if(this._root.search(e,t),t.length>0){let r=t[0];for(let i=1;i<t.length;i++)t[i].low>r.low&&(r=t[i]);return r.event}}return null}forEach(e){if(this._root!==null){let t=[];this._root.traverse(r=>t.push(r)),t.forEach(r=>{r.event&&e(r.event)})}return this}forEachAtTime(e,t){if(this._root!==null){let r=[];this._root.search(e,r),r.forEach(i=>{i.event&&t(i.event)})}return this}forEachFrom(e,t){if(this._root!==null){let r=[];this._root.searchAfter(e,r),r.forEach(i=>{i.event&&t(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}},_u=class{constructor(e,t,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),!(this.low>e)&&this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}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 e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left!==null?e=this.left.height+1:this.right!==null&&(e=-(this.right.height+1)),e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var Ws=class extends Qt{constructor(e){super(),this.name="TimelineValue",this._timeline=new Wt({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){let t=this._timeline.get(e);return t?t.value:this._initialValue}};var se=class n extends j{constructor(){super(N(n.getDefaults(),arguments,["context"]))}connect(e,t=0,r=0){return sn(this,e,t,r),this}};var pe=class n extends se{constructor(){let e=N(n.getDefaults(),arguments,["mapping","length"]);super(e),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Rt(e.mapping)||e.mapping instanceof Float32Array?this.curve=Float32Array.from(e.mapping):hm(e.mapping)&&this.setMap(e.mapping,e.length)}static getDefaults(){return Object.assign($.getDefaults(),{length:1024})}setMap(e,t=1024){let r=new Float32Array(t);for(let i=0,o=t;i<o;i++){let s=i/(o-1)*2-1;r[i]=e(s,i)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){let t=["none","2x","4x"].some(r=>r.includes(e));z(t,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var un=class n extends se{constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="Pow",this._exponentScaler=this.input=this.output=new pe({context:this.context,mapping:this._expFunc(e.value),length:8192}),this._exponent=e.value}static getDefaults(){return Object.assign(se.getDefaults(),{value:1})}_expFunc(e){return t=>Math.pow(Math.abs(t),e)}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var _r=class n{constructor(e,t){this.id=n._eventId++,this._remainderTime=0;let r=Object.assign(n.getDefaults(),t);this.transport=e,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:rt,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){let t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};_r._eventId=0;var Us=class n extends _r{constructor(e,t){super(e,t),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(n.getDefaults(),t);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({},_r.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return di(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new ve(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){di(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 ve(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let t=this.transport.getTicksAtTime(e);Cr(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-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 zs=class n extends Ut{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="Transport",this._loop=new Ws(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Wt,this._repeatedEvents=new qs,this._syncedSignals=[],this._swingAmount=0,this._ppq=e.ppq,this._clock=new an({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=e.ppq,this.bpm.setValueAtTime(e.bpm,0),W(this,"bpm"),this._timeSignature=e.timeSignature,this._swingTicks=e.ppq/2}static getDefaults(){return Object.assign(Ut.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit("loopEnd",e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit("loopStart",e,this._clock.getSecondsAtTime(e)),this.emit("loop",e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!==0){let r=t%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(r*Math.PI)*this._swingAmount;e+=new ve(this.context,this._swingTicks*2/3).toSeconds()*i}fu(!0),this._timeline.forEachAtTime(t,r=>r.invoke(e)),fu(!1)}schedule(e,t){let r=new _r(this,{callback:e,time:new ke(this.context,t).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(e,t,r,i=1/0){let o=new Us(this,{callback:e,duration:new _e(this.context,i).toTicks(),interval:new _e(this.context,t).toTicks(),time:new ke(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(e,t){let r=new _r(this,{callback:e,once:!0,time:new ke(this.context,t).toTicks()});return this._addEvent(r,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){let t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){let t=this.toTicks(e);return this._timeline.forEachFrom(t,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(t,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(e,t)=>{t=new ve(this.context,t).toSeconds(),this.emit("start",e,t)}),this._clock.on("stop",e=>{this.emit("stop",e)}),this._clock.on("pause",e=>{this.emit("pause",e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let r;return et(t)&&(r=this.toTicks(t)),this._clock.start(e,r),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)!=="started"?this.start(e):this.stop(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){Rt(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new _e(this.context,this._loopStart,"i").toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new _e(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new ve(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){let e=this.now(),t=this._clock.getTicksAtTime(e);return new ve(this.context,t).toBarsBeatsSixteenths()}set position(e){let t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){let t=this.now(),r=this._clock.frequency.timeToTicks(e,t);this.ticks=r}get progress(){if(this.loop){let e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){let t=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(t),i=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,t),o=t+i;this.emit("stop",o),this._clock.setTicksAtTime(e,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!=="started")return 0;{let t=this.now(),r=this.getTicksAtTime(t),i=e-r%e;return this._clock.nextTickTime(i,t)}}syncSignal(e,t){let r=this.now(),i=this.bpm,o=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(e.units==="time"){let c=.015625/o,u=new Z(c),l=new un(-1),h=new Z(c);i.chain(u,l,h),i=h,o=1/o,s=[u,l,h]}t||(e.getValueAtTime(r)!==0?t=e.getValueAtTime(r)/o:t=0);let a=new Z(t);return i.connect(a),a.connect(e._param),s.push(a),this._syncedSignals.push({initial:e.value,nodes:s,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){let r=this._syncedSignals[t];r.signal===e&&(r.nodes.forEach(i=>i.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),mi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};Yr.mixin(zs);Ur(n=>{n.transport=new zs({context:n})});zr(n=>{n.transport.dispose()});var yt=class extends j{constructor(e){super(e),this.input=void 0,this._state=new ur("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=rt,this._syncedStop=rt,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new je({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,W(this,"volume"),this.onstop=e.onstop}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,onstop:rt,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(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,r){let i=Bt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")z(Cr(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,t,r);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){let o=this._state.get(i);o&&(o.offset=this.toSeconds(Ce(t,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,t,r)},i);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else ks(this.context),this._start(i,t,r);return this}stop(e){let t=Bt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)==="started"||et(this._state.getNextState("started",t))){if(this.log("stop",t),!this._synced)this._stop(t);else{let r=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(r)}this._state.cancel(t),this._state.setStateAtTime("stopped",t)}return this}restart(e,t,r){return e=this.toSeconds(e),this._state.getValueAtTime(e)==="started"&&(this._state.cancel(e),this._restart(e,t,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>{if(Cr(t,0)){let r=this._state.get(t);if(r&&r.state==="started"&&r.time!==t){let i=t-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-i),this._start(e,this.toSeconds(r.offset)+i,o)}}},this._syncedStop=e=>{let t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)==="started"&&this._stop(e)},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(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=rt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var lr=class n extends Xe{constructor(){let e=N(n.getDefaults(),arguments,["url","onload"]);super(e),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,ee(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new st({context:this.context,param:this._source.playbackRate,units:"positive",value:e.playbackRate}),this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this._buffer=new Lt(e.url,e.onload,e.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Xe.getDefaults(),{url:new Lt,loop:!1,loopEnd:0,loopStart:0,onload:rt,onerror:rt,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,r,i=1){z(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(e);this._startGain(o,i),this.loop?t=Ce(t,this.loopStart):t=Ce(t,0);let s=Math.max(this.toSeconds(t),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;io(s,a)&&(s=(s-c)%u+c),ue(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,di(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),et(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var gi=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["type"]);super(e),this.name="Noise",this._source=null,this._playbackRate=e.playbackRate,this.type=e.type,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(yt.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(e){if(z(e in Dm,"Noise: invalid type: "+e),this._type!==e&&(this._type=e,this.state==="started")){let t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){let t=Dm[this._type];this._source=new lr({url:t,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(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&(this._source.stop(this.toSeconds(e)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},ln=44100*5,vu=2,vr={brown:null,pink:null,white:null},Dm={get brown(){if(!vr.brown){let n=[];for(let e=0;e<vu;e++){let t=new Float32Array(ln);n[e]=t;let r=0;for(let i=0;i<ln;i++){let o=Math.random()*2-1;t[i]=(r+.02*o)/1.02,r=t[i],t[i]*=3.5}}vr.brown=new Lt().fromArray(n)}return vr.brown},get pink(){if(!vr.pink){let n=[];for(let e=0;e<vu;e++){let t=new Float32Array(ln);n[e]=t;let r,i,o,s,a,c,u;r=i=o=s=a=c=u=0;for(let l=0;l<ln;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,i=.99332*i+h*.0750759,o=.969*o+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,t[l]=r+i+o+s+a+c+u+h*.5362,t[l]*=.11,u=h*.115926}}vr.pink=new Lt().fromArray(n)}return vr.pink},get white(){if(!vr.white){let n=[];for(let e=0;e<vu;e++){let t=new Float32Array(ln);n[e]=t;for(let r=0;r<ln;r++)t[r]=Math.random()*2-1}vr.white=new Lt().fromArray(n)}return vr.white}};function me(n,e){return ht(this,void 0,void 0,function*(){let t=e/n.context.sampleRate,r=new He(1,t,n.context.sampleRate);return new n.constructor(Object.assign(n.get(),{frequency:2/t,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var ao=class n extends Xe{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],ee(this._oscillator,this._gainNode),this.type=e.type,this.frequency=new st({context:this.context,param:this._oscillator.frequency,units:"frequency",value:e.frequency}),this.detune=new st({context:this.context,param:this._oscillator.detune,units:"cents",value:e.detune}),W(this,["frequency","detune"])}static getDefaults(){return Object.assign(Xe.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(e){let t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Mt=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="Oscillator",this._oscillator=null,this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),W(this,"frequency"),this.detune=new $({context:this.context,units:"cents",value:e.detune}),W(this,"detune"),this._partials=e.partials,this._partialCount=e.partialCount,this._type=e.type,e.partialCount&&e.type!=="custom"&&(this._type=this.baseType+e.partialCount.toString()),this.phase=e.phase}static getDefaults(){return Object.assign(yt.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(e){let t=this.toSeconds(e),r=new ao({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(t)}_stop(e){let t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){let t=this.toSeconds(e);return this.log("restart",t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),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 n._periodicWaveCache.find(t=>t.phase===this._phase&&_m(t.partials,this._partials));{let e=n._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=e?e.partialCount:this._partialCount,e}}get type(){return this._type}set type(e){this._type=e;let t=["sine","square","sawtooth","triangle"].indexOf(e)!==-1;if(this._phase===0&&t)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=e);else{let r=this._getCachedPeriodicWave();if(et(r)){let{partials:i,wave:o}=r;this._wave=o,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[i,o]=this._getRealImaginary(e,this._phase),s=this.context.createPeriodicWave(i,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),n._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),n._periodicWaveCache.length>100&&n._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(e){this.partialCount&&this._type!=="custom"&&e!=="custom"?this.type=e+this.partialCount:this.type=e}get partialCount(){return this._partialCount}set partialCount(e){kt(e,0);let t=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(t=r[1]),this._type!=="custom")e===0?this.type=t:this.type=t+e.toString();else{let i=new Float32Array(e);this._partials.forEach((o,s)=>i[s]=o),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(e,t){let i=2048,o=new Float32Array(i),s=new Float32Array(i),a=1;if(e==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),e=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){let u=2/(c*Math.PI),l;switch(e){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: "+e)}l!==0?(o[c]=-l*Math.sin(t*c),s[c]=l*Math.cos(t*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(e,t,r){let i=0,o=e.length;for(let s=0;s<o;s++)i+=e[s]*Math.cos(s*r)+t[s]*Math.sin(s*r);return i}getInitialValue(){let[e,t]=this._getRealImaginary(this._type,0),r=0,i=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(e,t,s/o*i),r);return gu(-this._inverseFFT(e,t,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Mt._periodicWaveCache=[];var hn=class extends se{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new pe({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var zt=class n extends ${constructor(){let e=N(n.getDefaults(),arguments,["value"]);super(e),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Z({context:this.context,minValue:e.minValue,maxValue:e.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign($.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var co=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="AMOscillator",this._modulationScale=new hn({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Mt({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Mt({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new zt({context:this.context,units:"positive",value:e.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),W(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Mt.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}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 dn=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="FMOscillator",this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Mt({context:this.context,detune:e.detune,frequency:0,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.detune=this._carrier.detune,this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this._modulator=new Mt({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new zt({context:this.context,units:"positive",value:e.harmonicity}),this.modulationIndex=new zt({context:this.context,units:"positive",value:e.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),W(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Mt.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var yi=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","width"]);super(e),this.name="PulseOscillator",this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new pe({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new $({context:this.context,units:"audioRange",value:e.width}),this._triangle=new Mt({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.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),W(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(yt.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var uo=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","spread"]);super(e),this.name="FatOscillator",this._oscillators=[],this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this.detune=new $({context:this.context,units:"cents",value:e.detune}),this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=e.partials,this._partialCount=e.partialCount,this.count=e.count,W(this,["frequency","detune"])}static getDefaults(){return Object.assign(Mt.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){let t=-e/2,r=e/(this._oscillators.length-1);this._forEach((i,o)=>i.detune.value=t+r*o)}}get count(){return this._oscillators.length}set count(e){if(kt(e,1),this._oscillators.length!==e){this._forEach(t=>t.dispose()),this._oscillators=[];for(let t=0;t<e;t++){let r=new Mt({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):rt});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[t]=r}this.spread=this._spread,this.state==="started"&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((t,r)=>t.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type="custom",this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}};var lo=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","modulationFrequency"]);super(e),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new zt({context:this.context,value:2}),this._pulse=new yi({context:this.context,frequency:e.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Mt({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),W(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(yt.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var Em={am:co,fat:uo,fm:dn,oscillator:Mt,pulse:yi,pwm:lo},bi=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OmniOscillator",this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this.detune=new $({context:this.context,units:"cents",value:e.detune}),W(this,["frequency","detune"]),this.set(e)}static getDefaults(){return Object.assign(Mt.getDefaults(),dn.getDefaults(),co.getDefaults(),uo.getDefaults(),yi.getDefaults(),lo.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):e==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,"type")&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;let t=Em[e],r=this.now();if(this._oscillator){let i=this._oscillator;i.stop(r),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new t({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(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(t=this._oscillator.type),e==="fm"?this.type="fm"+t:e==="am"?this.type="am"+t:e==="fat"?this.type="fat"+t:e==="oscillator"?this.type=t:e==="pulse"?this.type="pulse":e==="pwm"&&(this.type="pwm")}_getOscType(e,t){return e instanceof Em[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&e!=="pulse"&&e!=="pwm"&&(this._oscillator.baseType=e)}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(e){this._getOscType(this._oscillator,"fat")&&te(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,"fat")&&te(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&ie(e)&&(this._oscillator.modulationType=e)}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 ht(this,arguments,void 0,function*(e=1024){return me(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function Hs(n,e=1/0){let t=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(o){kt(o,n,e),t.set(this,o)}})}}function fe(n,e=1/0){let t=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(o){kt(this.toSeconds(o),n,e),t.set(this,o)}})}}var ho=class n extends yt{constructor(){let e=N(n.getDefaults(),arguments,["url","onload"]);super(e),this.name="Player",this._activeSources=new Set,this._buffer=new Lt({onload:this._onload.bind(this,e.onload),onerror:e.onerror,reverse:e.reverse,url:e.url}),this.autostart=e.autostart,this._loop=e.loop,this._loopStart=e.loopStart,this._loopEnd=e.loopEnd,this._playbackRate=e.playbackRate,this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut}static getDefaults(){return Object.assign(yt.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:rt,onerror:rt,playbackRate:1,reverse:!1})}load(e){return ht(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=rt){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(e,t,r){return super.start(e,t,r),this}_start(e,t,r){this._loop?t=Ce(t,this._loopStart):t=Ce(t,0);let i=this.toSeconds(t),o=r;r=Ce(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,e=this.toSeconds(e);let a=new lr({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(e+s),this._state.setStateAtTime("stopped",e+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Bt(o)?a.start(e,i):a.start(e,i,s-this.toSeconds(this.fadeOut))}_stop(e){let t=this.toSeconds(e);this._activeSources.forEach(r=>r.stop(t))}restart(e,t,r){return super.restart(e,t,r),this}_restart(e,t,r){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(e),this._start(e,t,r)}seek(e,t){let r=this.toSeconds(t);if(this._state.getValueAtTime(r)==="started"){let i=this.toSeconds(e);this._stop(r),this._start(r,i)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&kt(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&kt(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){let t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;let t=this.now(),r=this._state.getNextState("stopped",t);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};oe([fe(0)],ho.prototype,"fadeIn",void 0);oe([fe(0)],ho.prototype,"fadeOut",void 0);var Zs=class extends se{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new pe({context:this.context,mapping:e=>Math.abs(e)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var he=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="Envelope",this._sig=new $({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve,this.decayCurve=e.decayCurve}static getDefaults(){return Object.assign(j.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(ie(e))return e;{let r;for(r in Xs)if(Xs[r][t]===e)return r;return e}}_setCurve(e,t,r){if(ie(r)&&Reflect.has(Xs,r)){let i=Xs[r];Ue(i)?e!=="_decayCurve"&&(this[e]=i[t]):this[e]=i}else if(Rt(r)&&e!=="_decayCurve")this[e]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(e){this._setCurve("_attackCurve","In",e)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(e){this._setCurve("_releaseCurve","Out",e)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(e){this._setCurve("_decayCurve","Out",e)}triggerAttack(e,t=1){this.log("triggerAttack",e,t),e=this.toSeconds(e);let i=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(e);if(s>0){let a=1/i;i=(1-s)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve==="linear")this._sig.linearRampTo(t,i,e);else if(this._attackCurve==="exponential")this._sig.targetRampTo(t,i,e);else{this._sig.cancelAndHoldAtTime(e);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,e,i,t)}if(o&&this.sustain<1){let a=t*this.sustain,c=e+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(e){this.log("triggerRelease",e),e=this.toSeconds(e);let t=this.getValueAtTime(e);if(t>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,e):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,e):(z(Rt(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,r,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,r=1){return t=this.toSeconds(t),this.triggerAttack(t,r),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}connect(e,t=0,r=0){return sn(this,e,t,r),this}asArray(){return ht(this,arguments,void 0,function*(e=1024){let t=e/this.context.sampleRate,r=new He(1,t,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=i+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/a,decay:t*this.toSeconds(this.decay)/a,release:t*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(t*(i+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};oe([fe(0)],he.prototype,"attack",void 0);oe([fe(0)],he.prototype,"decay",void 0);oe([Hs(0,1)],he.prototype,"sustain",void 0);oe([fe(0)],he.prototype,"release",void 0);var Xs=(()=>{let e,t,r=[];for(e=0;e<128;e++)r[e]=Math.sin(e/127*(Math.PI/2));let i=[],o=6.4;for(e=0;e<127;e++){t=e/127;let d=Math.sin(t*(Math.PI*2)*o-Math.PI/2)+1;i[e]=d/10+t*.83}i[127]=1;let s=[],a=5;for(e=0;e<128;e++)s[e]=Math.ceil(e/127*a)/a;let c=[];for(e=0;e<128;e++)t=e/127,c[e]=.5*(1-Math.cos(Math.PI*t));let u=[];for(e=0;e<128;e++){t=e/127;let d=Math.pow(t,3)*4+.2,m=Math.cos(d*Math.PI*2*t);u[e]=Math.abs(m*(1-t))}function l(d){let m=new Array(d.length);for(let f=0;f<d.length;f++)m[f]=1-d[f];return m}function h(d){return d.slice(0).reverse()}return{bounce:{In:l(u),Out:u},cosine:{In:r,Out:h(r)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:l(i)},sine:{In:c,Out:l(c)},step:{In:s,Out:l(s)}}})();var Ie=class n extends j{constructor(){let e=N(n.getDefaults(),arguments);super(e),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=t=>this._original_triggerRelease(t),this._volume=this.output=new je({context:this.context,volume:e.volume}),this.volume=this._volume.volume,W(this,"volume")}static getDefaults(){return Object.assign(j.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 e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){let r=this["_original_"+e]=this[e];this[e]=(...i)=>{let o=i[t],s=this.context.transport.schedule(a=>{i[t]=a,r.apply(this,i)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),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(e,t,r,i){let o=this.toSeconds(r),s=this.toSeconds(t);return this.triggerAttack(e,o,i),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var ge=class n extends Ie{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.portamento=e.portamento,this.onsilence=e.onsilence}static getDefaults(){return Object.assign(Ie.getDefaults(),{detune:0,onsilence:rt,portamento:0})}triggerAttack(e,t,r=1){this.log("triggerAttack",e,t,r);let i=this.toSeconds(t);return this._triggerEnvelopeAttack(i,r),this.setNote(e,i),this}triggerRelease(e){this.log("triggerRelease",e);let t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){let r=this.toSeconds(t),i=e instanceof le?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,o,r)}else this.frequency.setValueAtTime(i,r);return this}};oe([fe(0)],ge.prototype,"portamento",void 0);var pn=class n extends he{constructor(){super(N(n.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 hr=class n extends ge{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="Synth",this.oscillator=new bi(Object.assign({context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)},e.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new pn(Object.assign({context:this.context},e.envelope)),this.oscillator.chain(this.envelope,this.output),W(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ge.getDefaults(),{envelope:Object.assign(Ye(he.getDefaults(),Object.keys(j.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ye(bi.getDefaults(),[...Object.keys(yt.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+r+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var po=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type"]);super(e),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new st({context:this.context,units:"number",value:e.Q,param:this._filter.Q}),this.frequency=new st({context:this.context,units:"frequency",value:e.frequency,param:this._filter.frequency}),this.detune=new st({context:this.context,units:"cents",value:e.detune,param:this._filter.detune}),this.gain=new st({context:this.context,units:"decibels",convert:!1,value:e.gain,param:this._filter.gain}),this.type=e.type}static getDefaults(){return Object.assign(j.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){let t=new Float32Array(e);for(let s=0;s<e;s++){let c=Math.pow(s/e,2)*19980+20;t[s]=c}let r=new Float32Array(e),i=new Float32Array(e),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(t,r,i),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var Ir=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["frequency","type","rolloff"]);super(e),this.name="Filter",this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new $({context:this.context,units:"positive",value:e.Q}),this.frequency=new $({context:this.context,units:"frequency",value:e.frequency}),this.detune=new $({context:this.context,units:"cents",value:e.detune}),this.gain=new $({context:this.context,units:"decibels",convert:!1,value:e.gain}),this._type=e.type,this.rolloff=e.rolloff,W(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(j.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(e){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(r=>r.type=e)}get rolloff(){return this._rolloff}set rolloff(e){let t=te(e)?e:parseInt(e,10),r=[-12,-24,-48,-96],i=r.indexOf(t);z(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(i);for(let o=0;o<i;o++){let s=new po({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,Le(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){let t=new po({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(e).map(()=>1);return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((o,s)=>r[s]*=o)}),t.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),mi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var Qs=class n extends hr{constructor(){let e=N(n.getDefaults(),arguments);super(e),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=e.pitchDecay,this.octaves=e.octaves,W(this,["oscillator","envelope"])}static getDefaults(){return Ee(ge.getDefaults(),hr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(e,t){let r=this.toSeconds(t),i=this.toFrequency(e instanceof le?e.toFrequency():e),o=i*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(i,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};oe([Hs(0)],Qs.prototype,"octaves",void 0);oe([fe(0)],Qs.prototype,"pitchDecay",void 0);var km=new Set;function fn(n){km.add(n)}function Ks(n,e){let t=`registerProcessor("${n}", ${e})`;km.add(t)}var ox=`
20
20
  /**
21
21
  * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
22
22
  */
@@ -46,7 +46,7 @@
46
46
  };
47
47
  }
48
48
  }
49
- `;mn(nx);var ox=`
49
+ `;fn(ox);var sx=`
50
50
  /**
51
51
  * Abstract class for a single input/output processor.
52
52
  * has a 'generate' function which processes one sample at a time
@@ -113,7 +113,7 @@
113
113
  return !this.disposed;
114
114
  }
115
115
  };
116
- `;mn(ox);var sx=`
116
+ `;fn(sx);var ax=`
117
117
  /**
118
118
  * A multichannel buffer for use within an AudioWorkletProcessor as a delay line
119
119
  */
@@ -157,7 +157,7 @@
157
157
  return this.buffer[channel][readHead];
158
158
  }
159
159
  }
160
- `;mn(sx);var km="feedback-comb-filter",ax=`
160
+ `;fn(ax);var Lm="feedback-comb-filter",cx=`
161
161
  class FeedbackCombFilterWorklet extends SingleIOProcessor {
162
162
 
163
163
  constructor(options) {
@@ -187,7 +187,7 @@
187
187
  return delayedSample;
188
188
  }
189
189
  }
190
- `;Qs(km,ax);var Ks=class n extends Ie{constructor(){let e=N(n.getDefaults(),arguments,["voice","options"]);super(e),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=i=>this.releaseAll(i),z(!te(e.voice),"DEPRECATED: The polyphony count is no longer the first argument.");let t=e.voice.getDefaults();this.options=Object.assign(t,e.options),this.voice=e.voice,this.maxPolyphony=e.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(Ie.getDefaults(),{maxPolyphony:32,options:{},voice:hr})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(e){this._availableVoices.push(e);let t=this._activeVoices.findIndex(r=>r.voice===e);this._activeVoices.splice(t,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let e=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return z(e instanceof ge,"Voice must extend Monophonic class"),e.connect(this.output),this._voices.push(e),e}else li("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 e=this._availableVoices.shift(),t=this._voices.indexOf(e);this._voices.splice(t,1),this.context.isOffline||e.dispose()}}_triggerAttack(e,t,r){e.forEach(i=>{let o=new oo(this.context,i).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(i,t,r),this._activeVoices.push({midi:o,voice:s,released:!1}),this.log("triggerAttack",i,t))})}_triggerRelease(e,t){e.forEach(r=>{let i=new oo(this.context,r).toMidi(),o=this._activeVoices.find(({midi:s,released:a})=>s===i&&!a);o&&(o.voice.triggerRelease(t),o.released=!0,this.log("triggerRelease",r,t))})}_scheduleEvent(e,t,r,i){z(!this.disposed,"Synth was already disposed"),r<=this.now()?e==="attack"?this._triggerAttack(t,r,i):this._triggerRelease(t,r):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(e,t,r,i)},r-this.now())}triggerAttack(e,t,r){Array.isArray(e)||(e=[e]);let i=this.toSeconds(t);return this._scheduleEvent("attack",e,i,r),this}triggerRelease(e,t){Array.isArray(e)||(e=[e]);let r=this.toSeconds(t);return this._scheduleEvent("release",e,r),this}triggerAttackRelease(e,t,r,i){let o=this.toSeconds(r);if(this.triggerAttack(e,o,i),Rt(t)){z(Rt(e),"If the duration is an array, the notes must also be an array"),e=e;for(let s=0;s<e.length;s++){let a=t[Math.min(s,t.length-1)],c=this.toSeconds(a);z(c>0,"The duration must be greater than 0"),this.triggerRelease(e[s],o+c)}}else{let s=this.toSeconds(t);z(s>0,"The duration must be greater than 0"),this.triggerRelease(e,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(e){let t=Ye(e,["onsilence","context"]);return this.options=Ee(this.options,t),this._voices.forEach(r=>r.set(t)),this._dummyVoice.set(t),this}get(){return this._dummyVoice.get()}releaseAll(e){let t=this.toSeconds(e);return this._activeVoices.forEach(({voice:r})=>{r.triggerRelease(t)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(e=>e.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}};var Js=class n extends Ie{constructor(){let e=N(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(e),this.name="Sampler",this._activeSources=new Map;let t={};Object.keys(e.urls).forEach(r=>{let i=parseInt(r,10);if(z(eo(r)||te(i)&&isFinite(i),`url key is neither a note or midi pitch: ${r}`),eo(r)){let o=new le(this.context,r).toMidi();t[o]=e.urls[r]}else te(i)&&isFinite(i)&&(t[i]=e.urls[i])}),this._buffers=new an({urls:t,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.attack=e.attack,this.release=e.release,this.curve=e.curve,this._buffers.loaded&&Promise.resolve().then(e.onload)}static getDefaults(){return Object.assign(Ie.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:rt,onerror:rt,release:.1,urls:{}})}_findClosest(e){let r=0;for(;r<96;){if(this._buffers.has(e+r))return-r;if(this._buffers.has(e-r))return r;r++}throw new Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,r=1){return this.log("triggerAttack",e,t,r),Array.isArray(e)||(e=[e]),e.forEach(i=>{let o=yu(new le(this.context,i).toFrequency()),s=Math.round(o),a=o-s,c=this._findClosest(s),u=s-c,l=this._buffers.get(u),h=mi(c+a),d=new lr({url:l,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);d.start(t,0,l.duration/h,r),Rt(this._activeSources.get(s))||this._activeSources.set(s,[]),this._activeSources.get(s).push(d),d.onended=()=>{if(this._activeSources&&this._activeSources.has(s)){let m=this._activeSources.get(s),f=m.indexOf(d);f!==-1&&m.splice(f,1)}}}),this}triggerRelease(e,t){return this.log("triggerRelease",e,t),Array.isArray(e)||(e=[e]),e.forEach(r=>{let i=new le(this.context,r).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){let o=this._activeSources.get(i);t=this.toSeconds(t),o.forEach(s=>{s.stop(t)}),this._activeSources.set(i,[])}}),this}releaseAll(e){let t=this.toSeconds(e);return this._activeSources.forEach(r=>{for(;r.length;)r.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(e,t,r,i=1){let o=this.toSeconds(r);return this.triggerAttack(e,o,i),Rt(t)?(z(Rt(e),"notes must be an array when duration is array"),e.forEach((s,a)=>{let c=t[Math.min(a,t.length-1)];this.triggerRelease(s,o+this.toSeconds(c))})):this.triggerRelease(e,o+this.toSeconds(t)),this}add(e,t,r){if(z(eo(e)||isFinite(e),`note must be a pitch or midi: ${e}`),eo(e)){let i=new le(this.context,e).toMidi();this._buffers.add(i,t,r)}else this._buffers.add(e,t,r);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(t=>t.dispose())}),this._activeSources.clear(),this}};oe([fe(0)],Js.prototype,"attack",void 0);oe([fe(0)],Js.prototype,"release",void 0);var fn=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["fade"]);super(e),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Hs({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 $({context:this.context,units:"normalRange",value:e.fade}),W(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",ee(this._split,this.a.gain,0),ee(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(j.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 ye=class extends j{constructor(e){super(e),this.name="Effect",this._dryWet=new fn({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(e.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],W(this,"wet")}static getDefaults(){return Object.assign(j.getDefaults(),{wet:1})}connectEffect(e){return this._internalChannels.push(e),this.effectSend.chain(e,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};var po=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["pan"]);super(e),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new st({context:this.context,param:this._panner.pan,value:e.pan,minValue:-1,maxValue:1}),this._panner.channelCount=e.channelCount,this._panner.channelCountMode="explicit",W(this,"pan")}static getDefaults(){return Object.assign(j.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var jm="bit-crusher",mx=`
190
+ `;Ks(Lm,cx);var Js=class n extends Ie{constructor(){let e=N(n.getDefaults(),arguments,["voice","options"]);super(e),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=i=>this.releaseAll(i),z(!te(e.voice),"DEPRECATED: The polyphony count is no longer the first argument.");let t=e.voice.getDefaults();this.options=Object.assign(t,e.options),this.voice=e.voice,this.maxPolyphony=e.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(Ie.getDefaults(),{maxPolyphony:32,options:{},voice:hr})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(e){this._availableVoices.push(e);let t=this._activeVoices.findIndex(r=>r.voice===e);this._activeVoices.splice(t,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let e=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return z(e instanceof ge,"Voice must extend Monophonic class"),e.connect(this.output),this._voices.push(e),e}else hi("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 e=this._availableVoices.shift(),t=this._voices.indexOf(e);this._voices.splice(t,1),this.context.isOffline||e.dispose()}}_triggerAttack(e,t,r){e.forEach(i=>{let o=new so(this.context,i).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(i,t,r),this._activeVoices.push({midi:o,voice:s,released:!1}),this.log("triggerAttack",i,t))})}_triggerRelease(e,t){e.forEach(r=>{let i=new so(this.context,r).toMidi(),o=this._activeVoices.find(({midi:s,released:a})=>s===i&&!a);o&&(o.voice.triggerRelease(t),o.released=!0,this.log("triggerRelease",r,t))})}_scheduleEvent(e,t,r,i){z(!this.disposed,"Synth was already disposed"),r<=this.now()?e==="attack"?this._triggerAttack(t,r,i):this._triggerRelease(t,r):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(e,t,r,i)},r-this.now())}triggerAttack(e,t,r){Array.isArray(e)||(e=[e]);let i=this.toSeconds(t);return this._scheduleEvent("attack",e,i,r),this}triggerRelease(e,t){Array.isArray(e)||(e=[e]);let r=this.toSeconds(t);return this._scheduleEvent("release",e,r),this}triggerAttackRelease(e,t,r,i){let o=this.toSeconds(r);if(this.triggerAttack(e,o,i),Rt(t)){z(Rt(e),"If the duration is an array, the notes must also be an array"),e=e;for(let s=0;s<e.length;s++){let a=t[Math.min(s,t.length-1)],c=this.toSeconds(a);z(c>0,"The duration must be greater than 0"),this.triggerRelease(e[s],o+c)}}else{let s=this.toSeconds(t);z(s>0,"The duration must be greater than 0"),this.triggerRelease(e,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(e){let t=Ye(e,["onsilence","context"]);return this.options=Ee(this.options,t),this._voices.forEach(r=>r.set(t)),this._dummyVoice.set(t),this}get(){return this._dummyVoice.get()}releaseAll(e){let t=this.toSeconds(e);return this._activeVoices.forEach(({voice:r})=>{r.triggerRelease(t)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(e=>e.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}};var $s=class n extends Ie{constructor(){let e=N(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(e),this.name="Sampler",this._activeSources=new Map;let t={};Object.keys(e.urls).forEach(r=>{let i=parseInt(r,10);if(z(ro(r)||te(i)&&isFinite(i),`url key is neither a note or midi pitch: ${r}`),ro(r)){let o=new le(this.context,r).toMidi();t[o]=e.urls[r]}else te(i)&&isFinite(i)&&(t[i]=e.urls[i])}),this._buffers=new cn({urls:t,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.attack=e.attack,this.release=e.release,this.curve=e.curve,this._buffers.loaded&&Promise.resolve().then(e.onload)}static getDefaults(){return Object.assign(Ie.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:rt,onerror:rt,release:.1,urls:{}})}_findClosest(e){let r=0;for(;r<96;){if(this._buffers.has(e+r))return-r;if(this._buffers.has(e-r))return r;r++}throw new Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,r=1){return this.log("triggerAttack",e,t,r),Array.isArray(e)||(e=[e]),e.forEach(i=>{let o=bu(new le(this.context,i).toFrequency()),s=Math.round(o),a=o-s,c=this._findClosest(s),u=s-c,l=this._buffers.get(u),h=fi(c+a),d=new lr({url:l,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);d.start(t,0,l.duration/h,r),Rt(this._activeSources.get(s))||this._activeSources.set(s,[]),this._activeSources.get(s).push(d),d.onended=()=>{if(this._activeSources&&this._activeSources.has(s)){let m=this._activeSources.get(s),f=m.indexOf(d);f!==-1&&m.splice(f,1)}}}),this}triggerRelease(e,t){return this.log("triggerRelease",e,t),Array.isArray(e)||(e=[e]),e.forEach(r=>{let i=new le(this.context,r).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){let o=this._activeSources.get(i);t=this.toSeconds(t),o.forEach(s=>{s.stop(t)}),this._activeSources.set(i,[])}}),this}releaseAll(e){let t=this.toSeconds(e);return this._activeSources.forEach(r=>{for(;r.length;)r.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(e,t,r,i=1){let o=this.toSeconds(r);return this.triggerAttack(e,o,i),Rt(t)?(z(Rt(e),"notes must be an array when duration is array"),e.forEach((s,a)=>{let c=t[Math.min(a,t.length-1)];this.triggerRelease(s,o+this.toSeconds(c))})):this.triggerRelease(e,o+this.toSeconds(t)),this}add(e,t,r){if(z(ro(e)||isFinite(e),`note must be a pitch or midi: ${e}`),ro(e)){let i=new le(this.context,e).toMidi();this._buffers.add(i,t,r)}else this._buffers.add(e,t,r);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(t=>t.dispose())}),this._activeSources.clear(),this}};oe([fe(0)],$s.prototype,"attack",void 0);oe([fe(0)],$s.prototype,"release",void 0);var gn=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["fade"]);super(e),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Zs({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 $({context:this.context,units:"normalRange",value:e.fade}),W(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",ee(this._split,this.a.gain,0),ee(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(j.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 ye=class extends j{constructor(e){super(e),this.name="Effect",this._dryWet=new gn({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(e.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],W(this,"wet")}static getDefaults(){return Object.assign(j.getDefaults(),{wet:1})}connectEffect(e){return this._internalChannels.push(e),this.effectSend.chain(e,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};var mo=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["pan"]);super(e),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new st({context:this.context,param:this._panner.pan,value:e.pan,minValue:-1,maxValue:1}),this._panner.channelCount=e.channelCount,this._panner.channelCountMode="explicit",W(this,"pan")}static getDefaults(){return Object.assign(j.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var Pm="bit-crusher",fx=`
191
191
  class BitCrusherWorklet extends SingleIOProcessor {
192
192
 
193
193
  static get parameterDescriptors() {
@@ -206,8 +206,8 @@
206
206
  return val;
207
207
  }
208
208
  }
209
- `;Qs(jm,mx);var Hr=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["channels"]);super(e),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(e.channels)}static getDefaults(){return Object.assign(j.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var EJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var GJ=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var ea=class n extends ye{constructor(){let e=N(n.getDefaults(),arguments,["decay"]);super(e),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let t=this.toSeconds(e.decay);kt(t,.001),this._decay=t;let r=this.toSeconds(e.preDelay);kt(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(ye.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(e){e=this.toSeconds(e),kt(e,.001),this._decay=e,this.generate()}get preDelay(){return this._preDelay}set preDelay(e){e=this.toSeconds(e),kt(e,0),this._preDelay=e,this.generate()}generate(){return ht(this,void 0,void 0,function*(){let e=this.ready,t=new He(2,this._decay+this._preDelay,this.context.sampleRate),r=new fi({context:t}),i=new fi({context:t}),o=new Hr({context:t});r.connect(o,0,0),i.connect(o,0,1);let s=new Z({context:t}).toDestination();o.connect(s),r.start(0),i.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=t.render();return this.ready=a.then(rt),yield e,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var gn=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["solo"]);super(e),this.name="Solo",this.input=this.output=new Z({context:this.context}),n._allSolos.has(this.context)||n._allSolos.set(this.context,new Set),n._allSolos.get(this.context).add(this),this.solo=e.solo}static getDefaults(){return Object.assign(j.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(e){e?this._addSolo():this._removeSolo(),n._allSolos.get(this.context).forEach(t=>t._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){n._soloed.has(this.context)||n._soloed.set(this.context,new Set),n._soloed.get(this.context).add(this)}_removeSolo(){n._soloed.has(this.context)&&n._soloed.get(this.context).delete(this)}_isSoloed(){return n._soloed.has(this.context)&&n._soloed.get(this.context).has(this)}_noSolos(){return!n._soloed.has(this.context)||n._soloed.has(this.context)&&n._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(),n._allSolos.get(this.context).delete(this),this._removeSolo(),this}};gn._allSolos=new Map;gn._soloed=new Map;var ra=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["pan","volume"]);super(e),this.name="PanVol",this._panner=this.input=new po({context:this.context,pan:e.pan,channelCount:e.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new je({context:this.context,volume:e.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=e.mute,W(this,["pan","volume"])}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var Tu=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["volume","pan"]);super(e),this.name="Channel",this._solo=this.input=new gn({solo:e.solo,context:this.context}),this._panVol=this.output=new ra({context:this.context,pan:e.pan,volume:e.volume,mute:e.mute,channelCount:e.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),W(this,["pan","volume"])}static getDefaults(){return Object.assign(j.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(e){return n.buses.has(e)||n.buses.set(e,new Z({context:this.context})),n.buses.get(e)}send(e,t=0){let r=this._getBus(e),i=new Z({context:this.context,units:"decibels",gain:t});return this.connect(i),i.connect(r),i}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};Tu.buses=new Map;var Oit=Vt().transport;var Rit=Vt().destination,Mit=Vt().destination;var Dit=Vt().listener;var Eit=Vt().draw;var kit=Vt();var Nu=class{constructor(){p(this,"audioSource");try{let e=new ea({decay:3,wet:.4}).toDestination(),t=new Ir(800,"lowpass").connect(e);this.audioSource=new Ks(hr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(t)}catch(e){this.audioSource=void 0,console.error(e)}}getName(){return"Synthesizer"}playNote(e,t,r){try{this.audioSource&&(this.audioSource.volume.value=ms(r),this.audioSource.triggerAttackRelease(e,t))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(e){}}},Ou=new Nu;ti();function _x(n){return typeof n=="string"?n:(typeof n=="number"&&(n=U.getChromaticNote(n)),n.format(0,0))}var ia=[Ou],yn=Ou,vx=(function(e,t,r){var o;let i=parseInt((o=r.split("/")[1])!=null?o:"4");return 60*(1/e)/(t*(1/i))})(2,80,"4/4"),Ix=1,na=!1;function Sx(){return ia.map(n=>n.getName())}function wx(){return yn.getName()}function Tx(n){(A.Is.isArray(n)?n:[n]).forEach(e=>{if(!A.Obj.hasProperties(e,["getName","playNote","stop"])||!A.Is.isFunction(e.getName)||!A.Is.isFunction(e.playNote)||!A.Is.isFunction(e.stop))throw new O(7,"Invalid instrument object: "+e);ia.some(t=>t.getName()===e.getName())?console.warn(`Instrument "${e.getName()}" already registered!`):ia.push(e),Fm(e.getName())})}function Fm(n){if(n===yn.getName())return;yn.stop();let e=ia.find(t=>t.getName()===n);e&&(yn=e)}function oa(n,e,t){na||yn.playNote(_x(n),e!=null?e:vx,t!=null?t:Ix)}function sa(){yn.stop()}function Nx(){sa(),na=!0}function Ox(){na=!1}function Rx(){return na}var Gu={};Oi(Gu,{Annotation:()=>An,Arpeggio:()=>Zr,Clef:()=>bi,Connective:()=>Xr,DivRect:()=>F,DocumentBuilder:()=>Or,DynamicsAnnotation:()=>Cn,Fermata:()=>yo,Label:()=>bo,LyricsAlign:()=>go,LyricsHyphen:()=>xn,MAccidental:()=>Ao,MArpeggio:()=>wo,MBarLineLeft:()=>Fo,MBarLineRight:()=>Po,MBeamGroup:()=>qo,MConnective:()=>Yo,MDocument:()=>Nr,MEnding:()=>Vo,MExtensionLine:()=>zo,MFermata:()=>Uo,MHeader:()=>Jo,MImage:()=>xo,MLyrics:()=>Do,MMeasure:()=>Zo,MNoteGroup:()=>Oo,MPlaybackButtons:()=>Vu,MPlayer:()=>Rn,MRenderer:()=>Bu,MRest:()=>To,MRhythmColumn:()=>Eo,MScoreRow:()=>Ko,MSpecialText:()=>ko,MStaff:()=>Xo,MStaffBeamGroup:()=>Wo,MStaffNoteGroup:()=>Ro,MStaffRest:()=>No,MStaffSignature:()=>Io,MStaffTabBarLine:()=>Bo,MTab:()=>Qo,MTabNoteGroup:()=>Mo,MTabRhythm:()=>Ho,MTabSignature:()=>So,MText:()=>Co,MusicInterface:()=>pt,Navigation:()=>Je,NoteAnchor:()=>Pe,PlayState:()=>ua,ScoreEvent:()=>ts,ScoreObjectEvent:()=>Ai,ScoreStaffPosEvent:()=>xi,StaffPreset:()=>bn,Stem:()=>Qe,TempoAnnotation:()=>_n,TieType:()=>Ke,VerticalPosition:()=>fo,getStringNumbers:()=>aa,getVerseNumbers:()=>ca,getVoiceIds:()=>Kt});var F=class n{constructor(...e){p(this,"left");p(this,"centerX");p(this,"right");p(this,"top");p(this,"centerY");p(this,"bottom");if(e.length===6)this.left=e[0],this.centerX=e[1],this.right=e[2],this.top=e[3],this.centerY=e[4],this.bottom=e[5];else if(e.length===4)this.left=e[0],this.right=e[1],this.centerX=(this.left+this.right)/2,this.top=e[2],this.bottom=e[3],this.centerY=(this.top+this.bottom)/2;else if(e.length===0)this.left=this.centerX=this.right=0,this.top=this.centerY=this.bottom=0;else throw new O(1,`Invalid DivRect args: ${e}`)}static create(e,t,r,i){return new n(e,e+r,t,t+i)}static createCentered(e,t,r,i){return new n(e-r/2,e+r/2,t-i/2,t+i/2)}static createSections(e,t,r,i){return new n(-e,0,t,-r,0,i)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.centerX-this.left}get rightw(){return this.right-this.centerX}get toph(){return this.centerY-this.top}get bottomh(){return this.bottom-this.centerY}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}static overlap(e,t){return e.right>t.left&&e.left<t.right&&e.bottom>t.top&&e.top<t.bottom}static overlapX(e,t){return e.right>t.left&&e.left<t.right}static equals(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.left===t.left&&e.centerX===t.centerX&&e.right===t.right&&e.top===t.top&&e.centerY===t.centerY&&e.bottom===t.bottom}static equalsFrame(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}copy(){return new n(this.left,this.centerX,this.right,this.top,this.centerY,this.bottom)}offsetInPlace(e,t){return this.left+=e,this.centerX+=e,this.right+=e,this.top+=t,this.centerY+=t,this.bottom+=t,this}offsetCopy(e,t){return this.copy().offsetInPlace(e,t)}expandInPlace(e){return this.left=Math.min(this.left,e.left),this.right=Math.max(this.right,e.right),this.top=Math.min(this.top,e.top),this.bottom=Math.max(this.bottom,e.bottom),this}expandCopy(e){return this.copy().expandInPlace(e)}clipInPlace(e){return this.left=Math.max(this.left,e.left),this.right=Math.min(this.right,e.right),this.centerX=A.Math.clamp(this.centerX,this.left,this.right),this.top=Math.max(this.top,e.top),this.bottom=Math.min(this.bottom,e.bottom),this.centerY=A.Math.clamp(this.centerY,this.top,this.bottom),this}clipCopy(e){return this.copy().clipInPlace(e)}scaleInPlace(e,t){return t=t!=null?t:e,this.left=this.centerX-this.leftw*e,this.right=this.centerX+this.rightw*e,this.top=this.centerY-this.toph*t,this.bottom=this.centerY+this.bottomh*t,this}scaleCopy(e,t){return this.copy().scaleInPlace(e,t)}getRect(){return this}};var bn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(bn||{}),bi=(t=>(t.G="G",t.F="F",t))(bi||{});function Kt(){return[0,1,2,3]}function aa(){return[1,2,3,4,5,6]}function ca(){return[1,2,3]}var Qe=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(Qe||{}),Zr=(t=>(t.Up="up",t.Down="down",t))(Zr||{}),Ke=(t=>(t.Stub="stub",t.ToMeasureEnd="toMeasureEnd",t))(Ke||{}),Pe=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(Pe||{}),Xr=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(Xr||{}),fo=(i=>(i.Auto="auto",i.Above="above",i.Below="below",i.Both="both",i))(fo||{}),go=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(go||{}),xn=(t=>(t.Hyphen="-",t.Extender="---",t))(xn||{}),yo=(t=>(t.AtNote="atNote",t.AtMeasureEnd="atMeasureEnd",t))(yo||{}),Je=(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))(Je||{}),An=(t=>(t.Dynamics="dynamics",t.Tempo="tempo",t))(An||{}),Cn=(d=>(d.cresc="cresc.",d.decresc="decresc.",d.dim="dim.",d.ppp="ppp",d.pp="pp",d.p="p",d.mp="mp",d.m="m",d.mf="mf",d.f="f",d.ff="ff",d.fff="fff",d))(Cn||{}),_n=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(_n||{}),bo=(t=>(t.Note="note",t.Chord="chord",t))(bo||{}),ua=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(ua||{});var la=class{constructor(e){p(this,"head");p(this,"tail");this.head=e,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(e){this.tail.push(e)}detachTail(e){let t=this.tail.indexOf(e);t>=0&&this.tail.splice(t,1)}},tt=class{constructor(e){this.parent=e;p(this,"anchoredLayoutObjects",[]);p(this,"link");p(this,"rect",new F);p(this,"needRectUpdate",!0)}getParent(){return this.parent}requestRectUpdate(){this.needRectUpdate=!0}updateRect(){}getRect(){return this.needRectUpdate&&(this.updateRect(),this.needRectUpdate=!1),this.rect}getShapeRects(){return[this.rect]}addAnchoredLayoutObject(e){this.anchoredLayoutObjects.push(e)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(e){this.link=e}getLink(){return this.link}isLinked(){return this.link!==null}};var Bm={DrawDebugRects:!1,DisableBeams:!1},ct={DocumentScale:1,DocumentMinWidth:75,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,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var Vm="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 Gm="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 Mx="#55cc55",Dx="#55cc55",Ex="#44aa44",Ru=new Map([[0,{src:Vm}],[1,{src:Gm}]]);function kx(n,e){return!n&&!e?!0:!n||!e?!1:n.scoreRow===e.scoreRow&&n.diatonicId===e.diatonicId}function Lx(n,e){return!n&&!e?!0:!n||!e?!1:n.length===e.length&&n.every((t,r)=>t===e[r])}var ha=class{constructor(e){this.mi=e;p(this,"devicePixelRatio");p(this,"fontSize");p(this,"unitSize");p(this,"lineWidth");p(this,"beamThickness");p(this,"scoreEventListener");p(this,"canvas");p(this,"ctx");p(this,"mdoc");p(this,"cursorRect");p(this,"mousePos");p(this,"curStaffPos");p(this,"curObjects");p(this,"hilightedStaffPos");p(this,"hilightedObj");p(this,"usingTouch",!1);p(this,"onClickFn");p(this,"onMouseMoveFn");p(this,"onMouseLeaveFn");p(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=Pn.FontSize*ct.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this.lineWidth=this.unitSize*.2,this.beamThickness=this.unitSize*.8,Ru.forEach(t=>{if(t.finished!==!0){let r=new Image;r.src=t.src,r.onload=()=>{t.img=r,this.finishImageAsset(t)},r.onerror=()=>{throw this.finishImageAsset(t),new O(6,"Failed to load image: "+t.src)}}}),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 e;return(e=this.mdoc)==null?void 0:e.getMusicObject()}finishImageAsset(e){e.finished=!0,Array.from(Ru).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(e){var t;return(t=Ru.get(e))==null?void 0:t.img}setDocument(e){if(this.mdoc===e)return;this.updateCursorRect(void 0);let t=this.mdoc;this.mdoc=e,t&&t.getMusicObject().setRenderer(void 0),e&&e.getMusicObject().setRenderer(this)}setCanvas(e){var t,r;this.canvas!==e&&(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=e,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=(t=this.canvas)==null?void 0:t.getContext("2d"))!=null?r:void 0}setScoreEventListener(e){this.scoreEventListener=e}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(e){return new ol(e.offsetX,e.offsetY)}updateCurStaffPos(e,t){let r=!kx(e,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new xi("leave",this.getMusicInterface(),i.getMusicInterface(),o))}if(r&&e&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=e;this.scoreEventListener(new xi("enter",this.getMusicInterface(),i.getMusicInterface(),o))}if(t&&e&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=e;this.scoreEventListener(new xi("click",this.getMusicInterface(),i.getMusicInterface(),o))}return this.curStaffPos=e,r}updateCurObjects(e,t){let r=!Lx(e,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ai("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&e&&e.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ai("enter",this.getMusicInterface(),e.map(i=>i.getMusicInterface()))),t&&e&&e.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ai("click",this.getMusicInterface(),e.map(i=>i.getMusicInterface()))),this.curObjects=e,r}onClick(e){let{doc:t}=this;if(!(!this.needMouseInput()||!t)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(e)),this.scoreEventListener)){let r=t.pick(this.mousePos.x,this.mousePos.y),i=t.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(e){let{doc:t}=this;if(!(!this.needMouseInput()||!t)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(e)),!this.usingTouch)){let r=t.pick(this.mousePos.x,this.mousePos.y),i=t.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(e){if(!this.needMouseInput())return;this.mousePos=void 0;let t=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(t||r)&&this.draw()}onTouchEnd(e){this.usingTouch=!0}onLoad(){this.doc&&(this.doc.requestFullLayout(),this.draw())}hilightObject(e){this.hilightedObj=e}hilightStaffPos(e){this.hilightedStaffPos=e}updateCursorRect(e){this.cursorRect=e,this.draw()}updateCanvasSize(){let{canvas:e,doc:t}=this;if(e&&t){let r=t.getRect(),i=r.width+1,o=r.height+1;e.width=i,e.height=o,e.style.width=i/this.devicePixelRatio+"px",e.style.height=o/this.devicePixelRatio+"px"}}draw(){let{ctx:e,doc:t}=this;!e||!t||(t.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),t.drawContent())}drawHilightStaffPosRect(){let e=this.getCanvasContext(),{mousePos:t,hilightedStaffPos:r,unitSize:i}=this;if(!e||!r)return;let{scoreRow:o,diatonicId:s}=r,a=o.getStaff(s);a&&(e.fillStyle=Mx,e.fillRect(0,a.getDiatonicIdY(s)-i,e.canvas.width,2*i),t!==void 0&&this.drawLedgerLines(a,s,t.x))}drawHilightObjectRect(){let e=this.getCanvasContext(),{hilightedObj:t}=this;if(!e||!t)return;let r=t.getRect();e.strokeStyle=Dx,e.strokeRect(r.left,r.top,r.width,r.height)}drawPlayCursor(){let{cursorRect:e,lineWidth:t}=this;e&&this.drawLine(e.centerX,e.top,e.centerX,e.bottom,Ex,t*2)}txFromScreenCoord(e){return e.mul(this.devicePixelRatio)}txToScreenCoord(e){return e.div(this.devicePixelRatio)}getCanvasContext(){return this.ctx}clearCanvas(){let e=this.getCanvasContext();e&&e.clearRect(0,0,e.canvas.width,e.canvas.height)}getTextWidth(e,t){let r=this.getCanvasContext();if(r){let i=r.font;r.font=t;let o=r.measureText(e);return r.font=i,o.width}else return A.Dom.getCanvasTextWidth(e,t)}drawDebugRect(e){if(!Bm.DrawDebugRects)return;let t=this.getCanvasContext();t&&(t.lineWidth=1,t.strokeStyle="red",t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.stroke())}fillCircle(e,t,r,i){let o=this.getCanvasContext();o&&(i!==void 0&&(o.fillStyle=i),o.beginPath(),o.arc(e,t,r,0,2*Math.PI),o.fill())}drawLine(e,t,r,i,o,s){let a=this.getCanvasContext();a&&(a.strokeStyle=o!=null?o:"black",a.lineWidth=s!=null?s:this.lineWidth,a.beginPath(),a.moveTo(e,t),a.lineTo(r,i),a.stroke())}drawPartialLine(e,t,r,i,o,s,a,c){let u=this.getCanvasContext();if(u){let l=e+(r-e)*o,h=t+(i-t)*o,d=e+(r-e)*s,m=t+(i-t)*s;u.strokeStyle=a!=null?a:"black",u.lineWidth=c!=null?c:this.lineWidth,u.beginPath(),u.moveTo(l,h),u.lineTo(d,m),u.stroke()}}drawLedgerLines(e,t,r){let{unitSize:i}=this,o=i*ct.LedgerLineWidth;if(t>=e.topLineDiatonicId+2){for(let s=e.topLineDiatonicId+2;s<=t;s+=2)if(e.containsDiatonicId(s)){let a=e.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}else if(t<=e.bottomLineDiatonicId-2){for(let s=e.bottomLineDiatonicId-2;s>=t;s-=2)if(e.containsDiatonicId(s)){let a=e.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}}getRestRect(e){let{unitSize:t}=this,{flagCount:r}=_t.get(Ae(e+"n")),i=0,o=0,s=0,a=0;if(_t.equals(e,"1n"))i=t,o=t,s=0,a=t;else if(_t.equals(e,"2n"))i=t,o=t,s=t,a=0;else if(_t.equals(e,"4n"))i=t*1,o=t*1,s=t*3.2,a=t*3;else{let c=1-r%2;i=t*(1+r*.25),o=t*(1+r*.125),s=t*(.5+r-c),a=t*(1+r+c)}return new F(-i,0,o,-s,0,a)}drawRest(e,t,r,i){let o=this.getCanvasContext();if(!o)return;let{unitSize:s,lineWidth:a}=this,{flagCount:c}=_t.get(Ae(e+"n"));if(o.strokeStyle=o.fillStyle=i,o.lineWidth=a,_t.equals(e,"1n"))o.fillRect(t-s,r,s*2,s);else if(_t.equals(e,"2n"))o.fillRect(t-s,r-s,s*2,s);else if(_t.equals(e,"4n"))o.beginPath(),o.moveTo(t-s*.6,r-s*3.2),o.lineTo(t+s*.7,r-s*1.5),o.quadraticCurveTo(t-s*.8,r-s*.5,t+s*1,r+s*1.5),o.lineTo(t-s*1,r-s*.75),o.quadraticCurveTo(t+s*.2,r-s*1.5,t-s*.6,r-s*3.2),o.moveTo(t+s*1,r+s*1.5),o.quadraticCurveTo(t-s*.8,r+s*1,t-s*.2,r+s*2.8),o.bezierCurveTo(t-s*1.8,r+s*1.5,t-s*.6,r-s*.2,t+s*.9,r+s*1.5),o.fill(),o.stroke();else if(c>0){let u=1-c%2,l=d=>t+(-d*.25+.5)*s,h=d=>r+(d+u)*s;o.beginPath(),o.moveTo(l(1+c),h(1+c)),o.lineTo(l(-.5-c),h(-.5-c)),o.stroke();for(let d=0;d<c;d++){let m=c-d*2;o.beginPath(),o.moveTo(l(m-2.5),h(m-2.5)),o.quadraticCurveTo(l(m-.5)+s*.25,h(m-1.5),l(m-1.5)-s*1.5,h(m-1.5)),o.stroke(),o.beginPath(),o.arc(l(m-2)-s*1.5,h(m-2),s*.5,0,Math.PI*2),o.fill()}}}drawFlag(e,t){let r=this.getCanvasContext();if(!r)return;let i=e.left,s=e.right-i,a=t==="up"?e.top:e.bottom,c=t==="up"?e.bottom:e.top;r.beginPath(),r.moveTo(i,a),r.bezierCurveTo(i,a*.75+c*.25,i+s*1.5,a*.5+c*.5,i+s*.5,c),r.stroke()}};var da=class{constructor(e){this.measure=e;p(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(e){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===U.getDiatonicClass(e));return r?r.accidental:void 0}setAccidental(e){this.accidentalByDiatonicId[e.diatonicId]=e.accidental}needAccidental(e){var r,i;let t=(i=(r=this.accidentalByDiatonicId[e.diatonicId])!=null?r:this.getAccidentalFromKeySignature(e.diatonicId))!=null?i:0;return e.accidental!==t}};var pa=class extends tt{constructor(t,r,i,o,s){super(t);this.image=r;this.anchorX=i;this.anchorY=o;this.imageScale=s;p(this,"mi");this.mi=new xo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{anchorX:r,anchorY:i,image:o,imageScale:s}=this,{unitSize:a}=t;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=F.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new F}}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let i=this.rect;t.drawDebugRect(i);try{r.drawImage(this.image,i.centerX-i.leftw,i.centerY-i.toph,i.width,i.height)}catch(o){}}};var Ci=class extends tt{constructor(t,r,i,o="black"){super(t);this.diatonicId=r;this.accidental=i;this.color=o;p(this,"mi");this.mi=new Ao(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t;switch(this.accidental){case-2:this.rect=F.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=F.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=F.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=F.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=F.createSections(r*1,r*1,r*1,r*1);break;default:throw new O(6,"Invalid accidental value: "+this.accidental)}}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.rect);let{unitSize:i,lineWidth:o}=t,{accidental:s}=this,a=this.rect.centerX,c=this.rect.centerY;r.strokeStyle=r.fillStyle=this.color;function u(l,h){r&&(r.lineWidth=o,r.beginPath(),r.moveTo(l-i*.75,h-i*4),r.lineTo(l-i*.75,h+i*1.1),r.bezierCurveTo(l+i*.75,h-i*0,l+i*.75,h-i*2.2,l-i*.75,h-i*.5),r.stroke())}s===-2?(u(a-i*.5,c),u(a+i*.5,c)):s===-1&&u(a,c),s===0?(r.beginPath(),r.lineWidth=o,r.moveTo(a-i*.5,c-i*2.2),r.lineTo(a-i*.5,c+i*1),r.moveTo(a+i*.5,c+i*2.2),r.lineTo(a+i*.5,c-i*1),r.stroke(),r.beginPath(),r.lineWidth=o*2,r.moveTo(a-i*.5,c+i*1),r.lineTo(a+i*.5,c+i*.6),r.moveTo(a+i*.5,c-i*1),r.lineTo(a-i*.5,c-i*.6),r.stroke()):s===1?(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.3,c-i*1.6),r.lineTo(a-i*.3,c+i*2),r.moveTo(a+i*.3,c-i*2),r.lineTo(a+i*.3,c+i*1.6),r.stroke(),r.lineWidth=o*2,r.beginPath(),r.moveTo(a-i*.75,c-i*.5),r.lineTo(a+i*.75,c-i*.9),r.moveTo(a-i*.75,c+i*.9),r.lineTo(a+i*.75,c+i*.5),r.stroke()):s===2&&(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.75,c-i*.75),r.lineTo(a+i*.75,c+i*.75),r.moveTo(a-i*.75,c+i*.75),r.lineTo(a+i*.75,c-i*.75),r.stroke(),r.fillRect(a-i*1,c-i*1,i*.7,i*.7),r.fillRect(a+i*.3,c-i*1,i*.7,i*.7),r.fillRect(a-i*1,c+i*.3,i*.7,i*.7),r.fillRect(a+i*.3,c+i*.3,i*.7,i*.7))}};var jx=.5,nt=class extends tt{constructor(t,r,i,o){var a,c,u,l,h,d;super(t);this.anchorX=i;this.anchorY=o;p(this,"text");p(this,"scale");p(this,"color");p(this,"bold");p(this,"italic");p(this,"boxed");p(this,"padding");p(this,"bgcolor");p(this,"font","");p(this,"textLines");p(this,"lineWidths",[]);p(this,"lineHeight",0);p(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=(d=s.padding)!=null?d:this.boxed?jx:0,this.bgcolor=s.bgcolor,(!isFinite(this.padding)||this.padding<0)&&(this.padding=0),this.textLines=this.text.split(`
210
- `),this.textLines.length===0&&(this.textLines=[""]),this.rect=new F,this.mi=new Co(this)}getMusicInterface(){return this.mi}getText(){return this.text}updateAnchorX(t){this.anchorX=t;let{width:r}=this.rect;this.rect.left=this.rect.centerX-r*t,this.rect.right=this.rect.centerX+r*(1-t)}updateAnchorY(t){this.anchorY=t;let{height:r}=this.rect;this.rect.top=this.rect.centerY-r*t,this.rect.bottom=this.rect.centerY+r*(1-t)}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{scale:r,anchorX:i,anchorY:o,bold:s,italic:a}=this,c=t.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(d=>t.getTextWidth(d,this.font)),this.lineHeight=c;let u=this.padding*t.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=F.createSections(l*i,l*(1-i),h*o,h*(1-o))}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.rect),r.lineWidth=t.lineWidth,r.strokeStyle=r.fillStyle=this.color,r.font=this.font;let{rect:i,padding:o,lineHeight:s,lineWidths:a,anchorX:c,anchorY:u,italic:l}=this;this.bgcolor!==void 0&&(r.save(),r.fillStyle=this.bgcolor,r.beginPath(),r.fillRect(i.left,i.top,i.width,i.height),r.fill(),r.restore());let d=this.textLines.length*s,m=-s*(l?.25:.175),f=o*t.unitSize,g=(i.left+f)*(1-c)+(i.right-f)*c,b=(i.top+f)*(1-u)+(i.bottom-f)*u;switch(this.textLines.forEach((x,I)=>{let w=g-a[I]*c,S=b-d*u+s*(I+1)+m;r.fillText(x,w,S)}),this.boxed){case"square":case"rectangle":r.strokeRect(i.left,i.top,i.width,i.height);break;case"circle":case"ellipse":let x=(i.left+i.right)/2,I=(i.top+i.bottom)/2,w=(i.right-i.left)/2,S=(i.bottom-i.top)/2;r.beginPath(),r.ellipse(x,I,w,S,0,0,2*Math.PI),r.stroke();break}}};var _o=class extends tt{constructor(t,r){super(t);this.measure=t;this.staff=r;p(this,"clefImage");p(this,"eightBelowClef");p(this,"measureNumber");p(this,"ksNeutralizeAccidentals",[]);p(this,"ksNewAccidentals",[]);p(this,"beatCountText");p(this,"beatSizeText");p(this,"tempoText");p(this,"mi");this.mi=new Io(this)}getMusicInterface(){return this.mi}updateClefImage(t,r){if(r){let i=t.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new pa(this,i,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new nt(this,"8",.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(t){if(t){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new nt(this,r,0,1)}else this.measureNumber=void 0}updateKeySignature(t){if(t){let{measure:r}=this,i=r.getPrevMeasure(),o=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],o&&!Fe.equals(s,o)&&o.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new Ci(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new Ci(this,this.getAccidentalDiatonicId(a),a.accidental))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(t){if(t){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new nt(this,{text:i,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new nt(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(t){if(t){let r=ps(this.measure.getTempo());this.tempoText=new nt(this,r,.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(t){let{clef:r}=this.staff.staffConfig,i;if(r==="G"?t.accidental>0?i=this.staff.bottomLineDiatonicId+3:t.accidental<0&&(i=this.staff.bottomLineDiatonicId+1):r==="F"&&(t.accidental>0?i=this.staff.bottomLineDiatonicId+1:t.accidental<0&&(i=this.staff.bottomLineDiatonicId-1)),i!==void 0)return U.findNextDiatonicIdAbove(t.diatonicId,i,!1);throw new O(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.eightBelowClef){let i=this.eightBelowClef.pick(t,r);if(i.length>0)return[this,...i]}if(this.clefImage){let i=this.clefImage.pick(t,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.ksNeutralizeAccidentals.length;i++){let o=this.ksNeutralizeAccidentals[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.ksNewAccidentals.length;i++){let o=this.ksNewAccidentals[i].pick(t,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let i=this.beatCountText.pick(t,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(t,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(t,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(t,r);if(i.length>0)return[this,...i]}return[this]}layout(t){var u,l,h,d,m,f;let{unitSize:r}=t,{staff:i}=this,o=r,s=0;if(this.rect=new F,this.clefImage&&(s+=o,this.clefImage.layout(t),this.clefImage.offset(s,i.getDiatonicIdY(i.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let g=this.clefImage.getRect();this.eightBelowClef.layout(t),this.eightBelowClef.offset(g.left+g.width/2,Math.max(g.centerY+g.height*.3,i.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}if(this.measureNumber){this.measureNumber.layout(t);let g=this.clefImage?this.clefImage.getRect().top:i.getTopLineY();this.measureNumber.offset(0,g),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(t),g.offset(s+g.getRect().leftw,i.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(g=>{g.layout(t),g.offset(s+g.getRect().leftw,i.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right}));let a=s;(u=this.beatCountText)==null||u.layout(t),(l=this.beatSizeText)==null||l.layout(t);let c=Math.max((d=(h=this.beatCountText)==null?void 0:h.getRect().width)!=null?d:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);if(this.beatCountText&&(this.beatCountText.offset(s+c/2+o,i.getDiatonicIdY(i.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.offset(s+c/2+o,i.getDiatonicIdY(i.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText){let g=Math.min(this.clefImage?this.clefImage.getRect().top:i.getTopLineY(),...this.ksNeutralizeAccidentals.map(b=>b.getRect().top),...this.ksNewAccidentals.map(b=>b.getRect().top));this.tempoText.layout(t),this.tempoText.offset(s,g),this.rect.expandInPlace(this.tempoText.getRect())}this.rect.right+=o}offset(t,r){var i,o,s,a,c,u;(i=this.clefImage)==null||i.offset(t,r),(o=this.eightBelowClef)==null||o.offset(t,r),(s=this.measureNumber)==null||s.offset(t,r),this.ksNeutralizeAccidentals.forEach(l=>l.offset(t,r)),this.ksNewAccidentals.forEach(l=>l.offset(t,r)),(a=this.beatCountText)==null||a.offset(t,r),(c=this.beatSizeText)==null||c.offset(t,r),(u=this.tempoText)==null||u.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){var r,i,o,s,a,c;(r=this.clefImage)==null||r.draw(t),(i=this.eightBelowClef)==null||i.draw(t),(o=this.measureNumber)==null||o.draw(t),this.ksNeutralizeAccidentals.forEach(u=>u.draw(t)),this.ksNewAccidentals.forEach(u=>u.draw(t)),(s=this.beatCountText)==null||s.draw(t),(a=this.beatSizeText)==null||a.draw(t),(c=this.tempoText)==null||c.draw(t)}},vo=class extends tt{constructor(t,r){super(t);this.measure=t;this.tab=r;p(this,"measureNumber");p(this,"beatCountText");p(this,"beatSizeText");p(this,"tempoText");p(this,"mi");this.mi=new So(this)}getMusicInterface(){return this.mi}updateMeasureNumber(t){if(t){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new nt(this,r,0,1)}else this.measureNumber=void 0}updateTimeSignature(t){if(t){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new nt(this,{text:i,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new nt(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(t){if(t){let r=ps(this.measure.getTempo());this.tempoText=new nt(this,r,0,1)}else this.tempoText=void 0}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.beatCountText){let i=this.beatCountText.pick(t,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(t,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(t,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(t,r);if(i.length>0)return[this,...i]}return[this]}layout(t){var u,l,h,d,m,f;let{unitSize:r}=t,{tab:i}=this,o=r,s=0,a=i.getTopLineY();this.rect=new F,this.measureNumber&&(this.measureNumber.layout(t),this.measureNumber.offset(0,a),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),(u=this.beatCountText)==null||u.layout(t),(l=this.beatSizeText)==null||l.layout(t);let c=Math.max((d=(h=this.beatCountText)==null?void 0:h.getRect().width)!=null?d:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.offset(0+c/2+o,i.getRect().centerY-this.beatCountText.getRect().bottomh),this.rect.expandInPlace(this.beatCountText.getRect())),this.beatSizeText&&(this.beatSizeText.offset(0+c/2+o,i.getRect().centerY+this.beatSizeText.getRect().toph),this.rect.expandInPlace(this.beatSizeText.getRect())),this.tempoText&&(this.tempoText.layout(t),this.tempoText.offset(s+r*2,a),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(t,r){var i,o,s,a;(i=this.measureNumber)==null||i.offset(t,r),(o=this.beatCountText)==null||o.offset(t,r),(s=this.beatSizeText)==null||s.offset(t,r),(a=this.tempoText)==null||a.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){var r,i,o,s;(r=this.measureNumber)==null||r.draw(t),(i=this.beatCountText)==null||i.draw(t),(o=this.beatSizeText)==null||o.draw(t),(s=this.tempoText)==null||s.draw(t)}};var ma=class extends tt{constructor(t,r,i){super(t);this.col=t;this.line=r;this.arpeggioDir=i;p(this,"topArrowHeight",0);p(this,"bottomArrowHeight",0);p(this,"cycleHeight",0);p(this,"numCycles",0);p(this,"color","black");p(this,"mi");this.mi=new wo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let i=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-i)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new F(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{lineWidth:i}=t,{rect:o,topArrowHeight:s,bottomArrowHeight:a}=this;t.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i*2,r.beginPath();for(let c=0,u=o.top+s;c<this.numCycles;c++,u+=this.cycleHeight)r.moveTo(o.centerX,u),r.quadraticCurveTo(o.left,u+this.cycleHeight/4,o.centerX,u+this.cycleHeight/2),r.quadraticCurveTo(o.right,u+this.cycleHeight*3/4,o.centerX,u+this.cycleHeight);r.stroke(),s>0&&(r.beginPath(),r.moveTo(o.centerX,o.top),r.lineTo(o.right,o.top+s),r.lineTo(o.left,o.top+s),r.fill()),a>0&&(r.beginPath(),r.moveTo(o.centerX,o.bottom),r.lineTo(o.left,o.bottom-a),r.lineTo(o.right,o.bottom-a),r.fill())}};function Px(n){return typeof n=="number"?U.getChromaticNote(n).diatonicId:typeof n=="string"?U.getNote(n).diatonicId:n instanceof U?n.diatonicId:void 0}var fa=class extends tt{constructor(t,r){super(t);this.staff=t;this.rest=r;p(this,"restRect",new F);p(this,"dotRects",[]);p(this,"mi");t.addObject(this),this.mi=new No(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}offset(t,r){this.restRect.offsetInPlace(t,r),this.dotRects.forEach(i=>i.offsetInPlace(t,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRects.forEach(t=>this.rect.expandInPlace(t))}},Sr=class extends tt{constructor(t,r,i,o,s){var l,h;super(t);this.col=t;this.voiceId=r;p(this,"ownStemDir");p(this,"ownDiatonicId");p(this,"color");p(this,"hide");p(this,"oldStyleTriplet");p(this,"rhythmProps");p(this,"beamGroup");p(this,"staffObjects",[]);p(this,"mi");let a=Px(o==null?void 0:o.staffPos);if(a!==void 0){let d=this.row.hasStaff,m=this.row.getStaff(a);if(d&&!m)throw new O(6,"Rest staffPos is out of staff boundaries!")}this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,a),this.ownStemDir=this.measure.updateOwnStemDir(this);let c=this.row.getStaff(this.ownDiatonicId);c&&c.isSpace(this.ownDiatonicId)&&(this.ownDiatonicId+=this.ownDiatonicId>=c.middleLineDiatonicId?1:-1),this.color=(l=o==null?void 0:o.color)!=null?l:"black",this.hide=(h=o==null?void 0:o.hide)!=null?h:!1,this.oldStyleTriplet=s===void 0&&((o==null?void 0:o.triplet)===!0||_t.get(i).isTriplet);let u=typeof(o==null?void 0:o.dotted)=="number"?o.dotted>0?o.dotted:void 0:(o==null?void 0:o.dotted)===!0?1:void 0;this.rhythmProps=Gt.get(i,u,(s!=null?s:this.oldStyleTriplet)?gr.Triplet:void 0),this.mi=new To(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}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}getStaticObjects(t){let r=[];return this.staffObjects.forEach(i=>{i.staff===t&&r.push(i)}),r}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(t){this.beamGroup=t}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(t=>{let r=t.staff,i=t.getRect().centerX,o=this.stemDir==="up"?t.getRect().top:t.getRect().bottom,s=Math.abs(t.getRect().centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0}visibleInStaff(t){return t.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof fa&&r.staff===t)}getRestDotVerticalDisplacement(t){switch(t){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 O(6,`Get rest dot vertical displacement: Invalid note size: ${t}`)}}updateAccidentalState(t){}layout(t,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:i}=t,{ownDiatonicId:o}=this,{noteSize:s,dotCount:a}=this.rhythmProps;this.row.getStaves().forEach(c=>{if(!c.containsDiatonicId(o)||!c.containsVoiceId(this.voiceId))return;let u=new fa(c,this);u.restRect=t.getRestRect(s);for(let l=0;l<a;l++){let h=ct.DotSize*i,d=u.restRect.rightw+(ct.RestDotSpace+ct.DotSize*i)+l*ct.DotSize*i*1.5,m=this.getRestDotVerticalDisplacement(s)*i;u.dotRects.push(F.createCentered(d,m,h,h))}u.offset(0,c.getDiatonicIdY(o)),this.staffObjects.push(u)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;else if(this.rect=this.staffObjects[0].getRect().copy(),this.staffObjects.length>1)for(let t=1;t<this.staffObjects.length;t++)this.rect.expandInPlace(this.staffObjects[t].getRect())}offset(t,r){this.staffObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let r=t.getCanvasContext();if(!r||this.staffObjects.length===0)return;t.drawDebugRect(this.getRect());let{lineWidth:i}=t,{color:o}=this,{noteSize:s}=this.rhythmProps;r.strokeStyle=r.fillStyle=o,r.lineWidth=i,this.staffObjects.forEach(a=>{let{dotRects:c,restRect:u}=a,l=u.centerX,h=u.centerY;t.drawRest(s,l,h,o),c.forEach(d=>{t.fillCircle(d.centerX,d.centerY,d.width/2)})})}};function Fx(n){return A.Is.isEnumValue(n,Qe)?n:void 0}function Bx(n){return A.Is.isEnumValue(n,Zr)?n:n===!0?"up":void 0}function Vx(n,e){let t=A.Arr.isArray(e)?e:e!==void 0?[e]:[],r=n.map((i,o)=>({note:i,string:t[o]}));return r=A.Arr.removeDuplicatesCmp(r,(i,o)=>U.equals(i.note,o.note)).sort((i,o)=>U.compareFunc(i.note,o.note)),{notes:r.map(i=>i.note),strings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}var ga=class extends tt{constructor(t,r){super(t);this.staff=t;this.noteGroup=r;p(this,"noteHeadRects",[]);p(this,"dotRects",[]);p(this,"accidentals",[]);p(this,"stemTip");p(this,"stemBase");p(this,"flagRects",[]);p(this,"prevTopNoteY",0);p(this,"prevBottomNoteY",0);p(this,"mi");this.mi=new Ro(this)}getMusicInterface(){return this.mi}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.accidentals.length;i++){let o=this.accidentals[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].copy(),this.noteHeadRects.forEach(t=>this.rect.expandInPlace(t)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(t=>this.rect.expandInPlace(t)),this.flagRects.forEach(t=>this.rect.expandInPlace(t)),this.accidentals.forEach(t=>this.rect.expandInPlace(t.getRect()))}getRect(){let t=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.centerY||this.prevBottomNoteY!==t.centerY)&&(this.prevTopNoteY=r.centerY,this.prevBottomNoteY=t.centerY,this.requestRectUpdate()),super.getRect()}offset(t,r){var i,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(t,r)),this.dotRects.forEach(s=>s.offsetInPlace(t,r)),this.accidentals.forEach(s=>s.offset(t,r)),(i=this.stemTip)==null||i.offsetInPlace(t,r),(o=this.stemBase)==null||o.offsetInPlace(t,r),this.flagRects.forEach(s=>s.offsetInPlace(t,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},Mu=class extends tt{constructor(t,r){super(t);this.tab=t;this.noteGroup=r;p(this,"fretNumbers",[]);p(this,"mi");t.addObject(this),this.mi=new Mo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().copy(),this.fretNumbers.forEach(t=>this.rect.expandInPlace(t.getRect()))}offset(t,r){this.fretNumbers.forEach(i=>i.offset(t,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},xt=class n extends tt{constructor(t,r,i,o,s,a){var l,h,d;super(t);this.col=t;this.voiceId=r;this.notes=i;p(this,"minDiatonicId");p(this,"maxDiatonicId");p(this,"ownDiatonicId");p(this,"ownStemDir");p(this,"ownString");p(this,"color");p(this,"staccato");p(this,"diamond");p(this,"arpeggio");p(this,"oldStyleTriplet");p(this,"rhythmProps");p(this,"startConnnectives",[]);p(this,"runningConnectives",[]);p(this,"leftBeamCount",0);p(this,"rightBeamCount",0);p(this,"beamGroup");p(this,"staffObjects",[]);p(this,"tabObjects",[]);p(this,"mi");if(!A.Is.isIntegerGte(i.length,1))throw new O(6,"Cannot create note group object because notes array is empty.");let c=Vx(i,s==null?void 0:s.string);this.notes=c.notes,this.minDiatonicId=this.notes[0].diatonicId,this.maxDiatonicId=this.notes[this.notes.length-1].diatonicId,this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,Math.round((this.minDiatonicId+this.maxDiatonicId)/2)),this.ownStemDir=this.measure.updateOwnStemDir(this,Fx(s==null?void 0:s.stem)),this.ownString=this.measure.updateOwnString(this,c.strings),this.color=(l=s==null?void 0:s.color)!=null?l:"black",this.staccato=(h=s==null?void 0:s.staccato)!=null?h:!1,this.diamond=(d=s==null?void 0:s.diamond)!=null?d:!1,this.arpeggio=Bx(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&((s==null?void 0:s.triplet)===!0||_t.get(o).isTriplet);let u=typeof(s==null?void 0:s.dotted)=="number"?s.dotted>0?s.dotted:void 0:(s==null?void 0:s.dotted)===!0?1:void 0;this.rhythmProps=Gt.get(o,u,(a!=null?a:this.oldStyleTriplet)?gr.Triplet:void 0),this.mi=new Oo(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}enableConnective(t){return t.containsVoiceId(this.voiceId)&&(t instanceof Se||t.containsDiatonicId(this.ownDiatonicId))}startConnective(t){if(!this.row.hasStaff&&t.connective==="tie")throw new O(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&t.connective==="slur")throw new O(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(t),this.doc.addConnectiveProps(t)}getStaticObjects(t){let r=[];return this.staffObjects.forEach(i=>{i.staff===t&&r.push(i)}),this.tabObjects.forEach(i=>{i.tab===t&&r.push(i)}),r}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabObjects.length;i++){let o=this.tabObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(t,r,i,o,s){if(r instanceof Tt){let a=r;if(i<0||i>=this.notes.length)throw new O(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(_=>_.staff===a);if(!c||i<0||i>=c.noteHeadRects.length){let _=this.getRect();return{x:_.centerX,y:_.bottom}}let u=c.noteHeadRects[i],l=c.stemTip,h=this.stemDir,d=l!==void 0,m=d?h==="up"?"right":"left":void 0,f=u.height/2,g=u.centerX,b=u.centerY,x=u.left-f,I=u.right+f,w=u.top-f,S=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!d&&(o=h==="up"?"above":"below"),o){case"center":return s==="left"?{x:I,y:b}:{x,y:b};case"above":return!d||h==="down"?{x:g,y:w}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?x:g,y:w};case"below":return!d||h==="up"?{x:g,y:S}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?x:g,y:S};case"stemTip":return{x:g,y:l.centerY+(h==="up"?-f:f)};default:throw new O(6,"Invalid noteAnchor: "+o)}}else{let a=r,c=this.tabObjects.find(f=>f.tab===a),u=c==null?void 0:c.fretNumbers[i];if(!c||!u)return{x:0,y:0};let l=u.getRect(),h=s==="right"?l.left:l.right,d,m=.9;if(t.connective==="slide"){let f=t.noteGroups[0].getFretNumber(c,0),g=t.noteGroups[1].getFretNumber(c,0),b=f===void 0||g===void 0||f<=g;s==="left"?d=b?l.centerY+l.bottomh*m:l.centerY-l.toph*m:d=b?l.centerY-l.toph*m:l.centerY+l.bottomh*m}else d=l.centerY+l.bottomh*m;return{x:h,y:d}}}getFretNumberString(t){return this.ownString[t]}getFretNumber(t,r){let i=t.fretNumbers[r];return i===void 0?void 0:+i.getText()}getNextNoteGroup(){let t=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof n),r=t.indexOf(this);if(r<0)return;if(r<t.length-1)return t[r+1];let i=this.measure.getNextMeasure();for(;i;){let o=i.getVoiceSymbols(this.voiceId).filter(s=>s instanceof n);if(o.length>0)return o[0];i=i.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(t=>{this.runningConnectives.push(t);let r=this.getNextNoteGroup();for(;r&&t.addNoteGroup(r);)r.runningConnectives.push(t),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let t=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return t.indexOf("first")>=0?"first":t.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(t){this.beamGroup=t}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(t=>{var a,c,u,l;let r=t.staff,i=(c=(a=t.stemTip)==null?void 0:a.centerX)!=null?c:t.noteHeadRects[0].centerX,o=(l=(u=t.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir==="up"?t.getRect().top:t.getRect().bottom,s=this.stemDir==="up"?Math.abs(t.noteHeadRects[0].centerY-o):Math.abs(t.noteHeadRects[t.noteHeadRects.length-1].centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}getStemHeight(t){let{unitSize:r}=t,{flagCount:i,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?ct.BeamSeparation:ct.FlagSeparation;return(ct.StemHeight+Math.max(0,i-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}setLeftBeamCount(t){this.leftBeamCount=t}setRightBeamCount(t){this.rightBeamCount=t}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(t){return t.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ga&&r.staff===t)}getPlayTicks(t){let r=this.runningConnectives.filter(i=>i.connective==="tie").map(i=>{let o=i.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(i.span==="stub"||i.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,t))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!U.equals(u,t))),s>=0&&(o=o.slice(0,s)),A.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(t){this.notes.forEach(r=>{t.needAccidental(r)&&t.setAccidental(r)})}layout(t,r){this.requestRectUpdate();let{unitSize:i}=t,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,l=ct.DotSize*i,h=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadWidth)*i,d=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadHeight)*i;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.ownDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new ga(m,this),g=m,b=m;this.notes.forEach((C,y)=>{var P;let T=y===0,E=y===this.notes.length-1,R=(P=m.getActualStaff(C.diatonicId))!=null?P:m,M=this.col.getNoteHeadDisplacement(this,C)*h,q=R.getDiatonicIdY(C.diatonicId),L=R.isLine(C.diatonicId);T&&s==="up"&&(g=R),E&&s==="up"&&(b=R),T&&s==="down"&&(b=R),E&&s==="down"&&(g=R);let k=f.noteHeadRects[y]=F.createCentered(M,q,h,d);if(R.addObject(k),r.needAccidental(C)){let G=f.accidentals[y]=new Ci(this,C.diatonicId,C.accidental,this.color);G&&(G.layout(t),G.offset(-k.leftw-i*ct.NoteAccSpace-G.getRect().rightw,q)),R.addObject(G)}for(let G=0;G<a;G++){let Q=k.right+ct.NoteDotSpace*i+l/2+G*l*1.5,Y=q+this.getDotVerticalDisplacement(m,C.diatonicId,s)*i,V=F.createCentered(Q,Y,l,l);f.dotRects.push(V),R.addObject(V)}if(this.staccato){if(s==="up"&&T){let G=M,Q=q+i*(L?3:2),Y=F.createCentered(G,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}else if(s==="down"&&E){let G=M,Q=q-i*(L?3:2),Y=F.createCentered(G,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}}});let x=f.noteHeadRects[0].centerY,I=f.noteHeadRects[f.noteHeadRects.length-1].centerY,w=s==="up"?h/2:-h/2,S=this.getStemHeight(t),_=s==="up"?I-S:x+S,v=s==="up"?x:I;if(u&&(f.stemTip=new F(w,w,_,_),f.stemBase=new F(w,w,v,v),b.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let C=c===0?0:ct.FlagWidth*i,y=c===0?0:ct.FlagHeight*i;for(let T=0;T<c;T++){let E=T*i*ct.FlagSeparation,R=f.flagRects[T]=s==="up"?new F(w,w+C,_+E,_+y+E):new F(w,w+C,_-y-E,_-E);b.addObject(R)}}this.staffObjects.push(f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new Mu(m,this);this.notes.forEach((g,b)=>{if(this.ownString[b]!==void 0){let x=this.ownString[b]-1,I=g.chromaticId-m.getTuningStrings()[x].chromaticId,w=I<0?"red":"black",S=new nt(this,{text:String(I),color:w,bgcolor:"white"},.5,.5);f.fretNumbers.push(S),S.layout(t);let _=this.col.getRect().centerX,v=m.getStringY(x);S.offset(_,v)}}),f.fretNumbers.length>0&&this.tabObjects.push(f)})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].copy();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().copy();else{this.rect=new F;return}this.staffObjects.forEach(t=>this.rect.expandInPlace(t.getRect())),this.tabObjects.forEach(t=>this.rect.expandInPlace(t.getRect()))}setStemTipY(t,r){let i=this.staffObjects.find(o=>o.staff===t);this.hasBeamCount()&&(i!=null&&i.stemTip)&&r!==i.stemTip.centerY&&(i.stemTip.top=i.stemTip.centerY=i.stemTip.bottom=r,this.requestRectUpdate())}offset(t,r){this.staffObjects.forEach(i=>i.offset(t,0)),this.tabObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.getRect());let{lineWidth:i}=t,{color:o,stemDir:s}=this,{isSolidNoteHead:a}=this.rhythmProps;this.staffObjects.forEach(c=>{c.accidentals.forEach(u=>u.draw(t)),r.strokeStyle=r.fillStyle=o,r.lineWidth=i,c.noteHeadRects.forEach(u=>{this.diamond?a?(r.beginPath(),r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.lineTo(u.left,u.centerY),r.lineTo(u.centerX,u.top),r.fill()):(r.beginPath(),r.lineWidth=i*2.5,r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.moveTo(u.left,u.centerY),r.lineTo(u.centerX,u.bottom),r.stroke(),r.beginPath(),r.lineWidth=i,r.moveTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.moveTo(u.centerX,u.top),r.lineTo(u.left,u.centerY),r.stroke()):(r.beginPath(),r.ellipse(u.centerX,u.centerY,u.leftw,u.toph,-.3,0,Math.PI*2),a?r.fill():r.stroke())}),c.dotRects.forEach(u=>t.fillCircle(u.centerX,u.centerY,u.width/2)),c.stemTip&&c.stemBase&&(r.beginPath(),r.moveTo(c.stemBase.centerX,c.stemBase.centerY),r.lineTo(c.stemTip.centerX,c.stemTip.centerY),r.stroke()),c.flagRects.forEach(u=>t.drawFlag(u,s==="up"?"up":"down"))}),this.tabObjects.forEach(c=>c.fretNumbers.forEach(u=>u.draw(t)))}getDotVerticalDisplacement(t,r,i){return t.isLine(r)?i==="up"?-1:1:0}static hasSameNotes(t,r){if(t.notes.length!==r.notes.length)return!1;for(let i=0;i<t.notes.length;i++){let o=t.notes[i],s=r.notes[i];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var ya=class{constructor(e,t){this.col=e;p(this,"lyricsObjects",[]);p(this,"rhythmProps");this.rhythmProps=Gt.get(t)}addLyricsObject(e){var t;this.lyricsObjects.push(e),(t=e.measure.getPrevLyricsObject(e))==null||t.setNextLyricsObject(e)}},ba=class extends tt{constructor(t,r,i,o,s,a){super(t);this.col=t;this.verse=r;this.line=i;this.vpos=o;p(this,"nextLyricsObject");p(this,"color","black");p(this,"hyphen");p(this,"text");p(this,"mi");let c=(a==null?void 0:a.align)==="left"?0:(a==null?void 0:a.align)==="right"?1:.5;this.hyphen=A.Is.isEnumValue(a==null?void 0:a.hyphen,xn)?a==null?void 0:a.hyphen:void 0,this.text=new nt(this,{text:s,color:this.color,scale:.8},c,0),this.rect=new F,this.mi=new Do(this)}getMusicInterface(){return this.mi}get measure(){return this.col.measure}getText(){return this.text.getText()}setNextLyricsObject(t){this.nextLyricsObject=t}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){this.text.layout(t),this.rect=this.text.getRect().copy()}offset(t,r){this.text.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){var i;this.text.draw(t);let r=t.getCanvasContext();if(r&&this.hyphen!==void 0){let o=this.getRect(),s=(i=this.nextLyricsObject)==null?void 0:i.getRect(),a=t.unitSize*1.5,c=s?(s.left-o.right)*.85:a,u=this.hyphen==="-"?Math.min(a,c):c;if(u>0){r.lineWidth=t.lineWidth,r.strokeStyle=r.fillStyle=this.color;let l=s?(s.left+o.right)/2:o.right+u/.85,h=(o.top+o.bottom)/2;r.moveTo(l-u/2,h),r.lineTo(l+u/2,h),r.stroke()}}}};var Gx=(n,e)=>{let t=U.compareFunc(n.note,e.note);return t===0&&(t=n.noteGroup.stemDir===e.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1),t},wr=class extends tt{constructor(t,r){super(t);this.measure=t;this.positionTicks=r;p(this,"voiceSymbol",[]);p(this,"lyricsContainers",[]);p(this,"minDiatonicId");p(this,"maxDiatonicId");p(this,"staffMinDiatonicId",new Map);p(this,"staffMaxDiatonicId",new Map);p(this,"arpeggioDir");p(this,"arpeggios",[]);p(this,"noteHeadDisplacements",[]);p(this,"playerProps");p(this,"needLayout",!0);p(this,"shapeRects",[]);p(this,"mi");this.playerProps=new vn(this),this.mi=new Eo(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let t=this.measure.getColumns().indexOf(this);if(t>=0&&t<this.measure.getColumnCount())return this.measure.getColumn(t+1);throw new O(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let t=this.getNextColumnInMeasure();return t||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let t=this.getNextColumnInMeasure(),r=this.positionTicks,i=t?t.positionTicks:this.measure.getConsumedTicks();return Math.max(0,i-r)}getShapeRects(){return this.getRect(),this.shapeRects}getStaticObjects(t){let r=[];return this.voiceSymbol.forEach(i=>{i&&(i.getRect(),i.getStaticObjects(t).forEach(o=>r.push(o)))}),this.arpeggios.forEach(i=>{i.line===t&&(i.getRect(),r.push(i))}),r}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.voiceSymbol.length;i++)if(this.voiceSymbol[i]){let o=this.voiceSymbol[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.arpeggios.length;i++){let o=this.arpeggios[i].pick(t,r);if(o.length>0)return[this,...o]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var t;return(t=this.arpeggioDir)!=null?t:"up"}setVoiceSymbol(t,r){xa(t),this.voiceSymbol[t]=r,r instanceof Sr&&!r.hide?(this.minDiatonicId=this.minDiatonicId===void 0?r.ownDiatonicId:Math.min(this.minDiatonicId,r.ownDiatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.ownDiatonicId:Math.max(this.maxDiatonicId,r.ownDiatonicId)):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.setupNoteHeadDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(t){return this.voiceSymbol[t]}getLyricsContainerDatas(){return this.lyricsContainers}getLyricsContainer(t,r,i,o){let s=this.lyricsContainers.find(a=>a.verse===t&&a.line===r&&a.vpos===i);return s===void 0&&o!==void 0&&(s={lyricsContainer:new ya(this,Ae(o)),verse:t,line:r,vpos:i},this.lyricsContainers.push(s),this.requestLayout(),this.requestRectUpdate()),s==null?void 0:s.lyricsContainer}getMinWidth(){let t=Math.max(...this.voiceSymbol.map(i=>i.rhythmProps.noteSize)),r=ct.NoteHeadWidth;switch(t){case 1:return r*5;case 2:return r*3;case 4:return r*2;default:return r}}setupNoteHeadDisplacements(){if(this.noteHeadDisplacements=[],this.voiceSymbol.forEach(t=>{t instanceof xt&&t.notes.forEach(r=>{this.noteHeadDisplacements.push({noteGroup:t,note:r})})}),this.noteHeadDisplacements.sort(Gx),!(this.noteHeadDisplacements.length<2)){for(let t=0;t<this.noteHeadDisplacements.length;t++){let r=this.noteHeadDisplacements[t],i=this.noteHeadDisplacements[t+1];i&&r.note.diatonicId===i.note.diatonicId&&(r.displacement=i.displacement=0)}for(let t=0;t<this.noteHeadDisplacements.length;t++){let r=this.noteHeadDisplacements[t-1],i=this.noteHeadDisplacements[t],o=this.noteHeadDisplacements[t+1];if(i.displacement!==void 0)continue;let s=i.noteGroup.stemDir==="down"?-1:1;r&&i.note.diatonicId-r.note.diatonicId<=1?i.displacement=r.displacement===0?s:0:o&&o.note.diatonicId-i.note.diatonicId<=1&&(i.displacement=o.displacement===0?s:0)}}}getNoteHeadDisplacement(t,r){let i=this.noteHeadDisplacements.find(o=>o.noteGroup===t&&U.equals(o.note,r));return(i==null?void 0:i.displacement)!==void 0?i.displacement:0}isEmpty(){for(let t=0;t<this.voiceSymbol.length;t++)if(this.voiceSymbol[t]!==void 0&&!this.voiceSymbol[t].isEmpty())return!1;return!0}getPlayerNotes(){let t=[];function r(i,o,s,a){if(o<=0)return;t.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||t.push({note:i,ticks:o,staccato:s,slur:a})}return Kt().forEach(i=>{let o=this.getVoiceSymbol(i);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)})}}),t.sort((i,o)=>U.compareFunc(i.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&t.reverse(),t}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(t,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new F;let{row:i}=this,{unitSize:o}=t,s=this.getMinWidth()*o/2,a=s,c=s;if(this.voiceSymbol.forEach(l=>{l.layout(t,r);let h=l.getRect();a=Math.max(a,h.leftw),c=Math.max(c,h.rightw)}),this.arpeggioDir!==void 0){let l=0;this.arpeggios=i.getNotationLines().map(h=>{let d=new ma(this,h,this.getArpeggioDir());return d.layout(t),d.offset(-a-d.getRect().right,h.getRect().centerY-d.getRect().centerY),l=Math.max(l,d.getRect().width),h.addObject(d),d}),a+=l}else this.arpeggios=[];let u=this.getAnchoredLayoutObjects().filter(l=>l.layoutGroup.widensColumn);u.length>0&&u.forEach(l=>{a=Math.max(a,l.musicObj.getRect().leftw),c=Math.max(c,l.musicObj.getRect().rightw)}),this.voiceSymbol.forEach(l=>l.updateAccidentalState(r)),this.rect.left=-a,this.rect.centerX=0,this.rect.right=c,this.row.getStaves().forEach(l=>{let h,d;this.voiceSymbol.forEach(m=>{m.visibleInStaff(l)&&(m instanceof xt?(h=h===void 0?m.minDiatonicId:Math.min(h,m.minDiatonicId),d=d===void 0?m.maxDiatonicId:Math.max(d,m.maxDiatonicId)):m instanceof Sr&&(h=h===void 0?m.ownDiatonicId:Math.min(h,m.ownDiatonicId),d=d===void 0?m.ownDiatonicId:Math.max(d,m.ownDiatonicId)))}),h!==void 0?this.staffMinDiatonicId.set(l,h):this.staffMinDiatonicId.delete(l),d!==void 0?this.staffMaxDiatonicId.set(l,d):this.staffMaxDiatonicId.delete(l)})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(t=>!!t).map(t=>t.getRect().copy()),...this.arpeggios.map(t=>t.getRect().copy())],this.rect.top=Math.min(...this.shapeRects.map(t=>t.top)),this.rect.bottom=Math.max(...this.shapeRects.map(t=>t.bottom)),this.rect.centerY=(this.rect.top+this.rect.bottom)/2}offset(t,r){this.voiceSymbol.forEach(i=>i==null?void 0:i.offset(t,0)),this.arpeggios.forEach(i=>i.offset(t,0)),this.shapeRects.forEach(i=>i.offsetInPlace(t,r)),this.rect.offsetInPlace(t,r)}draw(t){this.row.getStaves().forEach(r=>{let i=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);i!==void 0&&t.drawLedgerLines(r,i,this.getRect().centerX),o!==void 0&&t.drawLedgerLines(r,o,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(t)}),this.arpeggios.forEach(r=>r.draw(t))}};var dr=class dr extends tt{constructor(t,r){super(t);this.text=r;p(this,"components",[]);p(this,"mi");switch(this.text){case dr.Coda:this.components=[new nt(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new nt(this," Coda",0,1)];break;case dr.toCoda:this.components=[new nt(this,"toCoda ",1,1),new nt(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case dr.Segno:this.components=[new nt(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new ko(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){switch(this.text){case dr.Coda:{let r=this.components[0],i=this.components[1];r.layout(t),i.layout(t),r.offset(0,(i.getRect().top+i.getRect().bottom)/2),i.offset(r.getRect().right,0),this.rect=new F(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case dr.toCoda:{let r=this.components[0],i=this.components[1];r.layout(t),i.layout(t),i.offset(0,(r.getRect().top+r.getRect().bottom)/2),r.offset(i.getRect().left,0),this.rect=new F(r.getRect().left,i.getRect().centerX,i.getRect().right,r.getRect().top,r.getRect().centerY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(t),this.rect=r.getRect().copy();break}}}offset(t,r){this.components.forEach(i=>i.offset(t,r)),this.rect.offsetInPlace(t,r)}draw(t){t.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(t))}};p(dr,"toCoda","\u{1D10C} toCoda"),p(dr,"Coda","Coda \u{1D10C}"),p(dr,"Segno","\u{1D10B}");var $e=dr;function Lo(n){switch(n){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 $e.Segno;case"Coda":return $e.Coda;case"toCoda":return $e.toCoda;default:return n[0].toUpperCase()+n.substring(1)}}function Du(n){return A.Is.isEnumValue(n,Cn)}function jo(n){if(/^(p+|f+|m|mp|mf)$/.test(n)){let e=.5-A.Str.charCount(n,"p")*.1+A.Str.charCount(n,"f")*.1;return A.Math.clamp(e,0,1)}else return}function Eu(n){return A.Is.isEnumValue(n,_n)}function qm(n){return A.Is.isEnumValue(n,Cn)?"dynamics":A.Is.isEnumValue(n,_n)?"tempo":void 0}function qx(n){switch(n){case"bottom":return .8;case"middle":return .5}}function Wx(n){return Du(n)?2:Eu(n)?1:0}var _i=class extends la{constructor(t,r,i,o,s,a){super(t);p(this,"length");p(this,"visible");p(this,"lineStyle");p(this,"linePos");p(this,"startColumn");p(this,"context");if(this.length=i,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=t instanceof nt?Wx(t.getText()):0,t instanceof nt)t.updateAnchorY(qx(a));else throw new O(6,"Update anchor's y-coordinate is only implemented for text objects.")}isVisible(){return this.visible}getLineStyle(){return this.lineStyle}getLinePos(){return this.linePos}getSpanBreakText(t,r){if(t===t.measure.getColumn(0)){let i=t.measure.getPrevMeasure();if(i){if(i.hasEndSection()||i.hasEndSong())return"section-break";let o=["endRepeat","ending"];for(let s=0;s<o.length;s++)if(i.hasNavigation(o[s]))return"section-break"}}if(r===1){let i=t.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&Eu(s))return s}}else if(r===2){let i=t.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&Du(s))return s}}}getExtensionRangeInfo(){let{startColumn:t,length:r,context:i}=this,o=[t];if(r<=0)return{startColumn:t,endColumn:t,columnRange:o,extensionBreakText:void 0};let s=r,a=t;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:t,endColumn:a,columnRange:o,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:t,endColumn:a,columnRange:o,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:t,endColumn:a,columnRange:o,extensionBreakText:void 0};a=c,o.push(a)}}};var Ux=2,zx=2,Yx=.5,Hx=.5;function Zx(n,e){let t=Gt.get(e.options.beatLength,e.options.dotCount).ticks,r=e.beatsPerMinute*t;return 60*n/r}function ku(){return jo("m")}function Xx(n){return n*1.25}var Qx=.5,vn=class{constructor(e){this.col=e;p(this,"speed");p(this,"volume");this.speed=1,this.volume=ku()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=ku()}setSpeed(e){this.speed=e}getSpeed(){return this.speed}getTempo(){let e=A.Math.clamp(this.getSpeed(),.1,10);return Sc(this.measure.getTempo(),e)}setVolume(e){this.volume=e}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:e}=this;if(e instanceof Tr)return this.measure.getMeasureTicks()/2;{let r=Kt().map(i=>e.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:A.Math.sum(r)/r.length}}},Aa=class n{constructor(){p(this,"playTimer");p(this,"playPos");p(this,"playState",2);p(this,"doc");p(this,"cursorPositionChangeListener");p(this,"playStateChnageListener");p(this,"playerColumnSequence",[])}setDocument(e){this.doc=e,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(e){this.cursorPositionChangeListener=e}setPlayStateChnageListener(e){this.playStateChnageListener=e}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let e=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==e&&(this.playStateChnageListener&&this.playStateChnageListener(e),this.playState=e)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let e=[],t=this.doc.getFirstMeasure(),r=t,i,o=!1,s=!1;for(;t;){if(t.incPassCount(),t.getEnding()){let u=t.getPassCount();t=n.getMeasureByEndingPassage(t,u)}if(t)if(e.push(t),t.hasNavigation("startRepeat")&&(r=t),t.hasNavigation("Segno")&&(i=t),s&&t.hasNavigation("toCoda"))for(;t&&!t.hasNavigation("Coda");)t=t.getNextMeasure();else if(o&&t.hasNavigation("Fine"))t=void 0;else if(t.hasNavigation("D.C. al Coda"))s=!0,t=this.doc.getFirstMeasure();else if(t.hasNavigation("D.C. al Fine"))o=!0,t=this.doc.getFirstMeasure();else if(t.hasNavigation("D.S. al Coda"))s=!0,t=i;else if(t.hasNavigation("D.S. al Fine"))o=!0,t=i;else if(t.hasNavigation("endRepeat")){let u=t.getPassCount(),l=t.getEndRepeatPlayCount()-1,h=((a=t.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=l||h?t=r:t=t.getNextMeasure()}else t.hasEndSong()?t=void 0:t=t.getNextMeasure()}return e}collectPlayerColumnSequence(){let e=this.collectPlayerMeasureSequence(),t=[];for(let r=0;r<e.length;r++){let i=e[r];t=t.concat(i.getColumns()),i.hasFermata(i.getBarLineRight())&&t.push(i.getBarLineRight())}return t}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let e=1,t=ku(),r=new Map,i=new Map,o=(a,c)=>{var u;return r.set(a,[...(u=r.get(a))!=null?u:[],c])},s=(a,c)=>{var u;return i.set(a,[...(u=i.get(a))!=null?u:[],c])};this.playerColumnSequence.forEach(a=>{var l,h;if(!(a instanceof wr))return;a.getAnchoredLayoutObjects().forEach(d=>{var g;let m=(g=d.getTextContent())!=null?g:"",f;if(m==="a tempo")e=1;else if((f=jo(m))!==void 0)t=f;else if(d.musicObj.getLink()instanceof _i){let b=d.musicObj.getLink(),{columnRange:x,extensionBreakText:I}=b.getExtensionRangeInfo(),w=A.Math.sum(x.map(S=>S.getTicksToNextColumn()));switch(m){case"accel.":{let S=e,_=S*Ux,v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,S+(_-S)*v/w)});break}case"rit.":{let S=e,_=S/zx,v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,S+(_-S)*v/w)});break}case"cresc.":{let S=t,_=S+Yx;I&&(f=jo(I))!==void 0&&f>S&&(_=f);let v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(_-S)*v/w)});break}case"decresc.":case"dim.":{let S=t,_=S-Hx;I&&(f=jo(I))!==void 0&&f<S&&(_=f);let v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(_-S)*v/w)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(e=A.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(t=A.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(e),a.getPlayerProps().setVolume(t)})}static getMeasureByEndingPassage(e,t){for(let r=e;;r=r.getNextMeasure()){let i=r==null?void 0:r.getEnding();if(i&&i.hasPassage(t))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 e=this.playerColumnSequence[this.playPos],t=(s,a)=>{let c=Zx(s,a);return Math.max(0,c)},r=e.getPlayerProps().getTempo(),i=e.getPlayerProps().getFermataHoldTicks(),o;e instanceof Tr?o=t(i,r):(e.getPlayerNotes().forEach((a,c)=>{let u=e.hasArpeggio()?Gt.get("32n").ticks*c:0,l=t(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(t(Gt.get("8n").ticks,r)/2,l/2));let h=Xx(e.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=Qx),u>0){let d=t(u,r);window.setTimeout(()=>oa(a.note,l,h),d*1e3)}else oa(a.note,l,h)}}),o=t(e.getTicksToNextColumn()+i,r)),this.playTimer=window.setTimeout(()=>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:e}=this;if(!e)return;e.getFirstMeasure()?(this.playPos=0,this.playStep()):this.playPos=void 0,this.notifyPlayStateChanged()}pause(){this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}stop(){this.playPos=void 0,this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}getNextPlayPosition(e){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let e=this.playerColumnSequence[this.playPos],t=e.measure,r=e.getRect().centerX,i=t.row.getRect().top,o=t.row.getRect().bottom;return new F(r,r,i,o)}};var Lu=class extends tt{constructor(t,r){super(r);this.barLine=t;this.line=r;p(this,"lineRects",[]);p(this,"dotRects",[]);p(this,"mi");r.addObject(this),this.mi=new Bo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}setRect(t){this.rect=t}offset(t,r){this.lineRects.forEach(i=>i.offsetInPlace(t,r)),this.dotRects.forEach(i=>i.offsetInPlace(t,r)),this.rect.offsetInPlace(t,r)}},Ca=class extends tt{constructor(t){super(t);this.measure=t;p(this,"staffTabObjects",[]);p(this,"barLineType",0)}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let o=this.staffTabObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}layout(t){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,lineWidth:i}=t,{measure:o,barLineType:s}=this,{row:a}=o,c=i,u=.7*r,l=.7*r,h=ct.DotSize*r,d=h/2;a.getNotationLines().forEach(m=>{let f=new Lu(this,m),g,b,x,I,w=(_,v)=>{f.lineRects.push(new F(_,_+v/2,_+v,x,0,I))},S=_=>{for(let v=-1;v<=1;v+=2){let C=g+v*b;f.dotRects.push(new F(_-d,_,_+d,C-d,C,C+d))}};switch(m instanceof Tt?(g=m.getMiddleLineY(),b=m.getDiatonicSpacing()):(g=(m.getBottomLineY()+m.getTopLineY())/2,b=(m.getBottomLineY()-m.getTopLineY())/6),x=m.getTopLineY(),I=m.getBottomLineY(),s){case 0:f.setRect(new F(0,0,0,x,0,I));break;case 1:f.setRect(new F(-c,0,0,x,0,I)),w(-c,c);break;case 2:f.setRect(new F(-c-l-c,0,0,x,0,I)),w(-c-l-c,c),w(-c,c);break;case 3:f.setRect(new F(-u-l-c,0,0,x,0,I)),w(-c-l-u,c),w(-u,u);break;case 4:f.setRect(new F(0,0,u+l+c+l+h,x,0,I)),w(0,u),w(u+l,c),S(u+l+c+l+d);break;case 5:f.setRect(new F(-u-l-c-l-h,0,0,x,0,I)),w(-c-l-u,c),w(-u,u),S(-c-l-u-l-d);break;case 6:f.setRect(new F(-h-l-c-l-u/2,0,u/2+l+c+l+h,x,0,I)),w(-u/2,u),w(-u/2-l-c,c),w(u/2+l,c),S(-u/2-l-c-l-d),S(u/2+l+c+l+d);break}this.staffTabObjects.push(f)})}updateRect(){if(this.staffTabObjects.length>0){this.rect=this.staffTabObjects[0].getRect().copy();for(let t=1;t<this.staffTabObjects.length;t++)this.rect.expandInPlace(this.staffTabObjects[t].getRect())}else this.rect=new F}offset(t,r){this.staffTabObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let r=t.getCanvasContext();!r||this.barLineType===0||(t.drawDebugRect(this.getRect()),r.strokeStyle=r.fillStyle="black",this.staffTabObjects.forEach(i=>{i.lineRects.forEach(o=>r.fillRect(o.left,o.top,o.width,o.height)),i.dotRects.forEach(o=>t.fillCircle(o.centerX,o.centerY,o.width/2))}))}},Qr=class extends Ca{constructor(t){super(t);p(this,"mi");this.mi=new Fo(this)}getMusicInterface(){return this.mi}solveBarLineType(){let t=this.measure,r=t.getPrevMeasure();return t.hasNavigation("startRepeat")?r&&r.row===t.row&&r.hasNavigation("endRepeat")?0:4:0}},Tr=class extends Ca{constructor(t){super(t);p(this,"playerProps");p(this,"mi");this.playerProps=new vn(this),this.mi=new Po(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let t=this.measure,r=t.getNextMeasure();return t.hasNavigation("endRepeat")?r&&r.row===t.row&&r.hasNavigation("startRepeat")?6:5:!t.doc.hasSingleMeasure()&&(t.hasEndSong()||!t.getNextMeasure())?3:t.hasEndSection()||t===t.row.getLastMeasure()&&r&&r.row===t.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var vi=class extends tt{constructor(t,r){super(t);this.measure=t;this.passages=r;p(this,"endingText");p(this,"shapeRects",[]);p(this,"mi");if(this.mi=new Vo(this),A.Is.isIntegerGte(r.length,1)){if(!this.passages.every(o=>A.Is.isIntegerGte(o,1)))throw new O(6,"Invalid passages: "+this.passages)}else throw new O(6,"Passages is empty.");this.passages.sort((o,s)=>o-s);let i=this.passages.map(o=>o+".").join("");this.endingText=new nt(this,i,0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:t}=this,r=t.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||t.hasNavigation("endRepeat")||t.isLastMeasure()}hasPassage(t){return this.passages.some(r=>r===t)}getHighestPassage(){return Math.max(0,...this.passages)}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){this.rect=new F,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(t){let{unitSize:r}=t,{measure:i}=this;this.endingText.layout(t);let o=this.endingText.getRect(),s=i.getColumnsContentRect(),a=o.height;this.rect=new F(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new F(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new F(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new F(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().copy()]}offset(t,r){this.endingText.offset(t,r),this.shapeRects.forEach(i=>i.offsetInPlace(t,r)),this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{lineWidth:i}=t,{rect:o}=this;t.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle="black",r.lineWidth=i,r.beginPath(),r.moveTo(o.left,o.bottom),r.lineTo(o.left,o.top),r.lineTo(o.right,o.top),this.isSingleMeasureEnding()&&r.lineTo(o.right,o.bottom),r.stroke(),this.endingText.draw(t)}};var Kx=(n,e)=>{let t=ct.BeamAngleFactor;if(!Number.isFinite(t)||t===0)return e;{let r=n/e/t;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),n/r*t}},Go=class{constructor(e,t,r,i,o){this.staff=e;this.beamGroup=t;this.symbol=r;this.x=i;this.y=o;p(this,"topBeamsHeight",0);p(this,"bottomBeamsHeight",0);e.addObject(this)}offset(e,t){this.x+=e,this.y+=t,this.beamGroup.requestRectUpdate()}getRect(){return new F(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},ju=class extends tt{constructor(t,r){super(t);this.staff=t;this.beamGroup=r;p(this,"tupletNumber");p(this,"tupletNumberOffsetY",0);p(this,"points",[]);p(this,"mi");t.addObject(this),this.mi=new Wo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}offset(t,r){var i;this.points.forEach(o=>o.offset(t,0)),(i=this.tupletNumber)==null||i.offset(t,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().copy():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().copy()),this.points.forEach(t=>this.rect.expandInPlace(t.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Ii=class n extends tt{constructor(t,r){super(t[0].measure);this.symbols=t;this.tupletRatio=r;p(this,"mi");p(this,"type");p(this,"staffObjects",[]);this.mi=new qo(this);let i=r?"Tuplet":"BeamGroup";if(t.every(o=>o.measure===t[0].measure)){if(t.length<2)throw new O(6,`${i} needs minimum 2 symbols, but ${t.length} given.`)}else throw new O(6,`All ${i} symbols are not in same measure.`);if(r!==void 0){let o=t.length<3||t.some(s=>!(s instanceof xt))||t.some(s=>s.rhythmProps.flagCount!==t[0].rhythmProps.flagCount);t.length>=3&&t[0]instanceof xt&&t[t.length-1]instanceof xt&&t[0].rhythmProps.flagCount===t[t.length-1].rhythmProps.flagCount&&(o=!1),t.some(s=>_t.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,this.setTupletBeamCounts()}else this.type=0,this.setBeamCounts();if(t.every(o=>o.getBeamGroup()===void 0))t.forEach(o=>o.setBeamGroup(this)),t[0].measure.addBeamGroup(this);else throw new O(6,`Cannot add ${i} because some symbol already has one.`);this.type===0&&this.symbols.filter(o=>o instanceof xt).some((o,s)=>{let a=s===0,c=s===this.symbols.length-1;(a&&o.getRightBeamCount()===0||c&&o.getLeftBeamCount()===0||!a&&!c&&(o.getLeftBeamCount()===0||o.getRightBeamCount()===0))&&this.detach()})}get showTupletRatio(){var t;return((t=this.tupletRatio)==null?void 0:t.showRatio)===!0}static createBeam(t){t.length>1&&t.every(r=>!r.hasTuplet())&&new n(t,void 0)}static createOldStyleTriplet(t){let r=t.slice(0,2),i=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(i[0]*2===i[1]||i[1]*2===i[0]))return new n(r,gr.Triplet),2;let o=t.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);return o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0])?(new n(o,gr.Triplet),3):0}static createTuplet(t,r){new n(t,r)}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(t=>t.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getTupletRatioText(){var t,r,i;return this.showTupletRatio?String((t=this.tupletRatio)==null?void 0:t.parts)+":"+String((r=this.tupletRatio)==null?void 0:r.inTimeOf):String((i=this.tupletRatio)==null?void 0:i.parts)}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get stemDir(){return this.symbols[0].ownStemDir}layout(t){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let i=r[0].voiceId;if(r.some(c=>c.voiceId!==i))return;let{unitSize:o}=t,{stemDir:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var q,L;if(!c)return;let l=a.map(k=>{var P;return(P=k[u])==null?void 0:P.x}),h=a.map(k=>{var P;return(P=k[u])==null?void 0:P.y}),d=a.map(k=>{var P;return(P=k[u])==null?void 0:P.staff}),m=a.map(k=>{var P;return(P=k[u])==null?void 0:P.stemHeight}),f=r[0],g=l[0],b=h[0],x=d[0],I=r[r.length-1],w=l[l.length-1],S=h[h.length-1],_=d[h.length-1];if(g===void 0||b===void 0||x===void 0||w===void 0||S===void 0||_===void 0)return;let v=(q=m[0])!=null?q:0,C=(L=m[m.length-1])!=null?L:0;if(this.type!==2){let k=v<C?Math.sqrt(C-v):0,P=C<v?Math.sqrt(v-C):0;s==="up"&&(k*=-1,P*=-1),k!==0&&(b+=k,h[0]+=k),P!==0&&(S+=P,h[h.length-1]+=P)}let y=o*2*(s==="up"?-1:1),T=(S+b)/2,E=Kx(w-g,S-b)/2;b=T-E,S=T+E;let R=0;h.forEach((k,P)=>{let G=l[P];if(G!==void 0&&k!==void 0){let Q=A.Math.interpolateY(g,b,w,S,G),Y=k-Q;s==="up"&&Y<0?R=Math.min(R,Y):s==="down"&&Y>0&&(R=Math.max(R,Y))}}),b+=R,S+=R,h=h.map(k=>k===void 0?void 0:k+R);let M=new ju(c,this);if(this.type===2){let k=o/(w-g),P=A.Math.interpolateCoord(g,b+y,w,S+y,-k),G=A.Math.interpolateCoord(g,b+y,w,S+y,1+k);M.points.push(new Go(x,this,f,P.x,P.y)),M.points.push(new Go(_,this,I,G.x,G.y)),M.tupletNumberOffsetY=0}else if(this.type===0||this.type===1){R*=.5;let{beamThickness:k}=t,P=G=>{let Q=r[G];if(Q instanceof xt){let Y=Q instanceof xt?Math.max(Q.getLeftBeamCount(),Q.getRightBeamCount()):0;return ct.BeamSeparation*o*(this.stemDir==="up"?Y-1:0)}else return 0};r.forEach((G,Q)=>{let Y=d[Q],V=l[Q],ut=h[Q];if(Y&&V!==void 0&&ut!==void 0){let At=new Go(Y,this,G,V,ut);At.topBeamsHeight=k/2+(s==="down"?P(Q):0),At.bottomBeamsHeight=k/2+(s==="up"?P(Q):0),M.points.push(At)}}),M.tupletNumberOffsetY=y}this.isTuplet()&&(M.tupletNumber=new nt(this,this.getTupletRatioText(),.5,.5),M.tupletNumber.layout(t),M.tupletNumber.offset((g+w)/2,(b+S)/2+M.tupletNumberOffsetY)),M.points.length>=2&&this.staffObjects.push(M)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;else{this.staffObjects.forEach(t=>t.updateRect()),this.rect=this.staffObjects[0].getRect().copy();for(let t=1;t<this.staffObjects.length;t++)this.rect.expandInPlace(this.staffObjects[t].getRect())}}updateStemTips(){this.staffObjects.forEach(t=>{let r=t.points[0],i=t.points[t.points.length-1];if(this.type!==2&&t.points.forEach(o=>{o.symbol instanceof xt&&(o!==r&&o!==i&&(o.y=A.Math.interpolateY(r.x,r.y,i.x,i.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),t.tupletNumber){let o=(r.y+i.y)/2+t.tupletNumberOffsetY;t.tupletNumber.offset(0,-t.tupletNumber.getRect().centerY+o)}})}offset(t,r){this.staffObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let{unitSize:r,beamThickness:i,lineWidth:o}=t,s="black";this.staffObjects.forEach(a=>{if(this.type===2){let c=a.points[0],u=a.points[a.points.length-1];if(c&&u){let l=a.tupletNumber?a.tupletNumber.getRect().width/(u.x-c.x)*1.2:0,h=A.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5-l/2),d=A.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5+l/2),m=this.stemDir==="up"?r:-r;t.drawLine(c.x,c.y,h.x,h.y,s,o),t.drawLine(d.x,d.y,u.x,u.y,s,o),t.drawLine(c.x,c.y,c.x,c.y+m,s,o),t.drawLine(u.x,u.y,u.x,u.y+m,s,o)}}else if(this.type===0||this.type===1){let c=ct.BeamSeparation*r*(this.stemDir==="up"?1:-1),u=a.points.filter(l=>l.symbol instanceof xt);for(let l=0;l<u.length-1;l++){let h=u[l],d=u[l+1];if(!(h.symbol instanceof xt&&d.symbol instanceof xt))continue;let m=h.symbol.getRightBeamCount(),f=d.symbol.getLeftBeamCount(),g=h.x,b=h.y,x=d.x,I=d.y,w=c*(1+.5*Math.abs(Math.atan2(I-b,x-g)));for(let S=0;S<Math.max(m,f);S++)S<m&&S<f?t.drawLine(g,b,x,I,s,i):m>f?t.drawPartialLine(g,b,x,I,0,.25,s,i):f>m&&t.drawPartialLine(g,b,x,I,.75,1,s,i),b+=w,I+=w}}a.tupletNumber&&a.tupletNumber.draw(t)})}setBeamCounts(){let t=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:l,noteSize:h,dotCount:d}=s.rhythmProps;return a>0&&l>0&&u>0&&d===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||t(a,s)||t(s,a)?s.setLeftBeamCount(s.rhythmProps.flagCount):s.setLeftBeamCount(Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount))),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||t(c,s)||t(s,c)?s.setRightBeamCount(s.rhythmProps.flagCount):s.setRightBeamCount(Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount))))}let i;do{i=!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),i=!0),c&&c.getLeftBeamCount()>0&&(c.setLeftBeamCount(0),i=!0))}}while(i)}setTupletBeamCounts(){let t=this.getType(),r=this.getSymbols();t===1?r.forEach((i,o)=>{i instanceof xt&&(i.setLeftBeamCount(o===0?0:i.rhythmProps.flagCount),i.setRightBeamCount(o===r.length-1?0:i.rhythmProps.flagCount))}):t===2&&r.forEach(i=>{i instanceof xt&&(i.setLeftBeamCount(0),i.setRightBeamCount(0))})}};var In=class extends tt{constructor(t,r){super(t);this.pos=r;p(this,"color","black");p(this,"mi");this.mi=new Uo(this)}getMusicInterface(){return this.mi}static getFermataPositions(t){let{measure:r}=t,{row:i}=r;return i.getTopStaff()!==i.getBottomStaff()?[0,1]:[0]}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t,i=r*4,o=r*3;this.rect=new F(-i/2,i/2,-o,0)}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{lineWidth:i,unitSize:o}=t,s=this.pos===1,a=(s?o:-o)*.7,c=this.rect.left,u=this.rect.right,l=(s?this.rect.bottom:this.rect.top)+a,h=(s?this.rect.top:this.rect.bottom)+a,d=h-l;t.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i,r.beginPath(),r.moveTo(c,h),r.bezierCurveTo(c,l,u,l,u,h),r.bezierCurveTo(u,l+d/5,c,l+d/5,c,h),r.stroke(),r.fill();let m=d/6;t.fillCircle((c+u)/2,h-m,Math.abs(m))}};var Sn=class extends tt{constructor(t,r,i,o,s){super(t);this.measure=t;this.line=r;this.extension=i;this.leftObj=o;this.rightObj=s;p(this,"mi");i.addTail(this),this.mi=new zo(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(){return this.leftObj instanceof Qr?this.leftObj.getRect().centerX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof wr){let t=this.rightObj,r=t.getNextColumn();return r&&r.measure===t.measure?(t.getRect().right+r.getRect().left)/2:(t.getRect().right+t.measure.getBarLineRight().getRect().left)/2}else return this.rightObj.getRect().centerX}layoutFitToMeasure(t){let{unitSize:r}=t,i=this.getLineLeft(),o=this.getLineRight(),s=r;this.rect=new F(i,o,-s/2,s/2)}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){this.rect=new F}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{rect:i}=this;this.extension.getLineStyle()==="dashed"&&r.setLineDash([7,3]),t.drawLine(i.left,i.centerY,i.right,i.centerY,"black",t.lineWidth),r.setLineDash([]);let o=this.extension.getTails();if(o.length>0&&this===o[o.length-1]){let s=i.centerY>this.line.getRect().centerY?-t.unitSize:t.unitSize;t.drawLine(i.right,i.centerY,i.right,i.centerY+s,"black",t.lineWidth)}}};var Si=class extends tt{constructor(t,r,i,o,s,...a){super(i);this.connectiveProps=t;this.line=r;this.measure=i;p(this,"lx",0);p(this,"ly",0);p(this,"rx",0);p(this,"ry",0);p(this,"cp1x",0);p(this,"cp1y",0);p(this,"cp2x",0);p(this,"cp2y",0);p(this,"arcHeight",0);p(this,"leftNoteGroup");p(this,"leftNoteId");p(this,"rightNoteGroup");p(this,"rightNoteId");p(this,"tieType");p(this,"mi");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):A.Is.isEnumValue(a[0],Ke)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new Yo(this)}getMusicInterface(){return this.mi}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t,{measure:i,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:d}=l,{row:m}=i,f=m.getPrevRow(),g=m.getNextRow(),b=m.getConnectivesContentRect(),x,I;x=s.getConnectiveAnchorPoint(l,o,a,h,"left"),c!==void 0&&u!==void 0?I=c.getConnectiveAnchorPoint(l,o,u,h,"right"):I=this.tieType==="toMeasureEnd"?{x:i.getColumnsContentRect().right,y:x.y}:{x:x.x+r*ct.StubTieLength,y:x.y};let w,S,_,v;if(c===void 0)w=x.x,S=x.y,_=I.x,v=I.y;else if(s.row===m&&c.row===m)w=x.x,S=x.y,_=I.x,v=I.y;else if(s.row===f&&c.row===m){let M=f.getConnectivesContentRect().right-x.x,q=I.x-b.left;w=b.left,S=x.y+(I.y-x.y)*M/(M+q),_=I.x,v=I.y}else if(s.row===m&&c.row===g){let R=g.getConnectivesContentRect(),M=b.right-x.x,q=I.x-R.left;w=x.x,S=x.y,_=b.right,v=x.y+(I.y-x.y)*M/(M+q)}else throw new O(6,"Cannot layout connective object because no valid left and right note groups.");let y=(d==="up"?-1:1)*r*Math.log2(_-w)/3;this.lx=w,this.ly=S,this.rx=_,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:y;let{nx:T,ny:E}=A.Math.calcNormal(w,S,_,v);this.cp1x=w*.7+_*.3+T*this.arcHeight,this.cp1y=S*.7+v*.3+E*this.arcHeight,this.cp2x=w*.3+_*.7+T*this.arcHeight,this.cp2y=S*.3+v*.7+E*this.arcHeight,this.rect=new F(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(t,r){this.lx+=t,this.ly+=r,this.rx+=t,this.ry+=r,this.cp1x+=t,this.cp1y+=r,this.cp2x+=t,this.cp2y+=r,this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;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:i}=this,{lineWidth:o}=t;t.drawDebugRect(i);let s=o*1.5,a=o*.25;r.strokeStyle=r.fillStyle="black",r.lineWidth=o,this.arcHeight===0?(r.beginPath(),r.moveTo(this.lx,this.ly),r.lineTo(this.rx,this.ry),r.stroke()):(r.beginPath(),r.moveTo(this.lx,this.ly-a),r.bezierCurveTo(this.cp1x,this.cp1y-s,this.cp2x,this.cp2y-s,this.rx,this.ry-a),r.lineTo(this.rx,this.ry+a),r.bezierCurveTo(this.cp2x,this.cp2y+s,this.cp1x,this.cp1y+s,this.lx,this.ly+a),r.fill())}};var wn=class{constructor(e,t,r,i){this.connective=e;this.span=t;this.noteAnchor=r;p(this,"noteGroups");p(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(e){return this.noteGroups[0]===e}addNoteGroup(e){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(e),!0):!1}computeParams(){let{stemDir:e}=this.noteGroups[0],{hasStem:t}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=e==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=e==="up"||!t?"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{row:r}=this.noteGroups[0].measure,i=this.noteGroups[0].ownDiatonicId,o=r.getStaff(i);this.arcDir=!o||i<o.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(e=>{e.measure.removeConnectiveObjects(),e.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){this.getStartNoteGroup().collectConnectiveProps(),this.computeParams();let{connective:e,span:t}=this;if(e==="tie"){if(A.Is.isEnumValue(t,Ke)){let r=this.noteGroups[0];for(let i=0;i<r.notes.length;i++)this.createObjConnectiveWithTieType(r,i,t)}else if(this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];i.notes.forEach((s,a)=>{let c=o.notes.findIndex(u=>U.equals(u,s));c>=0&&this.createObjConnective(i,a,o,c)})}}else if(e==="slur"){if(typeof t=="number"&&t>=2&&this.noteGroups.length===t){let r=this.noteGroups[0],i=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,0,i,0)}}else if(e==="slide"&&this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];this.createObjConnective(i,0,o,0)}}createObjConnectiveWithTieType(e,t,r){e.row.getNotationLines().filter(i=>e.enableConnective(i)).forEach(i=>{i instanceof Tt?new Si(this,i,e.measure,e,t,r):e.getFretNumberString(t)!==void 0&&new Si(this,i,e.measure,e,t,r)})}createObjConnective(e,t,r,i){let o=(s,a,c,u,l)=>{s.row.getNotationLines().filter(h=>a.enableConnective(h)&&u.enableConnective(h)).forEach(h=>{if(h instanceof Tt)new Si(this,h,s,a,c,u,l);else{let d=a.getFretNumberString(c),m=u.getFretNumberString(l);d!==void 0&&m!==void 0&&(d===m||this.connective==="slur")&&new Si(this,h,s,a,c,u,l)}})};if(e.measure===r.measure)o(e.measure,e,t,r,i);else if(e.measure.getNextMeasure()===r.measure)o(e.measure,e,t,r,i),o(r.measure,e,t,r,i);else throw new O(6,"Cannot create connective because it is jumping measures.")}};var Tn=class extends tt{constructor(t,r){super(t);this.measure=t;this.tab=r;p(this,"voiceIds");p(this,"mi");p(this,"tupletPartsTextObjMap",new Map);this.voiceIds=Kt().filter(i=>r.containsVoiceId(i)),this.rect=new F,this.mi=new Ho(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let r=this.measure.getColumns(),i=Kt().map(o=>A.Math.sum(r.map(s=>s.getVoiceSymbol(o)?1:0)));this.voiceIds.sort((o,s)=>A.Math.cmp(i[o],i[s])),this.rect=new F}hasTuplets(){return this.measure.getBeamGroups().some(t=>t.isTuplet())}layoutFitToMeasure(t){let{unitSize:r,fontSize:i}=t,{measure:o}=this,{left:s,right:a}=o.getColumnsContentRect(),c=r*5;this.rect.left=s,this.rect.centerX=(s+a)/2,this.rect.right=a,this.rect.top=this.hasTuplets()?-i:0,this.rect.centerY=0,this.rect.bottom=c}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.rect);let{unitSize:i,lineWidth:o,fontSize:s}=t,a=i,c=i,u=i*.25,{bottom:l,centerY:h}=this.getRect(),d=h,m=l,f=this.measure.getColumns();for(let g=0;g<f.length;g++){let b=f[g],x=this.voiceIds.map(S=>b.getVoiceSymbol(S)).find(S=>S!==void 0);if(!x)continue;let I=x.getBeamGroup(),w=I?I.getSymbols():[x];for(let S=0;S<w.length;S++){let _=w[S],v=w[S+1],C=_.col.getRect().centerX;if(_ instanceof xt){if(_.rhythmProps.noteSize>=2){let y=_.rhythmProps.noteSize===4?o*2:o;t.drawLine(C,m,C,d,"black",y)}if(w.length===1)for(let y=0;y<_.rhythmProps.flagCount;y++)t.drawFlag(new F(C,C+a,d+y*a,d+(y+2)*a),"up");for(let y=0;y<_.rhythmProps.dotCount;y++)t.fillCircle(C+c*(y+1),m-u,u)}else if(_ instanceof Sr){let y=C,T=(d+m)/2,E=.65;r.save(),r.scale(E,E),t.drawRest(_.rhythmProps.noteSize,y/E,T/E,"black"),r.restore();for(let R=0;R<_.rhythmProps.dotCount;R++)y+=c*1.5,t.fillCircle(y,T+c,u)}if(v){let y=_,T=v,E=y.col.getRect().centerX,R=T.col.getRect().centerX,M=y.hasTuplet()?1:y instanceof xt?y.getRightBeamCount():1,q=T.hasTuplet()?1:T instanceof xt?T.getLeftBeamCount():1,L=Math.max(M,q);for(let k=0;k<L;k++){let P=q>M&&k>=M?.75:0,G=M>q&&k>=q?.25:1;t.drawPartialLine(E,d+k*a,R,d+k*a,P,G,"black",o*2)}for(let k=0;k<y.rhythmProps.dotCount;k++)t.fillCircle(E+c*(k+1),m-u,u);for(let k=0;k<T.rhythmProps.dotCount;k++)t.fillCircle(R+c*(k+1),m-u,u)}if(I&&I.isTuplet()){let y=(w[0].col.getRect().centerX+w[w.length-1].col.getRect().centerX)/2,T=I.getTupletRatioText(),E=this.tupletPartsTextObjMap.get(T);E||(this.tupletPartsTextObjMap.set(T,E=new nt(this,{text:T,scale:.75},.5,.5)),E.layout(t)),E.offset(-E.getRect().centerX,-E.getRect().centerY),E.offset(y,d-s/2),E.draw(t)}w.length>1&&(g=f.indexOf(w[w.length-1].col),g<0&&(g=f.length))}}}};function xa(n){if(typeof n=="number"&&Kt().indexOf(n)<0)throw new O(6,"Invalid voiceId: "+n);return n}function Jx(n){if(typeof n=="string"&&(n=[n]),A.Is.isArray(n)){let e=0;for(let t=0;t<n.length;){let r=n[t],i=n[t+1];if(typeof r=="string"){t++;let o=Gt.get(r).ticks;typeof i=="number"&&(t++,o*=i),e+=o}else t++}return e}else return n}function $x(n){switch(n){case 1:return 8;case 2:return 9;case 3:return 10;default:throw new O(0,"VerseNumber is not 1, 2 or 3.")}}var _a=class _a extends tt{constructor(t){super(t);this.row=t;p(this,"prevMeasure");p(this,"nextMeasure");p(this,"keySignature",as());p(this,"timeSignature",hs());p(this,"tempo",ds());p(this,"alterKeySignature");p(this,"alterTimeSignature");p(this,"alterTempo");p(this,"signatures",[]);p(this,"tabStringNotes",[]);p(this,"barLineLeft");p(this,"columns",[]);p(this,"barLineRight");p(this,"connectives",[]);p(this,"beamGroups",[]);p(this,"tabStringNotesWidth",0);p(this,"measureId");p(this,"needLayout",!0);p(this,"leftSolidAreaWidth",0);p(this,"minColumnsAreaWidth",0);p(this,"rightSolidAreaWidth",0);p(this,"useDiatonicId",[]);p(this,"useStemDir",[]);p(this,"useString",[]);p(this,"voiceSymbols",[]);p(this,"lastAddedRhythmColumn");p(this,"lastAddedRhythmSymbol");p(this,"addExtensionToMusicObjects",[]);p(this,"layoutObjects",[]);p(this,"postMeasureBreakWidth",0);p(this,"passCount",0);p(this,"needBeamsUpdate",!0);p(this,"navigationSet",new Set);p(this,"isEndSong",!1);p(this,"isEndSection",!1);p(this,"endRepeatPlayCount",2);p(this,"endRepeatPlayCountText");p(this,"staticObjectsCache",new Map);p(this,"lyricsObjectsCache",new Map);p(this,"mi");this.mi=new Zo(this),this.prevMeasure=t.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new Qr(this),this.barLineRight=new Tr(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo(),this.row.getTabs().forEach(r=>{this.addLayoutObject(new Tn(this,r),r,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}updateOwnDiatonicId(t,r){if(typeof r=="number")this.useDiatonicId[t]=r;else if(this.useDiatonicId[t]===void 0){let o=this.getPrevMeasure();o&&o.useDiatonicId[t]!==void 0&&(this.useDiatonicId[t]=o.useDiatonicId[t])}let i=this.useDiatonicId[t];return i===void 0&&(this.row.hasStaff?i=this.row.getTopStaff().middleLineDiatonicId:i=U.getNote("C4").diatonicId),this.useDiatonicId[t]=U.validateDiatonicId(i)}updateOwnStemDir(t,r){var s,a;let{voiceId:i}=t;r!==void 0?this.useStemDir[i]=r:this.useStemDir[i]===void 0&&(this.useStemDir[i]=(a=(s=this.getPrevMeasure())==null?void 0:s.useStemDir[i])!=null?a:"auto");let o=this.useStemDir[i];if(o==="auto"||o===void 0){let c=this.row.getStaff(t.ownDiatonicId);return c?t.ownDiatonicId>c.middleLineDiatonicId?"down":"up":"up"}else return o}updateOwnString(t,r){var o,s;let{voiceId:i}=t;return r!==void 0?this.useString[i]=r:this.useString[i]===void 0&&(this.useString[i]=(s=(o=this.getPrevMeasure())==null?void 0:o.useString[i])!=null?s:[]),this.useString[i]}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.signatures.length;i++){let o=this.signatures[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabStringNotes.length;i++){let o=this.tabStringNotes[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.columns.length;i++){let o=this.columns[i].pick(t,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let i=this.barLineLeft.pick(t,r);if(i.length>0)return[this,...i]}if(this.barLineRight){let i=this.barLineRight.pick(t,r);if(i.length>0)return[this,...i]}if(this.endRepeatPlayCountText){let i=this.endRepeatPlayCountText.pick(t,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.connectives.length;i++){let o=this.connectives[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.beamGroups.length;i++){let o=this.beamGroups[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.layoutObjects.length;i++){let o=this.layoutObjects[i].musicObj.pick(t,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let t=this.doc.getFirstMeasure();return t&&t.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(t){return this.getColumns()[t]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...t){var r;if((r=this.getPrevMeasure())==null||r.endSection(),t[0]instanceof Fe)this.alterKeySignature=t[0];else if(t[0]instanceof Lr)this.alterKeySignature=t[0];else if(A.Is.isNonEmptyString(t[0])){if(t.length===1)this.alterKeySignature=mr(t[0]);else if(t.length===2)try{let i=""+t[0],o=Vn(""+t[1]);this.alterKeySignature=mr(i,o)}catch(i){throw new O(6,"Cannot set key signature because invalid args: "+t)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:as(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(t){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=t,this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:hs(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(t,r,i){var o;if((o=this.getPrevMeasure())==null||o.endSection(),r===void 0)this.alterTempo={beatsPerMinute:t};else{let s=typeof i=="number"&&i>0?i:i===!0?1:_t.get(r).dotCount,a={beatLength:Ae(r),dotCount:s>0?s:void 0};this.alterTempo={beatsPerMinute:t,options:a}}this.updateTempo()}updateTempo(){var t;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:ds(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,o;this.alterTempo.options?(i=this.alterTempo.options.beatLength,o=(t=this.alterTempo.options.dotCount)!=null?t:0):this.alterTimeSignature?(i=this.alterTimeSignature.beatLength,o=0):(i=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:i,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(t,r,i,o){this.layoutObjects.push(new va(t,r,i,o)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(t,r,i){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&i(o[a],c);else if(typeof a=="string"&&a.length>0){let l=o.filter(h=>h.name===a);if(l.forEach(h=>i(h,c)),l.length===0){let h=this.doc.getStaffGroup(a);if(h&&!u.includes(a)){let d=[...u,a];(A.Is.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(m=>{switch(h.verticalPosition){case"above":s(m,0,d);break;case"below":s(m,1,d);break;case"both":s(m,0,d),s(m,1,d);break;case"auto":s(m,r,d);break}})}}}};t===void 0?o.length>=2&&o[0]instanceof Tt&&o[1]instanceof Tt&&o[0].staffConfig.grandId!==void 0&&o[0].staffConfig.grandId===o[1].staffConfig.grandId?s(r===1?1:0,r):s(0,r):A.Is.isArray(t)?t.forEach(a=>s(a,r)):s(t,r)}addFermata(t,r){let i=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new O(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(t,0,(o,s)=>{this.addLayoutObject(new In(i,s),o,1,s)}),this.disableExtension(),this.requestLayout()}hasFermata(t){return this.layoutObjects.some(r=>r.musicObj instanceof In&&r.anchor===t)}addNavigation(t,r,...i){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new O(6,"Cannot add ending beasure measure already has one.");let s=this,a=i;o={createObj:()=>new vi(s,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=Lo(r);o={createObj:()=>new nt(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0},this.addNavigation(t,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=Lo(r);o={createObj:()=>new nt(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=Lo(r);o={createObj:()=>new $e(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=Lo(r);o={createObj:()=>new $e(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"endRepeat":if(i.length===0)this.endRepeatPlayCount=2;else if(A.Is.isIntegerGte(i[0],2))this.endRepeatPlayCount=i[0];else throw new O(6,"Invalid end repeat play count (should be 2 or greater integer): "+i[0]);if(this.endRepeatPlayCount!==2){let c={text:""+this.endRepeatPlayCount+"x",scale:.8};this.endRepeatPlayCountText=new nt(this,c,.5,1)}break}o&&this.forEachStaffGroup(t,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(t){return this.navigationSet.has(t)}addAnnotation(t,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add annotation because annotation text is empty.")}else throw new O(6,"Cannot add annotation because anchor is undefined.");let s={text:i},a,c;switch(r){case"dynamics":a=6,c=0,s.italic=!0;break;case"tempo":a=5,c=0,s.italic=!0;break}this.disableExtension(),this.forEachStaffGroup(t,c,(u,l)=>{let h=new nt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(t,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add label because label text is empty.")}else throw new O(6,"Cannot add label because anchor is undefined.");let s={text:i},a,c;switch(r){case"note":a=2,c=1;break;case"chord":a=7,c=0;break}this.disableExtension(),this.forEachStaffGroup(t,c,(u,l)=>{let h=new nt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addConnective(t,...r){let i=this.lastAddedRhythmSymbol;if(!(i instanceof xt))throw new O(6,"Connective can be added to note group only.");if(t==="tie"){let o=A.Is.isInteger(r[0])||A.Is.isEnumValue(r[0],Ke)?r[0]:2,s=A.Is.isEnumValue(r[1],Pe)?r[1]:"auto";i.startConnective(new wn("tie",o,s,i))}else if(t==="slur"){let o=A.Is.isInteger(r[0])?r[0]:2,s=A.Is.isEnumValue(r[1],Pe)?r[1]:"auto";i.startConnective(new wn("slur",o,s,i))}else if(t==="slide"){let o=A.Is.isEnumValue(r[0],Pe)?r[0]:"auto";i.startConnective(new wn("slide",2,o,i))}}addExtension(t,r){if(this.addExtensionToMusicObjects.forEach(i=>{let o=i.getParent();if(i instanceof nt&&o instanceof wr){let s="dashed",a="bottom",c=new _i(i,o,Jx(t),r,s,a);i.setLink(c)}else throw new O(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new O(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(t){this.addExtensionToMusicObjects.push(t)}disableExtension(){this.addExtensionToMusicObjects=[]}getEnding(){return this.layoutObjects.map(t=>t.musicObj).find(t=>t instanceof vi)}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(t){var o,s;let{col:r,voiceId:i}=t;r.setVoiceSymbol(i,t),(s=(o=this.voiceSymbols)[i])!=null||(o[i]=[]),this.voiceSymbols[i].push(t),t.oldStyleTriplet&&this.createOldStyleTriplets(i),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=r,this.lastAddedRhythmSymbol=t}addNoteGroup(t,r,i,o,s){let a=r.map(l=>typeof l=="string"?U.getNote(l):l),c=this.getRhythmColumn(t),u=new xt(c,t,a,i,o,s);return this.addRhythmSymbol(u),u}addRest(t,r,i,o){let s=this.getRhythmColumn(t),a=new Sr(s,t,r,i,o);return this.addRhythmSymbol(a),a}addLyrics(t,r,i,o,s){this.forEachStaffGroup(t,1,(a,c)=>{let u=this.getRhythmColumn({verse:r,line:a,vpos:c}),l=u.getLyricsContainer(r,a,c,Ae(i));if(l){let h=new ba(u,r,a,c,o,s),d=this.getLyricsObjects(h.line,h.vpos,h.verse);d.push(h),d.sort((m,f)=>A.Math.cmp(m.col.positionTicks,f.col.positionTicks)),l.addLyricsObject(h),this.addLayoutObject(h,a,$x(r),c)}this.lastAddedRhythmColumn=u})}getRhythmColumn(t){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let o=this.columns[i],s=typeof t=="number"?o.getVoiceSymbol(t):o.getLyricsContainer(t.verse,t.line,t.vpos);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let i=0;i<=this.columns.length;i++){let o=this.columns[i];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new wr(this,r);return this.columns.splice(i,0,s),s}}throw new O(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(t){let r=0;return this.columns.forEach(i=>{Kt().forEach(o=>{let s=i.getVoiceSymbol(o);s&&(t===void 0||t===o)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new F(this.barLineLeft.getRect().centerX,this.barLineRight.getRect().centerX,this.getRect().top,this.getRect().bottom)}getLeftSolidAreaWidth(){return this.leftSolidAreaWidth}getMinColumnsAreaWidth(){return this.minColumnsAreaWidth}getRightSolidAreaWidth(){return this.rightSolidAreaWidth}getSolidAreaWidth(){return this.leftSolidAreaWidth+this.rightSolidAreaWidth}getMinWidth(){return this.leftSolidAreaWidth+this.minColumnsAreaWidth+this.rightSolidAreaWidth}getStaffLineLeft(){let t=this.getPrevMeasure();return t&&t.row===this.row&&!t.hasPostMeasureBreak()?t.getStaffLineRight():this.getRect().left+this.tabStringNotesWidth}getStaffLineRight(){return this.barLineRight.getRect().centerX}getLyricsObjects(t,r,i){let o=this.lyricsObjectsCache.get(t);o===void 0&&(o=new Map,this.lyricsObjectsCache.set(t,o));let s=o.get(r);s===void 0&&(s=new Map,o.set(r,s));let a=s.get(i);return a===void 0&&(a=[],s.set(i,a)),a}getPrevLyricsObject(t){var o;let r=this.getLyricsObjects(t.line,t.vpos,t.verse),i=r.indexOf(t);if(i>0)return r[i-1];if(i===0){let s=(o=t.measure.getPrevMeasure())==null?void 0:o.getLyricsObjects(t.line,t.vpos,t.verse);if(s&&s.length>0)return s[s.length-1]}}getStaticObjects(t){let r=this.staticObjectsCache.get(t);r||(r=[],this.getColumns().forEach(o=>o.getStaticObjects(t).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(t,r));let i=this.layoutObjects.filter(o=>o.line===t&&o.isPositionResolved()).map(o=>o.musicObj);return i.length>0?[...r,...i]:r}removeLayoutObjects(t){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===t){let i=r.musicObj.getLink();return i&&i.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(t){this.connectives.push(t),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(t=>{var c;let{musicObj:r,measure:i,layoutGroupId:o,verticalPos:s,line:a}=t;if(r.getLink()instanceof _i){let u=r.getLink();if(u.getHead()===r){u.getTails().forEach(d=>i.removeLayoutObjects(d));let{startColumn:l,endColumn:h}=u.getExtensionRangeInfo();if(u.isVisible()&&l!==h)for(let d=l.measure;d!==void 0;d=d===h.measure?void 0:d.getNextMeasure()){let m=d===l.measure?u.getHead():d.getBarLineLeft(),f=d===h.measure?h:d.getBarLineRight(),g=d.row.getNotationLines(),b=(c=g.find(x=>x.name!==""&&x.name===a.name))!=null?c:g[a.id];b&&d.addLayoutObject(new Sn(d,b,u,m,f),b,o,s)}}}})}addBeamGroup(t){this.beamGroups.push(t)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(t){let r=this.getVoiceSymbols(t);for(let i=0;i<r.length;)if(r[i].oldStyleTriplet){let o=Ii.createOldStyleTriplet(r.slice(i,i+3));i+=o===0?1:o}else i++;this.requestLayout()}getBeamGroups(){return this.beamGroups}createBeams(){if(!this.needBeamsUpdate)return;this.beamGroups=this.beamGroups.filter(r=>r.isTuplet()?!0:(r.detach(),!1));let t=this.getTimeSignature();!this.needBeamsUpdate||t.beamGroupSizes.length===0||(Kt().forEach(r=>{let i=this.getVoiceSymbols(r).slice();if(i.length<2)return;let o=this.isUpBeat()?Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()):0,s=0;for(let a=0;a<t.beamGroupSizes.length;a++){let c=t.beamGroupSizes[a],u=[c];c.length>1&&u.unshift([A.Math.sum(c)]);let l=!1,h=s;for(;u.length>0&&!l;){let d=u.shift();s=h,d.forEach(m=>{let f=m*_t.get("8n").ticks,g=i.filter(x=>{let I=o+x.col.positionTicks,w=x.rhythmProps.ticks;return I>=s&&I+w<=s+f});A.Math.sum(g.map(x=>x.rhythmProps.ticks))===f&&g.every(x=>x instanceof xt)&&(g.every(x=>x.rhythmProps.flagCount===1)||u.length===0)&&(Ii.createBeam(g),l=!0),s+=f})}}}),this.needBeamsUpdate=!1,this.requestLayout())}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(t){var r,i;return xa(t),(i=(r=this.voiceSymbols)[t])!=null||(r[t]=[]),this.voiceSymbols[t]}completeRests(t){if(t===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(Kt().filter(r=>this.getConsumedTicks(r)>0));return}else if(A.Is.isArray(t)){t.forEach(r=>this.completeRests(r));return}else{xa(t);let r=this.getMeasureTicks(),i=this.getConsumedTicks(t),o=r-i,s=[];for(;o>0;)for(let a=_t.LongestNoteSize;a<=_t.ShortestNoteSize;a*=2){let c=_t.create(a).noteLength;for(let u=_t.get(c).maxDotCount;u>=0;u--){let l=Gt.get(c,u);for(;l.ticks<=o;)s.push(l),o-=l.ticks}}s.reverse().forEach(a=>this.addRest(t,a.noteLength,{dotted:a.dotCount}))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(t){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=t;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?ct.PostMeasureBreakWidth*r:0;let i=this===this.row.getFirstMeasure(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.tabStringNotesWidth=i&&this.row.hasTab?r*4:0;let s=i||o,a=i&&!this.row.isFirstRow(),c=i||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;this.signatures=[],this.row.getNotationLines().forEach((f,g)=>{if(f instanceof Tt&&(s||a||c||u||l)){let b=this.signatures.filter(I=>I instanceof _o).find(I=>I.staff===f),x=b!=null?b:new _o(this,f);x.staff.addObject(x),x.updateClefImage(t,s),x.updateMeasureNumber(a&&g===0),x.updateKeySignature(c),x.updateTimeSignature(u),x.updateTempo(l&&g===0),x.layout(t),this.signatures.push(x)}else if(f instanceof Se&&(a||u||l)){let b=this.signatures.filter(I=>I instanceof vo).find(I=>I.tab===f),x=b!=null?b:new vo(this,f);x.tab.addObject(x),x.updateMeasureNumber(a&&g===0),x.updateTimeSignature(u),x.updateTempo(l&&g===0),x.layout(t),this.signatures.push(x)}}),this.tabStringNotes.length=0,this===this.row.getFirstMeasure()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let b=f.getTuningStrings()[g].format(1,1),x=new nt(this,{text:b,scale:.8},1,.5);x.layout(t),x.offset(this.tabStringNotesWidth*.8,f.getStringY(g)),this.tabStringNotes.push(x),f.addObject(x)}}),this.barLineLeft.layout(t);let h=new da(this);this.columns.forEach(f=>f.layout(t,h)),this.barLineRight.layout(t),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(t),this.layoutObjects.forEach(f=>f.layout(t));let d=t.unitSize;this.leftSolidAreaWidth=this.tabStringNotesWidth+Math.max(0,...this.signatures.map(f=>f.getRect().width))+this.barLineLeft.getRect().width+d,this.rightSolidAreaWidth=d+this.barLineRight.getRect().width,this.minColumnsAreaWidth=0,this.columns.forEach(f=>this.minColumnsAreaWidth+=f.getRect().width),this.minColumnsAreaWidth=Math.max(this.minColumnsAreaWidth,_a.MinFlexContentWidth*r)}layoutWidth(t,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new F,this.rect.centerX=this.rect.left+r/2,this.rect.right=this.rect.left+r;let i;this.signatures.forEach(d=>{i=d.getRect(),d.offset(this.rect.left+this.tabStringNotesWidth-i.left,-i.centerY)});let o=Math.max(0,...this.signatures.map(d=>d.getRect().width));i=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.tabStringNotesWidth+o-i.left,-i.centerY),i=this.barLineRight.getRect(),this.barLineRight.offset(this.rect.right-i.right,-i.centerY),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left,this.barLineRight.getRect().top);let s=this.rect.left+this.leftSolidAreaWidth,c=this.rect.right-this.rightSolidAreaWidth-s,u=A.Math.sum(this.columns.map(d=>d.getRect().width)),l=c/u,h=s;this.columns.forEach(d=>{i=d.getRect();let m=h+i.leftw*l;d.offset(m-i.centerX,-i.centerY),h+=i.width*l})}layoutConnectives(t){this.needLayout&&this.connectives.forEach(r=>{r.layout(t),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(t){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(t),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(t=>t.updateStemTips())}layoutDone(){this.columns.forEach(t=>t.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(t=>t.getRect().top),...this.tabStringNotes.map(t=>t.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(t=>!t.isEmpty()).map(t=>t.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(t=>t.getRect().top),...this.beamGroups.filter(t=>!t.isEmpty()).map(t=>t.getRect().top),...this.layoutObjects.filter(t=>t.isPositionResolved()).map(t=>t.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(t=>t.getRect().bottom),...this.tabStringNotes.map(t=>t.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(t=>!t.isEmpty()).map(t=>t.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(t=>t.getRect().bottom),...this.beamGroups.filter(t=>!t.isEmpty()).map(t=>t.getRect().bottom),...this.layoutObjects.filter(t=>t.isPositionResolved()).map(t=>t.musicObj.getRect().bottom)),this===this.row.getLastMeasure()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(t=>t.isPositionResolved()&&t.musicObj instanceof In).map(t=>t.musicObj.getRect().right))),this.row.getNotationLines().forEach(t=>{this.rect.top=Math.min(this.rect.top,t.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,t.calcBottom())}),this.row.requestRectUpdate()}offset(t,r){this.signatures.forEach(i=>i.offset(t,0)),this.tabStringNotes.forEach(i=>i.offset(t,0)),this.barLineLeft.offset(t,r),this.columns.forEach(i=>i.offset(t,r)),this.barLineRight.offset(t,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(t,r),this.connectives.forEach(i=>i.offset(t,0)),this.beamGroups.forEach(i=>i.offset(t,r)),this.layoutObjects.forEach(i=>i.offset(t,0)),this.rect.offsetInPlace(t,r),this.requestRectUpdate()}draw(t){t.drawDebugRect(this.getRect());let r=this.getStaffLineLeft(),i=this.getStaffLineRight(),o=a=>t.drawLine(r,a,i,a),{row:s}=this;s.getNotationLines().forEach(a=>{if(a instanceof Tt)for(let c=a.bottomLineDiatonicId;c<=a.topLineDiatonicId;c+=2)o(a.getDiatonicIdY(c));else if(a instanceof Se)for(let c=0;c<6;c++)o(a.getStringY(c))}),this.signatures.forEach(a=>a.draw(t)),this.tabStringNotes.forEach(a=>a.draw(t)),this.barLineLeft.draw(t),this.columns.forEach(a=>a.draw(t)),this.barLineRight.draw(t),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(t),this.connectives.forEach(a=>a.draw(t)),this.layoutObjects.forEach(a=>a.musicObj.draw(t)),this.beamGroups.forEach(a=>a.draw(t))}};p(_a,"MinFlexContentWidth",10);var Nn=_a;var tA=[2,7],eA=[0,3,4,5,6,7,8,9,10];function rA(n){for(;n;){if(n instanceof Nn)return n;n=n.getParent()}throw new O(6,"Parent measure is required but not found!")}var Ia=class{constructor(e,t,r){this.groupName=e;this.staffsTabsAndGroups=t;this.verticalPosition=r}},va=class{constructor(e,t,r,i){this.musicObj=e;this.line=t;this.layoutGroupId=r;this.verticalPos=i;p(this,"anchor");p(this,"measure");p(this,"row");p(this,"layoutGroup");p(this,"positionResolved",!0);this.measure=rA(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new O(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)}clearPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(e){let{musicObj:t,measure:r,verticalPos:i,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=e.unitSize*2,u=i===1?a+c+t.getRect().toph:s-c-t.getRect().bottomh,l=r.getStaticObjects(o),h=t.getShapeRects();return l.forEach(d=>{let m=d.getShapeRects();h.forEach(f=>{m.forEach(g=>{F.overlapX(f,g)&&(u=i===1?Math.max(u,g.bottom+f.toph+f.centerY):Math.min(u,g.top-f.bottomh-f.centerY))})})}),u}getTextContent(){if(this.musicObj instanceof nt||this.musicObj instanceof $e)return this.musicObj.getText()}layout(e){this.line.addObject(this)}offset(e,t){this.musicObj.offset(e,t)}getRect(){return this.musicObj.getRect()}},Sa=class{constructor(e){this.layoutGroupId=e;p(this,"layoutObjectTable",[]);p(this,"rowAlign");p(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=eA.indexOf(e)>=0,this.widensColumn=tA.indexOf(e)>=0}getLayoutObjects(e){return this.layoutObjectTable[e]}add(e){this.layoutObjectTable[e.verticalPos].push(e)}remove(e){this.layoutObjectTable.forEach(t=>{let r=t.indexOf(e);r>=0&&t.splice(r,1)})}clearPositionAndLayout(e){this.layoutObjectTable.forEach(t=>{t.forEach(r=>{r.clearPositionResolved(),r.musicObj.layout(e)})})}};var wa=class extends tt{constructor(t){super(t);p(this,"objects",[]);p(this,"layoutGroups",[])}addObject(t){this.objects.push(t)}removeObjects(){this.objects.length=0}getLayoutGroup(t){let r=this.layoutGroups[t];return r||(r=this.layoutGroups[t]=new Sa(t)),r}resetLayoutGroups(t){this.layoutGroups.forEach(r=>{r&&r.clearPositionAndLayout(t)})}layoutLayoutGroups(t){this.layoutGroups.forEach(r=>{r&&(this.layoutLayoutGroup(t,r,0),this.layoutLayoutGroup(t,r,1))})}setObjectY(t,r){r!==void 0&&(t.offset(0,r-t.getRect().centerY),t.setPositionResolved())}alignObjectsY(t,r){r=r.filter(o=>!o.isPositionResolved());let i;r.forEach(o=>{let s=o.resolveClosestToStaffY(t);i=o.verticalPos===1?Math.max(s,i!=null?i:s):Math.min(s,i!=null?i:s)}),r.forEach(o=>this.setObjectY(o,i))}layoutLayoutGroup(t,r,i){let o=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof vi||a instanceof Sn||a instanceof Tn?a.layoutFitToMeasure(t):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(t,o):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(t,u)}else this.alignObjectsY(t,[s])})}},Tt=class extends wa{constructor(t,r,i){super(t);this.row=t;this.staffConfig=r;this.id=i;p(this,"clefImageAsset");p(this,"clefLineDiatonicId");p(this,"topLineDiatonicId");p(this,"middleLineDiatonicId");p(this,"bottomLineDiatonicId");p(this,"minDiatonicId");p(this,"maxDiatonicId");p(this,"joinedGrandStaff");p(this,"topLineY",0);p(this,"bottomLineY",0);p(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 O(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 Xo(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var t;return(t=this.staffConfig.name)!=null?t:""}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(t){t!==this&&(this.joinedGrandStaff=t)}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(t){return U.validateDiatonicId(t),(this.minDiatonicId===void 0||t>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||t<=this.maxDiatonicId)}getDiatonicIdY(t){if(this.containsDiatonicId(t))return this.bottomLineY+(this.bottomLineDiatonicId-t)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(t))return this.joinedGrandStaff.getDiatonicIdY(t);throw new O(6,"Staff does not contain diatonicId "+t)}getActualStaff(t){if(this.containsDiatonicId(t))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(t))return this.joinedGrandStaff;throw new O(6,"Staff does not contain diatonicId "+t)}getDiatonicIdAt(t){let r=Math.round(this.bottomLineDiatonicId-(t-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(t){return t%2===this.middleLineDiatonicId%2}isSpace(t){return t%2!==this.middleLineDiatonicId%2}containsVoiceId(t){return!this.staffConfig.voiceIds||this.staffConfig.voiceIds.includes(t)}calcTop(){let t=this.topLineY;if(this.objects.forEach(r=>t=Math.min(t,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),i=this.getDiatonicIdY(this.maxDiatonicId-1);t=Math.min(t,r-Math.abs(i-r)+1)}return t}calcBottom(){let t=this.bottomLineY;if(this.objects.forEach(r=>t=Math.max(t,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),i=this.getDiatonicIdY(this.minDiatonicId+1);t=Math.max(t,r+Math.abs(i-r)-1)}return t}pick(t,r){return[this]}layoutHeight(t){let{unitSize:r}=t,i=r*ct.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new F(0,0,this.topLineY,this.bottomLineY)}layoutWidth(t){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(t,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(t,r)}draw(t){}},Se=class extends wa{constructor(t,r,i){super(t);this.row=t;this.tabConfig=r;this.id=i;p(this,"top",0);p(this,"bottom",0);p(this,"tuningName");p(this,"tuningStrings");p(this,"mi");A.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>U.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=_c(r.tuning),this.tuningStrings=us(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=us(this.tuningName)),this.mi=new Qo(this)}getMusicInterface(){return this.mi}get name(){var t;return(t=this.tabConfig.name)!=null?t:""}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(t){return this.top+(this.bottom-this.top)/6*(t+.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(t){return!this.tabConfig.voiceIds||this.tabConfig.voiceIds.includes(t)}containsDiatonicId(t){return!0}calcTop(){let{top:t}=this;return this.objects.forEach(r=>t=Math.min(t,r.getRect().top)),t}calcBottom(){let{bottom:t}=this;return this.objects.forEach(r=>t=Math.max(t,r.getRect().bottom)),t}pick(t,r){return[this]}layoutHeight(t){let{unitSize:r}=t,i=r*ct.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new F(0,0,this.top,this.bottom)}layoutWidth(t){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(t,r){this.top+=r,this.bottom+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(t,r)}draw(t){}};var Ta=class extends tt{constructor(t,r,i){super(t);this.doc=t;this.prevRow=r;this.scoreConfig=i;p(this,"nextRow");p(this,"minWidth",0);p(this,"notationLines");p(this,"staves");p(this,"tabs");p(this,"measures",[]);p(this,"needLayout",!0);p(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(o=>o instanceof Tt),this.tabs=this.notationLines.filter(o=>o instanceof Se),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new Ko(this)}getMusicInterface(){return this.mi}createNotationLines(){let t=this.scoreConfig.map((r,i)=>r.type==="staff"?new Tt(this,r,i):new Se(this,r,i));for(let r=0;r<t.length-1;r++){let i=t[r],o=t[r+1];i instanceof Tt&&o instanceof Tt&&i.staffConfig.grandId!==void 0&&i.staffConfig.grandId===o.staffConfig.grandId&&(i.joinGrandStaff(o),o.joinGrandStaff(i))}return t}getNotationLines(){return this.notationLines}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let t=this.staves[0];if(t)return t;throw new O(6,"Top staff is required!")}getBottomStaff(){let t=this.staves[this.staves.length-1];if(t)return t;throw new O(6,"Bottom staff is required!")}getStaff(t){U.validateDiatonicId(t);for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r];if(i instanceof Tt&&i.containsDiatonicId(t))return i}}resetLayoutGroups(t){this.notationLines.forEach(r=>r.resetLayoutGroups(t))}layoutLayoutGroups(t){this.notationLines.forEach(r=>r.layoutLayoutGroups(t))}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.measures.length;i++){let o=this.measures[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.notationLines.length;i++){let o=this.notationLines[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}getConnectivesContentRect(){let t=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:t.left;return new F(i,(i+t.right)/2,t.right,t.top,t.centerY,t.bottom)}getDiatonicIdAt(t){for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r],o=i instanceof Tt?i.getDiatonicIdAt(t):void 0;if(o!==void 0)return o}}addMeasure(t){this.measures.push(t)}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}getMinWidth(){return this.minWidth}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(t){this.needLayout&&(this.requestRectUpdate(),this.notationLines.forEach(r=>{r.removeObjects(),r.layoutHeight(t)}),this.rect=new F(0,0,0,0),this.minWidth=0,this.measures.forEach(r=>{r.layout(t),this.minWidth+=r.getMinWidth(),this.minWidth+=r.getPostMeasureBreakWidth()}))}layoutWidth(t,r){if(!this.needLayout)return;let i=Math.max(r,this.minWidth);this.rect.centerX=this.rect.left+i/2,this.rect.right=this.rect.left+i,this.notationLines.forEach(u=>u.layoutWidth(t));let o=i,s=0;this.measures.forEach(u=>{o-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=o/s,c=0;this.measures.forEach(u=>{let l=u.getSolidAreaWidth()+u.getMinColumnsAreaWidth()*a;u.layoutWidth(t,l);let h=u.getRect();u.offset(c-h.left,-h.centerY),c+=h.width,c+=u.getPostMeasureBreakWidth()}),this.measures.forEach(u=>{u.layoutConnectives(t),u.layoutBeams(t)})}updateRect(){let t=this.measures.length>0?this.measures[0].getRect().left:0,r=this.measures.length>0?this.measures[this.measures.length-1].getRect().right:0,i=this.measures.length>0?Math.min(...this.measures.map(s=>s.getRect().top)):0,o=this.measures.length>0?Math.max(...this.measures.map(s=>s.getRect().bottom)):0;this.rect=new F(t,r,i,o)}alignStemsToBeams(){this.measures.forEach(t=>t.alignStemsToBeams())}layoutSetNotationLines(t){let{unitSize:r}=t;for(let i=1;i<this.notationLines.length;i++){let o=this.notationLines[i-1],s=this.notationLines[i];if(o instanceof Tt&&s instanceof Tt&&o.staffConfig.grandId!==void 0&&o.staffConfig.grandId===s.staffConfig.grandId){let a=o.getBottomLineY()-s.getTopLineY()+r*6;s.offset(0,a)}else{let a=o.calcBottom()-s.calcTop()+r*3;s.offset(0,a)}}this.measures.forEach(i=>{i.requestRectUpdate(),i.getBarLineLeft().requestRectUpdate(),i.getBarLineRight().requestRectUpdate(),i.getColumns().forEach(o=>{o.requestRectUpdate(),Kt().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.alignStemsToBeams(),this.requestRectUpdate()}layoutPadding(t){let r=t.unitSize/2;this.getRect(),this.rect.left-=r,this.rect.right+=r,this.rect.top-=r,this.rect.bottom+=r}layoutDone(){this.measures.forEach(t=>t.layoutDone()),this.needLayout=!1}offset(t,r){this.measures.forEach(i=>i.offset(t,r)),this.rect.offsetInPlace(t,r),this.notationLines.forEach(i=>i.offset(t,r))}draw(t){let r=t.getCanvasContext();if(r){if(t.drawDebugRect(this.getRect()),r.save(),r.rect(this.getRect().left,this.getRect().top,this.getRect().width,this.getRect().height),r.clip(),this.getFirstMeasure()&&(this.notationLines.length>1||this.notationLines[0]instanceof Se)){let i=this.getFirstMeasure().getStaffLineLeft(),o=Math.min(...this.notationLines.map(a=>a.getTopLineY())),s=Math.max(...this.notationLines.map(a=>a.getBottomLineY()));t.drawLine(i,o,i,s)}this.measures.forEach(i=>i.draw(t)),this.notationLines.forEach(i=>i.draw(t)),r.restore()}}};var Na=class extends tt{constructor(t,r,i,o){super(t);this.title=r;this.composer=i;this.arranger=o;p(this,"titleText");p(this,"composerText");p(this,"arrangerText");p(this,"mi");this.mi=new Jo(this),this.titleText=this.title?new nt(this,{text:this.title,scale:2},.5,0):void 0,this.composerText=this.composer?new nt(this,this.composer,1,0):void 0,this.arrangerText=this.arranger?new nt(this,"Arr.: "+this.arranger,1,0):void 0}getMusicInterface(){return this.mi}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.titleText){let i=this.titleText.pick(t,r);if(i)return[this,...i]}if(this.composerText){let i=this.composerText.pick(t,r);if(i)return[this,...i]}if(this.arrangerText){let i=this.arrangerText.pick(t,r);if(i)return[this,...i]}return[this]}layoutWidth(t,r){let i=0;this.rect=new F(0,r,0,0),this.titleText&&(this.titleText.layout(t),this.titleText.offset(r/2,i),i+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(t),this.composerText.offset(r,i),i+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(t),this.arrangerText.offset(r,i),i+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(t,r){this.titleText&&this.titleText.offset(t,r),this.composerText&&this.composerText.offset(t,r),this.arrangerText&&this.arrangerText.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){this.titleText&&this.titleText.draw(t),this.composerText&&this.composerText.draw(t),this.arrangerText&&this.arrangerText.draw(t)}};var Oa=class extends tt{constructor(){super(void 0);p(this,"needLayout",!0);p(this,"renderer");p(this,"rows",[]);p(this,"measures",[]);p(this,"measuresPerRow",1/0);p(this,"curScoreConfig",[{type:"staff",clef:"G"}]);p(this,"header");p(this,"newRowRequested",!1);p(this,"allConnectiveProps",[]);p(this,"staffGroups",new Map);p(this,"mi");this.mi=new Nr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(t){if(A.Is.isEnumValue(t,bn))switch(t){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 A.Is.isArray(t)?this.curScoreConfig=t:this.curScoreConfig=[t];for(let r=0,i="grand";r<this.curScoreConfig.length;){let o=this.curScoreConfig[r],s=this.curScoreConfig[r+1];for(;this.curScoreConfig.filter(a=>a.type==="staff").findIndex(a=>a.grandId===i)>=0;)i+="A";if(o&&o.type==="staff"&&o.isGrand){if(o.grandId!==void 0)throw new O(6,"Grand staff error: mixing isGrand and grandId!");if(s&&s.type==="staff"&&s.isGrand){if(s.grandId!==void 0)throw new O(6,"Grand staff error: mixing isGrand and grandId!");o.grandId=i,s.grandId=i,o.isGrand=s.isGrand=!1,r+=2}else throw new O(6,"Grand staff error: invalid use of isGrand!")}else r++}for(let r=0,i=[];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(i.includes(o.grandId))throw new O(6,`Grand staff error: grandId "${o.grandId}" already used!`);if(o.clef!=="G")throw new O(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(s.clef!=="F")throw new O(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(o.isOctaveDown||s.isOctaveDown)throw new O(6,"Grand staff error: cannot use isOctaveDown option!");i.push(o.grandId),o.minNote="C4",s.maxNote="B3",r+=2}else{if(o&&o.type==="staff"&&o.grandId!==void 0)throw new O(6,`Grand staff error: invalid use of grandId "${o.grandId}"!`);r++}}this.requestNewRow()}setMeasuresPerRow(t){this.measuresPerRow=t}addConnectiveProps(t){this.allConnectiveProps.push(t)}setRenderer(t){if(this.renderer===t)return;let r=this.renderer;this.renderer=t,r&&r.setDocument(void 0),t&&t.setDocument(this.mi),this.requestFullLayout()}setHeader(t,r,i){this.header=new Na(this,t,r,i),this.requestLayout()}getTitle(){var t;return(t=this.header)==null?void 0:t.title}getComposer(){var t;return(t=this.header)==null?void 0:t.composer}getArranger(){var t;return(t=this.header)==null?void 0:t.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(t){let r=new Ta(this,t,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(){let t=this.rows[this.rows.length-1];(!t||this.newRowRequested&&t.getMeasures().length>0||t.getMeasures().length>=this.measuresPerRow)&&(t=this.addNewRow(t),this.newRowRequested=!1);let r=new Nn(t);return this.measures.push(r),t.addMeasure(r),this.requestLayout(),r}addStaffGroup(t,r,i){this.staffGroups.set(t,new Ia(t,r,i))}getStaffGroup(t){return this.staffGroups.get(t)}getVoiceSymbols(t){let r=[];return this.forEachMeasure(i=>r=r.concat(i.getVoiceSymbols(t))),r}removeLayoutObjects(t){this.forEachMeasure(r=>r.removeLayoutObjects(t))}forEachMeasure(t){let r=this.getFirstMeasure();for(;r;)t(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(t=>t.resetPassCount())}updateCursorRect(t){this.renderer&&this.renderer.updateCursorRect(t)}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(t=>t.requestLayout()),this.forEachMeasure(t=>{t.getColumns().forEach(r=>r.requestLayout()),t.requestLayout()}),this.requestLayout()}layout(){if(!this.needLayout)return;let{renderer:t}=this;if(!t)return;let{unitSize:r}=t;this.forEachMeasure(o=>o.createBeams()),this.forEachMeasure(o=>o.createExtensions()),this.allConnectiveProps.forEach(o=>o.removeConnectives()),this.allConnectiveProps.forEach(o=>o.createConnectives()),this.rows.forEach(o=>o.resetLayoutGroups(t)),this.rows.forEach(o=>o.layout(t));let i=Math.max(ct.DocumentMinWidth*r,...this.rows.map(o=>1.4*o.getMinWidth()));this.rows.forEach(o=>o.layoutWidth(t,i)),this.rows.forEach(o=>o.layoutLayoutGroups(t)),this.rows.forEach(o=>o.layoutSetNotationLines(t)),this.rows.forEach(o=>o.layoutPadding(t)),this.rect=new F,this.header&&(this.header.layoutWidth(t,i),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(o=>{o.offset(-this.rect.left,this.rect.bottom+r*2-o.getRect().top),this.rect.expandInPlace(o.getRect())}),this.rows.forEach(o=>o.layoutDone()),this.needLayout=!1}drawContent(){let{renderer:t}=this;t&&(this.rows.forEach(r=>r.draw(t)),this.header&&this.header.draw(t))}pickStaffPosAt(t,r){if(this.rect.contains(t,r))for(let i=0;i<this.rows.length;i++){let o=this.rows[i];if(!o.hasStaff||!o.getRect().contains(t,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.header){let i=this.header.pick(t,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.rows.length;i++){let o=this.rows[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}};function B(n,e,t){if(!n)throw new O(6,`Invalid arg: ${e} = ${t}`)}function Pu(n){if(typeof n!="string")return!1;{let e=U.parseNote(n);return e!==void 0&&e.octave!==void 0}}function On(n){return A.Is.isNumber(n)&&Kt().indexOf(n)>=0}function Um(n){return A.Is.isNumber(n)&&aa().indexOf(n)>=0}function iA(n){return A.Is.isNumber(n)&&ca().indexOf(n)>=0}function Zm(n){B(A.Is.isObject(n),"baseConfig",n),B(A.Is.isStringOrUndefined(n.name),"baseConfig.name",n.name),B(A.Is.isUndefined(n.voiceIds)||A.Is.isArray(n.voiceIds)&&n.voiceIds.every(e=>A.Is.isNumber(e)),"baseConfig.voiceIds",n.voiceIds)}function zm(n){Zm(n),B(A.Is.isObject(n),"staffConfig",n),B(n.type==="staff","staffConfig.type",n.type),B(A.Is.isEnumValue(n.clef,bi),"staffConfig.clef",n.clef),B(A.Is.isBooleanOrUndefined(n.isOctaveDown),"staffConfig.isOctaveDown",n.isOctaveDown),B(A.Is.isUndefined(n.minNote)||Pu(n.minNote),"staffConfig.minNote",n.minNote),B(A.Is.isUndefined(n.maxNote)||Pu(n.maxNote),"staffConfig.maxNote",n.maxNote),B(A.Is.isStringOrUndefined(n.grandId),"staffConfig.grandId",n.grandId),B(A.Is.isBooleanOrUndefined(n.isGrand),"staffConfig.isGrand",n.isGrand)}function Ym(n){Zm(n),B(A.Is.isObject(n),"tabConfig",n),B(n.type==="tab","tabConfig.type",n.type),A.Is.isString(n.tuning)?B(Gn.includes(n.tuning),"tabConfig.tuning",n.tuning):A.Is.isArray(n.tuning)&&B(n.tuning.length===aa().length&&n.tuning.every(e=>Pu(e)),"tabConfig.tuning",n.tuning)}function Ra(n){B(A.Is.isObject(n),"noteOptions",n),B(A.Is.isBooleanOrUndefined(n.dotted)||A.Is.isIntegerGte(n.dotted,0),"noteOptions.dotted",n.dotted),B(A.Is.isEnumValueOrUndefined(n.stem,Qe),"noteOptions.stem",n.stem),B(A.Is.isStringOrUndefined(n.color),"noteOptions.color",n.color),B(A.Is.isBooleanOrUndefined(n.arpeggio)||A.Is.isEnumValue(n.arpeggio,Zr),"noteOptions.arpeggio",n.arpeggio),B(A.Is.isBooleanOrUndefined(n.staccato),"noteOptions.staccato",n.staccato),B(A.Is.isBooleanOrUndefined(n.diamond),"noteOptions.diamond",n.diamond),B(A.Is.isBooleanOrUndefined(n.triplet),"noteOptions.triplet",n.triplet),B(A.Is.isUndefined(n.string)||Um(n.string)||A.Is.isNonEmptyArray(n.string)&&n.string.every(e=>Um(e)),"noteOptions.string",n.string),B(A.Is.isUndefined(n.tieSpan),'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)',""),B(A.Is.isUndefined(n.slurSpan),'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)',"")}function Hm(n){B(A.Is.isObject(n),"restOptions",n),B(A.Is.isBooleanOrUndefined(n.dotted)||A.Is.isIntegerGte(n.dotted,0),"restOptions.dotted",n.dotted),B(A.Is.isStringOrUndefined(n.staffPos)||A.Is.isInteger(n.staffPos)||n.staffPos instanceof U,"restOptions.staffPos",n.staffPos),B(A.Is.isStringOrUndefined(n.color),"restOptions.color",n.color),B(A.Is.isBooleanOrUndefined(n.hide),"restOptions.hide",n.hide),B(A.Is.isBooleanOrUndefined(n.triplet),"restOptions.triplet",n.triplet)}function nA(n){B(A.Is.isObject(n),"lyricsOptions",n),B(A.Is.isEnumValueOrUndefined(n.align,go),"lyricsOptions.align",n.align),B(A.Is.isEnumValueOrUndefined(n.hyphen,xn),"lyricsOptions.hyphen",n.hyphen)}function $o(n){B(A.Is.isStringOrUndefined(n)||A.Is.isIntegerGte(n,0)||A.Is.isNonEmptyArray(n)&&n.every(e=>A.Is.isString(e)||A.Is.isIntegerGte(e,0)),"staffTabOrGroup",n)}function Kr(n){try{return Ae(n),!0}catch(e){return!1}}function oA(n){try{return ls(n),!0}catch(e){return!1}}var Or=class{constructor(){p(this,"doc");p(this,"currentLyricsAlign","center");this.doc=new Oa}setScoreConfiguration(e){return A.Is.isEnumValue(e,bn)?this.doc.setScoreConfiguration(e):A.Is.isObject(e)&&e.type==="staff"?(zm(e),this.doc.setScoreConfiguration(e)):A.Is.isObject(e)&&e.type==="tab"?(Ym(e),this.doc.setScoreConfiguration(e)):A.Is.isNonEmptyArray(e)?(e.forEach(t=>{A.Is.isObject(t)&&t.type==="staff"?zm(t):A.Is.isObject(t)&&t.type==="tab"?Ym(t):B(!1,"config",e)}),this.doc.setScoreConfiguration(e)):B(!1,"config",e),this}getMeasure(){var e;return(e=this.doc.getLastMeasure())!=null?e:this.doc.addMeasure()}getDocument(){return this.doc.getMusicInterface()}setHeader(e,t,r){return B(A.Is.isStringOrUndefined(e),"title",e),B(A.Is.isStringOrUndefined(t),"composer",t),B(A.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(e,t,r),this}setMeasuresPerRow(e){return B(A.Is.isIntegerGte(e,1)||A.Is.isPosInfinity(e),"measuresPerRow",e),this.doc.setMeasuresPerRow(e),this}addMeasure(){return this.doc.addMeasure(),this}setKeySignature(...e){return B(e[0]instanceof Lr||e[0]instanceof Fe||A.Is.isNonEmptyString(e[0])&&(e.length===1||A.Is.isEnumValue(e[1],ei)),"keySignature",e),this.getMeasure().setKeySignature(...e),this}setTimeSignature(...e){return e[0]instanceof jr?this.getMeasure().setTimeSignature(e[0]):A.Is.isEnumValue(e[0],qn)&&A.Is.isEnumValueOrUndefined(e[1],ii)?this.getMeasure().setTimeSignature(new jr(e[0],e[1])):A.Is.isIntegerGte(e[0],1)&&A.Is.isIntegerGte(e[1],1)&&A.Is.isEnumValueOrUndefined(e[2],ii)?this.getMeasure().setTimeSignature(new jr(e[0],e[1],e[2])):B(!1,"timeSignature args",e),this}setTempo(e,t,r){return B(A.Is.isIntegerGte(e,1),"beatsPerMinute",e),t===void 0?B(A.Is.isUndefined(r),"dotted",r):(B(A.Is.isEnumValue(t,Zt)||Kr(t),"beatLength",t),B(A.Is.isBooleanOrUndefined(r)||A.Is.isIntegerGte(r,0),"dotted",r)),this.getMeasure().setTempo(e,t,r),this}addNote(e,t,r,i){if(B(On(e),"voiceId",e),B(t instanceof U||A.Is.isNonEmptyString(t)||A.Is.isArray(t)&&t.every(o=>o instanceof U||A.Is.isNonEmptyString(o)),"note",t),B(A.Is.isEnumValue(r,Zt)||Kr(r),"noteLength",r),i!=null||(i={}),Ra(i),A.Is.isArray(t)){let o=i.string;t.forEach((s,a)=>{i.string=A.Is.isArray(o)?o[a]:o,this.getMeasure().addNoteGroup(e,[s],r,i)})}else this.getMeasure().addNoteGroup(e,[t],r,i);return this}addChord(e,t,r,i){return B(On(e),"voiceId",e),B(A.Is.isNonEmptyArray(t)&&t.every(o=>o instanceof U||A.Is.isNonEmptyString(o)),"notes",t),B(A.Is.isEnumValue(r,Zt)||Kr(r),"noteLength",r),i!=null||(i={}),Ra(i),this.getMeasure().addNoteGroup(e,t,r,i),this}addRest(e,t,r){return B(On(e),"voiceId",e),B(A.Is.isEnumValue(t,Zt)||Kr(t),"restLength",t),r!=null||(r={}),Hm(r),this.getMeasure().addRest(e,t,r),this}addTuplet(e,t,r){B(On(e),"voiceId",e),B(A.Is.isFunction(r),"tupletBuilder",r),B(oA(t)&&A.Is.isBooleanOrUndefined(t.showRatio),"tupletRatio",t);let i=[],o={addNote:(s,a,c)=>{if(B(s instanceof U||A.Is.isNonEmptyString(s)||A.Is.isArray(s)&&s.every(u=>u instanceof U||A.Is.isNonEmptyString(u)),"note",s),B(A.Is.isEnumValue(a,Zt)||Kr(a),"noteLength",a),c!=null||(c={}),delete c.triplet,Ra(c),A.Is.isArray(s)){let u=c.string;s.forEach((l,h)=>{c.string=A.Is.isArray(u)?u[h]:u;let d=this.getMeasure().addNoteGroup(e,[l],a,c,t);i.push(d)})}else{let u=this.getMeasure().addNoteGroup(e,[s],a,c,t);i.push(u)}return o},addChord:(s,a,c)=>{B(A.Is.isNonEmptyArray(s)&&s.every(l=>l instanceof U||A.Is.isNonEmptyString(l)),"notes",s),B(A.Is.isEnumValue(a,Zt)||Kr(a),"noteLength",a),c!=null||(c={}),delete c.triplet,Ra(c);let u=this.getMeasure().addNoteGroup(e,s,a,c,t);return i.push(u),o},addRest:(s,a)=>{B(A.Is.isEnumValue(s,Zt)||Kr(s),"restLength",s),a!=null||(a={}),delete a.triplet,Hm(a);let c=this.getMeasure().addRest(e,s,a,t);return i.push(c),o}};return r(o),Ii.createTuplet(i,t),this}addLyricsInternal(e,t,r,i,o){var s;return $o(e),B(iA(t),"verse",t),B(A.Is.isEnumValue(r,Zt),"lyricsLength",r),B(A.Is.isString(i)||A.Is.isArray(i)&&i.every(a=>A.Is.isString(a)),"lyricsText",i),o!=null||(o={}),nA(o),o.align!==void 0?this.currentLyricsAlign=o.align:(s=o.align)!=null||(o.align=this.currentLyricsAlign),A.Is.isArray(i)?i.forEach(a=>this.getMeasure().addLyrics(e,t,r,a,o)):this.getMeasure().addLyrics(e,t,r,i,o),this}addLyrics(e,t,r,i){return this.addLyricsInternal(void 0,e,t,r!=null?r:"",i)}addLyricsTo(e,t,r,i,o){return this.addLyricsInternal(e,t,r,i!=null?i:"",o)}addFermataInternal(e,t){return $o(e),B(A.Is.isEnumValue(t,yo),"fermata",t),this.getMeasure().addFermata(e,t),this}addFermata(e="atNote"){return this.addFermataInternal(void 0,e)}addFermataTo(e,t="atNote"){return this.addFermataInternal(e,t)}addNavigationInternal(e,t,...r){return $o(e),B(A.Is.isEnumValue(t,Je),"navigation",t),t==="endRepeat"&&r.length>0?B(A.Is.isIntegerGte(r[0],1),"playCount",r[0]):t==="ending"&&r.length>0&&B(r.every(i=>A.Is.isIntegerGte(i,1)),"passages",r),this.getMeasure().addNavigation(e,t,...r),this}addNavigation(e,...t){return this.addNavigationInternal(void 0,e,...t)}addNavigationTo(e,t,...r){return this.addNavigationInternal(e,t,...r)}addAnnotationInternal(e,t,r){if(t!=null||(t=qm(r)),t===void 0)throw new O(6,`Annotation text "${r}" is not known annotation.`);return $o(e),B(A.Is.isEnumValue(t,An),"annotation",t),B(A.Is.isNonEmptyString(r),"text",r),this.getMeasure().addAnnotation(e,t,r),this}addAnnotation(...e){return e.length===1?this.addAnnotationInternal(void 0,void 0,e[0]):this.addAnnotationInternal(void 0,e[0],e[1])}addAnnotationTo(e,...t){return t.length===1?this.addAnnotationInternal(e,void 0,t[0]):this.addAnnotationInternal(e,t[0],t[1])}addLabelInternal(e,t,r){return $o(e),B(A.Is.isEnumValue(t,bo),"label",t),B(A.Is.isNonEmptyString(r),"text",r),this.getMeasure().addLabel(e,t,r),this}addLabel(e,t){return this.addLabelInternal(void 0,e,t)}addLabelTo(e,t,r){return this.addLabelInternal(e,t,r)}addConnective(e,...t){if(B(A.Is.isEnumValue(e,Xr),"connective",e),e==="tie"){B(A.Is.isIntegerOrUndefined(t[0])||A.Is.isEnumValue(t[0],Ke),"tieSpan",t[0]),B(A.Is.isEnumValueOrUndefined(t[1],Pe),"noteAnchor",t[1]);let r=t[0],i=t[1];this.getMeasure().addConnective(e,r,i)}else if(e==="slur"){B(A.Is.isIntegerOrUndefined(t[0]),"slurSpan",t[0]),B(A.Is.isEnumValueOrUndefined(t[1],Pe),"noteAnchor",t[1]);let r=t[0],i=t[1];this.getMeasure().addConnective(e,r,i)}else if(e==="slide"){B(A.Is.isEnumValueOrUndefined(t[0],Pe),"noteAnchor",t[0]);let r=t[0];this.getMeasure().addConnective(e,r)}return this}addExtension(e){B(A.Is.isFunctionOrUndefined(e),"addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.",e);let t=0,r=!0,i={notes:(o,s)=>(B(A.Is.isEnumValue(o,Zt)||Kr(o),"noteLength",o),B(A.Is.isUndefined(s)||A.Is.isNumber(s)&&s>=0,"noteCount",s),t+=Gt.get(o).ticks*(s!=null?s:1),i),measures:o=>(B(A.Is.isNumber(o)&&o>=1,"measureCount",o),t+=this.getMeasure().getMeasureTicks()*o,i),infinity:()=>(t=1/0,i),hide:()=>(r=!1,i)};return e?e(i):t=1/0,this.getMeasure().addExtension(t,r),this}addStaffGroup(e,t,r="auto"){return B(A.Is.isNonEmptyString(e),"groupName",e),B(A.Is.isNonEmptyString(t)||A.Is.isIntegerGte(t,0)||A.Is.isNonEmptyArray(t)&&t.every(i=>A.Is.isNonEmptyString(i)||A.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",t),B(A.Is.isEnumValue(r,fo),"verticalPosition",r),this.doc.addStaffGroup(e,t,r),this}endSong(){return this.getMeasure().endSong(),this}endSection(){return this.getMeasure().endSection(),this}endRow(){var e;return(e=this.doc.getLastMeasure())==null||e.endRow(),this}completeRests(e){return B(A.Is.isUndefined(e)||On(e)||A.Is.isArray(e)&&e.every(t=>On(t)),"voiceId",e),this.getMeasure().completeRests(e),this}addScaleArpeggio(e,t,r){B(A.Is.isNonEmptyString(t),"bottomNote",t),B(A.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),o=e.getScaleNotes(t,r);for(let s=0;s<o.length;s++){s%i.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,i.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}};var ts=class{constructor(e){this.type=e}},xi=class extends ts{constructor(t,r,i,o){super(t);this.renderer=r;this.scoreRow=i;this.diatonicId=o}},Ai=class extends ts{constructor(t,r,i){super(t);this.renderer=r;this.objects=i;if(arguments.length===0)throw new O(6,"Empty array in score object event!")}get topObject(){return this.objects[this.objects.length-1]}findObject(t){return this.objects.find(r=>t(r))}};function Ma(n,e,t){if(!n)throw new O(6,`Invalid arg: ${e} = ${t}`)}function Xm(n){return A.Is.isNumber(n)&&Kt().indexOf(n)>=0}function Fu(n){if(n instanceof Tt||n instanceof Se)return n.getMusicInterface();throw new O(6,"Notation line not staff nor tab.")}var pt=class{constructor(e){this.name=e}getParent(){var e;return(e=this.getMusicObject().getParent())==null?void 0:e.getMusicInterface()}},Da=class Da extends pt{constructor(t){super(Da.Name);this.obj=t}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};p(Da,"Name","Accidental");var Ao=Da,Ea=class Ea extends pt{constructor(t){super(Ea.Name);this.obj=t}getMusicObject(){return this.obj}};p(Ea,"Name","Connective");var Yo=Ea,ka=class ka extends pt{constructor(t){super(ka.Name);this.obj=t}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return Fu(this.obj.line)}};p(ka,"Name","Arpeggio");var wo=ka,La=class La extends pt{constructor(t){super(La.Name);this.obj=t}getMusicObject(){return this.obj}};p(La,"Name","BeamGroup");var qo=La,ja=class ja extends pt{constructor(t){super(ja.Name);this.obj=t}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};p(ja,"Name","StaffBeamGroup");var Wo=ja,Pa=class Pa extends pt{constructor(t){super(Pa.Name);this.obj=t}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(t=>t.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(t=>t.getMusicInterface())}play(t){return Ma(A.Is.isFunctionOrUndefined(t),"playStateChangeListener",t),new Rn(this,t).play()}};p(Pa,"Name","Document");var Nr=Pa,Fa=class Fa extends pt{constructor(t){super(Fa.Name);this.obj=t}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(t){return Ma(A.Is.isIntegerGte(t,1),"passage",t),this.obj.hasPassage(t)}};p(Fa,"Name","Ending");var Vo=Fa,Ba=class Ba extends pt{constructor(t){super(Ba.Name);this.obj=t}getMusicObject(){return this.obj}};p(Ba,"Name","Fermata");var Uo=Ba,Va=class Va extends pt{constructor(t){super(Va.Name);this.obj=t}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};p(Va,"Name","Header");var Jo=Va,Ga=class Ga extends pt{constructor(t){super(Ga.Name);this.obj=t}getMusicObject(){return this.obj}};p(Ga,"Name","Image");var xo=Ga,qa=class qa extends pt{constructor(t){super(qa.Name);this.obj=t}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(t=>t.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};p(qa,"Name","Measure");var Zo=qa,Wa=class Wa extends pt{constructor(t){super(Wa.Name);this.obj=t}getMusicObject(){return this.obj}};p(Wa,"Name","BarLineRight");var Po=Wa,Ua=class Ua extends pt{constructor(t){super(Ua.Name);this.obj=t}getMusicObject(){return this.obj}};p(Ua,"Name","BarLineLeft");var Fo=Ua,za=class za extends pt{constructor(t){super(za.Name);this.obj=t}getMusicObject(){return this.obj}getBarLine(){let t=this.obj.barLine;if(t instanceof Qr||t instanceof Tr)return t.getMusicInterface();throw new O(6,"Bar line not let nor right.")}getNotationLine(){return Fu(this.obj.line)}};p(za,"Name","StaffTabBarLine");var Bo=za,Ya=class Ya extends pt{constructor(t){super(Ya.Name);this.obj=t}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()}};p(Ya,"Name","NoteGroup");var Oo=Ya,Ha=class Ha extends pt{constructor(t){super(Ha.Name);this.obj=t}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()}};p(Ha,"Name","StaffNoteGroup");var Ro=Ha,Za=class Za extends pt{constructor(t){super(Za.Name);this.obj=t}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()}};p(Za,"Name","TabNoteGroup");var Mo=Za,Xa=class Xa extends pt{constructor(t){super(Xa.Name);this.obj=t}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(Xa,"Name","Rest");var To=Xa,Qa=class Qa extends pt{constructor(t){super(Qa.Name);this.obj=t}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()}};p(Qa,"Name","StaffRest");var No=Qa,Ka=class Ka extends pt{constructor(t){super(Ka.Name);this.obj=t}getMusicObject(){return this.obj}getRhythmSymbol(t){var r;return Ma(Xm(t),"voiceId",t),(r=this.obj.getVoiceSymbol(t))==null?void 0:r.getMusicInterface()}getVoiceSymbol(t){var r;return Ma(Xm(t),"voiceId",t),(r=this.obj.getVoiceSymbol(t))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(Ka,"Name","RhythmColumn");var Eo=Ka,Ja=class Ja extends pt{constructor(t){super(Ja.Name);this.obj=t}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(t=>t.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(t=>Fu(t))}};p(Ja,"Name","ScoreRow");var Ko=Ja,$a=class $a extends pt{constructor(t){super($a.Name);this.obj=t}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()}};p($a,"Name","Staff");var Xo=$a,tc=class tc extends pt{constructor(t){super(tc.Name);this.obj=t}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()}};p(tc,"Name","Tab");var Qo=tc,ec=class ec extends pt{constructor(t){super(ec.Name);this.obj=t}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};p(ec,"Name","StaffSignature");var Io=ec,rc=class rc extends pt{constructor(t){super(rc.Name);this.obj=t}getMusicObject(){return this.obj}getTab(){return this.obj.tab.getMusicInterface()}};p(rc,"Name","TabSignature");var So=rc,ic=class ic extends pt{constructor(t){super(ic.Name);this.obj=t}getMusicObject(){return this.obj}getMeasure(){return this.obj.measure.getMusicInterface()}getTab(){return this.obj.tab.getMusicInterface()}};p(ic,"Name","TabRhythm");var Ho=ic,nc=class nc extends pt{constructor(t){super(nc.Name);this.obj=t}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(nc,"Name","SpecialText");var ko=nc,oc=class oc extends pt{constructor(t){super(oc.Name);this.obj=t}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(oc,"Name","Text");var Co=oc,sc=class sc extends pt{constructor(t){super(sc.Name);this.obj=t}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(sc,"Name","Lyrics");var Do=sc,ac=class ac extends pt{constructor(t){super(ac.Name);this.obj=t}getMusicObject(){return this.obj}};p(ac,"Name","ExtensionLine");var zo=ac;function tr(n,e,t){if(!n)throw new O(6,`Invalid arg: ${e} = ${t}`)}function es(n,e){if(n==null)throw new TypeError(e);return n}var rs=class rs{constructor(e,t){p(this,"player");tr(e instanceof Nr,"doc",e),tr(A.Is.isFunctionOrUndefined(t),"playStateChangeListener",t),this.player=new Aa,this.player.setDocument(e.getMusicObject()),this.player.setCursorPositionChangeListener(r=>e.getMusicObject().updateCursorRect(r)),t&&this.player.setPlayStateChnageListener(t)}static stopAll(){this.currentlyPlaying.forEach(e=>e.stop()),sa()}play(){return rs.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),rs.currentlyPlaying.delete(this),this}};p(rs,"currentlyPlaying",new Set);var Rn=rs,Bu=class{constructor(){p(this,"renderer");this.renderer=new ha(this)}setDocument(e){return tr(A.Is.isUndefined(e)||e instanceof Nr,"doc",e),this.renderer.setDocument(e),this}setCanvas(e){return e=es(A.Dom.getCanvas(e),typeof e=="string"?"Cannot set renderer canvas because invalid canvas id: "+e:"Cannot set renderer canvas because given canvas is undefined."),this.renderer.setCanvas(e),this}setScoreEventListener(e){tr(A.Is.isFunctionOrUndefined(e),"scoreEventListener",e),this.renderer.setScoreEventListener(e)}hilightObject(e){this.renderer.hilightObject(e==null?void 0:e.getMusicObject())}hilightStaffPos(e){this.renderer.hilightStaffPos(e?{scoreRow:e.scoreRow.getMusicObject(),diatonicId:e.diatonicId}:void 0)}draw(){try{this.renderer.draw()}catch(e){console.log("Draw failed in music renderer."),console.log(e)}}},de=class de{constructor(){p(this,"playButton");p(this,"stopButton");p(this,"playStopButton");p(this,"pauseButton");p(this,"onPlay");p(this,"onStop");p(this,"onPlayStop");p(this,"onPause");p(this,"playLabel","Play");p(this,"stopLabel","Stop");p(this,"pauseLabel","Pause");p(this,"playState",2);p(this,"player");this.onPlay=()=>{var e;return(e=this.player)==null?void 0:e.play()},this.onStop=()=>{var e;return(e=this.player)==null?void 0:e.stop()},this.onPlayStop=()=>{var e,t;this.playState===0?(e=this.player)==null||e.stop():(t=this.player)==null||t.play()},this.onPause=()=>{var e;return(e=this.player)==null?void 0:e.pause()},this.updateButtons()}setDocument(e){return tr(A.Is.isUndefined(e)||e instanceof Nr,"doc",e),this.onStop(),e?this.player=new Rn(e,t=>{this.playState=t,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(e,t){return tr(A.Is.isStringOrUndefined(t),"btnLabel",t),de.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=es(A.Dom.getButton(e),"Play button required!"),this.playLabel=t!=null?t:"Play",de.removeOnClickListeners(this.playButton,"all"),de.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(e,t){return tr(A.Is.isStringOrUndefined(t),"btnLabel",t),de.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=es(A.Dom.getButton(e),"Stop button required!"),this.stopLabel=t!=null?t:"Stop",de.removeOnClickListeners(this.stopButton,"all"),de.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(e,t,r){return tr(A.Is.isStringOrUndefined(t),"playLabel",t),tr(A.Is.isStringOrUndefined(r),"stopLabel",r),de.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=es(A.Dom.getButton(e),"Play/stop button required!"),this.playLabel=t!=null?t:"Play",this.stopLabel=r!=null?r:"Stop",de.removeOnClickListeners(this.playStopButton,"all"),de.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(e,t){return tr(A.Is.isStringOrUndefined(t),"btnLabel",t),de.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=es(A.Dom.getButton(e),"Pause button required!"),this.pauseLabel=t!=null?t:"Pause",de.removeOnClickListeners(this.pauseButton,"all"),de.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(e,t){if(e){let r=this.savedOnClickListeners.get(e)||[],i=[];r.forEach(o=>{t===o||t==="all"?e.removeEventListener("click",o):i.push(o)}),this.savedOnClickListeners.set(e,i)}}static addOnClickListener(e,t){tr(A.Is.isFunction(t),"onClick",t),e.addEventListener("click",t);let r=this.savedOnClickListeners.get(e)||[];this.savedOnClickListeners.set(e,[...r,t])}};p(de,"savedOnClickListeners",new Map);var Vu=de;ti();var qu={};Oi(qu,{createAndanteByDiabelli:()=>cA,createFrereJacques:()=>sA,createGreensleeves:()=>aA});function sA(){return new Or().setHeader("Fr\xE8re Jacques","Traditional").setScoreConfiguration([{type:"staff",clef:"G",voiceIds:[0]},{type:"staff",clef:"F",voiceIds:[1]}]).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 aA(){return new Or().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 cA(){return new Or().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()}return nf(uA);})();
209
+ `;Ks(Pm,fx);var Hr=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["channels"]);super(e),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(e.channels)}static getDefaults(){return Object.assign(j.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var kJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var qJ=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var ra=class n extends ye{constructor(){let e=N(n.getDefaults(),arguments,["decay"]);super(e),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let t=this.toSeconds(e.decay);kt(t,.001),this._decay=t;let r=this.toSeconds(e.preDelay);kt(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(ye.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(e){e=this.toSeconds(e),kt(e,.001),this._decay=e,this.generate()}get preDelay(){return this._preDelay}set preDelay(e){e=this.toSeconds(e),kt(e,0),this._preDelay=e,this.generate()}generate(){return ht(this,void 0,void 0,function*(){let e=this.ready,t=new He(2,this._decay+this._preDelay,this.context.sampleRate),r=new gi({context:t}),i=new gi({context:t}),o=new Hr({context:t});r.connect(o,0,0),i.connect(o,0,1);let s=new Z({context:t}).toDestination();o.connect(s),r.start(0),i.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=t.render();return this.ready=a.then(rt),yield e,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var yn=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["solo"]);super(e),this.name="Solo",this.input=this.output=new Z({context:this.context}),n._allSolos.has(this.context)||n._allSolos.set(this.context,new Set),n._allSolos.get(this.context).add(this),this.solo=e.solo}static getDefaults(){return Object.assign(j.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(e){e?this._addSolo():this._removeSolo(),n._allSolos.get(this.context).forEach(t=>t._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){n._soloed.has(this.context)||n._soloed.set(this.context,new Set),n._soloed.get(this.context).add(this)}_removeSolo(){n._soloed.has(this.context)&&n._soloed.get(this.context).delete(this)}_isSoloed(){return n._soloed.has(this.context)&&n._soloed.get(this.context).has(this)}_noSolos(){return!n._soloed.has(this.context)||n._soloed.has(this.context)&&n._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(),n._allSolos.get(this.context).delete(this),this._removeSolo(),this}};yn._allSolos=new Map;yn._soloed=new Map;var ia=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["pan","volume"]);super(e),this.name="PanVol",this._panner=this.input=new mo({context:this.context,pan:e.pan,channelCount:e.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new je({context:this.context,volume:e.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=e.mute,W(this,["pan","volume"])}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var Nu=class n extends j{constructor(){let e=N(n.getDefaults(),arguments,["volume","pan"]);super(e),this.name="Channel",this._solo=this.input=new yn({solo:e.solo,context:this.context}),this._panVol=this.output=new ia({context:this.context,pan:e.pan,volume:e.volume,mute:e.mute,channelCount:e.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),W(this,["pan","volume"])}static getDefaults(){return Object.assign(j.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(e){return n.buses.has(e)||n.buses.set(e,new Z({context:this.context})),n.buses.get(e)}send(e,t=0){let r=this._getBus(e),i=new Z({context:this.context,units:"decibels",gain:t});return this.connect(i),i.connect(r),i}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};Nu.buses=new Map;var Rit=Vt().transport;var Mit=Vt().destination,Dit=Vt().destination;var Eit=Vt().listener;var kit=Vt().draw;var Lit=Vt();var Ou=class{constructor(){p(this,"audioSource");try{let e=new ra({decay:3,wet:.4}).toDestination(),t=new Ir(800,"lowpass").connect(e);this.audioSource=new Js(hr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(t)}catch(e){this.audioSource=void 0,console.error(e)}}getName(){return"Synthesizer"}playNote(e,t,r){try{this.audioSource&&(this.audioSource.volume.value=fs(r),this.audioSource.triggerAttackRelease(e,t))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(e){}}},Ru=new Ou;ei();function vx(n){return typeof n=="string"?n:(typeof n=="number"&&(n=U.getChromaticNote(n)),n.format(0,0))}var na=[Ru],bn=Ru,Ix=(function(e,t,r){var o;let i=parseInt((o=r.split("/")[1])!=null?o:"4");return 60*(1/e)/(t*(1/i))})(2,80,"4/4"),Sx=1,oa=!1;function wx(){return na.map(n=>n.getName())}function Tx(){return bn.getName()}function Nx(n){(x.Is.isArray(n)?n:[n]).forEach(e=>{if(!x.Obj.hasProperties(e,["getName","playNote","stop"])||!x.Is.isFunction(e.getName)||!x.Is.isFunction(e.playNote)||!x.Is.isFunction(e.stop))throw new O(7,"Invalid instrument object: "+e);na.some(t=>t.getName()===e.getName())?console.warn(`Instrument "${e.getName()}" already added!`):na.push(e),Bm(e.getName())})}function Bm(n){if(n===bn.getName())return;bn.stop();let e=na.find(t=>t.getName()===n);e&&(bn=e)}function sa(n,e,t){oa||bn.playNote(vx(n),e!=null?e:Ix,t!=null?t:Sx)}function aa(){bn.stop()}function Ox(){aa(),oa=!0}function Rx(){oa=!1}function Mx(){return oa}var qu={};Ri(qu,{Annotation:()=>Cn,Arpeggio:()=>Zr,Clef:()=>xi,Connective:()=>Xr,DivRect:()=>F,DocumentBuilder:()=>Or,DynamicsAnnotation:()=>_n,Fermata:()=>bo,Label:()=>xo,LyricsAlign:()=>yo,LyricsHyphen:()=>An,MAccidental:()=>Co,MArpeggio:()=>To,MBarLineLeft:()=>Bo,MBarLineRight:()=>Fo,MBeamGroup:()=>Wo,MConnective:()=>Ho,MDocument:()=>Nr,MEnding:()=>Go,MExtensionLine:()=>Yo,MFermata:()=>zo,MHeader:()=>$o,MImage:()=>Ao,MLyrics:()=>Eo,MMeasure:()=>Xo,MNoteGroup:()=>Ro,MPlaybackButtons:()=>Gu,MPlayer:()=>Mn,MRenderer:()=>Vu,MRest:()=>No,MRhythmColumn:()=>ko,MScoreRow:()=>Jo,MSpecialText:()=>Lo,MStaff:()=>Qo,MStaffBeamGroup:()=>Uo,MStaffNoteGroup:()=>Mo,MStaffRest:()=>Oo,MStaffSignature:()=>So,MStaffTabBarLine:()=>Vo,MTab:()=>Ko,MTabNoteGroup:()=>Do,MTabRhythm:()=>Zo,MTabSignature:()=>wo,MText:()=>_o,MusicInterface:()=>pt,Navigation:()=>Je,NoteAnchor:()=>Pe,PlayState:()=>la,ScoreEvent:()=>es,ScoreObjectEvent:()=>Ci,ScoreStaffPosEvent:()=>Ai,StaffPreset:()=>xn,Stem:()=>Qe,TempoAnnotation:()=>vn,TieType:()=>Ke,VerticalPosition:()=>go,getStringNumbers:()=>ca,getVerseNumbers:()=>ua,getVoiceIds:()=>Kt});var F=class n{constructor(...e){p(this,"left");p(this,"centerX");p(this,"right");p(this,"top");p(this,"centerY");p(this,"bottom");if(e.length===6)this.left=e[0],this.centerX=e[1],this.right=e[2],this.top=e[3],this.centerY=e[4],this.bottom=e[5];else if(e.length===4)this.left=e[0],this.right=e[1],this.centerX=(this.left+this.right)/2,this.top=e[2],this.bottom=e[3],this.centerY=(this.top+this.bottom)/2;else if(e.length===0)this.left=this.centerX=this.right=0,this.top=this.centerY=this.bottom=0;else throw new O(1,`Invalid DivRect args: ${e}`)}static create(e,t,r,i){return new n(e,e+r,t,t+i)}static createCentered(e,t,r,i){return new n(e-r/2,e+r/2,t-i/2,t+i/2)}static createSections(e,t,r,i){return new n(-e,0,t,-r,0,i)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.centerX-this.left}get rightw(){return this.right-this.centerX}get toph(){return this.centerY-this.top}get bottomh(){return this.bottom-this.centerY}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}static overlap(e,t){return e.right>t.left&&e.left<t.right&&e.bottom>t.top&&e.top<t.bottom}static overlapX(e,t){return e.right>t.left&&e.left<t.right}static equals(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.left===t.left&&e.centerX===t.centerX&&e.right===t.right&&e.top===t.top&&e.centerY===t.centerY&&e.bottom===t.bottom}static equalsFrame(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e===t||e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}copy(){return new n(this.left,this.centerX,this.right,this.top,this.centerY,this.bottom)}offsetInPlace(e,t){return this.left+=e,this.centerX+=e,this.right+=e,this.top+=t,this.centerY+=t,this.bottom+=t,this}offsetCopy(e,t){return this.copy().offsetInPlace(e,t)}expandInPlace(e){return this.left=Math.min(this.left,e.left),this.right=Math.max(this.right,e.right),this.top=Math.min(this.top,e.top),this.bottom=Math.max(this.bottom,e.bottom),this}expandCopy(e){return this.copy().expandInPlace(e)}clipInPlace(e){return this.left=Math.max(this.left,e.left),this.right=Math.min(this.right,e.right),this.centerX=x.Math.clamp(this.centerX,this.left,this.right),this.top=Math.max(this.top,e.top),this.bottom=Math.min(this.bottom,e.bottom),this.centerY=x.Math.clamp(this.centerY,this.top,this.bottom),this}clipCopy(e){return this.copy().clipInPlace(e)}scaleInPlace(e,t){return t=t!=null?t:e,this.left=this.centerX-this.leftw*e,this.right=this.centerX+this.rightw*e,this.top=this.centerY-this.toph*t,this.bottom=this.centerY+this.bottomh*t,this}scaleCopy(e,t){return this.copy().scaleInPlace(e,t)}getRect(){return this}};var xn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(xn||{}),xi=(t=>(t.G="G",t.F="F",t))(xi||{});function Kt(){return[0,1,2,3]}function ca(){return[1,2,3,4,5,6]}function ua(){return[1,2,3]}var Qe=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(Qe||{}),Zr=(t=>(t.Up="up",t.Down="down",t))(Zr||{}),Ke=(t=>(t.Stub="stub",t.ToMeasureEnd="toMeasureEnd",t))(Ke||{}),Pe=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(Pe||{}),Xr=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(Xr||{}),go=(i=>(i.Auto="auto",i.Above="above",i.Below="below",i.Both="both",i))(go||{}),yo=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(yo||{}),An=(t=>(t.Hyphen="-",t.Extender="---",t))(An||{}),bo=(t=>(t.AtNote="atNote",t.AtMeasureEnd="atMeasureEnd",t))(bo||{}),Je=(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))(Je||{}),Cn=(t=>(t.Dynamics="dynamics",t.Tempo="tempo",t))(Cn||{}),_n=(d=>(d.cresc="cresc.",d.decresc="decresc.",d.dim="dim.",d.ppp="ppp",d.pp="pp",d.p="p",d.mp="mp",d.m="m",d.mf="mf",d.f="f",d.ff="ff",d.fff="fff",d))(_n||{}),vn=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(vn||{}),xo=(t=>(t.Note="note",t.Chord="chord",t))(xo||{}),la=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(la||{});var ha=class{constructor(e){p(this,"head");p(this,"tail");this.head=e,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(e){this.tail.push(e)}detachTail(e){let t=this.tail.indexOf(e);t>=0&&this.tail.splice(t,1)}},tt=class{constructor(e){this.parent=e;p(this,"anchoredLayoutObjects",[]);p(this,"link");p(this,"rect",new F);p(this,"needRectUpdate",!0)}getParent(){return this.parent}requestRectUpdate(){this.needRectUpdate=!0}updateRect(){}getRect(){return this.needRectUpdate&&(this.updateRect(),this.needRectUpdate=!1),this.rect}getShapeRects(){return[this.rect]}addAnchoredLayoutObject(e){this.anchoredLayoutObjects.push(e)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(e){this.link=e}getLink(){return this.link}isLinked(){return this.link!==null}};var Vm={DrawDebugRects:!1,DisableBeams:!1},ct={DocumentScale:1,DocumentMinWidth:75,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,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var Gm="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 qm="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 Dx="#55cc55",Ex="#55cc55",kx="#44aa44",Mu=new Map([[0,{src:Gm}],[1,{src:qm}]]);function Lx(n,e){return!n&&!e?!0:!n||!e?!1:n.scoreRow===e.scoreRow&&n.diatonicId===e.diatonicId}function jx(n,e){return!n&&!e?!0:!n||!e?!1:n.length===e.length&&n.every((t,r)=>t===e[r])}var da=class{constructor(e){this.mi=e;p(this,"devicePixelRatio");p(this,"fontSize");p(this,"unitSize");p(this,"lineWidth");p(this,"beamThickness");p(this,"scoreEventListener");p(this,"canvas");p(this,"ctx");p(this,"mdoc");p(this,"cursorRect");p(this,"mousePos");p(this,"curStaffPos");p(this,"curObjects");p(this,"hilightedStaffPos");p(this,"hilightedObj");p(this,"usingTouch",!1);p(this,"onClickFn");p(this,"onMouseMoveFn");p(this,"onMouseLeaveFn");p(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=Fn.FontSize*ct.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this.lineWidth=this.unitSize*.2,this.beamThickness=this.unitSize*.8,Mu.forEach(t=>{if(t.finished!==!0){let r=new Image;r.src=t.src,r.onload=()=>{t.img=r,this.finishImageAsset(t)},r.onerror=()=>{throw this.finishImageAsset(t),new O(6,"Failed to load image: "+t.src)}}}),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 e;return(e=this.mdoc)==null?void 0:e.getMusicObject()}finishImageAsset(e){e.finished=!0,Array.from(Mu).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(e){var t;return(t=Mu.get(e))==null?void 0:t.img}setDocument(e){if(this.mdoc===e)return;this.updateCursorRect(void 0);let t=this.mdoc;this.mdoc=e,t&&t.getMusicObject().setRenderer(void 0),e&&e.getMusicObject().setRenderer(this)}setCanvas(e){var t,r;this.canvas!==e&&(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=e,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=(t=this.canvas)==null?void 0:t.getContext("2d"))!=null?r:void 0}setScoreEventListener(e){this.scoreEventListener=e}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(e){return new sl(e.offsetX,e.offsetY)}updateCurStaffPos(e,t){let r=!Lx(e,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new Ai("leave",this.getMusicInterface(),i.getMusicInterface(),o))}if(r&&e&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=e;this.scoreEventListener(new Ai("enter",this.getMusicInterface(),i.getMusicInterface(),o))}if(t&&e&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=e;this.scoreEventListener(new Ai("click",this.getMusicInterface(),i.getMusicInterface(),o))}return this.curStaffPos=e,r}updateCurObjects(e,t){let r=!jx(e,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ci("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&e&&e.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ci("enter",this.getMusicInterface(),e.map(i=>i.getMusicInterface()))),t&&e&&e.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ci("click",this.getMusicInterface(),e.map(i=>i.getMusicInterface()))),this.curObjects=e,r}onClick(e){let{doc:t}=this;if(!(!this.needMouseInput()||!t)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(e)),this.scoreEventListener)){let r=t.pick(this.mousePos.x,this.mousePos.y),i=t.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(e){let{doc:t}=this;if(!(!this.needMouseInput()||!t)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(e)),!this.usingTouch)){let r=t.pick(this.mousePos.x,this.mousePos.y),i=t.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(e){if(!this.needMouseInput())return;this.mousePos=void 0;let t=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(t||r)&&this.draw()}onTouchEnd(e){this.usingTouch=!0}onLoad(){this.doc&&(this.doc.requestFullLayout(),this.draw())}hilightObject(e){this.hilightedObj=e}hilightStaffPos(e){this.hilightedStaffPos=e}updateCursorRect(e){this.cursorRect=e,this.draw()}updateCanvasSize(){let{canvas:e,doc:t}=this;if(e&&t){let r=t.getRect(),i=r.width+1,o=r.height+1;e.width=i,e.height=o,e.style.width=i/this.devicePixelRatio+"px",e.style.height=o/this.devicePixelRatio+"px"}}draw(){let{ctx:e,doc:t}=this;!e||!t||(t.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),t.drawContent())}drawHilightStaffPosRect(){let e=this.getCanvasContext(),{mousePos:t,hilightedStaffPos:r,unitSize:i}=this;if(!e||!r)return;let{scoreRow:o,diatonicId:s}=r,a=o.getStaff(s);a&&(e.fillStyle=Dx,e.fillRect(0,a.getDiatonicIdY(s)-i,e.canvas.width,2*i),t!==void 0&&this.drawLedgerLines(a,s,t.x))}drawHilightObjectRect(){let e=this.getCanvasContext(),{hilightedObj:t}=this;if(!e||!t)return;let r=t.getRect();e.strokeStyle=Ex,e.strokeRect(r.left,r.top,r.width,r.height)}drawPlayCursor(){let{cursorRect:e,lineWidth:t}=this;e&&this.drawLine(e.centerX,e.top,e.centerX,e.bottom,kx,t*2)}txFromScreenCoord(e){return e.mul(this.devicePixelRatio)}txToScreenCoord(e){return e.div(this.devicePixelRatio)}getCanvasContext(){return this.ctx}clearCanvas(){let e=this.getCanvasContext();e&&e.clearRect(0,0,e.canvas.width,e.canvas.height)}getTextWidth(e,t){let r=this.getCanvasContext();if(r){let i=r.font;r.font=t;let o=r.measureText(e);return r.font=i,o.width}else return x.Dom.getCanvasTextWidth(e,t)}drawDebugRect(e){if(!Vm.DrawDebugRects)return;let t=this.getCanvasContext();t&&(t.lineWidth=1,t.strokeStyle="red",t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.stroke())}fillCircle(e,t,r,i){let o=this.getCanvasContext();o&&(i!==void 0&&(o.fillStyle=i),o.beginPath(),o.arc(e,t,r,0,2*Math.PI),o.fill())}drawLine(e,t,r,i,o,s){let a=this.getCanvasContext();a&&(a.strokeStyle=o!=null?o:"black",a.lineWidth=s!=null?s:this.lineWidth,a.beginPath(),a.moveTo(e,t),a.lineTo(r,i),a.stroke())}drawPartialLine(e,t,r,i,o,s,a,c){let u=this.getCanvasContext();if(u){let l=e+(r-e)*o,h=t+(i-t)*o,d=e+(r-e)*s,m=t+(i-t)*s;u.strokeStyle=a!=null?a:"black",u.lineWidth=c!=null?c:this.lineWidth,u.beginPath(),u.moveTo(l,h),u.lineTo(d,m),u.stroke()}}drawLedgerLines(e,t,r){let{unitSize:i}=this,o=i*ct.LedgerLineWidth;if(t>=e.topLineDiatonicId+2){for(let s=e.topLineDiatonicId+2;s<=t;s+=2)if(e.containsDiatonicId(s)){let a=e.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}else if(t<=e.bottomLineDiatonicId-2){for(let s=e.bottomLineDiatonicId-2;s>=t;s-=2)if(e.containsDiatonicId(s)){let a=e.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}}getRestRect(e){let{unitSize:t}=this,{flagCount:r}=_t.get(Ae(e+"n")),i=0,o=0,s=0,a=0;if(_t.equals(e,"1n"))i=t,o=t,s=0,a=t;else if(_t.equals(e,"2n"))i=t,o=t,s=t,a=0;else if(_t.equals(e,"4n"))i=t*1,o=t*1,s=t*3.2,a=t*3;else{let c=1-r%2;i=t*(1+r*.25),o=t*(1+r*.125),s=t*(.5+r-c),a=t*(1+r+c)}return new F(-i,0,o,-s,0,a)}drawRest(e,t,r,i){let o=this.getCanvasContext();if(!o)return;let{unitSize:s,lineWidth:a}=this,{flagCount:c}=_t.get(Ae(e+"n"));if(o.strokeStyle=o.fillStyle=i,o.lineWidth=a,_t.equals(e,"1n"))o.fillRect(t-s,r,s*2,s);else if(_t.equals(e,"2n"))o.fillRect(t-s,r-s,s*2,s);else if(_t.equals(e,"4n"))o.beginPath(),o.moveTo(t-s*.6,r-s*3.2),o.lineTo(t+s*.7,r-s*1.5),o.quadraticCurveTo(t-s*.8,r-s*.5,t+s*1,r+s*1.5),o.lineTo(t-s*1,r-s*.75),o.quadraticCurveTo(t+s*.2,r-s*1.5,t-s*.6,r-s*3.2),o.moveTo(t+s*1,r+s*1.5),o.quadraticCurveTo(t-s*.8,r+s*1,t-s*.2,r+s*2.8),o.bezierCurveTo(t-s*1.8,r+s*1.5,t-s*.6,r-s*.2,t+s*.9,r+s*1.5),o.fill(),o.stroke();else if(c>0){let u=1-c%2,l=d=>t+(-d*.25+.5)*s,h=d=>r+(d+u)*s;o.beginPath(),o.moveTo(l(1+c),h(1+c)),o.lineTo(l(-.5-c),h(-.5-c)),o.stroke();for(let d=0;d<c;d++){let m=c-d*2;o.beginPath(),o.moveTo(l(m-2.5),h(m-2.5)),o.quadraticCurveTo(l(m-.5)+s*.25,h(m-1.5),l(m-1.5)-s*1.5,h(m-1.5)),o.stroke(),o.beginPath(),o.arc(l(m-2)-s*1.5,h(m-2),s*.5,0,Math.PI*2),o.fill()}}}drawFlag(e,t){let r=this.getCanvasContext();if(!r)return;let i=e.left,s=e.right-i,a=t==="up"?e.top:e.bottom,c=t==="up"?e.bottom:e.top;r.beginPath(),r.moveTo(i,a),r.bezierCurveTo(i,a*.75+c*.25,i+s*1.5,a*.5+c*.5,i+s*.5,c),r.stroke()}};var pa=class{constructor(e){this.measure=e;p(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(e){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===U.getDiatonicClass(e));return r?r.accidental:void 0}setAccidental(e){this.accidentalByDiatonicId[e.diatonicId]=e.accidental}needAccidental(e){var r,i;let t=(i=(r=this.accidentalByDiatonicId[e.diatonicId])!=null?r:this.getAccidentalFromKeySignature(e.diatonicId))!=null?i:0;return e.accidental!==t}};var ma=class extends tt{constructor(t,r,i,o,s){super(t);this.image=r;this.anchorX=i;this.anchorY=o;this.imageScale=s;p(this,"mi");this.mi=new Ao(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{anchorX:r,anchorY:i,image:o,imageScale:s}=this,{unitSize:a}=t;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=F.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new F}}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let i=this.rect;t.drawDebugRect(i);try{r.drawImage(this.image,i.centerX-i.leftw,i.centerY-i.toph,i.width,i.height)}catch(o){}}};var _i=class extends tt{constructor(t,r,i,o="black"){super(t);this.diatonicId=r;this.accidental=i;this.color=o;p(this,"mi");this.mi=new Co(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t;switch(this.accidental){case-2:this.rect=F.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=F.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=F.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=F.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=F.createSections(r*1,r*1,r*1,r*1);break;default:throw new O(6,"Invalid accidental value: "+this.accidental)}}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.rect);let{unitSize:i,lineWidth:o}=t,{accidental:s}=this,a=this.rect.centerX,c=this.rect.centerY;r.strokeStyle=r.fillStyle=this.color;function u(l,h){r&&(r.lineWidth=o,r.beginPath(),r.moveTo(l-i*.75,h-i*4),r.lineTo(l-i*.75,h+i*1.1),r.bezierCurveTo(l+i*.75,h-i*0,l+i*.75,h-i*2.2,l-i*.75,h-i*.5),r.stroke())}s===-2?(u(a-i*.5,c),u(a+i*.5,c)):s===-1&&u(a,c),s===0?(r.beginPath(),r.lineWidth=o,r.moveTo(a-i*.5,c-i*2.2),r.lineTo(a-i*.5,c+i*1),r.moveTo(a+i*.5,c+i*2.2),r.lineTo(a+i*.5,c-i*1),r.stroke(),r.beginPath(),r.lineWidth=o*2,r.moveTo(a-i*.5,c+i*1),r.lineTo(a+i*.5,c+i*.6),r.moveTo(a+i*.5,c-i*1),r.lineTo(a-i*.5,c-i*.6),r.stroke()):s===1?(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.3,c-i*1.6),r.lineTo(a-i*.3,c+i*2),r.moveTo(a+i*.3,c-i*2),r.lineTo(a+i*.3,c+i*1.6),r.stroke(),r.lineWidth=o*2,r.beginPath(),r.moveTo(a-i*.75,c-i*.5),r.lineTo(a+i*.75,c-i*.9),r.moveTo(a-i*.75,c+i*.9),r.lineTo(a+i*.75,c+i*.5),r.stroke()):s===2&&(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.75,c-i*.75),r.lineTo(a+i*.75,c+i*.75),r.moveTo(a-i*.75,c+i*.75),r.lineTo(a+i*.75,c-i*.75),r.stroke(),r.fillRect(a-i*1,c-i*1,i*.7,i*.7),r.fillRect(a+i*.3,c-i*1,i*.7,i*.7),r.fillRect(a-i*1,c+i*.3,i*.7,i*.7),r.fillRect(a+i*.3,c+i*.3,i*.7,i*.7))}};var Px=.5,nt=class extends tt{constructor(t,r,i,o){var a,c,u,l,h,d;super(t);this.anchorX=i;this.anchorY=o;p(this,"text");p(this,"scale");p(this,"color");p(this,"bold");p(this,"italic");p(this,"boxed");p(this,"padding");p(this,"bgcolor");p(this,"font","");p(this,"textLines");p(this,"lineWidths",[]);p(this,"lineHeight",0);p(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=(d=s.padding)!=null?d:this.boxed?Px:0,this.bgcolor=s.bgcolor,(!isFinite(this.padding)||this.padding<0)&&(this.padding=0),this.textLines=this.text.split(`
210
+ `),this.textLines.length===0&&(this.textLines=[""]),this.rect=new F,this.mi=new _o(this)}getMusicInterface(){return this.mi}getText(){return this.text}updateAnchorX(t){this.anchorX=t;let{width:r}=this.rect;this.rect.left=this.rect.centerX-r*t,this.rect.right=this.rect.centerX+r*(1-t)}updateAnchorY(t){this.anchorY=t;let{height:r}=this.rect;this.rect.top=this.rect.centerY-r*t,this.rect.bottom=this.rect.centerY+r*(1-t)}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{scale:r,anchorX:i,anchorY:o,bold:s,italic:a}=this,c=t.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(d=>t.getTextWidth(d,this.font)),this.lineHeight=c;let u=this.padding*t.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=F.createSections(l*i,l*(1-i),h*o,h*(1-o))}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.rect),r.lineWidth=t.lineWidth,r.strokeStyle=r.fillStyle=this.color,r.font=this.font;let{rect:i,padding:o,lineHeight:s,lineWidths:a,anchorX:c,anchorY:u,italic:l}=this;this.bgcolor!==void 0&&(r.save(),r.fillStyle=this.bgcolor,r.beginPath(),r.fillRect(i.left,i.top,i.width,i.height),r.fill(),r.restore());let d=this.textLines.length*s,m=-s*(l?.25:.175),f=o*t.unitSize,g=(i.left+f)*(1-c)+(i.right-f)*c,b=(i.top+f)*(1-u)+(i.bottom-f)*u;switch(this.textLines.forEach((A,I)=>{let w=g-a[I]*c,S=b-d*u+s*(I+1)+m;r.fillText(A,w,S)}),this.boxed){case"square":case"rectangle":r.strokeRect(i.left,i.top,i.width,i.height);break;case"circle":case"ellipse":let A=(i.left+i.right)/2,I=(i.top+i.bottom)/2,w=(i.right-i.left)/2,S=(i.bottom-i.top)/2;r.beginPath(),r.ellipse(A,I,w,S,0,0,2*Math.PI),r.stroke();break}}};var vo=class extends tt{constructor(t,r){super(t);this.measure=t;this.staff=r;p(this,"clefImage");p(this,"eightBelowClef");p(this,"measureNumber");p(this,"ksNeutralizeAccidentals",[]);p(this,"ksNewAccidentals",[]);p(this,"beatCountText");p(this,"beatSizeText");p(this,"tempoText");p(this,"mi");this.mi=new So(this)}getMusicInterface(){return this.mi}updateClefImage(t,r){if(r){let i=t.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new ma(this,i,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new nt(this,"8",.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(t){if(t){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new nt(this,r,0,1)}else this.measureNumber=void 0}updateKeySignature(t){if(t){let{measure:r}=this,i=r.getPrevMeasure(),o=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],o&&!Fe.equals(s,o)&&o.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new _i(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new _i(this,this.getAccidentalDiatonicId(a),a.accidental))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(t){if(t){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new nt(this,{text:i,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new nt(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(t){if(t){let r=ms(this.measure.getTempo());this.tempoText=new nt(this,r,.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(t){let{clef:r}=this.staff.staffConfig,i;if(r==="G"?t.accidental>0?i=this.staff.bottomLineDiatonicId+3:t.accidental<0&&(i=this.staff.bottomLineDiatonicId+1):r==="F"&&(t.accidental>0?i=this.staff.bottomLineDiatonicId+1:t.accidental<0&&(i=this.staff.bottomLineDiatonicId-1)),i!==void 0)return U.findNextDiatonicIdAbove(t.diatonicId,i,!1);throw new O(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.eightBelowClef){let i=this.eightBelowClef.pick(t,r);if(i.length>0)return[this,...i]}if(this.clefImage){let i=this.clefImage.pick(t,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.ksNeutralizeAccidentals.length;i++){let o=this.ksNeutralizeAccidentals[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.ksNewAccidentals.length;i++){let o=this.ksNewAccidentals[i].pick(t,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let i=this.beatCountText.pick(t,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(t,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(t,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(t,r);if(i.length>0)return[this,...i]}return[this]}layout(t){var u,l,h,d,m,f;let{unitSize:r}=t,{staff:i}=this,o=r,s=0;if(this.rect=new F,this.clefImage&&(s+=o,this.clefImage.layout(t),this.clefImage.offset(s,i.getDiatonicIdY(i.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let g=this.clefImage.getRect();this.eightBelowClef.layout(t),this.eightBelowClef.offset(g.left+g.width/2,Math.max(g.centerY+g.height*.3,i.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}if(this.measureNumber){this.measureNumber.layout(t);let g=this.clefImage?this.clefImage.getRect().top:i.getTopLineY();this.measureNumber.offset(0,g),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(t),g.offset(s+g.getRect().leftw,i.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(g=>{g.layout(t),g.offset(s+g.getRect().leftw,i.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right}));let a=s;(u=this.beatCountText)==null||u.layout(t),(l=this.beatSizeText)==null||l.layout(t);let c=Math.max((d=(h=this.beatCountText)==null?void 0:h.getRect().width)!=null?d:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);if(this.beatCountText&&(this.beatCountText.offset(s+c/2+o,i.getDiatonicIdY(i.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.offset(s+c/2+o,i.getDiatonicIdY(i.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText){let g=Math.min(this.clefImage?this.clefImage.getRect().top:i.getTopLineY(),...this.ksNeutralizeAccidentals.map(b=>b.getRect().top),...this.ksNewAccidentals.map(b=>b.getRect().top));this.tempoText.layout(t),this.tempoText.offset(s,g),this.rect.expandInPlace(this.tempoText.getRect())}this.rect.right+=o}offset(t,r){var i,o,s,a,c,u;(i=this.clefImage)==null||i.offset(t,r),(o=this.eightBelowClef)==null||o.offset(t,r),(s=this.measureNumber)==null||s.offset(t,r),this.ksNeutralizeAccidentals.forEach(l=>l.offset(t,r)),this.ksNewAccidentals.forEach(l=>l.offset(t,r)),(a=this.beatCountText)==null||a.offset(t,r),(c=this.beatSizeText)==null||c.offset(t,r),(u=this.tempoText)==null||u.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){var r,i,o,s,a,c;(r=this.clefImage)==null||r.draw(t),(i=this.eightBelowClef)==null||i.draw(t),(o=this.measureNumber)==null||o.draw(t),this.ksNeutralizeAccidentals.forEach(u=>u.draw(t)),this.ksNewAccidentals.forEach(u=>u.draw(t)),(s=this.beatCountText)==null||s.draw(t),(a=this.beatSizeText)==null||a.draw(t),(c=this.tempoText)==null||c.draw(t)}},Io=class extends tt{constructor(t,r){super(t);this.measure=t;this.tab=r;p(this,"measureNumber");p(this,"beatCountText");p(this,"beatSizeText");p(this,"tempoText");p(this,"mi");this.mi=new wo(this)}getMusicInterface(){return this.mi}updateMeasureNumber(t){if(t){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new nt(this,r,0,1)}else this.measureNumber=void 0}updateTimeSignature(t){if(t){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new nt(this,{text:i,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new nt(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(t){if(t){let r=ms(this.measure.getTempo());this.tempoText=new nt(this,r,0,1)}else this.tempoText=void 0}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.beatCountText){let i=this.beatCountText.pick(t,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(t,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(t,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(t,r);if(i.length>0)return[this,...i]}return[this]}layout(t){var u,l,h,d,m,f;let{unitSize:r}=t,{tab:i}=this,o=r,s=0,a=i.getTopLineY();this.rect=new F,this.measureNumber&&(this.measureNumber.layout(t),this.measureNumber.offset(0,a),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),(u=this.beatCountText)==null||u.layout(t),(l=this.beatSizeText)==null||l.layout(t);let c=Math.max((d=(h=this.beatCountText)==null?void 0:h.getRect().width)!=null?d:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.offset(0+c/2+o,i.getRect().centerY-this.beatCountText.getRect().bottomh),this.rect.expandInPlace(this.beatCountText.getRect())),this.beatSizeText&&(this.beatSizeText.offset(0+c/2+o,i.getRect().centerY+this.beatSizeText.getRect().toph),this.rect.expandInPlace(this.beatSizeText.getRect())),this.tempoText&&(this.tempoText.layout(t),this.tempoText.offset(s+r*2,a),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(t,r){var i,o,s,a;(i=this.measureNumber)==null||i.offset(t,r),(o=this.beatCountText)==null||o.offset(t,r),(s=this.beatSizeText)==null||s.offset(t,r),(a=this.tempoText)==null||a.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){var r,i,o,s;(r=this.measureNumber)==null||r.draw(t),(i=this.beatCountText)==null||i.draw(t),(o=this.beatSizeText)==null||o.draw(t),(s=this.tempoText)==null||s.draw(t)}};var fa=class extends tt{constructor(t,r,i){super(t);this.col=t;this.line=r;this.arpeggioDir=i;p(this,"topArrowHeight",0);p(this,"bottomArrowHeight",0);p(this,"cycleHeight",0);p(this,"numCycles",0);p(this,"color","black");p(this,"mi");this.mi=new To(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let i=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-i)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new F(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{lineWidth:i}=t,{rect:o,topArrowHeight:s,bottomArrowHeight:a}=this;t.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i*2,r.beginPath();for(let c=0,u=o.top+s;c<this.numCycles;c++,u+=this.cycleHeight)r.moveTo(o.centerX,u),r.quadraticCurveTo(o.left,u+this.cycleHeight/4,o.centerX,u+this.cycleHeight/2),r.quadraticCurveTo(o.right,u+this.cycleHeight*3/4,o.centerX,u+this.cycleHeight);r.stroke(),s>0&&(r.beginPath(),r.moveTo(o.centerX,o.top),r.lineTo(o.right,o.top+s),r.lineTo(o.left,o.top+s),r.fill()),a>0&&(r.beginPath(),r.moveTo(o.centerX,o.bottom),r.lineTo(o.left,o.bottom-a),r.lineTo(o.right,o.bottom-a),r.fill())}};function Fx(n){return typeof n=="number"?U.getChromaticNote(n).diatonicId:typeof n=="string"?U.getNote(n).diatonicId:n instanceof U?n.diatonicId:void 0}var ga=class extends tt{constructor(t,r){super(t);this.staff=t;this.rest=r;p(this,"restRect",new F);p(this,"dotRects",[]);p(this,"mi");t.addObject(this),this.mi=new Oo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}offset(t,r){this.restRect.offsetInPlace(t,r),this.dotRects.forEach(i=>i.offsetInPlace(t,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRects.forEach(t=>this.rect.expandInPlace(t))}},Sr=class extends tt{constructor(t,r,i,o,s){var l,h;super(t);this.col=t;this.voiceId=r;p(this,"ownStemDir");p(this,"ownDiatonicId");p(this,"color");p(this,"hide");p(this,"oldStyleTriplet");p(this,"rhythmProps");p(this,"beamGroup");p(this,"staffObjects",[]);p(this,"mi");let a=Fx(o==null?void 0:o.staffPos);if(a!==void 0){let d=this.row.hasStaff,m=this.row.getStaff(a);if(d&&!m)throw new O(6,"Rest staffPos is out of staff boundaries!")}this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,a),this.ownStemDir=this.measure.updateOwnStemDir(this);let c=this.row.getStaff(this.ownDiatonicId);c&&c.isSpace(this.ownDiatonicId)&&(this.ownDiatonicId+=this.ownDiatonicId>=c.middleLineDiatonicId?1:-1),this.color=(l=o==null?void 0:o.color)!=null?l:"black",this.hide=(h=o==null?void 0:o.hide)!=null?h:!1,this.oldStyleTriplet=s===void 0&&((o==null?void 0:o.triplet)===!0||_t.get(i).isTriplet);let u=typeof(o==null?void 0:o.dotted)=="number"?o.dotted>0?o.dotted:void 0:(o==null?void 0:o.dotted)===!0?1:void 0;this.rhythmProps=Gt.get(i,u,(s!=null?s:this.oldStyleTriplet)?gr.Triplet:void 0),this.mi=new No(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}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}getStaticObjects(t){let r=[];return this.staffObjects.forEach(i=>{i.staff===t&&r.push(i)}),r}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(t){this.beamGroup=t}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(t=>{let r=t.staff,i=t.getRect().centerX,o=this.stemDir==="up"?t.getRect().top:t.getRect().bottom,s=Math.abs(t.getRect().centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0}visibleInStaff(t){return t.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ga&&r.staff===t)}getRestDotVerticalDisplacement(t){switch(t){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 O(6,`Get rest dot vertical displacement: Invalid note size: ${t}`)}}updateAccidentalState(t){}layout(t,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:i}=t,{ownDiatonicId:o}=this,{noteSize:s,dotCount:a}=this.rhythmProps;this.row.getStaves().forEach(c=>{if(!c.containsDiatonicId(o)||!c.containsVoiceId(this.voiceId))return;let u=new ga(c,this);u.restRect=t.getRestRect(s);for(let l=0;l<a;l++){let h=ct.DotSize*i,d=u.restRect.rightw+(ct.RestDotSpace+ct.DotSize*i)+l*ct.DotSize*i*1.5,m=this.getRestDotVerticalDisplacement(s)*i;u.dotRects.push(F.createCentered(d,m,h,h))}u.offset(0,c.getDiatonicIdY(o)),this.staffObjects.push(u)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;else if(this.rect=this.staffObjects[0].getRect().copy(),this.staffObjects.length>1)for(let t=1;t<this.staffObjects.length;t++)this.rect.expandInPlace(this.staffObjects[t].getRect())}offset(t,r){this.staffObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let r=t.getCanvasContext();if(!r||this.staffObjects.length===0)return;t.drawDebugRect(this.getRect());let{lineWidth:i}=t,{color:o}=this,{noteSize:s}=this.rhythmProps;r.strokeStyle=r.fillStyle=o,r.lineWidth=i,this.staffObjects.forEach(a=>{let{dotRects:c,restRect:u}=a,l=u.centerX,h=u.centerY;t.drawRest(s,l,h,o),c.forEach(d=>{t.fillCircle(d.centerX,d.centerY,d.width/2)})})}};function Bx(n){return x.Is.isEnumValue(n,Qe)?n:void 0}function Vx(n){return x.Is.isEnumValue(n,Zr)?n:n===!0?"up":void 0}function Gx(n,e){let t=x.Arr.isArray(e)?e:e!==void 0?[e]:[],r=n.map((i,o)=>({note:i,string:t[o]}));return r=x.Arr.removeDuplicatesCmp(r,(i,o)=>U.equals(i.note,o.note)).sort((i,o)=>U.compareFunc(i.note,o.note)),{notes:r.map(i=>i.note),strings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}var ya=class extends tt{constructor(t,r){super(t);this.staff=t;this.noteGroup=r;p(this,"noteHeadRects",[]);p(this,"dotRects",[]);p(this,"accidentals",[]);p(this,"stemTip");p(this,"stemBase");p(this,"flagRects",[]);p(this,"prevTopNoteY",0);p(this,"prevBottomNoteY",0);p(this,"mi");this.mi=new Mo(this)}getMusicInterface(){return this.mi}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.accidentals.length;i++){let o=this.accidentals[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].copy(),this.noteHeadRects.forEach(t=>this.rect.expandInPlace(t)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(t=>this.rect.expandInPlace(t)),this.flagRects.forEach(t=>this.rect.expandInPlace(t)),this.accidentals.forEach(t=>this.rect.expandInPlace(t.getRect()))}getRect(){let t=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.centerY||this.prevBottomNoteY!==t.centerY)&&(this.prevTopNoteY=r.centerY,this.prevBottomNoteY=t.centerY,this.requestRectUpdate()),super.getRect()}offset(t,r){var i,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(t,r)),this.dotRects.forEach(s=>s.offsetInPlace(t,r)),this.accidentals.forEach(s=>s.offset(t,r)),(i=this.stemTip)==null||i.offsetInPlace(t,r),(o=this.stemBase)==null||o.offsetInPlace(t,r),this.flagRects.forEach(s=>s.offsetInPlace(t,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},Du=class extends tt{constructor(t,r){super(t);this.tab=t;this.noteGroup=r;p(this,"fretNumbers",[]);p(this,"mi");t.addObject(this),this.mi=new Do(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().copy(),this.fretNumbers.forEach(t=>this.rect.expandInPlace(t.getRect()))}offset(t,r){this.fretNumbers.forEach(i=>i.offset(t,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},Ct=class n extends tt{constructor(t,r,i,o,s,a){var l,h,d;super(t);this.col=t;this.voiceId=r;this.notes=i;p(this,"minDiatonicId");p(this,"maxDiatonicId");p(this,"ownDiatonicId");p(this,"ownStemDir");p(this,"ownString");p(this,"color");p(this,"staccato");p(this,"diamond");p(this,"arpeggio");p(this,"oldStyleTriplet");p(this,"rhythmProps");p(this,"startConnnectives",[]);p(this,"runningConnectives",[]);p(this,"leftBeamCount",0);p(this,"rightBeamCount",0);p(this,"beamGroup");p(this,"staffObjects",[]);p(this,"tabObjects",[]);p(this,"mi");if(!x.Is.isIntegerGte(i.length,1))throw new O(6,"Cannot create note group object because notes array is empty.");let c=Gx(i,s==null?void 0:s.string);this.notes=c.notes,this.minDiatonicId=this.notes[0].diatonicId,this.maxDiatonicId=this.notes[this.notes.length-1].diatonicId,this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,Math.round((this.minDiatonicId+this.maxDiatonicId)/2)),this.ownStemDir=this.measure.updateOwnStemDir(this,Bx(s==null?void 0:s.stem)),this.ownString=this.measure.updateOwnString(this,c.strings),this.color=(l=s==null?void 0:s.color)!=null?l:"black",this.staccato=(h=s==null?void 0:s.staccato)!=null?h:!1,this.diamond=(d=s==null?void 0:s.diamond)!=null?d:!1,this.arpeggio=Vx(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&((s==null?void 0:s.triplet)===!0||_t.get(o).isTriplet);let u=typeof(s==null?void 0:s.dotted)=="number"?s.dotted>0?s.dotted:void 0:(s==null?void 0:s.dotted)===!0?1:void 0;this.rhythmProps=Gt.get(o,u,(a!=null?a:this.oldStyleTriplet)?gr.Triplet:void 0),this.mi=new Ro(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}enableConnective(t){return t.containsVoiceId(this.voiceId)&&(t instanceof Se||t.containsDiatonicId(this.ownDiatonicId))}startConnective(t){if(!this.row.hasStaff&&t.connective==="tie")throw new O(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&t.connective==="slur")throw new O(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(t),this.doc.addConnectiveProps(t)}getStaticObjects(t){let r=[];return this.staffObjects.forEach(i=>{i.staff===t&&r.push(i)}),this.tabObjects.forEach(i=>{i.tab===t&&r.push(i)}),r}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabObjects.length;i++){let o=this.tabObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(t,r,i,o,s){if(r instanceof Tt){let a=r;if(i<0||i>=this.notes.length)throw new O(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(_=>_.staff===a);if(!c||i<0||i>=c.noteHeadRects.length){let _=this.getRect();return{x:_.centerX,y:_.bottom}}let u=c.noteHeadRects[i],l=c.stemTip,h=this.stemDir,d=l!==void 0,m=d?h==="up"?"right":"left":void 0,f=u.height/2,g=u.centerX,b=u.centerY,A=u.left-f,I=u.right+f,w=u.top-f,S=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!d&&(o=h==="up"?"above":"below"),o){case"center":return s==="left"?{x:I,y:b}:{x:A,y:b};case"above":return!d||h==="down"?{x:g,y:w}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?A:g,y:w};case"below":return!d||h==="up"?{x:g,y:S}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?A:g,y:S};case"stemTip":return{x:g,y:l.centerY+(h==="up"?-f:f)};default:throw new O(6,"Invalid noteAnchor: "+o)}}else{let a=r,c=this.tabObjects.find(f=>f.tab===a),u=c==null?void 0:c.fretNumbers[i];if(!c||!u)return{x:0,y:0};let l=u.getRect(),h=s==="right"?l.left:l.right,d,m=.9;if(t.connective==="slide"){let f=t.noteGroups[0].getFretNumber(c,0),g=t.noteGroups[1].getFretNumber(c,0),b=f===void 0||g===void 0||f<=g;s==="left"?d=b?l.centerY+l.bottomh*m:l.centerY-l.toph*m:d=b?l.centerY-l.toph*m:l.centerY+l.bottomh*m}else d=l.centerY+l.bottomh*m;return{x:h,y:d}}}getFretNumberString(t){return this.ownString[t]}getFretNumber(t,r){let i=t.fretNumbers[r];return i===void 0?void 0:+i.getText()}getNextNoteGroup(){let t=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof n),r=t.indexOf(this);if(r<0)return;if(r<t.length-1)return t[r+1];let i=this.measure.getNextMeasure();for(;i;){let o=i.getVoiceSymbols(this.voiceId).filter(s=>s instanceof n);if(o.length>0)return o[0];i=i.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(t=>{this.runningConnectives.push(t);let r=this.getNextNoteGroup();for(;r&&t.addNoteGroup(r);)r.runningConnectives.push(t),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let t=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return t.indexOf("first")>=0?"first":t.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(t){this.beamGroup=t}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(t=>{var a,c,u,l;let r=t.staff,i=(c=(a=t.stemTip)==null?void 0:a.centerX)!=null?c:t.noteHeadRects[0].centerX,o=(l=(u=t.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir==="up"?t.getRect().top:t.getRect().bottom,s=this.stemDir==="up"?Math.abs(t.noteHeadRects[0].centerY-o):Math.abs(t.noteHeadRects[t.noteHeadRects.length-1].centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}getStemHeight(t){let{unitSize:r}=t,{flagCount:i,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?ct.BeamSeparation:ct.FlagSeparation;return(ct.StemHeight+Math.max(0,i-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}setLeftBeamCount(t){this.leftBeamCount=t}setRightBeamCount(t){this.rightBeamCount=t}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(t){return t.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ya&&r.staff===t)}getPlayTicks(t){let r=this.runningConnectives.filter(i=>i.connective==="tie").map(i=>{let o=i.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(i.span==="stub"||i.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,t))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!U.equals(u,t))),s>=0&&(o=o.slice(0,s)),x.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(t){this.notes.forEach(r=>{t.needAccidental(r)&&t.setAccidental(r)})}layout(t,r){this.requestRectUpdate();let{unitSize:i}=t,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,l=ct.DotSize*i,h=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadWidth)*i,d=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadHeight)*i;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.ownDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new ya(m,this),g=m,b=m;this.notes.forEach((C,y)=>{var P;let T=y===0,E=y===this.notes.length-1,R=(P=m.getActualStaff(C.diatonicId))!=null?P:m,M=this.col.getNoteHeadDisplacement(this,C)*h,q=R.getDiatonicIdY(C.diatonicId),L=R.isLine(C.diatonicId);T&&s==="up"&&(g=R),E&&s==="up"&&(b=R),T&&s==="down"&&(b=R),E&&s==="down"&&(g=R);let k=f.noteHeadRects[y]=F.createCentered(M,q,h,d);if(R.addObject(k),r.needAccidental(C)){let G=f.accidentals[y]=new _i(this,C.diatonicId,C.accidental,this.color);G&&(G.layout(t),G.offset(-k.leftw-i*ct.NoteAccSpace-G.getRect().rightw,q)),R.addObject(G)}for(let G=0;G<a;G++){let Q=k.right+ct.NoteDotSpace*i+l/2+G*l*1.5,Y=q+this.getDotVerticalDisplacement(m,C.diatonicId,s)*i,V=F.createCentered(Q,Y,l,l);f.dotRects.push(V),R.addObject(V)}if(this.staccato){if(s==="up"&&T){let G=M,Q=q+i*(L?3:2),Y=F.createCentered(G,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}else if(s==="down"&&E){let G=M,Q=q-i*(L?3:2),Y=F.createCentered(G,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}}});let A=f.noteHeadRects[0].centerY,I=f.noteHeadRects[f.noteHeadRects.length-1].centerY,w=s==="up"?h/2:-h/2,S=this.getStemHeight(t),_=s==="up"?I-S:A+S,v=s==="up"?A:I;if(u&&(f.stemTip=new F(w,w,_,_),f.stemBase=new F(w,w,v,v),b.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let C=c===0?0:ct.FlagWidth*i,y=c===0?0:ct.FlagHeight*i;for(let T=0;T<c;T++){let E=T*i*ct.FlagSeparation,R=f.flagRects[T]=s==="up"?new F(w,w+C,_+E,_+y+E):new F(w,w+C,_-y-E,_-E);b.addObject(R)}}this.staffObjects.push(f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new Du(m,this);this.notes.forEach((g,b)=>{if(this.ownString[b]!==void 0){let A=this.ownString[b]-1,I=g.chromaticId-m.getTuningStrings()[A].chromaticId,w=I<0?"red":"black",S=new nt(this,{text:String(I),color:w,bgcolor:"white"},.5,.5);f.fretNumbers.push(S),S.layout(t);let _=this.col.getRect().centerX,v=m.getStringY(A);S.offset(_,v)}}),f.fretNumbers.length>0&&this.tabObjects.push(f)})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].copy();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().copy();else{this.rect=new F;return}this.staffObjects.forEach(t=>this.rect.expandInPlace(t.getRect())),this.tabObjects.forEach(t=>this.rect.expandInPlace(t.getRect()))}setStemTipY(t,r){let i=this.staffObjects.find(o=>o.staff===t);this.hasBeamCount()&&(i!=null&&i.stemTip)&&r!==i.stemTip.centerY&&(i.stemTip.top=i.stemTip.centerY=i.stemTip.bottom=r,this.requestRectUpdate())}offset(t,r){this.staffObjects.forEach(i=>i.offset(t,0)),this.tabObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.getRect());let{lineWidth:i}=t,{color:o,stemDir:s}=this,{isSolidNoteHead:a}=this.rhythmProps;this.staffObjects.forEach(c=>{c.accidentals.forEach(u=>u.draw(t)),r.strokeStyle=r.fillStyle=o,r.lineWidth=i,c.noteHeadRects.forEach(u=>{this.diamond?a?(r.beginPath(),r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.lineTo(u.left,u.centerY),r.lineTo(u.centerX,u.top),r.fill()):(r.beginPath(),r.lineWidth=i*2.5,r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.moveTo(u.left,u.centerY),r.lineTo(u.centerX,u.bottom),r.stroke(),r.beginPath(),r.lineWidth=i,r.moveTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.moveTo(u.centerX,u.top),r.lineTo(u.left,u.centerY),r.stroke()):(r.beginPath(),r.ellipse(u.centerX,u.centerY,u.leftw,u.toph,-.3,0,Math.PI*2),a?r.fill():r.stroke())}),c.dotRects.forEach(u=>t.fillCircle(u.centerX,u.centerY,u.width/2)),c.stemTip&&c.stemBase&&(r.beginPath(),r.moveTo(c.stemBase.centerX,c.stemBase.centerY),r.lineTo(c.stemTip.centerX,c.stemTip.centerY),r.stroke()),c.flagRects.forEach(u=>t.drawFlag(u,s==="up"?"up":"down"))}),this.tabObjects.forEach(c=>c.fretNumbers.forEach(u=>u.draw(t)))}getDotVerticalDisplacement(t,r,i){return t.isLine(r)?i==="up"?-1:1:0}static hasSameNotes(t,r){if(t.notes.length!==r.notes.length)return!1;for(let i=0;i<t.notes.length;i++){let o=t.notes[i],s=r.notes[i];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var ba=class{constructor(e,t){this.col=e;p(this,"lyricsObjects",[]);p(this,"rhythmProps");this.rhythmProps=Gt.get(t)}addLyricsObject(e){var t;this.lyricsObjects.push(e),(t=e.measure.getPrevLyricsObject(e))==null||t.setNextLyricsObject(e)}},xa=class extends tt{constructor(t,r,i,o,s,a){super(t);this.col=t;this.verse=r;this.line=i;this.vpos=o;p(this,"nextLyricsObject");p(this,"color","black");p(this,"hyphen");p(this,"text");p(this,"mi");let c=(a==null?void 0:a.align)==="left"?0:(a==null?void 0:a.align)==="right"?1:.5;this.hyphen=x.Is.isEnumValue(a==null?void 0:a.hyphen,An)?a==null?void 0:a.hyphen:void 0,this.text=new nt(this,{text:s,color:this.color,scale:.8},c,0),this.rect=new F,this.mi=new Eo(this)}getMusicInterface(){return this.mi}get measure(){return this.col.measure}getText(){return this.text.getText()}setNextLyricsObject(t){this.nextLyricsObject=t}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){this.text.layout(t),this.rect=this.text.getRect().copy()}offset(t,r){this.text.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){var i;this.text.draw(t);let r=t.getCanvasContext();if(r&&this.hyphen!==void 0){let o=this.getRect(),s=(i=this.nextLyricsObject)==null?void 0:i.getRect(),a=t.unitSize*1.5,c=s?(s.left-o.right)*.85:a,u=this.hyphen==="-"?Math.min(a,c):c;if(u>0){r.lineWidth=t.lineWidth,r.strokeStyle=r.fillStyle=this.color;let l=s?(s.left+o.right)/2:o.right+u/.85,h=(o.top+o.bottom)/2;r.moveTo(l-u/2,h),r.lineTo(l+u/2,h),r.stroke()}}}};var qx=(n,e)=>{let t=U.compareFunc(n.note,e.note);return t===0&&(t=n.noteGroup.stemDir===e.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1),t},wr=class extends tt{constructor(t,r){super(t);this.measure=t;this.positionTicks=r;p(this,"voiceSymbol",[]);p(this,"lyricsContainerCache",new Map);p(this,"minDiatonicId");p(this,"maxDiatonicId");p(this,"staffMinDiatonicId",new Map);p(this,"staffMaxDiatonicId",new Map);p(this,"arpeggioDir");p(this,"arpeggios",[]);p(this,"noteHeadDisplacements",[]);p(this,"playerProps");p(this,"needLayout",!0);p(this,"shapeRects",[]);p(this,"mi");this.playerProps=new In(this),this.mi=new ko(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let t=this.measure.getColumns().indexOf(this);if(t>=0&&t<this.measure.getColumnCount())return this.measure.getColumn(t+1);throw new O(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let t=this.getNextColumnInMeasure();return t||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let t=this.getNextColumnInMeasure(),r=this.positionTicks,i=t?t.positionTicks:this.measure.getConsumedTicks();return Math.max(0,i-r)}getShapeRects(){return this.getRect(),this.shapeRects}getStaticObjects(t){let r=[];return this.voiceSymbol.forEach(i=>{i&&(i.getRect(),i.getStaticObjects(t).forEach(o=>r.push(o)))}),this.arpeggios.forEach(i=>{i.line===t&&(i.getRect(),r.push(i))}),r}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.voiceSymbol.length;i++)if(this.voiceSymbol[i]){let o=this.voiceSymbol[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.arpeggios.length;i++){let o=this.arpeggios[i].pick(t,r);if(o.length>0)return[this,...o]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var t;return(t=this.arpeggioDir)!=null?t:"up"}setVoiceSymbol(t,r){Aa(t),this.voiceSymbol[t]=r,r instanceof Sr&&!r.hide?(this.minDiatonicId=this.minDiatonicId===void 0?r.ownDiatonicId:Math.min(this.minDiatonicId,r.ownDiatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.ownDiatonicId:Math.max(this.maxDiatonicId,r.ownDiatonicId)):r instanceof Ct&&(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.setupNoteHeadDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(t){return this.voiceSymbol[t]}getLyricsContainer(t,r,i,o){let s=this.lyricsContainerCache.get(r);s===void 0&&this.lyricsContainerCache.set(r,s=new Map);let a=s.get(i);a===void 0&&s.set(i,a=new Map);let c=a.get(t);return c===void 0&&o!==void 0&&a.set(t,c=new ba(this,Ae(o))),c}getMinWidth(){let t=Math.max(...this.voiceSymbol.map(i=>i.rhythmProps.noteSize)),r=ct.NoteHeadWidth;switch(t){case 1:return r*5;case 2:return r*3;case 4:return r*2;default:return r}}setupNoteHeadDisplacements(){if(this.noteHeadDisplacements=[],this.voiceSymbol.forEach(t=>{t instanceof Ct&&t.notes.forEach(r=>{this.noteHeadDisplacements.push({noteGroup:t,note:r})})}),this.noteHeadDisplacements.sort(qx),!(this.noteHeadDisplacements.length<2)){for(let t=0;t<this.noteHeadDisplacements.length;t++){let r=this.noteHeadDisplacements[t],i=this.noteHeadDisplacements[t+1];i&&r.note.diatonicId===i.note.diatonicId&&(r.displacement=i.displacement=0)}for(let t=0;t<this.noteHeadDisplacements.length;t++){let r=this.noteHeadDisplacements[t-1],i=this.noteHeadDisplacements[t],o=this.noteHeadDisplacements[t+1];if(i.displacement!==void 0)continue;let s=i.noteGroup.stemDir==="down"?-1:1;r&&i.note.diatonicId-r.note.diatonicId<=1?i.displacement=r.displacement===0?s:0:o&&o.note.diatonicId-i.note.diatonicId<=1&&(i.displacement=o.displacement===0?s:0)}}}getNoteHeadDisplacement(t,r){let i=this.noteHeadDisplacements.find(o=>o.noteGroup===t&&U.equals(o.note,r));return(i==null?void 0:i.displacement)!==void 0?i.displacement:0}isEmpty(){for(let t=0;t<this.voiceSymbol.length;t++)if(this.voiceSymbol[t]!==void 0&&!this.voiceSymbol[t].isEmpty())return!1;return!0}getPlayerNotes(){let t=[];function r(i,o,s,a){if(o<=0)return;t.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||t.push({note:i,ticks:o,staccato:s,slur:a})}return Kt().forEach(i=>{let o=this.getVoiceSymbol(i);if(o instanceof Ct){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),t.sort((i,o)=>U.compareFunc(i.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&t.reverse(),t}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(t,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new F;let{row:i}=this,{unitSize:o}=t,s=this.getMinWidth()*o/2,a=s,c=s;if(this.voiceSymbol.forEach(l=>{l.layout(t,r);let h=l.getRect();a=Math.max(a,h.leftw),c=Math.max(c,h.rightw)}),this.arpeggioDir!==void 0){let l=0;this.arpeggios=i.getNotationLines().map(h=>{let d=new fa(this,h,this.getArpeggioDir());return d.layout(t),d.offset(-a-d.getRect().right,h.getRect().centerY-d.getRect().centerY),l=Math.max(l,d.getRect().width),h.addObject(d),d}),a+=l}else this.arpeggios=[];let u=this.getAnchoredLayoutObjects().filter(l=>l.layoutGroup.widensColumn);u.length>0&&u.forEach(l=>{a=Math.max(a,l.musicObj.getRect().leftw),c=Math.max(c,l.musicObj.getRect().rightw)}),this.voiceSymbol.forEach(l=>l.updateAccidentalState(r)),this.rect.left=-a,this.rect.centerX=0,this.rect.right=c,this.row.getStaves().forEach(l=>{let h,d;this.voiceSymbol.forEach(m=>{m.visibleInStaff(l)&&(m instanceof Ct?(h=h===void 0?m.minDiatonicId:Math.min(h,m.minDiatonicId),d=d===void 0?m.maxDiatonicId:Math.max(d,m.maxDiatonicId)):m instanceof Sr&&(h=h===void 0?m.ownDiatonicId:Math.min(h,m.ownDiatonicId),d=d===void 0?m.ownDiatonicId:Math.max(d,m.ownDiatonicId)))}),h!==void 0?this.staffMinDiatonicId.set(l,h):this.staffMinDiatonicId.delete(l),d!==void 0?this.staffMaxDiatonicId.set(l,d):this.staffMaxDiatonicId.delete(l)})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(t=>!!t).map(t=>t.getRect().copy()),...this.arpeggios.map(t=>t.getRect().copy())],this.rect.top=Math.min(...this.shapeRects.map(t=>t.top)),this.rect.bottom=Math.max(...this.shapeRects.map(t=>t.bottom)),this.rect.centerY=(this.rect.top+this.rect.bottom)/2}offset(t,r){this.voiceSymbol.forEach(i=>i==null?void 0:i.offset(t,0)),this.arpeggios.forEach(i=>i.offset(t,0)),this.shapeRects.forEach(i=>i.offsetInPlace(t,r)),this.rect.offsetInPlace(t,r)}draw(t){this.row.getStaves().forEach(r=>{let i=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);i!==void 0&&t.drawLedgerLines(r,i,this.getRect().centerX),o!==void 0&&t.drawLedgerLines(r,o,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(t)}),this.arpeggios.forEach(r=>r.draw(t))}};var dr=class dr extends tt{constructor(t,r){super(t);this.text=r;p(this,"components",[]);p(this,"mi");switch(this.text){case dr.Coda:this.components=[new nt(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new nt(this," Coda",0,1)];break;case dr.toCoda:this.components=[new nt(this,"toCoda ",1,1),new nt(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case dr.Segno:this.components=[new nt(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new Lo(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){switch(this.text){case dr.Coda:{let r=this.components[0],i=this.components[1];r.layout(t),i.layout(t),r.offset(0,(i.getRect().top+i.getRect().bottom)/2),i.offset(r.getRect().right,0),this.rect=new F(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case dr.toCoda:{let r=this.components[0],i=this.components[1];r.layout(t),i.layout(t),i.offset(0,(r.getRect().top+r.getRect().bottom)/2),r.offset(i.getRect().left,0),this.rect=new F(r.getRect().left,i.getRect().centerX,i.getRect().right,r.getRect().top,r.getRect().centerY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(t),this.rect=r.getRect().copy();break}}}offset(t,r){this.components.forEach(i=>i.offset(t,r)),this.rect.offsetInPlace(t,r)}draw(t){t.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(t))}};p(dr,"toCoda","\u{1D10C} toCoda"),p(dr,"Coda","Coda \u{1D10C}"),p(dr,"Segno","\u{1D10B}");var $e=dr;function jo(n){switch(n){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 $e.Segno;case"Coda":return $e.Coda;case"toCoda":return $e.toCoda;default:return n[0].toUpperCase()+n.substring(1)}}function Eu(n){return x.Is.isEnumValue(n,_n)}function Po(n){if(/^(p+|f+|m|mp|mf)$/.test(n)){let e=.5-x.Str.charCount(n,"p")*.1+x.Str.charCount(n,"f")*.1;return x.Math.clamp(e,0,1)}else return}function ku(n){return x.Is.isEnumValue(n,vn)}function Wm(n){return x.Is.isEnumValue(n,_n)?"dynamics":x.Is.isEnumValue(n,vn)?"tempo":void 0}function Wx(n){switch(n){case"bottom":return .8;case"middle":return .5}}function Ux(n){return Eu(n)?2:ku(n)?1:0}var vi=class extends ha{constructor(t,r,i,o,s,a){super(t);p(this,"length");p(this,"visible");p(this,"lineStyle");p(this,"linePos");p(this,"startColumn");p(this,"context");if(this.length=i,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=t instanceof nt?Ux(t.getText()):0,t instanceof nt)t.updateAnchorY(Wx(a));else throw new O(6,"Update anchor's y-coordinate is only implemented for text objects.")}isVisible(){return this.visible}getLineStyle(){return this.lineStyle}getLinePos(){return this.linePos}getSpanBreakText(t,r){if(t===t.measure.getColumn(0)){let i=t.measure.getPrevMeasure();if(i){if(i.hasEndSection()||i.hasEndSong())return"section-break";let o=["endRepeat","ending"];for(let s=0;s<o.length;s++)if(i.hasNavigation(o[s]))return"section-break"}}if(r===1){let i=t.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&ku(s))return s}}else if(r===2){let i=t.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&Eu(s))return s}}}getExtensionRangeInfo(){let{startColumn:t,length:r,context:i}=this,o=[t];if(r<=0)return{startColumn:t,endColumn:t,columnRange:o,extensionBreakText:void 0};let s=r,a=t;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:t,endColumn:a,columnRange:o,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:t,endColumn:a,columnRange:o,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:t,endColumn:a,columnRange:o,extensionBreakText:void 0};a=c,o.push(a)}}};var zx=2,Yx=2,Hx=.5,Zx=.5;function Xx(n,e){let t=Gt.get(e.options.beatLength,e.options.dotCount).ticks,r=e.beatsPerMinute*t;return 60*n/r}function Lu(){return Po("m")}function Qx(n){return n*1.25}var Kx=.5,In=class{constructor(e){this.col=e;p(this,"speed");p(this,"volume");this.speed=1,this.volume=Lu()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=Lu()}setSpeed(e){this.speed=e}getSpeed(){return this.speed}getTempo(){let e=x.Math.clamp(this.getSpeed(),.1,10);return wc(this.measure.getTempo(),e)}setVolume(e){this.volume=e}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:e}=this;if(e instanceof Tr)return this.measure.getMeasureTicks()/2;{let r=Kt().map(i=>e.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:x.Math.sum(r)/r.length}}},Ca=class n{constructor(){p(this,"playTimer");p(this,"playPos");p(this,"playState",2);p(this,"doc");p(this,"cursorPositionChangeListener");p(this,"playStateChnageListener");p(this,"playerColumnSequence",[])}setDocument(e){this.doc=e,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(e){this.cursorPositionChangeListener=e}setPlayStateChnageListener(e){this.playStateChnageListener=e}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let e=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==e&&(this.playStateChnageListener&&this.playStateChnageListener(e),this.playState=e)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let e=[],t=this.doc.getFirstMeasure(),r=t,i,o=!1,s=!1;for(;t;){if(t.incPassCount(),t.getEnding()){let u=t.getPassCount();t=n.getMeasureByEndingPassage(t,u)}if(t)if(e.push(t),t.hasNavigation("startRepeat")&&(r=t),t.hasNavigation("Segno")&&(i=t),s&&t.hasNavigation("toCoda"))for(;t&&!t.hasNavigation("Coda");)t=t.getNextMeasure();else if(o&&t.hasNavigation("Fine"))t=void 0;else if(t.hasNavigation("D.C. al Coda"))s=!0,t=this.doc.getFirstMeasure();else if(t.hasNavigation("D.C. al Fine"))o=!0,t=this.doc.getFirstMeasure();else if(t.hasNavigation("D.S. al Coda"))s=!0,t=i;else if(t.hasNavigation("D.S. al Fine"))o=!0,t=i;else if(t.hasNavigation("endRepeat")){let u=t.getPassCount(),l=t.getEndRepeatPlayCount()-1,h=((a=t.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=l||h?t=r:t=t.getNextMeasure()}else t.hasEndSong()?t=void 0:t=t.getNextMeasure()}return e}collectPlayerColumnSequence(){let e=this.collectPlayerMeasureSequence(),t=[];for(let r=0;r<e.length;r++){let i=e[r];t=t.concat(i.getColumns()),i.hasFermata(i.getBarLineRight())&&t.push(i.getBarLineRight())}return t}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let e=1,t=Lu(),r=new Map,i=new Map,o=(a,c)=>{var u;return r.set(a,[...(u=r.get(a))!=null?u:[],c])},s=(a,c)=>{var u;return i.set(a,[...(u=i.get(a))!=null?u:[],c])};this.playerColumnSequence.forEach(a=>{var l,h;if(!(a instanceof wr))return;a.getAnchoredLayoutObjects().forEach(d=>{var g;let m=(g=d.getTextContent())!=null?g:"",f;if(m==="a tempo")e=1;else if((f=Po(m))!==void 0)t=f;else if(d.musicObj.getLink()instanceof vi){let b=d.musicObj.getLink(),{columnRange:A,extensionBreakText:I}=b.getExtensionRangeInfo(),w=x.Math.sum(A.map(S=>S.getTicksToNextColumn()));switch(m){case"accel.":{let S=e,_=S*zx,v=0;A.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,S+(_-S)*v/w)});break}case"rit.":{let S=e,_=S/Yx,v=0;A.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,S+(_-S)*v/w)});break}case"cresc.":{let S=t,_=S+Hx;I&&(f=Po(I))!==void 0&&f>S&&(_=f);let v=0;A.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(_-S)*v/w)});break}case"decresc.":case"dim.":{let S=t,_=S-Zx;I&&(f=Po(I))!==void 0&&f<S&&(_=f);let v=0;A.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(_-S)*v/w)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(e=x.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(t=x.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(e),a.getPlayerProps().setVolume(t)})}static getMeasureByEndingPassage(e,t){for(let r=e;;r=r.getNextMeasure()){let i=r==null?void 0:r.getEnding();if(i&&i.hasPassage(t))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 e=this.playerColumnSequence[this.playPos];if(!e){this.stop();return}let t=(s,a)=>{let c=Xx(s,a);return Math.max(0,c)},r=e.getPlayerProps().getTempo(),i=e.getPlayerProps().getFermataHoldTicks(),o;e instanceof Tr?o=t(i,r):(e.getPlayerNotes().forEach((a,c)=>{let u=e.hasArpeggio()?Gt.get("32n").ticks*c:0,l=t(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(t(Gt.get("8n").ticks,r)/2,l/2));let h=Qx(e.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=Kx),u>0){let d=t(u,r);window.setTimeout(()=>sa(a.note,l,h),d*1e3)}else sa(a.note,l,h)}}),o=t(e.getTicksToNextColumn()+i,r)),this.playTimer=window.setTimeout(()=>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:e}=this;if(!e)return;e.getFirstMeasure()?(this.playPos=0,this.playStep()):this.playPos=void 0,this.notifyPlayStateChanged()}pause(){this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}stop(){this.playPos=void 0,this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}getNextPlayPosition(e){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let e=this.playerColumnSequence[this.playPos];if(!e)return;let t=e.measure,r=e.getRect().centerX,i=t.row.getRect().top,o=t.row.getRect().bottom;return new F(r,r,i,o)}};var ju=class extends tt{constructor(t,r){super(r);this.barLine=t;this.line=r;p(this,"lineRects",[]);p(this,"dotRects",[]);p(this,"mi");r.addObject(this),this.mi=new Vo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}setRect(t){this.rect=t}offset(t,r){this.lineRects.forEach(i=>i.offsetInPlace(t,r)),this.dotRects.forEach(i=>i.offsetInPlace(t,r)),this.rect.offsetInPlace(t,r)}},_a=class extends tt{constructor(t){super(t);this.measure=t;p(this,"staffTabObjects",[]);p(this,"barLineType",0)}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let o=this.staffTabObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}layout(t){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,lineWidth:i}=t,{measure:o,barLineType:s}=this,{row:a}=o,c=i,u=.7*r,l=.7*r,h=ct.DotSize*r,d=h/2;a.getNotationLines().forEach(m=>{let f=new ju(this,m),g,b,A,I,w=(_,v)=>{f.lineRects.push(new F(_,_+v/2,_+v,A,0,I))},S=_=>{for(let v=-1;v<=1;v+=2){let C=g+v*b;f.dotRects.push(new F(_-d,_,_+d,C-d,C,C+d))}};switch(m instanceof Tt?(g=m.getMiddleLineY(),b=m.getDiatonicSpacing()):(g=(m.getBottomLineY()+m.getTopLineY())/2,b=(m.getBottomLineY()-m.getTopLineY())/6),A=m.getTopLineY(),I=m.getBottomLineY(),s){case 0:f.setRect(new F(0,0,0,A,0,I));break;case 1:f.setRect(new F(-c,0,0,A,0,I)),w(-c,c);break;case 2:f.setRect(new F(-c-l-c,0,0,A,0,I)),w(-c-l-c,c),w(-c,c);break;case 3:f.setRect(new F(-u-l-c,0,0,A,0,I)),w(-c-l-u,c),w(-u,u);break;case 4:f.setRect(new F(0,0,u+l+c+l+h,A,0,I)),w(0,u),w(u+l,c),S(u+l+c+l+d);break;case 5:f.setRect(new F(-u-l-c-l-h,0,0,A,0,I)),w(-c-l-u,c),w(-u,u),S(-c-l-u-l-d);break;case 6:f.setRect(new F(-h-l-c-l-u/2,0,u/2+l+c+l+h,A,0,I)),w(-u/2,u),w(-u/2-l-c,c),w(u/2+l,c),S(-u/2-l-c-l-d),S(u/2+l+c+l+d);break}this.staffTabObjects.push(f)})}updateRect(){if(this.staffTabObjects.length>0){this.rect=this.staffTabObjects[0].getRect().copy();for(let t=1;t<this.staffTabObjects.length;t++)this.rect.expandInPlace(this.staffTabObjects[t].getRect())}else this.rect=new F}offset(t,r){this.staffTabObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let r=t.getCanvasContext();!r||this.barLineType===0||(t.drawDebugRect(this.getRect()),r.strokeStyle=r.fillStyle="black",this.staffTabObjects.forEach(i=>{i.lineRects.forEach(o=>r.fillRect(o.left,o.top,o.width,o.height)),i.dotRects.forEach(o=>t.fillCircle(o.centerX,o.centerY,o.width/2))}))}},Qr=class extends _a{constructor(t){super(t);p(this,"mi");this.mi=new Bo(this)}getMusicInterface(){return this.mi}solveBarLineType(){let t=this.measure,r=t.getPrevMeasure();return t.hasNavigation("startRepeat")?r&&r.row===t.row&&r.hasNavigation("endRepeat")?0:4:0}},Tr=class extends _a{constructor(t){super(t);p(this,"playerProps");p(this,"mi");this.playerProps=new In(this),this.mi=new Fo(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let t=this.measure,r=t.getNextMeasure();return t.hasNavigation("endRepeat")?r&&r.row===t.row&&r.hasNavigation("startRepeat")?6:5:!t.doc.hasSingleMeasure()&&(t.hasEndSong()||!t.getNextMeasure())?3:t.hasEndSection()||t===t.row.getLastMeasure()&&r&&r.row===t.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var Ii=class extends tt{constructor(t,r){super(t);this.measure=t;this.passages=r;p(this,"endingText");p(this,"shapeRects",[]);p(this,"mi");if(this.mi=new Go(this),x.Is.isIntegerGte(r.length,1)){if(!this.passages.every(o=>x.Is.isIntegerGte(o,1)))throw new O(6,"Invalid passages: "+this.passages)}else throw new O(6,"Passages is empty.");this.passages.sort((o,s)=>o-s);let i=this.passages.map(o=>o+".").join("");this.endingText=new nt(this,i,0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:t}=this,r=t.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||t.hasNavigation("endRepeat")||t.isLastMeasure()}hasPassage(t){return this.passages.some(r=>r===t)}getHighestPassage(){return Math.max(0,...this.passages)}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){this.rect=new F,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(t){let{unitSize:r}=t,{measure:i}=this;this.endingText.layout(t);let o=this.endingText.getRect(),s=i.getColumnsContentRect(),a=o.height;this.rect=new F(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new F(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new F(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new F(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().copy()]}offset(t,r){this.endingText.offset(t,r),this.shapeRects.forEach(i=>i.offsetInPlace(t,r)),this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{lineWidth:i}=t,{rect:o}=this;t.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle="black",r.lineWidth=i,r.beginPath(),r.moveTo(o.left,o.bottom),r.lineTo(o.left,o.top),r.lineTo(o.right,o.top),this.isSingleMeasureEnding()&&r.lineTo(o.right,o.bottom),r.stroke(),this.endingText.draw(t)}};var Jx=(n,e)=>{let t=ct.BeamAngleFactor;if(!Number.isFinite(t)||t===0)return e;{let r=n/e/t;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),n/r*t}},qo=class{constructor(e,t,r,i,o){this.staff=e;this.beamGroup=t;this.symbol=r;this.x=i;this.y=o;p(this,"topBeamsHeight",0);p(this,"bottomBeamsHeight",0);e.addObject(this)}offset(e,t){this.x+=e,this.y+=t,this.beamGroup.requestRectUpdate()}getRect(){return new F(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},Pu=class extends tt{constructor(t,r){super(t);this.staff=t;this.beamGroup=r;p(this,"tupletNumber");p(this,"tupletNumberOffsetY",0);p(this,"points",[]);p(this,"mi");t.addObject(this),this.mi=new Uo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.getRect().contains(t,r)?[this]:[]}offset(t,r){var i;this.points.forEach(o=>o.offset(t,0)),(i=this.tupletNumber)==null||i.offset(t,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().copy():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().copy()),this.points.forEach(t=>this.rect.expandInPlace(t.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Kr=class{constructor(e,t){this.beamGroup=e;this.message=t}},Si=class n extends tt{constructor(t,r){super(t[0].measure);this.symbols=t;this.tupletRatio=r;p(this,"mi");p(this,"type");p(this,"staffObjects",[]);this.mi=new Wo(this);let i=r?"Tuplet":"BeamGroup";if(t.every(o=>o.measure===t[0].measure)){if(t.length<2)throw new O(6,`${i} needs minimum 2 symbols, but ${t.length} given.`)}else throw new O(6,`All ${i} symbols are not in same measure.`);if(r!==void 0){let o=t.length<3||t.some(s=>!(s instanceof Ct))||t.some(s=>s.rhythmProps.flagCount!==t[0].rhythmProps.flagCount);t.length>=3&&t[0]instanceof Ct&&t[t.length-1]instanceof Ct&&t[0].rhythmProps.flagCount===t[t.length-1].rhythmProps.flagCount&&(o=!1),t.some(s=>_t.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,this.setTupletBeamCounts()}else this.type=0,this.setBeamCounts();if(t.every(o=>o.getBeamGroup()===void 0))t.forEach(o=>o.setBeamGroup(this)),t[0].measure.addBeamGroup(this);else throw new O(6,`Cannot add ${i} because some symbol already has one.`);if(this.type===0&&this.symbols.filter(o=>o instanceof Ct).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 Kr(this,"Beam has zero left or right beam count!")}),t.some(o=>o.voiceId!==t[0].voiceId))throw this.type===0?new Kr(this,"Beam symbols have different voiceId."):new O(6,"Tuplet symbols have different voiceId.");t[0].row.getStaves().forEach(o=>{o.getActualStaff(t[0].ownDiatonicId)&&o.containsVoiceId(t[0].voiceId)&&t.forEach(s=>{let a=o.getActualStaff(s.ownDiatonicId);if(!a||!a.containsVoiceId(s.voiceId))throw new Kr(this,"Some of beam or tuplet symbols are not visible!")})})}get showTupletRatio(){var t;return((t=this.tupletRatio)==null?void 0:t.showRatio)===!0}static createBeam(t){if(t.length>1&&t.every(r=>!r.hasTuplet()))try{return new n(t,void 0),!0}catch(r){if(r instanceof Kr)r.beamGroup.detach();else throw r}return!1}static createOldStyleTriplet(t){try{let r=t.slice(0,2),i=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(i[0]*2===i[1]||i[1]*2===i[0]))return new n(r,gr.Triplet),2;let o=t.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 n(o,gr.Triplet),3}catch(r){if(r instanceof Kr)console.error(r.message),r.beamGroup.detach();else throw r}return 0}static createTuplet(t,r){try{new n(t,r)}catch(i){if(i instanceof Kr)console.error(i.message),i.beamGroup.detach();else throw i}}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(t=>t.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getTupletRatioText(){var t,r,i;return this.showTupletRatio?String((t=this.tupletRatio)==null?void 0:t.parts)+":"+String((r=this.tupletRatio)==null?void 0:r.inTimeOf):String((i=this.tupletRatio)==null?void 0:i.parts)}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get stemDir(){return this.symbols[0].ownStemDir}get color(){return this.symbols[0].color}layout(t){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let{unitSize:i}=t,{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 q,L;if(!c)return;let l=a.map(k=>{var P;return(P=k[u])==null?void 0:P.x}),h=a.map(k=>{var P;return(P=k[u])==null?void 0:P.y}),d=a.map(k=>{var P;return(P=k[u])==null?void 0:P.staff}),m=a.map(k=>{var P;return(P=k[u])==null?void 0:P.stemHeight}),f=r[0],g=l[0],b=h[0],A=d[0],I=r[r.length-1],w=l[l.length-1],S=h[h.length-1],_=d[h.length-1];if(g===void 0||b===void 0||A===void 0||w===void 0||S===void 0||_===void 0)return;let v=(q=m[0])!=null?q:0,C=(L=m[m.length-1])!=null?L:0;if(s!==2){let k=v<C?Math.sqrt(C-v):0,P=C<v?Math.sqrt(v-C):0;o==="up"&&(k*=-1,P*=-1),k!==0&&(b+=k,h[0]+=k),P!==0&&(S+=P,h[h.length-1]+=P)}let y=i*2*(o==="up"?-1:1),T=(S+b)/2,E=Jx(w-g,S-b)/2;b=T-E,S=T+E;let R=0;h.forEach((k,P)=>{let G=l[P];if(G!==void 0&&k!==void 0){let Q=x.Math.interpolateY(g,b,w,S,G),Y=k-Q;o==="up"&&Y<0?R=Math.min(R,Y):o==="down"&&Y>0&&(R=Math.max(R,Y))}}),b+=R,S+=R,h=h.map(k=>k===void 0?void 0:k+R);let M=new Pu(c,this);if(s===2){let k=i/(w-g),P=x.Math.interpolateCoord(g,b+y,w,S+y,-k),G=x.Math.interpolateCoord(g,b+y,w,S+y,1+k);M.points.push(new qo(A,this,f,P.x,P.y)),M.points.push(new qo(_,this,I,G.x,G.y)),M.tupletNumberOffsetY=0}else if(s===0||s===1){R*=.5;let{beamThickness:k}=t,P=G=>{let Q=r[G];if(Q instanceof Ct){let Y=Q instanceof Ct?Math.max(Q.getLeftBeamCount(),Q.getRightBeamCount()):0;return ct.BeamSeparation*i*(o==="up"?Y-1:0)}else return 0};r.forEach((G,Q)=>{let Y=d[Q],V=l[Q],ut=h[Q];if(Y&&V!==void 0&&ut!==void 0){let mt=new qo(Y,this,G,V,ut);switch(o){case"up":mt.topBeamsHeight=k/2,mt.bottomBeamsHeight=k/2+P(Q);break;case"down":mt.topBeamsHeight=k/2+P(Q),mt.bottomBeamsHeight=k/2;break}M.points.push(mt)}}),M.tupletNumberOffsetY=y}this.isTuplet()&&(M.tupletNumber=new nt(this,this.getTupletRatioText(),.5,.5),M.tupletNumber.layout(t),M.tupletNumber.offset((g+w)/2,(b+S)/2+M.tupletNumberOffsetY)),M.points.length>=2&&this.staffObjects.push(M)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;else{this.staffObjects.forEach(t=>t.updateRect()),this.rect=this.staffObjects[0].getRect().copy();for(let t=1;t<this.staffObjects.length;t++)this.rect.expandInPlace(this.staffObjects[t].getRect())}}updateStemTips(){this.staffObjects.forEach(t=>{let r=t.points[0],i=t.points[t.points.length-1];if(this.type!==2&&t.points.forEach(o=>{o.symbol instanceof Ct&&(o!==r&&o!==i&&(o.y=x.Math.interpolateY(r.x,r.y,i.x,i.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),t.tupletNumber){let o=(r.y+i.y)/2+t.tupletNumberOffsetY;t.tupletNumber.offset(0,-t.tupletNumber.getRect().centerY+o)}})}offset(t,r){this.staffObjects.forEach(i=>i.offset(t,0)),this.requestRectUpdate()}draw(t){let{unitSize:r,beamThickness:i,lineWidth:o}=t,{stemDir:s,color:a,type:c}=this;if(c===2){let u=(s==="up"?1:-1)*r;this.staffObjects.forEach(l=>{let{x:h,y:d}=l.points[0],{x:m,y:f}=l.points[l.points.length-1];if(l.tupletNumber){let g=l.tupletNumber.getRect().width/(m-h)*1.2,b=x.Math.interpolateCoord(h,d,m,f,.5-g/2),A=x.Math.interpolateCoord(h,d,m,f,.5+g/2);t.drawLine(h,d,b.x,b.y,a,o),t.drawLine(A.x,A.y,m,f,a,o)}else t.drawLine(h,d,m,f,a,o);t.drawLine(h,d,h,d+u,a,o),t.drawLine(m,f,m,f+u,a,o)})}else(c===0||c===1)&&this.staffObjects.forEach(u=>{let l=u.points.filter(b=>b.symbol instanceof Ct),{x:h,y:d}=l[0],{x:m,y:f}=l[l.length-1],g=ct.BeamSeparation*r*(s==="up"?1:-1)*(1+.5*Math.abs(Math.atan2(f-d,m-h)));for(let b=0;b<l.length-1;b++){let{x:A,y:I,symbol:w}=l[b],{x:S,y:_,symbol:v}=l[b+1],C=w.getRightBeamCount(),y=v.getLeftBeamCount();for(let T=0;T<Math.max(C,y);T++)T<C&&T<y?t.drawLine(A,I,S,_,a,i):C>y?t.drawPartialLine(A,I,S,_,0,.25,a,i):y>C&&t.drawPartialLine(A,I,S,_,.75,1,a,i),I+=g,_+=g}});this.staffObjects.forEach(u=>{var l;return(l=u.tupletNumber)==null?void 0:l.draw(t)})}setBeamCounts(){let t=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:l,noteSize:h,dotCount:d}=s.rhythmProps;return a>0&&l>0&&u>0&&d===0&&c*Math.pow(2,u)===h},r=this.symbols.filter(o=>o instanceof Ct);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||t(a,s)||t(s,a)?s.setLeftBeamCount(s.rhythmProps.flagCount):s.setLeftBeamCount(Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount))),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||t(c,s)||t(s,c)?s.setRightBeamCount(s.rhythmProps.flagCount):s.setRightBeamCount(Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount))))}let i;do{i=!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),i=!0),c&&c.getLeftBeamCount()>0&&(c.setLeftBeamCount(0),i=!0))}}while(i)}setTupletBeamCounts(){let t=this.getType(),r=this.getSymbols();t===1?r.forEach((i,o)=>{i instanceof Ct&&(i.setLeftBeamCount(o===0?0:i.rhythmProps.flagCount),i.setRightBeamCount(o===r.length-1?0:i.rhythmProps.flagCount))}):t===2&&r.forEach(i=>{i instanceof Ct&&(i.setLeftBeamCount(0),i.setRightBeamCount(0))})}};var Sn=class extends tt{constructor(t,r){super(t);this.pos=r;p(this,"color","black");p(this,"mi");this.mi=new zo(this)}getMusicInterface(){return this.mi}static getFermataPositions(t){let{measure:r}=t,{row:i}=r;return i.getTopStaff()!==i.getBottomStaff()?[0,1]:[0]}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t,i=r*4,o=r*3;this.rect=new F(-i/2,i/2,-o,0)}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{lineWidth:i,unitSize:o}=t,s=this.pos===1,a=(s?o:-o)*.7,c=this.rect.left,u=this.rect.right,l=(s?this.rect.bottom:this.rect.top)+a,h=(s?this.rect.top:this.rect.bottom)+a,d=h-l;t.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i,r.beginPath(),r.moveTo(c,h),r.bezierCurveTo(c,l,u,l,u,h),r.bezierCurveTo(u,l+d/5,c,l+d/5,c,h),r.stroke(),r.fill();let m=d/6;t.fillCircle((c+u)/2,h-m,Math.abs(m))}};var wn=class extends tt{constructor(t,r,i,o,s){super(t);this.measure=t;this.line=r;this.extension=i;this.leftObj=o;this.rightObj=s;p(this,"mi");i.addTail(this),this.mi=new Yo(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(){return this.leftObj instanceof Qr?this.leftObj.getRect().centerX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof wr){let t=this.rightObj,r=t.getNextColumn();return r&&r.measure===t.measure?(t.getRect().right+r.getRect().left)/2:(t.getRect().right+t.measure.getBarLineRight().getRect().left)/2}else return this.rightObj.getRect().centerX}layoutFitToMeasure(t){let{unitSize:r}=t,i=this.getLineLeft(),o=this.getLineRight(),s=r;this.rect=new F(i,o,-s/2,s/2)}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){this.rect=new F}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;let{rect:i}=this;this.extension.getLineStyle()==="dashed"&&r.setLineDash([7,3]),t.drawLine(i.left,i.centerY,i.right,i.centerY,"black",t.lineWidth),r.setLineDash([]);let o=this.extension.getTails();if(o.length>0&&this===o[o.length-1]){let s=i.centerY>this.line.getRect().centerY?-t.unitSize:t.unitSize;t.drawLine(i.right,i.centerY,i.right,i.centerY+s,"black",t.lineWidth)}}};var wi=class extends tt{constructor(t,r,i,o,s,...a){super(i);this.connectiveProps=t;this.line=r;this.measure=i;p(this,"lx",0);p(this,"ly",0);p(this,"rx",0);p(this,"ry",0);p(this,"cp1x",0);p(this,"cp1y",0);p(this,"cp2x",0);p(this,"cp2y",0);p(this,"arcHeight",0);p(this,"leftNoteGroup");p(this,"leftNoteId");p(this,"rightNoteGroup");p(this,"rightNoteId");p(this,"tieType");p(this,"mi");this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof Ct&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):x.Is.isEnumValue(a[0],Ke)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new Ho(this)}getMusicInterface(){return this.mi}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let{unitSize:r}=t,{measure:i,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:d}=l,{row:m}=i,f=m.getPrevRow(),g=m.getNextRow(),b=m.getConnectivesContentRect(),A,I;A=s.getConnectiveAnchorPoint(l,o,a,h,"left"),c!==void 0&&u!==void 0?I=c.getConnectiveAnchorPoint(l,o,u,h,"right"):I=this.tieType==="toMeasureEnd"?{x:i.getColumnsContentRect().right,y:A.y}:{x:A.x+r*ct.StubTieLength,y:A.y};let w,S,_,v;if(c===void 0)w=A.x,S=A.y,_=I.x,v=I.y;else if(s.row===m&&c.row===m)w=A.x,S=A.y,_=I.x,v=I.y;else if(s.row===f&&c.row===m){let M=f.getConnectivesContentRect().right-A.x,q=I.x-b.left;w=b.left,S=A.y+(I.y-A.y)*M/(M+q),_=I.x,v=I.y}else if(s.row===m&&c.row===g){let R=g.getConnectivesContentRect(),M=b.right-A.x,q=I.x-R.left;w=A.x,S=A.y,_=b.right,v=A.y+(I.y-A.y)*M/(M+q)}else throw new O(6,"Cannot layout connective object because no valid left and right note groups.");let y=(d==="up"?-1:1)*r*Math.log2(_-w)/3;this.lx=w,this.ly=S,this.rx=_,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:y;let{nx:T,ny:E}=x.Math.calcNormal(w,S,_,v);this.cp1x=w*.7+_*.3+T*this.arcHeight,this.cp1y=S*.7+v*.3+E*this.arcHeight,this.cp2x=w*.3+_*.7+T*this.arcHeight,this.cp2y=S*.3+v*.7+E*this.arcHeight,this.rect=new F(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(t,r){this.lx+=t,this.ly+=r,this.rx+=t,this.ry+=r,this.cp1x+=t,this.cp1y+=r,this.cp2x+=t,this.cp2y+=r,this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;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:i}=this,{lineWidth:o}=t;t.drawDebugRect(i);let s=o*1.5,a=o*.25;r.strokeStyle=r.fillStyle="black",r.lineWidth=o,this.arcHeight===0?(r.beginPath(),r.moveTo(this.lx,this.ly),r.lineTo(this.rx,this.ry),r.stroke()):(r.beginPath(),r.moveTo(this.lx,this.ly-a),r.bezierCurveTo(this.cp1x,this.cp1y-s,this.cp2x,this.cp2y-s,this.rx,this.ry-a),r.lineTo(this.rx,this.ry+a),r.bezierCurveTo(this.cp2x,this.cp2y+s,this.cp1x,this.cp1y+s,this.lx,this.ly+a),r.fill())}};var Tn=class{constructor(e,t,r,i){this.connective=e;this.span=t;this.noteAnchor=r;p(this,"noteGroups");p(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(e){return this.noteGroups[0]===e}addNoteGroup(e){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(e),!0):!1}computeParams(){let{stemDir:e}=this.noteGroups[0],{hasStem:t}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=e==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=e==="up"||!t?"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{row:r}=this.noteGroups[0].measure,i=this.noteGroups[0].ownDiatonicId,o=r.getStaff(i);this.arcDir=!o||i<o.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(e=>{e.measure.removeConnectiveObjects(),e.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){this.getStartNoteGroup().collectConnectiveProps(),this.computeParams();let{connective:e,span:t}=this;if(e==="tie"){if(x.Is.isEnumValue(t,Ke)){let r=this.noteGroups[0];for(let i=0;i<r.notes.length;i++)this.createObjConnectiveWithTieType(r,i,t)}else if(this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];i.notes.forEach((s,a)=>{let c=o.notes.findIndex(u=>U.equals(u,s));c>=0&&this.createObjConnective(i,a,o,c)})}}else if(e==="slur"){if(typeof t=="number"&&t>=2&&this.noteGroups.length===t){let r=this.noteGroups[0],i=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,0,i,0)}}else if(e==="slide"&&this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];this.createObjConnective(i,0,o,0)}}createObjConnectiveWithTieType(e,t,r){e.row.getNotationLines().filter(i=>e.enableConnective(i)).forEach(i=>{i instanceof Tt?new wi(this,i,e.measure,e,t,r):e.getFretNumberString(t)!==void 0&&new wi(this,i,e.measure,e,t,r)})}createObjConnective(e,t,r,i){let o=(s,a,c,u,l)=>{s.row.getNotationLines().filter(h=>a.enableConnective(h)&&u.enableConnective(h)).forEach(h=>{if(h instanceof Tt)new wi(this,h,s,a,c,u,l);else{let d=a.getFretNumberString(c),m=u.getFretNumberString(l);d!==void 0&&m!==void 0&&(d===m||this.connective==="slur")&&new wi(this,h,s,a,c,u,l)}})};if(e.measure===r.measure)o(e.measure,e,t,r,i);else if(e.measure.getNextMeasure()===r.measure)o(e.measure,e,t,r,i),o(r.measure,e,t,r,i);else throw new O(6,"Cannot create connective because it is jumping measures.")}};var Nn=class extends tt{constructor(t,r){super(t);this.measure=t;this.tab=r;p(this,"voiceIds");p(this,"mi");p(this,"tupletPartsTextObjMap",new Map);this.voiceIds=Kt().filter(i=>r.containsVoiceId(i)),this.rect=new F,this.mi=new Zo(this)}getMusicInterface(){return this.mi}pick(t,r){return this.rect.contains(t,r)?[this]:[]}layout(t){let r=this.measure.getColumns(),i=Kt().map(o=>x.Math.sum(r.map(s=>s.getVoiceSymbol(o)?1:0)));this.voiceIds.sort((o,s)=>x.Math.cmp(i[o],i[s])),this.rect=new F}hasTuplets(){return this.measure.getBeamGroups().some(t=>t.isTuplet())}layoutFitToMeasure(t){let{unitSize:r,fontSize:i}=t,{measure:o}=this,{left:s,right:a}=o.getColumnsContentRect(),c=r*5;this.rect.left=s,this.rect.centerX=(s+a)/2,this.rect.right=a,this.rect.top=this.hasTuplets()?-i:0,this.rect.centerY=0,this.rect.bottom=c}offset(t,r){this.rect.offsetInPlace(t,r)}draw(t){let r=t.getCanvasContext();if(!r)return;t.drawDebugRect(this.rect);let{unitSize:i,lineWidth:o,fontSize:s}=t,a=i,c=i,u=i*.25,{bottom:l,centerY:h}=this.getRect(),d=h,m=l,f=this.measure.getColumns();for(let g=0;g<f.length;g++){let b=f[g],A=this.voiceIds.map(S=>b.getVoiceSymbol(S)).find(S=>S!==void 0);if(!A)continue;let I=A.getBeamGroup(),w=I?I.getSymbols():[A];for(let S=0;S<w.length;S++){let _=w[S],v=w[S+1],C=_.col.getRect().centerX;if(_ instanceof Ct){if(_.rhythmProps.noteSize>=2){let y=_.rhythmProps.noteSize===4?o*2:o;t.drawLine(C,m,C,d,"black",y)}if(w.length===1)for(let y=0;y<_.rhythmProps.flagCount;y++)t.drawFlag(new F(C,C+a,d+y*a,d+(y+2)*a),"up");for(let y=0;y<_.rhythmProps.dotCount;y++)t.fillCircle(C+c*(y+1),m-u,u)}else if(_ instanceof Sr){let y=C,T=(d+m)/2,E=.65;r.save(),r.scale(E,E),t.drawRest(_.rhythmProps.noteSize,y/E,T/E,"black"),r.restore();for(let R=0;R<_.rhythmProps.dotCount;R++)y+=c*1.5,t.fillCircle(y,T+c,u)}if(v){let y=_,T=v,E=y.col.getRect().centerX,R=T.col.getRect().centerX,M=y.hasTuplet()?1:y instanceof Ct?y.getRightBeamCount():1,q=T.hasTuplet()?1:T instanceof Ct?T.getLeftBeamCount():1,L=Math.max(M,q);for(let k=0;k<L;k++){let P=q>M&&k>=M?.75:0,G=M>q&&k>=q?.25:1;t.drawPartialLine(E,d+k*a,R,d+k*a,P,G,"black",o*2)}for(let k=0;k<y.rhythmProps.dotCount;k++)t.fillCircle(E+c*(k+1),m-u,u);for(let k=0;k<T.rhythmProps.dotCount;k++)t.fillCircle(R+c*(k+1),m-u,u)}if(I&&I.isTuplet()){let y=(w[0].col.getRect().centerX+w[w.length-1].col.getRect().centerX)/2,T=I.getTupletRatioText(),E=this.tupletPartsTextObjMap.get(T);E||(this.tupletPartsTextObjMap.set(T,E=new nt(this,{text:T,scale:.75},.5,.5)),E.layout(t)),E.offset(-E.getRect().centerX,-E.getRect().centerY),E.offset(y,d-s/2),E.draw(t)}w.length>1&&(g=f.indexOf(w[w.length-1].col),g<0&&(g=f.length))}}}};function Aa(n){if(typeof n=="number"&&Kt().indexOf(n)<0)throw new O(6,"Invalid voiceId: "+n);return n}function $x(n){if(typeof n=="string"&&(n=[n]),x.Is.isArray(n)){let e=0;for(let t=0;t<n.length;){let r=n[t],i=n[t+1];if(typeof r=="string"){t++;let o=Gt.get(r).ticks;typeof i=="number"&&(t++,o*=i),e+=o}else t++}return e}else return n}function tA(n){switch(n){case 1:return 8;case 2:return 9;case 3:return 10;default:throw new O(0,"VerseNumber is not 1, 2 or 3.")}}var va=class va extends tt{constructor(t){super(t);this.row=t;p(this,"prevMeasure");p(this,"nextMeasure");p(this,"keySignature",cs());p(this,"timeSignature",ds());p(this,"tempo",ps());p(this,"alterKeySignature");p(this,"alterTimeSignature");p(this,"alterTempo");p(this,"signatures",[]);p(this,"tabStringNotes",[]);p(this,"barLineLeft");p(this,"columns",[]);p(this,"barLineRight");p(this,"connectives",[]);p(this,"beamGroups",[]);p(this,"tabStringNotesWidth",0);p(this,"measureId");p(this,"needLayout",!0);p(this,"leftSolidAreaWidth",0);p(this,"minColumnsAreaWidth",0);p(this,"rightSolidAreaWidth",0);p(this,"useDiatonicId",[]);p(this,"useStemDir",[]);p(this,"useString",[]);p(this,"voiceSymbols",[]);p(this,"lastAddedRhythmColumn");p(this,"lastAddedRhythmSymbol");p(this,"addExtensionToMusicObjects",[]);p(this,"layoutObjects",[]);p(this,"postMeasureBreakWidth",0);p(this,"passCount",0);p(this,"needBeamsUpdate",!0);p(this,"navigationSet",new Set);p(this,"isEndSong",!1);p(this,"isEndSection",!1);p(this,"endRepeatPlayCount",2);p(this,"endRepeatPlayCountText");p(this,"staticObjectsCache",new Map);p(this,"lyricsObjectsCache",new Map);p(this,"mi");this.mi=new Xo(this),this.prevMeasure=t.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new Qr(this),this.barLineRight=new Tr(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo(),this.row.getTabs().forEach(r=>{this.addLayoutObject(new Nn(this,r),r,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}updateOwnDiatonicId(t,r){if(typeof r=="number")this.useDiatonicId[t]=r;else if(this.useDiatonicId[t]===void 0){let o=this.getPrevMeasure();o&&o.useDiatonicId[t]!==void 0&&(this.useDiatonicId[t]=o.useDiatonicId[t])}let i=this.useDiatonicId[t];return i===void 0&&(this.row.hasStaff?i=this.row.getTopStaff().middleLineDiatonicId:i=U.getNote("C4").diatonicId),this.useDiatonicId[t]=U.validateDiatonicId(i)}updateOwnStemDir(t,r){var s,a;let{voiceId:i}=t;r!==void 0?this.useStemDir[i]=r:this.useStemDir[i]===void 0&&(this.useStemDir[i]=(a=(s=this.getPrevMeasure())==null?void 0:s.useStemDir[i])!=null?a:"auto");let o=this.useStemDir[i];if(o==="auto"||o===void 0){let c=this.row.getStaff(t.ownDiatonicId);return c?t.ownDiatonicId>c.middleLineDiatonicId?"down":"up":"up"}else return o}updateOwnString(t,r){var o,s;let{voiceId:i}=t;return r!==void 0?this.useString[i]=r:this.useString[i]===void 0&&(this.useString[i]=(s=(o=this.getPrevMeasure())==null?void 0:o.useString[i])!=null?s:[]),this.useString[i]}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.signatures.length;i++){let o=this.signatures[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabStringNotes.length;i++){let o=this.tabStringNotes[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.columns.length;i++){let o=this.columns[i].pick(t,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let i=this.barLineLeft.pick(t,r);if(i.length>0)return[this,...i]}if(this.barLineRight){let i=this.barLineRight.pick(t,r);if(i.length>0)return[this,...i]}if(this.endRepeatPlayCountText){let i=this.endRepeatPlayCountText.pick(t,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.connectives.length;i++){let o=this.connectives[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.beamGroups.length;i++){let o=this.beamGroups[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.layoutObjects.length;i++){let o=this.layoutObjects[i].musicObj.pick(t,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let t=this.doc.getFirstMeasure();return t&&t.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(t){return this.getColumns()[t]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...t){var r;if((r=this.getPrevMeasure())==null||r.endSection(),t[0]instanceof Fe)this.alterKeySignature=t[0];else if(t[0]instanceof Lr)this.alterKeySignature=t[0];else if(x.Is.isNonEmptyString(t[0])){if(t.length===1)this.alterKeySignature=mr(t[0]);else if(t.length===2)try{let i=""+t[0],o=Gn(""+t[1]);this.alterKeySignature=mr(i,o)}catch(i){throw new O(6,"Cannot set key signature because invalid args: "+t)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:cs(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(t){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=t,this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:ds(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(t,r,i){var o;if((o=this.getPrevMeasure())==null||o.endSection(),r===void 0)this.alterTempo={beatsPerMinute:t};else{let s=typeof i=="number"&&i>0?i:i===!0?1:_t.get(r).dotCount,a={beatLength:Ae(r),dotCount:s>0?s:void 0};this.alterTempo={beatsPerMinute:t,options:a}}this.updateTempo()}updateTempo(){var t;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:ps(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,o;this.alterTempo.options?(i=this.alterTempo.options.beatLength,o=(t=this.alterTempo.options.dotCount)!=null?t:0):this.alterTimeSignature?(i=this.alterTimeSignature.beatLength,o=0):(i=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:i,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(t,r,i,o){this.layoutObjects.push(new Ia(t,r,i,o)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(t,r,i){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&i(o[a],c);else if(typeof a=="string"&&a.length>0){let l=o.filter(h=>h.name===a);if(l.forEach(h=>i(h,c)),l.length===0){let h=this.doc.getStaffGroup(a);if(h&&!u.includes(a)){let d=[...u,a];(x.Is.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(m=>{switch(h.verticalPosition){case"above":s(m,0,d);break;case"below":s(m,1,d);break;case"both":s(m,0,d),s(m,1,d);break;case"auto":s(m,r,d);break}})}}}};t===void 0?o.length>=2&&o[0]instanceof Tt&&o[1]instanceof Tt&&o[0].staffConfig.grandId!==void 0&&o[0].staffConfig.grandId===o[1].staffConfig.grandId?s(r===1?1:0,r):s(0,r):x.Is.isArray(t)?t.forEach(a=>s(a,r)):s(t,r)}addFermata(t,r){let i=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new O(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(t,0,(o,s)=>{this.addLayoutObject(new Sn(i,s),o,1,s)}),this.disableExtension(),this.requestLayout()}hasFermata(t){return this.layoutObjects.some(r=>r.musicObj instanceof Sn&&r.anchor===t)}addNavigation(t,r,...i){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new O(6,"Cannot add ending beasure measure already has one.");let s=this,a=i;o={createObj:()=>new Ii(s,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=jo(r);o={createObj:()=>new nt(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0},this.addNavigation(t,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=jo(r);o={createObj:()=>new nt(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=jo(r);o={createObj:()=>new $e(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=jo(r);o={createObj:()=>new $e(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"endRepeat":if(i.length===0)this.endRepeatPlayCount=2;else if(x.Is.isIntegerGte(i[0],2))this.endRepeatPlayCount=i[0];else throw new O(6,"Invalid end repeat play count (should be 2 or greater integer): "+i[0]);if(this.endRepeatPlayCount!==2){let c={text:""+this.endRepeatPlayCount+"x",scale:.8};this.endRepeatPlayCountText=new nt(this,c,.5,1)}break}o&&this.forEachStaffGroup(t,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(t){return this.navigationSet.has(t)}addAnnotation(t,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add annotation because annotation text is empty.")}else throw new O(6,"Cannot add annotation because anchor is undefined.");let s={text:i},a,c;switch(r){case"dynamics":a=6,c=0,s.italic=!0;break;case"tempo":a=5,c=0,s.italic=!0;break}this.disableExtension(),this.forEachStaffGroup(t,c,(u,l)=>{let h=new nt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(t,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add label because label text is empty.")}else throw new O(6,"Cannot add label because anchor is undefined.");let s={text:i},a,c;switch(r){case"note":a=2,c=1;break;case"chord":a=7,c=0;break}this.disableExtension(),this.forEachStaffGroup(t,c,(u,l)=>{let h=new nt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addConnective(t,...r){let i=this.lastAddedRhythmSymbol;if(!(i instanceof Ct))throw new O(6,"Connective can be added to note group only.");if(t==="tie"){let o=x.Is.isInteger(r[0])||x.Is.isEnumValue(r[0],Ke)?r[0]:2,s=x.Is.isEnumValue(r[1],Pe)?r[1]:"auto";i.startConnective(new Tn("tie",o,s,i))}else if(t==="slur"){let o=x.Is.isInteger(r[0])?r[0]:2,s=x.Is.isEnumValue(r[1],Pe)?r[1]:"auto";i.startConnective(new Tn("slur",o,s,i))}else if(t==="slide"){let o=x.Is.isEnumValue(r[0],Pe)?r[0]:"auto";i.startConnective(new Tn("slide",2,o,i))}}addExtension(t,r){if(this.addExtensionToMusicObjects.forEach(i=>{let o=i.getParent();if(i instanceof nt&&o instanceof wr){let s="dashed",a="bottom",c=new vi(i,o,$x(t),r,s,a);i.setLink(c)}else throw new O(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new O(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(t){this.addExtensionToMusicObjects.push(t)}disableExtension(){this.addExtensionToMusicObjects=[]}getEnding(){return this.layoutObjects.map(t=>t.musicObj).find(t=>t instanceof Ii)}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(t){var o,s;let{col:r,voiceId:i}=t;r.setVoiceSymbol(i,t),(s=(o=this.voiceSymbols)[i])!=null||(o[i]=[]),this.voiceSymbols[i].push(t),t.oldStyleTriplet&&this.createOldStyleTriplets(i),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=r,this.lastAddedRhythmSymbol=t}addNoteGroup(t,r,i,o,s){let a=r.map(l=>typeof l=="string"?U.getNote(l):l),c=this.getRhythmColumn(t),u=new Ct(c,t,a,i,o,s);return this.addRhythmSymbol(u),u}addRest(t,r,i,o){let s=this.getRhythmColumn(t),a=new Sr(s,t,r,i,o);return this.addRhythmSymbol(a),a}addLyrics(t,r,i,o,s){this.forEachStaffGroup(t,1,(a,c)=>{let u=this.getRhythmColumn({verse:r,line:a,vpos:c}),l=u.getLyricsContainer(r,a,c,Ae(i));if(l){let h=new xa(u,r,a,c,o,s),d=this.getLyricsObjects(h.line,h.vpos,h.verse);d.push(h),d.sort((m,f)=>x.Math.cmp(m.col.positionTicks,f.col.positionTicks)),l.addLyricsObject(h),this.addLayoutObject(h,a,tA(r),c)}this.lastAddedRhythmColumn=u})}getRhythmColumn(t){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let o=this.columns[i],s=typeof t=="number"?o.getVoiceSymbol(t):o.getLyricsContainer(t.verse,t.line,t.vpos);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let i=0;i<=this.columns.length;i++){let o=this.columns[i];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new wr(this,r);return this.columns.splice(i,0,s),s}}throw new O(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(t){let r=0;return this.columns.forEach(i=>{Kt().forEach(o=>{let s=i.getVoiceSymbol(o);s&&(t===void 0||t===o)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new F(this.barLineLeft.getRect().centerX,this.barLineRight.getRect().centerX,this.getRect().top,this.getRect().bottom)}getLeftSolidAreaWidth(){return this.leftSolidAreaWidth}getMinColumnsAreaWidth(){return this.minColumnsAreaWidth}getRightSolidAreaWidth(){return this.rightSolidAreaWidth}getSolidAreaWidth(){return this.leftSolidAreaWidth+this.rightSolidAreaWidth}getMinWidth(){return this.leftSolidAreaWidth+this.minColumnsAreaWidth+this.rightSolidAreaWidth}getStaffLineLeft(){let t=this.getPrevMeasure();return t&&t.row===this.row&&!t.hasPostMeasureBreak()?t.getStaffLineRight():this.getRect().left+this.tabStringNotesWidth}getStaffLineRight(){return this.barLineRight.getRect().centerX}getLyricsObjects(t,r,i){let o=this.lyricsObjectsCache.get(t);o===void 0&&this.lyricsObjectsCache.set(t,o=new Map);let s=o.get(r);s===void 0&&o.set(r,s=new Map);let a=s.get(i);return a===void 0&&s.set(i,a=[]),a}getPrevLyricsObject(t){var o;let r=this.getLyricsObjects(t.line,t.vpos,t.verse),i=r.indexOf(t);if(i>0)return r[i-1];if(i===0){let s=(o=t.measure.getPrevMeasure())==null?void 0:o.getLyricsObjects(t.line,t.vpos,t.verse);if(s&&s.length>0)return s[s.length-1]}}getStaticObjects(t){let r=this.staticObjectsCache.get(t);r||(r=[],this.getColumns().forEach(o=>o.getStaticObjects(t).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(t,r));let i=this.layoutObjects.filter(o=>o.line===t&&o.isPositionResolved()).map(o=>o.musicObj);return i.length>0?[...r,...i]:r}removeLayoutObjects(t){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===t){let i=r.musicObj.getLink();return i&&i.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(t){this.connectives.push(t),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(t=>{var c;let{musicObj:r,measure:i,layoutGroupId:o,verticalPos:s,line:a}=t;if(r.getLink()instanceof vi){let u=r.getLink();if(u.getHead()===r){u.getTails().forEach(d=>i.removeLayoutObjects(d));let{startColumn:l,endColumn:h}=u.getExtensionRangeInfo();if(u.isVisible()&&l!==h)for(let d=l.measure;d!==void 0;d=d===h.measure?void 0:d.getNextMeasure()){let m=d===l.measure?u.getHead():d.getBarLineLeft(),f=d===h.measure?h:d.getBarLineRight(),g=d.row.getNotationLines(),b=(c=g.find(A=>A.name!==""&&A.name===a.name))!=null?c:g[a.id];b&&d.addLayoutObject(new wn(d,b,u,m,f),b,o,s)}}}})}addBeamGroup(t){this.beamGroups.push(t)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(t){let r=this.getVoiceSymbols(t);for(let i=0;i<r.length;)if(r[i].oldStyleTriplet){let o=Si.createOldStyleTriplet(r.slice(i,i+3));i+=o===0?1:o}else i++;this.requestLayout()}getBeamGroups(){return this.beamGroups}createBeams(){if(!this.needBeamsUpdate)return;this.beamGroups=this.beamGroups.filter(r=>r.isTuplet()?!0:(r.detach(),!1));let t=this.getTimeSignature();!this.needBeamsUpdate||t.beamGroupSizes.length===0||(Kt().forEach(r=>{let i=this.getVoiceSymbols(r).slice();if(i.length<2)return;let o=this.isUpBeat()?Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()):0,s=0;for(let a=0;a<t.beamGroupSizes.length;a++){let c=t.beamGroupSizes[a],u=[c];c.length>1&&u.unshift([x.Math.sum(c)]);let l=!1,h=s;for(;u.length>0&&!l;){let d=u.shift();s=h,d.forEach(m=>{let f=m*_t.get("8n").ticks,g=s+f,b=i.filter(I=>{let w=o+I.col.positionTicks,S=w+I.rhythmProps.ticks;return w>=s&&S<=g});x.Math.sum(b.map(I=>I.rhythmProps.ticks))===f&&b.every(I=>I instanceof Ct)&&(b.every(I=>I.rhythmProps.flagCount===1)||u.length===0)&&Si.createBeam(b)&&(l=!0),s+=f})}}}),this.needBeamsUpdate=!1,this.requestLayout())}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(t){var r,i;return Aa(t),(i=(r=this.voiceSymbols)[t])!=null||(r[t]=[]),this.voiceSymbols[t]}completeRests(t){if(t===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(Kt().filter(r=>this.getConsumedTicks(r)>0));return}else if(x.Is.isArray(t)){t.forEach(r=>this.completeRests(r));return}else{Aa(t);let r=this.getMeasureTicks(),i=this.getConsumedTicks(t),o=r-i,s=[];for(;o>0;)for(let a=_t.LongestNoteSize;a<=_t.ShortestNoteSize;a*=2){let c=_t.create(a).noteLength;for(let u=_t.get(c).maxDotCount;u>=0;u--){let l=Gt.get(c,u);for(;l.ticks<=o;)s.push(l),o-=l.ticks}}s.reverse().forEach(a=>this.addRest(t,a.noteLength,{dotted:a.dotCount}))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(t){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=t;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?ct.PostMeasureBreakWidth*r:0;let i=this===this.row.getFirstMeasure(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.tabStringNotesWidth=i&&this.row.hasTab?r*4:0;let s=i||o,a=i&&!this.row.isFirstRow(),c=i||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;this.signatures=[],this.row.getNotationLines().forEach((f,g)=>{if(f instanceof Tt&&(s||a||c||u||l)){let b=this.signatures.filter(I=>I instanceof vo).find(I=>I.staff===f),A=b!=null?b:new vo(this,f);A.staff.addObject(A),A.updateClefImage(t,s),A.updateMeasureNumber(a&&g===0),A.updateKeySignature(c),A.updateTimeSignature(u),A.updateTempo(l&&g===0),A.layout(t),this.signatures.push(A)}else if(f instanceof Se&&(a||u||l)){let b=this.signatures.filter(I=>I instanceof Io).find(I=>I.tab===f),A=b!=null?b:new Io(this,f);A.tab.addObject(A),A.updateMeasureNumber(a&&g===0),A.updateTimeSignature(u),A.updateTempo(l&&g===0),A.layout(t),this.signatures.push(A)}}),this.tabStringNotes.length=0,this===this.row.getFirstMeasure()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let b=f.getTuningStrings()[g].format(1,1),A=new nt(this,{text:b,scale:.8},1,.5);A.layout(t),A.offset(this.tabStringNotesWidth*.8,f.getStringY(g)),this.tabStringNotes.push(A),f.addObject(A)}}),this.barLineLeft.layout(t);let h=new pa(this);this.columns.forEach(f=>f.layout(t,h)),this.barLineRight.layout(t),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(t),this.layoutObjects.forEach(f=>f.layout(t));let d=t.unitSize;this.leftSolidAreaWidth=this.tabStringNotesWidth+Math.max(0,...this.signatures.map(f=>f.getRect().width))+this.barLineLeft.getRect().width+d,this.rightSolidAreaWidth=d+this.barLineRight.getRect().width,this.minColumnsAreaWidth=0,this.columns.forEach(f=>this.minColumnsAreaWidth+=f.getRect().width),this.minColumnsAreaWidth=Math.max(this.minColumnsAreaWidth,va.MinFlexContentWidth*r)}layoutWidth(t,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new F,this.rect.centerX=this.rect.left+r/2,this.rect.right=this.rect.left+r;let i;this.signatures.forEach(d=>{i=d.getRect(),d.offset(this.rect.left+this.tabStringNotesWidth-i.left,-i.centerY)});let o=Math.max(0,...this.signatures.map(d=>d.getRect().width));i=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.tabStringNotesWidth+o-i.left,-i.centerY),i=this.barLineRight.getRect(),this.barLineRight.offset(this.rect.right-i.right,-i.centerY),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left,this.barLineRight.getRect().top);let s=this.rect.left+this.leftSolidAreaWidth,c=this.rect.right-this.rightSolidAreaWidth-s,u=x.Math.sum(this.columns.map(d=>d.getRect().width)),l=c/u,h=s;this.columns.forEach(d=>{i=d.getRect();let m=h+i.leftw*l;d.offset(m-i.centerX,-i.centerY),h+=i.width*l})}layoutConnectives(t){this.needLayout&&this.connectives.forEach(r=>{r.layout(t),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(t){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(t),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(t=>t.updateStemTips())}layoutDone(){this.columns.forEach(t=>t.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(t=>t.getRect().top),...this.tabStringNotes.map(t=>t.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(t=>!t.isEmpty()).map(t=>t.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(t=>t.getRect().top),...this.beamGroups.filter(t=>!t.isEmpty()).map(t=>t.getRect().top),...this.layoutObjects.filter(t=>t.isPositionResolved()).map(t=>t.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(t=>t.getRect().bottom),...this.tabStringNotes.map(t=>t.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(t=>!t.isEmpty()).map(t=>t.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(t=>t.getRect().bottom),...this.beamGroups.filter(t=>!t.isEmpty()).map(t=>t.getRect().bottom),...this.layoutObjects.filter(t=>t.isPositionResolved()).map(t=>t.musicObj.getRect().bottom)),this===this.row.getLastMeasure()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(t=>t.isPositionResolved()&&t.musicObj instanceof Sn).map(t=>t.musicObj.getRect().right))),this.row.getNotationLines().forEach(t=>{this.rect.top=Math.min(this.rect.top,t.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,t.calcBottom())}),this.row.requestRectUpdate()}offset(t,r){this.signatures.forEach(i=>i.offset(t,0)),this.tabStringNotes.forEach(i=>i.offset(t,0)),this.barLineLeft.offset(t,r),this.columns.forEach(i=>i.offset(t,r)),this.barLineRight.offset(t,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(t,r),this.connectives.forEach(i=>i.offset(t,0)),this.beamGroups.forEach(i=>i.offset(t,r)),this.layoutObjects.forEach(i=>i.offset(t,0)),this.rect.offsetInPlace(t,r),this.requestRectUpdate()}draw(t){t.drawDebugRect(this.getRect());let r=this.getStaffLineLeft(),i=this.getStaffLineRight(),o=a=>t.drawLine(r,a,i,a),{row:s}=this;s.getNotationLines().forEach(a=>{if(a instanceof Tt)for(let c=a.bottomLineDiatonicId;c<=a.topLineDiatonicId;c+=2)o(a.getDiatonicIdY(c));else if(a instanceof Se)for(let c=0;c<6;c++)o(a.getStringY(c))}),this.signatures.forEach(a=>a.draw(t)),this.tabStringNotes.forEach(a=>a.draw(t)),this.barLineLeft.draw(t),this.columns.forEach(a=>a.draw(t)),this.barLineRight.draw(t),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(t),this.connectives.forEach(a=>a.draw(t)),this.layoutObjects.forEach(a=>a.musicObj.draw(t)),this.beamGroups.forEach(a=>a.draw(t))}};p(va,"MinFlexContentWidth",10);var On=va;var eA=[2,7],rA=[0,3,4,5,6,7,8,9,10];function iA(n){for(;n;){if(n instanceof On)return n;n=n.getParent()}throw new O(6,"Parent measure is required but not found!")}var Sa=class{constructor(e,t,r){this.groupName=e;this.staffsTabsAndGroups=t;this.verticalPosition=r}},Ia=class{constructor(e,t,r,i){this.musicObj=e;this.line=t;this.layoutGroupId=r;this.verticalPos=i;p(this,"anchor");p(this,"measure");p(this,"row");p(this,"layoutGroup");p(this,"positionResolved",!0);this.measure=iA(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new O(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)}clearPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(e){let{musicObj:t,measure:r,verticalPos:i,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=e.unitSize*2,u=i===1?a+c+t.getRect().toph:s-c-t.getRect().bottomh,l=r.getStaticObjects(o),h=t.getShapeRects();return l.forEach(d=>{let m=d.getShapeRects();h.forEach(f=>{m.forEach(g=>{F.overlapX(f,g)&&(u=i===1?Math.max(u,g.bottom+f.toph+f.centerY):Math.min(u,g.top-f.bottomh-f.centerY))})})}),u}getTextContent(){if(this.musicObj instanceof nt||this.musicObj instanceof $e)return this.musicObj.getText()}layout(e){this.line.addObject(this)}offset(e,t){this.musicObj.offset(e,t)}getRect(){return this.musicObj.getRect()}},wa=class{constructor(e){this.layoutGroupId=e;p(this,"layoutObjectTable",[]);p(this,"rowAlign");p(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=rA.indexOf(e)>=0,this.widensColumn=eA.indexOf(e)>=0}getLayoutObjects(e){return this.layoutObjectTable[e]}add(e){this.layoutObjectTable[e.verticalPos].push(e)}remove(e){this.layoutObjectTable.forEach(t=>{let r=t.indexOf(e);r>=0&&t.splice(r,1)})}clearPositionAndLayout(e){this.layoutObjectTable.forEach(t=>{t.forEach(r=>{r.clearPositionResolved(),r.musicObj.layout(e)})})}};var Ta=class extends tt{constructor(t){super(t);p(this,"objects",[]);p(this,"layoutGroups",[])}addObject(t){this.objects.push(t)}removeObjects(){this.objects.length=0}getLayoutGroup(t){let r=this.layoutGroups[t];return r||(r=this.layoutGroups[t]=new wa(t)),r}resetLayoutGroups(t){this.layoutGroups.forEach(r=>{r&&r.clearPositionAndLayout(t)})}layoutLayoutGroups(t){this.layoutGroups.forEach(r=>{r&&(this.layoutLayoutGroup(t,r,0),this.layoutLayoutGroup(t,r,1))})}setObjectY(t,r){r!==void 0&&(t.offset(0,r-t.getRect().centerY),t.setPositionResolved())}alignObjectsY(t,r){r=r.filter(o=>!o.isPositionResolved());let i;r.forEach(o=>{let s=o.resolveClosestToStaffY(t);i=o.verticalPos===1?Math.max(s,i!=null?i:s):Math.min(s,i!=null?i:s)}),r.forEach(o=>this.setObjectY(o,i))}layoutLayoutGroup(t,r,i){let o=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof Ii||a instanceof wn||a instanceof Nn?a.layoutFitToMeasure(t):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(t,o):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(t,u)}else this.alignObjectsY(t,[s])})}},Tt=class extends Ta{constructor(t,r,i){super(t);this.row=t;this.staffConfig=r;this.id=i;p(this,"clefImageAsset");p(this,"clefLineDiatonicId");p(this,"topLineDiatonicId");p(this,"middleLineDiatonicId");p(this,"bottomLineDiatonicId");p(this,"minDiatonicId");p(this,"maxDiatonicId");p(this,"joinedGrandStaff");p(this,"topLineY",0);p(this,"bottomLineY",0);p(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 O(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 Qo(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var t;return(t=this.staffConfig.name)!=null?t:""}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(t){t!==this&&(this.joinedGrandStaff=t)}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(t){return U.validateDiatonicId(t),(this.minDiatonicId===void 0||t>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||t<=this.maxDiatonicId)}getDiatonicIdY(t){if(this.containsDiatonicId(t))return this.bottomLineY+(this.bottomLineDiatonicId-t)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(t))return this.joinedGrandStaff.getDiatonicIdY(t);throw new O(6,"Staff does not contain diatonicId "+t)}getActualStaff(t){if(this.containsDiatonicId(t))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(t))return this.joinedGrandStaff;throw new O(6,"Staff does not contain diatonicId "+t)}getDiatonicIdAt(t){let r=Math.round(this.bottomLineDiatonicId-(t-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(t){return t%2===this.middleLineDiatonicId%2}isSpace(t){return t%2!==this.middleLineDiatonicId%2}containsVoiceId(t){return!this.staffConfig.voiceIds||this.staffConfig.voiceIds.includes(t)}calcTop(){let t=this.topLineY;if(this.objects.forEach(r=>t=Math.min(t,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),i=this.getDiatonicIdY(this.maxDiatonicId-1);t=Math.min(t,r-Math.abs(i-r)+1)}return t}calcBottom(){let t=this.bottomLineY;if(this.objects.forEach(r=>t=Math.max(t,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),i=this.getDiatonicIdY(this.minDiatonicId+1);t=Math.max(t,r+Math.abs(i-r)-1)}return t}pick(t,r){return[this]}layoutHeight(t){let{unitSize:r}=t,i=r*ct.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new F(0,0,this.topLineY,this.bottomLineY)}layoutWidth(t){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(t,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(t,r)}draw(t){}},Se=class extends Ta{constructor(t,r,i){super(t);this.row=t;this.tabConfig=r;this.id=i;p(this,"top",0);p(this,"bottom",0);p(this,"tuningName");p(this,"tuningStrings");p(this,"mi");x.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>U.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=vc(r.tuning),this.tuningStrings=ls(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=ls(this.tuningName)),this.mi=new Ko(this)}getMusicInterface(){return this.mi}get name(){var t;return(t=this.tabConfig.name)!=null?t:""}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(t){return this.top+(this.bottom-this.top)/6*(t+.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(t){return!this.tabConfig.voiceIds||this.tabConfig.voiceIds.includes(t)}containsDiatonicId(t){return!0}calcTop(){let{top:t}=this;return this.objects.forEach(r=>t=Math.min(t,r.getRect().top)),t}calcBottom(){let{bottom:t}=this;return this.objects.forEach(r=>t=Math.max(t,r.getRect().bottom)),t}pick(t,r){return[this]}layoutHeight(t){let{unitSize:r}=t,i=r*ct.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new F(0,0,this.top,this.bottom)}layoutWidth(t){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(t,r){this.top+=r,this.bottom+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(t,r)}draw(t){}};var Na=class extends tt{constructor(t,r,i){super(t);this.doc=t;this.prevRow=r;this.scoreConfig=i;p(this,"nextRow");p(this,"minWidth",0);p(this,"notationLines");p(this,"staves");p(this,"tabs");p(this,"measures",[]);p(this,"needLayout",!0);p(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(o=>o instanceof Tt),this.tabs=this.notationLines.filter(o=>o instanceof Se),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new Jo(this)}getMusicInterface(){return this.mi}createNotationLines(){let t=this.scoreConfig.map((r,i)=>r.type==="staff"?new Tt(this,r,i):new Se(this,r,i));for(let r=0;r<t.length-1;r++){let i=t[r],o=t[r+1];i instanceof Tt&&o instanceof Tt&&i.staffConfig.grandId!==void 0&&i.staffConfig.grandId===o.staffConfig.grandId&&(i.joinGrandStaff(o),o.joinGrandStaff(i))}return t}getNotationLines(){return this.notationLines}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let t=this.staves[0];if(t)return t;throw new O(6,"Top staff is required!")}getBottomStaff(){let t=this.staves[this.staves.length-1];if(t)return t;throw new O(6,"Bottom staff is required!")}getStaff(t){U.validateDiatonicId(t);for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r];if(i instanceof Tt&&i.containsDiatonicId(t))return i}}resetLayoutGroups(t){this.notationLines.forEach(r=>r.resetLayoutGroups(t))}layoutLayoutGroups(t){this.notationLines.forEach(r=>r.layoutLayoutGroups(t))}pick(t,r){if(!this.getRect().contains(t,r))return[];for(let i=0;i<this.measures.length;i++){let o=this.measures[i].pick(t,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.notationLines.length;i++){let o=this.notationLines[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}getConnectivesContentRect(){let t=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:t.left;return new F(i,(i+t.right)/2,t.right,t.top,t.centerY,t.bottom)}getDiatonicIdAt(t){for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r],o=i instanceof Tt?i.getDiatonicIdAt(t):void 0;if(o!==void 0)return o}}addMeasure(t){this.measures.push(t)}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}getMinWidth(){return this.minWidth}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(t){this.needLayout&&(this.requestRectUpdate(),this.notationLines.forEach(r=>{r.removeObjects(),r.layoutHeight(t)}),this.rect=new F(0,0,0,0),this.minWidth=0,this.measures.forEach(r=>{r.layout(t),this.minWidth+=r.getMinWidth(),this.minWidth+=r.getPostMeasureBreakWidth()}))}layoutWidth(t,r){if(!this.needLayout)return;let i=Math.max(r,this.minWidth);this.rect.centerX=this.rect.left+i/2,this.rect.right=this.rect.left+i,this.notationLines.forEach(u=>u.layoutWidth(t));let o=i,s=0;this.measures.forEach(u=>{o-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=o/s,c=0;this.measures.forEach(u=>{let l=u.getSolidAreaWidth()+u.getMinColumnsAreaWidth()*a;u.layoutWidth(t,l);let h=u.getRect();u.offset(c-h.left,-h.centerY),c+=h.width,c+=u.getPostMeasureBreakWidth()}),this.measures.forEach(u=>{u.layoutConnectives(t),u.layoutBeams(t)})}updateRect(){let t=this.measures.length>0?this.measures[0].getRect().left:0,r=this.measures.length>0?this.measures[this.measures.length-1].getRect().right:0,i=this.measures.length>0?Math.min(...this.measures.map(s=>s.getRect().top)):0,o=this.measures.length>0?Math.max(...this.measures.map(s=>s.getRect().bottom)):0;this.rect=new F(t,r,i,o)}alignStemsToBeams(){this.measures.forEach(t=>t.alignStemsToBeams())}layoutSetNotationLines(t){let{unitSize:r}=t;for(let i=1;i<this.notationLines.length;i++){let o=this.notationLines[i-1],s=this.notationLines[i];if(o instanceof Tt&&s instanceof Tt&&o.staffConfig.grandId!==void 0&&o.staffConfig.grandId===s.staffConfig.grandId){let a=o.getBottomLineY()-s.getTopLineY()+r*6;s.offset(0,a)}else{let a=o.calcBottom()-s.calcTop()+r*3;s.offset(0,a)}}this.measures.forEach(i=>{i.requestRectUpdate(),i.getBarLineLeft().requestRectUpdate(),i.getBarLineRight().requestRectUpdate(),i.getColumns().forEach(o=>{o.requestRectUpdate(),Kt().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.alignStemsToBeams(),this.requestRectUpdate()}layoutPadding(t){let r=t.unitSize/2;this.getRect(),this.rect.left-=r,this.rect.right+=r,this.rect.top-=r,this.rect.bottom+=r}layoutDone(){this.measures.forEach(t=>t.layoutDone()),this.needLayout=!1}offset(t,r){this.measures.forEach(i=>i.offset(t,r)),this.rect.offsetInPlace(t,r),this.notationLines.forEach(i=>i.offset(t,r))}draw(t){let r=t.getCanvasContext();if(r){if(t.drawDebugRect(this.getRect()),r.save(),r.rect(this.getRect().left,this.getRect().top,this.getRect().width,this.getRect().height),r.clip(),this.getFirstMeasure()&&(this.notationLines.length>1||this.notationLines[0]instanceof Se)){let i=this.getFirstMeasure().getStaffLineLeft(),o=Math.min(...this.notationLines.map(a=>a.getTopLineY())),s=Math.max(...this.notationLines.map(a=>a.getBottomLineY()));t.drawLine(i,o,i,s)}this.measures.forEach(i=>i.draw(t)),this.notationLines.forEach(i=>i.draw(t)),r.restore()}}};var Oa=class extends tt{constructor(t,r,i,o){super(t);this.title=r;this.composer=i;this.arranger=o;p(this,"titleText");p(this,"composerText");p(this,"arrangerText");p(this,"mi");this.mi=new $o(this),this.titleText=this.title?new nt(this,{text:this.title,scale:2},.5,0):void 0,this.composerText=this.composer?new nt(this,this.composer,1,0):void 0,this.arrangerText=this.arranger?new nt(this,"Arr.: "+this.arranger,1,0):void 0}getMusicInterface(){return this.mi}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.titleText){let i=this.titleText.pick(t,r);if(i)return[this,...i]}if(this.composerText){let i=this.composerText.pick(t,r);if(i)return[this,...i]}if(this.arrangerText){let i=this.arrangerText.pick(t,r);if(i)return[this,...i]}return[this]}layoutWidth(t,r){let i=0;this.rect=new F(0,r,0,0),this.titleText&&(this.titleText.layout(t),this.titleText.offset(r/2,i),i+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(t),this.composerText.offset(r,i),i+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(t),this.arrangerText.offset(r,i),i+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(t,r){this.titleText&&this.titleText.offset(t,r),this.composerText&&this.composerText.offset(t,r),this.arrangerText&&this.arrangerText.offset(t,r),this.rect.offsetInPlace(t,r)}draw(t){this.titleText&&this.titleText.draw(t),this.composerText&&this.composerText.draw(t),this.arrangerText&&this.arrangerText.draw(t)}};var Ra=class extends tt{constructor(){super(void 0);p(this,"needLayout",!0);p(this,"renderer");p(this,"rows",[]);p(this,"measures",[]);p(this,"measuresPerRow",1/0);p(this,"curScoreConfig",[{type:"staff",clef:"G"}]);p(this,"header");p(this,"newRowRequested",!1);p(this,"allConnectiveProps",[]);p(this,"staffGroups",new Map);p(this,"mi");this.mi=new Nr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(t){if(x.Is.isEnumValue(t,xn))switch(t){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 x.Is.isArray(t)?this.curScoreConfig=t:this.curScoreConfig=[t];for(let r=0,i="grand";r<this.curScoreConfig.length;){let o=this.curScoreConfig[r],s=this.curScoreConfig[r+1];for(;this.curScoreConfig.filter(a=>a.type==="staff").findIndex(a=>a.grandId===i)>=0;)i+="A";if(o&&o.type==="staff"&&o.isGrand){if(o.grandId!==void 0)throw new O(6,"Grand staff error: mixing isGrand and grandId!");if(s&&s.type==="staff"&&s.isGrand){if(s.grandId!==void 0)throw new O(6,"Grand staff error: mixing isGrand and grandId!");o.grandId=i,s.grandId=i,o.isGrand=s.isGrand=!1,r+=2}else throw new O(6,"Grand staff error: invalid use of isGrand!")}else r++}for(let r=0,i=[];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(i.includes(o.grandId))throw new O(6,`Grand staff error: grandId "${o.grandId}" already used!`);if(o.clef!=="G")throw new O(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(s.clef!=="F")throw new O(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(o.isOctaveDown||s.isOctaveDown)throw new O(6,"Grand staff error: cannot use isOctaveDown option!");i.push(o.grandId),o.minNote="C4",s.maxNote="B3",r+=2}else{if(o&&o.type==="staff"&&o.grandId!==void 0)throw new O(6,`Grand staff error: invalid use of grandId "${o.grandId}"!`);r++}}this.requestNewRow()}setMeasuresPerRow(t){this.measuresPerRow=t}addConnectiveProps(t){this.allConnectiveProps.push(t)}setRenderer(t){if(this.renderer===t)return;let r=this.renderer;this.renderer=t,r&&r.setDocument(void 0),t&&t.setDocument(this.mi),this.requestFullLayout()}setHeader(t,r,i){this.header=new Oa(this,t,r,i),this.requestLayout()}getTitle(){var t;return(t=this.header)==null?void 0:t.title}getComposer(){var t;return(t=this.header)==null?void 0:t.composer}getArranger(){var t;return(t=this.header)==null?void 0:t.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(t){let r=new Na(this,t,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(){let t=this.rows[this.rows.length-1];(!t||this.newRowRequested&&t.getMeasures().length>0||t.getMeasures().length>=this.measuresPerRow)&&(t=this.addNewRow(t),this.newRowRequested=!1);let r=new On(t);return this.measures.push(r),t.addMeasure(r),this.requestLayout(),r}addStaffGroup(t,r,i){this.staffGroups.set(t,new Sa(t,r,i))}getStaffGroup(t){return this.staffGroups.get(t)}getVoiceSymbols(t){let r=[];return this.forEachMeasure(i=>r=r.concat(i.getVoiceSymbols(t))),r}removeLayoutObjects(t){this.forEachMeasure(r=>r.removeLayoutObjects(t))}forEachMeasure(t){let r=this.getFirstMeasure();for(;r;)t(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(t=>t.resetPassCount())}updateCursorRect(t){this.renderer&&this.renderer.updateCursorRect(t)}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(t=>t.requestLayout()),this.forEachMeasure(t=>{t.getColumns().forEach(r=>r.requestLayout()),t.requestLayout()}),this.requestLayout()}layout(){if(!this.needLayout)return;let{renderer:t}=this;if(!t)return;let{unitSize:r}=t;this.forEachMeasure(o=>o.createBeams()),this.forEachMeasure(o=>o.createExtensions()),this.allConnectiveProps.forEach(o=>o.removeConnectives()),this.allConnectiveProps.forEach(o=>o.createConnectives()),this.rows.forEach(o=>o.resetLayoutGroups(t)),this.rows.forEach(o=>o.layout(t));let i=Math.max(ct.DocumentMinWidth*r,...this.rows.map(o=>1.4*o.getMinWidth()));this.rows.forEach(o=>o.layoutWidth(t,i)),this.rows.forEach(o=>o.layoutLayoutGroups(t)),this.rows.forEach(o=>o.layoutSetNotationLines(t)),this.rows.forEach(o=>o.layoutPadding(t)),this.rect=new F,this.header&&(this.header.layoutWidth(t,i),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(o=>{o.offset(-this.rect.left,this.rect.bottom+r*2-o.getRect().top),this.rect.expandInPlace(o.getRect())}),this.rows.forEach(o=>o.layoutDone()),this.needLayout=!1}drawContent(){let{renderer:t}=this;t&&(this.rows.forEach(r=>r.draw(t)),this.header&&this.header.draw(t))}pickStaffPosAt(t,r){if(this.rect.contains(t,r))for(let i=0;i<this.rows.length;i++){let o=this.rows[i];if(!o.hasStaff||!o.getRect().contains(t,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(t,r){if(!this.rect.contains(t,r))return[];if(this.header){let i=this.header.pick(t,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.rows.length;i++){let o=this.rows[i].pick(t,r);if(o.length>0)return[this,...o]}return[this]}};function B(n,e,t){if(!n)throw new O(6,`Invalid arg: ${e} = ${t}`)}function Fu(n){if(typeof n!="string")return!1;{let e=U.parseNote(n);return e!==void 0&&e.octave!==void 0}}function Rn(n){return x.Is.isNumber(n)&&Kt().indexOf(n)>=0}function zm(n){return x.Is.isNumber(n)&&ca().indexOf(n)>=0}function nA(n){return x.Is.isNumber(n)&&ua().indexOf(n)>=0}function Xm(n){B(x.Is.isObject(n),"baseConfig",n),B(x.Is.isStringOrUndefined(n.name),"baseConfig.name",n.name),B(x.Is.isUndefined(n.voiceIds)||x.Is.isArray(n.voiceIds)&&n.voiceIds.every(e=>x.Is.isNumber(e)),"baseConfig.voiceIds",n.voiceIds)}function Ym(n){Xm(n),B(x.Is.isObject(n),"staffConfig",n),B(n.type==="staff","staffConfig.type",n.type),B(x.Is.isEnumValue(n.clef,xi),"staffConfig.clef",n.clef),B(x.Is.isBooleanOrUndefined(n.isOctaveDown),"staffConfig.isOctaveDown",n.isOctaveDown),B(x.Is.isUndefined(n.minNote)||Fu(n.minNote),"staffConfig.minNote",n.minNote),B(x.Is.isUndefined(n.maxNote)||Fu(n.maxNote),"staffConfig.maxNote",n.maxNote),B(x.Is.isStringOrUndefined(n.grandId),"staffConfig.grandId",n.grandId),B(x.Is.isBooleanOrUndefined(n.isGrand),"staffConfig.isGrand",n.isGrand)}function Hm(n){Xm(n),B(x.Is.isObject(n),"tabConfig",n),B(n.type==="tab","tabConfig.type",n.type),x.Is.isString(n.tuning)?B(qn.includes(n.tuning),"tabConfig.tuning",n.tuning):x.Is.isArray(n.tuning)&&B(n.tuning.length===ca().length&&n.tuning.every(e=>Fu(e)),"tabConfig.tuning",n.tuning)}function Ma(n){B(x.Is.isObject(n),"noteOptions",n),B(x.Is.isBooleanOrUndefined(n.dotted)||x.Is.isIntegerGte(n.dotted,0),"noteOptions.dotted",n.dotted),B(x.Is.isEnumValueOrUndefined(n.stem,Qe),"noteOptions.stem",n.stem),B(x.Is.isStringOrUndefined(n.color),"noteOptions.color",n.color),B(x.Is.isBooleanOrUndefined(n.arpeggio)||x.Is.isEnumValue(n.arpeggio,Zr),"noteOptions.arpeggio",n.arpeggio),B(x.Is.isBooleanOrUndefined(n.staccato),"noteOptions.staccato",n.staccato),B(x.Is.isBooleanOrUndefined(n.diamond),"noteOptions.diamond",n.diamond),B(x.Is.isBooleanOrUndefined(n.triplet),"noteOptions.triplet",n.triplet),B(x.Is.isUndefined(n.string)||zm(n.string)||x.Is.isNonEmptyArray(n.string)&&n.string.every(e=>zm(e)),"noteOptions.string",n.string),B(x.Is.isUndefined(n.tieSpan),'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)',""),B(x.Is.isUndefined(n.slurSpan),'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)',"")}function Zm(n){B(x.Is.isObject(n),"restOptions",n),B(x.Is.isBooleanOrUndefined(n.dotted)||x.Is.isIntegerGte(n.dotted,0),"restOptions.dotted",n.dotted),B(x.Is.isStringOrUndefined(n.staffPos)||x.Is.isInteger(n.staffPos)||n.staffPos instanceof U,"restOptions.staffPos",n.staffPos),B(x.Is.isStringOrUndefined(n.color),"restOptions.color",n.color),B(x.Is.isBooleanOrUndefined(n.hide),"restOptions.hide",n.hide),B(x.Is.isBooleanOrUndefined(n.triplet),"restOptions.triplet",n.triplet)}function oA(n){B(x.Is.isObject(n),"lyricsOptions",n),B(x.Is.isEnumValueOrUndefined(n.align,yo),"lyricsOptions.align",n.align),B(x.Is.isEnumValueOrUndefined(n.hyphen,An),"lyricsOptions.hyphen",n.hyphen)}function ts(n){B(x.Is.isStringOrUndefined(n)||x.Is.isIntegerGte(n,0)||x.Is.isNonEmptyArray(n)&&n.every(e=>x.Is.isString(e)||x.Is.isIntegerGte(e,0)),"staffTabOrGroup",n)}function Jr(n){try{return Ae(n),!0}catch(e){return!1}}function sA(n){try{return hs(n),!0}catch(e){return!1}}var Or=class{constructor(){p(this,"doc");p(this,"currentLyricsAlign","center");this.doc=new Ra}setScoreConfiguration(e){return x.Is.isEnumValue(e,xn)?this.doc.setScoreConfiguration(e):x.Is.isObject(e)&&e.type==="staff"?(Ym(e),this.doc.setScoreConfiguration(e)):x.Is.isObject(e)&&e.type==="tab"?(Hm(e),this.doc.setScoreConfiguration(e)):x.Is.isNonEmptyArray(e)?(e.forEach(t=>{x.Is.isObject(t)&&t.type==="staff"?Ym(t):x.Is.isObject(t)&&t.type==="tab"?Hm(t):B(!1,"config",e)}),this.doc.setScoreConfiguration(e)):B(!1,"config",e),this}getMeasure(){var e;return(e=this.doc.getLastMeasure())!=null?e:this.doc.addMeasure()}getDocument(){return this.doc.getMusicInterface()}setHeader(e,t,r){return B(x.Is.isStringOrUndefined(e),"title",e),B(x.Is.isStringOrUndefined(t),"composer",t),B(x.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(e,t,r),this}setMeasuresPerRow(e){return B(x.Is.isIntegerGte(e,1)||x.Is.isPosInfinity(e),"measuresPerRow",e),this.doc.setMeasuresPerRow(e),this}addMeasure(){return this.doc.addMeasure(),this}setKeySignature(...e){return B(e[0]instanceof Lr||e[0]instanceof Fe||x.Is.isNonEmptyString(e[0])&&(e.length===1||x.Is.isEnumValue(e[1],ri)),"keySignature",e),this.getMeasure().setKeySignature(...e),this}setTimeSignature(...e){return e[0]instanceof jr?this.getMeasure().setTimeSignature(e[0]):x.Is.isEnumValue(e[0],Wn)&&x.Is.isEnumValueOrUndefined(e[1],ni)?this.getMeasure().setTimeSignature(new jr(e[0],e[1])):x.Is.isIntegerGte(e[0],1)&&x.Is.isIntegerGte(e[1],1)&&x.Is.isEnumValueOrUndefined(e[2],ni)?this.getMeasure().setTimeSignature(new jr(e[0],e[1],e[2])):B(!1,"timeSignature args",e),this}setTempo(e,t,r){return B(x.Is.isIntegerGte(e,1),"beatsPerMinute",e),t===void 0?B(x.Is.isUndefined(r),"dotted",r):(B(x.Is.isEnumValue(t,Zt)||Jr(t),"beatLength",t),B(x.Is.isBooleanOrUndefined(r)||x.Is.isIntegerGte(r,0),"dotted",r)),this.getMeasure().setTempo(e,t,r),this}addNote(e,t,r,i){if(B(Rn(e),"voiceId",e),B(t instanceof U||x.Is.isNonEmptyString(t)||x.Is.isArray(t)&&t.every(o=>o instanceof U||x.Is.isNonEmptyString(o)),"note",t),B(x.Is.isEnumValue(r,Zt)||Jr(r),"noteLength",r),i!=null||(i={}),Ma(i),x.Is.isArray(t)){let o=i.string;t.forEach((s,a)=>{i.string=x.Is.isArray(o)?o[a]:o,this.getMeasure().addNoteGroup(e,[s],r,i)})}else this.getMeasure().addNoteGroup(e,[t],r,i);return this}addChord(e,t,r,i){return B(Rn(e),"voiceId",e),B(x.Is.isNonEmptyArray(t)&&t.every(o=>o instanceof U||x.Is.isNonEmptyString(o)),"notes",t),B(x.Is.isEnumValue(r,Zt)||Jr(r),"noteLength",r),i!=null||(i={}),Ma(i),this.getMeasure().addNoteGroup(e,t,r,i),this}addRest(e,t,r){return B(Rn(e),"voiceId",e),B(x.Is.isEnumValue(t,Zt)||Jr(t),"restLength",t),r!=null||(r={}),Zm(r),this.getMeasure().addRest(e,t,r),this}addTuplet(e,t,r){B(Rn(e),"voiceId",e),B(x.Is.isFunction(r),"tupletBuilder",r),B(sA(t)&&x.Is.isBooleanOrUndefined(t.showRatio),"tupletRatio",t);let i=[],o={addNote:(s,a,c)=>{if(B(s instanceof U||x.Is.isNonEmptyString(s)||x.Is.isArray(s)&&s.every(u=>u instanceof U||x.Is.isNonEmptyString(u)),"note",s),B(x.Is.isEnumValue(a,Zt)||Jr(a),"noteLength",a),c!=null||(c={}),delete c.triplet,Ma(c),x.Is.isArray(s)){let u=c.string;s.forEach((l,h)=>{c.string=x.Is.isArray(u)?u[h]:u;let d=this.getMeasure().addNoteGroup(e,[l],a,c,t);i.push(d)})}else{let u=this.getMeasure().addNoteGroup(e,[s],a,c,t);i.push(u)}return o},addChord:(s,a,c)=>{B(x.Is.isNonEmptyArray(s)&&s.every(l=>l instanceof U||x.Is.isNonEmptyString(l)),"notes",s),B(x.Is.isEnumValue(a,Zt)||Jr(a),"noteLength",a),c!=null||(c={}),delete c.triplet,Ma(c);let u=this.getMeasure().addNoteGroup(e,s,a,c,t);return i.push(u),o},addRest:(s,a)=>{B(x.Is.isEnumValue(s,Zt)||Jr(s),"restLength",s),a!=null||(a={}),delete a.triplet,Zm(a);let c=this.getMeasure().addRest(e,s,a,t);return i.push(c),o}};return r(o),Si.createTuplet(i,t),this}addLyricsInternal(e,t,r,i,o){var s;return ts(e),B(nA(t),"verse",t),B(x.Is.isEnumValue(r,Zt),"lyricsLength",r),B(x.Is.isString(i)||x.Is.isArray(i)&&i.every(a=>x.Is.isString(a)),"lyricsText",i),o!=null||(o={}),oA(o),o.align!==void 0?this.currentLyricsAlign=o.align:(s=o.align)!=null||(o.align=this.currentLyricsAlign),x.Is.isArray(i)?i.forEach(a=>this.getMeasure().addLyrics(e,t,r,a,o)):this.getMeasure().addLyrics(e,t,r,i,o),this}addLyrics(e,t,r,i){return this.addLyricsInternal(void 0,e,t,r!=null?r:"",i)}addLyricsTo(e,t,r,i,o){return this.addLyricsInternal(e,t,r,i!=null?i:"",o)}addFermataInternal(e,t){return ts(e),B(x.Is.isEnumValue(t,bo),"fermata",t),this.getMeasure().addFermata(e,t),this}addFermata(e="atNote"){return this.addFermataInternal(void 0,e)}addFermataTo(e,t="atNote"){return this.addFermataInternal(e,t)}addNavigationInternal(e,t,...r){return ts(e),B(x.Is.isEnumValue(t,Je),"navigation",t),t==="endRepeat"&&r.length>0?B(x.Is.isIntegerGte(r[0],1),"playCount",r[0]):t==="ending"&&r.length>0&&B(r.every(i=>x.Is.isIntegerGte(i,1)),"passages",r),this.getMeasure().addNavigation(e,t,...r),this}addNavigation(e,...t){return this.addNavigationInternal(void 0,e,...t)}addNavigationTo(e,t,...r){return this.addNavigationInternal(e,t,...r)}addAnnotationInternal(e,t,r){if(t!=null||(t=Wm(r)),t===void 0)throw new O(6,`Annotation text "${r}" is not known annotation.`);return ts(e),B(x.Is.isEnumValue(t,Cn),"annotation",t),B(x.Is.isNonEmptyString(r),"text",r),this.getMeasure().addAnnotation(e,t,r),this}addAnnotation(...e){return e.length===1?this.addAnnotationInternal(void 0,void 0,e[0]):this.addAnnotationInternal(void 0,e[0],e[1])}addAnnotationTo(e,...t){return t.length===1?this.addAnnotationInternal(e,void 0,t[0]):this.addAnnotationInternal(e,t[0],t[1])}addLabelInternal(e,t,r){return ts(e),B(x.Is.isEnumValue(t,xo),"label",t),B(x.Is.isNonEmptyString(r),"text",r),this.getMeasure().addLabel(e,t,r),this}addLabel(e,t){return this.addLabelInternal(void 0,e,t)}addLabelTo(e,t,r){return this.addLabelInternal(e,t,r)}addConnective(e,...t){if(B(x.Is.isEnumValue(e,Xr),"connective",e),e==="tie"){B(x.Is.isIntegerOrUndefined(t[0])||x.Is.isEnumValue(t[0],Ke),"tieSpan",t[0]),B(x.Is.isEnumValueOrUndefined(t[1],Pe),"noteAnchor",t[1]);let r=t[0],i=t[1];this.getMeasure().addConnective(e,r,i)}else if(e==="slur"){B(x.Is.isIntegerOrUndefined(t[0]),"slurSpan",t[0]),B(x.Is.isEnumValueOrUndefined(t[1],Pe),"noteAnchor",t[1]);let r=t[0],i=t[1];this.getMeasure().addConnective(e,r,i)}else if(e==="slide"){B(x.Is.isEnumValueOrUndefined(t[0],Pe),"noteAnchor",t[0]);let r=t[0];this.getMeasure().addConnective(e,r)}return this}addExtension(e){B(x.Is.isFunctionOrUndefined(e),"addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.",e);let t=0,r=!0,i={notes:(o,s)=>(B(x.Is.isEnumValue(o,Zt)||Jr(o),"noteLength",o),B(x.Is.isUndefined(s)||x.Is.isNumber(s)&&s>=0,"noteCount",s),t+=Gt.get(o).ticks*(s!=null?s:1),i),measures:o=>(B(x.Is.isNumber(o)&&o>=1,"measureCount",o),t+=this.getMeasure().getMeasureTicks()*o,i),infinity:()=>(t=1/0,i),hide:()=>(r=!1,i)};return e?e(i):t=1/0,this.getMeasure().addExtension(t,r),this}addStaffGroup(e,t,r="auto"){return B(x.Is.isNonEmptyString(e),"groupName",e),B(x.Is.isNonEmptyString(t)||x.Is.isIntegerGte(t,0)||x.Is.isNonEmptyArray(t)&&t.every(i=>x.Is.isNonEmptyString(i)||x.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",t),B(x.Is.isEnumValue(r,go),"verticalPosition",r),this.doc.addStaffGroup(e,t,r),this}endSong(){return this.getMeasure().endSong(),this}endSection(){return this.getMeasure().endSection(),this}endRow(){var e;return(e=this.doc.getLastMeasure())==null||e.endRow(),this}completeRests(e){return B(x.Is.isUndefined(e)||Rn(e)||x.Is.isArray(e)&&e.every(t=>Rn(t)),"voiceId",e),this.getMeasure().completeRests(e),this}addScaleArpeggio(e,t,r){B(x.Is.isNonEmptyString(t),"bottomNote",t),B(x.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),o=e.getScaleNotes(t,r);for(let s=0;s<o.length;s++){s%i.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,i.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}};var es=class{constructor(e){this.type=e}},Ai=class extends es{constructor(t,r,i,o){super(t);this.renderer=r;this.scoreRow=i;this.diatonicId=o}},Ci=class extends es{constructor(t,r,i){super(t);this.renderer=r;this.objects=i;if(arguments.length===0)throw new O(6,"Empty array in score object event!")}get topObject(){return this.objects[this.objects.length-1]}findObject(t){return this.objects.find(r=>t(r))}};function Da(n,e,t){if(!n)throw new O(6,`Invalid arg: ${e} = ${t}`)}function Qm(n){return x.Is.isNumber(n)&&Kt().indexOf(n)>=0}function Bu(n){if(n instanceof Tt||n instanceof Se)return n.getMusicInterface();throw new O(6,"Notation line not staff nor tab.")}var pt=class{constructor(e){this.name=e}getParent(){var e;return(e=this.getMusicObject().getParent())==null?void 0:e.getMusicInterface()}},Ea=class Ea extends pt{constructor(t){super(Ea.Name);this.obj=t}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};p(Ea,"Name","Accidental");var Co=Ea,ka=class ka extends pt{constructor(t){super(ka.Name);this.obj=t}getMusicObject(){return this.obj}};p(ka,"Name","Connective");var Ho=ka,La=class La extends pt{constructor(t){super(La.Name);this.obj=t}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return Bu(this.obj.line)}};p(La,"Name","Arpeggio");var To=La,ja=class ja extends pt{constructor(t){super(ja.Name);this.obj=t}getMusicObject(){return this.obj}};p(ja,"Name","BeamGroup");var Wo=ja,Pa=class Pa extends pt{constructor(t){super(Pa.Name);this.obj=t}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};p(Pa,"Name","StaffBeamGroup");var Uo=Pa,Fa=class Fa extends pt{constructor(t){super(Fa.Name);this.obj=t}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(t=>t.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(t=>t.getMusicInterface())}play(t){return Da(x.Is.isFunctionOrUndefined(t),"playStateChangeListener",t),new Mn(this,t).play()}};p(Fa,"Name","Document");var Nr=Fa,Ba=class Ba extends pt{constructor(t){super(Ba.Name);this.obj=t}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(t){return Da(x.Is.isIntegerGte(t,1),"passage",t),this.obj.hasPassage(t)}};p(Ba,"Name","Ending");var Go=Ba,Va=class Va extends pt{constructor(t){super(Va.Name);this.obj=t}getMusicObject(){return this.obj}};p(Va,"Name","Fermata");var zo=Va,Ga=class Ga extends pt{constructor(t){super(Ga.Name);this.obj=t}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};p(Ga,"Name","Header");var $o=Ga,qa=class qa extends pt{constructor(t){super(qa.Name);this.obj=t}getMusicObject(){return this.obj}};p(qa,"Name","Image");var Ao=qa,Wa=class Wa extends pt{constructor(t){super(Wa.Name);this.obj=t}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(t=>t.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};p(Wa,"Name","Measure");var Xo=Wa,Ua=class Ua extends pt{constructor(t){super(Ua.Name);this.obj=t}getMusicObject(){return this.obj}};p(Ua,"Name","BarLineRight");var Fo=Ua,za=class za extends pt{constructor(t){super(za.Name);this.obj=t}getMusicObject(){return this.obj}};p(za,"Name","BarLineLeft");var Bo=za,Ya=class Ya extends pt{constructor(t){super(Ya.Name);this.obj=t}getMusicObject(){return this.obj}getBarLine(){let t=this.obj.barLine;if(t instanceof Qr||t instanceof Tr)return t.getMusicInterface();throw new O(6,"Bar line not let nor right.")}getNotationLine(){return Bu(this.obj.line)}};p(Ya,"Name","StaffTabBarLine");var Vo=Ya,Ha=class Ha extends pt{constructor(t){super(Ha.Name);this.obj=t}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()}};p(Ha,"Name","NoteGroup");var Ro=Ha,Za=class Za extends pt{constructor(t){super(Za.Name);this.obj=t}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()}};p(Za,"Name","StaffNoteGroup");var Mo=Za,Xa=class Xa extends pt{constructor(t){super(Xa.Name);this.obj=t}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()}};p(Xa,"Name","TabNoteGroup");var Do=Xa,Qa=class Qa extends pt{constructor(t){super(Qa.Name);this.obj=t}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(Qa,"Name","Rest");var No=Qa,Ka=class Ka extends pt{constructor(t){super(Ka.Name);this.obj=t}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()}};p(Ka,"Name","StaffRest");var Oo=Ka,Ja=class Ja extends pt{constructor(t){super(Ja.Name);this.obj=t}getMusicObject(){return this.obj}getRhythmSymbol(t){var r;return Da(Qm(t),"voiceId",t),(r=this.obj.getVoiceSymbol(t))==null?void 0:r.getMusicInterface()}getVoiceSymbol(t){var r;return Da(Qm(t),"voiceId",t),(r=this.obj.getVoiceSymbol(t))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(Ja,"Name","RhythmColumn");var ko=Ja,$a=class $a extends pt{constructor(t){super($a.Name);this.obj=t}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(t=>t.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(t=>Bu(t))}};p($a,"Name","ScoreRow");var Jo=$a,tc=class tc extends pt{constructor(t){super(tc.Name);this.obj=t}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()}};p(tc,"Name","Staff");var Qo=tc,ec=class ec extends pt{constructor(t){super(ec.Name);this.obj=t}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()}};p(ec,"Name","Tab");var Ko=ec,rc=class rc extends pt{constructor(t){super(rc.Name);this.obj=t}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};p(rc,"Name","StaffSignature");var So=rc,ic=class ic extends pt{constructor(t){super(ic.Name);this.obj=t}getMusicObject(){return this.obj}getTab(){return this.obj.tab.getMusicInterface()}};p(ic,"Name","TabSignature");var wo=ic,nc=class nc extends pt{constructor(t){super(nc.Name);this.obj=t}getMusicObject(){return this.obj}getMeasure(){return this.obj.measure.getMusicInterface()}getTab(){return this.obj.tab.getMusicInterface()}};p(nc,"Name","TabRhythm");var Zo=nc,oc=class oc extends pt{constructor(t){super(oc.Name);this.obj=t}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(oc,"Name","SpecialText");var Lo=oc,sc=class sc extends pt{constructor(t){super(sc.Name);this.obj=t}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(sc,"Name","Text");var _o=sc,ac=class ac extends pt{constructor(t){super(ac.Name);this.obj=t}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(ac,"Name","Lyrics");var Eo=ac,cc=class cc extends pt{constructor(t){super(cc.Name);this.obj=t}getMusicObject(){return this.obj}};p(cc,"Name","ExtensionLine");var Yo=cc;function tr(n,e,t){if(!n)throw new O(6,`Invalid arg: ${e} = ${t}`)}function rs(n,e){if(n==null)throw new TypeError(e);return n}var is=class is{constructor(e,t){p(this,"player");tr(e instanceof Nr,"doc",e),tr(x.Is.isFunctionOrUndefined(t),"playStateChangeListener",t),this.player=new Ca,this.player.setDocument(e.getMusicObject()),this.player.setCursorPositionChangeListener(r=>e.getMusicObject().updateCursorRect(r)),t&&this.player.setPlayStateChnageListener(t)}static stopAll(){this.currentlyPlaying.forEach(e=>e.stop()),aa()}play(){return is.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),is.currentlyPlaying.delete(this),this}};p(is,"currentlyPlaying",new Set);var Mn=is,Vu=class{constructor(){p(this,"renderer");this.renderer=new da(this)}setDocument(e){return tr(x.Is.isUndefined(e)||e instanceof Nr,"doc",e),this.renderer.setDocument(e),this}setCanvas(e){return e=rs(x.Dom.getCanvas(e),typeof e=="string"?"Cannot set renderer canvas because invalid canvas id: "+e:"Cannot set renderer canvas because given canvas is undefined."),this.renderer.setCanvas(e),this}setScoreEventListener(e){tr(x.Is.isFunctionOrUndefined(e),"scoreEventListener",e),this.renderer.setScoreEventListener(e)}hilightObject(e){this.renderer.hilightObject(e==null?void 0:e.getMusicObject())}hilightStaffPos(e){this.renderer.hilightStaffPos(e?{scoreRow:e.scoreRow.getMusicObject(),diatonicId:e.diatonicId}:void 0)}draw(){try{this.renderer.draw()}catch(e){console.log("Draw failed in music renderer."),console.log(e)}}},de=class de{constructor(){p(this,"playButton");p(this,"stopButton");p(this,"playStopButton");p(this,"pauseButton");p(this,"onPlay");p(this,"onStop");p(this,"onPlayStop");p(this,"onPause");p(this,"playLabel","Play");p(this,"stopLabel","Stop");p(this,"pauseLabel","Pause");p(this,"playState",2);p(this,"player");this.onPlay=()=>{var e;return(e=this.player)==null?void 0:e.play()},this.onStop=()=>{var e;return(e=this.player)==null?void 0:e.stop()},this.onPlayStop=()=>{var e,t;this.playState===0?(e=this.player)==null||e.stop():(t=this.player)==null||t.play()},this.onPause=()=>{var e;return(e=this.player)==null?void 0:e.pause()},this.updateButtons()}setDocument(e){return tr(x.Is.isUndefined(e)||e instanceof Nr,"doc",e),this.onStop(),e?this.player=new Mn(e,t=>{this.playState=t,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(e,t){return tr(x.Is.isStringOrUndefined(t),"btnLabel",t),de.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=rs(x.Dom.getButton(e),"Play button required!"),this.playLabel=t!=null?t:"Play",de.removeOnClickListeners(this.playButton,"all"),de.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(e,t){return tr(x.Is.isStringOrUndefined(t),"btnLabel",t),de.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=rs(x.Dom.getButton(e),"Stop button required!"),this.stopLabel=t!=null?t:"Stop",de.removeOnClickListeners(this.stopButton,"all"),de.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(e,t,r){return tr(x.Is.isStringOrUndefined(t),"playLabel",t),tr(x.Is.isStringOrUndefined(r),"stopLabel",r),de.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=rs(x.Dom.getButton(e),"Play/stop button required!"),this.playLabel=t!=null?t:"Play",this.stopLabel=r!=null?r:"Stop",de.removeOnClickListeners(this.playStopButton,"all"),de.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(e,t){return tr(x.Is.isStringOrUndefined(t),"btnLabel",t),de.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=rs(x.Dom.getButton(e),"Pause button required!"),this.pauseLabel=t!=null?t:"Pause",de.removeOnClickListeners(this.pauseButton,"all"),de.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(e,t){if(e){let r=this.savedOnClickListeners.get(e)||[],i=[];r.forEach(o=>{t===o||t==="all"?e.removeEventListener("click",o):i.push(o)}),this.savedOnClickListeners.set(e,i)}}static addOnClickListener(e,t){tr(x.Is.isFunction(t),"onClick",t),e.addEventListener("click",t);let r=this.savedOnClickListeners.get(e)||[];this.savedOnClickListeners.set(e,[...r,t])}};p(de,"savedOnClickListeners",new Map);var Gu=de;ei();var Wu={};Ri(Wu,{createAndanteByDiabelli:()=>uA,createFrereJacques:()=>aA,createGreensleeves:()=>cA});function aA(){return new Or().setHeader("Fr\xE8re Jacques","Traditional").setScoreConfiguration([{type:"staff",clef:"G",voiceIds:[0]},{type:"staff",clef:"F",voiceIds:[1]}]).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 cA(){return new Or().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 uA(){return new Or().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()}return of(lA);})();
211
211
  /*! Bundled license information:
212
212
 
213
213
  tone/build/esm/core/Tone.js: