PageSourceSearch

https://www.thebraindocs.com/assets/BrainGameDetail-BhAv5nKt.js

js thebraindocs.com collected 2026-09-24 22:22:12 UTC 269,016 bytes, 223 lines download raw bytes

1import{H as Ai,r as Y,j as y,B as fn,Q as fe,T as qe,U as Wr,s as Lr,t as Br,W as Ks,f as zr,L as Jn,b as ln,e as Kn,h as es,E as Ur}from"./index-CYVbSHRc.js";import{P as Gr}from"./PaygateModal-CtMKhGyD.js";import{u as $r}from"./useBrainGames-CFiJR1RF.js";import{s as Zr}from"./sanitizeHtml-D1goPPDs.js";import{G as ts}from"./gamepad-2-DnlRUBeD.js";import{A as ei}from"./arrow-left-DoXa4rR6.js";import{L as ti}from"./lock-TpbgVGbT.js";import"./sparkles-BRyq2P-W.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Yr=Ai("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Hr=Ai("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]),Xr=({embedUrl:s,title:e="Game",aspectRatio:t="16:9",allowFullscreen:n=!0})=>{const[i,r]=Y.useState(!1),o={"16:9":"aspect-video","4:3":"aspect-[4/3]","1:1":"aspect-square",square:"aspect-square"},a=()=>{const c=document.getElementById("game-iframe");c&&(document.fullscreenElement?(document.exitFullscreen(),r(!1)):(c.requestFullscreen(),r(!0)))};return y.jsxs("div",{className:"relative w-full",children:[n&&y.jsx("div",{className:"absolute top-2 right-2 z-10",children:y.jsx(fn,{variant:"secondary",size:"sm",onClick:a,className:"bg-background/80 backdrop-blur-sm hover:bg-background",children:i?y.jsxs(y.Fragment,{children:[y.jsx(Hr,{className:"w-4 h-4 mr-1"}),"Exit Fullscreen"]}):y.jsxs(y.Fragment,{children:[y.jsx(Yr,{className:"w-4 h-4 mr-1"}),"Fullscreen"]})})}),y.jsx("div",{className:`${o[t]} w-full bg-muted rounded-xl overflow-hidden`,children:y.jsx("iframe",{id:"game-iframe",src:s,title:e,className:"w-full h-full border-0",allow:"fullscreen; clipboard-write",loading:"lazy"})})]})},Ni="15.1.22",ni=(s,e,t)=>({endTime:e,insertTime:t,type:"exponentialRampToValue",value:s}),si=(s,e,t)=>({endTime:e,insertTime:t,type:"linearRampToValue",value:s}),rs=(s,e)=>({startTime:e,type:"setValue",value:s}),Oi=(s,e,t)=>({duration:t,startTime:e,type:"setValueCurve",values:s}),Mi=(s,e,{startTime:t,target:n,timeConstant:i})=>n+(e-n)*Math.exp((t-s)/i),Tt=s=>s.type==="exponentialRampToValue",_n=s=>s.type==="linearRampToValue",tt=s=>Tt(s)||_n(s),ms=s=>s.type==="setValue",Ze=s=>s.type==="setValueCurve",yn=(s,e,t,n)=>{const i=s[e];return i===void 0?n:tt(i)||ms(i)?i.value:Ze(i)?i.values[i.values.length-1]:Mi(t,yn(s,e-1,i.startTime,n),i)},ii=(s,e,t,n,i)=>t===void 0?[n.insertTime,i]:tt(t)?[t.endTime,t.value]:ms(t)?[t.startTime,t.value]:Ze(t)?[t.startTime+t.duration,t.values[t.values.length-1]]:[t.startTime,yn(s,e-1,t.startTime,i)],os=s=>s.type==="cancelAndHold",as=s=>s.type==="cancelScheduledValues",et=s=>os(s)||as(s)?s.cancelTime:Tt(s)||_n(s)?s.endTime:s.startTime,ri=(s,e,t,{endTime:n,value:i})=>t===i?i:0<t&&0<i||t<0&&i<0?t*(i/t)**((s-e)/(n-e)):s<n?t:i,oi=(s,e,t,{endTime:n,value:i})=>t+(s-e)/(n-e)*(i-t),Ii=(s,e)=>{const t=Math.floor(e);if(t===e)return s[t];const n=Math.ceil(e);return(1-(e-t))*s[t]+(1-(n-e))*s[n]},Qr=(s,{duration:e,startTime:t,values:n})=>{const i=(s-t)/e*(n.length-1);return Ii(n,i)},Jr=(s,e,t)=>{const n=s.length,i=Math.max(1,Math.floor(t/e*n))+1,r=s instanceof Float32Array?new Float32Array(i):s.slice(0,i);for(let o=0;o<i;o+=1){const c=o/(i-1)*t/e*(n-1);r[o]=Ii(s,c)}return r},un=s=>s.type==="setTarget";class Kr{constructor(e){this._automationEvents=[],this._currenTime=0,this._defaultValue=e}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(e){const t=et(e);if(os(e)||as(e)){const n=this._automationEvents.findIndex(r=>as(e)&&Ze(r)?r.startTime+r.duration>=t:et(r)>=t),i=this._automationEvents[n];if(n!==-1&&(this._automationEvents=this._automationEvents.slice(0,n)),os(e)){const r=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&tt(i)){if(r!==void 0&&un(r))throw new Error("The internal list is malformed.");const o=r===void 0?i.insertTime:Ze(r)?r.startTime+r.duration:et(r),a=r===void 0?this._defaultValue:Ze(r)?r.values[r.values.length-1]:r.value,c=Tt(i)?ri(t,o,a,i):oi(t,o,a,i),l=Tt(i)?ni(c,t,this._currenTime):si(c,t,this._currenTime);this._automationEvents.push(l)}if(r!==void 0&&un(r)&&this._automationEvents.push(rs(this.getValue(t),t)),r!==void 0&&Ze(r)&&r.startTime+r.duration>t){const o=t-r.startTime;this._automationEvents[this._automationEvents.length-1]=Oi(Jr(r.values,r.duration,o),r.startTime,o)}}}else{const n=this._automationEvents.findIndex(o=>et(o)>t),i=n===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[n-1];if(i!==void 0&&Ze(i)&&et(i)+i.duration>t)return!1;const r=Tt(e)?ni(e.value,e.endTime,this._currenTime):_n(e)?si(e.value,t,this._currenTime):e;if(n===-1)this._automationEvents.push(r);else{if(Ze(e)&&t+e.duration>et(this._automationEvents[n]))return!1;this._automationEvents.splice(n,0,r)}}return!0}flush(e){const t=this._automationEvents.findIndex(n=>et(n)>e);if(t>1){const n=this._automationEvents.slice(t-1),i=n[0];un(i)&&n.unshift(rs(yn(this._automationEvents,t-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=n}}getValue(e){if(this._automationEvents.length===0)return this._defaultValue;const t=this._automationEvents.findIndex(o=>et(o)>e),n=this._automationEvents[t],i=(t===-1?this._automationEvents.length:t)-1,r=this._automationEvents[i];if(r!==void 0&&un(r)&&(n===void 0||!tt(n)||n.insertTime>e))return Mi(e,yn(this._automationEvents,i-1,r.startTime,this._defaultValue),r);if(r!==void 0&&ms(r)&&(n===void 0||!tt(n)))return r.value;if(r!==void 0&&Ze(r)&&(n===void 0||!tt(n)||r.startTime+r.duration>e))return e<r.startTime+r.duration?Qr(e,r):r.values[r.values.length-1];if(r!==void 0&&tt(r)&&(n===void 0||!tt(n)))return r.value;if(n!==void 0&&Tt(n)){const[o,a]=ii(this._automationEvents,i,r,n,this._defaultValue);return ri(e,o,a,n)}if(n!==void 0&&_n(n)){const[o,a]=ii(this._automationEvents,i,r,n,this._defaultValue);return oi(e,o,a,n)}return this._defaultValue}}const eo=s=>({cancelTime:s,type:"cancelAndHold"}),to=s=>({cancelTime:s,type:"cancelScheduledValues"}),no=(s,e)=>({endTime:e,type:"exponentialRampToValue",value:s}),so=(s,e)=>({endTime:e,type:"linearRampToValue",value:s}),io=(s,e,t)=>({startTime:e,target:s,timeConstant:t,type:"setTarget"}),ro=()=>new DOMException("","AbortError"),oo=s=>(e,t,[n,i,r],o)=>{s(e[i],[t,n,r],a=>a[0]===t&&a[1]===n,o)},ao=s=>(e,t,n)=>{const i=[];for(let r=0;r<n.numberOfInputs;r+=1)i.push(new Set);s.set(e,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:t})},co=s=>(e,t)=>{s.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:t})}
11,Nt=new WeakSet,Ei=new WeakMap,gs=new WeakMap,Di=new WeakMap,_s=new WeakMap,Dn=new WeakMap,Ri=new WeakMap,cs=new WeakMap,ls=new WeakMap,us=new WeakMap,Pi={construct(){return Pi}},lo=s=>{try{const e=new Proxy(s,Pi);new e}catch{return!1}return!0},ai=/^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]*);?/,ci=(s,e)=>{const t=[];let n=s.replace(/^[\s]+/,""),i=n.match(ai);for(;i!==null;){const r=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(r,new URL(r,e).toString());t.push(o),n=n.slice(i[0].length).replace(/^[\s]+/,""),i=n.match(ai)}return[t.join(";"),n]},li=s=>{if(s!==void 0&&!Array.isArray(s))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},ui=s=>{if(!lo(s))throw new TypeError("The given value for processorCtor should be a constructor.");if(s.prototype===null||typeof s.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},uo=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>{let f=0;return(d,m,_={credentials:"omit"})=>{const v=u.get(d);if(v!==void 0&&v.has(m))return Promise.resolve();const T=l.get(d);if(T!==void 0){const g=T.get(m);
11if(g!==void 0)return g}const S=r(d),k=S.audioWorklet===void 0?i(m).then(([g,x])=>{const[b,w]=ci(g,x),O=`${b};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${w}
12})})(window,'_AWGS')`;return t(O)}).then(()=>{const g=p._AWGS.pop();if(g===void 0)throw new SyntaxError;n(S.currentTime,S.sampleRate,()=>g(class{},void 0,(x,b)=>{if(x.trim()==="")throw e();const w=ls.get(S);if(w!==void 0){if(w.has(x))throw e();ui(b),li(b.parameterDescriptors),w.set(x,b)}else ui(b),li(b.parameterDescriptors),ls.set(S,new Map([[x,b]]))},S.sampleRate,void 0,void 0))}):Promise.all([i(m),Promise.resolve(s(h,h))]).then(([[g,x],b])=>{const w=f+1;f=w;const[O,A]=ci(g,x),E=`${O};((AudioWorkletProcessor,registerProcessor)=>{${A}
13})(${b?"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{${b?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${b?"":"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${w}',class extends AudioWorkletProcessor{process(){return !1}})`,I=new Blob([E],{type:"application/javascript; charset=utf-8"}),D=URL.createObjectURL(I);return S.audioWorklet.addModule(D,_).then(()=>{if(a(S))return S;const V=o(S);return V.audioWorklet.addModule(D,_).then(()=>V)}).then(V=>{if(c===null)throw new SyntaxError;try{new c(V,`__sac${w}`)}catch{throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(D))});return T===void 0?l.set(d,new Map([[m,k]])):T.set(m,k),k.then(()=>{const g=u.get(d);g===void 0?u.set(d,new Set([m])):g.add(m)}).finally(()=>{const g=l.get(d);g!==void 0&&g.delete(m)}),k}},je=(s,e)=>{const t=s.get(e);if(t===void 0)throw new Error("A value with the given key could not be found.");return t},Rn=(s,e)=>{const t=Array.from(s).filter(e);if(t.length>1)throw Error("More than one element was found.");if(t.length===0)throw Error("No element was found.");const[n]=t;return s.delete(n),n},Fi=(s,e,t,n)=>{const i=je(s,e),r=Rn(i,o=>o[0]===t&&o[1]===n);return i.size===0&&s.delete(e),r},Ht=s=>je(Ri,s),Ot=s=>{if(Nt.has(s))throw new Error("The AudioNode is already stored.");Nt.add(s),Ht(s).forEach(e=>e(!0))},Vi=s=>"port"in s,Xt=s=>{if(!Nt.has(s))throw new Error("The AudioNode is not stored.");Nt.delete(s),Ht(s).forEach(e=>e(!1))},hs=(s,e)=>{!Vi(s)&&e.every(t=>t.size===0)&&Xt(s)},ho=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>{const f=new WeakMap;return(d,m,_,v,T)=>{const{activeInputs:S,passiveInputs:k}=r(m),{outputs:g}=r(d),x=a(d),b=w=>{const O=c(m),A=c(d);if(w){const N=Fi(k,d,_,v);s(S,d,N,!1),!T&&!h(d)&&t(A,O,_,v),p(m)&&Ot(m)}else{const N=n(S,d,_,v);e(k,v,N,!1),!T&&!h(d)&&i(A,O,_,v);const C=o(m);if(C===0)u(m)&&hs(m,S);else{const R=f.get(m);R!==void 0&&clearTimeout(R),f.set(m,setTimeout(()=>{u(m)&&hs(m,S)},C*1e3))}}};return l(g,[m,_,v],w=>w[0]===m&&w[1]===_&&w[2]===v,!0)?(x.add(b),u(d)?s(S,d,[_,v,b],!0):e(k,v,[d,_,b],!0),!0):!1}},po=s=>(e,t,[n,i,r],o)=>{const a=e.get(n);a===void 0?e.set(n,new Set([[i,t,r]])):s(a,[i,t,r],c=>c[0]===i&&c[1]===t,o)},fo=s=>(e,t)=>{const n=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});t.connect(n).connect(e.destination);const i=()=>{t.removeEventListener("ended",i),t.disconnect(n),n.disconnect()};t.addEventListener("ended",i)},mo=s=>(e,t)=>{s(e).add(t)},go={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},_o=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...go,...c},h=n(l,u),p=r(l)?e():null;super(a,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){const c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,t()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){const c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,t()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}},we=(s,e)=>s.context===e,yo=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!we(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},vn=s=>
13{try{s.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},ze=()=>new DOMException("","IndexSizeError"),ys=s=>{s.getChannelData=(e=>t=>{try{return e.call(s,t)}catch(n){throw n.code===12?ze():n}})(s.getChannelData)},vo={numberOfChannels:1},wo=(s,e,t,n,i,r,o,a)=>{let c=null;return class ji{constructor(u){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:h,numberOfChannels:p,sampleRate:f}={...vo,...u};c===null&&(c=new i(1,1,44100));const d=n!==null&&e(r,r)?new n({length:h,numberOfChannels:p,sampleRate:f}):c.createBuffer(p,h,f);if(d.numberOfChannels===0)throw t();return typeof d.copyFromChannel!="function"?(o(d),ys(d)):e(vn,()=>vn(d))||a(d),s.add(d),d}static[Symbol.hasInstance](u){return u!==null&&typeof u=="object"&&Object.getPrototypeOf(u)===ji.prototype||s.has(u)}}},ke=-34028234663852886e22,be=-ke,Ye=s=>Nt.has(s),xo={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},bo=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...xo,...u},f=i(h,p),d=o(h),m=d?e():null;super(l,!1,f,m),this._audioBufferSourceNodeRenderer=m,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=f,this._onended=null,this._playbackRate=t(this,d,f.playbackRate,be,ke)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(l){if(this._nativeAudioBufferSourceNode.buffer=l,l!==null){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(l){this._nativeAudioBufferSourceNode.loop=l}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(l){this._nativeAudioBufferSourceNode.loopEnd=l}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(l){this._nativeAudioBufferSourceNode.loopStart=l}get onended(){return this._onended}set onended(l){const u=typeof l=="function"?a(this,l):null;this._nativeAudioBufferSourceNode.onended=u;const h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===u?l:h}get playbackRate(){return this._playbackRate}start(l=0,u=0,h){if(this._nativeAudioBufferSourceNode.start(l,u,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[l,u]:[l,u,h]),this.context.state!=="closed"){Ot(this);const p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),Ye(this)&&Xt(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(l=0){this._nativeAudioBufferSourceNode.stop(l),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=l)}},To=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;const c=async(l,u)=>{let h=t(l);const p=we(h,u);if(!p){const f={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=e(u,f),o!==null&&h.start(...o),a!==null&&h.stop(a)}return r.set(u,h),p?await s(u,l.playbackRate,h.playbackRate):await n(u,l.playbackRate,h.playbackRate),await i(l,u,h),h};return{set start(l){o=l},set stop(l){a=l},render(l,u){const h=r.get(u);return h!==void 0?Promise.resolve(h):c(l,u)}}},So=s=>"playbackRate"in s,Co=s=>"frequency"in s&&"gain"in s,ko=s=>"offset"in s,Ao=s=>!("frequency"in s)&&"gain"in s,No=s=>"detune"in s&&"frequency"in s&&!("gain"in s),Oo=s=>"pan"in s,Te=s=>je(Ei,s),Qt=s=>je(Di,s),ds=(s,e)=>{const{activeInputs:t}=Te(s);t.forEach(i=>i.forEach(([r])=>{e.includes(s)||ds(r,[...e,s])}));const n=So(s)?[s.playbackRate]:Vi(s)?Array.from(s.parameters.values()):Co(s)?[s.Q,s.detune,s.frequency,s.gain]:ko(s)?[s.offset]:Ao(s)?[s.gain]:No(s)?[s.detune,s.frequency]:Oo(s)?[s.pan]:[];for(const i of n){const r=Qt(i);r!==void 0&&r.activeInputs.forEach(([o])=>ds(o,e))}Ye(s)&&Xt(s)},qi=s=>{ds(s.destination,[])},Mo=s=>s===void 0||typeof s=="number"||typeof s=="string"&&(s==="balanced"||s==="interactive"||s==="playback"),Io=(s,e,t,n,i,r,o,a,c)=>class extends s{constructor(u={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(u)}catch(d){throw d.code===12&&d.message==="sampleRate is not in range"?t():d}if(h===null)throw n();if(!Mo(u.latencyHint))throw new TypeError(`The provided value '${u.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(u.sampleRate!==void 0&&h.sampleRate!==u.sampleRate)throw t();super(h,2);const{latencyHint:p}=u,{sampleRate:f}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/f:p==="interactive"||p===void 0?256/f:p==="playback"?1024/f:Math.max(2,Math.min(128,Math.round(p*f/128)))*128/f,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";const d=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",d)};h.addEventListener("statechange",d)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw e()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),qi(this)}))}createMediaElementSource(u){return new i(this,{mediaElement:u})}createMediaStreamDestination(){return new r(this)}createMediaStreamSource(u){return new o(this,{mediaStream:u})}createMediaStreamTrackSource(u){return new a(this,{mediaStreamTrack:u})}resume(){return this._state==="suspended"?new Promise((u,h)=>{const p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?u():this.resume().then(u,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(u=>{throw u===void 0||u.code===15?e():u})}suspend(){return this._nativeAudioContext.suspend().catch(u=>{throw u===void 0?e():u})}},Eo=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p=o(h),f=i(h,u,p),d=p?e(a):null;super(l,!1,f,d),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=f}
13get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(l){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(l>this._nativeAudioDestinationNode.maxChannelCount)throw t();this._nativeAudioDestinationNode.channelCount=l}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(l){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=l}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},Do=s=>{const e=new WeakMap,t=async(n,i)=>{const r=i.destination;return e.set(i,r),await s(n,i,r),r};return{render(n,i){const r=e.get(i);return r!==void 0?Promise.resolve(r):t(n,i)}}},Ro=(s,e,t,n,i,r,o,a)=>(c,l)=>{const u=l.listener,h=()=>{const g=new Float32Array(1),x=e(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),b=o(l);let w=!1,O=[0,0,-1,0,1,0],A=[0,0,0];const N=()=>{if(w)return;w=!0;const I=n(l,256,9,0);I.onaudioprocess=({inputBuffer:D})=>{const V=[r(D,g,0),r(D,g,1),r(D,g,2),r(D,g,3),r(D,g,4),r(D,g,5)];V.some((M,P)=>M!==O[P])&&(u.setOrientation(...V),O=V);const W=[r(D,g,6),r(D,g,7),r(D,g,8)];W.some((M,P)=>M!==A[P])&&(u.setPosition(...W),A=W)},x.connect(I)},C=I=>D=>{D!==O[I]&&(O[I]=D,u.setOrientation(...O))},R=I=>D=>{D!==A[I]&&(A[I]=D,u.setPosition(...A))},E=(I,D,V)=>{const W=t(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:D});W.connect(x,0,I),W.start(),Object.defineProperty(W.offset,"defaultValue",{get(){return D}});const M=s({context:c},b,W.offset,be,ke);return a(M,"value",P=>()=>P.call(M),P=>q=>{try{P.call(M,q)}catch($){if($.code!==9)throw $}N(),b&&V(q)}),M.cancelAndHoldAtTime=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.cancelAndHoldAtTime),M.cancelScheduledValues=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.cancelScheduledValues),M.exponentialRampToValueAtTime=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.exponentialRampToValueAtTime),M.linearRampToValueAtTime=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.linearRampToValueAtTime),M.setTargetAtTime=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.setTargetAtTime),M.setValueAtTime=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.setValueAtTime),M.setValueCurveAtTime=(P=>b?()=>{throw i()}:(...q)=>{const $=P.apply(M,q);return N(),$})(M.setValueCurveAtTime),M};return{forwardX:E(0,0,C(0)),forwardY:E(1,0,C(1)),forwardZ:E(2,-1,C(2)),positionX:E(6,0,R(0)),positionY:E(7,0,R(1)),positionZ:E(8,0,R(2)),upX:E(3,0,C(3)),upY:E(4,1,C(4)),upZ:E(5,0,C(5))}},{forwardX:p,forwardY:f,forwardZ:d,positionX:m,positionY:_,positionZ:v,upX:T,upY:S,upZ:k}=u.forwardX===void 0?h():u;return{get forwardX(){return p},get forwardY(){return f},get forwardZ(){return d},get positionX(){return m},get positionY(){return _},get positionZ(){return v},get upX(){return T},get upY(){return S},get upZ(){return k}}},wn=s=>"context"in s,Jt=s=>wn(s[0]),gt=(s,e,t,n)=>{for(const i of s)if(t(i)){if(n)return!1;throw Error("The set contains at least one similar element.")}return s.add(e),!0},hi=(s,e,[t,n],i)=>{gt(s,[e,t,n],r=>r[0]===e&&r[1]===t,i)},di=(s,[e,t,n],i)=>{const r=s.get(e);r===void 0?s.set(e,new Set([[t,n]])):gt(r,[t,n],o=>o[0]===t,i)},Ft=s=>"inputs"in s,xn=(s,e,t,n)=>{if(Ft(e)){const i=e.inputs[n];return s.connect(i,t,0),[i,t,0]}return s.connect(e,t,n),[e,t,n]},Wi=(s,e,t)=>{for(const n of s)if(n[0]===e&&n[1]===t)return s.delete(n),n;return null},Po=(s,e,t)=>Rn(s,n=>n[0]===e&&n[1]===t),Li=(s,e)=>{if(!Ht(s).delete(e))throw new Error("Missing the expected event listener.")},Bi=(s,e,t)=>{const n=je(s,e),i=Rn(n,r=>r[0]===t);return n.size===0&&s.delete(e),i},bn=(s,e,t,n)=>{Ft(e)?s.disconnect(e.inputs[n],t,0):s.disconnect(e,t,n)},ne=s=>je(gs,s),$t=s=>je(_s,s),ft=s=>cs.has(s),mn=s=>!Nt.has(s),pi=(s,e)=>new Promise(t=>{if(e!==null)t(!0);else{const n=s.createScriptProcessor(256,1,1),i=s.createGain(),r=s.createBuffer(1,2,44100),o=r.getChannelData(0);o[0]=1,o[1]=1;const a=s.createBufferSource();a.buffer=r,a.loop=!0,a.connect(n).connect(s.destination),a.connect(i),a.disconnect(i),n.onaudioprocess=c=>{const l=c.inputBuffer.getChannelData(0);Array.prototype.some.call(l,u=>u===1)?t(!0):t(!1),a.stop(),n.onaudioprocess=null,a.disconnect(n),n.disconnect(s.destination)},a.start()}}),ns=(s,e)=>{const t=new Map;for(const n of s)for(const i of n){const r=t.get(i);t.set(i,r===void 0?1:r+1)}t.forEach((n,i)=>e(i,n))},Tn=s=>"context"in s,Fo=s=>{const e=new Map;s.connect=(t=>(n,i=0,r=0)=>{const o=Tn(n)?t(n,i,r):t(n,i),a=e.get(n);
13return a===void 0?e.set(n,[{input:r,output:i}]):a.every(c=>c.input!==r||c.output!==i)&&a.push({input:r,output:i}),o})(s.connect.bind(s)),s.disconnect=(t=>(n,i,r)=>{if(t.apply(s),n===void 0)e.clear();else if(typeof n=="number")for(const[o,a]of e){const c=a.filter(l=>l.output!==n);c.length===0?e.delete(o):e.set(o,c)}else if(e.has(n))if(i===void 0)e.delete(n);else{const o=e.get(n);if(o!==void 0){const a=o.filter(c=>c.output!==i&&(c.input!==r||r===void 0));a.length===0?e.delete(n):e.set(n,a)}}for(const[o,a]of e)a.forEach(c=>{Tn(o)?s.connect(o,c.output,c.input):s.connect(o,c.output)})})(s.disconnect)},Vo=(s,e,t,n)=>{const{activeInputs:i,passiveInputs:r}=Qt(e),{outputs:o}=Te(s),a=Ht(s),c=l=>{const u=ne(s),h=$t(e);if(l){const p=Bi(r,s,t);hi(i,s,p,!1),!n&&!ft(s)&&u.connect(h,t)}else{const p=Po(i,s,t);di(r,p,!1),!n&&!ft(s)&&u.disconnect(h,t)}};return gt(o,[e,t],l=>l[0]===e&&l[1]===t,!0)?(a.add(c),Ye(s)?hi(i,s,[t,c],!0):di(r,[s,t,c],!0),!0):!1},jo=(s,e,t,n)=>{const{activeInputs:i,passiveInputs:r}=Te(e),o=Wi(i[n],s,t);return o===null?[Fi(r,s,t,n)[2],!1]:[o[2],!0]},qo=(s,e,t)=>{const{activeInputs:n,passiveInputs:i}=Qt(e),r=Wi(n,s,t);return r===null?[Bi(i,s,t)[1],!1]:[r[2],!0]},vs=(s,e,t,n,i)=>{const[r,o]=jo(s,t,n,i);if(r!==null&&(Li(s,r),o&&!e&&!ft(s)&&bn(ne(s),ne(t),n,i)),Ye(t)){const{activeInputs:a}=Te(t);hs(t,a)}},ws=(s,e,t,n)=>{const[i,r]=qo(s,t,n);i!==null&&(Li(s,i),r&&!e&&!ft(s)&&ne(s).disconnect($t(t),n))},Wo=(s,e)=>{const t=Te(s),n=[];for(const i of t.outputs)Jt(i)?vs(s,e,...i):ws(s,e,...i),n.push(i[0]);return t.outputs.clear(),n},Lo=(s,e,t)=>{const n=Te(s),i=[];for(const r of n.outputs)r[1]===t&&(Jt(r)?vs(s,e,...r):ws(s,e,...r),i.push(r[0]),n.outputs.delete(r));return i},Bo=(s,e,t,n,i)=>{const r=Te(s);return Array.from(r.outputs).filter(o=>o[0]===t&&(n===void 0||o[1]===n)&&(i===void 0||o[2]===i)).map(o=>(Jt(o)?vs(s,e,...o):ws(s,e,...o),r.outputs.delete(o),o[0]))},zo=(s,e,t,n,i,r,o,a,c,l,u,h,p,f,d,m)=>class extends l{constructor(v,T,S,k){super(S),this._context=v,this._nativeAudioNode=S;const g=u(v);h(g)&&t(pi,()=>pi(g,m))!==!0&&Fo(S),gs.set(this,S),Ri.set(this,new Set),v.state!=="closed"&&T&&Ot(this),s(this,k,S)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(v){this._nativeAudioNode.channelCount=v}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(v){this._nativeAudioNode.channelCountMode=v}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(v){this._nativeAudioNode.channelInterpretation=v}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(v,T=0,S=0){if(T<0||T>=this._nativeAudioNode.numberOfOutputs)throw i();const k=u(this._context),g=d(k);if(p(v)||f(v))throw r();if(wn(v)){const w=ne(v);try{const A=xn(this._nativeAudioNode,w,T,S),N=mn(this);(g||N)&&this._nativeAudioNode.disconnect(...A),this.context.state!=="closed"&&!N&&mn(v)&&Ot(v)}catch(A){throw A.code===12?r():A}if(e(this,v,T,S,g)){const A=c([this],v);ns(A,n(g))}return v}const x=$t(v);if(x.name==="playbackRate"&&x.maxValue===1024)throw o();try{this._nativeAudioNode.connect(x,T),(g||mn(this))&&this._nativeAudioNode.disconnect(x,T)}catch(w){throw w.code===12?r():w}if(Vo(this,v,T,g)){const w=c([this],v);ns(w,n(g))}}disconnect(v,T,S){let k;const g=u(this._context),x=d(g);if(v===void 0)k=Wo(this,x);else if(typeof v=="number"){if(v<0||v>=this.numberOfOutputs)throw i();k=Lo(this,x,v)}else{if(T!==void 0&&(T<0||T>=this.numberOfOutputs)||wn(v)&&S!==void 0&&(S<0||S>=v.numberOfInputs))throw i();if(k=Bo(this,x,v,T,S),k.length===0)throw r()}for(const b of k){const w=c([this],b);ns(w,a)}}},Uo=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>(f,d,m,_=null,v=null)=>{const T=m.value,S=new Kr(T),k=d?n(S):null,g={get defaultValue(){return T},get maxValue(){return _===null?m.maxValue:_},get minValue(){return v===null?m.minValue:v},get value(){return m.value},set value(x){m.value=x,g.setValueAtTime(x,f.context.currentTime)},cancelAndHoldAtTime(x){if(typeof m.cancelAndHoldAtTime=="function")k===null&&S.flush(f.context.currentTime),S.add(i(x)),m.cancelAndHoldAtTime(x);else{const b=Array.from(S).pop();k===null&&S.flush(f.context.currentTime),S.add(i(x));const w=Array.from(S).pop();m.cancelScheduledValues(x),b!==w&&w!==void 0&&(w.type==="exponentialRampToValue"?m.exponentialRampToValueAtTime(w.value,w.endTime):w.type==="linearRampToValue"?m.linearRampToValueAtTime(w.value,w.endTime):w.type==="setValue"?m.setValueAtTime(w.value,w.startTime):w.type==="setValueCurve"&&m.setValueCurveAtTime(w.values,w.startTime,w.duration))}return g},cancelScheduledValues(x){return k===null&&S.flush(f.context.currentTime),S.add(r(x)),m.cancelScheduledValues(x),g},exponentialRampToValueAtTime(x,b){if(x===0)throw new RangeError;if(!Number.isFinite(b)||b<0)throw new RangeError;
13const w=f.context.currentTime;return k===null&&S.flush(w),Array.from(S).length===0&&(S.add(l(T,w)),m.setValueAtTime(T,w)),S.add(o(x,b)),m.exponentialRampToValueAtTime(x,b),g},linearRampToValueAtTime(x,b){const w=f.context.currentTime;return k===null&&S.flush(w),Array.from(S).length===0&&(S.add(l(T,w)),m.setValueAtTime(T,w)),S.add(a(x,b)),m.linearRampToValueAtTime(x,b),g},setTargetAtTime(x,b,w){return k===null&&S.flush(f.context.currentTime),S.add(c(x,b,w)),m.setTargetAtTime(x,b,w),g},setValueAtTime(x,b){return k===null&&S.flush(f.context.currentTime),S.add(l(x,b)),m.setValueAtTime(x,b),g},setValueCurveAtTime(x,b,w){const O=x instanceof Float32Array?x:new Float32Array(x);if(h!==null&&h.name==="webkitAudioContext"){const A=b+w,N=f.context.sampleRate,C=Math.ceil(b*N),R=Math.floor(A*N),E=R-C,I=new Float32Array(E);for(let V=0;V<E;V+=1){const W=(O.length-1)/w*((C+V)/N-b),M=Math.floor(W),P=Math.ceil(W);I[V]=M===P?O[M]:(1-(W-M))*O[M]+(1-(P-W))*O[P]}k===null&&S.flush(f.context.currentTime),S.add(u(I,b,w)),m.setValueCurveAtTime(I,b,w);const D=R/N;D<A&&p(g,I[I.length-1],D),p(g,O[O.length-1],A)}else k===null&&S.flush(f.context.currentTime),S.add(u(O,b,w)),m.setValueCurveAtTime(O,b,w);return g}};return t.set(g,m),e.set(g,f),s(g,k),g},Go=s=>({replay(e){for(const t of s)if(t.type==="exponentialRampToValue"){const{endTime:n,value:i}=t;e.exponentialRampToValueAtTime(i,n)}else if(t.type==="linearRampToValue"){const{endTime:n,value:i}=t;e.linearRampToValueAtTime(i,n)}else if(t.type==="setTarget"){const{startTime:n,target:i,timeConstant:r}=t;e.setTargetAtTime(i,n,r)}else if(t.type==="setValue"){const{startTime:n,value:i}=t;e.setValueAtTime(i,n)}else if(t.type==="setValueCurve"){const{duration:n,startTime:i,values:r}=t;e.setValueCurveAtTime(r,i,n)}else throw new Error("Can't apply an unknown automation.")}});class zi{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((n,i)=>e.call(t,n,i,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}}const $o={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},Zo=(s,e,t,n,i,r,o,a,c,l,u,h,p,f)=>class extends e{constructor(m,_,v){var T;const S=a(m),k=c(S),g=u({...$o,...v});p(g);const x=ls.get(S),b=x==null?void 0:x.get(_),w=k||S.state!=="closed"?S:(T=o(S))!==null&&T!==void 0?T:S,O=i(w,k?null:m.baseLatency,l,_,b,g),A=k?n(_,g,b):null;super(m,!0,O,A);const N=[];O.parameters.forEach((R,E)=>{const I=t(this,k,R);N.push([E,I])}),this._nativeAudioWorkletNode=O,this._onprocessorerror=null,this._parameters=new zi(N),k&&s(S,this);const{activeInputs:C}=r(this);h(O,C)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(m){const _=typeof m=="function"?f(this,m):null;this._nativeAudioWorkletNode.onprocessorerror=_;const v=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=v!==null&&v===_?m:v}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Sn(s,e,t,n,i){if(typeof s.copyFromChannel=="function")e[t].byteLength===0&&(e[t]=new Float32Array(128)),s.copyFromChannel(e[t],n,i);else{const r=s.getChannelData(n);if(e[t].byteLength===0)e[t]=r.slice(i,i+128);else{const o=new Float32Array(r.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[t].set(o)}}}const Ui=(s,e,t,n,i)=>{typeof s.copyToChannel=="function"?e[t].byteLength!==0&&s.copyToChannel(e[t],n,i):e[t].byteLength!==0&&s.getChannelData(n).set(e[t],i)},Cn=(s,e)=>{const t=[];for(let n=0;n<s;n+=1){const i=[],r=typeof e=="number"?e:e[n];for(let o=0;o<r;o+=1)i.push(new Float32Array(128));t.push(i)}return t},Yo=(s,e)=>{const t=je(us,s),n=ne(e);return je(t,n)},Ho=async(s,e,t,n,i,r,o)=>{const a=e===null?Math.ceil(s.context.length/128)*128:e.length,c=n.channelCount*n.numberOfInputs,l=i.reduce((_,v)=>_+v,0),u=l===0?null:t.createBuffer(l,a,t.sampleRate);if(r===void 0)throw new Error("Missing the processor constructor.");const h=Te(s),p=await Yo(t,s),f=Cn(n.numberOfInputs,n.channelCount),d=Cn(n.numberOfOutputs,i),m=Array.from(s.parameters.keys()).reduce((_,v)=>({..._,[v]:new Float32Array(128)}),{});for(let _=0;_<a;_+=128){if(n.numberOfInputs>0&&e!==null)for(let v=0;v<n.numberOfInputs;v+=1)for(let T=0;T<n.channelCount;T+=1)Sn(e,f[v],T,T,_);r.parameterDescriptors!==void 0&&e!==null&&r.parameterDescriptors.forEac
13h(({name:v},T)=>{Sn(e,m,v,c+T,_)});for(let v=0;v<n.numberOfInputs;v+=1)for(let T=0;T<i[v];T+=1)d[v][T].byteLength===0&&(d[v][T]=new Float32Array(128));try{const v=f.map((S,k)=>h.activeInputs[k].size===0?[]:S),T=o(_/t.sampleRate,t.sampleRate,()=>p.process(v,d,m));if(u!==null)for(let S=0,k=0;S<n.numberOfOutputs;S+=1){for(let g=0;g<i[S];g+=1)Ui(u,d[S],g,k+g,_);k+=i[S]}if(!T)break}catch(v){s.dispatchEvent(new ErrorEvent("processorerror",{colno:v.colno,filename:v.filename,lineno:v.lineno,message:v.message}));break}}return u},Xo=(s,e,t,n,i,r,o,a,c,l,u,h,p,f,d,m)=>(_,v,T)=>{const S=new WeakMap;let k=null;const g=async(x,b)=>{let w=u(x),O=null;const A=we(w,b),N=Array.isArray(v.outputChannelCount)?v.outputChannelCount:Array.from(v.outputChannelCount);if(h===null){const C=N.reduce((D,V)=>D+V,0),R=i(b,{channelCount:Math.max(1,C),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,C)}),E=[];for(let D=0;D<x.numberOfOutputs;D+=1)E.push(n(b,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:N[D]}));const I=o(b,{channelCount:v.channelCount,channelCountMode:v.channelCountMode,channelInterpretation:v.channelInterpretation,gain:1});I.connect=e.bind(null,E),I.disconnect=c.bind(null,E),O=[R,E,I]}else A||(w=new h(b,_));if(S.set(b,O===null?w:O[2]),O!==null){if(k===null){if(T===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");const V=x.channelCount*x.numberOfInputs,W=T.parameterDescriptors===void 0?0:T.parameterDescriptors.length,M=V+W;k=Ho(x,M===0?null:await(async()=>{const q=new p(M,Math.ceil(x.context.length/128)*128,b.sampleRate),$=[],oe=[];for(let J=0;J<v.numberOfInputs;J+=1)$.push(o(q,{channelCount:v.channelCount,channelCountMode:v.channelCountMode,channelInterpretation:v.channelInterpretation,gain:1})),oe.push(i(q,{channelCount:v.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:v.channelCount}));const _e=await Promise.all(Array.from(x.parameters.values()).map(async J=>{const xe=r(q,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:J.value});return await f(q,J,xe.offset),xe})),U=n(q,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,V+W)});for(let J=0;J<v.numberOfInputs;J+=1){$[J].connect(oe[J]);for(let xe=0;xe<v.channelCount;xe+=1)oe[J].connect(U,xe,J*v.channelCount+xe)}for(const[J,xe]of _e.entries())xe.connect(U,0,V+J),xe.start(0);return U.connect(q.destination),await Promise.all($.map(J=>d(x,q,J))),m(q)})(),b,v,N,T,l)}const C=await k,R=t(b,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[E,I,D]=O;C!==null&&(R.buffer=C,R.start(0)),R.connect(E);for(let V=0,W=0;V<x.numberOfOutputs;V+=1){const M=I[V];for(let P=0;P<N[V];P+=1)E.connect(M,W+P,P);W+=N[V]}return D}if(A)for(const[C,R]of x.parameters.entries())await s(b,R,w.parameters.get(C));else for(const[C,R]of x.parameters.entries())await f(b,R,w.parameters.get(C));return await d(x,b,w),w};return{render(x,b){a(b,x);const w=S.get(b);return w!==void 0?Promise.resolve(w):g(x,b)}}},Qo=(s,e,t,n,i,r,o,a,c,l,u,h,p,f,d,m,_,v,T,S)=>class extends d{constructor(g,x){super(g,x),this._nativeContext=g,this._audioWorklet=s===void 0?void 0:{addModule:(b,w)=>s(this,b,w)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(g,x,b){return new t({length:x,numberOfChannels:g,sampleRate:b})}createBufferSource(){return new n(this)}createChannelMerger(g=6){return new r(this,{numberOfInputs:g})}createChannelSplitter(g=6){return new o(this,{numberOfOutputs:g})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(g=1){return new u(this,{maxDelayTime:g})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(g,x){return new f(this,{feedback:x,feedforward:g})}createOscillator(){return new m(this)}createPanner(){return new _(this)}
13createPeriodicWave(g,x,b={disableNormalization:!1}){return new v(this,{...b,imag:x,real:g})}createStereoPanner(){return new T(this)}createWaveShaper(){return new S(this)}decodeAudioData(g,x,b){return l(this._nativeContext,g).then(w=>(typeof x=="function"&&x(w),w),w=>{throw typeof b=="function"&&b(w),w})}},Jo={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Ko=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...Jo,...u},f=i(h,p),d=o(h),m=d?t():null;super(l,!1,f,m),this._Q=e(this,d,f.Q,be,ke),this._detune=e(this,d,f.detune,1200*Math.log2(be),-1200*Math.log2(be)),this._frequency=e(this,d,f.frequency,l.sampleRate/2,0),this._gain=e(this,d,f.gain,40*Math.log10(be),ke),this._nativeBiquadFilterNode=f,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(l){this._nativeBiquadFilterNode.type=l}getFrequencyResponse(l,u,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(l,u,h)}catch(p){throw p.code===11?n():p}if(l.length!==u.length||u.length!==h.length)throw n()}},ea=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=we(l,c);if(!u){const h={Q:l.Q.value,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,detune:l.detune.value,frequency:l.frequency.value,gain:l.gain.value,type:l.type};l=e(c,h)}return r.set(c,l),u?(await s(c,a.Q,l.Q),await s(c,a.detune,l.detune),await s(c,a.frequency,l.frequency),await s(c,a.gain,l.gain)):(await n(c,a.Q,l.Q),await n(c,a.detune,l.detune),await n(c,a.frequency,l.frequency),await n(c,a.gain,l.gain)),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},ta=(s,e)=>(t,n)=>{const i=e.get(t);if(i!==void 0)return i;const r=s.get(t);if(r!==void 0)return r;try{const o=n();return o instanceof Promise?(s.set(t,o),o.catch(()=>!1).then(a=>(s.delete(t),e.set(t,a),a))):(e.set(t,o),o)}catch{return e.set(t,!1),!1}},na={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},sa=(s,e,t,n,i)=>class extends s{constructor(o,a){const c=n(o),l={...na,...a},u=t(c,l),h=i(c)?e():null;super(o,!1,u,h)}},ia=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!we(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},ra={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},oa=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u=r({...ra,...c}),h=t(l,u),p=i(l)?e():null;super(a,!1,h,p)}},aa=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!we(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},ca=s=>(e,t,n)=>s(t,e,n),la=s=>(e,t,n=0,i=0)=>{const r=e[n];if(r===void 0)throw s();return Tn(t)?r.connect(t,0,i):r.connect(t,0)},ua=s=>(e,t)=>{const n=s(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return n.buffer=i,n.loop=!0,n.connect(t),n.start(),()=>{n.stop(),n.disconnect(t)}},ha={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},da=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...ha,...l},p=n(u,h),f=r(u),d=f?t():null;super(c,!1,p,d),this._constantSourceNodeRenderer=d,this._nativeConstantSourceNode=p,this._offset=e(this,f,p.offset,be,ke),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){const l=typeof c=="function"?o(this,c):null;this._nativeConstantSourceNode.onended=l;const u=this._nativeConstantSourceNode.onended;this._onended=u!==null&&u===l?c:u}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){Ot(this);const l=()=>{this._nativeConstantSourceNode.removeEventListener("ended",l),Ye(this)&&Xt(this)};this._nativeConstantSourceNode.addEventListener("ended",l)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}},pa=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;const c=async(l,u)=>{let h=t(l);const p=we(h,u);if(!p){const f={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(u,f),o!==null&&h.start(o),a!==null&&h.stop(a)}return r.set(u,h),p?await s(u,l.offset,h.offset):await n(u,l.offset,h.offset),await i(l,u,h),h};return{set start(l){o=l},set stop(l){a=l},render(l,u){const h=r.get(u);return h!==void 0?Promise.resolve(h):c(l,u)}}},fa=s=>e=>(s[0]=e,s[0]),ma={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},ga=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u={...ma,...c},h=t(l,u),f=i(l)?e():null;super(a,!1,h,f),this._isBufferNullified=!1,this._nativeConvolverNode=h,u.buffer!==null&&r(this,u.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){const c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,r(this,0)}else this._isBufferNullified=!1,r(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}},_a=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!we(a,o)){const l={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=s(o,l)}return n.set(o,a),Ft(a)?await t(r,o,a.inputs[0]):await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},ya=(s,e)=>(t,n,i)=>{if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(t,n,i)}catch(r){throw r.name==="SyntaxError"?s():r}},va=()=>new DOMException("","DataCloneError"),fi=s=>{const{port1:e,port2:t}=new MessageChannel;return new Promise(n=>{const i=()=>{t.onmessage=null,e.close(),t.close(),n()};t.onmessage=()=>i();try{e.postMessage(s,[s])}catch{}finally{i()}})},wa=(s,e,t,n,i,r,o,a,c,l,u)=>(h,p)=>{const f=o(h)?h:r(h);if(i.has(p)){const d=t();return Promise.reject(d)}try{i.add(p)}catch{}return e(c,()=>c(f))?f.decodeAudioData(p).then(d=>
13(fi(p).catch(()=>{}),e(a,()=>a(d))||u(d),s.add(d),d)):new Promise((d,m)=>{const _=async()=>{try{await fi(p)}catch{}},v=T=>{m(T),_()};try{f.decodeAudioData(p,T=>{typeof T.copyFromChannel!="function"&&(l(T),ys(T)),s.add(T),_().then(()=>d(T))},T=>{v(T===null?n():T)})}catch(T){v(T)}})},xa=(s,e,t,n,i,r,o,a)=>(c,l)=>{const u=e.get(c);if(u===void 0)throw new Error("Missing the expected cycle count.");const h=r(c.context),p=a(h);if(u===l){if(e.delete(c),!p&&o(c)){const f=n(c),{outputs:d}=t(c);for(const m of d)if(Jt(m)){const _=n(m[0]);s(f,_,m[1],m[2])}else{const _=i(m[0]);f.connect(_,m[1])}}}else e.set(c,u-l)},ba={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Ta=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...ba,...l},p=n(u,h),f=r(u),d=f?t(h.maxDelayTime):null;super(c,!1,p,d),this._delayTime=e(this,f,p.delayTime),o(this,h.maxDelayTime)}get delayTime(){return this._delayTime}},Sa=(s,e,t,n,i)=>r=>{const o=new WeakMap,a=async(c,l)=>{let u=t(c);const h=we(u,l);if(!h){const p={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,delayTime:u.delayTime.value,maxDelayTime:r};u=e(l,p)}return o.set(l,u),h?await s(l,c.delayTime,u.delayTime):await n(l,c.delayTime,u.delayTime),await i(c,l,u),u};return{render(c,l){const u=o.get(l);return u!==void 0?Promise.resolve(u):a(c,l)}}},Ca=s=>(e,t,n,i)=>s(e[i],r=>r[0]===t&&r[1]===n),ka=s=>(e,t)=>{s(e).delete(t)},Aa=s=>"delayTime"in s,Na=(s,e,t)=>function n(i,r){const o=wn(r)?r:t(s,r);if(Aa(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map(c=>n([...i,o],c[0])).reduce((c,l)=>c.concat(l),[])},hn=(s,e,t)=>{const n=e[t];if(n===void 0)throw s();return n},Oa=s=>(e,t=void 0,n=void 0,i=0)=>t===void 0?e.forEach(r=>r.disconnect()):typeof t=="number"?hn(s,e,t).disconnect():Tn(t)?n===void 0?e.forEach(r=>r.disconnect(t)):i===void 0?hn(s,e,n).disconnect(t,0):hn(s,e,n).disconnect(t,0,i):n===void 0?e.forEach(r=>r.disconnect(t)):hn(s,e,n).disconnect(t,0),Ma={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Ia=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...Ma,...u},f=n(h,p),d=o(h),m=d?t():null;super(l,!1,f,m),this._attack=e(this,d,f.attack),this._knee=e(this,d,f.knee),this._nativeDynamicsCompressorNode=f,this._ratio=e(this,d,f.ratio),this._release=e(this,d,f.release),this._threshold=e(this,d,f.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(l){const u=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=l,l>2)throw this._nativeDynamicsCompressorNode.channelCount=u,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(l){const u=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=l,l==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=u,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}},Ea=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=we(l,c);if(!u){const h={attack:l.attack.value,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,knee:l.knee.value,ratio:l.ratio.value,release:l.release.value,threshold:l.threshold.value};l=e(c,h)}return r.set(c,l),u?(await s(c,a.attack,l.attack),await s(c,a.knee,l.knee),await s(c,a.ratio,l.ratio),await s(c,a.release,l.release),await s(c,a.threshold,l.threshold)):(await n(c,a.attack,l.attack),await n(c,a.knee,l.knee),await n(c,a.ratio,l.ratio),await n(c,a.release,l.release),await n(c,a.threshold,l.threshold)),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Da=()=>new DOMException("","EncodingError"),Ra=s=>e=>new Promise((t,n)=>{if(s===null){n(new SyntaxError);return}const i=s.document.head;if(i===null)n(new SyntaxError);else{const r=s.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),c=s.onerror,l=()=>{s.onerror=c,URL.revokeObjectURL(a)};s.onerror=(u,h,p,f,d)=>{if(h===a||h===s.location.href&&p===1&&f===1)return l(),n(d),!1;if(c!==null)return c(u,h,p,f,d)},r.onerror=()=>{l(),n(new SyntaxError)},r.onload=()=>
13{l(),t()},r.src=a,r.type="module",i.appendChild(r)}}),Pa=s=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,n,i){if(n!==null){let r=this._listeners.get(n);r===void 0&&(r=s(this,n),typeof n=="function"&&this._listeners.set(n,r)),this._nativeEventTarget.addEventListener(t,r,i)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,n,i){const r=n===null?void 0:this._listeners.get(n);this._nativeEventTarget.removeEventListener(t,r===void 0?null:r,i)}},Fa=s=>(e,t,n)=>{Object.defineProperties(s,{currentFrame:{configurable:!0,get(){return Math.round(e*t)}},currentTime:{configurable:!0,get(){return e}}});try{return n()}finally{s!==null&&(delete s.currentFrame,delete s.currentTime)}},Va=s=>async e=>{try{const t=await fetch(e);if(t.ok)return[await t.text(),t.url]}catch{}throw s()},ja={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},qa=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...ja,...c},h=n(l,u),p=r(l),f=p?t():null;super(a,!1,h,f),this._gain=e(this,p,h.gain,be,ke)}get gain(){return this._gain}},Wa=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=we(l,c);if(!u){const h={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,gain:l.gain.value};l=e(c,h)}return r.set(c,l),u?await s(c,a.gain,l.gain):await n(c,a.gain,l.gain),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},La=(s,e)=>t=>e(s,t),Ba=s=>e=>{const t=s(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return t.renderer},za=s=>e=>{var t;return(t=s.get(e))!==null&&t!==void 0?t:0},Ua=s=>e=>{const t=s(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return t.renderer},Ga=s=>e=>s.get(e),ye=()=>new DOMException("","InvalidStateError"),$a=s=>e=>{const t=s.get(e);if(t===void 0)throw ye();return t},Za=(s,e)=>t=>{let n=s.get(t);if(n!==void 0)return n;if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new e(1,1,44100),s.set(t,n),n},Ya=s=>e=>{const t=s.get(e);if(t===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return t},Pn=()=>new DOMException("","InvalidAccessError"),Ha=s=>{s.getFrequencyResponse=(e=>(t,n,i)=>{if(t.length!==n.length||n.length!==i.length)throw Pn();return e.call(s,t,n,i)})(s.getFrequencyResponse)},Xa={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Qa=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u=i(l),h={...Xa,...c},p=e(l,u?null:a.baseLatency,h),f=u?t(h.feedback,h.feedforward):null;super(a,!1,p,f),Ha(p),this._nativeIIRFilterNode=p,r(this,1)}getFrequencyResponse(a,c,l){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,l)}},Gi=(s,e,t,n,i,r,o,a,c,l,u)=>{const h=l.length;let p=a;for(let f=0;f<h;f+=1){let d=t[0]*l[f];for(let m=1;m<i;m+=1){const _=p-m&c-1;d+=t[m]*r[_],d-=s[m]*o[_]}for(let m=i;m<n;m+=1)d+=t[m]*r[p-m&c-1];for(let m=i;m<e;m+=1)d-=s[m]*o[p-m&c-1];r[p]=l[f],o[p]=d,p=p+1&c-1,u[f]=d}return p},Ja=(s,e,t,n)=>{const i=t instanceof Float64Array?t:new Float64Array(t),r=n instanceof Float64Array?n:new Float64Array(n),o=i.length,a=r.length,c=Math.min(o,a);if(i[0]!==1){for(let d=0;d<o;d+=1)r[d]/=i[0];for(let d=1;d<a;d+=1)i[d]/=i[0]}const l=32,u=new Float32Array(l),h=new Float32Array(l),p=e.createBuffer(s.numberOfChannels,s.length,s.sampleRate),f=s.numberOfChannels;for(let d=0;d<f;d+=1){const m=s.getChannelData(d),_=p.getChannelData(d);u.fill(0),h.fill(0),Gi(i,o,r,a,c,u,h,0,l,m,_)}return p},Ka=(s,e,t,n,i)=>(r,o)=>{const a=new WeakMap;let c=null;const l=async(u,h)=>{let p=null,f=e(u);const d=we(f,h);if(h.createIIRFilter===void 0?p=s(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(f=h.createIIRFilter(o,r)),a.set(h,p===null?f:p),p!==null){if(c===null){if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");const _=new t(u.context.destination.channelCount,u.context.length,h.sampleRate);c=(async()=>{await n(u,_,_.destination);const v=await i(_);return Ja(v,h,r,o)})()}const m=await c;return p.buffer=m,p.start(0),p}return await n(u,h,f),f};return{render(u,h){const p=a.get(h);return p!==void 0?Promise.resolve(p):l(u,h)}}},ec=(s,e,t,n,i,r)=>o=>(a,c)=>{const l=s.get(a);if(l===void 0){if(!o&&r(a)){const u=n(a),{outputs:h}=t(a);for(const p of h)if(Jt(p)){const f=n(p[0]);e(u,f,p[1],p[2])}else{const f=i(p[0]);u.disconnect(f,p[1])}}s.set(a,c)}else s.set(a,l+c)},tc=(s,e)=>t=>{const n=s.get(t);return e(n)||e(t)},nc=(s,e)=>t=>s.has(t)||e(t),sc=(s,e)=>t=>s.has(t)||e(t),ic=(s,e)=>t=>{const n=s.get(t);return e(n)||e(t)},rc=s=>e=>s!==null&&e instanceof s,oc=s=>e=>s!==null&&typeof s.AudioNode=="function"&&e instanceof s.AudioNode,ac=s=>e=>s!==null&&typeof s.AudioParam=="function"&&e instanceof s.AudioParam,cc=(s,e)=>t=>s(t)||e(t),lc=s=>e=>s!==null&&e instanceof s,uc=s=>s!==null&&s.isSecureContext,hc=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r),c=e(a,o);if(n(a))throw TypeError();super(r,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}},dc={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},pc=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r);if(n(a))throw new TypeError;const c={...dc,...o},l=e(a,c);super(r,!1,l,null),this._nativeMediaStreamAudioDestinationNode=l}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},fc=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r),c=e(a,o);if(n(a))throw new TypeError;super(r,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},mc=(s,e,t)=>class extends s{constructor(i,r){const o=t(i),a=e(o,r);super(i,!0,a,null)}},gc=(s,e,t,n,i,r)=>class extends t{constructor(a,c){super(a),this._nativeContext=a,Dn.set(this,a),n(a)&&i.set(a,new Set),this._destination=new s(this,c),this._listener=e(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){const c=typeof a=="function"?r(this,a):null;this._nativeContext.onstatechange=c;const l=this._nativeContext.onstatechange;this._onstatechange=l!==null&&l===c?a:l}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},Zt=s=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const t=s.decodeAudioData(e.buffer,()=>{});return t===void 0?!1:(t.catch(()=>{}),!0)}catch{}return!1},_c=(s,e)=>(t,n,i)=>{const r=new Set;return t.connect=(o=>(a,c=0,l=0)=>{const u=r.size===0;if(e(a))return o.call(t,a,c,l),s(r,[a,c,l],h=>h[0]===a&&h[1]===c&&h[2]===l,!0),u&&n(),a;o.call(t,a,c),s(r,[a,c],h=>h[0]===a&&h[1]===c,!0),u&&n()})(t.connect),t.disconnect=(o=>(a,c,l)=>{const u=r.size>0;
13if(a===void 0)o.apply(t),r.clear();else if(typeof a=="number"){o.call(t,a);for(const p of r)p[1]===a&&r.delete(p)}else{e(a)?o.call(t,a,c,l):o.call(t,a,c);for(const p of r)p[0]===a&&(c===void 0||p[1]===c)&&(l===void 0||p[2]===l)&&r.delete(p)}const h=r.size===0;u&&h&&i()})(t.disconnect),t},se=(s,e,t)=>{const n=e[t];n!==void 0&&n!==s[t]&&(s[t]=n)},ge=(s,e)=>{se(s,e,"channelCount"),se(s,e,"channelCountMode"),se(s,e,"channelInterpretation")},mi=s=>typeof s.getFloatTimeDomainData=="function",yc=s=>{s.getFloatTimeDomainData=e=>{const t=new Uint8Array(e.length);s.getByteTimeDomainData(t);const n=Math.max(t.length,s.fftSize);for(let i=0;i<n;i+=1)e[i]=(t[i]-128)*.0078125;return e}},vc=(s,e)=>(t,n)=>{const i=t.createAnalyser();if(ge(i,n),!(n.maxDecibels>n.minDecibels))throw e();return se(i,n,"fftSize"),se(i,n,"maxDecibels"),se(i,n,"minDecibels"),se(i,n,"smoothingTimeConstant"),s(mi,()=>mi(i))||yc(i),i},wc=s=>s===null?null:s.hasOwnProperty("AudioBuffer")?s.AudioBuffer:null,ce=(s,e,t)=>{const n=e[t];n!==void 0&&n!==s[t].value&&(s[t].value=n)},xc=s=>{s.start=(e=>{let t=!1;return(n=0,i=0,r)=>{if(t)throw ye();e.call(s,n,i,r),t=!0}})(s.start)},xs=s=>{s.start=(e=>(t=0,n=0,i)=>{if(typeof i=="number"&&i<0||n<0||t<0)throw new RangeError("The parameters can't be negative.");e.call(s,t,n,i)})(s.start)},bs=s=>{s.stop=(e=>(t=0)=>{if(t<0)throw new RangeError("The parameter can't be negative.");e.call(s,t)})(s.stop)},bc=(s,e,t,n,i,r,o,a,c,l,u)=>(h,p)=>{const f=h.createBufferSource();return ge(f,p),ce(f,p,"playbackRate"),se(f,p,"buffer"),se(f,p,"loop"),se(f,p,"loopEnd"),se(f,p,"loopStart"),e(t,()=>t(h))||xc(f),e(n,()=>n(h))||c(f),e(i,()=>i(h))||l(f,h),e(r,()=>r(h))||xs(f),e(o,()=>o(h))||u(f,h),e(a,()=>a(h))||bs(f),s(h,f),f},Tc=s=>s===null?null:s.hasOwnProperty("AudioContext")?s.AudioContext:s.hasOwnProperty("webkitAudioContext")?s.webkitAudioContext:null,Sc=(s,e)=>(t,n,i)=>{const r=t.destination;if(r.channelCount!==n)try{r.channelCount=n}catch{}i&&r.channelCountMode!=="explicit"&&(r.channelCountMode="explicit"),r.maxChannelCount===0&&Object.defineProperty(r,"maxChannelCount",{value:n});const o=s(t,{channelCount:n,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,gain:1});return e(o,"channelCount",a=>()=>a.call(o),a=>c=>{a.call(o,c);try{r.channelCount=c}catch(l){if(c>r.maxChannelCount)throw l}}),e(o,"channelCountMode",a=>()=>a.call(o),a=>c=>{a.call(o,c),r.channelCountMode=c}),e(o,"channelInterpretation",a=>()=>a.call(o),a=>c=>{a.call(o,c),r.channelInterpretation=c}),Object.defineProperty(o,"maxChannelCount",{get:()=>r.maxChannelCount}),o.connect(r),o},Cc=s=>s===null?null:s.hasOwnProperty("AudioWorkletNode")?s.AudioWorkletNode:null,kc=s=>{const{port1:e}=new MessageChannel;try{e.postMessage(s)}finally{e.close()}},Ac=(s,e,t,n,i)=>(r,o,a,c,l,u)=>{if(a!==null)try{const h=new a(r,c,u),p=new Map;let f=null;if(Object.defineProperties(h,{channelCount:{get:()=>u.channelCount,set:()=>{throw s()}},channelCountMode:{get:()=>"explicit",set:()=>{throw s()}},onprocessorerror:{get:()=>f,set:d=>{typeof f=="function"&&h.removeEventListener("processorerror",f),f=typeof d=="function"?d:null,typeof f=="function"&&h.addEventListener("processorerror",f)}}}),h.addEventListener=(d=>(...m)=>{if(m[0]==="processorerror"){const _=typeof m[1]=="function"?m[1]:typeof m[1]=="object"&&m[1]!==null&&typeof m[1].handleEvent=="function"?m[1].handleEvent:null;if(_!==null){const v=p.get(m[1]);v!==void 0?m[1]=v:(m[1]=T=>{T.type==="error"?(Object.defineProperties(T,{type:{value:"processorerror"}}),_(T)):_(new ErrorEvent(m[0],{...T}))},p.set(_,m[1]))}}return d.call(h,"error",m[1],m[2]),d.call(h,...m)})(h.addEventListener),h.removeEventListener=(d=>(...m)=>{if(m[0]==="processorerror"){const _=p.get(m[1]);_!==void 0&&(p.delete(m[1]),m[1]=_)}return d.call(h,"error",m[1],m[2]),d.call(h,m[0],m[1],m[2])})(h.removeEventListener),u.numberOfOutputs!==0){const d=t(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(d).connect(r.destination),i(h,()=>d.disconnect(),()=>d.connect(r.destination))}return h}catch(h){throw h.code===11?n():h}if(l===void 0)throw n();return kc(u),e(r,o,l,u)},$i=(s,e)=>s===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(s*e))))),Nc=s=>new Promise((e,t)=>
13{const{port1:n,port2:i}=new MessageChannel;n.onmessage=({data:r})=>{n.close(),i.close(),e(r)},n.onmessageerror=({data:r})=>{n.close(),i.close(),t(r)},i.postMessage(s)}),Oc=async(s,e)=>{const t=await Nc(e);return new s(t)},Mc=(s,e,t,n)=>{let i=us.get(s);i===void 0&&(i=new WeakMap,us.set(s,i));const r=Oc(t,n);return i.set(e,r),r},Ic=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>(f,d,m,_)=>{if(_.numberOfInputs===0&&_.numberOfOutputs===0)throw c();const v=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(v.some(F=>F<1))throw c();if(v.length!==_.numberOfOutputs)throw e();if(_.channelCountMode!=="explicit")throw c();const T=_.channelCount*_.numberOfInputs,S=v.reduce((F,L)=>F+L,0),k=m.parameterDescriptors===void 0?0:m.parameterDescriptors.length;if(T+k>6||S>6)throw c();const g=new MessageChannel,x=[],b=[];for(let F=0;F<_.numberOfInputs;F+=1)x.push(o(f,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),b.push(i(f,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const w=[];if(m.parameterDescriptors!==void 0)for(const{defaultValue:F,maxValue:L,minValue:me,name:ie}of m.parameterDescriptors){const H=r(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:_.parameterData[ie]!==void 0?_.parameterData[ie]:F===void 0?0:F});Object.defineProperties(H.offset,{defaultValue:{get:()=>F===void 0?0:F},maxValue:{get:()=>L===void 0?be:L},minValue:{get:()=>me===void 0?ke:me}}),w.push(H)}const O=n(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,T+k)}),A=$i(d,f.sampleRate),N=a(f,A,T+k,Math.max(1,S)),C=i(f,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),R=[];for(let F=0;F<_.numberOfOutputs;F+=1)R.push(n(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:v[F]}));for(let F=0;F<_.numberOfInputs;F+=1){x[F].connect(b[F]);for(let L=0;L<_.channelCount;L+=1)b[F].connect(O,L,F*_.channelCount+L)}const E=new zi(m.parameterDescriptors===void 0?[]:m.parameterDescriptors.map(({name:F},L)=>{const me=w[L];return me.connect(O,0,T+L),me.start(0),[F,me.offset]}));O.connect(N);let I=_.channelInterpretation,D=null;const V=_.numberOfOutputs===0?[N]:R,W={get bufferSize(){return A},get channelCount(){return _.channelCount},set channelCount(F){throw t()},get channelCountMode(){return _.channelCountMode},set channelCountMode(F){throw t()},get channelInterpretation(){return I},set channelInterpretation(F){for(const L of x)L.channelInterpretation=F;I=F},get context(){return N.context},get inputs(){return x},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get onprocessorerror(){return D},set onprocessorerror(F){typeof D=="function"&&W.removeEventListener("processorerror",D),D=typeof F=="function"?F:null,typeof D=="function"&&W.addEventListener("processorerror",D)},get parameters(){return E},get port(){return g.port2},addEventListener(...F){return N.addEventListener(F[0],F[1],F[2])},connect:s.bind(null,V),disconnect:l.bind(null,V),dispatchEvent(...F){return N.dispatchEvent(F[0])},removeEventListener(...F){return N.removeEventListener(F[0],F[1],F[2])}},M=new Map;g.port1.addEventListener=(F=>(...L)=>{if(L[0]==="message"){const me=typeof L[1]=="function"?L[1]:typeof L[1]=="object"&&L[1]!==null&&typeof L[1].handleEvent=="function"?L[1].handleEvent:null;if(me!==null){const ie=M.get(L[1]);ie!==void 0?L[1]=ie:(L[1]=H=>{u(f.currentTime,f.sampleRate,()=>me(H))},M.set(me,L[1]))}}return F.call(g.port1,L[0],L[1],L[2])})(g.port1.addEventListener),g.port1.removeEventListener=(F=>(...L)=>{if(L[0]==="message"){const me=M.get(L[1]);me!==void 0&&(M.delete(L[1]),L[1]=me)}return F.call(g.port1,L[0],L[1],L[2])})(g.port1.removeEventListener);let P=null;Object.defineProperty(g.port1,"onmessage",{get:()=>P,set:F=>{typeof P=="function"&&g.port1.removeEventListener("message",P),P=typeof F=="function"?F:null,typeof P=="function"&&(g.port1.addEventListener("message",P),g.port1.start())}}),m.prototype.port=g.port1;let q=null;Mc(f,W,m,_).then(F=>q=F);const oe=Cn(_.numberOfInputs,_.channelCount),_e=Cn(_.numberOfOutputs,v),U=m.parameterDescriptors===void 0?[]:m.parameterDescriptors.reduce((F,{name:L})=>({...F,[L]:new Float32Array(128)}),{});let J=!0;const xe=()=>{_.numberOfOutputs>0&&N.disconnect(C);for(let F=0,L=0;F<_.numberOfOutputs;F+=1){const me=R[F];for(let ie=0;ie<v[F];ie+=1)C.disconnect(me,L+ie,ie);L+=v[F]}},j=new Map;N.onaudioprocess=({inputBuffer:F,outputBuffer:L})=>{if(q!==null){const me=h(W);for(let ie=0;ie<A;ie+=128){for(let H=0;H<_.numberOfInputs;H+=1)for(let ae=0;ae<_.channelCount;ae+=1)Sn(F,oe[H],ae,ae,ie);
13m.parameterDescriptors!==void 0&&m.parameterDescriptors.forEach(({name:H},ae)=>{Sn(F,U,H,T+ae,ie)});for(let H=0;H<_.numberOfInputs;H+=1)for(let ae=0;ae<v[H];ae+=1)_e[H][ae].byteLength===0&&(_e[H][ae]=new Float32Array(128));try{const H=oe.map((Me,Ke)=>{if(me[Ke].size>0)return j.set(Ke,A/128),Me;const Qn=j.get(Ke);return Qn===void 0?[]:(Me.every(jr=>jr.every(qr=>qr===0))&&(Qn===1?j.delete(Ke):j.set(Ke,Qn-1)),Me)});J=u(f.currentTime+ie/f.sampleRate,f.sampleRate,()=>q.process(H,_e,U));for(let Me=0,Ke=0;Me<_.numberOfOutputs;Me+=1){for(let zt=0;zt<v[Me];zt+=1)Ui(L,_e[Me],zt,Ke+zt,ie);Ke+=v[Me]}}catch(H){J=!1,W.dispatchEvent(new ErrorEvent("processorerror",{colno:H.colno,filename:H.filename,lineno:H.lineno,message:H.message}))}if(!J){for(let H=0;H<_.numberOfInputs;H+=1){x[H].disconnect(b[H]);for(let ae=0;ae<_.channelCount;ae+=1)b[ie].disconnect(O,ae,H*_.channelCount+ae)}if(m.parameterDescriptors!==void 0){const H=m.parameterDescriptors.length;for(let ae=0;ae<H;ae+=1){const Me=w[ae];Me.disconnect(O,0,T+ae),Me.stop()}}O.disconnect(N),N.onaudioprocess=null,lt?xe():wt();break}}}};let lt=!1;const ut=o(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),vt=()=>N.connect(ut).connect(f.destination),wt=()=>{N.disconnect(ut),ut.disconnect()},Fr=()=>{if(J){wt(),_.numberOfOutputs>0&&N.connect(C);for(let F=0,L=0;F<_.numberOfOutputs;F+=1){const me=R[F];for(let ie=0;ie<v[F];ie+=1)C.connect(me,L+ie,ie);L+=v[F]}}lt=!0},Vr=()=>{J&&(vt(),xe()),lt=!1};return vt(),p(W,Fr,Vr)},Zi=(s,e)=>{const t=s.createBiquadFilter();return ge(t,e),ce(t,e,"Q"),ce(t,e,"detune"),ce(t,e,"frequency"),ce(t,e,"gain"),se(t,e,"type"),t},Ec=(s,e)=>(t,n)=>{const i=t.createChannelMerger(n.numberOfInputs);return s!==null&&s.name==="webkitAudioContext"&&e(t,i),ge(i,n),i},Dc=s=>{const e=s.numberOfOutputs;Object.defineProperty(s,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw ye()}}),Object.defineProperty(s,"channelCountMode",{get:()=>"explicit",set:t=>{if(t!=="explicit")throw ye()}}),Object.defineProperty(s,"channelInterpretation",{get:()=>"discrete",set:t=>{if(t!=="discrete")throw ye()}})},Kt=(s,e)=>{const t=s.createChannelSplitter(e.numberOfOutputs);return ge(t,e),Dc(t),t},Rc=(s,e,t,n,i)=>(r,o)=>{if(r.createConstantSource===void 0)return t(r,o);const a=r.createConstantSource();return ge(a,o),ce(a,o,"offset"),e(n,()=>n(r))||xs(a),e(i,()=>i(r))||bs(a),s(r,a),a},Vt=(s,e)=>(s.connect=e.connect.bind(e),s.disconnect=e.disconnect.bind(e),s),Pc=(s,e,t,n)=>(i,{offset:r,...o})=>{const a=i.createBuffer(1,2,44100),c=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=t(i,{...o,gain:r}),u=a.getChannelData(0);u[0]=1,u[1]=1,c.buffer=a,c.loop=!0;const h={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(d){l.channelCount=d},get channelCountMode(){return l.channelCountMode},set channelCountMode(d){l.channelCountMode=d},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(d){l.channelInterpretation=d},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return c.onended},set onended(d){c.onended=d},addEventListener(...d){return c.addEventListener(d[0],d[1],d[2])},dispatchEvent(...d){return c.dispatchEvent(d[0])},removeEventListener(...d){return c.removeEventListener(d[0],d[1],d[2])},start(d=0){c.start.call(c,d)},stop(d=0){c.stop.call(c,d)}},p=()=>c.connect(l),f=()=>c.disconnect(l);return s(i,c),n(Vt(h,l),p,f)},Fc=(s,e)=>(t,n)=>{const i=t.createConvolver();if(ge(i,n),n.disableNormalization===i.normalize&&(i.normalize=!n.disableNormalization),se(i,n,"buffer"),n.channelCount>2||(e(i,"channelCount",r=>()=>r.call(i),r=>o=>{if(o>2)throw s();return r.call(i,o)}),n.channelCountMode==="max"))throw s();return e(i,"channelCountMode",r=>()=>r.call(i),r=>o=>{if(o==="max")throw s();return r.call(i,o)}),i},Yi=(s,e)=>{const t=s.createDelay(e.maxDelayTime);return ge(t,e),ce(t,e,"delayTime"),t},Vc=s=>(e,t)=>{const n=e.createDynamicsCompressor();if(ge(n,t),t.channelCount>2||t.channelCountMode==="max")throw s();
13return ce(n,t,"attack"),ce(n,t,"knee"),ce(n,t,"ratio"),ce(n,t,"release"),ce(n,t,"threshold"),n},Ne=(s,e)=>{const t=s.createGain();return ge(t,e),ce(t,e,"gain"),t},jc=s=>(e,t,n)=>{if(e.createIIRFilter===void 0)return s(e,t,n);const i=e.createIIRFilter(n.feedforward,n.feedback);return ge(i,n),i};function qc(s,e){const t=e[0]*e[0]+e[1]*e[1];return[(s[0]*e[0]+s[1]*e[1])/t,(s[1]*e[0]-s[0]*e[1])/t]}function Wc(s,e){return[s[0]*e[0]-s[1]*e[1],s[0]*e[1]+s[1]*e[0]]}function gi(s,e){let t=[0,0];for(let n=s.length-1;n>=0;n-=1)t=Wc(t,e),t[0]+=s[n];return t}const Lc=(s,e,t,n)=>(i,r,{channelCount:o,channelCountMode:a,channelInterpretation:c,feedback:l,feedforward:u})=>{const h=$i(r,i.sampleRate),p=l instanceof Float64Array?l:new Float64Array(l),f=u instanceof Float64Array?u:new Float64Array(u),d=p.length,m=f.length,_=Math.min(d,m);if(d===0||d>20)throw n();if(p[0]===0)throw e();if(m===0||m>20)throw n();if(f[0]===0)throw e();if(p[0]!==1){for(let w=0;w<m;w+=1)f[w]/=p[0];for(let w=1;w<d;w+=1)p[w]/=p[0]}const v=t(i,h,o,o);v.channelCount=o,v.channelCountMode=a,v.channelInterpretation=c;const T=32,S=[],k=[],g=[];for(let w=0;w<o;w+=1){S.push(0);const O=new Float32Array(T),A=new Float32Array(T);O.fill(0),A.fill(0),k.push(O),g.push(A)}v.onaudioprocess=w=>{const O=w.inputBuffer,A=w.outputBuffer,N=O.numberOfChannels;for(let C=0;C<N;C+=1){const R=O.getChannelData(C),E=A.getChannelData(C);S[C]=Gi(p,d,f,m,_,k[C],g[C],S[C],T,R,E)}};const x=i.sampleRate/2;return Vt({get bufferSize(){return h},get channelCount(){return v.channelCount},set channelCount(w){v.channelCount=w},get channelCountMode(){return v.channelCountMode},set channelCountMode(w){v.channelCountMode=w},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(w){v.channelInterpretation=w},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},addEventListener(...w){return v.addEventListener(w[0],w[1],w[2])},dispatchEvent(...w){return v.dispatchEvent(w[0])},getFrequencyResponse(w,O,A){if(w.length!==O.length||O.length!==A.length)throw s();const N=w.length;for(let C=0;C<N;C+=1){const R=-Math.PI*(w[C]/x),E=[Math.cos(R),Math.sin(R)],I=gi(f,E),D=gi(p,E),V=qc(I,D);O[C]=Math.sqrt(V[0]*V[0]+V[1]*V[1]),A[C]=Math.atan2(V[1],V[0])}},removeEventListener(...w){return v.removeEventListener(w[0],w[1],w[2])}},v)},Bc=(s,e)=>s.createMediaElementSource(e.mediaElement),zc=(s,e)=>{const t=s.createMediaStreamDestination();return ge(t,e),t.numberOfOutputs===1&&Object.defineProperty(t,"numberOfOutputs",{get:()=>0}),t},Uc=(s,{mediaStream:e})=>{const t=e.getAudioTracks();t.sort((r,o)=>r.id<o.id?-1:r.id>o.id?1:0);const n=t.slice(0,1),i=s.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(i,"mediaStream",{value:e}),i},Gc=(s,e)=>(t,{mediaStreamTrack:n})=>{if(typeof t.createMediaStreamTrackSource=="function")return t.createMediaStreamTrackSource(n);const i=new MediaStream([n]),r=t.createMediaStreamSource(i);if(n.kind!=="audio")throw s();if(e(t))throw new TypeError;return r},$c=s=>s===null?null:s.hasOwnProperty("OfflineAudioContext")?s.OfflineAudioContext:s.hasOwnProperty("webkitOfflineAudioContext")?s.webkitOfflineAudioContext:null,Zc=(s,e,t,n,i,r)=>(o,a)=>{const c=o.createOscillator();return ge(c,a),ce(c,a,"detune"),ce(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):se(c,a,"type"),e(t,()=>t(o))||xs(c),e(n,()=>n(o))||r(c,o),e(i,()=>i(o))||bs(c),s(o,c),c},Yc=s=>(e,t)=>{const n=e.createPanner();return n.orientationX===void 0?s(e,t):(ge(n,t),ce(n,t,"orientationX"),ce(n,t,"orientationY"),ce(n,t,"orientationZ"),ce(n,t,"positionX"),ce(n,t,"positionY"),ce(n,t,"positionZ"),se(n,t,"coneInnerAngle"),se(n,t,"coneOuterAngle"),se(n,t,"coneOuterGain"),se(n,t,"distanceModel"),se(n,t,"maxDistance"),se(n,t,"panningModel"),se(n,t,"refDistance"),se(n,t,"rolloffFactor"),n)},Hc=(s,e,t,n,i,r,o,a,c,l)=>(u,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:f,distanceModel:d,maxDistance:m,orientationX:_,orientationY:v,orientationZ:T,panningModel:S,positionX:k,positionY:g,positionZ:x,refDistance:b,rolloffFactor:w,...O})=>{const A=u.createPanner();if(O.channelCount>2||O.channelCountMode==="max")throw o();ge(A,O);const N={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},C=t(u,{...N,channelInterpretation:"speakers",numberOfInputs:6}),R=n(u,{...O,gain:1}),E=n(u,{...N,gain:1}),I=n(u,{...N,gain:0}),D=n(u,{...N,gain:0}),V=n(u,{...N,gain:0}),W=n(u,{...N,gain:0}),M=n(u,{...N,gain:0}),P=i(u,256,6,1),q=r(u,{...N,curve:new Float32Array([1,1]),oversample:"none"});let $=[_,v,T],oe=[k,g,x];const _e=new Float32Array(1);P.onaudioprocess=({inputBuffer:j})=>{const lt=[c(j,_e,0),c(j,_e,1),c(j,_e,2)];lt.some((vt,wt)=>vt!==$[wt])&&(A.setOrientation(...lt),$=lt);const ut=[c(j,_e,3),c(j,_e,4),c(j,_e,5)];ut.some((vt,wt)=>vt!==oe[wt])&&(A.setPosition(...ut),oe=ut)},Object.defineProperty(I.gain,"defaultValue",{get:()=>0}),Object.defineProperty(D.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(W.gain,"defaultValue",{get:()=>0}),Object.defineProperty(M.gain,"defaultValue",{get:()=>0});const U={get bufferSize(){},get channelCount(){return A.channelCount},set channelCount(j){if(j>2)throw o();R.channelCount=j,A.channelCount=j},get channelCountMode(){return A.channelCountMode},set channelCountMode(j){if(j==="max")throw o();R.channelCountMode=j,A.channelCountMode=j},get channelInterpretation(){return A.channelInterpretation},set channelInterpretation(j){R.channelInterpretation=j,A.channelInterpretation=j},get coneInnerAngle(){return A.coneInnerAngle},set coneInnerAngle(j){A.coneInnerAngle=j},get coneOuterAngle(){return A.coneOuterAngle},set coneOuterAngle(j){A.coneOuterAngle=j},get coneOuterGain(){return A.coneOuterGain},set coneOuterGain(j){if(j<0||j>1)throw e();A.coneOuterGain=j},get context(){return A.context},get distanceModel(){return A.distanceModel},set distanceModel(j){A.distanceModel=j},get inputs(){return[R]},get maxDistance(){return A.maxDistance},set maxDistance(j){if(j<0)throw new RangeError;A.maxDistance=j},get numberOfInputs(){return A.numberOfInputs},get numberOfOutputs(){return A.numberOfOutputs},get orientationX(){return E.gain},get orientationY(){return I.gain},get orientationZ(){return D.gain},get panningModel(){return A.panningModel},set panningModel(j){A.panningModel=j},get positionX(){return V.gain},get positionY(){return W.gain},get positionZ(){return M.gain},get refDistance(){return A.refDistance},set refDistance(j){if(j<0)throw new RangeError;A.refDistance=j},get rolloffFactor(){return A.rolloffFactor},set rolloffFactor(j){if(j<0)throw new RangeError;A.rolloffFactor=j},addEventListener(...j){return R.addEventListener(j[0],j[1],j[2])},dispatchEvent(...j){return R.dispatchEvent(j[0])},removeEventListener(...j){return R.removeEventListener(j[0],j[1],j[2])}};h!==U.coneInnerAngle&&(U.coneInnerAngle=h),p!==U.coneOuterAngle&&(U.coneOuterAngle=p),f!==U.coneOuterGain&&(U.coneOuterGain=f),d!==U.distanceModel&&(U.distanceModel=d),m!==U.maxDistance&&(U.maxDistance=m),_!==U.orientationX.value&&(U.orientationX.value=_),v!==U.orientationY.value&&(U.orientationY.value=v),T!==U.orientationZ.value&&(U.orientationZ.value=T),S!==U.panningModel&&(U.panningModel=S),k!==U.positionX.value&&(U.positionX.value=k),g!==U.positionY.value&&(U.positionY.value=g),x!==U.positionZ.value&&(U.positionZ.value=x),b!==U.refDistance&&(U.refDistance=b),w!==U.rolloffFactor&&(U.rolloffFactor=w),($[0]!==1||$[1]!==0||$[2]!==0)&&A.setOrientation(...$),(oe[0]!==0||oe[1]!==0||oe[2]!==0)&&A.setPosition(...oe);const J=()=>{R.connect(A),s(R,q,0,0),q.connect(E).connect(C,0,0),q.connect(I).connect(C,0,1),q.connect(D).connect(C,0,2),q.connect(V).connect(C,0,3),q.connect(W).connect(C,0,4),q.connect(M).connect(C,0,5),C.connect(P).connect(u.destination)},xe=()=>{R.disconnect(A),a(R,q,0,0),q.disconnect(E),E.disconnect(C),q.disconnect(I),I.disconnect(C),q.disconnect(D),D.disconnect(C),q.disconnect(V),V.disconnect(C),q.disconnect(W),W.disconnect(C),q.disconnect(M),M.disconnect(C),C.disconnect(P),P.disconnect(u.destination)};return l(Vt(U,A),J,xe)},Xc=s=>(e,{disableNormalization:t,imag:n,real:i})=>{const r=n instanceof Float32Array?n:new Float32Array(n),o=i instanceof Float32Array?i:new Float32Array(i),a=e.createPerio
13dicWave(o,r,{disableNormalization:t});if(Array.from(n).length<2)throw s();return a},en=(s,e,t,n)=>s.createScriptProcessor(e,t,n),Qc=(s,e)=>(t,n)=>{const i=n.channelCountMode;if(i==="clamped-max")throw e();if(t.createStereoPanner===void 0)return s(t,n);const r=t.createStereoPanner();return ge(r,n),ce(r,n,"pan"),Object.defineProperty(r,"channelCountMode",{get:()=>i,set:o=>{if(o!==i)throw e()}}),r},Jc=(s,e,t,n,i,r)=>{const a=new Float32Array([1,1]),c=Math.PI/2,l={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},u={...l,oversample:"none"},h=(d,m,_,v)=>{const T=new Float32Array(16385),S=new Float32Array(16385);for(let O=0;O<16385;O+=1){const A=O/16384*c;T[O]=Math.cos(A),S[O]=Math.sin(A)}const k=t(d,{...l,gain:0}),g=n(d,{...u,curve:T}),x=n(d,{...u,curve:a}),b=t(d,{...l,gain:0}),w=n(d,{...u,curve:S});return{connectGraph(){m.connect(k),m.connect(x.inputs===void 0?x:x.inputs[0]),m.connect(b),x.connect(_),_.connect(g.inputs===void 0?g:g.inputs[0]),_.connect(w.inputs===void 0?w:w.inputs[0]),g.connect(k.gain),w.connect(b.gain),k.connect(v,0,0),b.connect(v,0,1)},disconnectGraph(){m.disconnect(k),m.disconnect(x.inputs===void 0?x:x.inputs[0]),m.disconnect(b),x.disconnect(_),_.disconnect(g.inputs===void 0?g:g.inputs[0]),_.disconnect(w.inputs===void 0?w:w.inputs[0]),g.disconnect(k.gain),w.disconnect(b.gain),k.disconnect(v,0,0),b.disconnect(v,0,1)}}},p=(d,m,_,v)=>{const T=new Float32Array(16385),S=new Float32Array(16385),k=new Float32Array(16385),g=new Float32Array(16385),x=Math.floor(16385/2);for(let V=0;V<16385;V+=1)if(V>x){const W=(V-x)/(16384-x)*c;T[V]=Math.cos(W),S[V]=Math.sin(W),k[V]=0,g[V]=1}else{const W=V/(16384-x)*c;T[V]=1,S[V]=0,k[V]=Math.cos(W),g[V]=Math.sin(W)}const b=e(d,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),w=t(d,{...l,gain:0}),O=n(d,{...u,curve:T}),A=t(d,{...l,gain:0}),N=n(d,{...u,curve:S}),C=n(d,{...u,curve:a}),R=t(d,{...l,gain:0}),E=n(d,{...u,curve:k}),I=t(d,{...l,gain:0}),D=n(d,{...u,curve:g});return{connectGraph(){m.connect(b),m.connect(C.inputs===void 0?C:C.inputs[0]),b.connect(w,0),b.connect(A,0),b.connect(R,1),b.connect(I,1),C.connect(_),_.connect(O.inputs===void 0?O:O.inputs[0]),_.connect(N.inputs===void 0?N:N.inputs[0]),_.connect(E.inputs===void 0?E:E.inputs[0]),_.connect(D.inputs===void 0?D:D.inputs[0]),O.connect(w.gain),N.connect(A.gain),E.connect(R.gain),D.connect(I.gain),w.connect(v,0,0),R.connect(v,0,0),A.connect(v,0,1),I.connect(v,0,1)},disconnectGraph(){m.disconnect(b),m.disconnect(C.inputs===void 0?C:C.inputs[0]),b.disconnect(w,0),b.disconnect(A,0),b.disconnect(R,1),b.disconnect(I,1),C.disconnect(_),_.disconnect(O.inputs===void 0?O:O.inputs[0]),_.disconnect(N.inputs===void 0?N:N.inputs[0]),_.disconnect(E.inputs===void 0?E:E.inputs[0]),_.disconnect(D.inputs===void 0?D:D.inputs[0]),O.disconnect(w.gain),N.disconnect(A.gain),E.disconnect(R.gain),D.disconnect(I.gain),w.disconnect(v,0,0),R.disconnect(v,0,0),A.disconnect(v,0,1),I.disconnect(v,0,1)}}},f=(d,m,_,v,T)=>{if(m===1)return h(d,_,v,T);if(m===2)return p(d,_,v,T);throw i()};return(d,{channelCount:m,channelCountMode:_,pan:v,...T})=>{if(_==="max")throw i();const S=s(d,{...T,channelCount:1,channelCountMode:_,numberOfInputs:2}),k=t(d,{...T,channelCount:m,channelCountMode:_,gain:1}),g=t(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:v});let{connectGraph:x,disconnectGraph:b}=f(d,m,k,g,S);Object.defineProperty(g.gain,"defaultValue",{get:()=>0}),Object.defineProperty(g.gain,"maxValue",{get:()=>1}),Object.defineProperty(g.gain,"minValue",{get:()=>-1});const w={get bufferSize(){},get channelCount(){return k.channelCount},set channelCount(C){k.channelCount!==C&&(O&&b(),{connectGraph:x,disconnectGraph:b}=f(d,C,k,g,S),O&&x()),k.channelCount=C},get channelCountMode(){return k.channelCountMode},set channelCountMode(C){if(C==="clamped-max"||C==="max")throw i();k.channelCountMode=C},get channelInterpretation(){return k.channelInterpretation},set channelInterpretation(C){k.channelInterpretation=C},get context(){return k.context},get inputs(){return[k]},get numberOfInputs(){return k.numberOfInputs},get numberOfOutputs(){return k.numberOfOutputs},get pan(){return g.gain},addEventListener(...C){return k.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return k.dispatchEvent(C[0])},removeEventListener(...C){return k.removeEventListener(C[0],C[1],C[2])}};let O=!1;const A=()=>{x(),O=!0},N=()=>{b(),O=!1};return r(Vt(w,S),A,N)}},Kc=(s,e,t,n,i,r,o)=>(a,c)=>{const l=a.createWaveShaper();if(r!==null&&r.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return t(a,c);ge(l,c);const u=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(u!==null&&u.length<2)throw e();se(l,{curve:u},"curve"),se(l,c,"oversample");let h=null,p=!1;return o(l,"curve",m=>()=>m.call(l),m=>_=>(m.call(l,_),p&&(n(_)&&h===null?h=s(a,l):!n(_)&&h!==null&&(h(),h=null)),_)),i(l,()=>{p=!0,n(l.curve)&&(h=s(a,l))},()=>{p=!1,h!==null&&(h(),h=null)})},el=(s,e,t,n,i)=>(r,{curve:o,oversample:a,...c})=>{const l=r.createWaveShaper(),u=r.createWaveShaper();ge(l,c),ge(u,c);const h=t(r,{...c,gain:1}),p=t(r,{...c,gain:-1}),f=t(r,{...c,gain:1}),d=t(r,{...c,gain:-1});let m=null,_=!1,v=null;const T={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(g){h.channelCount=g,p.channelCount=g,l.channelCount=g,f.channelCount=g,u.channelCount=g,d.channelCount=g},get channelCountMode(){return l.channelCountMode},set channelCountMode(g){h.channelCountMode=g,p.channelCountMode=g,l.channelCountMode=g,f.channelCountMode=g,u.channelCountMode=g,d.channelCountMode=g},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(g){h.channelInterpretation=g,p.channelInterpretation=g,l.channelInterpretation=g,f.channelInterpretation=g,u.channelInterpretation=g,d.channelInterpretation=g},get context(){return l.context},get curve(){return v},set curve(g){if(g!==null&&g.length<2)throw e();if(g===null)l.curve=g,u.curve=g;else{const x=g.length,b=new Float32Array(x+2-x%2),w=new Float32Array(x+2-x%2);b[0]=g[0],w[0]=-g[x-1];const O=Math.ceil((x+1)/2),A=(x+1)/2-1;for(let N=1;N<O;N+=1){const C=N/O*A,R=Math.floor(C),E=Math.ceil(C);b[N]=R===E?g[R]:(1-(C-R))*g[R]+(1-(E-C))*g[E],w[N]=R===E?-g[x-1-R]:-((1-(C-R))*g[x-1-R])-(1-(E-C))*g[x-1-E]}b[O]=x%2===1?g[O-1]:(g[O-2]+g[O-1])/2,l.curve=b,u.curve=w}v=g,_&&(n(v)&&m===null?m=s(r,h):m!==null&&(m(),m=null))},get inputs(){return[h]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(g){l.oversample=g,u.oversample=g},addEventListener(...g){return h.addEventListener(g[0],g[1],g[2])},dispatchEvent(...g){return h.dispatchEvent(g[0])},removeEventListener(...g){return h.removeEventListener(g[0],g[1],g[2])}};o!==null&&(T.curve=o instanceof Float32Array?o:new Float32Array(o)),a!==T.oversample&&(T.oversample=a);const S=()=>{h.connect(l).connect(f),h.connect(p).connect(u).connect(d).connect(f),_=!0,n(v)&&(m=s(r,h))},k=()=>{h.disconnect(l),l.disconnect(f),h.disconnect(p),p.disconnect(u),u.disconnect(d),d.disconnect(f),_=!1,m!==null&&(m(),m=null)};
13return i(Vt(T,f),S,k)},Ce=()=>new DOMException("","NotSupportedError"),tl={numberOfChannels:1},nl=(s,e,t,n,i)=>class extends s{constructor(o,a,c){let l;if(typeof o=="number"&&a!==void 0&&c!==void 0)l={length:a,numberOfChannels:o,sampleRate:c};else if(typeof o=="object")l=o;else throw new Error("The given parameters are not valid.");const{length:u,numberOfChannels:h,sampleRate:p}={...tl,...l},f=n(h,u,p);e(Zt,()=>Zt(f))||f.addEventListener("statechange",(()=>{let d=0;const m=_=>{this._state==="running"&&(d>0?(f.removeEventListener("statechange",m),_.stopImmediatePropagation(),this._waitForThePromiseToSettle(_)):d+=1)};return m})()),super(f,h),this._length=u,this._nativeOfflineAudioContext=f,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,qi(this)}))}_waitForThePromiseToSettle(o){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(o):setTimeout(()=>this._waitForThePromiseToSettle(o))}},sl={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},il=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...sl,...l},p=t(u,h),f=r(u),d=f?n():null,m=c.sampleRate/2;super(c,!1,p,d),this._detune=e(this,f,p.detune,153600,-153600),this._frequency=e(this,f,p.frequency,m,-m),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=d,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){const l=typeof c=="function"?o(this,c):null;this._nativeOscillatorNode.onended=l;const u=this._nativeOscillatorNode.onended;this._onended=u!==null&&u===l?c:u}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"){Ot(this);const l=()=>{this._nativeOscillatorNode.removeEventListener("ended",l),Ye(this)&&Xt(this)};this._nativeOscillatorNode.addEventListener("ended",l)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}},rl=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null,c=null;const l=async(u,h)=>{let p=t(u);const f=we(p,h);if(!f){const d={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:o===null?void 0:o,type:p.type};p=e(h,d),a!==null&&p.start(a),c!==null&&p.stop(c)}return r.set(h,p),f?(await s(h,u.detune,p.detune),await s(h,u.frequency,p.frequency)):(await n(h,u.detune,p.detune),await n(h,u.frequency,p.frequency)),await i(u,h,p),p};return{set periodicWave(u){o=u},set start(u){a=u},set stop(u){c=u},render(u,h){const p=r.get(h);return p!==void 0?Promise.resolve(p):l(u,h)}}},ol={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},al=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...ol,...l},p=t(u,h),f=r(u),d=f?n():null;super(c,!1,p,d),this._nativePannerNode=p,this._orientationX=e(this,f,p.orientationX,be,ke),this._orientationY=e(this,f,p.orientationY,be,ke),this._orientationZ=e(this,f,p.orientationZ,be,ke),this._positionX=e(this,f,p.positionX,be,ke),this._positionY=e(this,f,p.positionY,be,ke),this._positionZ=e(this,f,p.positionZ,be,ke),o(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}},cl=(s,e,t,n,i,r,o,a,c,l)=>()=>{const u=new WeakMap;let h=null;const p=async(f,d)=>{let m=null,_=r(f);const v={channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation},T={...v,coneInnerAngle:_.coneInnerAngle,coneOuterAngle:_.coneOuterAngle,coneOuterGain:_.coneOuterGain,distanceModel:_.distanceModel,maxDistance:_.maxDistance,panningModel:_.panningModel,refDistance:_.refDistance,rolloffFactor:_.rolloffFactor},S=we(_,d);if("bufferSize"in _)m=n(d,{...v,gain:1});else if(!S){const k={...T,orientationX:_.orientationX.value,orientationY:_.orientationY.value,orientationZ:_.orientationZ.value,positionX:_.positionX.value,positionY:_.positionY.value,positionZ:_.positionZ.value};_=i(d,k)}if(u.set(d,m===null?_:m),m!==null){if(h===null){if(o===null)throw new Error("Missing the native OfflineAudioContext constructor.");const N=new o(6,f.context.length,d.sampleRate),C=e(N,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});C.connect(N.destination),h=(async()=>{const R=await Promise.all([f.orientationX,f.orientationY,f.orientationZ,f.positionX,f.positionY,f.positionZ].map(async(E,I)=>{const D=t(N,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:I===0?1:0});return await a(N,E,D.offset),D}));for(let E=0;E<6;E+=1)R[E].connect(C,0,E),R[E].start(0);return l(N)})()}const k=await h,g=n(d,{...v,gain:1});await c(f,d,g);const x=[];for(let N=0;N<k.numberOfChannels;N+=1)x.push(k.getChannelData(N));let b=[x[0][0],x[1][0],x[2][0]],w=[x[3][0],x[4][0],x[5][0]],O=n(d,{...v,gain:1}),A=i(d,{...T,orientationX:b[0],orientationY:b[1],orientationZ:b[2],positionX:w[0],positionY:w[1],positionZ:w[2]});
13g.connect(O).connect(A.inputs[0]),A.connect(m);for(let N=128;N<k.length;N+=128){const C=[x[0][N],x[1][N],x[2][N]],R=[x[3][N],x[4][N],x[5][N]];if(C.some((E,I)=>E!==b[I])||R.some((E,I)=>E!==w[I])){b=C,w=R;const E=N/d.sampleRate;O.gain.setValueAtTime(0,E),O=n(d,{...v,gain:0}),A=i(d,{...T,orientationX:b[0],orientationY:b[1],orientationZ:b[2],positionX:w[0],positionY:w[1],positionZ:w[2]}),O.gain.setValueAtTime(1,E),g.connect(O).connect(A.inputs[0]),A.connect(m)}}return m}return S?(await s(d,f.orientationX,_.orientationX),await s(d,f.orientationY,_.orientationY),await s(d,f.orientationZ,_.orientationZ),await s(d,f.positionX,_.positionX),await s(d,f.positionY,_.positionY),await s(d,f.positionZ,_.positionZ)):(await a(d,f.orientationX,_.orientationX),await a(d,f.orientationY,_.orientationY),await a(d,f.orientationZ,_.orientationZ),await a(d,f.positionX,_.positionX),await a(d,f.positionY,_.positionY),await a(d,f.positionZ,_.positionZ)),Ft(_)?await c(f,d,_.inputs[0]):await c(f,d,_),_};return{render(f,d){const m=u.get(d);return m!==void 0?Promise.resolve(m):p(f,d)}}},ll={disableNormalization:!1},ul=(s,e,t,n)=>class Hi{constructor(r,o){const a=e(r),c=n({...ll,...o}),l=s(a,c);return t.add(l),l}static[Symbol.hasInstance](r){return r!==null&&typeof r=="object"&&Object.getPrototypeOf(r)===Hi.prototype||t.has(r)}},hl=(s,e)=>(t,n,i)=>(s(n).replay(i),e(n,t,i)),dl=(s,e,t)=>async(n,i,r)=>{const o=s(n);await Promise.all(o.activeInputs.map((a,c)=>Array.from(a).map(async([l,u])=>{const p=await e(l).render(l,i),f=n.context.destination;!t(l)&&(n!==f||!t(n))&&p.connect(r,u,c)})).reduce((a,c)=>[...a,...c],[]))},pl=(s,e,t)=>async(n,i,r)=>{const o=e(n);await Promise.all(Array.from(o.activeInputs).map(async([a,c])=>{const u=await s(a).render(a,i);t(a)||u.connect(r,c)}))},fl=(s,e,t,n)=>i=>s(Zt,()=>Zt(i))?Promise.resolve(s(n,n)).then(r=>{if(!r){const o=t(i,512,0,1);i.oncomplete=()=>{o.onaudioprocess=null,o.disconnect()},o.onaudioprocess=()=>i.currentTime,o.connect(i.destination)}return i.startRendering()}):new Promise(r=>{const o=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{o.disconnect(),r(a.renderedBuffer)},o.connect(i.destination),i.startRendering()}),ml=s=>(e,t)=>{s.set(e,t)},gl=s=>(e,t)=>s.set(e,t),_l=(s,e,t,n,i,r,o,a)=>(c,l)=>t(c).render(c,l).then(()=>Promise.all(Array.from(n(l)).map(u=>t(u).render(u,l)))).then(()=>i(l)).then(u=>(typeof u.copyFromChannel!="function"?(o(u),ys(u)):e(r,()=>r(u))||a(u),s.add(u),u)),yl={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},vl=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...yl,...c},h=t(l,u),p=r(l),f=p?n():null;super(a,!1,h,f),this._pan=e(this,p,h.pan)}get pan(){return this._pan}},wl=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=we(l,c);if(!u){const h={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,pan:l.pan.value};l=e(c,h)}return r.set(c,l),u?await s(c,a.pan,l.pan):await n(c,a.pan,l.pan),Ft(l)?await i(a,c,l.inputs[0]):await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},xl=s=>()=>{if(s===null)return!1;try{new s({length:1,sampleRate:44100})}catch{return!1}return!0},bl=(s,e)=>async()=>{if(s===null)return!0;if(e===null)return!1;const t=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new e(1,128,44100),i=URL.createObjectURL(t);let r=!1,o=!1;try{await n.audioWorklet.addModule(i);const a=new s(n,"a",{numberOfOutputs:0}),c=n.createOscillator();a.port.onmessage=()=>r=!0,a.onprocessorerror=()=>o=!0,c.connect(a),c.start(0),await n.startRendering(),await new Promise(l=>setTimeout(l))}catch{}finally{URL.revokeObjectURL(i)}return r&&!o},Tl=(s,e)=>()=>{if(e===null)return Promise.resolve(!1);const t=new e(1,1,44100),n=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{t.oncomplete=()=>{n.disconnect(),i(t.currentTime!==0)},t.startRendering()})},Sl=()=>new DOMException("","UnknownError"),Cl={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},kl=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...Cl,...l},p=t(u,h),d=r(u)?n():null;super(c,!0,p,d),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,o(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}
13set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}},Al=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!we(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=s(o,l)}return n.set(o,a),Ft(a)?await t(r,o,a.inputs[0]):await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},Nl=()=>typeof window>"u"?null:window,Ol=(s,e)=>t=>{t.copyFromChannel=(n,i,r=0)=>{const o=s(r),a=s(i);if(a>=t.numberOfChannels)throw e();const c=t.length,l=t.getChannelData(a),u=n.length;for(let h=o<0?-o:0;h+o<c&&h<u;h+=1)n[h]=l[h+o]},t.copyToChannel=(n,i,r=0)=>{const o=s(r),a=s(i);if(a>=t.numberOfChannels)throw e();const c=t.length,l=t.getChannelData(a),u=n.length;for(let h=o<0?-o:0;h+o<c&&h<u;h+=1)l[h+o]=n[h]}},Ml=s=>e=>{e.copyFromChannel=(t=>(n,i,r=0)=>{const o=s(r),a=s(i);if(o<e.length)return t.call(e,n,a,o)})(e.copyFromChannel),e.copyToChannel=(t=>(n,i,r=0)=>{const o=s(r),a=s(i);if(o<e.length)return t.call(e,n,a,o)})(e.copyToChannel)},Il=s=>(e,t)=>{const n=t.createBuffer(1,1,44100);e.buffer===null&&(e.buffer=n),s(e,"buffer",i=>()=>{const r=i.call(e);return r===n?null:r},i=>r=>i.call(e,r===null?n:r))},El=(s,e)=>(t,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw s()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw s()}});const i=t.createBufferSource();e(n,()=>{const a=n.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(n,0,c)},()=>i.disconnect(n))},Xi=(s,e,t)=>s.copyFromChannel===void 0?s.getChannelData(t)[0]:(s.copyFromChannel(e,t),e[0]),Qi=s=>{if(s===null)return!1;const e=s.length;return e%2!==0?s[Math.floor(e/2)]!==0:s[e/2-1]+s[e/2]!==0},tn=(s,e,t,n)=>{let i=s;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:r,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(s,e,{get:t(r),set:n(o)})},Dl=s=>({...s,outputChannelCount:s.outputChannelCount!==void 0?s.outputChannelCount:s.numberOfInputs===1&&s.numberOfOutputs===1?[s.channelCount]:Array.from({length:s.numberOfOutputs},()=>1)}),Rl=s=>({...s,channelCount:s.numberOfOutputs}),Pl=s=>{const{imag:e,real:t}=s;return e===void 0?t===void 0?{...s,imag:[0,0],real:[0,0]}:{...s,imag:Array.from(t,()=>0),real:t}:t===void 0?{...s,imag:e,real:Array.from(e,()=>0)}:{...s,imag:e,real:t}},Ji=(s,e,t)=>{try{s.setValueAtTime(e,t)}catch(n){if(n.code!==9)throw n;Ji(s,e,t+1e-7)}},Fl=s=>{const e=s.createBufferSource();e.start();try{e.start()}catch{return!0}return!1},Vl=s=>{const e=s.createBufferSource(),t=s.createBuffer(1,1,44100);e.buffer=t;try{e.start(0,1)}catch{return!1}return!0},jl=s=>{const e=s.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0},Ts=s=>{const e=s.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},Ki=s=>{const e=s.createBuffer(1,1,44100),t=s.createBufferSource();t.buffer=e,t.start(),t.stop();try{return t.stop(),!0}catch{return!1}},Ss=s=>{const e=s.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},ql=s=>{const{port1:e,port2:t}=new MessageChannel;try{e.postMessage(s)}finally{e.close(),t.close()}},Wl=s=>{s.start=(e=>(t=0,n=0,i)=>{const r=s.buffer,o=r===null?n:Math.min(r.duration,n);r!==null&&o>r.duration-.5/s.context.sampleRate?e.call(s,t,0,0):e.call(s,t,o,i)})(s.start)},er=(s,e)=>{const t=e.createGain();s.connect(t);const n=(i=>()=>{i.call(s,t),s.removeEventListener("ended",n)})(s.disconnect);s.addEventListener("ended",n),Vt(s,t),s.stop=(i=>{let r=!1;return(o=0)=>{if(r)try{i.call(s,o)}catch{t.gain.setValueAtTime(0,o)}else i.call(s,o),r=!0}})(s.stop)},jt=(s,e)=>t=>{const n={value:s};return Object.defineProperties(t,{currentTarget:n,target:n}),typeof e=="function"?e.call(s,t):e.handleEvent.call(s,t)},Ll=oo(gt),Bl=po(gt),zl=Ca(Rn),tr=new WeakMap,Ul=za(tr),We=ta(new Map,new WeakMap),Be=Nl(),nr=vc(We,ze),Cs=Ba(Te),ve=dl(Te,Cs,ft),Gl=yo(nr,ne,ve),te=$a(Dn),Xe=$c(Be),Q=lc(Xe),sr=new WeakMap,ir=Pa(jt),nn=Tc(Be),ks=rc(nn),As=oc(Be),rr=ac(Be),Yt=Cc(Be),he=zo(ao(Ei),ho(Ll,Bl,xn,zl,bn,Te,Ul,Ht,ne,gt,Ye,ft,mn),We,ec(cs,bn,Te,ne,$t,Ye),ze,Pn,Ce,xa(xn,cs,Te,ne,$t,te,Ye,Q),Na(sr,Te,
13je),ir,te,ks,As,rr,Q,Yt),$l=_o(he,Gl,ze,nr,te,Q),Ns=new WeakSet,_i=wc(Be),or=fa(new Uint32Array(1)),Os=Ol(or,ze),Ms=Ml(or),ar=wo(Ns,We,Ce,_i,Xe,xl(_i),Os,Ms),Fn=fo(Ne),cr=pl(Cs,Qt,ft),Ue=ca(cr),qt=bc(Fn,We,Fl,Vl,jl,Ts,Ki,Ss,Wl,Il(tn),er),Ge=hl(Ua(Qt),cr),Zl=To(Ue,qt,ne,Ge,ve),Le=Uo(co(Di),sr,_s,Go,eo,to,no,so,io,rs,Oi,nn,Ji),Yl=bo(he,Zl,Le,ye,qt,te,Q,jt),Hl=Eo(he,Do,ze,ye,Sc(Ne,tn),te,Q,ve),Xl=ea(Ue,Zi,ne,Ge,ve),_t=gl(tr),Ql=Ko(he,Le,Xl,Pn,Zi,te,Q,_t),ot=_c(gt,As),Jl=El(ye,ot),at=Ec(nn,Jl),Kl=ia(at,ne,ve),eu=sa(he,Kl,at,te,Q),tu=aa(Kt,ne,ve),nu=oa(he,tu,Kt,te,Q,Rl),su=Pc(Fn,qt,Ne,ot),Wt=Rc(Fn,We,su,Ts,Ss),iu=pa(Ue,Wt,ne,Ge,ve),ru=da(he,Le,iu,Wt,te,Q,jt),lr=Fc(Ce,tn),ou=_a(lr,ne,ve),au=ga(he,ou,lr,te,Q,_t),cu=Sa(Ue,Yi,ne,Ge,ve),lu=Ta(he,Le,cu,Yi,te,Q,_t),ur=Vc(Ce),uu=Ea(Ue,ur,ne,Ge,ve),hu=Ia(he,Le,uu,ur,Ce,te,Q,_t),du=Wa(Ue,Ne,ne,Ge,ve),pu=qa(he,Le,du,Ne,te,Q),fu=Lc(Pn,ye,en,Ce),Vn=fl(We,Ne,en,Tl(Ne,Xe)),mu=Ka(qt,ne,Xe,ve,Vn),gu=jc(fu),_u=Qa(he,gu,mu,te,Q,_t),yu=Ro(Le,at,Wt,en,Ce,Xi,Q,tn),hr=new WeakMap,vu=gc(Hl,yu,ir,Q,hr,jt),dr=Zc(Fn,We,Ts,Ki,Ss,er),wu=rl(Ue,dr,ne,Ge,ve),xu=il(he,Le,dr,wu,te,Q,jt),pr=ua(qt),bu=el(pr,ye,Ne,Qi,ot),jn=Kc(pr,ye,bu,Qi,ot,nn,tn),Tu=Hc(xn,ye,at,Ne,en,jn,Ce,bn,Xi,ot),fr=Yc(Tu),Su=cl(Ue,at,Wt,Ne,fr,ne,Xe,Ge,ve,Vn),Cu=al(he,Le,fr,Su,te,Q,_t),ku=Xc(ze),Au=ul(ku,te,new WeakSet,Pl),Nu=Jc(at,Kt,Ne,jn,Ce,ot),mr=Qc(Nu,Ce),Ou=wl(Ue,mr,ne,Ge,ve),Mu=vl(he,Le,mr,Ou,te,Q),Iu=Al(jn,ne,ve),Eu=kl(he,ye,jn,Iu,te,Q,_t),gr=uc(Be),Is=Fa(Be),_r=new WeakMap,Du=Za(_r,Xe),Ru=gr?uo(We,Ce,Ra(Be),Is,Va(ro),te,Du,Q,Yt,new WeakMap,new WeakMap,bl(Yt,Xe),Be):void 0,Pu=cc(ks,Q),Fu=wa(Ns,We,va,Da,new WeakSet,te,Pu,vn,Zt,Os,Ms),yr=Qo(Ru,$l,ar,Yl,Ql,eu,nu,ru,au,Fu,lu,hu,pu,_u,vu,xu,Cu,Au,Mu,Eu),Vu=hc(he,Bc,te,Q),ju=pc(he,zc,te,Q),qu=fc(he,Uc,te,Q),Wu=Gc(ye,Q),Lu=mc(he,Wu,te),Bu=Io(yr,ye,Ce,Sl,Vu,ju,qu,Lu,nn),Es=Ya(hr),zu=mo(Es),vr=la(ze),Uu=ka(Es),wr=Oa(ze),xr=new WeakMap,Gu=La(xr,je),$u=Ic(vr,ze,ye,at,Kt,Wt,Ne,en,Ce,wr,Is,Gu,ot),Zu=Ac(ye,$u,Ne,Ce,ot),Yu=Xo(Ue,vr,qt,at,Kt,Wt,Ne,Uu,wr,Is,ne,Yt,Xe,Ge,ve,Vn),Hu=Ga(_r),Xu=ml(xr),yi=gr?Zo(zu,he,Le,Yu,Zu,Te,Hu,te,Q,Yt,Dl,Xu,ql,jt):void 0,Qu=ya(Ce,Xe),Ju=_l(Ns,We,Cs,Es,Vn,vn,Os,Ms),Ku=nl(yr,We,ye,Qu,Ju),eh=tc(Dn,ks),th=nc(gs,As),nh=sc(_s,rr),sh=ic(Dn,Q);function Ee(s){return s===void 0}function Z(s){return s!==void 0}function ih(s){return typeof s=="function"}function st(s){return typeof s=="number"}function pt(s){return Object.prototype.toString.call(s)==="[object Object]"&&s.constructor===Object}function rh(s){return typeof s=="boolean"}function Ve(s){return Array.isArray(s)}function He(s){return typeof s=="string"}function dn(s){return He(s)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(s)}function B(s,e){if(!s)throw new Error(e)}function it(s,e,t=1/0){if(!(e<=s&&s<=t))throw new RangeError(`Value must be within [${e}, ${t}], got: ${s}`)}function br(s){!s.isOffline&&s.state!=="running"&&Ds('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Tr=!1,vi=!1;function wi(s){Tr=s}function oh(s){Ee(s)&&Tr&&!vi&&(vi=!0,Ds("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}let Sr=console;function ah(...s){Sr.log(...s)}function Ds(...s){Sr.warn(...s)}function ch(s){return new Bu(s)}function lh(s,e,t){return new Ku(s,e,t)}const Oe=typeof self=="object"?self:null,uh=Oe&&(Oe.hasOwnProperty("AudioContext")||Oe.hasOwnProperty("webkitAudioContext"));function hh(s,e,t){return B(Z(yi),"AudioWorkletNode only works in a secure context (https or localhost)"),new(s instanceof(Oe==null?void 0:Oe.BaseAudioContext)?Oe==null?void 0:Oe.AudioWorkletNode:yi)(s,e,t)}class dh{constructor(e,t,n,i){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=n,this._createClock()}_createWorker(){const e=new Blob([`
14			// the initial timeout time
15			let timeoutTime =  ${(this._updateInterval*1e3).toFixed(1)};
16			// onmessage callback
17			self.onmessage = function(msg){
18				timeoutTime = parseInt(msg.data);
19			};
20			// the tick function which posts a message
21			// and schedules a new tick
22			function tick(){
23				setTimeout(tick, timeoutTime);
24				self.postMessage('tick');
25			}
26			// call tick initially
27			tick();
28			`],{type:"text/javascript"}),t=URL.createObjectURL(e),n=new Worker(t);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch{this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type==="worker"&&((t=this._worker)===null||t===void 0||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}}function mt(s){return nh(s)}function nt(s){return th(s)}function gn(s){return sh(s)}function bt(s){return eh(s)}function ph(s){return s instanceof ar}function fh(s,e){return s==="value"||mt(e)||nt(e)||ph(e)}function kt(s,...e){if(!e.length)return s;const t=e.shift();if(pt(s)&&pt(t))for(const n in t)fh(n,t[n])?s[n]=t[n]:pt(t[n])?(s[n]||Object.assign(s,{[n]:{}}),kt(s[n],t[n])):Object.assign(s,{[n]:t[n]});return kt(s,...e)}function mh(s,e){return s.length===e.length&&s.every((t,n)=>e[n]===t)}function z(s,e,t=[],n){const i={},r=Array.from(e);if(pt(r[0])&&n&&!Reflect.has(r[0],n)&&(Object.keys(r[0]).some(a=>Reflect.has(s,a))||(kt(i,{[n]:r[0]}),t.splice(t.indexOf(n),1),r.shift())),r.length===1&&pt(r[0]))kt(i,r[0]);else for(let o=0;o<t.length;o++)Z(r[o])&&(i[t[o]]=r[o]);return kt(s,i)}function gh(s){return s.constructor.getDefaults()}function At(s,e){return Ee(s)?e:s}function xi(s,e){return e.forEach(t=>{Reflect.has(s,t)&&delete s[t]}),s}/**
29 * Tone.js
30 * @author Yotam Mann
31 * @license http://opensource.org/licenses/MIT MIT License
32 * @copyright 2014-2024 Yotam Mann
33 */class Qe{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||Oe&&this.toString()===Oe.TONE_DEBUG_CLASS)&&ah(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}Qe.version=Ni;const Rs=1e-6;function Mt(s,e){return s>e+Rs}function ps(s,e){return Mt(s,e)||Re(s,e)}function kn(s,e){return s+Rs<e}function Re(s,e){return Math.abs(s-e)<Rs}function _h(s,e,t){return Math.max(Math.min(s,t),e)}class De extends Qe{constructor(){super(),this.name="Timeline",this._timeline=[];const e=z(De.getDefaults(),arguments,["memory"]);this.memory=e.memory,this.increasing=e.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(e){if(B(Reflect.has(e,"time"),"Timeline: events must have a time attribute"),e.time=e.time.valueOf(),this.increasing&&this.length){const t=this._timeline[this.length-1];B(ps(e.time,t.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(e)}else{const t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(e){const t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t="time"){const n=this._search(e,t);return n!==-1?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t="time"){const n=this._search(e,t);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(e){const t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];const n=this._search(e);return n-1>=0?this._timeline[n-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0)if(Re(this._timeline[t].time,e)){for(let n=t;n>=0&&Re(this._timeline[n].time,e);n--)t=n;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1);else this._timeline=[]}else this._timeline.length===1&&ps(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){const t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){const t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t="time"){if(this._timeline.length===0)return-1;let n=0;const i=this._timeline.length;let r=i;if(i>0&&this._timeline[i-1][t]<=e)return i-1;for(;n<r;){let o=Math.floor(n+(r-n)/2);const a=this._timeline[o],c=this._timeline[o+1];if(Re(a[t],e)){for(let l=o;l<this._timeline.length;l++){const u=this._timeline[l];
33if(Re(u[t],e))o=l;else break}return o}else{if(kn(a[t],e)&&Mt(c[t],e))return o;Mt(a[t],e)?r=o:n=o+1}}return-1}_iterate(e,t=0,n=this._timeline.length-1){this._timeline.slice(t,n+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){const n=this._search(e);return n!==-1&&this._iterate(t,0,n),this}forEachAfter(e,t){const n=this._search(e);return this._iterate(t,n+1),this}forEachBetween(e,t,n){let i=this._search(e),r=this._search(t);return i!==-1&&r!==-1?(this._timeline[i].time!==e&&(i+=1),this._timeline[r].time===t&&(r-=1),this._iterate(n,i,r)):i===-1&&this._iterate(n,0,r),this}forEachFrom(e,t){let n=this._search(e);for(;n>=0&&this._timeline[n].time>=e;)n--;return this._iterate(t,n+1),this}forEachAtTime(e,t){const n=this._search(e);if(n!==-1&&Re(this._timeline[n].time,e)){let i=n;for(let r=n;r>=0&&Re(this._timeline[r].time,e);r--)i=r;this._iterate(r=>{t(r)},i,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const Cr=[];function qn(s){Cr.push(s)}function yh(s){Cr.forEach(e=>e(s))}const kr=[];function Wn(s){kr.push(s)}function vh(s){kr.forEach(e=>e(s))}class sn extends Qe{constructor(){super(...arguments),this.name="Emitter"}on(e,t){return e.split(/\W+/).forEach(i=>{Ee(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(t)}),this}once(e,t){const n=(...i)=>{t(...i),this.off(e,n)};return this.on(e,n),this}off(e,t){return e.split(/\W+/).forEach(i=>{if(Ee(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Ee(t))this._events[i]=[];else{const r=this._events[i];for(let o=r.length-1;o>=0;o--)r[o]===t&&r.splice(o,1)}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){const n=this._events[e].slice(0);for(let i=0,r=n.length;i<r;i++)n[i].apply(this,t)}return this}static mixin(e){["on","once","off","emit"].forEach(t=>{const n=Object.getOwnPropertyDescriptor(sn.prototype,t);Object.defineProperty(e.prototype,t,n)})}dispose(){return super.dispose(),this._events=void 0,this}}class Ar extends sn{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}class rn extends Ar{constructor(){var e,t;super(),this.name="Context",this._constants=new Map,this._timeouts=new De,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;const n=z(rn.getDefaults(),arguments,["context"]);n.context?(this._context=n.context,this._latencyHint=((e=arguments[0])===null||e===void 0?void 0:e.latencyHint)||""):(this._context=ch({latencyHint:n.latencyHint}),this._latencyHint=n.latencyHint),this._ticker=new dh(this.emit.bind(this,"tick"),n.clockSource,n.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((t=arguments[0])===null||t===void 0)&&t.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=n.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(yh(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(e,t,n){return this._context.createBuffer(e,t,n)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,n){return this._context.createPeriodicWave(e,t,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}
33createMediaStreamSource(e){return B(bt(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return B(bt(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return B(bt(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(e){B(!this._initialized,"The listener cannot be set after initialization."),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){B(!this._initialized,"The transport cannot be set after initialization."),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){B(!this._initialized,"Draw cannot be set after initialization."),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){B(!this._initialized,"The destination cannot be set after initialization."),this._destination=e}createAudioWorkletNode(e,t){return hh(this.rawContext,e,t)}addAudioWorkletModule(e){return fe(this,void 0,void 0,function*(){B(Z(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(e)),yield this._workletPromise})}workletsAreReady(){return fe(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return bt(this._context)?this._context.resume():Promise.resolve()}close(){return fe(this,void 0,void 0,function*(){bt(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&vh(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{const t=this._context.createBuffer(1,128,this._context.sampleRate),n=t.getChannelData(0);for(let r=0;r<n.length;r++)n[r]=e;const i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=t,i.loop=!0,i.start(0),this._constants.set(e,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){const e=this.now();this._timeouts.forEachBefore(e,t=>{t.callback(),this._timeouts.remove(t)})}setTimeout(e,t){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:n+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){const n=++this._timeoutIds,i=()=>{const r=this.now();this._timeouts.add({callback:()=>{e(),i()},id:n,time:r+t})};return i(),n}}class wh extends Ar{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,n){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return fe(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}}function re(s,e){Ve(e)?e.forEach(t=>re(s,t)):Object.defineProperty(s,e,{enumerable:!0,writable:!1})}function Ps(s,e){Ve(e)?e.forEach(t=>Ps(s,t)):Object.defineProperty(s,e,{writable:!0})}const X=()=>{};class K extends Qe{constructor(){super(),this.name="ToneAudioBuffer",this.onload=X;const e=z(K.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=e.reverse,this.onload=e.onload,He(e.url)?this.load(e.url).catch(e.onerror):e.url&&this.set(e.url)}static getDefaults(){return{onerror:X,onload:X,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Pe().sampleRate}set(e){return e instanceof K?e.loaded?this._buffer=e.get():e.onload=()=>{this.set(e),this.onload(this)}:this._buffer=e,this._reversed&&this._reverse(),this}get(){return this._buffer}load(e){return fe(this,void 0,void 0,function*(){const t=K.load(e).then(n=>{this.set(n),this.onload(this)});K.downloads.push(t);try{yield t}finally{const n=K.downloads.indexOf(t);K.downloads.splice(n,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){const t=Ve(e)&&e[0].length>0,n=t?e.length:1,i=t?e[0].length:e.length,r=Pe(),o=r.createBuffer(n,i,r.sampleRate),a=!t&&n===1?[e]:e;for(let c=0;c<n;
33c++)o.copyToChannel(a[c],c);return this._buffer=o,this}toMono(e){if(st(e))this.fromArray(this.toArray(e));else{let t=new Float32Array(this.length);const n=this.numberOfChannels;for(let i=0;i<n;i++){const r=this.toArray(i);for(let o=0;o<r.length;o++)t[o]+=r[o]}t=t.map(i=>i/n),this.fromArray(t)}return this}toArray(e){if(st(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{const t=[];for(let n=0;n<this.numberOfChannels;n++)t[n]=this.getChannelData(n);return t}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array(0)}slice(e,t=this.duration){B(this.loaded,"Buffer is not loaded");const n=Math.floor(e*this.sampleRate),i=Math.floor(t*this.sampleRate);B(n<i,"The start time must be less than the end time");const r=i-n,o=Pe().createBuffer(this.numberOfChannels,r,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)o.copyToChannel(this.getChannelData(a).subarray(n,i),a);return new K(o)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(e){return new K().fromArray(e)}static fromUrl(e){return fe(this,void 0,void 0,function*(){return yield new K().load(e)})}static load(e){return fe(this,void 0,void 0,function*(){const t=K.baseUrl===""||K.baseUrl.endsWith("/")?K.baseUrl:K.baseUrl+"/",n=yield fetch(t+e);if(!n.ok)throw new Error(`could not load url: ${e}`);const i=yield n.arrayBuffer();return yield Pe().decodeAudioData(i)})}static supportsType(e){const t=e.split("."),n=t[t.length-1];return document.createElement("audio").canPlayType("audio/"+n)!==""}static loaded(){return fe(this,void 0,void 0,function*(){for(yield Promise.resolve();K.downloads.length;)yield K.downloads[0]})}}K.baseUrl="";K.downloads=[];class Fs extends rn{constructor(){super({clockSource:"offline",context:gn(arguments[0])?arguments[0]:lh(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:gn(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=gn(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return fe(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,t++;const n=Math.floor(this.sampleRate/128);e&&t%n===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return fe(this,arguments,void 0,function*(e=!0){yield this.workletsAreReady(),yield this._renderClock(e);const t=yield this._context.startRendering();return new K(t)})}close(){return Promise.resolve()}}const Nr=new wh;let dt=Nr;function Pe(){return dt===Nr&&uh&&xh(new rn),dt}function xh(s,e=!1){e&&dt.dispose(),bt(s)?dt=new rn(s):gn(s)?dt=new Fs(s):dt=s}function bh(){return dt.resume()}if(Oe&&!Oe.TONE_SILENCE_LOGGING){const e=` * Tone.js v${Ni} * `;console.log(`%c${e}`,"background: #000; color: #fff")}function Th(s){return Math.pow(10,s/20)}function Sh(s){return 20*(Math.log(s)/Math.LN10)}function Or(s){return Math.pow(2,s/12)}let Ln=440;function Ch(){return Ln}function kh(s){Ln=s}function fs(s){return Math.round(Mr(s))}function Mr(s){return 69+12*Math.log2(s/Ln)}function Ah(s){return Ln*Math.pow(2,(s-69)/12)}class Vs extends Qe{constructor(e,t,n){super(),this.defaultUnits="s",this._val=t,this._units=n,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{const n=parseInt(e,10),i=t==="."?1.5:1;return n===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/n)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{const t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,n)=>{let i=0;return e&&e!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i+=this._beatsToUnits(parseFloat(t))),n&&n!=="0"&&(i+=this._beatsToUnits(parseFloat(n)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof Vs&&this.fromType(this._val),Ee(this._val))return this._noArg();if(He(this._val)&&Ee(this._units)){for(const e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(pt(this._val)){let e=0;for(const t in this._val)if(Z(this._val[t])){const n=this._val[t],i=new this.constructor(this.context,t).valueOf()*n;e+=i}return e}if(Z(this._units)){const e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}else return He(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(e){switch(this._units=void 0,this.defaultUnits){case"s":this._val=e.toSeconds();break;case"i":this._val=e.toTicks();break;case"hz":this._val=e.toFrequency();break;case"midi":this._val=e.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}}class Fe extends Vs{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:e=>{const t=new Fe(this.context,e).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(t))},regexp:/^@(.+)/}})}quantize(e,t=1){const n=new this.constructor(this.context,e).valueOf(),i=this.valueOf(),a=Math.round(i/n)*n-i;return i+a*t}toNotation(){const e=this.toSeconds(),t=["1m"];for(let r=1;r<9;r++){const o=Math.pow(2,r);
33t.push(o+"n."),t.push(o+"n"),t.push(o+"t")}t.push("0");let n=t[0],i=new Fe(this.context,t[0]).toSeconds();return t.forEach(r=>{const o=new Fe(this.context,r).toSeconds();Math.abs(o-e)<Math.abs(i-e)&&(n=r,i=o)}),n}toBarsBeatsSixteenths(){const e=this._beatsToUnits(1);let t=this.valueOf()/e;t=parseFloat(t.toFixed(4));const n=Math.floor(t/this._getTimeSignature());let i=t%1*4;t=Math.floor(t)%this._getTimeSignature();const r=i.toString();return r.length>3&&(i=parseFloat(parseFloat(r).toFixed(3))),[n,t,i].join(":")}toTicks(){const e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return fs(this.toFrequency())}_now(){return this.context.now()}}class Ie extends Fe{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Ch()}static set A4(e){kh(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(e){return this.defaultUnits==="midi"?e:Ie.mtof(e)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(e,t){const i=Nh[e.toLowerCase()]+(parseInt(t,10)+1)*12;return this.defaultUnits==="midi"?i:Ie.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,n){let i=1;return e&&e!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i*=this._beatsToUnits(parseFloat(t))),n&&n!=="0"&&(i*=this._beatsToUnits(parseFloat(n)/4)),i}}})}transpose(e){return new Ie(this.context,this.valueOf()*Or(e))}harmonize(e){return e.map(t=>this.transpose(t))}toMidi(){return fs(this.valueOf())}toNote(){const e=this.toFrequency(),t=Math.log2(e/Ie.A4);let n=Math.round(12*t)+57;const i=Math.floor(n/12);return i<0&&(n+=-12*i),Oh[n%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return Ah(e)}static ftom(e){return fs(e)}}const Nh={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},Oh=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];class Gt extends Fe{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}class Ae extends Qe{constructor(){super();const e=z(Ae.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=e.context}static getDefaults(){return{context:Pe()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(e){return oh(e),new Fe(this.context,e).toSeconds()}toFrequency(e){return new Ie(this.context,e).toFrequency()}toTicks(e){return new Gt(this.context,e).toTicks()}_getPartialProperties(e){const t=this.get();return Object.keys(t).forEach(n=>{Ee(e[n])&&delete t[n]}),t}get(){const e=gh(this);return Object.keys(e).forEach(t=>{if(Reflect.has(this,t)){const n=this[t];Z(n)&&Z(n.value)&&Z(n.setValueAtTime)?e[t]=n.value:n instanceof Ae?e[t]=n._getPartialProperties(e[t]):Ve(n)||st(n)||He(n)||rh(n)?e[t]=n:delete e[t]}}),e}set(e){return Object.keys(e).forEach(t=>{Reflect.has(this,t)&&Z(this[t])&&(this[t]&&Z(this[t].value)&&Z(this[t].setValueAtTime)?this[t].value!==e[t]&&(this[t].value=e[t]):this[t]instanceof Ae?this[t].set(e[t]):this[t]=e[t])}),this}}class js extends De{constructor(e="stopped"){super(),this.name="StateTimeline",this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){const t=this.get(e);return t!==null?t.state:this._initial}setStateAtTime(e,t,n){return it(t,0),this.add(Object.assign({},n,{state:e,time:t})),this}getLastState(e,t){const n=this._search(t);for(let i=n;i>=0;i--){const r=this._timeline[i];if(r.state===e)return r}}
33getNextState(e,t){const n=this._search(t);if(n!==-1)for(let i=n;i<this._timeline.length;i++){const r=this._timeline[i];if(r.state===e)return r}}}class ee extends Ae{constructor(){const e=z(ee.getDefaults(),arguments,["param","units","convert"]);for(super(e),this.name="Param",this.overridden=!1,this._minOutput=1e-7,B(Z(e.param)&&(mt(e.param)||e.param instanceof ee),"param must be an AudioParam");!mt(e.param);)e.param=e.param._param;this._swappable=Z(e.swappable)?e.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=e.param,this.input.connect(this._param)):this._param=this.input=e.param,this._events=new De(1e3),this._initialValue=this._param.defaultValue,this.units=e.units,this.convert=e.convert,this._minValue=e.minValue,this._maxValue=e.maxValue,Z(e.value)&&e.value!==this._toType(this._initialValue)&&this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(Ae.getDefaults(),{convert:!0,units:"number"})}get value(){const e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return Z(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 Z(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return Z(this.maxValue)&&Z(this.minValue)&&it(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,"time")?this.toSeconds(e):this._is(e,"decibels")?Th(e):this._is(e,"frequency")?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units==="decibels"?Sh(e):e}setValueAtTime(e,t){const n=this.toSeconds(t),i=this._fromType(e);return B(isFinite(i)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",e,n),this._events.add({time:n,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,n),this}getValueAtTime(e){const t=Math.max(this.toSeconds(e),0),n=this._events.getAfter(t),i=this._events.get(t);let r=this._initialValue;if(i===null)r=this._initialValue;else if(i.type==="setTargetAtTime"&&(n===null||n.type==="setValueAtTime")){const o=this._events.getBefore(i.time);let a;o===null?a=this._initialValue:a=o.value,i.type==="setTargetAtTime"&&(r=this._exponentialApproach(i.time,a,i.value,i.constant,t))}else if(n===null)r=i.value;else if(n.type==="linearRampToValueAtTime"||n.type==="exponentialRampToValueAtTime"){let o=i.value;if(i.type==="setTargetAtTime"){const a=this._events.getBefore(i.time);a===null?o=this._initialValue:o=a.value}n.type==="linearRampToValueAtTime"?r=this._linearInterpolate(i.time,o,n.time,n.value,t):r=this._exponentialInterpolate(i.time,o,n.time,n.value,t)}else r=i.value;return this._toType(r)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){const n=this._fromType(e),i=this.toSeconds(t);return B(isFinite(n)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(n),this._events.add({time:i,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",e,i),this._param.linearRampToValueAtTime(n,i),this}exponentialRampToValueAtTime(e,t){let n=this._fromType(e);n=Re(n,0)?this._minOutput:n,this._assertRange(n);const i=this.toSeconds(t);return B(isFinite(n)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",e,i),this._param.exponentialRampToValueAtTime(n,i),this}exponentialRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(e,n+this.toSeconds(t)),this}linearRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(e,n+this.toSeconds(t)),this}targetRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(e,n,t),this}exponentialApproachValueAtTime(e,t,n){t=this.toSeconds(t),n=this.toSeconds(n);const i=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(e,t,i),this.cancelAndHoldAtTime(t+n*.9),this.linearRampToValueAtTime(e,t+n),this}setTargetAtTime(e,t,n){const i=this._fromType(e);B(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const r=this.toSeconds(t);return this._assertRange(i),B(isFinite(i)&&isFinite(r),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:n,time:r,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",e,r,n),this._param.setTargetAtTime(i,r,n),this}setValueCurveAtTime(e,t,n,i=1){n=this.toSeconds(n),t=this.toSeconds(t);const r=this._fromType(e[0])*i;this.setValueAtTime(this._toType(r),t);const o=n/(e.length-1);for(let a=1;a<e.length;a++){const c=this._fromType(e[a])*i;this.linearRampToValueAtTime(this._toType(c),t+a*o)}return this}cancelScheduledValues(e){const t=this.toSeconds(e);return B(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,"cancelScheduledValues",t),this}cancelAndHoldAtTime(e){const t=this.toSeconds(e),n=this._fromType(this.getValueAtTime(t));B(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,"cancelAndHoldAtTime",t,"value="+n);const i=this._events.get(t),r=this._events.getAfter(t);return i&&Re(i.time,t)?r?(this._param.cancelScheduledValues(r.time),this._events.cancel(r.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):r&&(this._param.cancelScheduledValues(r.time),this._events.cancel(r.time),r.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(n),t):r.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(n),t)),this._events.add({time:t,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,t),this}rampTo(e,t=.1,n){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(e,t,n):this.linearRampTo(e,t,n),this}apply(e){const t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);const n=this._events.get(t);if(n&&n.type==="setTargetAtTime"){const i=this._events.getAfter(n.time),r=i?i.time:t+2,o=(r-t)/10;for(let a=t;a<r;a+=o)e.linearRampToValueAtTime(this.getValueAtTime(a),a)}
vendor: 6,341 bytes, line 33
33return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?e.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?e.setTargetAtTime(i.value,i.time,i.constant):e[i.type](i.value,i.time)}),this}setParam(e){B(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,n,i,r){return n+(t-n)*Math.exp(-(r-e)/i)}_linearInterpolate(e,t,n,i,r){return t+(i-t)*((r-e)/(n-e))}_exponentialInterpolate(e,t,n,i,r){return t*Math.pow(i/t,(r-e)/(n-e))}}class G extends Ae{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return Z(this.input)?mt(this.input)||this.input instanceof ee?1:this.input.numberOfInputs:0}get numberOfOutputs(){return Z(this.output)?this.output.numberOfOutputs:0}_isAudioNode(e){return Z(e)&&(e instanceof G||nt(e))}_getInternalNodes(){const e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(n=>{n.channelCount=e.channelCount,n.channelCountMode=e.channelCountMode,n.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){const e=this._getInternalNodes();B(e.length>0,"ToneAudioNode does not have any internal nodes");const t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,n=0){return Lt(this,e,t,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Ds("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(e,t=0,n=0){return Mh(this,e,t,n),this}chain(...e){return An(this,...e),this}fan(...e){return e.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),Z(this.input)&&(this.input instanceof G?this.input.dispose():nt(this.input)&&this.input.disconnect()),Z(this.output)&&(this.output instanceof G?this.output.dispose():nt(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function An(...s){const e=s.shift();s.reduce((t,n)=>(t instanceof G?t.connect(n):nt(t)&&Lt(t,n),n),e)}function Lt(s,e,t=0,n=0){for(B(Z(s),"Cannot connect from undefined node"),B(Z(e),"Cannot connect to undefined node"),(e instanceof G||nt(e))&&B(e.numberOfInputs>0,"Cannot connect to node with no inputs"),B(s.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof G||e instanceof ee;)Z(e.input)&&(e=e.input);for(;s instanceof G;)Z(s.output)&&(s=s.output);mt(e)?s.connect(e,t):s.connect(e,t,n)}function Mh(s,e,t=0,n=0){if(Z(e))for(;e instanceof G;)e=e.input;for(;!nt(s);)Z(s.output)&&(s=s.output);mt(e)?s.disconnect(e,t):nt(e)?s.disconnect(e,t,n):s.disconnect()}class ue extends G{constructor(){const e=z(ue.getDefaults(),arguments,["gain","units"]);super(e),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new ee({context:this.context,convert:e.convert,param:this._gainNode.gain,units:e.units,value:e.gain,minValue:e.minValue,maxValue:e.maxValue}),re(this,"gain")}static getDefaults(){return Object.assign(G.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class It extends G{constructor(e){super(e),this.onended=X,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new ue({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const n=this.toSeconds(t);return this._startTime!==-1&&n>=this._startTime&&(this._stopTime===-1||n<=this._stopTime)?"started":"stopped"},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign(G.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:X})}_startGain(e,t=1){B(this._startTime===-1,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=e+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(t,e+n):this._gainNode.gain.exponentialApproachValueAtTime(t,e,n)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log("stop",e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){B(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();const t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{const n=this._curve==="exponential"?t*2:0;this._stopSource(this.now()+n),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==X&&(this.onended(this),this.onended=X,!this.context.isOffline)){const e=()=>this.dispose();typeof requestIdleCallback<"u"?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),B(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}
vendor: 1,264 bytes, line 33
33dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=X,this}}class qs extends It{constructor(){const e=z(qs.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),Lt(this._source,this._gainNode),this.offset=new ee({context:this.context,convert:e.convert,param:this._source.offset,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(It.getDefaults(),{convert:!0,offset:1,units:"number"})}start(e){const t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}}class le extends G{constructor(){const e=z(le.getDefaults(),arguments,["value","units"]);super(e),this.name="Signal",this.override=!0,this.output=this._constantSource=new qs({context:this.context,convert:e.convert,offset:e.value,units:e.units,minValue:e.minValue,maxValue:e.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(G.getDefaults(),{convert:!0,units:"number",value:0})}
vendor: 5,902 bytes, line 33
33connect(e,t=0,n=0){return Ws(this,e,t,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,n){return this._param.exponentialRampTo(e,t,n),this}linearRampTo(e,t,n){return this._param.linearRampTo(e,t,n),this}targetRampTo(e,t,n){return this._param.targetRampTo(e,t,n),this}exponentialApproachValueAtTime(e,t,n){return this._param.exponentialApproachValueAtTime(e,t,n),this}setTargetAtTime(e,t,n){return this._param.setTargetAtTime(e,t,n),this}setValueCurveAtTime(e,t,n,i){return this._param.setValueCurveAtTime(e,t,n,i),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,n){return this._param.rampTo(e,t,n),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}}function Ws(s,e,t,n){(e instanceof ee||mt(e)||e instanceof le&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof le&&(e.overridden=!0)),Lt(s,e,t,n)}class Ls extends ee{constructor(){const e=z(Ls.getDefaults(),arguments,["value"]);super(e),this.name="TickParam",this._events=new De(1/0),this._multiplier=1,this._multiplier=e.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(e.value)}),this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(ee.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(e,t,n){t=this.toSeconds(t),this.setRampPoint(t);const i=this._fromType(e),r=this._events.get(t),o=Math.round(Math.max(1/n,1));for(let a=0;a<=o;a++){const c=n*a+t,l=this._exponentialApproach(r.time,r.value,i,n,c);this.linearRampToValueAtTime(this._toType(l),c)}return this}setValueAtTime(e,t){const n=this.toSeconds(t);super.setValueAtTime(e,t);const i=this._events.get(n),r=this._events.previousEvent(i),o=this._getTicksUntilEvent(r,n);return i.ticks=Math.max(o,0),this}linearRampToValueAtTime(e,t){const n=this.toSeconds(t);super.linearRampToValueAtTime(e,t);const i=this._events.get(n),r=this._events.previousEvent(i),o=this._getTicksUntilEvent(r,n);return i.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);const n=this._fromType(e),i=this._events.get(t),r=Math.round(Math.max((t-i.time)*10,1)),o=(t-i.time)/r;for(let a=0;a<=r;a++){const c=o*a+i.time,l=this._exponentialInterpolate(i.time,i.value,t,n,c);this.linearRampToValueAtTime(this._toType(l),c)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Ee(e.ticks)){const o=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(o,e.time)}const n=this._fromType(this.getValueAtTime(e.time));let i=this._fromType(this.getValueAtTime(t));const r=this._events.get(t);return r&&r.time===t&&r.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(n+i)+e.ticks}getTicksAtTime(e){const t=this.toSeconds(e),n=this._events.get(t);return Math.max(this._getTicksUntilEvent(n,t),0)}getDurationOfTicks(e,t){const n=this.toSeconds(t),i=this.getTicksAtTime(t);return this.getTimeOfTick(i+e)-n}getTimeOfTick(e){const t=this._events.get(e,"ticks"),n=this._events.getAfter(e,"ticks");if(t&&t.ticks===e)return t.time;if(t&&n&&n.type==="linearRampToValueAtTime"&&t.value!==n.value){const i=this._fromType(this.getValueAtTime(t.time)),o=(this._fromType(this.getValueAtTime(n.time))-i)/(n.time-t.time),a=Math.sqrt(Math.pow(i,2)-2*o*(t.ticks-e)),c=(-i+a)/o,l=(-i-a)/o;return(c>0?c:l)+t.time}else return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){const n=this.toSeconds(t),i=this.toSeconds(e),r=this.getTicksAtTime(n);return this.getTicksAtTime(n+i)-r}_fromType(e){return this.units==="bpm"&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units==="bpm"&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){const t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}}class Bs extends le{constructor(){const e=z(Bs.getDefaults(),arguments,["value"]);super(e),this.name="TickSignal",this.input=this._param=new Ls({context:this.context,convert:e.convert,multiplier:e.multiplier,param:this._constantSource.offset,units:e.units,value:e.value})}static getDefaults(){return Object.assign(le.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}}class zs extends Ae{constructor(){const e=z(zs.getDefaults(),arguments,["frequency"]);super(e),this.name="TickSource",this._state=new js,this._tickOffset=new De,this._ticksAtTime=new De,this._secondsAtTime=new De,this.frequency=new Bs({context:this.context,units:e.units,value:e.frequency}
33),re(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Ae.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){const n=this.toSeconds(e);return this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),Z(t)&&this.setTicksAtTime(t,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),this}stop(e){const t=this.toSeconds(e);if(this._state.getValueAtTime(t)==="stopped"){const n=this._state.get(t);n&&n.time>0&&(this._tickOffset.cancel(n.time),this._state.cancel(n.time))}return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){const t=this.toSeconds(e),n=this._state.getLastState("stopped",t),i=this._ticksAtTime.get(t),r={state:"paused",time:t};this._state.add(r);let o=i||n,a=i?i.ticks:0,c=null;return this._state.forEachBetween(o.time,t+this.sampleTime,l=>{let u=o.time;const h=this._tickOffset.get(l.time);h&&h.time>=o.time&&(a=h.ticks,u=h.time),o.state==="started"&&l.state!=="started"&&(a+=this.frequency.getTicksAtTime(l.time)-this.frequency.getTicksAtTime(u),l.time!==r.time&&(c={state:l.state,time:l.time,ticks:a})),o=l}),this._state.remove(r),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){const t=this.now(),n=this.frequency.timeToTicks(e,t);this.setTicksAtTime(n,t)}getSecondsAtTime(e){e=this.toSeconds(e);const t=this._state.getLastState("stopped",e),n={state:"paused",time:e};this._state.add(n);const i=this._secondsAtTime.get(e);let r=i||t,o=i?i.seconds:0,a=null;return this._state.forEachBetween(r.time,e+this.sampleTime,c=>{let l=r.time;const u=this._tickOffset.get(c.time);u&&u.time>=r.time&&(o=u.seconds,l=u.time),r.state==="started"&&c.state!=="started"&&(o+=c.time-l,c.time!==n.time&&(a={state:c.state,time:c.time,seconds:o})),r=c}),this._state.remove(n),a&&this._secondsAtTime.add(a),o}setTicksAtTime(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){const n=this._tickOffset.get(t),i=this._state.get(t),r=Math.max(n.time,i.time),o=this.frequency.getTicksAtTime(r)+e-n.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(e,t,n){let i=this._state.get(e);this._state.forEachBetween(e,t,o=>{i&&i.state==="started"&&o.state!=="started"&&this.forEachTickBetween(Math.max(i.time,e),o.time-this.sampleTime,n),i=o});let r=null;if(i&&i.state==="started"){const o=Math.max(i.time,e),a=this.frequency.getTicksAtTime(o),c=this.frequency.getTicksAtTime(i.time),l=a-c;let u=Math.ceil(l)-l;u=Re(u,1)?0:u;let h=this.frequency.getTimeOfTick(a+u);for(;h<t;){try{n(h,Math.round(this.getTicksAtTime(h)))}catch(p){r=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(r)throw r;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}}class Bn extends Ae{constructor(){const e=z(Bn.getDefaults(),arguments,["callback","frequency"]);super(e),this.name="Clock",this.callback=X,this._lastUpdate=0,this._state=new js("stopped"),this._boundLoop=this._loop.bind(this),this.callback=e.callback,this._tickSource=new zs({context:this.context,frequency:e.frequency,units:e.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,re(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Ae.getDefaults(),{callback:X,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){br(this.context);const n=this.toSeconds(e);return this.log("start",n),this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,t),n<this._lastUpdate&&this.emit
vendor: 4,341 bytes, line 33
33("start",n,t)),this}stop(e){const t=this.toSeconds(e);return this.log("stop",t),this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit("stop",t),this}pause(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit("pause",t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){const n=this.toSeconds(t),i=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(i+e,n)}_loop(){const e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log("loop",e,t),e!==t&&(this._state.forEachBetween(e,t,n=>{switch(n.state){case"started":const i=this._tickSource.getTicksAtTime(n.time);this.emit("start",n.time,i);break;case"stopped":n.time!==0&&this.emit("stop",n.time);break;case"paused":this.emit("pause",n.time);break}}),this._tickSource.forEachTickBetween(e,t,(n,i)=>{this.callback(n,i)}))}getStateAtTime(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}sn.mixin(Bn);class Bt extends G{constructor(){const e=z(Bt.getDefaults(),arguments,["volume"]);super(e),this.name="Volume",this.input=this.output=new ue({context:this.context,gain:e.volume,units:"decibels"}),this.volume=this.output.gain,re(this,"volume"),this._unmutedVolume=e.volume,this.mute=e.mute}static getDefaults(){return Object.assign(G.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class Us extends G{constructor(){const e=z(Us.getDefaults(),arguments);super(e),this.name="Destination",this.input=new Bt({context:this.context}),this.output=new ue({context:this.context}),this.volume=this.input.volume,An(this.input,this.output,this.context.rawContext.destination),this.mute=e.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(G.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),An(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}qn(s=>{s.destination=new Us({context:s})});Wn(s=>{s.destination.dispose()});class Ih extends G{constructor(){super(...arguments),this.name="Listener",this.positionX=new ee({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ee({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ee({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ee({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ee({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ee({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ee({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ee({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ee({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(G.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.dis
33pose(),this.upZ.dispose(),this}}qn(s=>{s.listener=new Ih({context:s})});Wn(s=>{s.listener.dispose()});class Gs extends Qe{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const e=z(Gs.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=e.baseUrl,Object.keys(e.urls).forEach(t=>{this._loadingCount++;const n=e.urls[t];this.add(t,n,this._bufferLoaded.bind(this,e.onload),e.onerror)})}static getDefaults(){return{baseUrl:"",onerror:X,onload:X,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return B(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,n=X,i=X){return He(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(e.toString(),new K(this.baseUrl+t,n,i))):this._buffers.set(e.toString(),new K(t,n,i)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}}class St extends Gt{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}class Eh extends Ae{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new De,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){const e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}qn(s=>{s.draw=new Eh({context:s})});Wn(s=>{s.draw.dispose()});class Dh extends Qe{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(e){B(Z(e.time),"Events must have a time property"),B(Z(e.duration),"Events must have a duration parameter"),e.time=e.time.valueOf();let t=new Rh(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){const t=[];this._root.search(e.time,t);for(const n of t)if(n.event===e){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,t=>this.remove(t)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent!==null?(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent)):this._setRoot(t)}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{const t=e.getBalance();let n,i=null;if(t>0)if(e.left.right===null)n=e.left,n.right=e.right,i=n;else{for(n=e.left.right;n.right!==null;)n=n.right;n.parent&&(n.parent.right=n.left,i=n.parent,n.left=e.left,n.right=e.right)}else if(e.right.left===null)n=e.right,n.left=e.left,i=n;else{for(n=e.right.left;n.left!==null;)n=n.left;n.parent&&(n.parent.left=n.right,i=n.parent,n.left=e.left,n.right=e.right)}e.parent!==null?e.isLeftChild()?e.parent.left=n:e.parent.right=n:this._setRoot(n),i&&this._rebalance(i)}e.dispose()}_rotateLeft(e){const t=e.parent,n=e.isLeftChild(),i=e.right;i&&(e.right=i.left,i.left=e),t!==null?n?t.left=i:t.right=i:this._setRoot(i)}_rotateRight(e){const t=e.parent,n=e.isLeftChild(),i=e.left;i&&(e.left=i.right,i.right=e),t!==null?n?t.left=i:t.right=i:this._setRoot(i)}_rebalance(e){const t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){const t=[];if(this._root.search(e,t),t.length>0){let n=t[0];for(let i=1;i<t.length;i++)t[i].low>n.low&&(n=t[i]);return n.event}}return null}forEach(e){if(this._root!==null){const t=[];this._root.traverse(n=>t.push(n)),t.forEach(n=>
33{n.event&&e(n.event)})}return this}forEachAtTime(e,t){if(this._root!==null){const n=[];this._root.search(e,n),n.forEach(i=>{i.event&&t(i.event)})}return this}forEachFrom(e,t){if(this._root!==null){const n=[];this._root.searchAfter(e,n),n.forEach(i=>{i.event&&t(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}}class Rh{constructor(e,t,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),!(this.low>e)&&this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left!==null?e=this.left.height+1:this.right!==null&&(e=-(this.right.height+1)),e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}class Ph extends Qe{constructor(e){super(),this.name="TimelineValue",this._timeline=new De({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){const t=this._timeline.get(e);return t?t.value:this._initialValue}}class Et extends G{constructor(){super(z(Et.getDefaults(),arguments,["context"]))}
vendor: 3,990 bytes, line 33
33connect(e,t=0,n=0){return Ws(this,e,t,n),this}}class on extends Et{constructor(){const e=z(on.getDefaults(),arguments,["mapping","length"]);super(e),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Ve(e.mapping)||e.mapping instanceof Float32Array?this.curve=Float32Array.from(e.mapping):ih(e.mapping)&&this.setMap(e.mapping,e.length)}static getDefaults(){return Object.assign(le.getDefaults(),{length:1024})}setMap(e,t=1024){const n=new Float32Array(t);for(let i=0,r=t;i<r;i++){const o=i/(r-1)*2-1;n[i]=e(o,i)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){const t=["none","2x","4x"].some(n=>n.includes(e));B(t,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class $s extends Et{constructor(){const e=z($s.getDefaults(),arguments,["value"]);super(e),this.name="Pow",this._exponentScaler=this.input=this.output=new on({context:this.context,mapping:this._expFunc(e.value),length:8192}),this._exponent=e.value}static getDefaults(){return Object.assign(Et.getDefaults(),{value:1})}_expFunc(e){return t=>Math.pow(Math.abs(t),e)}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class rt{constructor(e,t){this.id=rt._eventId++,this._remainderTime=0;const n=Object.assign(rt.getDefaults(),t);this.transport=e,this.callback=n.callback,this._once=n.once,this.time=Math.floor(n.time),this._remainderTime=n.time-this.time}static getDefaults(){return{callback:X,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){const t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}}rt._eventId=0;class Zs extends rt{constructor(e,t){super(e,t),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(Zs.getDefaults(),t);this.duration=n.duration,this._interval=n.interval,this._nextTick=n.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({},rt.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return kn(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new St(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){kn(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 St(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;const t=this.transport.getTicksAtTime(e);Mt(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}}class zn extends Ae{constructor(){const e=z(zn.getDefaults(),arguments);super(e),this.name="Transport",this._loop=new Ph(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new De,this._repeatedEvents=new Dh,this._syncedSignals=[],this._swingAmou
33nt=0,this._ppq=e.ppq,this._clock=new Bn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=e.ppq,this.bpm.setValueAtTime(e.bpm,0),re(this,"bpm"),this._timeSignature=e.timeSignature,this._swingTicks=e.ppq/2}static getDefaults(){return Object.assign(Ae.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit("loopEnd",e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit("loopStart",e,this._clock.getSecondsAtTime(e)),this.emit("loop",e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!==0){const n=t%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(n*Math.PI)*this._swingAmount;e+=new St(this.context,this._swingTicks*2/3).toSeconds()*i}wi(!0),this._timeline.forEachAtTime(t,n=>n.invoke(e)),wi(!1)}schedule(e,t){const n=new rt(this,{callback:e,time:new Gt(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(e,t,n,i=1/0){const r=new Zs(this,{callback:e,duration:new Fe(this.context,i).toTicks(),interval:new Fe(this.context,t).toTicks(),time:new Gt(this.context,n).toTicks()});return this._addEvent(r,this._repeatedEvents)}scheduleOnce(e,t){const n=new rt(this,{callback:e,once:!0,time:new Gt(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){const t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){const t=this.toTicks(e);return this._timeline.forEachFrom(t,n=>this.clear(n.id)),this._repeatedEvents.forEachFrom(t,n=>this.clear(n.id)),this}_bindClockEvents(){this._clock.on("start",(e,t)=>{t=new St(this.context,t).toSeconds(),this.emit("start",e,t)}),this._clock.on("stop",e=>{this.emit("stop",e)}),this._clock.on("pause",e=>{this.emit("pause",e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let n;return Z(t)&&(n=this.toTicks(t)),this._clock.start(e,n),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)!=="started"?this.start(e):this.stop(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){Ve(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new Fe(this.context,this._loopStart,"i").toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new Fe(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}
33get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new St(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){const e=this.now(),t=this._clock.getTicksAtTime(e);return new St(this.context,t).toBarsBeatsSixteenths()}set position(e){const t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){const t=this.now(),n=this._clock.frequency.timeToTicks(e,t);this.ticks=n}get progress(){if(this.loop){const e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){const t=this.now();if(this.state==="started"){const n=this._clock.getTicksAtTime(t),i=this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,t),r=t+i;this.emit("stop",r),this._clock.setTicksAtTime(e,r),this.emit("start",r,this._clock.getSecondsAtTime(r))}else this.emit("ticks",t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!=="started")return 0;{const t=this.now(),n=this.getTicksAtTime(t),i=e-n%e;return this._clock.nextTickTime(i,t)}}syncSignal(e,t){const n=this.now();let i=this.bpm,r=1/(60/i.getValueAtTime(n)/this.PPQ),o=[];if(e.units==="time"){const c=.015625/r,l=new ue(c),u=new $s(-1),h=new ue(c);i.chain(l,u,h),i=h,r=1/r,o=[l,u,h]}t||(e.getValueAtTime(n)!==0?t=e.getValueAtTime(n)/r:t=0);const a=new ue(t);return i.connect(a),a.connect(e._param),o.push(a),this._syncedSignals.push({initial:e.value,nodes:o,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){const n=this._syncedSignals[t];n.signal===e&&(n.nodes.forEach(i=>i.dispose()),n.signal.value=n.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Ps(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}sn.mixin(zn);qn(s=>{s.transport=new zn({context:s})});Wn(s=>
33{s.transport.dispose()});class Se extends G{constructor(e){super(e),this.input=void 0,this._state=new js("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=X,this._syncedStop=X,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Bt({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,re(this,"volume"),this.onstop=e.onstop}static getDefaults(){return Object.assign(G.getDefaults(),{mute:!1,onstop:X,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,n){let i=Ee(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")B(Mt(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,t,n);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){const r=this._state.get(i);r&&(r.offset=this.toSeconds(At(t,0)),r.duration=n?this.toSeconds(n):void 0);const o=this.context.transport.schedule(a=>{this._start(a,t,n)},i);this._scheduled.push(o),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else br(this.context),this._start(i,t,n);return this}stop(e){let t=Ee(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)==="started"||Z(this._state.getNextState("started",t))){if(this.log("stop",t),!this._synced)this._stop(t);else{const n=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(n)}this._state.cancel(t),this._state.setStateAtTime("stopped",t)}return this}restart(e,t,n){return e=this.toSeconds(e),this._state.getValueAtTime(e)==="started"&&(this._state.cancel(e),this._restart(e,t,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>
vendor: 7,228 bytes, line 33
33{if(Mt(t,0)){const n=this._state.get(t);if(n&&n.state==="started"&&n.time!==t){const i=t-this.toSeconds(n.time);let r;n.duration&&(r=this.toSeconds(n.duration)-i),this._start(e,this.toSeconds(n.offset)+i,r)}}},this._syncedStop=e=>{const t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)==="started"&&this._stop(e)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=X,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class an extends It{constructor(){const e=z(an.getDefaults(),arguments,["url","onload"]);super(e),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,Lt(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ee({context:this.context,param:this._source.playbackRate,units:"positive",value:e.playbackRate}),this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this._buffer=new K(e.url,e.onload,e.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(It.getDefaults(),{url:new K,loop:!1,loopEnd:0,loopStart:0,onload:X,onerror:X,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,n,i=1){B(this.buffer.loaded,"buffer is either not set or not loaded");const r=this.toSeconds(e);this._startGain(r,i),this.loop?t=At(t,this.loopStart):t=At(t,0);let o=Math.max(this.toSeconds(t),0);if(this.loop){const a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),l=a-c;ps(o,a)&&(o=(o-c)%l+c),Re(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,kn(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(r,o)),Z(n)){let a=this.toSeconds(n);a=Math.max(a,0),this.stop(r+a)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class Nn extends Se{constructor(){const e=z(Nn.getDefaults(),arguments,["type"]);super(e),this.name="Noise",this._source=null,this._playbackRate=e.playbackRate,this.type=e.type,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Se.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(e){if(B(e in bi,"Noise: invalid type: "+e),this._type!==e&&(this._type=e,this.state==="started")){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){const t=bi[this._type];this._source=new an({url:t,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&(this._source.stop(this.toSeconds(e)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const xt=44100*5,ss=2,$e={brown:null,pink:null,white:null},bi={get brown(){if(!$e.brown){const s=[];for(let e=0;e<ss;e++){const t=new Float32Array(xt);s[e]=t;let n=0;for(let i=0;i<xt;i++){const r=Math.random()*2-1;t[i]=(n+.02*r)/1.02,n=t[i],t[i]*=3.5}}$e.brown=new K().fromArray(s)}return $e.brown},get pink(){if(!$e.pink){const s=[];for(let e=0;e<ss;e++){const t=new Float32Array(xt);s[e]=t;let n,i,r,o,a,c,l;n=i=r=o=a=c=l=0;for(let u=0;u<xt;u++){const h=Math.random()*2-1;n=.99886*n+h*.0555179,i=.99332*i+h*.0750759,r=.969*r+h*.153852,o=.8665*o+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,t[u]=n+i+r+o+a+c+l+h*.5362,t[u]*=.11,l=h*.115926}}$e.pink=new K().fromArray(s)}return $e.pink},get white(){if(!$e.white){const s=[];for(let e=0;e<ss;e++){const t=new Float32Array(xt);s[e]=t;for(let n=0;n<xt;n++)t[n]=Math.random()*2-1}$e.white=new K().fromArray(s)}return $e.white}};function yt(s,e){return fe(this,void 0,void 0,function*(){const t=e/s.context.sampleRate,n=new Fs(1,t,s.context.sampleRate);return new s.constructor(Object.assign(s.get(),{frequency:2/t,detune:0,context:n})).toDestination().start(0),(yield n.render()).getChannelData(0)})}class Ys extends It{constructor(){const e=z(Ys.getDefaults(),arguments,["frequency","type"]);super(e),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],Lt(this._oscillator,this._gainNode),this.type=e.type,this.frequency=new ee({context:this.context,param:this._oscillator.frequency,units:"frequency",value:e.frequency}),this.detune=new ee({context:this.context,param:this._oscillator.detune,units:"cents",value:e.detune}),re(this,["frequency","detune"])}static getDefaults(){return Object.assign(It.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(e){const t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class pe extends Se{constructor(){const e=z(pe.getDefaults(),arguments,["frequency","type"]);super(e),this.name="Oscillator",this._oscillator=null,this.frequency=new le({context:this.context,units:"frequency",value:e.frequency}
33),re(this,"frequency"),this.detune=new le({context:this.context,units:"cents",value:e.detune}),re(this,"detune"),this._partials=e.partials,this._partialCount=e.partialCount,this._type=e.type,e.partialCount&&e.type!=="custom"&&(this._type=this.baseType+e.partialCount.toString()),this.phase=e.phase}static getDefaults(){return Object.assign(Se.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(e){const t=this.toSeconds(e),n=new Ys({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(t)}_stop(e){const t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){const t=this.toSeconds(e);return this.log("restart",t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return pe._periodicWaveCache.find(t=>t.phase===this._phase&&mh(t.partials,this._partials));{const e=pe._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=e?e.partialCount:this._partialCount,e}}get type(){return this._type}set type(e){this._type=e;const t=["sine","square","sawtooth","triangle"].indexOf(e)!==-1;if(this._phase===0&&t)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=e);else{const n=this._getCachedPeriodicWave();if(Z(n)){const{partials:i,wave:r}=n;this._wave=r,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{const[i,r]=this._getRealImaginary(e,this._phase),o=this.context.createPeriodicWave(i,r);this._wave=o,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),pe._periodicWaveCache.push({imag:r,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),pe._periodicWaveCache.length>100&&pe._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(e){this.partialCount&&this._type!=="custom"&&e!=="custom"?this.type=e+this.partialCount:this.type=e}get partialCount(){return this._partialCount}set partialCount(e){it(e,0);let t=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(t=n[1]),this._type!=="custom")e===0?this.type=t:this.type=t+e.toString();else{const i=new Float32Array(e);this._partials.forEach((r,o)=>i[o]=r),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(e,t){let i=2048;const r=new Float32Array(i),o=new Float32Array(i);let a=1;if(e==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[r,o]}else{const c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),e=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){const l=2/(c*Math.PI);let u;switch(e){case"sine":u=c<=a?1:0,this._partials[c-1]=u;break;case"square":u=c&1?2*l:0,this._partials[c-1]=u;break;case"sawtooth":u=l*(c&1?1:-1),this._partials[c-1]=u;break;case"triangle":c&1?u=2*(l*l)*(c-1>>1&1?-1:1):u=0,this._partials[c-1]=u;break;case"custom":u=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+e)}u!==0?(r[c]=-u*Math.sin(t*c),o[c]=u*Math.cos(t*c)):(r[c]=0,o[c]=0)}return[r,o]}_inverseFFT(e,t,n){let i=0;const r=e.length;for(let o=0;o<r;o++)i+=e[o]*Math.cos(o*n)+t[o]*Math.sin(o*n);return i}getInitialValue(){const[e,t]=this._getRealImaginary(this._type,0);let n=0;const i=Math.PI*2,r=32;for(let o=0;o<r;o++)n=Math.max(this._inverseFFT(e,t,o/r*i),n);return _h(-this._inverseFFT(e,t,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.t
vendor: 5,262 bytes, line 33
33ype="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}pe._periodicWaveCache=[];class Fh extends Et{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new on({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Dt extends le{constructor(){const e=z(Dt.getDefaults(),arguments,["value"]);super(e),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new ue({context:this.context,minValue:e.minValue,maxValue:e.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(le.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class Un extends Se{constructor(){const e=z(Un.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="AMOscillator",this._modulationScale=new Fh({context:this.context}),this._modulationNode=new ue({context:this.context}),this._carrier=new pe({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new pe({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new Dt({context:this.context,units:"positive",value:e.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),re(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(pe.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}}class Gn extends Se{constructor(){const e=z(Gn.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="FMOscillator",this._modulationNode=new ue({context:this.context,gain:0}),this._carrier=new pe({context:this.context,detune:e.detune,frequency:0,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.detune=this._carrier.detune,this.frequency=new le({context:this.context,units:"frequency",value:e.frequency}),this._modulator=new pe({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new Dt({context:this.context,units:"positive",value:e.harmonicity}),this.modulationIndex=new Dt({context:this.context,units:"positive",value:e.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),re(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(pe.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dis
33pose(),this.modulationIndex.dispose(),this}}class cn extends Se{constructor(){const e=z(cn.getDefaults(),arguments,["frequency","width"]);super(e),this.name="PulseOscillator",this._widthGate=new ue({context:this.context,gain:0}),this._thresh=new on({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new le({context:this.context,units:"audioRange",value:e.width}),this._triangle=new pe({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),re(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Se.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class $n extends Se{constructor(){const e=z($n.getDefaults(),arguments,["frequency","type","spread"]);super(e),this.name="FatOscillator",this._oscillators=[],this.frequency=new le({context:this.context,units:"frequency",value:e.frequency}),this.detune=new le({context:this.context,units:"cents",value:e.detune}),this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=e.partials,this._partialCount=e.partialCount,this.count=e.count,re(this,["frequency","detune"])}static getDefaults(){return Object.assign(pe.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){const t=-e/2,n=e/(this._oscillators.length-1);this._forEach((i,r)=>i.detune.value=t+n*r)}}get count(){return this._oscillators.length}set count(e){if(it(e,1),this._oscillators.length!==e){this._forEach(t=>t.dispose()),this._oscillators=[];for(let t=0;t<e;t++){const n=new pe({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):X});this.type==="custom"&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[t]=n}this.spread=this._spread,this.state==="started"&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((t,n)=>t.phase=this._phase+n/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type="custom",this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEac
33h(e=>e.dispose()),this}}class Zn extends Se{constructor(){const e=z(Zn.getDefaults(),arguments,["frequency","modulationFrequency"]);super(e),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Dt({context:this.context,value:2}),this._pulse=new cn({context:this.context,frequency:e.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new pe({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),re(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Se.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Ti={am:Un,fat:$n,fm:Gn,oscillator:pe,pulse:cn,pwm:Zn};class On extends Se{constructor(){const e=z(On.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OmniOscillator",this.frequency=new le({context:this.context,units:"frequency",value:e.frequency}),this.detune=new le({context:this.context,units:"cents",value:e.detune}),re(this,["frequency","detune"]),this.set(e)}static getDefaults(){return Object.assign(pe.getDefaults(),Gn.getDefaults(),Un.getDefaults(),$n.getDefaults(),cn.getDefaults(),Zn.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):e==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,"type")&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;const t=Ti[e],n=this.now();if(this._oscillator){const i=this._oscillator;i.stop(n),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new t({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(t=this._oscillator.type),e==="fm"?this.type="fm"+t:e==="am"?this.type="am"+t:e==="fat"?this.type="fat"+t:e==="oscillator"?this.type=t:e==="pulse"?this.type="pulse":e==="pwm"&&(this.t
33ype="pwm")}_getOscType(e,t){return e instanceof Ti[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&e!=="pulse"&&e!=="pwm"&&(this._oscillator.baseType=e)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(e){this._getOscType(this._oscillator,"fat")&&st(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,"fat")&&st(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&He(e)&&(this._oscillator.modulationType=e)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return fe(this,arguments,void 0,function*(e=1024){return yt(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}function Ir(s,e=1/0){const t=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(r){it(r,s,e),t.set(this,r)}})}}function Je(s,e=1/0){const t=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(r){it(this.toSeconds(r),s,e),t.set(this,r)}})}}class Yn extends Se{constructor(){const e=z(Yn.getDefaults(),arguments,["url","onload"]);super(e),this.name="Player",this._activeSources=new Set,this._buffer=new K({onload:this._onload.bind(this,e.onload),onerror:e.onerror,reverse:e.reverse,url:e.url}),this.autostart=e.autostart,this._loop=e.loop,this._loopStart=e.loopStart,this._loopEnd=e.loopEnd,this._playbackRate=e.playbackRate,this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Se.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:X,onerror:X,playbackRate:1,reverse:!1})}load(e){return fe(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=X){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(e,t,n){return super.start(e,t,n),this}_start(e,t,n){this._loop?t=At(t,this._loopStart):t=At(t,0);const i=this.toSeconds(t),r=n;n=At(n,Math.max(this._buffer.duration-i,0));let o=this.toSeconds(n);o=o/this._playbackRate,e=this.toSeconds(e);const a=new an({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(e+o),this._state.setStateAtTime("stopped",e+o,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Ee(r)?a.start(e,i):a.start(e,i,o-this.toSeconds(this.fadeOut))}_stop(e){const t=this.toSeconds(e);this._activeSources.forEach(n=>n.stop(t))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(e),this._start(e,t,n)}seek(e,t){const n=this.toSeconds(t);if(this._state.getValueAtTime(n)==="started"){const i=this.toSeconds(e);this._stop(n),this._start(n,i)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&it(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEac
33h(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&it(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;const t=this.now(),n=this._state.getNextState("stopped",t);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}}qe([Je(0)],Yn.prototype,"fadeIn",void 0);qe([Je(0)],Yn.prototype,"fadeOut",void 0);class ct extends G{constructor(){const e=z(ct.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="Envelope",this._sig=new le({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve,this.decayCurve=e.decayCurve}static getDefaults(){return Object.assign(G.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(He(e))return e;{let n;for(n in pn)if(pn[n][t]===e)return n;return e}}_setCurve(e,t,n){if(He(n)&&Reflect.has(pn,n)){const i=pn[n];pt(i)?e!=="_decayCurve"&&(this[e]=i[t]):this[e]=i}else if(Ve(n)&&e!=="_decayCurve")this[e]=n;else throw new Error("Envelope: invalid curve: "+n)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(e){this._setCurve("_attackCurve","In",e)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(e){this._setCurve("_releaseCurve","Out",e)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(e){this._setCurve("_decayCurve","Out",e)}triggerAttack(e,t=1){this.log("triggerAttack",e,t),e=this.toSeconds(e);let i=this.toSeconds(this.attack);const r=this.toSeconds(this.decay),o=this.getValueAtTime(e);if(o>0){const a=1/i;i=(1-o)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve==="linear")this._sig.linearRampTo(t,i,e);else if(this._attackCurve==="exponential")this._sig.targetRampTo(t,i,e);else{this._sig.cancelAndHoldAtTime(e);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=o&&o<=a[c]){a=this._attackCurve.slice(c),a[0]=o;break}this._sig.setValueCurveAtTime(a,e,i,t)}if(r&&this.sustain<1){const a=t*this.sustain,c=e+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,r+c):this._sig.exponentialApproachValueAtTime(a,c,r)}return this}triggerRelease(e){this.log("triggerRelease",e),e=this.toSeconds(e);const t=this.getValueAtTime(e);if(t>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve==="linear"?this._sig.linearRampTo(0,n,e):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,n,e):(B(Ve(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,n,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),this.triggerAttack(t,n),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}
33connect(e,t=0,n=0){return Ws(this,e,t,n),this}asArray(){return fe(this,arguments,void 0,function*(e=1024){const t=e/this.context.sampleRate,n=new Fs(1,t,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),r=i+this.toSeconds(this.release),o=r*.1,a=r+o,c=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/a,decay:t*this.toSeconds(this.decay)/a,release:t*this.toSeconds(this.release)/a,context:n}));return c._sig.toDestination(),c.triggerAttackRelease(t*(i+o)/a,0),(yield n.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}}qe([Je(0)],ct.prototype,"attack",void 0);qe([Je(0)],ct.prototype,"decay",void 0);qe([Ir(0,1)],ct.prototype,"sustain",void 0);qe([Je(0)],ct.prototype,"release",void 0);const pn=(()=>{let e,t;const n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));const i=[],r=6.4;for(e=0;e<127;e++){t=e/127;const p=Math.sin(t*(Math.PI*2)*r-Math.PI/2)+1;i[e]=p/10+t*.83}i[127]=1;const o=[],a=5;for(e=0;e<128;e++)o[e]=Math.ceil(e/127*a)/a;const c=[];for(e=0;e<128;e++)t=e/127,c[e]=.5*(1-Math.cos(Math.PI*t));const l=[];for(e=0;e<128;e++){t=e/127;const p=Math.pow(t,3)*4+.2,f=Math.cos(p*Math.PI*2*t);l[e]=Math.abs(f*(1-t))}function u(p){const f=new Array(p.length);for(let d=0;d<p.length;d++)f[d]=1-p[d];return f}function h(p){return p.slice(0).reverse()}return{bounce:{In:u(l),Out:l},cosine:{In:n,Out:h(n)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:u(i)},sine:{In:c,Out:u(c)},step:{In:o,Out:u(o)}}})();class Rt extends G{constructor(){const e=z(Rt.getDefaults(),arguments);super(e),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=t=>this._original_triggerRelease(t),this._volume=this.output=new Bt({context:this.context,volume:e.volume}),this.volume=this._volume.volume,re(this,"volume")}static getDefaults(){return Object.assign(G.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){const n=this["_original_"+e]=this[e];this[e]=(...i)=>{const r=i[t],o=this.context.transport.schedule(a=>{i[t]=a,n.apply(this,i)},r);this._scheduledEvents.push(o)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(e,t,n,i){const r=this.toSeconds(n),o=this.toSeconds(t);return this.triggerAttack(e,r,i),this.triggerRelease(r+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class Pt extends Rt{constructor(){const e=z(Pt.getDefaults(),arguments);super(e),this.portamento=e.portamento,this.onsilence=e.onsilence}static getDefaults(){return Object.assign(Rt.getDefaults(),{detune:0,onsilence:X,portamento:0})}triggerAttack(e,t,n=1){this.log("triggerAttack",e,t,n);const i=this.toSeconds(t);return this._triggerEnvelopeAttack(i,n),this.setNote(e,i),this}triggerRelease(e){this.log("triggerRelease",e);const t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){const n=this.toSeconds(t),i=e instanceof Ie?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const r=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,r,n)}else this.frequency.setValueAtTime(i,n);return this}}qe([Je(0)],Pt.prototype,"portamento",void 0);class Hs extends ct{constructor(){super(z(Hs.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new ue({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}
vendor: 4,553 bytes, line 33
33dispose(){return super.dispose(),this._gainNode.dispose(),this}}class Mn extends Pt{constructor(){const e=z(Mn.getDefaults(),arguments);super(e),this.name="Synth",this.oscillator=new On(Object.assign({context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)},e.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Hs(Object.assign({context:this.context},e.envelope)),this.oscillator.chain(this.envelope,this.output),re(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Pt.getDefaults(),{envelope:Object.assign(xi(ct.getDefaults(),Object.keys(G.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(xi(On.getDefaults(),[...Object.keys(Se.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){const n=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+n+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class In extends G{constructor(){const e=z(In.getDefaults(),arguments,["frequency","type"]);super(e),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ee({context:this.context,units:"number",value:e.Q,param:this._filter.Q}),this.frequency=new ee({context:this.context,units:"frequency",value:e.frequency,param:this._filter.frequency}),this.detune=new ee({context:this.context,units:"cents",value:e.detune,param:this._filter.detune}),this.gain=new ee({context:this.context,units:"decibels",convert:!1,value:e.gain,param:this._filter.gain}),this.type=e.type}static getDefaults(){return Object.assign(G.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){B(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){const t=new Float32Array(e);for(let o=0;o<e;o++){const c=Math.pow(o/e,2)*19980+20;t[o]=c}const n=new Float32Array(e),i=new Float32Array(e),r=this.context.createBiquadFilter();return r.type=this.type,r.Q.value=this.Q.value,r.frequency.value=this.frequency.value,r.gain.value=this.gain.value,r.getFrequencyResponse(t,n,i),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}class En extends G{constructor(){const e=z(En.getDefaults(),arguments,["frequency","type","rolloff"]);super(e),this.name="Filter",this.input=new ue({context:this.context}),this.output=new ue({context:this.context}),this._filters=[],this._filters=[],this.Q=new le({context:this.context,units:"positive",value:e.Q}),this.frequency=new le({context:this.context,units:"frequency",value:e.frequency}),this.detune=new le({context:this.context,units:"cents",value:e.detune}),this.gain=new le({context:this.context,units:"decibels",convert:!1,value:e.gain}),this._type=e.type,this.rolloff=e.rolloff,re(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(G.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(e){B(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(n=>n.type=e)}get rolloff(){return this._rolloff}set rolloff(e){const t=st(e)?e:parseInt(e,10),n=[-12,-24,-48,-96];let i=n.indexOf(t);B(i!==-1,`rolloff can only be ${n.join(", ")}`),i+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(r=>r.disconnect()),this._filters=new Array(i);for(let r=0;r<i;r++){const o=new In({context:this.context});o.type=this._type,this.frequency.connect(o.frequency),this.detune.connect(o.detune),this.Q.connect(o.Q),this.gain.connect(o.gain),this._filters[r]=o}this._internalChannels=this._filters,An(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){const t=new In({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(e).map(()=>1);
33return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((r,o)=>n[o]*=r)}),t.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),Ps(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class Hn extends Mn{constructor(){const e=z(Hn.getDefaults(),arguments);super(e),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=e.pitchDecay,this.octaves=e.octaves,re(this,["oscillator","envelope"])}static getDefaults(){return kt(Pt.getDefaults(),Mn.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(e,t){const n=this.toSeconds(t),i=this.toFrequency(e instanceof Ie?e.toFrequency():e),r=i*this.octaves;return this.oscillator.frequency.setValueAtTime(r,n),this.oscillator.frequency.exponentialRampToValueAtTime(i,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}qe([Ir(0)],Hn.prototype,"octaves",void 0);qe([Je(0)],Hn.prototype,"pitchDecay",void 0);const Er=new Set;function Xs(s){Er.add(s)}function Dr(s,e){const t=`registerProcessor("${s}", ${e})`;Er.add(t)}const Vh=`
34	/**
35	 * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}. 
36	 */
37	class ToneAudioWorkletProcessor extends AudioWorkletProcessor {
38
39		constructor(options) {
40			
41			super(options);
42			/**
43			 * If the processor was disposed or not. Keep alive until it's disposed.
44			 */
45			this.disposed = false;
46		   	/** 
47			 * The number of samples in the processing block
48			 */
49			this.blockSize = 128;
50			/**
51			 * the sample rate
52			 */
53			this.sampleRate = sampleRate;
54
55			this.port.onmessage = (event) => {
56				// when it receives a dispose 
57				if (event.data === "dispose") {
58					this.disposed = true;
59				}
60			};
61		}
62	}
63`;Xs(Vh);const jh=`
64	/**
65	 * Abstract class for a single input/output processor. 
66	 * has a 'generate' function which processes one sample at a time
67	 */
68	class SingleIOProcessor extends ToneAudioWorkletProcessor {
69
70		constructor(options) {
71			super(Object.assign(options, {
72				numberOfInputs: 1,
73				numberOfOutputs: 1
74			}));
75			/**
76			 * Holds the name of the parameter and a single value of that
77			 * parameter at the current sample
78			 * @type { [name: string]: number }
79			 */
80			this.params = {}
81		}
82
83		/**
84		 * Generate an output sample from the input sample and parameters
85		 * @abstract
86		 * @param input number
87		 * @param channel number
88		 * @param parameters { [name: string]: number }
89		 * @returns number
90		 */
91		generate(){}
92
93		/**
94		 * Update the private params object with the 
95		 * values of the parameters at the given index
96		 * @param parameters { [name: string]: Float32Array },
97		 * @param index number
98		 */
99		updateParams(parameters, index) {
100			for (const paramName in parameters) {
101				const param = parameters[paramName];
102				if (param.length > 1) {
103					this.params[paramName] = parameters[paramName][index];
104				} else {
105					this.params[paramName] = parameters[paramName][0];
106				}
107			}
108		}
109
110		/**
111		 * Process a single frame of the audio
112		 * @param inputs Float32Array[][]
113		 * @param outputs Float32Array[][]
114		 */
115		process(inputs, outputs, parameters) {
116			const input = inputs[0];
117			const output = outputs[0];
118			// get the parameter values
119			const channelCount = Math.max(input && input.length || 0, output.length);
120			for (let sample = 0; sample < this.blockSize; sample++) {
121				this.updateParams(parameters, sample);
122				for (let channel = 0; channel < channelCount; channel++) {
123					const inputSample = input && input.length ? input[channel][sample] : 0;
124					output[channel][sample] = this.generate(inputSample, channel, this.params);
125				}
126			}
127			return !this.disposed;
128		}
129	};
130`;Xs(jh);const qh=`
131	/**
132	 * A multichannel buffer for use within an AudioWorkletProcessor as a delay line
133	 */
134	class DelayLine {
135		
136		constructor(size, channels) {
137			this.buffer = [];
138			this.writeHead = []
139			this.size = size;
140
141			// create the empty channels
142			for (let i = 0; i < channels; i++) {
143				this.buffer[i] = new Float32Array(this.size);
144				this.writeHead[i] = 0;
145			}
146		}
147
148		/**
149		 * Push a value onto the end
150		 * @param channel number
151		 * @param value number
152		 */
153		push(channel, value) {
154			this.writeHead[channel] += 1;
155			if (this.writeHead[channel] > this.size) {
156				this.writeHead[channel] = 0;
157			}
158			this.buffer[channel][this.writeHead[channel]] = value;
159		}
160
161		/**
162		 * Get the recorded value of the channel given the delay
163		 * @param channel number
164		 * @param delay number delay samples
165		 */
166		get(channel, delay) {
167			let readHead = this.writeHead[channel] - Math.floor(delay);
168			if (readHead < 0) {
169				readHead += this.size;
170			}
171			return this.buffer[channel][readHead];
172		}
173	}
174`;Xs(qh);const Wh="feedback-comb-filter",Lh=`
175	class FeedbackCombFilterWorklet extends SingleIOProcessor {
176
177		constructor(options) {
178			super(options);
179			this.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);
180		}
181
182		static get parameterDescriptors() {
183			return [{
184				name: "delayTime",
185				defaultValue: 0.1,
186				minValue: 0,
187				maxValue: 1,
188				automationRate: "k-rate"
189			}, {
190				name: "feedback",
191				defaultValue: 0.5,
192				minValue: 0,
193				maxValue: 0.9999,
194				automationRate: "k-rate"
195			}];
196		}
197
198		generate(input, channel, parameters) {
199			const delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);
200			this.delayLine.push(channel, input + delayedSample * parameters.feedback);
201			return delayedSample;
202		}
203	}
204`;Dr(Wh,Lh);class Xn extends Rt{constructor(){const e=z(Xn.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(e),this.name="Sampler",this._activeSources=new Map;const t={};Object.keys(e.urls).forEach(n=>{const i=parseInt(n,10);if(B(dn(n)||st(i)&&isFinite(i),`url key is neither a note or midi pitch: ${n}`),dn(n)){const r=new Ie(this.context,n).toMidi();t[r]=e.urls[n]}else st(i)&&isFinite(i)&&(t[i]=e.urls[i])}),this._buffers=new Gs({urls:t,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.attack=e.attack,this.release=e.release,this.curve=e.curve,this._buffers.loaded&&Promise.resolve().then(e.onload)}static getDefaults(){return Object.assign(Rt.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:X,onerror:X,release:.1,urls:{}})}_findClosest(e){let n=0;for(;n<96;){if(this._buffers.has(e+n))return-n;if(this._buffers.has(e-n))return n;n++}throw new Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,n=1){return this.log("triggerAttack",e,t,n),Array.isArray(e)||(e=[e]),e.forEach(i=>{const r=Mr(new Ie(this.context,i).toFrequency()),o=Math.round(r),a=r-o,c=this._findClosest(o),l=o-c,u=this._buffers.get(l),h=Or(c+a),p=new an({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);p.start(t,0,u.duration/h,n),Ve(this._activeSources.get(o))||this._activeSources.set(o,[]),this._activeSources.get(o).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(o)){const f=this._activeSources.get(o),d=f.indexOf(p);d!==-1&&f.splice(d,1)}}}),this}triggerRelease(e,t){return this.log("triggerRelease",e,t),Array.isArray(e)||(e=[e]),e.forEach(n=>{const i=new Ie(this.context,n).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){const r=this._activeSources.get(i);t=this.toSeconds(t),r.forEach(o=>{o.stop(t)}),this._activeSources.set(i,[])}}),this}releaseAll(e){const t=this.toSeconds(e);return this._activeSources.forEach(n=>{for(;n.length;)n.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(e,t,n,i=1){const r=this.toSeconds(n);return this.triggerAttack(e,r,i),Ve(t)?(B(Ve(e),"notes must be an array when duration is array"),e.forEach((o,a)=>{const c=t[Math.min(a,t.length-1)];this.triggerRelease(o,r+this.toSeconds(c))})):this.triggerRelease(e,r+this.toSeconds(t)),this}add(e,t,n){if(B(dn(e)||isFinite(e),`note must be a pitch or midi: ${e}`),dn(e)){const i=new Ie(this.context,e).toMidi();this._buffers.add(i,t,n)}else this._buffers.add(e,t,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(t=>t.dispose())}),this._activeSources.clear(),this}}qe([Je(0)],Xn.prototype,"attack",void 0);qe([Je(0)],Xn.prototype,"release",void 0);class Qs extends G{constructor(){const e=z(Qs.getDefaults(),arguments,["pan"]);super(e),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ee({context:this.context,param:this._panner.pan,value:e.pan,minValue:-1,maxValue:1}),this._panner.channelCount=e.channelCount,this._panner.channelCountMode="explicit",re(this,"pan")}static getDefaults(){return Object.assign(G.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}const Bh="bit-crusher",zh=`
205	class BitCrusherWorklet extends SingleIOProcessor {
206
207		static get parameterDescriptors() {
208			return [{
209				name: "bits",
210				defaultValue: 12,
211				minValue: 1,
212				maxValue: 16,
213				automationRate: 'k-rate'
214			}];
215		}
216
217		generate(input, _channel, parameters) {
218			const step = Math.pow(0.5, parameters.bits - 1);
219			const val = step * Math.floor(input / step + 0.5);
220			return val;
221		}
222	}
223`;Dr(Bh,zh);class de extends G{constructor(){const e=z(de.getDefaults(),arguments,["solo"]);super(e),this.name="Solo",this.input=this.output=new ue({context:this.context}),de._allSolos.has(this.context)||de._allSolos.set(this.context,new Set),de._allSolos.get(this.context).add(this),this.solo=e.solo}static getDefaults(){return Object.assign(G.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(e){e?this._addSolo():this._removeSolo(),de._allSolos.get(this.context).forEach(t=>t._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){de._soloed.has(this.context)||de._soloed.set(this.context,new Set),de._soloed.get(this.context).add(this)}_removeSolo(){de._soloed.has(this.context)&&de._soloed.get(this.context).delete(this)}_isSoloed(){return de._soloed.has(this.context)&&de._soloed.get(this.context).has(this)}_noSolos(){return!de._soloed.has(this.context)||de._soloed.has(this.context)&&de._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(),de._allSolos.get(this.context).delete(this),this._removeSolo(),this}}de._allSolos=new Map;de._soloed=new Map;class Js extends G{constructor(){const e=z(Js.getDefaults(),arguments,["pan","volume"]);super(e),this.name="PanVol",this._panner=this.input=new Qs({context:this.context,pan:e.pan,channelCount:e.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Bt({context:this.context,volume:e.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=e.mute,re(this,["pan","volume"])}static getDefaults(){return Object.assign(G.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}
223dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class Ct extends G{constructor(){const e=z(Ct.getDefaults(),arguments,["volume","pan"]);super(e),this.name="Channel",this._solo=this.input=new de({solo:e.solo,context:this.context}),this._panVol=this.output=new Js({context:this.context,pan:e.pan,volume:e.volume,mute:e.mute,channelCount:e.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),re(this,["pan","volume"])}static getDefaults(){return Object.assign(G.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(e){return Ct.buses.has(e)||Ct.buses.set(e,new ue({context:this.context})),Ct.buses.get(e)}send(e,t=0){const n=this._getBus(e),i=new ue({context:this.context,units:"decibels",gain:t});return this.connect(i),i.connect(n),i}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}Ct.buses=new Map;Pe().transport;Pe().destination;Pe().destination;Pe().listener;Pe().draw;Pe();const Si={gentle:{name:"Gentle",inhale:4,hold1:0,exhale:6,hold2:0,desc:"4s in · 6s out"},box:{name:"Box",inhale:4,hold1:4,exhale:4,hold2:4,desc:"4 · 4 · 4 · 4"},extended:{name:"4-7-8",inhale:4,hold1:7,exhale:8,hold2:0,desc:"4s in · 7s hold · 8s out"}},is=[{label:"1 min",seconds:60},{label:"2 min",seconds:120},{label:"3 min",seconds:180}];function Rr(s){return s.inhale+s.hold1+s.exhale+s.hold2}function Ci(s,e){const t=Rr(e),n=s%t;return n<e.inhale?{phase:"inhale",progress:n/e.inhale}:n<e.inhale+e.hold1?{phase:"hold",progress:(n-e.inhale)/e.hold1}:n<e.inhale+e.hold1+e.exhale?{phase:"exhale",progress:(n-e.inhale-e.hold1)/e.exhale}:{phase:"rest",progress:(n-e.inhale-e.hold1-e.exhale)/Math.max(e.hold2,1)}}const Uh={inhale:"Breathe in",hold:"Hold",exhale:"Breathe out",rest:"Rest"};function ki({flip:s,style:e}){return y.jsxs("svg",{viewBox:"0 0 247.47 94.11",style:{...e,transform:s?"scaleX(-1)":void 0},xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{fill:"#ffb600",d:"M247.47,94.11H0s87.35-31.09,139.42-36.18c52.07-5.09,108.05-11.57,108.05-11.57v47.75Z"}),y.jsx("path",{fill:"#936037",d:"M220.26,16.17h-2.75c-.34,13.59-.68,27.19-1.02,40.79h4.79c-.34-13.6-.68-27.19-1.02-40.79Z"}),y.jsx("path",{fill:"#008d36",d:"M218.88,7.61s3.8-3.34,6.55-4.15c4.64-1.37,8.81.83,8.81.83,0,0-4.16.64-6.12,1.5-1.96.85-3.52,3.19-3.52,3.19,0,0,4.64.77,7.29,2.58,2.65,1.81,7.31,8.66,7.31,8.66,0,0-4.43-3.32-8.05-4.39-3.62-1.08-6.55-.24-6.55-.24,0,0,.58.91,1.8,3.18,1.22,2.26,1.43,5.97,1.43,5.97,0,0-2.46-2.27-4.51-3.99-2.04-1.71-4.44-1.85-4.44-1.85,0,0-3.57,1.37-4.75,3.01-1.17,1.63-3.27,4.53-3.27,4.53,0,0-.13-4.52.57-6.35.7-1.83,1.72-4.49,1.72-4.49,0,0-1.61-.56-4.57.59-2.47.96-6.83,5.49-6.83,5.49,0,0,1.18-4.92,4.15-7.55,1.71-1.52,4.56-3.23,4.56-3.23,0,0-1.98-2.05-3.98-3.09-2-1.05-5.14-1.01-5.14-1.01,0,0,4.61-1.15,7.79-1.1,3.18.06,9.74,1.93,9.74,1.93Z"}),y.jsx("path",{fill:"#936037",d:"M122.12,32.46h-2.46c-.3,12.11-.61,24.23-.91,36.34h4.27c-.3-12.11-.61-24.22-.91-36.34Z"}),y.jsx("path",{fill:"#008d36",d:"M120.9,24.83s3.38-2.97,5.84-3.7c4.14-1.22,7.85.74,7.85.74,0,0-3.7.57-5.45,1.34-1.75.76-3.14,2.84-3.14,2.84,0,0,4.13.69,6.5,2.3,2.36,1.61,6.51,7.71,6.51,7.71,0,0-3.95-2.96-7.17-3.92-3.23-.96-5.84-.21-5.84-.21,0,0,.51.81,1.6,2.83,1.09,2.02,1.28,5.32,1.28,5.32,0,0-2.19-2.03-4.02-3.55-1.82-1.53-3.96-1.65-3.96-1.65,0,0-3.18,1.23-4.23,2.68-1.05,1.45-2.91,4.04-2.91,4.04,0,0-.11-4.03.51-5.66.62-1.63,1.53-4,1.53-4,0,0-1.43-.5-4.07.52-2.2.85-6.08,4.89-6.08,4.89,0,0,1.05-4.38,3.69-6.73,1.52-1.36,4.07-2.88,4.07-2.88,0,0-1.77-1.82-3.55-2.76-1.78-.93-4.58-.9-4.58-.9,0,0,4.11-1.03,6.94-.98,2.83.05,8.67,1.72,8.67,1.72Z"}),y.jsx("path",{fill:"#063",d:"M247.47,48.18c0-5.81-6.41-10.52-14.31-10.52-6.85,0-12.58,3.55-13.98,8.28-2.09-1.87-5.27-3.06-8.82-3.06-6.31,0-11.42,3.76-11.42,8.4,0,.37.04.72.1,1.08h-2.67c-4.75,0-8.64,2.86-8.64,6.36h0v6.36h59.73v-16.88Z"}),y.jsx("path",{fill:"#00772a",d:"M204.99,57.72c0-3.59-3.95-6.5-8.83-6.5-4.23,0-7.76,2.19-8.63,5.11-1.29-1.15-3.25-1.89-5.44-1.89-3.89,0-7.05,2.32-7.05,5.18,0,.23.03.45.07.67h-1.65c-2.93,0-5.33,1.76-5.33,3.92h0v3.92h36.86v-10.42Z"}),y.jsx("path",{fill:"#936037",d:"M180.85,40.3h-2.46c-.3,12.11-.61,24.23-.91,36.34h4.27c-.3-12.11-.6-24.23-.91-36.34Z"}),y.jsx("path",{fill:"#008d36",d:"M179.62,32.67s3.38-2.97,5.84-3.7c4.14-1.22,7.85.74,7.85.74,0,0-3.7.57-5.45,1.33-1.75.76-3.14,2.84-3.14,2.84,0,0,4.13.69,6.5,2.3,2.36,1.61,6.51,7.71,6.51,7.71,0,0-3.95-2.96-7.18-3.92-3.23-.96-5.84-.21-5.84-.21,0,0,.51.81,1.6,2.83,1.09,2.02,1.28,5.32,1.28,5.32,0,0-2.19-2.03-4.02-3.55-1.82-1.53-3.96-1.65-3.96-1.65,0,0-3.18,1.23-4.23,2.68-1.05,1.45-2.91,4.04-2.91,4.04,0,0-.11-4.03.51-5.66.62-1.63,1.53-4,1.53-4,0,0-1.43-.5-4.07.52-2.2.85-6.08,4.89-6.08,4.89,0,0,1.05-4.38,3.69-6.73,1.52-1.36,4.07-2.88,4.07-2.88,0,0-1.77-1.82-3.55-2.76-1.78-.93-4.58-.9-4.58-.9,0,0,4.11-1.03,6.94-.98,2.83.05,8.67,1.72,8.67,1.72Z"}),y.jsx("path",{fill:"#936037",d:"M95.18,17.84h-3.73c-.46,18.43-.92,36.86-1.38,55.29h6.5c-.46-18.43-.92-36.86-1.38-55.29Z"}),y.jsx("path",{fill:"#2fac66",d:"M93.31,6.23s5.15-4.52,8.88-5.62c6.29-1.85,11.94,1.13,11.94,1.13,0,0-5.64.87-8.3,2.03-2.66,1.16-4.77,4.32-4.77,4.32,0,0,6.29,1.05,9.89,3.5,3.6,2.45,9.91,11.73,9.91,11.73,0,0-6-4.5-10.92-5.96-4.91-1.46-8.88-.32-8.88-.32,0,0,.78,1.24,2.44,4.31,1.65,3.07,1.94,8.09,1.94,8.09,0,0-3.34-3.08-6.11-5.41s-6.02-2.51-6.02-2.51c0,
2230-4.84,1.86-6.43,4.07-1.59,2.21-4.43,6.14-4.43,6.14,0,0-.17-6.13.78-8.61.95-2.48,2.33-6.08,2.33-6.08,0,0-2.18-.76-6.19.79-3.35,1.3-9.25,7.45-9.25,7.45,0,0,1.6-6.66,5.62-10.24,2.32-2.06,6.19-4.38,6.19-4.38,0,0-2.69-2.78-5.4-4.2-2.71-1.42-6.97-1.37-6.97-1.37,0,0,6.25-1.56,10.56-1.49,4.31.08,13.2,2.62,13.2,2.62Z"}),y.jsx("path",{fill:"#00772a",d:"M247.47,64.43c0-4.86-5.36-8.81-11.97-8.81-5.73,0-10.52,2.97-11.69,6.93-1.75-1.56-4.41-2.56-7.38-2.56-5.28,0-9.55,3.15-9.55,7.03,0,.31.04.61.09.9h-2.23c-3.98,0-7.23,2.39-7.23,5.32h0v5.32h49.97v-14.12Z"}),y.jsx("path",{fill:"#008d36",d:"M172.75,65.04c0-3.14-3.46-5.69-7.73-5.69-3.7,0-6.8,1.92-7.55,4.47-1.13-1.01-2.85-1.66-4.77-1.66-3.41,0-6.17,2.03-6.17,4.54,0,.2.02.39.06.58h-1.44c-2.57,0-4.67,1.55-4.67,3.43h0v3.44h32.28v-9.12Z"}),y.jsx("path",{fill:"#008d36",d:"M211.86,68.14c0-3.59-3.95-6.5-8.83-6.5-4.23,0-7.76,2.19-8.63,5.11-1.29-1.15-3.25-1.89-5.44-1.89-3.89,0-7.05,2.32-7.05,5.18,0,.23.03.45.07.67h-1.65c-2.93,0-5.33,1.76-5.33,3.92h0v3.92h36.86v-10.42Z"}),y.jsx("path",{fill:"#3aaa35",d:"M183.95,70.78c0-2.68-2.95-4.85-6.59-4.85-3.16,0-5.79,1.63-6.44,3.81-.96-.86-2.42-1.41-4.06-1.41-2.9,0-5.26,1.73-5.26,3.87,0,.17.02.33.05.5h-1.23c-2.19,0-3.98,1.32-3.98,2.93h0v2.93h27.5v-7.77Z"})]})}function Gh({style:s}){return y.jsxs("svg",{viewBox:"0 0 1181.1 1513.62",style:s,xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{fill:"#fff",d:"M998.99,1508.16h-326.46c-6.94,0-13.93,0-20.97.02-23.82.19-47.82,3.6-71.82,4.74-72,0-144-2.28-216,0-108,3.42-217-6.83-325.26-4.75-12.46,0-22.01,0-28.52,0H0s16.91-16.98,38.06-38.21c7.05-7.08,14.58-14.62,22.11-22.17,13.58-13.41,27.58-27.07,41.33-41.51,11.26-11.32,18.78-18.87,18.78-18.87l1042.63-65.06-42.8,99.73c-22.61,52.68-69.61,86.1-121.11,86.1Z"}),y.jsx("ellipse",{fill:"#634e42",cx:"905.88",cy:"1445.52",rx:"11.96",ry:"13.62"}),y.jsx("path",{fill:"#634e42",d:"M980.8,1439.64c.45,7.5-4.52,14-11.11,14.52-6.59.52-12.3-5.15-12.76-12.65-.45-7.5,4.52-14,11.11-14.52,6.59-.52,12.3,5.15,12.76,12.65Z"}),y.jsx("ellipse",{fill:"#634e42",cx:"1031.84",cy:"1435.63",rx:"11.96",ry:"13.62"}),y.jsx("path",{fill:"#fff",d:"M667.78,178.98l-17.82,1178.6s-282.9-133.1-408.15-113.43c0,0,209.47-797.82,425.97-1065.17Z"}),y.jsx("path",{fill:"#fff",d:"M711.51,194.92s149.01,772.66,0,1155.85c0,0,236.67-75.34,345.73-142.95,0,0-71.47-583.88-345.73-1012.9Z"}),y.jsx("path",{fill:"#634e42",d:"M689.09,1392.7V105.56c0-17.38.28-84.8,0-102.18-.01-.76,0-1.52,0-2.28,0-1.46-1.99-1.46-1.99,0v1337.15c0,17.38-.28,34.8,0,52.18.01.76,0,1.52,0,2.28,0,1.46,1.99,1.46,1.99,0h0Z"}),y.jsx("path",{fill:"#ff9314",d:"M1132.45,1393.3l30.45-70.97-1042.63,65.06s-8.15,8.18-19,19.09c-18.53,16.49-34.53,38.12-54.53,54.06,137-5.69,273-15.94,408.51-24.99,7.33-.46,14.69-.92,22.08-1.38,303.11-18.91,655.11-40.88,655.11-40.88Z"}),y.jsx("path",{fill:"#ff9314",d:"M887.77,111.15c-65.85,16.76-134.15,16.76-200,0V17.15c65.85,16.76,134.15,16.76,200,0-17.3,20.07-34.77,38.98-52.32,56.74,17.55,13.58,35.02,26,52.32,37.26Z"}),y.jsx("path",{fill:"#fff",d:"M783.54,38.7c-4.88,0-9.52.98-13.76,2.76-4.24-1.78-8.89-2.76-13.76-2.76-19.71,0-35.74,16.03-35.74,35.74s16.03,35.74,35.74,35.74c4.88,0,9.52-.98,13.76-2.76,4.24,1.78,8.89,2.76,13.76,2.76,19.71,0,35.74-16.03,35.74-35.74s-16.03-35.74-35.74-35.74ZM779.97,74.43c0,8.09-4.04,15.26-10.2,19.6-6.16-4.34-10.2-11.51-10.2-19.6s4.04-15.25,10.2-19.59c6.16,4.34,10.2,11.5,10.2,19.59ZM732.05,74.43c0-13.21,10.75-23.96,23.96-23.96.34,0,.67.01,1.01.03-5.73,6.34-9.22,14.74-9.22,23.93s3.5,17.6,9.23,23.94c-.34.01-.67.03-1.01.03-13.21,0-23.96-10.75-23.96-23.96ZM783.54,98.4c-.34,0-.68-.01-1.01-.03,5.73-6.34,9.23-14.74,9.23-23.94s-3.49-17.59-9.22-23.93c.34-.01.67-.03,1.01-.03,13.21,0,23.96,10.74,23.96,23.96s-10.75,23.96-23.96,23.96Z"})]})}const Ut=({children:s,active:e,onClick:t,style:n})=>{const[i,r]=Y.useState(!1);return y.jsx("button",{onClick:t,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{padding:"12px 22px",borderRadius:24,fontSize:17,cursor:"pointer",border:e?"2px solid #3a8a6a":"1.5px solid #9cc8b8",background:e?"#d8f0e4":i?"#e8f4ee":"transparent",color:"#1a5a4a",fontWeight:e?700:500,transition:"all 0.15s ease",lineHeight:1.4,...n},children:s})};function $h(){const[s,e]=Y.useState("gentle"),[t,n]=Y.useState(1),[i,r]=Y.useState(!1),[o,a]=Y.useState(0),[c,l]=Y.useState(!1),[u,h]=Y.useState(!1),[p,f]=Y.useState(!1),d=Si[s],m=is[t].seconds,_=Y.useRef(null),v=Y.useRef(0),T=Y.useRef(null),S=Y.useRef(null),k=Y.useRef(null),g=Y.useRef(null),x=Y.useRef(!1),b=Y.useCallback(async()=>
223{if(x.current)return;await bh(),x.current=!0;const M=new ue(1).toDestination();k.current=M;const P=new ue(0).connect(M);g.current=P;const q=new En({frequency:500,type:"lowpass",rolloff:-24}).connect(P),$=new Nn({type:"pink",volume:-6}).connect(q);$.start(),T.current={noise:$,filter:q};const oe=new ue(.14).connect(M),_e=new En({frequency:320,type:"lowpass",rolloff:-48}).connect(oe),U=new Nn({type:"brown",volume:-7}).connect(_e);U.start(),S.current={noise:U,gain:oe}},[]);Y.useEffect(()=>{k.current&&k.current.gain.rampTo(p?0:1,.2)},[p]),Y.useEffect(()=>{if(!i){_.current&&cancelAnimationFrame(_.current),g.current&&g.current.gain.rampTo(0,.3);return}v.current=performance.now()-o*1e3;const M=()=>{var oe;const P=(performance.now()-v.current)/1e3;if(P>=m){a(m),r(!1),l(!0),g.current&&g.current.gain.rampTo(0,.3);return}a(P);const{phase:q,progress:$}=Ci(P,d);q==="exhale"&&g.current?(g.current.gain.rampTo(Math.sin($*Math.PI)*.6,.15),(oe=T.current)!=null&&oe.filter&&T.current.filter.frequency.rampTo(350+$*400,.1)):g.current&&g.current.gain.rampTo(0,.3),_.current=requestAnimationFrame(M)};return _.current=requestAnimationFrame(M),()=>{_.current&&cancelAnimationFrame(_.current)}},[i,d,m]),Y.useEffect(()=>()=>{var M,P,q,$,oe,_e,U,J;try{(M=T.current)==null||M.noise.stop(),(P=T.current)==null||P.noise.dispose(),(q=T.current)==null||q.filter.dispose(),($=S.current)==null||$.noise.stop(),(oe=S.current)==null||oe.noise.dispose(),(_e=S.current)==null||_e.gain.dispose(),(U=g.current)==null||U.dispose(),(J=k.current)==null||J.dispose()}catch{}},[]);const w=async()=>{await b(),a(0),l(!1),r(!0)},O=()=>{r(!1),a(0),l(!1),g.current&&g.current.gain.rampTo(0,.1)},{phase:A,progress:N}=Ci(o,d),C=Rr(d),R=Math.max(1,Math.floor(m/C));let E=.45;(i||c)&&(A==="inhale"?E=.45+N*.55:A==="hold"?E=1:A==="exhale"?E=1-N*.55:E=.45);const I=Math.floor(o/C),V=Math.min((I+(A==="exhale"?N:0))/R,1),W=64;return y.jsxs("div",{style:{fontFamily:"'Lato', 'Helvetica Neue', sans-serif",maxWidth:560,margin:"0 auto",background:"linear-gradient(180deg, #daf0e8 0%, #c4e4da 50%, #a8d4cc 100%)",borderRadius:20,overflow:"hidden",position:"relative"},children:[(i||c)&&y.jsx("button",{onClick:()=>f(!p),style:{position:"absolute",top:14,right:14,background:"rgba(255,255,255,0.5)",border:"none",borderRadius:20,padding:"7px 9px",cursor:"pointer",zIndex:2,display:"flex",alignItems:"center"},children:y.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#1a5a4a",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p?y.jsxs(y.Fragment,{children:[y.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),y.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),y.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):y.jsxs(y.Fragment,{children:[y.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),y.jsx("path",{d:"M19.07 4.93a10 10 0 010 14.14"}),y.jsx("path",{d:"M15.54 8.46a5 5 0 010 7.07"})]})})}),y.jsxs("div",{style:{padding:"32px 28px 8px",textAlign:"center"},children:[y.jsx("h2",{style:{fontSize:24,fontWeight:700,color:"#1a5a4a",margin:"0 0 8px"},children:c?"Feeling calmer?":i?Uh[A]:"Breezy Breathing"}),y.jsx("p",{style:{fontSize:16,color:"#3a7a6a",margin:0,lineHeight:1.5},children:c?`${R} cycles · ${is[t].label}`:i?"":"Slowly inhale and exhale to guide the sailboat from island to island"})]}),y.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px 0 20px"},children:y.jsxs("div",{style:{position:"relative",width:W*2+8,height:W*2+8,display:"flex",alignItems:"center",justifyContent:"center"},children:[y.jsx("div",{style:{position:"absolute",width:W*2,height:W*2,borderRadius:"50%",border:"2px solid rgba(58,138,106,0.25)"}}),y.jsx("div",{style:{width:W*2*E,height:W*2*E,borderRadius:"50%",background:"radial-gradient(circle at 40% 38%, #7ec8a8, #3a8a6a)",opacity:.6,boxShadow:`0 0 ${30*E}px rgba(58,138,106,0.3)`}})]})}),y.jsxs("div",{style:{position:"relative",height:120,overflow:"hidden"},children:[y.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:60,background:"linear-gradient(180deg, #7cc4c0 0%, #5aada8 100%)"}}),y.jsx("svg",{viewBox:"0 0 560 30",style:{position:"absolute",bottom:28,left:0,width:"100%",height:30,opacity:.3},children:[0,1,2].map(M=>{const P=o*(15+M*8)%80;return y.jsx("path",{d:`M${-40+P},${10+M*6} Q${-20+P},${6+M*6} ${0+P},${10+M*6} T${80+P},${10+M*6} T${160+P},${10+M*6} T${240+P},${10+M*6} T${320+P},${10+M*6} T${400+P},${10+M*6} T${480+P},${10+M*6} T${560+P},${10+M*6}`,fill:"none",stroke:"#fff",strokeWidth:"1.2"},M)})}),y.jsx(ki,{flip:!0,style:{position:"absolute",bottom:0,left:-20,width:120,height:"auto"}}),y.jsx(ki,{flip:!1,style:{position:"absolute",bottom:0,right:-20,width:130,height:"auto"}}),y.jsx("div",{style:{position:"absolute",bottom:32,left:`${20+V*60}%`,width:48,height:48,transform:`translateX(-50%) translateY(${Math.sin(o*2.5)*2}px)`,transition:i?"none":"left 0.5s ease"},children:y.jsx(Gh,{style:{width:"100%",height:"100%",filter:"drop-shadow(0 2px 4px rgba(0,0,0,0.15))"}})})]}),y.jsxs("div",{style:{padding:"20px 28px 10px"},children:[!i&&!c&&y.jsxs(y.Fragment,{children:[y.jsx("div",{style:{display:"flex",gap:8,justifyContent:"center",marginBottom:12,flexWrap:"wrap"},children:Object.entries(Si).map(([M,P])=>y.jsxs(Ut,{active:s===M,onClick:()=>e(M),children:[P.name,y.jsx("br",{}),y.jsx("span",{style:{fontSize:14,fontWeight:400,opacity:.7},children:P.desc})]},M))}),y.jsx("div",{style:{display:"flex",gap:8,justifyContent:"center",marginBottom:16},children:is.map((M,P)=>y.jsx(Ut,{active:t===P,onClick:()=>n(P),children:M.label},P))}),y.jsx(Ut,{onClick:w,style:{display:"block",width:"100%",background:"#3a8a6a",color:"white",border:"none",fontSize:18,fontWeight:700,padding:"16px",letterSpacing:.5},children:"Begin"})]}),i&&y.jsx(Ut,{onClick:()=>{r(!1),g.current&&g.current.gain.rampTo(0,.1)},style:{display:"block",width:"100%",fontSize:16},children:"Stop"}),c&&y.jsx("div",{style:{textAlign:"center"},children:y.jsx(Ut,{onClick:O,style:{background:"#3a8a6a",color:"white",border:"none",fontSize:18,fontWeight:600,padding:"16px 40px"},children:"Sail again"})})]}),y.jsxs("div",{style:{padding:"6px 28px 20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y.jsx("button",{onClick:()=>h(!0),style:{background:"none",border:"none",color:"#2a6a5a",fontSize:14,cursor:"pointer",textDecoration:"underline",fontWeight:500},children:"Safety note"}),y.jsx("a",{href:"https://www.thebraindocs.com",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",textDecoration:"none",opacity:.45},children:y.jsx("img",{src:Wr,alt:"The Brain Docs",style:{height:20,width:"auto"}})})]}),u&&y.jsx("div",{onClick:()=>h(!1),style:{position:"absolute",inset:0,background:"rgba(20,60,50,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,borderRadius:20,padding:24},children:y.jsxs("div",{onClick:M=>M.stopPropagation(),style:{background:"#f0f8f4",borderRadius:14,padding:"24px 24px 20px",maxWidth:400,boxShadow:"0 8px 30px rgba(0,0,0,0.2)"},children:[y.jsx("h3",{style:{fontSize:17,fontWeight:700,color:"#1a5a4a",margin:"0 0 10px"},children:"Safety note"}),y.jsx("p",{style:{fontSize:14,color:"#2a6a5a",margin:"0 0 16px",lineHeight:1.6},children:"Stop if you feel dizzy or lightheaded. If you have a respiratory or cardiovascular condition, use the Gentle pattern (no breath hold) or consult your doctor before practising extended holds. The 4-7-8 pattern involves a 7-second hold that may not be suitable for everyone."}),y.jsx("button",{onClick:()=>h(!1),style:{background:"#3a8a6a",color:"white",border:"none",borderRadius:20,padding:"10px 24px",fontSize:15,fontWeight:600,cursor:"pointer",width:"100%"},children:"Got it"})]})})]})}
223const Pr=[{milestone:"Alois Alzheimer presents the first case of the disease that would bear his name",correctYear:1906,options:[1898,1906,1915],factoid:"Auguste Deter was just 51 when she was admitted to a Frankfurt hospital with memory loss and hallucinations. After she died, Alzheimer used silver staining to reveal the plaques and tangles in her brain that define the disease today."},{milestone:"Scientists identify the sticky protein that builds up in the brains of Alzheimer's patients",correctYear:1984,options:[1972,1984,1991],factoid:"The protein is called amyloid-beta. It took nearly 80 years from Alzheimer's original description to identify what the plaques were actually made of. This discovery launched the amyloid hypothesis, which has driven most drug development ever since."},{milestone:"A gene variant is discovered that dramatically increases Alzheimer's risk",correctYear:1993,options:[1986,1993,2001],factoid:"The gene is called APOE, and the variant is APOE ε4. Carrying one copy roughly triples your risk. Carrying two copies increases it 8 to 12 times. It remains the strongest known genetic risk factor for the most common form of Alzheimer's."},{milestone:"A vaccine clears Alzheimer's plaques from mouse brains for the first time",correctYear:1999,options:[1993,1999,2005],factoid:"Dale Schenk's team showed immunization could not only prevent plaques from forming but clear existing deposits. The human trial that followed was halted when some participants developed dangerous brain inflammation."},{milestone:"A brain scan detects Alzheimer's in a living person for the first time",correctYear:2004,options:[1998,2004,2010],factoid:"The tracer is called Pittsburgh Compound B (PiB), and it made Alzheimer's pathology visible on a PET scan for the first time. Before this, the only way to confirm a diagnosis was after death."},{milestone:"The first drug designed to slow Alzheimer's progression reaches patients",correctYear:2021,options:[2017,2021,2025],factoid:"The drug was aducanumab (brand name Aduhelm), and its approval was one of the most controversial FDA decisions in years. Many researchers questioned whether it truly worked. It was discontinued in 2024, superseded by newer drugs called lecanemab and donanemab."},{milestone:"The FDA clears the first blood test for Alzheimer's for use in clinics",correctYear:2025,options:[2021,2025,2028],factoid:"Fujirebio's Lumipulse test measures a protein called p-tau217 in a standard blood draw. For the first time, a routine blood test could flag Alzheimer's-related brain changes with accuracy approaching expensive brain scans."}];function Zh(s,e){const t=[...s];let n=e;for(let i=t.length-1;i>0;i--){n=(n*16807+11)%2147483647;const r=n%(i+1);[t[i],t[r]]=[t[r],t[i]]}return t}const ht=Pr.length,Yh=s=>s===ht?{emoji:"🧠",text:"Perfect score! You may actually know Alzheimer's research history better than we do..."}:s>=5?{emoji:"🎓",text:"Impressive!"}:s>=3?{emoji:"👏",text:"Solid work!"}:s>=1?{emoji:"💡",text:"Not bad!"}:{emoji:"🌱",text:"Thanks for playing!"};function Hh(){const[s,e]=Y.useState(0),[t,n]=Y.useState(null),[i,r]=Y.useState(!1),[o,a]=Y.useState(0),[c,l]=Y.useState(!1),[u,h]=Y.useState(!0),[p,f]=Y.useState(""),[d,m]=Y.useState(""),[_,v]=Y.useState(!1),[T,S]=Y.useState(!1),[k]=Y.useState(()=>Math.floor(Math.random()*1e5)),g=Pr[s],x=t===(g==null?void 0:g.correctYear),b=s/ht*100,w=Y.useMemo(()=>g?Zh(g.options,k+s):[],[s,k,g]),O=()=>{t!==null&&(r(!0),t===g.correctYear&&a(I=>I+1))},A=()=>{s+1>=ht?l(!0):(e(I=>I+1),n(null),r(!1))},N=()=>{e(0),n(null),r(!1),a(0),l(!1),h(!0)},C=async I=>{if(I.preventDefault(),!!p.trim()){S(!0);try{const{error:D}=await Lr.functions.invoke("subscribe-newsletter",{body:{firstName:d.trim(),email:p.trim(),extraTags:["history_quiz_sign_up"]}});if(D)throw D;v(!0),m(""),f(""),Br("alzheimers-timeline-quiz"),Ks.success("Welcome to The Synapse!")}catch{Ks.error("Something went wrong. Please try again.")}finally{S(!1)}}},R={width:"100%",fontFamily:"'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif"},E={maxWidth:520,width:"100%",background:"#fff",borderRadius:24,padding:"44px 32px",textAlign:"center",boxShadow:"0 4px 24px rgba(0,0,0,0.06)"};if(u)return y.jsx("div",{style:R,children:y.jsxs("div",{style:E,children:[y.jsx("div",{style:{fontSize:56,marginBottom:16},children:"🧠"}),y.jsx("h1",{style:{fontSize:30,fontWeight:800,color:"#1a1a1a",margin:"0 0 8px",lineHeight:1.3},children:"How well do you know the past 120 years of Alzheimer's research?"}),y.jsx("p",{style:{color:"#ff9417",fontWeight:700,fontSize:15,textTransform:"uppercase",letterSpacing:1,margin:"0 0 20px"},children:"Alzheimer's Awareness Month"}),y.jsxs("p",{style:{color:"#555",fontSize:18,lineHeight:1.6,margin:"0 0 36px"}
223,children:["From Alois Alzheimer's first case to the blood tests arriving in clinics today, test your knowledge of the milestones that shaped the field! ",ht," questions. Can you match the discovery to the year?"]}),y.jsx("button",{onClick:()=>h(!1),style:{background:"#ff9417",color:"#fff",border:"none",borderRadius:100,padding:"16px 44px",fontSize:20,fontWeight:700,cursor:"pointer",width:"100%",maxWidth:300,transition:"transform 0.15s, box-shadow 0.15s",boxShadow:"0 2px 8px rgba(255,148,23,0.3)"},onMouseOver:I=>{I.currentTarget.style.transform="translateY(-1px)",I.currentTarget.style.boxShadow="0 4px 12px rgba(255,148,23,0.4)"},onMouseOut:I=>{I.currentTarget.style.transform="none",I.currentTarget.style.boxShadow="0 2px 8px rgba(255,148,23,0.3)"},children:"Start the quiz →"}),y.jsx("p",{style:{color:"#999",fontSize:13,marginTop:20},children:"From The Brain Docs • thebraindocs.com"})]})});if(c){const I=Yh(o);return y.jsx("div",{style:R,children:y.jsxs("div",{style:E,children:[y.jsx("div",{style:{fontSize:56,marginBottom:8},children:I.emoji}),y.jsxs("h2",{style:{fontSize:28,fontWeight:800,color:"#1a1a1a",margin:"0 0 6px"},children:[o," out of ",ht]}),y.jsx("p",{style:{color:"#555",fontSize:17,lineHeight:1.5,margin:"0 0 32px"},children:I.text}),y.jsxs("div",{style:{background:"#fff8f0",borderRadius:16,padding:"24px 22px",marginBottom:24,textAlign:"left",border:"1px solid #ffe8cc"},children:[y.jsx("p",{style:{fontWeight:700,fontSize:18,color:"#1a1a1a",margin:"0 0 8px"},children:"🧬 Get more brain science like this"}),y.jsx("p",{style:{color:"#666",fontSize:15,lineHeight:1.5,margin:"0 0 16px"},children:"Join 150,000+ readers of The Synapse, our free weekly newsletter from Drs. Ayesha & Dean Sherzai."}),_?y.jsxs("div",{style:{background:"#e8faf0",borderRadius:12,padding:"14px 18px",display:"flex",alignItems:"center",gap:8,color:"#2a7d4f",fontWeight:600,fontSize:16},children:[y.jsx("span",{children:"✓"})," You're subscribed! Check your inbox."]}):y.jsxs("form",{onSubmit:C,children:[y.jsx("input",{type:"text",placeholder:"First name",value:d,onChange:D=>m(D.target.value),style:{width:"100%",boxSizing:"border-box",padding:"12px 14px",borderRadius:10,border:"1px solid #ddd",fontSize:15,outline:"none",marginBottom:8}}),y.jsx("input",{type:"email",placeholder:"Email address",value:p,onChange:D=>f(D.target.value),required:!0,style:{width:"100%",boxSizing:"border-box",padding:"12px 14px",borderRadius:10,border:"1px solid #ddd",fontSize:15,outline:"none",marginBottom:8}}),y.jsx("button",{type:"submit",disabled:T,style:{width:"100%",boxSizing:"border-box",background:T?"#ffc580":"#ff9417",color:"#fff",border:"none",borderRadius:10,padding:"12px 20px",fontSize:16,fontWeight:700,cursor:T?"default":"pointer"},children:T?"Subscribing...":"Subscribe free →"})]}),y.jsx("p",{style:{color:"#aaa",fontSize:12,marginTop:10,textAlign:"center"},children:"Free forever. Unsubscribe anytime."})]}),y.jsx("button",{onClick:N,style:{background:"none",border:"1px solid #ddd",borderRadius:100,padding:"12px 32px",fontSize:15,fontWeight:600,color:"#555",cursor:"pointer"},children:"Play again"})]})})}return y.jsx("div",{style:R,children:y.jsxs("div",{style:{maxWidth:520,width:"100%",minHeight:580,background:"#fff",borderRadius:24,padding:"28px 28px 32px",boxShadow:"0 4px 24px rgba(0,0,0,0.06)",display:"flex",flexDirection:"column"},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:28},children:[y.jsx("div",{style:{flex:1,height:8,background:"#f0f0f0",borderRadius:100,overflow:"hidden"},children:y.jsx("div",{style:{width:`${b}%`,height:"100%",background:"linear-gradient(90deg, #ff9417, #ffb347)",borderRadius:100,transition:"width 0.4s ease"}})}),y.jsxs("span",{style:{fontSize:15,fontWeight:700,color:"#ff9417",minWidth:44,textAlign:"right"},children:[s+1,"/",ht]})]}),y.jsx("p",{style:{color:"#ff9417",fontSize:14,fontWeight:700,textTransform:"uppercase",letterSpacing:1.2,margin:"0 0 10px"},children:"When did this happen?"}),y.jsx("h2",{style:{fontSize:22,fontWeight:700,color:"#1a1a1a",lineHeight:1.4,margin:"0 0 28px"},children:g.milestone}),y.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:20},children:w.map(I=>{let D="#fff",V="2px solid #e0e0e0",W="#333",M=500;return i?I===g.correctYear?(D="#e8faf0",V="2px solid #34c759",W="#1a7d3f",M=700):I===t&&I!==g.correctYear?(D="#fef0f0",V="2px solid #e74c3c",W="#c0392b",M=700):(D="#f8f8f8",V="2px solid #eee",W="#bbb"):I===t&&(D="#fff8f0",V="2px solid #ff9417",W="#ff9417",M=700),y.jsxs("button",{onClick:()=>!i&&n(I),disabled:i,style:{background:D,border:V,borderRadius:14,padding:"16px 20px",fontSize:22,fontWeight:M,color:W,cursor:i?"default":"pointer",textAlign:"center",transition:"all 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[I,i&&I===g.correctYear&&y.jsx("span",{children:"✓"}),i&&I===t&&I!==g.correctYear&&y.jsx("span",{children:"✗"})]},I)})}),y.jsx("div",{style:{flex:1}}),i?y.jsxs("div",{style:{background:x?"#f0faf5":"#fef8f0",border:`1px solid ${x?"#c8e6d0":"#ffe0b2"}`,borderRadius:16,padding:"18px 20px",marginBottom:12},children:[y.jsx("p",{style:{fontWeight:700,fontSize:17,color:x?"#2a7d4f":"#c0392b",margin:"0 0 8px",display:"flex",alignItems:"center",gap:6},children:x?"✓ Correct!":`✗ The answer was ${g.correctYear}`}),y.jsx("p",{style:{color:"#555",fontSize:16,lineHeight:1.6,margin:0},children:g.factoid})]}):y.jsx("button",{onClick:O,disabled:t===null,style:{width:"100%",background:t===null?"#e0e0e0":"#ff9417",color:t===null?"#999":"#fff",border:"none",borderRadius:100,padding:"15px 20px",fontSize:18,fontWeight:700,cursor:t===null?"default":"pointer",transition:"all 0.15s",boxShadow:t!==null?"0 2px 8px rgba(255,148,23,0.3)":"none"},children:"Submit"}),i&&y.jsx("button",{onClick:A,style:{width:"100%",background:"#18d4e8",color:"#fff",border:"none",borderRadius:100,padding:"15px 20px",fontSize:18,fontWeight:700,cursor:"pointer",boxShadow:"0 2px 8px rgba(24,212,232,0.3)",transition:"transform 0.15s"},onMouseOver:I=>I.currentTarget.style.transform="translateY(-1px)",onMouseOut:I=>I.currentTarget.style.transform="none",children:s+1>=ht?"See your score →":"Next question →"})]})})}const Xh={crossword:"Crossword",embedded:"Embedded Game",unity:"Unity Game",external:"External Game",other:"Game"},Dd=()=>{const{slug:s}=zr(),{data:e,isLoading:t,error:n}=$r(s),[i,r]=Y.useState(!1),o=(e==null?void 0:e.is_paygated)&&e.paygate_mode==="members_only";return Y.useEffect(()=>{if(!e)return;const a=e.summary||"",c=`https://brain-docs-preview.lovable.app/brain-games/${s}`;document.title=`${e.title} | Brain Games | The Brain Docs`;const l=[],u=(h,p)=>{let f=document.querySelector(h);f?p.content&&(f.content=p.content):(f=document.createElement("meta"),Object.entries(p).forEac
223h(([d,m])=>{d==="content"?f.content=m:f.setAttribute(d,m)}),document.head.appendChild(f)),l.push(f)};return u('meta[name="description"]',{name:"description",content:a}),u('link[rel="canonical"]',{rel:"canonical",content:c}),u('meta[property="og:title"]',{property:"og:title",content:`${e.title} | Brain Games | The Brain Docs`}),u('meta[property="og:description"]',{property:"og:description",content:a}),u('meta[property="og:url"]',{property:"og:url",content:c}),e.thumbnail_url&&u('meta[property="og:image"]',{property:"og:image",content:e.thumbnail_url}),u('meta[property="og:type"]',{property:"og:type",content:"website"}),()=>{l.forEach(h=>{document.head.contains(h)&&document.head.removeChild(h)})}},[e,s]),t?y.jsx(Jn,{children:y.jsxs("div",{className:"container-wide section-spacing",children:[y.jsx(ln,{className:"h-8 w-32 mb-4"}),y.jsx(ln,{className:"h-12 w-2/3 mb-4"}),y.jsx(ln,{className:"h-6 w-1/2 mb-8"}),y.jsx(ln,{className:"aspect-video rounded-xl"})]})}):n||!e?y.jsx(Jn,{children:y.jsxs("div",{className:"container-wide section-spacing text-center",children:[y.jsx(ts,{className:"w-16 h-16 text-muted-foreground mx-auto mb-4"}),y.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:"Game Not Found"}),y.jsx("p",{className:"text-muted-foreground mb-6",children:"The game you're looking for doesn't exist or has been removed."}),y.jsx(fn,{asChild:!0,children:y.jsxs(Kn,{to:"/brain-games",children:[y.jsx(ei,{className:"w-4 h-4 mr-2"}),"Back to Brain Games"]})})]})}):y.jsxs(Jn,{children:[y.jsx("section",{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-secondary/5 py-12 md:py-16",children:y.jsxs("div",{className:"container-wide",children:[y.jsxs(Kn,{to:"/brain-games",className:"inline-flex items-center gap-2 text-muted-foreground hover:text-primary transition-colors mb-6",children:[y.jsx(ei,{className:"w-4 h-4"}),"Back to Brain Games"]}),y.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[y.jsxs(es,{variant:"secondary",className:"gap-1",children:[y.jsx(ts,{className:"w-3 h-3"}),Xh[e.type]]}),e.is_paygated&&y.jsxs(es,{className:"badge-premium gap-1",children:[y.jsx(ti,{className:"w-3 h-3"}),e.paygate_mode==="demo_available"?"Demo Available":"Members Only"]}),!e.is_paygated&&y.jsx(es,{className:"badge-free",children:"Free"})]}),y.jsx("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-foreground mb-4",children:e.title}),e.summary&&y.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl",children:e.summary})]})}),y.jsx("section",{className:"section-spacing",children:y.jsx("div",{className:"container-narrow",children:o?y.jsxs("div",{className:"text-center py-16 bg-card rounded-xl border border-border",children:[y.jsx(ti,{className:"w-16 h-16 text-muted-foreground mx-auto mb-4"}),y.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:e.paygate_headline||"Premium Content"}),y.jsx("p",{className:"text-muted-foreground mb-6 max-w-md mx-auto",children:e.paygate_copy||"This game is available exclusively for premium members."}),y.jsx(fn,{size:"lg",className:"bg-gradient-to-r from-primary to-primary/80",asChild:!0,children:y.jsx("a",{href:e.paygate_cta_url||"/premium",children:e.paygate_cta_text||"Unlock Access"})})]}):y.jsxs(y.Fragment,{children:[(e.slug==="breezy-breathing"||e.slug==="breathing-sailboat")&&y.jsx("div",{className:"mb-12",children:y.jsx($h,{})}),e.slug==="alzheimers-timeline-quiz"&&y.jsx("div",{className:"mb-12",children:y.jsx(Hh,{})}),e.embed_url&&y.jsx("div",{className:"mb-12",children:y.jsx(Xr,{embedUrl:e.embed_url,title:e.title,aspectRatio:"16:9",allowFullscreen:!0})}),e.external_url&&!e.embed_url&&y.jsxs("div",{className:"mb-12 text-center py-12 bg-card rounded-xl border border-border",children:[y.jsx(ts,{className:"w-12 h-12 text-primary mx-auto mb-4"}),y.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Play on External Site"}),y.jsx(fn,{size:"lg",asChild:!0,children:y.jsxs("a",{href:e.external_url,target:"_blank",rel:"noopener noreferrer",children:[y.jsx(Ur,{className:"w-4 h-4 mr-2"}),"Open Game"]})})]}),e.body_copy&&y.jsx("div",{className:"prose prose-width",children:y.jsx("div",{dangerouslySetInnerHTML:{__html:Zr(e.body_copy)}})}),e.linked_episode&&y.jsxs("div",{className:"mt-12 p-6 bg-card rounded-xl border border-border",children:[y.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Related Podcast Episode"}),y.jsx(Kn,{to:`/your-brain-on/${e.linked_episode.slug}`,className:"text-lg font-semibold text-foreground hover:text-primary transition-colors",children:e.linked_episode.title})]})]})})}),y.jsx(Gr,{isOpen:i,onClose:()=>r(!1),headline:e.paygate_headline,copy:e.paygate_copy,ctaText:e.paygate_cta_text,ctaUrl:e.paygate_cta_url})]})};export{Dd as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.