@tspro/web-music-score 5.3.0 → 5.4.1
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.
- package/CHANGELOG.md +18 -0
- package/LICENSE +1 -1
- package/README.md +6 -4
- package/dist/audio/index.d.mts +1 -1
- package/dist/audio/index.d.ts +1 -1
- package/dist/audio/index.js +3 -3
- package/dist/audio/index.mjs +6 -6
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +3 -3
- package/dist/audio-synth/index.js +1 -1
- package/dist/audio-synth/index.mjs +3 -3
- package/dist/{chunk-PMDIUO22.mjs → chunk-5I5KENEC.mjs} +2 -2
- package/dist/chunk-6P4ECBUH.mjs +37 -0
- package/dist/{chunk-ZBA5XLYR.mjs → chunk-A5SMODAT.mjs} +21 -21
- package/dist/{chunk-C6UQDKWU.mjs → chunk-U2ACCEHX.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +6 -31
- package/dist/{guitar-BsSayRsH.d.ts → guitar-CNOxM4ZK.d.ts} +1 -1
- package/dist/{guitar-DdexKdN6.d.mts → guitar-DXlB-9vK.d.mts} +1 -1
- package/dist/iife/audio-cg.global.js +1 -1
- package/dist/iife/index.global.js +18 -11
- package/dist/{music-objects-BGiRQIXW.d.mts → music-objects-DYMqx839.d.mts} +66 -260
- package/dist/{music-objects-Ih9vCl4p.d.ts → music-objects-DumXKWJp.d.ts} +66 -260
- package/dist/{note-eA2xPPiG.d.mts → note-RVXvpfyV.d.mts} +13 -1
- package/dist/{note-CgCIBwvR.d.ts → note-RVXvpfyV.d.ts} +14 -2
- package/dist/pieces/index.d.mts +3 -3
- package/dist/pieces/index.d.ts +3 -3
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +9 -9
- package/dist/react-ui/index.d.ts +9 -9
- package/dist/react-ui/index.js +12 -14
- package/dist/react-ui/index.mjs +14 -16
- package/dist/{scale-CBW4eTz7.d.ts → scale-C8gHC448.d.mts} +3 -3
- package/dist/{scale-DQP3b9Zx.d.mts → scale-CUYFBo-8.d.ts} +3 -3
- package/dist/score/index.d.mts +232 -6
- package/dist/score/index.d.ts +232 -6
- package/dist/score/index.js +1122 -975
- package/dist/score/index.mjs +978 -861
- package/dist/{tempo-dkctPkCS.d.mts → tempo-BlCGZuYg.d.mts} +14 -2
- package/dist/{tempo-DMt3iwz9.d.ts → tempo-DwuZsv2T.d.ts} +14 -2
- package/dist/theory/index.d.mts +6 -6
- package/dist/theory/index.d.ts +6 -6
- package/dist/theory/index.js +88 -86
- package/dist/theory/index.mjs +85 -81
- package/package.json +5 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
2
|
-
"use strict";var WebMusicScore=(()=>{var ss=Object.defineProperty,af=Object.defineProperties,cf=Object.getOwnPropertyDescriptor,uf=Object.getOwnPropertyDescriptors,lf=Object.getOwnPropertyNames,os=Object.getOwnPropertySymbols;var fc=Object.prototype.hasOwnProperty,Qu=Object.prototype.propertyIsEnumerable;var pc=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),hf=n=>{throw TypeError(n)},Ku=Math.pow,mc=(n,t,e)=>t in n?ss(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,D=(n,t)=>{for(var e in t||(t={}))fc.call(t,e)&&mc(n,e,t[e]);if(os)for(var e of os(t))Qu.call(t,e)&&mc(n,e,t[e]);return n},X=(n,t)=>af(n,uf(t));var Dr=(n,t)=>{var e={};for(var r in n)fc.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&os)for(var r of os(n))t.indexOf(r)<0&&Qu.call(n,r)&&(e[r]=n[r]);return e};var Mi=(n,t)=>{for(var e in t)ss(n,e,{get:t[e],enumerable:!0})},df=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lf(t))!fc.call(n,i)&&i!==e&&ss(n,i,{get:()=>t[i],enumerable:!(r=cf(t,i))||r.enumerable});return n};var pf=n=>df(ss({},"__esModule",{value:!0}),n);var p=(n,t,e)=>mc(n,typeof t!="symbol"?t+"":t,e);var K=(n,t,e)=>new Promise((r,i)=>{var o=c=>{try{a(e.next(c))}catch(u){i(u)}},s=c=>{try{a(e.throw(c))}catch(u){i(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((e=e.apply(n,t)).next())}),mf=function(n,t){this[0]=n,this[1]=t};var gc=n=>{var t=n[pc("asyncIterator")],e=!1,r,i={};return t==null?(t=n[pc("iterator")](),r=o=>i[o]=s=>t[o](s)):(t=t.call(n),r=o=>i[o]=s=>{if(e){if(e=!1,o==="throw")throw s;return s}return e=!0,{done:!1,value:new mf(new Promise(a=>{var c=t[o](s);c instanceof Object||hf("Object expected"),a(c)}),1)}}),i[pc("iterator")]=()=>i,r("next"),"throw"in t?r("throw"):i.throw=o=>{throw o},"return"in t&&r("return"),i};var CC={};Mi(CC,{Audio:()=>go,Core:()=>vc,Pieces:()=>Xu,Score:()=>Zu,Theory:()=>Ec});var go={};Mi(go,{addInstrument:()=>Px,getCurrentInstrument:()=>jx,getInstrumentList:()=>Lx,isMuted:()=>Gx,linearToDecibels:()=>bs,mute:()=>Fx,playNote:()=>ca,stop:()=>ua,unmute:()=>Bx,useInstrument:()=>Ym});var Ec={};Mi(Ec,{AccidentalType:()=>Sc,BeamGrouping:()=>oi,Chord:()=>wc,DefaultGuitarNoteLabel:()=>Yg,DefaultHandedness:()=>yb,DefaultPitchNotation:()=>Ug,DefaultTuningName:()=>Cb,GuitarNoteLabel:()=>us,GuitarNoteLabelList:()=>Hg,Handedness:()=>Tc,Interval:()=>Vn,KeySignature:()=>Bt,Mode:()=>Ic,Note:()=>U,NoteLength:()=>Xe,NoteLengthProps:()=>_e,PitchNotation:()=>kr,PitchNotationList:()=>Wg,RhythmProps:()=>qe,Scale:()=>jr,ScaleFactory:()=>Ze,ScaleType:()=>ii,SymbolSet:()=>Er,TimeSignature:()=>Pr,TimeSignatures:()=>Un,TuningNameList:()=>Wn,Tuplet:()=>xr,alterTempoSpeed:()=>Dc,getDefaultKeySignature:()=>ls,getDefaultScale:()=>lb,getDefaultTempo:()=>fs,getDefaultTimeSignature:()=>ms,getPitchNotationName:()=>zg,getScale:()=>br,getScaleFactory:()=>Sl,getScaleFactoryList:()=>cb,getTempoString:()=>gs,getTuningStrings:()=>ds,validateGuitarNoteLabel:()=>Zg,validateHandedness:()=>xb,validateIntervalQuality:()=>ib,validateNoteLength:()=>Gt,validatePitchNotation:()=>gl,validateScaleType:()=>qn,validateTuningName:()=>Oc,validateTupletRatio:()=>ps});var $u=Object.defineProperty,ff=(n,t,e)=>t in n?$u(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,gr=(n,t)=>{for(var e in t)$u(n,e,{get:t[e],enumerable:!0})},Ft=(n,t,e)=>ff(n,typeof t!="symbol"?t+"":t,e),b={};gr(b,{Arr:()=>el,Dom:()=>ol,Enum:()=>sl,Is:()=>al,Map:()=>ul,Math:()=>tl,Obj:()=>ll,Str:()=>dl});var el={};gr(el,{arrayContains:()=>Ef,chunckArray:()=>kf,duplicate:()=>Nf,fillArray:()=>Rf,getRangeArray:()=>Df,getSequenceArray:()=>Mf,isArray:()=>xc,mapRangeArray:()=>nl,mapSequenceArray:()=>il,removeDuplicates:()=>Tf,removeDuplicatesCmp:()=>Of,toArray:()=>wf});var tl={};gr(tl,{avg:()=>If,calcNormal:()=>vf,clamp:()=>_f,cmp:()=>Sf,interpolateCoord:()=>Cf,interpolateY:()=>Af,isInteger:()=>Nt,linearToDecibels:()=>gf,mod:()=>bf,romanize:()=>yf,sum:()=>rl,toOrdinalNumber:()=>xf});function Nt(n){return typeof n=="number"&&isFinite(n)&&n===Math.trunc(n)}function gf(n){if(isFinite(n))return n<=0?-1/0:20*Math.log10(n);throw new Error("linearToDecibel: Invalid linearVolume = "+n)}function bf(n,t){return(n%t+t)%t}function yf(n){if(!Nt(n)||n<0)throw new Error("romanize: Invalid n = "+n);for(var t=String(+n).split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",i=3;i--;)r=(e[+t.pop()+i*10]||"")+r;return Array(+t.join("")+1).join("M")+r}function xf(n){if(!Nt(n))throw new Error("toOrdinalNumber: Invalid n = "+n);let t=n.toString(),e=Number(t.charAt(t.length-1));return n===1||n>=20&&e===1?t+"st":n===2||n>=20&&e===2?t+"nd":n===3||n>=20&&e===3?t+"rd":t+"th"}function Cf(n,t,e,r,i){return{x:n+(e-n)*i,y:t+(r-t)*i}}function Af(n,t,e,r,i){let o=(i-n)/(e-n);return t+(r-t)*o}function _f(n,t,e){return Math.min(Math.max(n,t),e)}function vf(n,t,e,r){let i=e-n,s=-(r-t),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 rl(n){return n.reduce((t,e)=>e+t,0)}function If(...n){return rl(n)/n.length}function Sf(n,t){return n<t?-1:n>t?1:0}function xc(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function wf(n){return xc(n)?n:[n]}function Nf(n){return n===void 0?n:n.slice()}function Tf(n){return n.filter((t,e,r)=>r.indexOf(t)===e)}function Of(n,t){return n.filter((e,r,i)=>r===i.findIndex(o=>t(e,o)))}function Rf(n,t){if(!Nt(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(n)}function il(n,t){if(!Nt(n)||n<0)throw new Error("mapSequenceArray: Invalid len = "+n);let e=new Array(n);for(let r=0;r<n;r++)e[r]=t(r);return e}function Mf(n){return il(n,t=>t)}function nl(n,t,e){if(!Nt(n))throw new Error("mapRangeArray: Invalid start = "+t);if(!Nt(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-n)+1,i=new Array(r);for(let o=0,s=n,a=Math.sign(t-n);o<r;s+=a,o++)i[o]=e(s);return i}function Df(n,t){return nl(n,t,e=>e)}function Ef(n,t){return n.indexOf(t)>=0}function kf(n,t){if(!Nt(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}var ol={};gr(ol,{addClass:()=>Lf,appendTo:()=>Wf,getButton:()=>Hf,getCanvas:()=>Zf,getCanvasTextWidth:()=>Jf,getDimension:()=>Qf,getHeight:()=>Vf,getOffset:()=>Ff,getPadding:()=>Xf,getWidth:()=>Bf,hasClass:()=>Cc,removeClass:()=>jf,removeFromParent:()=>Uf,setHeight:()=>qf,setOffset:()=>Pf,setRect:()=>Yf,setVisibility:()=>zf,setWidth:()=>Gf,styleLayoutChanged:()=>Kf});var sl={};gr(sl,{getEnumValues:()=>as});function as(n){return Object.keys(n).filter(t=>Number.isNaN(Number(t))).map(t=>n[t])}var bc;(n=>{let t=Error;function e(x){t=x!=null?x:Error}n.setErrorClass=e;function r(x,T){throw new t("Assertion Error: "+x+(T?" "+T:""))}function i(x){return typeof x=="number"&&isFinite(x)&&x===Math.trunc(x)}function o(x){return typeof x=="number"}function s(x,T){x||r(T!=null?T:"Assertion failed!")}n.assert=s;function a(x,T,E="value"){if(!as(T).some(R=>R===x))throw new TypeError(`Invalid ${E} enum value: ${x}`)}n.assertEnum=a;function c(x){r(x!=null?x:"Interrupted!")}n.interrupt=c;function u(x,T){return i(x)||r(`Expected ${x} to be integer.`,T),x}n.int=u;function l(x,T,E){return x!==T&&r(`Expected ${x} to equal ${T}.`,E),x}n.eq=l;function h(x,T,E){return i(x)&&o(T)&&x===T||r(`Expected ${x} to be integer equal to ${T}.`,E),x}n.int_eq=h;function d(x,T,E){return i(x)&&o(T)&&x<T||r(`Expected ${x} to be integer less than ${T}.`,E),x}n.int_lt=d;function m(x,T,E){return i(x)&&o(T)&&x<=T||r(`Expected ${x} to be integer less than or equal to ${T}.`,E),x}n.int_lte=m;function f(x,T,E){return i(x)&&o(T)&&x>T||r(`Expected ${x} to be integer greater than ${T}.`,E),x}n.int_gt=f;function g(x,T,E){return i(x)&&o(T)&&x>=T||r(`Expected ${x} to be integer greater than or equal to ${T}.`,E),x}n.int_gte=g;function y(x,T,E,R){return i(x)&&o(T)&&o(E)&&x>=T&&x<=E||r(`Expected ${x} to be integer between ${T} and ${E}.`,R),x}n.int_between=y;function C(x,T){return i(x)&&x%2===1||r(`Expected ${x} to be odd number.`,T),x}n.odd=C;function I(x,T){return i(x)&&x%2===0||r(`Expected ${x} to be even number.`,T),x}n.even=I;function S(x,T,E){if(!T.some(R=>R===x)){let R=T.map(M=>String(M)).join(", ");r(`Expected ${x} to be in group [${R}].`,E)}return x}n.in_group=S;function w(x,T){return o(x)&&isFinite(x)||r(`Expected ${x} to be finite number.`,T),x}n.finite=w;function v(x,T,E){return i(T)&&T>=0&&T<x.length||r(`Expected ${T} to be array index in bounds [0..${x.length-1}].`,E),T}n.array_id=v;function _(x,T,E){return x[v(x,T,E)]}n.array_elem=_;function A(x,T){if(x===void 0)r("Required value is undefined.",T);else return x}n.require=A})(bc||(bc={}));var Bn;(n=>{function t(){let d=document.createElement("div");d.style.width="1in",document.body.appendChild(d);let m=d.offsetWidth;return d.remove(),m||96}function e(){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=t(),n.PxPerMm=n.DPI/25.4,n.ScrollbarWidth=e(),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 y=g[2]?g[2].toLowerCase():"undefined";f=a.test(y)?y:void 0,f||console.log("Unknown unit '"+y+"' => using 'px'.")}else m=parseFloat(d);switch(bc.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})(Bn||(Bn={}));function Se(n){return n===void 0?void 0:Bn.toPx(n)}function Cc(n,t){return t.length===0?!1:n.classList?n.classList.contains(t):!!n.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function Lf(n,t){t.length!==0&&(n.classList?n.classList.add(t):Cc(n,t)||(n.className+=" "+t))}function jf(n,t){if(t.length!==0){if(n.classList)n.classList.remove(t);else if(Cc(n,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");n.className=n.className.replace(e," ")}}}function Pf(n,t,e,r="px"){n.style.left=t+r,n.style.top=e+r}function Ff(n){let t=n.getBoundingClientRect(),e=document.documentElement;return{top:t.top+window.pageYOffset-e.clientTop,left:t.left+window.pageXOffset-e.clientLeft}}function Bf(n){if(n instanceof Window)return n.innerWidth;{let t=parseFloat(getComputedStyle(n,null).width.replace("px",""));return isNaN(t)?0:t}}function Gf(n,t){n.style.width=t+"px"}function Vf(n){if(n instanceof Window)return n.innerHeight;{let t=parseFloat(getComputedStyle(n,null).height.replace("px",""));return isNaN(t)?0:t}}function qf(n,t){n.style.height=t+"px"}function Wf(n,t){t.appendChild(n)}function Uf(n){n.remove()}function zf(n,t){n.style.display=t?"block":"none"}function Yf(n,t,e,r,i,o="px"){n.style.left=t+o,n.style.top=e+o,n.style.width=r+o,n.style.height=i+o}function Hf(n){let t=typeof n=="string"?document.getElementById(n):n;return t instanceof HTMLButtonElement?t:void 0}function Zf(n){let t=typeof n=="string"?document.getElementById(n):n;return t instanceof HTMLCanvasElement?t:void 0}function Xf(n){var s;if(!n)return{top:0,right:0,bottom:0,left:0};let t=Se(n.paddingTop),e=Se(n.paddingRight),r=Se(n.paddingBottom),i=Se(n.paddingLeft),o=((s=n.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:t!=null||(t=Se(o[0])),e!=null||(e=Se(o[0])),r!=null||(r=Se(o[0])),i!=null||(i=Se(o[0]));break;case 2:t!=null||(t=Se(o[0])),e!=null||(e=Se(o[1])),r!=null||(r=Se(o[0])),i!=null||(i=Se(o[1]));break;case 3:t!=null||(t=Se(o[0])),e!=null||(e=Se(o[1])),r!=null||(r=Se(o[2])),i!=null||(i=Se(o[1]));break;case 4:default:t!=null||(t=Se(o[0])),e!=null||(e=Se(o[1])),r!=null||(r=Se(o[2])),i!=null||(i=Se(o[3]));break}return t!=null||(t=0),e!=null||(e=0),r!=null||(r=0),i!=null||(i=0),{top:t,right:e,bottom:r,left:i}}function Qf(n){let t=Se(n==null?void 0:n.left),e=Se(n==null?void 0:n.right),r=Se(n==null?void 0:n.top),i=Se(n==null?void 0:n.bottom),o=Se(n==null?void 0:n.width),s=Se(n==null?void 0:n.height);return o===void 0&&t!==void 0&&e!==void 0&&(o=e-t),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:t,top:r,width:o,height:s}}function Kf(n,t){return!n&&!t?!1:!n||!t?!0:n.left!==t.left||n.top!==t.top||n.right!==t.right||n.bottom!==t.bottom||n.width!==t.width||n.height!==t.height}var Pn;function Jf(n,t){Pn!=null||(Pn=document.createElement("canvas"));let e=Pn.getContext("2d");return e?(e.font=t,e.measureText(n).width):0}var al={};gr(al,{isArray:()=>ei,isArrayOrUndefined:()=>ig,isBoolean:()=>mg,isBooleanOrUndefined:()=>fg,isEmptyArray:()=>ng,isEmptyArrayOrUndefined:()=>sg,isEmptyString:()=>ug,isEmptyStringOrUndefined:()=>dg,isEnumValue:()=>yg,isEnumValueOrUndefined:()=>xg,isFinite:()=>Ac,isFunction:()=>gg,isFunctionOrUndefined:()=>bg,isInfinity:()=>Rg,isInteger:()=>ti,isIntegerBetween:()=>Tg,isIntegerEq:()=>vg,isIntegerGt:()=>Ig,isIntegerGte:()=>Sg,isIntegerLt:()=>wg,isIntegerLte:()=>Ng,isIntegerOrUndefined:()=>_g,isNaNValue:()=>Og,isNegInfinity:()=>Dg,isNonEmptyArray:()=>og,isNonEmptyArrayOrUndefined:()=>ag,isNonEmptyString:()=>lg,isNonEmptyStringOrUndefined:()=>pg,isNull:()=>eg,isNullish:()=>tg,isNumber:()=>Cg,isNumberOrUndefined:()=>Ag,isObject:()=>cl,isObjectOrUndefined:()=>rg,isPosInfinity:()=>Mg,isString:()=>cg,isStringOrUndefined:()=>hg,isUndefined:()=>$f});function $f(n){return n===void 0}function eg(n){return n===null}function tg(n){return n==null}function cl(n){return typeof n=="object"&&n!==null&&!ei(n)}function rg(n){return n===void 0||cl(n)}function ei(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function ig(n){return n===void 0||ei(n)}function ng(n){return ei(n)&&n.length===0}function og(n){return ei(n)&&n.length>0}function sg(n){return ei(n)&&n.length===0||n===void 0}function ag(n){return ei(n)&&n.length>0||n===void 0}function cg(n){return typeof n=="string"}function ug(n){return typeof n=="string"&&n.length===0}function lg(n){return typeof n=="string"&&n.length>0}function hg(n){return n===void 0||typeof n=="string"}function dg(n){return typeof n=="string"&&n.length===0||n===void 0}function pg(n){return typeof n=="string"&&n.length>0||n===void 0}function mg(n){return typeof n=="boolean"}function fg(n){return n===void 0||typeof n=="boolean"}function gg(n){return typeof n=="function"}function bg(n){return n===void 0||typeof n=="function"}function yg(n,t,e="value"){return as(t).some(r=>r===n)}function xg(n,t,e="value"){return n===void 0||as(t).some(r=>r===n)}function Cg(n){return typeof n=="number"}function Ag(n){return typeof n=="number"||n===void 0}function Ac(n){return typeof n=="number"&&Number.isFinite(n)}function ti(n){return typeof n=="number"&&Ac(n)&&n===Math.trunc(n)}function _g(n){return typeof n=="number"&&Ac(n)&&n===Math.trunc(n)||n===void 0}function vg(n,t){return ti(n)&&n===t}function Ig(n,t){return ti(n)&&n>t}function Sg(n,t){return ti(n)&&n>=t}function wg(n,t){return ti(n)&&n<t}function Ng(n,t){return ti(n)&&n<=t}function Tg(n,t,e){return ti(n)&&n>=t&&n<=e}function Og(n){return typeof n=="number"&&Number.isNaN(n)}function Rg(n){return typeof n=="number"&&Math.abs(n)===1/0}function Mg(n){return typeof n=="number"&&n===1/0}function Dg(n){return typeof n=="number"&&n===-1/0}var ul={};gr(ul,{getMapKeys:()=>Eg});function Eg(n){let t=[];return n.forEach((e,r)=>t.push(r)),t}var ll={};gr(ll,{deepEqual:()=>yc,hasProperties:()=>kg,isObject:()=>hl});function hl(n){return typeof n=="object"&&n!==null&&!xc(n)}function kg(n,t){return hl(n)&&t.every(e=>e in n)}function yc(n,t){if(n===t)return!0;if(n===null||t===null||typeof n!="object"||typeof t!="object")return!1;if(Array.isArray(n)&&Array.isArray(t))return n.length!==t.length?!1:n.every((i,o)=>yc(i,t[o]));if(Array.isArray(n)!==Array.isArray(t))return!1;let e=Object.keys(n),r=Object.keys(t);if(e.length!==r.length)return!1;for(let i of e)if(!Object.prototype.hasOwnProperty.call(t,i)||!yc(n[i],t[i]))return!1;return!0}var dl={};gr(dl,{charCount:()=>Gg,chunkString:()=>Pg,insertAt:()=>Fg,makeSentenceFromPascal:()=>Vg,removeAt:()=>Bg,repeatString:()=>jg,replaceAt:()=>_c,toCharArray:()=>Lg});function Lg(n){return n.split("")}function jg(n,t){if(!Nt(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(n)}function Pg(n,t){if(!Nt(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}function _c(n,t,e,r){if(!Nt(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!Nt(t)||t<0||t+e>n.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+n.length);return n.substring(0,t)+r+n.substring(t+e)}function Fg(n,t,e){return _c(n,t,0,e)}function Bg(n,t,e){return _c(n,t,e,"")}function Gg(n,t){if(t.length!==1||n.length===0)return 0;let e=0;for(let r=0;r<n.length;r++)n[r]===t&&e++;return e}function Vg(n){if(n==="")return"";let t=n.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},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(),t+=s.toLowerCase()}return r(),e}var Ju;(n=>{let t="ConsentCookie",e;(w=>{w.Accept="accept",w.Decline="decline"})(e||(e={}));let r,i,o=d(t);r=o==="accept"||o==="decline"?o:void 0;function s(w){i=new Date,i.setDate(i.getDate()+w)}n.setExpireDays=s;function a(){return r===void 0}n.isConsentPending=a;function c(){r="accept",h(t,r)}n.accept=c;function u(){r="decline",h(t,r)}n.decline=u;function l(){return document.cookie.split(";").map(v=>v.trim())}function h(w,v){let _=w+"="+v.toString()+";sameSite=Lax;";return i&&(_+="expires="+i.toUTCString()+";"),document.cookie=_,v}function d(w,v){let _=l().find(A=>A.startsWith(w+"="));return _===void 0?v:_.substring(w.length+1)}function m(w){document.cookie=w+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(w,v){return r==="accept"&&h(w,v),v}n.save=f;function g(w,v){return r==="accept"&&d(w,v)||v}n.read=g;function y(w,v){if(r==="accept"){let _=d(w);return _===void 0?v:parseInt(_)}else return v}n.readInt=y;function C(w,v){if(r==="accept"){let _=d(w);return _===void 0?v:/true|1/i.test(_)}else return v}n.readBool=C;function I(w){(r==="accept"||w===t)&&m(w)}n.erase=I;function S(){document.cookie.split(";").forEach(w=>I(w.trim().split("=")[0]))}n.eraseAll=S})(Ju||(Ju={}));var pl=class Fn{constructor(t,e){Ft(this,"x"),Ft(this,"y"),this.x=t!=null?t:0,this.y=e!=null?e:0}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}add(t){return new Fn(this.x+t.x,this.y+t.y)}sub(t){return new Fn(this.x-t.x,this.y-t.y)}mul(t){return new Fn(this.x*t,this.y*t)}div(t){return new Fn(this.x/t,this.y/t)}},ml=class{constructor(n,t=1/0){Ft(this,"cache"),Ft(this,"next"),Ft(this,"prev"),Ft(this,"head"),Ft(this,"tail"),Ft(this,"capacity"),Ft(this,"size"),Ft(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=t}get(n){if(!(n.length>this.maxKeyLength)&&this.cache[n]!==void 0)return this.touch(n),this.cache[n]}set(n,t){if(!(n.length>this.maxKeyLength)){if(this.cache[n]!==void 0){this.cache[n]=t,this.touch(n);return}this.size>=this.capacity&&this.evict(),this.cache[n]=t,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 t=this.prev[n],e=this.next[n];t!==void 0?this.next[t]=e:this.head=e!=null?e:null,e!==void 0?this.prev[e]=t:this.tail=t!=null?t:null,delete this.prev[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 cs=class{constructor(){Ft(this,"map1",new Map)}set(n,t,e,r){let i=this.map1.get(n);i||this.map1.set(n,i=new Map);let o=i.get(t);return o||i.set(t,o=new Map),o.set(e,r),r}get(n,t,e){var r,i;return(i=(r=this.map1.get(n))==null?void 0:r.get(t))==null?void 0:i.get(e)}has(n,t,e){var r,i,o;return(o=(i=(r=this.map1.get(n))==null?void 0:r.get(t))==null?void 0:i.has(e))!=null?o:!1}delete(n,t,e){var r;if(e===void 0){if(t===void 0)return this.map1.delete(n);let i=this.map1.get(n);return i?i.delete(t):!1}else{if(t===void 0)return this.map1.delete(n);let i=(r=this.map1.get(n))==null?void 0:r.get(t);return i?i.delete(e):!1}}clear(){this.map1.clear()}get size(){let n=0;for(let t of this.map1.values())for(let e of t.values())n+=e.size;return n}forEach(n,t){this.map1.forEach((e,r)=>e.forEach((i,o)=>i.forEach((s,a)=>n.call(t,s,r,o,a,this))))}keys(){function*n(t){for(let[e,r]of t)for(let[i,o]of r)for(let s of o.keys())yield[e,i,s]}return n(this.map1)}values(){function*n(t){for(let e of t.values())for(let r of e.values())for(let i of r.values())yield i}return n(this.map1)}*entries(){for(let[n,t]of this.map1)for(let[e,r]of t)for(let[i,o]of r)yield[n,e,i,o]}*[Symbol.iterator](){yield*gc(this.entries())}};var vc={};Mi(vc,{MusicError:()=>O,MusicErrorType:()=>de,init:()=>ri});var de=(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))(de||{});function qg(n){return n===void 0?"":`[${de[n]}] `}var O=class extends Error{constructor(...e){let[r,i]=e.length===1?[0,e[0]]:e;super(qg(r)+i);p(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var fl=!1;function ri(){fl||(fl=!0,console.log("%cWebMusicScore v5.3.0 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Er=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(Er||{}),kr=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(kr||{}),Wg=b.Enum.getEnumValues(kr),Ug=0;function gl(n){if(b.Is.isEnumValue(n,kr))return n;throw new O(1,`Invalid pitchNotation: ${n}`)}function zg(n){return kr[gl(n)]}var us=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(us||{}),Yg="Default",Hg=b.Enum.getEnumValues(us);function Zg(n){if(b.Is.isEnumValue(n,us))return n;throw new O(5,`Invalid guitarNoteLabel: ${n}`)}function bl(n,t){return(n%t+t)%t}var yl=12,xl=7,Xg=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),Qg=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Cl=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),Gn=["C","D","E","F","G","A","B"],Al=[0,2,4,5,7,9,11],_l=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,ce=class ce{constructor(t,e,r){p(this,"diatonicClass");p(this,"accidental");p(this,"octave");if(typeof t=="number"&&typeof e=="number"&&r===void 0)ce.validateDiatonicId(t),this.diatonicClass=ce.getDiatonicClass(t),this.accidental=ce.validateAccidental(e),this.octave=ce.getOctaveFromDiatonicId(t);else if(typeof t=="number"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=ce.validateDiatonicClass(t),this.accidental=ce.validateAccidental(e),this.octave=ce.validateOctave(r);else if(typeof t=="string"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=ce.getDiatonicClass(t),this.accidental=ce.validateAccidental(e),this.octave=ce.validateOctave(r);else throw new O(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return ce.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return ce.getChromaticIdInOctave(Al[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return ce.getChromaticClass(Al[this.diatonicClass]+this.accidental)}get noteLetter(){return Gn[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:i}=this,o=ce.getAccidentalSymbol(this.accidental,e);return t===1?i>=3?r.toLowerCase()+o+"\u2032".repeat(i-3):r.toUpperCase()+o+"\u0375".repeat(2-i):r+o+i}formatOmitOctave(t){let e=Gn[this.diatonicClass],r=ce.getAccidentalSymbol(this.accidental,t);return e+r}static getNote(t){let e=this.noteByNameCache.get(t);if(e===void 0){let r=ce.parseNote(t);if(!r)throw new O(2,`Invalid noteName: ${t}`);if(r.octave===void 0)throw new O(2,"Octave is required for note.");e=new ce(r.noteLetter,r.accidental,r.octave),this.noteByNameCache.set(t,e)}return e}static getChromaticNote(t){let e=this.chromaticNoteCache.get(t);if(e===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"][ce.getChromaticClass(t)].split("/")[0]+ce.getOctaveFromChromaticId(t),o=ce.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.");e=new ce(o.noteLetter,o.accidental,o.octave),this.chromaticNoteCache.set(t,e)}return e}static getDiatonicClass(t){if(typeof t=="number")return bl(t,7);if(typeof t=="string"&&t.length>0)return Gn.indexOf(ce.validateNoteLetter(t[0]));throw new O(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-xl)/7)}static getDiatonicIdInOctave(t,e){return ce.getDiatonicClass(t)+e*7+xl}static getChromaticClass(t){return bl(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-yl)/12)}static getChromaticIdInOctave(t,e){return ce.getChromaticClass(t)+e*12+yl}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.diatonicId===e.diatonicId&&t.accidental===e.accidental}static replaceAccidentalSymbols(t,e){return e===1?t.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):t.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(t){return _l.test(t)}static parseNote(t){var c;let e=_l.exec(t);if(!e)return;let r=ce.validateNoteLetter(e[1]),i=e[2],o=ce.validateAccidental((c=Cl.get(i))!=null?c:0),s=e[3],a=s?ce.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(t,e){let r=ce.parseNote(t);if(!r)throw new O(2,`Invalid noteName: ${t}`);let{noteLetter:i,accidental:o,octave:s}=r;return i+ce.getAccidentalSymbol(o,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?Qg.get(t):Xg.get(t)}static getAccidental(t){let e=Cl.get(t);if(e===void 0)throw new O(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return Gn[ce.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let i=ce.getDiatonicClass(t),o=ce.getDiatonicClass(e),s=r?i<=o?1:0:i<o?1:0;return ce.getDiatonicIdInOctave(i,ce.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(b.Is.isInteger(t))return t;throw new O(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(b.Is.isIntegerBetween(t,0,6))return t;throw new O(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(b.Is.isInteger(t))return t;throw new O(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(b.Is.isIntegerBetween(t,0,11))return t;throw new O(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(Gn.some(e=>e===t))return t;throw new O(2,`Invalid note: ${t}`)}static validateOctave(t){if(b.Is.isInteger(t))return t;throw new O(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(b.Is.isIntegerBetween(t,-2,2))return t;throw new O(2,`Invalid accidental: ${t}`)}static sort(t){return t.slice().sort(ce.compareFunc)}static removeDuplicates(t){let e=[];return t.forEach(r=>{e.find(i=>ce.equals(r,i))===void 0&&e.push(r)}),e}static compareFunc(t,e){return t.diatonicId<e.diatonicId?-1:t.diatonicId>e.diatonicId?1:t.accidental<e.accidental?-1:t.accidental>e.accidental?1:0}};p(ce,"noteByNameCache",new Map),p(ce,"chromaticNoteCache",new Map);var U=ce;function Kg(n,t){let e=U.getChromaticClass(n)-new U(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return U.validateAccidental(e)}var Jg=/^(bb?|b?|#?|x?)([0-9]*)$/;function $g(n){var i,o;let t=Jg.exec(""+n);if(!t)throw new O(4,`Invalid degree: ${n}`);let e=(o=U.getAccidental((i=t[1])!=null?i:""))!=null?o:0,r=+t[2];if(!b.Is.isInteger(e)||e<-2||e>2||!b.Is.isInteger(r)||r<1)throw new O(4,`Invalid degree: ${n}`);return{deg:r,acc:e}}var Ic=(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))(Ic||{}),Sc=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(Sc||{});function ls(){return br("C","Major")}var Lr=class Lr{constructor(t,e){this.tonic=t;this.mode=e;p(this,"naturalScaleNotes");p(this,"accidentalByDiatonicClass");p(this,"orderedAccidentedNotes");if(!b.Is.isEnumValue(e,Ic))throw new O(4,`Invalid mode: ${e}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<e;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let i=U.getDiatonicClass(t[0]),o=U.getNote(t+"0").chromaticId;for(let c=0;c<7;i++,o+=r[c],c++){let u=new U(U.getDiatonicClass(i),Kg(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=Lr.OrderOfSharps.indexOf(c.noteLetter),h=Lr.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=Lr.OrderOfFlats.indexOf(c.noteLetter),h=Lr.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(t){var e;return(e=this.accidentalByDiatonicClass[U.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=$g(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let i=this.naturalScaleNotes[(e-1)%7];return new U(i.diatonicId,i.accidental+r)}}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.tonic===e.tonic&&t.mode===e.mode}};p(Lr,"OrderOfSharps","FCGDAEB"),p(Lr,"OrderOfFlats","BEADGCF");var Bt=Lr;var eb=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),tb={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 rb(n,t){for(;n<1;)n+=7,t+=12;for(;n>8;)n-=7,t-=12;let e=tb[n];if(e)return e[t]}function ib(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 nb(n){if(b.Is.isIntegerGte(n,1))return b.Math.toOrdinalNumber(n);throw new O(1,`Invalid interval quantity: ${n}`)}var hs=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},Vn=class n{constructor(t,e){this.note1=t;this.note2=e;p(this,"direction");p(this,"semitones");p(this,"quantity");p(this,"quality");e.diatonicId>=t.diatonicId?(this.direction=e.diatonicId===t.diatonicId?"Unison":"Ascending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId):(this.direction="Descending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId);let r=rb(this.quantity,this.semitones);if(r)this.quality=r;else throw new hs("Unknown interval quality")}static get(t,e){try{return new n(t,e)}catch(r){if(r instanceof hs)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":nb(this.quantity);return t+e+r}toAbbrString(){var i;let t=this.direction==="Descending"?"\u2193":"",e=(i=eb.get(this.quality))!=null?i:"?",r=this.quantity;return t+e+r}};function ob(n){let t=U.getDiatonicClass("CCDDEFFGGAAB"[U.getChromaticClass(n)]),e=U.getOctaveFromChromaticId(n);return U.getDiatonicIdInOctave(t,e)}var sb=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],ii=(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))(ii||{});function ab(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 jr=class extends Bt{constructor(e,r){super(e,ab(r));this.tonic=e;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(e,r){return e==null&&r==null?!0:e==null||r==null?!1:e===r||e.getScaleName()===r.getScaleName()}getScaleName(e){switch(e){case 1:return U.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!b.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(e).diatonicId;return i.map(s=>(o=U.findNextDiatonicIdAbove(s.diatonicId,o,!1),new U(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(e=>e.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let e=this.getScaleNotes("C4",1).map(i=>i.chromaticId),r=[];for(let i=0;i<e.length-1;i++)r.push(b.Math.mod(e[i+1]-e[i],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(e=>e===1?"H":e===2?"W":e.toString()+"H")}isScaleNote(e){return this.chromaticClassDegree[e.chromaticClass]!==void 0}isScaleRootNote(e){return String(this.chromaticClassDegree[e.chromaticClass])==="1"}getIntervalFromRootNote(e){let r=this.getScaleNotes("C0",1)[0];for(;e.chromaticId>=r.chromaticId+12;)e=new U(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new O(3,"Note is below rootNote.");let i=Vn.get(r,e);if(i===void 0)throw new O(3,"Interval is undefined.");return i}getPreferredChromaticNote(e){U.validateChromaticId(e);let r=this.preferredChromaticNoteCache.get(e);if(r)return r;let i=U.getOctaveFromChromaticId(e);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(e)===h.chromaticClass),r)return this.preferredChromaticNoteCache.set(e,r),r;let s=ob(e),a=s-2,c=s+2,l=this.getAccidentalType()===1?[0,-1,1,-2,2]:[0,1,-1,2,-2];for(let h=0;h<l.length;h++){let d=l[h];for(let m=Math.max(0,a);m<=c;m++)if(r=new U(m,d),e===r.chromaticId)return this.preferredChromaticNoteCache.set(e,r),r}return r=U.getChromaticNote(e),this.preferredChromaticNoteCache.set(e,r),r}},Ze=class{constructor(t){this.type=t;p(this,"tonicList",[]);p(this,"scaleMap",new Map);let e=[],r=[],i=[];if(sb.forEach(s=>{try{let a=new jr(s,this.type);switch(a.getAccidentalType()){case 0:e.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;i.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),e.length===0)throw new O(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...i.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(t){let e=this.scaleMap.get(t);if(e)return e;throw new O(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},vl=[new Ze("Major"),new Ze("Natural Minor"),new Ze("Harmonic Minor"),"- Modes -",new Ze("Ionian"),new Ze("Dorian"),new Ze("Phrygian"),new Ze("Lydian"),new Ze("Mixolydian"),new Ze("Aeolian"),new Ze("Locrian"),"- Pentatonic -",new Ze("Major Pentatonic"),new Ze("Minor Pentatonic"),"- Blues -",new Ze("Major Hexatonic Blues"),new Ze("Minor Hexatonic Blues"),new Ze("Heptatonic Blues")];function cb(){return vl}var Il=new Map;vl.forEach(n=>{n instanceof Ze&&Il.set(n.getType(),n)});function Sl(n){let t=Il.get(n);if(t)return t;throw new O(3,`Invalid scaleType: ${n}`)}function qn(n){if(b.Is.isEnumValue(n,ii))return n;throw new O(3,`Invalid scaleType: "${n}"`)}function br(n,t){let e,r;return t!==void 0?(e=n,r=qn(t)):(e=n.split(" ")[0],r=qn(n.substring(e.length+1))),Sl(r).getScale(e)}var ub=br("C","Major");function lb(){return ub}var yr=(n,t)=>n.chromaticClass===t.chromaticClass,hb=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(n=>U.getNote(n+"0")),wl=new Map;function db(n){let t=n.chromaticClass,e=wl.get(t);if(!e){if(e=hb.find(r=>yr(r,n)),!e)throw new O(1,`Invalid chord root note: ${n.formatOmitOctave(1)}`);wl.set(t,e)}return e}function pb(n,t){let e=n.formatOmitOctave(0);return br(e,"Major").getNoteByDegree(t)}function mb(n){return b.Arr.removeDuplicatesCmp(n,yr)}var fb=[{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 gb(n,t){return n.degrees.every(e=>e!==t)?!0:n.degrees.length>=4&&t===5||n.degrees.length>=6&&t===9||n.degrees.length>=7&&t===11}var Di=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},wc=class n{constructor(t,e,r,i){this.chordInfo=t;this.rootNote=r;p(this,"name");p(this,"notes");p(this,"omitNotes");p(this,"slashBassNote");this.name=t.name;let o=e.slice();!o.some(a=>yr(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<t.degrees.length;a++){let c=t.degrees[a],u=this.notes[a]=pb(this.rootNote,c),l=o.findIndex(h=>yr(h,u));if(l>=0)this.omitNotes[a]=!1,o.splice(l,1);else if(gb(t,c))this.omitNotes[a]=!0;else throw new Di("Missing chord note!");yr(i,u)&&(i=u)}if(o.length>0)if(o.every(a=>yr(a,i)))this.slashBassNote=i;else throw new Di("Got some extra notes that are not bass note!");else this.slashBassNote=yr(i,this.rootNote)?void 0:i;if(t.name==="5"&&this.slashBassNote)throw new Di("Power chord no bass note allowed!")}static getChords(t){let e=[],r=U.sort(t),i=r[0],o=mb(r);for(let s=0;s<o.length;s++){let a=db(o[s]);fb.forEach(c=>{try{let u=new n(c,o,a,i),l=e.findIndex(h=>h.replaceWith(u));l>=0?e[l]=u:e.push(u)}catch(u){if(!(u instanceof Di))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!yr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!yr(t.notes[e],this.notes[e])||t.omitNotes[e]!==this.omitNotes[e])return!1;return!0}toString(){let t=1,e=this.rootNote.formatOmitOctave(t),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(t):"";return e+this.name+r}getDegreeNotationString(){let t=1,e=this.slashBassNote?this.slashBassNote.formatOmitOctave(t)+" - ":"",r=this.omitNotes.map((i,o)=>this.getDegreeStr(o)+"("+(i?"-":this.getNoteStr(o))+")").join(" - ");return e+r}getOmittedDegreesString(){let t=this.omitNotes.map((e,r)=>e?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(e=>e!==void 0);return t.length>0?"Omits "+t.join(", "):""}getDegreeStr(t){return U.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var Nc={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 Tc=(e=>(e[e.RightHanded=0]="RightHanded",e[e.LeftHanded=1]="LeftHanded",e))(Tc||{}),yb=0;function xb(n){if(b.Is.isEnumValue(n,Tc))return n;throw new O(1,`Invalid handedness: ${n}`)}var Wn=Nc.list.map(n=>n.name),Cb=Wn[0];function Oc(n){if(Wn.indexOf(n)<0)throw new O(1,`Invalid tuning name: ${n}`);return n}var Nl=new ml(100);function ds(n){let t=Nl.get(n);if(!t){let e=Nc.list.find(r=>r.name===n);if(!e)throw new O(1,`Invalid tuningName: ${n}`);if(t=e.strings.slice().reverse().map(r=>U.getNote(r)),!b.Is.isIntegerEq(t.length,6))throw new O(0,`Tuning has ${t.length} strings.`);Nl.set(n,t)}return t}var Tl=12,Ab=1188*7*5,Xe=(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))(Xe||{});function Gt(n){if(b.Is.isEnumValue(n,Xe))return n;throw new O(1,`Invalid noteLength: ${n}`)}var it=class it{constructor(t){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=Gt(t),this.noteSize=parseInt(t),this.isTriplet=t.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(it.ShortestNoteSize/this.noteSize)),this.dotCount=b.Str.charCount(t,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=Ab*it.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(t){let e=this.cache.get(t);return e||this.cache.set(t,e=new it(t)),e}static create(t,e=0){let r=typeof t=="number"?t:this.get(t).noteSize;return this.get(r+(b.Is.isIntegerGte(e,1)?".".repeat(e):"n"))}static cmp(t,e){let r=t instanceof it?t.noteSize:typeof t=="number"?t:it.get(t).noteSize,i=e instanceof it?e.noteSize:typeof e=="number"?e:it.get(e).noteSize;return b.Math.cmp(i,r)}static equals(t,e){let r=t instanceof it?t.noteSize:typeof t=="number"?t:it.get(t).noteSize,i=e instanceof it?e.noteSize:typeof e=="number"?e:it.get(e).noteSize;return r===i}};p(it,"LongestNoteSize",Math.min(...b.Enum.getEnumValues(Xe).map(t=>parseInt(t)))),p(it,"ShortestNoteSize",Math.max(...b.Enum.getEnumValues(Xe).map(t=>parseInt(t)))),p(it,"cache",new Map);var _e=it;function ps(n){if(b.Is.isObject(n)&&b.Is.isIntegerBetween(n.parts,2,Tl)&&b.Is.isIntegerBetween(n.inTimeOf,2,Tl))return n;throw new O(2,`Invalid tupletRatio ${JSON.stringify(n)}`)}var xr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},ni=class ni{constructor(t,e,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=Gt(t);let i=_e.get(t);if(this.noteSize=i.noteSize,this.ticks=i.ticks,this.flagCount=i.flagCount,this.dotCount=e!=null?e:i.dotCount,this.hasStem=i.hasStem,this.isSolidNoteHead=i.isSolid,b.Is.isObject(r)?this.tupletRatio=ps(r):i.isTriplet?this.tupletRatio=xr.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 t=ni.NoteSymbolMap.get(this.noteSize),e=".".repeat(this.dotCount);return t?t+e:""+this.noteSize+(e.length>0?e:"n")}static get(t,e,r){if(e!==void 0||r!==void 0)return new ni(t,e,r);{let i=this.cache.get(t);return i||this.cache.set(t,i=new ni(t)),i}}static cmp(t,e){return b.Math.cmp(t.ticks,e.ticks)}static equals(t,e){return t.ticks===e.ticks}};p(ni,"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(ni,"cache",new Map);var qe=ni;var Un=(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))(Un||{}),oi=(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))(oi||{}),Pr=class{constructor(...t){p(this,"beatCount");p(this,"beatSize");p(this,"beatLength");p(this,"measureTicks");p(this,"beamGroupSizes",[]);let e;if(b.Is.isEnumValue(t[0],Un)){let o=t[0].split("/");this.beatCount=+o[0],this.beatSize=+o[1],b.Is.isEnumValue(t[1],oi)&&(e=t[1])}else if(b.Is.isIntegerGte(t[0],2)&&b.Is.isIntegerGte(t[1],2))this.beatCount=t[0],this.beatSize=t[1],b.Is.isEnumValue(t[2],oi)&&(e=t[2]);else throw new O(5,`Invalid args: ${t}`);if(b.Is.isIntegerGte(this.beatCount,1)){if(!b.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}=_e.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(!b.Is.isUndefined(e)&&e!=="2-3"&&e!=="3-2")throw new O(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2"?[[3],[2]]:[[2],[3]],e=void 0}else if(this.is(6,8))this.beamGroupSizes=[[3],[3]];else if(this.is(7,8)){if(!b.Is.isUndefined(e)&&e!=="2-2-3"&&e!=="3-2-2")throw new O(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2-2"?[[3],[2],[2]]:[[2],[2],[3]],e=void 0}else this.is(9,8)?this.beamGroupSizes=[[3],[3],[3]]:this.is(12,8)&&(this.beamGroupSizes=[[3],[3],[3],[3]]);if(this.beamGroupSizes.length===0)throw new O(5,`Unimplemented time signature "${this.toString()}".`);if(e!==void 0)throw new O(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},Rc;function ms(){return Rc||(Rc=new Pr(4,4)),Rc}var Mc;function fs(){return Mc||(Mc={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),Mc}function gs(n){return qe.get(n.options.beatLength,n.options.dotCount).toString()+"="+n.beatsPerMinute}function Dc(n,t){return{beatsPerMinute:n.beatsPerMinute*t,options:{beatLength:n.options.beatLength,dotCount:n.options.dotCount}}}ri();function bs(n){return!isFinite(n)||n<=0?-1/0:20*Math.log10(n)}var zn="15.1.22";var kc=(n,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:n});var Lc=(n,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:n});var Ei=(n,t)=>({startTime:t,type:"setValue",value:n});var Yn=(n,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:n});var ys=(n,t,{startTime:e,target:r,timeConstant:i})=>r+(t-r)*Math.exp((e-n)/i);var Cr=n=>n.type==="exponentialRampToValue";var si=n=>n.type==="linearRampToValue";var Vt=n=>Cr(n)||si(n);var ki=n=>n.type==="setValue";var Tt=n=>n.type==="setValueCurve";var Li=(n,t,e,r)=>{let i=n[t];return i===void 0?r:Vt(i)||ki(i)?i.value:Tt(i)?i.values[i.values.length-1]:ys(e,Li(n,t-1,i.startTime,r),i)};var jc=(n,t,e,r,i)=>e===void 0?[r.insertTime,i]:Vt(e)?[e.endTime,e.value]:ki(e)?[e.startTime,e.value]:Tt(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,Li(n,t-1,e.startTime,i)];var Hn=n=>n.type==="cancelAndHold";var Zn=n=>n.type==="cancelScheduledValues";var Ar=n=>Hn(n)||Zn(n)?n.cancelTime:Cr(n)||si(n)?n.endTime:n.startTime;var Pc=(n,t,e,{endTime:r,value:i})=>e===i?i:0<e&&0<i||e<0&&i<0?e*Ku(i/e,(n-t)/(r-t)):0;var Fc=(n,t,e,{endTime:r,value:i})=>e+(n-t)/(r-t)*(i-e);var Ol=(n,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?n[e]:(1-(t-e))*n[e]+(1-(r-t))*n[r]};var Rl=(n,{duration:t,startTime:e,values:r})=>{let i=(n-e)/t*(r.length-1);return Ol(r,i)};var Xn=n=>n.type==="setTarget";var Qn=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=Ar(t);if(Hn(t)||Zn(t)){let r=this._automationEvents.findIndex(o=>Zn(t)&&Tt(o)?o.startTime+o.duration>=e:Ar(o)>=e),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),Hn(t)){let o=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Vt(i)){if(o!==void 0&&Xn(o))throw new Error("The internal list is malformed.");let s=o===void 0?i.insertTime:Tt(o)?o.startTime+o.duration:Ar(o),a=o===void 0?this._defaultValue:Tt(o)?o.values[o.values.length-1]:o.value,c=Cr(i)?Pc(e,s,a,i):Fc(e,s,a,i),u=Cr(i)?kc(c,e,this._currenTime):Lc(c,e,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Xn(o)&&this._automationEvents.push(Ei(this.getValue(e),e)),o!==void 0&&Tt(o)&&o.startTime+o.duration>e){let s=e-o.startTime,a=(o.values.length-1)/o.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,l=o.values.slice(0,c);if(u<1)for(let h=1;h<c;h+=1){let d=u*h%1;l[h]=o.values[h-1]*(1-d)+o.values[h]*d}this._automationEvents[this._automationEvents.length-1]=Yn(l,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>Ar(s)>e),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&Tt(i)&&Ar(i)+i.duration>e)return!1;let o=Cr(t)?kc(t.value,t.endTime,this._currenTime):si(t)?Lc(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(o);else{if(Tt(t)&&e+t.duration>Ar(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>Ar(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),i=r[0];Xn(i)&&r.unshift(Ei(Li(this._automationEvents,e-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=r}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;let e=this._automationEvents.findIndex(s=>Ar(s)>t),r=this._automationEvents[e],i=(e===-1?this._automationEvents.length:e)-1,o=this._automationEvents[i];if(o!==void 0&&Xn(o)&&(r===void 0||!Vt(r)||r.insertTime>t))return ys(t,Li(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(o!==void 0&&ki(o)&&(r===void 0||!Vt(r)))return o.value;if(o!==void 0&&Tt(o)&&(r===void 0||!Vt(r)||o.startTime+o.duration>t))return t<o.startTime+o.duration?Rl(t,o):o.values[o.values.length-1];if(o!==void 0&&Vt(o)&&(r===void 0||!Vt(r)))return o.value;if(r!==void 0&&Cr(r)){let[s,a]=jc(this._automationEvents,i,o,r,this._defaultValue);return Pc(t,s,a,r)}if(r!==void 0&&si(r)){let[s,a]=jc(this._automationEvents,i,o,r,this._defaultValue);return Fc(t,s,a,r)}return this._defaultValue}};var Bc=n=>({cancelTime:n,type:"cancelAndHold"});var Gc=n=>({cancelTime:n,type:"cancelScheduledValues"});var Vc=(n,t)=>({endTime:t,type:"exponentialRampToValue",value:n});var qc=(n,t)=>({endTime:t,type:"linearRampToValue",value:n});var Wc=(n,t,e)=>({startTime:t,target:n,timeConstant:e,type:"setTarget"});var Ml=()=>new DOMException("","AbortError");var Dl=n=>(t,e,[r,i,o],s)=>{n(t[i],[e,r,o],a=>a[0]===e&&a[1]===r,s)};var El=n=>(t,e,r)=>{let i=[];for(let o=0;o<r.numberOfInputs;o+=1)i.push(new Set);n.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var kl=n=>(t,e)=>{n.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var nr=new WeakSet,xs=new WeakMap,ji=new WeakMap,Cs=new WeakMap,Kn=new WeakMap,Pi=new WeakMap,As=new WeakMap,Jn=new WeakMap,$n=new WeakMap,eo=new WeakMap;var Ll={construct(){return Ll}},jl=n=>{try{let t=new Proxy(n,Ll);new t}catch(t){return!1}return!0};var Pl=/^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]*);?/,Uc=(n,t)=>{let e=[],r=n.replace(/^[\s]+/,""),i=r.match(Pl);for(;i!==null;){let o=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,t).toString());e.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(Pl)}return[e.join(";"),r]};var Fl=n=>{if(n!==void 0&&!Array.isArray(n))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Bl=n=>{if(!jl(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.")},Gl=(n,t,e,r,i,o,s,a,c,u,l,h,d)=>{let m=0;return(f,g,y={credentials:"omit"})=>{let C=l.get(f);if(C!==void 0&&C.has(g))return Promise.resolve();let I=u.get(f);if(I!==void 0){let v=I.get(g);if(v!==void 0)return v}let S=o(f),w=S.audioWorklet===void 0?i(g).then(([v,_])=>{let[A,x]=Uc(v,_),T=`${A};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${x}
|
|
3
|
-
})})(window,'_AWGS')`;return e(
|
|
4
|
-
})(${A?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${A?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${A?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${x}',class extends AudioWorkletProcessor{process(){return !1}})`,L=new Blob([k],{type:"application/javascript; charset=utf-8"}),F=URL.createObjectURL(L);return S.audioWorklet.addModule(F,y).then(()=>{if(a(S))return S;let q=s(S);return q.audioWorklet.addModule(F,y).then(()=>q)}).then(q=>{if(c===null)throw new SyntaxError;try{new c(q,`__sac${x}`)}catch(Q){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(F))});return I===void 0?u.set(f,new Map([[g,w]])):I.set(g,w),w.then(()=>{let v=l.get(f);v===void 0?l.set(f,new Set([g])):v.add(g)}).finally(()=>{let v=u.get(f);v!==void 0&&v.delete(g)}),w}};var We=(n,t)=>{let e=n.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var Fr=(n,t)=>{let e=Array.from(n).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");let[r]=e;return n.delete(r),r};var _s=(n,t,e,r)=>{let i=We(n,t),o=Fr(i,s=>s[0]===e&&s[1]===r);return i.size===0&&n.delete(t),o};var or=n=>We(As,n);var qt=n=>{if(nr.has(n))throw new Error("The AudioNode is already stored.");nr.add(n),or(n).forEach(t=>t(!0))};var vs=n=>"port"in n;var sr=n=>{if(!nr.has(n))throw new Error("The AudioNode is not stored.");nr.delete(n),or(n).forEach(t=>t(!1))};var to=(n,t)=>{!vs(n)&&t.every(e=>e.size===0)&&sr(n)};var Vl=(n,t,e,r,i,o,s,a,c,u,l,h,d)=>{let m=new WeakMap;return(f,g,y,C,I)=>{let{activeInputs:S,passiveInputs:w}=o(g),{outputs:v}=o(f),_=a(f),A=x=>{let T=c(g),E=c(f);if(x){let R=_s(w,f,y,C);n(S,f,R,!1),!I&&!h(f)&&e(E,T,y,C),d(g)&&qt(g)}else{let R=r(S,f,y,C);t(w,C,R,!1),!I&&!h(f)&&i(E,T,y,C);let M=s(g);if(M===0)l(g)&&to(g,S);else{let G=m.get(g);G!==void 0&&clearTimeout(G),m.set(g,setTimeout(()=>{l(g)&&to(g,S)},M*1e3))}}};return u(v,[g,y,C],x=>x[0]===g&&x[1]===y&&x[2]===C,!0)?(_.add(A),l(f)?n(S,f,[y,C,A],!0):t(w,C,[f,y,A],!0),!0):!1}};var ql=n=>(t,e,[r,i,o],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[i,e,o]])):n(a,[i,e,o],c=>c[0]===i&&c[1]===e,s)};var Wl=n=>(t,e)=>{let r=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(r).connect(t.destination);let i=()=>{e.removeEventListener("ended",i),e.disconnect(r),r.disconnect()};e.addEventListener("ended",i)};var Ul=n=>(t,e)=>{n(t).add(e)};var _b={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},zl=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},_b),c),h=r(u,l),d=o(u)?t():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,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){let c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}};var fe=(n,t)=>n.context===t;var Yl=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!fe(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 e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Fi=n=>{try{n.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var Ot=()=>new DOMException("","IndexSizeError");var Bi=n=>{n.getChannelData=(t=>e=>{try{return t.call(n,e)}catch(r){throw r.code===12?Ot():r}})(n.getChannelData)};var vb={numberOfChannels:1},Hl=(n,t,e,r,i,o,s,a)=>{let c=null;return class Zl{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:d,sampleRate:m}=D(D({},vb),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&t(o,o)?new r({length:h,numberOfChannels:d,sampleRate:m}):c.createBuffer(d,h,m);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),Bi(f)):t(Fi,()=>Fi(f))||a(f),n.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===Zl.prototype||n.has(l)}}};var Pe=-34028234663852886e22,Ee=-Pe;var ut=n=>nr.has(n);var Ib={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},Xl=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},Ib),l),m=i(h,d),f=s(h),g=f?t():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=e(this,f,m.playbackRate,Ee,Pe)}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"){qt(this);let d=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",d),ut(this)&&sr(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",d)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var Ql=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=e(u),d=fe(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=t(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 Kl=n=>"playbackRate"in n;var Jl=n=>"frequency"in n&&"gain"in n;var $l=n=>"offset"in n;var eh=n=>!("frequency"in n)&&"gain"in n;var th=n=>"detune"in n&&"frequency"in n&&!("gain"in n);var rh=n=>"pan"in n;var Qe=n=>We(xs,n);var Br=n=>We(Cs,n);var Is=(n,t)=>{let{activeInputs:e}=Qe(n);e.forEach(i=>i.forEach(([o])=>{t.includes(n)||Is(o,[...t,n])}));let r=Kl(n)?[n.playbackRate]:vs(n)?Array.from(n.parameters.values()):Jl(n)?[n.Q,n.detune,n.frequency,n.gain]:$l(n)?[n.offset]:eh(n)?[n.gain]:th(n)?[n.detune,n.frequency]:rh(n)?[n.pan]:[];for(let i of r){let o=Br(i);o!==void 0&&o.activeInputs.forEach(([s])=>Is(s,t))}ut(n)&&sr(n)};var Gr=n=>{Is(n.destination,[])};var Ss=n=>n===void 0||typeof n=="number"||typeof n=="string"&&(n==="balanced"||n==="interactive"||n==="playback");var ih=(n,t,e,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"?e():f}if(h===null)throw r();if(!Ss(l.latencyHint))throw new TypeError(`The provided value '${l.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(l.sampleRate!==void 0&&h.sampleRate!==l.sampleRate)throw e();super(h,2);let{latencyHint: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 t()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),Gr(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?t():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?t():l})}};var nh=(n,t,e,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?t(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 e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}};var oh=n=>{let t=new WeakMap,e=(r,i)=>K(null,null,function*(){let o=i.destination;return t.set(i,o),yield n(r,i,o),o});return{render(r,i){let o=t.get(i);return o!==void 0?Promise.resolve(o):e(r,i)}}};var sh=(n,t,e,r,i,o,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let v=new Float32Array(1),_=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),A=s(u),x=!1,T=[0,0,-1,0,1,0],E=[0,0,0],R=()=>{if(x)return;x=!0;let L=r(u,256,9,0);L.onaudioprocess=({inputBuffer:F})=>{let q=[o(F,v,0),o(F,v,1),o(F,v,2),o(F,v,3),o(F,v,4),o(F,v,5)];q.some((Y,V)=>Y!==T[V])&&(l.setOrientation(...q),T=q);let Q=[o(F,v,6),o(F,v,7),o(F,v,8)];Q.some((Y,V)=>Y!==E[V])&&(l.setPosition(...Q),E=Q)},_.connect(L)},M=L=>F=>{F!==T[L]&&(T[L]=F,l.setOrientation(...T))},G=L=>F=>{F!==E[L]&&(E[L]=F,l.setPosition(...E))},k=(L,F,q)=>{let Q=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:F});Q.connect(_,0,L),Q.start(),Object.defineProperty(Q.offset,"defaultValue",{get(){return F}});let Y=n({context:c},A,Q.offset,Ee,Pe);return a(Y,"value",V=>()=>V.call(Y),V=>ue=>{try{V.call(Y,ue)}catch(me){if(me.code!==9)throw me}R(),A&&q(ue)}),Y.cancelAndHoldAtTime=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.cancelAndHoldAtTime),Y.cancelScheduledValues=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.cancelScheduledValues),Y.exponentialRampToValueAtTime=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.exponentialRampToValueAtTime),Y.linearRampToValueAtTime=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.linearRampToValueAtTime),Y.setTargetAtTime=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.setTargetAtTime),Y.setValueAtTime=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.setValueAtTime),Y.setValueCurveAtTime=(V=>A?()=>{throw i()}:(...ue)=>{let me=V.apply(Y,ue);return R(),me})(Y.setValueCurveAtTime),Y};return{forwardX:k(0,0,M(0)),forwardY:k(1,0,M(1)),forwardZ:k(2,-1,M(2)),positionX:k(6,0,G(0)),positionY:k(7,0,G(1)),positionZ:k(8,0,G(2)),upX:k(3,0,M(3)),upY:k(4,1,M(4)),upZ:k(5,0,M(5))}},{forwardX:d,forwardY:m,forwardZ:f,positionX:g,positionY:y,positionZ:C,upX:I,upY:S,upZ:w}=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 y},get positionZ(){return C},get upX(){return I},get upY(){return S},get upZ(){return w}}};var ai=n=>"context"in n;var Vr=n=>ai(n[0]);var Wt=(n,t,e,r)=>{for(let i of n)if(e(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return n.add(t),!0};var zc=(n,t,[e,r],i)=>{Wt(n,[t,e,r],o=>o[0]===t&&o[1]===e,i)};var Yc=(n,[t,e,r],i)=>{let o=n.get(t);o===void 0?n.set(t,new Set([[e,r]])):Wt(o,[e,r],s=>s[0]===e,i)};var Rt=n=>"inputs"in n;var Gi=(n,t,e,r)=>{if(Rt(t)){let i=t.inputs[r];return n.connect(i,e,0),[i,e,0]}return n.connect(t,e,r),[t,e,r]};var Hc=(n,t,e)=>{for(let r of n)if(r[0]===t&&r[1]===e)return n.delete(r),r;return null};var ah=(n,t,e)=>Fr(n,r=>r[0]===t&&r[1]===e);var Zc=(n,t)=>{if(!or(n).delete(t))throw new Error("Missing the expected event listener.")};var Xc=(n,t,e)=>{let r=We(n,t),i=Fr(r,o=>o[0]===e);return r.size===0&&n.delete(t),i};var Vi=(n,t,e,r)=>{Rt(t)?n.disconnect(t.inputs[r],e,0):n.disconnect(t,e,r)};var ve=n=>We(ji,n);var ci=n=>We(Kn,n);var _r=n=>Jn.has(n);var qi=n=>!nr.has(n);var Qc=(n,t)=>new Promise(e=>{if(t!==null)e(!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)?e(!0):e(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(n.destination)},a.start()}});var ws=(n,t)=>{let e=new Map;for(let r of n)for(let i of r){let o=e.get(i);e.set(i,o===void 0?1:o+1)}e.forEach((r,i)=>t(i,r))};var ui=n=>"context"in n;var ch=n=>{let t=new Map;n.connect=(e=>(r,i=0,o=0)=>{let s=ui(r)?e(r,i,o):e(r,i),a=t.get(r);return a===void 0?t.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=(e=>(r,i,o)=>{if(e.apply(n),r===void 0)t.clear();else if(typeof r=="number")for(let[s,a]of t){let c=a.filter(u=>u.output!==r);c.length===0?t.delete(s):t.set(s,c)}else if(t.has(r))if(i===void 0)t.delete(r);else{let s=t.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==i&&(c.input!==o||o===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{ui(s)?n.connect(s,c.output,c.input):n.connect(s,c.output)})})(n.disconnect)};var Sb=(n,t,e,r)=>{let{activeInputs:i,passiveInputs:o}=Br(t),{outputs:s}=Qe(n),a=or(n),c=u=>{let l=ve(n),h=ci(t);if(u){let d=Xc(o,n,e);zc(i,n,d,!1),!r&&!_r(n)&&l.connect(h,e)}else{let d=ah(i,n,e);Yc(o,d,!1),!r&&!_r(n)&&l.disconnect(h,e)}};return Wt(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),ut(n)?zc(i,n,[e,c],!0):Yc(o,[n,e,c],!0),!0):!1},wb=(n,t,e,r)=>{let{activeInputs:i,passiveInputs:o}=Qe(t),s=Hc(i[r],n,e);return s===null?[_s(o,n,e,r)[2],!1]:[s[2],!0]},Nb=(n,t,e)=>{let{activeInputs:r,passiveInputs:i}=Br(t),o=Hc(r,n,e);return o===null?[Xc(i,n,e)[1],!1]:[o[2],!0]},Kc=(n,t,e,r,i)=>{let[o,s]=wb(n,e,r,i);if(o!==null&&(Zc(n,o),s&&!t&&!_r(n)&&Vi(ve(n),ve(e),r,i)),ut(e)){let{activeInputs:a}=Qe(e);to(e,a)}},Jc=(n,t,e,r)=>{let[i,o]=Nb(n,e,r);i!==null&&(Zc(n,i),o&&!t&&!_r(n)&&ve(n).disconnect(ci(e),r))},Tb=(n,t)=>{let e=Qe(n),r=[];for(let i of e.outputs)Vr(i)?Kc(n,t,...i):Jc(n,t,...i),r.push(i[0]);return e.outputs.clear(),r},Ob=(n,t,e)=>{let r=Qe(n),i=[];for(let o of r.outputs)o[1]===e&&(Vr(o)?Kc(n,t,...o):Jc(n,t,...o),i.push(o[0]),r.outputs.delete(o));return i},Rb=(n,t,e,r,i)=>{let o=Qe(n);return Array.from(o.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Vr(s)?Kc(n,t,...s):Jc(n,t,...s),o.outputs.delete(s),s[0]))},uh=(n,t,e,r,i,o,s,a,c,u,l,h,d,m,f,g)=>class extends u{constructor(C,I,S,w){super(S),this._context=C,this._nativeAudioNode=S;let v=l(C);h(v)&&e(Qc,()=>Qc(v,g))!==!0&&ch(S),ji.set(this,S),As.set(this,new Set),C.state!=="closed"&&I&&qt(this),n(this,w,S)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(C){this._nativeAudioNode.channelCount=C}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(C){this._nativeAudioNode.channelCountMode=C}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(C){this._nativeAudioNode.channelInterpretation=C}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(C,I=0,S=0){if(I<0||I>=this._nativeAudioNode.numberOfOutputs)throw i();let w=l(this._context),v=f(w);if(d(C)||m(C))throw o();if(ai(C)){let x=ve(C);try{let E=Gi(this._nativeAudioNode,x,I,S),R=qi(this);(v||R)&&this._nativeAudioNode.disconnect(...E),this.context.state!=="closed"&&!R&&qi(C)&&qt(C)}catch(E){throw E.code===12?o():E}if(t(this,C,I,S,v)){let E=c([this],C);ws(E,r(v))}return C}let _=ci(C);if(_.name==="playbackRate"&&_.maxValue===1024)throw s();try{this._nativeAudioNode.connect(_,I),(v||qi(this))&&this._nativeAudioNode.disconnect(_,I)}catch(x){throw x.code===12?o():x}if(Sb(this,C,I,v)){let x=c([this],C);ws(x,r(v))}}disconnect(C,I,S){let w,v=l(this._context),_=f(v);if(C===void 0)w=Tb(this,_);else if(typeof C=="number"){if(C<0||C>=this.numberOfOutputs)throw i();w=Ob(this,_,C)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||ai(C)&&S!==void 0&&(S<0||S>=C.numberOfInputs))throw i();if(w=Rb(this,_,C,I,S),w.length===0)throw o()}for(let A of w){let x=c([this],A);ws(x,a)}}};var lh=(n,t,e,r,i,o,s,a,c,u,l,h,d)=>(m,f,g,y=null,C=null)=>{let I=g.value,S=new Qn(I),w=f?r(S):null,v={get defaultValue(){return I},get maxValue(){return y===null?g.maxValue:y},get minValue(){return C===null?g.minValue:C},get value(){return g.value},set value(_){g.value=_,v.setValueAtTime(_,m.context.currentTime)},cancelAndHoldAtTime(_){if(typeof g.cancelAndHoldAtTime=="function")w===null&&S.flush(m.context.currentTime),S.add(i(_)),g.cancelAndHoldAtTime(_);else{let A=Array.from(S).pop();w===null&&S.flush(m.context.currentTime),S.add(i(_));let x=Array.from(S).pop();g.cancelScheduledValues(_),A!==x&&x!==void 0&&(x.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(x.value,x.endTime):x.type==="linearRampToValue"?g.linearRampToValueAtTime(x.value,x.endTime):x.type==="setValue"?g.setValueAtTime(x.value,x.startTime):x.type==="setValueCurve"&&g.setValueCurveAtTime(x.values,x.startTime,x.duration))}return v},cancelScheduledValues(_){return w===null&&S.flush(m.context.currentTime),S.add(o(_)),g.cancelScheduledValues(_),v},exponentialRampToValueAtTime(_,A){if(_===0)throw new RangeError;if(!Number.isFinite(A)||A<0)throw new RangeError;let x=m.context.currentTime;return w===null&&S.flush(x),Array.from(S).length===0&&(S.add(u(I,x)),g.setValueAtTime(I,x)),S.add(s(_,A)),g.exponentialRampToValueAtTime(_,A),v},linearRampToValueAtTime(_,A){let x=m.context.currentTime;return w===null&&S.flush(x),Array.from(S).length===0&&(S.add(u(I,x)),g.setValueAtTime(I,x)),S.add(a(_,A)),g.linearRampToValueAtTime(_,A),v},setTargetAtTime(_,A,x){return w===null&&S.flush(m.context.currentTime),S.add(c(_,A,x)),g.setTargetAtTime(_,A,x),v},setValueAtTime(_,A){return w===null&&S.flush(m.context.currentTime),S.add(u(_,A)),g.setValueAtTime(_,A),v},setValueCurveAtTime(_,A,x){let T=_ instanceof Float32Array?_:new Float32Array(_);if(h!==null&&h.name==="webkitAudioContext"){let E=A+x,R=m.context.sampleRate,M=Math.ceil(A*R),G=Math.floor(E*R),k=G-M,L=new Float32Array(k);for(let q=0;q<k;q+=1){let Q=(T.length-1)/x*((M+q)/R-A),Y=Math.floor(Q),V=Math.ceil(Q);L[q]=Y===V?T[Y]:(1-(Q-Y))*T[Y]+(1-(V-Q))*T[V]}w===null&&S.flush(m.context.currentTime),S.add(l(L,A,x)),g.setValueCurveAtTime(L,A,x);let F=G/R;F<E&&d(v,L[L.length-1],F),d(v,T[T.length-1],E)}else w===null&&S.flush(m.context.currentTime),S.add(l(T,A,x)),g.setValueCurveAtTime(T,A,x);return v}};return e.set(v,g),t.set(v,m),n(v,w),v};var hh=n=>({replay(t){for(let e of n)if(e.type==="exponentialRampToValue"){let{endTime:r,value:i}=e;t.exponentialRampToValueAtTime(i,r)}else if(e.type==="linearRampToValue"){let{endTime:r,value:i}=e;t.linearRampToValueAtTime(i,r)}else if(e.type==="setTarget"){let{startTime:r,target:i,timeConstant:o}=e;t.setTargetAtTime(i,r,o)}else if(e.type==="setValue"){let{startTime:r,value:i}=e;t.setValueAtTime(i,r)}else if(e.type==="setValueCurve"){let{duration:r,startTime:i,values:o}=e;t.setValueCurveAtTime(o,i,r)}else throw new Error("Can't apply an unknown automation.")}});var Wi=class{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((r,i)=>t.call(e,r,i,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}};var Mb={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},dh=(n,t,e,r,i,o,s,a,c,u,l,h,d,m)=>class extends t{constructor(g,y,C){var I;let S=a(g),w=c(S),v=l(D(D({},Mb),C));d(v);let _=$n.get(S),A=_==null?void 0:_.get(y),x=w||S.state!=="closed"?S:(I=s(S))!==null&&I!==void 0?I:S,T=i(x,w?null:g.baseLatency,u,y,A,v),E=w?r(y,v,A):null;super(g,!0,T,E);let R=[];T.parameters.forEach((G,k)=>{let L=e(this,w,G);R.push([k,L])}),this._nativeAudioWorkletNode=T,this._onprocessorerror=null,this._parameters=new Wi(R),w&&n(S,this);let{activeInputs:M}=o(this);h(T,M)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let y=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=y;let C=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=C!==null&&C===y?g:C}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Ui(n,t,e,r,i){if(typeof n.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),n.copyFromChannel(t[e],r,i);else{let o=n.getChannelData(r);if(t[e].byteLength===0)t[e]=o.slice(i,i+128);else{let s=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var Ns=(n,t,e,r,i)=>{typeof n.copyToChannel=="function"?t[e].byteLength!==0&&n.copyToChannel(t[e],r,i):t[e].byteLength!==0&&n.getChannelData(r).set(t[e],i)};var zi=(n,t)=>{let e=[];for(let r=0;r<n;r+=1){let i=[],o=typeof t=="number"?t:t[r];for(let s=0;s<o;s+=1)i.push(new Float32Array(128));e.push(i)}return e};var ph=(n,t)=>{let e=We(eo,n),r=ve(t);return We(e,r)};var Db=(n,t,e,r,i,o,s)=>K(null,null,function*(){let a=t===null?Math.ceil(n.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((y,C)=>y+C,0),l=u===0?null:e.createBuffer(u,a,e.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let h=Qe(n),d=yield ph(e,n),m=zi(r.numberOfInputs,r.channelCount),f=zi(r.numberOfOutputs,i),g=Array.from(n.parameters.keys()).reduce((y,C)=>X(D({},y),{[C]:new Float32Array(128)}),{});for(let y=0;y<a;y+=128){if(r.numberOfInputs>0&&t!==null)for(let C=0;C<r.numberOfInputs;C+=1)for(let I=0;I<r.channelCount;I+=1)Ui(t,m[C],I,I,y);o.parameterDescriptors!==void 0&&t!==null&&o.parameterDescriptors.forEach(({name:C},I)=>{Ui(t,g,C,c+I,y)});for(let C=0;C<r.numberOfInputs;C+=1)for(let I=0;I<i[C];I+=1)f[C][I].byteLength===0&&(f[C][I]=new Float32Array(128));try{let C=m.map((S,w)=>h.activeInputs[w].size===0?[]:S),I=s(y/e.sampleRate,e.sampleRate,()=>d.process(C,f,g));if(l!==null)for(let S=0,w=0;S<r.numberOfOutputs;S+=1){for(let v=0;v<i[S];v+=1)Ns(l,f[S],v,w+v,y);w+=i[S]}if(!I)break}catch(C){n.dispatchEvent(new ErrorEvent("processorerror",{colno:C.colno,filename:C.filename,lineno:C.lineno,message:C.message}));break}}return l}),mh=(n,t,e,r,i,o,s,a,c,u,l,h,d,m,f,g)=>(y,C,I)=>{let S=new WeakMap,w=null,v=(_,A)=>K(null,null,function*(){let x=l(_),T=null,E=fe(x,A),R=Array.isArray(C.outputChannelCount)?C.outputChannelCount:Array.from(C.outputChannelCount);if(h===null){let M=R.reduce((F,q)=>F+q,0),G=i(A,{channelCount:Math.max(1,M),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,M)}),k=[];for(let F=0;F<_.numberOfOutputs;F+=1)k.push(r(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:R[F]}));let L=s(A,{channelCount:C.channelCount,channelCountMode:C.channelCountMode,channelInterpretation:C.channelInterpretation,gain:1});L.connect=t.bind(null,k),L.disconnect=c.bind(null,k),T=[G,k,L]}else E||(x=new h(A,y));if(S.set(A,T===null?x:T[2]),T!==null){if(w===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(d===null)throw new Error("Missing the native OfflineAudioContext constructor.");let q=_.channelCount*_.numberOfInputs,Q=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,Y=q+Q;w=Db(_,Y===0?null:yield K(null,null,function*(){let ue=new d(Y,Math.ceil(_.context.length/128)*128,A.sampleRate),me=[],je=[];for(let Ae=0;Ae<C.numberOfInputs;Ae+=1)me.push(s(ue,{channelCount:C.channelCount,channelCountMode:C.channelCountMode,channelInterpretation:C.channelInterpretation,gain:1})),je.push(i(ue,{channelCount:C.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:C.channelCount}));let Ct=yield Promise.all(Array.from(_.parameters.values()).map(Ae=>K(null,null,function*(){let oe=o(ue,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:Ae.value});return yield m(ue,Ae,oe.offset),oe}))),At=r(ue,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,q+Q)});for(let Ae=0;Ae<C.numberOfInputs;Ae+=1){me[Ae].connect(je[Ae]);for(let oe=0;oe<C.channelCount;oe+=1)je[Ae].connect(At,oe,Ae*C.channelCount+oe)}for(let[Ae,oe]of Ct.entries())oe.connect(At,0,q+Ae),oe.start(0);return At.connect(ue.destination),yield Promise.all(me.map(Ae=>f(_,ue,Ae))),g(ue)}),A,C,R,I,u)}let M=yield w,G=e(A,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[k,L,F]=T;M!==null&&(G.buffer=M,G.start(0)),G.connect(k);for(let q=0,Q=0;q<_.numberOfOutputs;q+=1){let Y=L[q];for(let V=0;V<R[q];V+=1)k.connect(Y,Q+V,V);Q+=R[q]}return F}if(E)for(let[M,G]of _.parameters.entries())yield n(A,G,x.parameters.get(M));else for(let[M,G]of _.parameters.entries())yield m(A,G,x.parameters.get(M));return yield f(_,A,x),x});return{render(_,A){a(A,_);let x=S.get(A);return x!==void 0?Promise.resolve(x):v(_,A)}}};var fh=(n,t,e,r,i,o,s,a,c,u,l,h,d,m,f,g,y,C,I,S)=>class extends f{constructor(v,_){super(v,_),this._nativeContext=v,this._audioWorklet=n===void 0?void 0:{addModule:(A,x)=>n(this,A,x)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(v,_,A){return new e({length:_,numberOfChannels:v,sampleRate:A})}createBufferSource(){return new r(this)}createChannelMerger(v=6){return new o(this,{numberOfInputs:v})}createChannelSplitter(v=6){return new s(this,{numberOfOutputs:v})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(v=1){return new l(this,{maxDelayTime:v})}createDynamicsCompressor(){return new h(this)}createGain(){return new d(this)}createIIRFilter(v,_){return new m(this,{feedback:_,feedforward:v})}createOscillator(){return new g(this)}createPanner(){return new y(this)}createPeriodicWave(v,_,A={disableNormalization:!1}){return new C(this,X(D({},A),{imag:_,real:v}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new S(this)}decodeAudioData(v,_,A){return u(this._nativeContext,v).then(x=>(typeof _=="function"&&_(x),x),x=>{throw typeof A=="function"&&A(x),x})}};var Eb={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},gh=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},Eb),l),m=i(h,d),f=s(h),g=f?e():null;super(u,!1,m,g),this._Q=t(this,f,m.Q,Ee,Pe),this._detune=t(this,f,m.detune,1200*Math.log2(Ee),-1200*Math.log2(Ee)),this._frequency=t(this,f,m.frequency,u.sampleRate/2,0),this._gain=t(this,f,m.gain,40*Math.log10(Ee),Pe),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 bh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=fe(u,c);if(!l){let h={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,h)}return o.set(c,u),l?(yield 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 yh=(n,t)=>(e,r)=>{let i=t.get(e);if(i!==void 0)return i;let o=n.get(e);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(n.set(e,s),s.catch(()=>!1).then(a=>(n.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var kb={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},xh=(n,t,e,r,i)=>class extends n{constructor(s,a){let c=r(s),u=D(D({},kb),a),l=e(c,u),h=i(c)?t():null;super(s,!1,l,h)}};var Ch=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!fe(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 e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Lb={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Ah=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=o(D(D({},Lb),c)),h=e(u,l),d=i(u)?t():null;super(a,!1,h,d)}};var _h=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!fe(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 e(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=>(t,e,r)=>n(e,t,r);var Ih=n=>(t,e,r=0,i=0)=>{let o=t[r];if(o===void 0)throw n();return ui(e)?o.connect(e,0,i):o.connect(e,0)};var Sh=n=>(t,e)=>{let r=n(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=t.createBuffer(1,2,44100);return r.buffer=i,r.loop=!0,r.connect(e),r.start(),()=>{r.stop(),r.disconnect(e)}};var jb={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},wh=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},jb),u),d=r(l,h),m=o(l),f=m?e():null;super(c,!1,d,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=d,this._offset=t(this,m,d.offset,Ee,Pe),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"){qt(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),ut(this)&&sr(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var Nh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=e(u),d=fe(h,l);if(!d){let m={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,m),s!==null&&h.start(s),a!==null&&h.stop(a)}return o.set(l,h),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 Th=n=>t=>(n[0]=t,n[0]);var Pb={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Oh=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=D(D({},Pb),c),h=e(u,l),m=i(u)?t():null;super(a,!1,h,m),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&o(this,l.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){let c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var Rh=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!fe(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),Rt(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Mh=(n,t)=>(e,r,i)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,i)}catch(o){throw o.name==="SyntaxError"?n():o}};var Dh=()=>new DOMException("","DataCloneError");var $c=n=>{let{port1:t,port2:e}=new MessageChannel;return new Promise(r=>{let i=()=>{e.onmessage=null,t.close(),e.close(),r()};e.onmessage=()=>i();try{t.postMessage(n,[n])}catch(o){}finally{i()}})};var Eh=(n,t,e,r,i,o,s,a,c,u,l)=>(h,d)=>{let m=s(h)?h:o(h);if(i.has(d)){let f=e();return Promise.reject(f)}try{i.add(d)}catch(f){}return t(c,()=>c(m))?m.decodeAudioData(d).then(f=>($c(d).catch(()=>{}),t(a,()=>a(f))||l(f),n.add(f),f)):new Promise((f,g)=>{let y=()=>K(null,null,function*(){try{yield $c(d)}catch(I){}}),C=I=>{g(I),y()};try{m.decodeAudioData(d,I=>{typeof I.copyFromChannel!="function"&&(u(I),Bi(I)),n.add(I),y().then(()=>f(I))},I=>{C(I===null?r():I)})}catch(I){C(I)}})};var kh=(n,t,e,r,i,o,s,a)=>(c,u)=>{let l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=o(c.context),d=a(h);if(l===u){if(t.delete(c),!d&&s(c)){let m=r(c),{outputs:f}=e(c);for(let g of f)if(Vr(g)){let y=r(g[0]);n(m,y,g[1],g[2])}else{let y=i(g[0]);m.connect(y,g[1])}}}else t.set(c,l-u)};var Fb={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Lh=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Fb),u),d=r(l,h),m=o(l),f=m?e(h.maxDelayTime):null;super(c,!1,d,f),this._delayTime=t(this,m,d.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var jh=(n,t,e,r,i)=>o=>{let s=new WeakMap,a=(c,u)=>K(null,null,function*(){let l=e(c),h=fe(l,u);if(!h){let d={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=t(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 Ph=n=>(t,e,r,i)=>n(t[i],o=>o[0]===e&&o[1]===r);var Fh=n=>(t,e)=>{n(t).delete(e)};var Bh=n=>"delayTime"in n;var Gh=(n,t,e)=>function r(i,o){let s=ai(o)?o:e(n,o);if(Bh(s))return[];if(i[0]===s)return[i];if(i.includes(s))return[];let{outputs:a}=t(s);return Array.from(a).map(c=>r([...i,s],c[0])).reduce((c,u)=>c.concat(u),[])};var Ts=(n,t,e)=>{let r=t[e];if(r===void 0)throw n();return r},Vh=n=>(t,e=void 0,r=void 0,i=0)=>e===void 0?t.forEach(o=>o.disconnect()):typeof e=="number"?Ts(n,t,e).disconnect():ui(e)?r===void 0?t.forEach(o=>o.disconnect(e)):i===void 0?Ts(n,t,r).disconnect(e,0):Ts(n,t,r).disconnect(e,0,i):r===void 0?t.forEach(o=>o.disconnect(e)):Ts(n,t,r).disconnect(e,0);var Bb={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},qh=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),d=D(D({},Bb),l),m=r(h,d),f=s(h),g=f?e():null;super(u,!1,m,g),this._attack=t(this,f,m.attack),this._knee=t(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=t(this,f,m.ratio),this._release=t(this,f,m.release),this._threshold=t(this,f,m.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){let l=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=l,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 Wh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=fe(u,c);if(!l){let h={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,h)}return o.set(c,u),l?(yield 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 Uh=()=>new DOMException("","EncodingError");var zh=n=>t=>new Promise((e,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([t],{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(),e()},o.src=a,o.type="module",i.appendChild(o)}});var Yh=n=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,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(e,o,i)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,i){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,o===void 0?null:o,i)}};var Hh=n=>(t,e,r)=>{Object.defineProperties(n,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{n!==null&&(delete n.currentFrame,delete n.currentTime)}};var Zh=n=>t=>K(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw n()});var Gb={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Xh=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},Gb),c),h=r(u,l),d=o(u),m=d?e():null;super(a,!1,h,m),this._gain=t(this,d,h.gain,Ee,Pe)}get gain(){return this._gain}};var Qh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=fe(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,h)}return o.set(c,u),l?yield 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 Kh=(n,t)=>e=>t(n,e);var Jh=n=>t=>{let e=n(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var $h=n=>t=>{var e;return(e=n.get(t))!==null&&e!==void 0?e:0};var ed=n=>t=>{let e=n(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var td=n=>t=>n.get(t);var Te=()=>new DOMException("","InvalidStateError");var rd=n=>t=>{let e=n.get(t);if(e===void 0)throw Te();return e};var id=(n,t)=>e=>{let r=n.get(e);if(r!==void 0)return r;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new t(1,1,44100),n.set(e,r),r};var nd=n=>t=>{let e=n.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var Yi=()=>new DOMException("","InvalidAccessError");var od=n=>{n.getFrequencyResponse=(t=>(e,r,i)=>{if(e.length!==r.length||r.length!==i.length)throw Yi();return t.call(n,e,r,i)})(n.getFrequencyResponse)};var Vb={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},sd=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=i(u),h=D(D({},Vb),c),d=t(u,l?null:a.baseLatency,h),m=l?e(h.feedback,h.feedforward):null;super(a,!1,d,m),od(d),this._nativeIIRFilterNode=d,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var Os=(n,t,e,r,i,o,s,a,c,u,l)=>{let h=u.length,d=a;for(let m=0;m<h;m+=1){let f=e[0]*u[m];for(let g=1;g<i;g+=1){let y=d-g&c-1;f+=e[g]*o[y],f-=n[g]*s[y]}for(let g=i;g<r;g+=1)f+=e[g]*o[d-g&c-1];for(let g=i;g<t;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 qb=(n,t,e,r)=>{let i=e instanceof Float64Array?e:new Float64Array(e),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=t.createBuffer(n.numberOfChannels,n.length,n.sampleRate),m=n.numberOfChannels;for(let f=0;f<m;f+=1){let g=n.getChannelData(f),y=d.getChannelData(f);l.fill(0),h.fill(0),Os(i,s,o,a,c,l,h,0,u,g,y)}return d},ad=(n,t,e,r,i)=>(o,s)=>{let a=new WeakMap,c=null,u=(l,h)=>K(null,null,function*(){let d=null,m=t(l),f=fe(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(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let y=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=K(null,null,function*(){yield r(l,y,y.destination);let C=yield i(y);return qb(C,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 cd=(n,t,e,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}=e(a);for(let d of h)if(Vr(d)){let m=r(d[0]);t(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 ud=(n,t)=>e=>{let r=n.get(e);return t(r)||t(e)};var ld=(n,t)=>e=>n.has(e)||t(e);var hd=(n,t)=>e=>n.has(e)||t(e);var dd=(n,t)=>e=>{let r=n.get(e);return t(r)||t(e)};var pd=n=>t=>n!==null&&t instanceof n;var md=n=>t=>n!==null&&typeof n.AudioNode=="function"&&t instanceof n.AudioNode;var fd=n=>t=>n!==null&&typeof n.AudioParam=="function"&&t instanceof n.AudioParam;var gd=(n,t)=>e=>n(e)||t(e);var bd=n=>t=>n!==null&&t instanceof n;var yd=n=>n!==null&&n.isSecureContext;var xd=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var Wb={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Cd=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o);if(r(a))throw new TypeError;let c=D(D({},Wb),s),u=t(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Ad=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var _d=(n,t,e)=>class extends n{constructor(i,o){let s=e(i),a=t(s,o);super(i,!0,a,null)}};var vd=(n,t,e,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"?t():l}if(a===null)throw e();if(!Ss(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw t();super(a,2);let{latencyHint:c}=s,{sampleRate:u}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/u:c==="interactive"||c===void 0?256/u:c==="playback"?1024/u:Math.max(2,Math.min(128,Math.round(c*u/128)))*128/u,this._nativeAudioContext=a,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()),Gr(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 Id=(n,t,e,r,i,o)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,Pi.set(this,a),r(a)&&i.set(a,new Set),this._destination=new n(this,c),this._listener=t(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){let c=typeof a=="function"?o(this,a):null;this._nativeContext.onstatechange=c;let u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?a:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}};var Ut=n=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=n.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var Ub={numberOfChannels:1},Sd=(n,t,e,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=D(D({},Ub),s),l=e(c,a,u);n(Ut,()=>Ut(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(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Gr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var wd=(n,t)=>(e,r,i)=>{let o=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let l=o.size===0;if(t(a))return s.call(e,a,c,u),n(o,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(e,a,c),n(o,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let l=o.size>0;if(a===void 0)s.apply(e),o.clear();else if(typeof a=="number"){s.call(e,a);for(let d of o)d[1]===a&&o.delete(d)}else{t(a)?s.call(e,a,c,u):s.call(e,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()})(e.disconnect),e};var ge=(n,t,e)=>{let r=t[e];r!==void 0&&r!==n[e]&&(n[e]=r)};var le=(n,t)=>{ge(n,t,"channelCount"),ge(n,t,"channelCountMode"),ge(n,t,"channelInterpretation")};var eu=n=>typeof n.getFloatTimeDomainData=="function";var Nd=n=>{n.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);n.getByteTimeDomainData(e);let r=Math.max(e.length,n.fftSize);for(let i=0;i<r;i+=1)t[i]=(e[i]-128)*.0078125;return t}};var Td=(n,t)=>(e,r)=>{let i=e.createAnalyser();if(le(i,r),!(r.maxDecibels>r.minDecibels))throw t();return ge(i,r,"fftSize"),ge(i,r,"maxDecibels"),ge(i,r,"minDecibels"),ge(i,r,"smoothingTimeConstant"),n(eu,()=>eu(i))||Nd(i),i};var Od=n=>n===null?null:n.hasOwnProperty("AudioBuffer")?n.AudioBuffer:null;var Ce=(n,t,e)=>{let r=t[e];r!==void 0&&r!==n[e].value&&(n[e].value=r)};var Rd=n=>{n.start=(t=>{let e=!1;return(r=0,i=0,o)=>{if(e)throw Te();t.call(n,r,i,o),e=!0}})(n.start)};var Hi=n=>{n.start=(t=>(e=0,r=0,i)=>{if(typeof i=="number"&&i<0||r<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(n,e,r,i)})(n.start)};var Zi=n=>{n.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(n,e)})(n.stop)};var Md=(n,t,e,r,i,o,s,a,c,u,l)=>(h,d)=>{let m=h.createBufferSource();return le(m,d),Ce(m,d,"playbackRate"),ge(m,d,"buffer"),ge(m,d,"loop"),ge(m,d,"loopEnd"),ge(m,d,"loopStart"),t(e,()=>e(h))||Rd(m),t(r,()=>r(h))||c(m),t(i,()=>i(h))||u(m,h),t(o,()=>o(h))||Hi(m),t(s,()=>s(h))||l(m,h),t(a,()=>a(h))||Zi(m),n(h,m),m};var Dd=n=>n===null?null:n.hasOwnProperty("AudioContext")?n.AudioContext:n.hasOwnProperty("webkitAudioContext")?n.webkitAudioContext:null;var Ed=(n,t)=>(e,r,i)=>{let o=e.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(e,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>o.maxChannelCount}),s.connect(o),s};var kd=n=>n===null?null:n.hasOwnProperty("AudioWorkletNode")?n.AudioWorkletNode:null;var Ld=n=>{let{port1:t}=new MessageChannel;try{t.postMessage(n)}finally{t.close()}};var jd=(n,t,e,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 y=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(y!==null){let C=d.get(g[1]);C!==void 0?g[1]=C:(g[1]=I=>{I.type==="error"?(Object.defineProperties(I,{type:{value:"processorerror"}}),y(I)):y(new ErrorEvent(g[0],D({},I)))},d.set(y,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 y=d.get(g[1]);y!==void 0&&(d.delete(g[1]),g[1]=y)}return f.call(h,"error",g[1],g[2]),f.call(h,g[0],g[1],g[2])})(h.removeEventListener),l.numberOfOutputs!==0){let f=e(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(o.destination),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 Ld(l),t(o,s,u,l)};var Rs=(n,t)=>n===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(n*t)))));var Pd=n=>new Promise((t,e)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),i.close(),t(o)},r.onmessageerror=({data:o})=>{r.close(),i.close(),e(o)},i.postMessage(n)});var Fd=(n,t)=>K(null,null,function*(){let e=yield Pd(t);return new n(e)});var Bd=(n,t,e,r)=>{let i=eo.get(n);i===void 0&&(i=new WeakMap,eo.set(n,i));let o=Fd(e,r);return i.set(t,o),o};var Gd=(n,t,e,r,i,o,s,a,c,u,l,h,d)=>(m,f,g,y)=>{if(y.numberOfInputs===0&&y.numberOfOutputs===0)throw c();let C=Array.isArray(y.outputChannelCount)?y.outputChannelCount:Array.from(y.outputChannelCount);if(C.some(H=>H<1))throw c();if(C.length!==y.numberOfOutputs)throw t();if(y.channelCountMode!=="explicit")throw c();let I=y.channelCount*y.numberOfInputs,S=C.reduce((H,ie)=>H+ie,0),w=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+w>6||S>6)throw c();let v=new MessageChannel,_=[],A=[];for(let H=0;H<y.numberOfInputs;H+=1)_.push(s(m,{channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation,gain:1})),A.push(i(m,{channelCount:y.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:y.channelCount}));let x=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:H,maxValue:ie,minValue:He,name:Oe}of g.parameterDescriptors){let xe=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:y.parameterData[Oe]!==void 0?y.parameterData[Oe]:H===void 0?0:H});Object.defineProperties(xe.offset,{defaultValue:{get:()=>H===void 0?0:H},maxValue:{get:()=>ie===void 0?Ee:ie},minValue:{get:()=>He===void 0?Pe:He}}),x.push(xe)}let T=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+w)}),E=Rs(f,m.sampleRate),R=a(m,E,I+w,Math.max(1,S)),M=i(m,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),G=[];for(let H=0;H<y.numberOfOutputs;H+=1)G.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:C[H]}));for(let H=0;H<y.numberOfInputs;H+=1){_[H].connect(A[H]);for(let ie=0;ie<y.channelCount;ie+=1)A[H].connect(T,ie,H*y.channelCount+ie)}let k=new Wi(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:H},ie)=>{let He=x[ie];return He.connect(T,0,I+ie),He.start(0),[H,He.offset]}));T.connect(R);let L=y.channelInterpretation,F=null,q=y.numberOfOutputs===0?[R]:G,Q={get bufferSize(){return E},get channelCount(){return y.channelCount},set channelCount(H){throw e()},get channelCountMode(){return y.channelCountMode},set channelCountMode(H){throw e()},get channelInterpretation(){return L},set channelInterpretation(H){for(let ie of _)ie.channelInterpretation=H;L=H},get context(){return R.context},get inputs(){return _},get numberOfInputs(){return y.numberOfInputs},get numberOfOutputs(){return y.numberOfOutputs},get onprocessorerror(){return F},set onprocessorerror(H){typeof F=="function"&&Q.removeEventListener("processorerror",F),F=typeof H=="function"?H:null,typeof F=="function"&&Q.addEventListener("processorerror",F)},get parameters(){return k},get port(){return v.port2},addEventListener(...H){return R.addEventListener(H[0],H[1],H[2])},connect:n.bind(null,q),disconnect:u.bind(null,q),dispatchEvent(...H){return R.dispatchEvent(H[0])},removeEventListener(...H){return R.removeEventListener(H[0],H[1],H[2])}},Y=new Map;v.port1.addEventListener=(H=>(...ie)=>{if(ie[0]==="message"){let He=typeof ie[1]=="function"?ie[1]:typeof ie[1]=="object"&&ie[1]!==null&&typeof ie[1].handleEvent=="function"?ie[1].handleEvent:null;if(He!==null){let Oe=Y.get(ie[1]);Oe!==void 0?ie[1]=Oe:(ie[1]=xe=>{l(m.currentTime,m.sampleRate,()=>He(xe))},Y.set(He,ie[1]))}}return H.call(v.port1,ie[0],ie[1],ie[2])})(v.port1.addEventListener),v.port1.removeEventListener=(H=>(...ie)=>{if(ie[0]==="message"){let He=Y.get(ie[1]);He!==void 0&&(Y.delete(ie[1]),ie[1]=He)}return H.call(v.port1,ie[0],ie[1],ie[2])})(v.port1.removeEventListener);let V=null;Object.defineProperty(v.port1,"onmessage",{get:()=>V,set:H=>{typeof V=="function"&&v.port1.removeEventListener("message",V),V=typeof H=="function"?H:null,typeof V=="function"&&(v.port1.addEventListener("message",V),v.port1.start())}}),g.prototype.port=v.port1;let ue=null;Bd(m,Q,g,y).then(H=>ue=H);let je=zi(y.numberOfInputs,y.channelCount),Ct=zi(y.numberOfOutputs,C),At=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((H,{name:ie})=>X(D({},H),{[ie]:new Float32Array(128)}),{}),Ae=!0,oe=()=>{y.numberOfOutputs>0&&R.disconnect(M);for(let H=0,ie=0;H<y.numberOfOutputs;H+=1){let He=G[H];for(let Oe=0;Oe<C[H];Oe+=1)M.disconnect(He,ie+Oe,Oe);ie+=C[H]}},Ti=new Map;R.onaudioprocess=({inputBuffer:H,outputBuffer:ie})=>{if(ue!==null){let He=h(Q);for(let Oe=0;Oe<E;Oe+=128){for(let xe=0;xe<y.numberOfInputs;xe+=1)for(let De=0;De<y.channelCount;De+=1)Ui(H,je[xe],De,De,Oe);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:xe},De)=>{Ui(H,At,xe,I+De,Oe)});for(let xe=0;xe<y.numberOfInputs;xe+=1)for(let De=0;De<C[xe];De+=1)Ct[xe][De].byteLength===0&&(Ct[xe][De]=new Float32Array(128));try{let xe=je.map((wt,Mr)=>{if(He[Mr].size>0)return Ti.set(Mr,E/128),wt;let dc=Ti.get(Mr);return dc===void 0?[]:(wt.every(of=>of.every(sf=>sf===0))&&(dc===1?Ti.delete(Mr):Ti.set(Mr,dc-1)),wt)});Ae=l(m.currentTime+Oe/m.sampleRate,m.sampleRate,()=>ue.process(xe,Ct,At));for(let wt=0,Mr=0;wt<y.numberOfOutputs;wt+=1){for(let jn=0;jn<C[wt];jn+=1)Ns(ie,Ct[wt],jn,Mr+jn,Oe);Mr+=C[wt]}}catch(xe){Ae=!1,Q.dispatchEvent(new ErrorEvent("processorerror",{colno:xe.colno,filename:xe.filename,lineno:xe.lineno,message:xe.message}))}if(!Ae){for(let xe=0;xe<y.numberOfInputs;xe+=1){_[xe].disconnect(A[xe]);for(let De=0;De<y.channelCount;De+=1)A[Oe].disconnect(T,De,xe*y.channelCount+De)}if(g.parameterDescriptors!==void 0){let xe=g.parameterDescriptors.length;for(let De=0;De<xe;De+=1){let wt=x[De];wt.disconnect(T,0,I+De),wt.stop()}}T.disconnect(R),R.onaudioprocess=null,En?oe():Ri();break}}}};let En=!1,J=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Oi=()=>R.connect(J).connect(m.destination),Ri=()=>{R.disconnect(J),J.disconnect()},kn=()=>{if(Ae){Ri(),y.numberOfOutputs>0&&R.connect(M);for(let H=0,ie=0;H<y.numberOfOutputs;H+=1){let He=G[H];for(let Oe=0;Oe<C[H];Oe+=1)M.connect(He,ie+Oe,Oe);ie+=C[H]}}En=!0},Ln=()=>{Ae&&(Oi(),oe()),En=!1};return Oi(),d(Q,kn,Ln)};var tu=(n,t)=>{let e=n.createBiquadFilter();return le(e,t),Ce(e,t,"Q"),Ce(e,t,"detune"),Ce(e,t,"frequency"),Ce(e,t,"gain"),ge(e,t,"type"),e};var Vd=(n,t)=>(e,r)=>{let i=e.createChannelMerger(r.numberOfInputs);return n!==null&&n.name==="webkitAudioContext"&&t(e,i),le(i,r),i};var qd=n=>{let t=n.numberOfOutputs;Object.defineProperty(n,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw Te()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw Te()}}),Object.defineProperty(n,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw Te()}})};var Xi=(n,t)=>{let e=n.createChannelSplitter(t.numberOfOutputs);return le(e,t),qd(e),e};var Wd=(n,t,e,r,i)=>(o,s)=>{if(o.createConstantSource===void 0)return e(o,s);let a=o.createConstantSource();return le(a,s),Ce(a,s,"offset"),t(r,()=>r(o))||Hi(a),t(i,()=>i(o))||Zi(a),n(o,a),a};var Mt=(n,t)=>(n.connect=t.connect.bind(t),n.disconnect=t.disconnect.bind(t),n);var Ud=(n,t,e,r)=>(i,a)=>{var c=a,{offset:o}=c,s=Dr(c,["offset"]);let u=i.createBuffer(1,2,44100),l=t(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=e(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(y){h.channelCount=y},get channelCountMode(){return h.channelCountMode},set channelCountMode(y){h.channelCountMode=y},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(y){h.channelInterpretation=y},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(y){l.onended=y},addEventListener(...y){return l.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return l.dispatchEvent(y[0])},removeEventListener(...y){return l.removeEventListener(y[0],y[1],y[2])},start(y=0){l.start.call(l,y)},stop(y=0){l.stop.call(l,y)}},f=()=>l.connect(h),g=()=>l.disconnect(h);return n(i,l),r(Mt(m,h),f,g)};var zd=(n,t)=>(e,r)=>{let i=e.createConvolver();if(le(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),ge(i,r,"buffer"),r.channelCount>2||(t(i,"channelCount",o=>()=>o.call(i),o=>s=>{if(s>2)throw n();return o.call(i,s)}),r.channelCountMode==="max"))throw n();return t(i,"channelCountMode",o=>()=>o.call(i),o=>s=>{if(s==="max")throw n();return o.call(i,s)}),i};var ru=(n,t)=>{let e=n.createDelay(t.maxDelayTime);return le(e,t),Ce(e,t,"delayTime"),e};var Yd=n=>(t,e)=>{let r=t.createDynamicsCompressor();if(le(r,e),e.channelCount>2||e.channelCountMode==="max")throw n();return Ce(r,e,"attack"),Ce(r,e,"knee"),Ce(r,e,"ratio"),Ce(r,e,"release"),Ce(r,e,"threshold"),r};var lt=(n,t)=>{let e=n.createGain();return le(e,t),Ce(e,t,"gain"),e};var Hd=n=>(t,e,r)=>{if(t.createIIRFilter===void 0)return n(t,e,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return le(i,r),i};function zb(n,t){let e=t[0]*t[0]+t[1]*t[1];return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]}function Yb(n,t){return[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]]}function Zd(n,t){let e=[0,0];for(let r=n.length-1;r>=0;r-=1)e=Yb(e,t),e[0]+=n[r];return e}var Xd=(n,t,e,r)=>(i,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=Rs(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,y=Math.min(f,g);if(f===0||f>20)throw r();if(d[0]===0)throw t();if(g===0||g>20)throw r();if(m[0]===0)throw t();if(d[0]!==1){for(let x=0;x<g;x+=1)m[x]/=d[0];for(let x=1;x<f;x+=1)d[x]/=d[0]}let C=e(i,h,s,s);C.channelCount=s,C.channelCountMode=a,C.channelInterpretation=c;let I=32,S=[],w=[],v=[];for(let x=0;x<s;x+=1){S.push(0);let T=new Float32Array(I),E=new Float32Array(I);T.fill(0),E.fill(0),w.push(T),v.push(E)}C.onaudioprocess=x=>{let T=x.inputBuffer,E=x.outputBuffer,R=T.numberOfChannels;for(let M=0;M<R;M+=1){let G=T.getChannelData(M),k=E.getChannelData(M);S[M]=Os(d,f,m,g,y,w[M],v[M],S[M],I,G,k)}};let _=i.sampleRate/2;return Mt({get bufferSize(){return h},get channelCount(){return C.channelCount},set channelCount(x){C.channelCount=x},get channelCountMode(){return C.channelCountMode},set channelCountMode(x){C.channelCountMode=x},get channelInterpretation(){return C.channelInterpretation},set channelInterpretation(x){C.channelInterpretation=x},get context(){return C.context},get inputs(){return[C]},get numberOfInputs(){return C.numberOfInputs},get numberOfOutputs(){return C.numberOfOutputs},addEventListener(...x){return C.addEventListener(x[0],x[1],x[2])},dispatchEvent(...x){return C.dispatchEvent(x[0])},getFrequencyResponse(x,T,E){if(x.length!==T.length||T.length!==E.length)throw n();let R=x.length;for(let M=0;M<R;M+=1){let G=-Math.PI*(x[M]/_),k=[Math.cos(G),Math.sin(G)],L=Zd(m,k),F=Zd(d,k),q=zb(L,F);T[M]=Math.sqrt(q[0]*q[0]+q[1]*q[1]),E[M]=Math.atan2(q[1],q[0])}},removeEventListener(...x){return C.removeEventListener(x[0],x[1],x[2])}},C)};var Qd=(n,t)=>n.createMediaElementSource(t.mediaElement);var Kd=(n,t)=>{let e=n.createMediaStreamDestination();return le(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var Jd=(n,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=e.slice(0,1),i=n.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i};var $d=(n,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let i=new MediaStream([r]),o=e.createMediaStreamSource(i);if(r.kind!=="audio")throw n();if(t(e))throw new TypeError;return o};var ep=n=>n===null?null:n.hasOwnProperty("OfflineAudioContext")?n.OfflineAudioContext:n.hasOwnProperty("webkitOfflineAudioContext")?n.webkitOfflineAudioContext:null;var tp=(n,t,e,r,i,o)=>(s,a)=>{let c=s.createOscillator();return le(c,a),Ce(c,a,"detune"),Ce(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):ge(c,a,"type"),t(e,()=>e(s))||Hi(c),t(r,()=>r(s))||o(c,s),t(i,()=>i(s))||Zi(c),n(s,c),c};var rp=n=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?n(t,e):(le(r,e),Ce(r,e,"orientationX"),Ce(r,e,"orientationY"),Ce(r,e,"orientationZ"),Ce(r,e,"positionX"),Ce(r,e,"positionY"),Ce(r,e,"positionZ"),ge(r,e,"coneInnerAngle"),ge(r,e,"coneOuterAngle"),ge(r,e,"coneOuterGain"),ge(r,e,"distanceModel"),ge(r,e,"maxDistance"),ge(r,e,"panningModel"),ge(r,e,"refDistance"),ge(r,e,"rolloffFactor"),r)};var ip=(n,t,e,r,i,o,s,a,c,u)=>(l,E)=>{var R=E,{coneInnerAngle:h,coneOuterAngle:d,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:y,orientationY:C,orientationZ:I,panningModel:S,positionX:w,positionY:v,positionZ:_,refDistance:A,rolloffFactor:x}=R,T=Dr(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();le(M,T);let G={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},k=e(l,X(D({},G),{channelInterpretation:"speakers",numberOfInputs:6})),L=r(l,X(D({},T),{gain:1})),F=r(l,X(D({},G),{gain:1})),q=r(l,X(D({},G),{gain:0})),Q=r(l,X(D({},G),{gain:0})),Y=r(l,X(D({},G),{gain:0})),V=r(l,X(D({},G),{gain:0})),ue=r(l,X(D({},G),{gain:0})),me=i(l,256,6,1),je=o(l,X(D({},G),{curve:new Float32Array([1,1]),oversample:"none"})),Ct=[y,C,I],At=[w,v,_],Ae=new Float32Array(1);me.onaudioprocess=({inputBuffer:J})=>{let Oi=[c(J,Ae,0),c(J,Ae,1),c(J,Ae,2)];Oi.some((kn,Ln)=>kn!==Ct[Ln])&&(M.setOrientation(...Oi),Ct=Oi);let Ri=[c(J,Ae,3),c(J,Ae,4),c(J,Ae,5)];Ri.some((kn,Ln)=>kn!==At[Ln])&&(M.setPosition(...Ri),At=Ri)},Object.defineProperty(q.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(ue.gain,"defaultValue",{get:()=>0});let oe={get bufferSize(){},get channelCount(){return M.channelCount},set channelCount(J){if(J>2)throw s();L.channelCount=J,M.channelCount=J},get channelCountMode(){return M.channelCountMode},set channelCountMode(J){if(J==="max")throw s();L.channelCountMode=J,M.channelCountMode=J},get channelInterpretation(){return M.channelInterpretation},set channelInterpretation(J){L.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 t();M.coneOuterGain=J},get context(){return M.context},get distanceModel(){return M.distanceModel},set distanceModel(J){M.distanceModel=J},get inputs(){return[L]},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 F.gain},get orientationY(){return q.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 ue.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 L.addEventListener(J[0],J[1],J[2])},dispatchEvent(...J){return L.dispatchEvent(J[0])},removeEventListener(...J){return L.removeEventListener(J[0],J[1],J[2])}};h!==oe.coneInnerAngle&&(oe.coneInnerAngle=h),d!==oe.coneOuterAngle&&(oe.coneOuterAngle=d),m!==oe.coneOuterGain&&(oe.coneOuterGain=m),f!==oe.distanceModel&&(oe.distanceModel=f),g!==oe.maxDistance&&(oe.maxDistance=g),y!==oe.orientationX.value&&(oe.orientationX.value=y),C!==oe.orientationY.value&&(oe.orientationY.value=C),I!==oe.orientationZ.value&&(oe.orientationZ.value=I),S!==oe.panningModel&&(oe.panningModel=S),w!==oe.positionX.value&&(oe.positionX.value=w),v!==oe.positionY.value&&(oe.positionY.value=v),_!==oe.positionZ.value&&(oe.positionZ.value=_),A!==oe.refDistance&&(oe.refDistance=A),x!==oe.rolloffFactor&&(oe.rolloffFactor=x),(Ct[0]!==1||Ct[1]!==0||Ct[2]!==0)&&M.setOrientation(...Ct),(At[0]!==0||At[1]!==0||At[2]!==0)&&M.setPosition(...At);let Ti=()=>{L.connect(M),n(L,je,0,0),je.connect(F).connect(k,0,0),je.connect(q).connect(k,0,1),je.connect(Q).connect(k,0,2),je.connect(Y).connect(k,0,3),je.connect(V).connect(k,0,4),je.connect(ue).connect(k,0,5),k.connect(me).connect(l.destination)},En=()=>{L.disconnect(M),a(L,je,0,0),je.disconnect(F),F.disconnect(k),je.disconnect(q),q.disconnect(k),je.disconnect(Q),Q.disconnect(k),je.disconnect(Y),Y.disconnect(k),je.disconnect(V),V.disconnect(k),je.disconnect(ue),ue.disconnect(k),k.disconnect(me),me.disconnect(l.destination)};return u(Mt(oe,M),Ti,En)};var np=n=>(t,{disableNormalization:e,imag:r,real:i})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=t.createPeriodicWave(s,o,{disableNormalization:e});if(Array.from(r).length<2)throw n();return a};var Qi=(n,t,e,r)=>n.createScriptProcessor(t,e,r);var op=(n,t)=>(e,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw t();if(e.createStereoPanner===void 0)return n(e,r);let o=e.createStereoPanner();return le(o,r),Ce(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw t()}}),o};var sp=(n,t,e,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,y,C)=>{let I=new Float32Array(16385),S=new Float32Array(16385);for(let T=0;T<16385;T+=1){let E=T/16384*c;I[T]=Math.cos(E),S[T]=Math.sin(E)}let w=e(f,X(D({},u),{gain:0})),v=r(f,X(D({},l),{curve:I})),_=r(f,X(D({},l),{curve:a})),A=e(f,X(D({},u),{gain:0})),x=r(f,X(D({},l),{curve:S}));return{connectGraph(){g.connect(w),g.connect(_.inputs===void 0?_:_.inputs[0]),g.connect(A),_.connect(y),y.connect(v.inputs===void 0?v:v.inputs[0]),y.connect(x.inputs===void 0?x:x.inputs[0]),v.connect(w.gain),x.connect(A.gain),w.connect(C,0,0),A.connect(C,0,1)},disconnectGraph(){g.disconnect(w),g.disconnect(_.inputs===void 0?_:_.inputs[0]),g.disconnect(A),_.disconnect(y),y.disconnect(v.inputs===void 0?v:v.inputs[0]),y.disconnect(x.inputs===void 0?x:x.inputs[0]),v.disconnect(w.gain),x.disconnect(A.gain),w.disconnect(C,0,0),A.disconnect(C,0,1)}}},d=(f,g,y,C)=>{let I=new Float32Array(16385),S=new Float32Array(16385),w=new Float32Array(16385),v=new Float32Array(16385),_=Math.floor(16385/2);for(let q=0;q<16385;q+=1)if(q>_){let Q=(q-_)/(16384-_)*c;I[q]=Math.cos(Q),S[q]=Math.sin(Q),w[q]=0,v[q]=1}else{let Q=q/(16384-_)*c;I[q]=1,S[q]=0,w[q]=Math.cos(Q),v[q]=Math.sin(Q)}let A=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),x=e(f,X(D({},u),{gain:0})),T=r(f,X(D({},l),{curve:I})),E=e(f,X(D({},u),{gain:0})),R=r(f,X(D({},l),{curve:S})),M=r(f,X(D({},l),{curve:a})),G=e(f,X(D({},u),{gain:0})),k=r(f,X(D({},l),{curve:w})),L=e(f,X(D({},u),{gain:0})),F=r(f,X(D({},l),{curve:v}));return{connectGraph(){g.connect(A),g.connect(M.inputs===void 0?M:M.inputs[0]),A.connect(x,0),A.connect(E,0),A.connect(G,1),A.connect(L,1),M.connect(y),y.connect(T.inputs===void 0?T:T.inputs[0]),y.connect(R.inputs===void 0?R:R.inputs[0]),y.connect(k.inputs===void 0?k:k.inputs[0]),y.connect(F.inputs===void 0?F:F.inputs[0]),T.connect(x.gain),R.connect(E.gain),k.connect(G.gain),F.connect(L.gain),x.connect(C,0,0),G.connect(C,0,0),E.connect(C,0,1),L.connect(C,0,1)},disconnectGraph(){g.disconnect(A),g.disconnect(M.inputs===void 0?M:M.inputs[0]),A.disconnect(x,0),A.disconnect(E,0),A.disconnect(G,1),A.disconnect(L,1),M.disconnect(y),y.disconnect(T.inputs===void 0?T:T.inputs[0]),y.disconnect(R.inputs===void 0?R:R.inputs[0]),y.disconnect(k.inputs===void 0?k:k.inputs[0]),y.disconnect(F.inputs===void 0?F:F.inputs[0]),T.disconnect(x.gain),R.disconnect(E.gain),k.disconnect(G.gain),F.disconnect(L.gain),x.disconnect(C,0,0),G.disconnect(C,0,0),E.disconnect(C,0,1),L.disconnect(C,0,1)}}},m=(f,g,y,C,I)=>{if(g===1)return h(f,y,C,I);if(g===2)return d(f,y,C,I);throw i()};return(f,S)=>{var w=S,{channelCount:g,channelCountMode:y,pan:C}=w,I=Dr(w,["channelCount","channelCountMode","pan"]);if(y==="max")throw i();let v=n(f,X(D({},I),{channelCount:1,channelCountMode:y,numberOfInputs:2})),_=e(f,X(D({},I),{channelCount:g,channelCountMode:y,gain:1})),A=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:C}),{connectGraph:x,disconnectGraph:T}=m(f,g,_,A,v);Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"maxValue",{get:()=>1}),Object.defineProperty(A.gain,"minValue",{get:()=>-1});let E={get bufferSize(){},get channelCount(){return _.channelCount},set channelCount(k){_.channelCount!==k&&(R&&T(),{connectGraph:x,disconnectGraph:T}=m(f,k,_,A,v),R&&x()),_.channelCount=k},get channelCountMode(){return _.channelCountMode},set channelCountMode(k){if(k==="clamped-max"||k==="max")throw i();_.channelCountMode=k},get channelInterpretation(){return _.channelInterpretation},set channelInterpretation(k){_.channelInterpretation=k},get context(){return _.context},get inputs(){return[_]},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get pan(){return A.gain},addEventListener(...k){return _.addEventListener(k[0],k[1],k[2])},dispatchEvent(...k){return _.dispatchEvent(k[0])},removeEventListener(...k){return _.removeEventListener(k[0],k[1],k[2])}},R=!1,M=()=>{x(),R=!0},G=()=>{T(),R=!1};return o(Mt(E,v),M,G)}};var ap=(n,t,e,r,i,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return e(a,c);le(u,c);let l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw t();ge(u,{curve:l},"curve"),ge(u,c,"oversample");let h=null,d=!1;return s(u,"curve",g=>()=>g.call(u),g=>y=>(g.call(u,y),d&&(r(y)&&h===null?h=n(a,u):!r(y)&&h!==null&&(h(),h=null)),y)),i(u,()=>{d=!0,r(u.curve)&&(h=n(a,u))},()=>{d=!1,h!==null&&(h(),h=null)})};var cp=(n,t,e,r,i)=>(o,u)=>{var l=u,{curve:s,oversample:a}=l,c=Dr(l,["curve","oversample"]);let h=o.createWaveShaper(),d=o.createWaveShaper();le(h,c),le(d,c);let m=e(o,X(D({},c),{gain:1})),f=e(o,X(D({},c),{gain:-1})),g=e(o,X(D({},c),{gain:1})),y=e(o,X(D({},c),{gain:-1})),C=null,I=!1,S=null,w={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(A){m.channelCount=A,f.channelCount=A,h.channelCount=A,g.channelCount=A,d.channelCount=A,y.channelCount=A},get channelCountMode(){return h.channelCountMode},set channelCountMode(A){m.channelCountMode=A,f.channelCountMode=A,h.channelCountMode=A,g.channelCountMode=A,d.channelCountMode=A,y.channelCountMode=A},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(A){m.channelInterpretation=A,f.channelInterpretation=A,h.channelInterpretation=A,g.channelInterpretation=A,d.channelInterpretation=A,y.channelInterpretation=A},get context(){return h.context},get curve(){return S},set curve(A){if(A!==null&&A.length<2)throw t();if(A===null)h.curve=A,d.curve=A;else{let x=A.length,T=new Float32Array(x+2-x%2),E=new Float32Array(x+2-x%2);T[0]=A[0],E[0]=-A[x-1];let R=Math.ceil((x+1)/2),M=(x+1)/2-1;for(let G=1;G<R;G+=1){let k=G/R*M,L=Math.floor(k),F=Math.ceil(k);T[G]=L===F?A[L]:(1-(k-L))*A[L]+(1-(F-k))*A[F],E[G]=L===F?-A[x-1-L]:-((1-(k-L))*A[x-1-L])-(1-(F-k))*A[x-1-F]}T[R]=x%2===1?A[R-1]:(A[R-2]+A[R-1])/2,h.curve=T,d.curve=E}S=A,I&&(r(S)&&C===null?C=n(o,m):C!==null&&(C(),C=null))},get inputs(){return[m]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(A){h.oversample=A,d.oversample=A},addEventListener(...A){return m.addEventListener(A[0],A[1],A[2])},dispatchEvent(...A){return m.dispatchEvent(A[0])},removeEventListener(...A){return m.removeEventListener(A[0],A[1],A[2])}};s!==null&&(w.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==w.oversample&&(w.oversample=a);let v=()=>{m.connect(h).connect(g),m.connect(f).connect(d).connect(y).connect(g),I=!0,r(S)&&(C=n(o,m))},_=()=>{m.disconnect(h),h.disconnect(g),m.disconnect(f),f.disconnect(d),d.disconnect(y),y.disconnect(g),I=!1,C!==null&&(C(),C=null)};return i(Mt(w,g),v,_)};var Je=()=>new DOMException("","NotSupportedError");var Hb={numberOfChannels:1},up=(n,t,e,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({},Hb),u),m=r(h,l,d);t(Ut,()=>Ut(m))||m.addEventListener("statechange",(()=>{let f=0,g=y=>{this._state==="running"&&(f>0?(m.removeEventListener("statechange",g),y.stopImmediatePropagation(),this._waitForThePromiseToSettle(y)):f+=1)};return g})()),super(m,h),this._length=l,this._nativeOfflineAudioContext=m,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(e()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Gr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var Zb={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},lp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Zb),u),d=e(l,h),m=o(l),f=m?r():null,g=c.sampleRate/2;super(c,!1,d,f),this._detune=t(this,m,d.detune,153600,-153600),this._frequency=t(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"){qt(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),ut(this)&&sr(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var hp=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(l,h)=>K(null,null,function*(){let d=e(l),m=fe(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=t(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 Xb={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},dp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Xb),u),d=e(l,h),m=o(l),f=m?r():null;super(c,!1,d,f),this._nativePannerNode=d,this._orientationX=t(this,m,d.orientationX,Ee,Pe),this._orientationY=t(this,m,d.orientationY,Ee,Pe),this._orientationZ=t(this,m,d.orientationZ,Ee,Pe),this._positionX=t(this,m,d.positionX,Ee,Pe),this._positionY=t(this,m,d.positionY,Ee,Pe),this._positionZ=t(this,m,d.positionZ,Ee,Pe),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 pp=(n,t,e,r,i,o,s,a,c,u)=>()=>{let l=new WeakMap,h=null,d=(m,f)=>K(null,null,function*(){let g=null,y=o(m),C={channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation},I=X(D({},C),{coneInnerAngle:y.coneInnerAngle,coneOuterAngle:y.coneOuterAngle,coneOuterGain:y.coneOuterGain,distanceModel:y.distanceModel,maxDistance:y.maxDistance,panningModel:y.panningModel,refDistance:y.refDistance,rolloffFactor:y.rolloffFactor}),S=fe(y,f);if("bufferSize"in y)g=r(f,X(D({},C),{gain:1}));else if(!S){let w=X(D({},I),{orientationX:y.orientationX.value,orientationY:y.orientationY.value,orientationZ:y.orientationZ.value,positionX:y.positionX.value,positionY:y.positionY.value,positionZ:y.positionZ.value});y=i(f,w)}if(l.set(f,g===null?y: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=t(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});M.connect(R.destination),h=K(null,null,function*(){let G=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((k,L)=>K(null,null,function*(){let F=e(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:L===0?1:0});return yield a(R,k,F.offset),F})));for(let k=0;k<6;k+=1)G[k].connect(M,0,k),G[k].start(0);return u(R)})}let w=yield h,v=r(f,X(D({},C),{gain:1}));yield c(m,f,v);let _=[];for(let R=0;R<w.numberOfChannels;R+=1)_.push(w.getChannelData(R));let A=[_[0][0],_[1][0],_[2][0]],x=[_[3][0],_[4][0],_[5][0]],T=r(f,X(D({},C),{gain:1})),E=i(f,X(D({},I),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:x[0],positionY:x[1],positionZ:x[2]}));v.connect(T).connect(E.inputs[0]),E.connect(g);for(let R=128;R<w.length;R+=128){let M=[_[0][R],_[1][R],_[2][R]],G=[_[3][R],_[4][R],_[5][R]];if(M.some((k,L)=>k!==A[L])||G.some((k,L)=>k!==x[L])){A=M,x=G;let k=R/f.sampleRate;T.gain.setValueAtTime(0,k),T=r(f,X(D({},C),{gain:0})),E=i(f,X(D({},I),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:x[0],positionY:x[1],positionZ:x[2]})),T.gain.setValueAtTime(1,k),v.connect(T).connect(E.inputs[0]),E.connect(g)}}return g}return S?(yield n(f,m.orientationX,y.orientationX),yield n(f,m.orientationY,y.orientationY),yield n(f,m.orientationZ,y.orientationZ),yield n(f,m.positionX,y.positionX),yield n(f,m.positionY,y.positionY),yield n(f,m.positionZ,y.positionZ)):(yield a(f,m.orientationX,y.orientationX),yield a(f,m.orientationY,y.orientationY),yield a(f,m.orientationZ,y.orientationZ),yield a(f,m.positionX,y.positionX),yield a(f,m.positionY,y.positionY),yield a(f,m.positionZ,y.positionZ)),Rt(y)?yield c(m,f,y.inputs[0]):yield c(m,f,y),y});return{render(m,f){let g=l.get(f);return g!==void 0?Promise.resolve(g):d(m,f)}}};var Qb={disableNormalization:!1},mp=(n,t,e,r)=>class fp{constructor(o,s){let a=t(o),c=r(D(D({},Qb),s)),u=n(a,c);return e.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===fp.prototype||e.has(o)}};var gp=(n,t)=>(e,r,i)=>(n(r).replay(i),t(r,e,i));var bp=(n,t,e)=>(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 t(u).render(u,i),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&m.connect(o,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var yp=(n,t,e)=>(r,i,o)=>K(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>K(null,[u],function*([a,c]){let h=yield n(a).render(a,i);e(a)||h.connect(o,c)})))});var xp=(n,t,e,r)=>i=>n(Ut,()=>Ut(i))?Promise.resolve(n(r,r)).then(o=>{if(!o){let s=e(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=t(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var Cp=n=>(t,e)=>{n.set(t,e)};var Ap=n=>(t,e)=>n.set(t,e);var _p=(n,t,e,r,i,o,s,a)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(l=>e(l).render(l,u)))).then(()=>i(u)).then(l=>(typeof l.copyFromChannel!="function"?(s(l),Bi(l)):t(o,()=>o(l))||a(l),n.add(l),l));var Kb={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},vp=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=D(D({},Kb),c),h=e(u,l),d=o(u),m=d?r():null;super(a,!1,h,m),this._pan=t(this,d,h.pan)}get pan(){return this._pan}};var Ip=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=fe(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,h)}return o.set(c,u),l?yield n(c,a.pan,u.pan):yield r(c,a.pan,u.pan),Rt(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 Sp=n=>()=>{if(n===null)return!1;try{new n({length:1,sampleRate:44100})}catch(t){return!1}return!0};var wp=(n,t)=>()=>K(null,null,function*(){if(n===null)return!0;if(t===null)return!1;let e=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new t(1,128,44100),i=URL.createObjectURL(e),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 Np=(n,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{e.oncomplete=()=>{r.disconnect(),i(e.currentTime!==0)},e.startRendering()})};var iu=()=>new DOMException("","UnknownError");var Jb={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Tp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=D(D({},Jb),u),d=e(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 t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var Op=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!fe(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),Rt(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Rp=()=>typeof window=="undefined"?null:window;var Mp=(n,t)=>e=>{e.copyFromChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)r[h]=u[h+s]},e.copyToChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)u[h+s]=r[h]}};var Dp=n=>t=>{t.copyFromChannel=(e=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var Ep=n=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),n(t,"buffer",i=>()=>{let o=i.call(t);return o===r?null:o},i=>o=>i.call(t,o===null?r:o))};var kp=(n,t)=>(e,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=e.createBufferSource();t(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(r,0,c)},()=>i.disconnect(r))};var nu=(n,t,e)=>n.copyFromChannel===void 0?n.getChannelData(e)[0]:(n.copyFromChannel(t,e),t[0]);var ou=n=>{if(n===null)return!1;let t=n.length;return t%2!==0?n[Math.floor(t/2)]!==0:n[t/2-1]+n[t/2]!==0};var Ki=(n,t,e,r)=>{let i=n;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:o,set:s}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(n,t,{get:e(o),set:r(s)})};var Lp=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 jp=n=>X(D({},n),{channelCount:n.numberOfOutputs});var Pp=n=>{let{imag:t,real:e}=n;return t===void 0?e===void 0?X(D({},n),{imag:[0,0],real:[0,0]}):X(D({},n),{imag:Array.from(e,()=>0),real:e}):e===void 0?X(D({},n),{imag:t,real:Array.from(t,()=>0)}):X(D({},n),{imag:t,real:e})};var su=(n,t,e)=>{try{n.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;su(n,t,e+1e-7)}};var Fp=n=>{let t=n.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var Bp=n=>{let t=n.createBufferSource(),e=n.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var Gp=n=>{let t=n.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var Ms=n=>{let t=n.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var au=n=>{let t=n.createBuffer(1,1,44100),e=n.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var Ds=n=>{let t=n.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var Vp=n=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(n)}finally{t.close(),e.close()}};var qp=n=>{n.start=(t=>(e=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?t.call(n,e,0,0):t.call(n,e,s,i)})(n.start)};var cu=(n,t)=>{let e=t.createGain();n.connect(e);let r=(i=>()=>{i.call(n,e),n.removeEventListener("ended",r)})(n.disconnect);n.addEventListener("ended",r),Mt(n,e),n.stop=(i=>{let o=!1;return(s=0)=>{if(o)try{i.call(n,s)}catch(a){e.gain.setValueAtTime(0,s)}else i.call(n,s),o=!0}})(n.stop)};var li=(n,t)=>e=>{let r={value:n};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(n,e):t.handleEvent.call(n,e)};var $b=Dl(Wt),ey=ql(Wt),ty=Ph(Fr),Up=new WeakMap,ry=$h(Up),Dt=yh(new Map,new WeakMap),ar=Rp(),zp=Td(Dt,Ot),uu=Jh(Qe),$e=bp(Qe,uu,_r),iy=Yl(zp,ve,$e),we=rd(Pi),vr=ep(ar),Ie=bd(vr),Yp=new WeakMap,Hp=Yh(li),Ji=Dd(ar),lu=pd(Ji),hu=md(ar),Zp=fd(ar),ro=kd(ar),Fe=uh(El(xs),Vl($b,ey,Gi,ty,Vi,Qe,ry,or,ve,Wt,ut,_r,qi),Dt,cd(Jn,Vi,Qe,ve,ci,ut),Ot,Yi,Je,kh(Gi,Jn,Qe,ve,ci,we,ut,Ie),Gh(Yp,Qe,We),Hp,we,lu,hu,Zp,Ie,ro),ny=zl(Fe,iy,Ot,zp,we,Ie);var du=new WeakSet,Wp=Od(ar),Xp=Th(new Uint32Array(1)),pu=Mp(Xp,Ot),mu=Dp(Xp),fu=Hl(du,Dt,Je,Wp,vr,Sp(Wp),pu,mu);var Es=Wl(lt),Qp=yp(uu,Br,_r),cr=vh(Qp),$i=Md(Es,Dt,Fp,Bp,Gp,Ms,au,Ds,qp,Ep(Ki),cu),ur=gp(ed(Br),Qp),oy=Ql(cr,$i,ve,ur,$e),zt=lh(kl(Cs),Yp,Kn,hh,Bc,Gc,Vc,qc,Wc,Ei,Yn,Ji,su),sy=Xl(Fe,oy,zt,Te,$i,we,Ie,li);var ay=nh(Fe,oh,Ot,Te,Ed(lt,Ki),we,Ie,$e),cy=bh(cr,tu,ve,ur,$e),hi=Ap(Up),uy=gh(Fe,zt,cy,Yi,tu,we,Ie,hi),qr=wd(Wt,hu),ly=kp(Te,qr),Wr=Vd(Ji,ly),hy=Ch(Wr,ve,$e),dy=xh(Fe,hy,Wr,we,Ie),py=_h(Xi,ve,$e),my=Ah(Fe,py,Xi,we,Ie,jp),fy=Ud(Es,$i,lt,qr),en=Wd(Es,Dt,fy,Ms,Ds),gy=Nh(cr,en,ve,ur,$e),by=wh(Fe,zt,gy,en,we,Ie,li),Kp=zd(Je,Ki),yy=Rh(Kp,ve,$e),xy=Oh(Fe,yy,Kp,we,Ie,hi),Cy=jh(cr,ru,ve,ur,$e),Ay=Lh(Fe,zt,Cy,ru,we,Ie,hi),Jp=Yd(Je),_y=Wh(cr,Jp,ve,ur,$e),vy=qh(Fe,zt,_y,Jp,Je,we,Ie,hi),Iy=Qh(cr,lt,ve,ur,$e),Sy=Xh(Fe,zt,Iy,lt,we,Ie),wy=Xd(Yi,Te,Qi,Je),ks=xp(Dt,lt,Qi,Np(lt,vr)),Ny=ad($i,ve,vr,$e,ks),Ty=Hd(wy),Oy=sd(Fe,Ty,Ny,we,Ie,hi),Ry=sh(zt,Wr,en,Qi,Je,nu,Ie,Ki),$p=new WeakMap,gu=Id(ay,Ry,Hp,Ie,$p,li),em=tp(Es,Dt,Ms,au,Ds,cu),My=hp(cr,em,ve,ur,$e),Dy=lp(Fe,zt,em,My,we,Ie,li),tm=Sh($i),Ey=cp(tm,Te,lt,ou,qr),Ls=ap(tm,Te,Ey,ou,qr,Ji,Ki),ky=ip(Gi,Te,Wr,lt,Qi,Ls,Je,Vi,nu,qr),rm=rp(ky),Ly=pp(cr,Wr,en,lt,rm,ve,vr,ur,$e,ks),jy=dp(Fe,zt,rm,Ly,we,Ie,hi),Py=np(Ot),Fy=mp(Py,we,new WeakSet,Pp),By=sp(Wr,Xi,lt,Ls,Je,qr),im=op(By,Je),Gy=Ip(cr,im,ve,ur,$e),Vy=vp(Fe,zt,im,Gy,we,Ie),qy=Op(Ls,ve,$e),Wy=Tp(Fe,Te,Ls,qy,we,Ie,hi),nm=yd(ar),bu=Hh(ar),om=new WeakMap,Uy=id(om,vr),zy=nm?Gl(Dt,Je,zh(ar),bu,Zh(Ml),we,Uy,Ie,ro,new WeakMap,new WeakMap,wp(ro,vr),ar):void 0,Yy=gd(lu,Ie),Hy=Eh(du,Dt,Dh,Uh,new WeakSet,we,Yy,Fi,Ut,pu,mu),sm=fh(zy,ny,fu,sy,uy,dy,my,by,xy,Hy,Ay,vy,Sy,Oy,gu,Dy,jy,Fy,Vy,Wy),Zy=xd(Fe,Qd,we,Ie),Xy=Cd(Fe,Kd,we,Ie),Qy=Ad(Fe,Jd,we,Ie),Ky=$d(Te,Ie),Jy=_d(Fe,Ky,we),am=ih(sm,Te,Je,iu,Zy,Xy,Qy,Jy,Ji);var yu=nd($p),$y=Ul(yu),cm=Ih(Ot),ex=Fh(yu),um=Vh(Ot),lm=new WeakMap,tx=Kh(lm,We),rx=Gd(cm,Ot,Te,Wr,Xi,en,lt,Qi,Je,um,bu,tx,qr),ix=jd(Te,rx,lt,Je,qr),nx=mh(cr,cm,$i,Wr,Xi,en,lt,ex,um,bu,ve,ro,vr,ur,$e,ks),ox=td(om),sx=Cp(lm),xu=nm?dh($y,Fe,zt,nx,ix,Qe,ox,we,Ie,ro,Lp,sx,Vp,li):void 0;var vq=vd(Te,Je,iu,gu,Ji);var hm=Mh(Je,vr),dm=_p(du,Dt,uu,yu,ks,Fi,pu,mu),Iq=Sd(Dt,Te,hm,gu,dm);var pm=up(sm,Dt,Te,hm,dm);var mm=ud(Pi,lu),fm=ld(ji,hu),gm=hd(Kn,Zp),bm=dd(Pi,Ie);function Be(n){return n===void 0}function te(n){return n!==void 0}function ym(n){return typeof n=="function"}function et(n){return typeof n=="number"}function Yt(n){return Object.prototype.toString.call(n)==="[object Object]"&&n.constructor===Object}function Cu(n){return typeof n=="boolean"}function Re(n){return Array.isArray(n)}function nt(n){return typeof n=="string"}function io(n){return nt(n)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(n)}function z(n,t){if(!n)throw new Error(t)}function ke(n,t,e=1/0){if(!(t<=n&&n<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${n}`)}function js(n){!n.isOffline&&n.state!=="running"&&di('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Cm=!1,xm=!1;function Au(n){Cm=n}function Am(n){Be(n)&&Cm&&!xm&&(xm=!0,di("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var _m=console;function vm(...n){_m.log(...n)}function di(...n){_m.warn(...n)}function Im(n){return new am(n)}function Sm(n,t,e){return new pm(n,t,e)}var ot=typeof self=="object"?self:null,wm=ot&&(ot.hasOwnProperty("AudioContext")||ot.hasOwnProperty("webkitAudioContext"));function Nm(n,t,e){return z(te(xu),"AudioWorkletNode only works in a secure context (https or localhost)"),new(n instanceof(ot==null?void 0:ot.BaseAudioContext)?ot==null?void 0:ot.AudioWorkletNode:xu)(n,t,e)}function st(n,t,e,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(t,e,o):s(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o}function he(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(h){s(h)}}function c(l){try{u(r.throw(l))}catch(h){s(h)}}function u(l){l.done?o(l.value):i(l.value).then(a,c)}u((r=r.apply(n,t||[])).next())})}var Ps=class{constructor(t,e,r,i){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let t=new Blob([`
|
|
1
|
+
/* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
|
+
"use strict";var WebMusicScore=(()=>{var Os=Object.defineProperty,Xf=Object.defineProperties,$f=Object.getOwnPropertyDescriptor,Qf=Object.getOwnPropertyDescriptors,Kf=Object.getOwnPropertyNames,Ts=Object.getOwnPropertySymbols;var zc=Object.prototype.hasOwnProperty,Eh=Object.prototype.propertyIsEnumerable;var Wc=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),Jf=i=>{throw TypeError(i)},Dh=Math.pow,Uc=(i,t,e)=>t in i?Os(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,O=(i,t)=>{for(var e in t||(t={}))zc.call(t,e)&&Uc(i,e,t[e]);if(Ts)for(var e of Ts(t))Eh.call(t,e)&&Uc(i,e,t[e]);return i},Q=(i,t)=>Xf(i,Qf(t));var Xr=(i,t)=>{var e={};for(var r in i)zc.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&Ts)for(var r of Ts(i))t.indexOf(r)<0&&Eh.call(i,r)&&(e[r]=i[r]);return e};var $i=(i,t)=>{for(var e in t)Os(i,e,{get:t[e],enumerable:!0})},tg=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Kf(t))!zc.call(i,n)&&n!==e&&Os(i,n,{get:()=>t[n],enumerable:!(r=$f(t,n))||r.enumerable});return i};var eg=i=>tg(Os({},"__esModule",{value:!0}),i);var d=(i,t,e)=>Uc(i,typeof t!="symbol"?t+"":t,e);var J=(i,t,e)=>new Promise((r,n)=>{var o=c=>{try{a(e.next(c))}catch(u){n(u)}},s=c=>{try{a(e.throw(c))}catch(u){n(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((e=e.apply(i,t)).next())}),rg=function(i,t){this[0]=i,this[1]=t};var be=i=>{var t=i[Wc("asyncIterator")],e=!1,r,n={};return t==null?(t=i[Wc("iterator")](),r=o=>n[o]=s=>t[o](s)):(t=t.call(i),r=o=>n[o]=s=>{if(e){if(e=!1,o==="throw")throw s;return s}return e=!0,{done:!1,value:new rg(new Promise(a=>{var c=t[o](s);c instanceof Object||Jf("Object expected"),a(c)}),1)}}),n[Wc("iterator")]=()=>n,r("next"),"throw"in t?r("throw"):n.throw=o=>{throw o},"return"in t&&r("return"),n};var Ov={};$i(Ov,{Audio:()=>Po,Core:()=>eu,Pieces:()=>Mh,Score:()=>Rh,Theory:()=>lu});var Po={};$i(Po,{addInstrument:()=>X_,getCurrentInstrument:()=>Z_,getInstrumentList:()=>H_,isMuted:()=>K_,linearToDecibels:()=>Zs,mute:()=>$_,playNote:()=>Ba,stop:()=>Ga,unmute:()=>Q_,useInstrument:()=>Lf});var lu={};$i(lu,{AccidentalType:()=>iu,BeamGrouping:()=>Ii,Chord:()=>nu,DefaultGuitarNoteLabel:()=>iA,DefaultHandedness:()=>RA,DefaultPitchNotation:()=>eA,DefaultTuningName:()=>EA,GuitarNoteLabel:()=>Gs,GuitarNoteLabelList:()=>nA,Handedness:()=>su,Interval:()=>co,KeySignature:()=>tr,Mode:()=>ru,Note:()=>W,NoteLength:()=>er,NoteLengthProps:()=>Tt,PitchNotation:()=>Jr,PitchNotationList:()=>tA,RhythmProps:()=>Xt,Scale:()=>ei,ScaleFactory:()=>ee,ScaleType:()=>_i,SymbolSet:()=>Kr,TimeSignature:()=>ri,TimeSignatures:()=>lo,TuningNameList:()=>ho,Tuplet:()=>jr,alterTempoSpeed:()=>hu,getDefaultKeySignature:()=>Vs,getDefaultScale:()=>CA,getDefaultTempo:()=>Ys,getDefaultTimeSignature:()=>zs,getPitchNotationName:()=>rA,getScale:()=>Dr,getScaleFactory:()=>pl,getScaleFactoryList:()=>xA,getTempoString:()=>Hs,getTuningStrings:()=>Ws,isNoteLength:()=>rr,isTupletRatio:()=>Us,validateGuitarNoteLabel:()=>oA,validateHandedness:()=>MA,validateIntervalQuality:()=>mA,validateNoteLength:()=>Lr,validatePitchNotation:()=>nl,validateScaleType:()=>uo,validateTuningName:()=>au,validateTupletRatio:()=>gl});var kh=Object.defineProperty,ig=(i,t,e)=>t in i?kh(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Je=(i,t)=>{for(var e in t)kh(i,e,{get:t[e],enumerable:!0})},gt=(i,t,e)=>ig(i,typeof t!="symbol"?t+"":t,e),Lh={};Je(Lh,{assert:()=>vy,doesNotThrow:()=>Ub,doesThrow:()=>Wb,fail:()=>Ny,isArray:()=>Gy,isArrayOrUndefined:()=>Vy,isBigInt:()=>ub,isBoolean:()=>Ky,isBooleanOrUndefined:()=>Jy,isDeepEqual:()=>Oy,isDefined:()=>Dy,isEmptyArray:()=>qy,isEmptyArrayOrUndefined:()=>Uy,isEmptyObject:()=>jy,isEmptyString:()=>Hy,isEmptyStringOrUndefined:()=>$y,isEnumValue:()=>sb,isEnumValueOrUndefined:()=>ab,isEven:()=>Fb,isFalse:()=>rb,isFalseOrUndefined:()=>ib,isFinite:()=>db,isFloat:()=>pb,isFunction:()=>nb,isFunctionOrUndefined:()=>ob,isIncluded:()=>Vb,isIndex:()=>qb,isInfinity:()=>Nb,isInteger:()=>mb,isIntegerBetween:()=>_b,isIntegerBetweenExclusive:()=>vb,isIntegerEq:()=>yb,isIntegerGt:()=>bb,isIntegerGte:()=>xb,isIntegerLt:()=>Ab,isIntegerLte:()=>Cb,isIntegerOrUndefined:()=>gb,isMultipleOf:()=>Bb,isNaNValue:()=>wb,isNeg:()=>Mb,isNegInfinity:()=>Ob,isNegZero:()=>jb,isNonEmptyArray:()=>Wy,isNonEmptyArrayOrUndefined:()=>zy,isNonEmptyString:()=>Zy,isNonEmptyStringOrUndefined:()=>Qy,isNonNeg:()=>Db,isNonNull:()=>ky,isNonPos:()=>Eb,isNull:()=>My,isNullish:()=>Ey,isNumber:()=>hb,isNumberBetween:()=>Ib,isNumberBetweenExclusive:()=>Sb,isNumberOrUndefined:()=>lb,isNumericString:()=>cb,isObject:()=>Ly,isObjectOrUndefined:()=>Fy,isOdd:()=>Pb,isPlainObject:()=>Py,isPos:()=>Rb,isPosInfinity:()=>Tb,isPosZero:()=>Lb,isPowerOfTwo:()=>Gb,isSafeInteger:()=>fb,isStrictEqual:()=>Ty,isString:()=>Yy,isStringOrUndefined:()=>Xy,isTrue:()=>tb,isTrueOrUndefined:()=>eb,isTypedObject:()=>By,isUndefined:()=>Ry,isZero:()=>kb,require:()=>Iy,requireDefined:()=>Sy,requireElement:()=>wy,setErrorClass:()=>_y});var jh={};Je(jh,{charCount:()=>Ay,chunkString:()=>yy,insertAt:()=>by,isString:()=>Gh,makeSentenceFromPascal:()=>Cy,removeAt:()=>xy,repeatString:()=>gy,replaceAt:()=>$c,stringify:()=>Zt,toCharArray:()=>fy});var Ph={};Je(Ph,{deepEqual:()=>Es,getCtorName:()=>Wh,hasProperties:()=>my,isObject:()=>Ai});var y={};Je(y,{doesNotThrow:()=>dy,doesThrow:()=>ly,isArray:()=>ke,isArrayOrUndefined:()=>yg,isBigInt:()=>Pg,isBoolean:()=>Ng,isBooleanOrUndefined:()=>Tg,isDeepEqual:()=>so,isDefined:()=>hg,isEmptyArray:()=>bg,isEmptyArrayOrUndefined:()=>Ag,isEmptyObject:()=>dg,isEmptyString:()=>_g,isEmptyStringOrUndefined:()=>Sg,isEnumValue:()=>kg,isEnumValueOrUndefined:()=>Lg,isEven:()=>sy,isFalse:()=>Mg,isFalseOrUndefined:()=>Eg,isFinite:()=>Qi,isFloat:()=>Bg,isFunction:()=>Er,isFunctionOrUndefined:()=>Dg,isIncluded:()=>uy,isIndex:()=>hy,isInfinity:()=>Xg,isInteger:()=>Et,isIntegerBetween:()=>Vh,isIntegerBetweenExclusive:()=>Yg,isIntegerEq:()=>qg,isIntegerGt:()=>Wg,isIntegerGte:()=>Xc,isIntegerLt:()=>Ug,isIntegerLte:()=>zg,isIntegerOrUndefined:()=>Vg,isMultipleOf:()=>ay,isNaNValue:()=>qh,isNeg:()=>Jg,isNegInfinity:()=>Qg,isNegZero:()=>ny,isNonEmptyArray:()=>xg,isNonEmptyArrayOrUndefined:()=>Cg,isNonEmptyString:()=>vg,isNonEmptyStringOrUndefined:()=>wg,isNonNeg:()=>ey,isNonNull:()=>lg,isNonPos:()=>ty,isNull:()=>cg,isNullish:()=>ug,isNumber:()=>le,isNumberBetween:()=>Hg,isNumberBetweenExclusive:()=>Zg,isNumberOrUndefined:()=>Fg,isNumericString:()=>jg,isObject:()=>Ai,isObjectOrUndefined:()=>pg,isOdd:()=>oy,isPlainObject:()=>mg,isPos:()=>Kg,isPosInfinity:()=>$g,isPosZero:()=>iy,isPowerOfTwo:()=>cy,isSafeInteger:()=>Gg,isStrictEqual:()=>sg,isString:()=>Gh,isStringOrUndefined:()=>Ig,isTrue:()=>Og,isTrueOrUndefined:()=>Rg,isTypedObject:()=>fg,isUndefined:()=>ag,isZero:()=>ry,tryOr:()=>py});var Fh={};Je(Fh,{forEachEnum:()=>og,getEnumEntries:()=>Bh,getEnumKey:()=>ng,getEnumKeys:()=>Ds,getEnumValues:()=>Zc});function Ds(i){return Object.keys(i).filter(t=>isNaN(Number(t)))}function Zc(i){return Ds(i).map(t=>i[t])}function Bh(i){return Ds(i).map(t=>[t,i[t]])}function ng(i,t){return Ds(i).find(e=>i[e]===t)}function og(i,t){for(let[e,r]of Bh(i))t(e,r)}function sg(i,t){return i===t}function so(i,t){return Es(i,t)}function ag(i){return i===void 0}function cg(i){return i===null}function ug(i){return i==null}function hg(i){return i!==void 0}function lg(i){return i!==null}function Ai(i){return typeof i=="object"&&i!==null&&!ke(i)}function dg(i){return Ai(i)&&Object.keys(i).length===0}function pg(i){return i===void 0||Ai(i)}function mg(i){if(!Ai(i))return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function fg(i,t){return Ai(i)&&t.every(e=>e in i)}function gg(i){return i instanceof Set}function ke(i){return!!i&&Object.prototype.toString.call(i)==="[object Array]"}function yg(i){return i===void 0||ke(i)}function bg(i){return ke(i)&&i.length===0}function xg(i){return ke(i)&&i.length>0}function Ag(i){return ke(i)&&i.length===0||i===void 0}function Cg(i){return ke(i)&&i.length>0||i===void 0}function Gh(i){return typeof i=="string"}function _g(i){return typeof i=="string"&&i.length===0}function vg(i){return typeof i=="string"&&i.length>0}function Ig(i){return i===void 0||typeof i=="string"}function Sg(i){return typeof i=="string"&&i.length===0||i===void 0}function wg(i){return typeof i=="string"&&i.length>0||i===void 0}function Ng(i){return typeof i=="boolean"}function Tg(i){return i===void 0||typeof i=="boolean"}function Og(i){return i===!0}function Rg(i){return i===!0||i===void 0}function Mg(i){return i===!1}function Eg(i){return i===!1||i===void 0}function Er(i){return typeof i=="function"}function Dg(i){return i===void 0||typeof i=="function"}function kg(i,t){return Zc(t).some(e=>e===i)}function Lg(i,t){return i===void 0||Zc(t).some(e=>e===i)}function jg(i){if(typeof i!="string"||i.trim()==="")return!1;let t=+i;return Number.isFinite(t)}function Pg(i){return typeof i=="bigint"}function le(i){return typeof i=="number"}function Fg(i){return typeof i=="number"||i===void 0}function Qi(i){return typeof i=="number"&&Number.isFinite(i)}function Bg(i){return Qi(i)&&!Et(i)}function Et(i){return typeof i=="number"&&Qi(i)&&i===Math.trunc(i)}function Gg(i){return Et(i)&&Number.isSafeInteger(i)}function Vg(i){return typeof i=="number"&&Qi(i)&&i===Math.trunc(i)||i===void 0}function qg(i,t){return Et(i)&&i===t}function Wg(i,t){return Et(i)&&le(t)&&i>t}function Xc(i,t){return Et(i)&&le(t)&&i>=t}function Ug(i,t){return Et(i)&&le(t)&&i<t}function zg(i,t){return Et(i)&&le(t)&&i<=t}function Vh(i,t,e){return Et(i)&&le(t)&&le(e)&&i>=t&&i<=e}function Yg(i,t,e){return Et(i)&&le(t)&&le(e)&&i>t&&i<e}function Hg(i,t,e){return le(i)&&le(t)&&le(e)&&i>=t&&i<=e}function Zg(i,t,e){return le(i)&&le(t)&&le(e)&&i>t&&i<e}function qh(i){return typeof i=="number"&&Number.isNaN(i)}function Xg(i){return i===1/0||i===-1/0}function $g(i){return i===1/0}function Qg(i){return i===-1/0}function Kg(i){return typeof i=="number"&&i>0}function Jg(i){return typeof i=="number"&&i<0}function ty(i){return typeof i=="number"&&i<=0}function ey(i){return typeof i=="number"&&i>=0}function ry(i){return typeof i=="number"&&i===0}function iy(i){return typeof i=="number"&&i===0&&1/i===1/0}function ny(i){return typeof i=="number"&&i===0&&1/i===-1/0}function oy(i){return Et(i)&&Math.abs(i)%2===1}function sy(i){return Et(i)&&i%2===0}function ay(i,t){return typeof i=="number"&&typeof t=="number"&&i%t===0}function cy(i){return Et(i)&&i>0&&(i&i-1)===0}function uy(i,t){return ke(t)?t.includes(i):gg(t)?t.has(i):!1}function hy(i,t){return ke(t)?Vh(i,0,t.length-1):Xc(i,0)}function ly(i){try{return i(),!1}catch(t){return!0}}function dy(i){try{return i(),!0}catch(t){return!1}}function py(i,t){try{return i()}catch(e){return Er(t)?t():t}}function my(i,t){return Ai(i)&&t.every(e=>e in i)}function Es(i,t){if(i===t)return!0;if(i===null||t===null||typeof i!="object"||typeof t!="object")return!1;if(Array.isArray(i)&&Array.isArray(t))return i.length!==t.length?!1:i.every((n,o)=>Es(n,t[o]));if(Array.isArray(i)!==Array.isArray(t))return!1;let e=Object.keys(i),r=Object.keys(t);if(e.length!==r.length)return!1;for(let n of e)if(!Object.prototype.hasOwnProperty.call(t,n)||!Es(i[n],t[n]))return!1;return!0}function Wh(i){return i===null?"null":ke(i)?"Array":typeof i!="object"?typeof i:Object.prototype.toString.call(i).slice(8,-1)||"Object"}function fy(i){return i.split("")}function gy(i,t){if(!Et(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(i)}function yy(i,t){if(!Et(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e}function $c(i,t,e,r){if(!Et(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!Et(t)||t<0||t+e>i.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+i.length);return i.substring(0,t)+r+i.substring(t+e)}function by(i,t,e){return $c(i,t,0,e)}function xy(i,t,e){return $c(i,t,e,"")}function Ay(i,t){if(t.length!==1||i.length===0)return 0;let e=0;for(let r=0;r<i.length;r++)i[r]===t&&e++;return e}function Cy(i){if(i==="")return"";let t=i.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},n=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<i.length;o++){let s=i.charAt(o);n(s)&&r(),t+=s.toLowerCase()}return r(),e}function Zt(i,t=5,e=new WeakSet){if(i===null)return"null";if(i===void 0)return"undefined";let r=typeof i;switch(r){case"boolean":return i?"true":"false";case"number":return qh(i)?"NaN":Qi(i)?i.toString():i<0?"-Infinity":"Infinity";case"bigint":return`${i}n`;case"string":return`"${i}"`;case"symbol":return i.description?`Symbol(${i.description})`:"Symbol()";case"function":return`[Function${i.name?` ${i.name}`:""}]`}if(e.has(i))return"[Circular]";if(t<=0)return"[Depth limit]";t--,e.add(i);let n=s=>Zt(s,t,e);if(ke(i)){let s=i.map(a=>n(a)).join(", ");return s.length===0?"[ ]":`[ ${s} ]`}if(ArrayBuffer.isView(i)){if(i instanceof DataView)return`DataView(${i.byteLength})`;let s=Array.from(i).map(a=>n(a)).join(", ");return`${i.constructor.name}[ ${s} ]`}if(i instanceof ArrayBuffer)return`ArrayBuffer(${i.byteLength})`;if(i instanceof Map){let s=Array.from(i.entries()).map(([a,c])=>`${n(a)} => ${n(c)}`).join(", ");return s.length===0?`Map(${i.size}){ }`:`Map(${i.size}){ ${s} }`}if(i instanceof Set){let s=Array.from(i.values()).map(a=>n(a)).join(", ");return s.length===0?`Set(${i.size}){ }`:`Set(${i.size}){ ${s} }`}if(i instanceof WeakMap)return"WeakMap{ ? }";if(i instanceof WeakSet)return"WeakSet{ ? }";if(i instanceof Date)return`Date("${i.toISOString()}")`;if(i instanceof RegExp)return i.toString();if(i instanceof Error)return`${i.name}("${i.message}")`;if(i instanceof Promise)return"Promise{ ? }";if(i instanceof URL)return`URL("${i.href}")`;if(i instanceof URLSearchParams)return`URLSearchParams("${i.toString()}")`;if(i===Math)return"Math";if(i===JSON)return"JSON";if(i===Reflect)return"Reflect";if(i===Intl)return"Intl";if(typeof(i==null?void 0:i.toString)=="function"&&i.toString!==Object.prototype.toString)try{let s=i.toString();if(!/^\[object .+\]$/.test(s))return s}catch(s){}if(r==="object"){let s=Wh(i),a=Object.entries(i).map(([c,u])=>`${n(c)}: ${n(u)}`);return a.length===0?`${s}{ }`:`${s}{ ${a.join(", ")} }`}return String(i)}var F=Zt,Uh=Error;function _y(i){Uh=i!=null?i:Error}function z(...i){let t=i.join(", ");throw new Uh("Assertion Failed!"+(t===""?"":" "+t))}function vy(i,t){i||z(t)}function Iy(i,t){return i==null&&z(`Expected ${F(i)} not to be nullish`,t),i}function Sy(i,t){return i===void 0&&z(`Expected ${F(i)} not to be undefined`,t),i}function wy(i,t,e){return y.isIndex(i,t)||z(`Expected ${i} to be index for array ${F(t)}`,e),t[i]}function Ny(i){z(i)}function Ty(i,t,e){return y.isStrictEqual(i,t)||z(`Expected ${F(i)} to ne strict equal to ${t}`,e),i}function Oy(i,t,e){return y.isDeepEqual(i,t)||z(`Expected ${F(i)} to deep equal with ${F(t)}`,e),i}function Ry(i,t){return y.isUndefined(i)||z(`Expected ${F(i)} to be undefined`,t),i}function My(i,t){return y.isNull(i)||z(`Expected ${F(i)} to be null`,t),i}function Ey(i,t){return y.isNullish(i)||z(`Expected ${F(i)} to be null or undefined`,t),i}function Dy(i,t){return y.isDefined(i)||z(`Expected ${F(i)} to be defined`,t),i}function ky(i,t){return y.isNonNull(i)||z(`Expected ${F(i)} to be defined`,t),i}function Ly(i,t){return y.isObject(i)||z(`Expected ${F(i)} to be object`,t),i}function jy(i,t){return y.isEmptyObject(i)||z(`Expected ${F(i)} to be empty object`,t),i}function Py(i,t){return y.isPlainObject(i)||z(`Expected ${F(i)} to be plain object`,t),i}function Fy(i,t){return y.isObjectOrUndefined(i)||z(`Expected ${F(i)} to be object or undefined`,t),i}function By(i,t,e){return y.isTypedObject(i,t)||z(`Expected ${F(i)} to have keys ${F(t)}`,e),i}function Gy(i,t){return y.isArray(i)||z(`Expected ${F(i)} to be array`,t),i}function Vy(i,t){return y.isArrayOrUndefined(i)||z(`Expected ${F(i)} to be array or undefined`,t),!0}function qy(i,t){y.isEmptyArray(i)||z(`Expected ${F(i)} to be empty array`,t)}function Wy(i,t){y.isNonEmptyArray(i)||z(`Expected ${F(i)} to be non-empty array`,t)}function Uy(i,t){y.isEmptyArrayOrUndefined(i)||z(`Expected ${F(i)} to be empty array or undefined`,t)}function zy(i,t){y.isNonEmptyArrayOrUndefined(i)||z(`Expected ${F(i)} to be non-empty array or undefined`,t)}function Yy(i,t){return y.isString(i)||z(`Expected ${F(i)} to be string`,t),i}function Hy(i,t){return y.isEmptyString(i)||z(`Expected ${F(i)} to be empty string`,t),i}function Zy(i,t){return y.isNonEmptyString(i)||z(`Expected ${F(i)} to be non-empty string`,t),i}function Xy(i,t){return y.isStringOrUndefined(i)||z(`Expected ${F(i)} to be string or undefined`,t),i}function $y(i,t){return y.isEmptyStringOrUndefined(i)||z(`Expected ${F(i)} to be empty string or undefined`,t),i}function Qy(i,t){return y.isNonEmptyStringOrUndefined(i)||z(`Expected ${F(i)} to be non-empty string or undefined`,t),i}function Ky(i,t){return y.isBoolean(i)||z(`Expected ${F(i)} to be boolean`,t),i}function Jy(i,t){return y.isBooleanOrUndefined(i)||z(`Expected ${F(i)} to be boolean or undefined`,t),i}function tb(i,t){return y.isTrue(i)||z(`Expected ${F(i)} to be true`,t),i}function eb(i,t){return y.isTrueOrUndefined(i)||z(`Expected ${F(i)} to be true or undefined`,t),i}function rb(i,t){return y.isFalse(i)||z(`Expected ${F(i)} to be false`,t),i}function ib(i,t){return y.isFalseOrUndefined(i)||z(`Expected ${F(i)} to be false or undefined`,t),i}function nb(i,t){return y.isFunction(i)||z(`Expected ${F(i)} to be function`,t),i}function ob(i,t){return y.isFunctionOrUndefined(i)||z(`Expected ${F(i)} to be function or undefined`,t),i}function sb(i,t,e){return y.isEnumValue(i,t)||z(`Expected ${F(i)} to be enum val`,e),i}function ab(i,t,e){return y.isEnumValueOrUndefined(i,t)||z(`Expected ${F(i)} to be enum val or undefined`,e),i}function cb(i,t){return y.isNumericString(i)||z(`Expected ${F(i)} to be numeric string`,t),i}function ub(i,t){return y.isBigInt(i)||z(`Expected ${F(i)} to be BigInt`,t),i}function hb(i,t){return y.isNumber(i)||z(`Expected ${F(i)} to be number`,t),i}function lb(i,t){return y.isNumberOrUndefined(i)||z(`Expected ${F(i)} to be number or undefined`,t),i}function db(i,t){return y.isFinite(i)||z(`Expected ${F(i)} to be finite`,t),i}function pb(i,t){return y.isFloat(i)||z(`Expected ${F(i)} to be float`,t),i}function mb(i,t){return y.isInteger(i)||z(`Expected ${F(i)} to be integer`,t),i}function fb(i,t){return y.isSafeInteger(i)||z(`Expected ${F(i)} to be safe integer`,t),i}function gb(i,t){return y.isIntegerOrUndefined(i)||z(`Expected ${F(i)} to be integer or undefined`,t),i}function yb(i,t,e){return y.isIntegerEq(i,t)||z(`Expected ${F(i)} to be integer equal to ${F(t)}`,e),i}function bb(i,t,e){return y.isIntegerGt(i,t)||z(`Expected ${F(i)} to be integer > ${F(t)}`,e),i}function xb(i,t,e){return y.isIntegerGte(i,t)||z(`Expected ${F(i)} to be integer >= ${F(t)}`,e),i}function Ab(i,t,e){return y.isIntegerLt(i,t)||z(`Expected ${F(i)} to be integer < ${F(t)}`,e),i}function Cb(i,t,e){return y.isIntegerLte(i,t)||z(`Expected ${F(i)} to be integer <= ${F(t)}`,e),i}function _b(i,t,e,r){return y.isIntegerBetween(i,t,e)||z(`Expected integer ${F(t)} <= ${F(i)} <= ${F(e)}`,r),i}function vb(i,t,e,r){return y.isIntegerBetweenExclusive(i,t,e)||z(`Expected integer ${F(t)} < ${F(i)} < ${F(e)}`,r),i}function Ib(i,t,e,r){return y.isNumberBetween(i,t,e)||z(`Expected number ${F(t)} <= ${F(i)} <= ${F(e)}`,r),i}function Sb(i,t,e,r){return y.isNumberBetweenExclusive(i,t,e)||z(`Expected number ${F(t)} < ${F(i)} < ${F(e)}`,r),i}function wb(i,t){return y.isNaNValue(i)||z(`Expected ${F(i)} to be NaN`,t),NaN}function Nb(i,t){return y.isInfinity(i)||z(`Expected ${F(i)} to be +-Infinity`,t),i}function Tb(i,t){return y.isPosInfinity(i)||z(`Expected ${F(i)} to be +Infinity`,t),i}function Ob(i,t){return y.isNegInfinity(i)||z(`Expected ${F(i)} to be -Infinity`,t),i}function Rb(i,t){return y.isPos(i)||z(`Expected ${F(i)} to be positive (> 0)`,t),i}function Mb(i,t){return y.isNeg(i)||z(`Expected ${F(i)} to be negative (< 0)`,t),i}function Eb(i,t){return y.isNonPos(i)||z(`Expected ${F(i)} to be non-positive (<= 0)`,t),i}function Db(i,t){return y.isNonNeg(i)||z(`Expected ${F(i)} to be non-negative (>= 0)`,t),i}function kb(i,t){return y.isZero(i)||z(`Expected ${F(i)} to be 0`,t),i}function Lb(i,t){return y.isPosZero(i)||z(`Expected ${F(i)} to be +0`,t),i}function jb(i,t){return y.isNegZero(i)||z(`Expected ${F(i)} to be -0`,t),i}function Pb(i,t){return y.isOdd(i)||z(`Expected ${F(i)} to odd`,t),i}function Fb(i,t){return y.isEven(i)||z(`Expected ${F(i)} to even`,t),i}function Bb(i,t,e){return y.isMultipleOf(i,t)||z(`Expected ${F(i)} to be divisble bu ${F(t)}`,e),i}function Gb(i,t){return y.isPowerOfTwo(i)||z(`Expected ${F(i)} to be power of two`,t),i}function Vb(i,t,e){return y.isIncluded(i,t)||z(`Expected ${F(i)} to be included in ${F(t)}`,e),i}function qb(...i){let t=i.shift(),e=y.isString(i[i.length-1])?i.pop():void 0,r=y.isArray(i[0])?i.shift():void 0;return y.isIndex(t,r)||z(r===void 0?`Expected ${t} to be index`:`Expected ${t} to be index for ${F(r)}`,e),t}function Wb(i,t){return y.doesThrow(i)||z("Expected to throw",t),!0}function Ub(i,t){return y.doesNotThrow(i)||z("Expected to throw",t),!0}var zb={};Je(zb,{accept:()=>$b,decline:()=>Qb,erase:()=>zh,eraseAll:()=>rx,isConsentPending:()=>Xb,read:()=>Jb,readBool:()=>ex,readInt:()=>tx,save:()=>Kb,setExpireDays:()=>Zb});var ks="ConsentCookie",Ke,oo,Yc=Ls(ks);Ke=Yc==="accept"||Yc==="decline"?Yc:void 0;function Yb(){return document.cookie.split(";").map(t=>t.trim())}function Qc(i,t){let e=i+"="+t.toString()+";sameSite=Lax;";return oo&&(e+="expires="+oo.toUTCString()+";"),document.cookie=e,t}function Ls(i,t){let e=Yb().find(r=>r.startsWith(i+"="));return e===void 0?t:e.substring(i.length+1)}function Hb(i){document.cookie=i+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function Zb(i){oo=new Date,oo.setDate(oo.getDate()+i)}function Xb(){return Ke===void 0}function $b(){Ke="accept",Qc(ks,Ke)}function Qb(){Ke="decline",Qc(ks,Ke)}function Kb(i,t){return Ke==="accept"&&Qc(i,t),t}function Jb(i,t){var e;return Ke==="accept"&&(e=Ls(i,t))!=null?e:t}function tx(i,t){if(Ke==="accept"){let e=Ls(i);return e===void 0?t:parseInt(e)}else return t}function ex(i,t){if(Ke==="accept"){let e=Ls(i);return e===void 0?t:/true|1/i.test(e)}else return t}function zh(i){(Ke==="accept"||i===ks)&&Hb(i)}function rx(){document.cookie.split(";").forEach(i=>zh(i.trim().split("=")[0]))}var js={};Je(js,{DPI:()=>Yh,FontSize:()=>Hh,HostAddress:()=>mx,IsMobileDevice:()=>px,IsTouchDevice:()=>dx,PxPerMm:()=>Kc,ScrollbarWidth:()=>lx,mmToPx:()=>Rs,pxToMm:()=>fx,toPx:()=>gx});function ix(){let i=document.createElement("div");i.style.width="1in",document.body.appendChild(i);let t=i.offsetWidth;return i.remove(),t||96}function nx(){try{let i=document.createElement("div");i.style.visibility="hidden",i.style.width="100px",document.body.appendChild(i);let t=i.offsetWidth;i.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",i.appendChild(e);let r=e.offsetWidth;return i.parentNode&&i.parentNode.removeChild(i),t-r}catch(i){return 0}}function ox(){let i=document.createElement("div");i.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",i.appendChild(document.createTextNode("M")),document.body.appendChild(i);let t=i.offsetHeight;return document.body.removeChild(i),t}function sx(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var i=" -webkit- -moz- -o- -ms- ".split(" "),t=function(r){return window.matchMedia(r).matches},e=["(",i.join("touch-enabled),("),"heartz",")"].join("");return t(e)}function ax(){let i=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(i)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(i.substr(0,4))}function cx(){return location.protocol+"//"+location.host}var ux=/^(mm|cm|in|inch|px|em)$/,hx=/^([0-9\\.]+)(.*)$/,Yh=ix(),Kc=Yh/25.4,lx=nx(),Hh=ox(),dx=sx(),px=ax(),mx=cx();function fx(i){return i/Kc}function Rs(i){return i*Kc}function gx(i){if(typeof i=="number")return i;let t=NaN,e,r=i.toString().match(hx);if(r&&r[1]){t=parseFloat(r[1]);let n=r[2]?r[2].toLowerCase():"undefined";e=ux.test(n)?n:void 0,e||console.log("Unknown unit '"+n+"' => using 'px'.")}else t=parseFloat(i);switch(Lh.isFinite(t,"value in function toPx"),e){case"mm":return Rs(t);case"cm":return Rs(t)*10;case"in":case"inch":return Rs(t)*25.4;case"em":return Hh*t;default:case"px":return t}}var H={};Je(H,{Arr:()=>Zh,Dom:()=>Qh,Enum:()=>Fh,Math:()=>Kh,Obj:()=>Ph,Str:()=>jh});var Zh={};Je(Zh,{arrayContains:()=>vx,chunckArray:()=>Ix,duplicate:()=>bx,fillArray:()=>Ax,getRangeArray:()=>_x,getSequenceArray:()=>Cx,isArray:()=>ke,mapRangeArray:()=>$h,mapSequenceArray:()=>Xh,removeDuplicates:()=>xx,toArray:()=>yx});function yx(i){return ke(i)?i:[i]}function bx(i){var t;return(t=i==null?void 0:i.slice())!=null?t:[]}function xx(i,t){return t!==void 0?i.filter((e,r,n)=>r===n.findIndex(o=>t(e,o))):i.filter((e,r,n)=>r===n.indexOf(e))}function Ax(i,t){if(!Et(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(i)}function Xh(i,t){if(!Et(i)||i<0)throw new Error("mapSequenceArray: Invalid len = "+i);let e=new Array(i);for(let r=0;r<i;r++)e[r]=t(r);return e}function Cx(i){return Xh(i,t=>t)}function $h(i,t,e){if(!Et(i))throw new Error("mapRangeArray: Invalid start = "+t);if(!Et(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-i)+1,n=new Array(r);for(let o=0,s=i,a=Math.sign(t-i);o<r;s+=a,o++)n[o]=e(s);return n}function _x(i,t){return $h(i,t,e=>e)}function vx(i,t){return i.indexOf(t)>=0}function Ix(i,t){if(!Et(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<i.length;r+=t)e.push(i.slice(r,r+t));return e}var Qh={};Je(Qh,{addClass:()=>Sx,appendTo:()=>Dx,getButton:()=>Px,getCanvas:()=>Fx,getCanvasTextWidth:()=>qx,getDimension:()=>Gx,getHeight:()=>Mx,getOffset:()=>Tx,getPadding:()=>Bx,getWidth:()=>Ox,hasClass:()=>Jc,removeClass:()=>wx,removeFromParent:()=>kx,setHeight:()=>Ex,setOffset:()=>Nx,setRect:()=>jx,setVisibility:()=>Lx,setWidth:()=>Rx,styleLayoutChanged:()=>Vx});function Mt(i){return i===void 0?void 0:js.toPx(i)}function Jc(i,t){return t.length===0?!1:i.classList?i.classList.contains(t):!!i.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function Sx(i,t){t.length!==0&&(i.classList?i.classList.add(t):Jc(i,t)||(i.className+=" "+t))}function wx(i,t){if(t.length!==0){if(i.classList)i.classList.remove(t);else if(Jc(i,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");i.className=i.className.replace(e," ")}}}function Nx(i,t,e,r="px"){i.style.left=t+r,i.style.top=e+r}function Tx(i){let t=i.getBoundingClientRect(),e=document.documentElement;return{top:t.top+window.pageYOffset-e.clientTop,left:t.left+window.pageXOffset-e.clientLeft}}function Ox(i){if(i instanceof Window)return i.innerWidth;{let t=parseFloat(getComputedStyle(i,null).width.replace("px",""));return isNaN(t)?0:t}}function Rx(i,t){i.style.width=t+"px"}function Mx(i){if(i instanceof Window)return i.innerHeight;{let t=parseFloat(getComputedStyle(i,null).height.replace("px",""));return isNaN(t)?0:t}}function Ex(i,t){i.style.height=t+"px"}function Dx(i,t){t.appendChild(i)}function kx(i){i.remove()}function Lx(i,t){i.style.display=t?"block":"none"}function jx(i,t,e,r,n,o="px"){i.style.left=t+o,i.style.top=e+o,i.style.width=r+o,i.style.height=n+o}function Px(i){let t=typeof i=="string"?document.getElementById(i):i;return t instanceof HTMLButtonElement?t:void 0}function Fx(i){let t=typeof i=="string"?document.getElementById(i):i;return t instanceof HTMLCanvasElement?t:void 0}function Bx(i){var s;if(!i)return{top:0,right:0,bottom:0,left:0};let t=Mt(i.paddingTop),e=Mt(i.paddingRight),r=Mt(i.paddingBottom),n=Mt(i.paddingLeft),o=((s=i.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:t!=null||(t=Mt(o[0])),e!=null||(e=Mt(o[0])),r!=null||(r=Mt(o[0])),n!=null||(n=Mt(o[0]));break;case 2:t!=null||(t=Mt(o[0])),e!=null||(e=Mt(o[1])),r!=null||(r=Mt(o[0])),n!=null||(n=Mt(o[1]));break;case 3:t!=null||(t=Mt(o[0])),e!=null||(e=Mt(o[1])),r!=null||(r=Mt(o[2])),n!=null||(n=Mt(o[1]));break;case 4:default:t!=null||(t=Mt(o[0])),e!=null||(e=Mt(o[1])),r!=null||(r=Mt(o[2])),n!=null||(n=Mt(o[3]));break}return t!=null||(t=0),e!=null||(e=0),r!=null||(r=0),n!=null||(n=0),{top:t,right:e,bottom:r,left:n}}function Gx(i){let t=Mt(i==null?void 0:i.left),e=Mt(i==null?void 0:i.right),r=Mt(i==null?void 0:i.top),n=Mt(i==null?void 0:i.bottom),o=Mt(i==null?void 0:i.width),s=Mt(i==null?void 0:i.height);return o===void 0&&t!==void 0&&e!==void 0&&(o=e-t),s===void 0&&r!==void 0&&n!==void 0&&(s=n-r),{left:t,top:r,width:o,height:s}}function Vx(i,t){return!i&&!t?!1:!i||!t?!0:i.left!==t.left||i.top!==t.top||i.right!==t.right||i.bottom!==t.bottom||i.width!==t.width||i.height!==t.height}var io;function qx(i,t){io!=null||(io=document.createElement("canvas"));let e=io.getContext("2d");return e?(e.font=t,e.measureText(i).width):0}var Kh={};Je(Kh,{avg:()=>$x,calcNormal:()=>Xx,clamp:()=>Hc,cmp:()=>Qx,interpolateCoord:()=>Hx,interpolateY:()=>Zx,isInteger:()=>Et,isNumber:()=>le,linearToDecibels:()=>Wx,mod:()=>Ux,romanize:()=>zx,sum:()=>Jh,toOrdinalNumber:()=>Yx});function Wx(i){if(isFinite(i))return i<=0?-1/0:20*Math.log10(i);throw new Error("linearToDecibel: Invalid linearVolume = "+i)}function Ux(i,t){return(i%t+t)%t}function zx(i){if(!Et(i)||i<0)throw new Error("romanize: Invalid n = "+i);for(var t=String(+i).split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",n=3;n--;)r=(e[+t.pop()+n*10]||"")+r;return Array(+t.join("")+1).join("M")+r}function Yx(i){if(!Et(i))throw new Error("toOrdinalNumber: Invalid n = "+i);let t=i.toString(),e=Number(t.charAt(t.length-1));return i===1||i>=20&&e===1?t+"st":i===2||i>=20&&e===2?t+"nd":i===3||i>=20&&e===3?t+"rd":t+"th"}function Hx(i,t,e,r,n){return{x:i+(e-i)*n,y:t+(r-t)*n}}function Zx(i,t,e,r,n){let o=(n-i)/(e-i);return t+(r-t)*o}function Hc(i,t,e){return Math.min(Math.max(i,t),e)}function Xx(i,t,e,r){let n=e-i,s=-(r-t),a=n,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function Jh(i){return i.reduce((t,e)=>e+t,0)}function $x(...i){return Jh(i)/i.length}function Qx(i,t){return i<t?-1:i>t?1:0}var Qe=(i,t)=>i===t,Qr=class{};var tl=class Ge extends Qr{constructor(...t){if(super(),gt(this,"coords"),t.length<2)throw new TypeError("Vec needs minumum two coords!");this.coords=t}static vec2(t,e){return new Ge(t,e)}static vec3(t,e,r){return new Ge(t,e,r)}static zero(t){if(t<2)throw new TypeError("Vec.zero requires dimension >= 2");return new Ge(...Array(t).fill(0))}get dim(){return this.coords.length}get length(){return Math.hypot(...this.coords)}magnitude(){return this.length}get x(){return this.coords[0]}get y(){return this.coords[1]}get z(){if(this.coords[2]===void 0)throw new TypeError("Vec z-coord not available!");return this.coords[2]}add(...t){let e=t[0]instanceof Ge?t[0].coords:t;if(this.coords.length!==e.length)throw new TypeError("Coordinate length mismatch!");return new Ge(...this.coords.map((r,n)=>r+e[n]))}sub(...t){let e=t[0]instanceof Ge?t[0].coords:t;if(this.coords.length!==e.length)throw new TypeError("Coordinate length mismatch!");return new Ge(...this.coords.map((r,n)=>r-e[n]))}mul(t){return new Ge(...this.coords.map(e=>e*t))}div(t){return new Ge(...this.coords.map(e=>e/t))}dot(t){if(this.coords.length!==t.coords.length)throw new TypeError("Coordinate length mismatch!");return this.coords.reduce((e,r,n)=>e+r*t.coords[n],0)}distance(t){if(this.coords.length!==t.coords.length)throw new TypeError("Coordinate length mismatch!");return Math.hypot(...this.coords.map((e,r)=>e-t.coords[r]))}normalize(){let t=this.length;if(t===0)throw new TypeError("Cannot normalize zero-length vector!");return this.div(t)}static lerp(t,e,r){if(t.coords.length!==e.coords.length)throw new TypeError("Coordinate length mismatch!");if(!Qi(r))throw new TypeError("Lerp t is not finite!");return t.add(e.sub(t).mul(r))}toLength(t){let e=this.length;return e===0?this:this.mul(t/e)}clamp(t,e,r){let n=this.length;if(n===0){if(t!==void 0){if(r&&r.coords.length!==this.coords.length)throw new TypeError("Coordinate length mismatch!");return(r&&r.length!==0?r.normalize():new Ge(1,...Array(this.coords.length-1).fill(0))).mul(t)}return this}return e!==void 0&&n>e?this.normalize().mul(e):t!==void 0&&n<t?this.normalize().mul(t):this}equals(t){return this.coords.length===t.coords.length&&this.coords.every((e,r)=>e===t.coords[r])}clone(){return new Ge(...this.coords)}toObject(){return{x:this.x,y:this.y,z:this.z}}[Symbol.iterator](){return this.coords[Symbol.iterator]()}toString(){return`Vec(${this.coords.join(", ")})`}},tu=class Se{constructor(...t){if(gt(this,"x"),gt(this,"y"),gt(this,"width"),gt(this,"height"),t.length===0?this.x=this.y=this.width=this.height=0:t.length===2?(this.x=this.y=0,this.width=t[0],this.height=t[1]):(this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]),this.width<0||this.height<0)throw new Error("Rect width and height must be non-negative.")}set(...t){if(t.length===0?this.x=this.y=this.width=this.height=0:t.length===2?(this.x=this.y=0,this.width=t[0],this.height=t[1]):(this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]),this.width<0||this.height<0)throw new Error("Rect width and height must be non-negative.");return this}static fromPoints(t,e){let r=Math.min(t.x,e.x),n=Math.min(t.y,e.y),o=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return new Se(r,n,o,s)}static fromCenter(t,e,r,n){return new Se(t-r/2,e-n/2,r,n)}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get center(){return{x:this.centerX,y:this.centerY}}get area(){return this.width*this.height}get isEmpty(){return this.width<=0||this.height<=0}containsPoint(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}containsRect(t){return t.left>=this.left&&t.right<=this.right&&t.top>=this.top&&t.bottom<=this.bottom}intersects(t){return!(t.right<this.left||t.left>this.right||t.bottom<this.top||t.top>this.bottom)}intersectionCopy(t){let e=Math.max(this.left,t.left),r=Math.max(this.top,t.top),n=Math.min(this.right,t.right),o=Math.min(this.bottom,t.bottom);return n<=e||o<=r?new Se:new Se(e,r,n-e,o-r)}unionCopy(t){let e=Math.min(this.left,t.left),r=Math.min(this.top,t.top),n=Math.max(this.right,t.right),o=Math.max(this.bottom,t.bottom);return new Se(e,r,n-e,o-r)}insetCopy(t,e){return new Se(this.x+t,this.y+e,this.width-2*t,this.height-2*e)}inflateCopy(t,e){return new Se(this.x-t,this.y-e,this.width+2*t,this.height+2*e)}offsetInPlace(t,e){return this.x+=t,this.y+=e,this}offsetCopy(t,e){return new Se(this.x+t,this.y+e,this.width,this.height)}scaleInPlace(t,e=t){return this.x=this.centerX-this.width*t/2,this.width*=t,this.y=this.centerY-this.height*e/2,this.height*=e,this}scaleCopy(t,e=t){return this.clone().scaleInPlace(t,e)}roundCopy(){let t=Math.round(this.left),e=Math.round(this.top),r=Math.round(this.right),n=Math.round(this.bottom);return new Se(t,e,r-t,n-e)}floorCopy(){let t=Math.floor(this.left),e=Math.floor(this.top),r=Math.floor(this.right),n=Math.floor(this.bottom);return new Se(t,e,r-t,n-e)}ceilCopy(){let t=Math.ceil(this.left),e=Math.ceil(this.top),r=Math.ceil(this.right),n=Math.ceil(this.bottom);return new Se(t,e,r-t,n-e)}expandCopy(t,e){let r=Math.min(this.left,t),n=Math.min(this.top,e),o=Math.max(this.right,t),s=Math.max(this.bottom,e);return new Se(r,n,o-r,s-n)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new Se(this.x,this.y,this.width,this.height)}toString(){return`Rect(x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height})`}toAnchoredRect(){return new G(this.left,this.right,this.top,this.bottom)}},G=class bi{constructor(...t){if(gt(this,"left"),gt(this,"anchorX"),gt(this,"right"),gt(this,"top"),gt(this,"anchorY"),gt(this,"bottom"),t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid AnchoredRect args: ${t}`)}set(...t){if(t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid AnchoredRect args: ${t}`);return this}static create(t,e,r,n){return new bi(t,t+r,e,e+n)}static createCentered(t,e,r,n){return new bi(t-r/2,t,t+r/2,e-n/2,e,e+n/2)}static createSections(t,e,r,n){return new bi(-t,0,e,-r,0,n)}get centerX(){return this.left+this.width/2}get centerY(){return this.top+this.height/2}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.anchorX-this.left}get rightw(){return this.right-this.anchorX}get toph(){return this.anchorY-this.top}get bottomh(){return this.bottom-this.anchorY}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.anchorX===e.anchorX&&t.right===e.right&&t.top===e.top&&t.anchorY===e.anchorY&&t.bottom===e.bottom}equals(t){return bi.equals(this,t)}static equalsEdges(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}equalsEdges(t){return bi.equalsEdges(this,t)}clone(){return new bi(this.left,this.anchorX,this.right,this.top,this.anchorY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.anchorX+=t,this.right+=t,this.top+=e,this.anchorY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.clone().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.clone().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.anchorX=Hc(this.anchorX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.anchorY=Hc(this.anchorY,this.top,this.bottom),this}clipCopy(t){return this.clone().clipInPlace(t)}scaleInPlace(t,e=t){return this.left=this.anchorX-this.leftw*t,this.right=this.anchorX+this.rightw*t,this.top=this.anchorY-this.toph*e,this.bottom=this.anchorY+this.bottomh*e,this}scaleCopy(t,e=t){return this.clone().scaleInPlace(t,e)}getRect(){return this}toRect(){return new tu(this.left,this.right,this.width,this.height)}toString(){return`Rect(left=${this.left}, anchorX=${this.anchorX}, right=${this.right}, top=${this.top}, anchorY=${this.anchorY}, bottom=${this.bottom})`}},el=class extends Qr{constructor(i,t=1/0){super(),gt(this,"cache"),gt(this,"next"),gt(this,"prev"),gt(this,"head"),gt(this,"tail"),gt(this,"capacity"),gt(this,"size"),gt(this,"maxKeyLength"),this.cache=Object.create(null),this.next=Object.create(null),this.prev=Object.create(null),this.head=null,this.tail=null,this.capacity=i,this.size=0,this.maxKeyLength=t}get(i){if(!(i.length>this.maxKeyLength)&&this.cache[i]!==void 0)return this.touch(i),this.cache[i]}set(i,t){if(!(i.length>this.maxKeyLength)){if(this.cache[i]!==void 0){this.cache[i]=t,this.touch(i);return}this.size>=this.capacity&&this.evict(),this.cache[i]=t,this.addToTail(i),this.size++}}touch(i){this.tail!==i&&(this.removeKey(i),this.addToTail(i))}evict(){if(this.head!==null){let i=this.head;this.removeKey(i),delete this.cache[i],this.size--}}removeKey(i){let t=this.prev[i],e=this.next[i];t!==void 0?this.next[t]=e:this.head=e!=null?e:null,e!==void 0?this.prev[e]=t:this.tail=t!=null?t:null,delete this.prev[i],delete this.next[i]}addToTail(i){this.tail!==null?(this.next[this.tail]=i,this.prev[i]=this.tail):this.head=i,this.tail=i}*keys(){for(let i=this.head;i!=null;i=this.next[i])yield i}*values(){for(let i=this.head;i!=null;i=this.next[i])yield this.cache[i]}*entries(){for(let i=this.head;i!=null;i=this.next[i])yield[i,this.cache[i]]}*[Symbol.iterator](){yield*be(this.entries())}toString(){let i=[...this.entries()];return i.length===0?"LRUCache(0){ }":`LRUCache(${i.length}){ ${i.map(t=>`${Zt(t[0])}: ${Zt(t[1])}`).join(", ")} }`}},Ar=class $r extends Qr{constructor(t){if(super(),gt(this,"posVal"),gt(this,"hasPos"),gt(this,"valCount"),t instanceof $r)this.posVal=t.posVal.slice(),this.hasPos=t.hasPos.slice(),this.valCount=t.valCount;else if(this.posVal=[],this.hasPos=[],this.valCount=0,t)for(let[e,r]of t)this.set(e,r)}static validateIndex(t){if(!Xc(t,0))throw new Error(`Invalid index ${t} - must be an integer >= 0!`);return t}get posLen(){return this.hasPos.length}get size(){return this.valCount}get length(){return this.hasPos.length}trimRight(){let t=this.length;for(;t>0&&this.hasPos[t-1]!==!0;)t--;t<this.length&&(this.posVal.length=this.hasPos.length=t)}isEmpty(){return this.size===0}has(t){return $r.validateIndex(t),this.hasPos[t]===!0}set(t,e){$r.validateIndex(t),this.hasPos[t]!==!0&&this.valCount++,this.posVal[t]=e,this.hasPos[t]=!0}get(t){return $r.validateIndex(t),this.hasPos[t]?this.posVal[t]:void 0}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=Er(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){return $r.validateIndex(t),this.hasPos[t]?(this.posVal[t]=void 0,this.hasPos[t]=!1,this.valCount--,this.trimRight(),!0):!1}clear(){this.posVal=[],this.hasPos=[],this.valCount=0}forEach(t,e){for(let[r,n]of this.entries())t.call(e,n,r,this)}*indices(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield t)}*values(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield this.posVal[t])}*entries(){for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield[t,this.posVal[t]])}indicesArray(){return[...this.indices()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.indices())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*be(this.entries())}clone(){return new $r(this)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.entries())if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.entries())if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.entries())t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty IndexArray with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapToArray(t){let e=[];for(let[r,n]of this.entries())e.push(t(n,r));return e}map(t){let e=new $r;for(let[r,n]of this.entries())e.set(r,t(n,r));return e}equals(t,e){if(this.size!==t.size)return!1;e!=null||(e=(n,o)=>n===o);let r=Math.max(this.posLen,t.posLen);for(let n=0;n<r;++n){let o=this.hasPos[n],s=t.hasPos[n];if(o!==s||o&&!e(this.posVal[n],t.posVal[n]))return!1}return!0}toArray(){return this.valuesArray()}toString(){let t=!0;for(let r=0;r<this.hasPos.length&&t;r++)this.hasPos[r]||(t=!1);if(t)return Zt(this.posVal.slice(0,this.hasPos.length));let e=this.entriesArray().map(([r,n])=>`${Zt(r)}: ${Zt(n)}`).join(", ");return e.length===0?"[ ]":`[ ${e} ]`}},rl=class we extends Qr{constructor(t){if(super(),gt(this,"posVal"),gt(this,"hasPos"),gt(this,"negVal"),gt(this,"hasNeg"),gt(this,"valCount"),t instanceof we)this.negVal=t.negVal.slice(),this.hasNeg=t.hasNeg.slice(),this.posVal=t.posVal.slice(),this.hasPos=t.hasPos.slice(),this.valCount=t.valCount;else if(this.negVal=[],this.hasNeg=[],this.posVal=[],this.hasPos=[],this.valCount=0,t)for(let[e,r]of t)this.set(e,r)}static toNegIndex(t){return-t-1}static validateIndex(t){if(!Et(t))throw new Error(`Invalid index ${t} - must be an integer!`);return t}get size(){return this.valCount}isEmpty(){return this.size===0}get posLen(){return this.hasPos.length}get negLen(){return this.hasNeg.length}has(t){return we.validateIndex(t),t>=0?this.hasPos[t]===!0:this.hasNeg[we.toNegIndex(t)]===!0}set(t,e){if(we.validateIndex(t),t>=0)this.hasPos[t]!==!0&&this.valCount++,this.posVal[t]=e,this.hasPos[t]=!0;else{let r=we.toNegIndex(t);this.hasNeg[r]!==!0&&this.valCount++,this.negVal[r]=e,this.hasNeg[r]=!0}}get(t){if(we.validateIndex(t),t>=0)return this.hasPos[t]?this.posVal[t]:void 0;{let e=we.toNegIndex(t);return this.hasNeg[e]?this.negVal[e]:void 0}}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=Er(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){we.validateIndex(t);let e=t>=0,r=e?this.posVal:this.negVal,n=e?this.hasPos:this.hasNeg,o=e?t:we.toNegIndex(t);return n[o]?(r[o]=void 0,n[o]=!1,this.valCount--,!0):!1}clear(){this.negVal=[],this.hasNeg=[],this.posVal=[],this.hasPos=[],this.valCount=0}forEach(t,e){for(let[r,n]of this.entries())t.call(e,n,r,this)}*indices(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield we.toNegIndex(t));for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield t)}*values(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield this.negVal[t]);for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield this.posVal[t])}*entries(){for(let t=this.negLen-1;t>=0;t--)this.hasNeg[t]&&(yield[we.toNegIndex(t),this.negVal[t]]);for(let t=0;t<this.posLen;t++)this.hasPos[t]&&(yield[t,this.posVal[t]])}indicesArray(){return[...this.indices()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.indices())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*be(this.entries())}clone(){return new we(this)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.entries())if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.entries())if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.entries())t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty SignedIndexArray with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapToArray(t){let e=[];for(let[r,n]of this.entries())e.push(t(n,r));return e}map(t){let e=new we;for(let[r,n]of this.entries())e.set(r,t(n,r));return e}equals(t,e){if(this.size!==t.size)return!1;e!=null||(e=(o,s)=>o===s);let r=Math.max(this.posLen,t.posLen);for(let o=0;o<r;++o){let s=this.hasPos[o],a=t.hasPos[o];if(s!==a||s&&!e(this.posVal[o],t.posVal[o]))return!1}let n=Math.max(this.negLen,t.negLen);for(let o=0;o<n;++o){let s=this.hasNeg[o],a=t.hasNeg[o];if(s!==a||s&&!e(this.negVal[o],t.negVal[o]))return!1}return!0}toArray(){return this.valuesArray()}toString(){let t=this.hasNeg.length===0;for(let r=0;r<this.hasPos.length&&t;r++)this.hasPos[r]||(t=!1);if(t)return Zt(this.posVal.slice(0,this.hasPos.length));let e=this.entriesArray().map(([r,n])=>`${Zt(r)}: ${Zt(n)}`).join(", ");return e.length===0?"[ ]":`[ ${e} ]`}};var yt=class no extends Qr{constructor(...t){super(),gt(this,"map"),gt(this,"keyEquals");let e=t.at(-1);this.keyEquals=Er(e)?t.pop():Qe;let r=t[0];this.map=new Map(r)}static createDeep(t){return t?new no(t,so):new no(so)}has(t){if(this.keyEquals===Qe||this.map.has(t))return this.map.has(t);for(let[e,r]of this.map)if(this.keyEquals(e,t))return!0;return!1}set(t,e){if(this.keyEquals===Qe||this.map.has(t))return this.map.set(t,e),e;for(let r of this.map.keys())if(this.keyEquals(r,t))return this.map.set(r,e),e;return this.map.set(t,e),e}get(t){if(this.keyEquals===Qe||this.map.has(t))return this.map.get(t);for(let[e,r]of this.map)if(this.keyEquals(e,t))return r}delete(t){if(this.keyEquals===Qe||this.map.has(t))return this.map.delete(t);for(let e of this.map.keys())if(this.keyEquals(e,t))return this.map.delete(e);return this.map.delete(t)}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=Er(e)?e():e;return this.set(t,r)}return this.get(t)}clear(){this.map.clear()}get size(){return this.map.size}isEmpty(){return this.size===0}forEach(t,e){this.map.forEach((r,n)=>t.call(e,r,n,this))}*keys(){yield*be(this.map.keys())}*values(){yield*be(this.map.values())}*entries(){for(let[t,e]of this.map)yield[t,e]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let t of this.keys())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*be(this.entries())}clone(){return new no(this,this.keyEquals)}merge(t,e){for(let[r,n]of t.entries())this.has(r)&&e?this.set(r,e(this.get(r),n,r)):this.set(r,n);return this}some(t){for(let[e,r]of this.map)if(t(r,e))return!0;return!1}every(t){for(let[e,r]of this.map)if(!t(r,e))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map)t(n,r,this)&&e.set(r,n);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty UniMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[1],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u]=a.value;o=t(o,u,c)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map)e.push(t(n,r));return e}mapValues(t){let e=new no;for(let[r,n]of this.map)e.set(r,t(n,r));return e}toMap(){return new Map(this.map)}toString(){let t=[...this.map].map(([e,r])=>`${Zt(e)} => ${Zt(r)}`).join(", ");return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t} }`}};var Ps=class Ms extends Qr{constructor(t){if(super(),gt(this,"map1"),gt(this,"key1Equals",Qe),gt(this,"key2Equals",Qe),gt(this,"key3Equals",Qe),this.map1=new yt(this.key1Equals),t instanceof Ms)for(let[e,r]of t.map1){let n=this.map1.set(e,new yt(this.key2Equals));for(let[o,s]of r)n.set(o,new yt(s,this.key3Equals))}else if(t)for(let[e,r,n,o]of t)this.set(e,r,n,o)}has(t,e,r){var n,o,s;return(s=(o=(n=this.map1.get(t))==null?void 0:n.get(e))==null?void 0:o.has(r))!=null?s:!1}set(t,e,r,n){return this.map1.getOrCreate(t,()=>new yt(this.key2Equals)).getOrCreate(e,()=>new yt(this.key3Equals)).set(r,n),n}get(t,e,r){var n,o;return(o=(n=this.map1.get(t))==null?void 0:n.get(e))==null?void 0:o.get(r)}getOrDefault(t,e,r,n){var o;return(o=this.get(t,e,r))!=null?o:n}getOrCreate(t,e,r,n){if(!this.has(t,e,r)){let o=Er(n)?n():n;return this.set(t,e,r,o),o}return this.get(t,e,r)}delete(t,e,r){var n;if(r===void 0){if(e===void 0)return this.map1.delete(t);let o=this.map1.get(t);return o?o.delete(e):!1}else{if(e===void 0)return this.map1.delete(t);let o=(n=this.map1.get(t))==null?void 0:n.get(e);return o?o.delete(r):!1}}clear(){this.map1.clear()}get size(){let t=0;for(let e of this.map1.values())for(let r of e.values())t+=r.size;return t}isEmpty(){return this.size===0}forEach(t,e){this.map1.forEach((r,n)=>r.forEach((o,s)=>o.forEach((a,c)=>t.call(e,a,n,s,c,this))))}*keys(){for(let[t,e]of this.map1)for(let[r,n]of e)for(let o of n.keys())yield[t,r,o]}*values(){for(let t of this.map1.values())for(let e of t.values())for(let r of e.values())yield r}*entries(){for(let[t,e]of this.map1)for(let[r,n]of e)for(let[o,s]of n)yield[t,r,o,s]}keysArray(){return[...this.keys()]}valuesArray(){return[...this.values()]}entriesArray(){return[...this.entries()]}*kvKeys(){for(let[t,e,r]of this.keys())yield[t,e,r]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e,r,n]of this.entries())yield[[t,e,r],n]}*[Symbol.iterator](){yield*be(this.entries())}clone(){return new Ms(this)}merge(t,e){for(let[r,n,o,s]of t.entries())this.has(r,n,o)&&e?this.set(r,n,o,e(this.get(r,n,o),s,r,n,o)):this.set(r,n,o,s);return this}some(t){for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)if(t(a,e,n,s))return!0;return!1}every(t){for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)if(!t(a,e,n,s))return!1;return!0}filter(t){let e=new this.constructor;for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)t(c,r,o,a,this)&&e.set(r,o,a,c);return e}reduce(t,e){let r=this.entries(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty TriMap with no initial value!");return e}let o,s;arguments.length<2?(o=n.value[3],s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let[c,u,h,l]=a.value;o=t(o,l,c,u,h)}return o}mapEntries(t){let e=[];for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)e.push(t(c,r,o,a));return e}mapValues(t){let e=new Ms;for(let[r,n]of this.map1)for(let[o,s]of n)for(let[a,c]of s)e.set(r,o,a,t(c,r,o,a));return e}toMap(){let t=new Map;for(let[e,r]of this.map1)for(let[n,o]of r)for(let[s,a]of o)t.set([e,n,s],a);return t}toString(){let t=[];for(let[e,r]of this.map1)for(let[n,o]of r){let s=[...o].map(([a,c])=>`${Zt(a)} => ${Zt(c)}`).join(", ");t.push(`${Zt(e)} => ${Zt(n)} => { ${s} }`)}return t.length===0?`Map(${this.size}){ }`:`Map(${this.size}){ ${t.join(", ")} }`}},Fs=class xi extends Qr{constructor(...t){super(),gt(this,"data"),gt(this,"equals");let e=t.at(-1);this.equals=Er(e)?t.pop():Qe;let r=t[0];this.data=new Set(r)}static createDeep(t){return t?new xi(t,so):new xi(so)}has(t){return this.equals===Qe?this.data.has(t):this.some(e=>this.equals(e,t))}add(t){return this.has(t)||this.data.add(t),t}set(t,e){if(!this.equals(t,e))throw new TypeError("ValueSet.set() requires key === value.");this.add(e)}get(t){return this.has(t)?t:void 0}getOrDefault(t,e){var r;return(r=this.get(t))!=null?r:e}getOrCreate(t,e){if(!this.has(t)){let r=Er(e)?e():e;return this.set(t,r),r}return this.get(t)}delete(t){if(this.equals===Qe||this.data.has(t))return this.data.delete(t);for(let e of this.values())if(this.equals(e,t))return this.data.delete(e),!0;return!1}clear(){this.data.clear()}get size(){return this.data.size}isEmpty(){return this.size===0}forEach(t,e){this.data.forEach(r=>t.call(e,r,this))}*keys(){yield*be(this.data.keys())}*values(){yield*be(this.data.values())}*entries(){yield*be(this.data.entries())}*kvKeys(){for(let t of this.keys())yield[t]}*kvValues(){for(let t of this.values())yield t}*kvEntries(){for(let[t,e]of this.entries())yield[[t],e]}*[Symbol.iterator](){yield*be(this.values())}clone(){let t=new xi;for(let e of this.values())t.add(e);return t}merge(t){for(let e of t.values())this.add(e);return this}some(t){for(let e of this.data)if(t(e))return!0;return!1}every(t){for(let e of this.data)if(!t(e))return!1;return!0}filter(t){let e=new xi;for(let r of this.data)t(r,this)&&e.add(r);return e}reduce(t,e){let r=this.values(),n=r.next();if(n.done){if(arguments.length<2)throw new TypeError("Reduce of empty ValueSet with no initial value!");return e}let o,s;arguments.length<2?(o=n.value,s=r.next()):(o=e,s=n);for(let a=s;!a.done;a=r.next()){let c=a.value;o=t(o,c)}return o}mapValues(t){let e=new xi;for(let r of this.data)e.add(t(r));return e}mapToArray(t){let e=[];for(let r of this.values())e.push(t(r));return e}map(t){let e=new xi;for(let r of this.values())e.add(t(r));return e}toSet(){return new Set(this.data)}toArray(){return[...this.values()]}toString(){return Zt(this.data)}},Kx=class extends Qr{constructor(i){super(),this.base=i}isEmpty(){return this.base.isEmpty()}clear(){var i,t;(t=(i=this.base).clear)==null||t.call(i)}add(...i){let t=i.slice(0,-1),e=i[i.length-1],r=this.base.get(...t);return this.base.set(...t,r?[...r,e]:[e]),e}remove(...i){let t=i.slice(0,-1),e=i[i.length-1],r=this.base.get(...t);if(!r)return!1;let n=r.indexOf(e);return n===-1?!1:(r.splice(n,1),r.length===0&&this.base.delete(...t),!0)}getAll(...i){var t;return(t=this.base.get(...i))!=null?t:[]}*iterAll(...i){yield*be(this.getAll(...i))}*values(){for(let i of this.keys())yield*be(this.getAll(...i))}*keys(){for(let i of this.base.kvKeys())yield i}*entries(){for(let i of this.keys()){let t=this.getAll(...i);t.length>0&&(yield[i,t])}}[Symbol.iterator](){return this.entries()}toString(){let i=[];for(let t of this.keys()){let e=this.getAll(...t),r=Array.isArray(t)?Zt(t):"[ ]",n=Array.isArray(e)?Zt(e):"[ ]";i.push(`${r} => ${n}`)}return i.length===0?"MultiContainer{ }":`MultiContainer{ ${i.join(", ")} }`}};function Bs(i){return new Kx(i)}var eu={};$i(eu,{MusicError:()=>N,MusicErrorType:()=>bt,init:()=>Ci});var bt=(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))(bt||{});function Jx(i){return i===void 0?"":`[${bt[i]}] `}var N=class extends Error{constructor(...e){let[r,n]=e.length===1?[0,e[0]]:e;super(Jx(r)+n);d(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var il=!1;function Ci(){il||(il=!0,console.log("%cWebMusicScore v5.4.1 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Kr=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(Kr||{}),Jr=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(Jr||{}),tA=H.Enum.getEnumValues(Jr),eA=0;function nl(i){if(y.isEnumValue(i,Jr))return i;throw new N(1,`Invalid pitchNotation: ${i}`)}function rA(i){return Jr[nl(i)]}var Gs=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Gs||{}),iA="Default",nA=H.Enum.getEnumValues(Gs);function oA(i){if(y.isEnumValue(i,Gs))return i;throw new N(5,`Invalid guitarNoteLabel: ${i}`)}function ol(i,t){return(i%t+t)%t}var sl=12,al=7,sA=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),aA=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),cl=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),ao=["C","D","E","F","G","A","B"],ul=[0,2,4,5,7,9,11],hl=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,lt=class lt{constructor(t,e,r){d(this,"diatonicClass");d(this,"accidental");d(this,"octave");if(typeof t=="number"&&typeof e=="number"&&r===void 0)lt.validateDiatonicId(t),this.diatonicClass=lt.getDiatonicClass(t),this.accidental=lt.validateAccidental(e),this.octave=lt.getOctaveFromDiatonicId(t);else if(typeof t=="number"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=lt.validateDiatonicClass(t),this.accidental=lt.validateAccidental(e),this.octave=lt.validateOctave(r);else if(typeof t=="string"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=lt.getDiatonicClass(t),this.accidental=lt.validateAccidental(e),this.octave=lt.validateOctave(r);else throw new N(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return lt.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return lt.getChromaticIdInOctave(ul[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return lt.getChromaticClass(ul[this.diatonicClass]+this.accidental)}get noteLetter(){return ao[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:n}=this,o=lt.getAccidentalSymbol(this.accidental,e);return t===1?n>=3?r.toLowerCase()+o+"\u2032".repeat(n-3):r.toUpperCase()+o+"\u0375".repeat(2-n):r+o+n}formatOmitOctave(t){let e=ao[this.diatonicClass],r=lt.getAccidentalSymbol(this.accidental,t);return e+r}static getNote(t){return this.noteCache.getOrCreate(t,()=>{let e=lt.parseNote(t);if(!e)throw new N(2,`Invalid note "${t}".`);if(e.octave===void 0)throw new N(2,`Invalid note "${t}" (missing octave).`);return new lt(e.noteLetter,e.accidental,e.octave)})}static isNote(t){let e=lt.parseNote(t);return e!==void 0&&e.octave!==void 0}static validateNote(t){if(this.isNote(t))return!0;throw new N(2,`Invalid note "${t}"`)}static getChromaticNote(t){return this.chromaticNoteCache.getOrCreate(t,()=>{let r=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][lt.getChromaticClass(t)].split("/")[0]+lt.getOctaveFromChromaticId(t);return lt.getNote(r)})}static getDiatonicClass(t){if(typeof t=="number")return ol(t,7);if(typeof t=="string"&&t.length>0)return ao.indexOf(lt.validateNoteLetter(t[0]));throw new N(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-al)/7)}static getDiatonicIdInOctave(t,e){return lt.getDiatonicClass(t)+e*7+al}static getChromaticClass(t){return ol(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-sl)/12)}static getChromaticIdInOctave(t,e){return lt.getChromaticClass(t)+e*12+sl}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.diatonicId===e.diatonicId&&t.accidental===e.accidental}static replaceAccidentalSymbols(t,e){return e===1?t.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):t.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(t){return hl.test(t)}static parseNote(t){var c;let e=hl.exec(t);if(!e)return;let r=lt.validateNoteLetter(e[1]),n=e[2],o=lt.validateAccidental((c=cl.get(n))!=null?c:0),s=e[3],a=s?lt.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(t,e){let r=lt.parseNote(t);if(!r)throw new N(2,`Invalid noteName: ${t}`);let{noteLetter:n,accidental:o,octave:s}=r;return n+lt.getAccidentalSymbol(o,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?aA.get(t):sA.get(t)}static getAccidental(t){let e=cl.get(t);if(e===void 0)throw new N(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return ao[lt.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let n=lt.getDiatonicClass(t),o=lt.getDiatonicClass(e),s=r?n<=o?1:0:n<o?1:0;return lt.getDiatonicIdInOctave(n,lt.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(y.isInteger(t))return t;throw new N(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(y.isIntegerBetween(t,0,6))return t;throw new N(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(y.isInteger(t))return t;throw new N(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(y.isIntegerBetween(t,0,11))return t;throw new N(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(ao.some(e=>e===t))return t;throw new N(2,`Invalid note: ${t}`)}static validateOctave(t){if(y.isInteger(t))return t;throw new N(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(y.isIntegerBetween(t,-2,2))return t;throw new N(2,`Invalid accidental: ${t}`)}static sort(t){return t.slice().sort(lt.compareFunc)}static removeDuplicates(t){let e=[];return t.forEach(r=>{e.find(n=>lt.equals(r,n))===void 0&&e.push(r)}),e}static compareFunc(t,e){return t.diatonicId<e.diatonicId?-1:t.diatonicId>e.diatonicId?1:t.accidental<e.accidental?-1:t.accidental>e.accidental?1:0}};d(lt,"noteCache",new yt),d(lt,"chromaticNoteCache",new yt);var W=lt;function cA(i,t){let e=W.getChromaticClass(i)-new W(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return W.validateAccidental(e)}var uA=/^(bb?|b?|#?|x?)([0-9]*)$/;function hA(i){var n,o;let t=uA.exec(""+i);if(!t)throw new N(4,`Invalid degree: ${i}`);let e=(o=W.getAccidental((n=t[1])!=null?n:""))!=null?o:0,r=+t[2];if(!y.isInteger(e)||e<-2||e>2||!y.isInteger(r)||r<1)throw new N(4,`Invalid degree: ${i}`);return{deg:r,acc:e}}var ru=(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))(ru||{}),iu=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(iu||{});function Vs(){return Dr("C","Major")}var ti=class ti{constructor(t,e){this.tonic=t;this.mode=e;d(this,"naturalScaleNotes");d(this,"accidentalByDiatonicClass");d(this,"orderedAccidentedNotes");if(!y.isEnumValue(e,ru))throw new N(4,`Invalid mode: ${e}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<e;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let n=W.getDiatonicClass(t[0]),o=W.getNote(t+"0").chromaticId;for(let c=0;c<7;n++,o+=r[c],c++){let u=new W(W.getDiatonicClass(n),cA(o,n));if(Math.abs(u.accidental)>=2)throw new N(4,"Key signature contains double accidental.");this.naturalScaleNotes[c]=u,this.accidentalByDiatonicClass[u.diatonicClass]=u.accidental}let s=this.naturalScaleNotes.filter(c=>c.accidental>0).sort((c,u)=>{let h=ti.OrderOfSharps.indexOf(c.noteLetter),l=ti.OrderOfSharps.indexOf(u.noteLetter);if(h===-1||l===-1)throw new N(4,"Unexpected note in key signature.");return h-l}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let h=ti.OrderOfFlats.indexOf(c.noteLetter),l=ti.OrderOfFlats.indexOf(u.noteLetter);if(h===-1||l===-1)throw new N(4,"Unexpected note in key signature.");return h-l});if(s.length!==0&&a.length!==0)throw new N(4,"Key Signature has both sharps and flats.");this.orderedAccidentedNotes=a.length>0?a:s}getAccidentalType(){return this.orderedAccidentedNotes.length===0?0:this.orderedAccidentedNotes[0].accidental<0?1:2}getNaturalScaleNotes(){return this.naturalScaleNotes}getAccidental(t){var e;return(e=this.accidentalByDiatonicClass[W.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=hA(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let n=this.naturalScaleNotes[(e-1)%7];return new W(n.diatonicId,n.accidental+r)}}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.tonic===e.tonic&&t.mode===e.mode}};d(ti,"OrderOfSharps","FCGDAEB"),d(ti,"OrderOfFlats","BEADGCF");var tr=ti;var lA=new yt([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),dA={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 pA(i,t){for(;i<1;)i+=7,t+=12;for(;i>8;)i-=7,t-=12;let e=dA[i];if(e)return e[t]}function mA(i){if(i==="Perfect"||i==="Major"||i==="minor"||i==="Augmented"||i==="diminished"||i==="Doubly Augmented"||i==="doubly diminished")return i;throw new N(1,`Invalid interval quality: ${i}`)}function fA(i){if(y.isIntegerGte(i,1))return H.Math.toOrdinalNumber(i);throw new N(1,`Invalid interval quantity: ${i}`)}var qs=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},co=class i{constructor(t,e){this.note1=t;this.note2=e;d(this,"direction");d(this,"semitones");d(this,"quantity");d(this,"quality");e.diatonicId>=t.diatonicId?(this.direction=e.diatonicId===t.diatonicId?"Unison":"Ascending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId):(this.direction="Descending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId);let r=pA(this.quantity,this.semitones);if(r)this.quality=r;else throw new qs("Unknown interval quality")}static get(t,e){try{return new i(t,e)}catch(r){if(r instanceof qs)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":fA(this.quantity);return t+e+r}toAbbrString(){let t=this.direction==="Descending"?"\u2193":"",e=lA.getOrDefault(this.quality,"?"),r=this.quantity;return t+e+r}};function gA(i){let t=W.getDiatonicClass("CCDDEFFGGAAB"[W.getChromaticClass(i)]),e=W.getOctaveFromChromaticId(i);return W.getDiatonicIdInOctave(t,e)}var yA=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],_i=(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))(_i||{});function bA(i){switch(i){case"Major":return 1;case"Natural Minor":return 6;case"Harmonic Minor":return 6;case"Ionian":return 1;case"Dorian":return 2;case"Phrygian":return 3;case"Lydian":return 4;case"Mixolydian":return 5;case"Aeolian":return 6;case"Locrian":return 7;case"Major Pentatonic":return 1;case"Minor Pentatonic":return 6;case"Major Hexatonic Blues":return 1;case"Minor Hexatonic Blues":return 6;case"Heptatonic Blues":return 1;default:throw new N(3,`Invalid scaleType: ${i}`)}}var ei=class extends tr{constructor(e,r){super(e,bA(r));this.tonic=e;this.scaleType=r;d(this,"scaleDegrees");d(this,"scaleNotes");d(this,"chromaticClassDegree");d(this,"preferredChromaticIdNoteCache",new rl);switch(r){case"Harmonic Minor":this.scaleDegrees=[1,2,3,4,5,6,"#7"];break;case"Major Pentatonic":this.scaleDegrees=[1,2,3,5,6];break;case"Minor Pentatonic":this.scaleDegrees=[1,3,4,5,7];break;case"Major Hexatonic Blues":this.scaleDegrees=[1,2,"b3",3,5,6];break;case"Minor Hexatonic Blues":this.scaleDegrees=[1,3,4,"b5",5,7];break;case"Heptatonic Blues":this.scaleDegrees=[1,2,"b3",4,"b5",6,"b7"];break;default:this.scaleDegrees=[1,2,3,4,5,6,7];break}this.scaleNotes=this.scaleDegrees.map(n=>this.getNoteByDegree(n)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(n=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===n);return o>=0?this.scaleDegrees[o]:void 0})}static equals(e,r){return e==null&&r==null?!0:e==null||r==null?!1:e===r||e.getScaleName()===r.getScaleName()}getScaleName(e){switch(e){case 1:return W.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!y.isIntegerGte(r,1))throw new N(3,`Invalid numOctaves: ${r}`);let n=[];for(let s=1;s<=r;s++)n=[...n,...this.scaleNotes];n.push(this.scaleNotes[0]);let o=W.getNote(e).diatonicId;return n.map(s=>(o=W.findNextDiatonicIdAbove(s.diatonicId,o,!1),new W(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(e=>e.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let e=this.getScaleNotes("C4",1).map(n=>n.chromaticId),r=[];for(let n=0;n<e.length-1;n++)r.push(H.Math.mod(e[n+1]-e[n],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(e=>e===1?"H":e===2?"W":e.toString()+"H")}isScaleNote(e){return this.chromaticClassDegree[e.chromaticClass]!==void 0}isScaleRootNote(e){return String(this.chromaticClassDegree[e.chromaticClass])==="1"}getIntervalFromRootNote(e){let r=this.getScaleNotes("C0",1)[0];for(;e.chromaticId>=r.chromaticId+12;)e=new W(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new N(3,"Note is below rootNote.");let n=co.get(r,e);if(n===void 0)throw new N(3,"Interval is undefined.");return n}getPreferredChromaticNote(e){W.validateChromaticId(e);let r=this.preferredChromaticIdNoteCache.get(e);if(r)return r;let n=W.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(l=>l.noteLetter==="C"&&l.accidental<0?new W(l.diatonicClass,l.accidental,n+1):l.noteLetter==="B"&&l.accidental>0?new W(l.diatonicClass,l.accidental,n-1):new W(l.diatonicClass,l.accidental,n)).find(l=>W.getChromaticClass(e)===l.chromaticClass),r)return this.preferredChromaticIdNoteCache.set(e,r),r;let s=gA(e),a=s-2,c=s+2,h=this.getAccidentalType()===1?[0,-1,1,-2,2]:[0,1,-1,2,-2];for(let l=0;l<h.length;l++){let p=h[l];for(let m=Math.max(0,a);m<=c;m++)if(r=new W(m,p),e===r.chromaticId)return this.preferredChromaticIdNoteCache.set(e,r),r}return r=W.getChromaticNote(e),this.preferredChromaticIdNoteCache.set(e,r),r}},ee=class{constructor(t){this.type=t;d(this,"tonicList",[]);d(this,"scaleMap",new Map);let e=[],r=[],n=[];if(yA.forEach(s=>{try{let a=new ei(s,this.type);switch(a.getAccidentalType()){case 0:e.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;n.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),e.length===0)throw new N(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...n.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(t){let e=this.scaleMap.get(t);if(e)return e;throw new N(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},ll=[new ee("Major"),new ee("Natural Minor"),new ee("Harmonic Minor"),"- Modes -",new ee("Ionian"),new ee("Dorian"),new ee("Phrygian"),new ee("Lydian"),new ee("Mixolydian"),new ee("Aeolian"),new ee("Locrian"),"- Pentatonic -",new ee("Major Pentatonic"),new ee("Minor Pentatonic"),"- Blues -",new ee("Major Hexatonic Blues"),new ee("Minor Hexatonic Blues"),new ee("Heptatonic Blues")];function xA(){return ll}var dl=new yt;ll.forEach(i=>{i instanceof ee&&dl.set(i.getType(),i)});function pl(i){let t=dl.get(i);if(t)return t;throw new N(3,`Invalid scaleType: ${i}`)}function uo(i){if(y.isEnumValue(i,_i))return i;throw new N(3,`Invalid scaleType: "${i}"`)}function Dr(i,t){let e,r;return t!==void 0?(e=i,r=uo(t)):(e=i.split(" ")[0],r=uo(i.substring(e.length+1))),pl(r).getScale(e)}var AA=Dr("C","Major");function CA(){return AA}var kr=(i,t)=>i.chromaticClass===t.chromaticClass,_A=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(i=>W.getNote(i+"0")),vA=new Ar;function IA(i){return vA.getOrCreate(i.chromaticClass,()=>{let t=_A.find(e=>kr(e,i));if(!t)throw new N(1,`Invalid chord root note: ${i.formatOmitOctave(1)}`);return t})}function SA(i,t){let e=i.formatOmitOctave(0);return Dr(e,"Major").getNoteByDegree(t)}function wA(i){return H.Arr.removeDuplicates(i,kr)}var NA=[{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 TA(i,t){return i.degrees.every(e=>e!==t)?!0:i.degrees.length>=4&&t===5||i.degrees.length>=6&&t===9||i.degrees.length>=7&&t===11}var Ki=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},nu=class i{constructor(t,e,r,n){this.chordInfo=t;this.rootNote=r;d(this,"name");d(this,"notes");d(this,"omitNotes");d(this,"slashBassNote");this.name=t.name;let o=e.slice();!o.some(a=>kr(a,n))&&o.push(n),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<t.degrees.length;a++){let c=t.degrees[a],u=this.notes[a]=SA(this.rootNote,c),h=o.findIndex(l=>kr(l,u));if(h>=0)this.omitNotes[a]=!1,o.splice(h,1);else if(TA(t,c))this.omitNotes[a]=!0;else throw new Ki("Missing chord note!");kr(n,u)&&(n=u)}if(o.length>0)if(o.every(a=>kr(a,n)))this.slashBassNote=n;else throw new Ki("Got some extra notes that are not bass note!");else this.slashBassNote=kr(n,this.rootNote)?void 0:n;if(t.name==="5"&&this.slashBassNote)throw new Ki("Power chord no bass note allowed!")}static getChords(t){let e=[],r=W.sort(t),n=r[0],o=wA(r);for(let s=0;s<o.length;s++){let a=IA(o[s]);NA.forEach(c=>{try{let u=new i(c,o,a,n),h=e.findIndex(l=>l.replaceWith(u));h>=0?e[h]=u:e.push(u)}catch(u){if(!(u instanceof Ki))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!kr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!kr(t.notes[e],this.notes[e])||t.omitNotes[e]!==this.omitNotes[e])return!1;return!0}toString(){let t=1,e=this.rootNote.formatOmitOctave(t),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(t):"";return e+this.name+r}getDegreeNotationString(){let t=1,e=this.slashBassNote?this.slashBassNote.formatOmitOctave(t)+" - ":"",r=this.omitNotes.map((n,o)=>this.getDegreeStr(o)+"("+(n?"-":this.getNoteStr(o))+")").join(" - ");return e+r}getOmittedDegreesString(){let t=this.omitNotes.map((e,r)=>e?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(e=>e!==void 0);return t.length>0?"Omits "+t.join(", "):""}getDegreeStr(t){return W.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var ou={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 su=(e=>(e[e.RightHanded=0]="RightHanded",e[e.LeftHanded=1]="LeftHanded",e))(su||{}),RA=0;function MA(i){if(y.isEnumValue(i,su))return i;throw new N(1,`Invalid handedness: ${i}`)}var ho=ou.list.map(i=>i.name),EA=ho[0];function au(i){if(ho.indexOf(i)<0)throw new N(1,`Invalid tuning name: ${i}`);return i}var ml=new el(100);function Ws(i){let t=ml.get(i);if(!t){let e=ou.list.find(r=>r.name===i);if(!e)throw new N(1,`Invalid tuningName: ${i}`);if(t=e.strings.slice().reverse().map(r=>W.getNote(r)),!y.isIntegerEq(t.length,6))throw new N(0,`Tuning has ${t.length} strings.`);ml.set(i,t)}return t}var fl=12,DA=1188*7*5,er=(B=>(B.Whole="1n",B.WholeTriplet="1t",B.WholeDot="1.",B.Whole2Dots="1..",B.Whole12Dots="1..",B.Whole3Dots="1...",B.Whole4Dots="1....",B.Whole5Dots="1.....",B.Whole6Dots="1......",B.Half="2n",B.HalfTriplet="2t",B.HalfDot="2.",B.Half2Dots="2..",B.Half3Dots="2...",B.Half4Dots="2....",B.Half5Dots="2.....",B.Quarter="4n",B.QuarterTriplet="4t",B.QuarterDot="4.",B.Quarter2Dots="4..",B.Quarter3Dots="4...",B.Quarter4Dots="4....",B.Eighth="8n",B.EighthTriplet="8t",B.EighthDot="8.",B.Eighth2Dots="8..",B.Eighth3Dots="8...",B.Sixteenth="16n",B.SixteenthTriplet="16t",B.SixteenthDot="16.",B.Sixteenth2Dots="16..",B.ThirtySecond="32n",B.ThirtySecondTriplet="32t",B.ThirtySecondDot="32.",B.SixtyFourth="64n",B.SixtyFourthTriplet="64t",B))(er||{});function rr(i){return y.isEnumValue(i,er)}function Lr(i){if(rr(i))return i;throw new N(1,`Invalid noteLength: ${i}`)}var de=class de{constructor(t){d(this,"noteLength");d(this,"noteSize");d(this,"ticks");d(this,"flagCount");d(this,"dotCount");d(this,"maxDotCount");d(this,"isTriplet");d(this,"hasStem");d(this,"isSolid");if(this.noteLength=Lr(t),this.noteSize=parseInt(t),this.isTriplet=t.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(de.ShortestNoteSize/this.noteSize)),this.dotCount=H.Str.charCount(t,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=DA*de.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new N(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new N(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(t){return this.cache.getOrCreate(t,()=>new de(t))}static create(t,e=0){let r=typeof t=="number"?t:this.get(t).noteSize;return this.get(r+(y.isIntegerGte(e,1)?".".repeat(e):"n"))}static cmp(t,e){let r=t instanceof de?t.noteSize:typeof t=="number"?t:de.get(t).noteSize,n=e instanceof de?e.noteSize:typeof e=="number"?e:de.get(e).noteSize;return H.Math.cmp(n,r)}static equals(t,e){let r=t instanceof de?t.noteSize:typeof t=="number"?t:de.get(t).noteSize,n=e instanceof de?e.noteSize:typeof e=="number"?e:de.get(e).noteSize;return r===n}};d(de,"LongestNoteSize",Math.min(...H.Enum.getEnumValues(er).map(t=>parseInt(t)))),d(de,"ShortestNoteSize",Math.max(...H.Enum.getEnumValues(er).map(t=>parseInt(t)))),d(de,"cache",new yt);var Tt=de;function Us(i){return y.isObject(i)&&y.isIntegerBetween(i.parts,2,fl)&&y.isIntegerBetween(i.inTimeOf,2,fl)}function gl(i){if(Us(i))return i;throw new N(2,`Invalid tupletRatio ${JSON.stringify(i)}`)}var jr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},vi=class vi{constructor(t,e,r){d(this,"noteLength");d(this,"noteSize");d(this,"dotCount");d(this,"tupletRatio");d(this,"ticks");d(this,"flagCount");d(this,"hasStem");d(this,"isSolidNoteHead");this.noteLength=Lr(t);let n=Tt.get(t);if(this.noteSize=n.noteSize,this.ticks=n.ticks,this.flagCount=n.flagCount,this.dotCount=e!=null?e:n.dotCount,this.hasStem=n.hasStem,this.isSolidNoteHead=n.isSolid,y.isObject(r)?this.tupletRatio=gl(r):n.isTriplet?this.tupletRatio=jr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new N(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>n.maxDotCount)throw new N(2,`Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);for(let o=this.ticks/2,s=1;s<=this.dotCount;s++,o/=2)this.ticks+=o;this.tupletRatio&&(this.ticks*=this.tupletRatio.inTimeOf/this.tupletRatio.parts)}toString(){let t=vi.NoteSymbolMap.get(this.noteSize),e=".".repeat(this.dotCount);return t?t+e:""+this.noteSize+(e.length>0?e:"n")}static get(t,e,r){return e!==void 0||r!==void 0?new vi(t,e,r):this.cache.getOrCreate(t,()=>new vi(t))}static cmp(t,e){return H.Math.cmp(t.ticks,e.ticks)}static equals(t,e){return t.ticks===e.ticks}};d(vi,"NoteSymbolMap",new Ar([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),d(vi,"cache",new yt);var Xt=vi;var lo=(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))(lo||{}),Ii=(n=>(n._2_3="2-3",n._3_2="3-2",n._2_2_3="2-2-3",n._3_2_2="3-2-2",n))(Ii||{}),ri=class{constructor(...t){d(this,"beatCount");d(this,"beatSize");d(this,"beatLength");d(this,"measureTicks");d(this,"beamGroupSizes",[]);let e;if(y.isEnumValue(t[0],lo)){let o=t[0].split("/");this.beatCount=+o[0],this.beatSize=+o[1],y.isEnumValue(t[1],Ii)&&(e=t[1])}else if(y.isIntegerGte(t[0],2)&&y.isIntegerGte(t[1],2))this.beatCount=t[0],this.beatSize=t[1],y.isEnumValue(t[2],Ii)&&(e=t[2]);else throw new N(5,`Invalid args: ${t}`);if(y.isIntegerGte(this.beatCount,1)){if(!y.isIntegerGte(this.beatSize,1))throw new N(5,`Invalid beatSize: ${this.beatSize}`)}else throw new N(5,`Invalid beatCount: ${this.beatCount}`);let{noteLength:r,ticks:n}=Tt.create(this.beatSize);if(this.beatLength=r,this.measureTicks=this.beatCount*n,this.is(2,4))this.beamGroupSizes=[[2],[2]];else if(this.is(3,4))this.beamGroupSizes=[[2],[2],[2]];else if(this.is(4,4))this.beamGroupSizes=[[2,2],[2,2]];else if(this.is(3,8))this.beamGroupSizes=[[3]];else if(this.is(5,8)){if(!y.isUndefined(e)&&e!=="2-3"&&e!=="3-2")throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2"?[[3],[2]]:[[2],[3]],e=void 0}else if(this.is(6,8))this.beamGroupSizes=[[3],[3]];else if(this.is(7,8)){if(!y.isUndefined(e)&&e!=="2-2-3"&&e!=="3-2-2")throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`);this.beamGroupSizes=e==="3-2-2"?[[3],[2],[2]]:[[2],[2],[3]],e=void 0}else this.is(9,8)?this.beamGroupSizes=[[3],[3],[3]]:this.is(12,8)&&(this.beamGroupSizes=[[3],[3],[3],[3]]);if(this.beamGroupSizes.length===0)throw new N(5,`Unimplemented time signature "${this.toString()}".`);if(e!==void 0)throw new N(5,`Invalid beam grouping "${e}" for time signature "${this.toString()}".`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},cu;function zs(){return cu||(cu=new ri(4,4)),cu}var uu;function Ys(){return uu||(uu={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),uu}function Hs(i){return Xt.get(i.options.beatLength,i.options.dotCount).toString()+"="+i.beatsPerMinute}function hu(i,t){return{beatsPerMinute:i.beatsPerMinute*t,options:{beatLength:i.options.beatLength,dotCount:i.options.dotCount}}}Ci();function Zs(i){return!isFinite(i)||i<=0?-1/0:20*Math.log10(i)}var po="15.1.22";var du=(i,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:i});var pu=(i,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:i});var Ji=(i,t)=>({startTime:t,type:"setValue",value:i});var mo=(i,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:i});var Xs=(i,t,{startTime:e,target:r,timeConstant:n})=>r+(t-r)*Math.exp((e-i)/n);var Pr=i=>i.type==="exponentialRampToValue";var Si=i=>i.type==="linearRampToValue";var ir=i=>Pr(i)||Si(i);var tn=i=>i.type==="setValue";var Ve=i=>i.type==="setValueCurve";var en=(i,t,e,r)=>{let n=i[t];return n===void 0?r:ir(n)||tn(n)?n.value:Ve(n)?n.values[n.values.length-1]:Xs(e,en(i,t-1,n.startTime,r),n)};var mu=(i,t,e,r,n)=>e===void 0?[r.insertTime,n]:ir(e)?[e.endTime,e.value]:tn(e)?[e.startTime,e.value]:Ve(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,en(i,t-1,e.startTime,n)];var fo=i=>i.type==="cancelAndHold";var go=i=>i.type==="cancelScheduledValues";var Fr=i=>fo(i)||go(i)?i.cancelTime:Pr(i)||Si(i)?i.endTime:i.startTime;var fu=(i,t,e,{endTime:r,value:n})=>e===n?n:0<e&&0<n||e<0&&n<0?e*Dh(n/e,(i-t)/(r-t)):0;var gu=(i,t,e,{endTime:r,value:n})=>e+(i-t)/(r-t)*(n-e);var yl=(i,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?i[e]:(1-(t-e))*i[e]+(1-(r-t))*i[r]};var bl=(i,{duration:t,startTime:e,values:r})=>{let n=(i-e)/t*(r.length-1);return yl(r,n)};var yo=i=>i.type==="setTarget";var bo=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=Fr(t);if(fo(t)||go(t)){let r=this._automationEvents.findIndex(o=>go(t)&&Ve(o)?o.startTime+o.duration>=e:Fr(o)>=e),n=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),fo(t)){let o=this._automationEvents[this._automationEvents.length-1];if(n!==void 0&&ir(n)){if(o!==void 0&&yo(o))throw new Error("The internal list is malformed.");let s=o===void 0?n.insertTime:Ve(o)?o.startTime+o.duration:Fr(o),a=o===void 0?this._defaultValue:Ve(o)?o.values[o.values.length-1]:o.value,c=Pr(n)?fu(e,s,a,n):gu(e,s,a,n),u=Pr(n)?du(c,e,this._currenTime):pu(c,e,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&yo(o)&&this._automationEvents.push(Ji(this.getValue(e),e)),o!==void 0&&Ve(o)&&o.startTime+o.duration>e){let s=e-o.startTime,a=(o.values.length-1)/o.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,h=o.values.slice(0,c);if(u<1)for(let l=1;l<c;l+=1){let p=u*l%1;h[l]=o.values[l-1]*(1-p)+o.values[l]*p}this._automationEvents[this._automationEvents.length-1]=mo(h,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>Fr(s)>e),n=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(n!==void 0&&Ve(n)&&Fr(n)+n.duration>e)return!1;let o=Pr(t)?du(t.value,t.endTime,this._currenTime):Si(t)?pu(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(o);else{if(Ve(t)&&e+t.duration>Fr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>Fr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),n=r[0];yo(n)&&r.unshift(Ji(en(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=r}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;let e=this._automationEvents.findIndex(s=>Fr(s)>t),r=this._automationEvents[e],n=(e===-1?this._automationEvents.length:e)-1,o=this._automationEvents[n];if(o!==void 0&&yo(o)&&(r===void 0||!ir(r)||r.insertTime>t))return Xs(t,en(this._automationEvents,n-1,o.startTime,this._defaultValue),o);if(o!==void 0&&tn(o)&&(r===void 0||!ir(r)))return o.value;if(o!==void 0&&Ve(o)&&(r===void 0||!ir(r)||o.startTime+o.duration>t))return t<o.startTime+o.duration?bl(t,o):o.values[o.values.length-1];if(o!==void 0&&ir(o)&&(r===void 0||!ir(r)))return o.value;if(r!==void 0&&Pr(r)){let[s,a]=mu(this._automationEvents,n,o,r,this._defaultValue);return fu(t,s,a,r)}if(r!==void 0&&Si(r)){let[s,a]=mu(this._automationEvents,n,o,r,this._defaultValue);return gu(t,s,a,r)}return this._defaultValue}};var yu=i=>({cancelTime:i,type:"cancelAndHold"});var bu=i=>({cancelTime:i,type:"cancelScheduledValues"});var xu=(i,t)=>({endTime:t,type:"exponentialRampToValue",value:i});var Au=(i,t)=>({endTime:t,type:"linearRampToValue",value:i});var Cu=(i,t,e)=>({startTime:t,target:i,timeConstant:e,type:"setTarget"});var xl=()=>new DOMException("","AbortError");var Al=i=>(t,e,[r,n,o],s)=>{i(t[n],[e,r,o],a=>a[0]===e&&a[1]===r,s)};var Cl=i=>(t,e,r)=>{let n=[];for(let o=0;o<r.numberOfInputs;o+=1)n.push(new Set);i.set(t,{activeInputs:n,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var _l=i=>(t,e)=>{i.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var Cr=new WeakSet,$s=new WeakMap,rn=new WeakMap,Qs=new WeakMap,xo=new WeakMap,nn=new WeakMap,Ks=new WeakMap,Ao=new WeakMap,Co=new WeakMap,_o=new WeakMap;var vl={construct(){return vl}},Il=i=>{try{let t=new Proxy(i,vl);new t}catch(t){return!1}return!0};var Sl=/^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]*);?/,_u=(i,t)=>{let e=[],r=i.replace(/^[\s]+/,""),n=r.match(Sl);for(;n!==null;){let o=n[1].slice(1,-1),s=n[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,t).toString());e.push(s),r=r.slice(n[0].length).replace(/^[\s]+/,""),n=r.match(Sl)}return[e.join(";"),r]};var wl=i=>{if(i!==void 0&&!Array.isArray(i))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Nl=i=>{if(!Il(i))throw new TypeError("The given value for processorCtor should be a constructor.");if(i.prototype===null||typeof i.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},Tl=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>{let m=0;return(f,g,b={credentials:"omit"})=>{let x=h.get(f);if(x!==void 0&&x.has(g))return Promise.resolve();let C=u.get(f);if(C!==void 0){let S=C.get(g);if(S!==void 0)return S}let I=o(f),T=I.audioWorklet===void 0?n(g).then(([S,v])=>{let[A,_]=_u(S,v),E=`${A};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${_}
|
|
3
|
+
})})(window,'_AWGS')`;return e(E)}).then(()=>{let S=p._AWGS.pop();if(S===void 0)throw new SyntaxError;r(I.currentTime,I.sampleRate,()=>S(class{},void 0,(v,A)=>{if(v.trim()==="")throw t();let _=Co.get(I);if(_!==void 0){if(_.has(v))throw t();Nl(A),wl(A.parameterDescriptors),_.set(v,A)}else Nl(A),wl(A.parameterDescriptors),Co.set(I,new Map([[v,A]]))},I.sampleRate,void 0,void 0))}):Promise.all([n(g),Promise.resolve(i(l,l))]).then(([[S,v],A])=>{let _=m+1;m=_;let[E,V]=_u(S,v),D=`${E};((AudioWorkletProcessor,registerProcessor)=>{${V}
|
|
4
|
+
})(${A?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${A?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${A?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${_}',class extends AudioWorkletProcessor{process(){return !1}})`,k=new Blob([D],{type:"application/javascript; charset=utf-8"}),j=URL.createObjectURL(k);return I.audioWorklet.addModule(j,b).then(()=>{if(a(I))return I;let q=s(I);return q.audioWorklet.addModule(j,b).then(()=>q)}).then(q=>{if(c===null)throw new SyntaxError;try{new c(q,`__sac${_}`)}catch(K){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(j))});return C===void 0?u.set(f,new Map([[g,T]])):C.set(g,T),T.then(()=>{let S=h.get(f);S===void 0?h.set(f,new Set([g])):S.add(g)}).finally(()=>{let S=u.get(f);S!==void 0&&S.delete(g)}),T}};var $t=(i,t)=>{let e=i.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var ii=(i,t)=>{let e=Array.from(i).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");let[r]=e;return i.delete(r),r};var Js=(i,t,e,r)=>{let n=$t(i,t),o=ii(n,s=>s[0]===e&&s[1]===r);return n.size===0&&i.delete(t),o};var _r=i=>$t(Ks,i);var nr=i=>{if(Cr.has(i))throw new Error("The AudioNode is already stored.");Cr.add(i),_r(i).forEach(t=>t(!0))};var ta=i=>"port"in i;var vr=i=>{if(!Cr.has(i))throw new Error("The AudioNode is not stored.");Cr.delete(i),_r(i).forEach(t=>t(!1))};var vo=(i,t)=>{!ta(i)&&t.every(e=>e.size===0)&&vr(i)};var Ol=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>{let m=new WeakMap;return(f,g,b,x,C)=>{let{activeInputs:I,passiveInputs:T}=o(g),{outputs:S}=o(f),v=a(f),A=_=>{let E=c(g),V=c(f);if(_){let M=Js(T,f,b,x);i(I,f,M,!1),!C&&!l(f)&&e(V,E,b,x),p(g)&&nr(g)}else{let M=r(I,f,b,x);t(T,x,M,!1),!C&&!l(f)&&n(V,E,b,x);let R=s(g);if(R===0)h(g)&&vo(g,I);else{let P=m.get(g);P!==void 0&&clearTimeout(P),m.set(g,setTimeout(()=>{h(g)&&vo(g,I)},R*1e3))}}};return u(S,[g,b,x],_=>_[0]===g&&_[1]===b&&_[2]===x,!0)?(v.add(A),h(f)?i(I,f,[b,x,A],!0):t(T,x,[f,b,A],!0),!0):!1}};var Rl=i=>(t,e,[r,n,o],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[n,e,o]])):i(a,[n,e,o],c=>c[0]===n&&c[1]===e,s)};var Ml=i=>(t,e)=>{let r=i(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(r).connect(t.destination);let n=()=>{e.removeEventListener("ended",n),e.disconnect(r),r.disconnect()};e.addEventListener("ended",n)};var El=i=>(t,e)=>{i(t).add(e)};var kA={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Dl=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),h=O(O({},kA),c),l=r(u,h),p=o(u)?t():null;super(a,!1,l,p),this._nativeAnalyserNode=l}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){let c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){let c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}};var _t=(i,t)=>i.context===t;var kl=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>J(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var on=i=>{try{i.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var qe=()=>new DOMException("","IndexSizeError");var sn=i=>{i.getChannelData=(t=>e=>{try{return t.call(i,e)}catch(r){throw r.code===12?qe():r}})(i.getChannelData)};var LA={numberOfChannels:1},Ll=(i,t,e,r,n,o,s,a)=>{let c=null;return class jl{constructor(h){if(n===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:l,numberOfChannels:p,sampleRate:m}=O(O({},LA),h);c===null&&(c=new n(1,1,44100));let f=r!==null&&t(o,o)?new r({length:l,numberOfChannels:p,sampleRate:m}):c.createBuffer(p,l,m);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),sn(f)):t(on,()=>on(f))||a(f),i.add(f),f}static[Symbol.hasInstance](h){return h!==null&&typeof h=="object"&&Object.getPrototypeOf(h)===jl.prototype||i.has(h)}}};var Ut=-34028234663852886e22,Gt=-Ut;var xe=i=>Cr.has(i);var jA={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},Pl=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=O(O({},jA),h),m=n(l,p),f=s(l),g=f?t():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=e(this,f,m.playbackRate,Gt,Ut)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(u){if(this._nativeAudioBufferSourceNode.buffer=u,u!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(u){this._nativeAudioBufferSourceNode.loop=u}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(u){this._nativeAudioBufferSourceNode.loopEnd=u}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(u){this._nativeAudioBufferSourceNode.loopStart=u}get onended(){return this._onended}set onended(u){let h=typeof u=="function"?a(this,u):null;this._nativeAudioBufferSourceNode.onended=h;let l=this._nativeAudioBufferSourceNode.onended;this._onended=l!==null&&l===h?u:l}get playbackRate(){return this._playbackRate}start(u=0,h=0,l){if(this._nativeAudioBufferSourceNode.start(u,h,l),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=l===void 0?[u,h]:[u,h,l]),this.context.state!=="closed"){nr(this);let p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),xe(this)&&vr(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var Fl=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,h)=>J(null,null,function*(){let l=e(u),p=_t(l,h);if(!p){let m={buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value};l=t(h,m),s!==null&&l.start(...s),a!==null&&l.stop(a)}return o.set(h,l),p?yield i(h,u.playbackRate,l.playbackRate):yield r(h,u.playbackRate,l.playbackRate),yield n(u,h,l),l});return{set start(u){s=u},set stop(u){a=u},render(u,h){let l=o.get(h);return l!==void 0?Promise.resolve(l):c(u,h)}}};var Bl=i=>"playbackRate"in i;var Gl=i=>"frequency"in i&&"gain"in i;var Vl=i=>"offset"in i;var ql=i=>!("frequency"in i)&&"gain"in i;var Wl=i=>"detune"in i&&"frequency"in i&&!("gain"in i);var Ul=i=>"pan"in i;var re=i=>$t($s,i);var ni=i=>$t(Qs,i);var ea=(i,t)=>{let{activeInputs:e}=re(i);e.forEach(n=>n.forEach(([o])=>{t.includes(i)||ea(o,[...t,i])}));let r=Bl(i)?[i.playbackRate]:ta(i)?Array.from(i.parameters.values()):Gl(i)?[i.Q,i.detune,i.frequency,i.gain]:Vl(i)?[i.offset]:ql(i)?[i.gain]:Wl(i)?[i.detune,i.frequency]:Ul(i)?[i.pan]:[];for(let n of r){let o=ni(n);o!==void 0&&o.activeInputs.forEach(([s])=>ea(s,t))}xe(i)&&vr(i)};var oi=i=>{ea(i.destination,[])};var ra=i=>i===void 0||typeof i=="number"||typeof i=="string"&&(i==="balanced"||i==="interactive"||i==="playback");var zl=(i,t,e,r,n,o,s,a,c)=>class extends i{constructor(h={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let l;try{l=new c(h)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?e():f}if(l===null)throw r();if(!ra(h.latencyHint))throw new TypeError(`The provided value '${h.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(h.sampleRate!==void 0&&l.sampleRate!==h.sampleRate)throw e();super(l,2);let{latencyHint:p}=h,{sampleRate:m}=l;if(this._baseLatency=typeof l.baseLatency=="number"?l.baseLatency:p==="balanced"?512/m:p==="interactive"||p===void 0?256/m:p==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(p*m/128)))*128/m,this._nativeAudioContext=l,c.name==="webkitAudioContext"?(this._nativeGainNode=l.createGain(),this._nativeOscillatorNode=l.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(l.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,l.state==="running"){this._state="suspended";let f=()=>{this._state==="suspended"&&(this._state=null),l.removeEventListener("statechange",f)};l.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),oi(this)}))}createMediaElementSource(h){return new n(this,{mediaElement:h})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(h){return new s(this,{mediaStream:h})}createMediaStreamTrackSource(h){return new a(this,{mediaStreamTrack:h})}resume(){return this._state==="suspended"?new Promise((h,l)=>{let p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?h():this.resume().then(h,l)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(h=>{throw h===void 0||h.code===15?t():h})}suspend(){return this._nativeAudioContext.suspend().catch(h=>{throw h===void 0?t():h})}};var Yl=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=s(l),m=n(l,h,p),f=p?t(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}};var Hl=i=>{let t=new WeakMap,e=(r,n)=>J(null,null,function*(){let o=n.destination;return t.set(n,o),yield i(r,n,o),o});return{render(r,n){let o=t.get(n);return o!==void 0?Promise.resolve(o):e(r,n)}}};var Zl=(i,t,e,r,n,o,s,a)=>(c,u)=>{let h=u.listener,l=()=>{let S=new Float32Array(1),v=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),A=s(u),_=!1,E=[0,0,-1,0,1,0],V=[0,0,0],M=()=>{if(_)return;_=!0;let k=r(u,256,9,0);k.onaudioprocess=({inputBuffer:j})=>{let q=[o(j,S,0),o(j,S,1),o(j,S,2),o(j,S,3),o(j,S,4),o(j,S,5)];q.some((Z,B)=>Z!==E[B])&&(h.setOrientation(...q),E=q);let K=[o(j,S,6),o(j,S,7),o(j,S,8)];K.some((Z,B)=>Z!==V[B])&&(h.setPosition(...K),V=K)},v.connect(k)},R=k=>j=>{j!==E[k]&&(E[k]=j,h.setOrientation(...E))},P=k=>j=>{j!==V[k]&&(V[k]=j,h.setPosition(...V))},D=(k,j,q)=>{let K=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:j});K.connect(v,0,k),K.start(),Object.defineProperty(K.offset,"defaultValue",{get(){return j}});let Z=i({context:c},A,K.offset,Gt,Ut);return a(Z,"value",B=>()=>B.call(Z),B=>dt=>{try{B.call(Z,dt)}catch(Ct){if(Ct.code!==9)throw Ct}M(),A&&q(dt)}),Z.cancelAndHoldAtTime=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.cancelAndHoldAtTime),Z.cancelScheduledValues=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.cancelScheduledValues),Z.exponentialRampToValueAtTime=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.exponentialRampToValueAtTime),Z.linearRampToValueAtTime=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.linearRampToValueAtTime),Z.setTargetAtTime=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.setTargetAtTime),Z.setValueAtTime=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.setValueAtTime),Z.setValueCurveAtTime=(B=>A?()=>{throw n()}:(...dt)=>{let Ct=B.apply(Z,dt);return M(),Ct})(Z.setValueCurveAtTime),Z};return{forwardX:D(0,0,R(0)),forwardY:D(1,0,R(1)),forwardZ:D(2,-1,R(2)),positionX:D(6,0,P(0)),positionY:D(7,0,P(1)),positionZ:D(8,0,P(2)),upX:D(3,0,R(3)),upY:D(4,1,R(4)),upZ:D(5,0,R(5))}},{forwardX:p,forwardY:m,forwardZ:f,positionX:g,positionY:b,positionZ:x,upX:C,upY:I,upZ:T}=h.forwardX===void 0?l():h;return{get forwardX(){return p},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return b},get positionZ(){return x},get upX(){return C},get upY(){return I},get upZ(){return T}}};var wi=i=>"context"in i;var si=i=>wi(i[0]);var or=(i,t,e,r)=>{for(let n of i)if(e(n)){if(r)return!1;throw Error("The set contains at least one similar element.")}return i.add(t),!0};var vu=(i,t,[e,r],n)=>{or(i,[t,e,r],o=>o[0]===t&&o[1]===e,n)};var Iu=(i,[t,e,r],n)=>{let o=i.get(t);o===void 0?i.set(t,new Set([[e,r]])):or(o,[e,r],s=>s[0]===e,n)};var We=i=>"inputs"in i;var an=(i,t,e,r)=>{if(We(t)){let n=t.inputs[r];return i.connect(n,e,0),[n,e,0]}return i.connect(t,e,r),[t,e,r]};var Su=(i,t,e)=>{for(let r of i)if(r[0]===t&&r[1]===e)return i.delete(r),r;return null};var Xl=(i,t,e)=>ii(i,r=>r[0]===t&&r[1]===e);var wu=(i,t)=>{if(!_r(i).delete(t))throw new Error("Missing the expected event listener.")};var Nu=(i,t,e)=>{let r=$t(i,t),n=ii(r,o=>o[0]===e);return r.size===0&&i.delete(t),n};var cn=(i,t,e,r)=>{We(t)?i.disconnect(t.inputs[r],e,0):i.disconnect(t,e,r)};var Ot=i=>$t(rn,i);var Ni=i=>$t(xo,i);var Br=i=>Ao.has(i);var un=i=>!Cr.has(i);var Tu=(i,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=i.createScriptProcessor(256,1,1),n=i.createGain(),o=i.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=i.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(i.destination),a.connect(n),a.disconnect(n),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,h=>h===1)?e(!0):e(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(i.destination)},a.start()}});var ia=(i,t)=>{let e=new Map;for(let r of i)for(let n of r){let o=e.get(n);e.set(n,o===void 0?1:o+1)}e.forEach((r,n)=>t(n,r))};var Ti=i=>"context"in i;var $l=i=>{let t=new Map;i.connect=(e=>(r,n=0,o=0)=>{let s=Ti(r)?e(r,n,o):e(r,n),a=t.get(r);return a===void 0?t.set(r,[{input:o,output:n}]):a.every(c=>c.input!==o||c.output!==n)&&a.push({input:o,output:n}),s})(i.connect.bind(i)),i.disconnect=(e=>(r,n,o)=>{if(e.apply(i),r===void 0)t.clear();else if(typeof r=="number")for(let[s,a]of t){let c=a.filter(u=>u.output!==r);c.length===0?t.delete(s):t.set(s,c)}else if(t.has(r))if(n===void 0)t.delete(r);else{let s=t.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==n&&(c.input!==o||o===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{Ti(s)?i.connect(s,c.output,c.input):i.connect(s,c.output)})})(i.disconnect)};var PA=(i,t,e,r)=>{let{activeInputs:n,passiveInputs:o}=ni(t),{outputs:s}=re(i),a=_r(i),c=u=>{let h=Ot(i),l=Ni(t);if(u){let p=Nu(o,i,e);vu(n,i,p,!1),!r&&!Br(i)&&h.connect(l,e)}else{let p=Xl(n,i,e);Iu(o,p,!1),!r&&!Br(i)&&h.disconnect(l,e)}};return or(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),xe(i)?vu(n,i,[e,c],!0):Iu(o,[i,e,c],!0),!0):!1},FA=(i,t,e,r)=>{let{activeInputs:n,passiveInputs:o}=re(t),s=Su(n[r],i,e);return s===null?[Js(o,i,e,r)[2],!1]:[s[2],!0]},BA=(i,t,e)=>{let{activeInputs:r,passiveInputs:n}=ni(t),o=Su(r,i,e);return o===null?[Nu(n,i,e)[1],!1]:[o[2],!0]},Ou=(i,t,e,r,n)=>{let[o,s]=FA(i,e,r,n);if(o!==null&&(wu(i,o),s&&!t&&!Br(i)&&cn(Ot(i),Ot(e),r,n)),xe(e)){let{activeInputs:a}=re(e);vo(e,a)}},Ru=(i,t,e,r)=>{let[n,o]=BA(i,e,r);n!==null&&(wu(i,n),o&&!t&&!Br(i)&&Ot(i).disconnect(Ni(e),r))},GA=(i,t)=>{let e=re(i),r=[];for(let n of e.outputs)si(n)?Ou(i,t,...n):Ru(i,t,...n),r.push(n[0]);return e.outputs.clear(),r},VA=(i,t,e)=>{let r=re(i),n=[];for(let o of r.outputs)o[1]===e&&(si(o)?Ou(i,t,...o):Ru(i,t,...o),n.push(o[0]),r.outputs.delete(o));return n},qA=(i,t,e,r,n)=>{let o=re(i);return Array.from(o.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(n===void 0||s[2]===n)).map(s=>(si(s)?Ou(i,t,...s):Ru(i,t,...s),o.outputs.delete(s),s[0]))},Ql=(i,t,e,r,n,o,s,a,c,u,h,l,p,m,f,g)=>class extends u{constructor(x,C,I,T){super(I),this._context=x,this._nativeAudioNode=I;let S=h(x);l(S)&&e(Tu,()=>Tu(S,g))!==!0&&$l(I),rn.set(this,I),Ks.set(this,new Set),x.state!=="closed"&&C&&nr(this),i(this,T,I)}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,C=0,I=0){if(C<0||C>=this._nativeAudioNode.numberOfOutputs)throw n();let T=h(this._context),S=f(T);if(p(x)||m(x))throw o();if(wi(x)){let _=Ot(x);try{let V=an(this._nativeAudioNode,_,C,I),M=un(this);(S||M)&&this._nativeAudioNode.disconnect(...V),this.context.state!=="closed"&&!M&&un(x)&&nr(x)}catch(V){throw V.code===12?o():V}if(t(this,x,C,I,S)){let V=c([this],x);ia(V,r(S))}return x}let v=Ni(x);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,C),(S||un(this))&&this._nativeAudioNode.disconnect(v,C)}catch(_){throw _.code===12?o():_}if(PA(this,x,C,S)){let _=c([this],x);ia(_,r(S))}}disconnect(x,C,I){let T,S=h(this._context),v=f(S);if(x===void 0)T=GA(this,v);else if(typeof x=="number"){if(x<0||x>=this.numberOfOutputs)throw n();T=VA(this,v,x)}else{if(C!==void 0&&(C<0||C>=this.numberOfOutputs)||wi(x)&&I!==void 0&&(I<0||I>=x.numberOfInputs))throw n();if(T=qA(this,v,x,C,I),T.length===0)throw o()}for(let A of T){let _=c([this],A);ia(_,a)}}};var Kl=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>(m,f,g,b=null,x=null)=>{let C=g.value,I=new bo(C),T=f?r(I):null,S={get defaultValue(){return C},get maxValue(){return b===null?g.maxValue:b},get minValue(){return x===null?g.minValue:x},get value(){return g.value},set value(v){g.value=v,S.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")T===null&&I.flush(m.context.currentTime),I.add(n(v)),g.cancelAndHoldAtTime(v);else{let A=Array.from(I).pop();T===null&&I.flush(m.context.currentTime),I.add(n(v));let _=Array.from(I).pop();g.cancelScheduledValues(v),A!==_&&_!==void 0&&(_.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(_.value,_.endTime):_.type==="linearRampToValue"?g.linearRampToValueAtTime(_.value,_.endTime):_.type==="setValue"?g.setValueAtTime(_.value,_.startTime):_.type==="setValueCurve"&&g.setValueCurveAtTime(_.values,_.startTime,_.duration))}return S},cancelScheduledValues(v){return T===null&&I.flush(m.context.currentTime),I.add(o(v)),g.cancelScheduledValues(v),S},exponentialRampToValueAtTime(v,A){if(v===0)throw new RangeError;if(!Number.isFinite(A)||A<0)throw new RangeError;let _=m.context.currentTime;return T===null&&I.flush(_),Array.from(I).length===0&&(I.add(u(C,_)),g.setValueAtTime(C,_)),I.add(s(v,A)),g.exponentialRampToValueAtTime(v,A),S},linearRampToValueAtTime(v,A){let _=m.context.currentTime;return T===null&&I.flush(_),Array.from(I).length===0&&(I.add(u(C,_)),g.setValueAtTime(C,_)),I.add(a(v,A)),g.linearRampToValueAtTime(v,A),S},setTargetAtTime(v,A,_){return T===null&&I.flush(m.context.currentTime),I.add(c(v,A,_)),g.setTargetAtTime(v,A,_),S},setValueAtTime(v,A){return T===null&&I.flush(m.context.currentTime),I.add(u(v,A)),g.setValueAtTime(v,A),S},setValueCurveAtTime(v,A,_){let E=v instanceof Float32Array?v:new Float32Array(v);if(l!==null&&l.name==="webkitAudioContext"){let V=A+_,M=m.context.sampleRate,R=Math.ceil(A*M),P=Math.floor(V*M),D=P-R,k=new Float32Array(D);for(let q=0;q<D;q+=1){let K=(E.length-1)/_*((R+q)/M-A),Z=Math.floor(K),B=Math.ceil(K);k[q]=Z===B?E[Z]:(1-(K-Z))*E[Z]+(1-(B-K))*E[B]}T===null&&I.flush(m.context.currentTime),I.add(h(k,A,_)),g.setValueCurveAtTime(k,A,_);let j=P/M;j<V&&p(S,k[k.length-1],j),p(S,E[E.length-1],V)}else T===null&&I.flush(m.context.currentTime),I.add(h(E,A,_)),g.setValueCurveAtTime(E,A,_);return S}};return e.set(S,g),t.set(S,m),i(S,T),S};var Jl=i=>({replay(t){for(let e of i)if(e.type==="exponentialRampToValue"){let{endTime:r,value:n}=e;t.exponentialRampToValueAtTime(n,r)}else if(e.type==="linearRampToValue"){let{endTime:r,value:n}=e;t.linearRampToValueAtTime(n,r)}else if(e.type==="setTarget"){let{startTime:r,target:n,timeConstant:o}=e;t.setTargetAtTime(n,r,o)}else if(e.type==="setValue"){let{startTime:r,value:n}=e;t.setValueAtTime(n,r)}else if(e.type==="setValueCurve"){let{duration:r,startTime:n,values:o}=e;t.setValueCurveAtTime(o,n,r)}else throw new Error("Can't apply an unknown automation.")}});var hn=class{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((r,n)=>t.call(e,r,n,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}};var WA={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},td=(i,t,e,r,n,o,s,a,c,u,h,l,p,m)=>class extends t{constructor(g,b,x){var C;let I=a(g),T=c(I),S=h(O(O({},WA),x));p(S);let v=Co.get(I),A=v==null?void 0:v.get(b),_=T||I.state!=="closed"?I:(C=s(I))!==null&&C!==void 0?C:I,E=n(_,T?null:g.baseLatency,u,b,A,S),V=T?r(b,S,A):null;super(g,!0,E,V);let M=[];E.parameters.forEach((P,D)=>{let k=e(this,T,P);M.push([D,k])}),this._nativeAudioWorkletNode=E,this._onprocessorerror=null,this._parameters=new hn(M),T&&i(I,this);let{activeInputs:R}=o(this);l(E,R)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let b=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=b;let x=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=x!==null&&x===b?g:x}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function ln(i,t,e,r,n){if(typeof i.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),i.copyFromChannel(t[e],r,n);else{let o=i.getChannelData(r);if(t[e].byteLength===0)t[e]=o.slice(n,n+128);else{let s=new Float32Array(o.buffer,n*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var na=(i,t,e,r,n)=>{typeof i.copyToChannel=="function"?t[e].byteLength!==0&&i.copyToChannel(t[e],r,n):t[e].byteLength!==0&&i.getChannelData(r).set(t[e],n)};var dn=(i,t)=>{let e=[];for(let r=0;r<i;r+=1){let n=[],o=typeof t=="number"?t:t[r];for(let s=0;s<o;s+=1)n.push(new Float32Array(128));e.push(n)}return e};var ed=(i,t)=>{let e=$t(_o,i),r=Ot(t);return $t(e,r)};var UA=(i,t,e,r,n,o,s)=>J(null,null,function*(){let a=t===null?Math.ceil(i.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=n.reduce((b,x)=>b+x,0),h=u===0?null:e.createBuffer(u,a,e.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let l=re(i),p=yield ed(e,i),m=dn(r.numberOfInputs,r.channelCount),f=dn(r.numberOfOutputs,n),g=Array.from(i.parameters.keys()).reduce((b,x)=>Q(O({},b),{[x]:new Float32Array(128)}),{});for(let b=0;b<a;b+=128){if(r.numberOfInputs>0&&t!==null)for(let x=0;x<r.numberOfInputs;x+=1)for(let C=0;C<r.channelCount;C+=1)ln(t,m[x],C,C,b);o.parameterDescriptors!==void 0&&t!==null&&o.parameterDescriptors.forEach(({name:x},C)=>{ln(t,g,x,c+C,b)});for(let x=0;x<r.numberOfInputs;x+=1)for(let C=0;C<n[x];C+=1)f[x][C].byteLength===0&&(f[x][C]=new Float32Array(128));try{let x=m.map((I,T)=>l.activeInputs[T].size===0?[]:I),C=s(b/e.sampleRate,e.sampleRate,()=>p.process(x,f,g));if(h!==null)for(let I=0,T=0;I<r.numberOfOutputs;I+=1){for(let S=0;S<n[I];S+=1)na(h,f[I],S,T+S,b);T+=n[I]}if(!C)break}catch(x){i.dispatchEvent(new ErrorEvent("processorerror",{colno:x.colno,filename:x.filename,lineno:x.lineno,message:x.message}));break}}return h}),rd=(i,t,e,r,n,o,s,a,c,u,h,l,p,m,f,g)=>(b,x,C)=>{let I=new WeakMap,T=null,S=(v,A)=>J(null,null,function*(){let _=h(v),E=null,V=_t(_,A),M=Array.isArray(x.outputChannelCount)?x.outputChannelCount:Array.from(x.outputChannelCount);if(l===null){let R=M.reduce((j,q)=>j+q,0),P=n(A,{channelCount:Math.max(1,R),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,R)}),D=[];for(let j=0;j<v.numberOfOutputs;j+=1)D.push(r(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:M[j]}));let k=s(A,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1});k.connect=t.bind(null,D),k.disconnect=c.bind(null,D),E=[P,D,k]}else V||(_=new l(A,b));if(I.set(A,E===null?_:E[2]),E!==null){if(T===null){if(C===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let q=v.channelCount*v.numberOfInputs,K=C.parameterDescriptors===void 0?0:C.parameterDescriptors.length,Z=q+K;T=UA(v,Z===0?null:yield J(null,null,function*(){let dt=new p(Z,Math.ceil(v.context.length/128)*128,A.sampleRate),Ct=[],Wt=[];for(let Nt=0;Nt<x.numberOfInputs;Nt+=1)Ct.push(s(dt,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1})),Wt.push(n(dt,{channelCount:x.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:x.channelCount}));let Ee=yield Promise.all(Array.from(v.parameters.values()).map(Nt=>J(null,null,function*(){let ct=o(dt,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:Nt.value});return yield m(dt,Nt,ct.offset),ct}))),De=r(dt,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,q+K)});for(let Nt=0;Nt<x.numberOfInputs;Nt+=1){Ct[Nt].connect(Wt[Nt]);for(let ct=0;ct<x.channelCount;ct+=1)Wt[Nt].connect(De,ct,Nt*x.channelCount+ct)}for(let[Nt,ct]of Ee.entries())ct.connect(De,0,q+Nt),ct.start(0);return De.connect(dt.destination),yield Promise.all(Ct.map(Nt=>f(v,dt,Nt))),g(dt)}),A,x,M,C,u)}let R=yield T,P=e(A,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[D,k,j]=E;R!==null&&(P.buffer=R,P.start(0)),P.connect(D);for(let q=0,K=0;q<v.numberOfOutputs;q+=1){let Z=k[q];for(let B=0;B<M[q];B+=1)D.connect(Z,K+B,B);K+=M[q]}return j}if(V)for(let[R,P]of v.parameters.entries())yield i(A,P,_.parameters.get(R));else for(let[R,P]of v.parameters.entries())yield m(A,P,_.parameters.get(R));return yield f(v,A,_),_});return{render(v,A){a(A,v);let _=I.get(A);return _!==void 0?Promise.resolve(_):S(v,A)}}};var id=(i,t,e,r,n,o,s,a,c,u,h,l,p,m,f,g,b,x,C,I)=>class extends f{constructor(S,v){super(S,v),this._nativeContext=S,this._audioWorklet=i===void 0?void 0:{addModule:(A,_)=>i(this,A,_)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new n(this)}createBuffer(S,v,A){return new e({length:v,numberOfChannels:S,sampleRate:A})}createBufferSource(){return new r(this)}createChannelMerger(S=6){return new o(this,{numberOfInputs:S})}createChannelSplitter(S=6){return new s(this,{numberOfOutputs:S})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(S=1){return new h(this,{maxDelayTime:S})}createDynamicsCompressor(){return new l(this)}createGain(){return new p(this)}createIIRFilter(S,v){return new m(this,{feedback:v,feedforward:S})}createOscillator(){return new g(this)}createPanner(){return new b(this)}createPeriodicWave(S,v,A={disableNormalization:!1}){return new x(this,Q(O({},A),{imag:v,real:S}))}createStereoPanner(){return new C(this)}createWaveShaper(){return new I(this)}decodeAudioData(S,v,A){return u(this._nativeContext,S).then(_=>(typeof v=="function"&&v(_),_),_=>{throw typeof A=="function"&&A(_),_})}};var zA={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},nd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=O(O({},zA),h),m=n(l,p),f=s(l),g=f?e():null;super(u,!1,m,g),this._Q=t(this,f,m.Q,Gt,Ut),this._detune=t(this,f,m.detune,1200*Math.log2(Gt),-1200*Math.log2(Gt)),this._frequency=t(this,f,m.frequency,u.sampleRate/2,0),this._gain=t(this,f,m.gain,40*Math.log10(Gt),Ut),this._nativeBiquadFilterNode=m,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(u){this._nativeBiquadFilterNode.type=u}getFrequencyResponse(u,h,l){try{this._nativeBiquadFilterNode.getFrequencyResponse(u,h,l)}catch(p){throw p.code===11?r():p}if(u.length!==h.length||h.length!==l.length)throw r()}};var od=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>J(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,l)}return o.set(c,u),h?(yield i(c,a.Q,u.Q),yield i(c,a.detune,u.detune),yield i(c,a.frequency,u.frequency),yield i(c,a.gain,u.gain)):(yield r(c,a.Q,u.Q),yield r(c,a.detune,u.detune),yield r(c,a.frequency,u.frequency),yield r(c,a.gain,u.gain)),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var sd=(i,t)=>(e,r)=>{let n=t.get(e);if(n!==void 0)return n;let o=i.get(e);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(i.set(e,s),s.catch(()=>!1).then(a=>(i.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var YA={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},ad=(i,t,e,r,n)=>class extends i{constructor(s,a){let c=r(s),u=O(O({},YA),a),h=e(c,u),l=n(c)?t():null;super(s,!1,h,l)}};var cd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>J(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var HA={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},ud=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),h=o(O(O({},HA),c)),l=e(u,h),p=n(u)?t():null;super(a,!1,l,p)}};var hd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>J(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=i(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var ld=i=>(t,e,r)=>i(e,t,r);var dd=i=>(t,e,r=0,n=0)=>{let o=t[r];if(o===void 0)throw i();return Ti(e)?o.connect(e,0,n):o.connect(e,0)};var pd=i=>(t,e)=>{let r=i(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),n=t.createBuffer(1,2,44100);return r.buffer=n,r.loop=!0,r.connect(e),r.start(),()=>{r.stop(),r.disconnect(e)}};var ZA={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},md=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},ZA),u),p=r(h,l),m=o(h),f=m?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,m,p.offset,Gt,Ut),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeConstantSourceNode.onended=u;let h=this._nativeConstantSourceNode.onended;this._onended=h!==null&&h===u?c:h}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){nr(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),xe(this)&&vr(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var fd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,h)=>J(null,null,function*(){let l=e(u),p=_t(l,h);if(!p){let m={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,offset:l.offset.value};l=t(h,m),s!==null&&l.start(s),a!==null&&l.stop(a)}return o.set(h,l),p?yield i(h,u.offset,l.offset):yield r(h,u.offset,l.offset),yield n(u,h,l),l});return{set start(u){s=u},set stop(u){a=u},render(u,h){let l=o.get(h);return l!==void 0?Promise.resolve(l):c(u,h)}}};var gd=i=>t=>(i[0]=t,i[0]);var XA={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},yd=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),h=O(O({},XA),c),l=e(u,h),m=n(u)?t():null;super(a,!1,l,m),this._isBufferNullified=!1,this._nativeConvolverNode=l,h.buffer!==null&&o(this,h.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){let c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var bd=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>J(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=i(s,u)}return r.set(s,a),We(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var xd=(i,t)=>(e,r,n)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,n)}catch(o){throw o.name==="SyntaxError"?i():o}};var Ad=()=>new DOMException("","DataCloneError");var Mu=i=>{let{port1:t,port2:e}=new MessageChannel;return new Promise(r=>{let n=()=>{e.onmessage=null,t.close(),e.close(),r()};e.onmessage=()=>n();try{t.postMessage(i,[i])}catch(o){}finally{n()}})};var Cd=(i,t,e,r,n,o,s,a,c,u,h)=>(l,p)=>{let m=s(l)?l:o(l);if(n.has(p)){let f=e();return Promise.reject(f)}try{n.add(p)}catch(f){}return t(c,()=>c(m))?m.decodeAudioData(p).then(f=>(Mu(p).catch(()=>{}),t(a,()=>a(f))||h(f),i.add(f),f)):new Promise((f,g)=>{let b=()=>J(null,null,function*(){try{yield Mu(p)}catch(C){}}),x=C=>{g(C),b()};try{m.decodeAudioData(p,C=>{typeof C.copyFromChannel!="function"&&(u(C),sn(C)),i.add(C),b().then(()=>f(C))},C=>{x(C===null?r():C)})}catch(C){x(C)}})};var _d=(i,t,e,r,n,o,s,a)=>(c,u)=>{let h=t.get(c);if(h===void 0)throw new Error("Missing the expected cycle count.");let l=o(c.context),p=a(l);if(h===u){if(t.delete(c),!p&&s(c)){let m=r(c),{outputs:f}=e(c);for(let g of f)if(si(g)){let b=r(g[0]);i(m,b,g[1],g[2])}else{let b=n(g[0]);m.connect(b,g[1])}}}else t.set(c,h-u)};var $A={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},vd=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},$A),u),p=r(h,l),m=o(h),f=m?e(l.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,m,p.delayTime),s(this,l.maxDelayTime)}get delayTime(){return this._delayTime}};var Id=(i,t,e,r,n)=>o=>{let s=new WeakMap,a=(c,u)=>J(null,null,function*(){let h=e(c),l=_t(h,u);if(!l){let p={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,delayTime:h.delayTime.value,maxDelayTime:o};h=t(u,p)}return s.set(u,h),l?yield i(u,c.delayTime,h.delayTime):yield r(u,c.delayTime,h.delayTime),yield n(c,u,h),h});return{render(c,u){let h=s.get(u);return h!==void 0?Promise.resolve(h):a(c,u)}}};var Sd=i=>(t,e,r,n)=>i(t[n],o=>o[0]===e&&o[1]===r);var wd=i=>(t,e)=>{i(t).delete(e)};var Nd=i=>"delayTime"in i;var Td=(i,t,e)=>function r(n,o){let s=wi(o)?o:e(i,o);if(Nd(s))return[];if(n[0]===s)return[n];if(n.includes(s))return[];let{outputs:a}=t(s);return Array.from(a).map(c=>r([...n,s],c[0])).reduce((c,u)=>c.concat(u),[])};var oa=(i,t,e)=>{let r=t[e];if(r===void 0)throw i();return r},Od=i=>(t,e=void 0,r=void 0,n=0)=>e===void 0?t.forEach(o=>o.disconnect()):typeof e=="number"?oa(i,t,e).disconnect():Ti(e)?r===void 0?t.forEach(o=>o.disconnect(e)):n===void 0?oa(i,t,r).disconnect(e,0):oa(i,t,r).disconnect(e,0,n):r===void 0?t.forEach(o=>o.disconnect(e)):oa(i,t,r).disconnect(e,0);var QA={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Rd=(i,t,e,r,n,o,s,a)=>class extends i{constructor(u,h){let l=o(u),p=O(O({},QA),h),m=r(l,p),f=s(l),g=f?e():null;super(u,!1,m,g),this._attack=t(this,f,m.attack),this._knee=t(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=t(this,f,m.ratio),this._release=t(this,f,m.release),this._threshold=t(this,f,m.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){let h=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=h,n()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(u){let h=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=u,u==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=h,n()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value=="number"?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}};var Md=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>J(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,l)}return o.set(c,u),h?(yield i(c,a.attack,u.attack),yield i(c,a.knee,u.knee),yield i(c,a.ratio,u.ratio),yield i(c,a.release,u.release),yield i(c,a.threshold,u.threshold)):(yield r(c,a.attack,u.attack),yield r(c,a.knee,u.knee),yield r(c,a.ratio,u.ratio),yield r(c,a.release,u.release),yield r(c,a.threshold,u.threshold)),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Ed=()=>new DOMException("","EncodingError");var Dd=i=>t=>new Promise((e,r)=>{if(i===null){r(new SyntaxError);return}let n=i.document.head;if(n===null)r(new SyntaxError);else{let o=i.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=i.onerror,u=()=>{i.onerror=c,URL.revokeObjectURL(a)};i.onerror=(h,l,p,m,f)=>{if(l===a||l===i.location.href&&p===1&&m===1)return u(),r(f),!1;if(c!==null)return c(h,l,p,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),e()},o.src=a,o.type="module",n.appendChild(o)}});var kd=i=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,n){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=i(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(e,o,n)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,n){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,o===void 0?null:o,n)}};var Ld=i=>(t,e,r)=>{Object.defineProperties(i,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{i!==null&&(delete i.currentFrame,delete i.currentTime)}};var jd=i=>t=>J(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw i()});var KA={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Pd=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),h=O(O({},KA),c),l=r(u,h),p=o(u),m=p?e():null;super(a,!1,l,m),this._gain=t(this,p,l.gain,Gt,Ut)}get gain(){return this._gain}};var Fd=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>J(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,l)}return o.set(c,u),h?yield i(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Bd=(i,t)=>e=>t(i,e);var Gd=i=>t=>{let e=i(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var Vd=i=>t=>{var e;return(e=i.get(t))!==null&&e!==void 0?e:0};var qd=i=>t=>{let e=i(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var Wd=i=>t=>i.get(t);var Lt=()=>new DOMException("","InvalidStateError");var Ud=i=>t=>{let e=i.get(t);if(e===void 0)throw Lt();return e};var zd=(i,t)=>e=>{let r=i.get(e);if(r!==void 0)return r;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new t(1,1,44100),i.set(e,r),r};var Yd=i=>t=>{let e=i.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var pn=()=>new DOMException("","InvalidAccessError");var Hd=i=>{i.getFrequencyResponse=(t=>(e,r,n)=>{if(e.length!==r.length||r.length!==n.length)throw pn();return t.call(i,e,r,n)})(i.getFrequencyResponse)};var JA={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Zd=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=r(a),h=n(u),l=O(O({},JA),c),p=t(u,h?null:a.baseLatency,l),m=h?e(l.feedback,l.feedforward):null;super(a,!1,p,m),Hd(p),this._nativeIIRFilterNode=p,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var sa=(i,t,e,r,n,o,s,a,c,u,h)=>{let l=u.length,p=a;for(let m=0;m<l;m+=1){let f=e[0]*u[m];for(let g=1;g<n;g+=1){let b=p-g&c-1;f+=e[g]*o[b],f-=i[g]*s[b]}for(let g=n;g<r;g+=1)f+=e[g]*o[p-g&c-1];for(let g=n;g<t;g+=1)f-=i[g]*s[p-g&c-1];o[p]=u[m],s[p]=f,p=p+1&c-1,h[m]=f}return p};var tC=(i,t,e,r)=>{let n=e instanceof Float64Array?e:new Float64Array(e),o=r instanceof Float64Array?r:new Float64Array(r),s=n.length,a=o.length,c=Math.min(s,a);if(n[0]!==1){for(let f=0;f<s;f+=1)o[f]/=n[0];for(let f=1;f<a;f+=1)n[f]/=n[0]}let u=32,h=new Float32Array(u),l=new Float32Array(u),p=t.createBuffer(i.numberOfChannels,i.length,i.sampleRate),m=i.numberOfChannels;for(let f=0;f<m;f+=1){let g=i.getChannelData(f),b=p.getChannelData(f);h.fill(0),l.fill(0),sa(n,s,o,a,c,h,l,0,u,g,b)}return p},Xd=(i,t,e,r,n)=>(o,s)=>{let a=new WeakMap,c=null,u=(h,l)=>J(null,null,function*(){let p=null,m=t(h),f=_t(m,l);if(l.createIIRFilter===void 0?p=i(l,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(m=l.createIIRFilter(s,o)),a.set(l,p===null?m:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let b=new e(h.context.destination.channelCount,h.context.length,l.sampleRate);c=J(null,null,function*(){yield r(h,b,b.destination);let x=yield n(b);return tC(x,l,o,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(h,l,m),m});return{render(h,l){let p=a.get(l);return p!==void 0?Promise.resolve(p):u(h,l)}}};var $d=(i,t,e,r,n,o)=>s=>(a,c)=>{let u=i.get(a);if(u===void 0){if(!s&&o(a)){let h=r(a),{outputs:l}=e(a);for(let p of l)if(si(p)){let m=r(p[0]);t(h,m,p[1],p[2])}else{let m=n(p[0]);h.disconnect(m,p[1])}}i.set(a,c)}else i.set(a,u+c)};var Qd=(i,t)=>e=>{let r=i.get(e);return t(r)||t(e)};var Kd=(i,t)=>e=>i.has(e)||t(e);var Jd=(i,t)=>e=>i.has(e)||t(e);var tp=(i,t)=>e=>{let r=i.get(e);return t(r)||t(e)};var ep=i=>t=>i!==null&&t instanceof i;var rp=i=>t=>i!==null&&typeof i.AudioNode=="function"&&t instanceof i.AudioNode;var ip=i=>t=>i!==null&&typeof i.AudioParam=="function"&&t instanceof i.AudioParam;var np=(i,t)=>e=>i(e)||t(e);var op=i=>t=>i!==null&&t instanceof i;var sp=i=>i!==null&&i.isSecureContext;var ap=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var eC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},cp=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o);if(r(a))throw new TypeError;let c=O(O({},eC),s),u=t(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var up=(i,t,e,r)=>class extends i{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var hp=(i,t,e)=>class extends i{constructor(n,o){let s=e(n),a=t(s,o);super(n,!0,a,null)}};var lp=(i,t,e,r,n)=>class extends r{constructor(s={}){if(n===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new n(s)}catch(h){throw h.code===12&&h.message==="sampleRate is not in range"?t():h}if(a===null)throw e();if(!ra(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw t();super(a,2);let{latencyHint:c}=s,{sampleRate:u}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/u:c==="interactive"||c===void 0?256/u:c==="playback"?1024/u:Math.max(2,Math.min(128,Math.round(c*u/128)))*128/u,this._nativeAudioContext=a,n.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";let h=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",h)};a.addEventListener("statechange",h)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw i()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),oi(this)}))}resume(){return this._state==="suspended"?new Promise((s,a)=>{let c=()=>{this._nativeAudioContext.removeEventListener("statechange",c),this._nativeAudioContext.state==="running"?s():this.resume().then(s,a)};this._nativeAudioContext.addEventListener("statechange",c)}):this._nativeAudioContext.resume().catch(s=>{throw s===void 0||s.code===15?i():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?i():s})}};var dp=(i,t,e,r,n,o)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,nn.set(this,a),r(a)&&n.set(a,new Set),this._destination=new i(this,c),this._listener=t(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){let c=typeof a=="function"?o(this,a):null;this._nativeContext.onstatechange=c;let u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?a:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}};var sr=i=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=i.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var rC={numberOfChannels:1},pp=(i,t,e,r,n)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=O(O({},rC),s),h=e(c,a,u);i(sr,()=>sr(h))||h.addEventListener("statechange",(()=>{let l=0,p=m=>{this._state==="running"&&(l>0?(h.removeEventListener("statechange",p),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):l+=1)};return p})()),super(h,c),this._length=a,this._nativeOfflineAudioContext=h,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(t()):(this._state="running",n(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,oi(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var mp=(i,t)=>(e,r,n)=>{let o=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let h=o.size===0;if(t(a))return s.call(e,a,c,u),i(o,[a,c,u],l=>l[0]===a&&l[1]===c&&l[2]===u,!0),h&&r(),a;s.call(e,a,c),i(o,[a,c],l=>l[0]===a&&l[1]===c,!0),h&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let h=o.size>0;if(a===void 0)s.apply(e),o.clear();else if(typeof a=="number"){s.call(e,a);for(let p of o)p[1]===a&&o.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of o)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&o.delete(p)}let l=o.size===0;h&&l&&n()})(e.disconnect),e};var vt=(i,t,e)=>{let r=t[e];r!==void 0&&r!==i[e]&&(i[e]=r)};var pt=(i,t)=>{vt(i,t,"channelCount"),vt(i,t,"channelCountMode"),vt(i,t,"channelInterpretation")};var Eu=i=>typeof i.getFloatTimeDomainData=="function";var fp=i=>{i.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);i.getByteTimeDomainData(e);let r=Math.max(e.length,i.fftSize);for(let n=0;n<r;n+=1)t[n]=(e[n]-128)*.0078125;return t}};var gp=(i,t)=>(e,r)=>{let n=e.createAnalyser();if(pt(n,r),!(r.maxDecibels>r.minDecibels))throw t();return vt(n,r,"fftSize"),vt(n,r,"maxDecibels"),vt(n,r,"minDecibels"),vt(n,r,"smoothingTimeConstant"),i(Eu,()=>Eu(n))||fp(n),n};var yp=i=>i===null?null:i.hasOwnProperty("AudioBuffer")?i.AudioBuffer:null;var wt=(i,t,e)=>{let r=t[e];r!==void 0&&r!==i[e].value&&(i[e].value=r)};var bp=i=>{i.start=(t=>{let e=!1;return(r=0,n=0,o)=>{if(e)throw Lt();t.call(i,r,n,o),e=!0}})(i.start)};var mn=i=>{i.start=(t=>(e=0,r=0,n)=>{if(typeof n=="number"&&n<0||r<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(i,e,r,n)})(i.start)};var fn=i=>{i.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(i,e)})(i.stop)};var xp=(i,t,e,r,n,o,s,a,c,u,h)=>(l,p)=>{let m=l.createBufferSource();return pt(m,p),wt(m,p,"playbackRate"),vt(m,p,"buffer"),vt(m,p,"loop"),vt(m,p,"loopEnd"),vt(m,p,"loopStart"),t(e,()=>e(l))||bp(m),t(r,()=>r(l))||c(m),t(n,()=>n(l))||u(m,l),t(o,()=>o(l))||mn(m),t(s,()=>s(l))||h(m,l),t(a,()=>a(l))||fn(m),i(l,m),m};var Ap=i=>i===null?null:i.hasOwnProperty("AudioContext")?i.AudioContext:i.hasOwnProperty("webkitAudioContext")?i.webkitAudioContext:null;var Cp=(i,t)=>(e,r,n)=>{let o=e.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}n&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=i(e,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>o.maxChannelCount}),s.connect(o),s};var _p=i=>i===null?null:i.hasOwnProperty("AudioWorkletNode")?i.AudioWorkletNode:null;var vp=i=>{let{port1:t}=new MessageChannel;try{t.postMessage(i)}finally{t.close()}};var Ip=(i,t,e,r,n)=>(o,s,a,c,u,h)=>{if(a!==null)try{let l=new a(o,c,h),p=new Map,m=null;if(Object.defineProperties(l,{channelCount:{get:()=>h.channelCount,set:()=>{throw i()}},channelCountMode:{get:()=>"explicit",set:()=>{throw i()}},onprocessorerror:{get:()=>m,set:f=>{typeof m=="function"&&l.removeEventListener("processorerror",m),m=typeof f=="function"?f:null,typeof m=="function"&&l.addEventListener("processorerror",m)}}}),l.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let b=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(b!==null){let x=p.get(g[1]);x!==void 0?g[1]=x:(g[1]=C=>{C.type==="error"?(Object.defineProperties(C,{type:{value:"processorerror"}}),b(C)):b(new ErrorEvent(g[0],O({},C)))},p.set(b,g[1]))}}return f.call(l,"error",g[1],g[2]),f.call(l,...g)})(l.addEventListener),l.removeEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let b=p.get(g[1]);b!==void 0&&(p.delete(g[1]),g[1]=b)}return f.call(l,"error",g[1],g[2]),f.call(l,g[0],g[1],g[2])})(l.removeEventListener),h.numberOfOutputs!==0){let f=e(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return l.connect(f).connect(o.destination),n(l,()=>f.disconnect(),()=>f.connect(o.destination))}return l}catch(l){throw l.code===11?r():l}if(u===void 0)throw r();return vp(h),t(o,s,u,h)};var aa=(i,t)=>i===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(i*t)))));var Sp=i=>new Promise((t,e)=>{let{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),n.close(),t(o)},r.onmessageerror=({data:o})=>{r.close(),n.close(),e(o)},n.postMessage(i)});var wp=(i,t)=>J(null,null,function*(){let e=yield Sp(t);return new i(e)});var Np=(i,t,e,r)=>{let n=_o.get(i);n===void 0&&(n=new WeakMap,_o.set(i,n));let o=wp(e,r);return n.set(t,o),o};var Tp=(i,t,e,r,n,o,s,a,c,u,h,l,p)=>(m,f,g,b)=>{if(b.numberOfInputs===0&&b.numberOfOutputs===0)throw c();let x=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(x.some(X=>X<1))throw c();if(x.length!==b.numberOfOutputs)throw t();if(b.channelCountMode!=="explicit")throw c();let C=b.channelCount*b.numberOfInputs,I=x.reduce((X,ot)=>X+ot,0),T=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(C+T>6||I>6)throw c();let S=new MessageChannel,v=[],A=[];for(let X=0;X<b.numberOfInputs;X+=1)v.push(s(m,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),A.push(n(m,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let _=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:X,maxValue:ot,minValue:te,name:jt}of g.parameterDescriptors){let St=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:b.parameterData[jt]!==void 0?b.parameterData[jt]:X===void 0?0:X});Object.defineProperties(St.offset,{defaultValue:{get:()=>X===void 0?0:X},maxValue:{get:()=>ot===void 0?Gt:ot},minValue:{get:()=>te===void 0?Ut:te}}),_.push(St)}let E=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,C+T)}),V=aa(f,m.sampleRate),M=a(m,V,C+T,Math.max(1,I)),R=n(m,{channelCount:Math.max(1,I),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,I)}),P=[];for(let X=0;X<b.numberOfOutputs;X+=1)P.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:x[X]}));for(let X=0;X<b.numberOfInputs;X+=1){v[X].connect(A[X]);for(let ot=0;ot<b.channelCount;ot+=1)A[X].connect(E,ot,X*b.channelCount+ot)}let D=new hn(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:X},ot)=>{let te=_[ot];return te.connect(E,0,C+ot),te.start(0),[X,te.offset]}));E.connect(M);let k=b.channelInterpretation,j=null,q=b.numberOfOutputs===0?[M]:P,K={get bufferSize(){return V},get channelCount(){return b.channelCount},set channelCount(X){throw e()},get channelCountMode(){return b.channelCountMode},set channelCountMode(X){throw e()},get channelInterpretation(){return k},set channelInterpretation(X){for(let ot of v)ot.channelInterpretation=X;k=X},get context(){return M.context},get inputs(){return v},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},get onprocessorerror(){return j},set onprocessorerror(X){typeof j=="function"&&K.removeEventListener("processorerror",j),j=typeof X=="function"?X:null,typeof j=="function"&&K.addEventListener("processorerror",j)},get parameters(){return D},get port(){return S.port2},addEventListener(...X){return M.addEventListener(X[0],X[1],X[2])},connect:i.bind(null,q),disconnect:u.bind(null,q),dispatchEvent(...X){return M.dispatchEvent(X[0])},removeEventListener(...X){return M.removeEventListener(X[0],X[1],X[2])}},Z=new Map;S.port1.addEventListener=(X=>(...ot)=>{if(ot[0]==="message"){let te=typeof ot[1]=="function"?ot[1]:typeof ot[1]=="object"&&ot[1]!==null&&typeof ot[1].handleEvent=="function"?ot[1].handleEvent:null;if(te!==null){let jt=Z.get(ot[1]);jt!==void 0?ot[1]=jt:(ot[1]=St=>{h(m.currentTime,m.sampleRate,()=>te(St))},Z.set(te,ot[1]))}}return X.call(S.port1,ot[0],ot[1],ot[2])})(S.port1.addEventListener),S.port1.removeEventListener=(X=>(...ot)=>{if(ot[0]==="message"){let te=Z.get(ot[1]);te!==void 0&&(Z.delete(ot[1]),ot[1]=te)}return X.call(S.port1,ot[0],ot[1],ot[2])})(S.port1.removeEventListener);let B=null;Object.defineProperty(S.port1,"onmessage",{get:()=>B,set:X=>{typeof B=="function"&&S.port1.removeEventListener("message",B),B=typeof X=="function"?X:null,typeof B=="function"&&(S.port1.addEventListener("message",B),S.port1.start())}}),g.prototype.port=S.port1;let dt=null;Np(m,K,g,b).then(X=>dt=X);let Wt=dn(b.numberOfInputs,b.channelCount),Ee=dn(b.numberOfOutputs,x),De=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((X,{name:ot})=>Q(O({},X),{[ot]:new Float32Array(128)}),{}),Nt=!0,ct=()=>{b.numberOfOutputs>0&&M.disconnect(R);for(let X=0,ot=0;X<b.numberOfOutputs;X+=1){let te=P[X];for(let jt=0;jt<x[X];jt+=1)R.disconnect(te,ot+jt,jt);ot+=x[X]}},Hi=new Map;M.onaudioprocess=({inputBuffer:X,outputBuffer:ot})=>{if(dt!==null){let te=l(K);for(let jt=0;jt<V;jt+=128){for(let St=0;St<b.numberOfInputs;St+=1)for(let Bt=0;Bt<b.channelCount;Bt+=1)ln(X,Wt[St],Bt,Bt,jt);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:St},Bt)=>{ln(X,De,St,C+Bt,jt)});for(let St=0;St<b.numberOfInputs;St+=1)for(let Bt=0;Bt<x[St];Bt+=1)Ee[St][Bt].byteLength===0&&(Ee[St][Bt]=new Float32Array(128));try{let St=Wt.map((Be,Zr)=>{if(te[Zr].size>0)return Hi.set(Zr,V/128),Be;let qc=Hi.get(Zr);return qc===void 0?[]:(Be.every(Hf=>Hf.every(Zf=>Zf===0))&&(qc===1?Hi.delete(Zr):Hi.set(Zr,qc-1)),Be)});Nt=h(m.currentTime+jt/m.sampleRate,m.sampleRate,()=>dt.process(St,Ee,De));for(let Be=0,Zr=0;Be<b.numberOfOutputs;Be+=1){for(let ro=0;ro<x[Be];ro+=1)na(ot,Ee[Be],ro,Zr+ro,jt);Zr+=x[Be]}}catch(St){Nt=!1,K.dispatchEvent(new ErrorEvent("processorerror",{colno:St.colno,filename:St.filename,lineno:St.lineno,message:St.message}))}if(!Nt){for(let St=0;St<b.numberOfInputs;St+=1){v[St].disconnect(A[St]);for(let Bt=0;Bt<b.channelCount;Bt+=1)A[jt].disconnect(E,Bt,St*b.channelCount+Bt)}if(g.parameterDescriptors!==void 0){let St=g.parameterDescriptors.length;for(let Bt=0;Bt<St;Bt+=1){let Be=_[Bt];Be.disconnect(E,0,C+Bt),Be.stop()}}E.disconnect(M),M.onaudioprocess=null,Jn?ct():Xi();break}}}};let Jn=!1,tt=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Zi=()=>M.connect(tt).connect(m.destination),Xi=()=>{M.disconnect(tt),tt.disconnect()},to=()=>{if(Nt){Xi(),b.numberOfOutputs>0&&M.connect(R);for(let X=0,ot=0;X<b.numberOfOutputs;X+=1){let te=P[X];for(let jt=0;jt<x[X];jt+=1)R.connect(te,ot+jt,jt);ot+=x[X]}}Jn=!0},eo=()=>{Nt&&(Zi(),ct()),Jn=!1};return Zi(),p(K,to,eo)};var Du=(i,t)=>{let e=i.createBiquadFilter();return pt(e,t),wt(e,t,"Q"),wt(e,t,"detune"),wt(e,t,"frequency"),wt(e,t,"gain"),vt(e,t,"type"),e};var Op=(i,t)=>(e,r)=>{let n=e.createChannelMerger(r.numberOfInputs);return i!==null&&i.name==="webkitAudioContext"&&t(e,n),pt(n,r),n};var Rp=i=>{let t=i.numberOfOutputs;Object.defineProperty(i,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw Lt()}}),Object.defineProperty(i,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw Lt()}}),Object.defineProperty(i,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw Lt()}})};var gn=(i,t)=>{let e=i.createChannelSplitter(t.numberOfOutputs);return pt(e,t),Rp(e),e};var Mp=(i,t,e,r,n)=>(o,s)=>{if(o.createConstantSource===void 0)return e(o,s);let a=o.createConstantSource();return pt(a,s),wt(a,s,"offset"),t(r,()=>r(o))||mn(a),t(n,()=>n(o))||fn(a),i(o,a),a};var Ue=(i,t)=>(i.connect=t.connect.bind(t),i.disconnect=t.disconnect.bind(t),i);var Ep=(i,t,e,r)=>(n,a)=>{var c=a,{offset:o}=c,s=Xr(c,["offset"]);let u=n.createBuffer(1,2,44100),h=t(n,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=e(n,Q(O({},s),{gain:o})),p=u.getChannelData(0);p[0]=1,p[1]=1,h.buffer=u,h.loop=!0;let m={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(b){l.channelCount=b},get channelCountMode(){return l.channelCountMode},set channelCountMode(b){l.channelCountMode=b},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(b){l.channelInterpretation=b},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return h.onended},set onended(b){h.onended=b},addEventListener(...b){return h.addEventListener(b[0],b[1],b[2])},dispatchEvent(...b){return h.dispatchEvent(b[0])},removeEventListener(...b){return h.removeEventListener(b[0],b[1],b[2])},start(b=0){h.start.call(h,b)},stop(b=0){h.stop.call(h,b)}},f=()=>h.connect(l),g=()=>h.disconnect(l);return i(n,h),r(Ue(m,l),f,g)};var Dp=(i,t)=>(e,r)=>{let n=e.createConvolver();if(pt(n,r),r.disableNormalization===n.normalize&&(n.normalize=!r.disableNormalization),vt(n,r,"buffer"),r.channelCount>2||(t(n,"channelCount",o=>()=>o.call(n),o=>s=>{if(s>2)throw i();return o.call(n,s)}),r.channelCountMode==="max"))throw i();return t(n,"channelCountMode",o=>()=>o.call(n),o=>s=>{if(s==="max")throw i();return o.call(n,s)}),n};var ku=(i,t)=>{let e=i.createDelay(t.maxDelayTime);return pt(e,t),wt(e,t,"delayTime"),e};var kp=i=>(t,e)=>{let r=t.createDynamicsCompressor();if(pt(r,e),e.channelCount>2||e.channelCountMode==="max")throw i();return wt(r,e,"attack"),wt(r,e,"knee"),wt(r,e,"ratio"),wt(r,e,"release"),wt(r,e,"threshold"),r};var Ae=(i,t)=>{let e=i.createGain();return pt(e,t),wt(e,t,"gain"),e};var Lp=i=>(t,e,r)=>{if(t.createIIRFilter===void 0)return i(t,e,r);let n=t.createIIRFilter(r.feedforward,r.feedback);return pt(n,r),n};function iC(i,t){let e=t[0]*t[0]+t[1]*t[1];return[(i[0]*t[0]+i[1]*t[1])/e,(i[1]*t[0]-i[0]*t[1])/e]}function nC(i,t){return[i[0]*t[0]-i[1]*t[1],i[0]*t[1]+i[1]*t[0]]}function jp(i,t){let e=[0,0];for(let r=i.length-1;r>=0;r-=1)e=nC(e,t),e[0]+=i[r];return e}var Pp=(i,t,e,r)=>(n,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:h})=>{let l=aa(o,n.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),m=h instanceof Float64Array?h:new Float64Array(h),f=p.length,g=m.length,b=Math.min(f,g);if(f===0||f>20)throw r();if(p[0]===0)throw t();if(g===0||g>20)throw r();if(m[0]===0)throw t();if(p[0]!==1){for(let _=0;_<g;_+=1)m[_]/=p[0];for(let _=1;_<f;_+=1)p[_]/=p[0]}let x=e(n,l,s,s);x.channelCount=s,x.channelCountMode=a,x.channelInterpretation=c;let C=32,I=[],T=[],S=[];for(let _=0;_<s;_+=1){I.push(0);let E=new Float32Array(C),V=new Float32Array(C);E.fill(0),V.fill(0),T.push(E),S.push(V)}x.onaudioprocess=_=>{let E=_.inputBuffer,V=_.outputBuffer,M=E.numberOfChannels;for(let R=0;R<M;R+=1){let P=E.getChannelData(R),D=V.getChannelData(R);I[R]=sa(p,f,m,g,b,T[R],S[R],I[R],C,P,D)}};let v=n.sampleRate/2;return Ue({get bufferSize(){return l},get channelCount(){return x.channelCount},set channelCount(_){x.channelCount=_},get channelCountMode(){return x.channelCountMode},set channelCountMode(_){x.channelCountMode=_},get channelInterpretation(){return x.channelInterpretation},set channelInterpretation(_){x.channelInterpretation=_},get context(){return x.context},get inputs(){return[x]},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},addEventListener(..._){return x.addEventListener(_[0],_[1],_[2])},dispatchEvent(..._){return x.dispatchEvent(_[0])},getFrequencyResponse(_,E,V){if(_.length!==E.length||E.length!==V.length)throw i();let M=_.length;for(let R=0;R<M;R+=1){let P=-Math.PI*(_[R]/v),D=[Math.cos(P),Math.sin(P)],k=jp(m,D),j=jp(p,D),q=iC(k,j);E[R]=Math.sqrt(q[0]*q[0]+q[1]*q[1]),V[R]=Math.atan2(q[1],q[0])}},removeEventListener(..._){return x.removeEventListener(_[0],_[1],_[2])}},x)};var Fp=(i,t)=>i.createMediaElementSource(t.mediaElement);var Bp=(i,t)=>{let e=i.createMediaStreamDestination();return pt(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var Gp=(i,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=e.slice(0,1),n=i.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(n,"mediaStream",{value:t}),n};var Vp=(i,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let n=new MediaStream([r]),o=e.createMediaStreamSource(n);if(r.kind!=="audio")throw i();if(t(e))throw new TypeError;return o};var qp=i=>i===null?null:i.hasOwnProperty("OfflineAudioContext")?i.OfflineAudioContext:i.hasOwnProperty("webkitOfflineAudioContext")?i.webkitOfflineAudioContext:null;var Wp=(i,t,e,r,n,o)=>(s,a)=>{let c=s.createOscillator();return pt(c,a),wt(c,a,"detune"),wt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):vt(c,a,"type"),t(e,()=>e(s))||mn(c),t(r,()=>r(s))||o(c,s),t(n,()=>n(s))||fn(c),i(s,c),c};var Up=i=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?i(t,e):(pt(r,e),wt(r,e,"orientationX"),wt(r,e,"orientationY"),wt(r,e,"orientationZ"),wt(r,e,"positionX"),wt(r,e,"positionY"),wt(r,e,"positionZ"),vt(r,e,"coneInnerAngle"),vt(r,e,"coneOuterAngle"),vt(r,e,"coneOuterGain"),vt(r,e,"distanceModel"),vt(r,e,"maxDistance"),vt(r,e,"panningModel"),vt(r,e,"refDistance"),vt(r,e,"rolloffFactor"),r)};var zp=(i,t,e,r,n,o,s,a,c,u)=>(h,V)=>{var M=V,{coneInnerAngle:l,coneOuterAngle:p,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:b,orientationY:x,orientationZ:C,panningModel:I,positionX:T,positionY:S,positionZ:v,refDistance:A,rolloffFactor:_}=M,E=Xr(M,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let R=h.createPanner();if(E.channelCount>2||E.channelCountMode==="max")throw s();pt(R,E);let P={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},D=e(h,Q(O({},P),{channelInterpretation:"speakers",numberOfInputs:6})),k=r(h,Q(O({},E),{gain:1})),j=r(h,Q(O({},P),{gain:1})),q=r(h,Q(O({},P),{gain:0})),K=r(h,Q(O({},P),{gain:0})),Z=r(h,Q(O({},P),{gain:0})),B=r(h,Q(O({},P),{gain:0})),dt=r(h,Q(O({},P),{gain:0})),Ct=n(h,256,6,1),Wt=o(h,Q(O({},P),{curve:new Float32Array([1,1]),oversample:"none"})),Ee=[b,x,C],De=[T,S,v],Nt=new Float32Array(1);Ct.onaudioprocess=({inputBuffer:tt})=>{let Zi=[c(tt,Nt,0),c(tt,Nt,1),c(tt,Nt,2)];Zi.some((to,eo)=>to!==Ee[eo])&&(R.setOrientation(...Zi),Ee=Zi);let Xi=[c(tt,Nt,3),c(tt,Nt,4),c(tt,Nt,5)];Xi.some((to,eo)=>to!==De[eo])&&(R.setPosition(...Xi),De=Xi)},Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(K.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Z.gain,"defaultValue",{get:()=>0}),Object.defineProperty(B.gain,"defaultValue",{get:()=>0}),Object.defineProperty(dt.gain,"defaultValue",{get:()=>0});let ct={get bufferSize(){},get channelCount(){return R.channelCount},set channelCount(tt){if(tt>2)throw s();k.channelCount=tt,R.channelCount=tt},get channelCountMode(){return R.channelCountMode},set channelCountMode(tt){if(tt==="max")throw s();k.channelCountMode=tt,R.channelCountMode=tt},get channelInterpretation(){return R.channelInterpretation},set channelInterpretation(tt){k.channelInterpretation=tt,R.channelInterpretation=tt},get coneInnerAngle(){return R.coneInnerAngle},set coneInnerAngle(tt){R.coneInnerAngle=tt},get coneOuterAngle(){return R.coneOuterAngle},set coneOuterAngle(tt){R.coneOuterAngle=tt},get coneOuterGain(){return R.coneOuterGain},set coneOuterGain(tt){if(tt<0||tt>1)throw t();R.coneOuterGain=tt},get context(){return R.context},get distanceModel(){return R.distanceModel},set distanceModel(tt){R.distanceModel=tt},get inputs(){return[k]},get maxDistance(){return R.maxDistance},set maxDistance(tt){if(tt<0)throw new RangeError;R.maxDistance=tt},get numberOfInputs(){return R.numberOfInputs},get numberOfOutputs(){return R.numberOfOutputs},get orientationX(){return j.gain},get orientationY(){return q.gain},get orientationZ(){return K.gain},get panningModel(){return R.panningModel},set panningModel(tt){R.panningModel=tt},get positionX(){return Z.gain},get positionY(){return B.gain},get positionZ(){return dt.gain},get refDistance(){return R.refDistance},set refDistance(tt){if(tt<0)throw new RangeError;R.refDistance=tt},get rolloffFactor(){return R.rolloffFactor},set rolloffFactor(tt){if(tt<0)throw new RangeError;R.rolloffFactor=tt},addEventListener(...tt){return k.addEventListener(tt[0],tt[1],tt[2])},dispatchEvent(...tt){return k.dispatchEvent(tt[0])},removeEventListener(...tt){return k.removeEventListener(tt[0],tt[1],tt[2])}};l!==ct.coneInnerAngle&&(ct.coneInnerAngle=l),p!==ct.coneOuterAngle&&(ct.coneOuterAngle=p),m!==ct.coneOuterGain&&(ct.coneOuterGain=m),f!==ct.distanceModel&&(ct.distanceModel=f),g!==ct.maxDistance&&(ct.maxDistance=g),b!==ct.orientationX.value&&(ct.orientationX.value=b),x!==ct.orientationY.value&&(ct.orientationY.value=x),C!==ct.orientationZ.value&&(ct.orientationZ.value=C),I!==ct.panningModel&&(ct.panningModel=I),T!==ct.positionX.value&&(ct.positionX.value=T),S!==ct.positionY.value&&(ct.positionY.value=S),v!==ct.positionZ.value&&(ct.positionZ.value=v),A!==ct.refDistance&&(ct.refDistance=A),_!==ct.rolloffFactor&&(ct.rolloffFactor=_),(Ee[0]!==1||Ee[1]!==0||Ee[2]!==0)&&R.setOrientation(...Ee),(De[0]!==0||De[1]!==0||De[2]!==0)&&R.setPosition(...De);let Hi=()=>{k.connect(R),i(k,Wt,0,0),Wt.connect(j).connect(D,0,0),Wt.connect(q).connect(D,0,1),Wt.connect(K).connect(D,0,2),Wt.connect(Z).connect(D,0,3),Wt.connect(B).connect(D,0,4),Wt.connect(dt).connect(D,0,5),D.connect(Ct).connect(h.destination)},Jn=()=>{k.disconnect(R),a(k,Wt,0,0),Wt.disconnect(j),j.disconnect(D),Wt.disconnect(q),q.disconnect(D),Wt.disconnect(K),K.disconnect(D),Wt.disconnect(Z),Z.disconnect(D),Wt.disconnect(B),B.disconnect(D),Wt.disconnect(dt),dt.disconnect(D),D.disconnect(Ct),Ct.disconnect(h.destination)};return u(Ue(ct,R),Hi,Jn)};var Yp=i=>(t,{disableNormalization:e,imag:r,real:n})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=n instanceof Float32Array?n:new Float32Array(n),a=t.createPeriodicWave(s,o,{disableNormalization:e});if(Array.from(r).length<2)throw i();return a};var yn=(i,t,e,r)=>i.createScriptProcessor(t,e,r);var Hp=(i,t)=>(e,r)=>{let n=r.channelCountMode;if(n==="clamped-max")throw t();if(e.createStereoPanner===void 0)return i(e,r);let o=e.createStereoPanner();return pt(o,r),wt(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>n,set:s=>{if(s!==n)throw t()}}),o};var Zp=(i,t,e,r,n,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},h=Q(O({},u),{oversample:"none"}),l=(f,g,b,x)=>{let C=new Float32Array(16385),I=new Float32Array(16385);for(let E=0;E<16385;E+=1){let V=E/16384*c;C[E]=Math.cos(V),I[E]=Math.sin(V)}let T=e(f,Q(O({},u),{gain:0})),S=r(f,Q(O({},h),{curve:C})),v=r(f,Q(O({},h),{curve:a})),A=e(f,Q(O({},u),{gain:0})),_=r(f,Q(O({},h),{curve:I}));return{connectGraph(){g.connect(T),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(A),v.connect(b),b.connect(S.inputs===void 0?S:S.inputs[0]),b.connect(_.inputs===void 0?_:_.inputs[0]),S.connect(T.gain),_.connect(A.gain),T.connect(x,0,0),A.connect(x,0,1)},disconnectGraph(){g.disconnect(T),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(A),v.disconnect(b),b.disconnect(S.inputs===void 0?S:S.inputs[0]),b.disconnect(_.inputs===void 0?_:_.inputs[0]),S.disconnect(T.gain),_.disconnect(A.gain),T.disconnect(x,0,0),A.disconnect(x,0,1)}}},p=(f,g,b,x)=>{let C=new Float32Array(16385),I=new Float32Array(16385),T=new Float32Array(16385),S=new Float32Array(16385),v=Math.floor(16385/2);for(let q=0;q<16385;q+=1)if(q>v){let K=(q-v)/(16384-v)*c;C[q]=Math.cos(K),I[q]=Math.sin(K),T[q]=0,S[q]=1}else{let K=q/(16384-v)*c;C[q]=1,I[q]=0,T[q]=Math.cos(K),S[q]=Math.sin(K)}let A=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),_=e(f,Q(O({},u),{gain:0})),E=r(f,Q(O({},h),{curve:C})),V=e(f,Q(O({},u),{gain:0})),M=r(f,Q(O({},h),{curve:I})),R=r(f,Q(O({},h),{curve:a})),P=e(f,Q(O({},u),{gain:0})),D=r(f,Q(O({},h),{curve:T})),k=e(f,Q(O({},u),{gain:0})),j=r(f,Q(O({},h),{curve:S}));return{connectGraph(){g.connect(A),g.connect(R.inputs===void 0?R:R.inputs[0]),A.connect(_,0),A.connect(V,0),A.connect(P,1),A.connect(k,1),R.connect(b),b.connect(E.inputs===void 0?E:E.inputs[0]),b.connect(M.inputs===void 0?M:M.inputs[0]),b.connect(D.inputs===void 0?D:D.inputs[0]),b.connect(j.inputs===void 0?j:j.inputs[0]),E.connect(_.gain),M.connect(V.gain),D.connect(P.gain),j.connect(k.gain),_.connect(x,0,0),P.connect(x,0,0),V.connect(x,0,1),k.connect(x,0,1)},disconnectGraph(){g.disconnect(A),g.disconnect(R.inputs===void 0?R:R.inputs[0]),A.disconnect(_,0),A.disconnect(V,0),A.disconnect(P,1),A.disconnect(k,1),R.disconnect(b),b.disconnect(E.inputs===void 0?E:E.inputs[0]),b.disconnect(M.inputs===void 0?M:M.inputs[0]),b.disconnect(D.inputs===void 0?D:D.inputs[0]),b.disconnect(j.inputs===void 0?j:j.inputs[0]),E.disconnect(_.gain),M.disconnect(V.gain),D.disconnect(P.gain),j.disconnect(k.gain),_.disconnect(x,0,0),P.disconnect(x,0,0),V.disconnect(x,0,1),k.disconnect(x,0,1)}}},m=(f,g,b,x,C)=>{if(g===1)return l(f,b,x,C);if(g===2)return p(f,b,x,C);throw n()};return(f,I)=>{var T=I,{channelCount:g,channelCountMode:b,pan:x}=T,C=Xr(T,["channelCount","channelCountMode","pan"]);if(b==="max")throw n();let S=i(f,Q(O({},C),{channelCount:1,channelCountMode:b,numberOfInputs:2})),v=e(f,Q(O({},C),{channelCount:g,channelCountMode:b,gain:1})),A=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:x}),{connectGraph:_,disconnectGraph:E}=m(f,g,v,A,S);Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"maxValue",{get:()=>1}),Object.defineProperty(A.gain,"minValue",{get:()=>-1});let V={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(D){v.channelCount!==D&&(M&&E(),{connectGraph:_,disconnectGraph:E}=m(f,D,v,A,S),M&&_()),v.channelCount=D},get channelCountMode(){return v.channelCountMode},set channelCountMode(D){if(D==="clamped-max"||D==="max")throw n();v.channelCountMode=D},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(D){v.channelInterpretation=D},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return A.gain},addEventListener(...D){return v.addEventListener(D[0],D[1],D[2])},dispatchEvent(...D){return v.dispatchEvent(D[0])},removeEventListener(...D){return v.removeEventListener(D[0],D[1],D[2])}},M=!1,R=()=>{_(),M=!0},P=()=>{E(),M=!1};return o(Ue(V,S),R,P)}};var Xp=(i,t,e,r,n,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return e(a,c);pt(u,c);let h=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(h!==null&&h.length<2)throw t();vt(u,{curve:h},"curve"),vt(u,c,"oversample");let l=null,p=!1;return s(u,"curve",g=>()=>g.call(u),g=>b=>(g.call(u,b),p&&(r(b)&&l===null?l=i(a,u):!r(b)&&l!==null&&(l(),l=null)),b)),n(u,()=>{p=!0,r(u.curve)&&(l=i(a,u))},()=>{p=!1,l!==null&&(l(),l=null)})};var $p=(i,t,e,r,n)=>(o,u)=>{var h=u,{curve:s,oversample:a}=h,c=Xr(h,["curve","oversample"]);let l=o.createWaveShaper(),p=o.createWaveShaper();pt(l,c),pt(p,c);let m=e(o,Q(O({},c),{gain:1})),f=e(o,Q(O({},c),{gain:-1})),g=e(o,Q(O({},c),{gain:1})),b=e(o,Q(O({},c),{gain:-1})),x=null,C=!1,I=null,T={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(A){m.channelCount=A,f.channelCount=A,l.channelCount=A,g.channelCount=A,p.channelCount=A,b.channelCount=A},get channelCountMode(){return l.channelCountMode},set channelCountMode(A){m.channelCountMode=A,f.channelCountMode=A,l.channelCountMode=A,g.channelCountMode=A,p.channelCountMode=A,b.channelCountMode=A},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(A){m.channelInterpretation=A,f.channelInterpretation=A,l.channelInterpretation=A,g.channelInterpretation=A,p.channelInterpretation=A,b.channelInterpretation=A},get context(){return l.context},get curve(){return I},set curve(A){if(A!==null&&A.length<2)throw t();if(A===null)l.curve=A,p.curve=A;else{let _=A.length,E=new Float32Array(_+2-_%2),V=new Float32Array(_+2-_%2);E[0]=A[0],V[0]=-A[_-1];let M=Math.ceil((_+1)/2),R=(_+1)/2-1;for(let P=1;P<M;P+=1){let D=P/M*R,k=Math.floor(D),j=Math.ceil(D);E[P]=k===j?A[k]:(1-(D-k))*A[k]+(1-(j-D))*A[j],V[P]=k===j?-A[_-1-k]:-((1-(D-k))*A[_-1-k])-(1-(j-D))*A[_-1-j]}E[M]=_%2===1?A[M-1]:(A[M-2]+A[M-1])/2,l.curve=E,p.curve=V}I=A,C&&(r(I)&&x===null?x=i(o,m):x!==null&&(x(),x=null))},get inputs(){return[m]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(A){l.oversample=A,p.oversample=A},addEventListener(...A){return m.addEventListener(A[0],A[1],A[2])},dispatchEvent(...A){return m.dispatchEvent(A[0])},removeEventListener(...A){return m.removeEventListener(A[0],A[1],A[2])}};s!==null&&(T.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==T.oversample&&(T.oversample=a);let S=()=>{m.connect(l).connect(g),m.connect(f).connect(p).connect(b).connect(g),C=!0,r(I)&&(x=i(o,m))},v=()=>{m.disconnect(l),l.disconnect(g),m.disconnect(f),f.disconnect(p),p.disconnect(b),b.disconnect(g),C=!1,x!==null&&(x(),x=null)};return n(Ue(T,g),S,v)};var se=()=>new DOMException("","NotSupportedError");var oC={numberOfChannels:1},Qp=(i,t,e,r,n)=>class extends i{constructor(s,a,c){let u;if(typeof s=="number"&&a!==void 0&&c!==void 0)u={length:a,numberOfChannels:s,sampleRate:c};else if(typeof s=="object")u=s;else throw new Error("The given parameters are not valid.");let{length:h,numberOfChannels:l,sampleRate:p}=O(O({},oC),u),m=r(l,h,p);t(sr,()=>sr(m))||m.addEventListener("statechange",(()=>{let f=0,g=b=>{this._state==="running"&&(f>0?(m.removeEventListener("statechange",g),b.stopImmediatePropagation(),this._waitForThePromiseToSettle(b)):f+=1)};return g})()),super(m,l),this._length=h,this._nativeOfflineAudioContext=m,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(e()):(this._state="running",n(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,oi(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var sC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Kp=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},sC),u),p=e(h,l),m=o(h),f=m?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,m,p.detune,153600,-153600),this._frequency=t(this,m,p.frequency,g,-g),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&l.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=l.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeOscillatorNode.onended=u;let h=this._nativeOscillatorNode.onended;this._onended=h!==null&&h===u?c:h}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){nr(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),xe(this)&&vr(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var Jp=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(h,l)=>J(null,null,function*(){let p=e(h),m=_t(p,l);if(!m){let f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:s===null?void 0:s,type:p.type};p=t(l,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return o.set(l,p),m?(yield i(l,h.detune,p.detune),yield i(l,h.frequency,p.frequency)):(yield r(l,h.detune,p.detune),yield r(l,h.frequency,p.frequency)),yield n(h,l,p),p});return{set periodicWave(h){s=h},set start(h){a=h},set stop(h){c=h},render(h,l){let p=o.get(l);return p!==void 0?Promise.resolve(p):u(h,l)}}};var aC={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},tm=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},aC),u),p=e(h,l),m=o(h),f=m?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,m,p.orientationX,Gt,Ut),this._orientationY=t(this,m,p.orientationY,Gt,Ut),this._orientationZ=t(this,m,p.orientationZ,Gt,Ut),this._positionX=t(this,m,p.positionX,Gt,Ut),this._positionY=t(this,m,p.positionY,Gt,Ut),this._positionZ=t(this,m,p.positionZ,Gt,Ut),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 em=(i,t,e,r,n,o,s,a,c,u)=>()=>{let h=new WeakMap,l=null,p=(m,f)=>J(null,null,function*(){let g=null,b=o(m),x={channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation},C=Q(O({},x),{coneInnerAngle:b.coneInnerAngle,coneOuterAngle:b.coneOuterAngle,coneOuterGain:b.coneOuterGain,distanceModel:b.distanceModel,maxDistance:b.maxDistance,panningModel:b.panningModel,refDistance:b.refDistance,rolloffFactor:b.rolloffFactor}),I=_t(b,f);if("bufferSize"in b)g=r(f,Q(O({},x),{gain:1}));else if(!I){let T=Q(O({},C),{orientationX:b.orientationX.value,orientationY:b.orientationY.value,orientationZ:b.orientationZ.value,positionX:b.positionX.value,positionY:b.positionY.value,positionZ:b.positionZ.value});b=n(f,T)}if(h.set(f,g===null?b:g),g!==null){if(l===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let M=new s(6,m.context.length,f.sampleRate),R=t(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});R.connect(M.destination),l=J(null,null,function*(){let P=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((D,k)=>J(null,null,function*(){let j=e(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:k===0?1:0});return yield a(M,D,j.offset),j})));for(let D=0;D<6;D+=1)P[D].connect(R,0,D),P[D].start(0);return u(M)})}let T=yield l,S=r(f,Q(O({},x),{gain:1}));yield c(m,f,S);let v=[];for(let M=0;M<T.numberOfChannels;M+=1)v.push(T.getChannelData(M));let A=[v[0][0],v[1][0],v[2][0]],_=[v[3][0],v[4][0],v[5][0]],E=r(f,Q(O({},x),{gain:1})),V=n(f,Q(O({},C),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:_[0],positionY:_[1],positionZ:_[2]}));S.connect(E).connect(V.inputs[0]),V.connect(g);for(let M=128;M<T.length;M+=128){let R=[v[0][M],v[1][M],v[2][M]],P=[v[3][M],v[4][M],v[5][M]];if(R.some((D,k)=>D!==A[k])||P.some((D,k)=>D!==_[k])){A=R,_=P;let D=M/f.sampleRate;E.gain.setValueAtTime(0,D),E=r(f,Q(O({},x),{gain:0})),V=n(f,Q(O({},C),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:_[0],positionY:_[1],positionZ:_[2]})),E.gain.setValueAtTime(1,D),S.connect(E).connect(V.inputs[0]),V.connect(g)}}return g}return I?(yield i(f,m.orientationX,b.orientationX),yield i(f,m.orientationY,b.orientationY),yield i(f,m.orientationZ,b.orientationZ),yield i(f,m.positionX,b.positionX),yield i(f,m.positionY,b.positionY),yield i(f,m.positionZ,b.positionZ)):(yield a(f,m.orientationX,b.orientationX),yield a(f,m.orientationY,b.orientationY),yield a(f,m.orientationZ,b.orientationZ),yield a(f,m.positionX,b.positionX),yield a(f,m.positionY,b.positionY),yield a(f,m.positionZ,b.positionZ)),We(b)?yield c(m,f,b.inputs[0]):yield c(m,f,b),b});return{render(m,f){let g=h.get(f);return g!==void 0?Promise.resolve(g):p(m,f)}}};var cC={disableNormalization:!1},rm=(i,t,e,r)=>class im{constructor(o,s){let a=t(o),c=r(O(O({},cC),s)),u=i(a,c);return e.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===im.prototype||e.has(o)}};var nm=(i,t)=>(e,r,n)=>(i(r).replay(n),t(r,e,n));var om=(i,t,e)=>(r,n,o)=>J(null,null,function*(){let s=i(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(l=>J(null,[l],function*([u,h]){let m=yield t(u).render(u,n),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&m.connect(o,h,c)}))).reduce((a,c)=>[...a,...c],[]))});var sm=(i,t,e)=>(r,n,o)=>J(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>J(null,[u],function*([a,c]){let l=yield i(a).render(a,n);e(a)||l.connect(o,c)})))});var am=(i,t,e,r)=>n=>i(sr,()=>sr(n))?Promise.resolve(i(r,r)).then(o=>{if(!o){let s=e(n,512,0,1);n.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>n.currentTime,s.connect(n.destination)}return n.startRendering()}):new Promise(o=>{let s=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(n.destination),n.startRendering()});var cm=i=>(t,e)=>{i.set(t,e)};var um=i=>(t,e)=>i.set(t,e);var hm=(i,t,e,r,n,o,s,a)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(h=>e(h).render(h,u)))).then(()=>n(u)).then(h=>(typeof h.copyFromChannel!="function"?(s(h),sn(h)):t(o,()=>o(h))||a(h),i.add(h),h));var uC={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},lm=(i,t,e,r,n,o)=>class extends i{constructor(a,c){let u=n(a),h=O(O({},uC),c),l=e(u,h),p=o(u),m=p?r():null;super(a,!1,l,m),this._pan=t(this,p,l.pan)}get pan(){return this._pan}};var dm=(i,t,e,r,n)=>()=>{let o=new WeakMap,s=(a,c)=>J(null,null,function*(){let u=e(a),h=_t(u,c);if(!h){let l={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,l)}return o.set(c,u),h?yield i(c,a.pan,u.pan):yield r(c,a.pan,u.pan),We(u)?yield n(a,c,u.inputs[0]):yield n(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var pm=i=>()=>{if(i===null)return!1;try{new i({length:1,sampleRate:44100})}catch(t){return!1}return!0};var mm=(i,t)=>()=>J(null,null,function*(){if(i===null)return!0;if(t===null)return!1;let e=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new t(1,128,44100),n=URL.createObjectURL(e),o=!1,s=!1;try{yield r.audioWorklet.addModule(n);let a=new i(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>o=!0,a.onprocessorerror=()=>s=!0,c.connect(a),c.start(0),yield r.startRendering(),yield new Promise(u=>setTimeout(u))}catch(a){}finally{URL.revokeObjectURL(n)}return o&&!s});var fm=(i,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=i(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(n=>{e.oncomplete=()=>{r.disconnect(),n(e.currentTime!==0)},e.startRendering()})};var Lu=()=>new DOMException("","UnknownError");var hC={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},gm=(i,t,e,r,n,o,s)=>class extends i{constructor(c,u){let h=n(c),l=O(O({},hC),u),p=e(h,l),f=o(h)?r():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,s(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var ym=(i,t,e)=>()=>{let r=new WeakMap,n=(o,s)=>J(null,null,function*(){let a=t(o);if(!_t(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=i(s,u)}return r.set(s,a),We(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):n(o,s)}}};var bm=()=>typeof window=="undefined"?null:window;var xm=(i,t)=>e=>{e.copyFromChannel=(r,n,o=0)=>{let s=i(o),a=i(n);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),h=r.length;for(let l=s<0?-s:0;l+s<c&&l<h;l+=1)r[l]=u[l+s]},e.copyToChannel=(r,n,o=0)=>{let s=i(o),a=i(n);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),h=r.length;for(let l=s<0?-s:0;l+s<c&&l<h;l+=1)u[l+s]=r[l]}};var Am=i=>t=>{t.copyFromChannel=(e=>(r,n,o=0)=>{let s=i(o),a=i(n);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,n,o=0)=>{let s=i(o),a=i(n);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var Cm=i=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),i(t,"buffer",n=>()=>{let o=n.call(t);return o===r?null:o},n=>o=>n.call(t,o===null?r:o))};var _m=(i,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw i()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw i()}});let n=e.createBufferSource();t(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)n.connect(r,0,c)},()=>n.disconnect(r))};var ju=(i,t,e)=>i.copyFromChannel===void 0?i.getChannelData(e)[0]:(i.copyFromChannel(t,e),t[0]);var Pu=i=>{if(i===null)return!1;let t=i.length;return t%2!==0?i[Math.floor(t/2)]!==0:i[t/2-1]+i[t/2]!==0};var bn=(i,t,e,r)=>{let n=i;for(;!n.hasOwnProperty(t);)n=Object.getPrototypeOf(n);let{get:o,set:s}=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(i,t,{get:e(o),set:r(s)})};var vm=i=>Q(O({},i),{outputChannelCount:i.outputChannelCount!==void 0?i.outputChannelCount:i.numberOfInputs===1&&i.numberOfOutputs===1?[i.channelCount]:Array.from({length:i.numberOfOutputs},()=>1)});var Im=i=>Q(O({},i),{channelCount:i.numberOfOutputs});var Sm=i=>{let{imag:t,real:e}=i;return t===void 0?e===void 0?Q(O({},i),{imag:[0,0],real:[0,0]}):Q(O({},i),{imag:Array.from(e,()=>0),real:e}):e===void 0?Q(O({},i),{imag:t,real:Array.from(t,()=>0)}):Q(O({},i),{imag:t,real:e})};var Fu=(i,t,e)=>{try{i.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;Fu(i,t,e+1e-7)}};var wm=i=>{let t=i.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var Nm=i=>{let t=i.createBufferSource(),e=i.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var Tm=i=>{let t=i.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var ca=i=>{let t=i.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Bu=i=>{let t=i.createBuffer(1,1,44100),e=i.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var ua=i=>{let t=i.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var Om=i=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(i)}finally{t.close(),e.close()}};var Rm=i=>{i.start=(t=>(e=0,r=0,n)=>{let o=i.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/i.context.sampleRate?t.call(i,e,0,0):t.call(i,e,s,n)})(i.start)};var Gu=(i,t)=>{let e=t.createGain();i.connect(e);let r=(n=>()=>{n.call(i,e),i.removeEventListener("ended",r)})(i.disconnect);i.addEventListener("ended",r),Ue(i,e),i.stop=(n=>{let o=!1;return(s=0)=>{if(o)try{n.call(i,s)}catch(a){e.gain.setValueAtTime(0,s)}else n.call(i,s),o=!0}})(i.stop)};var Oi=(i,t)=>e=>{let r={value:i};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(i,e):t.handleEvent.call(i,e)};var lC=Al(or),dC=Rl(or),pC=Sd(ii),Em=new WeakMap,mC=Vd(Em),ze=sd(new Map,new WeakMap),Ir=bm(),Dm=gp(ze,qe),Vu=Gd(re),ae=om(re,Vu,Br),fC=kl(Dm,Ot,ae),Dt=Ud(nn),Gr=qp(Ir),Rt=op(Gr),km=new WeakMap,Lm=kd(Oi),xn=Ap(Ir),qu=ep(xn),Wu=rp(Ir),jm=ip(Ir),Io=_p(Ir),zt=Ql(Cl($s),Ol(lC,dC,an,pC,cn,re,mC,_r,Ot,or,xe,Br,un),ze,$d(Ao,cn,re,Ot,Ni,xe),qe,pn,se,_d(an,Ao,re,Ot,Ni,Dt,xe,Rt),Td(km,re,$t),Lm,Dt,qu,Wu,jm,Rt,Io),gC=Dl(zt,fC,qe,Dm,Dt,Rt);var Uu=new WeakSet,Mm=yp(Ir),Pm=gd(new Uint32Array(1)),zu=xm(Pm,qe),Yu=Am(Pm),Hu=Ll(Uu,ze,se,Mm,Gr,pm(Mm),zu,Yu);var ha=Ml(Ae),Fm=sm(Vu,ni,Br),Sr=ld(Fm),An=xp(ha,ze,wm,Nm,Tm,ca,Bu,ua,Rm,Cm(bn),Gu),wr=nm(qd(ni),Fm),yC=Fl(Sr,An,Ot,wr,ae),ar=Kl(_l(Qs),km,xo,Jl,yu,bu,xu,Au,Cu,Ji,mo,xn,Fu),bC=Pl(zt,yC,ar,Lt,An,Dt,Rt,Oi);var xC=Yl(zt,Hl,qe,Lt,Cp(Ae,bn),Dt,Rt,ae),AC=od(Sr,Du,Ot,wr,ae),Ri=um(Em),CC=nd(zt,ar,AC,pn,Du,Dt,Rt,Ri),ai=mp(or,Wu),_C=_m(Lt,ai),ci=Op(xn,_C),vC=cd(ci,Ot,ae),IC=ad(zt,vC,ci,Dt,Rt),SC=hd(gn,Ot,ae),wC=ud(zt,SC,gn,Dt,Rt,Im),NC=Ep(ha,An,Ae,ai),Cn=Mp(ha,ze,NC,ca,ua),TC=fd(Sr,Cn,Ot,wr,ae),OC=md(zt,ar,TC,Cn,Dt,Rt,Oi),Bm=Dp(se,bn),RC=bd(Bm,Ot,ae),MC=yd(zt,RC,Bm,Dt,Rt,Ri),EC=Id(Sr,ku,Ot,wr,ae),DC=vd(zt,ar,EC,ku,Dt,Rt,Ri),Gm=kp(se),kC=Md(Sr,Gm,Ot,wr,ae),LC=Rd(zt,ar,kC,Gm,se,Dt,Rt,Ri),jC=Fd(Sr,Ae,Ot,wr,ae),PC=Pd(zt,ar,jC,Ae,Dt,Rt),FC=Pp(pn,Lt,yn,se),la=am(ze,Ae,yn,fm(Ae,Gr)),BC=Xd(An,Ot,Gr,ae,la),GC=Lp(FC),VC=Zd(zt,GC,BC,Dt,Rt,Ri),qC=Zl(ar,ci,Cn,yn,se,ju,Rt,bn),Vm=new WeakMap,Zu=dp(xC,qC,Lm,Rt,Vm,Oi),qm=Wp(ha,ze,ca,Bu,ua,Gu),WC=Jp(Sr,qm,Ot,wr,ae),UC=Kp(zt,ar,qm,WC,Dt,Rt,Oi),Wm=pd(An),zC=$p(Wm,Lt,Ae,Pu,ai),da=Xp(Wm,Lt,zC,Pu,ai,xn,bn),YC=zp(an,Lt,ci,Ae,yn,da,se,cn,ju,ai),Um=Up(YC),HC=em(Sr,ci,Cn,Ae,Um,Ot,Gr,wr,ae,la),ZC=tm(zt,ar,Um,HC,Dt,Rt,Ri),XC=Yp(qe),$C=rm(XC,Dt,new WeakSet,Sm),QC=Zp(ci,gn,Ae,da,se,ai),zm=Hp(QC,se),KC=dm(Sr,zm,Ot,wr,ae),JC=lm(zt,ar,zm,KC,Dt,Rt),t_=ym(da,Ot,ae),e_=gm(zt,Lt,da,t_,Dt,Rt,Ri),Ym=sp(Ir),Xu=Ld(Ir),Hm=new WeakMap,r_=zd(Hm,Gr),i_=Ym?Tl(ze,se,Dd(Ir),Xu,jd(xl),Dt,r_,Rt,Io,new WeakMap,new WeakMap,mm(Io,Gr),Ir):void 0,n_=np(qu,Rt),o_=Cd(Uu,ze,Ad,Ed,new WeakSet,Dt,n_,on,sr,zu,Yu),Zm=id(i_,gC,Hu,bC,CC,IC,wC,OC,MC,o_,DC,LC,PC,VC,Zu,UC,ZC,$C,JC,e_),s_=ap(zt,Fp,Dt,Rt),a_=cp(zt,Bp,Dt,Rt),c_=up(zt,Gp,Dt,Rt),u_=Vp(Lt,Rt),h_=hp(zt,u_,Dt),Xm=zl(Zm,Lt,se,Lu,s_,a_,c_,h_,xn);var $u=Yd(Vm),l_=El($u),$m=dd(qe),d_=wd($u),Qm=Od(qe),Km=new WeakMap,p_=Bd(Km,$t),m_=Tp($m,qe,Lt,ci,gn,Cn,Ae,yn,se,Qm,Xu,p_,ai),f_=Ip(Lt,m_,Ae,se,ai),g_=rd(Sr,$m,An,ci,gn,Cn,Ae,d_,Qm,Xu,Ot,Io,Gr,wr,ae,la),y_=Wd(Hm),b_=cm(Km),Qu=Ym?td(l_,zt,ar,g_,f_,re,y_,Dt,Rt,Io,vm,b_,Om,Oi):void 0;var DU=lp(Lt,se,Lu,Zu,xn);var Jm=xd(se,Gr),tf=hm(Uu,ze,Vu,$u,la,on,zu,Yu),kU=pp(ze,Lt,Jm,Zu,tf);var ef=Qp(Zm,ze,Lt,Jm,tf);var rf=Qd(nn,qu),nf=Kd(rn,Wu),of=Jd(xo,jm),sf=tp(nn,Rt);function Yt(i){return i===void 0}function it(i){return i!==void 0}function af(i){return typeof i=="function"}function ce(i){return typeof i=="number"}function cr(i){return Object.prototype.toString.call(i)==="[object Object]"&&i.constructor===Object}function Ku(i){return typeof i=="boolean"}function Pt(i){return Array.isArray(i)}function pe(i){return typeof i=="string"}function So(i){return pe(i)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(i)}function Y(i,t){if(!i)throw new Error(t)}function Vt(i,t,e=1/0){if(!(t<=i&&i<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${i}`)}function pa(i){!i.isOffline&&i.state!=="running"&&Mi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var uf=!1,cf=!1;function Ju(i){uf=i}function hf(i){Yt(i)&&uf&&!cf&&(cf=!0,Mi("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var lf=console;function df(...i){lf.log(...i)}function Mi(...i){lf.warn(...i)}function pf(i){return new Xm(i)}function mf(i,t,e){return new ef(i,t,e)}var me=typeof self=="object"?self:null,ff=me&&(me.hasOwnProperty("AudioContext")||me.hasOwnProperty("webkitAudioContext"));function gf(i,t,e){return Y(it(Qu),"AudioWorkletNode only works in a secure context (https or localhost)"),new(i instanceof(me==null?void 0:me.BaseAudioContext)?me==null?void 0:me.AudioWorkletNode:Qu)(i,t,e)}function fe(i,t,e,r){var n=arguments.length,o=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,r);else for(var a=i.length-1;a>=0;a--)(s=i[a])&&(o=(n<3?s(o):n>3?s(t,e,o):s(t,e))||o);return n>3&&o&&Object.defineProperty(t,e,o),o}function mt(i,t,e,r){function n(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(h){try{u(r.next(h))}catch(l){s(l)}}function c(h){try{u(r.throw(h))}catch(l){s(l)}}function u(h){h.done?o(h.value):n(h.value).then(a,c)}u((r=r.apply(i,t||[])).next())})}var ma=class{constructor(t,e,r,n){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(n||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let t=new Blob([`
|
|
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"}),e=URL.createObjectURL(t),r=new Worker(e);r.onmessage=this._callback.bind(this),this._worker=r}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}};function Ht(n){return gm(n)}function lr(n){return fm(n)}function tn(n){return bm(n)}function Ur(n){return mm(n)}function Tm(n){return n instanceof fu}function ux(n,t){return n==="value"||Ht(t)||lr(t)||Tm(t)}function Et(n,...t){if(!t.length)return n;let e=t.shift();if(Yt(n)&&Yt(e))for(let r in e)ux(r,e[r])?n[r]=e[r]:Yt(e[r])?(n[r]||Object.assign(n,{[r]:{}}),Et(n[r],e[r])):Object.assign(n,{[r]:e[r]});return Et(n,...t)}function Om(n,t){return n.length===t.length&&n.every((e,r)=>t[r]===e)}function N(n,t,e=[],r){let i={},o=Array.from(t);if(Yt(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(n,a))||(Et(i,{[r]:o[0]}),e.splice(e.indexOf(r),1),o.shift())),o.length===1&&Yt(o[0]))Et(i,o[0]);else for(let s=0;s<e.length;s++)te(o[s])&&(i[e[s]]=o[s]);return Et(n,i)}function Rm(n){return n.constructor.getDefaults()}function _t(n,t){return Be(n)?t:n}function Zt(n,t){return t.forEach(e=>{Reflect.has(n,e)&&delete n[e]}),n}var Ke=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ot&&this.toString()===ot.TONE_DEBUG_CLASS)&&vm(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Ke.version=zn;function Ir(n,t){return n>t+1e-6}function no(n,t){return Ir(n,t)||ht(n,t)}function pi(n,t){return n+1e-6<t}function ht(n,t){return Math.abs(n-t)<1e-6}function _u(n,t,e){return Math.max(Math.min(n,e),t)}var Ue=class n extends Ke{constructor(){super(),this.name="Timeline",this._timeline=[];let t=N(n.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(z(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){let e=this._timeline[this.length-1];z(no(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{let e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){let e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){let r=this._search(t,e);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){let r=this._search(t,e);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(t){let e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];let r=this._search(t);return r-1>=0?this._timeline[r-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(ht(this._timeline[e].time,t)){for(let r=e;r>=0&&ht(this._timeline[r].time,t);r--)e=r;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&no(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){let e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){let e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let r=0,i=this._timeline.length,o=i;if(i>0&&this._timeline[i-1][e]<=t)return i-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ht(a[e],t)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ht(l[e],t))s=u;else break}return s}else{if(pi(a[e],t)&&Ir(c[e],t))return s;Ir(a[e],t)?o=s:r=s+1}}return-1}_iterate(t,e=0,r=this._timeline.length-1){this._timeline.slice(e,r+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){let r=this._search(t);return r!==-1&&this._iterate(e,0,r),this}forEachAfter(t,e){let r=this._search(t);return this._iterate(e,r+1),this}forEachBetween(t,e,r){let i=this._search(t),o=this._search(e);return i!==-1&&o!==-1?(this._timeline[i].time!==t&&(i+=1),this._timeline[o].time===e&&(o-=1),this._iterate(r,i,o)):i===-1&&this._iterate(r,0,o),this}forEachFrom(t,e){let r=this._search(t);for(;r>=0&&this._timeline[r].time>=t;)r--;return this._iterate(e,r+1),this}forEachAtTime(t,e){let r=this._search(t);if(r!==-1&&ht(this._timeline[r].time,t)){let i=r;for(let o=r;o>=0&&ht(this._timeline[o].time,t);o--)i=o;this._iterate(o=>{e(o)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Mm=[];function zr(n){Mm.push(n)}function Dm(n){Mm.forEach(t=>t(n))}var Em=[];function Yr(n){Em.push(n)}function km(n){Em.forEach(t=>t(n))}var Hr=class n extends Ke{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(i=>{Be(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(e)}),this}once(t,e){let r=(...i)=>{e(...i),this.off(t,r)};return this.on(t,r),this}off(t,e){return t.split(/\W+/).forEach(i=>{if(Be(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Be(e))this._events[i]=[];else{let o=this._events[i];for(let s=o.length-1;s>=0;s--)o[s]===e&&o.splice(s,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){let r=this._events[t].slice(0);for(let i=0,o=r.length;i<o;i++)r[i].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(n.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var rn=class extends Hr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var mi=class n extends rn{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Ue,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=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=Im({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new Ps(this.emit.bind(this,"tick"),r.clockSource,r.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Dm(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,r){return this._context.createBuffer(t,e,r)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,r){return this._context.createPeriodicWave(t,e,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return z(Ur(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return z(Ur(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return z(Ur(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){z(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){z(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){z(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){z(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return Nm(this.rawContext,t,e)}addAudioWorkletModule(t){return he(this,void 0,void 0,function*(){z(te(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return he(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return Ur(this._context)?this._context.resume():Promise.resolve()}close(){return he(this,void 0,void 0,function*(){Ur(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&km(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{let e=this._context.createBuffer(1,128,this._context.sampleRate),r=e.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=t;let i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=e,i.loop=!0,i.start(0),this._constants.set(t,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){let t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:r+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){let r=++this._timeoutIds,i=()=>{let o=this.now();this._timeouts.add({callback:()=>{t(),i()},id:r,time:o+e})};return i(),r}};var Fs=class extends rn{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,r){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return he(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};function W(n,t){Re(t)?t.forEach(e=>W(n,e)):Object.defineProperty(n,t,{enumerable:!0,writable:!1})}function fi(n,t){Re(t)?t.forEach(e=>fi(n,e)):Object.defineProperty(n,t,{writable:!0})}var re=()=>{};var Le=class n extends Ke{constructor(){super(),this.name="ToneAudioBuffer",this.onload=re;let t=N(n.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,nt(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:re,onload:re,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Ge().sampleRate}set(t){return t instanceof n?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return he(this,void 0,void 0,function*(){let e=n.load(t).then(r=>{this.set(r),this.onload(this)});n.downloads.push(e);try{yield e}finally{let r=n.downloads.indexOf(e);n.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Re(t)&&t[0].length>0,r=e?t.length:1,i=e?t[0].length:t.length,o=Ge(),s=o.createBuffer(r,i,o.sampleRate),a=!e&&r===1?[t]:t;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(t){if(et(t))this.fromArray(this.toArray(t));else{let e=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++)e[s]+=o[s]}e=e.map(i=>i/r),this.fromArray(e)}return this}toArray(t){if(et(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let r=0;r<this.numberOfChannels;r++)e[r]=this.getChannelData(r);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){z(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),i=Math.floor(e*this.sampleRate);z(r<i,"The start time must be less than the end time");let o=i-r,s=Ge().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 t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new n().fromArray(t)}static fromUrl(t){return he(this,void 0,void 0,function*(){return yield new n().load(t)})}static load(t){return he(this,void 0,void 0,function*(){let e=n.baseUrl===""||n.baseUrl.endsWith("/")?n.baseUrl:n.baseUrl+"/",r=yield fetch(e+t);if(!r.ok)throw new Error(`could not load url: ${t}`);let i=yield r.arrayBuffer();return yield Ge().decodeAudioData(i)})}static supportsType(t){let e=t.split("."),r=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return he(this,void 0,void 0,function*(){for(yield Promise.resolve();n.downloads.length;)yield n.downloads[0]})}};Le.baseUrl="";Le.downloads=[];var Xt=class extends mi{constructor(){super({clockSource:"offline",context:tn(arguments[0])?arguments[0]:Sm(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(t){return he(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;let r=Math.floor(this.sampleRate/128);t&&e%r===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return he(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);let e=yield this._context.startRendering();return new Le(e)})}close(){return Promise.resolve()}};var Lm=new Fs,nn=Lm;function Ge(){return nn===Lm&&wm&&vu(new mi),nn}function vu(n,t=!1){t&&nn.dispose(),Ur(n)?nn=new mi(n):tn(n)?nn=new Xt(n):nn=n}if(ot&&!ot.TONE_SILENCE_LOGGING){let n="v";zn==="dev"&&(n="");let t=` * Tone.js ${n}${zn} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function on(n){return Math.pow(10,n/20)}function sn(n){return 20*(Math.log(n)/Math.LN10)}function gi(n){return Math.pow(2,n/12)}var Bs=440;function jm(){return Bs}function Pm(n){Bs=n}function Qt(n){return Math.round(Iu(n))}function Iu(n){return 69+12*Math.log2(n/Bs)}function oo(n){return Bs*Math.pow(2,(n-69)/12)}var Gs=class n extends Ke{constructor(t,e,r){super(),this.defaultUnits="s",this._val=e,this._units=r,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{let r=parseInt(t,10),i=e==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/r)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{let e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,r)=>{let i=0;return t&&t!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(i+=this._beatsToUnits(parseFloat(e))),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),Be(this._val))return this._noArg();if(nt(this._val)&&Be(this._units)){for(let t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(Yt(this._val)){let t=0;for(let e in this._val)if(te(this._val[e])){let r=this._val[e],i=new this.constructor(this.context,e).valueOf()*r;t+=i}return t}if(te(this._units)){let t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return nt(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var vt=class n extends Gs{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let e=new n(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){let r=new this.constructor(this.context,t).valueOf(),i=this.valueOf(),a=Math.round(i/r)*r-i;return i+a*e}toNotation(){let t=this.toSeconds(),e=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],i=new n(this.context,e[0]).toSeconds();return e.forEach(o=>{let s=new n(this.context,o).toSeconds();Math.abs(s-t)<Math.abs(i-t)&&(r=o,i=s)}),r}toBarsBeatsSixteenths(){let t=this._beatsToUnits(1),e=this.valueOf()/t;e=parseFloat(e.toFixed(4));let r=Math.floor(e/this._getTimeSignature()),i=e%1*4;e=Math.floor(e)%this._getTimeSignature();let o=i.toString();return o.length>3&&(i=parseFloat(parseFloat(o).toFixed(3))),[r,e,i].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Qt(this.toFrequency())}_now(){return this.context.now()}};var dt=class n extends vt{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return jm()}static set A4(t){Pm(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:n.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let i=lx[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?i:n.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,r){let i=1;return t&&t!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(i*=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(i*=this._beatsToUnits(parseFloat(r)/4)),i}}})}transpose(t){return new n(this.context,this.valueOf()*gi(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return Qt(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/n.A4),r=Math.round(12*e)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),hx[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return oo(t)}static ftom(t){return Qt(t)}},lx={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},hx=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var kt=class extends vt{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var ze=class n extends Ke{constructor(){super();let t=N(n.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Ge()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return Am(t),new vt(this.context,t).toSeconds()}toFrequency(t){return new dt(this.context,t).toFrequency()}toTicks(t){return new kt(this.context,t).toTicks()}_getPartialProperties(t){let e=this.get();return Object.keys(e).forEach(r=>{Be(t[r])&&delete e[r]}),e}get(){let t=Rm(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){let r=this[e];te(r)&&te(r.value)&&te(r.setValueAtTime)?t[e]=r.value:r instanceof n?t[e]=r._getPartialProperties(t[e]):Re(r)||et(r)||nt(r)||Cu(r)?t[e]=r:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&te(this[e])&&(this[e]&&te(this[e].value)&&te(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof n?this[e].set(t[e]):this[e]=t[e])}),this}};var hr=class extends Ue{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){let e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,r){return ke(e,0),this.add(Object.assign({},r,{state:t,time:e})),this}getLastState(t,e){let r=this._search(e);for(let i=r;i>=0;i--){let o=this._timeline[i];if(o.state===t)return o}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let o=this._timeline[i];if(o.state===t)return o}}};var se=class n extends ze{constructor(){let t=N(n.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,z(te(t.param)&&(Ht(t.param)||t.param instanceof n),"param must be an AudioParam");!Ht(t.param);)t.param=t.param._param;this._swappable=te(t.swappable)?t.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new Ue(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,te(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(ze.getDefaults(),{convert:!0,units:"number"})}get value(){let t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return te(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 te(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return te(this.maxValue)&&te(this.minValue)&&ke(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?on(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?sn(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),i=this._fromType(t);return z(isFinite(i)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",t,r),this._events.add({time:r,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,r),this}getValueAtTime(t){let e=Math.max(this.toSeconds(t),0),r=this._events.getAfter(e),i=this._events.get(e),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,e))}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,e):o=this._exponentialInterpolate(i.time,s,r.time,r.value,e)}else o=i.value;return this._toType(o)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){let r=this._fromType(t),i=this.toSeconds(e);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this._events.add({time:i,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",t,i),this._param.linearRampToValueAtTime(r,i),this}exponentialRampToValueAtTime(t,e){let r=this._fromType(t);r=ht(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(e);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",t,i),this._param.exponentialRampToValueAtTime(r,i),this}exponentialRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(t,r+this.toSeconds(e)),this}linearRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(t,r+this.toSeconds(e)),this}targetRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(t,r,e),this}exponentialApproachValueAtTime(t,e,r){e=this.toSeconds(e),r=this.toSeconds(r);let i=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(t,e,i),this.cancelAndHoldAtTime(e+r*.9),this.linearRampToValueAtTime(t,e+r),this}setTargetAtTime(t,e,r){let i=this._fromType(t);z(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(e);return this._assertRange(i),z(isFinite(i)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",t,o,r),this._param.setTargetAtTime(i,o,r),this}setValueCurveAtTime(t,e,r,i=1){r=this.toSeconds(r),e=this.toSeconds(e);let o=this._fromType(t[0])*i;this.setValueAtTime(this._toType(o),e);let s=r/(t.length-1);for(let a=1;a<t.length;a++){let c=this._fromType(t[a])*i;this.linearRampToValueAtTime(this._toType(c),e+a*s)}return this}cancelScheduledValues(t){let e=this.toSeconds(t);return z(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){let e=this.toSeconds(t),r=this._fromType(this.getValueAtTime(e));z(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let i=this._events.get(e),o=this._events.getAfter(e);return i&&ht(i.time,e)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),e)),this._events.add({time:e,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,e),this}rampTo(t,e=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,r):this.linearRampTo(t,e,r),this}apply(t){let e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);let r=this._events.get(e);if(r&&r.type==="setTargetAtTime"){let i=this._events.getAfter(r.time),o=i?i.time:e+2,s=(o-e)/10;for(let a=e;a<o;a+=s)t.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?t.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?t.setTargetAtTime(i.value,i.time,i.constant):t[i.type](i.value,i.time)}),this}setParam(t){z(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,r,i,o){return r+(e-r)*Math.exp(-(o-t)/i)}_linearInterpolate(t,e,r,i,o){return e+(i-e)*((o-t)/(r-t))}_exponentialInterpolate(t,e,r,i,o){return e*Math.pow(i/e,(o-t)/(r-t))}};var j=class n extends ze{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return te(this.input)?Ht(this.input)||this.input instanceof se?1:this.input.numberOfInputs:0}get numberOfOutputs(){return te(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return te(t)&&(t instanceof n||lr(t))}_getInternalNodes(){let t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(r=>{r.channelCount=t.channelCount,r.channelCountMode=t.channelCountMode,r.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){let t=this._getInternalNodes();z(t.length>0,"ToneAudioNode does not have any internal nodes");let e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,r=0){return tt(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return di("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return Fm(this,t,e,r),this}chain(...t){return Lt(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),te(this.input)&&(this.input instanceof n?this.input.dispose():lr(this.input)&&this.input.disconnect()),te(this.output)&&(this.output instanceof n?this.output.dispose():lr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Lt(...n){let t=n.shift();n.reduce((e,r)=>(e instanceof j?e.connect(r):lr(e)&&tt(e,r),r),t)}function tt(n,t,e=0,r=0){for(z(te(n),"Cannot connect from undefined node"),z(te(t),"Cannot connect to undefined node"),(t instanceof j||lr(t))&&z(t.numberOfInputs>0,"Cannot connect to node with no inputs"),z(n.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof j||t instanceof se;)te(t.input)&&(t=t.input);for(;n instanceof j;)te(n.output)&&(n=n.output);Ht(t)?n.connect(t,e):n.connect(t,e,r)}function Fm(n,t,e=0,r=0){if(te(t))for(;t instanceof j;)t=t.input;for(;!lr(n);)te(n.output)&&(n=n.output);Ht(t)?n.disconnect(t,e):lr(t)?n.disconnect(t,e,r):n.disconnect()}var Z=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new se({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.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 Kt=class extends j{constructor(t){super(t),this.onended=re,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Z({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let r=this.toSeconds(e);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(j.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:re})}_startGain(t,e=1){z(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=t+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+r):this._gainNode.gain.exponentialApproachValueAtTime(e,t,r)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){z(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==re&&(this.onended(this),this.onended=re,!this.context.isOffline)){let t=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),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=re,this}};var so=class n extends Kt{constructor(){let t=N(n.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),tt(this._source,this._gainNode),this.offset=new se({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(Kt.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var $=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new so({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(j.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,r=0){return an(this,t,e,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,r){return this._param.exponentialRampTo(t,e,r),this}linearRampTo(t,e,r){return this._param.linearRampTo(t,e,r),this}targetRampTo(t,e,r){return this._param.targetRampTo(t,e,r),this}exponentialApproachValueAtTime(t,e,r){return this._param.exponentialApproachValueAtTime(t,e,r),this}setTargetAtTime(t,e,r){return this._param.setTargetAtTime(t,e,r),this}setValueCurveAtTime(t,e,r,i){return this._param.setValueCurveAtTime(t,e,r,i),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,r){return this._param.rampTo(t,e,r),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}};function an(n,t,e,r){(t instanceof se||Ht(t)||t instanceof $&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof $&&(t.overridden=!0)),tt(n,t,e,r)}var Vs=class n extends se{constructor(){let t=N(n.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Ue(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(se.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let i=this._fromType(t),o=this._events.get(e),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+e,u=this._exponentialApproach(o.time,o.value,i,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){let r=this.toSeconds(e);super.setValueAtTime(t,e);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(t,e){let r=this.toSeconds(e);super.linearRampToValueAtTime(t,e);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(t,e){e=this.toSeconds(e);let r=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max((e-i.time)*10,1)),s=(e-i.time)/o;for(let a=0;a<=o;a++){let c=s*a+i.time,u=this._exponentialInterpolate(i.time,i.value,e,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Be(t.ticks)){let s=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(s,t.time)}let r=this._fromType(this.getValueAtTime(t.time)),i=this._fromType(this.getValueAtTime(e)),o=this._events.get(e);return o&&o.time===e&&o.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(r+i)+t.ticks}getTicksAtTime(t){let e=this.toSeconds(t),r=this._events.get(e);return Math.max(this._getTicksUntilEvent(r,e),0)}getDurationOfTicks(t,e){let r=this.toSeconds(e),i=this.getTicksAtTime(e);return this.getTimeOfTick(i+t)-r}getTimeOfTick(t){let e=this._events.get(t,"ticks"),r=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&r&&r.type==="linearRampToValueAtTime"&&e.value!==r.value){let i=this._fromType(this.getValueAtTime(e.time)),s=(this._fromType(this.getValueAtTime(r.time))-i)/(r.time-e.time),a=Math.sqrt(Math.pow(i,2)-2*s*(e.ticks-t)),c=(-i+a)/s,u=(-i-a)/s;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){let r=this.toSeconds(e),i=this.toSeconds(t),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-o}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){let e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}};var qs=class n extends ${constructor(){let t=N(n.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new Vs({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign($.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}};var Ws=class n extends ze{constructor(){let t=N(n.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new hr,this._tickOffset=new Ue,this._ticksAtTime=new Ue,this._secondsAtTime=new Ue,this.frequency=new qs({context:this.context,units:t.units,value:t.frequency}),W(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},ze.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){let r=this.toSeconds(t);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),te(e)&&this.setTicksAtTime(e,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(t){let e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){let r=this._state.get(e);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){let e=this.toSeconds(t),r=this._state.getLastState("stopped",e),i=this._ticksAtTime.get(e),o={state:"paused",time:e};this._state.add(o);let s=i||r,a=i?i.ticks:0,c=null;return this._state.forEachBetween(s.time,e+this.sampleTime,u=>{let l=s.time,h=this._tickOffset.get(u.time);h&&h.time>=s.time&&(a=h.ticks,l=h.time),s.state==="started"&&u.state!=="started"&&(a+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(l),u.time!==o.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(o),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){let e=this.now(),r=this.frequency.timeToTicks(t,e);this.setTicksAtTime(r,e)}getSecondsAtTime(t){t=this.toSeconds(t);let e=this._state.getLastState("stopped",t),r={state:"paused",time:t};this._state.add(r);let i=this._secondsAtTime.get(t),o=i||e,s=i?i.seconds:0,a=null;return this._state.forEachBetween(o.time,t+this.sampleTime,c=>{let u=o.time,l=this._tickOffset.get(c.time);l&&l.time>=o.time&&(s=l.seconds,u=l.time),o.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),o=c}),this._state.remove(r),a&&this._secondsAtTime.add(a),s}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){let r=this._tickOffset.get(e),i=this._state.get(e),o=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(o)+t-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,r){let i=this._state.get(t);this._state.forEachBetween(t,e,s=>{i&&i.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(i.time,t),s.time-this.sampleTime,r),i=s});let o=null;if(i&&i.state==="started"){let s=Math.max(i.time,t),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(i.time),u=a-c,l=Math.ceil(u)-u;l=ht(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<e;){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 cn=class n extends ze{constructor(){let t=N(n.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=re,this._lastUpdate=0,this._state=new hr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Ws({context:this.context,frequency:t.frequency,units:t.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(ze.getDefaults(),{callback:re,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){js(this.context);let r=this.toSeconds(t);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,e),r<this._lastUpdate&&this.emit("start",r,e)),this}stop(t){let e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){let r=this.toSeconds(e),i=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(i+t,r)}_loop(){let t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,r=>{switch(r.state){case"started":let 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(t,e,(r,i)=>{this.callback(r,i)}))}getStateAtTime(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};Hr.mixin(cn);var jt=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new Z({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,W(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var Su=class n extends j{constructor(){let t=N(n.getDefaults(),arguments);super(t),this.name="Destination",this.input=new jt({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Lt(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),Lt(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};zr(n=>{n.destination=new Su({context:n})});Yr(n=>{n.destination.dispose()});var wu=class extends j{constructor(){super(...arguments),this.name="Listener",this.positionX=new se({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new se({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new se({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new se({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new se({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new se({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new se({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new se({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new se({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}};zr(n=>{n.listener=new wu({context:n})});Yr(n=>{n.listener.dispose()});var un=class n extends Ke{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=N(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let r=t.urls[e];this.add(e,r,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:re,onload:re,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return z(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,r=re,i=re){return nt(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new Le(this.baseUrl+e,r,i))):this._buffers.set(t.toString(),new Le(e,r,i)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var ao=class n extends dt{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return Qt(super._frequencyToUnits(t))}_ticksToUnits(t){return Qt(super._ticksToUnits(t))}_beatsToUnits(t){return Qt(super._beatsToUnits(t))}_secondsToUnits(t){return Qt(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return oo(this.toMidi())}transpose(t){return new n(this.context,this.toMidi()+t)}};var It=class extends kt{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var Nu=class extends ze{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Ue,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){let t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};zr(n=>{n.draw=new Nu({context:n})});Yr(n=>{n.draw.dispose()});var Us=class extends Ke{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){z(te(t.time),"Events must have a time property"),z(te(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Tu(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){let e=[];this._root.search(t.time,e);for(let r of e)if(r.event===t){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{let e=t.getBalance(),r,i=null;if(e>0)if(t.left.right===null)r=t.left,r.right=t.right,i=r;else{for(r=t.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,i=r.parent,r.left=t.left,r.right=t.right)}else if(t.right.left===null)r=t.right,r.left=t.left,i=r;else{for(r=t.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,i=r.parent,r.left=t.left,r.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=r:t.parent.right=r:this._setRoot(r),i&&this._rebalance(i)}t.dispose()}_rotateLeft(t){let e=t.parent,r=t.isLeftChild(),i=t.right;i&&(t.right=i.left,i.left=t),e!==null?r?e.left=i:e.right=i:this._setRoot(i)}_rotateRight(t){let e=t.parent,r=t.isLeftChild(),i=t.left;i&&(t.left=i.right,i.right=t),e!==null?r?e.left=i:e.right=i:this._setRoot(i)}_rebalance(t){let e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){let e=[];if(this._root.search(t,e),e.length>0){let r=e[0];for(let i=1;i<e.length;i++)e[i].low>r.low&&(r=e[i]);return r.event}}return null}forEach(t){if(this._root!==null){let e=[];this._root.traverse(r=>e.push(r)),e.forEach(r=>{r.event&&t(r.event)})}return this}forEachAtTime(t,e){if(this._root!==null){let r=[];this._root.search(t,r),r.forEach(i=>{i.event&&e(i.event)})}return this}forEachFrom(t,e){if(this._root!==null){let r=[];this._root.searchAfter(t,r),r.forEach(i=>{i.event&&e(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}},Tu=class{constructor(t,e,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var zs=class extends Ke{constructor(t){super(),this.name="TimelineValue",this._timeline=new Ue({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){let e=this._timeline.get(t);return e?e.value:this._initialValue}};var at=class n extends j{constructor(){super(N(n.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return an(this,t,e,r),this}};var ft=class n extends at{constructor(){let t=N(n.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Re(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):ym(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign($.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let i=0,o=e;i<o;i++){let s=i/(o-1)*2-1;r[i]=t(s,i)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){let e=["none","2x","4x"].some(r=>r.includes(t));z(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var ln=class n extends at{constructor(){let t=N(n.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new ft({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(at.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var Sr=class n{constructor(t,e){this.id=n._eventId++,this._remainderTime=0;let r=Object.assign(n.getDefaults(),e);this.transport=t,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:re,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){let e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};Sr._eventId=0;var Ys=class n extends Sr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(n.getDefaults(),e);this.duration=r.duration,this._interval=r.interval,this._nextTick=r.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Sr.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return pi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new It(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){pi(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 It(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let e=this.transport.getTicksAtTime(t);Ir(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}};var Hs=class n extends ze{constructor(){let t=N(n.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new zs(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Ue,this._repeatedEvents=new Us,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new cn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),W(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(ze.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){let r=e%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(r*Math.PI)*this._swingAmount;t+=new It(this.context,this._swingTicks*2/3).toSeconds()*i}Au(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),Au(!1)}schedule(t,e){let r=new Sr(this,{callback:t,time:new kt(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,i=1/0){let o=new Ys(this,{callback:t,duration:new vt(this.context,i).toTicks(),interval:new vt(this.context,e).toTicks(),time:new kt(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(t,e){let r=new Sr(this,{callback:t,once:!0,time:new kt(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){let e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){let e=this.toTicks(t);return this._timeline.forEachFrom(e,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(e,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new It(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let r;return te(e)&&(r=this.toTicks(e)),this._clock.start(t,r),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Re(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new vt(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new vt(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new It(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){let t=this.now(),e=this._clock.getTicksAtTime(t);return new It(this.context,e).toBarsBeatsSixteenths()}set position(t){let e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){let e=this.now(),r=this._clock.frequency.timeToTicks(t,e);this.ticks=r}get progress(){if(this.loop){let t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){let e=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(e),i=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,e),o=e+i;this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{let e=this.now(),r=this.getTicksAtTime(e),i=t-r%t;return this._clock.nextTickTime(i,e)}}syncSignal(t,e){let r=this.now(),i=this.bpm,o=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/o,u=new Z(c),l=new ln(-1),h=new Z(c);i.chain(u,l,h),i=h,o=1/o,s=[u,l,h]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/o:e=0);let a=new Z(e);return i.connect(a),a.connect(t._param),s.push(a),this._syncedSignals.push({initial:t.value,nodes:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){let r=this._syncedSignals[e];r.signal===t&&(r.nodes.forEach(i=>i.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),fi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};Hr.mixin(Hs);zr(n=>{n.transport=new Hs({context:n})});Yr(n=>{n.transport.dispose()});var be=class extends j{constructor(t){super(t),this.input=void 0,this._state=new hr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=re,this._syncedStop=re,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new jt({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,W(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,onstop:re,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,r){let i=Be(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")z(Ir(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,e,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(_t(e,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,e,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 js(this.context),this._start(i,e,r);return this}stop(t){let e=Be(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||te(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{let r=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(r)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,r){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(Ir(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let i=e-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-i),this._start(t,this.toSeconds(r.offset)+i,o)}}},this._syncedStop=t=>{let e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=re,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var dr=class n extends Kt{constructor(){let t=N(n.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,tt(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new se({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new Le(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Kt.getDefaults(),{url:new Le,loop:!1,loopEnd:0,loopStart:0,onload:re,onerror:re,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,r,i=1){z(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(t);this._startGain(o,i),this.loop?e=_t(e,this.loopStart):e=_t(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;no(s,a)&&(s=(s-c)%u+c),ht(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,pi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),te(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var bi=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(be.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(z(t in Bm,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,this.state==="started")){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){let e=Bm[this._type];this._source=new dr({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},hn=44100*5,Ou=2,wr={brown:null,pink:null,white:null},Bm={get brown(){if(!wr.brown){let n=[];for(let t=0;t<Ou;t++){let e=new Float32Array(hn);n[t]=e;let r=0;for(let i=0;i<hn;i++){let o=Math.random()*2-1;e[i]=(r+.02*o)/1.02,r=e[i],e[i]*=3.5}}wr.brown=new Le().fromArray(n)}return wr.brown},get pink(){if(!wr.pink){let n=[];for(let t=0;t<Ou;t++){let e=new Float32Array(hn);n[t]=e;let r,i,o,s,a,c,u;r=i=o=s=a=c=u=0;for(let l=0;l<hn;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,e[l]=r+i+o+s+a+c+u+h*.5362,e[l]*=.11,u=h*.115926}}wr.pink=new Le().fromArray(n)}return wr.pink},get white(){if(!wr.white){let n=[];for(let t=0;t<Ou;t++){let e=new Float32Array(hn);n[t]=e;for(let r=0;r<hn;r++)e[r]=Math.random()*2-1}wr.white=new Le().fromArray(n)}return wr.white}};function gt(n,t){return he(this,void 0,void 0,function*(){let e=t/n.context.sampleRate,r=new Xt(1,e,n.context.sampleRate);return new n.constructor(Object.assign(n.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var co=class n extends Kt{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],tt(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new se({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new se({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),W(this,["frequency","detune"])}static getDefaults(){return Object.assign(Kt.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Me=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),W(this,"frequency"),this.detune=new $({context:this.context,units:"cents",value:t.detune}),W(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!=="custom"&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(be.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){let e=this.toSeconds(t),r=new co({context:this.context,onended:()=>this.onstop(this)});this._oscillator=r,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){let e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){let e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return n._periodicWaveCache.find(e=>e.phase===this._phase&&Om(e.partials,this._partials));{let t=n._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;let e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let r=this._getCachedPeriodicWave();if(te(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(t,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(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){ke(t,0);let e=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(e=r[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{let i=new Float32Array(t);this._partials.forEach((o,s)=>i[s]=o),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(t,e){let i=2048,o=new Float32Array(i),s=new Float32Array(i),a=1;if(t==="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(t);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=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(t){case"sine":l=c<=a?1:0,this._partials[c-1]=l;break;case"square":l=c&1?2*u:0,this._partials[c-1]=l;break;case"sawtooth":l=u*(c&1?1:-1),this._partials[c-1]=l;break;case"triangle":c&1?l=2*(u*u)*(c-1>>1&1?-1:1):l=0,this._partials[c-1]=l;break;case"custom":l=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}l!==0?(o[c]=-l*Math.sin(e*c),s[c]=l*Math.cos(e*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(t,e,r){let i=0,o=t.length;for(let s=0;s<o;s++)i+=t[s]*Math.cos(s*r)+e[s]*Math.sin(s*r);return i}getInitialValue(){let[t,e]=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(t,e,s/o*i),r);return _u(-this._inverseFFT(t,e,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Me._periodicWaveCache=[];var dn=class extends at{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new ft({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var Ye=class n extends ${constructor(){let t=N(n.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Z({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign($.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var uo=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new dn({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Me({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Me({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ye({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),W(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Me.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}};var pn=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Me({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Me({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ye({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Ye({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),W(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Me.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var yi=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new ft({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new $({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Me({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),W(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(be.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var lo=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this.detune=new $({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,W(this,["frequency","detune"])}static getDefaults(){return Object.assign(Me.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){let e=-t/2,r=t/(this._oscillators.length-1);this._forEach((i,o)=>i.detune.value=e+r*o)}}get count(){return this._oscillators.length}set count(t){if(ke(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Me({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):re});this.type==="custom"&&(r.partials=this._partials),this.frequency.connect(r.frequency),this.detune.connect(r.detune),r.detune.overridden=!1,r.connect(this.output),this._oscillators[e]=r}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,r)=>e.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var ho=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Ye({context:this.context,value:2}),this._pulse=new yi({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Me({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),W(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(be.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var Gm={am:uo,fat:lo,fm:pn,oscillator:Me,pulse:yi,pwm:ho},xi=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this.detune=new $({context:this.context,units:"cents",value:t.detune}),W(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Me.getDefaults(),pn.getDefaults(),uo.getDefaults(),lo.getDefaults(),yi.getDefaults(),ho.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;let e=Gm[t],r=this.now();if(this._oscillator){let i=this._oscillator;i.stop(r),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(r)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof Gm[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(t){this._getOscType(this._oscillator,"fat")&&et(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&et(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&nt(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return he(this,arguments,void 0,function*(t=1024){return gt(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function Xs(n,t=1/0){let e=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){ke(o,n,t),e.set(this,o)}})}}function bt(n,t=1/0){let e=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){ke(this.toSeconds(o),n,t),e.set(this,o)}})}}var po=class n extends be{constructor(){let t=N(n.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new Le({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(be.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:re,onerror:re,playbackRate:1,reverse:!1})}load(t){return he(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=re){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,r){return super.start(t,e,r),this}_start(t,e,r){this._loop?e=_t(e,this._loopStart):e=_t(e,0);let i=this.toSeconds(e),o=r;r=_t(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new dr({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Be(o)?a.start(t,i):a.start(t,i,s-this.toSeconds(this.fadeOut))}_stop(t){let e=this.toSeconds(t);this._activeSources.forEach(r=>r.stop(e))}restart(t,e,r){return super.restart(t,e,r),this}_restart(t,e,r){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(t),this._start(t,e,r)}seek(t,e){let r=this.toSeconds(e);if(this._state.getValueAtTime(r)==="started"){let i=this.toSeconds(t);this._stop(r),this._start(r,i)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&ke(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&ke(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){let e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;let e=this.now(),r=this._state.getNextState("stopped",e);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};st([bt(0)],po.prototype,"fadeIn",void 0);st([bt(0)],po.prototype,"fadeOut",void 0);var Qs=class extends at{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new ft({context:this.context,mapping:t=>Math.abs(t)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var pt=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new $({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(j.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(nt(t))return t;{let r;for(r in Ks)if(Ks[r][e]===t)return r;return t}}_setCurve(t,e,r){if(nt(r)&&Reflect.has(Ks,r)){let i=Ks[r];Yt(i)?t!=="_decayCurve"&&(this[t]=i[e]):this[t]=i}else if(Re(r)&&t!=="_decayCurve")this[t]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let i=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(t);if(s>0){let a=1/i;i=(1-s)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,i,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,i,t);else{this._sig.cancelAndHoldAtTime(t);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=s&&s<=a[c]){a=this._attackCurve.slice(c),a[0]=s;break}this._sig.setValueCurveAtTime(a,t,i,e)}if(o&&this.sustain<1){let a=e*this.sustain,c=t+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);let e=this.getValueAtTime(t);if(e>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,t):(z(Re(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,r,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,r=1){return e=this.toSeconds(e),this.triggerAttack(e,r),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,r=0){return an(this,t,e,r),this}asArray(){return he(this,arguments,void 0,function*(t=1024){let e=t/this.context.sampleRate,r=new Xt(1,e,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:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(e*(i+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};st([bt(0)],pt.prototype,"attack",void 0);st([bt(0)],pt.prototype,"decay",void 0);st([Xs(0,1)],pt.prototype,"sustain",void 0);st([bt(0)],pt.prototype,"release",void 0);var Ks=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let i=[],o=6.4;for(t=0;t<127;t++){e=t/127;let d=Math.sin(e*(Math.PI*2)*o-Math.PI/2)+1;i[t]=d/10+e*.83}i[127]=1;let s=[],a=5;for(t=0;t<128;t++)s[t]=Math.ceil(t/127*a)/a;let c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));let u=[];for(t=0;t<128;t++){e=t/127;let d=Math.pow(e,3)*4+.2,m=Math.cos(d*Math.PI*2*e);u[t]=Math.abs(m*(1-e))}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 St=class n extends j{constructor(){let t=N(n.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new jt({context:this.context,volume:t.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 t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){let r=this["_original_"+t]=this[t];this[t]=(...i)=>{let o=i[e],s=this.context.transport.schedule(a=>{i[e]=a,r.apply(this,i)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,r,i){let o=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,o,i),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var yt=class n extends St{constructor(){let t=N(n.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(St.getDefaults(),{detune:0,onsilence:re,portamento:0})}triggerAttack(t,e,r=1){this.log("triggerAttack",t,e,r);let i=this.toSeconds(e);return this._triggerEnvelopeAttack(i,r),this.setNote(t,i),this}triggerRelease(t){this.log("triggerRelease",t);let e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){let r=this.toSeconds(e),i=t instanceof dt?t.toFrequency():t;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}};st([bt(0)],yt.prototype,"portamento",void 0);var mn=class n extends pt{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 pr=class n extends yt{constructor(){let t=N(n.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new xi(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new mn(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),W(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(yt.getDefaults(),{envelope:Object.assign(Zt(pt.getDefaults(),Object.keys(j.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Zt(xi.getDefaults(),[...Object.keys(be.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+r+i)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var mo=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new se({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new se({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new se({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new se({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.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(t){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){let e=new Float32Array(t);for(let s=0;s<t;s++){let c=Math.pow(s/t,2)*19980+20;e[s]=c}let r=new Float32Array(t),i=new Float32Array(t),o=this.context.createBiquadFilter();return o.type=this.type,o.Q.value=this.Q.value,o.frequency.value=this.frequency.value,o.gain.value=this.gain.value,o.getFrequencyResponse(e,r,i),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var Nr=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new $({context:this.context,units:"positive",value:t.Q}),this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this.detune=new $({context:this.context,units:"cents",value:t.detune}),this.gain=new $({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.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(t){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._type=t,this._filters.forEach(r=>r.type=t)}get rolloff(){return this._rolloff}set rolloff(t){let e=et(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],i=r.indexOf(e);z(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(i);for(let o=0;o<i;o++){let s=new mo({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,Lt(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new mo({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),r=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((o,s)=>r[s]*=o)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),fi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var Js=class n extends pr{constructor(){let t=N(n.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,W(this,["oscillator","envelope"])}static getDefaults(){return Et(yt.getDefaults(),pr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){let r=this.toSeconds(e),i=this.toFrequency(t instanceof dt?t.toFrequency():t),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}};st([Xs(0)],Js.prototype,"octaves",void 0);st([bt(0)],Js.prototype,"pitchDecay",void 0);var Vm=new Set;function gn(n){Vm.add(n)}function $s(n,t){let e=`registerProcessor("${n}", ${t})`;Vm.add(e)}var mx=`
|
|
19
|
+
`],{type:"text/javascript"}),e=URL.createObjectURL(t),r=new Worker(e);r.onmessage=this._callback.bind(this),this._worker=r}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}};function ur(i){return of(i)}function Nr(i){return nf(i)}function _n(i){return sf(i)}function ui(i){return rf(i)}function yf(i){return i instanceof Hu}function C_(i,t){return i==="value"||ur(t)||Nr(t)||yf(t)}function Ye(i,...t){if(!t.length)return i;let e=t.shift();if(cr(i)&&cr(e))for(let r in e)C_(r,e[r])?i[r]=e[r]:cr(e[r])?(i[r]||Object.assign(i,{[r]:{}}),Ye(i[r],e[r])):Object.assign(i,{[r]:e[r]});return Ye(i,...t)}function bf(i,t){return i.length===t.length&&i.every((e,r)=>t[r]===e)}function w(i,t,e=[],r){let n={},o=Array.from(t);if(cr(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(i,a))||(Ye(n,{[r]:o[0]}),e.splice(e.indexOf(r),1),o.shift())),o.length===1&&cr(o[0]))Ye(n,o[0]);else for(let s=0;s<e.length;s++)it(o[s])&&(n[e[s]]=o[s]);return Ye(i,n)}function xf(i){return i.constructor.getDefaults()}function Le(i,t){return Yt(i)?t:i}function hr(i,t){return t.forEach(e=>{Reflect.has(i,e)&&delete i[e]}),i}var ie=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||me&&this.toString()===me.TONE_DEBUG_CLASS)&&df(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};ie.version=po;function Vr(i,t){return i>t+1e-6}function wo(i,t){return Vr(i,t)||Ce(i,t)}function Ei(i,t){return i+1e-6<t}function Ce(i,t){return Math.abs(i-t)<1e-6}function th(i,t,e){return Math.max(Math.min(i,e),t)}var Qt=class i extends ie{constructor(){super(),this.name="Timeline",this._timeline=[];let t=w(i.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(Y(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){let e=this._timeline[this.length-1];Y(wo(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{let e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){let e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){let r=this._search(t,e);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){let r=this._search(t,e);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(t){let e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];let r=this._search(t);return r-1>=0?this._timeline[r-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Ce(this._timeline[e].time,t)){for(let r=e;r>=0&&Ce(this._timeline[r].time,t);r--)e=r;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&wo(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){let e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){let e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let r=0,n=this._timeline.length,o=n;if(n>0&&this._timeline[n-1][e]<=t)return n-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(Ce(a[e],t)){for(let u=s;u<this._timeline.length;u++){let h=this._timeline[u];if(Ce(h[e],t))s=u;else break}return s}else{if(Ei(a[e],t)&&Vr(c[e],t))return s;Vr(a[e],t)?o=s:r=s+1}}return-1}_iterate(t,e=0,r=this._timeline.length-1){this._timeline.slice(e,r+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){let r=this._search(t);return r!==-1&&this._iterate(e,0,r),this}forEachAfter(t,e){let r=this._search(t);return this._iterate(e,r+1),this}forEachBetween(t,e,r){let n=this._search(t),o=this._search(e);return n!==-1&&o!==-1?(this._timeline[n].time!==t&&(n+=1),this._timeline[o].time===e&&(o-=1),this._iterate(r,n,o)):n===-1&&this._iterate(r,0,o),this}forEachFrom(t,e){let r=this._search(t);for(;r>=0&&this._timeline[r].time>=t;)r--;return this._iterate(e,r+1),this}forEachAtTime(t,e){let r=this._search(t);if(r!==-1&&Ce(this._timeline[r].time,t)){let n=r;for(let o=r;o>=0&&Ce(this._timeline[o].time,t);o--)n=o;this._iterate(o=>{e(o)},n,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Af=[];function hi(i){Af.push(i)}function Cf(i){Af.forEach(t=>t(i))}var _f=[];function li(i){_f.push(i)}function vf(i){_f.forEach(t=>t(i))}var di=class i extends ie{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(n=>{Yt(this._events)&&(this._events={}),this._events.hasOwnProperty(n)||(this._events[n]=[]),this._events[n].push(e)}),this}once(t,e){let r=(...n)=>{e(...n),this.off(t,r)};return this.on(t,r),this}off(t,e){return t.split(/\W+/).forEach(n=>{if(Yt(this._events)&&(this._events={}),this._events.hasOwnProperty(n))if(Yt(e))this._events[n]=[];else{let o=this._events[n];for(let s=o.length-1;s>=0;s--)o[s]===e&&o.splice(s,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){let r=this._events[t].slice(0);for(let n=0,o=r.length;n<o;n++)r[n].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(i.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var vn=class extends di{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var Di=class i extends vn{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Qt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=w(i.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=pf({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new ma(this.emit.bind(this,"tick"),r.clockSource,r.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Cf(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,r){return this._context.createBuffer(t,e,r)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,r){return this._context.createPeriodicWave(t,e,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return Y(ui(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return Y(ui(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return Y(ui(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){Y(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Y(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Y(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Y(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return gf(this.rawContext,t,e)}addAudioWorkletModule(t){return mt(this,void 0,void 0,function*(){Y(it(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return mt(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return ui(this._context)?this._context.resume():Promise.resolve()}close(){return mt(this,void 0,void 0,function*(){ui(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&vf(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{let e=this._context.createBuffer(1,128,this._context.sampleRate),r=e.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=t;let n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants.set(t,n),n}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){let t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:r+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){let r=++this._timeoutIds,n=()=>{let o=this.now();this._timeouts.add({callback:()=>{t(),n()},id:r,time:o+e})};return n(),r}};var fa=class extends vn{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,r){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return mt(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};function U(i,t){Pt(t)?t.forEach(e=>U(i,e)):Object.defineProperty(i,t,{enumerable:!0,writable:!1})}function ki(i,t){Pt(t)?t.forEach(e=>ki(i,e)):Object.defineProperty(i,t,{writable:!0})}var nt=()=>{};var qt=class i extends ie{constructor(){super(),this.name="ToneAudioBuffer",this.onload=nt;let t=w(i.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,pe(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:nt,onload:nt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Ht().sampleRate}set(t){return t instanceof i?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return mt(this,void 0,void 0,function*(){let e=i.load(t).then(r=>{this.set(r),this.onload(this)});i.downloads.push(e);try{yield e}finally{let r=i.downloads.indexOf(e);i.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Pt(t)&&t[0].length>0,r=e?t.length:1,n=e?t[0].length:t.length,o=Ht(),s=o.createBuffer(r,n,o.sampleRate),a=!e&&r===1?[t]:t;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(t){if(ce(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let n=0;n<r;n++){let o=this.toArray(n);for(let s=0;s<o.length;s++)e[s]+=o[s]}e=e.map(n=>n/r),this.fromArray(e)}return this}toArray(t){if(ce(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let r=0;r<this.numberOfChannels;r++)e[r]=this.getChannelData(r);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){Y(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),n=Math.floor(e*this.sampleRate);Y(r<n,"The start time must be less than the end time");let o=n-r,s=Ht().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,n),a);return new i(s)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new i().fromArray(t)}static fromUrl(t){return mt(this,void 0,void 0,function*(){return yield new i().load(t)})}static load(t){return mt(this,void 0,void 0,function*(){let e=i.baseUrl===""||i.baseUrl.endsWith("/")?i.baseUrl:i.baseUrl+"/",r=yield fetch(e+t);if(!r.ok)throw new Error(`could not load url: ${t}`);let n=yield r.arrayBuffer();return yield Ht().decodeAudioData(n)})}static supportsType(t){let e=t.split("."),r=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return mt(this,void 0,void 0,function*(){for(yield Promise.resolve();i.downloads.length;)yield i.downloads[0]})}};qt.baseUrl="";qt.downloads=[];var lr=class extends Di{constructor(){super({clockSource:"offline",context:_n(arguments[0])?arguments[0]:mf(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:_n(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=_n(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return mt(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;let r=Math.floor(this.sampleRate/128);t&&e%r===0&&(yield new Promise(n=>setTimeout(n,1)))}})}render(){return mt(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);let e=yield this._context.startRendering();return new qt(e)})}close(){return Promise.resolve()}};var If=new fa,In=If;function Ht(){return In===If&&ff&&eh(new Di),In}function eh(i,t=!1){t&&In.dispose(),ui(i)?In=new Di(i):_n(i)?In=new lr(i):In=i}if(me&&!me.TONE_SILENCE_LOGGING){let i="v";po==="dev"&&(i="");let t=` * Tone.js ${i}${po} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function Sn(i){return Math.pow(10,i/20)}function wn(i){return 20*(Math.log(i)/Math.LN10)}function Li(i){return Math.pow(2,i/12)}var ga=440;function Sf(){return ga}function wf(i){ga=i}function dr(i){return Math.round(rh(i))}function rh(i){return 69+12*Math.log2(i/ga)}function No(i){return ga*Math.pow(2,(i-69)/12)}var ya=class i extends ie{constructor(t,e,r){super(),this.defaultUnits="s",this._val=e,this._units=r,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{let r=parseInt(t,10),n=e==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*n:this._beatsToUnits(4/r)*n},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{let e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,r)=>{let n=0;return t&&t!=="0"&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(n+=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(n+=this._beatsToUnits(parseFloat(r)/4)),n},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof i&&this.fromType(this._val),Yt(this._val))return this._noArg();if(pe(this._val)&&Yt(this._units)){for(let t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(cr(this._val)){let t=0;for(let e in this._val)if(it(this._val[e])){let r=this._val[e],n=new this.constructor(this.context,e).valueOf()*r;t+=n}return t}if(it(this._units)){let t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return pe(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var je=class i extends ya{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let e=new i(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){let r=new this.constructor(this.context,t).valueOf(),n=this.valueOf(),a=Math.round(n/r)*r-n;return n+a*e}toNotation(){let t=this.toSeconds(),e=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],n=new i(this.context,e[0]).toSeconds();return e.forEach(o=>{let s=new i(this.context,o).toSeconds();Math.abs(s-t)<Math.abs(n-t)&&(r=o,n=s)}),r}toBarsBeatsSixteenths(){let t=this._beatsToUnits(1),e=this.valueOf()/t;e=parseFloat(e.toFixed(4));let r=Math.floor(e/this._getTimeSignature()),n=e%1*4;e=Math.floor(e)%this._getTimeSignature();let o=n.toString();return o.length>3&&(n=parseFloat(parseFloat(o).toFixed(3))),[r,e,n].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return dr(this.toFrequency())}_now(){return this.context.now()}};var _e=class i extends je{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Sf()}static set A4(t){wf(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:i.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let n=__[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?n:i.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,r){let n=1;return t&&t!=="0"&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(n*=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(n*=this._beatsToUnits(parseFloat(r)/4)),n}}})}transpose(t){return new i(this.context,this.valueOf()*Li(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return dr(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/i.A4),r=Math.round(12*e)+57,n=Math.floor(r/12);return n<0&&(r+=-12*n),v_[r%12]+n.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return No(t)}static ftom(t){return dr(t)}},__={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},v_=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var He=class extends je{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var Kt=class i extends ie{constructor(){super();let t=w(i.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Ht()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return hf(t),new je(this.context,t).toSeconds()}toFrequency(t){return new _e(this.context,t).toFrequency()}toTicks(t){return new He(this.context,t).toTicks()}_getPartialProperties(t){let e=this.get();return Object.keys(e).forEach(r=>{Yt(t[r])&&delete e[r]}),e}get(){let t=xf(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){let r=this[e];it(r)&&it(r.value)&&it(r.setValueAtTime)?t[e]=r.value:r instanceof i?t[e]=r._getPartialProperties(t[e]):Pt(r)||ce(r)||pe(r)||Ku(r)?t[e]=r:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&it(this[e])&&(this[e]&&it(this[e].value)&&it(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof i?this[e].set(t[e]):this[e]=t[e])}),this}};var Tr=class extends Qt{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){let e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,r){return Vt(e,0),this.add(Object.assign({},r,{state:t,time:e})),this}getLastState(t,e){let r=this._search(e);for(let n=r;n>=0;n--){let o=this._timeline[n];if(o.state===t)return o}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let n=r;n<this._timeline.length;n++){let o=this._timeline[n];if(o.state===t)return o}}};var ut=class i extends Kt{constructor(){let t=w(i.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,Y(it(t.param)&&(ur(t.param)||t.param instanceof i),"param must be an AudioParam");!ur(t.param);)t.param=t.param._param;this._swappable=it(t.swappable)?t.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new Qt(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,it(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Kt.getDefaults(),{convert:!0,units:"number"})}get value(){let t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return it(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 it(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return it(this.maxValue)&&it(this.minValue)&&Vt(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?Sn(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?wn(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),n=this._fromType(t);return Y(isFinite(n)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this.log(this.units,"setValueAtTime",t,r),this._events.add({time:r,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,r),this}getValueAtTime(t){let e=Math.max(this.toSeconds(t),0),r=this._events.getAfter(e),n=this._events.get(e),o=this._initialValue;if(n===null)o=this._initialValue;else if(n.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(n.time),a;s===null?a=this._initialValue:a=s.value,n.type==="setTargetAtTime"&&(o=this._exponentialApproach(n.time,a,n.value,n.constant,e))}else if(r===null)o=n.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=n.value;if(n.type==="setTargetAtTime"){let a=this._events.getBefore(n.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(n.time,s,r.time,r.value,e):o=this._exponentialInterpolate(n.time,s,r.time,r.value,e)}else o=n.value;return this._toType(o)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){let r=this._fromType(t),n=this.toSeconds(e);return Y(isFinite(r)&&isFinite(n),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this._events.add({time:n,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",t,n),this._param.linearRampToValueAtTime(r,n),this}exponentialRampToValueAtTime(t,e){let r=this._fromType(t);r=Ce(r,0)?this._minOutput:r,this._assertRange(r);let n=this.toSeconds(e);return Y(isFinite(r)&&isFinite(n),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:n,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",t,n),this._param.exponentialRampToValueAtTime(r,n),this}exponentialRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(t,r+this.toSeconds(e)),this}linearRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(t,r+this.toSeconds(e)),this}targetRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(t,r,e),this}exponentialApproachValueAtTime(t,e,r){e=this.toSeconds(e),r=this.toSeconds(r);let n=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(t,e,n),this.cancelAndHoldAtTime(e+r*.9),this.linearRampToValueAtTime(t,e+r),this}setTargetAtTime(t,e,r){let n=this._fromType(t);Y(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(e);return this._assertRange(n),Y(isFinite(n)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:n}),this.log(this.units,"setTargetAtTime",t,o,r),this._param.setTargetAtTime(n,o,r),this}setValueCurveAtTime(t,e,r,n=1){r=this.toSeconds(r),e=this.toSeconds(e);let o=this._fromType(t[0])*n;this.setValueAtTime(this._toType(o),e);let s=r/(t.length-1);for(let a=1;a<t.length;a++){let c=this._fromType(t[a])*n;this.linearRampToValueAtTime(this._toType(c),e+a*s)}return this}cancelScheduledValues(t){let e=this.toSeconds(t);return Y(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){let e=this.toSeconds(t),r=this._fromType(this.getValueAtTime(e));Y(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let n=this._events.get(e),o=this._events.getAfter(e);return n&&Ce(n.time,e)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),e)),this._events.add({time:e,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,e),this}rampTo(t,e=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,r):this.linearRampTo(t,e,r),this}apply(t){let e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);let r=this._events.get(e);if(r&&r.type==="setTargetAtTime"){let n=this._events.getAfter(r.time),o=n?n.time:e+2,s=(o-e)/10;for(let a=e;a<o;a+=s)t.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,n=>{n.type==="cancelScheduledValues"?t.cancelScheduledValues(n.time):n.type==="setTargetAtTime"?t.setTargetAtTime(n.value,n.time,n.constant):t[n.type](n.value,n.time)}),this}setParam(t){Y(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,r,n,o){return r+(e-r)*Math.exp(-(o-t)/n)}_linearInterpolate(t,e,r,n,o){return e+(n-e)*((o-t)/(r-t))}_exponentialInterpolate(t,e,r,n,o){return e*Math.pow(n/e,(o-t)/(r-t))}};var L=class i extends Kt{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return it(this.input)?ur(this.input)||this.input instanceof ut?1:this.input.numberOfInputs:0}get numberOfOutputs(){return it(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return it(t)&&(t instanceof i||Nr(t))}_getInternalNodes(){let t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(r=>{r.channelCount=t.channelCount,r.channelCountMode=t.channelCountMode,r.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){let t=this._getInternalNodes();Y(t.length>0,"ToneAudioNode does not have any internal nodes");let e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,r=0){return ue(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Mi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return Nf(this,t,e,r),this}chain(...t){return Ze(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),it(this.input)&&(this.input instanceof i?this.input.dispose():Nr(this.input)&&this.input.disconnect()),it(this.output)&&(this.output instanceof i?this.output.dispose():Nr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Ze(...i){let t=i.shift();i.reduce((e,r)=>(e instanceof L?e.connect(r):Nr(e)&&ue(e,r),r),t)}function ue(i,t,e=0,r=0){for(Y(it(i),"Cannot connect from undefined node"),Y(it(t),"Cannot connect to undefined node"),(t instanceof L||Nr(t))&&Y(t.numberOfInputs>0,"Cannot connect to node with no inputs"),Y(i.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof L||t instanceof ut;)it(t.input)&&(t=t.input);for(;i instanceof L;)it(i.output)&&(i=i.output);ur(t)?i.connect(t,e):i.connect(t,e,r)}function Nf(i,t,e=0,r=0){if(it(t))for(;t instanceof L;)t=t.input;for(;!Nr(i);)it(i.output)&&(i=i.output);ur(t)?i.disconnect(t,e):Nr(t)?i.disconnect(t,e,r):i.disconnect()}var $=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new ut({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),U(this,"gain")}static getDefaults(){return Object.assign(L.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}};var pr=class extends L{constructor(t){super(t),this.onended=nt,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new $({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let r=this.toSeconds(e);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(L.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:nt})}_startGain(t,e=1){Y(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=t+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+r):this._gainNode.gain.exponentialApproachValueAtTime(e,t,r)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Y(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==nt&&(this.onended(this),this.onended=nt,!this.context.isOffline)){let t=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Y(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=nt,this}};var To=class i extends pr{constructor(){let t=w(i.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),ue(this._source,this._gainNode),this.offset=new ut({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(pr.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var et=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new To({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(L.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,r=0){return Nn(this,t,e,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,r){return this._param.exponentialRampTo(t,e,r),this}linearRampTo(t,e,r){return this._param.linearRampTo(t,e,r),this}targetRampTo(t,e,r){return this._param.targetRampTo(t,e,r),this}exponentialApproachValueAtTime(t,e,r){return this._param.exponentialApproachValueAtTime(t,e,r),this}setTargetAtTime(t,e,r){return this._param.setTargetAtTime(t,e,r),this}setValueCurveAtTime(t,e,r,n){return this._param.setValueCurveAtTime(t,e,r,n),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,r){return this._param.rampTo(t,e,r),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}};function Nn(i,t,e,r){(t instanceof ut||ur(t)||t instanceof et&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof et&&(t.overridden=!0)),ue(i,t,e,r)}var ba=class i extends ut{constructor(){let t=w(i.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Qt(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(ut.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let n=this._fromType(t),o=this._events.get(e),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+e,u=this._exponentialApproach(o.time,o.value,n,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){let r=this.toSeconds(e);super.setValueAtTime(t,e);let n=this._events.get(r),o=this._events.previousEvent(n),s=this._getTicksUntilEvent(o,r);return n.ticks=Math.max(s,0),this}linearRampToValueAtTime(t,e){let r=this.toSeconds(e);super.linearRampToValueAtTime(t,e);let n=this._events.get(r),o=this._events.previousEvent(n),s=this._getTicksUntilEvent(o,r);return n.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);let r=this._fromType(t),n=this._events.get(e),o=Math.round(Math.max((e-n.time)*10,1)),s=(e-n.time)/o;for(let a=0;a<=o;a++){let c=s*a+n.time,u=this._exponentialInterpolate(n.time,n.value,e,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Yt(t.ticks)){let s=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(s,t.time)}let r=this._fromType(this.getValueAtTime(t.time)),n=this._fromType(this.getValueAtTime(e)),o=this._events.get(e);return o&&o.time===e&&o.type==="setValueAtTime"&&(n=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(r+n)+t.ticks}getTicksAtTime(t){let e=this.toSeconds(t),r=this._events.get(e);return Math.max(this._getTicksUntilEvent(r,e),0)}getDurationOfTicks(t,e){let r=this.toSeconds(e),n=this.getTicksAtTime(e);return this.getTimeOfTick(n+t)-r}getTimeOfTick(t){let e=this._events.get(t,"ticks"),r=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&r&&r.type==="linearRampToValueAtTime"&&e.value!==r.value){let n=this._fromType(this.getValueAtTime(e.time)),s=(this._fromType(this.getValueAtTime(r.time))-n)/(r.time-e.time),a=Math.sqrt(Math.pow(n,2)-2*s*(e.ticks-t)),c=(-n+a)/s,u=(-n-a)/s;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){let r=this.toSeconds(e),n=this.toSeconds(t),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+n)-o}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){let e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}};var xa=class i extends et{constructor(){let t=w(i.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new ba({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(et.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}};var Aa=class i extends Kt{constructor(){let t=w(i.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new Tr,this._tickOffset=new Qt,this._ticksAtTime=new Qt,this._secondsAtTime=new Qt,this.frequency=new xa({context:this.context,units:t.units,value:t.frequency}),U(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Kt.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){let r=this.toSeconds(t);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),it(e)&&this.setTicksAtTime(e,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(t){let e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){let r=this._state.get(e);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){let e=this.toSeconds(t),r=this._state.getLastState("stopped",e),n=this._ticksAtTime.get(e),o={state:"paused",time:e};this._state.add(o);let s=n||r,a=n?n.ticks:0,c=null;return this._state.forEachBetween(s.time,e+this.sampleTime,u=>{let h=s.time,l=this._tickOffset.get(u.time);l&&l.time>=s.time&&(a=l.ticks,h=l.time),s.state==="started"&&u.state!=="started"&&(a+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(h),u.time!==o.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(o),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){let e=this.now(),r=this.frequency.timeToTicks(t,e);this.setTicksAtTime(r,e)}getSecondsAtTime(t){t=this.toSeconds(t);let e=this._state.getLastState("stopped",t),r={state:"paused",time:t};this._state.add(r);let n=this._secondsAtTime.get(t),o=n||e,s=n?n.seconds:0,a=null;return this._state.forEachBetween(o.time,t+this.sampleTime,c=>{let u=o.time,h=this._tickOffset.get(c.time);h&&h.time>=o.time&&(s=h.seconds,u=h.time),o.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),o=c}),this._state.remove(r),a&&this._secondsAtTime.add(a),s}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){let r=this._tickOffset.get(e),n=this._state.get(e),o=Math.max(r.time,n.time),s=this.frequency.getTicksAtTime(o)+t-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,r){let n=this._state.get(t);this._state.forEachBetween(t,e,s=>{n&&n.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(n.time,t),s.time-this.sampleTime,r),n=s});let o=null;if(n&&n.state==="started"){let s=Math.max(n.time,t),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(n.time),u=a-c,h=Math.ceil(u)-u;h=Ce(h,1)?0:h;let l=this.frequency.getTimeOfTick(a+h);for(;l<e;){try{r(l,Math.round(this.getTicksAtTime(l)))}catch(p){o=p;break}l+=this.frequency.getDurationOfTicks(1,l)}}if(o)throw o;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var Tn=class i extends Kt{constructor(){let t=w(i.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=nt,this._lastUpdate=0,this._state=new Tr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Aa({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,U(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Kt.getDefaults(),{callback:nt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){pa(this.context);let r=this.toSeconds(t);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,e),r<this._lastUpdate&&this.emit("start",r,e)),this}stop(t){let e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){let r=this.toSeconds(e),n=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(n+t,r)}_loop(){let t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,r=>{switch(r.state){case"started":let n=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,n);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(t,e,(r,n)=>{this.callback(r,n)}))}getStateAtTime(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};di.mixin(Tn);var Xe=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new $({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,U(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var ih=class i extends L{constructor(){let t=w(i.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Xe({context:this.context}),this.output=new $({context:this.context}),this.volume=this.input.volume,Ze(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),Ze(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};hi(i=>{i.destination=new ih({context:i})});li(i=>{i.destination.dispose()});var nh=class extends L{constructor(){super(...arguments),this.name="Listener",this.positionX=new ut({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ut({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ut({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ut({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ut({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ut({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ut({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ut({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ut({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(L.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}};hi(i=>{i.listener=new nh({context:i})});li(i=>{i.listener.dispose()});var On=class i extends ie{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=w(i.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let r=t.urls[e];this.add(e,r,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:nt,onload:nt,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Y(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,r=nt,n=nt){return pe(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new qt(this.baseUrl+e,r,n))):this._buffers.set(t.toString(),new qt(e,r,n)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var Oo=class i extends _e{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return dr(super._frequencyToUnits(t))}_ticksToUnits(t){return dr(super._ticksToUnits(t))}_beatsToUnits(t){return dr(super._beatsToUnits(t))}_secondsToUnits(t){return dr(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return No(this.toMidi())}transpose(t){return new i(this.context,this.toMidi()+t)}};var Pe=class extends He{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var oh=class extends Kt{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Qt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){let t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};hi(i=>{i.draw=new oh({context:i})});li(i=>{i.draw.dispose()});var Ca=class extends ie{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Y(it(t.time),"Events must have a time property"),Y(it(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new sh(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){let e=[];this._root.search(t.time,e);for(let r of e)if(r.event===t){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{let e=t.getBalance(),r,n=null;if(e>0)if(t.left.right===null)r=t.left,r.right=t.right,n=r;else{for(r=t.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,n=r.parent,r.left=t.left,r.right=t.right)}else if(t.right.left===null)r=t.right,r.left=t.left,n=r;else{for(r=t.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,n=r.parent,r.left=t.left,r.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=r:t.parent.right=r:this._setRoot(r),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){let e=t.parent,r=t.isLeftChild(),n=t.right;n&&(t.right=n.left,n.left=t),e!==null?r?e.left=n:e.right=n:this._setRoot(n)}_rotateRight(t){let e=t.parent,r=t.isLeftChild(),n=t.left;n&&(t.left=n.right,n.right=t),e!==null?r?e.left=n:e.right=n:this._setRoot(n)}_rebalance(t){let e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){let e=[];if(this._root.search(t,e),e.length>0){let r=e[0];for(let n=1;n<e.length;n++)e[n].low>r.low&&(r=e[n]);return r.event}}return null}forEach(t){if(this._root!==null){let e=[];this._root.traverse(r=>e.push(r)),e.forEach(r=>{r.event&&t(r.event)})}return this}forEachAtTime(t,e){if(this._root!==null){let r=[];this._root.search(t,r),r.forEach(n=>{n.event&&e(n.event)})}return this}forEachFrom(t,e){if(this._root!==null){let r=[];this._root.searchAfter(t,r),r.forEach(n=>{n.event&&e(n.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}},sh=class{constructor(t,e,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var _a=class extends ie{constructor(t){super(),this.name="TimelineValue",this._timeline=new Qt({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){let e=this._timeline.get(t);return e?e.value:this._initialValue}};var ge=class i extends L{constructor(){super(w(i.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return Nn(this,t,e,r),this}};var Ne=class i extends ge{constructor(){let t=w(i.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Pt(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):af(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(et.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let n=0,o=e;n<o;n++){let s=n/(o-1)*2-1;r[n]=t(s,n)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){let e=["none","2x","4x"].some(r=>r.includes(t));Y(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var Rn=class i extends ge{constructor(){let t=w(i.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new Ne({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ge.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var qr=class i{constructor(t,e){this.id=i._eventId++,this._remainderTime=0;let r=Object.assign(i.getDefaults(),e);this.transport=t,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:nt,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){let e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};qr._eventId=0;var va=class i extends qr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(i.getDefaults(),e);this.duration=r.duration,this._interval=r.interval,this._nextTick=r.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},qr.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return Ei(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Pe(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){Ei(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 Pe(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let e=this.transport.getTicksAtTime(t);Vr(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}};var Ia=class i extends Kt{constructor(){let t=w(i.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new _a(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Qt,this._repeatedEvents=new Ca,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new Tn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),U(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(Kt.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){let r=e%(this._swingTicks*2)/(this._swingTicks*2),n=Math.sin(r*Math.PI)*this._swingAmount;t+=new Pe(this.context,this._swingTicks*2/3).toSeconds()*n}Ju(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),Ju(!1)}schedule(t,e){let r=new qr(this,{callback:t,time:new He(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,n=1/0){let o=new va(this,{callback:t,duration:new je(this.context,n).toTicks(),interval:new je(this.context,e).toTicks(),time:new He(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(t,e){let r=new qr(this,{callback:t,once:!0,time:new He(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){let e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){let e=this.toTicks(t);return this._timeline.forEachFrom(e,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(e,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new Pe(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let r;return it(e)&&(r=this.toTicks(e)),this._clock.start(t,r),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Pt(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new je(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new je(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Pe(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){let t=this.now(),e=this._clock.getTicksAtTime(t);return new Pe(this.context,e).toBarsBeatsSixteenths()}set position(t){let e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){let e=this.now(),r=this._clock.frequency.timeToTicks(t,e);this.ticks=r}get progress(){if(this.loop){let t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){let e=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(e),n=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,e),o=e+n;this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{let e=this.now(),r=this.getTicksAtTime(e),n=t-r%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){let r=this.now(),n=this.bpm,o=1/(60/n.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/o,u=new $(c),h=new Rn(-1),l=new $(c);n.chain(u,h,l),n=l,o=1/o,s=[u,h,l]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/o:e=0);let a=new $(e);return n.connect(a),a.connect(t._param),s.push(a),this._syncedSignals.push({initial:t.value,nodes:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){let r=this._syncedSignals[e];r.signal===t&&(r.nodes.forEach(n=>n.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),ki(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};di.mixin(Ia);hi(i=>{i.transport=new Ia({context:i})});li(i=>{i.transport.dispose()});var It=class extends L{constructor(t){super(t),this.input=void 0,this._state=new Tr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=nt,this._syncedStop=nt,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Xe({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,U(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,onstop:nt,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,r){let n=Yt(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(n=this._clampToCurrentTime(n),!this._synced&&this._state.getValueAtTime(n)==="started")Y(Vr(n,this._state.get(n).time),"Start time must be strictly greater than previous start time"),this._state.cancel(n),this._state.setStateAtTime("started",n),this.log("restart",n),this.restart(n,e,r);else if(this.log("start",n),this._state.setStateAtTime("started",n),this._synced){let o=this._state.get(n);o&&(o.offset=this.toSeconds(Le(e,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,e,r)},n);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>n&&this._syncedStart(this.now(),this.context.transport.seconds)}else pa(this.context),this._start(n,e,r);return this}stop(t){let e=Yt(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||it(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{let r=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(r)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,r){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(Vr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let n=e-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-n),this._start(t,this.toSeconds(r.offset)+n,o)}}},this._syncedStop=t=>{let e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=nt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var Or=class i extends pr{constructor(){let t=w(i.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,ue(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ut({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new qt(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(pr.getDefaults(),{url:new qt,loop:!1,loopEnd:0,loopStart:0,onload:nt,onerror:nt,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,r,n=1){Y(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(t);this._startGain(o,n),this.loop?e=Le(e,this.loopStart):e=Le(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;wo(s,a)&&(s=(s-c)%u+c),Ce(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Ei(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),it(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var ji=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(It.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Y(t in Tf,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,this.state==="started")){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){let e=Tf[this._type];this._source=new Or({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},Mn=44100*5,ah=2,Wr={brown:null,pink:null,white:null},Tf={get brown(){if(!Wr.brown){let i=[];for(let t=0;t<ah;t++){let e=new Float32Array(Mn);i[t]=e;let r=0;for(let n=0;n<Mn;n++){let o=Math.random()*2-1;e[n]=(r+.02*o)/1.02,r=e[n],e[n]*=3.5}}Wr.brown=new qt().fromArray(i)}return Wr.brown},get pink(){if(!Wr.pink){let i=[];for(let t=0;t<ah;t++){let e=new Float32Array(Mn);i[t]=e;let r,n,o,s,a,c,u;r=n=o=s=a=c=u=0;for(let h=0;h<Mn;h++){let l=Math.random()*2-1;r=.99886*r+l*.0555179,n=.99332*n+l*.0750759,o=.969*o+l*.153852,s=.8665*s+l*.3104856,a=.55*a+l*.5329522,c=-.7616*c-l*.016898,e[h]=r+n+o+s+a+c+u+l*.5362,e[h]*=.11,u=l*.115926}}Wr.pink=new qt().fromArray(i)}return Wr.pink},get white(){if(!Wr.white){let i=[];for(let t=0;t<ah;t++){let e=new Float32Array(Mn);i[t]=e;for(let r=0;r<Mn;r++)e[r]=Math.random()*2-1}Wr.white=new qt().fromArray(i)}return Wr.white}};function Te(i,t){return mt(this,void 0,void 0,function*(){let e=t/i.context.sampleRate,r=new lr(1,e,i.context.sampleRate);return new i.constructor(Object.assign(i.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var Ro=class i extends pr{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],ue(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new ut({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new ut({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),U(this,["frequency","detune"])}static getDefaults(){return Object.assign(pr.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Ft=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),U(this,"frequency"),this.detune=new et({context:this.context,units:"cents",value:t.detune}),U(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!=="custom"&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(It.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){let e=this.toSeconds(t),r=new Ro({context:this.context,onended:()=>this.onstop(this)});this._oscillator=r,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){let e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){let e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return i._periodicWaveCache.find(e=>e.phase===this._phase&&bf(e.partials,this._partials));{let t=i._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;let e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let r=this._getCachedPeriodicWave();if(it(r)){let{partials:n,wave:o}=r;this._wave=o,this._partials=n,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[n,o]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(n,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),i._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:n,type:this._type,wave:this._wave}),i._periodicWaveCache.length>100&&i._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){Vt(t,0);let e=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(e=r[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{let n=new Float32Array(t);this._partials.forEach((o,s)=>n[s]=o),this._partials=Array.from(n),this.type=this._type}}_getRealImaginary(t,e){let n=2048,o=new Float32Array(n),s=new Float32Array(n),a=1;if(t==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,n=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=c[1],a=Math.max(a,2),n=a):this._partialCount=0,this._partials=[]}for(let c=1;c<n;++c){let u=2/(c*Math.PI),h;switch(t){case"sine":h=c<=a?1:0,this._partials[c-1]=h;break;case"square":h=c&1?2*u:0,this._partials[c-1]=h;break;case"sawtooth":h=u*(c&1?1:-1),this._partials[c-1]=h;break;case"triangle":c&1?h=2*(u*u)*(c-1>>1&1?-1:1):h=0,this._partials[c-1]=h;break;case"custom":h=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}h!==0?(o[c]=-h*Math.sin(e*c),s[c]=h*Math.cos(e*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(t,e,r){let n=0,o=t.length;for(let s=0;s<o;s++)n+=t[s]*Math.cos(s*r)+e[s]*Math.sin(s*r);return n}getInitialValue(){let[t,e]=this._getRealImaginary(this._type,0),r=0,n=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(t,e,s/o*n),r);return th(-this._inverseFFT(t,e,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Ft._periodicWaveCache=[];var En=class extends ge{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Ne({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var Jt=class i extends et{constructor(){let t=w(i.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new $({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(et.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var Mo=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new En({context:this.context}),this._modulationNode=new $({context:this.context}),this._carrier=new Ft({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Ft({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Jt({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),U(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ft.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}};var Dn=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new $({context:this.context,gain:0}),this._carrier=new Ft({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Ft({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Jt({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Jt({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),U(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ft.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var Pi=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new $({context:this.context,gain:0}),this._thresh=new Ne({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new et({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Ft({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),U(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(It.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var Eo=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,U(this,["frequency","detune"])}static getDefaults(){return Object.assign(Ft.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){let e=-t/2,r=t/(this._oscillators.length-1);this._forEach((n,o)=>n.detune.value=e+r*o)}}get count(){return this._oscillators.length}set count(t){if(Vt(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Ft({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):nt});this.type==="custom"&&(r.partials=this._partials),this.frequency.connect(r.frequency),this.detune.connect(r.detune),r.detune.overridden=!1,r.connect(this.output),this._oscillators[e]=r}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,r)=>e.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var Do=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Jt({context:this.context,value:2}),this._pulse=new Pi({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Ft({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),U(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(It.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var Of={am:Mo,fat:Eo,fm:Dn,oscillator:Ft,pulse:Pi,pwm:Do},Fi=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),U(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Ft.getDefaults(),Dn.getDefaults(),Mo.getDefaults(),Eo.getDefaults(),Pi.getDefaults(),Do.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;let e=Of[t],r=this.now();if(this._oscillator){let n=this._oscillator;n.stop(r),this.context.setTimeout(()=>n.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(r)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof Of[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(t){this._getOscType(this._oscillator,"fat")&&ce(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&ce(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&pe(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return mt(this,arguments,void 0,function*(t=1024){return Te(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function wa(i,t=1/0){let e=new WeakMap;return function(r,n){Reflect.defineProperty(r,n,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Vt(o,i,t),e.set(this,o)}})}}function Oe(i,t=1/0){let e=new WeakMap;return function(r,n){Reflect.defineProperty(r,n,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Vt(this.toSeconds(o),i,t),e.set(this,o)}})}}var ko=class i extends It{constructor(){let t=w(i.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new qt({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(It.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:nt,onerror:nt,playbackRate:1,reverse:!1})}load(t){return mt(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=nt){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,r){return super.start(t,e,r),this}_start(t,e,r){this._loop?e=Le(e,this._loopStart):e=Le(e,0);let n=this.toSeconds(e),o=r;r=Le(r,Math.max(this._buffer.duration-n,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new Or({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Yt(o)?a.start(t,n):a.start(t,n,s-this.toSeconds(this.fadeOut))}_stop(t){let e=this.toSeconds(t);this._activeSources.forEach(r=>r.stop(e))}restart(t,e,r){return super.restart(t,e,r),this}_restart(t,e,r){var n;(n=[...this._activeSources].pop())===null||n===void 0||n.stop(t),this._start(t,e,r)}seek(t,e){let r=this.toSeconds(e);if(this._state.getValueAtTime(r)==="started"){let n=this.toSeconds(t);this._stop(r),this._start(r,n)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Vt(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&Vt(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){let e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;let e=this.now(),r=this._state.getNextState("stopped",e);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(n=>n.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};fe([Oe(0)],ko.prototype,"fadeIn",void 0);fe([Oe(0)],ko.prototype,"fadeOut",void 0);var Na=class extends ge{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Ne({context:this.context,mapping:t=>Math.abs(t)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var ve=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new et({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(L.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(pe(t))return t;{let r;for(r in Ta)if(Ta[r][e]===t)return r;return t}}_setCurve(t,e,r){if(pe(r)&&Reflect.has(Ta,r)){let n=Ta[r];cr(n)?t!=="_decayCurve"&&(this[t]=n[e]):this[t]=n}else if(Pt(r)&&t!=="_decayCurve")this[t]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let n=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(t);if(s>0){let a=1/n;n=(1-s)/a}if(n<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,n,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,n,t);else{this._sig.cancelAndHoldAtTime(t);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=s&&s<=a[c]){a=this._attackCurve.slice(c),a[0]=s;break}this._sig.setValueCurveAtTime(a,t,n,e)}if(o&&this.sustain<1){let a=e*this.sustain,c=t+n;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);let e=this.getValueAtTime(t);if(e>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,t):(Y(Pt(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,r,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,r=1){return e=this.toSeconds(e),this.triggerAttack(e,r),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,r=0){return Nn(this,t,e,r),this}asArray(){return mt(this,arguments,void 0,function*(t=1024){let e=t/this.context.sampleRate,r=new lr(1,e,this.context.sampleRate),n=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=n+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(e*(n+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};fe([Oe(0)],ve.prototype,"attack",void 0);fe([Oe(0)],ve.prototype,"decay",void 0);fe([wa(0,1)],ve.prototype,"sustain",void 0);fe([Oe(0)],ve.prototype,"release",void 0);var Ta=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let n=[],o=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*o-Math.PI/2)+1;n[t]=p/10+e*.83}n[127]=1;let s=[],a=5;for(t=0;t<128;t++)s[t]=Math.ceil(t/127*a)/a;let c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));let u=[];for(t=0;t<128;t++){e=t/127;let p=Math.pow(e,3)*4+.2,m=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(m*(1-e))}function h(p){let m=new Array(p.length);for(let f=0;f<p.length;f++)m[f]=1-p[f];return m}function l(p){return p.slice(0).reverse()}return{bounce:{In:h(u),Out:u},cosine:{In:r,Out:l(r)},exponential:"exponential",linear:"linear",ripple:{In:n,Out:h(n)},sine:{In:c,Out:h(c)},step:{In:s,Out:h(s)}}})();var Fe=class i extends L{constructor(){let t=w(i.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new Xe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,U(this,"volume")}static getDefaults(){return Object.assign(L.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){let r=this["_original_"+t]=this[t];this[t]=(...n)=>{let o=n[e],s=this.context.transport.schedule(a=>{n[e]=a,r.apply(this,n)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,r,n){let o=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,o,n),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var Re=class i extends Fe{constructor(){let t=w(i.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Fe.getDefaults(),{detune:0,onsilence:nt,portamento:0})}triggerAttack(t,e,r=1){this.log("triggerAttack",t,e,r);let n=this.toSeconds(e);return this._triggerEnvelopeAttack(n,r),this.setNote(t,n),this}triggerRelease(t){this.log("triggerRelease",t);let e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){let r=this.toSeconds(e),n=t instanceof _e?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(n,o,r)}else this.frequency.setValueAtTime(n,r);return this}};fe([Oe(0)],Re.prototype,"portamento",void 0);var kn=class i extends ve{constructor(){super(w(i.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new $({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 Rr=class i extends Re{constructor(){let t=w(i.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new Fi(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new kn(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),U(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Re.getDefaults(),{envelope:Object.assign(hr(ve.getDefaults(),Object.keys(L.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(hr(Fi.getDefaults(),[...Object.keys(It.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+r+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var Lo=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ut({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new ut({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new ut({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new ut({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(L.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Y(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){let e=new Float32Array(t);for(let s=0;s<t;s++){let c=Math.pow(s/t,2)*19980+20;e[s]=c}let r=new Float32Array(t),n=new Float32Array(t),o=this.context.createBiquadFilter();return o.type=this.type,o.Q.value=this.Q.value,o.frequency.value=this.frequency.value,o.gain.value=this.gain.value,o.getFrequencyResponse(e,r,n),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var Ur=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new $({context:this.context}),this.output=new $({context:this.context}),this._filters=[],this._filters=[],this.Q=new et({context:this.context,units:"positive",value:t.Q}),this.frequency=new et({context:this.context,units:"frequency",value:t.frequency}),this.detune=new et({context:this.context,units:"cents",value:t.detune}),this.gain=new et({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,U(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(L.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Y(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._type=t,this._filters.forEach(r=>r.type=t)}get rolloff(){return this._rolloff}set rolloff(t){let e=ce(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],n=r.indexOf(e);Y(n!==-1,`rolloff can only be ${r.join(", ")}`),n+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(n);for(let o=0;o<n;o++){let s=new Lo({context:this.context});s.type=this._type,this.frequency.connect(s.frequency),this.detune.connect(s.detune),this.Q.connect(s.Q),this.gain.connect(s.gain),this._filters[o]=s}this._internalChannels=this._filters,Ze(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new Lo({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),r=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((o,s)=>r[s]*=o)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),ki(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var Oa=class i extends Rr{constructor(){let t=w(i.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,U(this,["oscillator","envelope"])}static getDefaults(){return Ye(Re.getDefaults(),Rr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){let r=this.toSeconds(e),n=this.toFrequency(t instanceof _e?t.toFrequency():t),o=n*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(n,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};fe([wa(0)],Oa.prototype,"octaves",void 0);fe([Oe(0)],Oa.prototype,"pitchDecay",void 0);var Rf=new Set;function jn(i){Rf.add(i)}function Ra(i,t){let e=`registerProcessor("${i}", ${t})`;Rf.add(e)}var w_=`
|
|
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
|
-
`;
|
|
49
|
+
`;jn(w_);var N_=`
|
|
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
|
-
`;
|
|
116
|
+
`;jn(N_);var T_=`
|
|
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
|
-
`;
|
|
160
|
+
`;jn(T_);var Mf="feedback-comb-filter",O_=`
|
|
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
|
-
|
|
190
|
+
`;Ra(Mf,O_);var Ma=class i extends Fe{constructor(){let t=w(i.getDefaults(),arguments,["voice","options"]);super(t),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=n=>this.releaseAll(n),Y(!ce(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");let e=t.voice.getDefaults();this.options=Object.assign(e,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();let r=this._voices.indexOf(this._dummyVoice);this._voices.splice(r,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(Fe.getDefaults(),{maxPolyphony:32,options:{},voice:Rr})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);let e=this._activeVoices.findIndex(r=>r.voice===t);this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return Y(t instanceof Re,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}else Mi("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){let t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,r){t.forEach(n=>{let o=new Oo(this.context,n).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(n,e,r),this._activeVoices.push({midi:o,voice:s,released:!1}),this.log("triggerAttack",n,e))})}_triggerRelease(t,e){t.forEach(r=>{let n=new Oo(this.context,r).toMidi(),o=this._activeVoices.find(({midi:s,released:a})=>s===n&&!a);o&&(o.voice.triggerRelease(e),o.released=!0,this.log("triggerRelease",r,e))})}_scheduleEvent(t,e,r,n){Y(!this.disposed,"Synth was already disposed"),r<=this.now()?t==="attack"?this._triggerAttack(e,r,n):this._triggerRelease(e,r):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(t,e,r,n)},r-this.now())}triggerAttack(t,e,r){Array.isArray(t)||(t=[t]);let n=this.toSeconds(e);return this._scheduleEvent("attack",t,n,r),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);let r=this.toSeconds(e);return this._scheduleEvent("release",t,r),this}triggerAttackRelease(t,e,r,n){let o=this.toSeconds(r);if(this.triggerAttack(t,o,n),Pt(e)){Y(Pt(t),"If the duration is an array, the notes must also be an array"),t=t;for(let s=0;s<t.length;s++){let a=e[Math.min(s,e.length-1)],c=this.toSeconds(a);Y(c>0,"The duration must be greater than 0"),this.triggerRelease(t[s],o+c)}}else{let s=this.toSeconds(e);Y(s>0,"The duration must be greater than 0"),this.triggerRelease(t,o+s)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}set(t){let e=hr(t,["onsilence","context"]);return this.options=Ye(this.options,e),this._voices.forEach(r=>r.set(e)),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){let e=this.toSeconds(t);return this._activeVoices.forEach(({voice:r})=>{r.triggerRelease(e)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(t=>t.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}};var Ea=class i extends Fe{constructor(){let t=w(i.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map;let e={};Object.keys(t.urls).forEach(r=>{let n=parseInt(r,10);if(Y(So(r)||ce(n)&&isFinite(n),`url key is neither a note or midi pitch: ${r}`),So(r)){let o=new _e(this.context,r).toMidi();e[o]=t.urls[r]}else ce(n)&&isFinite(n)&&(e[n]=t.urls[n])}),this._buffers=new On({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(Fe.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:nt,onerror:nt,release:.1,urls:{}})}_findClosest(t){let r=0;for(;r<96;){if(this._buffers.has(t+r))return-r;if(this._buffers.has(t-r))return r;r++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,r=1){return this.log("triggerAttack",t,e,r),Array.isArray(t)||(t=[t]),t.forEach(n=>{let o=rh(new _e(this.context,n).toFrequency()),s=Math.round(o),a=o-s,c=this._findClosest(s),u=s-c,h=this._buffers.get(u),l=Li(c+a),p=new Or({url:h,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:l}).connect(this.output);p.start(e,0,h.duration/l,r),Pt(this._activeSources.get(s))||this._activeSources.set(s,[]),this._activeSources.get(s).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(s)){let m=this._activeSources.get(s),f=m.indexOf(p);f!==-1&&m.splice(f,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(r=>{let n=new _e(this.context,r).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){let o=this._activeSources.get(n);e=this.toSeconds(e),o.forEach(s=>{s.stop(e)}),this._activeSources.set(n,[])}}),this}releaseAll(t){let e=this.toSeconds(t);return this._activeSources.forEach(r=>{for(;r.length;)r.shift().stop(e)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,r,n=1){let o=this.toSeconds(r);return this.triggerAttack(t,o,n),Pt(e)?(Y(Pt(t),"notes must be an array when duration is array"),t.forEach((s,a)=>{let c=e[Math.min(a,e.length-1)];this.triggerRelease(s,o+this.toSeconds(c))})):this.triggerRelease(t,o+this.toSeconds(e)),this}add(t,e,r){if(Y(So(t)||isFinite(t),`note must be a pitch or midi: ${t}`),So(t)){let n=new _e(this.context,t).toMidi();this._buffers.add(n,e,r)}else this._buffers.add(t,e,r);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(e=>e.dispose())}),this._activeSources.clear(),this}};fe([Oe(0)],Ea.prototype,"attack",void 0);fe([Oe(0)],Ea.prototype,"release",void 0);var Pn=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Na({context:this.context}),this.a=new $({context:this.context,gain:0}),this.b=new $({context:this.context,gain:0}),this.output=new $({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new et({context:this.context,units:"normalRange",value:t.fade}),U(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",ue(this._split,this.a.gain,0),ue(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(L.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}};var Me=class extends L{constructor(t){super(t),this.name="Effect",this._dryWet=new Pn({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new $({context:this.context}),this.effectReturn=new $({context:this.context}),this.input=new $({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],U(this,"wet")}static getDefaults(){return Object.assign(L.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};var jo=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ut({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",U(this,"pan")}static getDefaults(){return Object.assign(L.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var Df="bit-crusher",j_=`
|
|
191
191
|
class BitCrusherWorklet extends SingleIOProcessor {
|
|
192
192
|
|
|
193
193
|
static get parameterDescriptors() {
|
|
@@ -206,10 +206,17 @@
|
|
|
206
206
|
return val;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
`;$s(Um,Ix);var Zr=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(j.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var zJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var $J=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var na=class n extends xt{constructor(){let t=N(n.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);ke(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);ke(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(xt.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),ke(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),ke(t,0),this._preDelay=t,this.generate()}generate(){return he(this,void 0,void 0,function*(){let t=this.ready,e=new Xt(2,this._decay+this._preDelay,this.context.sampleRate),r=new bi({context:e}),i=new bi({context:e}),o=new Zr({context:e});r.connect(o,0,0),i.connect(o,0,1);let s=new Z({context:e}).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=e.render();return this.ready=a.then(re),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var yn=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["solo"]);super(t),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=t.solo}static getDefaults(){return Object.assign(j.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),n._allSolos.get(this.context).forEach(e=>e._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 oa=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new fo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new jt({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.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(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var ku=class n extends j{constructor(){let t=N(n.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new yn({solo:t.solo,context:this.context}),this._panVol=this.output=new oa({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),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(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return n.buses.has(t)||n.buses.set(t,new Z({context:this.context})),n.buses.get(t)}send(t,e=0){let r=this._getBus(t),i=new Z({context:this.context,units:"decibels",gain:e});return this.connect(i),i.connect(r),i}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};ku.buses=new Map;var Bie=Ge().transport;var Gie=Ge().destination,Vie=Ge().destination;var qie=Ge().listener;var Wie=Ge().draw;var Uie=Ge();var Lu=class{constructor(){p(this,"audioSource");try{let t=new na({decay:3,wet:.4}).toDestination(),e=new Nr(800,"lowpass").connect(t);this.audioSource=new ea(pr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(e)}catch(t){this.audioSource=void 0,console.error(t)}}getName(){return"Synthesizer"}playNote(t,e,r){try{this.audioSource&&(this.audioSource.volume.value=bs(r),this.audioSource.triggerAttackRelease(t,e))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},ju=new Lu;ri();function Dx(n){return typeof n=="string"?n:(typeof n=="number"&&(n=U.getChromaticNote(n)),n.format(0,0))}var sa=[ju],xn=ju,Ex=(function(t,e,r){var o;let i=parseInt((o=r.split("/")[1])!=null?o:"4");return 60*(1/t)/(e*(1/i))})(2,80,"4/4"),kx=1,aa=!1;function Lx(){return sa.map(n=>n.getName())}function jx(){return xn.getName()}function Px(n){(b.Is.isArray(n)?n:[n]).forEach(t=>{if(!b.Obj.hasProperties(t,["getName","playNote","stop"])||!b.Is.isFunction(t.getName)||!b.Is.isFunction(t.playNote)||!b.Is.isFunction(t.stop))throw new O(7,"Invalid instrument object: "+t);sa.some(e=>e.getName()===t.getName())?console.warn(`Instrument "${t.getName()}" already added!`):sa.push(t),Ym(t.getName())})}function Ym(n){if(n===xn.getName())return;xn.stop();let t=sa.find(e=>e.getName()===n);t&&(xn=t)}function ca(n,t,e){aa||xn.playNote(Dx(n),t!=null?t:Ex,e!=null?e:kx)}function ua(){xn.stop()}function Fx(){ua(),aa=!0}function Bx(){aa=!1}function Gx(){return aa}var Zu={};Mi(Zu,{Annotation:()=>_n,Arpeggio:()=>Xr,Clef:()=>Ci,Connective:()=>Qr,DivRect:()=>B,DocumentBuilder:()=>rr,DynamicsAnnotation:()=>vn,Fermata:()=>xo,Label:()=>Co,LyricsAlign:()=>yo,LyricsHyphen:()=>An,MAccidental:()=>_o,MArpeggio:()=>To,MBarLineLeft:()=>Bo,MBarLineRight:()=>Fo,MBeamGroup:()=>Wo,MConnective:()=>Ho,MDocument:()=>Rr,MEnding:()=>Vo,MExtensionLine:()=>Yo,MFermata:()=>zo,MHeader:()=>es,MImage:()=>Ao,MLyrics:()=>Zo,MMeasure:()=>Qo,MNoteGroup:()=>Mo,MPlaybackButtons:()=>Hu,MPlayer:()=>Dn,MRenderContext:()=>hc,MRenderer:()=>Yu,MRest:()=>Oo,MRhythmColumn:()=>ko,MScoreRow:()=>$o,MSpecialText:()=>Lo,MStaff:()=>Ko,MStaffBeamGroup:()=>Uo,MStaffNoteGroup:()=>Do,MStaffRest:()=>Ro,MStaffSignature:()=>wo,MStaffTabBarLine:()=>Go,MTab:()=>Jo,MTabNoteGroup:()=>Eo,MTabRhythm:()=>Xo,MTabSignature:()=>No,MText:()=>vo,MusicInterface:()=>pe,Navigation:()=>er,NoteAnchor:()=>Pt,PlayState:()=>da,ScoreEvent:()=>rs,ScoreObjectEvent:()=>_i,ScoreStaffPosEvent:()=>Ai,StaffPreset:()=>Cn,Stem:()=>Jt,TempoAnnotation:()=>In,TieType:()=>$t,VerticalPosition:()=>bo,getStringNumbers:()=>la,getVerseNumbers:()=>ha,getVoiceIds:()=>Ve});var B=class n{constructor(...t){p(this,"left");p(this,"centerX");p(this,"right");p(this,"top");p(this,"centerY");p(this,"bottom");if(t.length===6)this.left=t[0],this.centerX=t[1],this.right=t[2],this.top=t[3],this.centerY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.centerX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.centerY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.centerX=this.right=0,this.top=this.centerY=this.bottom=0;else throw new O(1,`Invalid DivRect args: ${t}`)}static create(t,e,r,i){return new n(t,t+r,e,e+i)}static createCentered(t,e,r,i){return new n(t-r/2,t+r/2,e-i/2,e+i/2)}static createSections(t,e,r,i){return new n(-t,0,e,-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(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.centerX===e.centerX&&t.right===e.right&&t.top===e.top&&t.centerY===e.centerY&&t.bottom===e.bottom}static equalsFrame(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}copy(){return new n(this.left,this.centerX,this.right,this.top,this.centerY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.centerX+=t,this.right+=t,this.top+=e,this.centerY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.copy().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.copy().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.centerX=b.Math.clamp(this.centerX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.centerY=b.Math.clamp(this.centerY,this.top,this.bottom),this}clipCopy(t){return this.copy().clipInPlace(t)}scaleInPlace(t,e){return e=e!=null?e:t,this.left=this.centerX-this.leftw*t,this.right=this.centerX+this.rightw*t,this.top=this.centerY-this.toph*e,this.bottom=this.centerY+this.bottomh*e,this}scaleCopy(t,e){return this.copy().scaleInPlace(t,e)}getRect(){return this}};var Cn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(Cn||{}),Ci=(e=>(e.G="G",e.F="F",e))(Ci||{});function Ve(){return[0,1,2,3]}function la(){return[1,2,3,4,5,6]}function ha(){return[1,2,3]}var Jt=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(Jt||{}),Xr=(e=>(e.Up="up",e.Down="down",e))(Xr||{}),$t=(e=>(e.Stub="stub",e.ToMeasureEnd="toMeasureEnd",e))($t||{}),Pt=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(Pt||{}),Qr=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(Qr||{}),bo=(i=>(i.Auto="auto",i.Above="above",i.Below="below",i.Both="both",i))(bo||{}),yo=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(yo||{}),An=(e=>(e.Hyphen="-",e.Extender="---",e))(An||{}),xo=(e=>(e.AtNote="atNote",e.AtMeasureEnd="atMeasureEnd",e))(xo||{}),er=(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))(er||{}),_n=(e=>(e.Dynamics="dynamics",e.Tempo="tempo",e))(_n||{}),vn=(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))(vn||{}),In=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(In||{}),Co=(e=>(e.Note="note",e.Chord="chord",e))(Co||{}),da=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(da||{});var pa=class{constructor(t){p(this,"head");p(this,"tail");this.head=t,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(t){this.tail.push(t)}detachTail(t){let e=this.tail.indexOf(t);e>=0&&this.tail.splice(e,1)}},ee=class{constructor(t){this.parent=t;p(this,"anchoredLayoutObjects",[]);p(this,"link");p(this,"rect",new B);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(t){this.anchoredLayoutObjects.push(t)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(t){this.link=t}getLink(){return this.link}isLinked(){return this.link!==null}};var Hm={DrawDebugRects:!1,DisableBeams:!1},ae={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,BeamThickness:4,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var Zm="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 Xm="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 Vx="#55cc55",qx="#55cc55",Wx="#44aa44",Pu=new Map([[0,{src:Xm}],[1,{src:Zm}]]);function Ux(n,t){return!n&&!t?!0:!n||!t?!1:n.scoreRow===t.scoreRow&&n.diatonicId===t.diatonicId}function zx(n,t){return!n&&!t?!0:!n||!t?!1:n.length===t.length&&n.every((e,r)=>e===t[r])}var ma=class{constructor(t){this.mi=t;p(this,"devicePixelRatio");p(this,"fontSize");p(this,"unitSize");p(this,"_lineWidth");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=Bn.FontSize*ae.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this._lineWidth=this.unitSize*.2,Pu.forEach(e=>{if(e.finished!==!0){let r=new Image;r.src=e.src,r.onload=()=>{e.img=r,this.finishImageAsset(e)},r.onerror=()=>{throw this.finishImageAsset(e),new O(6,"Failed to load image: "+e.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 t;return(t=this.mdoc)==null?void 0:t.getMusicObject()}finishImageAsset(t){t.finished=!0,Array.from(Pu).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(t){var e;return(e=Pu.get(t))==null?void 0:e.img}setDocument(t){if(this.mdoc===t)return;this.updateCursorRect(void 0);let e=this.mdoc;this.mdoc=t,e&&e.getMusicObject().setRenderContext(void 0),t&&t.getMusicObject().setRenderContext(this)}setCanvas(t){var e,r;this.canvas!==t&&(this.canvas&&(this.canvas.removeEventListener("click",this.onClickFn),this.canvas.removeEventListener("mousemove",this.onMouseMoveFn),this.canvas.removeEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.removeEventListener("touchend",this.onTouchEndFn)),this.canvas=t,this.canvas.addEventListener("click",this.onClickFn),this.canvas.addEventListener("mousemove",this.onMouseMoveFn),this.canvas.addEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.addEventListener("touchend",this.onTouchEndFn),this.canvas.style.position="relative"),this.ctx=(r=(e=this.canvas)==null?void 0:e.getContext("2d"))!=null?r:void 0}setScoreEventListener(t){this.scoreEventListener=t}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(t){return new pl(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!Ux(t,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&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=t;this.scoreEventListener(new Ai("enter",this.getMusicInterface(),i.getMusicInterface(),o))}if(e&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=t;this.scoreEventListener(new Ai("click",this.getMusicInterface(),i.getMusicInterface(),o))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!zx(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new _i("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new _i("enter",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new _i("click",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),this.curObjects=t,r}onClick(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),this.scoreEventListener)){let r=e.pick(this.mousePos.x,this.mousePos.y),i=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),!this.usingTouch)){let r=e.pick(this.mousePos.x,this.mousePos.y),i=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(t){if(!this.needMouseInput())return;this.mousePos=void 0;let e=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(e||r)&&this.draw()}onTouchEnd(t){this.usingTouch=!0}onLoad(){this.doc&&(this.doc.requestFullLayout(),this.draw())}hilightObject(t){this.hilightedObj=t}hilightStaffPos(t){this.hilightedStaffPos=t}updateCursorRect(t){this.cursorRect=t,this.draw()}updateCanvasSize(){let{canvas:t,doc:e}=this;if(t&&e){let r=e.getRect(),i=r.width+1,o=r.height+1;t.width=i,t.height=o,t.style.width=i/this.devicePixelRatio+"px",t.style.height=o/this.devicePixelRatio+"px"}}draw(){try{let{doc:t}=this;t&&(t.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),t.drawContent())}catch(t){console.error("Render failed!",t)}}drawHilightStaffPosRect(){let{mousePos:t,hilightedStaffPos:e,unitSize:r}=this;if(!e)return;let{scoreRow:i,diatonicId:o}=e,s=i.getStaff(o);s&&(this.fillColor(Vx),this.fillRect(s.row.getRect().left,s.getDiatonicIdY(o)-r,s.row.getRect().width,2*r),t!==void 0&&this.drawLedgerLines(s,o,t.x))}drawHilightObjectRect(){let{hilightedObj:t}=this;if(!t)return;let e=t.getRect();this.lineColor(qx),this.strokeRect(e.left,e.top,e.width,e.height)}drawPlayCursor(){let{cursorRect:t}=this;t&&this.color(Wx).lineWidth(2).strokeLine(t.centerX,t.top,t.centerX,t.bottom)}txFromScreenCoord(t){return t.mul(this.devicePixelRatio)}txToScreenCoord(t){return t.div(this.devicePixelRatio)}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}drawDebugRect(t){Hm.DrawDebugRects&&this.color("red").lineWidth(1).strokeRect(t.left,t.top,t.width,t.height)}drawLedgerLines(t,e,r){let{unitSize:i}=this,o=i*ae.LedgerLineWidth;if(e>=t.topLineDiatonicId+2){for(let s=t.topLineDiatonicId+2;s<=e;s+=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}else if(e<=t.bottomLineDiatonicId-2){for(let s=t.bottomLineDiatonicId-2;s>=e;s-=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}}getRestRect(t){let{unitSize:e}=this,{flagCount:r}=_e.get(Gt(t+"n")),i=0,o=0,s=0,a=0;if(_e.equals(t,"1n"))i=e,o=e,s=0,a=e;else if(_e.equals(t,"2n"))i=e,o=e,s=e,a=0;else if(_e.equals(t,"4n"))i=e*1,o=e*1,s=e*3.2,a=e*3;else{let c=1-r%2;i=e*(1+r*.25),o=e*(1+r*.125),s=e*(.5+r-c),a=e*(1+r+c)}return new B(-i,0,o,-s,0,a)}drawRest(t,e,r){let{unitSize:i}=this,{flagCount:o}=_e.get(Gt(t+"n"));if(_e.equals(t,"1n"))this.fillRect(e-i,r,i*2,i);else if(_e.equals(t,"2n"))this.fillRect(e-i,r-i,i*2,i);else if(_e.equals(t,"4n"))this.beginPath(),this.moveTo(e-i*.6,r-i*3.2),this.lineTo(e+i*.7,r-i*1.5),this.quadraticCurveTo(e-i*.8,r-i*.5,e+i*1,r+i*1.5),this.lineTo(e-i*1,r-i*.75),this.quadraticCurveTo(e+i*.2,r-i*1.5,e-i*.6,r-i*3.2),this.moveTo(e+i*1,r+i*1.5),this.quadraticCurveTo(e-i*.8,r+i*1,e-i*.2,r+i*2.8),this.bezierCurveTo(e-i*1.8,r+i*1.5,e-i*.6,r-i*.2,e+i*.9,r+i*1.5),this.fill(),this.stroke();else if(o>0){let s=1-o%2,a=u=>e+(-u*.25+.5)*i,c=u=>r+(u+s)*i;this.beginPath(),this.moveTo(a(1+o),c(1+o)),this.lineTo(a(-.5-o),c(-.5-o)),this.stroke();for(let u=0;u<o;u++){let l=o-u*2;this.beginPath(),this.moveTo(a(l-2.5),c(l-2.5)),this.quadraticCurveTo(a(l-.5)+i*.25,c(l-1.5),a(l-1.5)-i*1.5,c(l-1.5)),this.stroke(),this.beginPath(),this.arc(a(l-2)-i*1.5,c(l-2),i*.5,0,Math.PI*2),this.fill()}}}drawFlag(t,e){let r=t.left,o=t.right-r,s=e==="up"?t.top:t.bottom,a=e==="up"?t.bottom:t.top;this.beginPath(),this.moveTo(r,s),this.bezierCurveTo(r,s*.75+a*.25,r+o*1.5,s*.5+a*.5,r+o*.5,a),this.stroke()}color(t){return this.ctx&&(this.ctx.strokeStyle=this.ctx.fillStyle=t),this}lineColor(t){return this.ctx&&(this.ctx.strokeStyle=t),this}fillColor(t){return this.ctx&&(this.ctx.fillStyle=t),this}lineWidth(t){return this.ctx&&(this.ctx.lineWidth=this._lineWidth*(t!=null?t:1)),this}font(t){return this.ctx&&(this.ctx.font=t),this}beginPath(){return this.ctx&&this.ctx.beginPath(),this}stroke(){return this.ctx&&this.ctx.stroke(),this}fill(){return this.ctx&&this.ctx.fill(),this}moveTo(t,e){return this.ctx&&this.ctx.moveTo(t,e),this}lineTo(t,e){return this.ctx&&this.ctx.lineTo(t,e),this}bezierCurveTo(t,e,r,i,o,s){return this.ctx&&this.ctx.bezierCurveTo(t,e,r,i,o,s),this}quadraticCurveTo(t,e,r,i){return this.ctx&&this.ctx.quadraticCurveTo(t,e,r,i),this}fillRect(t,e,r,i){return this.ctx&&this.ctx.fillRect(t,e,r,i),this}setLineDash(t){return this.ctx&&this.ctx.setLineDash(t),this}drawImage(t,e,r,i,o){return this.ctx&&this.ctx.drawImage(t,e,r,i,o),this}ellipse(t,e,r,i,o,s,a){return this.ctx&&this.ctx.ellipse(t,e,r,i,o,s,a),this}clip(){return this.ctx&&this.ctx.clip(),this}save(){return this.ctx&&this.ctx.save(),this}restore(){return this.ctx&&this.ctx.restore(),this}rect(t,e,r,i){return this.ctx&&this.ctx.rect(t,e,r,i),this}scale(t,e){return this.ctx&&this.ctx.scale(t,e),this}strokeRect(t,e,r,i){return this.ctx&&this.ctx.strokeRect(t,e,r,i),this}fillText(t,e,r){return this.ctx&&this.ctx.fillText(t,e,r),this}getTextWidth(t,e){if(this.ctx){let r=this.ctx.font;this.ctx.font=e;let i=this.ctx.measureText(t);return this.ctx.font=r,i.width}else return b.Dom.getCanvasTextWidth(t,e)}arc(t,e,r,i,o){var s;(s=this.ctx)==null||s.arc(t,e,r,i,o)}fillCircle(t,e,r){this.ctx&&(this.ctx.beginPath(),this.ctx.arc(t,e,r,0,2*Math.PI),this.ctx.fill())}strokeLine(t,e,r,i){this.ctx&&(this.ctx.beginPath(),this.ctx.moveTo(t,e),this.ctx.lineTo(r,i),this.ctx.stroke())}strokePartialLine(t,e,r,i,o,s){let a=t+(r-t)*o,c=e+(i-e)*o,u=t+(r-t)*s,l=e+(i-e)*s;this.ctx&&(this.ctx.beginPath(),this.ctx.moveTo(a,c),this.ctx.lineTo(u,l),this.ctx.stroke())}drawBrace(t,e){if(this.ctx){let{left:r,right:i,width:o,top:s,bottom:a,centerY:c}=t;e==="right"&&([r,i,o]=[i,r,-o]),this.ctx.beginPath(),this.ctx.moveTo(i,s),this.ctx.bezierCurveTo(r+o*.1,s,r+o*.8,c,r,c),this.ctx.moveTo(i,a),this.ctx.bezierCurveTo(r+o*.1,a,r+o*.8,c,r,c),this.ctx.stroke()}}};var fa=class{constructor(t){this.measure=t;p(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===U.getDiatonicClass(t));return r?r.accidental:void 0}setAccidental(t){this.accidentalByDiatonicId[t.diatonicId]=t.accidental}needAccidental(t){var r,i;let e=(i=(r=this.accidentalByDiatonicId[t.diatonicId])!=null?r:this.getAccidentalFromKeySignature(t.diatonicId))!=null?i:0;return t.accidental!==e}};var ga=class extends ee{constructor(e,r,i,o,s){super(e);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(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:i,image:o,imageScale:s}=this,{unitSize:a}=e;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=B.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new B}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=this.rect;e.drawDebugRect(r),e.drawImage(this.image,r.centerX-r.leftw,r.centerY-r.toph,r.width,r.height)}};var vi=class extends ee{constructor(e,r,i,o="black"){super(e);this.diatonicId=r;this.accidental=i;this.color=o;p(this,"mi");this.mi=new _o(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;switch(this.accidental){case-2:this.rect=B.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=B.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=B.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=B.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=B.createSections(r*1,r*1,r*1,r*1);break;default:throw new O(6,"Invalid accidental value: "+this.accidental)}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect);let{unitSize:r}=e,{accidental:i}=this,o=this.rect.centerX,s=this.rect.centerY;e.color(this.color);let a=(c,u)=>{e.lineWidth(1).beginPath().moveTo(c-r*.75,u-r*4).lineTo(c-r*.75,u+r*1.1).bezierCurveTo(c+r*.75,u-r*0,c+r*.75,u-r*2.2,c-r*.75,u-r*.5).stroke()};i===-2?(a(o-r*.5,s),a(o+r*.5,s)):i===-1&&a(o,s),i===0?e.beginPath().lineWidth(1).moveTo(o-r*.5,s-r*2.2).lineTo(o-r*.5,s+r*1).moveTo(o+r*.5,s+r*2.2).lineTo(o+r*.5,s-r*1).stroke().beginPath().lineWidth(2).moveTo(o-r*.5,s+r*1).lineTo(o+r*.5,s+r*.6).moveTo(o+r*.5,s-r*1).lineTo(o-r*.5,s-r*.6).stroke():i===1?e.lineWidth(1).beginPath().moveTo(o-r*.3,s-r*1.6).lineTo(o-r*.3,s+r*2).moveTo(o+r*.3,s-r*2).lineTo(o+r*.3,s+r*1.6).stroke().lineWidth(2).beginPath().moveTo(o-r*.75,s-r*.5).lineTo(o+r*.75,s-r*.9).moveTo(o-r*.75,s+r*.9).lineTo(o+r*.75,s+r*.5).stroke():i===2&&e.lineWidth(1).beginPath().moveTo(o-r*.75,s-r*.75).lineTo(o+r*.75,s+r*.75).moveTo(o-r*.75,s+r*.75).lineTo(o+r*.75,s-r*.75).stroke().fillRect(o-r*1,s-r*1,r*.7,r*.7).fillRect(o+r*.3,s-r*1,r*.7,r*.7).fillRect(o-r*1,s+r*.3,r*.7,r*.7).fillRect(o+r*.3,s+r*.3,r*.7,r*.7)}};var Yx=.5,ne=class extends ee{constructor(e,r,i,o){var a,c,u,l,h,d;super(e);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?Yx: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 B,this.mi=new vo(this)}getMusicInterface(){return this.mi}getText(){return this.text}updateAnchorX(e){this.anchorX=e;let{width:r}=this.rect;this.rect.left=this.rect.centerX-r*e,this.rect.right=this.rect.centerX+r*(1-e)}updateAnchorY(e){this.anchorY=e;let{height:r}=this.rect;this.rect.top=this.rect.centerY-r*e,this.rect.bottom=this.rect.centerY+r*(1-e)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{scale:r,anchorX:i,anchorY:o,bold:s,italic:a}=this,c=e.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(d=>e.getTextWidth(d,this.font)),this.lineHeight=c;let u=this.padding*e.unitSize,l=u+Math.max(...this.lineWidths)+u,h=u+this.lineHeight*this.textLines.length+u;(this.boxed==="square"||this.boxed==="circle")&&(h=l=Math.max(h,l)),this.rect=B.createSections(l*i,l*(1-i),h*o,h*(1-o))}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){var y;e.drawDebugRect(this.rect),e.lineWidth(1).font(this.font);let{rect:r,padding:i,lineHeight:o,lineWidths:s,anchorX:a,anchorY:c,italic:u}=this;this.bgcolor!==void 0&&(e.save(),e.fillColor((y=this.bgcolor)!=null?y:"black"),e.beginPath(),e.fillRect(r.left,r.top,r.width,r.height),e.fill(),e.restore());let h=this.textLines.length*o,d=-o*(u?.25:.2),m=i*e.unitSize,f=(r.left+m)*(1-a)+(r.right-m)*a,g=(r.top+m)*(1-c)+(r.bottom-m)*c;switch(e.color(this.color),this.textLines.forEach((C,I)=>{let S=f-s[I]*a,w=g-h*c+o*(I+1)+d;e.fillText(C,S,w)}),this.boxed){case"square":case"rectangle":e.strokeRect(r.left,r.top,r.width,r.height);break;case"circle":case"ellipse":let C=(r.left+r.right)/2,I=(r.top+r.bottom)/2,S=(r.right-r.left)/2,w=(r.bottom-r.top)/2;e.beginPath(),e.ellipse(C,I,S,w,0,0,2*Math.PI),e.stroke();break}}};var Io=class extends ee{constructor(e,r){super(e);this.measure=e;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 wo(this)}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let i=e.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new ga(this,i,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new ne(this,"8",.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(e){if(e){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new ne(this,r,0,1)}else this.measureNumber=void 0}updateKeySignature(e){if(e){let{measure:r}=this,i=r.getPrevMeasure(),o=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],o&&!Bt.equals(s,o)&&o.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new vi(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new vi(this,this.getAccidentalDiatonicId(a),a.accidental))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new ne(this,{text:i,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new ne(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=gs(this.measure.getTempo());this.tempoText=new ne(this,r,.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(e){let{clef:r}=this.staff.staffConfig,i;if(r==="G"?e.accidental>0?i=this.staff.bottomLineDiatonicId+3:e.accidental<0&&(i=this.staff.bottomLineDiatonicId+1):r==="F"&&(e.accidental>0?i=this.staff.bottomLineDiatonicId+1:e.accidental<0&&(i=this.staff.bottomLineDiatonicId-1)),i!==void 0)return U.findNextDiatonicIdAbove(e.diatonicId,i,!1);throw new O(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.eightBelowClef){let i=this.eightBelowClef.pick(e,r);if(i.length>0)return[this,...i]}if(this.clefImage){let i=this.clefImage.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.ksNeutralizeAccidentals.length;i++){let o=this.ksNeutralizeAccidentals[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.ksNewAccidentals.length;i++){let o=this.ksNewAccidentals[i].pick(e,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let i=this.beatCountText.pick(e,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(e,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(e,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(e,r);if(i.length>0)return[this,...i]}return[this]}layout(e){var u,l,h,d,m,f;let{unitSize:r}=e,{staff:i}=this,o=r,s=0;if(this.rect=new B,this.clefImage&&(s+=o,this.clefImage.layout(e),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(e),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(e);let g=Math.min(i.getTopLineY(),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(e),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(e),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(e),(l=this.beatSizeText)==null||l.layout(e);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(y=>y.getRect().top),...this.ksNewAccidentals.map(y=>y.getRect().top));this.tempoText.layout(e),this.tempoText.offset(s,g),this.rect.expandInPlace(this.tempoText.getRect())}this.rect.right+=o}offset(e,r){var i,o,s,a,c,u;(i=this.clefImage)==null||i.offset(e,r),(o=this.eightBelowClef)==null||o.offset(e,r),(s=this.measureNumber)==null||s.offset(e,r),this.ksNeutralizeAccidentals.forEach(l=>l.offset(e,r)),this.ksNewAccidentals.forEach(l=>l.offset(e,r)),(a=this.beatCountText)==null||a.offset(e,r),(c=this.beatSizeText)==null||c.offset(e,r),(u=this.tempoText)==null||u.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,i,o,s,a,c;(r=this.clefImage)==null||r.draw(e),(i=this.eightBelowClef)==null||i.draw(e),(o=this.measureNumber)==null||o.draw(e),this.ksNeutralizeAccidentals.forEach(u=>u.draw(e)),this.ksNewAccidentals.forEach(u=>u.draw(e)),(s=this.beatCountText)==null||s.draw(e),(a=this.beatSizeText)==null||a.draw(e),(c=this.tempoText)==null||c.draw(e)}},So=class extends ee{constructor(e,r){super(e);this.measure=e;this.tab=r;p(this,"measureNumber");p(this,"beatCountText");p(this,"beatSizeText");p(this,"tempoText");p(this,"mi");this.mi=new No(this)}getMusicInterface(){return this.mi}updateMeasureNumber(e){if(e){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new ne(this,r,0,1)}else this.measureNumber=void 0}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new ne(this,{text:i,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new ne(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=gs(this.measure.getTempo());this.tempoText=new ne(this,r,0,1)}else this.tempoText=void 0}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.beatCountText){let i=this.beatCountText.pick(e,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(e,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(e,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(e,r);if(i.length>0)return[this,...i]}return[this]}layout(e){var u,l,h,d,m,f;let{unitSize:r}=e,{tab:i}=this,o=r,s=0,a=i.getTopLineY();this.rect=new B,this.measureNumber&&(this.measureNumber.layout(e),this.measureNumber.offset(0,a),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),(u=this.beatCountText)==null||u.layout(e),(l=this.beatSizeText)==null||l.layout(e);let c=Math.max((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(e),this.tempoText.offset(s+r*2,a),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){var i,o,s,a;(i=this.measureNumber)==null||i.offset(e,r),(o=this.beatCountText)==null||o.offset(e,r),(s=this.beatSizeText)==null||s.offset(e,r),(a=this.tempoText)==null||a.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,i,o,s;(r=this.measureNumber)==null||r.draw(e),(i=this.beatCountText)==null||i.draw(e),(o=this.beatSizeText)==null||o.draw(e),(s=this.tempoText)==null||s.draw(e)}};var ba=class extends ee{constructor(e,r,i){super(e);this.col=e;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(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let 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 B(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r,topArrowHeight:i,bottomArrowHeight:o}=this;e.drawDebugRect(this.rect),e.color(this.color),e.lineWidth(2),e.beginPath();for(let s=0,a=r.top+i;s<this.numCycles;s++,a+=this.cycleHeight)e.moveTo(r.centerX,a),e.quadraticCurveTo(r.left,a+this.cycleHeight/4,r.centerX,a+this.cycleHeight/2),e.quadraticCurveTo(r.right,a+this.cycleHeight*3/4,r.centerX,a+this.cycleHeight);e.stroke(),i>0&&(e.beginPath(),e.moveTo(r.centerX,r.top),e.lineTo(r.right,r.top+i),e.lineTo(r.left,r.top+i),e.fill()),o>0&&(e.beginPath(),e.moveTo(r.centerX,r.bottom),e.lineTo(r.left,r.bottom-o),e.lineTo(r.right,r.bottom-o),e.fill())}};function Hx(n){return typeof n=="number"?U.getChromaticNote(n).diatonicId:typeof n=="string"?U.getNote(n).diatonicId:n instanceof U?n.diatonicId:void 0}var ya=class extends ee{constructor(e,r){super(e);this.staff=e;this.rest=r;p(this,"restRect",new B);p(this,"dotRects",[]);p(this,"mi");e.addObject(this),this.mi=new Ro(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){this.restRect.offsetInPlace(e,r),this.dotRects.forEach(i=>i.offsetInPlace(e,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRects.forEach(e=>this.rect.expandInPlace(e))}},Sn=class Sn extends ee{constructor(e,r,i,o,s){var u,l,h,d;super(e);this.col=e;this.voiceId=r;this.options=o;p(this,"color");p(this,"hide");p(this,"oldStyleTriplet");p(this,"rhythmProps");p(this,"setDiatonicId");p(this,"runningDiatonicId");p(this,"runningStemDir");p(this,"beamGroup");p(this,"staffObjects",[]);p(this,"mi");this.setDiatonicId=(l=Hx((u=this.options)==null?void 0:u.staffPos))!=null?l:Sn.UndefinedDiatonicId;let a=this.row.getStaves().filter(m=>m.containsVoiceId(this.voiceId));this.setDiatonicId!==Sn.UndefinedDiatonicId&&a.length>0&&a[0].isSpace(this.setDiatonicId)&&(this.setDiatonicId+=this.setDiatonicId>=a[0].middleLineDiatonicId?1:-1),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.color=(h=o==null?void 0:o.color)!=null?h:"black",this.hide=(d=o==null?void 0:o.hide)!=null?d:!1,this.oldStyleTriplet=s===void 0&&((o==null?void 0:o.triplet)===!0||_e.get(i).isTriplet);let c=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=qe.get(i,c,(s!=null?s:this.oldStyleTriplet)?xr.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 noteLength(){return this.rhythmProps.noteLength}getDiatonicId(e){return this.runningDiatonicId===Sn.UndefinedDiatonicId?e?_e.equals(this.noteLength,"1n")?e.middleLineDiatonicId+2:e.middleLineDiatonicId:U.getNote("G4").diatonicId:this.runningDiatonicId}get stemDir(){return this.runningStemDir}updateRunningArguments(e,r,i){this.runningDiatonicId=e,this.runningStemDir=r}getStaticObjects(e){let r=[];return this.staffObjects.forEach(i=>{i.staff===e&&r.push(i)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{let r=e.staff,i=e.getRect().centerX,o=this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=Math.abs(e.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(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ya&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case 1:return 1;case 2:return-1;case 4:return-1;case 8:return-1;case 16:return-1;case 32:return-3;case 64:return-3;default:throw new O(6,`Get rest dot vertical displacement: Invalid note size: ${e}`)}}updateAccidentalState(e){}layout(e,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:i}=e,{noteSize:o,dotCount:s}=this.rhythmProps;this.row.getStaves().forEach(a=>{let c=this.getDiatonicId(a);if(!a.containsDiatonicId(c)||!a.containsVoiceId(this.voiceId))return;let u=new ya(a,this);u.restRect=e.getRestRect(o);for(let l=0;l<s;l++){let h=ae.DotSize*i,d=u.restRect.rightw+(ae.RestDotSpace+ae.DotSize*i)+l*ae.DotSize*i*1.5,m=this.getRestDotVerticalDisplacement(o)*i;u.dotRects.push(B.createCentered(d,m,h,h))}u.offset(0,a.getDiatonicIdY(c)),this.staffObjects.push(u)})}updateRect(){if(this.staffObjects.length===0)this.rect=new B;else if(this.rect=this.staffObjects[0].getRect().copy(),this.staffObjects.length>1)for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){if(this.staffObjects.length===0)return;e.drawDebugRect(this.getRect());let{noteSize:r}=this.rhythmProps;e.color(this.color).lineWidth(1),this.staffObjects.forEach(i=>{let{dotRects:o,restRect:s}=i,a=s.centerX,c=s.centerY;e.drawRest(r,a,c),o.forEach(u=>e.fillCircle(u.centerX,u.centerY,u.width/2))})}};p(Sn,"UndefinedDiatonicId",1/0);var ct=Sn;function Zx(n){return b.Is.isEnumValue(n,Xr)?n:n===!0?"up":void 0}function Xx(n,t){let e=b.Arr.isArray(t)?t:t!==void 0?[t]:[],r=n.map((i,o)=>({note:i,string:e[o]}));return r=b.Arr.removeDuplicatesCmp(r,(i,o)=>U.equals(i.note,o.note)).sort((i,o)=>U.compareFunc(i.note,o.note)),{sortedNotes:r.map(i=>i.note),sortedStrings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}var xa=class extends ee{constructor(e,r){super(e);this.staff=e;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 Do(this)}getMusicInterface(){return this.mi}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.accidentals.length;i++){let o=this.accidentals[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].copy(),this.noteHeadRects.forEach(e=>this.rect.expandInPlace(e)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(e=>this.rect.expandInPlace(e)),this.flagRects.forEach(e=>this.rect.expandInPlace(e)),this.accidentals.forEach(e=>this.rect.expandInPlace(e.getRect()))}getRect(){let e=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.centerY||this.prevBottomNoteY!==e.centerY)&&(this.prevTopNoteY=r.centerY,this.prevBottomNoteY=e.centerY,this.requestRectUpdate()),super.getRect()}offset(e,r){var i,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(e,r)),this.dotRects.forEach(s=>s.offsetInPlace(e,r)),this.accidentals.forEach(s=>s.offset(e,r)),(i=this.stemTip)==null||i.offsetInPlace(e,r),(o=this.stemBase)==null||o.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},Fu=class extends ee{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;p(this,"fretNumbers",[]);p(this,"mi");this.mi=new Eo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().copy(),this.fretNumbers.forEach(e=>this.rect.expandInPlace(e.getRect()))}offset(e,r){this.fretNumbers.forEach(i=>i.offset(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},ye=class n extends ee{constructor(e,r,i,o,s,a){var h,d,m;super(e);this.col=e;this.voiceId=r;this.notes=i;this.options=s;p(this,"setDiatonicId");p(this,"setStringsNumbers");p(this,"runningDiatonicId");p(this,"runningStemDir");p(this,"runningStringNumbers");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(!b.Is.isIntegerGte(i.length,1))throw new O(6,"Cannot create note group object because notes array is empty.");let{sortedNotes:c,sortedStrings:u}=Xx(i,s==null?void 0:s.string);this.notes=c,this.setStringsNumbers=u,this.setDiatonicId=Math.round((this.minDiatonicId+this.maxDiatonicId)/2),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.runningStringNumbers=[],this.color=(h=s==null?void 0:s.color)!=null?h:"black",this.staccato=(d=s==null?void 0:s.staccato)!=null?d:!1,this.diamond=(m=s==null?void 0:s.diamond)!=null?m:!1,this.arpeggio=Zx(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&((s==null?void 0:s.triplet)===!0||_e.get(o).isTriplet);let l=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=qe.get(o,l,(a!=null?a:this.oldStyleTriplet)?xr.Triplet:void 0),this.mi=new Mo(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get minDiatonicId(){return this.notes[0].diatonicId}get maxDiatonicId(){return this.notes[this.notes.length-1].diatonicId}getDiatonicId(e){return this.runningDiatonicId}get stemDir(){return this.runningStemDir}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof rt||e.containsDiatonicId(this.runningDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective==="tie")throw new O(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective==="slur")throw new O(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(e),this.doc.addConnectiveProps(e)}updateRunningArguments(e,r,i){this.runningDiatonicId=e===ct.UndefinedDiatonicId?this.setDiatonicId:e,this.runningStemDir=r,this.runningStringNumbers=i}getStaticObjects(e){let r=[];return this.staffObjects.forEach(i=>{i.staff===e&&r.push(i)}),this.tabObjects.forEach(i=>{i.tab===e&&r.push(i)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabObjects.length;i++){let o=this.tabObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,i,o,s){var a;if(r instanceof Ne){if(i<0||i>=this.notes.length)throw new O(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(v=>v.staff===r);if(!c||i<0||i>=c.noteHeadRects.length){let v=this.getRect();return{x:v.centerX,y:v.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,y=u.centerY,C=u.left-f,I=u.right+f,S=u.top-f,w=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}:{x:C,y};case"above":return!d||h==="down"?{x:g,y:S}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?C:g,y:S};case"below":return!d||h==="up"?{x:g,y:w}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?C:g,y:w};case"stemTip":return{x:g,y:l.centerY+(h==="up"?-f:f)};default:throw new O(6,"Invalid noteAnchor: "+o)}}else if(r instanceof rt){let c=(a=this.tabObjects.find(m=>m.tab===r))==null?void 0:a.fretNumbers[i];if(!c)return{x:0,y:0};let u=c.getRect(),l=s==="right"?u.left:u.right,h,d=.9;if(e.connective==="slide"){let m=e.noteGroups[0].getFretNumber(r,0),f=e.noteGroups[1].getFretNumber(r,0),g=m===void 0||f===void 0||m<=f;s==="left"?h=(g?u.centerY+u.bottomh:u.centerY-u.toph)*d:h=(g?u.centerY-u.toph:u.centerY+u.bottomh)*d}else h=u.centerY+u.bottomh*d;return{x:l,y:h}}else return{x:0,y:0}}getFretNumberString(e){return this.runningStringNumbers[e]}getFretNumber(e,r){let i=this.tabObjects.find(s=>s.tab===e),o=i==null?void 0:i.fretNumbers[r];return o?parseInt(o.getText()):void 0}getNextNoteGroup(){let e=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof n),r=e.indexOf(this);if(r<0)return;if(r<e.length-1)return e[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(e=>{this.runningConnectives.push(e);let r=this.getNextNoteGroup();for(;r&&e.addNoteGroup(r);)r.runningConnectives.push(e),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let e=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return e.indexOf("first")>=0?"first":e.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{var a,c,u,l;let r=e.staff,i=(c=(a=e.stemTip)==null?void 0:a.centerX)!=null?c:e.noteHeadRects[0].centerX,o=(l=(u=e.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=this.stemDir==="up"?Math.abs(e.noteHeadRects[0].centerY-o):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{flagCount:i,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?ae.BeamSeparation:ae.FlagSeparation;return(ae.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(e){this.leftBeamCount=e}setRightBeamCount(e){this.rightBeamCount=e}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof xa&&r.staff===e)}getPlayTicks(e){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,e))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!U.equals(u,e))),s>=0&&(o=o.slice(0,s)),b.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(e){this.notes.forEach(r=>{e.needAccidental(r)&&e.setAccidental(r)})}layout(e,r){this.requestRectUpdate();let{unitSize:i}=e,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,l=ae.DotSize*i,h=(this.diamond?ae.DiamondNoteHeadSize:ae.NoteHeadWidth)*i,d=(this.diamond?ae.DiamondNoteHeadSize:ae.NoteHeadHeight)*i;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.runningDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new xa(m,this),g=m,y=m;this.notes.forEach((A,x)=>{var F;let T=x===0,E=x===this.notes.length-1,R=(F=m.getActualStaff(A.diatonicId))!=null?F:m,M=this.col.getNoteHeadDisplacement(this,A)*h,G=R.getDiatonicIdY(A.diatonicId),k=R.isLine(A.diatonicId);T&&s==="up"&&(g=R),E&&s==="up"&&(y=R),T&&s==="down"&&(y=R),E&&s==="down"&&(g=R);let L=f.noteHeadRects[x]=B.createCentered(M,G,h,d);if(R.addObject(L),r.needAccidental(A)){let q=f.accidentals[x]=new vi(this,A.diatonicId,A.accidental,this.color);q&&(q.layout(e),q.offset(-L.leftw-i*ae.NoteAccSpace-q.getRect().rightw,G)),R.addObject(q)}for(let q=0;q<a;q++){let Q=L.right+ae.NoteDotSpace*i+l/2+q*l*1.5,Y=G+this.getDotVerticalDisplacement(m,A.diatonicId,s)*i,V=B.createCentered(Q,Y,l,l);f.dotRects.push(V),R.addObject(V)}if(this.staccato){if(s==="up"&&T){let q=M,Q=G+i*(k?3:2),Y=B.createCentered(q,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}else if(s==="down"&&E){let q=M,Q=G-i*(k?3:2),Y=B.createCentered(q,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}}});let C=f.noteHeadRects[0].centerY,I=f.noteHeadRects[f.noteHeadRects.length-1].centerY,S=s==="up"?h/2:-h/2,w=this.getStemHeight(e),v=s==="up"?I-w:C+w,_=s==="up"?C:I;if(u&&(f.stemTip=new B(S,S,v,v),f.stemBase=new B(S,S,_,_),y.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let A=c===0?0:ae.FlagWidth*i,x=c===0?0:ae.FlagHeight*i;for(let T=0;T<c;T++){let E=T*i*ae.FlagSeparation,R=f.flagRects[T]=s==="up"?new B(S,S+A,v+E,v+x+E):new B(S,S+A,v-x-E,v-E);y.addObject(R)}}this.staffObjects.push(f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new Fu(m,this);this.notes.forEach((g,y)=>{let C=this.runningStringNumbers[y];if(b.Is.isIntegerBetween(C,1,6)){let I=g.chromaticId-m.getTuningStrings()[C-1].chromaticId,S=I<0?"red":"black",w=new ne(this,{text:String(I),color:S,bgcolor:"white"},.5,.5);w.layout(e);let v=this.col.getRect().centerX,_=m.getStringY(C-1);w.offset(v,_),f.fretNumbers.push(w)}}),f.fretNumbers.length>0&&(this.tabObjects.push(f),m.addObject(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 B;return}this.staffObjects.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tabObjects.forEach(e=>this.rect.expandInPlace(e.getRect()))}setStemTipY(e,r){let i=this.staffObjects.find(o=>o.staff===e);this.hasBeamCount()&&(i!=null&&i.stemTip)&&r!==i.stemTip.centerY&&(i.stemTip.top=i.stemTip.centerY=i.stemTip.bottom=r,this.requestRectUpdate())}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.tabObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let{stemDir:r}=this,{isSolidNoteHead:i}=this.rhythmProps;this.staffObjects.forEach(o=>{o.accidentals.forEach(s=>s.draw(e)),e.color(this.color),e.lineWidth(1),o.noteHeadRects.forEach(s=>{this.diamond?i?(e.beginPath(),e.moveTo(s.centerX,s.top),e.lineTo(s.right,s.centerY),e.lineTo(s.centerX,s.bottom),e.lineTo(s.left,s.centerY),e.lineTo(s.centerX,s.top),e.fill()):(e.beginPath(),e.lineWidth(2.5),e.moveTo(s.centerX,s.top),e.lineTo(s.right,s.centerY),e.moveTo(s.left,s.centerY),e.lineTo(s.centerX,s.bottom),e.stroke(),e.beginPath(),e.lineWidth(1),e.moveTo(s.right,s.centerY),e.lineTo(s.centerX,s.bottom),e.moveTo(s.centerX,s.top),e.lineTo(s.left,s.centerY),e.stroke()):(e.beginPath(),e.ellipse(s.centerX,s.centerY,s.leftw,s.toph,-.3,0,Math.PI*2),i?e.fill():e.stroke())}),o.dotRects.forEach(s=>e.fillCircle(s.centerX,s.centerY,s.width/2)),o.stemTip&&o.stemBase&&(e.beginPath(),e.moveTo(o.stemBase.centerX,o.stemBase.centerY),e.lineTo(o.stemTip.centerX,o.stemTip.centerY),e.stroke()),o.flagRects.forEach(s=>e.drawFlag(s,r==="up"?"up":"down"))}),this.tabObjects.forEach(o=>o.fretNumbers.forEach(s=>s.draw(e)))}getDotVerticalDisplacement(e,r,i){return e.isLine(r)?i==="up"?-1:1:0}static hasSameNotes(e,r){if(e.notes.length!==r.notes.length)return!1;for(let i=0;i<e.notes.length;i++){let o=e.notes[i],s=r.notes[i];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var Qx=(n,t)=>{let e=U.compareFunc(n.note,t.note);return e===0&&(e=n.noteGroup.stemDir===t.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1),e},Tr=class extends ee{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;p(this,"voiceSymbol",[]);p(this,"lyricsObject",new cs);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 wn(this),this.mi=new ko(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let e=this.measure.getColumns().indexOf(this);if(e>=0&&e<this.measure.getColumnCount())return this.measure.getColumn(e+1);throw new O(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let e=this.getNextColumnInMeasure();return e||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let e=this.getNextColumnInMeasure(),r=this.positionTicks,i=e?e.positionTicks:this.measure.getConsumedTicks();return Math.max(0,i-r)}getShapeRects(){return this.getRect(),this.shapeRects}getStaticObjects(e){let r=[];return this.voiceSymbol.forEach(i=>{i&&(i.getRect(),i.getStaticObjects(e).forEach(o=>r.push(o)))}),this.arpeggios.forEach(i=>{i.line===e&&(i.getRect(),r.push(i))}),r}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.voiceSymbol.length;i++)if(this.voiceSymbol[i]){let o=this.voiceSymbol[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.arpeggios.length;i++){let o=this.arpeggios[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:"up"}setVoiceSymbol(e,r){Ca(e),this.voiceSymbol[e]=r,r instanceof ct&&!r.hide?this.row.getStaves().forEach(i=>{let o=r.getDiatonicId(i);this.minDiatonicId=this.minDiatonicId===void 0?o:Math.min(this.minDiatonicId,o),this.maxDiatonicId=this.maxDiatonicId===void 0?o:Math.max(this.maxDiatonicId,o)}):r instanceof ye&&(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(e){return this.voiceSymbol[e]}getLyricsObject(e,r,i){return this.lyricsObject.get(e,r,i)}addLyricsObject(e){this.lyricsObject.set(e.verse,e.line,e.vpos,e)}getMinWidth(){let e=Math.max(...this.voiceSymbol.map(i=>i.rhythmProps.noteSize)),r=ae.NoteHeadWidth;switch(e){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(e=>{e instanceof ye&&e.notes.forEach(r=>{this.noteHeadDisplacements.push({noteGroup:e,note:r})})}),this.noteHeadDisplacements.sort(Qx),!(this.noteHeadDisplacements.length<2)){for(let e=0;e<this.noteHeadDisplacements.length;e++){let r=this.noteHeadDisplacements[e],i=this.noteHeadDisplacements[e+1];i&&r.note.diatonicId===i.note.diatonicId&&(r.displacement=i.displacement=0)}for(let e=0;e<this.noteHeadDisplacements.length;e++){let r=this.noteHeadDisplacements[e-1],i=this.noteHeadDisplacements[e],o=this.noteHeadDisplacements[e+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(e,r){let i=this.noteHeadDisplacements.find(o=>o.noteGroup===e&&U.equals(o.note,r));return(i==null?void 0:i.displacement)!==void 0?i.displacement:0}isEmpty(){for(let e=0;e<this.voiceSymbol.length;e++)if(this.voiceSymbol[e]!==void 0&&!this.voiceSymbol[e].isEmpty())return!1;return!0}getPlayerNotes(){let e=[];function r(i,o,s,a){if(o<=0)return;e.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||e.push({note:i,ticks:o,staccato:s,slur:a})}return Ve().forEach(i=>{let o=this.getVoiceSymbol(i);if(o instanceof ye){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),e.sort((i,o)=>U.compareFunc(i.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new B;let{row:i}=this,{unitSize:o}=e,s=this.getMinWidth()*o/2,a=s,c=s;if(this.voiceSymbol.forEach(l=>{l.layout(e,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 ba(this,h,this.getArpeggioDir());return d.layout(e),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=>{if(m.visibleInStaff(l)){if(m instanceof ye)h=h===void 0?m.minDiatonicId:Math.min(h,m.minDiatonicId),d=d===void 0?m.maxDiatonicId:Math.max(d,m.maxDiatonicId);else if(m instanceof ct){let f=m.getDiatonicId(l);h=h===void 0?f:Math.min(h,f),d=d===void 0?f:Math.max(d,f)}}}),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(e=>!!e).map(e=>e.getRect().copy()),...this.arpeggios.map(e=>e.getRect().copy())],this.rect.top=Math.min(...this.shapeRects.map(e=>e.top)),this.rect.bottom=Math.max(...this.shapeRects.map(e=>e.bottom)),this.rect.centerY=(this.rect.top+this.rect.bottom)/2}offset(e,r){this.voiceSymbol.forEach(i=>i==null?void 0:i.offset(e,0)),this.arpeggios.forEach(i=>i.offset(e,0)),this.shapeRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){this.row.getStaves().forEach(r=>{let i=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);i!==void 0&&e.drawLedgerLines(r,i,this.getRect().centerX),o!==void 0&&e.drawLedgerLines(r,o,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(e)}),this.arpeggios.forEach(r=>r.draw(e))}};var mr=class mr extends ee{constructor(e,r){super(e);this.text=r;p(this,"components",[]);p(this,"mi");switch(this.text){case mr.Coda:this.components=[new ne(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new ne(this," Coda",0,1)];break;case mr.toCoda:this.components=[new ne(this,"toCoda ",1,1),new ne(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case mr.Segno:this.components=[new ne(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(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){switch(this.text){case mr.Coda:{let r=this.components[0],i=this.components[1];r.layout(e),i.layout(e),r.offset(0,(i.getRect().top+i.getRect().bottom)/2),i.offset(r.getRect().right,0),this.rect=new B(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case mr.toCoda:{let r=this.components[0],i=this.components[1];r.layout(e),i.layout(e),i.offset(0,(r.getRect().top+r.getRect().bottom)/2),r.offset(i.getRect().left,0),this.rect=new B(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(e),this.rect=r.getRect().copy();break}}}offset(e,r){this.components.forEach(i=>i.offset(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(e))}};p(mr,"toCoda","\u{1D10C} toCoda"),p(mr,"Coda","Coda \u{1D10C}"),p(mr,"Segno","\u{1D10B}");var tr=mr;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 tr.Segno;case"Coda":return tr.Coda;case"toCoda":return tr.toCoda;default:return n[0].toUpperCase()+n.substring(1)}}function Bu(n){return b.Is.isEnumValue(n,vn)}function Po(n){if(/^(p+|f+|m|mp|mf)$/.test(n)){let t=.5-b.Str.charCount(n,"p")*.1+b.Str.charCount(n,"f")*.1;return b.Math.clamp(t,0,1)}else return}function Gu(n){return b.Is.isEnumValue(n,In)}function Qm(n){return b.Is.isEnumValue(n,vn)?"dynamics":b.Is.isEnumValue(n,In)?"tempo":void 0}function Kx(n){switch(n){case"bottom":return .8;case"middle":return .5}}function Jx(n){return Bu(n)?2:Gu(n)?1:0}var Ii=class extends pa{constructor(e,r,i,o,s,a){super(e);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=e instanceof ne?Jx(e.getText()):0,e instanceof ne)e.updateAnchorY(Kx(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(e,r){if(e===e.measure.getColumn(0)){let i=e.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=e.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&Gu(s))return s}}else if(r===2){let i=e.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&Bu(s))return s}}}getExtensionRangeInfo(){let{startColumn:e,length:r,context:i}=this,o=[e];if(r<=0)return{startColumn:e,endColumn:e,columnRange:o,extensionBreakText:void 0};let s=r,a=e;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};a=c,o.push(a)}}};var $x=2,eC=2,tC=.5,rC=.5;function iC(n,t){let e=qe.get(t.options.beatLength,t.options.dotCount).ticks,r=t.beatsPerMinute*e;return 60*n/r}function Vu(){return Po("m")}function nC(n){return n*1.25}var oC=.5,wn=class{constructor(t){this.col=t;p(this,"speed");p(this,"volume");this.speed=1,this.volume=Vu()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=Vu()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=b.Math.clamp(this.getSpeed(),.1,10);return Dc(this.measure.getTempo(),t)}setVolume(t){this.volume=t}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:t}=this;if(t instanceof Or)return this.measure.getMeasureTicks()/2;{let r=Ve().map(i=>t.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:b.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(t){this.doc=t,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(t){this.cursorPositionChangeListener=t}setPlayStateChnageListener(t){this.playStateChnageListener=t}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let t=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==t&&(this.playStateChnageListener&&this.playStateChnageListener(t),this.playState=t)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let t=[],e=this.doc.getFirstMeasure(),r=e,i,o=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=n.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation("startRepeat")&&(r=e),e.hasNavigation("Segno")&&(i=e),s&&e.hasNavigation("toCoda"))for(;e&&!e.hasNavigation("Coda");)e=e.getNextMeasure();else if(o&&e.hasNavigation("Fine"))e=void 0;else if(e.hasNavigation("D.C. al Coda"))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.C. al Fine"))o=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.S. al Coda"))s=!0,e=i;else if(e.hasNavigation("D.S. al Fine"))o=!0,e=i;else if(e.hasNavigation("endRepeat")){let u=e.getPassCount(),l=e.getEndRepeatPlayCount()-1,h=((a=e.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=l||h?e=r:e=e.getNextMeasure()}else e.hasEndSong()?e=void 0:e=e.getNextMeasure()}return t}collectPlayerColumnSequence(){let t=this.collectPlayerMeasureSequence(),e=[];for(let r=0;r<t.length;r++){let i=t[r];e=e.concat(i.getColumns()),i.hasFermata(i.getBarLineRight())&&e.push(i.getBarLineRight())}return e}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let t=1,e=Vu(),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 Tr))return;a.getAnchoredLayoutObjects().forEach(d=>{var g;let m=(g=d.getTextContent())!=null?g:"",f;if(m==="a tempo")t=1;else if((f=Po(m))!==void 0)e=f;else if(d.musicObj.getLink()instanceof Ii){let y=d.musicObj.getLink(),{columnRange:C,extensionBreakText:I}=y.getExtensionRangeInfo(),S=b.Math.sum(C.map(w=>w.getTicksToNextColumn()));switch(m){case"accel.":{let w=t,v=w*$x,_=0;C.forEach(A=>{_+=A.getTicksToNextColumn(),o(A,w+(v-w)*_/S)});break}case"rit.":{let w=t,v=w/eC,_=0;C.forEach(A=>{_+=A.getTicksToNextColumn(),o(A,w+(v-w)*_/S)});break}case"cresc.":{let w=e,v=w+tC;I&&(f=Po(I))!==void 0&&f>w&&(v=f);let _=0;C.forEach(A=>{_+=A.getTicksToNextColumn(),s(A,w+(v-w)*_/S)});break}case"decresc.":case"dim.":{let w=e,v=w-rC;I&&(f=Po(I))!==void 0&&f<w&&(v=f);let _=0;C.forEach(A=>{_+=A.getTicksToNextColumn(),s(A,w+(v-w)*_/S)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(t=b.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(e=b.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(t),a.getPlayerProps().setVolume(e)})}static getMeasureByEndingPassage(t,e){for(let r=t;;r=r.getNextMeasure()){let i=r==null?void 0:r.getEnding();if(i&&i.hasPassage(e))return r;let o=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!o||o.hasNavigation("startRepeat"))return}}playStep(){if(this.notifyCursorPositionChanged(),this.notifyPlayStateChanged(),this.playPos===void 0){this.stop();return}let t=this.playerColumnSequence[this.playPos];if(!t){this.stop();return}let e=(s,a)=>{let c=iC(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),i=t.getPlayerProps().getFermataHoldTicks(),o;t instanceof Or?o=e(i,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?qe.get("32n").ticks*c:0,l=e(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(e(qe.get("8n").ticks,r)/2,l/2));let h=nC(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=oC),u>0){let d=e(u,r);window.setTimeout(()=>ca(a.note,l,h),d*1e3)}else ca(a.note,l,h)}}),o=e(t.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:t}=this;if(!t)return;t.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(t){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let t=this.playerColumnSequence[this.playPos];if(!t)return;let e=t.measure,r=t.getRect().centerX,i=e.row.getRect().top,o=e.row.getRect().bottom;return new B(r,r,i,o)}};var qu=class extends ee{constructor(e,r){super(r);this.barLine=e;this.line=r;p(this,"verticalLines",[]);p(this,"dots",[]);p(this,"mi");r.addObject(this),this.mi=new Go(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}setRect(e){this.rect=e}offset(e,r){this.verticalLines.forEach(i=>i.left+=e),this.dots.forEach(i=>{i.x+=e,i.y+=r}),this.rect.offsetInPlace(e,r)}},_a=class extends ee{constructor(e){super(e);this.measure=e;p(this,"staffTabObjects",[]);p(this,"staffTabObjectGroups",[]);p(this,"barLineType",0)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let o=this.staffTabObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}layout(e){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,_lineWidth:i}=e,{measure:o,barLineType:s}=this,{row:a}=o,c=i,u=.7*r,l=.7*r,h=ae.DotSize*r,d=h/2;a.getNotationLines().forEach(m=>{let f=new qu(this,m),g,y,C,I,S=(v,_)=>{f.verticalLines.push({left:v,width:_})},w=v=>{for(let _=-1;_<=1;_+=2){let A=g+_*y;f.dots.push({x:v,y:A,r:d})}};switch(m instanceof Ne?(g=m.getMiddleLineY(),y=m.getDiatonicSpacing()):(g=(m.getBottomLineY()+m.getTopLineY())/2,y=(m.getBottomLineY()-m.getTopLineY())/6),C=m.getTopLineY(),I=m.getBottomLineY(),s){case 0:f.setRect(new B(0,0,0,C,0,I));break;case 1:f.setRect(new B(-c,0,0,C,0,I)),S(-c,c);break;case 2:f.setRect(new B(-c-l-c,0,0,C,0,I)),S(-c-l-c,c),S(-c,c);break;case 3:f.setRect(new B(-u-l-c,0,0,C,0,I)),S(-c-l-u,c),S(-u,u);break;case 4:f.setRect(new B(0,0,u+l+c+l+h,C,0,I)),S(0,u),S(u+l,c),w(u+l+c+l+d);break;case 5:f.setRect(new B(-u-l-c-l-h,0,0,C,0,I)),S(-c-l-u,c),S(-u,u),w(-c-l-u-l-d);break;case 6:f.setRect(new B(-h-l-c-l-u/2,0,u/2+l+c+l+h,C,0,I)),S(-u/2,u),S(-u/2-l-c,c),S(u/2+l,c),w(-u/2-l-c-l-d),w(u/2+l+c+l+d);break}this.staffTabObjects.push(f)}),this.staffTabObjectGroups=a.getInstrumentLineGroups().map(m=>m.map(f=>this.staffTabObjects.find(g=>g.line===f)).filter(f=>f!==void 0))}updateRect(){if(this.staffTabObjects.length>0){this.rect=this.staffTabObjects[0].getRect().copy();for(let e=1;e<this.staffTabObjects.length;e++)this.rect.expandInPlace(this.staffTabObjects[e].getRect())}else this.rect=new B}offset(e,r){this.staffTabObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){this.barLineType!==0&&(e.drawDebugRect(this.getRect()),e.color("black"),this.staffTabObjectGroups.forEach(r=>{if(r.length>0){r.forEach(s=>s.dots.forEach(a=>e.fillCircle(a.x,a.y,a.r)));let i=r[0].getRect().top,o=r[r.length-1].getRect().bottom-i;r[0].verticalLines.forEach(s=>e.fillRect(s.left,i,s.width,o))}}))}},Kr=class extends _a{constructor(e){super(e);p(this,"mi");this.mi=new Bo(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation("startRepeat")?r&&r.row===e.row&&r.hasNavigation("endRepeat")?0:4:0}},Or=class extends _a{constructor(e){super(e);p(this,"playerProps");p(this,"mi");this.playerProps=new wn(this),this.mi=new Fo(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation("endRepeat")?r&&r.row===e.row&&r.hasNavigation("startRepeat")?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var Si=class extends ee{constructor(e,r){super(e);this.measure=e;this.passages=r;p(this,"endingText");p(this,"shapeRects",[]);p(this,"mi");if(this.mi=new Vo(this),b.Is.isIntegerGte(r.length,1)){if(!this.passages.every(o=>b.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 ne(this,i,0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:e}=this,r=e.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||e.hasNavigation("endRepeat")||e.isLastMeasure()}hasPassage(e){return this.passages.some(r=>r===e)}getHighestPassage(){return Math.max(0,...this.passages)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new B,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:i}=this;this.endingText.layout(e);let o=this.endingText.getRect(),s=i.getColumnsContentRect(),a=o.height;this.rect=new B(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new B(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new B(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new B(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().copy()]}offset(e,r){this.endingText.offset(e,r),this.shapeRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this;e.drawDebugRect(this.rect),e.color("black").lineWidth(1),e.beginPath(),e.moveTo(r.left,r.bottom),e.lineTo(r.left,r.top),e.lineTo(r.right,r.top),this.isSingleMeasureEnding()&&e.lineTo(r.right,r.bottom),e.stroke(),this.endingText.draw(e)}};var sC=(n,t)=>{let e=ae.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=n/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),n/r*e}},qo=class{constructor(t,e,r,i,o){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=i;this.y=o;p(this,"topBeamsHeight",0);p(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new B(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},Wu=class extends ee{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;p(this,"tupletNumber");p(this,"tupletNumberOffsetY",0);p(this,"points",[]);p(this,"mi");e.addObject(this),this.mi=new Uo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.points.forEach(o=>o.offset(e,0)),(i=this.tupletNumber)==null||i.offset(e,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(e=>this.rect.expandInPlace(e.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Jr=class{constructor(t,e){this.beamGroup=t;this.message=e}},wi=class n extends ee{constructor(e,r){super(e[0].measure);this.symbols=e;this.tupletRatio=r;p(this,"mi");p(this,"type");p(this,"staffObjects",[]);this.mi=new Wo(this);let i=r?"Tuplet":"BeamGroup";if(e.every(o=>o.measure===e[0].measure)){if(e.length<2)throw new O(6,`${i} needs minimum 2 symbols, but ${e.length} given.`)}else throw new O(6,`All ${i} symbols are not in same measure.`);if(r!==void 0){let o=e.length<3||e.some(s=>!(s instanceof ye))||e.some(s=>s.rhythmProps.flagCount!==e[0].rhythmProps.flagCount);e.length>=3&&e[0]instanceof ye&&e[e.length-1]instanceof ye&&e[0].rhythmProps.flagCount===e[e.length-1].rhythmProps.flagCount&&(o=!1),e.some(s=>_e.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,this.setTupletBeamCounts()}else this.type=0,this.setBeamCounts();if(e.every(o=>o.getBeamGroup()===void 0))e.forEach(o=>o.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new O(6,`Cannot add ${i} because some symbol already has one.`);if(this.type===0&&this.symbols.filter(o=>o instanceof ye).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 Jr(this,"Beam has zero left or right beam count!")}),e.some(o=>o.voiceId!==e[0].voiceId))throw this.type===0?new Jr(this,"Beam symbols have different voiceId."):new O(6,"Tuplet symbols have different voiceId.");e[0].row.getStaves().forEach(o=>{o.getActualStaff(e[0].getDiatonicId(o))&&o.containsVoiceId(e[0].voiceId)&&e.forEach(s=>{let a=o.getActualStaff(s.getDiatonicId(o));if(!a||!a.containsVoiceId(s.voiceId))throw new Jr(this,"Some of beam or tuplet symbols are not visible!")})})}get stemDir(){return this.symbols[0].stemDir}get showTupletRatio(){var e;return((e=this.tupletRatio)==null?void 0:e.showRatio)===!0}static createBeam(e){if(e.length>1&&e.every(r=>!r.hasTuplet()))try{return new n(e,void 0),!0}catch(r){if(r instanceof Jr)r.beamGroup.detach();else throw r}return!1}static createOldStyleTriplet(e){try{let r=e.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,xr.Triplet),2;let o=e.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);if(o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0]))return new n(o,xr.Triplet),3}catch(r){if(r instanceof Jr)console.error(r.message),r.beamGroup.detach();else throw r}return 0}static createTuplet(e,r){try{new n(e,r)}catch(i){if(i instanceof Jr)console.error(i.message),i.beamGroup.detach();else throw i}}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(e=>e.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getTupletRatioText(){var e,r,i;return this.showTupletRatio?String((e=this.tupletRatio)==null?void 0:e.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 color(){return this.symbols[0].color}layout(e){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let{unitSize:i}=e,{stemDir:o,type:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var G,k;if(!c)return;let l=a.map(L=>{var F;return(F=L[u])==null?void 0:F.x}),h=a.map(L=>{var F;return(F=L[u])==null?void 0:F.y}),d=a.map(L=>{var F;return(F=L[u])==null?void 0:F.staff}),m=a.map(L=>{var F;return(F=L[u])==null?void 0:F.stemHeight}),f=r[0],g=l[0],y=h[0],C=d[0],I=r[r.length-1],S=l[l.length-1],w=h[h.length-1],v=d[h.length-1];if(g===void 0||y===void 0||C===void 0||S===void 0||w===void 0||v===void 0)return;let _=(G=m[0])!=null?G:0,A=(k=m[m.length-1])!=null?k:0;if(s!==2){let L=_<A?Math.sqrt(A-_):0,F=A<_?Math.sqrt(_-A):0;o==="up"&&(L*=-1,F*=-1),L!==0&&(y+=L,h[0]+=L),F!==0&&(w+=F,h[h.length-1]+=F)}let x=i*2*(o==="up"?-1:1),T=(w+y)/2,E=sC(S-g,w-y)/2;y=T-E,w=T+E;let R=0;h.forEach((L,F)=>{let q=l[F];if(q!==void 0&&L!==void 0){let Q=b.Math.interpolateY(g,y,S,w,q),Y=L-Q;o==="up"&&Y<0?R=Math.min(R,Y):o==="down"&&Y>0&&(R=Math.max(R,Y))}}),y+=R,w+=R,h=h.map(L=>L===void 0?void 0:L+R);let M=new Wu(c,this);if(s===2){let L=i/(S-g),F=b.Math.interpolateCoord(g,y+x,S,w+x,-L),q=b.Math.interpolateCoord(g,y+x,S,w+x,1+L);M.points.push(new qo(C,this,f,F.x,F.y)),M.points.push(new qo(v,this,I,q.x,q.y)),M.tupletNumberOffsetY=0}else if(s===0||s===1){R*=.5;let L=e._lineWidth*ae.BeamThickness,F=q=>{let Q=r[q];if(Q instanceof ye){let Y=Q instanceof ye?Math.max(Q.getLeftBeamCount(),Q.getRightBeamCount()):0;return ae.BeamSeparation*i*(o==="up"?Y-1:0)}else return 0};r.forEach((q,Q)=>{let Y=d[Q],V=l[Q],ue=h[Q];if(Y&&V!==void 0&&ue!==void 0){let me=new qo(Y,this,q,V,ue);switch(o){case"up":me.topBeamsHeight=L/2,me.bottomBeamsHeight=L/2+F(Q);break;case"down":me.topBeamsHeight=L/2+F(Q),me.bottomBeamsHeight=L/2;break}M.points.push(me)}}),M.tupletNumberOffsetY=x}this.isTuplet()&&(M.tupletNumber=new ne(this,this.getTupletRatioText(),.5,.5),M.tupletNumber.layout(e),M.tupletNumber.offset((g+S)/2,(y+w)/2+M.tupletNumberOffsetY)),M.points.length>=2&&this.staffObjects.push(M)})}updateRect(){if(this.staffObjects.length===0)this.rect=new B;else{this.staffObjects.forEach(e=>e.updateRect()),this.rect=this.staffObjects[0].getRect().copy();for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}}updateStemTips(){this.staffObjects.forEach(e=>{let r=e.points[0],i=e.points[e.points.length-1];if(this.type!==2&&e.points.forEach(o=>{o.symbol instanceof ye&&(o!==r&&o!==i&&(o.y=b.Math.interpolateY(r.x,r.y,i.x,i.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),e.tupletNumber){let o=(r.y+i.y)/2+e.tupletNumberOffsetY;e.tupletNumber.offset(0,-e.tupletNumber.getRect().centerY+o)}})}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r}=e,{stemDir:i,color:o,type:s}=this;if(s===2){e.color(o).lineWidth(1);let a=(i==="up"?1:-1)*r;this.staffObjects.forEach(c=>{let{x:u,y:l}=c.points[0],{x:h,y:d}=c.points[c.points.length-1];if(c.tupletNumber){let m=c.tupletNumber.getRect().width/(h-u)*1.2,f=b.Math.interpolateCoord(u,l,h,d,.5-m/2),g=b.Math.interpolateCoord(u,l,h,d,.5+m/2);e.strokeLine(u,l,f.x,f.y),e.strokeLine(g.x,g.y,h,d)}else e.strokeLine(u,l,h,d);e.strokeLine(u,l,u,l+a),e.strokeLine(h,d,h,d+a)})}else(s===0||s===1)&&(e.color(o).lineWidth(ae.BeamThickness),this.staffObjects.forEach(a=>{let c=a.points.filter(f=>f.symbol instanceof ye),{x:u,y:l}=c[0],{x:h,y:d}=c[c.length-1],m=ae.BeamSeparation*r*(i==="up"?1:-1)*(1+.5*Math.abs(Math.atan2(d-l,h-u)));for(let f=0;f<c.length-1;f++){let{x:g,y,symbol:C}=c[f],{x:I,y:S,symbol:w}=c[f+1],v=C.getRightBeamCount(),_=w.getLeftBeamCount();for(let A=0;A<Math.max(v,_);A++)A<v&&A<_?e.strokeLine(g,y,I,S):v>_?e.strokePartialLine(g,y,I,S,0,.25):_>v&&e.strokePartialLine(g,y,I,S,.75,1),y+=m,S+=m}}));this.staffObjects.forEach(a=>{var c;return(c=a.tupletNumber)==null?void 0:c.draw(e)})}setBeamCounts(){let e=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:l,noteSize:h,dotCount: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 ye);for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&(a.rhythmProps.flagCount===s.rhythmProps.flagCount||e(a,s)||e(s,a)?s.setLeftBeamCount(s.rhythmProps.flagCount):s.setLeftBeamCount(Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount))),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||e(c,s)||e(s,c)?s.setRightBeamCount(s.rhythmProps.flagCount):s.setRightBeamCount(Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount))))}let 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 e=this.getType(),r=this.getSymbols();e===1?r.forEach((i,o)=>{i instanceof ye&&(i.setLeftBeamCount(o===0?0:i.rhythmProps.flagCount),i.setRightBeamCount(o===r.length-1?0:i.rhythmProps.flagCount))}):e===2&&r.forEach(i=>{i instanceof ye&&(i.setLeftBeamCount(0),i.setRightBeamCount(0))})}};var Nn=class extends ee{constructor(e,r){super(e);this.pos=r;p(this,"color","black");p(this,"mi");this.mi=new zo(this)}getMusicInterface(){return this.mi}static getFermataPositions(e){let{measure:r}=e,{row:i}=r;return i.getTopStaff()!==i.getBottomStaff()?[0,1]:[0]}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,i=r*4,o=r*3;this.rect=new B(-i/2,i/2,-o,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{unitSize:r}=e,i=this.pos===1,o=(i?r:-r)*.7,s=this.rect.left,a=this.rect.right,c=(i?this.rect.bottom:this.rect.top)+o,u=(i?this.rect.top:this.rect.bottom)+o,l=u-c;e.drawDebugRect(this.rect),e.color("black").lineWidth(1),e.beginPath(),e.moveTo(s,u),e.bezierCurveTo(s,c,a,c,a,u),e.bezierCurveTo(a,c+l/5,s,c+l/5,s,u),e.stroke(),e.fill();let h=l/6;e.fillCircle((s+a)/2,u-h,Math.abs(h))}};var Tn=class extends ee{constructor(e,r,i,o,s){super(e);this.measure=e;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 Kr?this.leftObj.getRect().centerX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof Tr){let e=this.rightObj,r=e.getNextColumn();return r&&r.measure===e.measure?(e.getRect().right+r.getRect().left)/2:(e.getRect().right+e.measure.getBarLineRight().getRect().left)/2}else return this.rightObj.getRect().centerX}layoutFitToMeasure(e){let{unitSize:r}=e,i=this.getLineLeft(),o=this.getLineRight(),s=r;this.rect=new B(i,o,-s/2,s/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new B}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this;this.extension.getLineStyle()==="dashed"&&e.setLineDash([7,3]),e.color("black").lineWidth(1),e.strokeLine(r.left,r.centerY,r.right,r.centerY),e.setLineDash([]);let i=this.extension.getTails();if(i.length>0&&this===i[i.length-1]){let o=r.centerY>this.line.getRect().centerY?-e.unitSize:e.unitSize;e.strokeLine(r.right,r.centerY,r.right,r.centerY+o)}}};var Ni=class extends ee{constructor(e,r,i,o,s,...a){var c;super(i);this.connectiveProps=e;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,"line");p(this,"leftNoteGroup");p(this,"leftNoteId");p(this,"rightNoteGroup");p(this,"rightNoteId");p(this,"tieType");p(this,"mi");this.line=(c=this.measure.row.findMatchingLine(r))!=null?c:r,this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof ye&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):b.Is.isEnumValue(a[0],$t)&&(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(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,{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(),y=m.getConnectivesContentRect(),C,I;C=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:C.y}:{x:C.x+r*ae.StubTieLength,y:C.y};let S,w,v,_;if(c===void 0)S=C.x,w=C.y,v=I.x,_=I.y;else if(s.row===m&&c.row===m)S=C.x,w=C.y,v=I.x,_=I.y;else if(s.row===f&&c.row===m){let M=f.getConnectivesContentRect().right-C.x,G=I.x-y.left;S=y.left,w=C.y+(I.y-C.y)*M/(M+G),v=I.x,_=I.y}else if(s.row===m&&c.row===g){let R=g.getConnectivesContentRect(),M=y.right-C.x,G=I.x-R.left;S=C.x,w=C.y,v=y.right,_=C.y+(I.y-C.y)*M/(M+G)}else throw new O(6,"Cannot layout connective object because no valid left and right note groups.");let x=(d==="up"?-1:1)*r*Math.log2(v-S)/3;this.lx=S,this.ly=w,this.rx=v,this.ry=_,this.arcHeight=this.connectiveProps.connective==="slide"?0:x;let{nx:T,ny:E}=b.Math.calcNormal(S,w,v,_);this.cp1x=S*.7+v*.3+T*this.arcHeight,this.cp1y=w*.7+_*.3+E*this.arcHeight,this.cp2x=S*.3+v*.7+T*this.arcHeight,this.cp2y=w*.3+_*.7+E*this.arcHeight,this.rect=new B(Math.min(this.lx,this.cp1x,this.cp2x,this.rx),Math.max(this.lx,this.cp1x,this.cp2x,this.rx),Math.min(this.ly,this.cp1y,this.cp2y,this.ry),Math.max(this.ly,this.cp1y,this.cp2y,this.ry)),this.line.addObject(this)}offset(e,r){this.lx+=e,this.ly+=r,this.rx+=e,this.ry+=r,this.cp1x+=e,this.cp1y+=r,this.cp2x+=e,this.cp2y+=r,this.rect.offsetInPlace(e,r)}draw(e){if(this.rightNoteGroup!==void 0){if(this.leftNoteGroup.measure!==this.rightNoteGroup.measure){if(this.leftNoteGroup.row.getNextRow()!==this.rightNoteGroup.row){if(this.measure!==this.rightNoteGroup.measure)return}}}let{rect:r}=this,{_lineWidth:i}=e;e.drawDebugRect(r);let o=i*1.5,s=i*.25;e.color("black").lineWidth(1),this.arcHeight===0?(e.beginPath(),e.moveTo(this.lx,this.ly),e.lineTo(this.rx,this.ry),e.stroke()):(e.beginPath(),e.moveTo(this.lx,this.ly-s),e.bezierCurveTo(this.cp1x,this.cp1y-o,this.cp2x,this.cp2y-o,this.rx,this.ry-s),e.lineTo(this.rx,this.ry+s),e.bezierCurveTo(this.cp2x,this.cp2y+o,this.cp1x,this.cp1y+o,this.lx,this.ly+s),e.fill())}};var On=class{constructor(t,e,r,i){this.connective=t;this.span=e;this.noteAnchor=r;p(this,"noteGroups");p(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(t){let{stemDir:e}=this.noteGroups[0],{hasStem:r}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=e==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=e==="up"||!r?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor="center":this.connective==="slide"?this.noteAnchor="center":this.arcDir==="up"?this.noteAnchor="above":this.noteAnchor="below";else if(this.noteAnchor==="center"){let i=t instanceof Ne?t:void 0,o=this.noteGroups[0].getDiatonicId(i);this.arcDir=!i||o<i.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(t=>{t.measure.removeConnectiveObjects(),t.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){if(this.noteGroups.length===0)return;this.getStartNoteGroup().collectConnectiveProps();let{connective:t,span:e}=this;this.noteGroups[0].row.getNotationLines().forEach(r=>{if(this.computeParams(r),t==="tie"){if(b.Is.isEnumValue(e,$t)){let i=this.noteGroups[0];for(let o=0;o<i.notes.length;o++)this.createObjConnectiveWithTieType(r,i,o,e)}else if(this.noteGroups.length>=2)for(let i=0;i<this.noteGroups.length-1;i++){let o=this.noteGroups[i],s=this.noteGroups[i+1];o.notes.forEach((a,c)=>{let u=s.notes.findIndex(l=>U.equals(l,a));u>=0&&this.createObjConnective(r,o,c,s,u)})}}else if(t==="slur"){if(typeof e=="number"&&e>=2&&this.noteGroups.length===e){let i=this.noteGroups[0],o=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,i,0,o,0)}}else if(t==="slide"&&this.noteGroups.length>=2)for(let i=0;i<this.noteGroups.length-1;i++){let o=this.noteGroups[i],s=this.noteGroups[i+1];this.createObjConnective(r,o,0,s,0)}})}createObjConnectiveWithTieType(t,e,r,i){if(e.enableConnective(t))t instanceof Ne?new Ni(this,t,e.measure,e,r,i):t instanceof rt&&e.getFretNumberString(r)!==void 0&&new Ni(this,t,e.measure,e,r,i);else return}createObjConnective(t,e,r,i,o){let s=(a,c,u,l,h)=>{if(c.enableConnective(t)&&l.enableConnective(t)){if(t instanceof Ne)new Ni(this,t,a,c,u,l,h);else if(t instanceof rt){let d=c.getFretNumberString(u),m=l.getFretNumberString(h);d!==void 0&&m!==void 0&&(d===m||this.connective==="slur")&&new Ni(this,t,a,c,u,l,h)}}else return};if(e.measure===i.measure)s(e.measure,e,r,i,o);else if(e.measure.getNextMeasure()===i.measure)s(e.measure,e,r,i,o),s(i.measure,e,r,i,o);else throw new O(6,"Cannot create connective because it is jumping measures.")}};var va=class extends ee{constructor(e,r,i,o,s,a,c){super(e);this.col=e;this.verse=r;this.line=i;this.vpos=o;p(this,"nextLyricsObject");p(this,"rhythmProps");p(this,"color","black");p(this,"hyphen");p(this,"text");p(this,"mi");this.rhythmProps=qe.get(s);let u=(c==null?void 0:c.align)==="left"?0:(c==null?void 0:c.align)==="right"?1:.5;this.hyphen=b.Is.isEnumValue(c==null?void 0:c.hyphen,An)?c==null?void 0:c.hyphen:void 0,this.text=new ne(this,{text:a,color:this.color,scale:.8},u,0),this.rect=new B,this.mi=new Zo(this)}getMusicInterface(){return this.mi}get measure(){return this.col.measure}getText(){return this.text.getText()}setNextLyricsObject(e){this.nextLyricsObject=e}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.text.layout(e),this.rect=this.text.getRect().copy()}offset(e,r){this.text.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r;if(this.text.draw(e),this.hyphen!==void 0){e.color(this.color).lineWidth(1);let i=this.getRect(),o=(r=this.nextLyricsObject)==null?void 0:r.getRect(),s=e.unitSize*1.5,a=o?(o.left-i.right)*.85:s,c=this.hyphen==="-"?Math.min(s,a):a;if(c>0){let u=o?(o.left+i.right)/2:i.right+c/.85,l=(i.top+i.bottom)/2;e.moveTo(u-c/2,l),e.lineTo(u+c/2,l),e.stroke()}}}};var Rn=class extends ee{constructor(e,r){super(e);this.measure=e;this.tab=r;p(this,"voiceId");p(this,"mi");p(this,"tupletPartsTextObjMap",new Map);this.voiceId=Ve().filter(i=>r.containsVoiceId(i)),this.rect=new B,this.mi=new Xo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let r=this.measure.getColumns(),i=Ve().map(o=>b.Math.sum(r.map(s=>s.getVoiceSymbol(o)?1:0)));this.voiceId.sort((o,s)=>b.Math.cmp(i[o],i[s])),this.rect=new B}hasTuplets(){return this.measure.getBeamGroups().some(e=>e.isTuplet())}layoutFitToMeasure(e){let{unitSize:r,fontSize:i}=e,{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(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),e.color("black").lineWidth(1);let{unitSize:r,fontSize:i}=e,o=r,s=r,a=r*.25,{bottom:c,centerY:u}=this.getRect(),l=u,h=c,d=this.measure.getColumns();for(let m=0;m<d.length;m++){let f=d[m],g=this.voiceId.map(I=>f.getVoiceSymbol(I)).find(I=>I!==void 0);if(!g)continue;let y=g.getBeamGroup(),C=y?y.getSymbols():[g];for(let I=0;I<C.length;I++){let S=C[I],w=C[I+1],v=S.col.getRect().centerX;if(S instanceof ye){if(S.rhythmProps.noteSize>=2&&(e.lineWidth(S.rhythmProps.noteSize===4?2:1),e.strokeLine(v,h,v,l)),e.lineWidth(1),C.length===1)for(let _=0;_<S.rhythmProps.flagCount;_++)e.drawFlag(new B(v,v+o,l+_*o,l+(_+2)*o),"up");for(let _=0;_<S.rhythmProps.dotCount;_++)e.fillCircle(v+s*(_+1),h-a,a)}else if(S instanceof ct){let _=v,A=(l+h)/2,x=.65;e.save(),e.scale(x,x),e.drawRest(S.rhythmProps.noteSize,_/x,A/x),e.restore();for(let T=0;T<S.rhythmProps.dotCount;T++)_+=s*1.5,e.fillCircle(_,A+s,a)}if(w){let _=S,A=w,x=_.col.getRect().centerX,T=A.col.getRect().centerX,E=_.hasTuplet()?1:_ instanceof ye?_.getRightBeamCount():1,R=A.hasTuplet()?1:A instanceof ye?A.getLeftBeamCount():1,M=Math.max(E,R);e.lineWidth(2);for(let G=0;G<M;G++){let k=R>E&&G>=E?.75:0,L=E>R&&G>=R?.25:1;e.strokePartialLine(x,l+G*o,T,l+G*o,k,L)}e.lineWidth(1);for(let G=0;G<_.rhythmProps.dotCount;G++)e.fillCircle(x+s*(G+1),h-a,a);for(let G=0;G<A.rhythmProps.dotCount;G++)e.fillCircle(T+s*(G+1),h-a,a)}if(y&&y.isTuplet()){let _=(C[0].col.getRect().centerX+C[C.length-1].col.getRect().centerX)/2,A=y.getTupletRatioText(),x=this.tupletPartsTextObjMap.get(A);x||(this.tupletPartsTextObjMap.set(A,x=new ne(this,{text:A,scale:.75},.5,.5)),x.layout(e)),x.offset(-x.getRect().centerX,-x.getRect().centerY),x.offset(_,l-i/2),x.draw(e)}C.length>1&&(m=d.indexOf(C[C.length-1].col),m<0&&(m=d.length))}}}};function Ca(n){if(typeof n=="number"&&Ve().indexOf(n)<0)throw new O(6,"Invalid voiceId: "+n);return n}function aC(n){if(typeof n=="string"&&(n=[n]),b.Is.isArray(n)){let t=0;for(let e=0;e<n.length;){let r=n[e],i=n[e+1];if(typeof r=="string"){e++;let o=qe.get(r).ticks;typeof i=="number"&&(e++,o*=i),t+=o}else e++}return t}else return n}function cC(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 Ia=class Ia extends ee{constructor(e,r){super(e);this.row=e;this.options=r;p(this,"prevMeasure");p(this,"nextMeasure");p(this,"keySignature",ls());p(this,"timeSignature",ms());p(this,"tempo",fs());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,"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 cs);p(this,"mi");this.mi=new Qo(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new Kr(this),this.barLineRight=new Or(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo(),this.row.getTabs().forEach(i=>{this.addLayoutObject(new Rn(this,i),i,0,0)})}getMusicInterface(){return this.mi}get doc(){return this.row.doc}isPartialMeasure(){return this.getConsumedTicks()<this.getMeasureTicks()}isUpBeat(){return this===this.doc.getFirstMeasure()}resetPassCount(){this.passCount=0}incPassCount(){this.passCount++}getPassCount(){return this.passCount}updateRunningArguments(e){var i;e!=null||(e=[]);let r=b.Math.sum(Ve().map(o=>this.getVoiceSymbols(o).length>0?1:0));Ve().forEach(o=>{var l;let s=()=>{let h=this.row.getStaves().filter(m=>m.containsVoiceId(o)),d=this.row.getTabs().filter(m=>m.containsVoiceId(o));return h.length>0?h[0].middleLineDiatonicId:d.length>0?d[0].getTuningStrings()[3].diatonicId:U.getNote("G4").diatonicId},a=()=>"auto",c=()=>[],u=(l=e[o])!=null?l:e[o]={diatonicId:s(),stemDir:a(),stringNumbers:c()};this.getVoiceSymbols(o).forEach((h,d,m)=>{var y,C;if(h.setDiatonicId===ct.UndefinedDiatonicId?r<2&&(u.diatonicId=ct.UndefinedDiatonicId):u.diatonicId=h.setDiatonicId,h instanceof ye)switch(h.setStringsNumbers&&(u.stringNumbers=h.setStringsNumbers),(y=h.options)==null?void 0:y.stem){case"up":case"up":u.stemDir="up";break;case"down":case"down":u.stemDir="down";break;case"auto":case"auto":u.stemDir="auto";break}let f=(C=h.getBeamGroup())==null?void 0:C.getSymbols(),g;f===void 0?g=u.stemDir==="auto"?this.row.solveAutoStemDir([h]):u.stemDir:h===f[0]?g=u.stemDir==="auto"?this.row.solveAutoStemDir(f):u.stemDir:g=f[0].stemDir,h.updateRunningArguments(u.diatonicId,g,u.stringNumbers)})}),(i=this.getNextMeasure())==null||i.updateRunningArguments(e)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.signatures.length;i++){let o=this.signatures[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabStringNotes.length;i++){let o=this.tabStringNotes[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.columns.length;i++){let o=this.columns[i].pick(e,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let i=this.barLineLeft.pick(e,r);if(i.length>0)return[this,...i]}if(this.barLineRight){let i=this.barLineRight.pick(e,r);if(i.length>0)return[this,...i]}if(this.endRepeatPlayCountText){let i=this.endRepeatPlayCountText.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.connectives.length;i++){let o=this.connectives[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.beamGroups.length;i++){let o=this.beamGroups[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.layoutObjects.length;i++){let o=this.layoutObjects[i].musicObj.pick(e,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let e=this.doc.getFirstMeasure();return e&&e.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(e){return this.getColumns()[e]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...e){var r;if((r=this.getPrevMeasure())==null||r.endSection(),e[0]instanceof Bt)this.alterKeySignature=e[0];else if(e[0]instanceof jr)this.alterKeySignature=e[0];else if(b.Is.isNonEmptyString(e[0])){if(e.length===1)this.alterKeySignature=br(e[0]);else if(e.length===2)try{let i=""+e[0],o=qn(""+e[1]);this.alterKeySignature=br(i,o)}catch(i){throw new O(6,"Cannot set key signature because invalid args: "+e)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:ls(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(e){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=e,this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:ms(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r,i){var o;if((o=this.getPrevMeasure())==null||o.endSection(),r===void 0)this.alterTempo={beatsPerMinute:e};else{let s=typeof i=="number"&&i>0?i:i===!0?1:_e.get(r).dotCount,a={beatLength:Gt(r),dotCount:s>0?s:void 0};this.alterTempo={beatsPerMinute:e,options:a}}this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:fs(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,o;this.alterTempo.options?(i=this.alterTempo.options.beatLength,o=(e=this.alterTempo.options.dotCount)!=null?e: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(e,r,i,o){this.layoutObjects.push(new Sa(e,r,i,o)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(e,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];(b.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}})}}}};e===void 0?o.length>=2&&o[0]instanceof Ne&&o[1]instanceof Ne&&o[0].staffConfig.grandId!==void 0&&o[0].staffConfig.grandId===o[1].staffConfig.grandId?s(r===1?1:0,r):s(0,r):b.Is.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let i=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new O(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(o,s)=>{this.addLayoutObject(new Nn(i,s),o,1,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof Nn&&r.anchor===e)}addNavigation(e,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 Si(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 ne(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0},this.addNavigation(e,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=jo(r);o={createObj:()=>new ne(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=jo(r);o={createObj:()=>new tr(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=jo(r);o={createObj:()=>new tr(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"endRepeat":if(i.length===0)this.endRepeatPlayCount=2;else if(b.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 ne(this,c,.5,1)}break}o&&this.forEachStaffGroup(e,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,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(e,c,(u,l)=>{let h=new ne(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(e,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(e,c,(u,l)=>{let h=new ne(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addConnective(e,...r){let i=this.lastAddedRhythmSymbol;if(!(i instanceof ye))throw new O(6,"Connective can be added to note group only.");if(e==="tie"){let o=b.Is.isInteger(r[0])||b.Is.isEnumValue(r[0],$t)?r[0]:2,s=b.Is.isEnumValue(r[1],Pt)?r[1]:"auto";i.startConnective(new On("tie",o,s,i))}else if(e==="slur"){let o=b.Is.isInteger(r[0])?r[0]:2,s=b.Is.isEnumValue(r[1],Pt)?r[1]:"auto";i.startConnective(new On("slur",o,s,i))}else if(e==="slide"){let o=b.Is.isEnumValue(r[0],Pt)?r[0]:"auto";i.startConnective(new On("slide",2,o,i))}}addExtension(e,r){if(this.addExtensionToMusicObjects.forEach(i=>{let o=i.getParent();if(i instanceof ne&&o instanceof Tr){let s="dashed",a="bottom",c=new Ii(i,o,aC(e),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(e){this.addExtensionToMusicObjects.push(e)}disableExtension(){this.addExtensionToMusicObjects=[]}getEnding(){return this.layoutObjects.map(e=>e.musicObj).find(e=>e instanceof Si)}getEndRepeatPlayCount(){return this.endRepeatPlayCount}endSong(){this.isEndSong=!0,this.requestLayout(),this.disableExtension()}hasEndSong(){return this.isEndSong}endSection(){this.isEndSection=!0,this.requestLayout(),this.disableExtension()}hasEndSection(){return this.isEndSection}endRow(){this.doc.requestNewRow(),this.disableExtension()}addRhythmSymbol(e){var o,s;let{col:r,voiceId:i}=e;r.setVoiceSymbol(i,e),(s=(o=this.voiceSymbols)[i])!=null||(o[i]=[]),this.voiceSymbols[i].push(e),e.oldStyleTriplet&&this.createOldStyleTriplets(i),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=r,this.lastAddedRhythmSymbol=e}addNoteGroup(e,r,i,o,s){let a=r.map(l=>typeof l=="string"?U.getNote(l):l),c=this.getRhythmColumn(e),u=new ye(c,e,a,i,o,s);return this.addRhythmSymbol(u),u}addRest(e,r,i,o){let s=this.getRhythmColumn(e),a=new ct(s,e,r,i,o);return this.addRhythmSymbol(a),a}addLyrics(e,r,i,o,s){this.forEachStaffGroup(e,1,(a,c)=>{var d;let u=this.getRhythmColumn({verse:r,line:a,vpos:c}),l=new va(u,r,a,c,Gt(i),o,s);u.addLyricsObject(l);let h=this.getLyricsObjects(a,c,r);h.push(l),h.sort((m,f)=>b.Math.cmp(m.col.positionTicks,f.col.positionTicks)),(d=l.measure.getPrevLyricsObject(l))==null||d.setNextLyricsObject(l),this.addLayoutObject(l,a,cC(r),c),this.lastAddedRhythmColumn=u})}getRhythmColumn(e){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let o=this.columns[i],s=typeof e=="number"?o.getVoiceSymbol(e):o.getLyricsObject(e.verse,e.line,e.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 Tr(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(e){let r=0;return this.columns.forEach(i=>{Ve().forEach(o=>{let s=i.getVoiceSymbol(o);s&&(e===void 0||e===o)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new B(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 e=this.getPrevMeasure();return e&&e.row===this.row&&!e.hasPostMeasureBreak()?e.getStaffLineRight():this.getRect().left+this.tabStringNotesWidth}getStaffLineRight(){return this.barLineRight.getRect().centerX}getLyricsObjects(e,r,i){let o=this.lyricsObjectsCache.get(e,r,i);return o||this.lyricsObjectsCache.set(e,r,i,o=[]),o}getPrevLyricsObject(e){var c;let{line:r,verse:i,vpos:o}=e,s=this.getLyricsObjects(r,o,i),a=s.indexOf(e);if(a>0)return s[a-1];if(a===0){let u=(c=e.measure.getPrevMeasure())==null?void 0:c.getLyricsObjects(r,o,i);if(u&&u.length>0)return u[u.length-1]}}getStaticObjects(e){let r=this.staticObjectsCache.get(e);r||(r=[],this.getColumns().forEach(o=>o.getStaticObjects(e).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(e,r));let i=this.layoutObjects.filter(o=>o.line===e&&o.isPositionResolved()).map(o=>o.musicObj);return i.length>0?[...r,...i]:r}removeLayoutObjects(e){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===e){let i=r.musicObj.getLink();return i&&i.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(e){this.connectives.push(e),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(e=>{var c;let{musicObj:r,measure:i,layoutGroupId:o,verticalPos:s,line:a}=e;if(r.getLink()instanceof Ii){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(),y=(c=g.find(C=>C.name!==""&&C.name===a.name))!=null?c:g[a.id];y&&d.addLayoutObject(new Tn(d,y,u,m,f),y,o,s)}}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);for(let i=0;i<r.length;)if(r[i].oldStyleTriplet){let o=wi.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 e=this.getTimeSignature();!this.needBeamsUpdate||e.beamGroupSizes.length===0||(Ve().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<e.beamGroupSizes.length;a++){let c=e.beamGroupSizes[a],u=[c];c.length>1&&u.unshift([b.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*_e.get("8n").ticks,g=s+f,y=i.filter(I=>{let S=o+I.col.positionTicks,w=S+I.rhythmProps.ticks;return S>=s&&w<=g});b.Math.sum(y.map(I=>I.rhythmProps.ticks))===f&&y.every(I=>I instanceof ye)&&(y.every(I=>I.rhythmProps.flagCount===1)||u.length===0)&&wi.createBeam(y)&&(l=!0),s+=f})}}}),this.needBeamsUpdate=!1,this.requestLayout())}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){var r,i;return Ca(e),(i=(r=this.voiceSymbols)[e])!=null||(r[e]=[]),this.voiceSymbols[e]}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(Ve().filter(r=>this.getConsumedTicks(r)>0));return}else if(b.Is.isArray(e)){e.forEach(r=>this.completeRests(r));return}else{Ca(e);let r=this.getMeasureTicks(),i=this.getConsumedTicks(e),o=r-i,s=[];for(;o>0;)for(let a=_e.LongestNoteSize;a<=_e.ShortestNoteSize;a*=2){let c=_e.create(a).noteLength;for(let u=_e.get(c).maxDotCount;u>=0;u--){let l=qe.get(c,u);for(;l.ticks<=o;)s.push(l),o-=l.ticks}}s.reverse().forEach(a=>this.addRest(e,a.noteLength,{dotted:a.dotCount}))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?ae.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=this.options.showNumber===!1?!1:this.options.showNumber===!0||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 Ne&&(s||a||c||u||l)){let y=this.signatures.filter(I=>I instanceof Io).find(I=>I.staff===f),C=y!=null?y:new Io(this,f);C.staff.addObject(C),C.updateClefImage(e,s),C.updateMeasureNumber(a&&g===0),C.updateKeySignature(c),C.updateTimeSignature(u),C.updateTempo(l&&g===0),C.layout(e),this.signatures.push(C)}else if(f instanceof rt&&(a||u||l)){let y=this.signatures.filter(I=>I instanceof So).find(I=>I.tab===f),C=y!=null?y:new So(this,f);C.tab.addObject(C),C.updateMeasureNumber(a&&g===0),C.updateTimeSignature(u),C.updateTempo(l&&g===0),C.layout(e),this.signatures.push(C)}}),this.tabStringNotes.length=0,this===this.row.getFirstMeasure()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let y=f.getTuningStrings()[g].format(1,1),C=new ne(this,{text:y,scale:.8},1,.5);C.layout(e),C.offset(this.tabStringNotesWidth*.8,f.getStringY(g)),this.tabStringNotes.push(C),f.addObject(C)}}),this.barLineLeft.layout(e);let h=new fa(this);this.columns.forEach(f=>f.layout(e,h)),this.barLineRight.layout(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(e),this.layoutObjects.forEach(f=>f.layout(e));let d=e.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,Ia.MinFlexContentWidth*r)}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new B,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=b.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(e){this.needLayout&&this.connectives.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(e){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}alignStemsToBeams(){this.beamGroups.forEach(e=>e.updateStemTips())}layoutDone(){this.columns.forEach(e=>e.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(e=>e.getRect().top),...this.tabStringNotes.map(e=>e.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(e=>e.getRect().top),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(e=>e.getRect().bottom),...this.tabStringNotes.map(e=>e.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(e=>e.getRect().bottom),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().bottom)),this===this.row.getLastMeasure()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(e=>e.isPositionResolved()&&e.musicObj instanceof Nn).map(e=>e.musicObj.getRect().right))),this.row.getNotationLines().forEach(e=>{this.rect.top=Math.min(this.rect.top,e.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,e.calcBottom())}),this.row.requestRectUpdate()}offset(e,r){this.signatures.forEach(i=>i.offset(e,0)),this.tabStringNotes.forEach(i=>i.offset(e,0)),this.barLineLeft.offset(e,r),this.columns.forEach(i=>i.offset(e,r)),this.barLineRight.offset(e,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(e,r),this.connectives.forEach(i=>i.offset(e,0)),this.beamGroups.forEach(i=>i.offset(e,r)),this.layoutObjects.forEach(i=>i.offset(e,0)),this.rect.offsetInPlace(e,r),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let r=this.getStaffLineLeft(),i=this.getStaffLineRight();e.color("black").lineWidth(1);let o=s=>e.strokeLine(r,s,i,s);this.row.getNotationLines().forEach(s=>{if(s instanceof Ne)for(let a=s.bottomLineDiatonicId;a<=s.topLineDiatonicId;a+=2)o(s.getDiatonicIdY(a));else if(s instanceof rt)for(let a=0;a<6;a++)o(s.getStringY(a))}),this.signatures.forEach(s=>s.draw(e)),this.tabStringNotes.forEach(s=>s.draw(e)),this.barLineLeft.draw(e),this.columns.forEach(s=>s.draw(e)),this.barLineRight.draw(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(e),this.connectives.forEach(s=>s.draw(e)),this.layoutObjects.forEach(s=>s.musicObj.draw(e)),this.beamGroups.forEach(s=>s.draw(e))}};p(Ia,"MinFlexContentWidth",10);var Mn=Ia;var uC=[2,7],lC=[0,3,4,5,6,7,8,9,10];function hC(n){for(;n;){if(n instanceof Mn)return n;n=n.getParent()}throw new O(6,"Parent measure is required but not found!")}var wa=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},Sa=class{constructor(t,e,r,i){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=i;p(this,"anchor");p(this,"measure");p(this,"row");p(this,"layoutGroup");p(this,"positionResolved",!0);this.measure=hC(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(t){let{musicObj:e,measure:r,verticalPos:i,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=t.unitSize*2,u=i===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,l=r.getStaticObjects(o),h=e.getShapeRects();return l.forEach(d=>{let m=d.getShapeRects();h.forEach(f=>{m.forEach(g=>{B.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 ne||this.musicObj instanceof tr)return this.musicObj.getText()}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}getRect(){return this.musicObj.getRect()}},Na=class{constructor(t){this.layoutGroupId=t;p(this,"layoutObjectTable",[]);p(this,"rowAlign");p(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=lC.indexOf(t)>=0,this.widensColumn=uC.indexOf(t)>=0}getLayoutObjects(t){return this.layoutObjectTable[t]}add(t){this.layoutObjectTable[t.verticalPos].push(t)}remove(t){this.layoutObjectTable.forEach(e=>{let r=e.indexOf(t);r>=0&&e.splice(r,1)})}clearPositionAndLayout(t){this.layoutObjectTable.forEach(e=>{e.forEach(r=>{r.clearPositionResolved(),r.musicObj.layout(t)})})}};var Ta=class extends ee{constructor(e){super(e);this.row=e;p(this,"objects",[]);p(this,"layoutGroups",[])}addObject(e){this.objects.push(e)}removeObjects(){this.objects.length=0}getLayoutGroup(e){let r=this.layoutGroups[e];return r||(r=this.layoutGroups[e]=new Na(e)),r}resetLayoutGroups(e){this.layoutGroups.forEach(r=>{r&&r.clearPositionAndLayout(e)})}layoutLayoutGroups(e){this.layoutGroups.forEach(r=>{r&&(this.layoutLayoutGroup(e,r,0),this.layoutLayoutGroup(e,r,1))})}setObjectY(e,r){r!==void 0&&(e.offset(0,r-e.getRect().centerY),e.setPositionResolved())}alignObjectsY(e,r){r=r.filter(o=>!o.isPositionResolved());let i;r.forEach(o=>{let s=o.resolveClosestToStaffY(e);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(e,r,i){let o=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof Si||a instanceof Tn||a instanceof Rn?a.layoutFitToMeasure(e):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(e,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(e,u)}else this.alignObjectsY(e,[s])})}},Ne=class extends Ta{constructor(e,r,i){super(e);this.row=e;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 Ko(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var e;return(e=this.staffConfig.name)!=null?e:""}getConfig(){return this.staffConfig}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(e){e!==this&&(this.joinedGrandStaff=e)}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(e){return U.validateDiatonicId(e),(this.minDiatonicId===void 0||e>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||e<=this.maxDiatonicId)}getDiatonicIdY(e){if(this.containsDiatonicId(e))return this.bottomLineY+(this.bottomLineDiatonicId-e)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff.getDiatonicIdY(e);throw new O(6,"Staff does not contain diatonicId "+e)}getActualStaff(e){if(this.containsDiatonicId(e))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff;throw new O(6,"Staff does not contain diatonicId "+e)}getDiatonicIdAt(e){let r=Math.round(this.bottomLineDiatonicId-(e-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(e){return e%2===this.middleLineDiatonicId%2}isSpace(e){return e%2!==this.middleLineDiatonicId%2}containsVoiceId(e){return b.Is.isUndefined(this.staffConfig.voiceId)||b.Arr.toArray(this.staffConfig.voiceId).includes(e)}calcTop(){let e=this.topLineY;if(this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),i=this.getDiatonicIdY(this.maxDiatonicId-1);e=Math.min(e,r-Math.abs(i-r)+1)}return e}calcBottom(){let e=this.bottomLineY;if(this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),i=this.getDiatonicIdY(this.minDiatonicId+1);e=Math.max(e,r+Math.abs(i-r)-1)}return e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,i=r*ae.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new B(0,0,this.topLineY,this.bottomLineY)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}},rt=class extends Ta{constructor(e,r,i){super(e);this.row=e;this.tabConfig=r;this.id=i;p(this,"top",0);p(this,"bottom",0);p(this,"tuningName");p(this,"tuningStrings");p(this,"mi");b.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>U.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=Oc(r.tuning),this.tuningStrings=ds(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=ds(this.tuningName)),this.mi=new Jo(this)}getMusicInterface(){return this.mi}get name(){var e;return(e=this.tabConfig.name)!=null?e:""}getConfig(){return this.tabConfig}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(e){return this.top+(this.bottom-this.top)/6*(e+.5)}getTopStringY(){return this.getStringY(0)}getBottomStringY(){return this.getStringY(5)}getTopLineY(){return this.getTopStringY()}getBottomLineY(){return this.getBottomStringY()}getTop(){return this.top}getBottom(){return this.bottom}containsVoiceId(e){return b.Is.isUndefined(this.tabConfig.voiceId)||b.Arr.toArray(this.tabConfig.voiceId).includes(e)}containsDiatonicId(e){return!0}calcTop(){let{top:e}=this;return this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),e}calcBottom(){let{bottom:e}=this;return this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,i=r*ae.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new B(0,0,this.top,this.bottom)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.top+=r,this.bottom+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}};var Oa=class extends ee{constructor(e,r,i){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=i;p(this,"nextRow");p(this,"minWidth",0);p(this,"notationLines");p(this,"instrumentLineGroups");p(this,"staves");p(this,"tabs");p(this,"instrumentNames");p(this,"measures",[]);p(this,"needLayout",!0);p(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(s=>s instanceof Ne),this.tabs=this.notationLines.filter(s=>s instanceof rt);let o=[];for(let s=0;s<this.notationLines.length;s++){let a=this.notationLines[s],c=o[o.length-1];c===void 0||c[0].getConfig().instrument===void 0||c[0].getConfig().instrument!==a.getConfig().instrument?o.push([a]):c.push(a)}this.instrumentLineGroups=o,this.instrumentNames=this.instrumentLineGroups.map(s=>s.length>0&&b.Is.isNonEmptyString(s[0].getConfig().instrument)?new ne(this,String(s[0].getConfig().instrument),0,.5):void 0),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new $o(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,i)=>r.type==="staff"?new Ne(this,r,i):new rt(this,r,i));for(let r=0;r<e.length-1;r++){let i=e[r],o=e[r+1];i instanceof Ne&&o instanceof Ne&&i.staffConfig.grandId!==void 0&&i.staffConfig.grandId===o.staffConfig.grandId&&(i.joinGrandStaff(o),o.joinGrandStaff(i))}return e}getNotationLines(){return this.notationLines}getInstrumentLineGroups(){return this.instrumentLineGroups}findMatchingLine(e){return e.row===this?e:this.notationLines.find(r=>b.Obj.deepEqual(e.row.scoreConfig,r.row.scoreConfig)&&e.id===r.id||b.Is.isNonEmptyString(e.getConfig().name)&&e.getConfig().name===r.getConfig().name&&e.getConfig().type===r.getConfig().type)}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let e=this.staves[0];if(e)return e;throw new O(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new O(6,"Bottom staff is required!")}getStaff(e){U.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r];if(i instanceof Ne&&i.containsDiatonicId(e))return i}}resetLayoutGroups(e){this.notationLines.forEach(r=>r.resetLayoutGroups(e))}layoutLayoutGroups(e){this.notationLines.forEach(r=>r.layoutLayoutGroups(e))}pick(e,r){var i,o;if(!this.getRect().contains(e,r))return[];for(let s=0;s<this.measures.length;s++){let a=this.measures[s].pick(e,r);if(a.length>0)return[this,...a]}for(let s=0;s<this.instrumentNames.length;s++){let a=(o=(i=this.instrumentNames[s])==null?void 0:i.pick(e,r))!=null?o:[];if(a.length>0)return[this,...a]}for(let s=0;s<this.notationLines.length;s++){let a=this.notationLines[s].pick(e,r);if(a.length>0)return[this,...a]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:e.left;return new B(i,(i+e.right)/2,e.right,e.top,e.centerY,e.bottom)}getDiatonicIdAt(e){for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r],o=i instanceof Ne?i.getDiatonicIdAt(e):void 0;if(o!==void 0)return o}}addMeasure(e){this.measures.push(e)}getMeasures(){return this.measures}isFirstRow(){return this===this.doc.getFirstRow()}isLastRow(){return this===this.doc.getLastRow()}getPrevRow(){return this.prevRow}getNextRow(){return this.nextRow}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}getMinWidth(){return this.minWidth}solveAutoStemDir(e){if(e.length===0)return"up";{let r=e[0].voiceId,i=e.filter(u=>u instanceof ye).map(u=>u.setDiatonicId),o=e.filter(u=>u instanceof ct&&u.setDiatonicId!==ct.UndefinedDiatonicId).map(u=>u.setDiatonicId);if(i.length===0&&o.length===0)return"up";let s=i.length>0?i:o,a=Math.floor(b.Math.avg(...s)),c=this.getStaves().filter(u=>u.containsVoiceId(r)&&u.containsDiatonicId(a));return c.length>0?a>=c[0].middleLineDiatonicId?"down":"up":"up"}}getInstrumentNameWidth(e){return Math.max(0,...this.instrumentNames.map(r=>r?r.getRect().width:0))}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(e){this.needLayout&&(this.requestRectUpdate(),this.instrumentNames.forEach(r=>r==null?void 0:r.layout(e)),this.notationLines.forEach(r=>{r.removeObjects(),r.layoutHeight(e)}),this.minWidth=0,this.measures.forEach(r=>{r.layout(e),this.minWidth+=r.getMinWidth(),this.minWidth+=r.getPostMeasureBreakWidth()}))}layoutWidth(e,r,i){if(!this.needLayout)return;this.rect=new B(0,i,0,0),this.notationLines.forEach(u=>u.layoutWidth(e));let o=i-r,s=0;this.measures.forEach(u=>{o-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=o/s,c=this.doc.getInstrumentGroupSize(e).braceRight;this.measures.forEach(u=>{let l=u.getSolidAreaWidth()+u.getMinColumnsAreaWidth()*a;u.layoutWidth(e,l);let h=u.getRect();u.offset(c-h.left,-h.centerY),c+=h.width,c+=u.getPostMeasureBreakWidth()}),this.measures.forEach(u=>{u.layoutConnectives(e),u.layoutBeams(e)})}updateRect(){let e=0,r=this.measures.length>0?this.measures[this.measures.length-1].getRect().right:e,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 B(e,r,i,o)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutSetNotationLines(e){let{unitSize:r}=e;for(let i=1;i<this.notationLines.length;i++){let o=this.notationLines[i-1],s=this.notationLines[i];if(o instanceof Ne&&s instanceof Ne&&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(),Ve().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.instrumentNames.forEach((i,o)=>{let s=this.instrumentLineGroups[o];i&&s.length>0&&i.offset(-i.getRect().left,-i.getRect().centerY+(s[0].getRect().top+s[s.length-1].getRect().bottom)/2)}),this.alignStemsToBeams(),this.requestRectUpdate()}layoutPadding(e){let r=e.unitSize/2;this.getRect(),this.rect.left-=r,this.rect.right+=r,this.rect.top-=r,this.rect.bottom+=r}layoutDone(){this.measures.forEach(e=>e.layoutDone()),this.needLayout=!1}offset(e,r){this.measures.forEach(i=>i.offset(e,r)),this.rect.offsetInPlace(e,r),this.notationLines.forEach(i=>i.offset(e,r)),this.instrumentNames.forEach(i=>i==null?void 0:i.offset(e,r))}draw(e){e.drawDebugRect(this.getRect()),e.save();let{left:r,top:i,width:o,height:s}=this.getRect();if(e.rect(r,i,o,s),e.clip(),this.getFirstMeasure()&&(this.notationLines.length>1||this.notationLines[0]instanceof rt)){let c=this.getFirstMeasure().getStaffLineLeft(),u=Math.min(...this.notationLines.map(h=>h.getTopLineY())),l=Math.max(...this.notationLines.map(h=>h.getBottomLineY()));e.color("black").lineWidth(1).strokeLine(c,u,c,l)}this.measures.forEach(c=>c.draw(e)),this.notationLines.forEach(c=>c.draw(e));let a=this.doc.getInstrumentGroupSize(e);this.instrumentNames.forEach((c,u)=>{let l=this.instrumentLineGroups[u];if(l.length>1){let h=new B(a.braceLeft,a.braceRight,l[0].getTopLineY(),l[l.length-1].getBottomLineY());e.color("brack").lineWidth(1).drawBrace(h,"left")}c&&c.draw(e)}),e.restore()}};var Ra=class extends ee{constructor(e,r,i,o){super(e);this.title=r;this.composer=i;this.arranger=o;p(this,"titleText");p(this,"composerText");p(this,"arrangerText");p(this,"mi");this.mi=new es(this),this.titleText=this.title?new ne(this,{text:this.title,scale:2},.5,0):void 0,this.composerText=this.composer?new ne(this,this.composer,1,0):void 0,this.arrangerText=this.arranger?new ne(this,"Arr.: "+this.arranger,1,0):void 0}getMusicInterface(){return this.mi}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.titleText){let i=this.titleText.pick(e,r);if(i)return[this,...i]}if(this.composerText){let i=this.composerText.pick(e,r);if(i)return[this,...i]}if(this.arrangerText){let i=this.arrangerText.pick(e,r);if(i)return[this,...i]}return[this]}layoutWidth(e,r,i){let o=0;this.rect=new B(r,i,0,0),this.titleText&&(this.titleText.layout(e),this.titleText.offset((r+i)/2,o),o+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(e),this.composerText.offset(i,o),o+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(e),this.arrangerText.offset(i,o),o+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(e,r){this.titleText&&this.titleText.offset(e,r),this.composerText&&this.composerText.offset(e,r),this.arrangerText&&this.arrangerText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.titleText&&this.titleText.draw(e),this.composerText&&this.composerText.draw(e),this.arrangerText&&this.arrangerText.draw(e)}};var Ma=class extends ee{constructor(){super(void 0);p(this,"needLayout",!0);p(this,"ctx");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 Rr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(b.Is.isEnumValue(e,Cn))switch(e){default:case"treble":this.curScoreConfig=[{type:"staff",clef:"G"}];break;case"bass":this.curScoreConfig=[{type:"staff",clef:"F"}];break;case"grand":this.curScoreConfig=[{type:"staff",clef:"G",grandId:"grand1"},{type:"staff",clef:"F",grandId:"grand1"}];break;case"guitarTreble":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case"guitarTab":this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case"guitarCombined":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else b.Is.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];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(e){this.measuresPerRow=e}addConnectiveProps(e){this.allConnectiveProps.push(e)}setRenderContext(e){if(this.ctx===e)return;let r=this.ctx;this.ctx=e,r&&r.setDocument(void 0),e&&e.setDocument(this.mi),this.requestFullLayout()}setHeader(e,r,i){this.header=new Ra(this,e,r,i),this.requestLayout()}getTitle(){var e;return(e=this.header)==null?void 0:e.title}getComposer(){var e;return(e=this.header)==null?void 0:e.composer}getArranger(){var e;return(e=this.header)==null?void 0:e.arranger}hasSingleMeasure(){return this.measures.length===1}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}addNewRow(e){let r=new Oa(this,e,this.curScoreConfig);return this.rows.push(r),r}getFirstRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[0]}getLastRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[this.rows.length-1]}getRows(){return this.rows}getMeasures(){return this.measures}requestNewRow(){this.newRowRequested=!0}addMeasure(e){let r=this.rows[this.rows.length-1];(!r||this.newRowRequested&&r.getMeasures().length>0||r.getMeasures().length>=this.measuresPerRow)&&(r=this.addNewRow(r),this.newRowRequested=!1);let i=new Mn(r,e);return this.measures.push(i),r.addMeasure(i),this.requestLayout(),i}addStaffGroup(e,r,i){this.staffGroups.set(e,new wa(e,r,i))}getStaffGroup(e){return this.staffGroups.get(e)}getVoiceSymbols(e){let r=[];return this.forEachMeasure(i=>r=r.concat(i.getVoiceSymbols(e))),r}removeLayoutObjects(e){this.forEachMeasure(r=>r.removeLayoutObjects(e))}forEachMeasure(e){let r=this.getFirstMeasure();for(;r;)e(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(e=>e.resetPassCount())}updateCursorRect(e){this.ctx&&this.ctx.updateCursorRect(e)}getInstrumentGroupSize(e){let r=Math.max(0,...this.rows.map(a=>a.getInstrumentNameWidth(e))),i=r>0,o=i?e.unitSize:0,s=i?e.unitSize*5:0;return{nameLeft:0,nameRight:r,braceLeft:r+o,braceRight:r+o+s+o}}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(e=>e.requestLayout()),this.forEachMeasure(e=>{e.getColumns().forEach(r=>r.requestLayout()),e.requestLayout()}),this.requestLayout()}layout(){var s;if(!this.needLayout)return;let{ctx:e}=this;if(!e)return;let{unitSize:r}=e;this.forEachMeasure(a=>a.createBeams()),(s=this.getFirstMeasure())==null||s.updateRunningArguments(),this.forEachMeasure(a=>a.createExtensions()),this.allConnectiveProps.forEach(a=>a.removeConnectives()),this.allConnectiveProps.forEach(a=>a.createConnectives()),this.rows.forEach(a=>a.resetLayoutGroups(e)),this.rows.forEach(a=>a.layout(e));let i=this.getInstrumentGroupSize(e).braceRight,o=Math.max(ae.DocumentMinWidth*r,...this.rows.map(a=>1.4*a.getMinWidth()));this.rows.forEach(a=>a.layoutWidth(e,i,o)),this.rows.forEach(a=>a.layoutLayoutGroups(e)),this.rows.forEach(a=>a.layoutSetNotationLines(e)),this.rows.forEach(a=>a.layoutPadding(e)),this.rect=new B,this.header&&(this.header.layoutWidth(e,i,o),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(a=>{a.offset(-this.rect.left,this.rect.bottom+r*2-a.getRect().top),this.rect.expandInPlace(a.getRect())}),this.rows.forEach(a=>a.layoutDone()),this.needLayout=!1}drawContent(){let{ctx:e}=this;e&&(this.rows.forEach(r=>r.draw(e)),this.header&&this.header.draw(e))}pickStaffPosAt(e,r){if(this.rect.contains(e,r))for(let i=0;i<this.rows.length;i++){let o=this.rows[i];if(!o.hasStaff||!o.getRect().contains(e,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.header){let i=this.header.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.rows.length;i++){let o=this.rows[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}};function P(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function Uu(n){if(typeof n!="string")return!1;{let t=U.parseNote(n);return t!==void 0&&t.octave!==void 0}}function fr(n){return b.Is.isNumber(n)&&Ve().indexOf(n)>=0}function Jm(n){return b.Is.isNumber(n)&&la().indexOf(n)>=0}function dC(n){return b.Is.isNumber(n)&&ha().indexOf(n)>=0}function rf(n){var t;if(P(b.Is.isObject(n),"baseConfig",n),P(b.Is.isStringOrUndefined(n.name),"baseConfig.name",n.name),P(b.Is.isUndefined(n.voiceId)||fr(n.voiceId)||b.Is.isArray(n.voiceId)&&n.voiceId.every(e=>fr(e)),"baseConfig.voiceId",n.voiceId),!b.Is.isUndefined(n.voiceIds)){P(fr(n.voiceIds)||b.Is.isArray(n.voiceIds)&&n.voiceIds.every(r=>fr(r)),"baseConfig.voiceIds",n.voiceIds),console.warn("Staff/tab config property 'voiceIds' is deprecated, use 'voiceId' instead.");let e=b.Arr.toArray((t=n.voiceId)!=null?t:[]);b.Arr.toArray(n.voiceIds).forEach(r=>e.push(r)),n.voiceId=e}b.Is.isArray(n.voiceId)&&(n.voiceId=b.Arr.removeDuplicates(n.voiceId)),P(b.Is.isStringOrUndefined(n.instrument),"baseConfig.instrument",n.instrument)}function $m(n){rf(n),P(b.Is.isObject(n),"staffConfig",n),P(n.type==="staff","staffConfig.type",n.type),P(b.Is.isEnumValue(n.clef,Ci),"staffConfig.clef",n.clef),P(b.Is.isBooleanOrUndefined(n.isOctaveDown),"staffConfig.isOctaveDown",n.isOctaveDown),P(b.Is.isUndefined(n.minNote)||Uu(n.minNote),"staffConfig.minNote",n.minNote),P(b.Is.isUndefined(n.maxNote)||Uu(n.maxNote),"staffConfig.maxNote",n.maxNote),P(b.Is.isStringOrUndefined(n.grandId),"staffConfig.grandId",n.grandId),P(b.Is.isBooleanOrUndefined(n.isGrand),"staffConfig.isGrand",n.isGrand),b.Is.isUndefined(n.isGrand)||console.warn("Staff config property 'isGrand' is deprecated, use 'grandId' instead.")}function ef(n){rf(n),P(b.Is.isObject(n),"tabConfig",n),P(n.type==="tab","tabConfig.type",n.type),b.Is.isString(n.tuning)?P(Wn.includes(n.tuning),"tabConfig.tuning",n.tuning):b.Is.isArray(n.tuning)&&P(n.tuning.length===la().length&&n.tuning.every(t=>Uu(t)),"tabConfig.tuning",n.tuning)}function Da(n){P(b.Is.isObject(n),"noteOptions",n),P(b.Is.isBooleanOrUndefined(n.dotted)||b.Is.isIntegerGte(n.dotted,0),"noteOptions.dotted",n.dotted),P(b.Is.isEnumValueOrUndefined(n.stem,Jt),"noteOptions.stem",n.stem),P(b.Is.isStringOrUndefined(n.color),"noteOptions.color",n.color),P(b.Is.isBooleanOrUndefined(n.arpeggio)||b.Is.isEnumValue(n.arpeggio,Xr),"noteOptions.arpeggio",n.arpeggio),P(b.Is.isBooleanOrUndefined(n.staccato),"noteOptions.staccato",n.staccato),P(b.Is.isBooleanOrUndefined(n.diamond),"noteOptions.diamond",n.diamond),P(b.Is.isBooleanOrUndefined(n.triplet),"noteOptions.triplet",n.triplet),P(b.Is.isUndefined(n.string)||Jm(n.string)||b.Is.isNonEmptyArray(n.string)&&n.string.every(t=>Jm(t)),"noteOptions.string",n.string),P(b.Is.isUndefined(n.tieSpan),'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)',""),P(b.Is.isUndefined(n.slurSpan),'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)',"")}function tf(n){P(b.Is.isObject(n),"restOptions",n),P(b.Is.isBooleanOrUndefined(n.dotted)||b.Is.isIntegerGte(n.dotted,0),"restOptions.dotted",n.dotted),P(b.Is.isStringOrUndefined(n.staffPos)||b.Is.isInteger(n.staffPos)||n.staffPos instanceof U,"restOptions.staffPos",n.staffPos),P(b.Is.isStringOrUndefined(n.color),"restOptions.color",n.color),P(b.Is.isBooleanOrUndefined(n.hide),"restOptions.hide",n.hide),P(b.Is.isBooleanOrUndefined(n.triplet),"restOptions.triplet",n.triplet)}function pC(n){P(b.Is.isObject(n),"lyricsOptions",n),P(b.Is.isEnumValueOrUndefined(n.align,yo),"lyricsOptions.align",n.align),P(b.Is.isEnumValueOrUndefined(n.hyphen,An),"lyricsOptions.hyphen",n.hyphen)}function mC(n){P(b.Is.isObject(n),"measureOptions",n),P(b.Is.isBooleanOrUndefined(n.showNumber),"measureOptions.showNumber",n.showNumber)}function ts(n){P(b.Is.isStringOrUndefined(n)||b.Is.isIntegerGte(n,0)||b.Is.isNonEmptyArray(n)&&n.every(t=>b.Is.isString(t)||b.Is.isIntegerGte(t,0)),"staffTabOrGroup",n)}function $r(n){try{return Gt(n),!0}catch(t){return!1}}function fC(n){try{return ps(n),!0}catch(t){return!1}}var Ea=class Ea{constructor(){p(this,"doc");p(this,"currentLyricsAlign","center");this.doc=new Ma}setScoreConfiguration(t){return b.Is.isEnumValue(t,Cn)?this.doc.setScoreConfiguration(t):b.Is.isObject(t)&&t.type==="staff"?($m(t),this.doc.setScoreConfiguration(t)):b.Is.isObject(t)&&t.type==="tab"?(ef(t),this.doc.setScoreConfiguration(t)):b.Is.isNonEmptyArray(t)?(t.forEach(e=>{b.Is.isObject(e)&&e.type==="staff"?$m(e):b.Is.isObject(e)&&e.type==="tab"?ef(e):P(!1,"config",t)}),this.doc.setScoreConfiguration(t)):P(!1,"config",t),this}getMeasure(){var t;return(t=this.doc.getLastMeasure())!=null?t:this.doc.addMeasure(Ea.DefaultMeasureOptions)}getDocument(){return this.doc.getMusicInterface()}setHeader(t,e,r){return P(b.Is.isStringOrUndefined(t),"title",t),P(b.Is.isStringOrUndefined(e),"composer",e),P(b.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return P(b.Is.isIntegerGte(t,1)||b.Is.isPosInfinity(t),"measuresPerRow",t),this.doc.setMeasuresPerRow(t),this}addMeasure(t){return t!=null||(t={}),mC(t),this.doc.addMeasure(t),this}setKeySignature(...t){return P(t[0]instanceof jr||t[0]instanceof Bt||b.Is.isNonEmptyString(t[0])&&(t.length===1||b.Is.isEnumValue(t[1],ii)),"keySignature",t),this.getMeasure().setKeySignature(...t),this}setTimeSignature(...t){return t[0]instanceof Pr?this.getMeasure().setTimeSignature(t[0]):b.Is.isEnumValue(t[0],Un)&&b.Is.isEnumValueOrUndefined(t[1],oi)?this.getMeasure().setTimeSignature(new Pr(t[0],t[1])):b.Is.isIntegerGte(t[0],1)&&b.Is.isIntegerGte(t[1],1)&&b.Is.isEnumValueOrUndefined(t[2],oi)?this.getMeasure().setTimeSignature(new Pr(t[0],t[1],t[2])):P(!1,"timeSignature args",t),this}setTempo(t,e,r){return P(b.Is.isIntegerGte(t,1),"beatsPerMinute",t),e===void 0?P(b.Is.isUndefined(r),"dotted",r):(P(b.Is.isEnumValue(e,Xe)||$r(e),"beatLength",e),P(b.Is.isBooleanOrUndefined(r)||b.Is.isIntegerGte(r,0),"dotted",r)),this.getMeasure().setTempo(t,e,r),this}addNote(t,e,r,i){if(P(fr(t),"voiceId",t),P(e instanceof U||b.Is.isNonEmptyString(e)||b.Is.isArray(e)&&e.every(o=>o instanceof U||b.Is.isNonEmptyString(o)),"note",e),P(b.Is.isEnumValue(r,Xe)||$r(r),"noteLength",r),i!=null||(i={}),Da(i),b.Is.isArray(e)){let o=i.string;e.forEach((s,a)=>{i.string=b.Is.isArray(o)?o[a]:o,this.getMeasure().addNoteGroup(t,[s],r,i)})}else this.getMeasure().addNoteGroup(t,[e],r,i);return this}addChord(t,e,r,i){return P(fr(t),"voiceId",t),P(b.Is.isNonEmptyArray(e)&&e.every(o=>o instanceof U||b.Is.isNonEmptyString(o)),"notes",e),P(b.Is.isEnumValue(r,Xe)||$r(r),"noteLength",r),i!=null||(i={}),Da(i),this.getMeasure().addNoteGroup(t,e,r,i),this}addRest(t,e,r){return P(fr(t),"voiceId",t),P(b.Is.isEnumValue(e,Xe)||$r(e),"restLength",e),r!=null||(r={}),tf(r),this.getMeasure().addRest(t,e,r),this}addTuplet(t,e,r){P(fr(t),"voiceId",t),P(b.Is.isFunction(r),"tupletBuilder",r),P(fC(e)&&b.Is.isBooleanOrUndefined(e.showRatio),"tupletRatio",e);let i=[],o={addNote:(s,a,c)=>{if(P(s instanceof U||b.Is.isNonEmptyString(s)||b.Is.isArray(s)&&s.every(u=>u instanceof U||b.Is.isNonEmptyString(u)),"note",s),P(b.Is.isEnumValue(a,Xe)||$r(a),"noteLength",a),c!=null||(c={}),delete c.triplet,Da(c),b.Is.isArray(s)){let u=c.string;s.forEach((l,h)=>{c.string=b.Is.isArray(u)?u[h]:u;let d=this.getMeasure().addNoteGroup(t,[l],a,c,e);i.push(d)})}else{let u=this.getMeasure().addNoteGroup(t,[s],a,c,e);i.push(u)}return o},addChord:(s,a,c)=>{P(b.Is.isNonEmptyArray(s)&&s.every(l=>l instanceof U||b.Is.isNonEmptyString(l)),"notes",s),P(b.Is.isEnumValue(a,Xe)||$r(a),"noteLength",a),c!=null||(c={}),delete c.triplet,Da(c);let u=this.getMeasure().addNoteGroup(t,s,a,c,e);return i.push(u),o},addRest:(s,a)=>{P(b.Is.isEnumValue(s,Xe)||$r(s),"restLength",s),a!=null||(a={}),delete a.triplet,tf(a);let c=this.getMeasure().addRest(t,s,a,e);return i.push(c),o}};return r(o),wi.createTuplet(i,e),this}addLyricsInternal(t,e,r,i,o){var s;return ts(t),P(dC(e),"verse",e),P(b.Is.isEnumValue(r,Xe),"lyricsLength",r),P(b.Is.isString(i)||b.Is.isArray(i)&&i.every(a=>b.Is.isString(a)),"lyricsText",i),o!=null||(o={}),pC(o),o.align!==void 0?this.currentLyricsAlign=o.align:(s=o.align)!=null||(o.align=this.currentLyricsAlign),b.Is.isArray(i)?i.forEach(a=>this.getMeasure().addLyrics(t,e,r,a,o)):this.getMeasure().addLyrics(t,e,r,i,o),this}addLyrics(t,e,r,i){return this.addLyricsInternal(void 0,t,e,r!=null?r:"",i)}addLyricsTo(t,e,r,i,o){return this.addLyricsInternal(t,e,r,i!=null?i:"",o)}addFermataInternal(t,e){return ts(t),P(b.Is.isEnumValue(e,xo),"fermata",e),this.getMeasure().addFermata(t,e),this}addFermata(t="atNote"){return this.addFermataInternal(void 0,t)}addFermataTo(t,e="atNote"){return this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return ts(t),P(b.Is.isEnumValue(e,er),"navigation",e),e==="endRepeat"&&r.length>0?P(b.Is.isIntegerGte(r[0],1),"playCount",r[0]):e==="ending"&&r.length>0&&P(r.every(i=>b.Is.isIntegerGte(i,1)),"passages",r),this.getMeasure().addNavigation(t,e,...r),this}addNavigation(t,...e){return this.addNavigationInternal(void 0,t,...e)}addNavigationTo(t,e,...r){return this.addNavigationInternal(t,e,...r)}addAnnotationInternal(t,e,r){if(e!=null||(e=Qm(r)),e===void 0)throw new O(6,`Annotation text "${r}" is not known annotation.`);return ts(t),P(b.Is.isEnumValue(e,_n),"annotation",e),P(b.Is.isNonEmptyString(r),"text",r),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(...t){return t.length===1?this.addAnnotationInternal(void 0,void 0,t[0]):this.addAnnotationInternal(void 0,t[0],t[1])}addAnnotationTo(t,...e){return e.length===1?this.addAnnotationInternal(t,void 0,e[0]):this.addAnnotationInternal(t,e[0],e[1])}addLabelInternal(t,e,r){return ts(t),P(b.Is.isEnumValue(e,Co),"label",e),P(b.Is.isNonEmptyString(r),"text",r),this.getMeasure().addLabel(t,e,r),this}addLabel(t,e){return this.addLabelInternal(void 0,t,e)}addLabelTo(t,e,r){return this.addLabelInternal(t,e,r)}addConnective(t,...e){if(P(b.Is.isEnumValue(t,Qr),"connective",t),t==="tie"){P(b.Is.isIntegerOrUndefined(e[0])||b.Is.isEnumValue(e[0],$t),"tieSpan",e[0]),P(b.Is.isEnumValueOrUndefined(e[1],Pt),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t==="slur"){P(b.Is.isIntegerOrUndefined(e[0]),"slurSpan",e[0]),P(b.Is.isEnumValueOrUndefined(e[1],Pt),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t==="slide"){P(b.Is.isEnumValueOrUndefined(e[0],Pt),"noteAnchor",e[0]);let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t){P(b.Is.isFunctionOrUndefined(t),"addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.",t);let e=0,r=!0,i={notes:(o,s)=>(P(b.Is.isEnumValue(o,Xe)||$r(o),"noteLength",o),P(b.Is.isUndefined(s)||b.Is.isNumber(s)&&s>=0,"noteCount",s),e+=qe.get(o).ticks*(s!=null?s:1),i),measures:o=>(P(b.Is.isNumber(o)&&o>=1,"measureCount",o),e+=this.getMeasure().getMeasureTicks()*o,i),infinity:()=>(e=1/0,i),hide:()=>(r=!1,i)};return t?t(i):e=1/0,this.getMeasure().addExtension(e,r),this}addStaffGroup(t,e,r="auto"){return P(b.Is.isNonEmptyString(t),"groupName",t),P(b.Is.isNonEmptyString(e)||b.Is.isIntegerGte(e,0)||b.Is.isNonEmptyArray(e)&&e.every(i=>b.Is.isNonEmptyString(i)||b.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",e),P(b.Is.isEnumValue(r,bo),"verticalPosition",r),this.doc.addStaffGroup(t,e,r),this}endSong(){return this.getMeasure().endSong(),this}endSection(){return this.getMeasure().endSection(),this}endRow(){var t;return(t=this.doc.getLastMeasure())==null||t.endRow(),this}completeRests(t){return P(b.Is.isUndefined(t)||fr(t)||b.Is.isArray(t)&&t.every(e=>fr(e)),"voiceId",t),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){P(b.Is.isNonEmptyString(e),"bottomNote",e),P(b.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),o=t.getScaleNotes(e,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}};p(Ea,"DefaultMeasureOptions",{});var rr=Ea;var rs=class{constructor(t){this.type=t}},Ai=class extends rs{constructor(e,r,i,o){super(e);this.renderContext=r;this.scoreRow=i;this.diatonicId=o}get renderer(){return this.renderContext}},_i=class extends rs{constructor(e,r,i){super(e);this.renderContext=r;this.objects=i;if(arguments.length===0)throw new O(6,"Empty array in score object event!")}get renderer(){return this.renderContext}get topObject(){return this.objects[this.objects.length-1]}findObject(e){return this.objects.find(r=>e(r))}};function ka(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function nf(n){return b.Is.isNumber(n)&&Ve().indexOf(n)>=0}function zu(n){if(n instanceof Ne||n instanceof rt)return n.getMusicInterface();throw new O(6,"Notation line not staff nor tab.")}var pe=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},La=class La extends pe{constructor(e){super(La.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};p(La,"Name","Accidental");var _o=La,ja=class ja extends pe{constructor(e){super(ja.Name);this.obj=e}getMusicObject(){return this.obj}};p(ja,"Name","Connective");var Ho=ja,Pa=class Pa extends pe{constructor(e){super(Pa.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return zu(this.obj.line)}};p(Pa,"Name","Arpeggio");var To=Pa,Fa=class Fa extends pe{constructor(e){super(Fa.Name);this.obj=e}getMusicObject(){return this.obj}};p(Fa,"Name","BeamGroup");var Wo=Fa,Ba=class Ba extends pe{constructor(e){super(Ba.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};p(Ba,"Name","StaffBeamGroup");var Uo=Ba,Ga=class Ga extends pe{constructor(e){super(Ga.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}getRows(){return this.obj.getRows().map(e=>e.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}play(e){return ka(b.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),new Dn(this,e).play()}};p(Ga,"Name","Document");var Rr=Ga,Va=class Va extends pe{constructor(e){super(Va.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return ka(b.Is.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};p(Va,"Name","Ending");var Vo=Va,qa=class qa extends pe{constructor(e){super(qa.Name);this.obj=e}getMusicObject(){return this.obj}};p(qa,"Name","Fermata");var zo=qa,Wa=class Wa extends pe{constructor(e){super(Wa.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};p(Wa,"Name","Header");var es=Wa,Ua=class Ua extends pe{constructor(e){super(Ua.Name);this.obj=e}getMusicObject(){return this.obj}};p(Ua,"Name","Image");var Ao=Ua,za=class za extends pe{constructor(e){super(za.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};p(za,"Name","Measure");var Qo=za,Ya=class Ya extends pe{constructor(e){super(Ya.Name);this.obj=e}getMusicObject(){return this.obj}};p(Ya,"Name","BarLineRight");var Fo=Ya,Ha=class Ha extends pe{constructor(e){super(Ha.Name);this.obj=e}getMusicObject(){return this.obj}};p(Ha,"Name","BarLineLeft");var Bo=Ha,Za=class Za extends pe{constructor(e){super(Za.Name);this.obj=e}getMusicObject(){return this.obj}getBarLine(){let e=this.obj.barLine;if(e instanceof Kr||e instanceof Or)return e.getMusicInterface();throw new O(6,"Bar line not let nor right.")}getNotationLine(){return zu(this.obj.line)}};p(Za,"Name","StaffTabBarLine");var Go=Za,Xa=class Xa extends pe{constructor(e){super(Xa.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(Xa,"Name","NoteGroup");var Mo=Xa,Qa=class Qa extends pe{constructor(e){super(Qa.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};p(Qa,"Name","StaffNoteGroup");var Do=Qa,Ka=class Ka extends pe{constructor(e){super(Ka.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getTab(){return this.obj.tab.getMusicInterface()}};p(Ka,"Name","TabNoteGroup");var Eo=Ka,Ja=class Ja extends pe{constructor(e){super(Ja.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(Ja,"Name","Rest");var Oo=Ja,$a=class $a extends pe{constructor(e){super($a.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}getRhythmColumn(){return this.getRest().getRhythmColumn()}getMeasure(){return this.getRest().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};p($a,"Name","StaffRest");var Ro=$a,ec=class ec extends pe{constructor(e){super(ec.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return ka(nf(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getVoiceSymbol(e){var r;return ka(nf(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};p(ec,"Name","RhythmColumn");var ko=ec,tc=class tc extends pe{constructor(e){super(tc.Name);this.obj=e}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(e=>zu(e))}};p(tc,"Name","ScoreRow");var $o=tc,rc=class rc extends pe{constructor(e){super(rc.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};p(rc,"Name","Staff");var Ko=rc,ic=class ic extends pe{constructor(e){super(ic.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};p(ic,"Name","Tab");var Jo=ic,nc=class nc extends pe{constructor(e){super(nc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};p(nc,"Name","StaffSignature");var wo=nc,oc=class oc extends pe{constructor(e){super(oc.Name);this.obj=e}getMusicObject(){return this.obj}getTab(){return this.obj.tab.getMusicInterface()}};p(oc,"Name","TabSignature");var No=oc,sc=class sc extends pe{constructor(e){super(sc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasure(){return this.obj.measure.getMusicInterface()}getTab(){return this.obj.tab.getMusicInterface()}};p(sc,"Name","TabRhythm");var Xo=sc,ac=class ac extends pe{constructor(e){super(ac.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(ac,"Name","SpecialText");var Lo=ac,cc=class cc extends pe{constructor(e){super(cc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(cc,"Name","Text");var vo=cc,uc=class uc extends pe{constructor(e){super(uc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};p(uc,"Name","Lyrics");var Zo=uc,lc=class lc extends pe{constructor(e){super(lc.Name);this.obj=e}getMusicObject(){return this.obj}};p(lc,"Name","ExtensionLine");var Yo=lc;function ir(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function is(n,t){if(n==null)throw new TypeError(t);return n}var ns=class ns{constructor(t,e){p(this,"player");ir(t instanceof Rr,"doc",t),ir(b.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new Aa,this.player.setDocument(t.getMusicObject()),this.player.setCursorPositionChangeListener(r=>t.getMusicObject().updateCursorRect(r)),e&&this.player.setPlayStateChnageListener(e)}static stopAll(){this.currentlyPlaying.forEach(t=>t.stop()),ua()}play(){return ns.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),ns.currentlyPlaying.delete(this),this}};p(ns,"currentlyPlaying",new Set);var Dn=ns,hc=class{constructor(){p(this,"ctx");this.ctx=new ma(this)}setDocument(t){return ir(b.Is.isUndefined(t)||t instanceof Rr,"doc",t),this.ctx.setDocument(t),this}setCanvas(t){return t=is(b.Dom.getCanvas(t),typeof t=="string"?"Cannot set render canvas because invalid canvas id: "+t:"Cannot set render canvas because given canvas is undefined."),this.ctx.setCanvas(t),this}setScoreEventListener(t){ir(b.Is.isFunctionOrUndefined(t),"scoreEventListener",t),this.ctx.setScoreEventListener(t)}hilightObject(t){this.ctx.hilightObject(t==null?void 0:t.getMusicObject())}hilightStaffPos(t){this.ctx.hilightStaffPos(t?{scoreRow:t.scoreRow.getMusicObject(),diatonicId:t.diatonicId}:void 0)}draw(){try{this.ctx.draw()}catch(t){console.log("Draw failed in music render context!",t)}}},Yu=class extends hc{},mt=class mt{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 t;return(t=this.player)==null?void 0:t.play()},this.onStop=()=>{var t;return(t=this.player)==null?void 0:t.stop()},this.onPlayStop=()=>{var t,e;this.playState===0?(t=this.player)==null||t.stop():(e=this.player)==null||e.play()},this.onPause=()=>{var t;return(t=this.player)==null?void 0:t.pause()},this.updateButtons()}setDocument(t){return ir(b.Is.isUndefined(t)||t instanceof Rr,"doc",t),this.onStop(),t?this.player=new Dn(t,e=>{this.playState=e,this.updateButtons()}):this.player=void 0,this.updateButtons(),this}detachDocument(){this.setDocument(void 0)}updateButtons(){this.playButton&&(this.playButton.disabled=this.player?this.playState===0:!0,this.playButton.innerText=this.playLabel),this.stopButton&&(this.stopButton.disabled=this.player?this.playState===2:!0,this.stopButton.innerText=this.stopLabel),this.playStopButton&&(this.playStopButton.disabled=!this.player,this.playStopButton.innerText=this.playState===0?this.stopLabel:this.playLabel),this.pauseButton&&(this.pauseButton.disabled=this.player?this.playState!==0:!0,this.pauseButton.innerText=this.pauseLabel)}setPlayButton(t,e){return ir(b.Is.isStringOrUndefined(e),"btnLabel",e),mt.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=is(b.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",mt.removeOnClickListeners(this.playButton,"all"),mt.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return ir(b.Is.isStringOrUndefined(e),"btnLabel",e),mt.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=is(b.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",mt.removeOnClickListeners(this.stopButton,"all"),mt.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return ir(b.Is.isStringOrUndefined(e),"playLabel",e),ir(b.Is.isStringOrUndefined(r),"stopLabel",r),mt.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=is(b.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",mt.removeOnClickListeners(this.playStopButton,"all"),mt.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return ir(b.Is.isStringOrUndefined(e),"btnLabel",e),mt.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=is(b.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",mt.removeOnClickListeners(this.pauseButton,"all"),mt.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(t){let r=this.savedOnClickListeners.get(t)||[],i=[];r.forEach(o=>{e===o||e==="all"?t.removeEventListener("click",o):i.push(o)}),this.savedOnClickListeners.set(t,i)}}static addOnClickListener(t,e){ir(b.Is.isFunction(e),"onClick",e),t.addEventListener("click",e);let r=this.savedOnClickListeners.get(t)||[];this.savedOnClickListeners.set(t,[...r,e])}};p(mt,"savedOnClickListeners",new Map);var Hu=mt;ri();var Xu={};Mi(Xu,{createAndanteByDiabelli:()=>xC,createCanonInD:()=>gC,createFrereJacques:()=>bC,createGreensleeves:()=>yC});function gC(){return new rr().setHeader("Canon in D","Pachelbel").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0,instrument:"Piano"},{type:"staff",clef:"F",voiceId:1,instrument:"Piano"}]).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").setTempo(50,"2n").completeRests(0).addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).completeRests(0).addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().completeRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).completeRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["F#5","E5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","C#5"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().addNote(0,["B4","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addNote(0,["B4","C#5"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addChord(0,["F#5","D5"],"2n").addChord(0,["E5","C#5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).addChord(0,["D5","B4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").endRow().addMeasure({showNumber:!1}).addChord(0,["B4","G4"],"2n").addChord(0,["A4","F#4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addChord(0,["B4","G4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["D4","F#4","A4","G4"],"4n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","D4","F#4","E4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","D4","A4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","B4","A4","G4"],"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["F#4","D4","E4","C#5"],"4n").addNote(1,["D3","A2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","F#5","A5","A4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B4","G4","A4","F#4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5"],"4n").addRest(0,"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D5","C#5","D5","D4"],"8n").addNote(0,["C#4","A4","E4","F#4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5","B4"],"8n").addNote(0,["C#5","F#5","A5","B5"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["G5","F#5","E5","G5"],"8n").addNote(0,["F#5","E5","D5","C#5"],"8n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["B4","A4","G4","F#4"],"8n").addNote(0,["E4","G4","F#4","E4"],"8n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D4","E4","F#4","G4"],"8n").addNote(0,["A4","E4","A4","G4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","B4","A4","G4"],"8n").addNote(0,["A4","G4","F#4","E4"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","B4","C#5"],"8n").addNote(0,["D5","C#5","B4","A4"],"8n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","F#4","E4","B4"],"8n").addNote(0,["A4","B4","A4","G4"],"8n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"F#4","4n").addNote(0,"F#5","4n").addNote(0,"E5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(0,"F#5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B5","A5"],"2n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["B5","C#6"],"2n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D6","D5"],"4n").addNote(0,"C#5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"B4","4n").addNote(0,"D5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"D5","2n").addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","F#5","E5","A5"],"4n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,["A5","A4","B4","C#5"],"16n").addNote(0,["D5","E5","F#5","G5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["F#4","G4"],"16n").addNote(0,["A4","B4","A4","G4"],"16n").addNote(0,["A4","F#4","G4","A4"],"16n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"G4","8n").addNote(0,["F#4","E4"],"16n").addNote(0,["F#4","E4","D4","E4"],"16n").addNote(0,["F#4","G4","A4","B4"],"16n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"B4","8n").addNote(0,["C#5","D5"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(0,["E5","F#5","G5","A5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["E5","D5"],"16n").addNote(0,["E5","C#5","D5","E5"],"16n").addNote(0,["F#5","E5","D5","C#5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"D5","8n").addNote(0,["B4","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["D4","E4"],"16n").addNote(0,["F#4","G4","F#4","E4"],"16n").addNote(0,["F#4","D5","C#5","D5"],"16n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"B4","8n").addNote(0,["A4","G4"],"16n").addNote(0,["A4","G4","F#4","G4"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["C#5","B4"],"16n").addNote(0,["C#5","D5","E5","D5"],"16n").addNote(0,["C#5","D5","B4","C#5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNavigation("startRepeat").addNote(0,"D5","4.").addNote(0,"A5","8n").addNote(0,["A5","B5","A5","G5"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","4.").addNote(0,"F#5","8n").addNote(0,["F#5","G5","F#5","E5"],"8n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"D5","4.").addNote(0,"D5","8n").addNote(0,["D5","A5"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","C5","B5","C5"],"8n").addNote(0,"C#5","2n").addNote(1,["G2","A2"],"2n").addNavigation("endRepeat").addMeasure().addNote(0,"D5","1n").addNote(1,"D3","1n").getDocument()}function bC(){return new rr().setHeader("Fr\xE8re Jacques","Traditional").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0},{type:"staff",clef:"F",voiceId: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 yC(){return new rr().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 xC(){return new rr().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 pf(CC);})();
|
|
209
|
+
`;Ra(Df,j_);var pi=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(L.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var irt=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var lrt=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var La=class i extends Me{constructor(){let t=w(i.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Vt(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Vt(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Me.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Vt(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Vt(t,0),this._preDelay=t,this.generate()}generate(){return mt(this,void 0,void 0,function*(){let t=this.ready,e=new lr(2,this._decay+this._preDelay,this.context.sampleRate),r=new ji({context:e}),n=new ji({context:e}),o=new pi({context:e});r.connect(o,0,0),n.connect(o,0,1);let s=new $({context:e}).toDestination();o.connect(s),r.start(0),n.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=e.render();return this.ready=a.then(nt),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var Fn=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new $({context:this.context}),i._allSolos.has(this.context)||i._allSolos.set(this.context,new Set),i._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(L.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),i._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){i._soloed.has(this.context)||i._soloed.set(this.context,new Set),i._soloed.get(this.context).add(this)}_removeSolo(){i._soloed.has(this.context)&&i._soloed.get(this.context).delete(this)}_isSoloed(){return i._soloed.has(this.context)&&i._soloed.get(this.context).has(this)}_noSolos(){return!i._soloed.has(this.context)||i._soloed.has(this.context)&&i._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),i._allSolos.get(this.context).delete(this),this._removeSolo(),this}};Fn._allSolos=new Map;Fn._soloed=new Map;var ja=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new jo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Xe({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,U(this,["pan","volume"])}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var dh=class i extends L{constructor(){let t=w(i.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new Fn({solo:t.solo,context:this.context}),this._panVol=this.output=new ja({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),U(this,["pan","volume"])}static getDefaults(){return Object.assign(L.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return i.buses.has(t)||i.buses.set(t,new $({context:this.context})),i.buses.get(t)}send(t,e=0){let r=this._getBus(t),n=new $({context:this.context,units:"decibels",gain:e});return this.connect(n),n.connect(r),n}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};dh.buses=new Map;var Qst=Ht().transport;var Kst=Ht().destination,Jst=Ht().destination;var tat=Ht().listener;var eat=Ht().draw;var rat=Ht();var ph=class{constructor(){d(this,"audioSource");try{let t=new La({decay:3,wet:.4}).toDestination(),e=new Ur(800,"lowpass").connect(t);this.audioSource=new Ma(Rr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(e)}catch(t){this.audioSource=void 0,console.error(t)}}getName(){return"Synthesizer"}playNote(t,e,r){try{this.audioSource&&(this.audioSource.volume.value=Zs(r),this.audioSource.triggerAttackRelease(t,e))}catch(n){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},mh=new ph;Ci();function U_(i){return typeof i=="string"?i:(typeof i=="number"&&(i=W.getChromaticNote(i)),i.format(0,0))}var Pa=[mh],Bn=mh,z_=(function(t,e,r){var o;let n=parseInt((o=r.split("/")[1])!=null?o:"4");return 60*(1/t)/(e*(1/n))})(2,80,"4/4"),Y_=1,Fa=!1;function H_(){return Pa.map(i=>i.getName())}function Z_(){return Bn.getName()}function X_(i){(y.isArray(i)?i:[i]).forEach(t=>{if(!H.Obj.hasProperties(t,["getName","playNote","stop"])||!y.isFunction(t.getName)||!y.isFunction(t.playNote)||!y.isFunction(t.stop))throw new N(7,"Invalid instrument object: "+t);Pa.some(e=>e.getName()===t.getName())?console.warn(`Instrument "${t.getName()}" already added!`):Pa.push(t),Lf(t.getName())})}function Lf(i){if(i===Bn.getName())return;Bn.stop();let t=Pa.find(e=>e.getName()===i);t&&(Bn=t)}function Ba(i,t,e){Fa||Bn.playNote(U_(i),t!=null?t:z_,e!=null?e:Y_)}function Ga(){Bn.stop()}function $_(){Ga(),Fa=!0}function Q_(){Fa=!1}function K_(){return Fa}var Rh={};$i(Rh,{Annotation:()=>qn,Arpeggio:()=>mi,Clef:()=>Bi,Connective:()=>fi,DivRect:()=>fh,DocumentBuilder:()=>br,DynamicsAnnotation:()=>Wn,Fermata:()=>qo,Label:()=>Wo,LyricsAlign:()=>Vo,LyricsHyphen:()=>Vn,MAccidental:()=>zo,MArpeggio:()=>Qo,MBarLineLeft:()=>cs,MBarLineRight:()=>as,MBeamGroup:()=>ds,MConnective:()=>gs,MDocument:()=>Hr,MEnding:()=>hs,MExtensionLine:()=>fs,MFermata:()=>ms,MHeader:()=>vs,MImage:()=>Uo,MLyrics:()=>ys,MMeasure:()=>xs,MNoteGroup:()=>ts,MPlaybackButtons:()=>Oh,MPlayer:()=>Kn,MRenderContext:()=>Vc,MRenderer:()=>Th,MRest:()=>Ko,MRhythmColumn:()=>is,MScoreRow:()=>_s,MSpecialText:()=>ns,MStaff:()=>As,MStaffBeamGroup:()=>ps,MStaffNoteGroup:()=>es,MStaffRest:()=>Jo,MStaffSignature:()=>Xo,MStaffTabBarLine:()=>us,MTab:()=>Cs,MTabNoteGroup:()=>rs,MTabRhythm:()=>bs,MTabSignature:()=>$o,MText:()=>Yo,MusicInterface:()=>At,Navigation:()=>gr,NoteAnchor:()=>$e,PlayState:()=>Wa,ScoreEvent:()=>Ss,ScoreObjectEvent:()=>Vi,ScoreStaffPosEvent:()=>Gi,StaffPreset:()=>Gn,Stem:()=>mr,TempoAnnotation:()=>Un,TieType:()=>fr,VerticalPosition:()=>Go,getStringNumbers:()=>Va,getVerseNumbers:()=>jf,getVoiceIds:()=>ne,isStringNumber:()=>Bo,isVerseNumber:()=>qa,isVoiceId:()=>ye,validateStringNumber:()=>J_,validateVerseNumber:()=>tv,validateVoiceId:()=>Fo});var fh=class i{constructor(...t){d(this,"left");d(this,"anchorX");d(this,"right");d(this,"top");d(this,"anchorY");d(this,"bottom");if(t.length===6)this.left=t[0],this.anchorX=t[1],this.right=t[2],this.top=t[3],this.anchorY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.anchorX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.anchorY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.anchorX=this.right=0,this.top=this.anchorY=this.bottom=0;else throw new TypeError(`Invalid DivRect args: ${t}`)}static create(t,e,r,n){return new i(t,t+r,e,e+n)}static createCentered(t,e,r,n){return new i(t-r/2,t,t+r/2,e-n/2,e,e+n/2)}static createSections(t,e,r,n){return new i(-t,0,e,-r,0,n)}get centerX(){return this.anchorX}set centerX(t){this.anchorX=t}get centerY(){return this.anchorY}set centerY(t){this.anchorY=t}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.anchorX-this.left}get rightw(){return this.right-this.anchorX}get toph(){return this.anchorY-this.top}get bottomh(){return this.bottom-this.anchorY}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.anchorX===e.anchorX&&t.right===e.right&&t.top===e.top&&t.anchorY===e.anchorY&&t.bottom===e.bottom}equals(t){return i.equals(this,t)}static equalsEdges(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}equalsEdges(t){return i.equalsEdges(this,t)}static equalsFrame(t,e){return i.equalsEdges(t,e)}copy(){return new i(this.left,this.anchorX,this.right,this.top,this.anchorY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.anchorX+=t,this.right+=t,this.top+=e,this.anchorY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.copy().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.copy().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.anchorX=H.Math.clamp(this.anchorX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.anchorY=H.Math.clamp(this.anchorY,this.top,this.bottom),this}clipCopy(t){return this.copy().clipInPlace(t)}scaleInPlace(t,e){return e=e!=null?e:t,this.left=this.anchorX-this.leftw*t,this.right=this.anchorX+this.rightw*t,this.top=this.anchorY-this.toph*e,this.bottom=this.anchorY+this.bottomh*e,this}scaleCopy(t,e){return this.copy().scaleInPlace(t,e)}getRect(){return this}};var Gn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(Gn||{}),Bi=(e=>(e.G="G",e.F="F",e))(Bi||{});function ne(){return[0,1,2,3]}function ye(i){return y.isIncluded(i,ne())}function Fo(i){if(ye(i))return i;throw new N(6,`Voice id ${i} is invalid!`)}function Va(){return[1,2,3,4,5,6]}function Bo(i){return y.isIncluded(i,Va())}function J_(i){if(Bo(i))return i;throw new N(6,`String number ${i} is invalid!`)}function jf(){return[1,2,3]}function qa(i){return y.isIncluded(i,jf())}function tv(i){if(qa(i))return i;throw new N(6,`Verse number ${i} is invalid!`)}var mr=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(mr||{}),mi=(e=>(e.Up="up",e.Down="down",e))(mi||{}),fr=(e=>(e.Stub="stub",e.ToMeasureEnd="toMeasureEnd",e))(fr||{}),$e=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))($e||{}),fi=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(fi||{}),Go=(n=>(n.Auto="auto",n.Above="above",n.Below="below",n.Both="both",n))(Go||{}),Vo=(r=>(r.Left="left",r.Center="center",r.Right="right",r))(Vo||{}),Vn=(e=>(e.Hyphen="-",e.Extender="---",e))(Vn||{}),qo=(e=>(e.AtNote="atNote",e.AtMeasureEnd="atMeasureEnd",e))(qo||{}),gr=(l=>(l.DC_al_Fine="D.C. al Fine",l.DC_al_Coda="D.C. al Coda",l.DS_al_Fine="D.S. al Fine",l.DS_al_Coda="D.S. al Coda",l.Coda="Coda",l.toCoda="toCoda",l.Segno="Segno",l.Fine="Fine",l.StartRepeat="startRepeat",l.EndRepeat="endRepeat",l.Ending="ending",l))(gr||{}),qn=(e=>(e.Dynamics="dynamics",e.Tempo="tempo",e))(qn||{}),Wn=(p=>(p.cresc="cresc.",p.decresc="decresc.",p.dim="dim.",p.ppp="ppp",p.pp="pp",p.p="p",p.mp="mp",p.m="m",p.mf="mf",p.f="f",p.ff="ff",p.fff="fff",p))(Wn||{}),Un=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(Un||{}),Wo=(e=>(e.Note="note",e.Chord="chord",e))(Wo||{}),Wa=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(Wa||{});var Ua=class{constructor(t){d(this,"head");d(this,"tail");this.head=t,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(t){this.tail.push(t)}detachTail(t){let e=this.tail.indexOf(t);e>=0&&this.tail.splice(e,1)}},rt=class{constructor(t){this.parent=t;d(this,"anchoredLayoutObjects",[]);d(this,"link");d(this,"rect",new G);d(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(t){this.anchoredLayoutObjects.push(t)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(t){this.link=t}getLink(){return this.link}isLinked(){return this.link!==null}};var Pf={DrawDebugRects:!1,DisableBeams:!1},at={DocumentScale:1,DocumentMinWidth:75,MinColumnsWidth:10,ColumnWidthScale:1.7,PostMeasureBreakWidth:10,NoteDotSpace:.5,NoteAccSpace:.5,NoteHeadWidth:2,NoteHeadHeight:1.3,DiamondNoteHeadSize:1.8,DotSize:.8,StemHeight:7,FlagWidth:1.5,FlagHeight:4,FlagSeparation:2,BeamSeparation:1.25,BeamAngleFactor:.5,BeamThickness:4,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var Ff="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 Bf="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 ev="#55cc55",rv="#55cc55",iv="#44aa44",gh=new yt([[0,{src:Bf}],[1,{src:Ff}]]);function nv(i,t){return!i&&!t?!0:!i||!t?!1:i.scoreRow===t.scoreRow&&i.diatonicId===t.diatonicId}function ov(i,t){return!i&&!t?!0:!i||!t?!1:i.length===t.length&&i.every((e,r)=>e===t[r])}var za=class{constructor(t){this.mi=t;d(this,"devicePixelRatio");d(this,"fontSize");d(this,"unitSize");d(this,"_lineWidth");d(this,"scoreEventListener");d(this,"canvas");d(this,"ctx");d(this,"mdoc");d(this,"cursorRect");d(this,"mousePos");d(this,"curStaffPos");d(this,"curObjects");d(this,"hilightedStaffPos");d(this,"hilightedObj");d(this,"usingTouch",!1);d(this,"onClickFn");d(this,"onMouseMoveFn");d(this,"onMouseLeaveFn");d(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=js.FontSize*at.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this._lineWidth=this.unitSize*.2,gh.forEach(e=>{if(e.finished!==!0){let r=new Image;r.src=e.src,r.onload=()=>{e.img=r,this.finishImageAsset(e)},r.onerror=()=>{throw this.finishImageAsset(e),new N(6,"Failed to load image: "+e.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 t;return(t=this.mdoc)==null?void 0:t.getMusicObject()}finishImageAsset(t){t.finished=!0,gh.every(r=>r.finished===!0)&&this.onLoad()}getImageAsset(t){var e;return(e=gh.get(t))==null?void 0:e.img}setDocument(t){if(this.mdoc===t)return;this.updateCursorRect(void 0);let e=this.mdoc;this.mdoc=t,e&&e.getMusicObject().setRenderContext(void 0),t&&t.getMusicObject().setRenderContext(this)}setCanvas(t){var e,r;this.canvas!==t&&(this.canvas&&(this.canvas.removeEventListener("click",this.onClickFn),this.canvas.removeEventListener("mousemove",this.onMouseMoveFn),this.canvas.removeEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.removeEventListener("touchend",this.onTouchEndFn)),this.canvas=t,this.canvas.addEventListener("click",this.onClickFn),this.canvas.addEventListener("mousemove",this.onMouseMoveFn),this.canvas.addEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.addEventListener("touchend",this.onTouchEndFn),this.canvas.style.position="relative"),this.ctx=(r=(e=this.canvas)==null?void 0:e.getContext("2d"))!=null?r:void 0}setScoreEventListener(t){this.scoreEventListener=t}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(t){return new tl(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!nv(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new Gi("leave",this.getMusicInterface(),n.getMusicInterface(),o))}if(r&&t&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=t;this.scoreEventListener(new Gi("enter",this.getMusicInterface(),n.getMusicInterface(),o))}if(e&&t&&this.scoreEventListener){let{scoreRow:n,diatonicId:o}=t;this.scoreEventListener(new Gi("click",this.getMusicInterface(),n.getMusicInterface(),o))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!ov(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new Vi("leave",this.getMusicInterface(),this.curObjects.map(n=>n.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Vi("enter",this.getMusicInterface(),t.map(n=>n.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Vi("click",this.getMusicInterface(),t.map(n=>n.getMusicInterface()))),this.curObjects=t,r}onClick(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),this.scoreEventListener)){let r=e.pick(this.mousePos.x,this.mousePos.y),n=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(n,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),!this.usingTouch)){let r=e.pick(this.mousePos.x,this.mousePos.y),n=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(n,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(t){if(!this.needMouseInput())return;this.mousePos=void 0;let e=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(e||r)&&this.draw()}onTouchEnd(t){this.usingTouch=!0}onLoad(){this.doc&&(this.doc.requestFullLayout(),this.draw())}hilightObject(t){this.hilightedObj=t}hilightStaffPos(t){this.hilightedStaffPos=t}updateCursorRect(t){this.cursorRect=t,this.draw()}updateCanvasSize(){let{canvas:t,doc:e}=this;if(t&&e){let r=e.getRect(),n=r.width+1,o=r.height+1;t.width=n,t.height=o,t.style.width=n/this.devicePixelRatio+"px",t.style.height=o/this.devicePixelRatio+"px"}}draw(){try{let{doc:t}=this;t&&(t.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),t.drawContent())}catch(t){console.error("Render failed!",t)}}drawHilightStaffPosRect(){let{mousePos:t,hilightedStaffPos:e,unitSize:r}=this;if(!e)return;let{scoreRow:n,diatonicId:o}=e,s=n.getStaff(o);s&&(this.fillColor(ev),this.fillRect(s.row.getRect().left,s.getDiatonicIdY(o)-r,s.row.getRect().width,2*r),t!==void 0&&this.drawLedgerLines(s,o,t.x))}drawHilightObjectRect(){let{hilightedObj:t}=this;if(!t)return;let e=t.getRect();this.lineColor(rv),this.strokeRect(e.left,e.top,e.width,e.height)}drawPlayCursor(){let{cursorRect:t}=this;t&&this.color(iv).lineWidth(2).strokeLine(t.centerX,t.top,t.centerX,t.bottom)}txFromScreenCoord(t){return t.mul(this.devicePixelRatio)}txToScreenCoord(t){return t.div(this.devicePixelRatio)}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height)}drawDebugRect(t){Pf.DrawDebugRects&&this.color("red").lineWidth(1).strokeRect(t.left,t.top,t.width,t.height)}drawLedgerLines(t,e,r){let{unitSize:n}=this,o=n*at.LedgerLineWidth;if(e>=t.topLineDiatonicId+2){for(let s=t.topLineDiatonicId+2;s<=e;s+=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}else if(e<=t.bottomLineDiatonicId-2){for(let s=t.bottomLineDiatonicId-2;s>=e;s-=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.strokeLine(r-o/2,a,r+o/2,a)}}}getRestRect(t){let{unitSize:e}=this,{flagCount:r}=Tt.get(Lr(t+"n")),n=0,o=0,s=0,a=0;if(Tt.equals(t,"1n"))n=e,o=e,s=0,a=e;else if(Tt.equals(t,"2n"))n=e,o=e,s=e,a=0;else if(Tt.equals(t,"4n"))n=e*1,o=e*1,s=e*3.2,a=e*3;else{let c=1-r%2;n=e*(1+r*.25),o=e*(1+r*.125),s=e*(.5+r-c),a=e*(1+r+c)}return new G(-n,0,o,-s,0,a)}drawRest(t,e,r){let{unitSize:n}=this,{flagCount:o}=Tt.get(Lr(t+"n"));if(Tt.equals(t,"1n"))this.fillRect(e-n,r,n*2,n);else if(Tt.equals(t,"2n"))this.fillRect(e-n,r-n,n*2,n);else if(Tt.equals(t,"4n"))this.beginPath(),this.moveTo(e-n*.6,r-n*3.2),this.lineTo(e+n*.7,r-n*1.5),this.quadraticCurveTo(e-n*.8,r-n*.5,e+n*1,r+n*1.5),this.lineTo(e-n*1,r-n*.75),this.quadraticCurveTo(e+n*.2,r-n*1.5,e-n*.6,r-n*3.2),this.moveTo(e+n*1,r+n*1.5),this.quadraticCurveTo(e-n*.8,r+n*1,e-n*.2,r+n*2.8),this.bezierCurveTo(e-n*1.8,r+n*1.5,e-n*.6,r-n*.2,e+n*.9,r+n*1.5),this.fill(),this.stroke();else if(o>0){let s=1-o%2,a=u=>e+(-u*.25+.5)*n,c=u=>r+(u+s)*n;this.beginPath(),this.moveTo(a(1+o),c(1+o)),this.lineTo(a(-.5-o),c(-.5-o)),this.stroke();for(let u=0;u<o;u++){let h=o-u*2;this.beginPath(),this.moveTo(a(h-2.5),c(h-2.5)),this.quadraticCurveTo(a(h-.5)+n*.25,c(h-1.5),a(h-1.5)-n*1.5,c(h-1.5)),this.stroke(),this.beginPath(),this.arc(a(h-2)-n*1.5,c(h-2),n*.5,0,Math.PI*2),this.fill()}}}drawFlag(t,e){let r=t.left,o=t.right-r,s=e==="up"?t.top:t.bottom,a=e==="up"?t.bottom:t.top;this.beginPath(),this.moveTo(r,s),this.bezierCurveTo(r,s*.75+a*.25,r+o*1.5,s*.5+a*.5,r+o*.5,a),this.stroke()}color(t){return this.ctx&&(this.ctx.strokeStyle=this.ctx.fillStyle=t),this}lineColor(t){return this.ctx&&(this.ctx.strokeStyle=t),this}fillColor(t){return this.ctx&&(this.ctx.fillStyle=t),this}lineWidth(t){return this.ctx&&(this.ctx.lineWidth=this._lineWidth*(t!=null?t:1)),this}font(t){return this.ctx&&(this.ctx.font=t),this}beginPath(){return this.ctx&&this.ctx.beginPath(),this}stroke(){return this.ctx&&this.ctx.stroke(),this}fill(){return this.ctx&&this.ctx.fill(),this}moveTo(t,e){return this.ctx&&this.ctx.moveTo(t,e),this}lineTo(t,e){return this.ctx&&this.ctx.lineTo(t,e),this}bezierCurveTo(t,e,r,n,o,s){return this.ctx&&this.ctx.bezierCurveTo(t,e,r,n,o,s),this}quadraticCurveTo(t,e,r,n){return this.ctx&&this.ctx.quadraticCurveTo(t,e,r,n),this}fillRect(t,e,r,n){return this.ctx&&this.ctx.fillRect(t,e,r,n),this}setLineDash(t){return this.ctx&&this.ctx.setLineDash(t),this}drawImage(t,e,r,n,o){return this.ctx&&this.ctx.drawImage(t,e,r,n,o),this}ellipse(t,e,r,n,o,s,a){return this.ctx&&this.ctx.ellipse(t,e,r,n,o,s,a),this}clip(){return this.ctx&&this.ctx.clip(),this}save(){return this.ctx&&this.ctx.save(),this}restore(){return this.ctx&&this.ctx.restore(),this}rect(t,e,r,n){return this.ctx&&this.ctx.rect(t,e,r,n),this}scale(t,e){return this.ctx&&this.ctx.scale(t,e),this}strokeRect(t,e,r,n){return this.ctx&&this.ctx.strokeRect(t,e,r,n),this}fillText(t,e,r){return this.ctx&&this.ctx.fillText(t,e,r),this}getTextWidth(t,e){if(this.ctx){let r=this.ctx.font;this.ctx.font=e;let n=this.ctx.measureText(t);return this.ctx.font=r,n.width}else return H.Dom.getCanvasTextWidth(t,e)}arc(t,e,r,n,o){var s;(s=this.ctx)==null||s.arc(t,e,r,n,o)}fillCircle(t,e,r){this.ctx&&(this.ctx.beginPath(),this.ctx.arc(t,e,r,0,2*Math.PI),this.ctx.fill())}strokeLine(t,e,r,n){this.ctx&&(this.ctx.beginPath(),this.ctx.moveTo(t,e),this.ctx.lineTo(r,n),this.ctx.stroke())}strokePartialLine(t,e,r,n,o,s){let a=t+(r-t)*o,c=e+(n-e)*o,u=t+(r-t)*s,h=e+(n-e)*s;this.ctx&&(this.ctx.beginPath(),this.ctx.moveTo(a,c),this.ctx.lineTo(u,h),this.ctx.stroke())}drawBrace(t,e){if(this.ctx){let{left:r,right:n,width:o,top:s,bottom:a,anchorY:c}=t;e==="right"&&([r,n,o]=[n,r,-o]),this.ctx.beginPath(),this.ctx.moveTo(n,s),this.ctx.bezierCurveTo(r+o*.1,s,r+o*.8,c,r,c),this.ctx.moveTo(n,a),this.ctx.bezierCurveTo(r+o*.1,a,r+o*.8,c,r,c),this.ctx.stroke()}}};var Ya=class{constructor(t){this.measure=t;d(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(n=>n.diatonicClass===W.getDiatonicClass(t));return r?r.accidental:void 0}setAccidental(t){this.accidentalByDiatonicId[t.diatonicId]=t.accidental}needAccidental(t){var r,n;let e=(n=(r=this.accidentalByDiatonicId[t.diatonicId])!=null?r:this.getAccidentalFromKeySignature(t.diatonicId))!=null?n:0;return t.accidental!==e}};var Ha=class extends rt{constructor(e,r,n,o,s){super(e);this.image=r;this.anchorX=n;this.anchorY=o;this.imageScale=s;d(this,"mi");this.mi=new Uo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:n,image:o,imageScale:s}=this,{unitSize:a}=e;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=G.createSections(c*r,c*(1-r),u*n,u*(1-n))}catch(c){this.rect=new G}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=this.rect;e.drawDebugRect(r),e.drawImage(this.image,r.anchorX-r.leftw,r.anchorY-r.toph,r.width,r.height)}};var qi=class extends rt{constructor(e,r,n,o="black"){super(e);this.diatonicId=r;this.accidental=n;this.color=o;d(this,"mi");this.mi=new zo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;switch(this.accidental){case-2:this.rect=G.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=G.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=G.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=G.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=G.createSections(r*1,r*1,r*1,r*1);break;default:throw new N(6,"Invalid accidental value: "+this.accidental)}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect);let{unitSize:r}=e,{accidental:n}=this,o=this.rect.anchorX,s=this.rect.anchorY;e.color(this.color);let a=(c,u)=>{e.lineWidth(1).beginPath().moveTo(c-r*.75,u-r*4).lineTo(c-r*.75,u+r*1.1).bezierCurveTo(c+r*.75,u-r*0,c+r*.75,u-r*2.2,c-r*.75,u-r*.5).stroke()};n===-2?(a(o-r*.5,s),a(o+r*.5,s)):n===-1&&a(o,s),n===0?e.beginPath().lineWidth(1).moveTo(o-r*.5,s-r*2.2).lineTo(o-r*.5,s+r*1).moveTo(o+r*.5,s+r*2.2).lineTo(o+r*.5,s-r*1).stroke().beginPath().lineWidth(2).moveTo(o-r*.5,s+r*1).lineTo(o+r*.5,s+r*.6).moveTo(o+r*.5,s-r*1).lineTo(o-r*.5,s-r*.6).stroke():n===1?e.lineWidth(1).beginPath().moveTo(o-r*.3,s-r*1.6).lineTo(o-r*.3,s+r*2).moveTo(o+r*.3,s-r*2).lineTo(o+r*.3,s+r*1.6).stroke().lineWidth(2).beginPath().moveTo(o-r*.75,s-r*.5).lineTo(o+r*.75,s-r*.9).moveTo(o-r*.75,s+r*.9).lineTo(o+r*.75,s+r*.5).stroke():n===2&&e.lineWidth(1).beginPath().moveTo(o-r*.75,s-r*.75).lineTo(o+r*.75,s+r*.75).moveTo(o-r*.75,s+r*.75).lineTo(o+r*.75,s-r*.75).stroke().fillRect(o-r*1,s-r*1,r*.7,r*.7).fillRect(o+r*.3,s-r*1,r*.7,r*.7).fillRect(o-r*1,s+r*.3,r*.7,r*.7).fillRect(o+r*.3,s+r*.3,r*.7,r*.7)}};var sv=.5,st=class extends rt{constructor(e,r,n,o){var a,c,u,h,l,p;super(e);this.anchorX=n;this.anchorY=o;d(this,"text");d(this,"scale");d(this,"color");d(this,"bold");d(this,"italic");d(this,"boxed");d(this,"padding");d(this,"bgcolor");d(this,"font","");d(this,"textLines");d(this,"lineWidths",[]);d(this,"lineHeight",0);d(this,"mi");let s=typeof r=="string"?{text:r}:r;this.text=s.text,this.scale=(a=s.scale)!=null?a:1,this.color=(c=s.color)!=null?c:"black",this.bold=(u=s.bold)!=null?u:!1,this.italic=(h=s.italic)!=null?h:!1,this.boxed=(l=s.boxed)!=null?l:!1,this.padding=(p=s.padding)!=null?p:this.boxed?sv: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 G,this.mi=new Yo(this)}getMusicInterface(){return this.mi}getText(){return this.text}updateAnchorX(e){this.anchorX=e;let{width:r}=this.rect;this.rect.left=this.rect.anchorX-r*e,this.rect.right=this.rect.anchorX+r*(1-e)}updateAnchorY(e){this.anchorY=e;let{height:r}=this.rect;this.rect.top=this.rect.anchorY-r*e,this.rect.bottom=this.rect.anchorY+r*(1-e)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{scale:r,anchorX:n,anchorY:o,bold:s,italic:a}=this,c=e.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(p=>e.getTextWidth(p,this.font)),this.lineHeight=c;let u=this.padding*e.unitSize,h=u+Math.max(...this.lineWidths)+u,l=u+this.lineHeight*this.textLines.length+u;(this.boxed==="square"||this.boxed==="circle")&&(l=h=Math.max(l,h)),this.rect=G.createSections(h*n,h*(1-n),l*o,l*(1-o))}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){var b;e.drawDebugRect(this.rect),e.lineWidth(1).font(this.font);let{rect:r,padding:n,lineHeight:o,lineWidths:s,anchorX:a,anchorY:c,italic:u}=this;this.bgcolor!==void 0&&(e.save(),e.fillColor((b=this.bgcolor)!=null?b:"black"),e.beginPath(),e.fillRect(r.left,r.top,r.width,r.height),e.fill(),e.restore());let l=this.textLines.length*o,p=-o*(u?.25:.2),m=n*e.unitSize,f=(r.left+m)*(1-a)+(r.right-m)*a,g=(r.top+m)*(1-c)+(r.bottom-m)*c;switch(e.color(this.color),this.textLines.forEach((x,C)=>{let I=f-s[C]*a,T=g-l*c+o*(C+1)+p;e.fillText(x,I,T)}),this.boxed){case"square":case"rectangle":e.strokeRect(r.left,r.top,r.width,r.height);break;case"circle":case"ellipse":e.beginPath(),e.ellipse(r.centerX,r.centerY,r.width/2,r.height/2,0,0,2*Math.PI),e.stroke();break}}};var Ho=class extends rt{constructor(e,r){super(e);this.measure=e;this.staff=r;d(this,"clefImage");d(this,"eightBelowClef");d(this,"measureNumber");d(this,"ksNeutralizeAccidentals",[]);d(this,"ksNewAccidentals",[]);d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new Xo(this)}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let n=e.getImageAsset(this.staff.clefImageAsset);this.clefImage=n?new Ha(this,n,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new st(this,"8",.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(e){if(e){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new st(this,r,0,1)}else this.measureNumber=void 0}updateKeySignature(e){if(e){let{measure:r}=this,n=r.getPrevMeasure(),o=n?n.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],o&&!tr.equals(s,o)&&o.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new qi(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new qi(this,this.getAccidentalDiatonicId(a),a.accidental))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),n=r.beatCount.toString();this.beatCountText=new st(this,{text:n,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new st(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=Hs(this.measure.getTempo());this.tempoText=new st(this,r,.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(e){let{clef:r}=this.staff.staffConfig,n;if(r==="G"?e.accidental>0?n=this.staff.bottomLineDiatonicId+3:e.accidental<0&&(n=this.staff.bottomLineDiatonicId+1):r==="F"&&(e.accidental>0?n=this.staff.bottomLineDiatonicId+1:e.accidental<0&&(n=this.staff.bottomLineDiatonicId-1)),n!==void 0)return W.findNextDiatonicIdAbove(e.diatonicId,n,!1);throw new N(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.eightBelowClef){let n=this.eightBelowClef.pick(e,r);if(n.length>0)return[this,...n]}if(this.clefImage){let n=this.clefImage.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.ksNeutralizeAccidentals.length;n++){let o=this.ksNeutralizeAccidentals[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.ksNewAccidentals.length;n++){let o=this.ksNewAccidentals[n].pick(e,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let n=this.beatCountText.pick(e,r);if(n.length>0)return[this,...n]}if(this.beatSizeText){let n=this.beatSizeText.pick(e,r);if(n.length>0)return[this,...n]}if(this.tempoText){let n=this.tempoText.pick(e,r);if(n.length>0)return[this,...n]}if(this.measureNumber){let n=this.measureNumber.pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){var u,h,l,p,m,f;let{unitSize:r}=e,{staff:n}=this,o=r,s=0;if(this.rect=new G,this.clefImage&&(s+=o,this.clefImage.layout(e),this.clefImage.offset(s,n.getDiatonicIdY(n.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let g=this.clefImage.getRect();this.eightBelowClef.layout(e),this.eightBelowClef.offset(g.centerX,Math.max(g.anchorY+g.height*.3,n.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}if(this.measureNumber){this.measureNumber.layout(e);let g=Math.min(n.getTopLineY(),this.clefImage?this.clefImage.getRect().top:n.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(e),g.offset(s+g.getRect().leftw,n.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(g=>{g.layout(e),g.offset(s+g.getRect().leftw,n.getDiatonicIdY(g.diatonicId)),this.rect.expandInPlace(g.getRect()),s=this.rect.right}));let a=s;(u=this.beatCountText)==null||u.layout(e),(h=this.beatSizeText)==null||h.layout(e);let c=Math.max((p=(l=this.beatCountText)==null?void 0:l.getRect().width)!=null?p:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);if(this.beatCountText&&(this.beatCountText.offset(s+c/2+o,n.getDiatonicIdY(n.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.offset(s+c/2+o,n.getDiatonicIdY(n.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText){let g=Math.min(this.clefImage?this.clefImage.getRect().top:n.getTopLineY(),...this.ksNeutralizeAccidentals.map(b=>b.getRect().top),...this.ksNewAccidentals.map(b=>b.getRect().top));this.tempoText.layout(e),this.tempoText.offset(s,g),this.rect.expandInPlace(this.tempoText.getRect())}this.rect.right+=o}offset(e,r){var n,o,s,a,c,u;(n=this.clefImage)==null||n.offset(e,r),(o=this.eightBelowClef)==null||o.offset(e,r),(s=this.measureNumber)==null||s.offset(e,r),this.ksNeutralizeAccidentals.forEach(h=>h.offset(e,r)),this.ksNewAccidentals.forEach(h=>h.offset(e,r)),(a=this.beatCountText)==null||a.offset(e,r),(c=this.beatSizeText)==null||c.offset(e,r),(u=this.tempoText)==null||u.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,n,o,s,a,c;(r=this.clefImage)==null||r.draw(e),(n=this.eightBelowClef)==null||n.draw(e),(o=this.measureNumber)==null||o.draw(e),this.ksNeutralizeAccidentals.forEach(u=>u.draw(e)),this.ksNewAccidentals.forEach(u=>u.draw(e)),(s=this.beatCountText)==null||s.draw(e),(a=this.beatSizeText)==null||a.draw(e),(c=this.tempoText)==null||c.draw(e)}},Zo=class extends rt{constructor(e,r){super(e);this.measure=e;this.tab=r;d(this,"measureNumber");d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new $o(this)}getMusicInterface(){return this.mi}updateMeasureNumber(e){if(e){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new st(this,r,0,1)}else this.measureNumber=void 0}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),n=r.beatCount.toString();this.beatCountText=new st(this,{text:n,scale:1.4},.5,.5);let o=r.beatSize.toString();this.beatSizeText=new st(this,{text:o,scale:1.4},.5,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=Hs(this.measure.getTempo());this.tempoText=new st(this,r,0,1)}else this.tempoText=void 0}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.beatCountText){let n=this.beatCountText.pick(e,r);if(n.length>0)return[this,...n]}if(this.beatSizeText){let n=this.beatSizeText.pick(e,r);if(n.length>0)return[this,...n]}if(this.tempoText){let n=this.tempoText.pick(e,r);if(n.length>0)return[this,...n]}if(this.measureNumber){let n=this.measureNumber.pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){var u,h,l,p,m,f;let{unitSize:r}=e,{tab:n}=this,o=r,s=0,a=n.getTopLineY();this.rect=new G,this.measureNumber&&(this.measureNumber.layout(e),this.measureNumber.offset(0,a),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)),(u=this.beatCountText)==null||u.layout(e),(h=this.beatSizeText)==null||h.layout(e);let c=Math.max((p=(l=this.beatCountText)==null?void 0:l.getRect().width)!=null?p:0,(f=(m=this.beatSizeText)==null?void 0:m.getRect().width)!=null?f:0);this.beatCountText&&(this.beatCountText.offset(0+c/2+o,n.getRect().anchorY-this.beatCountText.getRect().bottomh),this.rect.expandInPlace(this.beatCountText.getRect())),this.beatSizeText&&(this.beatSizeText.offset(0+c/2+o,n.getRect().anchorY+this.beatSizeText.getRect().toph),this.rect.expandInPlace(this.beatSizeText.getRect())),this.tempoText&&(this.tempoText.layout(e),this.tempoText.offset(s+r*2,a),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){var n,o,s,a;(n=this.measureNumber)==null||n.offset(e,r),(o=this.beatCountText)==null||o.offset(e,r),(s=this.beatSizeText)==null||s.offset(e,r),(a=this.tempoText)==null||a.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r,n,o,s;(r=this.measureNumber)==null||r.draw(e),(n=this.beatCountText)==null||n.draw(e),(o=this.beatSizeText)==null||o.draw(e),(s=this.tempoText)==null||s.draw(e)}};var Za=class extends rt{constructor(e,r,n){super(e);this.col=e;this.line=r;this.arpeggioDir=n;d(this,"topArrowHeight",0);d(this,"bottomArrowHeight",0);d(this,"cycleHeight",0);d(this,"numCycles",0);d(this,"color","black");d(this,"mi");this.mi=new Qo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let n=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-n)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new G(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r,topArrowHeight:n,bottomArrowHeight:o}=this;e.drawDebugRect(this.rect),e.color(this.color),e.lineWidth(2),e.beginPath();for(let s=0,a=r.top+n;s<this.numCycles;s++,a+=this.cycleHeight)e.moveTo(r.anchorX,a),e.quadraticCurveTo(r.left,a+this.cycleHeight/4,r.anchorX,a+this.cycleHeight/2),e.quadraticCurveTo(r.right,a+this.cycleHeight*3/4,r.anchorX,a+this.cycleHeight);e.stroke(),n>0&&(e.beginPath(),e.moveTo(r.anchorX,r.top),e.lineTo(r.right,r.top+n),e.lineTo(r.left,r.top+n),e.fill()),o>0&&(e.beginPath(),e.moveTo(r.anchorX,r.bottom),e.lineTo(r.left,r.bottom-o),e.lineTo(r.right,r.bottom-o),e.fill())}};function av(i){return typeof i=="number"?W.getChromaticNote(i).diatonicId:typeof i=="string"?W.getNote(i).diatonicId:i instanceof W?i.diatonicId:void 0}var Xa=class extends rt{constructor(e,r){super(e);this.staff=e;this.rest=r;d(this,"restRect",new G);d(this,"dotRects",[]);d(this,"mi");e.addObject(this),this.mi=new Jo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){this.restRect.offsetInPlace(e,r),this.dotRects.forEach(n=>n.offsetInPlace(e,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.clone(),this.dotRects.forEach(e=>this.rect.expandInPlace(e))}},zn=class zn extends rt{constructor(e,r,n,o,s){var u,h,l,p;super(e);this.col=e;this.voiceId=r;this.options=o;d(this,"color");d(this,"hide");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"setDiatonicId");d(this,"runningDiatonicId");d(this,"runningStemDir");d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"mi");this.setDiatonicId=(h=av((u=this.options)==null?void 0:u.staffPos))!=null?h:zn.UndefinedDiatonicId;let a=this.row.getStaves().filter(m=>m.containsVoiceId(this.voiceId));this.setDiatonicId!==zn.UndefinedDiatonicId&&a.length>0&&a[0].isSpace(this.setDiatonicId)&&(this.setDiatonicId+=this.setDiatonicId>=a[0].middleLineDiatonicId?1:-1),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.color=(l=o==null?void 0:o.color)!=null?l:"black",this.hide=(p=o==null?void 0:o.hide)!=null?p:!1,this.oldStyleTriplet=s===void 0&&((o==null?void 0:o.triplet)===!0||Tt.get(n).isTriplet);let c=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=Xt.get(n,c,(s!=null?s:this.oldStyleTriplet)?jr.Triplet:void 0),this.mi=new Ko(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get noteLength(){return this.rhythmProps.noteLength}getDiatonicId(e){return this.runningDiatonicId===zn.UndefinedDiatonicId?e?Tt.equals(this.noteLength,"1n")?e.middleLineDiatonicId+2:e.middleLineDiatonicId:W.getNote("G4").diatonicId:this.runningDiatonicId}get stemDir(){return this.runningStemDir}updateRunningArguments(e,r,n){this.runningDiatonicId=e,this.runningStemDir=r}getStaticObjects(e){let r=[];return this.staffObjects.forEach(n=>{n.staff===e&&r.push(n)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{let r=e.staff,n=e.getRect().anchorX,o=this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().anchorY-o);return{staff:r,x:n,y:o,stemHeight:s}})}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof Xa&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case 1:return 1;case 2:return-1;case 4:return-1;case 8:return-1;case 16:return-1;case 32:return-3;case 64:return-3;default:throw new N(6,`Get rest dot vertical displacement: Invalid note size: ${e}`)}}updateAccidentalState(e){}layout(e,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:n}=e,{noteSize:o,dotCount:s}=this.rhythmProps;this.row.getStaves().forEach(a=>{let c=this.getDiatonicId(a);if(!a.containsDiatonicId(c)||!a.containsVoiceId(this.voiceId))return;let u=new Xa(a,this);u.restRect=e.getRestRect(o);for(let h=0;h<s;h++){let l=at.DotSize*n,p=u.restRect.rightw+(at.RestDotSpace+at.DotSize*n)+h*at.DotSize*n*1.5,m=this.getRestDotVerticalDisplacement(o)*n;u.dotRects.push(G.createCentered(p,m,l,l))}u.offset(0,a.getDiatonicIdY(c)),this.staffObjects.push(u),this.measure.addStaticObject(a,u)})}updateRect(){if(this.staffObjects.length===0)this.rect=new G;else if(this.rect=this.staffObjects[0].getRect().clone(),this.staffObjects.length>1)for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){if(this.staffObjects.length===0)return;e.drawDebugRect(this.getRect());let{noteSize:r}=this.rhythmProps;e.color(this.color).lineWidth(1),this.staffObjects.forEach(n=>{let{dotRects:o,restRect:s}=n;e.drawRest(r,s.anchorX,s.anchorY),o.forEach(a=>e.fillCircle(a.anchorX,a.anchorY,a.width/2))})}};d(zn,"UndefinedDiatonicId",1/0);var oe=zn;function cv(i){return y.isEnumValue(i,mi)?i:i===!0?"up":void 0}function uv(i,t){let e=H.Arr.isArray(t)?t:t!==void 0?[t]:[],r=i.map((n,o)=>({note:n,string:e[o]}));return r=H.Arr.removeDuplicates(r,(n,o)=>W.equals(n.note,o.note)).sort((n,o)=>W.compareFunc(n.note,o.note)),{sortedNotes:r.map(n=>n.note),sortedStrings:r.every(n=>n.string===void 0)?void 0:r.map(n=>n.string)}}var $a=class extends rt{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;d(this,"noteHeadRects",[]);d(this,"dotRects",[]);d(this,"accidentals",[]);d(this,"stemTip");d(this,"stemBase");d(this,"flagRects",[]);d(this,"prevTopNoteY",0);d(this,"prevBottomNoteY",0);d(this,"mi");this.mi=new es(this)}getMusicInterface(){return this.mi}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.accidentals.length;n++){let o=this.accidentals[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].clone(),this.noteHeadRects.forEach(e=>this.rect.expandInPlace(e)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(e=>this.rect.expandInPlace(e)),this.flagRects.forEach(e=>this.rect.expandInPlace(e)),this.accidentals.forEach(e=>this.rect.expandInPlace(e.getRect()))}getRect(){let e=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.anchorY||this.prevBottomNoteY!==e.anchorY)&&(this.prevTopNoteY=r.anchorY,this.prevBottomNoteY=e.anchorY,this.requestRectUpdate()),super.getRect()}offset(e,r){var n,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(e,r)),this.dotRects.forEach(s=>s.offsetInPlace(e,r)),this.accidentals.forEach(s=>s.offset(e,r)),(n=this.stemTip)==null||n.offsetInPlace(e,r),(o=this.stemBase)==null||o.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},yh=class extends rt{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;d(this,"fretNumbers",[]);d(this,"mi");this.mi=new rs(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().clone(),this.fretNumbers.forEach(e=>this.rect.expandInPlace(e.getRect()))}offset(e,r){this.fretNumbers.forEach(n=>n.offset(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},xt=class i extends rt{constructor(e,r,n,o,s,a){var l,p,m;super(e);this.col=e;this.voiceId=r;this.notes=n;this.options=s;d(this,"setDiatonicId");d(this,"setStringsNumbers");d(this,"runningDiatonicId");d(this,"runningStemDir");d(this,"runningStringNumbers");d(this,"color");d(this,"staccato");d(this,"diamond");d(this,"arpeggio");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"startConnnectives",[]);d(this,"runningConnectives",[]);d(this,"leftBeamCount",0);d(this,"rightBeamCount",0);d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"tabObjects",[]);d(this,"isNoteDisplaced");d(this,"mi");if(!y.isIntegerGte(n.length,1))throw new N(6,"Cannot create note group object because notes array is empty.");let{sortedNotes:c,sortedStrings:u}=uv(n,s==null?void 0:s.string);this.notes=c,this.setStringsNumbers=u,this.isNoteDisplaced=this.notes.map(()=>!1),this.setDiatonicId=Math.round((this.minDiatonicId+this.maxDiatonicId)/2),this.runningDiatonicId=this.setDiatonicId,this.runningStemDir="up",this.runningStringNumbers=[],this.color=(l=s==null?void 0:s.color)!=null?l:"black",this.staccato=(p=s==null?void 0:s.staccato)!=null?p:!1,this.diamond=(m=s==null?void 0:s.diamond)!=null?m:!1,this.arpeggio=cv(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&((s==null?void 0:s.triplet)===!0||Tt.get(o).isTriplet);let h=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=Xt.get(o,h,(a!=null?a:this.oldStyleTriplet)?jr.Triplet:void 0),this.mi=new ts(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get minDiatonicId(){return this.notes[0].diatonicId}get maxDiatonicId(){return this.notes[this.notes.length-1].diatonicId}getDiatonicId(e){return this.runningDiatonicId}get stemDir(){return this.runningStemDir}setNoteDisplacement(e,r){let n=this.notes.indexOf(e);n>=0&&(this.isNoteDisplaced[n]=r)}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof he||e.containsDiatonicId(this.runningDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective==="tie")throw new N(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective==="slur")throw new N(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(e),this.doc.addConnectiveProps(e)}updateRunningArguments(e,r,n){this.runningDiatonicId=e===oe.UndefinedDiatonicId?this.setDiatonicId:e,this.runningStemDir=r,this.runningStringNumbers=n}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.tabObjects.length;n++){let o=this.tabObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,n,o,s){var a;if(r instanceof kt){if(n<0||n>=this.notes.length)throw new N(6,"Invalid noteIndex: "+n);let c=this.staffObjects.find(S=>S.staff===r);if(!c||n<0||n>=c.noteHeadRects.length){let S=this.getRect();return{x:S.anchorX,y:S.bottom}}let u=c.noteHeadRects[n],h=c.stemTip,l=this.stemDir,p=h!==void 0,m=p?l==="up"?"right":"left":void 0,f=u.height/2,g=u.anchorX,b=u.anchorY,x=u.left-f,C=u.right+f,I=u.top-f,T=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!p&&(o=l==="up"?"above":"below"),o){case"center":return s==="left"?{x:C,y:b}:{x,y:b};case"above":return!p||l==="down"?{x:g,y:I}:{x:s==="left"&&m==="right"?C:s==="right"&&m==="left"?x:g,y:I};case"below":return!p||l==="up"?{x:g,y:T}:{x:s==="left"&&m==="right"?C:s==="right"&&m==="left"?x:g,y:T};case"stemTip":return{x:g,y:h.anchorY+(l==="up"?-f:f)};default:throw new N(6,"Invalid noteAnchor: "+o)}}else if(r instanceof he){let c=(a=this.tabObjects.find(m=>m.tab===r))==null?void 0:a.fretNumbers[n];if(!c)return{x:0,y:0};let u=c.getRect(),h=s==="right"?u.left:u.right,l,p=.9;if(e.connective==="slide"){let m=e.noteGroups[0].getFretNumber(r,0),f=e.noteGroups[1].getFretNumber(r,0),g=m===void 0||f===void 0||m<=f;s==="left"?l=(g?u.anchorY+u.bottomh:u.anchorY-u.toph)*p:l=(g?u.anchorY-u.toph:u.anchorY+u.bottomh)*p}else l=u.anchorY+u.bottomh*p;return{x:h,y:l}}else return{x:0,y:0}}getFretNumberString(e){return this.runningStringNumbers[e]}getFretNumber(e,r){let n=this.tabObjects.find(s=>s.tab===e),o=n==null?void 0:n.fretNumbers[r];return o?parseInt(o.getText()):void 0}getNextNoteGroup(){let e=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof i),r=e.indexOf(this);if(r<0)return;if(r<e.length-1)return e[r+1];let n=this.measure.getNextMeasure();for(;n;){let o=n.getVoiceSymbols(this.voiceId).filter(s=>s instanceof i);if(o.length>0)return o[0];n=n.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(e=>{this.runningConnectives.push(e);let r=this.getNextNoteGroup();for(;r&&e.addNoteGroup(r);)r.runningConnectives.push(e),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let e=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return e.indexOf("first")>=0?"first":e.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{var a,c,u,h;let r=e.staff,n=(c=(a=e.stemTip)==null?void 0:a.anchorX)!=null?c:e.noteHeadRects[0].anchorX,o=(h=(u=e.stemTip)==null?void 0:u.anchorY)!=null?h:this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=this.stemDir==="up"?Math.abs(e.noteHeadRects[0].anchorY-o):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].anchorY-o);return{staff:r,x:n,y:o,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{flagCount:n,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?at.BeamSeparation:at.FlagSeparation;return(at.StemHeight+Math.max(0,n-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}setLeftBeamCount(e){this.leftBeamCount=e}setRightBeamCount(e){this.rightBeamCount=e}hasTuplet(){return this.rhythmProps.tupletRatio!==void 0}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof $a&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(n=>n.connective==="tie").map(n=>{let o=n.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(n.span==="stub"||n.span==="toMeasureEnd")return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=o[s-1];return a&&a.notes.some(c=>W.equals(c,e))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!W.equals(u,e))),s>=0&&(o=o.slice(0,s)),H.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(e){this.notes.forEach(r=>{e.needAccidental(r)&&e.setAccidental(r)})}layout(e,r){this.requestRectUpdate();let{unitSize:n}=e,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,h=at.DotSize*n,l=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadWidth)*n,p=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadHeight)*n;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.runningDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new $a(m,this),g=m,b=m;this.notes.forEach((A,_)=>{var j;let E=_===0,V=_===this.notes.length-1,M=(j=m.getActualStaff(A.diatonicId))!=null?j:m,R=this.isNoteDisplaced[_]?l*(s==="down"?-1:1):0,P=M.getDiatonicIdY(A.diatonicId),D=M.isLine(A.diatonicId);E&&s==="up"&&(g=M),V&&s==="up"&&(b=M),E&&s==="down"&&(b=M),V&&s==="down"&&(g=M);let k=f.noteHeadRects[_]=G.createCentered(R,P,l,p);if(M.addObject(k),r.needAccidental(A)){let q=f.accidentals[_]=new qi(this,A.diatonicId,A.accidental,this.color);q&&(q.layout(e),q.offset(-k.leftw-n*at.NoteAccSpace-q.getRect().rightw,P)),M.addObject(q)}for(let q=0;q<a;q++){let K=k.right+at.NoteDotSpace*n+h/2+q*h*1.5,Z=P+this.getDotVerticalDisplacement(m,A.diatonicId,s)*n,B=G.createCentered(K,Z,h,h);f.dotRects.push(B),M.addObject(B)}if(this.staccato){if(s==="up"&&E){let q=R,K=P+n*(D?3:2),Z=G.createCentered(q,K,h,h);f.dotRects.push(Z),g.addObject(Z)}else if(s==="down"&&V){let q=R,K=P-n*(D?3:2),Z=G.createCentered(q,K,h,h);f.dotRects.push(Z),g.addObject(Z)}}});let x=f.noteHeadRects[0].anchorY,C=f.noteHeadRects[f.noteHeadRects.length-1].anchorY,I=s==="up"?l/2:-l/2,T=this.getStemHeight(e),S=s==="up"?C-T:x+T,v=s==="up"?x:C;if(u&&(f.stemTip=new G(I,I,S,S),f.stemBase=new G(I,I,v,v),b.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let A=c===0?0:at.FlagWidth*n,_=c===0?0:at.FlagHeight*n;for(let E=0;E<c;E++){let V=E*n*at.FlagSeparation,M=f.flagRects[E]=s==="up"?new G(I,I+A,S+V,S+_+V):new G(I,I+A,S-_-V,S-V);b.addObject(M)}}this.staffObjects.push(f),this.measure.addStaticObject(m,f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new yh(m,this);this.notes.forEach((g,b)=>{let x=this.runningStringNumbers[b];if(y.isIntegerBetween(x,1,6)){let C=g.chromaticId-m.getTuningStrings()[x-1].chromaticId,I=C<0?"red":"black",T=new st(this,{text:String(C),color:I,bgcolor:"white"},.5,.5);T.layout(e);let S=this.col.getRect().anchorX,v=m.getStringY(x-1);T.offset(S,v),f.fretNumbers.push(T)}}),f.fretNumbers.length>0&&(this.tabObjects.push(f),m.addObject(f),this.measure.addStaticObject(m,f))})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].clone();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().clone();else{this.rect=new G;return}this.staffObjects.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tabObjects.forEach(e=>this.rect.expandInPlace(e.getRect()))}setStemTipY(e,r){let n=this.staffObjects.find(o=>o.staff===e);this.hasBeamCount()&&(n!=null&&n.stemTip)&&r!==n.stemTip.anchorY&&(n.stemTip.top=n.stemTip.anchorY=n.stemTip.bottom=r,this.requestRectUpdate(),this.col.requestRectUpdate())}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.tabObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let{stemDir:r}=this,{isSolidNoteHead:n}=this.rhythmProps;this.staffObjects.forEach(o=>{o.accidentals.forEach(s=>s.draw(e)),e.color(this.color),e.lineWidth(1),o.noteHeadRects.forEach(s=>{this.diamond?n?(e.beginPath(),e.moveTo(s.anchorX,s.top),e.lineTo(s.right,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.lineTo(s.left,s.anchorY),e.lineTo(s.anchorX,s.top),e.fill()):(e.beginPath(),e.lineWidth(2.5),e.moveTo(s.anchorX,s.top),e.lineTo(s.right,s.anchorY),e.moveTo(s.left,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.stroke(),e.beginPath(),e.lineWidth(1),e.moveTo(s.right,s.anchorY),e.lineTo(s.anchorX,s.bottom),e.moveTo(s.anchorX,s.top),e.lineTo(s.left,s.anchorY),e.stroke()):(e.beginPath(),e.ellipse(s.anchorX,s.anchorY,s.leftw,s.toph,-.3,0,Math.PI*2),n?e.fill():e.stroke())}),o.dotRects.forEach(s=>e.fillCircle(s.anchorX,s.anchorY,s.width/2)),o.stemTip&&o.stemBase&&(e.beginPath(),e.moveTo(o.stemBase.anchorX,o.stemBase.anchorY),e.lineTo(o.stemTip.anchorX,o.stemTip.anchorY),e.stroke()),o.flagRects.forEach(s=>e.drawFlag(s,r==="up"?"up":"down"))}),this.tabObjects.forEach(o=>o.fretNumbers.forEach(s=>s.draw(e)))}getDotVerticalDisplacement(e,r,n){return e.isLine(r)?n==="up"?-1:1:0}static hasSameNotes(e,r){if(e.notes.length!==r.notes.length)return!1;for(let n=0;n<e.notes.length;n++){let o=e.notes[n],s=r.notes[n];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var zr=class extends rt{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;d(this,"voiceSymbol",new Ar);d(this,"lyricsObject",new Ps);d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"staffMinDiatonicId",new yt);d(this,"staffMaxDiatonicId",new yt);d(this,"arpeggioDir");d(this,"arpeggios",[]);d(this,"playerProps");d(this,"needLayout",!0);d(this,"shapeRects",[]);d(this,"mi");this.playerProps=new Yn(this),this.mi=new is(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let e=this.measure.getColumns().indexOf(this);if(e>=0&&e<this.measure.getColumnCount())return this.measure.getColumn(e+1);throw new N(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let e=this.getNextColumnInMeasure();return e||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let e=this.getNextColumnInMeasure(),r=this.positionTicks,n=e?e.positionTicks:this.measure.getConsumedTicks();return Math.max(0,n-r)}getShapeRects(){return this.getRect(),this.shapeRects}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){let n=this.getRect().contains(e,r);for(let o=0;o<this.voiceSymbol.length;o++){let s=this.voiceSymbol.get(o);if(s instanceof oe){let a=s.pick(e,r);if(a.length>0)return n?[this,...a]:a}}if(!n)return[];for(let o=0;o<this.voiceSymbol.length;o++){let s=this.voiceSymbol.get(o);if(s instanceof xt){let a=s.pick(e,r);if(a.length>0)return[this,...a]}}for(let o=0;o<this.arpeggios.length;o++){let s=this.arpeggios[o].pick(e,r);if(s.length>0)return[this,...s]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:"up"}setVoiceSymbol(e,r){Fo(e),this.voiceSymbol.set(e,r),r instanceof oe&&!r.hide?this.row.getStaves().forEach(n=>{let o=r.getDiatonicId(n);this.minDiatonicId=this.minDiatonicId===void 0?o:Math.min(this.minDiatonicId,o),this.maxDiatonicId=this.maxDiatonicId===void 0?o:Math.max(this.maxDiatonicId,o)}):r instanceof xt&&(this.minDiatonicId=this.minDiatonicId===void 0?r.notes[0].diatonicId:Math.min(this.minDiatonicId,r.notes[0].diatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.notes[r.notes.length-1].diatonicId:Math.max(this.maxDiatonicId,r.notes[r.notes.length-1].diatonicId),r.arpeggio!==void 0&&(this.arpeggioDir=r.arpeggio),this.updateNoteDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(e){return this.voiceSymbol.get(e)}getLyricsObject(e,r,n){return this.lyricsObject.get(e,r,n)}addLyricsObject(e){this.lyricsObject.set(e.verse,e.line,e.vpos,e)}updateNoteDisplacements(){let e=[];this.voiceSymbol.forEach(n=>{n instanceof xt&&n.notes.forEach(o=>{n.setNoteDisplacement(o,!1),e.push({noteGroup:n,note:o})})});let r=(n,o)=>{let s=W.compareFunc(n.note,o.note);return s===0?n.noteGroup.stemDir===o.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1:s};if(e.sort(r),!(e.length<2)){for(let n=0;n<e.length;n++){let o=e[n],s=e[n+1];s&&o.note.diatonicId===s.note.diatonicId&&(o.isDisplaced=s.isDisplaced=!1)}for(let n=0;n<e.length;n++){let o=e[n-1],s=e[n],a=e[n+1];s.isDisplaced===void 0&&(o&&s.note.diatonicId-o.note.diatonicId<=1?s.isDisplaced=!o.isDisplaced:a&&a.note.diatonicId-s.note.diatonicId<=1&&(s.isDisplaced=!a.isDisplaced))}e.forEach(n=>{var o;return n.noteGroup.setNoteDisplacement(n.note,(o=n.isDisplaced)!=null?o:!1)})}}isEmpty(){return this.voiceSymbol.size===0||this.voiceSymbol.every(e=>e.isEmpty())}getPlayerNotes(){let e=[];function r(n,o,s,a){if(o<=0)return;e.some(u=>n.diatonicId===u.note.diatonicId&&n.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||e.push({note:n,ticks:o,staccato:s,slur:a})}return ne().forEach(n=>{let o=this.getVoiceSymbol(n);if(o instanceof xt){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),e.sort((n,o)=>W.compareFunc(n.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;let{row:n}=this,o=0,s=0;if(this.voiceSymbol.forEach(h=>{h.layout(e,r);let l=h.getRect();o=Math.max(o,l.leftw),s=Math.max(s,l.rightw)}),this.arpeggioDir!==void 0){this.arpeggios=n.getNotationLines().map(l=>new Za(this,l,this.getArpeggioDir())),this.arpeggios.forEach(l=>l.layout(e));let h=this.arpeggios.map(l=>l.getRect().width).reduce((l,p)=>Math.max(l,p))+e.unitSize;this.arpeggios.forEach(l=>{l.offset(-o-h+l.getRect().leftw,l.line.getRect().anchorY-l.getRect().anchorY),l.line.addObject(l),this.measure.addStaticObject(l.line,l)}),o+=h}else this.arpeggios=[];let a=this.voiceSymbol.mapToArray(h=>h.rhythmProps.noteSize),c=Math.min(8,Math.max(1,...a)),u=Math.ceil(8/c)*at.NoteHeadWidth*e.unitSize*.75;o=Math.max(o,u/2),s=Math.max(s,u/2),o*=at.ColumnWidthScale,s*=at.ColumnWidthScale,this.rect=new G(-o,0,s,0,0,0),this.requestRectUpdate(),this.voiceSymbol.forEach(h=>h.updateAccidentalState(r)),this.row.getStaves().forEach(h=>{let l,p;this.voiceSymbol.forEach(m=>{if(m.visibleInStaff(h)){if(m instanceof xt)l=l===void 0?m.minDiatonicId:Math.min(l,m.minDiatonicId),p=p===void 0?m.maxDiatonicId:Math.max(p,m.maxDiatonicId);else if(m instanceof oe){let f=m.getDiatonicId(h);l=l===void 0?f:Math.min(l,f),p=p===void 0?f:Math.max(p,f)}}}),l!==void 0?this.staffMinDiatonicId.set(h,l):this.staffMinDiatonicId.delete(h),p!==void 0?this.staffMaxDiatonicId.set(h,p):this.staffMaxDiatonicId.delete(h)})}layoutReserveSpace(e){let r=this.measure.getColumns(),n=e.unitSize;this.getAnchoredLayoutObjects().forEach(o=>{if(o.layoutGroup.reserveSpace){let s=r.indexOf(this);if(s<0)return;let a=o.getRect().leftw-this.getRect().leftw;if(a>0){let u=r[s-1];u&&u.getAnchoredLayoutObjects().forEach(h=>{if(h.layoutGroupId===o.layoutGroupId){let l=h.getRect().rightw-u.getRect().rightw;this.rect.left-=Math.max(l+a,0)+n,this.requestRectUpdate()}})}let c=o.getRect().rightw-this.getRect().rightw;if(c>0){let u=r[s+1];u&&u.getAnchoredLayoutObjects().forEach(h=>{if(h.layoutGroupId===o.layoutGroupId){let l=h.getRect().leftw-u.getRect().leftw;this.rect.right+=Math.max(c+l,0)+n,this.requestRectUpdate()}})}}})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(e=>e!==void 0).mapToArray(e=>e.getRect().clone()),...this.arpeggios.map(e=>e.getRect().clone())],this.rect.top=Math.min(...this.shapeRects.map(e=>e.top)),this.rect.bottom=Math.max(...this.shapeRects.map(e=>e.bottom)),this.rect.anchorY=(this.rect.top+this.rect.bottom)/2}offset(e,r){this.voiceSymbol.forEach(n=>n.offset(e,0)),this.arpeggios.forEach(n=>n.offset(e,0)),this.shapeRects.forEach(n=>n.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){this.row.getStaves().forEach(r=>{let n=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);n!==void 0&&e.drawLedgerLines(r,n,this.getRect().anchorX),o!==void 0&&e.drawLedgerLines(r,o,this.getRect().anchorX)}),this.voiceSymbol.forEach(r=>r.draw(e)),this.arpeggios.forEach(r=>r.draw(e))}};var Mr=class Mr extends rt{constructor(e,r){super(e);this.text=r;d(this,"components",[]);d(this,"mi");switch(this.text){case Mr.Coda:this.components=[new st(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new st(this," Coda",0,1)];break;case Mr.toCoda:this.components=[new st(this,"toCoda ",1,1),new st(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case Mr.Segno:this.components=[new st(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new ns(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){switch(this.text){case Mr.Coda:{let r=this.components[0],n=this.components[1];r.layout(e),n.layout(e),r.offset(0,n.getRect().centerY),n.offset(r.getRect().right,0),this.rect=new G(r.getRect().left,r.getRect().anchorX,n.getRect().right,n.getRect().top,n.getRect().anchorY,n.getRect().bottom);break}case Mr.toCoda:{let r=this.components[0],n=this.components[1];r.layout(e),n.layout(e),n.offset(0,r.getRect().centerY),r.offset(n.getRect().left,0),this.rect=new G(r.getRect().left,n.getRect().anchorX,n.getRect().right,r.getRect().top,r.getRect().anchorY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(e),this.rect=r.getRect().clone();break}}}offset(e,r){this.components.forEach(n=>n.offset(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(e))}};d(Mr,"toCoda","\u{1D10C} toCoda"),d(Mr,"Coda","Coda \u{1D10C}"),d(Mr,"Segno","\u{1D10B}");var yr=Mr;function os(i){switch(i){case"D.C. al Coda":return"D.C. al Coda";case"D.C. al Fine":return"D.C. al Fine";case"D.S. al Coda":return"D.S. al Coda";case"D.S. al Fine":return"D.S. al Fine";case"Fine":return"Fine";case"Segno":return yr.Segno;case"Coda":return yr.Coda;case"toCoda":return yr.toCoda;default:return i[0].toUpperCase()+i.substring(1)}}function bh(i){return y.isEnumValue(i,Wn)}function ss(i){if(/^(p+|f+|m|mp|mf)$/.test(i)){let t=.5-H.Str.charCount(i,"p")*.1+H.Str.charCount(i,"f")*.1;return H.Math.clamp(t,0,1)}else return}function xh(i){return y.isEnumValue(i,Un)}function Gf(i){return y.isEnumValue(i,Wn)?"dynamics":y.isEnumValue(i,Un)?"tempo":void 0}function hv(i){switch(i){case"bottom":return .8;case"middle":return .5}}function lv(i){return bh(i)?2:xh(i)?1:0}var Wi=class extends Ua{constructor(e,r,n,o,s,a){super(e);d(this,"length");d(this,"visible");d(this,"lineStyle");d(this,"linePos");d(this,"startColumn");d(this,"context");if(this.length=n,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=e instanceof st?lv(e.getText()):0,e instanceof st)e.updateAnchorY(hv(a));else throw new N(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(e,r){if(e===e.measure.getColumn(0)){let n=e.measure.getPrevMeasure();if(n){if(n.hasEndSection()||n.hasEndSong())return"section-break";let o=["endRepeat","ending"];for(let s=0;s<o.length;s++)if(n.hasNavigation(o[s]))return"section-break"}}if(r===1){let n=e.getAnchoredLayoutObjects();for(let o=0;o<n.length;o++){let s=n[o].getTextContent();if(s&&xh(s))return s}}else if(r===2){let n=e.getAnchoredLayoutObjects();for(let o=0;o<n.length;o++){let s=n[o].getTextContent();if(s&&bh(s))return s}}}getExtensionRangeInfo(){let{startColumn:e,length:r,context:n}=this,o=[e];if(r<=0)return{startColumn:e,endColumn:e,columnRange:o,extensionBreakText:void 0};let s=r,a=e;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};let u=this.getSpanBreakText(c,n);if(u!==void 0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};a=c,o.push(a)}}};var dv=2,pv=2,mv=.5,fv=.5;function gv(i,t){let e=Xt.get(t.options.beatLength,t.options.dotCount).ticks,r=t.beatsPerMinute*e;return 60*i/r}function Ah(){return ss("m")}function yv(i){return i*1.25}var bv=.5,Yn=class{constructor(t){this.col=t;d(this,"speed");d(this,"volume");this.speed=1,this.volume=Ah()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=Ah()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=H.Math.clamp(this.getSpeed(),.1,10);return hu(this.measure.getTempo(),t)}setVolume(t){this.volume=t}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:t}=this;if(t instanceof Yr)return this.measure.getMeasureTicks()/2;{let r=ne().map(n=>t.getVoiceSymbol(n)).filter(n=>!!n).map(n=>n.rhythmProps.ticks);return r.length===0?0:H.Math.sum(r)/r.length}}},Qa=class i{constructor(){d(this,"playTimer");d(this,"playPos");d(this,"playState",2);d(this,"doc");d(this,"cursorPositionChangeListener");d(this,"playStateChnageListener");d(this,"playerColumnSequence",[])}setDocument(t){this.doc=t,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(t){this.cursorPositionChangeListener=t}setPlayStateChnageListener(t){this.playStateChnageListener=t}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let t=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==t&&(this.playStateChnageListener&&this.playStateChnageListener(t),this.playState=t)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let t=[],e=this.doc.getFirstMeasure(),r=e,n,o=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=i.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation("startRepeat")&&(r=e),e.hasNavigation("Segno")&&(n=e),s&&e.hasNavigation("toCoda"))for(;e&&!e.hasNavigation("Coda");)e=e.getNextMeasure();else if(o&&e.hasNavigation("Fine"))e=void 0;else if(e.hasNavigation("D.C. al Coda"))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.C. al Fine"))o=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.S. al Coda"))s=!0,e=n;else if(e.hasNavigation("D.S. al Fine"))o=!0,e=n;else if(e.hasNavigation("endRepeat")){let u=e.getPassCount(),h=e.getEndRepeatPlayCount()-1,l=((a=e.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=h||l?e=r:e=e.getNextMeasure()}else e.hasEndSong()?e=void 0:e=e.getNextMeasure()}return t}collectPlayerColumnSequence(){let t=this.collectPlayerMeasureSequence(),e=[];for(let r=0;r<t.length;r++){let n=t[r];e=e.concat(n.getColumns()),n.hasFermata(n.getBarLineRight())&&e.push(n.getBarLineRight())}return e}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let t=1,e=Ah(),r=new yt,n=new yt,o=(a,c)=>r.getOrCreate(a,[]).push(c),s=(a,c)=>n.getOrCreate(a,[]).push(c);this.playerColumnSequence.forEach(a=>{if(!(a instanceof zr))return;a.getAnchoredLayoutObjects().forEach(h=>{var m;let l=(m=h.getTextContent())!=null?m:"",p;if(l==="a tempo")t=1;else if((p=ss(l))!==void 0)e=p;else if(h.musicObj.getLink()instanceof Wi){let f=h.musicObj.getLink(),{columnRange:g,extensionBreakText:b}=f.getExtensionRangeInfo(),x=H.Math.sum(g.map(C=>C.getTicksToNextColumn()));switch(l){case"accel.":{let C=t,I=C*dv,T=0;g.forEach(S=>{T+=S.getTicksToNextColumn(),o(S,C+(I-C)*T/x)});break}case"rit.":{let C=t,I=C/pv,T=0;g.forEach(S=>{T+=S.getTicksToNextColumn(),o(S,C+(I-C)*T/x)});break}case"cresc.":{let C=e,I=C+mv;b&&(p=ss(b))!==void 0&&p>C&&(I=p);let T=0;g.forEach(S=>{T+=S.getTicksToNextColumn(),s(S,C+(I-C)*T/x)});break}case"decresc.":case"dim.":{let C=e,I=C-fv;b&&(p=ss(b))!==void 0&&p<C&&(I=p);let T=0;g.forEach(S=>{T+=S.getTicksToNextColumn(),s(S,C+(I-C)*T/x)});break}}}});let c=r.getOrDefault(a,[]);c.length>0&&(t=H.Math.sum(c)/c.length);let u=n.getOrDefault(a,[]);u.length>0&&(e=H.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(t),a.getPlayerProps().setVolume(e)})}static getMeasureByEndingPassage(t,e){for(let r=t;;r=r.getNextMeasure()){let n=r==null?void 0:r.getEnding();if(n&&n.hasPassage(e))return r;let o=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!o||o.hasNavigation("startRepeat"))return}}playStep(){if(this.notifyCursorPositionChanged(),this.notifyPlayStateChanged(),this.playPos===void 0){this.stop();return}let t=this.playerColumnSequence[this.playPos];if(!t){this.stop();return}let e=(s,a)=>{let c=gv(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),n=t.getPlayerProps().getFermataHoldTicks(),o;t instanceof Yr?o=e(n,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?Xt.get("32n").ticks*c:0,h=e(a.ticks+n-u,r);if(h>0){a.staccato&&(h=Math.min(e(Xt.get("8n").ticks,r)/2,h/2));let l=yv(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(l*=bv),u>0){let p=e(u,r);window.setTimeout(()=>Ba(a.note,h,l),p*1e3)}else Ba(a.note,h,l)}}),o=e(t.getTicksToNextColumn()+n,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:t}=this;if(!t)return;t.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(t){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let t=this.playerColumnSequence[this.playPos];if(!t)return;let e=t.measure,r=t.getRect().anchorX,{top:n,height:o}=e.row.getRect();return new tu(r,n,0,o)}};var Ch=class extends rt{constructor(e,r){super(r);this.barLine=e;this.line=r;d(this,"verticalLines",[]);d(this,"dots",[]);d(this,"mi");r.addObject(this),this.mi=new us(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}setRect(e){this.rect=e}offset(e,r){this.verticalLines.forEach(n=>n.left+=e),this.dots.forEach(n=>{n.x+=e,n.y+=r}),this.rect.offsetInPlace(e,r)}},Ka=class extends rt{constructor(e){super(e);this.measure=e;d(this,"staffTabObjects",[]);d(this,"staffTabObjectGroups",[]);d(this,"barLineType",0)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffTabObjects.length;n++){let o=this.staffTabObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}layout(e){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,_lineWidth:n}=e,{measure:o,barLineType:s}=this,{row:a}=o,c=n,u=.7*r,h=.7*r,l=at.DotSize*r,p=l/2;a.getNotationLines().forEach(m=>{let f=new Ch(this,m),g,b,x,C,I=(S,v)=>{f.verticalLines.push({left:S,width:v})},T=S=>{for(let v=-1;v<=1;v+=2){let A=g+v*b;f.dots.push({x:S,y:A,r:p})}};switch(m instanceof kt?(g=m.getMiddleLineY(),b=m.getDiatonicSpacing()):(g=(m.getBottomLineY()+m.getTopLineY())/2,b=(m.getBottomLineY()-m.getTopLineY())/6),x=m.getTopLineY(),C=m.getBottomLineY(),s){case 0:f.setRect(new G(0,0,0,x,0,C));break;case 1:f.setRect(new G(-c,0,0,x,0,C)),I(-c,c);break;case 2:f.setRect(new G(-c-h-c,0,0,x,0,C)),I(-c-h-c,c),I(-c,c);break;case 3:f.setRect(new G(-u-h-c,0,0,x,0,C)),I(-c-h-u,c),I(-u,u);break;case 4:f.setRect(new G(0,0,u+h+c+h+l,x,0,C)),I(0,u),I(u+h,c),T(u+h+c+h+p);break;case 5:f.setRect(new G(-u-h-c-h-l,0,0,x,0,C)),I(-c-h-u,c),I(-u,u),T(-c-h-u-h-p);break;case 6:f.setRect(new G(-l-h-c-h-u/2,0,u/2+h+c+h+l,x,0,C)),I(-u/2,u),I(-u/2-h-c,c),I(u/2+h,c),T(-u/2-h-c-h-p),T(u/2+h+c+h+p);break}this.staffTabObjects.push(f)}),this.staffTabObjectGroups=a.getInstrumentLineGroups().map(m=>m.map(f=>this.staffTabObjects.find(g=>g.line===f)).filter(f=>f!==void 0))}updateRect(){if(this.staffTabObjects.length>0){this.rect=this.staffTabObjects[0].getRect().clone();for(let e=1;e<this.staffTabObjects.length;e++)this.rect.expandInPlace(this.staffTabObjects[e].getRect())}else this.rect=new G}offset(e,r){this.staffTabObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){this.barLineType!==0&&(e.drawDebugRect(this.getRect()),e.color("black"),this.staffTabObjectGroups.forEach(r=>{if(r.length>0){r.forEach(s=>s.dots.forEach(a=>e.fillCircle(a.x,a.y,a.r)));let n=r[0].getRect().top,o=r[r.length-1].getRect().bottom-n;r[0].verticalLines.forEach(s=>e.fillRect(s.left,n,s.width,o))}}))}},gi=class extends Ka{constructor(e){super(e);d(this,"mi");this.mi=new cs(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation("startRepeat")?r&&r.row===e.row&&r.hasNavigation("endRepeat")?0:4:0}},Yr=class extends Ka{constructor(e){super(e);d(this,"playerProps");d(this,"mi");this.playerProps=new Yn(this),this.mi=new as(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation("endRepeat")?r&&r.row===e.row&&r.hasNavigation("startRepeat")?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var Ui=class extends rt{constructor(e,r){super(e);this.measure=e;this.passages=r;d(this,"endingText");d(this,"shapeRects",[]);d(this,"mi");if(this.mi=new hs(this),y.isIntegerGte(r.length,1)){if(!this.passages.every(o=>y.isIntegerGte(o,1)))throw new N(6,"Invalid passages: "+this.passages)}else throw new N(6,"Passages is empty.");this.passages.sort((o,s)=>o-s);let n=this.passages.map(o=>o+".").join("");this.endingText=new st(this,n,0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:e}=this,r=e.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||e.hasNavigation("endRepeat")||e.isLastMeasure()}hasPassage(e){return this.passages.some(r=>r===e)}getHighestPassage(){return Math.max(0,...this.passages)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new G,this.shapeRects=[this.rect.clone()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:n}=this;this.endingText.layout(e);let o=this.endingText.getRect(),s=n.getColumnsContentRect(),a=o.height;this.rect=new G(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new G(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new G(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new G(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().clone()]}offset(e,r){this.endingText.offset(e,r),this.shapeRects.forEach(n=>n.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this;e.drawDebugRect(this.rect),e.color("black").lineWidth(1),e.beginPath(),e.moveTo(r.left,r.bottom),e.lineTo(r.left,r.top),e.lineTo(r.right,r.top),this.isSingleMeasureEnding()&&e.lineTo(r.right,r.bottom),e.stroke(),this.endingText.draw(e)}};var xv=(i,t)=>{let e=at.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=i/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),i/r*e}},ls=class{constructor(t,e,r,n,o){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=n;this.y=o;d(this,"topBeamsHeight",0);d(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new G(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},_h=class extends rt{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;d(this,"tupletNumber");d(this,"tupletNumberOffsetY",0);d(this,"points",[]);d(this,"mi");e.addObject(this),this.mi=new ps(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var n;this.points.forEach(o=>o.offset(e,0)),(n=this.tupletNumber)==null||n.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().clone():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().clone()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},yi=class{constructor(t,e){this.beamGroup=t;this.message=e}},zi=class i extends rt{constructor(e,r){super(e[0].measure);this.symbols=e;this.tupletRatio=r;d(this,"mi");d(this,"type");d(this,"staffObjects",[]);this.mi=new ds(this);let n=r?"Tuplet":"BeamGroup";if(e.every(o=>o.measure===e[0].measure)){if(e.length<2)throw new N(6,`${n} needs minimum 2 symbols, but ${e.length} given.`)}else throw new N(6,`All ${n} symbols are not in same measure.`);if(r!==void 0){let o=e.length<3||e.some(s=>!(s instanceof xt))||e.some(s=>s.rhythmProps.flagCount!==e[0].rhythmProps.flagCount);e.length>=3&&e[0]instanceof xt&&e[e.length-1]instanceof xt&&e[0].rhythmProps.flagCount===e[e.length-1].rhythmProps.flagCount&&(o=!1),e.some(s=>Tt.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,this.setTupletBeamCounts()}else this.type=0,this.setBeamCounts();if(e.every(o=>o.getBeamGroup()===void 0))e.forEach(o=>o.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new N(6,`Cannot add ${n} because some symbol already has one.`);if(this.type===0&&this.symbols.filter(o=>o instanceof xt).some((o,s)=>{let a=s===0,c=s===this.symbols.length-1;if(a&&o.getRightBeamCount()===0||c&&o.getLeftBeamCount()===0||!a&&!c&&(o.getLeftBeamCount()===0||o.getRightBeamCount()===0))throw new yi(this,"Beam has zero left or right beam count!")}),e.some(o=>o.voiceId!==e[0].voiceId))throw this.type===0?new yi(this,"Beam symbols have different voiceId."):new N(6,"Tuplet symbols have different voiceId.");e[0].row.getStaves().forEach(o=>{o.getActualStaff(e[0].getDiatonicId(o))&&o.containsVoiceId(e[0].voiceId)&&e.forEach(s=>{let a=o.getActualStaff(s.getDiatonicId(o));if(!a||!a.containsVoiceId(s.voiceId))throw new yi(this,"Some of beam or tuplet symbols are not visible!")})})}get stemDir(){return this.symbols[0].stemDir}get showTupletRatio(){var e;return((e=this.tupletRatio)==null?void 0:e.showRatio)===!0}static createBeam(e){if(e.length>1&&e.every(r=>!r.hasTuplet()))try{return new i(e,void 0),!0}catch(r){if(r instanceof yi)r.beamGroup.detach();else throw r}return!1}static createOldStyleTriplet(e){try{let r=e.slice(0,2),n=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(n[0]*2===n[1]||n[1]*2===n[0]))return new i(r,jr.Triplet),2;let o=e.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);if(o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0]))return new i(o,jr.Triplet),3}catch(r){if(r instanceof yi)console.error(r.message),r.beamGroup.detach();else throw r}return 0}static createTuplet(e,r){try{new i(e,r)}catch(n){if(n instanceof yi)console.error(n.message),n.beamGroup.detach();else throw n}}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(e=>e.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.staffObjects.length;n++){let o=this.staffObjects[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getTupletRatioText(){var e,r,n;return this.showTupletRatio?String((e=this.tupletRatio)==null?void 0:e.parts)+":"+String((r=this.tupletRatio)==null?void 0:r.inTimeOf):String((n=this.tupletRatio)==null?void 0:n.parts)}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get color(){return this.symbols[0].color}layout(e){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let{unitSize:n}=e,{stemDir:o,type:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var P,D;if(!c)return;let h=a.map(k=>{var j;return(j=k[u])==null?void 0:j.x}),l=a.map(k=>{var j;return(j=k[u])==null?void 0:j.y}),p=a.map(k=>{var j;return(j=k[u])==null?void 0:j.staff}),m=a.map(k=>{var j;return(j=k[u])==null?void 0:j.stemHeight}),f=r[0],g=h[0],b=l[0],x=p[0],C=r[r.length-1],I=h[h.length-1],T=l[l.length-1],S=p[l.length-1];if(g===void 0||b===void 0||x===void 0||I===void 0||T===void 0||S===void 0)return;let v=(P=m[0])!=null?P:0,A=(D=m[m.length-1])!=null?D:0;if(s!==2){let k=v<A?Math.sqrt(A-v):0,j=A<v?Math.sqrt(v-A):0;o==="up"&&(k*=-1,j*=-1),k!==0&&(b+=k,l[0]+=k),j!==0&&(T+=j,l[l.length-1]+=j)}let _=n*2*(o==="up"?-1:1),E=(T+b)/2,V=xv(I-g,T-b)/2;b=E-V,T=E+V;let M=0;l.forEach((k,j)=>{let q=h[j];if(q!==void 0&&k!==void 0){let K=H.Math.interpolateY(g,b,I,T,q),Z=k-K;o==="up"&&Z<0?M=Math.min(M,Z):o==="down"&&Z>0&&(M=Math.max(M,Z))}}),b+=M,T+=M,l=l.map(k=>k===void 0?void 0:k+M);let R=new _h(c,this);if(s===2){let k=n/(I-g),j=H.Math.interpolateCoord(g,b+_,I,T+_,-k),q=H.Math.interpolateCoord(g,b+_,I,T+_,1+k);R.points.push(new ls(x,this,f,j.x,j.y)),R.points.push(new ls(S,this,C,q.x,q.y)),R.tupletNumberOffsetY=0}else if(s===0||s===1){M*=.5;let k=e._lineWidth*at.BeamThickness,j=q=>{let K=r[q];if(K instanceof xt){let Z=K instanceof xt?Math.max(K.getLeftBeamCount(),K.getRightBeamCount()):0;return at.BeamSeparation*n*(o==="up"?Z-1:0)}else return 0};r.forEach((q,K)=>{let Z=p[K],B=h[K],dt=l[K];if(Z&&B!==void 0&&dt!==void 0){let Ct=new ls(Z,this,q,B,dt);switch(o){case"up":Ct.topBeamsHeight=k/2,Ct.bottomBeamsHeight=k/2+j(K);break;case"down":Ct.topBeamsHeight=k/2+j(K),Ct.bottomBeamsHeight=k/2;break}R.points.push(Ct)}}),R.tupletNumberOffsetY=_}this.isTuplet()&&(R.tupletNumber=new st(this,this.getTupletRatioText(),.5,.5),R.tupletNumber.layout(e),R.tupletNumber.offset((g+I)/2,(b+T)/2+R.tupletNumberOffsetY)),R.points.length>=2&&this.staffObjects.push(R)})}updateRect(){if(this.staffObjects.length===0)this.rect=new G;else{this.staffObjects.forEach(e=>e.updateRect()),this.rect=this.staffObjects[0].getRect().clone();for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}}updateStemTips(){this.staffObjects.forEach(e=>{let r=e.points[0],n=e.points[e.points.length-1];if(this.type!==2&&e.points.forEach(o=>{o.symbol instanceof xt&&(o!==r&&o!==n&&(o.y=H.Math.interpolateY(r.x,r.y,n.x,n.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),e.tupletNumber){let o=(r.y+n.y)/2+e.tupletNumberOffsetY;e.tupletNumber.offset(0,-e.tupletNumber.getRect().anchorY+o)}})}offset(e,r){this.staffObjects.forEach(n=>n.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r}=e,{stemDir:n,color:o,type:s}=this;if(s===2){e.color(o).lineWidth(1);let a=(n==="up"?1:-1)*r;this.staffObjects.forEach(c=>{let{x:u,y:h}=c.points[0],{x:l,y:p}=c.points[c.points.length-1];if(c.tupletNumber){let m=c.tupletNumber.getRect().width/(l-u)*1.2,f=H.Math.interpolateCoord(u,h,l,p,.5-m/2),g=H.Math.interpolateCoord(u,h,l,p,.5+m/2);e.strokeLine(u,h,f.x,f.y),e.strokeLine(g.x,g.y,l,p)}else e.strokeLine(u,h,l,p);e.strokeLine(u,h,u,h+a),e.strokeLine(l,p,l,p+a)})}else(s===0||s===1)&&(e.color(o).lineWidth(at.BeamThickness),this.staffObjects.forEach(a=>{let c=a.points.filter(f=>f.symbol instanceof xt),{x:u,y:h}=c[0],{x:l,y:p}=c[c.length-1],m=at.BeamSeparation*r*(n==="up"?1:-1)*(1+.5*Math.abs(Math.atan2(p-h,l-u)));for(let f=0;f<c.length-1;f++){let{x:g,y:b,symbol:x}=c[f],{x:C,y:I,symbol:T}=c[f+1],S=x.getRightBeamCount(),v=T.getLeftBeamCount();for(let A=0;A<Math.max(S,v);A++)A<S&&A<v?e.strokeLine(g,b,C,I):S>v?e.strokePartialLine(g,b,C,I,0,.25):v>S&&e.strokePartialLine(g,b,C,I,.75,1),b+=m,I+=m}}));this.staffObjects.forEach(a=>{var c;return(c=a.tupletNumber)==null?void 0:c.draw(e)})}setBeamCounts(){let e=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:h,noteSize:l,dotCount:p}=s.rhythmProps;return a>0&&h>0&&u>0&&p===0&&c*Math.pow(2,u)===l},r=this.symbols.filter(o=>o instanceof xt);for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&(a.rhythmProps.flagCount===s.rhythmProps.flagCount||e(a,s)||e(s,a)?s.setLeftBeamCount(s.rhythmProps.flagCount):s.setLeftBeamCount(Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount))),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||e(c,s)||e(s,c)?s.setRightBeamCount(s.rhythmProps.flagCount):s.setRightBeamCount(Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount))))}let n;do{n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o-1],c=r[o+1];s&&s.getLeftBeamCount()!==s.rhythmProps.flagCount&&s.getRightBeamCount()!==s.rhythmProps.flagCount&&(s.setLeftBeamCount(0),s.setRightBeamCount(0),a&&a.getRightBeamCount()>0&&(a.setRightBeamCount(0),n=!0),c&&c.getLeftBeamCount()>0&&(c.setLeftBeamCount(0),n=!0))}}while(n)}setTupletBeamCounts(){let e=this.getType(),r=this.getSymbols();e===1?r.forEach((n,o)=>{n instanceof xt&&(n.setLeftBeamCount(o===0?0:n.rhythmProps.flagCount),n.setRightBeamCount(o===r.length-1?0:n.rhythmProps.flagCount))}):e===2&&r.forEach(n=>{n instanceof xt&&(n.setLeftBeamCount(0),n.setRightBeamCount(0))})}};var Hn=class extends rt{constructor(e,r){super(e);this.pos=r;d(this,"color","black");d(this,"mi");this.mi=new ms(this)}getMusicInterface(){return this.mi}static getFermataPositions(e){let{measure:r}=e,{row:n}=r;return n.getTopStaff()!==n.getBottomStaff()?[0,1]:[0]}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,n=r*4,o=r*3;this.rect=new G(-n/2,n/2,-o,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{unitSize:r}=e,n=this.pos===1,o=(n?r:-r)*.7,s=this.rect.left,a=this.rect.right,c=(n?this.rect.bottom:this.rect.top)+o,u=(n?this.rect.top:this.rect.bottom)+o,h=u-c;e.drawDebugRect(this.rect),e.color("black").lineWidth(1),e.beginPath(),e.moveTo(s,u),e.bezierCurveTo(s,c,a,c,a,u),e.bezierCurveTo(a,c+h/5,s,c+h/5,s,u),e.stroke(),e.fill();let l=h/6;e.fillCircle((s+a)/2,u-l,Math.abs(l))}};var Zn=class extends rt{constructor(e,r,n,o,s){super(e);this.measure=e;this.line=r;this.extension=n;this.leftObj=o;this.rightObj=s;d(this,"mi");n.addTail(this),this.mi=new fs(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(){return this.leftObj instanceof gi?this.leftObj.getRect().anchorX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof zr){let e=this.rightObj,r=e.getNextColumn();return r&&r.measure===e.measure?(e.getRect().right+r.getRect().left)/2:(e.getRect().right+e.measure.getBarLineRight().getRect().left)/2}else return this.rightObj.getRect().anchorX}layoutFitToMeasure(e){let{unitSize:r}=e,n=this.getLineLeft(),o=this.getLineRight(),s=r;this.rect=new G(n,o,-s/2,s/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new G}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let{rect:r}=this;this.extension.getLineStyle()==="dashed"&&e.setLineDash([7,3]),e.color("black").lineWidth(1),e.strokeLine(r.left,r.anchorY,r.right,r.anchorY),e.setLineDash([]);let n=this.extension.getTails();if(n.length>0&&this===n[n.length-1]){let o=r.anchorY>this.line.getRect().anchorY?-e.unitSize:e.unitSize;e.strokeLine(r.right,r.anchorY,r.right,r.anchorY+o)}}};var Yi=class extends rt{constructor(e,r,n,o,s,...a){var c;super(n);this.connectiveProps=e;this.measure=n;d(this,"lx",0);d(this,"ly",0);d(this,"rx",0);d(this,"ry",0);d(this,"cp1x",0);d(this,"cp1y",0);d(this,"cp2x",0);d(this,"cp2y",0);d(this,"arcHeight",0);d(this,"line");d(this,"leftNoteGroup");d(this,"leftNoteId");d(this,"rightNoteGroup");d(this,"rightNoteId");d(this,"tieType");d(this,"mi");this.line=(c=this.measure.row.findMatchingLine(r))!=null?c:r,this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof xt&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):y.isEnumValue(a[0],fr)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new gs(this)}getMusicInterface(){return this.mi}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,{measure:n,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:h}=this,{noteAnchor:l,arcDir:p}=h,{row:m}=n,f=m.getPrevRow(),g=m.getNextRow(),b=m.getConnectivesContentRect(),x,C;x=s.getConnectiveAnchorPoint(h,o,a,l,"left"),c!==void 0&&u!==void 0?C=c.getConnectiveAnchorPoint(h,o,u,l,"right"):C=this.tieType==="toMeasureEnd"?{x:n.getColumnsContentRect().right,y:x.y}:{x:x.x+r*at.StubTieLength,y:x.y};let I,T,S,v;if(c===void 0)I=x.x,T=x.y,S=C.x,v=C.y;else if(s.row===m&&c.row===m)I=x.x,T=x.y,S=C.x,v=C.y;else if(s.row===f&&c.row===m){let R=f.getConnectivesContentRect().right-x.x,P=C.x-b.left;I=b.left,T=x.y+(C.y-x.y)*R/(R+P),S=C.x,v=C.y}else if(s.row===m&&c.row===g){let M=g.getConnectivesContentRect(),R=b.right-x.x,P=C.x-M.left;I=x.x,T=x.y,S=b.right,v=x.y+(C.y-x.y)*R/(R+P)}else throw new N(6,"Cannot layout connective object because no valid left and right note groups.");let _=(p==="up"?-1:1)*r*Math.log2(S-I)/3;this.lx=I,this.ly=T,this.rx=S,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:_;let{nx:E,ny:V}=H.Math.calcNormal(I,T,S,v);this.cp1x=I*.7+S*.3+E*this.arcHeight,this.cp1y=T*.7+v*.3+V*this.arcHeight,this.cp2x=I*.3+S*.7+E*this.arcHeight,this.cp2y=T*.3+v*.7+V*this.arcHeight,this.rect=new G(Math.min(this.lx,this.cp1x,this.cp2x,this.rx),Math.max(this.lx,this.cp1x,this.cp2x,this.rx),Math.min(this.ly,this.cp1y,this.cp2y,this.ry),Math.max(this.ly,this.cp1y,this.cp2y,this.ry)),this.line.addObject(this)}offset(e,r){this.lx+=e,this.ly+=r,this.rx+=e,this.ry+=r,this.cp1x+=e,this.cp1y+=r,this.cp2x+=e,this.cp2y+=r,this.rect.offsetInPlace(e,r)}draw(e){if(this.rightNoteGroup!==void 0){if(this.leftNoteGroup.measure!==this.rightNoteGroup.measure){if(this.leftNoteGroup.row.getNextRow()!==this.rightNoteGroup.row){if(this.measure!==this.rightNoteGroup.measure)return}}}let{rect:r}=this,{_lineWidth:n}=e;e.drawDebugRect(r);let o=n*1.5,s=n*.25;e.color("black").lineWidth(1),this.arcHeight===0?(e.beginPath(),e.moveTo(this.lx,this.ly),e.lineTo(this.rx,this.ry),e.stroke()):(e.beginPath(),e.moveTo(this.lx,this.ly-s),e.bezierCurveTo(this.cp1x,this.cp1y-o,this.cp2x,this.cp2y-o,this.rx,this.ry-s),e.lineTo(this.rx,this.ry+s),e.bezierCurveTo(this.cp2x,this.cp2y+o,this.cp1x,this.cp1y+o,this.lx,this.ly+s),e.fill())}};var Xn=class{constructor(t,e,r,n){this.connective=t;this.span=e;this.noteAnchor=r;d(this,"noteGroups");d(this,"arcDir","down");this.noteGroups=[n]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(t){let{stemDir:e}=this.noteGroups[0],{hasStem:r}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=e==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=e==="up"||!r?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor="center":this.connective==="slide"?this.noteAnchor="center":this.arcDir==="up"?this.noteAnchor="above":this.noteAnchor="below";else if(this.noteAnchor==="center"){let n=t instanceof kt?t:void 0,o=this.noteGroups[0].getDiatonicId(n);this.arcDir=!n||o<n.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(t=>{t.measure.removeConnectiveObjects(),t.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){if(this.noteGroups.length===0)return;this.getStartNoteGroup().collectConnectiveProps();let{connective:t,span:e}=this;this.noteGroups[0].row.getNotationLines().forEach(r=>{if(this.computeParams(r),t==="tie"){if(y.isEnumValue(e,fr)){let n=this.noteGroups[0];for(let o=0;o<n.notes.length;o++)this.createObjConnectiveWithTieType(r,n,o,e)}else if(this.noteGroups.length>=2)for(let n=0;n<this.noteGroups.length-1;n++){let o=this.noteGroups[n],s=this.noteGroups[n+1];o.notes.forEach((a,c)=>{let u=s.notes.findIndex(h=>W.equals(h,a));u>=0&&this.createObjConnective(r,o,c,s,u)})}}else if(t==="slur"){if(typeof e=="number"&&e>=2&&this.noteGroups.length===e){let n=this.noteGroups[0],o=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,n,0,o,0)}}else if(t==="slide"&&this.noteGroups.length>=2)for(let n=0;n<this.noteGroups.length-1;n++){let o=this.noteGroups[n],s=this.noteGroups[n+1];this.createObjConnective(r,o,0,s,0)}})}createObjConnectiveWithTieType(t,e,r,n){if(e.enableConnective(t))t instanceof kt?new Yi(this,t,e.measure,e,r,n):t instanceof he&&e.getFretNumberString(r)!==void 0&&new Yi(this,t,e.measure,e,r,n);else return}createObjConnective(t,e,r,n,o){let s=(a,c,u,h,l)=>{if(c.enableConnective(t)&&h.enableConnective(t)){if(t instanceof kt)new Yi(this,t,a,c,u,h,l);else if(t instanceof he){let p=c.getFretNumberString(u),m=h.getFretNumberString(l);p!==void 0&&m!==void 0&&(p===m||this.connective==="slur")&&new Yi(this,t,a,c,u,h,l)}}else return};if(e.measure===n.measure)s(e.measure,e,r,n,o);else if(e.measure.getNextMeasure()===n.measure)s(e.measure,e,r,n,o),s(n.measure,e,r,n,o);else throw new N(6,"Cannot create connective because it is jumping measures.")}};var Ja=class extends rt{constructor(e,r,n,o,s,a,c){super(e);this.col=e;this.verse=r;this.line=n;this.vpos=o;d(this,"nextLyricsObject");d(this,"rhythmProps");d(this,"color","black");d(this,"hyphen");d(this,"text");d(this,"mi");this.rhythmProps=Xt.get(s);let u=(c==null?void 0:c.align)==="left"?0:(c==null?void 0:c.align)==="right"?1:.5;this.hyphen=y.isEnumValue(c==null?void 0:c.hyphen,Vn)?c==null?void 0:c.hyphen:void 0,this.text=new st(this,{text:a,color:this.color,scale:.8},u,0),this.rect=this.text.getRect().clone(),this.mi=new ys(this)}getMusicInterface(){return this.mi}get measure(){return this.col.measure}getText(){return this.text.getText()}setNextLyricsObject(e){this.nextLyricsObject=e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layout(e){this.text.layout(e),this.rect=this.text.getRect().clone()}offset(e,r){this.text.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){var r;if(this.text.draw(e),this.hyphen!==void 0){e.color(this.color).lineWidth(1);let n=this.getRect(),o=(r=this.nextLyricsObject)==null?void 0:r.getRect(),s=e.unitSize*1.5,a=o?(o.left-n.right)*.85:s,c=this.hyphen==="-"?Math.min(s,a):a;if(c>0){let u=o?(n.right+o.left)/2:n.right+c/.85,h=n.centerY;e.moveTo(u-c/2,h),e.lineTo(u+c/2,h),e.stroke()}}}};var $n=class extends rt{constructor(e,r){super(e);this.measure=e;this.tab=r;d(this,"voiceId");d(this,"mi");d(this,"tupletPartsTextObjMap",new yt);this.voiceId=ne().filter(n=>r.containsVoiceId(n)),this.rect=new G,this.mi=new bs(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let r=this.measure.getColumns(),n=ne().map(o=>H.Math.sum(r.map(s=>s.getVoiceSymbol(o)?1:0)));this.voiceId.sort((o,s)=>H.Math.cmp(n[o],n[s])),this.rect=new G}hasTuplets(){return this.measure.getBeamGroups().some(e=>e.isTuplet())}layoutFitToMeasure(e){let{unitSize:r,fontSize:n}=e,{measure:o}=this,s=o.getColumnsContentRect(),a=r*5;this.rect.left=s.left,this.rect.anchorX=s.centerX,this.rect.right=s.right,this.rect.top=this.hasTuplets()?-n:0,this.rect.anchorY=0,this.rect.bottom=a}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),e.color("black").lineWidth(1);let{unitSize:r,fontSize:n}=e,o=r,s=r,a=r*.25,{bottom:c,anchorY:u}=this.getRect(),h=u,l=c,p=this.measure.getColumns();for(let m=0;m<p.length;m++){let f=p[m],g=this.voiceId.map(C=>f.getVoiceSymbol(C)).find(C=>C!==void 0);if(!g)continue;let b=g.getBeamGroup(),x=b?b.getSymbols():[g];for(let C=0;C<x.length;C++){let I=x[C],T=x[C+1],S=I.col.getRect().anchorX;if(I instanceof xt){if(I.rhythmProps.noteSize>=2&&(e.lineWidth(I.rhythmProps.noteSize===4?2:1),e.strokeLine(S,l,S,h)),e.lineWidth(1),x.length===1)for(let v=0;v<I.rhythmProps.flagCount;v++)e.drawFlag(new G(S,S+o,h+v*o,h+(v+2)*o),"up");for(let v=0;v<I.rhythmProps.dotCount;v++)e.fillCircle(S+s*(v+1),l-a,a)}else if(I instanceof oe){let v=S,A=(h+l)/2,_=.65;e.save(),e.scale(_,_),e.drawRest(I.rhythmProps.noteSize,v/_,A/_),e.restore();for(let E=0;E<I.rhythmProps.dotCount;E++)v+=s*1.5,e.fillCircle(v,A+s,a)}if(T){let v=I,A=T,_=v.col.getRect().anchorX,E=A.col.getRect().anchorX,V=v.hasTuplet()?1:v instanceof xt?v.getRightBeamCount():1,M=A.hasTuplet()?1:A instanceof xt?A.getLeftBeamCount():1,R=Math.max(V,M);e.lineWidth(2);for(let P=0;P<R;P++){let D=M>V&&P>=V?.75:0,k=V>M&&P>=M?.25:1;e.strokePartialLine(_,h+P*o,E,h+P*o,D,k)}e.lineWidth(1);for(let P=0;P<v.rhythmProps.dotCount;P++)e.fillCircle(_+s*(P+1),l-a,a);for(let P=0;P<A.rhythmProps.dotCount;P++)e.fillCircle(E+s*(P+1),l-a,a)}if(b&&b.isTuplet()){let v=(x[0].col.getRect().anchorX+x[x.length-1].col.getRect().anchorX)/2,A=b.getTupletRatioText(),_=this.tupletPartsTextObjMap.get(A);_||(this.tupletPartsTextObjMap.set(A,_=new st(this,{text:A,scale:.75},.5,.5)),_.layout(e)),_.offset(-_.getRect().anchorX,-_.getRect().anchorY),_.offset(v,h-n/2),_.draw(e)}x.length>1&&(m=p.indexOf(x[x.length-1].col),m<0&&(m=p.length))}}}};function Av(i){if(typeof i=="string"&&(i=[i]),y.isArray(i)){let t=0;for(let e=0;e<i.length;){let r=i[e],n=i[e+1];if(typeof r=="string"){e++;let o=Xt.get(r).ticks;typeof n=="number"&&(e++,o*=n),t+=o}else e++}return t}else return i}function Cv(i){switch(i){case 1:return 8;case 2:return 9;case 3:return 10;default:throw new N(0,"VerseNumber is not 1, 2 or 3.")}}var vh=class{constructor(){d(this,"tabTuning_0",0);d(this,"signature_1",0);d(this,"leftBarLine_2",0);d(this,"padding_3",0);d(this,"columnsMin_4",0);d(this,"padding_5",0);d(this,"rightBarLine_6",0)}get leftSolid(){return this.tabTuning_0+this.signature_1+this.leftBarLine_2+this.padding_3}get columnsMin(){return this.columnsMin_4}get rightSolid(){return this.padding_5+this.rightBarLine_6}},Qn=class extends rt{constructor(e,r){super(e);this.row=e;this.options=r;d(this,"prevMeasure");d(this,"nextMeasure");d(this,"keySignature",Vs());d(this,"timeSignature",zs());d(this,"tempo",Ys());d(this,"alterKeySignature");d(this,"alterTimeSignature");d(this,"alterTempo");d(this,"signatures",[]);d(this,"tabStringNotes",[]);d(this,"barLineLeft");d(this,"columns",[]);d(this,"barLineRight");d(this,"connectives",[]);d(this,"beamGroups",[]);d(this,"measureId");d(this,"regions",new vh);d(this,"needLayout",!0);d(this,"voiceSymbols",Bs(new Ar));d(this,"lastAddedRhythmColumn");d(this,"lastAddedRhythmSymbol");d(this,"addExtensionToMusicObjects",[]);d(this,"layoutObjects",[]);d(this,"postMeasureBreakWidth",0);d(this,"passCount",0);d(this,"needBeamsUpdate",!0);d(this,"navigationSet",new Fs);d(this,"isEndSong",!1);d(this,"isEndSection",!1);d(this,"endRepeatPlayCount",2);d(this,"endRepeatPlayCountText");d(this,"staticObjectsCache",new yt);d(this,"lyricsObjectsCache",new Ps);d(this,"mi");this.mi=new xs(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new gi(this),this.barLineRight=new Yr(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo(),this.row.getTabs().forEach(n=>{this.addLayoutObject(new $n(this,n),n,0,0)})}getMusicInterface(){return this.mi}get doc(){return this.row.doc}isPartialMeasure(){return this.getConsumedTicks()<this.getMeasureTicks()}isUpBeat(){return this===this.doc.getFirstMeasure()}resetPassCount(){this.passCount=0}incPassCount(){this.passCount++}getPassCount(){return this.passCount}updateRunningArguments(e){var n;e!=null||(e=[]);let r=H.Math.sum(ne().map(o=>this.getVoiceSymbols(o).length>0?1:0));ne().forEach(o=>{var h;let s=()=>{let l=this.row.getStaves().filter(m=>m.containsVoiceId(o)),p=this.row.getTabs().filter(m=>m.containsVoiceId(o));return l.length>0?l[0].middleLineDiatonicId:p.length>0?p[0].getTuningStrings()[3].diatonicId:W.getNote("G4").diatonicId},a=()=>"auto",c=()=>[],u=(h=e[o])!=null?h:e[o]={diatonicId:s(),stemDir:a(),stringNumbers:c()};this.getVoiceSymbols(o).forEach((l,p,m)=>{var b,x;if(l.setDiatonicId===oe.UndefinedDiatonicId?r<2&&(u.diatonicId=oe.UndefinedDiatonicId):u.diatonicId=l.setDiatonicId,l instanceof xt)switch(l.setStringsNumbers&&(u.stringNumbers=l.setStringsNumbers),(b=l.options)==null?void 0:b.stem){case"up":case"up":u.stemDir="up";break;case"down":case"down":u.stemDir="down";break;case"auto":case"auto":u.stemDir="auto";break}let f=(x=l.getBeamGroup())==null?void 0:x.getSymbols(),g;f===void 0?g=u.stemDir==="auto"?this.row.solveAutoStemDir([l]):u.stemDir:l===f[0]?g=u.stemDir==="auto"?this.row.solveAutoStemDir(f):u.stemDir:g=f[0].stemDir,l.updateRunningArguments(u.diatonicId,g,u.stringNumbers)})}),(n=this.getNextMeasure())==null||n.updateRunningArguments(e)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let n=0;n<this.signatures.length;n++){let o=this.signatures[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.tabStringNotes.length;n++){let o=this.tabStringNotes[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.columns.length;n++){let o=this.columns[n].pick(e,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let n=this.barLineLeft.pick(e,r);if(n.length>0)return[this,...n]}if(this.barLineRight){let n=this.barLineRight.pick(e,r);if(n.length>0)return[this,...n]}if(this.endRepeatPlayCountText){let n=this.endRepeatPlayCountText.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.connectives.length;n++){let o=this.connectives[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.beamGroups.length;n++){let o=this.beamGroups[n].pick(e,r);if(o.length>0)return[this,...o]}for(let n=0;n<this.layoutObjects.length;n++){let o=this.layoutObjects[n].musicObj.pick(e,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let e=this.doc.getFirstMeasure();return e&&e.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(e){return this.getColumns()[e]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...e){var r;if((r=this.getPrevMeasure())==null||r.endSection(),e[0]instanceof tr)this.alterKeySignature=e[0];else if(e[0]instanceof ei)this.alterKeySignature=e[0];else if(y.isNonEmptyString(e[0])){if(e.length===1)this.alterKeySignature=Dr(e[0]);else if(e.length===2)try{let n=""+e[0],o=uo(""+e[1]);this.alterKeySignature=Dr(n,o)}catch(n){throw new N(6,"Cannot set key signature because invalid args: "+e)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:Vs(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(e){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=e,this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:zs(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r,n){var o;if((o=this.getPrevMeasure())==null||o.endSection(),r===void 0)this.alterTempo={beatsPerMinute:e};else{let s=typeof n=="number"&&n>0?n:n===!0?1:Tt.get(r).dotCount,a={beatLength:Lr(r),dotCount:s>0?s:void 0};this.alterTempo={beatsPerMinute:e,options:a}}this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:Ys(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,n,o;this.alterTempo.options?(n=this.alterTempo.options.beatLength,o=(e=this.alterTempo.options.dotCount)!=null?e:0):this.alterTimeSignature?(n=this.alterTimeSignature.beatLength,o=0):(n=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:n,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,n,o){this.layoutObjects.push(new ec(e,r,n,o)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(e,r,n){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&n(o[a],c);else if(typeof a=="string"&&a.length>0){let h=o.filter(l=>l.name===a);if(h.forEach(l=>n(l,c)),h.length===0){let l=this.doc.getStaffGroup(a);if(l&&!u.includes(a)){let p=[...u,a];(y.isArray(l.staffsTabsAndGroups)?l.staffsTabsAndGroups:[l.staffsTabsAndGroups]).forEach(m=>{switch(l.verticalPosition){case"above":s(m,0,p);break;case"below":s(m,1,p);break;case"both":s(m,0,p),s(m,1,p);break;case"auto":s(m,r,p);break}})}}}};e===void 0?o.length>=2&&o[0]instanceof kt&&o[1]instanceof kt&&o[0].staffConfig.grandId!==void 0&&o[0].staffConfig.grandId===o[1].staffConfig.grandId?s(r===1?1:0,r):s(0,r):y.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let n=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!n)throw new N(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(o,s)=>{this.addLayoutObject(new Hn(n,s),o,1,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof Hn&&r.anchor===e)}addNavigation(e,r,...n){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new N(6,"Cannot add ending beasure measure already has one.");let s=this,a=n;o={createObj:()=>new Ui(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=os(r);o={createObj:()=>new st(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0},this.addNavigation(e,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=os(r);o={createObj:()=>new st(c,u,1,1),layoutGroupId:3,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=os(r);o={createObj:()=>new yr(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=os(r);o={createObj:()=>new yr(c,u),layoutGroupId:3,defaultVerticalPos:0};break}case"endRepeat":if(n.length===0)this.endRepeatPlayCount=2;else if(y.isIntegerGte(n[0],2))this.endRepeatPlayCount=n[0];else throw new N(6,"Invalid end repeat play count (should be 2 or greater integer): "+n[0]);if(this.endRepeatPlayCount!==2){let c={text:""+this.endRepeatPlayCount+"x",scale:.8};this.endRepeatPlayCountText=new st(this,c,.5,1)}break}o&&this.forEachStaffGroup(e,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,n){let o=this.lastAddedRhythmColumn;if(o){if(n.length===0)throw new N(6,"Cannot add annotation because annotation text is empty.")}else throw new N(6,"Cannot add annotation because anchor is undefined.");let s={text:n},a,c;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(e,c,(u,h)=>{let l=new st(o,s,.5,1);this.addLayoutObject(l,u,a,h),this.enableExtension(l)})}addLabel(e,r,n){let o=this.lastAddedRhythmColumn;if(o){if(n.length===0)throw new N(6,"Cannot add label because label text is empty.")}else throw new N(6,"Cannot add label because anchor is undefined.");let s={text:n},a,c;switch(r){case"note":a=2,c=1;break;case"chord":a=7,c=0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,h)=>{let l=new st(o,s,.5,1);this.addLayoutObject(l,u,a,h),this.enableExtension(l)})}addConnective(e,...r){let n=this.lastAddedRhythmSymbol;if(!(n instanceof xt))throw new N(6,"Connective can be added to note group only.");if(e==="tie"){let o=y.isInteger(r[0])||y.isEnumValue(r[0],fr)?r[0]:2,s=y.isEnumValue(r[1],$e)?r[1]:"auto";n.startConnective(new Xn("tie",o,s,n))}else if(e==="slur"){let o=y.isInteger(r[0])?r[0]:2,s=y.isEnumValue(r[1],$e)?r[1]:"auto";n.startConnective(new Xn("slur",o,s,n))}else if(e==="slide"){let o=y.isEnumValue(r[0],$e)?r[0]:"auto";n.startConnective(new Xn("slide",2,o,n))}}addExtension(e,r){if(this.addExtensionToMusicObjects.forEach(n=>{let o=n.getParent();if(n instanceof st&&o instanceof zr){let s="dashed",a="bottom",c=new Wi(n,o,Av(e),r,s,a);n.setLink(c)}else throw new N(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new N(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(e){this.addExtensionToMusicObjects.push(e)}disableExtension(){this.addExtensionToMusicObjects=[]}getEnding(){return this.layoutObjects.map(e=>e.musicObj).find(e=>e instanceof Ui)}getEndRepeatPlayCount(){return this.endRepeatPlayCount}endSong(){this.isEndSong=!0,this.requestLayout(),this.disableExtension()}hasEndSong(){return this.isEndSong}endSection(){this.isEndSection=!0,this.requestLayout(),this.disableExtension()}hasEndSection(){return this.isEndSection}endRow(){this.doc.requestNewRow(),this.disableExtension()}addRhythmSymbol(e){let{col:r,voiceId:n}=e;r.setVoiceSymbol(n,e),this.voiceSymbols.add(n,e),e.oldStyleTriplet&&this.createOldStyleTriplets(n),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=r,this.lastAddedRhythmSymbol=e}addNoteGroup(e,r,n,o,s){let a=r.map(h=>typeof h=="string"?W.getNote(h):h),c=this.getRhythmColumn(e),u=new xt(c,e,a,n,o,s);return this.addRhythmSymbol(u),u}addRest(e,r,n,o){let s=this.getRhythmColumn(e),a=new oe(s,e,r,n,o);return this.addRhythmSymbol(a),a}addLyrics(e,r,n,o,s){this.forEachStaffGroup(e,1,(a,c)=>{var p;let u=this.getRhythmColumn({verse:r,line:a,vpos:c}),h=new Ja(u,r,a,c,Lr(n),o,s);u.addLyricsObject(h);let l=this.lyricsObjectsCache.getOrCreate(a,c,r,[]);l.push(h),l.sort((m,f)=>H.Math.cmp(m.col.positionTicks,f.col.positionTicks)),(p=h.measure.getPrevLyricsObject(h))==null||p.setNextLyricsObject(h),this.addLayoutObject(h,a,Cv(r),c),this.lastAddedRhythmColumn=u})}getRhythmColumn(e){let r=0;for(let n=this.columns.length-1;n>=0&&r===0;n--){let o=this.columns[n],s=typeof e=="number"?o.getVoiceSymbol(e):o.getLyricsObject(e.verse,e.line,e.vpos);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let n=0;n<=this.columns.length;n++){let o=this.columns[n];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new zr(this,r);return this.columns.splice(n,0,s),s}}throw new N(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(n=>{ne().forEach(o=>{let s=n.getVoiceSymbol(o);s&&(e===void 0||e===o)&&(r=Math.max(r,n.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new G(this.barLineLeft.getRect().anchorX,this.barLineRight.getRect().anchorX,this.getRect().top,this.getRect().bottom)}getLeftSolidWidth(){return this.regions.leftSolid}getMinColumnsWidth(){return this.regions.columnsMin}getRightSolidWidth(){return this.regions.rightSolid}getTotalSolidWidth(){return this.getLeftSolidWidth()+this.getRightSolidWidth()}getMinWidth(){return this.getLeftSolidWidth()+this.getMinColumnsWidth()+this.getRightSolidWidth()}getStaffLineLeft(){let e=this.getPrevMeasure();return e&&e.row===this.row&&!e.hasPostMeasureBreak()?e.getStaffLineRight():this.getRect().left+this.regions.tabTuning_0}getStaffLineRight(){return this.barLineRight.getRect().anchorX}getPrevLyricsObject(e){var c;let{line:r,verse:n,vpos:o}=e,s=this.lyricsObjectsCache.getOrDefault(r,o,n,[]),a=s.indexOf(e);if(a>0)return s[a-1];if(a===0){let u=(c=e.measure.getPrevMeasure())==null?void 0:c.lyricsObjectsCache.get(r,o,n);if(u&&u.length>0)return u[u.length-1]}}getStaticObjects(e){let r=this.layoutObjects.filter(o=>o.line===e&&o.isPositionResolved()).map(o=>o.musicObj),n=r.length>0?[...this.staticObjectsCache.getOrDefault(e,[]),...r]:this.staticObjectsCache.getOrDefault(e,[]);return n.forEach(o=>o.getRect()),n}addStaticObject(e,r){this.staticObjectsCache.getOrCreate(e,[]).push(r)}removeLayoutObjects(e){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===e){let n=r.musicObj.getLink();return n&&n.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(e){this.connectives.push(e),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(e=>{var c;let{musicObj:r,measure:n,layoutGroupId:o,verticalPos:s,line:a}=e;if(r.getLink()instanceof Wi){let u=r.getLink();if(u.getHead()===r){u.getTails().forEach(p=>n.removeLayoutObjects(p));let{startColumn:h,endColumn:l}=u.getExtensionRangeInfo();if(u.isVisible()&&h!==l)for(let p=h.measure;p!==void 0;p=p===l.measure?void 0:p.getNextMeasure()){let m=p===h.measure?u.getHead():p.getBarLineLeft(),f=p===l.measure?l:p.getBarLineRight(),g=p.row.getNotationLines(),b=(c=g.find(x=>x.name!==""&&x.name===a.name))!=null?c:g[a.id];b&&p.addLayoutObject(new Zn(p,b,u,m,f),b,o,s)}}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);for(let n=0;n<r.length;)if(r[n].oldStyleTriplet){let o=zi.createOldStyleTriplet(r.slice(n,n+3));n+=o===0?1:o}else n++;this.requestLayout()}getBeamGroups(){return this.beamGroups}createBeams(){if(!this.needBeamsUpdate)return;this.beamGroups=this.beamGroups.filter(r=>r.isTuplet()?!0:(r.detach(),!1));let e=this.getTimeSignature();!this.needBeamsUpdate||e.beamGroupSizes.length===0||(ne().forEach(r=>{let n=this.getVoiceSymbols(r).slice();if(n.length<2)return;let o=this.isUpBeat()?Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()):0,s=0;for(let a=0;a<e.beamGroupSizes.length;a++){let c=e.beamGroupSizes[a],u=[c];c.length>1&&u.unshift([H.Math.sum(c)]);let h=!1,l=s;for(;u.length>0&&!h;){let p=u.shift();s=l,p.forEach(m=>{let f=m*Tt.get("8n").ticks,g=s+f,b=n.filter(C=>{let I=o+C.col.positionTicks,T=I+C.rhythmProps.ticks;return I>=s&&T<=g});H.Math.sum(b.map(C=>C.rhythmProps.ticks))===f&&b.every(C=>C instanceof xt)&&(b.every(C=>C.rhythmProps.flagCount===1)||u.length===0)&&zi.createBeam(b)&&(h=!0),s+=f})}}}),this.needBeamsUpdate=!1,this.requestLayout())}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return this.voiceSymbols.getAll(e)}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(ne().filter(r=>this.getConsumedTicks(r)>0));return}else if(y.isArray(e)){e.forEach(r=>this.completeRests(r));return}else{Fo(e);let r=this.getMeasureTicks(),n=this.getConsumedTicks(e),o=r-n,s=[];for(;o>0;)for(let a=Tt.LongestNoteSize;a<=Tt.ShortestNoteSize;a*=2){let c=Tt.create(a).noteLength;for(let u=Tt.get(c).maxDotCount;u>=0;u--){let h=Xt.get(c,u);for(;h.ticks<=o;)s.push(h),o-=h.ticks}}s.reverse().forEach(a=>this.addRest(e,a.noteLength,{dotted:a.dotCount}))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?at.PostMeasureBreakWidth*r:0;let n=this===this.row.getFirstMeasure(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.regions.tabTuning_0=n&&this.row.hasTab?r*4:0;let s=n||o,a=this.options.showNumber===!1?!1:this.options.showNumber===!0||n&&!this.row.isFirstRow(),c=n||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,h=!!this.alterTempo;this.signatures=[],this.row.getNotationLines().forEach((f,g)=>{if(f instanceof kt&&(s||a||c||u||h)){let b=this.signatures.filter(C=>C instanceof Ho).find(C=>C.staff===f),x=b!=null?b:new Ho(this,f);x.staff.addObject(x),x.updateClefImage(e,s),x.updateMeasureNumber(a&&g===0),x.updateKeySignature(c),x.updateTimeSignature(u),x.updateTempo(h&&g===0),x.layout(e),this.signatures.push(x)}else if(f instanceof he&&(a||u||h)){let b=this.signatures.filter(C=>C instanceof Zo).find(C=>C.tab===f),x=b!=null?b:new Zo(this,f);x.tab.addObject(x),x.updateMeasureNumber(a&&g===0),x.updateTimeSignature(u),x.updateTempo(h&&g===0),x.layout(e),this.signatures.push(x)}}),this.tabStringNotes.length=0,this===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 st(this,{text:b,scale:.8},1,.5);x.layout(e),x.offset(this.regions.tabTuning_0*.8,f.getStringY(g)),this.tabStringNotes.push(x),f.addObject(x)}}),this.barLineLeft.layout(e);let l=new Ya(this);this.columns.forEach(f=>f.layout(e,l)),this.columns.forEach(f=>f.layoutReserveSpace(e)),this.barLineRight.layout(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(e),this.layoutObjects.forEach(f=>f.layout(e));let p=e.unitSize;this.regions.signature_1=Math.max(0,...this.signatures.map(f=>f.getRect().width)),this.regions.leftBarLine_2=this.barLineLeft.getRect().width,this.regions.padding_3=p,this.regions.columnsMin_4=Math.max(at.MinColumnsWidth*r,this.columns.map(f=>f.getRect().width).reduce((f,g)=>f+g)),this.regions.padding_5=p,this.regions.rightBarLine_6=this.barLineRight.getRect().width}layoutWidth(e,r){var p;if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new G,this.rect.anchorX=this.rect.left+r/2,this.rect.right=this.rect.left+r;let n;this.signatures.forEach(m=>{n=m.getRect(),m.offset(this.rect.left+this.regions.tabTuning_0-n.left,-n.anchorY)});let o=Math.max(0,...this.signatures.map(m=>m.getRect().width));n=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.regions.tabTuning_0+o-n.left,-n.anchorY),n=this.barLineRight.getRect(),this.barLineRight.offset(this.rect.right-n.right,-n.anchorY),(p=this.endRepeatPlayCountText)==null||p.offset(this.barLineRight.getRect().left,this.barLineRight.getRect().top);let s=this.rect.left+this.regions.leftSolid,c=this.rect.right-this.regions.rightSolid-s,u=this.regions.columnsMin,h=c/u,l=s;this.columns.forEach(m=>{n=m.getRect();let f=l+n.leftw*h;m.offset(f-n.anchorX,-n.anchorY),l+=n.width*h}),ne().forEach(m=>{let f=this.getVoiceSymbols(m),g=f.length===1&&f[0]instanceof oe?f[0]:void 0;if(!g||ne().map(C=>g.col.getVoiceSymbol(C)).filter(C=>C!==void 0&&C!==g).length===0)return;let x=this.getColumnsContentRect();g.offset(x.centerX-g.getRect().anchorX,0)})}layoutConnectives(e){this.needLayout&&this.connectives.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(e){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}alignStemsToBeams(){this.beamGroups.forEach(e=>e.updateStemTips())}layoutDone(){this.columns.forEach(e=>e.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(e=>e.getRect().top),...this.tabStringNotes.map(e=>e.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(e=>e.getRect().top),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(e=>e.getRect().bottom),...this.tabStringNotes.map(e=>e.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(e=>e.getRect().bottom),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().bottom)),this===this.row.getLastMeasure()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(e=>e.isPositionResolved()&&e.musicObj instanceof Hn).map(e=>e.musicObj.getRect().right))),this.row.getNotationLines().forEach(e=>{this.rect.top=Math.min(this.rect.top,e.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,e.calcBottom())}),this.row.requestRectUpdate()}offset(e,r){this.signatures.forEach(n=>n.offset(e,0)),this.tabStringNotes.forEach(n=>n.offset(e,0)),this.barLineLeft.offset(e,r),this.columns.forEach(n=>n.offset(e,r)),this.barLineRight.offset(e,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(e,r),this.connectives.forEach(n=>n.offset(e,0)),this.beamGroups.forEach(n=>n.offset(e,r)),this.layoutObjects.forEach(n=>n.offset(e,0)),this.rect.offsetInPlace(e,r),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let r=this.getStaffLineLeft(),n=this.getStaffLineRight();e.color("black").lineWidth(1);let o=s=>e.strokeLine(r,s,n,s);this.row.getNotationLines().forEach(s=>{if(s instanceof kt)for(let a=s.bottomLineDiatonicId;a<=s.topLineDiatonicId;a+=2)o(s.getDiatonicIdY(a));else if(s instanceof he)for(let a=0;a<6;a++)o(s.getStringY(a))}),this.signatures.forEach(s=>s.draw(e)),this.tabStringNotes.forEach(s=>s.draw(e)),this.barLineLeft.draw(e),this.columns.forEach(s=>s.draw(e)),this.barLineRight.draw(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(e),this.connectives.forEach(s=>s.draw(e)),this.layoutObjects.forEach(s=>s.musicObj.draw(e)),this.beamGroups.forEach(s=>s.draw(e))}};var tc=(l=>(l[l.TabRhythm=0]="TabRhythm",l[l.Fermata=1]="Fermata",l[l.NoteLabel=2]="NoteLabel",l[l.Navigation=3]="Navigation",l[l.Ending=4]="Ending",l[l.TempoAnnotation=5]="TempoAnnotation",l[l.DynamicsAnnotation=6]="DynamicsAnnotation",l[l.ChordLabel=7]="ChordLabel",l[l.LyricsVerse1=8]="LyricsVerse1",l[l.LyricsVerse2=9]="LyricsVerse2",l[l.LyricsVerse3=10]="LyricsVerse3",l))(tc||{}),Ih=new yt([[0,{rowAlign:!0}],[1,{reserveSpace:!0}],[2,{reserveSpace:!0}],[3,{rowAlign:!0}],[4,{rowAlign:!0,padding:2}],[5,{rowAlign:!0,padding:2}],[6,{rowAlign:!0,padding:2}],[7,{reserveSpace:!0,rowAlign:!0}],[8,{reserveSpace:!0,rowAlign:!0}],[9,{reserveSpace:!0,rowAlign:!0}],[10,{reserveSpace:!0,rowAlign:!0}]]);function _v(i){for(;i;){if(i instanceof Qn)return i;i=i.getParent()}throw new N(6,"Parent measure is required but not found!")}var rc=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},ec=class{constructor(t,e,r,n){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=n;d(this,"anchor");d(this,"measure");d(this,"row");d(this,"layoutGroup");d(this,"positionResolved",!0);this.measure=_v(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new N(6,"Parent music object is required as an anchor.");this.anchor=o,this.anchor.addAnchoredLayoutObject(this),this.layoutGroup=this.line.getLayoutGroup(r),this.layoutGroup.add(this)}resetPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(t){let{musicObj:e,measure:r,verticalPos:n,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=t.unitSize*2,u=n===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,h=r.getStaticObjects(o),l=e.getShapeRects();return h.forEach(p=>{let m=p.getShapeRects();l.forEach(f=>{m.forEach(g=>{G.overlapX(f,g)&&(u=n===1?Math.max(u,g.bottom+f.toph+f.anchorY):Math.min(u,g.top-f.bottomh-f.anchorY))})})}),u}getTextContent(){if(this.musicObj instanceof st||this.musicObj instanceof yr)return this.musicObj.getText()}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}getRect(){return this.musicObj.getRect()}},ic=class{constructor(t){this.layoutGroupId=t;d(this,"layoutObject",Bs(new Ar));d(this,"rowAlign");d(this,"reserveSpace");d(this,"padding");var e,r,n,o;this.rowAlign=((e=Ih.get(t))==null?void 0:e.rowAlign)===!0,this.reserveSpace=((r=Ih.get(t))==null?void 0:r.reserveSpace)===!0,this.padding=(o=(n=Ih.get(t))==null?void 0:n.padding)!=null?o:0}getLayoutObjects(t){return this.layoutObject.getAll(t)}add(t){this.layoutObject.add(t.verticalPos,t)}remove(t){this.layoutObject.remove(t.verticalPos,t)}layout(t){for(let e of this.layoutObject.values())e.resetPositionResolved(),e.musicObj.layout(t)}getPadding(t){return this.padding*t.unitSize}};var nc=class extends rt{constructor(e){super(e);this.row=e;d(this,"objects",[]);d(this,"layoutGroups",new yt)}addObject(e){this.objects.push(e)}removeObjects(){this.objects.length=0}getLayoutGroup(e){return this.layoutGroups.getOrCreate(e,()=>new ic(e))}resetLayoutGroups(e){this.layoutGroups.forEach(r=>r.layout(e))}layoutLayoutGroups(e){for(let r of H.Enum.getEnumValues(tc)){let n=this.getLayoutGroup(r);n&&(this.layoutLayoutGroup(e,n,0),this.layoutLayoutGroup(e,n,1))}}setObjectY(e,r){r!==void 0&&(e.offset(0,r-e.getRect().anchorY),e.setPositionResolved())}alignObjectsY(e,r,n){let o=r.filter(u=>!u.isPositionResolved()&&u.verticalPos===n);if(o.length===0)return;let s=n===1?1:-1,a=o.map(u=>u.resolveClosestToStaffY(e)+u.layoutGroup.getPadding(e)*s),c=n===1?Math.max(...a):Math.min(...a);o.forEach(u=>this.setObjectY(u,c))}layoutLayoutGroup(e,r,n){let o=r.getLayoutObjects(n).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof Ui||a instanceof Zn||a instanceof $n?a.layoutFitToMeasure(e):a.offset(c.getRect().anchorX-a.getRect().anchorX,0)}),r.rowAlign?this.alignObjectsY(e,o,n):o.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=o.filter(h=>c.some(l=>l===h.musicObj));this.alignObjectsY(e,u,n)}else this.alignObjectsY(e,[s],n)})}},kt=class extends nc{constructor(e,r,n){super(e);this.row=e;this.staffConfig=r;this.id=n;d(this,"clefImageAsset");d(this,"clefLineDiatonicId");d(this,"topLineDiatonicId");d(this,"middleLineDiatonicId");d(this,"bottomLineDiatonicId");d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"joinedGrandStaff");d(this,"topLineY",0);d(this,"bottomLineY",0);d(this,"mi");let o=(s,a)=>W.getNote(s).diatonicId-(a?7:0);if(r.clef==="G")this.clefImageAsset=0,this.clefLineDiatonicId=o("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2;else if(r.clef==="F")this.clefImageAsset=1,this.clefLineDiatonicId=o("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2;else throw new N(6,`Invalid staffConfig.clef ${r.clef}.`);this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(o(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(o(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new As(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var e;return(e=this.staffConfig.name)!=null?e:""}getConfig(){return this.staffConfig}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(e){e!==this&&(this.joinedGrandStaff=e)}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(e){return W.validateDiatonicId(e),(this.minDiatonicId===void 0||e>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||e<=this.maxDiatonicId)}getDiatonicIdY(e){if(this.containsDiatonicId(e))return this.bottomLineY+(this.bottomLineDiatonicId-e)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff.getDiatonicIdY(e);throw new N(6,"Staff does not contain diatonicId "+e)}getActualStaff(e){if(this.containsDiatonicId(e))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff;throw new N(6,"Staff does not contain diatonicId "+e)}getDiatonicIdAt(e){let r=Math.round(this.bottomLineDiatonicId-(e-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(e){return e%2===this.middleLineDiatonicId%2}isSpace(e){return e%2!==this.middleLineDiatonicId%2}containsVoiceId(e){return y.isUndefined(this.staffConfig.voiceId)||H.Arr.toArray(this.staffConfig.voiceId).includes(e)}calcTop(){let e=this.topLineY;if(this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),n=this.getDiatonicIdY(this.maxDiatonicId-1);e=Math.min(e,r-Math.abs(n-r)+1)}return e}calcBottom(){let e=this.bottomLineY;if(this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),n=this.getDiatonicIdY(this.minDiatonicId+1);e=Math.max(e,r+Math.abs(n-r)-1)}return e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,n=r*at.StaffHeight;this.topLineY=-n/2,this.bottomLineY=n/2,this.rect=new G(0,0,this.topLineY,this.bottomLineY)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(n=>{n.offsetInPlace?n.offsetInPlace(0,r):n.offset&&n.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}},he=class extends nc{constructor(e,r,n){super(e);this.row=e;this.tabConfig=r;this.id=n;d(this,"top",0);d(this,"bottom",0);d(this,"tuningName");d(this,"tuningStrings");d(this,"mi");y.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>W.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=au(r.tuning),this.tuningStrings=Ws(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=Ws(this.tuningName)),this.mi=new Cs(this)}getMusicInterface(){return this.mi}get name(){var e;return(e=this.tabConfig.name)!=null?e:""}getConfig(){return this.tabConfig}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(e){return this.top+(this.bottom-this.top)/6*(e+.5)}getTopStringY(){return this.getStringY(0)}getBottomStringY(){return this.getStringY(5)}getTopLineY(){return this.getTopStringY()}getBottomLineY(){return this.getBottomStringY()}getTop(){return this.top}getBottom(){return this.bottom}containsVoiceId(e){return y.isUndefined(this.tabConfig.voiceId)||H.Arr.toArray(this.tabConfig.voiceId).includes(e)}containsDiatonicId(e){return!0}calcTop(){let{top:e}=this;return this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),e}calcBottom(){let{bottom:e}=this;return this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),e}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}layoutHeight(e){let{unitSize:r}=e,n=r*at.TabHeight;this.top=-n/2,this.bottom=n/2,this.rect=new G(0,0,this.top,this.bottom)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.top+=r,this.bottom+=r,this.objects.forEach(n=>{n.offsetInPlace?n.offsetInPlace(0,r):n.offset&&n.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}};var oc=class extends rt{constructor(e,r,n){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=n;d(this,"nextRow");d(this,"minWidth",0);d(this,"notationLines");d(this,"instrumentLineGroups");d(this,"staves");d(this,"tabs");d(this,"instrumentNames");d(this,"measures",[]);d(this,"needLayout",!0);d(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(s=>s instanceof kt),this.tabs=this.notationLines.filter(s=>s instanceof he);let o=[];for(let s=0;s<this.notationLines.length;s++){let a=this.notationLines[s],c=o[o.length-1];c===void 0||c[0].getConfig().instrument===void 0||c[0].getConfig().instrument!==a.getConfig().instrument?o.push([a]):c.push(a)}this.instrumentLineGroups=o,this.instrumentNames=this.instrumentLineGroups.map(s=>s.length>0&&y.isNonEmptyString(s[0].getConfig().instrument)?new st(this,String(s[0].getConfig().instrument),0,.5):void 0),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new _s(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,n)=>r.type==="staff"?new kt(this,r,n):new he(this,r,n));for(let r=0;r<e.length-1;r++){let n=e[r],o=e[r+1];n instanceof kt&&o instanceof kt&&n.staffConfig.grandId!==void 0&&n.staffConfig.grandId===o.staffConfig.grandId&&(n.joinGrandStaff(o),o.joinGrandStaff(n))}return e}getNotationLines(){return this.notationLines}getInstrumentLineGroups(){return this.instrumentLineGroups}findMatchingLine(e){return e.row===this?e:this.notationLines.find(r=>H.Obj.deepEqual(e.row.scoreConfig,r.row.scoreConfig)&&e.id===r.id||y.isNonEmptyString(e.getConfig().name)&&e.getConfig().name===r.getConfig().name&&e.getConfig().type===r.getConfig().type)}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let e=this.staves[0];if(e)return e;throw new N(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new N(6,"Bottom staff is required!")}getStaff(e){W.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let n=this.notationLines[r];if(n instanceof kt&&n.containsDiatonicId(e))return n}}resetLayoutGroups(e){this.notationLines.forEach(r=>r.resetLayoutGroups(e))}layoutLayoutGroups(e){this.notationLines.forEach(r=>r.layoutLayoutGroups(e))}pick(e,r){var n,o;if(!this.getRect().contains(e,r))return[];for(let s=0;s<this.measures.length;s++){let a=this.measures[s].pick(e,r);if(a.length>0)return[this,...a]}for(let s=0;s<this.instrumentNames.length;s++){let a=(o=(n=this.instrumentNames[s])==null?void 0:n.pick(e,r))!=null?o:[];if(a.length>0)return[this,...a]}for(let s=0;s<this.notationLines.length;s++){let a=this.notationLines[s].pick(e,r);if(a.length>0)return[this,...a]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),n=r?r.getColumnsContentRect().left:e.left;return new G(n,(n+e.right)/2,e.right,e.top,e.anchorY,e.bottom)}getDiatonicIdAt(e){for(let r=0;r<this.notationLines.length;r++){let n=this.notationLines[r],o=n instanceof kt?n.getDiatonicIdAt(e):void 0;if(o!==void 0)return o}}addMeasure(e){this.measures.push(e)}getMeasures(){return this.measures}isFirstRow(){return this===this.doc.getFirstRow()}isLastRow(){return this===this.doc.getLastRow()}getPrevRow(){return this.prevRow}getNextRow(){return this.nextRow}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}getMinWidth(){return this.minWidth}solveAutoStemDir(e){if(e.length===0)return"up";{let r=e[0].voiceId,n=e.filter(u=>u instanceof xt).map(u=>u.setDiatonicId),o=e.filter(u=>u instanceof oe&&u.setDiatonicId!==oe.UndefinedDiatonicId).map(u=>u.setDiatonicId);if(n.length===0&&o.length===0)return"up";let s=n.length>0?n:o,a=Math.floor(H.Math.avg(...s)),c=this.getStaves().filter(u=>u.containsVoiceId(r)&&u.containsDiatonicId(a));return c.length>0?a>=c[0].middleLineDiatonicId?"down":"up":"up"}}getInstrumentNameWidth(e){return Math.max(0,...this.instrumentNames.map(r=>r?r.getRect().width:0))}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(e){this.needLayout&&(this.requestRectUpdate(),this.instrumentNames.forEach(r=>r==null?void 0:r.layout(e)),this.notationLines.forEach(r=>{r.removeObjects(),r.layoutHeight(e)}),this.minWidth=0,this.measures.forEach(r=>{r.layout(e),this.minWidth+=r.getMinWidth(),this.minWidth+=r.getPostMeasureBreakWidth()}))}layoutWidth(e,r,n){if(!this.needLayout)return;this.rect=new G(0,n,0,0),this.notationLines.forEach(u=>u.layoutWidth(e));let o=n-r,s=0;this.measures.forEach(u=>{o-=u.getTotalSolidWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsWidth()});let a=o/s,c=this.doc.getInstrumentGroupRegions(e).braceRight;this.measures.forEach(u=>{let h=u.getTotalSolidWidth()+u.getMinColumnsWidth()*a;u.layoutWidth(e,h);let l=u.getRect();u.offset(c-l.left,-l.anchorY),c+=l.width,c+=u.getPostMeasureBreakWidth()}),this.measures.forEach(u=>{u.layoutConnectives(e),u.layoutBeams(e)})}updateRect(){let e=0,r=this.measures.length>0?this.measures[this.measures.length-1].getRect().right:e,n=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 G(e,r,n,o)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutSetNotationLines(e){let{unitSize:r}=e;for(let n=1;n<this.notationLines.length;n++){let o=this.notationLines[n-1],s=this.notationLines[n];if(o instanceof kt&&s instanceof kt&&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(n=>{n.requestRectUpdate(),n.getBarLineLeft().requestRectUpdate(),n.getBarLineRight().requestRectUpdate(),n.getColumns().forEach(o=>{o.requestRectUpdate(),ne().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.instrumentNames.forEach((n,o)=>{let s=this.instrumentLineGroups[o];n&&s.length>0&&n.offset(-n.getRect().left,-n.getRect().anchorY+(s[0].getRect().top+s[s.length-1].getRect().bottom)/2)}),this.alignStemsToBeams(),this.requestRectUpdate()}layoutPadding(e){let r=e.unitSize/2;this.getRect(),this.rect.left-=r,this.rect.right+=r,this.rect.top-=r,this.rect.bottom+=r}layoutDone(){this.measures.forEach(e=>e.layoutDone()),this.needLayout=!1}offset(e,r){this.measures.forEach(n=>n.offset(e,r)),this.rect.offsetInPlace(e,r),this.notationLines.forEach(n=>n.offset(e,r)),this.instrumentNames.forEach(n=>n==null?void 0:n.offset(e,r))}draw(e){e.drawDebugRect(this.getRect()),e.save();let{left:r,top:n,width:o,height:s}=this.getRect();if(e.rect(r,n,o,s),e.clip(),this.getFirstMeasure()&&(this.notationLines.length>1||this.notationLines[0]instanceof he)){let c=this.getFirstMeasure().getStaffLineLeft(),u=Math.min(...this.notationLines.map(l=>l.getTopLineY())),h=Math.max(...this.notationLines.map(l=>l.getBottomLineY()));e.color("black").lineWidth(1).strokeLine(c,u,c,h)}this.measures.forEach(c=>c.draw(e)),this.notationLines.forEach(c=>c.draw(e));let a=this.doc.getInstrumentGroupRegions(e);this.instrumentNames.forEach((c,u)=>{let h=this.instrumentLineGroups[u];if(h.length>1){let l=new G(a.braceLeft,a.braceRight,h[0].getTopLineY(),h[h.length-1].getBottomLineY());e.color("brack").lineWidth(1).drawBrace(l,"left")}c&&c.draw(e)}),e.restore()}};var sc=class extends rt{constructor(e,r,n,o){super(e);this.title=r;this.composer=n;this.arranger=o;d(this,"titleText");d(this,"composerText");d(this,"arrangerText");d(this,"mi");this.mi=new vs(this),this.titleText=this.title?new st(this,{text:this.title,scale:2},.5,0):void 0,this.composerText=this.composer?new st(this,this.composer,1,0):void 0,this.arrangerText=this.arranger?new st(this,"Arr.: "+this.arranger,1,0):void 0}getMusicInterface(){return this.mi}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.titleText){let n=this.titleText.pick(e,r);if(n)return[this,...n]}if(this.composerText){let n=this.composerText.pick(e,r);if(n)return[this,...n]}if(this.arrangerText){let n=this.arrangerText.pick(e,r);if(n)return[this,...n]}return[this]}layoutWidth(e,r,n){let o=0;this.rect=new G(r,n,0,0),this.titleText&&(this.titleText.layout(e),this.titleText.offset((r+n)/2,o),o+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(e),this.composerText.offset(n,o),o+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(e),this.arrangerText.offset(n,o),o+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(e,r){this.titleText&&this.titleText.offset(e,r),this.composerText&&this.composerText.offset(e,r),this.arrangerText&&this.arrangerText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.titleText&&this.titleText.draw(e),this.composerText&&this.composerText.draw(e),this.arrangerText&&this.arrangerText.draw(e)}};var Sh=class{constructor(){d(this,"nameLeft",0);d(this,"nameRight",0);d(this,"braceLeft",0);d(this,"braceRight",0)}get left(){return this.nameLeft}get right(){return this.braceRight}get width(){return this.right-this.left}},ac=class extends rt{constructor(){super(void 0);d(this,"needLayout",!0);d(this,"ctx");d(this,"rows",[]);d(this,"measures",[]);d(this,"measuresPerRow",1/0);d(this,"curScoreConfig",[{type:"staff",clef:"G"}]);d(this,"header");d(this,"newRowRequested",!1);d(this,"allConnectiveProps",[]);d(this,"staffGroups",new yt);d(this,"instrumentGroupRegions",new Sh);d(this,"mi");this.mi=new Hr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(y.isEnumValue(e,Gn))switch(e){default:case"treble":this.curScoreConfig=[{type:"staff",clef:"G"}];break;case"bass":this.curScoreConfig=[{type:"staff",clef:"F"}];break;case"grand":this.curScoreConfig=[{type:"staff",clef:"G",grandId:"grand1"},{type:"staff",clef:"F",grandId:"grand1"}];break;case"guitarTreble":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case"guitarTab":this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case"guitarCombined":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else y.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0,n="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===n)>=0;)n+="A";if(o&&o.type==="staff"&&o.isGrand){if(o.grandId!==void 0)throw new N(6,"Grand staff error: mixing isGrand and grandId!");if(s&&s.type==="staff"&&s.isGrand){if(s.grandId!==void 0)throw new N(6,"Grand staff error: mixing isGrand and grandId!");o.grandId=n,s.grandId=n,o.isGrand=s.isGrand=!1,r+=2}else throw new N(6,"Grand staff error: invalid use of isGrand!")}else r++}for(let r=0,n=[];r<this.curScoreConfig.length;){let o=this.curScoreConfig[r],s=this.curScoreConfig[r+1];if(o&&s&&o.type==="staff"&&s.type==="staff"&&o.grandId!==void 0&&o.grandId===s.grandId){if(n.includes(o.grandId))throw new N(6,`Grand staff error: grandId "${o.grandId}" already used!`);if(o.clef!=="G")throw new N(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(s.clef!=="F")throw new N(6,`Grand staff error: Invalid treble clef "${o.clef}"!`);if(o.isOctaveDown||s.isOctaveDown)throw new N(6,"Grand staff error: cannot use isOctaveDown option!");n.push(o.grandId),o.minNote="C4",s.maxNote="B3",r+=2}else{if(o&&o.type==="staff"&&o.grandId!==void 0)throw new N(6,`Grand staff error: invalid use of grandId "${o.grandId}"!`);r++}}this.requestNewRow()}setMeasuresPerRow(e){this.measuresPerRow=e}addConnectiveProps(e){this.allConnectiveProps.push(e)}setRenderContext(e){if(this.ctx===e)return;let r=this.ctx;this.ctx=e,r&&r.setDocument(void 0),e&&e.setDocument(this.mi),this.requestFullLayout()}setHeader(e,r,n){this.header=new sc(this,e,r,n),this.requestLayout()}getTitle(){var e;return(e=this.header)==null?void 0:e.title}getComposer(){var e;return(e=this.header)==null?void 0:e.composer}getArranger(){var e;return(e=this.header)==null?void 0:e.arranger}hasSingleMeasure(){return this.measures.length===1}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}addNewRow(e){let r=new oc(this,e,this.curScoreConfig);return this.rows.push(r),r}getFirstRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[0]}getLastRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[this.rows.length-1]}getRows(){return this.rows}getMeasures(){return this.measures}requestNewRow(){this.newRowRequested=!0}addMeasure(e){let r=this.rows[this.rows.length-1];(!r||this.newRowRequested&&r.getMeasures().length>0||r.getMeasures().length>=this.measuresPerRow)&&(r=this.addNewRow(r),this.newRowRequested=!1);let n=new Qn(r,e);return this.measures.push(n),r.addMeasure(n),this.requestLayout(),n}addStaffGroup(e,r,n){this.staffGroups.set(e,new rc(e,r,n))}getStaffGroup(e){return this.staffGroups.get(e)}getVoiceSymbols(e){let r=[];return this.forEachMeasure(n=>r=r.concat(n.getVoiceSymbols(e))),r}removeLayoutObjects(e){this.forEachMeasure(r=>r.removeLayoutObjects(e))}forEachMeasure(e){let r=this.getFirstMeasure();for(;r;)e(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(e=>e.resetPassCount())}updateCursorRect(e){this.ctx&&this.ctx.updateCursorRect(e)}getInstrumentGroupRegions(e){let r=Math.max(0,...this.rows.map(a=>a.getInstrumentNameWidth(e))),n=r>0,o=n?e.unitSize:0,s=n?e.unitSize*5:0;return this.instrumentGroupRegions.nameLeft=0,this.instrumentGroupRegions.nameRight=r,this.instrumentGroupRegions.braceLeft=r+o,this.instrumentGroupRegions.braceRight=r+o+s+o,this.instrumentGroupRegions}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(e=>e.requestLayout()),this.forEachMeasure(e=>{e.getColumns().forEach(r=>r.requestLayout()),e.requestLayout()}),this.requestLayout()}layout(){var s;if(!this.needLayout)return;let{ctx:e}=this;if(!e)return;let{unitSize:r}=e;this.forEachMeasure(a=>a.createBeams()),(s=this.getFirstMeasure())==null||s.updateRunningArguments(),this.forEachMeasure(a=>a.createExtensions()),this.allConnectiveProps.forEach(a=>a.removeConnectives()),this.allConnectiveProps.forEach(a=>a.createConnectives()),this.rows.forEach(a=>a.resetLayoutGroups(e)),this.rows.forEach(a=>a.layout(e));let n=this.getInstrumentGroupRegions(e).right,o=n+Math.max(at.DocumentMinWidth*r,...this.rows.map(a=>a.getMinWidth()));this.rows.forEach(a=>a.layoutWidth(e,n,o)),this.rows.forEach(a=>a.layoutLayoutGroups(e)),this.rows.forEach(a=>a.layoutSetNotationLines(e)),this.rows.forEach(a=>a.layoutPadding(e)),this.rect=new G,this.header&&(this.header.layoutWidth(e,n,o),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(a=>{a.offset(-this.rect.left,this.rect.bottom+r*2-a.getRect().top),this.rect.expandInPlace(a.getRect())}),this.rows.forEach(a=>a.layoutDone()),this.needLayout=!1}drawContent(){let{ctx:e}=this;e&&(this.rows.forEach(r=>r.draw(e)),this.header&&this.header.draw(e))}pickStaffPosAt(e,r){if(this.rect.contains(e,r))for(let n=0;n<this.rows.length;n++){let o=this.rows[n];if(!o.hasStaff||!o.getRect().contains(e,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.header){let n=this.header.pick(e,r);if(n.length>0)return[this,...n]}for(let n=0;n<this.rows.length;n++){let o=this.rows[n].pick(e,r);if(o.length>0)return[this,...o]}return[this]}};var zf="";function ft(i,...t){let e=t.map(r=>JSON.stringify(r)).join(", ");zf=`DocumentBuilder.${i}(${e})`}function ht(...i){i.forEach(t=>{if(!t)throw new N(6,zf)})}function wh(i,t){if(!i)throw new N(6,t)}function Yf(i){var t;if(ht(y.isObject(i),y.isStringOrUndefined(i.name),y.isUndefined(i.voiceId)||ye(i.voiceId)||y.isArray(i.voiceId)&&i.voiceId.every(e=>ye(e))),!y.isUndefined(i.voiceIds)){ht(ye(i.voiceIds)||y.isArray(i.voiceIds)&&i.voiceIds.every(r=>ye(r))),console.warn("Staff/tab config property 'voiceIds' is deprecated, use 'voiceId' instead.");let e=H.Arr.toArray((t=i.voiceId)!=null?t:[]);H.Arr.toArray(i.voiceIds).forEach(r=>e.push(r)),i.voiceId=e}y.isArray(i.voiceId)&&(i.voiceId=H.Arr.removeDuplicates(i.voiceId)),ht(y.isStringOrUndefined(i.instrument))}function qf(i){Yf(i),ht(y.isObject(i),y.isStrictEqual(i.type,"staff"),y.isEnumValue(i.clef,Bi),y.isBooleanOrUndefined(i.isOctaveDown),y.isUndefined(i.minNote)||W.isNote(i.minNote),y.isUndefined(i.maxNote)||W.isNote(i.maxNote),y.isStringOrUndefined(i.grandId),y.isBooleanOrUndefined(i.isGrand)),y.isUndefined(i.isGrand)||console.warn("Staff config property 'isGrand' is deprecated, use 'grandId' instead.")}function Wf(i){Yf(i),ht(y.isObject(i),y.isStrictEqual(i.type,"tab"),y.isUndefined(i.tuning)||y.isString(i.tuning)&&y.isIncluded(i.tuning,ho)||y.isArray(i.tuning)&&y.isStrictEqual(i.tuning.length,Va().length&&i.tuning.every(t=>W.isNote(t))))}function cc(i){ht(y.isObject(i),y.isBooleanOrUndefined(i.dotted)||y.isIntegerGte(i.dotted,0),y.isEnumValueOrUndefined(i.stem,mr),y.isStringOrUndefined(i.color),y.isBooleanOrUndefined(i.arpeggio)||y.isEnumValue(i.arpeggio,mi),y.isBooleanOrUndefined(i.staccato),y.isBooleanOrUndefined(i.diamond),y.isBooleanOrUndefined(i.triplet),y.isUndefined(i.string)||Bo(i.string)||y.isEmptyArray(i.string)||y.isNonEmptyArray(i.string)&&i.string.every(t=>Bo(t))),wh(y.isUndefined(i.tieSpan),'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)'),wh(y.isUndefined(i.slurSpan),'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)')}function Uf(i){ht(y.isObject(i),y.isBooleanOrUndefined(i.dotted)||y.isIntegerGte(i.dotted,0),y.isStringOrUndefined(i.staffPos)||y.isInteger(i.staffPos)||i.staffPos instanceof W,y.isStringOrUndefined(i.color),y.isBooleanOrUndefined(i.hide),y.isBooleanOrUndefined(i.triplet))}function vv(i){ht(y.isObject(i),y.isEnumValueOrUndefined(i.align,Vo),y.isEnumValueOrUndefined(i.hyphen,Vn))}function Iv(i){ht(y.isObject(i),y.isBooleanOrUndefined(i.showNumber))}function Is(i){ht(y.isStringOrUndefined(i)||y.isIntegerGte(i,0)||y.isNonEmptyArray(i)&&i.every(t=>y.isString(t)||y.isIntegerGte(t,0)))}var uc=class uc{constructor(){d(this,"doc");d(this,"currentLyricsAlign","center");this.doc=new ac}setScoreConfiguration(t){return ft("setScoreConfiguration",t),y.isEnumValue(t,Gn)?this.doc.setScoreConfiguration(t):y.isObject(t)&&t.type==="staff"?(qf(t),this.doc.setScoreConfiguration(t)):y.isObject(t)&&t.type==="tab"?(Wf(t),this.doc.setScoreConfiguration(t)):y.isNonEmptyArray(t)?(t.forEach(e=>{y.isObject(e)&&e.type==="staff"?qf(e):y.isObject(e)&&e.type==="tab"?Wf(e):ht(!1)}),this.doc.setScoreConfiguration(t)):ht(!1),this}getMeasure(){var t;return(t=this.doc.getLastMeasure())!=null?t:this.doc.addMeasure(uc.DefaultMeasureOptions)}getDocument(){return this.doc.getMusicInterface()}setHeader(t,e,r){return ft("setHeader",t,e,r),ht(y.isStringOrUndefined(t),y.isStringOrUndefined(e),y.isStringOrUndefined(r)),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return ft("setMeasuresPerRow",t),ht(y.isIntegerGte(t,1)||y.isPosInfinity(t)),this.doc.setMeasuresPerRow(t),this}addMeasure(t){return ft("addMeasure",t),t!=null||(t={}),Iv(t),this.doc.addMeasure(t),this}setKeySignature(...t){return ft("setKeySignature",...t),ht(t[0]instanceof ei||t[0]instanceof tr||y.isNonEmptyString(t[0])&&y.isEnumValueOrUndefined(t[1],_i)),this.getMeasure().setKeySignature(...t),this}setTimeSignature(...t){return ft("setTimeSignature",...t),t[0]instanceof ri?this.getMeasure().setTimeSignature(t[0]):y.isEnumValue(t[0],lo)&&y.isEnumValueOrUndefined(t[1],Ii)?this.getMeasure().setTimeSignature(new ri(t[0],t[1])):y.isIntegerGte(t[0],1)&&y.isIntegerGte(t[1],1)&&y.isEnumValueOrUndefined(t[2],Ii)?this.getMeasure().setTimeSignature(new ri(t[0],t[1],t[2])):ht(!1),this}setTempo(t,e,r){return ft("setTempo",t,e,r),ht(y.isIntegerGte(t,1),y.isUndefined(e)&&y.isUndefined(r)||rr(e)&&(y.isBooleanOrUndefined(r)||y.isIntegerGte(r,0))),this.getMeasure().setTempo(t,e,r),this}addNote(t,e,r,n){if(ft("addNote",t,e,r,n),ht(ye(t),e instanceof W||y.isNonEmptyString(e)||y.isArray(e)&&e.every(o=>o instanceof W||y.isNonEmptyString(o)),rr(r)),n!=null||(n={}),cc(n),y.isArray(e)){let o=n.string;e.forEach((s,a)=>{n.string=y.isArray(o)?o[a]:o,this.getMeasure().addNoteGroup(t,[s],r,n)})}else this.getMeasure().addNoteGroup(t,[e],r,n);return this}addChord(t,e,r,n){return ft("addChord",t,e,r,n),ht(ye(t),y.isNonEmptyArray(e)&&e.every(o=>o instanceof W||y.isNonEmptyString(o)),rr(r)),n!=null||(n={}),cc(n),this.getMeasure().addNoteGroup(t,e,r,n),this}addRest(t,e,r){return ft("addRest",t,e,r),ht(ye(t),rr(e)),r!=null||(r={}),Uf(r),this.getMeasure().addRest(t,e,r),this}addTuplet(t,e,r){ft("addTuplet",t,e),ht(ye(t),y.isFunction(r),Us(e)&&y.isBooleanOrUndefined(e.showRatio));let n=[],o={addNote:(s,a,c)=>{if(ft("addTuplet => addNote",s,a,c),ht(s instanceof W||y.isNonEmptyString(s)||y.isArray(s)&&s.every(u=>u instanceof W||y.isNonEmptyString(u)),rr(a)),c!=null||(c={}),delete c.triplet,cc(c),y.isArray(s)){let u=c.string;s.forEach((h,l)=>{c.string=y.isArray(u)?u[l]:u;let p=this.getMeasure().addNoteGroup(t,[h],a,c,e);n.push(p)})}else{let u=this.getMeasure().addNoteGroup(t,[s],a,c,e);n.push(u)}return o},addChord:(s,a,c)=>{ft("addTuplet => addChord",s,a,c),ht(y.isNonEmptyArray(s)&&s.every(h=>h instanceof W||y.isNonEmptyString(h)),rr(a)),c!=null||(c={}),delete c.triplet,cc(c);let u=this.getMeasure().addNoteGroup(t,s,a,c,e);return n.push(u),o},addRest:(s,a)=>{ft("addTuplet => addRest",s,a),ht(rr(s)),a!=null||(a={}),delete a.triplet,Uf(a);let c=this.getMeasure().addRest(t,s,a,e);return n.push(c),o}};return r(o),zi.createTuplet(n,e),this}addLyricsInternal(t,e,r,n,o){var s;return Is(t),ht(qa(e),y.isEnumValue(r,er),y.isString(n)||y.isArray(n)&&n.every(a=>y.isString(a))),o!=null||(o={}),vv(o),o.align!==void 0?this.currentLyricsAlign=o.align:(s=o.align)!=null||(o.align=this.currentLyricsAlign),y.isArray(n)?n.forEach(a=>this.getMeasure().addLyrics(t,e,r,a,o)):this.getMeasure().addLyrics(t,e,r,n,o),this}addLyrics(t,e,r,n){return ft("addLyrics",t,e,r,n),this.addLyricsInternal(void 0,t,e,r!=null?r:"",n)}addLyricsTo(t,e,r,n,o){return ft("addLyricsTo",e,r,n,o),this.addLyricsInternal(t,e,r,n!=null?n:"",o)}addFermataInternal(t,e){return Is(t),ht(y.isEnumValue(e,qo)),this.getMeasure().addFermata(t,e),this}addFermata(t="atNote"){return ft("addFermata",t),this.addFermataInternal(void 0,t)}addFermataTo(t,e="atNote"){return ft("addFermataTo",t,e),this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return Is(t),ht(y.isStrictEqual(e,"endRepeat")&&y.isStrictEqual(r.length,1)||y.isStrictEqual(e,"ending")&&y.isIntegerGte(r.length,1)&&r.every(n=>y.isIntegerGte(n,1))||y.isEnumValue(e,gr)&&y.isEmptyArray(r)),this.getMeasure().addNavigation(t,e,...r),this}addNavigation(t,...e){return ft("addNavigation",t,...e),this.addNavigationInternal(void 0,t,...e)}addNavigationTo(t,e,...r){return ft("addNavigationTo",t,e,...r),this.addNavigationInternal(t,e,...r)}addAnnotationInternal(t,e,r){if(e!=null||(e=Gf(r)),e===void 0)throw new N(6,`Annotation text "${r}" is not known annotation.`);return Is(t),ht(y.isEnumValue(e,qn),y.isNonEmptyString(r)),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(...t){return ft("addAnnotation",...t),t.length===1?this.addAnnotationInternal(void 0,void 0,t[0]):this.addAnnotationInternal(void 0,t[0],t[1])}addAnnotationTo(t,...e){return ft("addAnnotationTo",t,...e),e.length===1?this.addAnnotationInternal(t,void 0,e[0]):this.addAnnotationInternal(t,e[0],e[1])}addLabelInternal(t,e,r){return Is(t),ht(y.isEnumValue(e,Wo),y.isNonEmptyString(r)),this.getMeasure().addLabel(t,e,r),this}addLabel(t,e){return ft("addLabel",t,e),this.addLabelInternal(void 0,t,e)}addLabelTo(t,e,r){return ft("addLabelTo",t,e,r),this.addLabelInternal(t,e,r)}addConnective(t,...e){if(ft("addConnective",t,...e),ht(y.isEnumValue(t,fi)),t==="tie"){ht(y.isIntegerOrUndefined(e[0])||y.isEnumValue(e[0],fr)),ht(y.isEnumValueOrUndefined(e[1],$e));let r=e[0],n=e[1];this.getMeasure().addConnective(t,r,n)}else if(t==="slur"){ht(y.isIntegerOrUndefined(e[0])),ht(y.isEnumValueOrUndefined(e[1],$e));let r=e[0],n=e[1];this.getMeasure().addConnective(t,r,n)}else if(t==="slide"){ht(y.isEnumValueOrUndefined(e[0],$e));let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t){ft("addExtension"),wh(y.isFunctionOrUndefined(t),"addExtension() has new usage, e.g. addExtension(ext => ext.measures(2)).");let e=0,r=!0,n={notes:(o,s)=>(ft("addExtension.notes",o,s),ht(rr(o)),ht(y.isUndefined(s)||y.isNumber(s)&&s>=0),e+=Xt.get(o).ticks*(s!=null?s:1),n),measures:o=>(ft("addExtension.measures",o),ht(y.isNumber(o)&&o>=1),e+=this.getMeasure().getMeasureTicks()*o,n),infinity:()=>(ft("addExtension.infinity"),e=1/0,n),hide:()=>(ft("addExtension.hide"),r=!1,n)};return t?t(n):e=1/0,this.getMeasure().addExtension(e,r),this}addStaffGroup(t,e,r="auto"){return ft("addStaffGroup",t,e,r),ht(y.isNonEmptyString(t),y.isNonEmptyString(e)||y.isIntegerGte(e,0)||y.isNonEmptyArray(e)&&e.every(n=>y.isNonEmptyString(n)||y.isIntegerGte(n,0)),y.isEnumValue(r,Go)),this.doc.addStaffGroup(t,e,r),this}endSong(){return ft("endSong"),this.getMeasure().endSong(),this}endSection(){return ft("endSection"),this.getMeasure().endSection(),this}endRow(){var t;return ft("endRow"),(t=this.doc.getLastMeasure())==null||t.endRow(),this}completeRests(t){return ft("completeRests",t),ht(y.isUndefined(t)||ye(t)||y.isArray(t)&&t.every(e=>ye(e))),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){ft("addScaleArpeggio",t,e,r),ht(y.isNonEmptyString(e),y.isIntegerGte(r,1));let n=this.getMeasure().getTimeSignature(),o=t.getScaleNotes(e,r);for(let s=0;s<o.length;s++){s%n.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,n.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}};d(uc,"DefaultMeasureOptions",{});var br=uc;var Ss=class{constructor(t){this.type=t}},Gi=class extends Ss{constructor(e,r,n,o){super(e);this.renderContext=r;this.scoreRow=n;this.diatonicId=o}get renderer(){return this.renderContext}},Vi=class extends Ss{constructor(e,r,n){super(e);this.renderContext=r;this.objects=n;if(arguments.length===0)throw new N(6,"Empty array in score object event!")}get renderer(){return this.renderContext}get topObject(){return this.objects[this.objects.length-1]}findObject(e){return this.objects.find(r=>e(r))}};function hc(i,t,e){if(!i)throw new N(6,`Invalid arg: ${t} = ${e}`)}function Nh(i){if(i instanceof kt||i instanceof he)return i.getMusicInterface();throw new N(6,"Notation line not staff nor tab.")}var At=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},lc=class lc extends At{constructor(e){super(lc.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};d(lc,"Name","Accidental");var zo=lc,dc=class dc extends At{constructor(e){super(dc.Name);this.obj=e}getMusicObject(){return this.obj}};d(dc,"Name","Connective");var gs=dc,pc=class pc extends At{constructor(e){super(pc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return Nh(this.obj.line)}};d(pc,"Name","Arpeggio");var Qo=pc,mc=class mc extends At{constructor(e){super(mc.Name);this.obj=e}getMusicObject(){return this.obj}};d(mc,"Name","BeamGroup");var ds=mc,fc=class fc extends At{constructor(e){super(fc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(fc,"Name","StaffBeamGroup");var ps=fc,gc=class gc extends At{constructor(e){super(gc.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}getRows(){return this.obj.getRows().map(e=>e.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}play(e){return hc(y.isFunctionOrUndefined(e),"playStateChangeListener",e),new Kn(this,e).play()}};d(gc,"Name","Document");var Hr=gc,yc=class yc extends At{constructor(e){super(yc.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return hc(y.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};d(yc,"Name","Ending");var hs=yc,bc=class bc extends At{constructor(e){super(bc.Name);this.obj=e}getMusicObject(){return this.obj}};d(bc,"Name","Fermata");var ms=bc,xc=class xc extends At{constructor(e){super(xc.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};d(xc,"Name","Header");var vs=xc,Ac=class Ac extends At{constructor(e){super(Ac.Name);this.obj=e}getMusicObject(){return this.obj}};d(Ac,"Name","Image");var Uo=Ac,Cc=class Cc extends At{constructor(e){super(Cc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};d(Cc,"Name","Measure");var xs=Cc,_c=class _c extends At{constructor(e){super(_c.Name);this.obj=e}getMusicObject(){return this.obj}};d(_c,"Name","BarLineRight");var as=_c,vc=class vc extends At{constructor(e){super(vc.Name);this.obj=e}getMusicObject(){return this.obj}};d(vc,"Name","BarLineLeft");var cs=vc,Ic=class Ic extends At{constructor(e){super(Ic.Name);this.obj=e}getMusicObject(){return this.obj}getBarLine(){let e=this.obj.barLine;if(e instanceof gi||e instanceof Yr)return e.getMusicInterface();throw new N(6,"Bar line not let nor right.")}getNotationLine(){return Nh(this.obj.line)}};d(Ic,"Name","StaffTabBarLine");var us=Ic,Sc=class Sc extends At{constructor(e){super(Sc.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Sc,"Name","NoteGroup");var ts=Sc,wc=class wc extends At{constructor(e){super(wc.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(wc,"Name","StaffNoteGroup");var es=wc,Nc=class Nc extends At{constructor(e){super(Nc.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getTab(){return this.obj.tab.getMusicInterface()}};d(Nc,"Name","TabNoteGroup");var rs=Nc,Tc=class Tc extends At{constructor(e){super(Tc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Tc,"Name","Rest");var Ko=Tc,Oc=class Oc extends At{constructor(e){super(Oc.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}getRhythmColumn(){return this.getRest().getRhythmColumn()}getMeasure(){return this.getRest().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Oc,"Name","StaffRest");var Jo=Oc,Rc=class Rc extends At{constructor(e){super(Rc.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return hc(ye(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getVoiceSymbol(e){var r;return hc(ye(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Rc,"Name","RhythmColumn");var is=Rc,Mc=class Mc extends At{constructor(e){super(Mc.Name);this.obj=e}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(e=>Nh(e))}};d(Mc,"Name","ScoreRow");var _s=Mc,Ec=class Ec extends At{constructor(e){super(Ec.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Ec,"Name","Staff");var As=Ec,Dc=class Dc extends At{constructor(e){super(Dc.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Dc,"Name","Tab");var Cs=Dc,kc=class kc extends At{constructor(e){super(kc.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(kc,"Name","StaffSignature");var Xo=kc,Lc=class Lc extends At{constructor(e){super(Lc.Name);this.obj=e}getMusicObject(){return this.obj}getTab(){return this.obj.tab.getMusicInterface()}};d(Lc,"Name","TabSignature");var $o=Lc,jc=class jc extends At{constructor(e){super(jc.Name);this.obj=e}getMusicObject(){return this.obj}getMeasure(){return this.obj.measure.getMusicInterface()}getTab(){return this.obj.tab.getMusicInterface()}};d(jc,"Name","TabRhythm");var bs=jc,Pc=class Pc extends At{constructor(e){super(Pc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Pc,"Name","SpecialText");var ns=Pc,Fc=class Fc extends At{constructor(e){super(Fc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Fc,"Name","Text");var Yo=Fc,Bc=class Bc extends At{constructor(e){super(Bc.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Bc,"Name","Lyrics");var ys=Bc,Gc=class Gc extends At{constructor(e){super(Gc.Name);this.obj=e}getMusicObject(){return this.obj}};d(Gc,"Name","ExtensionLine");var fs=Gc;function xr(i,t,e){if(!i)throw new N(6,`Invalid arg: ${t} = ${e}`)}function ws(i,t){if(i==null)throw new TypeError(t);return i}var Ns=class Ns{constructor(t,e){d(this,"player");xr(t instanceof Hr,"doc",t),xr(y.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new Qa,this.player.setDocument(t.getMusicObject()),this.player.setCursorPositionChangeListener(r=>{t.getMusicObject().updateCursorRect(r)}),e&&this.player.setPlayStateChnageListener(e)}static stopAll(){this.currentlyPlaying.forEach(t=>t.stop()),Ga()}play(){return Ns.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),Ns.currentlyPlaying.delete(this),this}};d(Ns,"currentlyPlaying",new Fs);var Kn=Ns,Vc=class{constructor(){d(this,"ctx");this.ctx=new za(this)}setDocument(t){return xr(y.isUndefined(t)||t instanceof Hr,"doc",t),this.ctx.setDocument(t),this}setCanvas(t){return t=ws(H.Dom.getCanvas(t),typeof t=="string"?"Cannot set render canvas because invalid canvas id: "+t:"Cannot set render canvas because given canvas is undefined."),this.ctx.setCanvas(t),this}setScoreEventListener(t){xr(y.isFunctionOrUndefined(t),"scoreEventListener",t),this.ctx.setScoreEventListener(t)}hilightObject(t){this.ctx.hilightObject(t==null?void 0:t.getMusicObject())}hilightStaffPos(t){this.ctx.hilightStaffPos(t?{scoreRow:t.scoreRow.getMusicObject(),diatonicId:t.diatonicId}:void 0)}draw(){try{this.ctx.draw()}catch(t){console.log("Draw failed in music render context!",t)}}},Th=class extends Vc{},Ie=class Ie{constructor(){d(this,"playButton");d(this,"stopButton");d(this,"playStopButton");d(this,"pauseButton");d(this,"onPlay");d(this,"onStop");d(this,"onPlayStop");d(this,"onPause");d(this,"playLabel","Play");d(this,"stopLabel","Stop");d(this,"pauseLabel","Pause");d(this,"playState",2);d(this,"player");this.onPlay=()=>{var t;return(t=this.player)==null?void 0:t.play()},this.onStop=()=>{var t;return(t=this.player)==null?void 0:t.stop()},this.onPlayStop=()=>{var t,e;this.playState===0?(t=this.player)==null||t.stop():(e=this.player)==null||e.play()},this.onPause=()=>{var t;return(t=this.player)==null?void 0:t.pause()},this.updateButtons()}setDocument(t){return xr(y.isUndefined(t)||t instanceof Hr,"doc",t),this.onStop(),t?this.player=new Kn(t,e=>{this.playState=e,this.updateButtons()}):this.player=void 0,this.updateButtons(),this}detachDocument(){this.setDocument(void 0)}updateButtons(){this.playButton&&(this.playButton.disabled=this.player?this.playState===0:!0,this.playButton.innerText=this.playLabel),this.stopButton&&(this.stopButton.disabled=this.player?this.playState===2:!0,this.stopButton.innerText=this.stopLabel),this.playStopButton&&(this.playStopButton.disabled=!this.player,this.playStopButton.innerText=this.playState===0?this.stopLabel:this.playLabel),this.pauseButton&&(this.pauseButton.disabled=this.player?this.playState!==0:!0,this.pauseButton.innerText=this.pauseLabel)}setPlayButton(t,e){return xr(y.isStringOrUndefined(e),"btnLabel",e),Ie.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=ws(H.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",Ie.removeOnClickListeners(this.playButton,"all"),Ie.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return xr(y.isStringOrUndefined(e),"btnLabel",e),Ie.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=ws(H.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",Ie.removeOnClickListeners(this.stopButton,"all"),Ie.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return xr(y.isStringOrUndefined(e),"playLabel",e),xr(y.isStringOrUndefined(r),"stopLabel",r),Ie.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=ws(H.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",Ie.removeOnClickListeners(this.playStopButton,"all"),Ie.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return xr(y.isStringOrUndefined(e),"btnLabel",e),Ie.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=ws(H.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",Ie.removeOnClickListeners(this.pauseButton,"all"),Ie.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(!t)return;let r=this.savedOnClickListeners.getOrDefault(t,[]);r=r.filter(n=>e===n||e==="all"?(t.removeEventListener("click",n),!1):!0),this.savedOnClickListeners.set(t,r)}static addOnClickListener(t,e){xr(y.isFunction(e),"onClick",e),t.addEventListener("click",e),this.savedOnClickListeners.getOrCreate(t,[]).push(e)}};d(Ie,"savedOnClickListeners",new yt);var Oh=Ie;Ci();var Mh={};$i(Mh,{createAndanteByDiabelli:()=>Tv,createCanonInD:()=>Sv,createFrereJacques:()=>wv,createGreensleeves:()=>Nv});function Sv(){return new br().setHeader("Canon in D","Pachelbel").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0,instrument:"Piano"},{type:"staff",clef:"F",voiceId:1,instrument:"Piano"}]).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").setTempo(50,"2n").completeRests(0).addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).completeRests(0).addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().completeRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).completeRests(0).addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["F#5","E5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","C#5"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").addMeasure().addNote(0,["B4","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addNote(0,["B4","C#5"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addChord(0,["F#5","D5"],"2n").addChord(0,["E5","C#5"],"2n").addNote(1,["D3","F#3","A3","D4"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure({showNumber:!0}).addChord(0,["D5","B4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["B2","D3","F#3","B3"],"8n").addNote(1,["F#2","A2","C#3","F#3"],"8n").endRow().addMeasure({showNumber:!1}).addChord(0,["B4","G4"],"2n").addChord(0,["A4","F#4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["D2","F#2","A2","D3"],"8n").addMeasure({showNumber:!0}).addChord(0,["B4","G4"],"2n").addChord(0,["C#5","A4"],"2n").addNote(1,["G2","B2","D3","G3"],"8n").addNote(1,["A2","C#3","E3","A3"],"8n").addMeasure().addNote(0,["D4","F#4","A4","G4"],"4n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","D4","F#4","E4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","D4","A4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","B4","A4","G4"],"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["F#4","D4","E4","C#5"],"4n").addNote(1,["D3","A2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["D5","F#5","A5","A4"],"4n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B4","G4","A4","F#4"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5"],"4n").addRest(0,"4n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D5","C#5","D5","D4"],"8n").addNote(0,["C#4","A4","E4","F#4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D4","D5","C#5","B4"],"8n").addNote(0,["C#5","F#5","A5","B5"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["G5","F#5","E5","G5"],"8n").addNote(0,["F#5","E5","D5","C#5"],"8n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,["B4","A4","G4","F#4"],"8n").addNote(0,["E4","G4","F#4","E4"],"8n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D4","E4","F#4","G4"],"8n").addNote(0,["A4","E4","A4","G4"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,["F#4","B4","A4","G4"],"8n").addNote(0,["A4","G4","F#4","E4"],"8n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["D4","B3","B4","C#5"],"8n").addNote(0,["D5","C#5","B4","A4"],"8n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["G4","F#4","E4","B4"],"8n").addNote(0,["A4","B4","A4","G4"],"8n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"F#4","4n").addNote(0,"F#5","4n").addNote(0,"E5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(0,"F#5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,["B5","A5"],"2n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["B5","C#6"],"2n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,["D6","D5"],"4n").addNote(0,"C#5","2n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addRest(0,"4n",{staffPos:"B4"}).addNote(0,"B4","4n").addNote(0,"D5","2n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"D5","2n").addRest(0,"4n",{staffPos:"B4"}).addNote(0,"D5","4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","F#5","E5","A5"],"4n").addNote(1,["G2","A2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,"A5","8n").addNote(0,["F#5","G5"],"16n").addNote(0,["A5","A4","B4","C#5"],"16n").addNote(0,["D5","E5","F#5","G5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["F#4","G4"],"16n").addNote(0,["A4","B4","A4","G4"],"16n").addNote(0,["A4","F#4","G4","A4"],"16n").addNote(1,["B2","F#2"],"2n").addMeasure().addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"G4","8n").addNote(0,["F#4","E4"],"16n").addNote(0,["F#4","E4","D4","E4"],"16n").addNote(0,["F#4","G4","A4","B4"],"16n").addNote(1,["G2","D2"],"2n").endRow().addMeasure({showNumber:!0}).addNote(0,"G4","8n").addNote(0,["B4","A4"],"16n").addNote(0,"B4","8n").addNote(0,["C#5","D5"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(0,["E5","F#5","G5","A5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNote(0,"F#5","8n").addNote(0,["D5","E5"],"16n").addNote(0,"F#5","8n").addNote(0,["E5","D5"],"16n").addNote(0,["E5","C#5","D5","E5"],"16n").addNote(0,["F#5","E5","D5","C#5"],"16n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"D5","8n").addNote(0,["B4","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["D4","E4"],"16n").addNote(0,["F#4","G4","F#4","E4"],"16n").addNote(0,["F#4","D5","C#5","D5"],"16n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"B4","8n").addNote(0,["A4","G4"],"16n").addNote(0,["A4","G4","F#4","G4"],"16n").addNote(0,["A4","B4","C#5","D5"],"16n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,"B4","8n").addNote(0,["D5","C#5"],"16n").addNote(0,"D5","8n").addNote(0,["C#5","B4"],"16n").addNote(0,["C#5","D5","E5","D5"],"16n").addNote(0,["C#5","D5","B4","C#5"],"16n").addNote(1,["G2","A2"],"2n").addMeasure().addNavigation("startRepeat").addNote(0,"D5","4.").addNote(0,"A5","8n").addNote(0,["A5","B5","A5","G5"],"8n").addNote(1,["D3","A2"],"2n").addMeasure({showNumber:!0}).addNote(0,"F#5","4.").addNote(0,"F#5","8n").addNote(0,["F#5","G5","F#5","E5"],"8n").addNote(1,["B2","F#2"],"2n").endRow().addMeasure({showNumber:!1}).addNote(0,"D5","4.").addNote(0,"D5","8n").addNote(0,["D5","A5"],"4n").addNote(1,["G2","D2"],"2n").addMeasure({showNumber:!0}).addNote(0,["D5","C5","B5","C5"],"8n").addNote(0,"C#5","2n").addNote(1,["G2","A2"],"2n").addNavigation("endRepeat").addMeasure().addNote(0,"D5","1n").addNote(1,"D3","1n").getDocument()}function wv(){return new br().setHeader("Fr\xE8re Jacques","Traditional").setScoreConfiguration([{type:"staff",clef:"G",voiceId:0},{type:"staff",clef:"F",voiceId: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 Nv(){return new br().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 Tv(){return new br().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 eg(Ov);})();
|
|
211
211
|
/*! Bundled license information:
|
|
212
212
|
|
|
213
|
+
@tspro/ts-utils-lib/dist/index.mjs:
|
|
214
|
+
(*!
|
|
215
|
+
* TsUtilsLib v2.1.0 (esm)
|
|
216
|
+
* (c) 2023–2025 PahkaSoft
|
|
217
|
+
* Licensed under the MIT License
|
|
218
|
+
*)
|
|
219
|
+
|
|
213
220
|
tone/build/esm/core/Tone.js:
|
|
214
221
|
(**
|
|
215
222
|
* Tone.js
|