@opendaw/studio-core 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/AudioDevices.js +4 -4
  2. package/dist/AudioOfflineRenderer.d.ts +8 -0
  3. package/dist/AudioOfflineRenderer.d.ts.map +1 -0
  4. package/dist/AudioOfflineRenderer.js +88 -0
  5. package/dist/AudioWorklets.d.ts +1 -1
  6. package/dist/AudioWorklets.d.ts.map +1 -1
  7. package/dist/AudioWorklets.js +3 -2
  8. package/dist/FilePickerAcceptTypes.d.ts +8 -0
  9. package/dist/FilePickerAcceptTypes.d.ts.map +1 -0
  10. package/dist/FilePickerAcceptTypes.js +27 -0
  11. package/dist/WorkerAgents.d.ts +1 -1
  12. package/dist/WorkerAgents.d.ts.map +1 -1
  13. package/dist/WorkerAgents.js +3 -3
  14. package/dist/capture/CaptureAudio.d.ts.map +1 -1
  15. package/dist/capture/CaptureAudio.js +9 -4
  16. package/dist/capture/CaptureMidi.d.ts.map +1 -1
  17. package/dist/capture/CaptureMidi.js +5 -4
  18. package/dist/capture/Recording.d.ts.map +1 -1
  19. package/dist/capture/Recording.js +3 -3
  20. package/dist/index.d.ts +15 -8
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +15 -8
  23. package/dist/midi/MIDILearning.d.ts +26 -0
  24. package/dist/midi/MIDILearning.d.ts.map +1 -0
  25. package/dist/midi/MIDILearning.js +88 -0
  26. package/dist/midi/MIDIMessageSubscriber.d.ts +5 -0
  27. package/dist/midi/MIDIMessageSubscriber.d.ts.map +1 -0
  28. package/dist/midi/MIDIMessageSubscriber.js +40 -0
  29. package/dist/{MidiDevices.d.ts → midi/MidiDevices.d.ts} +2 -1
  30. package/dist/midi/MidiDevices.d.ts.map +1 -0
  31. package/dist/{MidiDevices.js → midi/MidiDevices.js} +16 -4
  32. package/dist/processors.js +3 -3
  33. package/dist/processors.js.map +4 -4
  34. package/dist/project/Project.d.ts +8 -1
  35. package/dist/project/Project.d.ts.map +1 -1
  36. package/dist/project/Project.js +14 -3
  37. package/dist/project/ProjectBundle.d.ts +1 -1
  38. package/dist/project/ProjectBundle.d.ts.map +1 -1
  39. package/dist/project/ProjectBundle.js +9 -11
  40. package/dist/project/ProjectEnv.d.ts +0 -7
  41. package/dist/project/ProjectEnv.d.ts.map +1 -1
  42. package/dist/project/ProjectProfile.js +3 -3
  43. package/dist/samples/OpenSampleAPI.d.ts +14 -0
  44. package/dist/samples/OpenSampleAPI.d.ts.map +1 -0
  45. package/dist/samples/OpenSampleAPI.js +109 -0
  46. package/dist/samples/SampleAPI.d.ts +10 -0
  47. package/dist/samples/SampleAPI.d.ts.map +1 -0
  48. package/dist/samples/SampleAPI.js +1 -0
  49. package/dist/samples/SampleImporter.d.ts +11 -0
  50. package/dist/samples/SampleImporter.d.ts.map +1 -0
  51. package/dist/samples/SampleImporter.js +1 -0
  52. package/dist/workers.js +2 -2
  53. package/dist/workers.js.map +4 -4
  54. package/package.json +14 -14
  55. package/dist/MidiDevices.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
- var ni=i=>i,D=i=>i!=null,pr=i=>i==null,Yo=(i,e)=>i!=null?e(i):void 0,U=(i,e="asDefined failed")=>i??y(e),de=(i,e)=>i instanceof e,Qt=(i,e)=>i instanceof e?i:y(`${i} is not instance of ${e}`),Xo=(i,e)=>{i instanceof e||y(`${i} is not instance of ${e}`)};var mr=i=>i instanceof Function?i():i;var g=(i,...e)=>i?.apply(null,e);var it=i=>{throw new Error(`Unhandled ${i}`)},y=i=>{throw typeof i=="string"?new Error(i):i},b=(i,e)=>i?void 0:y(mr(e));var Zo=i=>new Proxy({},{get(){return y(i)}});var Yt=i=>{try{return{error:null,value:i(),status:"success"}}catch(e){return{error:e,value:null,status:"failure"}}};var Cn=(i,e)=>Object.keys(e).length===0?y("Empty enum object (are you using `const enum`?)"):Object.keys(e).filter(s=>isNaN(Number(s))).map(s=>e[s]).includes(i)?i:y(`Invalid enum value: ${String(i)}`),Xt=()=>{};var Rn=i=>{};var Jo;(function(i){i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(Jo||(Jo={}));var A=class{static#e=Object.freeze(new Array(0));static empty=()=>this.#e;static clear=e=>{e.length=0};static replace=(e,t)=>{e.length=0,e.push(...t)};static consume=(e,t)=>{for(let r=0;r<e.length;)t(e[r])?e.splice(r,1):r++};static peekFirst=e=>e.at(0)??null;static peekLast=e=>e.at(-1)??null;static getFirst=(e,t)=>U(e.at(0),t);static getLast=(e,t)=>U(e.at(-1),t);static getPrev=(e,t)=>{let r=e.indexOf(t);return r===-1?y(`${t} not found in ${e}`):U(e.at((r-1)%e.length),"Internal Error")};static getNext=(e,t)=>{let r=e.indexOf(t);return r===-1?y(`${t} not found in ${e}`):U(e.at((r+1)%e.length),"Internal Error")};static removeLast=(e,t)=>U(e.pop(),t);static create=(e,t)=>{let r=new Array(t);for(let s=0;s<t;s++)r[s]=e(s);return r};static equals=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};static satisfy=(e,t)=>{if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++)if(!t(r,e[s]))return!1;return!0};static remove=(e,t)=>{let r=e.indexOf(t);if(r===-1)return y(`${t} not found in ${e}`);e.splice(r,1)};static removeOpt=(e,t)=>{let r=e.indexOf(t);return r===-1?!1:(e.splice(r,1),!0)};static hasDuplicates=e=>new Set(e).size<e.length;static removeDuplicates=e=>{let t=0,r=new Set;for(let s of e)r.has(s)||(r.add(s),e[t++]=s);return e.length=t,e};static removeDuplicateKeys=(e,t)=>{let r=0,s=new Set;for(let o of e){let n=o[t];s.has(n)||(s.add(n),e[r++]=o)}return e.length=r,e};static*iterate(e){for(let t=0;t<e.length;t++)yield e[t]}static*iterateReverse(e){for(let t=e.length-1;t>=0;t--)yield e[t]}static*iterateStateFull(e){let t=e.length-1;for(let r=0;r<=t;r++)yield{value:e[r],isFirst:r===0,isLast:r===t}}static isSorted(e,t=Jo.Ascending){if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++){let o=e[s];if(Math.sign(r-o)===t)return!1;r=o}return!0}};var m;(function(i){i.wrap=t=>D(t)?new e(t):i.None,i.from=t=>i.wrap(t()),i.tryFrom=t=>{try{return i.wrap(t())}catch{return i.None}},i.execute=(t,...r)=>i.wrap(t?.apply(null,r)),i.async=t=>t.then(r=>i.wrap(r),()=>i.None);class e{#e;constructor(r){this.#e=U(r)}unwrap(){return this.#e}unwrapOrElse(r){return this.#e}unwrapOrNull(){return this.#e}unwrapOrUndefined(){return this.#e}contains(r){return r===this.#e}match(r){return r.some(this.#e)}ifSome(r){return r(this.#e)}isEmpty(){return!1}nonEmpty(){return!0}map(r){return i.wrap(r(this.#e))}mapOr(r,s){return r(this.#e)}flatMap(r){return r(this.#e)}equals(r){return this.unwrapOrNull()===r.unwrapOrNull()}assert(r){return this}toString(){return`{Option.Some(${this.#e})}`}get[Symbol.toStringTag](){return this.toString()}}i.Some=e,i.None=new class{unwrap=t=>y(D(t)?mr(t):"unwrap failed");unwrapOrElse=t=>mr(t);unwrapOrNull=()=>null;unwrapOrUndefined=()=>{};contains=t=>!1;match=t=>t.none();ifSome=t=>{};isEmpty=()=>!0;nonEmpty=()=>!1;map=t=>i.None;mapOr=(t,r)=>mr(r);flatMap=t=>i.None;equals=t=>t.isEmpty();assert=t=>y(mr(t)??"assert failed");toString=()=>"{Option.None}";get[Symbol.toStringTag](){return this.toString()}}})(m||(m={}));var Mn;(function(i){i.async=e=>e.then(t=>i.ok(t),t=>i.err(t)),i.tryGet=e=>{try{return i.ok(e())}catch(t){return i.err(t)}},i.ok=e=>new class{value;constructor(t){this.value=t}asOption=()=>m.wrap(this.value);failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>this.value;map=t=>{try{return i.ok(t(this.value))}catch(r){return i.err(r)}};flatMap=t=>t(this.value);match=t=>t.ok(this.value);toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>`{Success: ${this.value}`;get[Symbol.toStringTag](){return"Success"}}(e),i.Ok=new class{constructor(){}asOption=()=>m.None;failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>{};map=e=>i.ok(e());flatMap=e=>e();match=e=>e.ok();toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>"{Success: Ok";get[Symbol.toStringTag](){return"Success"}},i.err=e=>new class{reason;constructor(t){this.reason=t}asOption=()=>m.None;failureReason=()=>this.reason;isFailure=()=>!0;isSuccess=()=>!1;result=()=>{throw new Error(`No result because '${this.reason}'`)};map=()=>this;flatMap=()=>this;match=t=>t.err(this.reason);toVoid=()=>i.err(this.reason);failure=()=>this;toString=()=>`{Failure: ${this.reason}`;get[Symbol.toStringTag](){return"Failure"}}(e)})(Mn||(Mn={}));var ie;(function(i){i.exact=(e,t,r)=>{let s=0,o=e.length-1;for(;s<=o;){let n=s+o>>>1,a=r(e[n],t);if(a===0)return n;a<0?s=n+1:o=n-1}return-1},i.exactMapped=(e,t,r,s)=>{let o=0,n=e.length-1;for(;o<=n;){let a=o+n>>>1,u=r(s(e[a]),t);if(u===0)return a;u<0?o=a+1:n=a-1}return-1},i.leftMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<0?s=n+1:o=n}return s},i.rightMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<=0?s=n+1:o=n}return o-1},i.leftMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<0?o=a+1:n=a}return o},i.rightMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<=0?o=a+1:n=a}return n-1},i.rangeMapped=(e,t,r,s)=>[i.leftMostMapped(e,t,r,s),i.rightMostMapped(e,t,r,s)]})(ie||(ie={}));var ye=class{static every=(e,t)=>(e&t)===t;static some=(e,t)=>(e&t)>0;#e;#t;constructor(e=32){this.#e=e,this.#t=new Int32Array((e-1>>>5)+1)}getBit(e){let t=e>>>5,r=1<<e-(t<<5);return(this.#t[t]&r)!==0}setBit(e,t){let r=e>>>5,s=1<<e-(r<<5),o=this.#t[r],n=t?o|s:o&~s;return n===o?!1:(this.#t[r]=n,!0)}isEmpty(){return this.#t.every(e=>e===0)}nonEmpty(){return this.#t.some(e=>e>0)}set buffer(e){this.#t.set(new Int32Array(e))}get buffer(){return this.#t.buffer}replace(e){let t=new Int32Array(e),r=!1;for(let s=0;s<t.length;s++)this.#t[s]!==t[s]&&(this.#t[s]=t[s],r=!0);return r}toString(){let e="";for(let t of A.iterateReverse(this.#t))e+=t.toString(2).padStart(32,"0");return e.substring(e.length-this.#e)}clear(){this.#t.fill(0)}};var Si=class{#e;#t=null;constructor(e){this.#e=e}invalidate=()=>this.#t=null;get(){return this.#t===null&&(this.#t=this.#e()),this.#t}terminate(){this.invalidate()}};var Ci;(function(i){i.parseCssRgbOrRgba=e=>{let t=e.match(/\(([^)]+)\)/)?.at(1)?.split(",")?.map(Number);if(D(t)&&t.every(r=>!isNaN(r))){if(t.length===3)return[t[0]/255,t[1]/255,t[2]/255,1];if(t.length===4)return[t[0]/255,t[1]/255,t[2]/255,t[3]]}throw new Error(`${e} is not proper formatted. Example: 'rgb(255, 255, 255)' or 'rgba(255, 255, 255, 1)'`)},i.hslToHex=(e,t,r)=>{let s=u=>(u+e/30)%12,o=t*Math.min(r,1-r),n=u=>r-o*Math.max(-1,Math.min(s(u)-3,Math.min(9-s(u),1))),a=u=>Math.round(u*255).toString(16).padStart(2,"0");return`#${a(n(0))}${a(n(8))}${a(n(4))}`},i.hexToHsl=e=>{let t=e.startsWith("#")?e.slice(1):e,r=parseInt(t.slice(0,2),16)/255,s=parseInt(t.slice(2,4),16)/255,o=parseInt(t.slice(4,6),16)/255,n=Math.max(r,s,o),a=Math.min(r,s,o),u=(n+a)/2,h=0,d=0;if(n!==a){let p=n-a;switch(d=u>.5?p/(2-n-a):p/(n+a),n){case r:h=((s-o)/p+(s<o?6:0))*60;break;case s:h=((o-r)/p+2)*60;break;case o:h=((r-s)/p+4)*60;break}}return{h,s:d,l:u}},i.hslStringToHex=e=>{let[t,r,s]=e.match(/\d+(\.\d+)?/g).map(Number);return i.hslToHex(t,r/100,s/100)}})(Ci||(Ci={}));var yt=(i,e)=>i-e,Tn=(i,e)=>{let t=Math.min(i.length,e.length);for(let r=0;r<t;r++){let s=i[r]-e[r];if(s!==0)return s}return i.length-e.length};var qe=Math.PI*2,ml=Math.PI/2,en=Math.PI/4,fl=1/Math.sqrt(2),L=(i,e,t)=>Math.max(e,Math.min(i,t));var Vn=(i,e)=>e+(1-2*e)*Math.max(0,Math.min(i,1)),st=(i,e)=>Math.floor(i/e)*e;var Dn=(i,e,t)=>i+(e-i)*t;var ai=(i,e)=>qa(i/e)*e,qa=i=>i-Math.floor(i),ot=i=>Math.pow(2,Math.ceil(Math.log(i)/Math.log(2)));var tn=(i,e)=>i*e/((2*e-1)*(i-1)+e);var Oe;(function(i){i.valueAt=({slope:s,steps:o,y0:n,y1:a},u)=>i.normalizedAt(u/o,s)*(a-n)+n,i.normalizedAt=(s,o)=>{if(o>.499999&&o<.500001)return s;{let n=L(o,1e-15,.999999999999999);return n*n/(1-n*2)*(Math.pow((1-n)/n,2*s)-1)}},i.inverseAt=(s,o)=>{let n=L(o,1e-15,.999999999999999);return Math.log(s*(1-2*n)/(n*n)+1)/(2*Math.log((1-n)/n))},i.coefficients=s=>{let o=i.valueAt(s,1),a=(i.valueAt(s,2)-o)/(o-s.y0),u=o-a*s.y0;return{m:a,q:u}};function*t(s,o,n,a){let{m:u,q:h}=i.coefficients({slope:s,steps:o,y0:n,y1:a});for(let d=0,p=n;d<o;d++)yield p=u*p+h}i.walk=t;function*r(s,o){let n=1/o,a=i.normalizedAt(n,s),h=(i.normalizedAt(2*n,s)-a)/a;for(let d=0,p=0;d<o;d++)yield p=h*p+a}i.walkNormalized=r,i.byHalf=(s,o,n,a)=>({slope:i.slopeByHalf(o,n,a),steps:s,y0:o,y1:a}),i.slopeByHalf=(s,o,n)=>Math.abs(n-s)<1e-6?.5:(o-s)/(n-s)})(Oe||(Oe={}));var We=new DataView(new ArrayBuffer(8)),Ie;(function(i){i.MIN_VALUE=-2147483648,i.MAX_VALUE=2147483647,i.toByte=e=>(We.setInt8(0,e),We.getInt8(0)),i.toShort=e=>(We.setInt16(0,e),We.getInt16(0)),i.toInt=e=>(We.setInt32(0,e),We.getInt32(0))})(Ie||(Ie={}));var nt;(function(i){let r=new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(r),o=new Int32Array(r);i.floatToIntBits=n=>{let a=i.floatToRawIntBits(n);return(a&2139095040)===2139095040&&(a&8388607)!==0?2143289344:a},i.intBitsToFloat=n=>(o[0]=n,s[0]),i.floatToRawIntBits=n=>(s[0]=n,o[0]),i.toFloat32=n=>(We.setFloat32(0,n),We.getFloat32(0))})(nt||(nt={}));var vt;(function(i){i.floatToIntBits=e=>{let t=nt.floatToIntBits(e),r=t>>>16&32768,s=(t&2147483647)+4096;return s>=1199570944?(t&2147483647)>=1199570944?s<2139095040?r|31744:r|31744|(t&8388607)>>>13:r|31743:s>=947912704?r|s-939524096>>>13:s<855638016?r:(s=(t&2147483647)>>>23,r|(t&8388607|8388608)+(8388608>>>s-102)>>>126-s)},i.intBitsToFloat=e=>{let t=e&1023,r=e&31744;if(r===31744)r=261120;else if(r!==0){if(r+=114688,t===0&&r>115712)return nt.intBitsToFloat((e&32768)<<16|r<<13|1023)}else if(t!==0){r=115712;do t<<=1,r-=1024;while((t&1024)===0);t&=1023}return nt.intBitsToFloat((e&32768)<<16|(r|t)<<13)}})(vt||(vt={}));var Ri;(function(i){let e=9218868437227405312n,t=4503599627370495n,r=new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT),s=new Float64Array(r),o=new BigInt64Array(r);i.float64ToLongBits=n=>{let a=i.float64ToRawLongBits(n);return(a&e)===e&&(a&t)!==0n?0x7ff8000000000000n:a},i.longBitsToFloat64=n=>(o[0]=n,s[0]),i.float64ToRawLongBits=n=>(s[0]=n,o[0]),i.clamp=n=>(We.setFloat64(0,n),We.getFloat64(0))})(Ri||(Ri={}));var se=class{static*empty(){}static one(e){return[e]}static count(e){let t=0;for(let r of e)t++;return t}static some(e,t){for(let r of e)if(t(r))return!0;return!1}static every(e,t){for(let r of e)if(!t(r))return!1;return!0}static reduce(e,t,r){let s=r,o=0;for(let n of e)s=t(s,n,o++);return s}static includes(e,t){for(let r of e)if(r===t)return!0;return!1}static forEach(e,t){for(let r of e)t(r)}static*map(e,t){let r=0;for(let s of e)yield t(s,r++)}static*take(e,t){let r=0;for(let s of e){if(r++>=t)return;yield s}}static filter(e,t){let r=[];for(let s of e)t(s)&&r.push(s);return r}static filterMap(e,t){let r=[];for(let s of e){let o=t(s);D(o)&&r.push(o)}return r}static reverse(e){let t=[];for(let r of e)t.push(r);return t.reverse()}static*pairWise(e){let t=e[Symbol.iterator](),{done:r,value:s}=t.next(),o=s;if(r!==!0)for(;;){let{done:n,value:a}=t.next();if(n===!0){yield[o,null];return}yield[o,a],o=a}}};var ue=class i{static create(e=1024){return this.use(new ArrayBuffer(e))}static use(e,t=0){return new i(new DataView(e,t))}littleEndian=!1;#e;#t=0;constructor(e){this.#e=e}get remaining(){return this.#e.byteLength-this.#t}get position(){return this.#t}set position(e){e<0?y(`position(${e}) cannot be negative.`):e>this.#e.byteLength?y(`position(${e}) is outside range (${this.#e.byteLength}).`):this.#t=e}writeBoolean(e){this.writeByte(e?1:0)}writeByte(e){this.#r(1),this.#e.setInt8(this.#t++,e)}writeShort(e){this.#r(Int16Array.BYTES_PER_ELEMENT),this.#e.setInt16(this.#t,e,this.littleEndian),this.#t+=Int16Array.BYTES_PER_ELEMENT}writeInt(e){this.#r(Int32Array.BYTES_PER_ELEMENT),this.#e.setInt32(this.#t,e,this.littleEndian),this.#t+=Int32Array.BYTES_PER_ELEMENT}writeLong(e){this.#r(BigInt64Array.BYTES_PER_ELEMENT),this.#e.setBigInt64(this.#t,e,this.littleEndian),this.#t+=BigInt64Array.BYTES_PER_ELEMENT}writeFloat(e){this.#r(Float32Array.BYTES_PER_ELEMENT),this.#e.setFloat32(this.#t,e,this.littleEndian),this.#t+=Float32Array.BYTES_PER_ELEMENT}writeDouble(e){this.#r(Float64Array.BYTES_PER_ELEMENT),this.#e.setFloat64(this.#t,e,this.littleEndian),this.#t+=Float64Array.BYTES_PER_ELEMENT}writeBytes(e){this.#r(e.length);for(let t=0;t<e.length;++t)this.#e.setInt8(this.#t++,e[t])}writeString(e){let t=e.length;this.#r(Int32Array.BYTES_PER_ELEMENT+t*Int16Array.BYTES_PER_ELEMENT),this.writeInt(t);for(let r=0;r<t;r++)this.writeShort(e.charCodeAt(r))}toArrayBuffer(){return this.#e.buffer.slice(0,this.#t)}#r(e){let t=this.#e.byteLength;if(this.#t+e>t){let r=this.#e;this.#e=new DataView(new ArrayBuffer(ot(t+e)));for(let s=0;s<this.#t;s++)this.#e.setInt8(s,r.getInt8(s))}}},fr=class{#e=0;writeByte(e){this.#e++}writeShort(e){this.#e+=2}writeInt(e){this.#e+=4}writeLong(e){this.#e+=8}writeFloat(e){this.#e+=4}writeDouble(e){this.#e+=8}writeBoolean(e){this.#e++}writeBytes(e){this.#e+=e.length}writeString(e){this.#e+=e.length+4}get count(){return this.#e}},Mi=class{#e;#t=0;constructor(e=32){this.#e=new Int8Array(e)}result(){return this.#e}equals(e){return e===this?!0:this.#e.every((t,r)=>e.#e[r]===t)}writeBoolean(e){this.writeByte(e?31:11)}writeShort(e){this.writeByte(e&255),this.writeByte(e>>>8&255)}writeByte(e){this.#t>=this.#e.length&&(this.#t=0),this.#e[this.#t++]^=e}writeInt(e){this.writeByte(e&255),this.writeByte(e>>>8&255),this.writeByte(e>>>16&255),this.writeByte(e>>>24&255)}writeBytes(e){e.forEach(t=>this.writeByte(t))}writeFloat(e){this.writeInt(nt.floatToIntBits(e))}writeDouble(e){this.writeLong(Ri.float64ToLongBits(e))}writeLong(e){this.writeByte(Number(e)&255),this.writeByte(Number(e>>8n)&255),this.writeByte(Number(e>>16n)&255),this.writeByte(Number(e>>24n)&255),this.writeByte(Number(e>>32n)&255),this.writeByte(Number(e>>40n)&255),this.writeByte(Number(e>>48n)&255),this.writeByte(Number(e>>56n)&255)}writeString(e){for(let t=0;t<e.length;t++)this.writeShort(e.charCodeAt(t))}toHexString(){return Array.from(se.map(this.#e.values(),e=>(e&255).toString(16).padStart(2,"0"))).join("")}},ge=class{littleEndian=!1;#e;#t=0;constructor(e,t=0){this.#e=new DataView(e,t)}get position(){return this.#t}set position(e){e<0?y(`position(${e}) cannot be negative.`):e>this.#e.byteLength?y(`position(${e}) is outside range (${this.#e.byteLength}).`):this.#t=e}readByte(){return this.#e.getInt8(this.#t++)}readShort(){let e=this.#e.getInt16(this.#t,this.littleEndian);return this.#t+=Int16Array.BYTES_PER_ELEMENT,e}readInt(){let e=this.#e.getInt32(this.#t,this.littleEndian);return this.#t+=Int32Array.BYTES_PER_ELEMENT,e}readLong(){let e=this.#e.getBigInt64(this.#t,this.littleEndian);return this.#t+=BigInt64Array.BYTES_PER_ELEMENT,e}readFloat(){let e=this.#e.getFloat32(this.#t,this.littleEndian);return this.#t+=Float32Array.BYTES_PER_ELEMENT,e}readDouble(){let e=this.#e.getFloat64(this.#t,this.littleEndian);return this.#t+=Float64Array.BYTES_PER_ELEMENT,e}readBoolean(){return this.readByte()===1}readBytes(e){for(let t=0;t<e.length;t++)e[t]=this.readByte()}readString(){let e=this.readInt(),t="";for(let r=0;r<e;r++)t+=String.fromCharCode(this.readShort());return t}available(e){return this.#t+e<=this.#e.byteLength}remaining(){return this.#e.byteLength-this.#t}skip(e){this.position+=e}};var za=i=>D(i)?i.value!==void 0?"value":i.get!==void 0?"get":y(`Cannot resolve method key of ${i}`):y("Cannot resolve method key of undefined descriptor"),gr=(i,e,t)=>{if(!D(t))return function(o,n){if(n&&n.kind==="getter")return function(){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this),e);if(!D(a?.get))return y(`Cannot find getter for property '${e}'`);let u=a.get.apply(this);return Object.defineProperty(this,e,{value:u,configurable:!1,writable:!1,enumerable:!1}),u}};let r=za(t),s=U(t[r]);return{[r]:function(...o){if(o.length>0)return y("lazy accessory must not have any construction parameters");let n=s.apply(this);return Object.defineProperty(this,e,{value:r==="get"?n:()=>n,configurable:!1,writable:!1,enumerable:!1}),n}}};var at;(function(i){function*e(){}i.empty=e,i.next=r=>{let{value:s,done:o}=r.next();return o?null:s};function*t(...r){for(let s of r)for(let o of s)yield o}i.flatten=t})(at||(at={}));var xr;(function(i){i[i.T=0]="T",i[i.R=1]="R",i[i.B=2]="B",i[i.L=3]="L"})(xr||(xr={}));var yr;(function(i){i[i.TL=0]="TL",i[i.TR=1]="TR",i[i.BR=2]="BR",i[i.BL=3]="BL"})(yr||(yr={}));var In;(function(i){i.outerTangentPoints=(e,t)=>{let r=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,r)+Math.acos((e.r-t.r)/Math.sqrt(r*r+s*s)),n=Math.cos(o),a=Math.sin(o);return[{x:e.x+e.r*n,y:e.y+e.r*a},{x:t.x+t.r*n,y:t.y+t.r*a}]}})(In||(In={}));var On;(function(i){i.zero=()=>({x:0,y:0}),i.create=(e,t)=>({x:e,y:t}),i.clone=e=>({...e}),i.floor=e=>({x:Math.floor(e.x),y:Math.floor(e.y)}),i.length=e=>Math.sqrt(e.x*e.x+e.y*e.y),i.distance=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),i.add=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),i.subtract=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),i.scaleBy=(e,t)=>({x:e.x*t,y:e.y*t}),i.scaleTo=(e,t)=>{let r=t/i.length(e);return{x:e.x*r,y:e.y*r}},i.fromClient=e=>({x:e.clientX,y:e.clientY})})(On||(On={}));var li;(function(i){i.Empty=Object.freeze({x:0,y:0,width:0,height:0}),i.corners=e=>{let t=e.x,r=e.y,s=t+e.width,o=r+e.height;return[{x:t,y:r},{x:s,y:r},{x:s,y:o},{x:t,y:o}]},i.inflate=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}),i.contains=(e,t)=>{let r=t.x>=e.x&&t.y>=e.y,s=t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;return r&&s},i.isPointInside=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,i.intersect=(e,t)=>{let r=Math.max(e.x,t.x),s=Math.min(e.x+e.width,t.x+t.width),o=Math.min(e.y+e.height,t.y+t.height),n=Math.max(e.y,t.y);return s>r&&o>n},i.axis=(e,t)=>{switch(t){case xr.T:return e.y;case xr.R:return e.x+e.width;case xr.B:return e.y+e.height;case xr.L:return e.x;default:return it(t)}},i.corner=(e,t)=>{switch(t){case yr.TL:return{x:e.x,y:e.y};case yr.TR:return{x:e.x+e.width,y:e.y};case yr.BR:return{x:e.x+e.width,y:e.y+e.height};case yr.BL:return{x:e.x,y:e.y+e.height};default:return it(t)}},i.center=e=>({x:e.x+e.width*.5,y:e.y+e.height*.5}),i.isEmpty=e=>e.width===0||e.height===0,i.union=(e,t)=>{if(i.isEmpty(e))i.isEmpty(t)||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height);else if(!i.isEmpty(t)){let r=t.x,s=t.y,o=Math.min(e.x,r),n=Math.min(e.y,s);e.width=Math.max(e.x+e.width,r+t.width)-o,e.height=Math.max(e.y+e.height,s+t.height)-n,e.x=o,e.y=n}}})(li||(li={}));var kn;(function(i){i.width=e=>e.xMax-e.xMin,i.height=e=>e.yMax-e.yMin,i.from=(e,t)=>{e.xMin=t.xMin,e.xMax=t.xMax,e.yMin=t.yMin,e.yMax=t.yMax},i.extend=(e,t)=>{e.xMin-=t,e.yMin-=t,e.xMax+=t,e.yMax+=t},i.padding=(e,[t,r,s,o])=>(e.xMin+=o,e.yMin+=t,e.xMax-=r,e.yMax-=s,e),i.intersectPoint=(e,t)=>e.xMin<=t.x&&t.x<e.xMax&&e.yMin<=t.y&&t.y<e.yMax,i.intersectThat=(e,t)=>t.xMin<e.xMax&&t.xMax>e.xMin&&t.yMin<e.yMax&&t.yMax>e.yMin,i.center=e=>({x:(e.xMin+e.xMax)*.5,y:(e.yMin+e.yMax)*.5})})(kn||(kn={}));var Un;(function(i){i.Identity=Object.freeze([0,0,0,0])})(Un||(Un={}));var Kn;(function(i){i.intersects=(r,s,o,n,a,u,h,d)=>{let p=e(r,s,o,n,a,u),f=e(r,s,o,n,h,d);if((p|f)===0||(p&f)!==0)return!1;let w=t(a,u,h,d,r,o);return w!==t(a,u,h,d,s,o)||w!==t(a,u,h,d,s,n)||w!==t(a,u,h,d,r,n)};let e=(r,s,o,n,a,u)=>{let h=0;return a<=r?h|=1:a>=s&&(h|=2),u<=o?h|=8:u>=n&&(h|=4),h},t=(r,s,o,n,a,u)=>(o-r)*(u-s)-(a-r)*(n-s)>=0})(Kn||(Kn={}));var Ln;(function(i){i.Identity={valueToAxis:e=>e,axisToValue:e=>e},i.toClamped=(e,t,r)=>({valueToAxis:s=>e.valueToAxis(L(s,t,r)),axisToValue:s=>L(e.axisToValue(s),t,r)}),i.createClamped=(e,t)=>({valueToAxis:r=>L(r,e,t),axisToValue:r=>L(r,e,t)})})(Ln||(Ln={}));var $n;(function(i){i.fromBuffers=async(...e)=>{let t=e.reduce((o,n)=>o+n.byteLength,0),r=new Uint8Array(t),s=0;for(let o of e)r.set(new Uint8Array(o),s),s+=o.byteLength;return await crypto.subtle.digest("SHA-256",r)},i.equals=(e,t)=>{b(e.byteLength===32,"First hash has invalid length"),b(t.byteLength===32,"Second hash has invalid length");let r=new Uint8Array(e),s=new Uint8Array(t);for(let o=0;o<32;o++)if(r[o]!==s[o])return!1;return!0},i.toString=e=>Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")})($n||($n={}));var ui;(function(i){i.intersect1D=(e,t,r,s)=>Math.max(e,r)<=Math.min(t,s)})(ui||(ui={}));var ve=class{#e=new Set;#t;constructor(){this.#t=new Proxy({},{get:(e,t)=>(...r)=>this.#e.forEach(s=>Object.getPrototypeOf(s)===Object.getPrototypeOf({})?g(s[t],...r):s[t]?.apply(s,r))})}get proxy(){return this.#t}get size(){return this.#e.size}subscribe(e){return this.#e.add(e),{terminate:()=>this.#e.delete(e)}}forEach(e){this.#e.forEach(e)}terminate(){this.#e.clear()}};var lt=class{static createIfAbsent(e,t,r){let s=e.get(t);return s===void 0&&(s=r(t),e.set(t,s)),s}};var hi=class i{static#e=Object.freeze(new Set);static empty=()=>i.#e};var Zt=class i{#e;#t;constructor(e,t){this.#e=new Map(e),this.#t=m.wrap(t),this.#t.ifSome(r=>Array.from(this.#e.values()).forEach(s=>s.sort(r)))}[Symbol.iterator](){return this.#e.entries()}clear(){this.#e.clear()}containsEntry(e,t){return se.some(this.#e.entries(),r=>e===r[0]&&r[1].includes(t))}containsKey(e){return se.includes(this.#e.keys(),e)}containsValue(e){return se.some(this.#e.values(),t=>t.includes(e))}get(e){return this.#e.get(e)??A.empty()}isEmpty(){return this.keyCount()===0}add(e,t){let r=lt.createIfAbsent(this.#e,e,()=>[]);if(this.#t.isEmpty())r.push(t);else{let s=ie.leftMost(r,t,this.#t.unwrap());r.splice(s,0,t)}}addAll(e,t){let r=lt.createIfAbsent(this.#e,e,()=>[]);r.push(...t),this.#t.nonEmpty()&&r.sort(this.#t.unwrap())}remove(e,t){let r=this.#e.get(e);if(r===void 0)return!1;{let s=r.indexOf(t);return s===-1?!1:(r.splice(s,1),r.length===0&&this.#e.delete(e),!0)}}removeFromKeyIf(e,t){let r=this.#e.get(e);if(r===void 0)return null;{let s=r.findIndex(t);if(s===-1)return null;{let o=r.splice(s,1)[0];return r.length===0&&this.#e.delete(e),o}}}removeValueIf(e){let t=[];for(let[r,s]of this.#e.entries())for(let o of s.filter(n=>e(n)))t.push([r,o]);for(let[r,s]of t)this.remove(r,s);return new Set(t.map(([,r])=>r))}removeKey(e){let t=this.#e.get(e);return this.#e.delete(e),t??A.empty()}forEach(e){se.forEach(this.#e.entries(),t=>e(t[0],t[1]))}keyCount(){return this.#e.size}keys(){return this.#e.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.#e.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.#e.forEach((t,r)=>{e.#e.set(r,t.map(s=>s))}),e}},Ti=class i{map;constructor(e){this.map=new Map(e?.map(t=>{let r=t[0],s=t[1];return[r,new Set(s)]}))}clear(){this.map.clear()}containsEntry(e,t){return se.some(this.map.entries(),r=>e===r[0]&&r[1].has(t))}containsKey(e){return se.includes(this.map.keys(),e)}containsValue(e){return se.some(this.map.values(),t=>t.has(e))}get(e){return this.map.get(e)??hi.empty()}isEmpty(){return this.keyCount()===0}add(e,t){lt.createIfAbsent(this.map,e,()=>new Set).add(t)}addAll(e,t){let r=lt.createIfAbsent(this.map,e,()=>new Set);for(let s of t)r.add(s)}remove(e,t){let r=this.map.get(e);return r===void 0?!1:r.delete(t)?(r.size===0&&this.map.delete(e),!0):!1}removeValueIf(e){let t=new Set;for(let[r,s]of this.map.entries()){for(let o of s)e(o)&&(s.delete(o),t.add(o));s.size===0&&this.map.delete(r)}return t}removeFromKeyIf(e,t){let r=this.map.get(e);if(r===void 0)return null;for(let s of r)if(t(s))return r.delete(s),r.size===0&&this.map.delete(e),s;return null}removeKey(e){let t=this.map.get(e);return this.map.delete(e),t??hi.empty()}forEach(e){se.forEach(this.map.entries(),t=>e(t[0],t[1]))}keyCount(){return this.map.size}keys(){return this.map.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.map.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.map.forEach((t,r)=>{e.map.set(r,new Set(Array.from(t)))}),e}};var O=Object.freeze({Empty:{terminate:Xt},create:i=>({terminate:i}),many:(...i)=>({terminate:()=>{for(;i.length>0;)i.pop().terminate()}})}),V=class i{#e=[];own(e){return this.#e.push(e),e}ownAll(...e){for(let t of e)this.#e.push(t)}spawn(){let e=new i;return e.own({terminate:()=>A.removeOpt(this.#e,e)}),this.own(e)}terminate(){for(;this.#e.length>0;)this.#e.pop().terminate()}};var $=class{static subscribeMany(e,...t){return O.many(...t.map(r=>r.subscribe(()=>e(r))))}#e=new Set;subscribe(e){return this.#e.add(e),{terminate:()=>this.#e.delete(e)}}isEmpty(){return this.#e.size===0}notify(e){this.#e.forEach(t=>t(e))}observers(){return this.#e}terminate(){this.#e.clear()}};var bt;(function(i){i.mergeNoOverlap=(e,t)=>{let r=new Set(Object.keys(e));for(let s of Object.keys(t))if(r.has(s))return y(`'${s}' is an overlapping key`);return{...e,...t}},i.include=(e,...t)=>t.reduce((r,s)=>(r[s]=e[s],r),{}),i.exclude=(e,...t)=>{let r=new Set(t);return Object.entries(e).reduce((s,[o,n])=>(r.has(o)||(s[o]=n),s),{})},i.overwrite=(e,t)=>Object.assign(e,t)})(bt||(bt={}));var qn;(function(i){i.make=e=>new class{getValue(){return e}subscribe(t){return O.Empty}catchupAndSubscribe(t){return t(this),O.Empty}}})(qn||(qn={}));var zn;(function(i){i.False=new class{getValue(){return!1}setValue(e){}subscribe(e){return O.Empty}catchupAndSubscribe(e){return e(this),O.Empty}},i.inverseBoolean=e=>new class{getValue(){return!e.getValue()}setValue(t){e.setValue(!t)}subscribe(t){return e.subscribe(t)}catchupAndSubscribe(t){return t(this),this.subscribe(t)}}})(zn||(zn={}));var Pe=class{#e;#t=m.None;#r;constructor(e,t){this.#e=new $,this.#r=t?.guard(e)??e,this.#t=m.wrap(t)}setValue(e){this.#t.nonEmpty()&&(e=this.#t.unwrap().guard(e)),this.#r!==e&&(this.#r=e,this.#e.notify(this))}getValue(){return this.#r}subscribe(e){return this.#e.subscribe(e)}catchupAndSubscribe(e){return e(this),this.#e.subscribe(e)}terminate(){this.#e.terminate()}toString(){return`{DefaultObservableValue value: ${this.#r}`}};var rn=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=t-e}x(e){return(this.clamp(e)-this.#e)/this.#r}y(e){return this.#e+L(e,0,1)*this.#r}clamp(e){return L(e,this.#e,this.#t)}floating(){return!0}},sn=class{#e;#t;#r;constructor(e,t){this.#e=L(Math.round(e),Ie.MIN_VALUE,Ie.MAX_VALUE),this.#t=L(Math.round(t),Ie.MIN_VALUE,Ie.MAX_VALUE),this.#r=this.#t-this.#e}x(e){return(this.clamp(e)-this.#e)/this.#r}y(e){return this.#e+Math.round(L(e,0,1)*this.#r)}clamp(e){return L(Math.round(e),this.#e,this.#t)}floating(){return!1}},on=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=Math.log(t/e)}x(e){return Math.log(L(e,this.#e,this.#t)/this.#e)/this.#r}y(e){return this.#e*Math.exp(L(e,0,1)*this.#r)}clamp(e){return Math.min(this.#t,Math.max(this.#e,e))}floating(){return!0}},nn=class{#e;constructor(e){this.#e=e}x(e){let t=this.#e.findIndex(r=>r===e);return t===-1?y(`Could not find index for ${e}`):t/(this.#e.length-1)}y(e){let t=Math.round(L(e,0,1)*(this.#e.length-1));return t>-1?U(this.#e.at(t),`Could not find value for ${e}`):y(`Index ${t} is out of box.`)}clamp(e){return e}floating(){return!1}},an=class{#e;#t;#r;#i;#s;constructor(e,t,r){this.#e=e,this.#t=r;let s=e*e,o=r*r,n=t*t,a=e+r-2*t,u=r-t;this.#r=((2*r-t)*e-t*r)/a,this.#i=(u*s+(n-o)*e+t*o-n*r)/(s+(2*r-4*t)*e+o-4*t*r+4*n),this.#s=-u/a}y(e){return e<=0?Number.NEGATIVE_INFINITY:e>=1?this.#t:this.#r-this.#i/(e+this.#s)}x(e){return this.#e>=e?0:this.#t<=e?1:-this.#i/(e-this.#r)-this.#s}clamp(e){return Math.min(this.#t,e)}floating(){return!0}},R;(function(i){i.linear=(o,n)=>new rn(o,n),i.linearInteger=(o,n)=>new sn(o,n),i.exponential=(o,n)=>new on(o,n),i.values=o=>new nn(o),i.decibel=(o,n,a)=>new an(o,n,a);let e=new class{x(o){return o?1:0}y(o){return o>=.5}clamp(o){return o}floating(){return!1}},t=i.linear(0,1),r=i.linear(-1,1);i.bool=e;let s=i.decibel(-72,-12,0);i.unipolar=()=>t,i.bipolar=()=>r,i.DefaultDecibel=s})(R||(R={}));var C;(function(i){i.percent=({bipolar:o,fractionDigits:n}={})=>new e("%",n,!1,o),i.numeric=({unit:o,fractionDigits:n,unitPrefix:a,bipolar:u}={})=>new e(o,n,a,u),i.indices=(o,n)=>new class{x(a){return{unit:o,value:n[a]}}y(a){let u=n.indexOf(a);return u===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:u}}},i.values=(o,n,a)=>new class{x(u){return{unit:o,value:a.at(n.indexOf(u))??"N/A"}}y(u){let h=a.indexOf(u);return h===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:n[h]}}},i.bool=new class{y(o){switch(o.trim()){case"on":case"yes":case"true":return{type:"explicit",value:!0};default:return{type:"explicit",value:!1}}}x(o){return{value:String(o),unit:""}}};class e{#e;#t;#r;#i;constructor(n,a,u,h){this.#e=n??"",this.#t=a??0,this.#r=u??!1,this.#i=h??!1}y(n){let a=n.trim(),u=parseFloat(a);if(isNaN(u))return{type:"unknown",value:a};if(this.#e==="%")return{type:"explicit",value:u/100};if(a.endsWith("%"))return{type:"unitValue",value:this.#i?L(u/200+.5,0,1):L(u/100,0,1)};{a.endsWith(this.#e)&&this.#e.length>0&&(a=a.slice(0,-this.#e.length));let p=/(\d+)(\D+)/.exec(a)?.at(2)?.at(0);if(D(p)){let f=t.indexOf(p);if(f>-1)return{type:"explicit",value:u*Math.pow(10,(f-4)*3)}}return{type:"explicit",value:u}}}x(n){if(Number.isNaN(n))return{value:"\u{1F4A3}",unit:this.#e};if(Number.isFinite(n)){if(this.#e==="%")return this.#i?{value:(n*200-100).toFixed(this.#t),unit:this.#e}:{value:(n*100).toFixed(this.#t),unit:this.#e};if(this.#r){let{value:a,prefix:u}=s(n);return{value:a.toFixed(this.#t),unit:`${u}${this.#e}`}}else return{value:n.toFixed(this.#t),unit:this.#e}}else return{value:n===Number.POSITIVE_INFINITY?"\u221E":"-\u221E",unit:this.#e}}}let t=Object.freeze(["p","n","\u03BC","m","","k","M","G","T"]),r=o=>Math.log(o)/Math.log(9.999999999999998),s=o=>{let n=Math.floor(r(o)/3),a=t[n+4];return D(a)?{value:o*Math.pow(10,n*-3),prefix:a}:{value:o,prefix:""}};i.decible=i.numeric({unit:"db",fractionDigits:1}),i.panning=i.percent({unit:"%",fractionDigits:0})})(C||(C={}));var Vi;(function(i){i.alwaysTrue=()=>!0,i.alwaysFalse=()=>!1,i.definedPredicate=e=>e!=null})(Vi||(Vi={}));var _n;(function(i){i.Empty=Object.freeze(e=>{}),i.split=(e,t)=>{let r=new Float32Array(t);return A.create(s=>o=>{r[s]=o,e(r.reduce((n,a)=>n+a,0)/t)},t)}})(_n||(_n={}));var Di;(function(i){i.create=(e=252854082)=>new ln(e),i.monotoneAscending=(e,t=128,r=i.create())=>{let s=e.length;if(s<2)return y("Array must have at least 2 elements");let o=0;for(let a=1;a<s;a++){let u=Math.floor(r.uniform()*(1+t))+1;e[a]=u,o+=u}let n=0;e[0]=0;for(let a=1;a<s;a++)n+=e[a],e[a]=n/o;return e}})(Di||(Di={}));var ln=class{#e=0;constructor(e){this.setSeed(e)}setSeed(e){this.#e=e&4294967295}nextDouble(e,t){return e+this.uniform()*(t-e)}nextInt(e,t){return e+Math.floor(this.uniform()*(t-e))}nextElement(e){return e[Math.floor(this.uniform()*e.length)]}nextBoolean(){return this.uniform()<.5}uniform(){let e=this.#e+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}};var Se;(function(i){class e{}i.createBuilder=r=>{let s=o=>{let n=o instanceof Array?[]:{};return Object.entries(o).forEach(([a,u])=>{u instanceof e?n[a]=u.initialValue():typeof u=="object"&&(n[a]=s(u))}),n};return()=>new t(r,Object.seal(s(r)))},i.bool=new class extends e{read(r){return r.readByte()===1}write(r,s){r.writeByte(s?1:0)}initialValue(){return!1}},i.int8=new class extends e{read(r){return r.readByte()}write(r,s){r.writeByte(s)}initialValue(){return 0}},i.int16=new class extends e{read(r){return r.readShort()}write(r,s){r.writeShort(s)}initialValue(){return 0}},i.int32=new class extends e{read(r){return r.readInt()}write(r,s){r.writeInt(s)}initialValue(){return 0}},i.float=new class extends e{read(r){return r.readFloat()}write(r,s){r.writeFloat(s)}initialValue(){return 0}},i.double=new class extends e{read(r){return r.readDouble()}write(r,s){r.writeDouble(s)}initialValue(){return 0}},i.int64=new class extends e{read(r){return r.readLong()}write(r,s){r.writeLong(s)}initialValue(){return 0n}},i.floats=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readFloat();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeFloat(o[n])}initialValue(){return new Float32Array(r)}},i.doubles=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readDouble();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeDouble(o[n])}initialValue(){return new Float64Array(r)}};class t{#e;#t;#r;constructor(s,o){this.#e=s,this.#t=o,this.#r=this.#i()}get object(){return this.#t}get bytesTotal(){return this.#r}read(s){let o=(n,a)=>{Object.entries(n).forEach(([u,h])=>{let d=a;h instanceof e?d[u]=h.read(s,d[u]):typeof h=="object"&&o(h,d[u])})};o(this.#e,this.#t)}write(s){let o=(n,a)=>{Object.entries(n).forEach(([u,h])=>{let d=a;h instanceof e?h.write(s,d[u]):typeof h=="object"&&o(h,d[u])})};o(this.#e,this.#t)}#i(){let s=new fr;return this.write(s),s.count}}})(Se||(Se={}));var wt=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=[]}add(e,t=!1){let r=this.#e(e),s=ie.leftMostMapped(this.#r,r,this.#t,this.#e),o=this.#r[s];return D(o)&&this.#t(this.#e(o),r)===0?t?(this.#r.splice(s,1,e),!0):!1:(this.#r.splice(s,0,e),!0)}getOrCreate(e,t){let r=ie.leftMostMapped(this.#r,e,this.#t,this.#e),s=this.#r[r];if(D(s)&&this.#t(this.#e(s),e)===0)return s;let o=t(e);return this.#r.splice(r,0,o),o}addMany(e){for(let t of e)this.#r.push(t);try{return this.#r.sort((t,r)=>{let s=this.#t(this.#e(t),this.#e(r));if(s===0)throw"cancel";return s}),!0}catch(t){if(t==="cancel"){let r=new Map(this.entries());return this.#r.splice(0,this.#r.length,...r.values()),this.#r.sort((s,o)=>this.#t(this.#e(s),this.#e(o))),!1}return y(t)}}removeByValue(e){return this.removeByKey(this.#e(e))}removeByKey(e){let t=ie.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return D(r)&&this.#t(this.#e(r),e)===0?(this.#r.splice(t,1),r):y(`Could not remove ${e}`)}removeByKeyIfExist(e){let t=ie.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return D(r)&&this.#t(this.#e(r),e)===0?(this.#r.splice(t,1),r):null}removeRange(e,t){this.#r.splice(e,(t??this.#r.length)-e)}removeByPredicate(e){let t=0,r=this.#r.length;for(;--r>=0;)e(this.#r[r])&&(this.#r.splice(r,1),t++);return t}get(e){return U(this.#i(e),`Unknown key: ${e}`)}getOrThrow(e,t){let r=this.#i(e);if(D(r))return r;throw t()}opt(e){return m.wrap(this.#i(e))}getOrNull(e){return this.#i(e)??null}getByIndex(e){return this.#r[e]}hasKey(e){return D(this.#i(e))}hasValue(e){return D(this.#i(this.#e(e)))}size(){return this.#r.length}isEmpty(){return this.#r.length===0}forEach(e){this.values().forEach(e)}values(){return this.#r}entries(){return this.#r.map(e=>[this.#e(e),e])}clear(){A.clear(this.#r)}[Symbol.iterator](){return this.#r.values()}#i(e){let t=ie.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return D(r)&&this.#t(this.#e(r),e)===0?r:void 0}};var Hn;(function(i){i.hyphenToCamelCase=e=>e.replace(/-([a-z])/g,t=>t[1].toUpperCase()),i.fallback=(e,t)=>D(e)&&e.length>0?e:t,i.endsWithDigit=e=>/\d$/.test(e),i.nonEmpty=(e,t)=>D(e)&&e.trim().length>0?e:t,i.toArrayBuffer=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return t},i.getUniqueName=(e,t)=>{let r=new Set(e),s=t,o=1;if(r.has(t)||r.has(`${t} 1`))o=2;else return t;for(;r.has(s=`${t} ${o++}`););return s}})(Hn||(Hn={}));var Jt=class i{static POSITIVE_INFINITY=new i(Number.POSITIVE_INFINITY);static millis=e=>new i(e);static seconds=e=>new i(e*i.#e);static minutes=e=>new i(e*i.#t);static hours=e=>new i(e*i.#r);static days=e=>new i(e*i.#i);static#e=1e3;static#t=6e4;static#r=36e5;static#i=864e5;#s;constructor(e){this.#s=e}millis(){return this.#s}absSeconds(){return Math.abs(this.#s)/i.#e}absMinutes(){return Math.abs(this.#s)/i.#t}absHours(){return Math.abs(this.#s)/i.#r}absDays(){return Math.abs(this.#s)/i.#i}split(){return{d:Math.floor(this.absDays()),h:Math.floor(this.absHours())%24,m:Math.floor(this.absMinutes())%60,s:Math.floor(this.absSeconds())%60}}isNow(){return this.#s===0}isPast(){return this.#s<0}isFuture(){return this.#s>0}toUnitString(){let e,t,r=Math.floor(Math.abs(this.#s)/1e3),s=Math.floor(r/60),o=Math.floor(s/60),n=Math.floor(o/24);return r<60?(e=r,t="second"):s<60?(e=s,t="minute"):o<24?(e=o,t="hour"):(e=n,t="day"),new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"long"}).format(e*Math.sign(this.#s),t)}toString(){if(isNaN(this.#s))return"NaN";if(!isFinite(this.#s))return"\u221E";let{d:e,h:t,m:r,s}=this.split();return e>0?[i.#o("d",e),i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):t>0?[i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):r>0?[i.#o("m",r),i.#o("s",s)].join(", "):s>0?i.#o("s",s):"now"}static#o=(e,t)=>{switch(e){case"d":return`${t} ${t<2?"day":"days"}`;case"h":return`${t} ${t<2?"hour":"hours"}`;case"m":return`${t} ${t<2?"minute":"minutes"}`;case"s":return`${t} ${t<2?"second":"seconds"}`;default:return it(e)}}};var vr;(function(i){let e;(function(t){t[t.READING=0]="READING",t[t.READ=1]="READ",t[t.WRITING=2]="WRITING",t[t.WRITTEN=3]="WRITTEN"})(e||(e={})),i.writer=(t,r,s)=>{if(t.bytesTotal+1>r.byteLength)return y("Insufficient memory allocated.");let o=new Uint8Array(r),n=ue.use(r,1);return Atomics.store(o,0,e.READ),{tryWrite:()=>Atomics.compareExchange(o,0,e.READ,e.WRITING)===e.WRITING?(s(t.object),n.position=0,t.write(n),Atomics.store(o,0,e.WRITTEN),!0):!1}},i.reader=(t,r)=>{let s=new SharedArrayBuffer(t.bytesTotal+1),o=new Uint8Array(s),n=new ge(s,1);return{buffer:s,tryRead:()=>Atomics.compareExchange(o,0,e.WRITTEN,e.READING)===e.READING?(n.position=0,t.read(n),r(t.object),Atomics.store(o,0,e.READ),!0):!1}}})(vr||(vr={}));var v;(function(i){i.length=16,i.generate=()=>t(crypto.getRandomValues(new Uint8Array(i.length))),i.sha256=async r=>{let s=typeof process<"u"&&process.env?.VITEST==="true";return crypto.subtle.digest("SHA-256",s?new Uint8Array(r.slice(0)):r).then(o=>t(new Uint8Array(o.slice(0,i.length))))},i.validate=r=>i.parse(i.toString(r)),i.fromDataInput=r=>{let s=new Uint8Array(i.length);return r.readBytes(new Int8Array(s.buffer)),s},i.toDataOutput=(r,s)=>r.writeBytes(new Int8Array(s.buffer)),i.toString=r=>{let s=A.create(o=>(o+256).toString(16).substring(1),256);return s[r[0]]+s[r[1]]+s[r[2]]+s[r[3]]+"-"+s[r[4]]+s[r[5]]+"-"+s[r[6]]+s[r[7]]+"-"+s[r[8]]+s[r[9]]+"-"+s[r[10]]+s[r[11]]+s[r[12]]+s[r[13]]+s[r[14]]+s[r[15]]},i.parse=r=>{let s=r.replace(/-/g,"").toLowerCase();if(s.length!==32)return y("Invalid UUID format");let o=new Uint8Array(i.length);for(let n=0,a=0;n<32;n+=2,a++)o[a]=parseInt(s.slice(n,n+2),16);return o},i.Comparator=(r,s)=>{if(r.length!==i.length||s.length!==i.length)return y("Unexpected array length for uuid(v4)");for(let o=0;o<i.length;o++){let n=r[o]-s[o];if(n!==0)return n}return 0},i.equals=(r,s)=>i.Comparator(r,s)===0,i.newSet=r=>new wt(r,i.Comparator),i.Lowest=i.parse("00000000-0000-4000-8000-000000000000"),i.Highest=i.parse("FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"),i.fromInt=r=>{let s=new Uint8Array(i.Lowest),o=new Uint8Array(new Uint32Array([r]).buffer);for(let n=0;n<4;n++)s[n]=o[n];return s};class e{#e;constructor(){this.#e=new Map}getOrCreate(s){return lt.createIfAbsent(this.#e,s,()=>i.generate())}}i.SimpleIdDecoder=e;let t=r=>(b(r.length===i.length,"UUID must be 16 bytes long"),r[6]=r[6]&15|64,r[8]=r[8]&63|128,r)})(v||(v={}));var Gn;(function(i){i.create=o=>D(o)?D(o?.snap)?i.snap(o?.trackLength,o?.snap?.snapLength,Array.isArray(o?.snap?.threshold)?o?.snap.threshold:[o?.snap?.threshold]):i.identity(o?.trackLength):i.identity(),i.snap=(o=e,n=t,a)=>new s(o,n/o,a),i.identity=(o=e)=>new r(o);let e=128,t=24;class r{length;#e=NaN;#t=NaN;#r=1;constructor(n){this.length=n}begin(n){this.#t=this.#e=n}moveBy(n){b(!isNaN(this.#t),()=>"value has never been set"),this.#e+=n/this.length*this.#r,this.#t=L(this.#e,0,1)}ratio(n){this.#r=n}value(){return b(!isNaN(this.#t),()=>"value has never been set"),this.#t}disable(){}enable(){}}class s{#e;#t;#r;#i;#s=NaN;#o=NaN;#n=1;#a=!0;constructor(n,a,u){b(a>0,()=>`margin(${a}) must be greater then 0`),b(A.isSorted(u),()=>"thresholds are not sorted"),b(a<n,()=>`margin(${a}) must be lower then length(${n})`),this.#e=n,this.#t=a,this.#r=u,this.#i=u.map((h,d)=>h+d*this.#t)}begin(n){this.#a&&(this.#s=this.valueToX(n)),this.#o=n}moveBy(n){b(!isNaN(this.#o),()=>"value has never been set"),this.#s+=n/this.#e*this.#n,this.#o=this.#a?this.xToValue(this.#s):L(this.#s,0,1)}ratio(n){this.#n=n}value(){return b(!isNaN(this.#o),()=>"value has never been set"),this.#o}disable(){this.#a&&(this.#a=!1,this.#s=this.xToValue(this.#s))}enable(){this.#a||(this.#a=!0,this.#s=this.valueToX(this.#s))}valueToX(n){let a=ie.rightMost(this.#r,n,yt);if(a<0)return n;{let u=this.#i[a],h=this.#r[a];return n===h?u+this.#t/2:u+this.#t+(n-h)}}xToValue(n){let a=L(n,0,1+this.#t*this.#r.length),u=ie.rightMost(this.#i,a,yt);if(u<0)return a;{let h=this.#i[u],d=this.#r[u];return a>h+this.#t?a-(h+this.#t)+d:d}}get margin(){return this.#t}}})(Gn||(Gn={}));var Ii=Symbol.for("@openDAW/lib-std");globalThis[Ii]?console.debug(`%c${Ii.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Ii]=!0,console.debug(`%c${Ii.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var At=class{a1=0;a2=0;b0=0;b1=0;b2=0;constructor(){this.identity()}identity(){this.setNormalizedCoefficients(1,0,0,1,0,0)}setLowpassParams(e,t){if(e=L(e,0,1),e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1-o)/2,a=n,u=2*n,h=n,d=1+s,p=-2*o,f=1-s;this.setNormalizedCoefficients(a,u,h,d,p,f)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}setHighpassParams(e,t){if(e=L(e,0,1),e===1)this.setNormalizedCoefficients(0,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1+o)/2,a=n,u=-2*n,h=n,d=1+s,p=-2*o,f=1-s;this.setNormalizedCoefficients(a,u,h,d,p,f)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNormalizedCoefficients(e,t,r,s,o,n){let a=1/s;return this.b0=e*a,this.b1=t*a,this.b2=r*a,this.a1=o*a,this.a2=n*a,this}setLowShelfParams(e,t){e=L(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(r*r,0,0,1,0,0);else if(e>0){let s=qe*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),u=2*Math.sqrt(r)*n,h=r+1,d=r-1,p=r*(h-d*a+u),f=2*r*(d-h*a),w=r*(h-d*a-u),N=h+d*a+u,S=-2*(d+h*a),M=h+d*a-u;this.setNormalizedCoefficients(p,f,w,N,S,M)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setHighShelfParams(e,t){e=L(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){let s=qe*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),u=2*Math.sqrt(r)*n,h=r+1,d=r-1,p=r*(h+d*a+u),f=-2*r*(d+h*a),w=r*(h+d*a-u),N=h-d*a+u,S=2*(d-h*a),M=h-d*a-u;this.setNormalizedCoefficients(p,f,w,N,S,M)}else this.setNormalizedCoefficients(r*r,0,0,1,0,0);return this}setPeakingParams(e,t,r){e=L(e,0,1),t=Math.max(0,t);let s=Math.pow(10,r/40);if(e>0&&e<1)if(t>0){let o=qe*e,n=Math.sin(o)/(2*t),a=Math.cos(o),u=1+n*s,h=-2*a,d=1-n*s,p=1+n/s,f=-2*a,w=1-n/s;this.setNormalizedCoefficients(u,h,d,p,f,w)}else this.setNormalizedCoefficients(s*s,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setAllpassParams(e,t){if(e=L(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1-s,a=-2*o,u=1+s,h=1+s,d=-2*o,p=1-s;this.setNormalizedCoefficients(n,a,u,h,d,p)}else this.setNormalizedCoefficients(-1,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNotchParams(e,t){if(e=L(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1,a=-2*o,u=1,h=1+s,d=-2*o,p=1-s;this.setNormalizedCoefficients(n,a,u,h,d,p)}else this.setNormalizedCoefficients(0,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setBandpassParams(e,t){if(e=Math.max(0,e),t=Math.max(0,t),e>0&&e<1){let r=qe*e;if(t>0){let s=Math.sin(r)/(2*t),o=Math.cos(r),n=s,a=0,u=-s,h=1+s,d=-2*o,p=1-s;this.setNormalizedCoefficients(n,a,u,h,d,p)}else this.setNormalizedCoefficients(1,0,0,1,0,0)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}getFrequencyResponse(e,t,r){b(e.length===t.length&&e.length===r.length,"Array lengths do not match");let s=this.b0,o=this.b1,n=this.b2,a=this.a1,u=this.a2;for(let h=0;h<e.length;++h){let d=-Math.PI*2*e[h],p=Math.cos(d),f=Math.sin(d),w=s+((o+n*p)*p-n*f*f),N=(o+n*p)*f+n*f*p,S=1+((a+u*p)*p-u*f*f),M=(a+u*p)*f+u*f*p,k=S*S+M*M,K=(w*S+N*M)/k,q=(N*S-w*M)/k;t[h]=Math.sqrt(K*K+q*q),r[h]=Math.atan2(q,K)}}};var be=class{#e=0;#t=0;#r=0;#i=0;reset(){this.#e=0,this.#t=0,this.#r=0,this.#i=0}process({a1:e,a2:t,b0:r,b1:s,b2:o},n,a,u,h){let d=this.#e,p=this.#t,f=this.#r,w=this.#i;for(let N=u;N<h;N++){let S=n[N],M=a[N]=r*S+s*d+o*p-e*f-t*w+1e-18-1e-18;p=d,d=S,w=f,f=M}this.#e=d,this.#t=p,this.#r=f,this.#i=w}processFrame({a1:e,a2:t,b0:r,b1:s,b2:o},n){let a=r*n+s*this.#e+o*this.#t-e*this.#r-t*this.#i+1e-18-1e-18;return this.#t=this.#e,this.#e=n,this.#i=this.#r,this.#r=a,a}},er=class{#e;order;constructor(e){this.#e=A.create(()=>new be,e),this.order=this.#e.length}reset(){this.#e.forEach(e=>e.reset())}process(e,t,r,s,o){for(let n=0;n<this.order;n++)this.#e[n].process(e,t,r,s,o),t=r}processFrame(e,t){for(let r=0;r<this.order;r++)t=this.#e[r].processFrame(e,t);return t}};var Wn;(function(i){function e(t,r,s={}){let{interval:o=64,scanSteps:n=1024,scanSamples:a=2048,minBPM:u=90,maxBPM:h=180}=s,d=new Float32Array(Math.floor(t.length/o)),p=0,f=0,w=0;for(let H of t){let Y=Math.abs(H);p+=(Y-p)*(Y>p?1/8:1/512),++f===o&&(f=0,d[w++]=p)}if(!d.length)return NaN;let N=(H,Y)=>H[Math.floor(Y)]??0,S=H=>r/(H/60)/o,M=H=>r/(H*o)*60,k=[-32,-16,-8,-4,-2,-1,1,2,4,8,16,32],K=[-.5,-.25,.25,.5],q=H=>{let Y=Math.random()*d.length,ae=N(d,Y),He=0,rt=0;for(let Ge of k){let oi=1/Math.abs(Ge);He+=oi*Math.abs(N(d,Y+Ge*H)-ae),rt+=oi}for(let Ge of K){let oi=Math.abs(Ge);He-=oi*Math.abs(N(d,Y+Ge*H)-ae),rt+=oi}return He/rt},z=H=>{let Y=0;for(let ae=0;ae<a;++ae)Y+=q(H);return Y/a},ee=S(u),he=S(h),ce=(ee-he)/n,_=u,j=1/0;for(let H=he;H<=ee;H+=ce){let Y=M(H),ae=z(H)*(u/Y);ae<j&&(j=ae,_=Y)}return _}i.detect=e})(Wn||(Wn={}));var jn;(function(i){i.Major=[0,2,4,5,7,9,11],i.Minor=[0,2,3,5,7,8,10],i.NoteLabels=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],i.compile=(e,t,r,s)=>A.create(o=>{let n=r+o*2,a=e[n%7]+Math.floor(n/7)*12;return t+a},s),i.toString=e=>i.NoteLabels[e%12]+(Math.floor(e/12)-2)})(jn||(jn={}));var tr;(function(i){i.Comparator=(e,t)=>e.position-t.position,i.PositionExtractor=e=>e.position})(tr||(tr={}));var rr;(function(i){i.complete=e=>e.position+e.duration,i.DescendingComparator=(e,t)=>i.complete(t)-i.complete(e)})(rr||(rr={}));var Te;(function(i){i.globalToLocal=(t,r)=>ai(r-t.position+t.loopOffset,t.loopDuration),i.locateLoop=({position:t,complete:r,loopOffset:s,loopDuration:o},n,a)=>{let u=t-s,h=u+o;if(u>=a||h<=n)return m.None;let d=Math.max(u,n),p=Math.min(h,a);return m.wrap({index:0,rawStart:u,rawEnd:h,regionStart:Math.max(u,t),regionEnd:Math.min(h,r),resultStart:d,resultEnd:p,resultStartValue:u<d?(d-u)/o:0,resultEndValue:h>p?(p-u)/o:1})};function*e({position:t,complete:r,loopOffset:s,loopDuration:o},n,a){let u=t-s,h=Math.max(t,n),d=Math.min(r,a),p=Math.floor((h-u)/o),f=u+p*o;for(;f<d;){let w=f+o,N=Math.max(f,t),S=Math.min(w,r),M=Math.max(f,h),k=Math.min(w,d),K=f<M?(M-f)/o:0,q=w>k?(k-f)/o:1;yield{index:p++,rawStart:f,rawEnd:w,regionStart:N,regionEnd:S,resultStart:M,resultEnd:k,resultStartValue:K,resultEndValue:q},f=w}}i.locateLoops=e})(Te||(Te={}));var Et=class i{static DefaultComparator=(e,t)=>e.position-t.position;static create(e){return new i(e??i.DefaultComparator)}#e;constructor(e){this.#e=new Oi(e)}add(e){this.#e.add(e)}remove(e){return this.#e.remove(e)}contains(e){return this.#e.contains(e)}clear(){this.#e.clear()}optAt(e){return this.#e.optAt(e)}asArray(){return this.#e.asArray()}lowerEqual(e,t){return this.#e.lowerEqual(e,t)}greaterEqual(e,t){return this.#e.greaterEqual(e,t)}floorLastIndex(e){return this.#e.floorLastIndex(e)}ceilFirstIndex(e){return this.#e.ceilFirstIndex(e)}iterateFrom(e,t){return this.#e.isEmpty()?at.empty():this.#e.iterateFrom(e,t)}iterateRange(e,t,r){return this.#e.isEmpty()?at.empty():this.#e.iterate(this.#e.ceilFirstIndex(e),t,r)}length(){return this.#e.length()}isEmpty(){return this.#e.isEmpty()}onIndexingChanged(){this.#e.onIndexingChanged()}},Ft=class i{static Comparator=(e,t)=>e.position-t.position;static create(e){return new i(e)}#e;constructor(e=i.Comparator){this.#e=new Oi(e)}add(e){this.#e.add(e)}remove(e){return this.#e.remove(e)}contains(e){return this.#e.contains(e)}clear(){this.#e.clear()}optAt(e){return this.#e.optAt(e)}asArray(){return this.#e.asArray()}lowerEqual(e,t){return this.#e.lowerEqual(e,t)}greaterEqual(e,t){return this.#e.greaterEqual(e,t)}floorLastIndex(e){return this.#e.floorLastIndex(e)}ceilFirstIndex(e){return this.#e.ceilFirstIndex(e)}iterateFrom(e,t){return this.#e.isEmpty()?at.empty():this.#e.iterateFrom(e,t)}iterateRange(e,t){if(this.#e.isEmpty())return at.empty();let r=Math.max(0,this.#e.floorLastIndex(e)),s=this.#e.optAt(r);if(s===null)return at.empty();for(;s.position+s.duration<=e;)if(s=this.#e.optAt(++r),s===null||s.position>=t)return at.empty();return this.#e.iterate(r,t)}length(){return this.#e.length()}isEmpty(){return this.#e.isEmpty()}onIndexingChanged(){this.#e.onIndexingChanged()}},br=class{#e;constructor(){this.#e=[]}addAndRetain(e){if(this.#e.length===0)this.#e.push(e);else{let t=ie.leftMost(this.#e,e,rr.DescendingComparator);this.#e.splice(t,0,e)}}*overlapping(e,t){let r=this.#e.filter(s=>s.position<=e&&e<s.position+s.duration);yield*D(t)?r.sort(t):r}*releaseLinearCompleted(e){if(this.#e.length!==0)for(let t=this.#e.length-1;t>=0;t--){let r=this.#e[t];if(rr.complete(r)<e)this.#e.splice(t,1),yield r;else return}}*releaseAll(){if(this.#e.length!==0)for(let e=this.#e.length-1;e>=0;e--){let t=this.#e[e];Number.POSITIVE_INFINITY>t.duration&&(this.#e.splice(e,1),yield t)}}isEmpty(){return this.#e.length===0}nonEmpty(){return this.#e.length>0}clear(){A.clear(this.#e)}},Oi=class{comparator;#e=[];#t=!1;modCount=0;constructor(e){this.comparator=e}add(e){++this.modCount,this.#e.push(e),this.#e.length>1&&(this.#t=!0)}remove(e){++this.modCount;let t=this.#e.indexOf(e);return t===-1?!1:(this.#e.splice(t,1),!0)}contains(e){if(this.#e.length===0)return!1;this.#t&&this.#r();let r=e.position,s=ie.leftMostMapped(this.#e,r,yt,tr.PositionExtractor);for(let o=s;o<this.#e.length;o++){let n=this.#e[o];if(n===e)return!0;if(n.position!==r)return!1}return!1}clear(){++this.modCount,A.clear(this.#e),this.#t=!1}optAt(e){return e<0||e>=this.#e.length?null:(this.#t&&this.#r(),this.#e[e])}asArray(){return this.#t&&this.#r(),this.#e}lowerEqual(e,t){if(t===void 0)return this.optAt(this.floorLastIndex(e));let r=this.floorLastIndex(e);for(;r>=0;){let s=this.#e[r--];if(t(s))return s}return null}greaterEqual(e,t){if(t===void 0)return this.optAt(this.ceilFirstIndex(e));let r=this.ceilFirstIndex(e);for(;r<this.#e.length;){let s=this.#e[r++];if(t(s))return s}return null}floorLastIndex(e){return this.#t&&this.#r(),ie.rightMostMapped(this.#e,e,yt,tr.PositionExtractor)}ceilFirstIndex(e){return this.#t&&this.#r(),ie.leftMostMapped(this.#e,e,yt,tr.PositionExtractor)}iterateFrom(e,t){let r=this.floorLastIndex(e),s=r;if(s<0)return this.iterate(0,Ie.MAX_VALUE,t);for(;s>=0;){let o=this.optAt(s);if(o!==null&&t!==void 0&&t(o))return this.iterate(s,Ie.MAX_VALUE,t);s--}return this.iterate(r,Ie.MAX_VALUE,t)}length(){return this.#e.length}isEmpty(){return this.#e.length===0}onIndexingChanged(){this.#t=this.length()>1}*iterate(e,t,r=Vi.alwaysTrue){for(this.#t&&this.#r();e<this.#e.length;){let s=this.#e[e++];if(s.position>=t)return;r(s)&&(yield s)}}#r(){this.#e.sort(this.comparator),this.#t=!1}};var ki=class i{static reverse(e){return e=(e&1431655765)<<1|e>>>1&1431655765,e=(e&858993459)<<2|e>>>2&858993459,e=(e&252645135)<<4|e>>>4&252645135,e=e<<24|(e&65280)<<8|e>>>8&65280|e>>>24,e}#e;#t;#r;#i;constructor(e){this.#e=e;let t=e/2;this.#t=32-Math.floor(Math.log2(e))|0,this.#r=new Float32Array(t),this.#i=new Float32Array(t);for(let r=0;r<t;r++){let s=2*Math.PI*r/e;this.#r[r]=Math.cos(s),this.#i[r]=Math.sin(s)}}process(e,t){let r,s,o,n;for(let h=0;h<this.#e;++h)s=i.reverse(h)>>>this.#t,s>h&&(n=e[h],e[h]=e[s],e[s]=n,n=t[h],t[h]=t[s],t[s]=n);let a=this.#r,u=this.#i;for(let h=2;h<=this.#e;h<<=1){let d=h>>1,p=this.#e/h;for(r=0;r<this.#e;r+=h){let f=r+d;for(s=r,o=0;s<f;s++,o=o+p|0){let w=s+d|0,N=a[o],S=u[o],M=e[w],k=t[w],K=M*N+k*S,q=k*N-M*S,z=e[s],ee=t[s];e[w]=z-K,t[w]=ee-q,e[s]=z+K,t[s]=ee+q}}if(h===this.#e)break}}};var un=(i,e)=>Math.floor(3840/e)*i,Qn=(i,e=4,t=4)=>{let r=un(1,t),s=Math.floor(i/r),o=Math.floor(s/e),a=(Math.floor(i)-un(o*e,t))%r,u=Math.floor(a/240),h=a%240;return{bars:o,beats:s-o*e,semiquavers:u,ticks:h}},Yn=(i,e)=>i*e/60*960,Xn=(i,e)=>i*60/960/e,_a=(i,e,t)=>Yn(i/t,e),Ha=(i,e,t)=>Xn(i,e)*t,G={Bar:3840,Quarter:960,SemiQuaver:240,fromSignature:un,toParts:Qn,secondsToPulses:Yn,pulsesToSeconds:Xn,samplesToPulses:_a,pulsesToSamples:Ha,toString:(i,e=4,t=4)=>{let{bars:r,beats:s,semiquavers:o,ticks:n}=Qn(i|0,e,t);return`${r+1}.${s+1}.${o+1}:${n}`}};var ze;(function(i){i.builder=()=>new e,i.toDouble=([t,r])=>t/r,i.toPPQN=([t,r])=>G.fromSignature(t,r);class e{#e=[];add(r){return this.#e.push(r),this}asArray(){return this.#e}asAscendingArray(){return this.#e.toSorted((r,s)=>i.toDouble(r)-i.toDouble(s))}asDescendingArray(){return this.#e.toSorted((r,s)=>i.toDouble(s)-i.toDouble(r))}}})(ze||(ze={}));var Bt=class{static*iterate(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield o,o=++s*r}static*iterateWithIndex(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield{position:o,index:s},o=++s*r}};var Ui=class{#e;#t;constructor(){this.#e=[],this.#t=new Map}addVertex(e){b(!this.#e.includes(e),"Vertex already exists"),this.#e.push(e),b(!this.#t.has(e),"Predecessor already exists"),this.#t.set(e,[])}removeVertex(e){A.remove(this.#e,e);let t=this.#t.delete(e);b(t,"Predecessor does not exists")}getPredecessors(e){return this.#t.get(e)??A.empty()}predecessors(){return this.#t}vertices(){return this.#e}addEdge([e,t]){let r=U(this.#t.get(t),`[add] Edge has unannounced vertex. (${t})`);b(!r.includes(e),`${e} is already marked.`),r.push(e)}removeEdge([e,t]){let r=U(this.#t.get(t),`[remove] Edge has unannounced vertex. (${t})`);b(r.includes(e),`${e} is not marked.`),A.remove(r,e)}isEmpty(){return this.#e.length===0}},Ki=class{#e;#t;#r;#i;#s;constructor(e){this.#e=e,this.#t=[],this.#r=new Set,this.#i=new Set,this.#s=new Map}update(){this.#o(),this.#e.vertices().forEach(e=>this.#n(e))}sorted(){return this.#t}hasLoops(){return this.#i.size!==0}#o(){this.#a();let e=new Map;for(let r of this.#e.vertices())this.#s.set(r,new Set),e.set(r,new Set);for(let r of this.#e.vertices())for(let s of this.#e.getPredecessors(r))U(this.#s.get(s),`Could not find Successor for ${s}`).add(r);let t;do{t=!1;for(let r of this.#e.vertices()){U(e.get(r)).clear();for(let s of U(this.#s.get(r)))for(let o of U(this.#s.get(s)))this.#s.get(r)?.has(o)||(t=!0,U(e.get(r)).add(o))}for(let r of this.#e.vertices()){let s=U(this.#s.get(r));U(e.get(r)).forEach(o=>s.add(o))}}while(t)}#n(e){if(!this.#r.has(e)){this.#r.add(e);for(let t of this.#e.getPredecessors(e)){if(U(this.#s.get(e)).has(t)){this.#i.add(e),this.#i.add(t);continue}this.#n(t)}this.#t.push(e)}}#a(){A.clear(this.#t),this.#r.clear(),this.#i.clear(),this.#s.clear()}};var ci;(function(i){i.Identity={warp:e=>e,unwarp:e=>e}})(ci||(ci={}));var Li=class{#e;constructor(e){this.#e=e}warp(e){return this.#t(!0,e)}unwarp(e){return this.#t(!1,e)}#t(e,t){let r=this.#e.duration(),s=st(t,r),o=(t-s)/r,n=e?this.#e.fx(o):this.#e.fy(o);return s+n*r}};var Zn;(function(i){i.BlackKeyIndices=[1,3,6,8,10],i.BlackKeyBits=i.BlackKeyIndices.reduce((t,r)=>t|=1<<r,0),i.Names={English:["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],German:["C","Cis","D","Dis","E","F","Fis","G","Gis","A","Ais","H"],Solfege:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],French:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Spanish:["Do","Do#","Re","Re#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Japanese:["\u30C9","\u30C9\u266F","\u30EC","\u30EC\u266F","\u30DF","\u30D5\u30A1","\u30D5\u30A1\u266F","\u30BD","\u30BD\u266F","\u30E9","\u30E9\u266F","\u30B7"]},i.isBlackKey=t=>(i.BlackKeyBits&1<<t%12)!==0,i.toFullString=t=>`${i.Names.English[t%12]}${Math.floor(t/12)-2}`;class e{#e;#t;constructor(r,...s){this.#e=r,this.#t=s.reduce((o,n)=>o|=1<<n,0)}get name(){return this.#e}get bits(){return this.#t}has(r){return(this.#t&1<<r%12)!==0}equals(r){return this.#t===r.bits}}i.StockScales=[new e("Major",0,2,4,5,7,9,11),new e("Natural Minor",0,2,3,5,7,8,10),new e("Harmonic Minor",0,2,3,5,7,8,11),new e("Melodic Minor",0,2,3,5,7,9,11),new e("Dorian",0,2,3,5,7,9,10),new e("Phrygian",0,1,3,5,7,8,10),new e("Lydian",0,2,4,6,7,9,11),new e("Mixolydian",0,2,4,5,7,9,10),new e("Locrian",0,1,3,5,6,8,10),new e("Pentatonic Major",0,2,4,7,9),new e("Pentatonic Minor",0,3,5,7,10),new e("Blues",0,3,5,6,7,10),new e("Whole Tone",0,2,4,6,8,10),new e("Diminished",0,2,3,5,6,8,9,11),new e("Augmented",0,3,4,7,8,11)]})(Zn||(Zn={}));var Ce;(function(i){i.isOfType=e=>e.type==="note-event",i.Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.pitch-t.pitch;return s!==0?s:0},i.curveFunc=(e,t)=>t<0?e**2**-t:1-(1-e)**2**t,i.inverseCurveFunc=(e,t)=>t<0?e**2**t:1-Math.max(0,1-e)**2**-t,i.CompleteComparator=(e,t)=>{let r=rr.complete(e)-rr.complete(t);return r!==0?r:e.pitch-t.pitch}})(Ce||(Ce={}));var ut;(function(i){i[i.sine=0]="sine",i[i.triangle=1]="triangle",i[i.sawtooth=2]="sawtooth",i[i.square=3]="square"})(ut||(ut={}));var $i=class{#e=0;#t=0;generate(e,t,r,s,o){for(let n=s;n<o;n++){let a=this.#e%1,u=0;switch(r){case ut.sine:u=Math.sin(2*Math.PI*a);break;case ut.sawtooth:u=2*a-1,u-=this.#r(a,t);break;case ut.square:u=a<.5?1:-1,u+=this.#r(a,t),u-=this.#r((a+.5)%1,t);break;case ut.triangle:let h=a<.5?1:-1;h+=this.#r(a,t),h-=this.#r((a+.5)%1,t),this.#t+=h*(4*t),u=this.#t;break}e[n]=u,this.#e+=t}}#r(e,t){return e<t?(e/=t,e+e-e*e-1):e>1-t?(e=(e-1)/t,e*e+e+e+1):0}};var ht;(function(i){let e;(function(t){t[t.Linear=0]="Linear",t[t.EqualPower=1]="EqualPower"})(e=i.Mixing||(i.Mixing={})),i.zero=()=>({ll:0,lr:0,rl:0,rr:0}),i.identity=()=>({ll:1,lr:0,rl:0,rr:1}),i.update=(t,{gain:r,panning:s,invertL:o,invertR:n,stereo:a,swap:u},h=e.EqualPower)=>{let[d,p]=i.panningToGains(s,h),f=d*r,w=p*r;o&&(f*=-1),n&&(w*=-1);let N=Math.max(0,-a),S=Math.max(0,a),M=1-S,k=1+S,K=N*.5,q=1-N,z=(M+k)*.5,ee=(M-k)*.5,he=(M-k)*.5,ce=(M+k)*.5,_=f*(K+q)*z+w*K*ee,j=f*(K+q)*he+w*K*ce,H=f*K*z+w*(K+q)*ee,Y=f*K*he+w*(K+q)*ce;u?(t.ll=j,t.rl=_,t.lr=Y,t.rr=H):(t.ll=_,t.lr=H,t.rl=j,t.rr=Y)},i.panningToGains=(t,r)=>{let s=L(t,-1,1);switch(r){case e.Linear:return[Math.min(1-s,1),Math.min(s+1,1)];case e.EqualPower:return[Math.cos((s+1)*en),Math.sin((s+1)*en)]}},i.applyFrame=(t,r,s)=>[t.ll*r+t.rl*s,t.lr*r+t.rr*s],i.processFrames=(t,r,s,o,n)=>{let[a,u]=r,[h,d]=s;for(let p=o;p<n;p++){let f=a[p],w=u[p];h[p]=t.ll*f+t.rl*w,d[p]=t.lr*f+t.rr*w}},i.replaceFrames=(t,[r,s],o,n)=>{for(let a=o;a<n;a++){let u=r[a],h=s[a];r[a]=t.ll*u+t.rl*h,s[a]=t.lr*u+t.rr*h}}})(ht||(ht={}));var _e;(function(i){i.linear=(r,s=.005)=>new e(Math.ceil(r*s)|0),i.stereoMatrix=(r,s=.005)=>new t(Math.ceil(r*s)|0);class e{#e;#t=0;#r=0;#i=0;#s=0;constructor(s){this.#e=s}set(s,o){this.#t!==s&&(o===!0?(this.#r=s,this.#i=(s-this.#t)/this.#e,this.#s=this.#e):(this.#t=this.#r=s,this.#i=0,this.#s=0))}get(){return this.#t}moveAndGet(){return 0<this.#s&&(this.#t+=this.#i,--this.#s===0&&(this.#i=0,this.#t=this.#r)),this.#t}isFixed(s){return this.#t===s&&this.#s===0}isInterpolating(){return this.#s>0}}class t{#e;#t=ht.zero();#r=ht.zero();#i=ht.zero();#s=0;constructor(s){this.#e=s}update(s,o,n){ht.update(this.#r,s,o),n===!0?(this.#i.ll=(this.#r.ll-this.#t.ll)/this.#e,this.#i.lr=(this.#r.lr-this.#t.lr)/this.#e,this.#i.rl=(this.#r.rl-this.#t.rl)/this.#e,this.#i.rr=(this.#r.rr-this.#t.rr)/this.#e,this.#s=this.#e):(this.#t.ll=this.#r.ll,this.#t.lr=this.#r.lr,this.#t.rl=this.#r.rl,this.#t.rr=this.#r.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0)}processFrames(s,o,n,a){let[u,h]=s,[d,p]=o;if(this.isInterpolating())for(let f=n;f<a;f++){let w=u[f],N=h[f],S=this.moveAndGet();d[f]=S.ll*w+S.rl*N,p[f]=S.lr*w+S.rr*N}else{let f=this.#r;for(let w=n;w<a;w++){let N=u[w],S=h[w];d[w]=f.ll*N+f.rl*S,p[w]=f.lr*N+f.rr*S}}}set(s,o){this.#o(s)||(o===!0?(this.#r.ll=s.ll,this.#r.lr=s.lr,this.#r.rl=s.rl,this.#r.rr=s.rr,this.#i.ll=(s.ll-this.#t.ll)/this.#e,this.#i.lr=(s.lr-this.#t.lr)/this.#e,this.#i.rl=(s.rl-this.#t.rl)/this.#e,this.#i.rr=(s.rr-this.#t.rr)/this.#e,this.#s=this.#e):(this.#t.ll=this.#r.ll=s.ll,this.#t.lr=this.#r.lr=s.lr,this.#t.rl=this.#r.rl=s.rl,this.#t.rr=this.#r.rr=s.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0))}get(){return this.#t}moveAndGet(){return 0<this.#s&&(this.#t.ll+=this.#i.ll,this.#t.lr+=this.#i.lr,this.#t.rl+=this.#i.rl,this.#t.rr+=this.#i.rr,--this.#s===0&&(this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#t.ll=this.#r.ll,this.#t.lr=this.#r.lr,this.#t.rl=this.#r.rl,this.#t.rr=this.#r.rr)),this.#t}isFixed(s){return this.#o(s)&&this.#s===0}isInterpolating(){return this.#s>0}#o(s){return this.#t.ll===s.ll&&this.#t.lr===s.lr&&this.#t.rl===s.rl&&this.#t.rr===s.rr}}i.StereoMatrixRamp=t})(_e||(_e={}));var wr=class{#e;#t;#r;#i;constructor(e){this.#e=new Float32Array(e),this.#t=1/e,this.#r=0,this.#i=0}pushPop(e){let t=e*e;return this.#i-=this.#e[this.#r],this.#i+=t,this.#e[this.#r]=t,++this.#r===this.#e.length&&(this.#r=0),this.#i<=0?0:Math.sqrt(this.#i*this.#t)}clear(){this.#e.fill(0),this.#i=0,this.#r=0}};var Ga=Math.log(10)/20,Jn=(i=60,e=440)=>e*Math.pow(2,(i+3)/12-6);var we=i=>Math.exp(i*Ga);var qi=i=>we(20*Math.log10(i));var Nt={None:{type:"none"},Linear:{type:"linear"},Curve:i=>({type:"curve",slope:i})},zi;(function(i){i.Comparator=(s,o)=>{let n=s.position-o.position;if(n!==0)return n;let a=s.index-o.index;return a!==0?a:s===o?0:y(`${s} and ${o} are identical in terms of comparison`)};function*e(s,o,n){if(s.isEmpty())return se.empty();for(let a of s.iterateFrom(o))if(yield a,a.position>=n)return}i.iterateWindow=e,i.nextEvent=(s,o)=>{let n=s.asArray(),a=ie.rightMost(n,o,i.Comparator);return a===-1?null:n[a+1]??null},i.valueAt=(s,o,n)=>{if(s.isEmpty())return n;let a=s.iterateFrom(o),{done:u,value:h}=a.next();if(u)return n;if(h.position<=o){let{done:d,value:p}=a.next();if(d)return h.value;if(o<p.position)return r(h,p,o);if(h.interpolation===Nt.None)return h.value}return h.value};function*t(s,o,n,a){if(s.isEmpty())return;let u=s.iterateFrom(o),{done:h,value:d}=u.next();if(h)return;let p=n/a,f=d;if(f.position>o){for(;o<f.position;)if(yield{position:o,value:f.value},o+=p,o>n)return;f.position<=n&&(yield f)}for(;o<=n;){let{done:w,value:N}=u.next();if(w)break;for(;o<N.position;){if(o>n)return;yield{position:o,value:r(f,N,o)},o+=p}N.position<n&&(f.interpolation===Nt.None&&(yield{position:N.position,value:f.value}),yield N),f=N}for(;o<=n;)yield{position:o,value:f.value},o+=p}i.quantise=t;let r=({value:s,position:o,interpolation:n},a,u)=>n.type==="none"?s:n.type==="linear"?s+(u-o)/(a.position-o)*(a.value-s):n.type==="curve"?Oe.valueAt({slope:n.slope,steps:a.position-o,y0:s,y1:a.value},u-o):y("Unknown interpolation")})(zi||(zi={}));var di;(function(i){let e;(function(t){t[t.Bartlett=0]="Bartlett",t[t.Blackman=1]="Blackman",t[t.BlackmanHarris=2]="BlackmanHarris",t[t.Hamming=3]="Hamming",t[t.Hanning=4]="Hanning"})(e=i.Type||(i.Type={})),i.create=(t,r)=>{let s=new Float32Array(r),o=Math.PI/(r-1);switch(t){case e.Bartlett:{let n=(r>>1)-1,a=0;for(;a<=n;++a)s[a]=2*a/(r-1);for(;a<r;++a)s[a]=2-2*a/(r-1);return s}case e.Blackman:{let n=2*o,a=4*o;for(let u=0;u<r;++u)s[u]=.42323-.49755*Math.cos(n*u)+.07922*Math.cos(a*u);return s}case e.BlackmanHarris:{let n=2*o,a=4*o,u=6*o;for(let h=0;h<r;++h)s[h]=.35875-.48829*Math.cos(n*h)+.14128*Math.cos(a*h)-.01168*Math.cos(u*h);return s}case e.Hamming:{let n=2*o;for(let a=0;a<r;++a)s[a]=.54-.46*Math.cos(n*a);return s}case e.Hanning:{let n=2*o;for(let a=0;a<r;++a)s[a]=.5-.5*Math.cos(n*a);return s}}}})(di||(di={}));var _i=Symbol.for("@openDAW/lib-dsp");globalThis[_i]?console.debug(`%c${_i.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[_i]=!0,console.debug(`%c${_i.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Hi=class extends AudioWorkletProcessor{#e;#t;#r;#i;#s;#o=0;constructor({processorOptions:{sab:e,numberOfChannels:t,rmsWindowInSeconds:r,valueDecay:s}}){super(),this.#e=t,this.#t=new Float32Array(t),this.#r=new Float32Array(t),this.#i=A.create(()=>new wr(sampleRate*r),t);let o=Se.createBuilder({peak:Se.floats(t),rms:Se.floats(t)})();this.#s=vr.writer(o,e,n=>{let a=Math.exp(-(128*this.#o)/(sampleRate*s));for(let u=0;u<t;++u){let h=this.#t[u],d=this.#r[u];n.peak[u]=h,n.rms[u]=Math.sqrt(d),this.#t[u]=h*a,this.#r[u]=d*a}this.#o=0})}process([e]){for(let t=0;t<this.#e;++t){let r=e[t];if(r===void 0)this.#t[t]=0,this.#r[t]=0;else{let s=this.#i[t],o=this.#t[t],n=this.#r[t];for(let a=0;a<128;++a){let u=r[a];o=Math.max(o,Math.abs(u)),n=Math.max(n,s.pushPop(u*u))}this.#t[t]=o,this.#r[t]=n}}return this.#o++,this.#s.tryWrite(),!0}};var Q=class i{static newSet(e){return new wt(e,i.Comparator)}static compose=(e,...t)=>{let r=t.length===0?this.#e:new Int16Array(t);return b(r.every((s,o)=>s===t[o]),`fieldKeys (${r.join(",")}) only allows i16`),new i(e,r)};static decode(e){let t=e.split("/");return b(t.length>0,"Unable to parse Address"),i.compose(v.parse(t[0]),...t.slice(1).map(r=>parseInt(r)))}static reconstruct(e){return this.compose(e[0],...e[1])}static boxRange(e,t,r){let s=e.values(),o=ie.leftMostMapped(s,t,v.Comparator,r),n=s.length;if(o<0||o>=n)return null;for(let a=o;a<n;a++)if(v.Comparator(r(s[a]),t)!==0)return o<a?[o,a]:null;return[o,n]}static Comparator=(e,t)=>{let r=v.Comparator(e.#t,t.#t);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return e.#r.length-t.#r.length};static MinimalComparator=(e,t)=>{let r=v.Comparator(e.#t,t.#t);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return 0};static LengthComparator=(e,t)=>{let r=v.Comparator(e.#t,t.#t);return r!==0?r:t.#r.length-e.#r.length};static#e=new Int16Array(0);#t;#r;constructor(e,t){this.#t=e,this.#r=t}get uuid(){return this.#t}get fieldKeys(){return this.#r}isBox(){return this.#r.length===0}isContent(){return!this.isBox()}equals(e){return i.Comparator(this,e)===0}compareTo(e){return i.Comparator(this,e)}append(e){return new i(this.#t,new Int16Array([...this.#r,e]))}startsWith(e){return v.Comparator(e.#t,this.#t)===0&&e.#r.length<=this.#r.length&&e.#r.every((t,r)=>this.#r[r]===t)}write(e){e.writeBytes(new Int8Array(this.#t.buffer)),e.writeByte(this.#r.length),this.#r.forEach(t=>e.writeShort(t))}moveTo(e){return new i(e,this.#r)}decompose(){return[this.#t,this.#r]}toJSON(){return{uuid:Array.from(this.#t.values()),fields:Array.from(this.#r.values())}}toArrayBuffer(){let e=new Uint8Array(v.length+this.#r.length);return e.set(this.#t,0),e.set(this.#r,v.length),e.buffer}toString(){return[v.toString(this.#t),...this.#r].join("/")}static read(e){let t=v.fromDataInput(e),r=e.readByte();return i.compose(t,...A.create(()=>e.readShort(),r))}},ir;(function(i){i.AddressReader=e=>e.address,i.Comparator=({address:e},{address:t})=>Q.Comparator(e,t),i.equals=(e,t)=>{let[r,s]=ie.rangeMapped(t,e,Q.Comparator,i.AddressReader);return t.slice(r,s+1)},i.startsWith=(e,t)=>{let[r,s]=ie.rangeMapped(t,e,Q.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>o.address.startsWith(e))},i.endsWith=(e,t)=>{let r=ie.leftMostMapped(t,e,Q.LengthComparator,i.AddressReader),s=ie.rightMostMapped(t,e,Q.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>e.startsWith(o.address))}})(ir||(ir={}));var je=class i{static validate(e,t){if(e.address.equals(t.address))return m.wrap(`PointerField cannot point to itself: ${e}`);if(!t.pointerRules.accepts.some(r=>r===e.pointerType)){let r=t.pointerRules.accepts.join(", ");return m.wrap(`${String(e.pointerType)} does not satisfy any of the allowed types (${r}).`)}return m.None}#e;#t;#r;#i=m.None;constructor(e){this.#e=e,this.#t=new ve,this.#r=new ve}subscribeImmediate(e,...t){return this.#s(this.#t,e,t)}subscribeTransactual(e,...t){return this.#s(this.#r,e,t)}catchupAndSubscribeTransactual(e,...t){let r=Q.newSet(s=>s.address);return r.addMany(this.filter(...t)),r.forEach(s=>e.onAdd(s)),this.subscribeTransactual({onAdd:s=>{r.add(s)&&e.onAdd(s)},onRemove:s=>{r.removeByKey(s.address),e.onRemove(s)}},...t)}filter(...e){return e.length===0?this.incoming():se.filter(this.incoming().values(),t=>e.some(r=>r===t.pointerType))}size(){return this.incoming().length}isEmpty(){return this.size()===0}nonEmpty(){return this.size()>0}contains(e){return this.incoming().some(t=>e.address.equals(t.address))}incoming(){return this.#e.graph.edges().incomingEdgesOf(this.#e)}onAdded(e){let t=i.validate(e,this.#e);if(t.nonEmpty())return y(t.unwrap());this.#i.isEmpty()?(this.#i=m.wrap([{type:"add",pointerField:e}]),this.#e.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"add",pointerField:e}),this.#t.proxy.onAdd(e)}onRemoved(e){this.#i.isEmpty()?(this.#i=m.wrap([{type:"remove",pointerField:e}]),this.#e.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"remove",pointerField:e}),this.#t.proxy.onRemove(e)}toString(){return`{Pointers ${this.#e.address}, pointers: ${this.incoming().values().map(e=>e.toString())}}`}#s(e,t,r){return e.subscribe({onAdd:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onAdd(s)},onRemove:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onRemove(s)}})}#o=()=>{if(this.#e.isAttached()){let e=this.#i.unwrap("Callback without ChangeLog");e.forEach(({type:t,pointerField:r})=>{t==="add"?this.#r.proxy.onAdd(r):t==="remove"?this.#r.proxy.onRemove(r):y(`Unknown type: ${t}`)}),e.length=0}this.#i=m.None}};var hn=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},Ar=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},I=class i{static hook(e){return new i(e)}#e;#t;#r;#i;constructor({parent:e,fieldKey:t,fieldName:r,pointerRules:s}){this.#e=e,this.#t=t,this.#r=r,this.#i=s,s.mandatory&&this.graph.edges().watchVertex(this)}accept(e){return g(e.visitField,this)}get box(){return this.#e.box}get graph(){return this.#e.graph}get parent(){return this.#e}get fieldKey(){return this.#t}get fieldName(){return this.#r}get pointerRules(){return this.#i}get pointerHub(){return new je(this)}get address(){return this.#e.address.append(this.#t)}get debugPath(){return`${this.box.name}:${this.box.mapFields(e=>e.fieldName,...this.address.fieldKeys).join("/")}`}isBox(){return!1}isField(){return!0}isAttached(){return this.graph.findBox(this.address.uuid).nonEmpty()}fields(){return se.empty()}getField(e){return y()}optField(e){return m.None}read(e){}write(e){}disconnect(){if(this.pointerHub.isEmpty())return;let e=this.pointerHub.incoming();e.forEach(t=>{t.defer(),(t.mandatory||this.pointerRules.mandatory&&e.length===1)&&t.box.delete()})}toString(){return`{${this.box.constructor.name}:${this.constructor.name} (${this.fieldName}) ${this.address.toString()}`}};hn([gr,Ar("design:type",je),Ar("design:paramtypes",[])],I.prototype,"pointerHub",null);hn([gr,Ar("design:type",Q),Ar("design:paramtypes",[])],I.prototype,"address",null);hn([gr,Ar("design:type",String),Ar("design:paramtypes",[])],I.prototype,"debugPath",null);var c=Object.freeze({mandatory:!1,accepts:[]});var Er=class i extends I{static create(e,t,r){return new i(e,t,r)}#e;constructor(e,t,r){super(e),this.#e=A.create(s=>t({parent:this,fieldKey:s,fieldName:String(s),pointerRules:c}),r)}accept(e){return g(e.visitArrayField,this)}fields(){return this.#e}getField(e){return U(this.#e[e])}optField(e){return m.wrap(this.#e[e])}read(e){this.#e.forEach(t=>t.read(e))}write(e){this.#e.forEach(t=>t.write(e))}size(){return this.#e.length}toJSON(){return this.#e}};var Pt;(function(i){i.writeFields=(t,r)=>{let s=Object.entries(r);t.writeInt(1179403347),t.writeShort(s.length),s.forEach(([o,n])=>{let a=ue.create();n.write(a);let u=new Int8Array(a.toArrayBuffer());t.writeShort(Number(o)),t.writeInt(u.length),t.writeBytes(u)})},i.readFields=(t,r)=>{b(t.readInt()===1179403347,"Serializer header is corrupt");let s=t.readShort();for(let o=0;o<s;o++){let n=t.readShort();if(pr(r[n]))continue;let a=t.readInt(),u=new Int8Array(a);t.readBytes(u);let{status:h,error:d}=Yt(()=>r[n]?.read(new ge(u.buffer)));h==="failure"&&console.warn(d)}}})(Pt||(Pt={}));var Wa=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},ea=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},P=class i{static DEBUG_DELETION=!1;static Index=0;#e;#t;#r;#i;#s;#o=i.Index++;constructor({uuid:e,graph:t,name:r,pointerRules:s}){this.#e=Q.compose(e),this.#t=t,this.#r=r,this.#i=s,this.#s=this.initializeFields(),s.mandatory&&this.graph.edges().watchVertex(this)}fields(){return Object.values(this.#s)}getField(e){return U(this.#s[e])}optField(e){return m.wrap(this.#s[e])}subscribe(e,t){return this.graph.subscribeVertexUpdates(e,this.address,t)}get box(){return this}get name(){return this.#r}get graph(){return this.#t}get parent(){return this}get address(){return this.#e}get pointerRules(){return this.#i}get creationIndex(){return this.#o}get pointerHub(){return new je(this)}estimateMemory(){let e=new fr;return this.write(e),e.count}isBox(){return!0}asBox(e){return Qt(this,e)}isField(){return!1}isAttached(){return this.#t.findBox(this.address.uuid).nonEmpty()}read(e){Pt.readFields(e,this.#s)}write(e){Pt.writeFields(e,this.#s)}serialize(){let e=ue.create();return e.writeInt(this.#o),e.writeString(this.name),e.writeBytes(new Int8Array(this.address.uuid.buffer)),this.write(e),e.toArrayBuffer()}toArrayBuffer(){let e=ue.create();return this.write(e),e.toArrayBuffer()}incomingEdges(){return this.graph.edges().incomingEdgesOf(this)}outgoingEdges(){return this.graph.edges().outgoingEdgesOf(this)}mapFields(e,...t){if(t.length===0)return A.empty();let r=this.getField(t[0]),s=[e(r)];for(let o=1;o<t.length;o++)r=r.getField(t[o]),s.push(e(r));return s}searchVertex(e){if(e.length===0)return m.wrap(this);let t=this.optField(e[0]);if(t.isEmpty())return m.None;for(let r=1;r<e.length;r++)if(t=t.unwrap().optField(e[r]),t.isEmpty())return m.None;return t}delete(){let{boxes:e,pointers:t}=this.graph.dependenciesOf(this);i.DEBUG_DELETION&&(console.debug(`Delete ${this.toString()}`),console.debug(" unplugs",[...t].map(r=>r.toString()).join(`
1
+ var ni=i=>i,D=i=>i!=null,pr=i=>i==null,Mn=i=>i===null,Yo=(i,e)=>i!=null?e(i):void 0,U=(i,e="asDefined failed")=>i??y(e),de=(i,e)=>i instanceof e,Qt=(i,e)=>i instanceof e?i:y(`${i} is not instance of ${e}`),Xo=(i,e)=>{i instanceof e||y(`${i} is not instance of ${e}`)};var mr=i=>i instanceof Function?i():i;var g=(i,...e)=>i?.apply(null,e),Zo=i=>D(i)&&typeof i=="object",Jo=(i,e,t)=>{if(!(e in i))return!1;let r=i[e];return t==="null"?r===null:typeof r===t};var it=i=>{throw new Error(`Unhandled ${i}`)},y=i=>{throw typeof i=="string"?new Error(i):i},v=(i,e)=>i?void 0:y(mr(e));var en=i=>new Proxy({},{get(){return y(i)}});var Yt=i=>{try{return{error:null,value:i(),status:"success"}}catch(e){return{error:e,value:null,status:"failure"}}};var Tn=(i,e)=>Object.keys(e).length===0?y("Empty enum object (are you using `const enum`?)"):Object.keys(e).filter(s=>isNaN(Number(s))).map(s=>e[s]).includes(i)?i:y(`Invalid enum value: ${String(i)}`),Xt=()=>{};var Vn=i=>{};var tn;(function(i){i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(tn||(tn={}));var w=class{static#e=Object.freeze(new Array(0));static empty=()=>this.#e;static clear=e=>{e.length=0};static replace=(e,t)=>{e.length=0,e.push(...t)};static consume=(e,t)=>{for(let r=0;r<e.length;)t(e[r])?e.splice(r,1):r++};static peekFirst=e=>e.at(0)??null;static peekLast=e=>e.at(-1)??null;static getFirst=(e,t)=>U(e.at(0),t);static getLast=(e,t)=>U(e.at(-1),t);static getPrev=(e,t)=>{let r=e.indexOf(t);return r===-1?y(`${t} not found in ${e}`):U(e.at((r-1)%e.length),"Internal Error")};static getNext=(e,t)=>{let r=e.indexOf(t);return r===-1?y(`${t} not found in ${e}`):U(e.at((r+1)%e.length),"Internal Error")};static removeLast=(e,t)=>U(e.pop(),t);static create=(e,t)=>{let r=new Array(t);for(let s=0;s<t;s++)r[s]=e(s);return r};static equals=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};static satisfy=(e,t)=>{if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++)if(!t(r,e[s]))return!1;return!0};static remove=(e,t)=>{let r=e.indexOf(t);if(r===-1)return y(`${t} not found in ${e}`);e.splice(r,1)};static removeOpt=(e,t)=>{let r=e.indexOf(t);return r===-1?!1:(e.splice(r,1),!0)};static hasDuplicates=e=>new Set(e).size<e.length;static removeDuplicates=e=>{let t=0,r=new Set;for(let s of e)r.has(s)||(r.add(s),e[t++]=s);return e.length=t,e};static removeDuplicateKeys=(e,t)=>{let r=0,s=new Set;for(let o of e){let n=o[t];s.has(n)||(s.add(n),e[r++]=o)}return e.length=r,e};static*iterate(e){for(let t=0;t<e.length;t++)yield e[t]}static*iterateReverse(e){for(let t=e.length-1;t>=0;t--)yield e[t]}static*iterateStateFull(e){let t=e.length-1;for(let r=0;r<=t;r++)yield{value:e[r],isFirst:r===0,isLast:r===t}}static isSorted(e,t=tn.Ascending){if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++){let o=e[s];if(Math.sign(r-o)===t)return!1;r=o}return!0}};var m;(function(i){i.wrap=t=>D(t)?new e(t):i.None,i.from=t=>i.wrap(t()),i.tryFrom=t=>{try{return i.wrap(t())}catch{return i.None}},i.execute=(t,...r)=>i.wrap(t?.apply(null,r)),i.async=t=>t.then(r=>i.wrap(r),()=>i.None);class e{#e;constructor(r){this.#e=U(r)}unwrap(){return this.#e}unwrapOrElse(r){return this.#e}unwrapOrNull(){return this.#e}unwrapOrUndefined(){return this.#e}contains(r){return r===this.#e}match(r){return r.some(this.#e)}ifSome(r){return r(this.#e)}isEmpty(){return!1}nonEmpty(){return!0}map(r){return i.wrap(r(this.#e))}mapOr(r,s){return r(this.#e)}flatMap(r){return r(this.#e)}equals(r){return this.unwrapOrNull()===r.unwrapOrNull()}assert(r){return this}toString(){return`{Option.Some(${this.#e})}`}get[Symbol.toStringTag](){return this.toString()}}i.Some=e,i.None=new class{unwrap=t=>y(D(t)?mr(t):"unwrap failed");unwrapOrElse=t=>mr(t);unwrapOrNull=()=>null;unwrapOrUndefined=()=>{};contains=t=>!1;match=t=>t.none();ifSome=t=>{};isEmpty=()=>!0;nonEmpty=()=>!1;map=t=>i.None;mapOr=(t,r)=>mr(r);flatMap=t=>i.None;equals=t=>t.isEmpty();assert=t=>y(mr(t)??"assert failed");toString=()=>"{Option.None}";get[Symbol.toStringTag](){return this.toString()}}})(m||(m={}));var Dn;(function(i){i.async=e=>e.then(t=>i.ok(t),t=>i.err(t)),i.tryGet=e=>{try{return i.ok(e())}catch(t){return i.err(t)}},i.ok=e=>new class{value;constructor(t){this.value=t}asOption=()=>m.wrap(this.value);failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>this.value;map=t=>{try{return i.ok(t(this.value))}catch(r){return i.err(r)}};flatMap=t=>t(this.value);match=t=>t.ok(this.value);toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>`{Success: ${this.value}`;get[Symbol.toStringTag](){return"Success"}}(e),i.Ok=new class{constructor(){}asOption=()=>m.None;failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>{};map=e=>i.ok(e());flatMap=e=>e();match=e=>e.ok();toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>"{Success: Ok";get[Symbol.toStringTag](){return"Success"}},i.err=e=>new class{reason;constructor(t){this.reason=t}asOption=()=>m.None;failureReason=()=>this.reason;isFailure=()=>!0;isSuccess=()=>!1;result=()=>{throw new Error(`No result because '${this.reason}'`)};map=()=>this;flatMap=()=>this;match=t=>t.err(this.reason);toVoid=()=>i.err(this.reason);failure=()=>this;toString=()=>`{Failure: ${this.reason}`;get[Symbol.toStringTag](){return"Failure"}}(e)})(Dn||(Dn={}));var ie;(function(i){i.exact=(e,t,r)=>{let s=0,o=e.length-1;for(;s<=o;){let n=s+o>>>1,a=r(e[n],t);if(a===0)return n;a<0?s=n+1:o=n-1}return-1},i.exactMapped=(e,t,r,s)=>{let o=0,n=e.length-1;for(;o<=n;){let a=o+n>>>1,u=r(s(e[a]),t);if(u===0)return a;u<0?o=a+1:n=a-1}return-1},i.leftMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<0?s=n+1:o=n}return s},i.rightMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<=0?s=n+1:o=n}return o-1},i.leftMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<0?o=a+1:n=a}return o},i.rightMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<=0?o=a+1:n=a}return n-1},i.rangeMapped=(e,t,r,s)=>[i.leftMostMapped(e,t,r,s),i.rightMostMapped(e,t,r,s)]})(ie||(ie={}));var ye=class{static every=(e,t)=>(e&t)===t;static some=(e,t)=>(e&t)>0;#e;#t;constructor(e=32){this.#e=e,this.#t=new Int32Array((e-1>>>5)+1)}getBit(e){let t=e>>>5,r=1<<e-(t<<5);return(this.#t[t]&r)!==0}setBit(e,t){let r=e>>>5,s=1<<e-(r<<5),o=this.#t[r],n=t?o|s:o&~s;return n===o?!1:(this.#t[r]=n,!0)}isEmpty(){return this.#t.every(e=>e===0)}nonEmpty(){return this.#t.some(e=>e>0)}set buffer(e){this.#t.set(new Int32Array(e))}get buffer(){return this.#t.buffer}replace(e){let t=new Int32Array(e),r=!1;for(let s=0;s<t.length;s++)this.#t[s]!==t[s]&&(this.#t[s]=t[s],r=!0);return r}toString(){let e="";for(let t of w.iterateReverse(this.#t))e+=t.toString(2).padStart(32,"0");return e.substring(e.length-this.#e)}clear(){this.#t.fill(0)}};var Si=class{#e;#t=null;constructor(e){this.#e=e}invalidate=()=>this.#t=null;get(){return this.#t===null&&(this.#t=this.#e()),this.#t}terminate(){this.invalidate()}};var Ci;(function(i){i.parseCssRgbOrRgba=e=>{let t=e.match(/\(([^)]+)\)/)?.at(1)?.split(",")?.map(Number);if(D(t)&&t.every(r=>!isNaN(r))){if(t.length===3)return[t[0]/255,t[1]/255,t[2]/255,1];if(t.length===4)return[t[0]/255,t[1]/255,t[2]/255,t[3]]}throw new Error(`${e} is not proper formatted. Example: 'rgb(255, 255, 255)' or 'rgba(255, 255, 255, 1)'`)},i.hslToHex=(e,t,r)=>{let s=u=>(u+e/30)%12,o=t*Math.min(r,1-r),n=u=>r-o*Math.max(-1,Math.min(s(u)-3,Math.min(9-s(u),1))),a=u=>Math.round(u*255).toString(16).padStart(2,"0");return`#${a(n(0))}${a(n(8))}${a(n(4))}`},i.hexToHsl=e=>{let t=e.startsWith("#")?e.slice(1):e,r=parseInt(t.slice(0,2),16)/255,s=parseInt(t.slice(2,4),16)/255,o=parseInt(t.slice(4,6),16)/255,n=Math.max(r,s,o),a=Math.min(r,s,o),u=(n+a)/2,h=0,d=0;if(n!==a){let p=n-a;switch(d=u>.5?p/(2-n-a):p/(n+a),n){case r:h=((s-o)/p+(s<o?6:0))*60;break;case s:h=((o-r)/p+2)*60;break;case o:h=((r-s)/p+4)*60;break}}return{h,s:d,l:u}},i.hslStringToHex=e=>{let[t,r,s]=e.match(/\d+(\.\d+)?/g).map(Number);return i.hslToHex(t,r/100,s/100)}})(Ci||(Ci={}));var yt=(i,e)=>i-e,In=(i,e)=>{let t=Math.min(i.length,e.length);for(let r=0;r<t;r++){let s=i[r]-e[r];if(s!==0)return s}return i.length-e.length};var qe=Math.PI*2,xl=Math.PI/2,rn=Math.PI/4,yl=1/Math.sqrt(2),L=(i,e,t)=>Math.max(e,Math.min(i,t));var On=(i,e)=>e+(1-2*e)*Math.max(0,Math.min(i,1)),st=(i,e)=>Math.floor(i/e)*e;var kn=(i,e,t)=>i+(e-i)*t;var ai=(i,e)=>Ha(i/e)*e,Ha=i=>i-Math.floor(i),ot=i=>Math.pow(2,Math.ceil(Math.log(i)/Math.log(2)));var sn=(i,e)=>i*e/((2*e-1)*(i-1)+e);var Oe;(function(i){i.valueAt=({slope:s,steps:o,y0:n,y1:a},u)=>i.normalizedAt(u/o,s)*(a-n)+n,i.normalizedAt=(s,o)=>{if(o>.499999&&o<.500001)return s;{let n=L(o,1e-15,.999999999999999);return n*n/(1-n*2)*(Math.pow((1-n)/n,2*s)-1)}},i.inverseAt=(s,o)=>{let n=L(o,1e-15,.999999999999999);return Math.log(s*(1-2*n)/(n*n)+1)/(2*Math.log((1-n)/n))},i.coefficients=s=>{let o=i.valueAt(s,1),a=(i.valueAt(s,2)-o)/(o-s.y0),u=o-a*s.y0;return{m:a,q:u}};function*t(s,o,n,a){let{m:u,q:h}=i.coefficients({slope:s,steps:o,y0:n,y1:a});for(let d=0,p=n;d<o;d++)yield p=u*p+h}i.walk=t;function*r(s,o){let n=1/o,a=i.normalizedAt(n,s),h=(i.normalizedAt(2*n,s)-a)/a;for(let d=0,p=0;d<o;d++)yield p=h*p+a}i.walkNormalized=r,i.byHalf=(s,o,n,a)=>({slope:i.slopeByHalf(o,n,a),steps:s,y0:o,y1:a}),i.slopeByHalf=(s,o,n)=>Math.abs(n-s)<1e-6?.5:(o-s)/(n-s)})(Oe||(Oe={}));var We=new DataView(new ArrayBuffer(8)),Ie;(function(i){i.MIN_VALUE=-2147483648,i.MAX_VALUE=2147483647,i.toByte=e=>(We.setInt8(0,e),We.getInt8(0)),i.toShort=e=>(We.setInt16(0,e),We.getInt16(0)),i.toInt=e=>(We.setInt32(0,e),We.getInt32(0))})(Ie||(Ie={}));var nt;(function(i){let r=new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(r),o=new Int32Array(r);i.floatToIntBits=n=>{let a=i.floatToRawIntBits(n);return(a&2139095040)===2139095040&&(a&8388607)!==0?2143289344:a},i.intBitsToFloat=n=>(o[0]=n,s[0]),i.floatToRawIntBits=n=>(s[0]=n,o[0]),i.toFloat32=n=>(We.setFloat32(0,n),We.getFloat32(0))})(nt||(nt={}));var vt;(function(i){i.floatToIntBits=e=>{let t=nt.floatToIntBits(e),r=t>>>16&32768,s=(t&2147483647)+4096;return s>=1199570944?(t&2147483647)>=1199570944?s<2139095040?r|31744:r|31744|(t&8388607)>>>13:r|31743:s>=947912704?r|s-939524096>>>13:s<855638016?r:(s=(t&2147483647)>>>23,r|(t&8388607|8388608)+(8388608>>>s-102)>>>126-s)},i.intBitsToFloat=e=>{let t=e&1023,r=e&31744;if(r===31744)r=261120;else if(r!==0){if(r+=114688,t===0&&r>115712)return nt.intBitsToFloat((e&32768)<<16|r<<13|1023)}else if(t!==0){r=115712;do t<<=1,r-=1024;while((t&1024)===0);t&=1023}return nt.intBitsToFloat((e&32768)<<16|(r|t)<<13)}})(vt||(vt={}));var Ri;(function(i){let e=9218868437227405312n,t=4503599627370495n,r=new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT),s=new Float64Array(r),o=new BigInt64Array(r);i.float64ToLongBits=n=>{let a=i.float64ToRawLongBits(n);return(a&e)===e&&(a&t)!==0n?0x7ff8000000000000n:a},i.longBitsToFloat64=n=>(o[0]=n,s[0]),i.float64ToRawLongBits=n=>(s[0]=n,o[0]),i.clamp=n=>(We.setFloat64(0,n),We.getFloat64(0))})(Ri||(Ri={}));var se=class{static*empty(){}static one(e){return[e]}static count(e){let t=0;for(let r of e)t++;return t}static some(e,t){for(let r of e)if(t(r))return!0;return!1}static every(e,t){for(let r of e)if(!t(r))return!1;return!0}static reduce(e,t,r){let s=r,o=0;for(let n of e)s=t(s,n,o++);return s}static includes(e,t){for(let r of e)if(r===t)return!0;return!1}static forEach(e,t){for(let r of e)t(r)}static*map(e,t){let r=0;for(let s of e)yield t(s,r++)}static*take(e,t){let r=0;for(let s of e){if(r++>=t)return;yield s}}static filter(e,t){let r=[];for(let s of e)t(s)&&r.push(s);return r}static filterMap(e,t){let r=[];for(let s of e){let o=t(s);D(o)&&r.push(o)}return r}static reverse(e){let t=[];for(let r of e)t.push(r);return t.reverse()}static*pairWise(e){let t=e[Symbol.iterator](),{done:r,value:s}=t.next(),o=s;if(r!==!0)for(;;){let{done:n,value:a}=t.next();if(n===!0){yield[o,null];return}yield[o,a],o=a}}};var ue=class i{static create(e=1024){return this.use(new ArrayBuffer(e))}static use(e,t=0){return new i(new DataView(e,t))}littleEndian=!1;#e;#t=0;constructor(e){this.#e=e}get remaining(){return this.#e.byteLength-this.#t}get position(){return this.#t}set position(e){e<0?y(`position(${e}) cannot be negative.`):e>this.#e.byteLength?y(`position(${e}) is outside range (${this.#e.byteLength}).`):this.#t=e}writeBoolean(e){this.writeByte(e?1:0)}writeByte(e){this.#r(1),this.#e.setInt8(this.#t++,e)}writeShort(e){this.#r(Int16Array.BYTES_PER_ELEMENT),this.#e.setInt16(this.#t,e,this.littleEndian),this.#t+=Int16Array.BYTES_PER_ELEMENT}writeInt(e){this.#r(Int32Array.BYTES_PER_ELEMENT),this.#e.setInt32(this.#t,e,this.littleEndian),this.#t+=Int32Array.BYTES_PER_ELEMENT}writeLong(e){this.#r(BigInt64Array.BYTES_PER_ELEMENT),this.#e.setBigInt64(this.#t,e,this.littleEndian),this.#t+=BigInt64Array.BYTES_PER_ELEMENT}writeFloat(e){this.#r(Float32Array.BYTES_PER_ELEMENT),this.#e.setFloat32(this.#t,e,this.littleEndian),this.#t+=Float32Array.BYTES_PER_ELEMENT}writeDouble(e){this.#r(Float64Array.BYTES_PER_ELEMENT),this.#e.setFloat64(this.#t,e,this.littleEndian),this.#t+=Float64Array.BYTES_PER_ELEMENT}writeBytes(e){this.#r(e.length);for(let t=0;t<e.length;++t)this.#e.setInt8(this.#t++,e[t])}writeString(e){let t=e.length;this.#r(Int32Array.BYTES_PER_ELEMENT+t*Int16Array.BYTES_PER_ELEMENT),this.writeInt(t);for(let r=0;r<t;r++)this.writeShort(e.charCodeAt(r))}toArrayBuffer(){return this.#e.buffer.slice(0,this.#t)}#r(e){let t=this.#e.byteLength;if(this.#t+e>t){let r=this.#e;this.#e=new DataView(new ArrayBuffer(ot(t+e)));for(let s=0;s<this.#t;s++)this.#e.setInt8(s,r.getInt8(s))}}},fr=class{#e=0;writeByte(e){this.#e++}writeShort(e){this.#e+=2}writeInt(e){this.#e+=4}writeLong(e){this.#e+=8}writeFloat(e){this.#e+=4}writeDouble(e){this.#e+=8}writeBoolean(e){this.#e++}writeBytes(e){this.#e+=e.length}writeString(e){this.#e+=e.length+4}get count(){return this.#e}},Mi=class{#e;#t=0;constructor(e=32){this.#e=new Int8Array(e)}result(){return this.#e}equals(e){return e===this?!0:this.#e.every((t,r)=>e.#e[r]===t)}writeBoolean(e){this.writeByte(e?31:11)}writeShort(e){this.writeByte(e&255),this.writeByte(e>>>8&255)}writeByte(e){this.#t>=this.#e.length&&(this.#t=0),this.#e[this.#t++]^=e}writeInt(e){this.writeByte(e&255),this.writeByte(e>>>8&255),this.writeByte(e>>>16&255),this.writeByte(e>>>24&255)}writeBytes(e){e.forEach(t=>this.writeByte(t))}writeFloat(e){this.writeInt(nt.floatToIntBits(e))}writeDouble(e){this.writeLong(Ri.float64ToLongBits(e))}writeLong(e){this.writeByte(Number(e)&255),this.writeByte(Number(e>>8n)&255),this.writeByte(Number(e>>16n)&255),this.writeByte(Number(e>>24n)&255),this.writeByte(Number(e>>32n)&255),this.writeByte(Number(e>>40n)&255),this.writeByte(Number(e>>48n)&255),this.writeByte(Number(e>>56n)&255)}writeString(e){for(let t=0;t<e.length;t++)this.writeShort(e.charCodeAt(t))}toHexString(){return Array.from(se.map(this.#e.values(),e=>(e&255).toString(16).padStart(2,"0"))).join("")}},ge=class{littleEndian=!1;#e;#t=0;constructor(e,t=0){this.#e=new DataView(e,t)}get position(){return this.#t}set position(e){e<0?y(`position(${e}) cannot be negative.`):e>this.#e.byteLength?y(`position(${e}) is outside range (${this.#e.byteLength}).`):this.#t=e}readByte(){return this.#e.getInt8(this.#t++)}readShort(){let e=this.#e.getInt16(this.#t,this.littleEndian);return this.#t+=Int16Array.BYTES_PER_ELEMENT,e}readInt(){let e=this.#e.getInt32(this.#t,this.littleEndian);return this.#t+=Int32Array.BYTES_PER_ELEMENT,e}readLong(){let e=this.#e.getBigInt64(this.#t,this.littleEndian);return this.#t+=BigInt64Array.BYTES_PER_ELEMENT,e}readFloat(){let e=this.#e.getFloat32(this.#t,this.littleEndian);return this.#t+=Float32Array.BYTES_PER_ELEMENT,e}readDouble(){let e=this.#e.getFloat64(this.#t,this.littleEndian);return this.#t+=Float64Array.BYTES_PER_ELEMENT,e}readBoolean(){return this.readByte()===1}readBytes(e){for(let t=0;t<e.length;t++)e[t]=this.readByte()}readString(){let e=this.readInt(),t="";for(let r=0;r<e;r++)t+=String.fromCharCode(this.readShort());return t}available(e){return this.#t+e<=this.#e.byteLength}remaining(){return this.#e.byteLength-this.#t}skip(e){this.position+=e}};var Ga=i=>D(i)?i.value!==void 0?"value":i.get!==void 0?"get":y(`Cannot resolve method key of ${i}`):y("Cannot resolve method key of undefined descriptor"),gr=(i,e,t)=>{if(!D(t))return function(o,n){if(n&&n.kind==="getter")return function(){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this),e);if(!D(a?.get))return y(`Cannot find getter for property '${e}'`);let u=a.get.apply(this);return Object.defineProperty(this,e,{value:u,configurable:!1,writable:!1,enumerable:!1}),u}};let r=Ga(t),s=U(t[r]);return{[r]:function(...o){if(o.length>0)return y("lazy accessory must not have any construction parameters");let n=s.apply(this);return Object.defineProperty(this,e,{value:r==="get"?n:()=>n,configurable:!1,writable:!1,enumerable:!1}),n}}};var at;(function(i){function*e(){}i.empty=e,i.next=r=>{let{value:s,done:o}=r.next();return o?null:s};function*t(...r){for(let s of r)for(let o of s)yield o}i.flatten=t})(at||(at={}));var xr;(function(i){i[i.T=0]="T",i[i.R=1]="R",i[i.B=2]="B",i[i.L=3]="L"})(xr||(xr={}));var yr;(function(i){i[i.TL=0]="TL",i[i.TR=1]="TR",i[i.BR=2]="BR",i[i.BL=3]="BL"})(yr||(yr={}));var Un;(function(i){i.outerTangentPoints=(e,t)=>{let r=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,r)+Math.acos((e.r-t.r)/Math.sqrt(r*r+s*s)),n=Math.cos(o),a=Math.sin(o);return[{x:e.x+e.r*n,y:e.y+e.r*a},{x:t.x+t.r*n,y:t.y+t.r*a}]}})(Un||(Un={}));var Kn;(function(i){i.zero=()=>({x:0,y:0}),i.create=(e,t)=>({x:e,y:t}),i.clone=e=>({...e}),i.floor=e=>({x:Math.floor(e.x),y:Math.floor(e.y)}),i.length=e=>Math.sqrt(e.x*e.x+e.y*e.y),i.distance=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),i.add=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),i.subtract=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),i.scaleBy=(e,t)=>({x:e.x*t,y:e.y*t}),i.scaleTo=(e,t)=>{let r=t/i.length(e);return{x:e.x*r,y:e.y*r}},i.fromClient=e=>({x:e.clientX,y:e.clientY})})(Kn||(Kn={}));var li;(function(i){i.Empty=Object.freeze({x:0,y:0,width:0,height:0}),i.corners=e=>{let t=e.x,r=e.y,s=t+e.width,o=r+e.height;return[{x:t,y:r},{x:s,y:r},{x:s,y:o},{x:t,y:o}]},i.inflate=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}),i.contains=(e,t)=>{let r=t.x>=e.x&&t.y>=e.y,s=t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;return r&&s},i.isPointInside=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,i.intersect=(e,t)=>{let r=Math.max(e.x,t.x),s=Math.min(e.x+e.width,t.x+t.width),o=Math.min(e.y+e.height,t.y+t.height),n=Math.max(e.y,t.y);return s>r&&o>n},i.axis=(e,t)=>{switch(t){case xr.T:return e.y;case xr.R:return e.x+e.width;case xr.B:return e.y+e.height;case xr.L:return e.x;default:return it(t)}},i.corner=(e,t)=>{switch(t){case yr.TL:return{x:e.x,y:e.y};case yr.TR:return{x:e.x+e.width,y:e.y};case yr.BR:return{x:e.x+e.width,y:e.y+e.height};case yr.BL:return{x:e.x,y:e.y+e.height};default:return it(t)}},i.center=e=>({x:e.x+e.width*.5,y:e.y+e.height*.5}),i.isEmpty=e=>e.width===0||e.height===0,i.union=(e,t)=>{if(i.isEmpty(e))i.isEmpty(t)||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height);else if(!i.isEmpty(t)){let r=t.x,s=t.y,o=Math.min(e.x,r),n=Math.min(e.y,s);e.width=Math.max(e.x+e.width,r+t.width)-o,e.height=Math.max(e.y+e.height,s+t.height)-n,e.x=o,e.y=n}}})(li||(li={}));var Ln;(function(i){i.width=e=>e.xMax-e.xMin,i.height=e=>e.yMax-e.yMin,i.from=(e,t)=>{e.xMin=t.xMin,e.xMax=t.xMax,e.yMin=t.yMin,e.yMax=t.yMax},i.extend=(e,t)=>{e.xMin-=t,e.yMin-=t,e.xMax+=t,e.yMax+=t},i.padding=(e,[t,r,s,o])=>(e.xMin+=o,e.yMin+=t,e.xMax-=r,e.yMax-=s,e),i.intersectPoint=(e,t)=>e.xMin<=t.x&&t.x<e.xMax&&e.yMin<=t.y&&t.y<e.yMax,i.intersectThat=(e,t)=>t.xMin<e.xMax&&t.xMax>e.xMin&&t.yMin<e.yMax&&t.yMax>e.yMin,i.center=e=>({x:(e.xMin+e.xMax)*.5,y:(e.yMin+e.yMax)*.5})})(Ln||(Ln={}));var $n;(function(i){i.Identity=Object.freeze([0,0,0,0])})($n||($n={}));var qn;(function(i){i.intersects=(r,s,o,n,a,u,h,d)=>{let p=e(r,s,o,n,a,u),f=e(r,s,o,n,h,d);if((p|f)===0||(p&f)!==0)return!1;let A=t(a,u,h,d,r,o);return A!==t(a,u,h,d,s,o)||A!==t(a,u,h,d,s,n)||A!==t(a,u,h,d,r,n)};let e=(r,s,o,n,a,u)=>{let h=0;return a<=r?h|=1:a>=s&&(h|=2),u<=o?h|=8:u>=n&&(h|=4),h},t=(r,s,o,n,a,u)=>(o-r)*(u-s)-(a-r)*(n-s)>=0})(qn||(qn={}));var zn;(function(i){i.Identity={valueToAxis:e=>e,axisToValue:e=>e},i.toClamped=(e,t,r)=>({valueToAxis:s=>e.valueToAxis(L(s,t,r)),axisToValue:s=>L(e.axisToValue(s),t,r)}),i.createClamped=(e,t)=>({valueToAxis:r=>L(r,e,t),axisToValue:r=>L(r,e,t)})})(zn||(zn={}));var _n;(function(i){i.fromBuffers=async(...e)=>{let t=e.reduce((o,n)=>o+n.byteLength,0),r=new Uint8Array(t),s=0;for(let o of e)r.set(new Uint8Array(o),s),s+=o.byteLength;return await crypto.subtle.digest("SHA-256",r)},i.equals=(e,t)=>{v(e.byteLength===32,"First hash has invalid length"),v(t.byteLength===32,"Second hash has invalid length");let r=new Uint8Array(e),s=new Uint8Array(t);for(let o=0;o<32;o++)if(r[o]!==s[o])return!1;return!0},i.toString=e=>Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")})(_n||(_n={}));var ui;(function(i){i.intersect1D=(e,t,r,s)=>Math.max(e,r)<=Math.min(t,s)})(ui||(ui={}));var ve=class{#e=new Set;#t;constructor(){this.#t=new Proxy({},{get:(e,t)=>(...r)=>this.#e.forEach(s=>Object.getPrototypeOf(s)===Object.getPrototypeOf({})?g(s[t],...r):s[t]?.apply(s,r))})}get proxy(){return this.#t}get size(){return this.#e.size}subscribe(e){return this.#e.add(e),{terminate:()=>this.#e.delete(e)}}forEach(e){this.#e.forEach(e)}terminate(){this.#e.clear()}};var lt=class{static createIfAbsent(e,t,r){let s=e.get(t);return s===void 0&&(s=r(t),e.set(t,s)),s}};var hi=class i{static#e=Object.freeze(new Set);static empty=()=>i.#e};var Zt=class i{#e;#t;constructor(e,t){this.#e=new Map(e),this.#t=m.wrap(t),this.#t.ifSome(r=>Array.from(this.#e.values()).forEach(s=>s.sort(r)))}[Symbol.iterator](){return this.#e.entries()}clear(){this.#e.clear()}containsEntry(e,t){return se.some(this.#e.entries(),r=>e===r[0]&&r[1].includes(t))}containsKey(e){return se.includes(this.#e.keys(),e)}containsValue(e){return se.some(this.#e.values(),t=>t.includes(e))}get(e){return this.#e.get(e)??w.empty()}isEmpty(){return this.keyCount()===0}add(e,t){let r=lt.createIfAbsent(this.#e,e,()=>[]);if(this.#t.isEmpty())r.push(t);else{let s=ie.leftMost(r,t,this.#t.unwrap());r.splice(s,0,t)}}addAll(e,t){let r=lt.createIfAbsent(this.#e,e,()=>[]);r.push(...t),this.#t.nonEmpty()&&r.sort(this.#t.unwrap())}remove(e,t){let r=this.#e.get(e);if(r===void 0)return!1;{let s=r.indexOf(t);return s===-1?!1:(r.splice(s,1),r.length===0&&this.#e.delete(e),!0)}}removeFromKeyIf(e,t){let r=this.#e.get(e);if(r===void 0)return null;{let s=r.findIndex(t);if(s===-1)return null;{let o=r.splice(s,1)[0];return r.length===0&&this.#e.delete(e),o}}}removeValueIf(e){let t=[];for(let[r,s]of this.#e.entries())for(let o of s.filter(n=>e(n)))t.push([r,o]);for(let[r,s]of t)this.remove(r,s);return new Set(t.map(([,r])=>r))}removeKey(e){let t=this.#e.get(e);return this.#e.delete(e),t??w.empty()}forEach(e){se.forEach(this.#e.entries(),t=>e(t[0],t[1]))}keyCount(){return this.#e.size}keys(){return this.#e.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.#e.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.#e.forEach((t,r)=>{e.#e.set(r,t.map(s=>s))}),e}},Ti=class i{map;constructor(e){this.map=new Map(e?.map(t=>{let r=t[0],s=t[1];return[r,new Set(s)]}))}clear(){this.map.clear()}containsEntry(e,t){return se.some(this.map.entries(),r=>e===r[0]&&r[1].has(t))}containsKey(e){return se.includes(this.map.keys(),e)}containsValue(e){return se.some(this.map.values(),t=>t.has(e))}get(e){return this.map.get(e)??hi.empty()}isEmpty(){return this.keyCount()===0}add(e,t){lt.createIfAbsent(this.map,e,()=>new Set).add(t)}addAll(e,t){let r=lt.createIfAbsent(this.map,e,()=>new Set);for(let s of t)r.add(s)}remove(e,t){let r=this.map.get(e);return r===void 0?!1:r.delete(t)?(r.size===0&&this.map.delete(e),!0):!1}removeValueIf(e){let t=new Set;for(let[r,s]of this.map.entries()){for(let o of s)e(o)&&(s.delete(o),t.add(o));s.size===0&&this.map.delete(r)}return t}removeFromKeyIf(e,t){let r=this.map.get(e);if(r===void 0)return null;for(let s of r)if(t(s))return r.delete(s),r.size===0&&this.map.delete(e),s;return null}removeKey(e){let t=this.map.get(e);return this.map.delete(e),t??hi.empty()}forEach(e){se.forEach(this.map.entries(),t=>e(t[0],t[1]))}keyCount(){return this.map.size}keys(){return this.map.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.map.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.map.forEach((t,r)=>{e.map.set(r,new Set(Array.from(t)))}),e}};var O=Object.freeze({Empty:{terminate:Xt},create:i=>({terminate:i}),many:(...i)=>({terminate:()=>{for(;i.length>0;)i.pop().terminate()}})}),V=class i{#e=[];own(e){return this.#e.push(e),e}ownAll(...e){for(let t of e)this.#e.push(t)}spawn(){let e=new i;return e.own({terminate:()=>w.removeOpt(this.#e,e)}),this.own(e)}terminate(){for(;this.#e.length>0;)this.#e.pop().terminate()}};var $=class{static subscribeMany(e,...t){return O.many(...t.map(r=>r.subscribe(()=>e(r))))}#e=new Set;subscribe(e){return this.#e.add(e),{terminate:()=>this.#e.delete(e)}}isEmpty(){return this.#e.size===0}notify(e){this.#e.forEach(t=>t(e))}observers(){return this.#e}terminate(){this.#e.clear()}};var bt;(function(i){i.mergeNoOverlap=(e,t)=>{let r=new Set(Object.keys(e));for(let s of Object.keys(t))if(r.has(s))return y(`'${s}' is an overlapping key`);return{...e,...t}},i.include=(e,...t)=>t.reduce((r,s)=>(r[s]=e[s],r),{}),i.exclude=(e,...t)=>{let r=new Set(t);return Object.entries(e).reduce((s,[o,n])=>(r.has(o)||(s[o]=n),s),{})},i.overwrite=(e,t)=>Object.assign(e,t)})(bt||(bt={}));var Hn;(function(i){i.make=e=>new class{getValue(){return e}subscribe(t){return O.Empty}catchupAndSubscribe(t){return t(this),O.Empty}}})(Hn||(Hn={}));var Gn;(function(i){i.False=new class{getValue(){return!1}setValue(e){}subscribe(e){return O.Empty}catchupAndSubscribe(e){return e(this),O.Empty}},i.inverseBoolean=e=>new class{getValue(){return!e.getValue()}setValue(t){e.setValue(!t)}subscribe(t){return e.subscribe(t)}catchupAndSubscribe(t){return t(this),this.subscribe(t)}}})(Gn||(Gn={}));var Pe=class{#e;#t=m.None;#r;constructor(e,t){this.#e=new $,this.#r=t?.guard(e)??e,this.#t=m.wrap(t)}setValue(e){this.#t.nonEmpty()&&(e=this.#t.unwrap().guard(e)),this.#r!==e&&(this.#r=e,this.#e.notify(this))}getValue(){return this.#r}subscribe(e){return this.#e.subscribe(e)}catchupAndSubscribe(e){return e(this),this.#e.subscribe(e)}terminate(){this.#e.terminate()}toString(){return`{DefaultObservableValue value: ${this.#r}`}};var on=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=t-e}x(e){return(this.clamp(e)-this.#e)/this.#r}y(e){return this.#e+L(e,0,1)*this.#r}clamp(e){return L(e,this.#e,this.#t)}floating(){return!0}},nn=class{#e;#t;#r;constructor(e,t){this.#e=L(Math.round(e),Ie.MIN_VALUE,Ie.MAX_VALUE),this.#t=L(Math.round(t),Ie.MIN_VALUE,Ie.MAX_VALUE),this.#r=this.#t-this.#e}x(e){return(this.clamp(e)-this.#e)/this.#r}y(e){return this.#e+Math.round(L(e,0,1)*this.#r)}clamp(e){return L(Math.round(e),this.#e,this.#t)}floating(){return!1}},an=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=Math.log(t/e)}x(e){return Math.log(L(e,this.#e,this.#t)/this.#e)/this.#r}y(e){return this.#e*Math.exp(L(e,0,1)*this.#r)}clamp(e){return Math.min(this.#t,Math.max(this.#e,e))}floating(){return!0}},ln=class{#e;constructor(e){this.#e=e}x(e){let t=this.#e.findIndex(r=>r===e);return t===-1?y(`Could not find index for ${e}`):t/(this.#e.length-1)}y(e){let t=Math.round(L(e,0,1)*(this.#e.length-1));return t>-1?U(this.#e.at(t),`Could not find value for ${e}`):y(`Index ${t} is out of box.`)}clamp(e){return e}floating(){return!1}},un=class{#e;#t;#r;#i;#s;constructor(e,t,r){this.#e=e,this.#t=r;let s=e*e,o=r*r,n=t*t,a=e+r-2*t,u=r-t;this.#r=((2*r-t)*e-t*r)/a,this.#i=(u*s+(n-o)*e+t*o-n*r)/(s+(2*r-4*t)*e+o-4*t*r+4*n),this.#s=-u/a}y(e){return e<=0?Number.NEGATIVE_INFINITY:e>=1?this.#t:this.#r-this.#i/(e+this.#s)}x(e){return this.#e>=e?0:this.#t<=e?1:-this.#i/(e-this.#r)-this.#s}clamp(e){return Math.min(this.#t,e)}floating(){return!0}},R;(function(i){i.linear=(o,n)=>new on(o,n),i.linearInteger=(o,n)=>new nn(o,n),i.exponential=(o,n)=>new an(o,n),i.values=o=>new ln(o),i.decibel=(o,n,a)=>new un(o,n,a);let e=new class{x(o){return o?1:0}y(o){return o>=.5}clamp(o){return o}floating(){return!1}},t=i.linear(0,1),r=i.linear(-1,1);i.bool=e;let s=i.decibel(-72,-12,0);i.unipolar=()=>t,i.bipolar=()=>r,i.DefaultDecibel=s})(R||(R={}));var C;(function(i){i.percent=({bipolar:o,fractionDigits:n}={})=>new e("%",n,!1,o),i.numeric=({unit:o,fractionDigits:n,unitPrefix:a,bipolar:u}={})=>new e(o,n,a,u),i.indices=(o,n)=>new class{x(a){return{unit:o,value:n[a]}}y(a){let u=n.indexOf(a);return u===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:u}}},i.values=(o,n,a)=>new class{x(u){return{unit:o,value:a.at(n.indexOf(u))??"N/A"}}y(u){let h=a.indexOf(u);return h===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:n[h]}}},i.bool=new class{y(o){switch(o.trim()){case"on":case"yes":case"true":return{type:"explicit",value:!0};default:return{type:"explicit",value:!1}}}x(o){return{value:String(o),unit:""}}};class e{#e;#t;#r;#i;constructor(n,a,u,h){this.#e=n??"",this.#t=a??0,this.#r=u??!1,this.#i=h??!1}y(n){let a=n.trim(),u=parseFloat(a);if(isNaN(u))return{type:"unknown",value:a};if(this.#e==="%")return{type:"explicit",value:u/100};if(a.endsWith("%"))return{type:"unitValue",value:this.#i?L(u/200+.5,0,1):L(u/100,0,1)};{a.endsWith(this.#e)&&this.#e.length>0&&(a=a.slice(0,-this.#e.length));let p=/(\d+)(\D+)/.exec(a)?.at(2)?.at(0);if(D(p)){let f=t.indexOf(p);if(f>-1)return{type:"explicit",value:u*Math.pow(10,(f-4)*3)}}return{type:"explicit",value:u}}}x(n){if(Number.isNaN(n))return{value:"\u{1F4A3}",unit:this.#e};if(Number.isFinite(n)){if(this.#e==="%")return this.#i?{value:(n*200-100).toFixed(this.#t),unit:this.#e}:{value:(n*100).toFixed(this.#t),unit:this.#e};if(this.#r){let{value:a,prefix:u}=s(n);return{value:a.toFixed(this.#t),unit:`${u}${this.#e}`}}else return{value:n.toFixed(this.#t),unit:this.#e}}else return{value:n===Number.POSITIVE_INFINITY?"\u221E":"-\u221E",unit:this.#e}}}let t=Object.freeze(["p","n","\u03BC","m","","k","M","G","T"]),r=o=>Math.log(o)/Math.log(9.999999999999998),s=o=>{let n=Math.floor(r(o)/3),a=t[n+4];return D(a)?{value:o*Math.pow(10,n*-3),prefix:a}:{value:o,prefix:""}};i.decible=i.numeric({unit:"db",fractionDigits:1}),i.panning=i.percent({unit:"%",fractionDigits:0})})(C||(C={}));var Vi;(function(i){i.alwaysTrue=()=>!0,i.alwaysFalse=()=>!1,i.definedPredicate=e=>e!=null})(Vi||(Vi={}));var Wn;(function(i){i.Empty=Object.freeze(e=>{}),i.split=(e,t)=>{let r=new Float32Array(t);return w.create(s=>o=>{r[s]=o,e(r.reduce((n,a)=>n+a,0)/t)},t)}})(Wn||(Wn={}));var Di;(function(i){i.create=(e=252854082)=>new hn(e),i.monotoneAscending=(e,t=128,r=i.create())=>{let s=e.length;if(s<2)return y("Array must have at least 2 elements");let o=0;for(let a=1;a<s;a++){let u=Math.floor(r.uniform()*(1+t))+1;e[a]=u,o+=u}let n=0;e[0]=0;for(let a=1;a<s;a++)n+=e[a],e[a]=n/o;return e}})(Di||(Di={}));var hn=class{#e=0;constructor(e){this.setSeed(e)}setSeed(e){this.#e=e&4294967295}nextDouble(e,t){return e+this.uniform()*(t-e)}nextInt(e,t){return e+Math.floor(this.uniform()*(t-e))}nextElement(e){return e[Math.floor(this.uniform()*e.length)]}nextBoolean(){return this.uniform()<.5}uniform(){let e=this.#e+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}};var Se;(function(i){class e{}i.createBuilder=r=>{let s=o=>{let n=o instanceof Array?[]:{};return Object.entries(o).forEach(([a,u])=>{u instanceof e?n[a]=u.initialValue():typeof u=="object"&&(n[a]=s(u))}),n};return()=>new t(r,Object.seal(s(r)))},i.bool=new class extends e{read(r){return r.readByte()===1}write(r,s){r.writeByte(s?1:0)}initialValue(){return!1}},i.int8=new class extends e{read(r){return r.readByte()}write(r,s){r.writeByte(s)}initialValue(){return 0}},i.int16=new class extends e{read(r){return r.readShort()}write(r,s){r.writeShort(s)}initialValue(){return 0}},i.int32=new class extends e{read(r){return r.readInt()}write(r,s){r.writeInt(s)}initialValue(){return 0}},i.float=new class extends e{read(r){return r.readFloat()}write(r,s){r.writeFloat(s)}initialValue(){return 0}},i.double=new class extends e{read(r){return r.readDouble()}write(r,s){r.writeDouble(s)}initialValue(){return 0}},i.int64=new class extends e{read(r){return r.readLong()}write(r,s){r.writeLong(s)}initialValue(){return 0n}},i.floats=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readFloat();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeFloat(o[n])}initialValue(){return new Float32Array(r)}},i.doubles=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readDouble();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeDouble(o[n])}initialValue(){return new Float64Array(r)}};class t{#e;#t;#r;constructor(s,o){this.#e=s,this.#t=o,this.#r=this.#i()}get object(){return this.#t}get bytesTotal(){return this.#r}read(s){let o=(n,a)=>{Object.entries(n).forEach(([u,h])=>{let d=a;h instanceof e?d[u]=h.read(s,d[u]):typeof h=="object"&&o(h,d[u])})};o(this.#e,this.#t)}write(s){let o=(n,a)=>{Object.entries(n).forEach(([u,h])=>{let d=a;h instanceof e?h.write(s,d[u]):typeof h=="object"&&o(h,d[u])})};o(this.#e,this.#t)}#i(){let s=new fr;return this.write(s),s.count}}})(Se||(Se={}));var At=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=[]}add(e,t=!1){let r=this.#e(e),s=ie.leftMostMapped(this.#r,r,this.#t,this.#e),o=this.#r[s];return D(o)&&this.#t(this.#e(o),r)===0?t?(this.#r.splice(s,1,e),!0):!1:(this.#r.splice(s,0,e),!0)}getOrCreate(e,t){let r=ie.leftMostMapped(this.#r,e,this.#t,this.#e),s=this.#r[r];if(D(s)&&this.#t(this.#e(s),e)===0)return s;let o=t(e);return this.#r.splice(r,0,o),o}addMany(e){for(let t of e)this.#r.push(t);try{return this.#r.sort((t,r)=>{let s=this.#t(this.#e(t),this.#e(r));if(s===0)throw"cancel";return s}),!0}catch(t){if(t==="cancel"){let r=new Map(this.entries());return this.#r.splice(0,this.#r.length,...r.values()),this.#r.sort((s,o)=>this.#t(this.#e(s),this.#e(o))),!1}return y(t)}}removeByValue(e){return this.removeByKey(this.#e(e))}removeByKey(e){let t=ie.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return D(r)&&this.#t(this.#e(r),e)===0?(this.#r.splice(t,1),r):y(`Could not remove ${e}`)}removeByKeyIfExist(e){let t=ie.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return D(r)&&this.#t(this.#e(r),e)===0?(this.#r.splice(t,1),r):null}removeRange(e,t){this.#r.splice(e,(t??this.#r.length)-e)}removeByPredicate(e){let t=0,r=this.#r.length;for(;--r>=0;)e(this.#r[r])&&(this.#r.splice(r,1),t++);return t}get(e){return U(this.#i(e),`Unknown key: ${e}`)}getOrThrow(e,t){let r=this.#i(e);if(D(r))return r;throw t()}opt(e){return m.wrap(this.#i(e))}getOrNull(e){return this.#i(e)??null}getByIndex(e){return this.#r[e]}hasKey(e){return D(this.#i(e))}hasValue(e){return D(this.#i(this.#e(e)))}size(){return this.#r.length}isEmpty(){return this.#r.length===0}forEach(e){this.values().forEach(e)}values(){return this.#r}entries(){return this.#r.map(e=>[this.#e(e),e])}clear(){w.clear(this.#r)}[Symbol.iterator](){return this.#r.values()}#i(e){let t=ie.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return D(r)&&this.#t(this.#e(r),e)===0?r:void 0}};var jn;(function(i){i.hyphenToCamelCase=e=>e.replace(/-([a-z])/g,t=>t[1].toUpperCase()),i.fallback=(e,t)=>D(e)&&e.length>0?e:t,i.endsWithDigit=e=>/\d$/.test(e),i.nonEmpty=(e,t)=>D(e)&&e.trim().length>0?e:t,i.toArrayBuffer=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return t},i.getUniqueName=(e,t)=>{let r=new Set(e),s=t,o=1;if(r.has(t)||r.has(`${t} 1`))o=2;else return t;for(;r.has(s=`${t} ${o++}`););return s}})(jn||(jn={}));var rh=(()=>{let i=m.None;return{info:e=>i.match({none:()=>Promise.resolve(),some:t=>t.info(e)}),approve:e=>i.match({none:()=>Promise.resolve(!0),some:t=>t.approve(e)}),progress:e=>i.match({none:()=>O.Empty,some:t=>t.progress(e)}),install:e=>{v(i.isEmpty(),"RuntimeNotification already installed"),i=m.wrap(e)}}})();var Jt=class i{static POSITIVE_INFINITY=new i(Number.POSITIVE_INFINITY);static millis=e=>new i(e);static seconds=e=>new i(e*i.#e);static minutes=e=>new i(e*i.#t);static hours=e=>new i(e*i.#r);static days=e=>new i(e*i.#i);static#e=1e3;static#t=6e4;static#r=36e5;static#i=864e5;#s;constructor(e){this.#s=e}millis(){return this.#s}absSeconds(){return Math.abs(this.#s)/i.#e}absMinutes(){return Math.abs(this.#s)/i.#t}absHours(){return Math.abs(this.#s)/i.#r}absDays(){return Math.abs(this.#s)/i.#i}split(){return{d:Math.floor(this.absDays()),h:Math.floor(this.absHours())%24,m:Math.floor(this.absMinutes())%60,s:Math.floor(this.absSeconds())%60}}isNow(){return this.#s===0}isPast(){return this.#s<0}isFuture(){return this.#s>0}toUnitString(){let e,t,r=Math.floor(Math.abs(this.#s)/1e3),s=Math.floor(r/60),o=Math.floor(s/60),n=Math.floor(o/24);return r<60?(e=r,t="second"):s<60?(e=s,t="minute"):o<24?(e=o,t="hour"):(e=n,t="day"),new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"long"}).format(e*Math.sign(this.#s),t)}toString(){if(isNaN(this.#s))return"NaN";if(!isFinite(this.#s))return"\u221E";let{d:e,h:t,m:r,s}=this.split();return e>0?[i.#o("d",e),i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):t>0?[i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):r>0?[i.#o("m",r),i.#o("s",s)].join(", "):s>0?i.#o("s",s):"now"}static#o=(e,t)=>{switch(e){case"d":return`${t} ${t<2?"day":"days"}`;case"h":return`${t} ${t<2?"hour":"hours"}`;case"m":return`${t} ${t<2?"minute":"minutes"}`;case"s":return`${t} ${t<2?"second":"seconds"}`;default:return it(e)}}};var vr;(function(i){let e;(function(t){t[t.READING=0]="READING",t[t.READ=1]="READ",t[t.WRITING=2]="WRITING",t[t.WRITTEN=3]="WRITTEN"})(e||(e={})),i.writer=(t,r,s)=>{if(t.bytesTotal+1>r.byteLength)return y("Insufficient memory allocated.");let o=new Uint8Array(r),n=ue.use(r,1);return Atomics.store(o,0,e.READ),{tryWrite:()=>Atomics.compareExchange(o,0,e.READ,e.WRITING)===e.WRITING?(s(t.object),n.position=0,t.write(n),Atomics.store(o,0,e.WRITTEN),!0):!1}},i.reader=(t,r)=>{let s=new SharedArrayBuffer(t.bytesTotal+1),o=new Uint8Array(s),n=new ge(s,1);return{buffer:s,tryRead:()=>Atomics.compareExchange(o,0,e.WRITTEN,e.READING)===e.READING?(n.position=0,t.read(n),r(t.object),Atomics.store(o,0,e.READ),!0):!1}}})(vr||(vr={}));var b;(function(i){i.length=16,i.generate=()=>t(crypto.getRandomValues(new Uint8Array(i.length))),i.sha256=async r=>{let s=typeof process<"u"&&process.env?.VITEST==="true";return crypto.subtle.digest("SHA-256",s?new Uint8Array(r.slice(0)):r).then(o=>t(new Uint8Array(o.slice(0,i.length))))},i.validate=r=>i.parse(i.toString(r)),i.fromDataInput=r=>{let s=new Uint8Array(i.length);return r.readBytes(new Int8Array(s.buffer)),s},i.toDataOutput=(r,s)=>r.writeBytes(new Int8Array(s.buffer)),i.toString=r=>{let s=w.create(o=>(o+256).toString(16).substring(1),256);return s[r[0]]+s[r[1]]+s[r[2]]+s[r[3]]+"-"+s[r[4]]+s[r[5]]+"-"+s[r[6]]+s[r[7]]+"-"+s[r[8]]+s[r[9]]+"-"+s[r[10]]+s[r[11]]+s[r[12]]+s[r[13]]+s[r[14]]+s[r[15]]},i.parse=r=>{let s=r.replace(/-/g,"").toLowerCase();if(s.length!==32)return y("Invalid UUID format");let o=new Uint8Array(i.length);for(let n=0,a=0;n<32;n+=2,a++)o[a]=parseInt(s.slice(n,n+2),16);return o},i.Comparator=(r,s)=>{if(r.length!==i.length||s.length!==i.length)return y("Unexpected array length for uuid(v4)");for(let o=0;o<i.length;o++){let n=r[o]-s[o];if(n!==0)return n}return 0},i.equals=(r,s)=>i.Comparator(r,s)===0,i.newSet=r=>new At(r,i.Comparator),i.Lowest=i.parse("00000000-0000-4000-8000-000000000000"),i.Highest=i.parse("FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"),i.fromInt=r=>{let s=new Uint8Array(i.Lowest),o=new Uint8Array(new Uint32Array([r]).buffer);for(let n=0;n<4;n++)s[n]=o[n];return s};class e{#e;constructor(){this.#e=new Map}getOrCreate(s){return lt.createIfAbsent(this.#e,s,()=>i.generate())}}i.SimpleIdDecoder=e;let t=r=>(v(r.length===i.length,"UUID must be 16 bytes long"),r[6]=r[6]&15|64,r[8]=r[8]&63|128,r)})(b||(b={}));var Qn;(function(i){i.create=o=>D(o)?D(o?.snap)?i.snap(o?.trackLength,o?.snap?.snapLength,Array.isArray(o?.snap?.threshold)?o?.snap.threshold:[o?.snap?.threshold]):i.identity(o?.trackLength):i.identity(),i.snap=(o=e,n=t,a)=>new s(o,n/o,a),i.identity=(o=e)=>new r(o);let e=128,t=24;class r{length;#e=NaN;#t=NaN;#r=1;constructor(n){this.length=n}begin(n){this.#t=this.#e=n}moveBy(n){v(!isNaN(this.#t),()=>"value has never been set"),this.#e+=n/this.length*this.#r,this.#t=L(this.#e,0,1)}ratio(n){this.#r=n}value(){return v(!isNaN(this.#t),()=>"value has never been set"),this.#t}disable(){}enable(){}}class s{#e;#t;#r;#i;#s=NaN;#o=NaN;#n=1;#a=!0;constructor(n,a,u){v(a>0,()=>`margin(${a}) must be greater then 0`),v(w.isSorted(u),()=>"thresholds are not sorted"),v(a<n,()=>`margin(${a}) must be lower then length(${n})`),this.#e=n,this.#t=a,this.#r=u,this.#i=u.map((h,d)=>h+d*this.#t)}begin(n){this.#a&&(this.#s=this.valueToX(n)),this.#o=n}moveBy(n){v(!isNaN(this.#o),()=>"value has never been set"),this.#s+=n/this.#e*this.#n,this.#o=this.#a?this.xToValue(this.#s):L(this.#s,0,1)}ratio(n){this.#n=n}value(){return v(!isNaN(this.#o),()=>"value has never been set"),this.#o}disable(){this.#a&&(this.#a=!1,this.#s=this.xToValue(this.#s))}enable(){this.#a||(this.#a=!0,this.#s=this.valueToX(this.#s))}valueToX(n){let a=ie.rightMost(this.#r,n,yt);if(a<0)return n;{let u=this.#i[a],h=this.#r[a];return n===h?u+this.#t/2:u+this.#t+(n-h)}}xToValue(n){let a=L(n,0,1+this.#t*this.#r.length),u=ie.rightMost(this.#i,a,yt);if(u<0)return a;{let h=this.#i[u],d=this.#r[u];return a>h+this.#t?a-(h+this.#t)+d:d}}get margin(){return this.#t}}})(Qn||(Qn={}));var Yn;(function(i){class e extends Error{}i.Warning=e,i.warn=t=>{throw new e(t)},i.AbortError=typeof DOMException>"u"?NaN:Object.freeze(new DOMException("AbortError")),i.isAbort=t=>t===i.AbortError||i.isDOMException(t)&&t.name==="AbortError",i.CatchAbort=t=>t===i.AbortError?void 0:y(t),i.isOverconstrained=t=>Zo(t)&&"constraint"in t,i.isDOMException=t=>Zo(t)&&Jo(t,"name","string")&&Jo(t,"message","string")})(Yn||(Yn={}));var Ii=Symbol.for("@openDAW/lib-std");globalThis[Ii]?console.debug(`%c${Ii.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Ii]=!0,console.debug(`%c${Ii.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var wt=class{a1=0;a2=0;b0=0;b1=0;b2=0;constructor(){this.identity()}identity(){this.setNormalizedCoefficients(1,0,0,1,0,0)}setLowpassParams(e,t){if(e=L(e,0,1),e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1-o)/2,a=n,u=2*n,h=n,d=1+s,p=-2*o,f=1-s;this.setNormalizedCoefficients(a,u,h,d,p,f)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}setHighpassParams(e,t){if(e=L(e,0,1),e===1)this.setNormalizedCoefficients(0,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1+o)/2,a=n,u=-2*n,h=n,d=1+s,p=-2*o,f=1-s;this.setNormalizedCoefficients(a,u,h,d,p,f)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNormalizedCoefficients(e,t,r,s,o,n){let a=1/s;return this.b0=e*a,this.b1=t*a,this.b2=r*a,this.a1=o*a,this.a2=n*a,this}setLowShelfParams(e,t){e=L(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(r*r,0,0,1,0,0);else if(e>0){let s=qe*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),u=2*Math.sqrt(r)*n,h=r+1,d=r-1,p=r*(h-d*a+u),f=2*r*(d-h*a),A=r*(h-d*a-u),N=h+d*a+u,S=-2*(d+h*a),M=h+d*a-u;this.setNormalizedCoefficients(p,f,A,N,S,M)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setHighShelfParams(e,t){e=L(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){let s=qe*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),u=2*Math.sqrt(r)*n,h=r+1,d=r-1,p=r*(h+d*a+u),f=-2*r*(d+h*a),A=r*(h+d*a-u),N=h-d*a+u,S=2*(d-h*a),M=h-d*a-u;this.setNormalizedCoefficients(p,f,A,N,S,M)}else this.setNormalizedCoefficients(r*r,0,0,1,0,0);return this}setPeakingParams(e,t,r){e=L(e,0,1),t=Math.max(0,t);let s=Math.pow(10,r/40);if(e>0&&e<1)if(t>0){let o=qe*e,n=Math.sin(o)/(2*t),a=Math.cos(o),u=1+n*s,h=-2*a,d=1-n*s,p=1+n/s,f=-2*a,A=1-n/s;this.setNormalizedCoefficients(u,h,d,p,f,A)}else this.setNormalizedCoefficients(s*s,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setAllpassParams(e,t){if(e=L(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1-s,a=-2*o,u=1+s,h=1+s,d=-2*o,p=1-s;this.setNormalizedCoefficients(n,a,u,h,d,p)}else this.setNormalizedCoefficients(-1,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNotchParams(e,t){if(e=L(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=qe*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1,a=-2*o,u=1,h=1+s,d=-2*o,p=1-s;this.setNormalizedCoefficients(n,a,u,h,d,p)}else this.setNormalizedCoefficients(0,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setBandpassParams(e,t){if(e=Math.max(0,e),t=Math.max(0,t),e>0&&e<1){let r=qe*e;if(t>0){let s=Math.sin(r)/(2*t),o=Math.cos(r),n=s,a=0,u=-s,h=1+s,d=-2*o,p=1-s;this.setNormalizedCoefficients(n,a,u,h,d,p)}else this.setNormalizedCoefficients(1,0,0,1,0,0)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}getFrequencyResponse(e,t,r){v(e.length===t.length&&e.length===r.length,"Array lengths do not match");let s=this.b0,o=this.b1,n=this.b2,a=this.a1,u=this.a2;for(let h=0;h<e.length;++h){let d=-Math.PI*2*e[h],p=Math.cos(d),f=Math.sin(d),A=s+((o+n*p)*p-n*f*f),N=(o+n*p)*f+n*f*p,S=1+((a+u*p)*p-u*f*f),M=(a+u*p)*f+u*f*p,k=S*S+M*M,K=(A*S+N*M)/k,q=(N*S-A*M)/k;t[h]=Math.sqrt(K*K+q*q),r[h]=Math.atan2(q,K)}}};var be=class{#e=0;#t=0;#r=0;#i=0;reset(){this.#e=0,this.#t=0,this.#r=0,this.#i=0}process({a1:e,a2:t,b0:r,b1:s,b2:o},n,a,u,h){let d=this.#e,p=this.#t,f=this.#r,A=this.#i;for(let N=u;N<h;N++){let S=n[N],M=a[N]=r*S+s*d+o*p-e*f-t*A+1e-18-1e-18;p=d,d=S,A=f,f=M}this.#e=d,this.#t=p,this.#r=f,this.#i=A}processFrame({a1:e,a2:t,b0:r,b1:s,b2:o},n){let a=r*n+s*this.#e+o*this.#t-e*this.#r-t*this.#i+1e-18-1e-18;return this.#t=this.#e,this.#e=n,this.#i=this.#r,this.#r=a,a}},er=class{#e;order;constructor(e){this.#e=w.create(()=>new be,e),this.order=this.#e.length}reset(){this.#e.forEach(e=>e.reset())}process(e,t,r,s,o){for(let n=0;n<this.order;n++)this.#e[n].process(e,t,r,s,o),t=r}processFrame(e,t){for(let r=0;r<this.order;r++)t=this.#e[r].processFrame(e,t);return t}};var Xn;(function(i){function e(t,r,s={}){let{interval:o=64,scanSteps:n=1024,scanSamples:a=2048,minBPM:u=90,maxBPM:h=180}=s,d=new Float32Array(Math.floor(t.length/o)),p=0,f=0,A=0;for(let H of t){let Y=Math.abs(H);p+=(Y-p)*(Y>p?1/8:1/512),++f===o&&(f=0,d[A++]=p)}if(!d.length)return NaN;let N=(H,Y)=>H[Math.floor(Y)]??0,S=H=>r/(H/60)/o,M=H=>r/(H*o)*60,k=[-32,-16,-8,-4,-2,-1,1,2,4,8,16,32],K=[-.5,-.25,.25,.5],q=H=>{let Y=Math.random()*d.length,ae=N(d,Y),He=0,rt=0;for(let Ge of k){let oi=1/Math.abs(Ge);He+=oi*Math.abs(N(d,Y+Ge*H)-ae),rt+=oi}for(let Ge of K){let oi=Math.abs(Ge);He-=oi*Math.abs(N(d,Y+Ge*H)-ae),rt+=oi}return He/rt},z=H=>{let Y=0;for(let ae=0;ae<a;++ae)Y+=q(H);return Y/a},ee=S(u),he=S(h),ce=(ee-he)/n,_=u,j=1/0;for(let H=he;H<=ee;H+=ce){let Y=M(H),ae=z(H)*(u/Y);ae<j&&(j=ae,_=Y)}return _}i.detect=e})(Xn||(Xn={}));var Zn;(function(i){i.Major=[0,2,4,5,7,9,11],i.Minor=[0,2,3,5,7,8,10],i.NoteLabels=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],i.compile=(e,t,r,s)=>w.create(o=>{let n=r+o*2,a=e[n%7]+Math.floor(n/7)*12;return t+a},s),i.toString=e=>i.NoteLabels[e%12]+(Math.floor(e/12)-2)})(Zn||(Zn={}));var tr;(function(i){i.Comparator=(e,t)=>e.position-t.position,i.PositionExtractor=e=>e.position})(tr||(tr={}));var rr;(function(i){i.complete=e=>e.position+e.duration,i.DescendingComparator=(e,t)=>i.complete(t)-i.complete(e)})(rr||(rr={}));var Te;(function(i){i.globalToLocal=(t,r)=>ai(r-t.position+t.loopOffset,t.loopDuration),i.locateLoop=({position:t,complete:r,loopOffset:s,loopDuration:o},n,a)=>{let u=t-s,h=u+o;if(u>=a||h<=n)return m.None;let d=Math.max(u,n),p=Math.min(h,a);return m.wrap({index:0,rawStart:u,rawEnd:h,regionStart:Math.max(u,t),regionEnd:Math.min(h,r),resultStart:d,resultEnd:p,resultStartValue:u<d?(d-u)/o:0,resultEndValue:h>p?(p-u)/o:1})};function*e({position:t,complete:r,loopOffset:s,loopDuration:o},n,a){let u=t-s,h=Math.max(t,n),d=Math.min(r,a),p=Math.floor((h-u)/o),f=u+p*o;for(;f<d;){let A=f+o,N=Math.max(f,t),S=Math.min(A,r),M=Math.max(f,h),k=Math.min(A,d),K=f<M?(M-f)/o:0,q=A>k?(k-f)/o:1;yield{index:p++,rawStart:f,rawEnd:A,regionStart:N,regionEnd:S,resultStart:M,resultEnd:k,resultStartValue:K,resultEndValue:q},f=A}}i.locateLoops=e})(Te||(Te={}));var Et=class i{static DefaultComparator=(e,t)=>e.position-t.position;static create(e){return new i(e??i.DefaultComparator)}#e;constructor(e){this.#e=new Oi(e)}add(e){this.#e.add(e)}remove(e){return this.#e.remove(e)}contains(e){return this.#e.contains(e)}clear(){this.#e.clear()}optAt(e){return this.#e.optAt(e)}asArray(){return this.#e.asArray()}lowerEqual(e,t){return this.#e.lowerEqual(e,t)}greaterEqual(e,t){return this.#e.greaterEqual(e,t)}floorLastIndex(e){return this.#e.floorLastIndex(e)}ceilFirstIndex(e){return this.#e.ceilFirstIndex(e)}iterateFrom(e,t){return this.#e.isEmpty()?at.empty():this.#e.iterateFrom(e,t)}iterateRange(e,t,r){return this.#e.isEmpty()?at.empty():this.#e.iterate(this.#e.ceilFirstIndex(e),t,r)}length(){return this.#e.length()}isEmpty(){return this.#e.isEmpty()}onIndexingChanged(){this.#e.onIndexingChanged()}},Ft=class i{static Comparator=(e,t)=>e.position-t.position;static create(e){return new i(e)}#e;constructor(e=i.Comparator){this.#e=new Oi(e)}add(e){this.#e.add(e)}remove(e){return this.#e.remove(e)}contains(e){return this.#e.contains(e)}clear(){this.#e.clear()}optAt(e){return this.#e.optAt(e)}asArray(){return this.#e.asArray()}lowerEqual(e,t){return this.#e.lowerEqual(e,t)}greaterEqual(e,t){return this.#e.greaterEqual(e,t)}floorLastIndex(e){return this.#e.floorLastIndex(e)}ceilFirstIndex(e){return this.#e.ceilFirstIndex(e)}iterateFrom(e,t){return this.#e.isEmpty()?at.empty():this.#e.iterateFrom(e,t)}iterateRange(e,t){if(this.#e.isEmpty())return at.empty();let r=Math.max(0,this.#e.floorLastIndex(e)),s=this.#e.optAt(r);if(s===null)return at.empty();for(;s.position+s.duration<=e;)if(s=this.#e.optAt(++r),s===null||s.position>=t)return at.empty();return this.#e.iterate(r,t)}length(){return this.#e.length()}isEmpty(){return this.#e.isEmpty()}onIndexingChanged(){this.#e.onIndexingChanged()}},br=class{#e;constructor(){this.#e=[]}addAndRetain(e){if(this.#e.length===0)this.#e.push(e);else{let t=ie.leftMost(this.#e,e,rr.DescendingComparator);this.#e.splice(t,0,e)}}*overlapping(e,t){let r=this.#e.filter(s=>s.position<=e&&e<s.position+s.duration);yield*D(t)?r.sort(t):r}*releaseLinearCompleted(e){if(this.#e.length!==0)for(let t=this.#e.length-1;t>=0;t--){let r=this.#e[t];if(rr.complete(r)<e)this.#e.splice(t,1),yield r;else return}}*releaseAll(){if(this.#e.length!==0)for(let e=this.#e.length-1;e>=0;e--){let t=this.#e[e];Number.POSITIVE_INFINITY>t.duration&&(this.#e.splice(e,1),yield t)}}isEmpty(){return this.#e.length===0}nonEmpty(){return this.#e.length>0}clear(){w.clear(this.#e)}},Oi=class{comparator;#e=[];#t=!1;modCount=0;constructor(e){this.comparator=e}add(e){++this.modCount,this.#e.push(e),this.#e.length>1&&(this.#t=!0)}remove(e){++this.modCount;let t=this.#e.indexOf(e);return t===-1?!1:(this.#e.splice(t,1),!0)}contains(e){if(this.#e.length===0)return!1;this.#t&&this.#r();let r=e.position,s=ie.leftMostMapped(this.#e,r,yt,tr.PositionExtractor);for(let o=s;o<this.#e.length;o++){let n=this.#e[o];if(n===e)return!0;if(n.position!==r)return!1}return!1}clear(){++this.modCount,w.clear(this.#e),this.#t=!1}optAt(e){return e<0||e>=this.#e.length?null:(this.#t&&this.#r(),this.#e[e])}asArray(){return this.#t&&this.#r(),this.#e}lowerEqual(e,t){if(t===void 0)return this.optAt(this.floorLastIndex(e));let r=this.floorLastIndex(e);for(;r>=0;){let s=this.#e[r--];if(t(s))return s}return null}greaterEqual(e,t){if(t===void 0)return this.optAt(this.ceilFirstIndex(e));let r=this.ceilFirstIndex(e);for(;r<this.#e.length;){let s=this.#e[r++];if(t(s))return s}return null}floorLastIndex(e){return this.#t&&this.#r(),ie.rightMostMapped(this.#e,e,yt,tr.PositionExtractor)}ceilFirstIndex(e){return this.#t&&this.#r(),ie.leftMostMapped(this.#e,e,yt,tr.PositionExtractor)}iterateFrom(e,t){let r=this.floorLastIndex(e),s=r;if(s<0)return this.iterate(0,Ie.MAX_VALUE,t);for(;s>=0;){let o=this.optAt(s);if(o!==null&&t!==void 0&&t(o))return this.iterate(s,Ie.MAX_VALUE,t);s--}return this.iterate(r,Ie.MAX_VALUE,t)}length(){return this.#e.length}isEmpty(){return this.#e.length===0}onIndexingChanged(){this.#t=this.length()>1}*iterate(e,t,r=Vi.alwaysTrue){for(this.#t&&this.#r();e<this.#e.length;){let s=this.#e[e++];if(s.position>=t)return;r(s)&&(yield s)}}#r(){this.#e.sort(this.comparator),this.#t=!1}};var ki=class i{static reverse(e){return e=(e&1431655765)<<1|e>>>1&1431655765,e=(e&858993459)<<2|e>>>2&858993459,e=(e&252645135)<<4|e>>>4&252645135,e=e<<24|(e&65280)<<8|e>>>8&65280|e>>>24,e}#e;#t;#r;#i;constructor(e){this.#e=e;let t=e/2;this.#t=32-Math.floor(Math.log2(e))|0,this.#r=new Float32Array(t),this.#i=new Float32Array(t);for(let r=0;r<t;r++){let s=2*Math.PI*r/e;this.#r[r]=Math.cos(s),this.#i[r]=Math.sin(s)}}process(e,t){let r,s,o,n;for(let h=0;h<this.#e;++h)s=i.reverse(h)>>>this.#t,s>h&&(n=e[h],e[h]=e[s],e[s]=n,n=t[h],t[h]=t[s],t[s]=n);let a=this.#r,u=this.#i;for(let h=2;h<=this.#e;h<<=1){let d=h>>1,p=this.#e/h;for(r=0;r<this.#e;r+=h){let f=r+d;for(s=r,o=0;s<f;s++,o=o+p|0){let A=s+d|0,N=a[o],S=u[o],M=e[A],k=t[A],K=M*N+k*S,q=k*N-M*S,z=e[s],ee=t[s];e[A]=z-K,t[A]=ee-q,e[s]=z+K,t[s]=ee+q}}if(h===this.#e)break}}};var cn=(i,e)=>Math.floor(3840/e)*i,Jn=(i,e=4,t=4)=>{let r=cn(1,t),s=Math.floor(i/r),o=Math.floor(s/e),a=(Math.floor(i)-cn(o*e,t))%r,u=Math.floor(a/240),h=a%240;return{bars:o,beats:s-o*e,semiquavers:u,ticks:h}},ea=(i,e)=>i*e/60*960,ta=(i,e)=>i*60/960/e,Wa=(i,e,t)=>ea(i/t,e),ja=(i,e,t)=>ta(i,e)*t,G={Bar:3840,Quarter:960,SemiQuaver:240,fromSignature:cn,toParts:Jn,secondsToPulses:ea,pulsesToSeconds:ta,samplesToPulses:Wa,pulsesToSamples:ja,toString:(i,e=4,t=4)=>{let{bars:r,beats:s,semiquavers:o,ticks:n}=Jn(i|0,e,t);return`${r+1}.${s+1}.${o+1}:${n}`}};var ze;(function(i){i.builder=()=>new e,i.toDouble=([t,r])=>t/r,i.toPPQN=([t,r])=>G.fromSignature(t,r);class e{#e=[];add(r){return this.#e.push(r),this}asArray(){return this.#e}asAscendingArray(){return this.#e.toSorted((r,s)=>i.toDouble(r)-i.toDouble(s))}asDescendingArray(){return this.#e.toSorted((r,s)=>i.toDouble(s)-i.toDouble(r))}}})(ze||(ze={}));var Bt=class{static*iterate(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield o,o=++s*r}static*iterateWithIndex(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield{position:o,index:s},o=++s*r}};var Ui=class{#e;#t;constructor(){this.#e=[],this.#t=new Map}addVertex(e){v(!this.#e.includes(e),"Vertex already exists"),this.#e.push(e),v(!this.#t.has(e),"Predecessor already exists"),this.#t.set(e,[])}removeVertex(e){w.remove(this.#e,e);let t=this.#t.delete(e);v(t,"Predecessor does not exists")}getPredecessors(e){return this.#t.get(e)??w.empty()}predecessors(){return this.#t}vertices(){return this.#e}addEdge([e,t]){let r=U(this.#t.get(t),`[add] Edge has unannounced vertex. (${t})`);v(!r.includes(e),`${e} is already marked.`),r.push(e)}removeEdge([e,t]){let r=U(this.#t.get(t),`[remove] Edge has unannounced vertex. (${t})`);v(r.includes(e),`${e} is not marked.`),w.remove(r,e)}isEmpty(){return this.#e.length===0}},Ki=class{#e;#t;#r;#i;#s;constructor(e){this.#e=e,this.#t=[],this.#r=new Set,this.#i=new Set,this.#s=new Map}update(){this.#o(),this.#e.vertices().forEach(e=>this.#n(e))}sorted(){return this.#t}hasLoops(){return this.#i.size!==0}#o(){this.#a();let e=new Map;for(let r of this.#e.vertices())this.#s.set(r,new Set),e.set(r,new Set);for(let r of this.#e.vertices())for(let s of this.#e.getPredecessors(r))U(this.#s.get(s),`Could not find Successor for ${s}`).add(r);let t;do{t=!1;for(let r of this.#e.vertices()){U(e.get(r)).clear();for(let s of U(this.#s.get(r)))for(let o of U(this.#s.get(s)))this.#s.get(r)?.has(o)||(t=!0,U(e.get(r)).add(o))}for(let r of this.#e.vertices()){let s=U(this.#s.get(r));U(e.get(r)).forEach(o=>s.add(o))}}while(t)}#n(e){if(!this.#r.has(e)){this.#r.add(e);for(let t of this.#e.getPredecessors(e)){if(U(this.#s.get(e)).has(t)){this.#i.add(e),this.#i.add(t);continue}this.#n(t)}this.#t.push(e)}}#a(){w.clear(this.#t),this.#r.clear(),this.#i.clear(),this.#s.clear()}};var ci;(function(i){i.Identity={warp:e=>e,unwarp:e=>e}})(ci||(ci={}));var Li=class{#e;constructor(e){this.#e=e}warp(e){return this.#t(!0,e)}unwarp(e){return this.#t(!1,e)}#t(e,t){let r=this.#e.duration(),s=st(t,r),o=(t-s)/r,n=e?this.#e.fx(o):this.#e.fy(o);return s+n*r}};var ra;(function(i){i.BlackKeyIndices=[1,3,6,8,10],i.BlackKeyBits=i.BlackKeyIndices.reduce((t,r)=>t|=1<<r,0),i.Names={English:["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],German:["C","Cis","D","Dis","E","F","Fis","G","Gis","A","Ais","H"],Solfege:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],French:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Spanish:["Do","Do#","Re","Re#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Japanese:["\u30C9","\u30C9\u266F","\u30EC","\u30EC\u266F","\u30DF","\u30D5\u30A1","\u30D5\u30A1\u266F","\u30BD","\u30BD\u266F","\u30E9","\u30E9\u266F","\u30B7"]},i.isBlackKey=t=>(i.BlackKeyBits&1<<t%12)!==0,i.toFullString=t=>`${i.Names.English[t%12]}${Math.floor(t/12)-2}`;class e{#e;#t;constructor(r,...s){this.#e=r,this.#t=s.reduce((o,n)=>o|=1<<n,0)}get name(){return this.#e}get bits(){return this.#t}has(r){return(this.#t&1<<r%12)!==0}equals(r){return this.#t===r.bits}}i.StockScales=[new e("Major",0,2,4,5,7,9,11),new e("Natural Minor",0,2,3,5,7,8,10),new e("Harmonic Minor",0,2,3,5,7,8,11),new e("Melodic Minor",0,2,3,5,7,9,11),new e("Dorian",0,2,3,5,7,9,10),new e("Phrygian",0,1,3,5,7,8,10),new e("Lydian",0,2,4,6,7,9,11),new e("Mixolydian",0,2,4,5,7,9,10),new e("Locrian",0,1,3,5,6,8,10),new e("Pentatonic Major",0,2,4,7,9),new e("Pentatonic Minor",0,3,5,7,10),new e("Blues",0,3,5,6,7,10),new e("Whole Tone",0,2,4,6,8,10),new e("Diminished",0,2,3,5,6,8,9,11),new e("Augmented",0,3,4,7,8,11)]})(ra||(ra={}));var Ce;(function(i){i.isOfType=e=>e.type==="note-event",i.Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.pitch-t.pitch;return s!==0?s:0},i.curveFunc=(e,t)=>t<0?e**2**-t:1-(1-e)**2**t,i.inverseCurveFunc=(e,t)=>t<0?e**2**t:1-Math.max(0,1-e)**2**-t,i.CompleteComparator=(e,t)=>{let r=rr.complete(e)-rr.complete(t);return r!==0?r:e.pitch-t.pitch}})(Ce||(Ce={}));var ut;(function(i){i[i.sine=0]="sine",i[i.triangle=1]="triangle",i[i.sawtooth=2]="sawtooth",i[i.square=3]="square"})(ut||(ut={}));var $i=class{#e=0;#t=0;generate(e,t,r,s,o){for(let n=s;n<o;n++){let a=this.#e%1,u=0;switch(r){case ut.sine:u=Math.sin(2*Math.PI*a);break;case ut.sawtooth:u=2*a-1,u-=this.#r(a,t);break;case ut.square:u=a<.5?1:-1,u+=this.#r(a,t),u-=this.#r((a+.5)%1,t);break;case ut.triangle:let h=a<.5?1:-1;h+=this.#r(a,t),h-=this.#r((a+.5)%1,t),this.#t+=h*(4*t),u=this.#t;break}e[n]=u,this.#e+=t}}#r(e,t){return e<t?(e/=t,e+e-e*e-1):e>1-t?(e=(e-1)/t,e*e+e+e+1):0}};var ht;(function(i){let e;(function(t){t[t.Linear=0]="Linear",t[t.EqualPower=1]="EqualPower"})(e=i.Mixing||(i.Mixing={})),i.zero=()=>({ll:0,lr:0,rl:0,rr:0}),i.identity=()=>({ll:1,lr:0,rl:0,rr:1}),i.update=(t,{gain:r,panning:s,invertL:o,invertR:n,stereo:a,swap:u},h=e.EqualPower)=>{let[d,p]=i.panningToGains(s,h),f=d*r,A=p*r;o&&(f*=-1),n&&(A*=-1);let N=Math.max(0,-a),S=Math.max(0,a),M=1-S,k=1+S,K=N*.5,q=1-N,z=(M+k)*.5,ee=(M-k)*.5,he=(M-k)*.5,ce=(M+k)*.5,_=f*(K+q)*z+A*K*ee,j=f*(K+q)*he+A*K*ce,H=f*K*z+A*(K+q)*ee,Y=f*K*he+A*(K+q)*ce;u?(t.ll=j,t.rl=_,t.lr=Y,t.rr=H):(t.ll=_,t.lr=H,t.rl=j,t.rr=Y)},i.panningToGains=(t,r)=>{let s=L(t,-1,1);switch(r){case e.Linear:return[Math.min(1-s,1),Math.min(s+1,1)];case e.EqualPower:return[Math.cos((s+1)*rn),Math.sin((s+1)*rn)]}},i.applyFrame=(t,r,s)=>[t.ll*r+t.rl*s,t.lr*r+t.rr*s],i.processFrames=(t,r,s,o,n)=>{let[a,u]=r,[h,d]=s;for(let p=o;p<n;p++){let f=a[p],A=u[p];h[p]=t.ll*f+t.rl*A,d[p]=t.lr*f+t.rr*A}},i.replaceFrames=(t,[r,s],o,n)=>{for(let a=o;a<n;a++){let u=r[a],h=s[a];r[a]=t.ll*u+t.rl*h,s[a]=t.lr*u+t.rr*h}}})(ht||(ht={}));var _e;(function(i){i.linear=(r,s=.005)=>new e(Math.ceil(r*s)|0),i.stereoMatrix=(r,s=.005)=>new t(Math.ceil(r*s)|0);class e{#e;#t=0;#r=0;#i=0;#s=0;constructor(s){this.#e=s}set(s,o){this.#t!==s&&(o===!0?(this.#r=s,this.#i=(s-this.#t)/this.#e,this.#s=this.#e):(this.#t=this.#r=s,this.#i=0,this.#s=0))}get(){return this.#t}moveAndGet(){return 0<this.#s&&(this.#t+=this.#i,--this.#s===0&&(this.#i=0,this.#t=this.#r)),this.#t}isFixed(s){return this.#t===s&&this.#s===0}isInterpolating(){return this.#s>0}}class t{#e;#t=ht.zero();#r=ht.zero();#i=ht.zero();#s=0;constructor(s){this.#e=s}update(s,o,n){ht.update(this.#r,s,o),n===!0?(this.#i.ll=(this.#r.ll-this.#t.ll)/this.#e,this.#i.lr=(this.#r.lr-this.#t.lr)/this.#e,this.#i.rl=(this.#r.rl-this.#t.rl)/this.#e,this.#i.rr=(this.#r.rr-this.#t.rr)/this.#e,this.#s=this.#e):(this.#t.ll=this.#r.ll,this.#t.lr=this.#r.lr,this.#t.rl=this.#r.rl,this.#t.rr=this.#r.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0)}processFrames(s,o,n,a){let[u,h]=s,[d,p]=o;if(this.isInterpolating())for(let f=n;f<a;f++){let A=u[f],N=h[f],S=this.moveAndGet();d[f]=S.ll*A+S.rl*N,p[f]=S.lr*A+S.rr*N}else{let f=this.#r;for(let A=n;A<a;A++){let N=u[A],S=h[A];d[A]=f.ll*N+f.rl*S,p[A]=f.lr*N+f.rr*S}}}set(s,o){this.#o(s)||(o===!0?(this.#r.ll=s.ll,this.#r.lr=s.lr,this.#r.rl=s.rl,this.#r.rr=s.rr,this.#i.ll=(s.ll-this.#t.ll)/this.#e,this.#i.lr=(s.lr-this.#t.lr)/this.#e,this.#i.rl=(s.rl-this.#t.rl)/this.#e,this.#i.rr=(s.rr-this.#t.rr)/this.#e,this.#s=this.#e):(this.#t.ll=this.#r.ll=s.ll,this.#t.lr=this.#r.lr=s.lr,this.#t.rl=this.#r.rl=s.rl,this.#t.rr=this.#r.rr=s.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0))}get(){return this.#t}moveAndGet(){return 0<this.#s&&(this.#t.ll+=this.#i.ll,this.#t.lr+=this.#i.lr,this.#t.rl+=this.#i.rl,this.#t.rr+=this.#i.rr,--this.#s===0&&(this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#t.ll=this.#r.ll,this.#t.lr=this.#r.lr,this.#t.rl=this.#r.rl,this.#t.rr=this.#r.rr)),this.#t}isFixed(s){return this.#o(s)&&this.#s===0}isInterpolating(){return this.#s>0}#o(s){return this.#t.ll===s.ll&&this.#t.lr===s.lr&&this.#t.rl===s.rl&&this.#t.rr===s.rr}}i.StereoMatrixRamp=t})(_e||(_e={}));var Ar=class{#e;#t;#r;#i;constructor(e){this.#e=new Float32Array(e),this.#t=1/e,this.#r=0,this.#i=0}pushPop(e){let t=e*e;return this.#i-=this.#e[this.#r],this.#i+=t,this.#e[this.#r]=t,++this.#r===this.#e.length&&(this.#r=0),this.#i<=0?0:Math.sqrt(this.#i*this.#t)}clear(){this.#e.fill(0),this.#i=0,this.#r=0}};var Qa=Math.log(10)/20,ia=(i=60,e=440)=>e*Math.pow(2,(i+3)/12-6);var Ae=i=>Math.exp(i*Qa);var qi=i=>Ae(20*Math.log10(i));var Nt={None:{type:"none"},Linear:{type:"linear"},Curve:i=>({type:"curve",slope:i})},zi;(function(i){i.Comparator=(s,o)=>{let n=s.position-o.position;if(n!==0)return n;let a=s.index-o.index;return a!==0?a:s===o?0:y(`${s} and ${o} are identical in terms of comparison`)};function*e(s,o,n){if(s.isEmpty())return se.empty();for(let a of s.iterateFrom(o))if(yield a,a.position>=n)return}i.iterateWindow=e,i.nextEvent=(s,o)=>{let n=s.asArray(),a=ie.rightMost(n,o,i.Comparator);return a===-1?null:n[a+1]??null},i.valueAt=(s,o,n)=>{if(s.isEmpty())return n;let a=s.iterateFrom(o),{done:u,value:h}=a.next();if(u)return n;if(h.position<=o){let{done:d,value:p}=a.next();if(d)return h.value;if(o<p.position)return r(h,p,o);if(h.interpolation===Nt.None)return h.value}return h.value};function*t(s,o,n,a){if(s.isEmpty())return;let u=s.iterateFrom(o),{done:h,value:d}=u.next();if(h)return;let p=n/a,f=d;if(f.position>o){for(;o<f.position;)if(yield{position:o,value:f.value},o+=p,o>n)return;f.position<=n&&(yield f)}for(;o<=n;){let{done:A,value:N}=u.next();if(A)break;for(;o<N.position;){if(o>n)return;yield{position:o,value:r(f,N,o)},o+=p}N.position<n&&(f.interpolation===Nt.None&&(yield{position:N.position,value:f.value}),yield N),f=N}for(;o<=n;)yield{position:o,value:f.value},o+=p}i.quantise=t;let r=({value:s,position:o,interpolation:n},a,u)=>n.type==="none"?s:n.type==="linear"?s+(u-o)/(a.position-o)*(a.value-s):n.type==="curve"?Oe.valueAt({slope:n.slope,steps:a.position-o,y0:s,y1:a.value},u-o):y("Unknown interpolation")})(zi||(zi={}));var di;(function(i){let e;(function(t){t[t.Bartlett=0]="Bartlett",t[t.Blackman=1]="Blackman",t[t.BlackmanHarris=2]="BlackmanHarris",t[t.Hamming=3]="Hamming",t[t.Hanning=4]="Hanning"})(e=i.Type||(i.Type={})),i.create=(t,r)=>{let s=new Float32Array(r),o=Math.PI/(r-1);switch(t){case e.Bartlett:{let n=(r>>1)-1,a=0;for(;a<=n;++a)s[a]=2*a/(r-1);for(;a<r;++a)s[a]=2-2*a/(r-1);return s}case e.Blackman:{let n=2*o,a=4*o;for(let u=0;u<r;++u)s[u]=.42323-.49755*Math.cos(n*u)+.07922*Math.cos(a*u);return s}case e.BlackmanHarris:{let n=2*o,a=4*o,u=6*o;for(let h=0;h<r;++h)s[h]=.35875-.48829*Math.cos(n*h)+.14128*Math.cos(a*h)-.01168*Math.cos(u*h);return s}case e.Hamming:{let n=2*o;for(let a=0;a<r;++a)s[a]=.54-.46*Math.cos(n*a);return s}case e.Hanning:{let n=2*o;for(let a=0;a<r;++a)s[a]=.5-.5*Math.cos(n*a);return s}}}})(di||(di={}));var _i=Symbol.for("@openDAW/lib-dsp");globalThis[_i]?console.debug(`%c${_i.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[_i]=!0,console.debug(`%c${_i.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Hi=class extends AudioWorkletProcessor{#e;#t;#r;#i;#s;#o=0;constructor({processorOptions:{sab:e,numberOfChannels:t,rmsWindowInSeconds:r,valueDecay:s}}){super(),this.#e=t,this.#t=new Float32Array(t),this.#r=new Float32Array(t),this.#i=w.create(()=>new Ar(sampleRate*r),t);let o=Se.createBuilder({peak:Se.floats(t),rms:Se.floats(t)})();this.#s=vr.writer(o,e,n=>{let a=Math.exp(-(128*this.#o)/(sampleRate*s));for(let u=0;u<t;++u){let h=this.#t[u],d=this.#r[u];n.peak[u]=h,n.rms[u]=Math.sqrt(d),this.#t[u]=h*a,this.#r[u]=d*a}this.#o=0})}process([e]){for(let t=0;t<this.#e;++t){let r=e[t];if(r===void 0)this.#t[t]=0,this.#r[t]=0;else{let s=this.#i[t],o=this.#t[t],n=this.#r[t];for(let a=0;a<128;++a){let u=r[a];o=Math.max(o,Math.abs(u)),n=Math.max(n,s.pushPop(u*u))}this.#t[t]=o,this.#r[t]=n}}return this.#o++,this.#s.tryWrite(),!0}};var Q=class i{static newSet(e){return new At(e,i.Comparator)}static compose=(e,...t)=>{let r=t.length===0?this.#e:new Int16Array(t);return v(r.every((s,o)=>s===t[o]),`fieldKeys (${r.join(",")}) only allows i16`),new i(e,r)};static decode(e){let t=e.split("/");return v(t.length>0,"Unable to parse Address"),i.compose(b.parse(t[0]),...t.slice(1).map(r=>parseInt(r)))}static reconstruct(e){return this.compose(e[0],...e[1])}static boxRange(e,t,r){let s=e.values(),o=ie.leftMostMapped(s,t,b.Comparator,r),n=s.length;if(o<0||o>=n)return null;for(let a=o;a<n;a++)if(b.Comparator(r(s[a]),t)!==0)return o<a?[o,a]:null;return[o,n]}static Comparator=(e,t)=>{let r=b.Comparator(e.#t,t.#t);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return e.#r.length-t.#r.length};static MinimalComparator=(e,t)=>{let r=b.Comparator(e.#t,t.#t);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return 0};static LengthComparator=(e,t)=>{let r=b.Comparator(e.#t,t.#t);return r!==0?r:t.#r.length-e.#r.length};static#e=new Int16Array(0);#t;#r;constructor(e,t){this.#t=e,this.#r=t}get uuid(){return this.#t}get fieldKeys(){return this.#r}isBox(){return this.#r.length===0}isContent(){return!this.isBox()}equals(e){return i.Comparator(this,e)===0}compareTo(e){return i.Comparator(this,e)}append(e){return new i(this.#t,new Int16Array([...this.#r,e]))}startsWith(e){return b.Comparator(e.#t,this.#t)===0&&e.#r.length<=this.#r.length&&e.#r.every((t,r)=>this.#r[r]===t)}write(e){e.writeBytes(new Int8Array(this.#t.buffer)),e.writeByte(this.#r.length),this.#r.forEach(t=>e.writeShort(t))}moveTo(e){return new i(e,this.#r)}decompose(){return[this.#t,this.#r]}toJSON(){return{uuid:Array.from(this.#t.values()),fields:Array.from(this.#r.values())}}toArrayBuffer(){let e=new Uint8Array(b.length+this.#r.length);return e.set(this.#t,0),e.set(this.#r,b.length),e.buffer}toString(){return[b.toString(this.#t),...this.#r].join("/")}static read(e){let t=b.fromDataInput(e),r=e.readByte();return i.compose(t,...w.create(()=>e.readShort(),r))}},ir;(function(i){i.AddressReader=e=>e.address,i.Comparator=({address:e},{address:t})=>Q.Comparator(e,t),i.equals=(e,t)=>{let[r,s]=ie.rangeMapped(t,e,Q.Comparator,i.AddressReader);return t.slice(r,s+1)},i.startsWith=(e,t)=>{let[r,s]=ie.rangeMapped(t,e,Q.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>o.address.startsWith(e))},i.endsWith=(e,t)=>{let r=ie.leftMostMapped(t,e,Q.LengthComparator,i.AddressReader),s=ie.rightMostMapped(t,e,Q.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>e.startsWith(o.address))}})(ir||(ir={}));var je=class i{static validate(e,t){if(e.address.equals(t.address))return m.wrap(`PointerField cannot point to itself: ${e}`);if(!t.pointerRules.accepts.some(r=>r===e.pointerType)){let r=t.pointerRules.accepts.join(", ");return m.wrap(`${String(e.pointerType)} does not satisfy any of the allowed types (${r}).`)}return m.None}#e;#t;#r;#i=m.None;constructor(e){this.#e=e,this.#t=new ve,this.#r=new ve}subscribeImmediate(e,...t){return this.#s(this.#t,e,t)}subscribeTransactual(e,...t){return this.#s(this.#r,e,t)}catchupAndSubscribeTransactual(e,...t){let r=Q.newSet(s=>s.address);return r.addMany(this.filter(...t)),r.forEach(s=>e.onAdd(s)),this.subscribeTransactual({onAdd:s=>{r.add(s)&&e.onAdd(s)},onRemove:s=>{r.removeByKey(s.address),e.onRemove(s)}},...t)}filter(...e){return e.length===0?this.incoming():se.filter(this.incoming().values(),t=>e.some(r=>r===t.pointerType))}size(){return this.incoming().length}isEmpty(){return this.size()===0}nonEmpty(){return this.size()>0}contains(e){return this.incoming().some(t=>e.address.equals(t.address))}incoming(){return this.#e.graph.edges().incomingEdgesOf(this.#e)}onAdded(e){let t=i.validate(e,this.#e);if(t.nonEmpty())return y(t.unwrap());this.#i.isEmpty()?(this.#i=m.wrap([{type:"add",pointerField:e}]),this.#e.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"add",pointerField:e}),this.#t.proxy.onAdd(e)}onRemoved(e){this.#i.isEmpty()?(this.#i=m.wrap([{type:"remove",pointerField:e}]),this.#e.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"remove",pointerField:e}),this.#t.proxy.onRemove(e)}toString(){return`{Pointers ${this.#e.address}, pointers: ${this.incoming().values().map(e=>e.toString())}}`}#s(e,t,r){return e.subscribe({onAdd:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onAdd(s)},onRemove:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onRemove(s)}})}#o=()=>{if(this.#e.isAttached()){let e=this.#i.unwrap("Callback without ChangeLog");e.forEach(({type:t,pointerField:r})=>{t==="add"?this.#r.proxy.onAdd(r):t==="remove"?this.#r.proxy.onRemove(r):y(`Unknown type: ${t}`)}),e.length=0}this.#i=m.None}};var dn=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},wr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},I=class i{static hook(e){return new i(e)}#e;#t;#r;#i;constructor({parent:e,fieldKey:t,fieldName:r,pointerRules:s}){this.#e=e,this.#t=t,this.#r=r,this.#i=s,s.mandatory&&this.graph.edges().watchVertex(this)}accept(e){return g(e.visitField,this)}get box(){return this.#e.box}get graph(){return this.#e.graph}get parent(){return this.#e}get fieldKey(){return this.#t}get fieldName(){return this.#r}get pointerRules(){return this.#i}get pointerHub(){return new je(this)}get address(){return this.#e.address.append(this.#t)}get debugPath(){return`${this.box.name}:${this.box.mapFields(e=>e.fieldName,...this.address.fieldKeys).join("/")}`}isBox(){return!1}isField(){return!0}isAttached(){return this.graph.findBox(this.address.uuid).nonEmpty()}fields(){return se.empty()}getField(e){return y()}optField(e){return m.None}read(e){}write(e){}disconnect(){if(this.pointerHub.isEmpty())return;let e=this.pointerHub.incoming();e.forEach(t=>{t.defer(),(t.mandatory||this.pointerRules.mandatory&&e.length===1)&&t.box.delete()})}toString(){return`{${this.box.constructor.name}:${this.constructor.name} (${this.fieldName}) ${this.address.toString()}`}};dn([gr,wr("design:type",je),wr("design:paramtypes",[])],I.prototype,"pointerHub",null);dn([gr,wr("design:type",Q),wr("design:paramtypes",[])],I.prototype,"address",null);dn([gr,wr("design:type",String),wr("design:paramtypes",[])],I.prototype,"debugPath",null);var c=Object.freeze({mandatory:!1,accepts:[]});var Er=class i extends I{static create(e,t,r){return new i(e,t,r)}#e;constructor(e,t,r){super(e),this.#e=w.create(s=>t({parent:this,fieldKey:s,fieldName:String(s),pointerRules:c}),r)}accept(e){return g(e.visitArrayField,this)}fields(){return this.#e}getField(e){return U(this.#e[e])}optField(e){return m.wrap(this.#e[e])}read(e){this.#e.forEach(t=>t.read(e))}write(e){this.#e.forEach(t=>t.write(e))}size(){return this.#e.length}toJSON(){return this.#e}};var Pt;(function(i){i.writeFields=(t,r)=>{let s=Object.entries(r);t.writeInt(1179403347),t.writeShort(s.length),s.forEach(([o,n])=>{let a=ue.create();n.write(a);let u=new Int8Array(a.toArrayBuffer());t.writeShort(Number(o)),t.writeInt(u.length),t.writeBytes(u)})},i.readFields=(t,r)=>{v(t.readInt()===1179403347,"Serializer header is corrupt");let s=t.readShort();for(let o=0;o<s;o++){let n=t.readShort();if(pr(r[n]))continue;let a=t.readInt(),u=new Int8Array(a);t.readBytes(u);let{status:h,error:d}=Yt(()=>r[n]?.read(new ge(u.buffer)));h==="failure"&&console.warn(d)}}})(Pt||(Pt={}));var Ya=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},sa=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},P=class i{static DEBUG_DELETION=!1;static Index=0;#e;#t;#r;#i;#s;#o=i.Index++;constructor({uuid:e,graph:t,name:r,pointerRules:s}){this.#e=Q.compose(e),this.#t=t,this.#r=r,this.#i=s,this.#s=this.initializeFields(),s.mandatory&&this.graph.edges().watchVertex(this)}fields(){return Object.values(this.#s)}getField(e){return U(this.#s[e])}optField(e){return m.wrap(this.#s[e])}subscribe(e,t){return this.graph.subscribeVertexUpdates(e,this.address,t)}get box(){return this}get name(){return this.#r}get graph(){return this.#t}get parent(){return this}get address(){return this.#e}get pointerRules(){return this.#i}get creationIndex(){return this.#o}get pointerHub(){return new je(this)}estimateMemory(){let e=new fr;return this.write(e),e.count}isBox(){return!0}asBox(e){return Qt(this,e)}isField(){return!1}isAttached(){return this.#t.findBox(this.address.uuid).nonEmpty()}read(e){Pt.readFields(e,this.#s)}write(e){Pt.writeFields(e,this.#s)}serialize(){let e=ue.create();return e.writeInt(this.#o),e.writeString(this.name),e.writeBytes(new Int8Array(this.address.uuid.buffer)),this.write(e),e.toArrayBuffer()}toArrayBuffer(){let e=ue.create();return this.write(e),e.toArrayBuffer()}incomingEdges(){return this.graph.edges().incomingEdgesOf(this)}outgoingEdges(){return this.graph.edges().outgoingEdgesOf(this)}mapFields(e,...t){if(t.length===0)return w.empty();let r=this.getField(t[0]),s=[e(r)];for(let o=1;o<t.length;o++)r=r.getField(t[o]),s.push(e(r));return s}searchVertex(e){if(e.length===0)return m.wrap(this);let t=this.optField(e[0]);if(t.isEmpty())return m.None;for(let r=1;r<e.length;r++)if(t=t.unwrap().optField(e[r]),t.isEmpty())return m.None;return t}delete(){let{boxes:e,pointers:t}=this.graph.dependenciesOf(this);i.DEBUG_DELETION&&(console.debug(`Delete ${this.toString()}`),console.debug(" unplugs",[...t].map(r=>r.toString()).join(`
2
2
  `)),console.debug(" unstages",[...e].map(r=>r.toString()).join(`
3
- `),this));for(let r of t)r.defer();for(let r of e)r.unstage();this.unstage()}unstage(){this.graph.unstageBox(this)}toString(){return`${this.constructor.name} ${this.address.toString()}`}};Wa([gr,ea("design:type",je),ea("design:paramtypes",[])],P.prototype,"pointerHub",null);var X;(function(i){i[i.This=0]="This",i[i.Parent=1]="Parent",i[i.Children=2]="Children"})(X||(X={}));var Gi;(function(i){i.create=()=>new cn})(Gi||(Gi={}));var cn=class{#e=new pi(ir.equals);#t=new pi(ir.startsWith);#r=new pi(ir.endsWith);#i=[];#s=0;#o=!1;subscribe(e,t,r){let s=new dn(t,e,this.#s++,r);if(this.#o){let o=new pn(s,e);return this.#i.push(o),o}else return this.subscribeMonitor(s,e)}dispatch(e){this.#o=!0,[...this.#e.filter(e),...this.#t.filter(e),...this.#r.filter(e)].sort(({order:r},{order:s})=>r-s).forEach(r=>r.procedure(e)),this.#o=!1,this.#i.forEach(r=>r.subscribe(this)),this.#i.length=0}subscribeMonitor(e,t){switch(t){case X.This:return this.#e.subscribe(e);case X.Parent:return this.#t.subscribe(e);case X.Children:return this.#r.subscribe(e);default:return it(t)}}countStations(){return this.#e.count()+this.#t.count()+this.#r.count()}},dn=class{address;propagation;order;procedure;constructor(e,t,r,s){this.address=e,this.propagation=t,this.order=r,this.procedure=s}toString(){return`{ Monitor address: ${this.address}, propagation: ${X[this.propagation]}, order: ${this.order} }`}},pi=class{filterStrategy;#e=[];#t=!0;constructor(e){this.filterStrategy=e}subscribe(e){return this.#e.push(e),this.#t=this.#e.length<2,{terminate:()=>{let t=this.#e.length;for(;--t>=0;)this.#e[t]===e&&this.#e.splice(t,1)}}}stations(){return this.#t||(this.#e.sort(ir.Comparator),this.#t=!0),this.#e}filter(e){return this.filterStrategy(e.address,this.stations())}count(){return this.#e.length}},pn=class{monitor;propagation;#e=new V;#t=!1;constructor(e,t){this.monitor=e,this.propagation=t}subscribe(e){this.#t||(this.#e.terminate(),this.#e.own(e.subscribeMonitor(this.monitor,this.propagation)))}terminate(){this.#t=!0,this.#e.terminate()}};var pe;(function(i){i.Boolean="boolean",i.Float32="float32",i.Int32="int32",i.String="string",i.Bytes="bytes"})(pe||(pe={}));var or={[pe.Boolean]:{type:pe.Boolean,encode:(i,e)=>i.writeBoolean(e),decode:i=>i.readBoolean()},[pe.Float32]:{type:pe.Float32,encode:(i,e)=>i.writeFloat(e),decode:i=>i.readFloat()},[pe.Int32]:{type:pe.Int32,encode:(i,e)=>i.writeInt(e),decode:i=>i.readInt()},[pe.String]:{type:pe.String,encode:(i,e)=>i.writeString(e),decode:i=>i.readString()},[pe.Bytes]:{type:pe.Bytes,encode:(i,e)=>{i.writeInt(e.length),i.writeBytes(e)},decode:i=>{let e=new Int8Array(i.readInt());return i.readBytes(e),e}}},sr=class extends I{#e;#t;#r;constructor(e,t,r){super(e),this.#e=t,this.#t=this.clamp(r),this.#r=this.#t}accept(e){return g(e.visitPrimitiveField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(X.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.subscribe(e)}get type(){return this.#e}get initValue(){return this.#t}setInitValue(e){b(this.graph.constructingBox(),"Cannot change initial value at runtime"),this.setValue(this.#t=e)}getValue(){return this.#r}setValue(e){let t=this.#r,r=this.clamp(e);this.equals(r)||(this.#r=e,this.graph.onPrimitiveValueUpdate(this,t,r))}writeValue(e,t){this.serialization().encode(e,t)}readValue(e){return this.serialization().decode(e)}reset(){this.setValue(this.#t)}},B=class i extends sr{static create(e,t=!1){return new i(e,t)}constructor(e,t){super(e,pe.Boolean,t)}toggle(){this.setValue(!this.getValue())}serialization(){return or[pe.Boolean]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readBoolean())}write(e){e.writeBoolean(this.getValue())}},F=class i extends sr{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,pe.Float32,t)}serialization(){return or[pe.Float32]}equals(e){return this.getValue()===e}clamp(e){return nt.toFloat32(e)}read(e){this.setValue(e.readFloat())}write(e){e.writeFloat(this.getValue())}},x=class i extends sr{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,pe.Int32,t)}serialization(){return or[pe.Int32]}equals(e){return this.getValue()===e}clamp(e){return Ie.toInt(e)}read(e){this.setValue(e.readInt())}write(e){e.writeInt(this.getValue())}},T=class i extends sr{static create(e,t=""){return new i(e,t)}constructor(e,t){super(e,pe.String,t)}serialization(){return or[pe.String]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readString())}write(e){e.writeString(this.getValue())}},ta=class i extends sr{static create(e,t=this.#e){return new i(e,t)}static#e=Object.freeze(new Int8Array(0));constructor(e,t){super(e,pe.Bytes,t)}serialization(){return or[pe.Bytes]}equals(e){return this.getValue().length===e.length&&this.getValue().every((t,r)=>e[r]===t)}clamp(e){return e}read(e){let t=new Int8Array(e.readInt());e.readBytes(t),this.setValue(t)}write(e){let t=this.getValue();e.writeInt(t.length),e.writeBytes(t)}};var ra;(function(i){i.decode=e=>{let t=e.readInt();return A.create(()=>{switch(e.readString()){case"new":{let s=v.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new mi(s,o,n.buffer)}case"pointer":{let s=Q.read(e),o=e.readBoolean()?m.wrap(Q.read(e)):m.None,n=e.readBoolean()?m.wrap(Q.read(e)):m.None;return new gi(s,o,n)}case"primitive":{let s=Q.read(e),o=e.readString(),n=or[o],a=n.decode(e),u=n.decode(e);return new fi(s,n,a,u)}case"delete":{let s=v.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new xi(s,o,n.buffer)}}},t)}})(ra||(ra={}));var mi=class{type="new";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get uuid(){return this.#e}get name(){return this.#t}get settings(){return this.#r}forward(e){e.createBox(this.#t,this.#e,t=>t.read(new ge(this.#r)))}inverse(e){e.findBox(this.#e).unwrap(()=>`Could not find ${this.#t}`).unstage()}write(e){e.writeString(this.type),v.toDataOutput(e,this.#e),e.writeString(this.#t),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{NewUpdate uuid: ${v.toString(this.#e)}, attachment: ${this.settings.byteLength}b`}toDebugString(e){return this.toString()}},fi=class{type="primitive";#e;#t;#r;#i;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#r=r,this.#i=s}get address(){return this.#e}get oldValue(){return this.#r}get newValue(){return this.#i}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).setValue(this.#r)}forward(e){this.field(e).setValue(this.#i)}field(e){return e.findVertex(this.#e).unwrap(()=>`Could not find PrimitiveField at ${this.#e}`)}write(e){e.writeString(this.type),this.#e.write(e),e.writeString(this.#t.type),this.#t.encode(e,this.#r),this.#t.encode(e,this.#i)}toString(){return`{PrimitiveUpdate oldValue: ${this.#r}, newValue: ${this.#i}`}},gi=class{type="pointer";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get address(){return this.#e}get oldAddress(){return this.#t}get newAddress(){return this.#r}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).targetAddress=this.#t}forward(e){this.field(e).targetAddress=this.#r}field(e){return e.findVertex(this.#e).unwrap(()=>`Could not find PointerField at ${this.#e}`)}write(e){e.writeString(this.type),this.#e.write(e),this.#t.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}}),this.#r.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}toString(){return`{PointerUpdate oldValue: ${this.#t.unwrapOrNull()}, newValue: ${this.#r.unwrapOrNull()}`}},xi=class{type="delete";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get uuid(){return this.#e}get name(){return this.#t}get settings(){return this.#r}forward(e){e.findBox(this.#e).unwrap(()=>`Could not find ${this.#t}`).unstage()}inverse(e){e.createBox(this.#t,this.#e,t=>t.read(new ge(this.#r)))}write(e){e.writeString(this.type),v.toDataOutput(e,this.#e),e.writeString(this.#t),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{DeleteUpdate uuid: ${v.toString(this.#e)}, attachment: ${this.settings.byteLength}b`}};var Xd=Symbol("Unreferenceable"),E=class i extends I{static create(e,t,r){return new i(e,t,r)}static encodeWith(e,t){b(this.#e.isEmpty(),"SerializationEncoder already in use"),this.#e=m.wrap(e);let r=Yt(t);if(this.#e=m.None,r.status==="failure")throw r.error;return r.value}static decodeWith(e,t){b(this.#t.isEmpty(),"SerializationDecoder already in use"),this.#t=m.wrap(e);let r=Yt(t);if(this.#t=m.None,r.status==="failure")throw r.error;return r.value}static#e=m.None;static#t=m.None;#r;#i;#s=m.None;#o=m.None;constructor(e,t,r){super(e),this.#r=t,this.#i=r,r&&this.graph.edges().watchVertex(this)}get pointerHub(){return y(`${this} cannot be pointed to`)}get pointerType(){return this.#r}get mandatory(){return this.#i}accept(e){return g(e.visitPointerField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(X.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.graph.subscribeVertexUpdates(X.This,this.address,()=>this.graph.subscribeEndTransaction(()=>e(this)))}refer(e){this.targetVertex=m.wrap(e)}defer(){this.targetVertex=m.None}get targetVertex(){return this.graph.inTransaction()?this.#o.flatMap(e=>this.graph.findVertex(e)):this.#s}set targetVertex(e){if(e.nonEmpty()){let t=je.validate(this,e.unwrap());t.nonEmpty()&&y(t.unwrap())}this.targetAddress=e.map(t=>t.address)}get targetAddress(){return this.#o}set targetAddress(e){let t=this.#o;t.isEmpty()&&e.isEmpty()||(e.nonEmpty()&&t.unwrapOrNull()?.equals(e.unwrap()))===!0||(this.#o=e,this.graph.onPointerAddressUpdated(this,t,e))}isEmpty(){return this.targetAddress.isEmpty()}nonEmpty(){return this.targetAddress.nonEmpty()}resolvedTo(e){this.#s=e}read(e){let t=e.readBoolean()?m.wrap(Q.read(e)):m.None;this.targetAddress=i.#t.match({none:()=>t,some:r=>r.map(this,t)})}write(e){i.#e.match({none:()=>this.#o,some:t=>t.map(this)}).match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}};var Wi=class{#e;#t;#r;#i;constructor(){this.#e=Q.newSet(e=>e.address),this.#t=Q.newSet(e=>e.address),this.#r=Q.newSet(([e])=>e),this.#i=Q.newSet(([e])=>e.address)}watchVertex(e){if(de(e,E)){if(!e.mandatory)return y("watchVertex called but has no edge requirement");this.#e.add(e)}else{if(!e.pointerRules.mandatory)return y("watchVertex called but has no edge requirement");this.#t.add(e)}}unwatchVerticesOf(...e){let t=({box:{address:{uuid:r}}})=>r;for(let{address:{uuid:r}}of e)this.#o(this.#e,r,t),this.#o(this.#t,r,t);for(let r of e){let s=this.outgoingEdgesOf(r);if(s.length>0)return y(`${r} has outgoing edges: ${s.map(([n,a])=>`[${n.toString()}, ${a.toString()}]`)}`);let o=this.incomingEdgesOf(r);if(o.length>0)return y(`${r} has incoming edges from: ${o.map(n=>n.toString())}`)}}connect(e,t){this.#i.add([e,t]),this.#r.opt(t).match({none:()=>this.#r.add([t,[e]]),some:([,r])=>r.push(e)})}disconnect(e){let[,t]=this.#i.removeByKey(e.address),[,r]=this.#r.get(t);A.remove(r,e),r.length===0&&this.#r.removeByKey(t)}outgoingEdgesOf(e){return this.#s(this.#i,e.address.uuid,([{box:{address:{uuid:t}}}])=>t)}incomingEdgesOf(e){return e.isBox()?this.#s(this.#r,e.address.uuid,([{uuid:t}])=>t).flatMap(([t,r])=>r):this.#r.opt(e.address).mapOr(([t,r])=>r,A.empty())}validateRequirements(){this.#e.forEach(e=>{if(b(e.isAttached(),`Pointer ${e.address.toString()} is not attached`),e.isEmpty())return e.mandatory?y(`Pointer ${e.toString()} requires an edge.`):y(`Illegal state: ${e} has no edge requirements.`)}),this.#t.forEach(e=>{if(b(e.isAttached(),`Target ${e.address.toString()} is not attached`),e.pointerHub.isEmpty())return e.pointerRules.mandatory?y(`Target ${e.toString()} requires an edge.`):y(`Illegal state: ${e} has no edge requirements.`)})}#s(e,t,r){let s=Q.boxRange(e,t,r);return D(s)?e.values().slice(s[0],s[1]):A.empty()}#o(e,t,r){let s=Q.boxRange(e,t,r);D(s)&&e.removeRange(s[0],s[1])}};var ji=class{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u=!1;#h=!1;constructor(e=m.None){this.#e=e,this.#t=v.newSet(t=>t.address.uuid),this.#r=[],this.#n=Gi.create(),this.#i=new ve,this.#s=new ve,this.#o=new ve,this.#a=new Wi,this.#l=[]}beginTransaction(){b(!this.#u,"Transaction already in progress"),this.#u=!0,this.#o.proxy.onBeginTransaction()}endTransaction(){for(b(this.#u,"No transaction in progress"),this.#u=!1,this.#r.length>0&&(this.#r.forEach(({pointerField:e,update:t})=>this.#c(e,t)),this.#r.length=0);this.#l.length>0;)this.#l.splice(0).forEach(e=>e()),this.#l.length>0&&console.debug(`${this.#l.length} new observers while notifying`);this.#o.proxy.onEndTransaction()}inTransaction(){return this.#u}constructingBox(){return this.#h}createBox(e,t,r){return this.#e.unwrap("No box-factory installed")(e,this,t,r)}stageBox(e,t){this.#d(),b(!this.#h,"Cannot construct box while other box is constructing"),D(t)&&(this.#h=!0,t(e),this.#h=!1);let r=this.#t.add(e);b(r,`${e} already staged`);let s=new mi(e.address.uuid,e.name,e.toArrayBuffer());return this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s),e}subscribeTransaction(e){return this.#o.subscribe(e)}subscribeToAllUpdates(e){return this.#i.subscribe(e)}subscribeToAllUpdatesImmediate(e){return this.#s.subscribe(e)}subscribeVertexUpdates(e,t,r){return this.#n.subscribe(e,t,r)}subscribeEndTransaction(e){this.#l.push(e)}unstageBox(e){this.#d();let t=this.#t.removeByKey(e.address.uuid);b(t===e,`${e} could not be found to unstage`),this.#a.unwatchVerticesOf(e);let r=new xi(e.address.uuid,e.name,e.toArrayBuffer());this.#i.proxy.onUpdate(r),this.#s.proxy.onUpdate(r)}findBox(e){return this.#t.opt(e)}findVertex(e){return this.#t.opt(e.uuid).flatMap(t=>t.searchVertex(e.fieldKeys))}boxes(){return this.#t.values()}edges(){return this.#a}checksum(){let e=new Mi;return this.boxes().forEach(t=>t.write(e)),e.result()}onPrimitiveValueUpdate(e,t,r){if(this.#d(),e.isAttached()&&!this.#h){let s=new fi(e.address,e.serialization(),t,r);this.#n.dispatch(s),this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s)}}onPointerAddressUpdated(e,t,r){this.#d(),t.nonEmpty()&&this.#a.disconnect(e),r.nonEmpty()&&this.#a.connect(e,r.unwrap());let s=new gi(e.address,t,r);this.#h?this.#r.push({pointerField:e,update:s}):(this.#c(e,s),this.#s.proxy.onUpdate(s))}#c(e,t){let{oldAddress:r,newAddress:s}=t,o=r.flatMap(a=>this.findVertex(a)),n=s.flatMap(a=>this.findVertex(a));e.resolvedTo(n),o.equals(n)||(o.ifSome(a=>a.pointerHub.onRemoved(e)),n.ifSome(a=>a.pointerHub.onAdded(e))),this.#n.dispatch(t),this.#i.proxy.onUpdate(t)}dependenciesOf(e){let t=new Set,r=new Set,s=o=>{t.has(o)||(t.add(o),o.outgoingEdges().filter(([n])=>!r.has(n)).forEach(([n,a])=>{let u=this.findVertex(a).unwrap(`Could not find target of ${n.toString()}`);if(r.add(n),u.pointerRules.mandatory&&u.pointerHub.incoming().every(h=>r.has(h)))return s(u.box)}),o.incomingEdges().forEach(n=>{r.add(n),n.mandatory&&s(n.box)}))};return s(e),t.delete(e),{boxes:t,pointers:Array.from(r).reverse()}}verifyPointers(){this.#a.validateRequirements();let e=0,t=r=>{for(let s of r.fields())s.accept({visitPointerField:o=>{if(o.targetAddress.nonEmpty()){let n=o.targetVertex.nonEmpty(),a=this.findVertex(o.targetAddress.unwrap()).nonEmpty();b(n,`pointer ${o.address} is broken`),b(a,`Cannot find target for pointer ${o.address}`),e++}},visitObjectField:o=>t(o)})};return this.#t.forEach(r=>t(r)),console.debug("verification complete."),{count:e}}debugBoxes(){console.table(this.#t.values().reduce((e,t)=>(e[v.toString(t.address.uuid)]={class:t.name,"incoming links":t.incomingEdges().length,"outgoing links":t.outgoingEdges().length,"est. memory (bytes)":t.estimateMemory()},e),{}))}debugDependencies(){console.debug("Dependencies:"),this.boxes().forEach(e=>{console.debug(` ${e}`);for(let t of this.dependenciesOf(e).boxes)console.debug(` ${t}`)})}addressToDebugPath(e){return e.flatMap(t=>t.isBox()?this.findBox(t.uuid).map(r=>r.name):this.findBox(t.uuid).flatMap(r=>r.searchVertex(t.fieldKeys).map(s=>s.isField()?s.debugPath:y("Unknown address"))))}toArrayBuffer(){let e=ue.create(),t=this.#t.values();return e.writeInt(t.length),t.forEach(r=>{let s=r.serialize();e.writeInt(s.byteLength),e.writeBytes(new Int8Array(s))}),e.toArrayBuffer()}fromArrayBuffer(e){b(this.#t.isEmpty(),"Cannot call fromArrayBuffer if boxes is not empty");let t=new ge(e),r=t.readInt();this.beginTransaction();let s=[];for(let o=0;o<r;o++){let n=t.readInt(),a=new Int8Array(n);t.readBytes(a);let u=new ge(a.buffer),h=u.readInt(),d=u.readString(),p=v.fromDataInput(u);s.push({creationIndex:h,name:d,uuid:p,boxStream:u})}s.sort((o,n)=>o.creationIndex-n.creationIndex).forEach(({name:o,uuid:n,boxStream:a})=>this.createBox(o,n,u=>u.read(a))),this.endTransaction()}#d(){b(this.#u,()=>"Modification only prohibited in transaction mode.")}};var ia;(function(i){i.insertOrder=(e,t=Number.MAX_SAFE_INTEGER)=>{let r=i.collectIndexedBoxes(e),s=L(t,0,r.length);if(s<r.length)for(let o=s;o<r.length;o++)r[o].index.setValue(o+1);return s},i.removeOrder=(e,t)=>{let r=i.collectIndexedBoxes(e);if(t<r.length)for(let s=t+1;s<r.length;s++)r[s].index.setValue(s-1)},i.moveIndex=(e,t,r)=>{let s=i.collectIndexedBoxes(e),o=s[t];if(r<0){let n=L(t+r,0,s.length-1);for(let a=n;a<t;a++)s[a].index.setValue(a+1);o.index.setValue(n)}else if(r>1){let n=L(t+(r-1),0,s.length-1);for(let a=t;a<n;a++)s[a+1].index.setValue(a);o.index.setValue(n)}else console.warn(`moveIndex had no effect: startIndex: ${t}, delta: ${r}`)},i.isIndexedBox=e=>"index"in e&&e.index instanceof x,i.collectIndexedBoxes=(e,t)=>e.pointerHub.incoming().map(({box:r})=>i.isIndexedBox(r)&&(t===void 0||r instanceof t)?r:y(`${r} has no index field`)).sort((r,s)=>r.index.getValue()-s.index.getValue())})(ia||(ia={}));var le=class extends I{#e;constructor(e){super(e),this.#e=this.initializeFields()}accept(e){return g(e.visitObjectField,this)}fields(){return Object.values(this.#e)}getField(e){return U(this.#e[e])}optField(e){return m.wrap(this.#e[e])}read(e){Pt.readFields(e,this.#e)}write(e){Pt.writeFields(e,this.#e)}toJSON(){return this.#e}};var Re;(function(i){i.sender=(r,s)=>s(new e(r)),i.executor=(r,s)=>new t(r,s);class e{#e;#t=new Map;#r;#i=0;constructor(s){this.#e=s,this.#r=s.subscribe(this.#s)}terminate(){this.#r.terminate()}dispatchAndForget=(s,...o)=>this.#e.send({type:"send",returnId:!1,func:s.name,args:Array.from(se.map(o,n=>({value:n})))});dispatchAndReturn=(s,...o)=>new Promise((n,a)=>{let u=se.reduce(o,(h,d,p)=>(typeof d=="function"&&h.push([p,d]),h),[]);this.#t.set(this.#i,{executorTuple:{resolve:n,reject:a},callbacks:new Map(u)}),this.#e.send({type:"send",returnId:this.#i,func:s.name,args:Array.from(se.map(o,(h,d)=>typeof h=="function"?{callback:d}:{value:h}))}),this.#i++});#s=s=>{let o=this.#t.get(s.returnId);D(o)?s.type==="resolve"?(o.executorTuple.resolve(s.resolve),this.#t.delete(s.returnId)):s.type==="reject"?(o.executorTuple.reject(s.reject),this.#t.delete(s.returnId)):s.type==="callback"&&o.callbacks?.get(s.funcAt).apply(this,s.args):y(`Promise has already been resolved. ${JSON.stringify(s)}`)}}class t{#e;#t;#r;constructor(s,o){this.#e=s,this.#t=o,this.#r=s.subscribe(this.#i)}terminate(){this.#r.terminate()}#i=s=>{b(s.type==="send",()=>"Message type must be 'send'");let o=Object.getPrototypeOf(this.#t)===Object.getPrototypeOf({})?this.#t:Object.getPrototypeOf(this.#t),n=U(o[s.func],`${s.func.toString()} does not exists on ${this.#t}`),a=s.returnId;if(a===!1)n.apply(this.#t,s.args.map(u=>"value"in u?u.value:y(`${s.func.toString()} has no promise.`)));else try{n.apply(this.#t,s.args.map(h=>"callback"in h?(...d)=>this.#n(a,h.callback,d):h.value)).then(h=>this.#s(a,h),h=>this.#o(a,h))}catch(u){this.#o(a,u)}};#s=(s,o)=>this.#e.send({type:"resolve",returnId:s,resolve:o});#o=(s,o)=>this.#e.send({type:"reject",returnId:s,reject:o});#n=(s,o,n)=>this.#e.send({type:"callback",returnId:s,funcAt:o,args:n})}i.Executor=t})(Re||(Re={}));var sa;(function(i){i.ProgressArrayBuffer=e=>async t=>{if(!t.headers.has("Content-Length"))return console.debug("No Content-Length"),t.arrayBuffer();let r=parseInt(t.headers.get("Content-Length"));if(console.debug(`Content-Length: ${r}b`),isNaN(r)||r<4096)return t.arrayBuffer();e(0);let s=ue.create(r),o=U(t.body,"response.body is empty").getReader();for(;;){let{done:n,value:a}=await o.read();if(n)break;a.forEach(u=>s.writeByte(u)),e(s.position/r)}return e(1),s.toArrayBuffer()}})(sa||(sa={}));var oa;(function(i){i.debounce=(()=>{let e;return(t,r=1e3)=>{clearTimeout(e),e=setTimeout(t,r)}})(),i.scheduleInterval=(e,t,...r)=>{let s=setInterval(e,t,...r);return{terminate:()=>clearInterval(s)}},i.scheduleTimeout=(e,t,...r)=>{let s=setTimeout(e,t,...r);return{terminate:()=>clearTimeout(s)}}})(oa||(oa={}));var na={for:i=>new mn(i)},mn=class{#e;#t=new $;constructor(e){if(this.#e=e,D(e.onmessage)||D(e.onmessageerror))throw console.error(e),new Error(`${e} is already wrapped.`);e.onmessage=t=>this.#t.notify(t.data),e.onmessageerror=t=>{throw new Error(t.type)}}send(e){this.#e.postMessage(e)}channel(e){return new fn(this,e)}subscribe(e){return this.#t.subscribe(e)}terminate(){this.#t.terminate(),this.#e.onmessage=null,this.#e.onmessageerror=null}},fn=class i{#e;#t;#r=new $;#i;constructor(e,t){this.#e=e,this.#t=t,this.#i=e.subscribe(r=>{"message"in r&&"channel"in r&&r.channel===t&&this.#r.notify(r.message)})}send(e){this.#e.send({channel:this.#t,message:e})}channel(e){return new i(this,e)}subscribe(e){return this.#r.subscribe(e)}terminate(){this.#i.terminate(),this.#r.terminate()}};var gn=class{maxRetry;timeSpan;#e=0;constructor(e,t){this.maxRetry=e,this.timeSpan=t}retry(e,t){return++this.#e===this.maxRetry?!1:(console.debug(`${e} > will retry in ${this.timeSpan.toString()}`),setTimeout(t,this.timeSpan.millis()),!0)}},Qe;(function(i){class e{value;status="resolved";constructor(n){this.value=n}error=Zo("Cannot access error when promise is resolved")}i.ResolveResult=e;class t{error;status="rejected";constructor(n){this.error=n}value=Zo("Cannot access value when promise is rejected")}i.RejectedResult=t,i.makeAbortable=async(o,n)=>{let a=!0;return o.own(O.create(()=>a=!1)),new Promise((u,h)=>n.then(d=>{a&&u(d)},d=>{a&&h(d)}))},i.tryCatch=o=>o.then(n=>new e(n),n=>new t(n)),i.retry=(o,n=new gn(3,Jt.seconds(3)))=>o().catch(a=>new Promise((u,h)=>{let d=p=>{n.retry(p,()=>o().then(f=>u(f),d))||h(p)};d(a)})),i.fail=(o,n)=>{let a=()=>new Promise((u,h)=>setTimeout(()=>h("fails first"),o.millis()));return()=>{let u=a();return a=n,u}},i.timeout=(o,n,a)=>new Promise((u,h)=>{let d=!0,p=setTimeout(()=>{d=!1,h(new Error(a??"timeout"))},n.millis());o.then(f=>{d&&u(f)},f=>{d&&h(f)}).finally(()=>clearTimeout(p))}),i.sequential=o=>{let n=Promise.resolve(null);return a=>n=n.then(()=>o(a))};class r{max;#e;#t=0;constructor(n=1){this.max=n,this.#e=[]}async add(n){if(this.#t<this.max)return this.#t++,n().finally(()=>this.#r());{let a=Promise.withResolvers();return this.#e.push([n,a]),a.promise.finally(()=>this.#r())}}#r(){if(b(this.#t>0,"Internal Error in Promises.Limit"),--this.#t<this.max&&this.#e.length>0){let[n,{resolve:a,reject:u}]=this.#e.shift();this.#t++,n().then(a,u)}}}i.Limit=r;class s{#e;#t;#r;#i=m.None;constructor(n,a,u){this.#e=n,this.#t=a,this.#r=u}update(n){this.#i=m.wrap(n),n.then(a=>{this.#i.contains(n)&&this.#e(a)}).catch(a=>{this.#i.contains(n)&&this.#t(a)}).finally(()=>{this.#i.contains(n)&&(this.terminate(),g(this.#r))})}terminate(){this.#i=m.None}}i.Latest=s})(Qe||(Qe={}));var aa;(function(i){let e=new Qe.Limit(4);i.limitFetch=(t,r)=>e.add(()=>fetch(t,r))})(aa||(aa={}));var la=(i="debug")=>{let e=performance.now();return{lab:t=>console[i].call(console,`${t} in ${(performance.now()-e).toFixed(1)}ms`)}};var ua;(function(i){i.startEstimator=()=>{let e=performance.now();return t=>{if(t===0)return Jt.POSITIVE_INFINITY;let r=performance.now()-e;return Jt.millis(r/t-r)}}})(ua||(ua={}));var ha;(function(i){i.frame=()=>new Promise(e=>requestAnimationFrame(()=>e())),i.frames=e=>new Promise(t=>{let r=e,s=()=>{--r<=0?t():requestAnimationFrame(s)};requestAnimationFrame(s)}),i.timeSpan=(e,...t)=>new Promise(r=>setTimeout(r,e.millis(),...t)),i.event=(e,t)=>new Promise(r=>e.addEventListener(t,r,{once:!0})),i.observable=e=>new Promise(t=>{let r=e.subscribe(()=>{r.terminate(),t()})}),i.complete=e=>new Promise((t,r)=>{let s=setInterval(()=>{let{status:o,value:n,error:a}=Yt(()=>e.next());if(o==="success"){let{done:u,value:h}=n;u&&(clearInterval(s),t(h))}else clearInterval(s),r(a)},0)})})(ha||(ha={}));var Qi=Symbol.for("@openDAW/lib-runtime");globalThis[Qi]?console.debug(`%c${Qi.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Qi]=!0,console.debug(`%c${Qi.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var ca=(i,e)=>Re.executor(e,new class{sendUpdates(t){i.beginTransaction(),t.forEach(r=>{let s=r.type;s==="new"?i.createBox(r.name,r.uuid,o=>o.read(new ge(r.buffer))):s==="update-primitive"?i.findVertex(Q.reconstruct(r.address)).unwrap(()=>`Could not find primitive field ${r.address}`).setValue(r.value):s==="update-pointer"?i.findVertex(Q.reconstruct(r.address)).unwrap(()=>`Could not find pointer field ${r.address}`).targetAddress=D(r.target)?m.wrap(Q.reconstruct(r.target)):m.None:r.type==="delete"&&i.unstageBox(i.findBox(r.uuid).unwrap(()=>`Could not find box ${v.toString(r.uuid)}`))}),i.endTransaction()}checksum(t){return A.equals(i.checksum(),t)?Promise.resolve():Promise.reject("Checksum mismatch")}});var Yi=Symbol.for("@openDAW/lib-box");globalThis[Yi]?console.debug(`%c${Yi.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Yi]=!0,console.debug(`%c${Yi.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Xi=class{#e=0;#t=!1;#r=!1;isRecording=!1;isCountingIn=!1;metronomeEnabled=!1;getLeapStateAndReset(){let e=this.#r;return this.#r=!1,e}get position(){return this.#e}set position(e){this.#e=e,this.#r=!0}get transporting(){return this.#t}set transporting(e){this.#t!==e&&(this.#t=e)}advanceTo(e){this.#e=e}};var l;(function(i){i[i.Timeline=0]="Timeline",i[i.Selection=1]="Selection",i[i.PianoMode=2]="PianoMode",i[i.User=3]="User",i[i.AudioConnection=4]="AudioConnection",i[i.InstrumentHost=5]="InstrumentHost",i[i.AudioOutput=6]="AudioOutput",i[i.Capture=7]="Capture",i[i.NotesConnection=8]="NotesConnection",i[i.VoltageConnection=9]="VoltageConnection",i[i.AudioUnits=10]="AudioUnits",i[i.MidiEffectHost=11]="MidiEffectHost",i[i.AudioEffectHost=12]="AudioEffectHost",i[i.AudioBusses=13]="AudioBusses",i[i.AuxSend=14]="AuxSend",i[i.Modulation=15]="Modulation",i[i.Automation=16]="Automation",i[i.ParameterController=17]="ParameterController",i[i.MidiControl=18]="MidiControl",i[i.StepAutomation=19]="StepAutomation",i[i.Editing=20]="Editing",i[i.AudioFile=21]="AudioFile",i[i.AudioUnit=22]="AudioUnit",i[i.MarkerTrack=23]="MarkerTrack",i[i.MarkerEvents=24]="MarkerEvents",i[i.ClipCollection=25]="ClipCollection",i[i.RegionCollection=26]="RegionCollection",i[i.TrackCollection=27]="TrackCollection",i[i.Device=28]="Device",i[i.Groove=29]="Groove",i[i.ModularSetup=30]="ModularSetup",i[i.ModuleCollection=31]="ModuleCollection",i[i.ConnectionCollection=32]="ConnectionCollection",i[i.DeviceUserInterface=33]="DeviceUserInterface",i[i.NoteEvents=34]="NoteEvents",i[i.NoteEventFeature=35]="NoteEventFeature",i[i.NoteEventCollection=36]="NoteEventCollection",i[i.ValueEvents=37]="ValueEvents",i[i.ValueEventCollection=38]="ValueEventCollection",i[i.ValueInterpolation=39]="ValueInterpolation",i[i.Sample=40]="Sample"})(l||(l={}));var da;(function(i){i[i.Pre=0]="Pre",i[i.Post=1]="Post"})(da||(da={}));var Zi;(function(i){i.Instrument="instrument",i.Bus="bus",i.Aux="aux",i.Output="output"})(Zi||(Zi={}));var pa=(i,e)=>{if(i===e)return 0;let t=i-e;return t===0?y(`Indices cannot be equal (${i}, ${e})`):t};var Ee=class i{static create(e,t,r){return new i(e,t,r)}#e;#t;#r;#i;#s=null;constructor(e,t,r){this.#e=e,this.#t=v.newSet(s=>s.adapter.uuid),this.#r=new ve,this.#i=e.pointerHub.catchupAndSubscribeTransactual({onAdd:s=>{this.#s=null;let o=t(s.box),n=o.indexField.subscribe(()=>{this.#s=null,this.#r.proxy.onReorder(o)}),a=this.#t.add({adapter:o,subscription:n});b(a,`Could not add ${o}`),this.#r.proxy.onAdd(o)},onRemove:s=>{this.#s=null;let o=s.box.address.uuid,{adapter:n,subscription:a}=this.#t.removeByKey(o);a.terminate(),this.#r.proxy.onRemove(n)}},r)}field(){return this.#e}subscribe(e){return this.#r.subscribe(e)}catchupAndSubscribe(e){return this.#t.forEach(({adapter:t})=>e.onAdd(t)),this.subscribe(e)}getAdapterByIndex(e){let t=ie.exactMapped(this.adapters(),e,pa,r=>r.indexField.getValue());return t===-1?m.None:m.wrap(this.adapters()[t])}getAdapterById(e){return this.#t.opt(e).map(({adapter:t})=>t)}getMinFreeIndex(){let e=this.adapters();for(let t=0;t<e.length;t++)if(e[t].indexField.getValue()>t)return t;return e.length}adapters(){return this.#s===null&&(this.#s=this.#t.values().map(({adapter:e})=>e).sort((e,t)=>e.indexField.getValue()-t.indexField.getValue())),this.#s}move(e,t){this.moveIndex(e.indexField.getValue(),t)}moveIndex(e,t){let r=this.adapters(),s=r[e];if(t<0){let o=L(e+t,0,r.length-1);for(let n=o;n<e;n++)r[n].indexField.setValue(n+1);s.indexField.setValue(o)}else if(t>1){let o=L(e+(t-1),0,r.length-1);for(let n=e;n<o;n++)r[n+1].indexField.setValue(n);s.indexField.setValue(o)}else console.warn(`moveIndex had no effect: startIndex: ${e}, delta: ${t}`)}size(){return this.#t.size()}isEmpty(){return this.size()===0}terminate(){this.#s=null,this.#t.forEach(({subscription:e})=>e.terminate()),this.#t.clear(),this.#r.terminate(),this.#i.terminate()}};var Ji;(function(i){i.create=(e,t,r,s)=>{switch(e){case"RootBox":return es.create(t,r,s);case"SelectionBox":return yi.create(t,r,s);case"UserInterfaceBox":return ts.create(t,r,s);case"TimelineBox":return rs.create(t,r,s);case"TrackBox":return Fr.create(t,r,s);case"NoteEventBox":return St.create(t,r,s);case"NoteEventRepeatBox":return is.create(t,r,s);case"NoteEventCollectionBox":return ct.create(t,r,s);case"NoteRegionBox":return nr.create(t,r,s);case"NoteClipBox":return Br.create(t,r,s);case"ValueEventBox":return Ct.create(t,r,s);case"ValueEventCollectionBox":return dt.create(t,r,s);case"ValueEventCurveBox":return Rt.create(t,r,s);case"ValueRegionBox":return ar.create(t,r,s);case"ValueClipBox":return Nr.create(t,r,s);case"AudioRegionBox":return Pr.create(t,r,s);case"AudioClipBox":return Sr.create(t,r,s);case"MarkerBox":return Cr.create(t,r,s);case"AudioFileBox":return ss.create(t,r,s);case"AudioUnitBox":return pt.create(t,r,s);case"CaptureAudioBox":return os.create(t,r,s);case"CaptureMidiBox":return ns.create(t,r,s);case"AudioBusBox":return Rr.create(t,r,s);case"AuxSendBox":return as.create(t,r,s);case"StepAutomationBox":return ls.create(t,r,s);case"GrooveShuffleBox":return us.create(t,r,s);case"UnknownAudioEffectDeviceBox":return hs.create(t,r,s);case"UnknownMidiEffectDeviceBox":return cs.create(t,r,s);case"DeviceInterfaceKnobBox":return ds.create(t,r,s);case"ModularDeviceBox":return ps.create(t,r,s);case"DeviceClashBox":return ms.create(t,r,s);case"StereoToolDeviceBox":return fs.create(t,r,s);case"DelayDeviceBox":return gs.create(t,r,s);case"RevampDeviceBox":return xs.create(t,r,s);case"ReverbDeviceBox":return ys.create(t,r,s);case"VaporisateurDeviceBox":return vs.create(t,r,s);case"NanoDeviceBox":return bs.create(t,r,s);case"PlayfieldDeviceBox":return ws.create(t,r,s);case"PlayfieldSampleBox":return Mr.create(t,r,s);case"TapeDeviceBox":return As.create(t,r,s);case"ArpeggioDeviceBox":return Es.create(t,r,s);case"PitchDeviceBox":return Fs.create(t,r,s);case"ZeitgeistDeviceBox":return Bs.create(t,r,s);case"ModularBox":return Ns.create(t,r,s);case"ModuleConnectionBox":return Ps.create(t,r,s);case"ModularAudioInputBox":return Ss.create(t,r,s);case"ModularAudioOutputBox":return Cs.create(t,r,s);case"ModuleDelayBox":return Rs.create(t,r,s);case"ModuleMultiplierBox":return Ms.create(t,r,s);case"ModuleGainBox":return Ts.create(t,r,s);default:return y(`Unknown box class '${e}'`)}},i.deserialize=(e,t)=>{let r=new ge(t),s=r.readString(),o=v.fromDataInput(r),n=i.create(s,e,o);return n.read(r),n}})(Ji||(Ji={}));var Vs=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get keyboard(){return this.getField(1)}get timeRangeInQuarters(){return this.getField(2)}get noteScale(){return this.getField(3)}get noteLabels(){return this.getField(4)}get transpose(){return this.getField(5)}initializeFields(){return{1:x.create({parent:this,fieldKey:1,fieldName:"keyboard",pointerRules:c},0),2:F.create({parent:this,fieldKey:2,fieldName:"timeRangeInQuarters",pointerRules:c},8),3:F.create({parent:this,fieldKey:3,fieldName:"noteScale",pointerRules:c},1.5),4:B.create({parent:this,fieldKey:4,fieldName:"noteLabels",pointerRules:c},!0),5:x.create({parent:this,fieldKey:5,fieldName:"transpose",pointerRules:c},0)}}};var es=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RootBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitRootBox,this)}get timeline(){return this.getField(1)}get users(){return this.getField(2)}get created(){return this.getField(3)}get groove(){return this.getField(4)}get modularSetups(){return this.getField(10)}get audioUnits(){return this.getField(20)}get audioBusses(){return this.getField(21)}get outputDevice(){return this.getField(30)}get pianoMode(){return this.getField(40)}get editingChannel(){return this.getField(111)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"timeline",pointerRules:c},l.Timeline,!0),2:I.hook({parent:this,fieldKey:2,fieldName:"users",pointerRules:{accepts:[l.User],mandatory:!0}}),3:T.create({parent:this,fieldKey:3,fieldName:"created",pointerRules:c}),4:E.create({parent:this,fieldKey:4,fieldName:"groove",pointerRules:c},l.Groove,!0),10:I.hook({parent:this,fieldKey:10,fieldName:"modularSetups",pointerRules:{accepts:[l.ModularSetup],mandatory:!1}}),20:I.hook({parent:this,fieldKey:20,fieldName:"audioUnits",pointerRules:{accepts:[l.AudioUnits],mandatory:!1}}),21:I.hook({parent:this,fieldKey:21,fieldName:"audioBusses",pointerRules:{accepts:[l.AudioBusses],mandatory:!1}}),30:I.hook({parent:this,fieldKey:30,fieldName:"outputDevice",pointerRules:{accepts:[l.AudioOutput],mandatory:!0}}),40:Vs.create({parent:this,fieldKey:40,fieldName:"pianoMode",pointerRules:c}),111:E.create({parent:this,fieldKey:111,fieldName:"editingChannel",pointerRules:c},l.Editing,!1)}}};var yi=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"SelectionBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitSelectionBox,this)}get selection(){return this.getField(1)}get selectable(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"selection",pointerRules:c},l.Selection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"selectable",pointerRules:c},l.Selection,!0)}}};var ts=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UserInterfaceBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitUserInterfaceBox,this)}get root(){return this.getField(1)}get selection(){return this.getField(10)}get editingDeviceChain(){return this.getField(21)}get editingTimelineRegion(){return this.getField(22)}get editingModularSystem(){return this.getField(23)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"root",pointerRules:c},l.User,!0),10:I.hook({parent:this,fieldKey:10,fieldName:"selection",pointerRules:{accepts:[l.Selection],mandatory:!1}}),21:E.create({parent:this,fieldKey:21,fieldName:"editingDeviceChain",pointerRules:c},l.Editing,!1),22:E.create({parent:this,fieldKey:22,fieldName:"editingTimelineRegion",pointerRules:c},l.Editing,!1),23:E.create({parent:this,fieldKey:23,fieldName:"editingModularSystem",pointerRules:c},l.Editing,!1)}}};var Ds=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get nominator(){return this.getField(1)}get denominator(){return this.getField(2)}initializeFields(){return{1:x.create({parent:this,fieldKey:1,fieldName:"nominator",pointerRules:c},4),2:x.create({parent:this,fieldKey:2,fieldName:"denominator",pointerRules:c},4)}}};var Is=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get from(){return this.getField(2)}get to(){return this.getField(3)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:c},!0),2:x.create({parent:this,fieldKey:2,fieldName:"from",pointerRules:c},0),3:x.create({parent:this,fieldKey:3,fieldName:"to",pointerRules:c},15360)}}};var Os=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get markers(){return this.getField(1)}get index(){return this.getField(10)}get enabled(){return this.getField(20)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"markers",pointerRules:{accepts:[l.MarkerTrack],mandatory:!1}}),10:x.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:c}),20:B.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:c},!0)}}};var rs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TimelineBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitTimelineBox,this)}get root(){return this.getField(1)}get signature(){return this.getField(10)}get loopArea(){return this.getField(11)}get deprecatedMarkerTrack(){return this.getField(20)}get markerTrack(){return this.getField(21)}get durationInPulses(){return this.getField(30)}get bpm(){return this.getField(31)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"root",pointerRules:{accepts:[l.Timeline],mandatory:!0}}),10:Ds.create({parent:this,fieldKey:10,fieldName:"signature",pointerRules:c}),11:Is.create({parent:this,fieldKey:11,fieldName:"loopArea",pointerRules:c}),20:I.hook({parent:this,fieldKey:20,fieldName:"deprecatedMarkerTrack",pointerRules:{accepts:[l.MarkerTrack],mandatory:!1}}),21:Os.create({parent:this,fieldKey:21,fieldName:"markerTrack",pointerRules:c}),30:x.create({parent:this,fieldKey:30,fieldName:"durationInPulses",pointerRules:c},491520),31:F.create({parent:this,fieldKey:31,fieldName:"bpm",pointerRules:c},120)}}};var Fr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TrackBox",pointerRules:{accepts:[l.Selection,l.PianoMode],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitTrackBox,this)}get tracks(){return this.getField(1)}get target(){return this.getField(2)}get regions(){return this.getField(3)}get clips(){return this.getField(4)}get index(){return this.getField(10)}get type(){return this.getField(11)}get enabled(){return this.getField(20)}get excludePianoMode(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"tracks",pointerRules:c},l.TrackCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"target",pointerRules:c},l.Automation,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"regions",pointerRules:{accepts:[l.RegionCollection],mandatory:!1}}),4:I.hook({parent:this,fieldKey:4,fieldName:"clips",pointerRules:{accepts:[l.ClipCollection],mandatory:!1}}),10:x.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"type",pointerRules:c}),20:B.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:c},!0),30:B.create({parent:this,fieldKey:30,fieldName:"excludePianoMode",pointerRules:c},!1)}}};var St=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventBox",pointerRules:{accepts:[l.Selection,l.NoteEventFeature],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get pitch(){return this.getField(20)}get velocity(){return this.getField(21)}get playCount(){return this.getField(22)}get playCurve(){return this.getField(23)}get cent(){return this.getField(24)}get chance(){return this.getField(25)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:c},l.NoteEvents,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c},240),20:x.create({parent:this,fieldKey:20,fieldName:"pitch",pointerRules:c},60),21:F.create({parent:this,fieldKey:21,fieldName:"velocity",pointerRules:c},.7874015748031497),22:x.create({parent:this,fieldKey:22,fieldName:"playCount",pointerRules:c},1),23:F.create({parent:this,fieldKey:23,fieldName:"playCurve",pointerRules:c},0),24:F.create({parent:this,fieldKey:24,fieldName:"cent",pointerRules:c},0),25:x.create({parent:this,fieldKey:25,fieldName:"chance",pointerRules:c},100)}}};var is=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventRepeatBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteEventRepeatBox,this)}get event(){return this.getField(1)}get count(){return this.getField(2)}get curve(){return this.getField(3)}get length(){return this.getField(4)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:c},l.NoteEventFeature,!0),2:x.create({parent:this,fieldKey:2,fieldName:"count",pointerRules:c},1),3:F.create({parent:this,fieldKey:3,fieldName:"curve",pointerRules:c},0),4:F.create({parent:this,fieldKey:4,fieldName:"length",pointerRules:c},1)}}};var ct=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventCollectionBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[l.NoteEvents],mandatory:!1}}),2:I.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[l.NoteEventCollection],mandatory:!0}})}}};var nr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteRegionBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get eventOffset(){return this.getField(14)}get mute(){return this.getField(15)}get label(){return this.getField(16)}get hue(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:c},l.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.NoteEventCollection,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:c}),14:x.create({parent:this,fieldKey:14,fieldName:"eventOffset",pointerRules:c}),15:B.create({parent:this,fieldKey:15,fieldName:"mute",pointerRules:c}),16:T.create({parent:this,fieldKey:16,fieldName:"label",pointerRules:c}),17:x.create({parent:this,fieldKey:17,fieldName:"hue",pointerRules:c})}}};var Mt=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get loop(){return this.getField(1)}get reverse(){return this.getField(2)}get mute(){return this.getField(3)}get speed(){return this.getField(4)}get quantise(){return this.getField(5)}get trigger(){return this.getField(6)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"loop",pointerRules:c},!0),2:B.create({parent:this,fieldKey:2,fieldName:"reverse",pointerRules:c}),3:B.create({parent:this,fieldKey:3,fieldName:"mute",pointerRules:c}),4:x.create({parent:this,fieldKey:4,fieldName:"speed",pointerRules:c}),5:x.create({parent:this,fieldKey:5,fieldName:"quantise",pointerRules:c}),6:x.create({parent:this,fieldKey:6,fieldName:"trigger",pointerRules:c})}}};var Br=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteClipBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:c},l.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.NoteEventCollection,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:Mt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:c}),10:x.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:c}),11:B.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:c}),12:T.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:c})}}};var Ct=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get index(){return this.getField(11)}get interpolation(){return this.getField(12)}get value(){return this.getField(13)}get slope(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:c},l.ValueEvents,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"interpolation",pointerRules:{accepts:[l.ValueInterpolation],mandatory:!1}},1),13:F.create({parent:this,fieldKey:13,fieldName:"value",pointerRules:c}),14:F.create({parent:this,fieldKey:14,fieldName:"slope",pointerRules:c})}}};var dt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCollectionBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[l.ValueEvents],mandatory:!1}}),2:I.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[l.ValueEventCollection],mandatory:!0}})}}};var Rt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCurveBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueEventCurveBox,this)}get event(){return this.getField(1)}get slope(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:c},l.ValueInterpolation,!0),2:F.create({parent:this,fieldKey:2,fieldName:"slope",pointerRules:c},.5)}}};var ar=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueRegionBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:c},l.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.ValueEventCollection,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:c}),14:B.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:c}),15:T.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:c}),16:x.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:c})}}};var Nr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueClipBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:c},l.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.ValueEventCollection,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:Mt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:c}),10:x.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:c}),11:B.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:c}),12:T.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:c})}}};var Pr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioRegionBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioRegionBox,this)}get regions(){return this.getField(1)}get file(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:c},l.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:c},l.AudioFile,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:c}),14:B.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:c}),15:T.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:c}),16:x.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:c}),17:F.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:c})}}};var Sr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioClipBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioClipBox,this)}get clips(){return this.getField(1)}get file(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}get gain(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:c},l.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:c},l.AudioFile,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:Mt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:c}),10:x.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:c}),11:B.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:c}),12:T.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:c}),14:F.create({parent:this,fieldKey:14,fieldName:"gain",pointerRules:c})}}};var Cr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"MarkerBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitMarkerBox,this)}get track(){return this.getField(1)}get position(){return this.getField(2)}get plays(){return this.getField(3)}get label(){return this.getField(4)}get hue(){return this.getField(5)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"track",pointerRules:c},l.MarkerTrack,!0),2:x.create({parent:this,fieldKey:2,fieldName:"position",pointerRules:c}),3:x.create({parent:this,fieldKey:3,fieldName:"plays",pointerRules:c},1),4:T.create({parent:this,fieldKey:4,fieldName:"label",pointerRules:c}),5:x.create({parent:this,fieldKey:5,fieldName:"hue",pointerRules:c})}}};var ss=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioFileBox",pointerRules:{accepts:[l.AudioFile],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioFileBox,this)}get startInSeconds(){return this.getField(1)}get endInSeconds(){return this.getField(2)}get fileName(){return this.getField(3)}initializeFields(){return{1:x.create({parent:this,fieldKey:1,fieldName:"startInSeconds",pointerRules:c}),2:x.create({parent:this,fieldKey:2,fieldName:"endInSeconds",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"fileName",pointerRules:c})}}};var pt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioUnitBox",pointerRules:{accepts:[l.Selection,l.Automation],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioUnitBox,this)}get type(){return this.getField(1)}get collection(){return this.getField(2)}get editing(){return this.getField(3)}get index(){return this.getField(11)}get volume(){return this.getField(12)}get panning(){return this.getField(13)}get mute(){return this.getField(14)}get solo(){return this.getField(15)}get tracks(){return this.getField(20)}get midiEffects(){return this.getField(21)}get input(){return this.getField(22)}get audioEffects(){return this.getField(23)}get auxSends(){return this.getField(24)}get output(){return this.getField(25)}get capture(){return this.getField(26)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"type",pointerRules:c},"instrument"),2:E.create({parent:this,fieldKey:2,fieldName:"collection",pointerRules:c},l.AudioUnits,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[l.Editing],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:c}),12:F.create({parent:this,fieldKey:12,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:F.create({parent:this,fieldKey:13,fieldName:"panning",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),14:B.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),15:B.create({parent:this,fieldKey:15,fieldName:"solo",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),20:I.hook({parent:this,fieldKey:20,fieldName:"tracks",pointerRules:{accepts:[l.TrackCollection],mandatory:!1}}),21:I.hook({parent:this,fieldKey:21,fieldName:"midiEffects",pointerRules:{accepts:[l.MidiEffectHost],mandatory:!1}}),22:I.hook({parent:this,fieldKey:22,fieldName:"input",pointerRules:{accepts:[l.InstrumentHost,l.AudioOutput],mandatory:!1}}),23:I.hook({parent:this,fieldKey:23,fieldName:"audioEffects",pointerRules:{accepts:[l.AudioEffectHost],mandatory:!1}}),24:I.hook({parent:this,fieldKey:24,fieldName:"auxSends",pointerRules:{accepts:[l.AuxSend],mandatory:!1}}),25:E.create({parent:this,fieldKey:25,fieldName:"output",pointerRules:c},l.AudioOutput,!1),26:E.create({parent:this,fieldKey:26,fieldName:"capture",pointerRules:c},l.Capture,!1)}}};var os=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureAudioBox",pointerRules:{accepts:[l.Capture],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitCaptureAudioBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get requestChannels(){return this.getField(10)}get gainDb(){return this.getField(11)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:c}),2:T.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:c},"normal"),10:x.create({parent:this,fieldKey:10,fieldName:"requestChannels",pointerRules:c},1),11:F.create({parent:this,fieldKey:11,fieldName:"gainDb",pointerRules:c},0)}}};var ns=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureMidiBox",pointerRules:{accepts:[l.Capture],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitCaptureMidiBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get channel(){return this.getField(10)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:c}),2:T.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:c},"normal"),10:x.create({parent:this,fieldKey:10,fieldName:"channel",pointerRules:c},-1)}}};var Rr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioBusBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioBusBox,this)}get collection(){return this.getField(1)}get output(){return this.getField(2)}get input(){return this.getField(3)}get enabled(){return this.getField(4)}get icon(){return this.getField(5)}get label(){return this.getField(6)}get color(){return this.getField(7)}get minimized(){return this.getField(8)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.AudioBusses,!0),2:E.create({parent:this,fieldKey:2,fieldName:"output",pointerRules:c},l.AudioOutput,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"input",pointerRules:{accepts:[l.AudioOutput],mandatory:!1}}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:T.create({parent:this,fieldKey:5,fieldName:"icon",pointerRules:c}),6:T.create({parent:this,fieldKey:6,fieldName:"label",pointerRules:c}),7:T.create({parent:this,fieldKey:7,fieldName:"color",pointerRules:c},"red"),8:B.create({parent:this,fieldKey:8,fieldName:"minimized",pointerRules:c})}}};var as=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AuxSendBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitAuxSendBox,this)}get audioUnit(){return this.getField(1)}get targetBus(){return this.getField(2)}get index(){return this.getField(3)}get routing(){return this.getField(4)}get sendGain(){return this.getField(5)}get sendPan(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"audioUnit",pointerRules:c},l.AuxSend,!0),2:E.create({parent:this,fieldKey:2,fieldName:"targetBus",pointerRules:c},l.AudioOutput,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:x.create({parent:this,fieldKey:4,fieldName:"routing",pointerRules:c},1),5:F.create({parent:this,fieldKey:5,fieldName:"sendGain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),6:F.create({parent:this,fieldKey:6,fieldName:"sendPan",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var ls=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StepAutomationBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitStepAutomationBox,this)}get step(){return this.getField(1)}get parameter(){return this.getField(2)}get value(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"step",pointerRules:c},l.StepAutomation,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:c},l.StepAutomation,!0),3:F.create({parent:this,fieldKey:3,fieldName:"value",pointerRules:c})}}};var us=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"GrooveShuffleBox",pointerRules:{accepts:[l.Groove],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitGrooveShuffleBox,this)}get label(){return this.getField(1)}get amount(){return this.getField(10)}get duration(){return this.getField(11)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"label",pointerRules:c}),10:F.create({parent:this,fieldKey:10,fieldName:"amount",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.6),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},480)}}};var hs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownAudioEffectDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitUnknownAudioEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:T.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:c})}}};var cs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownMidiEffectDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitUnknownMidiEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:T.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:c})}}};var ds=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceInterfaceKnobBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitDeviceInterfaceKnobBox,this)}get userInterface(){return this.getField(1)}get parameter(){return this.getField(2)}get index(){return this.getField(3)}get anchor(){return this.getField(10)}get color(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"userInterface",pointerRules:c},l.DeviceUserInterface,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:c},l.ParameterController,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),10:F.create({parent:this,fieldKey:10,fieldName:"anchor",pointerRules:c}),11:T.create({parent:this,fieldKey:11,fieldName:"color",pointerRules:c})}}};var ks=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get elements(){return this.getField(1)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"elements",pointerRules:{accepts:[l.DeviceUserInterface],mandatory:!1}})}}};var ps=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modularSetup(){return this.getField(10)}get userInterface(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:E.create({parent:this,fieldKey:10,fieldName:"modularSetup",pointerRules:c},l.ModularSetup,!0),11:ks.create({parent:this,fieldKey:11,fieldName:"userInterface",pointerRules:c})}}};var Us=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get active(){return this.getField(1)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"active",pointerRules:{accepts:[l.StepAutomation],mandatory:!1}})}}};var Ks=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get steps(){return this.getField(10)}get length(){return this.getField(11)}get scale(){return this.getField(12)}initializeFields(){return{10:Er.create({parent:this,fieldKey:10,fieldName:"steps",pointerRules:c},e=>Us.create(e),128),11:x.create({parent:this,fieldKey:11,fieldName:"length",pointerRules:c},16),12:x.create({parent:this,fieldKey:12,fieldName:"scale",pointerRules:c},960)}}};var ms=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceClashBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitDeviceClashBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}get patterns(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},.5),11:F.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},.9),12:F.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},0),13:F.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},0),14:F.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},-3),15:F.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},-3),30:Er.create({parent:this,fieldKey:30,fieldName:"patterns",pointerRules:c},e=>Ks.create(e),16)}}};var fs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StereoToolDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitStereoToolDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get panning(){return this.getField(11)}get stereo(){return this.getField(12)}get invertL(){return this.getField(13)}get invertR(){return this.getField(14)}get swap(){return this.getField(15)}get panningMixing(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"panning",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"stereo",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:B.create({parent:this,fieldKey:13,fieldName:"invertL",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),14:B.create({parent:this,fieldKey:14,fieldName:"invertR",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),15:B.create({parent:this,fieldKey:15,fieldName:"swap",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),20:x.create({parent:this,fieldKey:20,fieldName:"panningMixing",pointerRules:c},1)}}};var gs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DelayDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitDelayDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},4),11:F.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.5),12:F.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),13:F.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),14:F.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},-6),15:F.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0)}}};var vi=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get order(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),10:F.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"order",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var bi=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),10:F.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Tr=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),10:F.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var xs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RevampDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitRevampDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get highPass(){return this.getField(10)}get lowShelf(){return this.getField(11)}get lowBell(){return this.getField(12)}get midBell(){return this.getField(13)}get highBell(){return this.getField(14)}get highShelf(){return this.getField(15)}get lowPass(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:vi.create({parent:this,fieldKey:10,fieldName:"highPass",pointerRules:c}),11:bi.create({parent:this,fieldKey:11,fieldName:"lowShelf",pointerRules:c}),12:Tr.create({parent:this,fieldKey:12,fieldName:"lowBell",pointerRules:c}),13:Tr.create({parent:this,fieldKey:13,fieldName:"midBell",pointerRules:c}),14:Tr.create({parent:this,fieldKey:14,fieldName:"highBell",pointerRules:c}),15:bi.create({parent:this,fieldKey:15,fieldName:"highShelf",pointerRules:c}),16:vi.create({parent:this,fieldKey:16,fieldName:"lowPass",pointerRules:c}),17:F.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var ys=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ReverbDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitReverbDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get decay(){return this.getField(10)}get preDelay(){return this.getField(11)}get damp(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"decay",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.5),11:F.create({parent:this,fieldKey:11,fieldName:"preDelay",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),12:F.create({parent:this,fieldKey:12,fieldName:"damp",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.5),13:F.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),14:F.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},-3),15:F.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0)}}};var vs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"VaporisateurDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitVaporisateurDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get octave(){return this.getField(11)}get tune(){return this.getField(12)}get waveform(){return this.getField(13)}get cutoff(){return this.getField(14)}get resonance(){return this.getField(15)}get attack(){return this.getField(16)}get release(){return this.getField(17)}get filterEnvelope(){return this.getField(18)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"octave",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"tune",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:x.create({parent:this,fieldKey:13,fieldName:"waveform",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),14:F.create({parent:this,fieldKey:14,fieldName:"cutoff",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),15:F.create({parent:this,fieldKey:15,fieldName:"resonance",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),16:F.create({parent:this,fieldKey:16,fieldName:"attack",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),17:F.create({parent:this,fieldKey:17,fieldName:"release",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),18:F.create({parent:this,fieldKey:18,fieldName:"filterEnvelope",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var bs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NanoDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNanoDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get file(){return this.getField(15)}get release(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},-3),15:E.create({parent:this,fieldKey:15,fieldName:"file",pointerRules:c},l.AudioFile,!1),20:F.create({parent:this,fieldKey:20,fieldName:"release",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.1)}}};var ws=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitPlayfieldDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get samples(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:I.hook({parent:this,fieldKey:10,fieldName:"samples",pointerRules:{accepts:[l.Sample],mandatory:!1}})}}};var Mr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldSampleBox",pointerRules:{accepts:[l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitPlayfieldSampleBox,this)}get device(){return this.getField(10)}get file(){return this.getField(11)}get midiEffects(){return this.getField(12)}get audioEffects(){return this.getField(13)}get index(){return this.getField(15)}get label(){return this.getField(20)}get icon(){return this.getField(21)}get enabled(){return this.getField(22)}get minimized(){return this.getField(23)}get mute(){return this.getField(40)}get solo(){return this.getField(41)}get exclude(){return this.getField(42)}get polyphone(){return this.getField(43)}get gate(){return this.getField(44)}get pitch(){return this.getField(45)}get sampleStart(){return this.getField(46)}get sampleEnd(){return this.getField(47)}get attack(){return this.getField(48)}get release(){return this.getField(49)}initializeFields(){return{10:E.create({parent:this,fieldKey:10,fieldName:"device",pointerRules:c},l.Sample,!0),11:E.create({parent:this,fieldKey:11,fieldName:"file",pointerRules:c},l.AudioFile,!0),12:I.hook({parent:this,fieldKey:12,fieldName:"midiEffects",pointerRules:{accepts:[l.MidiEffectHost],mandatory:!1}}),13:I.hook({parent:this,fieldKey:13,fieldName:"audioEffects",pointerRules:{accepts:[l.AudioEffectHost],mandatory:!1}}),15:x.create({parent:this,fieldKey:15,fieldName:"index",pointerRules:c},60),20:T.create({parent:this,fieldKey:20,fieldName:"label",pointerRules:c}),21:T.create({parent:this,fieldKey:21,fieldName:"icon",pointerRules:c}),22:B.create({parent:this,fieldKey:22,fieldName:"enabled",pointerRules:c},!0),23:B.create({parent:this,fieldKey:23,fieldName:"minimized",pointerRules:c},!1),40:B.create({parent:this,fieldKey:40,fieldName:"mute",pointerRules:c}),41:B.create({parent:this,fieldKey:41,fieldName:"solo",pointerRules:c}),42:B.create({parent:this,fieldKey:42,fieldName:"exclude",pointerRules:c}),43:B.create({parent:this,fieldKey:43,fieldName:"polyphone",pointerRules:c}),44:x.create({parent:this,fieldKey:44,fieldName:"gate",pointerRules:c},0),45:F.create({parent:this,fieldKey:45,fieldName:"pitch",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),46:F.create({parent:this,fieldKey:46,fieldName:"sampleStart",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),47:F.create({parent:this,fieldKey:47,fieldName:"sampleEnd",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),48:F.create({parent:this,fieldKey:48,fieldName:"attack",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.001),49:F.create({parent:this,fieldKey:49,fieldName:"release",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.02)}}};var As=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TapeDeviceBox",pointerRules:{accepts:[l.Device,l.Selection,l.Automation],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitTapeDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get flutter(){return this.getField(10)}get wow(){return this.getField(11)}get noise(){return this.getField(12)}get saturation(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"flutter",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"wow",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"noise",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:F.create({parent:this,fieldKey:13,fieldName:"saturation",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Es=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ArpeggioDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitArpeggioDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modeIndex(){return this.getField(10)}get numOctaves(){return this.getField(11)}get rateIndex(){return this.getField(12)}get gate(){return this.getField(13)}get repeat(){return this.getField(14)}get velocity(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:x.create({parent:this,fieldKey:10,fieldName:"modeIndex",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"numOctaves",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),12:x.create({parent:this,fieldKey:12,fieldName:"rateIndex",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},9),13:F.create({parent:this,fieldKey:13,fieldName:"gate",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),14:x.create({parent:this,fieldKey:14,fieldName:"repeat",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),15:F.create({parent:this,fieldKey:15,fieldName:"velocity",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Fs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PitchDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitPitchDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get semiTones(){return this.getField(10)}get cents(){return this.getField(11)}get octaves(){return this.getField(12)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:x.create({parent:this,fieldKey:10,fieldName:"semiTones",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"cents",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:x.create({parent:this,fieldKey:12,fieldName:"octaves",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Bs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ZeitgeistDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitZeitgeistDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get groove(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:E.create({parent:this,fieldKey:10,fieldName:"groove",pointerRules:c},l.Groove,!0)}}};var Ns=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularBox,this)}get collection(){return this.getField(1)}get device(){return this.getField(2)}get editing(){return this.getField(3)}get modules(){return this.getField(11)}get connections(){return this.getField(12)}get label(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.ModularSetup,!0),2:I.hook({parent:this,fieldKey:2,fieldName:"device",pointerRules:{accepts:[l.ModularSetup],mandatory:!0}}),3:I.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[l.Editing],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"modules",pointerRules:{accepts:[l.ModuleCollection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"connections",pointerRules:{accepts:[l.ConnectionCollection],mandatory:!1}}),13:T.create({parent:this,fieldKey:13,fieldName:"label",pointerRules:c})}}};var Ps=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleConnectionBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleConnectionBox,this)}get collection(){return this.getField(1)}get source(){return this.getField(2)}get target(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.ConnectionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"source",pointerRules:c},l.VoltageConnection,!0),3:E.create({parent:this,fieldKey:3,fieldName:"target",pointerRules:c},l.VoltageConnection,!0)}}};var ke=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get collection(){return this.getField(1)}get label(){return this.getField(2)}get x(){return this.getField(3)}get y(){return this.getField(4)}get collapsed(){return this.getField(5)}get removable(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.ModuleCollection,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:x.create({parent:this,fieldKey:3,fieldName:"x",pointerRules:c}),4:x.create({parent:this,fieldKey:4,fieldName:"y",pointerRules:c}),5:B.create({parent:this,fieldKey:5,fieldName:"collapsed",pointerRules:c},!1),6:B.create({parent:this,fieldKey:6,fieldName:"removable",pointerRules:c},!0)}}};var Ss=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioInputBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularAudioInputBox,this)}get attributes(){return this.getField(1)}get output(){return this.getField(10)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"output",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}})}}};var Cs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioOutputBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularAudioOutputBox,this)}get attributes(){return this.getField(1)}get input(){return this.getField(10)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"input",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}})}}};var Rs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleDelayBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleDelayBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(11)}get time(){return this.getField(20)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"voltageOutput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),20:F.create({parent:this,fieldKey:20,fieldName:"time",pointerRules:{accepts:[l.ParameterController],mandatory:!1}},500)}}};var Ms=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleMultiplierBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleMultiplierBox,this)}get attributes(){return this.getField(1)}get voltageInputX(){return this.getField(10)}get voltageInputY(){return this.getField(11)}get voltageOutput(){return this.getField(12)}get multiplier(){return this.getField(20)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInputX",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"voltageInputY",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),20:F.create({parent:this,fieldKey:20,fieldName:"multiplier",pointerRules:c})}}};var Ts=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleGainBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleGainBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(12)}get gain(){return this.getField(20)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),20:F.create({parent:this,fieldKey:20,fieldName:"gain",pointerRules:{accepts:[l.ParameterController],mandatory:!1}})}}};var Ye;(function(i){i.write=(e,t)=>{if(t.type==="none")e.disconnect(),e.setValue(0);else if(t.type==="linear")e.disconnect(),e.setValue(1);else if(t.type==="curve"){e.setValue(0);let r=e.pointerHub.filter(l.ValueInterpolation).at(0)?.box;D(r)?(Xo(r,Rt),r.slope.setValue(t.slope)):Rt.create(e.box.graph,v.generate(),s=>{s.slope.setValue(t.slope),s.event.refer(e)})}},i.read=e=>{let t=e.pointerHub.incoming().at(0)?.box;return D(t)?(Xo(t,Rt),{type:"curve",slope:t.slope.getValue()}):e.getValue()===0?Nt.None:e.getValue()===1?Nt.Linear:y("Unknown Interpolation value")}})(Ye||(Ye={}));var Tt=class i{static Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.index-t.index;if(s!==0)return s;throw new Error(`${e} and ${t} are identical in terms of comparison`)};type="value-event";#e=new V;#t;#r;#i;#s;#o=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new Si(()=>Ye.read(this.#r.interpolation)));let r=()=>{this.#i.invalidate(),this.collection.ifSome(s=>s.onEventPropertyChanged())};this.#e.ownAll(this.#r.subscribe(X.Children,s=>{if(!this.collection.isEmpty()&&(s.type==="primitive"||s.type==="pointer")){let o=this.collection.unwrap(),n=s.address.fieldKeys,a=A.equals(this.#r.index.address.fieldKeys,n),u=A.equals(this.#r.position.address.fieldKeys,n);a||u?o.requestSorting():o.onEventPropertyChanged()}}),this.#r.interpolation.subscribe(r),this.#r.interpolation.pointerHub.subscribeImmediate({onAdd:({targetVertex:s})=>{this.#s.terminate(),this.#s=s.unwrap().box.subscribe(X.Children,r),r()},onRemove:()=>{this.#s.terminate(),this.#s=O.Empty,r()}})),this.#s=this.#r.interpolation.pointerHub.filter(l.ValueInterpolation).at(0)?.box.subscribe(X.Children,r)??O.Empty}onSelected(){this.#o=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#o=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#s.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get index(){return this.#r.index.getValue()}set interpolation(e){Ye.write(this.#r.interpolation,e)}get interpolation(){return this.#i.get()}get value(){return this.#r.value.getValue()}get isSelected(){return this.#o}get collection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ue))}copyTo(e){let t=Ct.create(this.#t.boxGraph,v.generate(),r=>{r.position.setValue(e?.position??this.position),r.index.setValue(e?.index??this.index),r.events.refer(e?.events??this.collection.unwrap().box.events),r.value.setValue(e?.value??this.value)});return Ye.write(t.interpolation,e?.interpolation??this.interpolation),this.#t.boxAdapters.adapterFor(t,i)}copyFrom(e){return this.#r.position.setValue(e?.position??this.position),this.#r.index.setValue(e?.index??this.index),this.#r.events.refer(e?.events??this.collection.unwrap().box.events),this.#r.value.setValue(e?.value??this.value),Ye.write(this.#r.interpolation,e?.interpolation??this.interpolation),this}toString(){return`{ValueEventBoxAdapter position: ${this.position} index: ${this.index}}`}};var Ue=class i{#e=new V;#t;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#s=v.newSet(s=>s.uuid),this.#o=Et.create(Tt.Comparator);let r=s=>{let o=U(s.accept({visitValueEventBox:n=>this.#t.boxAdapters.adapterFor(n,Tt)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#n())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#e.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#n()}})),this.#e.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}valueAt(e,t){return zi.valueAt(this.#o,e,t)}copy(){let e=this.#t.boxGraph,t=dt.create(e,v.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#t.boxAdapters.adapterFor(t,i)}cut(e){let t=this.events.lowerEqual(e),r=this.events.greaterEqual(e);if(r===null)return t===null?m.None:m.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t===null)return m.wrap(this.createEvent({position:e,value:r.value,index:r.index,interpolation:r.interpolation}));if(t.position===e)return m.wrap(t);if(t.interpolation.type==="none")return m.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t.interpolation.type==="linear"){let{position:s,value:o}=t,{position:n,value:a}=r;return m.wrap(this.createEvent({position:e,value:Dn(o,a,(e-s)/(n-s)),index:0,interpolation:t.interpolation}))}if(t.interpolation.type==="curve"){let{position:s,value:o}=t,{position:n,value:a}=r,u=n-s,h=e-s,d=Oe.byHalf(u,o,Oe.valueAt({slope:t.interpolation.slope,steps:u,y0:o,y1:a},u*.5),a),p=Oe.valueAt(d,h),f=Oe.slopeByHalf(o,Oe.valueAt(d,h*.5),p);return Ye.write(t.box.interpolation,Nt.Curve(f)),m.wrap(this.createEvent({position:e,value:p,index:0,interpolation:Nt.Curve(Oe.slopeByHalf(p,Oe.valueAt(d,(h+u)*.5),a))}))}return y("Unknown interpolation type")}subscribeChange(e){return this.#i.subscribe(e)}createEvent({position:e,index:t,value:r,interpolation:s}){let o=Ct.create(this.#t.boxGraph,v.generate(),n=>{n.position.setValue(e),n.index.setValue(t),n.value.setValue(r),n.events.refer(this.#r.events)});return Ye.write(o.interpolation,s),this.#t.boxAdapters.adapterFor(o,Tt)}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#n()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(l.ValueEventCollection).length}get events(){return this.#o}toString(){return`{ValueEventCollectionBox ${v.toString(this.#r.address.uuid)}}`}#n(){this.#i.notify(this)}};var Vt=class{type="value-clip";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Pe(!1)),this.#s=this.#e.own(new $),this.#e.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#e.own(this.#r.subscribe(X.Children,r=>this.#a())),this.#e.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ue).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(e%this.duration,t)}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return g(e.visitValueClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Nr.create(this.#t.boxGraph,v.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ue))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{ValueClipBoxAdapter ${v.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var Xe=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get startInSeconds(){return this.#t.startInSeconds.getValue()}get endInSeconds(){return this.#t.endInSeconds.getValue()}get data(){return this.getOrCreateLoader().data}get peaks(){return this.getOrCreateLoader().peaks}getOrCreateLoader(){return this.#e.sampleManager.getOrCreate(this.#t.address.uuid)}terminate(){}};var Dt=class{type="audio-clip";#e=new V;#t;#r;#i;#s;#o;#n=m.None;#a=m.None;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Pe(!1)),this.#s=this.#e.own(new $),this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(s=>this.#t.boxAdapters.adapterFor(s.box,Xe)),this.#a.ifSome(s=>s.terminate()),this.#a=this.#n.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(X.Children,r=>this.#l()),{terminate:()=>{this.#a.ifSome(r=>r.terminate()),this.#a=m.None}}),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return g(e.visitAudioClipBoxAdapter,this)}consolidate(){}clone(e){Sr.create(this.#t.boxGraph,v.generate(),t=>{t.index.setValue(this.indexField.getValue()),t.gain.setValue(this.gain),t.label.setValue(this.label),t.hue.setValue(this.hue),t.duration.setValue(this.duration),t.mute.setValue(this.mute),t.clips.refer(this.#r.clips.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap())})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#n.unwrap("Cannot access file.")}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return m.None}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return!1}get canMirror(){return!1}toString(){return`{AudioClipBoxAdapter ${v.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#l(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var lr=class i{type="note-event";#e;#t;#r;#i=!1;constructor(e,t){this.#e=e,this.#t=t,this.#r=this.#t.subscribe(X.Children,r=>{if(!this.collection.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.collection.unwrap(),o=r.address.fieldKeys,n=A.equals(this.#t.pitch.address.fieldKeys,o),a=A.equals(this.#t.position.address.fieldKeys,o);n||a?s.requestSorting():s.onEventPropertyChanged()}})}onSelected(){this.#i=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#i=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#r.terminate()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get position(){return this.#t.position.getValue()}get duration(){return this.#t.duration.getValue()}get complete(){return this.position+this.duration}get velocity(){return this.#t.velocity.getValue()}get pitch(){return this.#t.pitch.getValue()}get cent(){return this.#t.cent.getValue()}get chance(){return this.#t.chance.getValue()}get playCount(){return this.#t.playCount.getValue()}get playCurve(){return this.#t.playCurve.getValue()}get isSelected(){return this.#i}get collection(){return this.#t.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,Ke))}normalizedPitch(){if(this.collection.isEmpty())return .5;let{minPitch:e,maxPitch:t}=this.collection.unwrap();return e===t?.5:1-(this.pitch-e)/(t-e)}copyAsNoteEvent(){return{type:"note-event",position:this.position,duration:this.duration,pitch:this.pitch,cent:this.cent,velocity:this.velocity}}copyTo(e){return this.#e.boxAdapters.adapterFor(St.create(this.#e.boxGraph,v.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.pitch.setValue(e?.pitch??this.pitch),t.playCount.setValue(e?.playCount??this.playCount),t.events.refer(e?.events??this.collection.unwrap().box.events),t.velocity.setValue(this.velocity),t.cent.setValue(this.cent),t.chance.setValue(this.chance)}),i)}computeCurveValue(e){return Ce.curveFunc(e,this.playCurve)}canConsolidate(){return this.playCount>1}consolidate(){let e=this.playCount,t=this.collection.unwrap().box.events,r=A.create(s=>{let o=Math.floor(this.computeCurveValue(s/e)*this.duration),n=Math.floor(this.computeCurveValue((s+1)/e)*this.duration);return this.copyTo({position:Math.floor(this.position+o),duration:Math.max(1,n-o),playCount:1,events:t})},e);return this.#t.delete(),r}};var Ke=class i{#e=new V;#t;#r;#i;#s;#o;#n=60;#a=60;#l=0;#u=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#s=v.newSet(s=>s.uuid),this.#o=Et.create(Ce.Comparator);let r=s=>{let o=U(s.accept({visitNoteEventBox:n=>this.#t.boxAdapters.adapterFor(n,lr)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#h())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#e.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#h()}})),this.#e.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}copy(){let e=this.#t.boxGraph,t=ct.create(e,v.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#t.boxAdapters.adapterFor(t,i)}createEvent({position:e,duration:t,velocity:r,pitch:s,chance:o,playCount:n,cent:a}){return this.#t.boxAdapters.adapterFor(St.create(this.#t.boxGraph,v.generate(),u=>{u.position.setValue(e),u.duration.setValue(t),u.velocity.setValue(r),u.pitch.setValue(s),u.chance.setValue(o),u.playCount.setValue(n),u.cent.setValue(a),u.events.refer(this.#r.events)}),lr)}subscribeChange(e){return this.#i.subscribe(e)}selectable(){return this.#o.asArray()}selectableAt(e){for(let t of this.#o.asArray())if(t.position<=e.u&&e.u<t.complete&&t.pitch===e.v)return se.one(t);return se.empty()}selectablesBetween(e,t){let r=[];for(let s of this.#o.asArray())ui.intersect1D(s.position,s.complete,e.u,t.u)&&ui.intersect1D(s.pitch,s.pitch,e.v,t.v)&&r.push(s);return r}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#h()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(l.NoteEventCollection).length}get events(){return this.#u||this.#c(),this.#o}get minPitch(){return this.#u||this.#c(),this.#n}get maxPitch(){return this.#u||this.#c(),this.#a}get maxDuration(){return this.#u||this.#c(),this.#l}toString(){return`{NoteEventCollectionBox ${v.toString(this.#r.address.uuid)}}`}#h(){this.#u=!1,this.#i.notify(this)}#c(){let e=127,t=0,r=0;this.#o.asArray().forEach(({pitch:s,duration:o})=>{e=Math.min(e,s),t=Math.max(t,s),r=Math.max(r,o)}),this.#n=e,this.#a=t,this.#l=r,this.#u=!0}};var Vr=class{type="note-clip";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Pe(!1)),this.#s=this.#e.own(new $),this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(X.Children,r=>this.#a()),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ke).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return g(e.visitNoteClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Br.create(this.#t.boxGraph,v.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get events(){return this.optCollection.map(e=>e.events)}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ke))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{NoteClipBoxAdapter ${v.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var Ls={for:(i,e)=>U(e.accept({visitNoteClipBox:t=>i.adapterFor(t,Vr),visitValueClipBox:t=>i.adapterFor(t,Vt),visitAudioClipBox:t=>i.adapterFor(t,Dt)}),"")};var $s=class{#e;#t;#r;#i;constructor(e,t){this.#e=e,this.#t=new V,this.#r=this.#t.own(new $),this.#i=this.#t.own(Ee.create(e.box.clips,r=>Ls.for(t,r),l.ClipCollection)),this.#i.subscribe({onAdd:()=>this.dispatchChange(),onRemove:()=>this.dispatchChange(),onReorder:()=>this.dispatchChange()})}get trackBoxAdapter(){return this.#e}get collection(){return this.#i}dispatchChange(){this.#r.notify()}subscribeChanges(e){return this.#r.subscribe(e)}terminate(){this.#t.terminate()}};var It=class i{type="audio-region";#e;#t;#r;#i;#s=m.None;#o=m.None;#n;#a;constructor(e,t){this.#t=e,this.#r=t,this.#e=new V,this.#i=new $,this.#n=!1,this.#a=!0,this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#s=r.targetVertex.map(s=>this.#t.boxAdapters.adapterFor(s.box,Xe)),this.#o.ifSome(s=>s.terminate()),this.#o=this.#s.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(X.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#l()):this.#l()}}),{terminate:()=>{this.#o.ifSome(r=>r.terminate()),this.#o=m.None}}),this.#a=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return g(e.visitAudioRegionBoxAdapter,this)}onSelected(){this.#n=!0,this.#l()}onDeselected(){this.#n=!1,this.#l()}get isSelected(){return this.#n}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){let e=this.#r.duration.getValue();if(e===0){let t=this.#s.unwrap("Cannot compute duration without file"),r=t.startInSeconds,o=t.endInSeconds-r;return G.secondsToPulses(o,this.#t.bpm)}return e}get complete(){return this.position+this.duration}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#s.unwrap("Cannot access file.")}get hasCollection(){return this.#s.nonEmpty()}get optCollection(){return m.None}get label(){if(this.#s.isEmpty())return"No Audio File";let e=this.#s.unwrap().getOrCreateLoader().state;return e.type==="progress"?`${Math.round(e.progress*100)}%`:e.type==="error"?String(e.reason):this.#r.label.getValue()}get isMirrowed(){return!1}get canMirror(){return!1}get trackBoxAdapter(){return this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}copyTo(e){return this.#t.boxAdapters.adapterFor(Pr.create(this.#t.boxGraph,v.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.loopOffset.setValue(e?.loopOffset??this.loopOffset),t.loopDuration.setValue(e?.loopDuration??this.loopDuration),t.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap()),t.mute.setValue(this.mute),t.hue.setValue(this.hue),t.label.setValue(this.label),t.gain.setValue(this.gain)}),i)}consolidate(){}canFlatten(e){return!1}flatten(e){return m.None}toString(){return`{AudioRegionBoxAdapter ${v.toString(this.#r.address.uuid)}}`}#l(){this.#a||(this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange())}};var Ot=class i{type="note-region";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#o=!1,this.#s=!0,this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(X.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}}),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ke).subscribeChange(()=>this.#a())}),this.#a()})),this.#s=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return g(e.visitNoteRegionBoxAdapter,this)}onSelected(){this.#o=!0,this.#a()}onDeselected(){this.#o=!1,this.#a()}get isSelected(){return this.#o}*iterateActiveNotesAt(e){let t=this.optCollection;if(t.isEmpty())return;let r=t.unwrap(),s=Te.globalToLocal(this,e);for(let o of r.events.iterateFrom(s-r.maxDuration)){if(s<o.position)return;s<o.complete&&(yield o.copyAsNoteEvent())}}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return this.optCollection.nonEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ke))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#s?m.None:this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#t.boxAdapters.adapterFor(nr.create(this.#t.boxGraph,v.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.optCollection.ifSome(e=>{let t=this.#t.boxGraph,r=ct.create(t,v.generate());e.events.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return e.length>0&&A.satisfy(e,(t,r)=>t.trackBoxAdapter.contains(r.trackBoxAdapter.unwrap()))&&e.every(t=>t.isSelected&&t instanceof i)}flatten(e){if(!this.canFlatten(e))return m.None;let t=this.#t.boxGraph,r=e.toSorted(Ft.Comparator),s=A.getFirst(r,"Internal error (no first)"),o=A.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,u=s.trackBoxAdapter.unwrap(),h=ct.create(t,v.generate()),d=Array.from(u.regions.collection.iterateRange(n,a));return d.filter(p=>p.isSelected).forEach(p=>{let f=p;for(let{resultStart:w,resultEnd:N,rawStart:S}of Te.locateLoops(f,f.position,f.complete)){let M=Math.floor(w-S),k=Math.floor(N-S);for(let K of f.optCollection.unwrap().events.iterateRange(M,k))K.copyTo({position:K.position+S-s.position,events:h.events})}}),d.forEach(({box:p})=>p.delete()),m.wrap(nr.create(t,v.generate(),p=>{p.position.setValue(n),p.duration.setValue(a-n),p.loopDuration.setValue(a-n),p.loopOffset.setValue(0),p.hue.setValue(this.hue),p.mute.setValue(this.mute),p.label.setValue(this.label),p.events.refer(h.owners),p.regions.refer(u.box.regions)}))}toString(){return`{NoteRegionBoxAdapter ${v.toString(this.#r.address.uuid)} p: ${G.toString(this.position)}, c: ${G.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var mt=class i{type="value-region";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=new $,this.#s=!1,this.#e.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#e.own(this.#r.subscribe(X.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}})),this.#e.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ue).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(Te.globalToLocal(this,e),t)}incomingValue(e){return this.valueAt(this.position,e)}outgoingValue(e){let t=this.optCollection;if(t.isEmpty())return e;let r=t.unwrap();return(this.complete-this.offset)%this.loopDuration===0?r.valueAt(this.loopDuration,e):r.valueAt(Te.globalToLocal(this,this.complete),e)}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return g(e.visitValueRegionBoxAdapter,this)}onSelected(){this.#s=!0,this.#a()}onDeselected(){this.#s=!1,this.#a()}get isSelected(){return this.#s}onValuesPropertyChanged(){this.#a()}onValuesSortingChanged(){this.onValuesPropertyChanged()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ue))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#t.boxAdapters.adapterFor(ar.create(this.#t.boxGraph,v.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.events.ifSome(e=>{let t=this.#t.boxGraph,r=dt.create(t,v.generate());e.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return!1}flatten(e){if(!this.canFlatten(e))return m.None;let t=this.#t.boxGraph,r=e.toSorted(Ft.Comparator),s=A.getFirst(r,"Internal error (no first)"),o=A.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,u=s.trackBoxAdapter.unwrap(),h=dt.create(t,v.generate()),d=Array.from(u.regions.collection.iterateRange(n,a));return d.filter(p=>p.isSelected).forEach(p=>{let f=p;for(let{resultStart:w,resultEnd:N,rawStart:S}of Te.locateLoops(f,f.position,f.complete)){let M=Math.floor(w-S),k=Math.floor(N-S);for(let K of f.events.unwrap().iterateRange(M,k));}}),d.forEach(({box:p})=>p.delete()),m.wrap(ar.create(t,v.generate(),p=>{p.position.setValue(n),p.duration.setValue(a-n),p.loopDuration.setValue(a-n),p.loopOffset.setValue(0),p.hue.setValue(this.hue),p.mute.setValue(this.mute),p.label.setValue(this.label),p.events.refer(h.owners),p.regions.refer(u.box.regions)}))}toString(){return`{ValueRegionBoxAdapter ${v.toString(this.#r.address.uuid)} p: ${G.toString(this.position)}, c: ${G.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var ma=(i,e)=>i.position-e.position,fa={for:(i,e)=>U(e.accept({visitNoteRegionBox:t=>i.adapterFor(t,Ot),visitAudioRegionBox:t=>i.adapterFor(t,It),visitValueRegionBox:t=>i.adapterFor(t,mt)}),"")};var qs=class{#e;#t;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=new V,this.#r=this.#t.own(new $),this.#i=Ft.create(ma),this.#s=v.newSet(r=>r.uuid),this.#t.ownAll(this.#e.box.regions.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{let s=fa.for(t,r),o=this.#s.add(s);b(o,`Cannot add ${r}`),this.#i.add(s),this.dispatchChange()},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#s.removeByKey(r)),this.dispatchChange()}},l.RegionCollection))}get trackBoxAdapter(){return this.#e}get collection(){return this.#i}get adapters(){return this.#s}onIndexingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}subscribeChanges(e){return this.#r.subscribe(e)}dispatchChange(){this.#r.notify()}terminate(){this.#t.terminate()}};var Ae;(function(i){i[i.Rectangle=0]="Rectangle",i[i.Checkbox=1]="Checkbox",i[i.Panel=2]="Panel",i[i.MainMenu=3]="MainMenu",i[i.Dropdown=4]="Dropdown",i[i.AudioDevice=5]="AudioDevice",i[i.GuitarTab=6]="GuitarTab",i[i.Effects=7]="Effects",i[i.Flask=8]="Flask",i[i.Robot=9]="Robot",i[i.NotePad=10]="NotePad",i[i.Pencil=11]="Pencil",i[i.Waveform=12]="Waveform",i[i.Mix=13]="Mix",i[i.Adsr=14]="Adsr",i[i.Dial=15]="Dial",i[i.Record=16]="Record",i[i.Play=17]="Play",i[i.Stop=18]="Stop",i[i.Loop=19]="Loop",i[i.Timeline=20]="Timeline",i[i.Region=21]="Region",i[i.Box=22]="Box",i[i.Mixing=23]="Mixing",i[i.Vinyl=24]="Vinyl",i[i.Help=25]="Help",i[i.Metronome=26]="Metronome",i[i.System=27]="System",i[i.Add=28]="Add",i[i.Subtract=29]="Subtract",i[i.Peak=30]="Peak",i[i.LowPass=31]="LowPass",i[i.HighPass=32]="HighPass",i[i.LowShelf=33]="LowShelf",i[i.HighShelf=34]="HighShelf",i[i.RoundUp=35]="RoundUp",i[i.RoundDown=36]="RoundDown",i[i.Mute=37]="Mute",i[i.Solo=38]="Solo",i[i.Exclude=39]="Exclude",i[i.Menu=40]="Menu",i[i.Pointer=41]="Pointer",i[i.Eraser=42]="Eraser",i[i.Scissors=43]="Scissors",i[i.Tape=44]="Tape",i[i.CollapseDown=45]="CollapseDown",i[i.FileList=46]="FileList",i[i.Close=47]="Close",i[i.DragConnections=48]="DragConnections",i[i.Heart=49]="Heart",i[i.Merge=50]="Merge",i[i.SpeakerHeadphone=51]="SpeakerHeadphone",i[i.AudioBus=52]="AudioBus",i[i.DrumSet=53]="DrumSet",i[i.BassGuitar=54]="BassGuitar",i[i.Guitar=55]="Guitar",i[i.Saxophone=56]="Saxophone",i[i.Microphone=57]="Microphone",i[i.New=58]="New",i[i.Piano=59]="Piano",i[i.ExpandWidth=60]="ExpandWidth",i[i.OpenDAW=61]="OpenDAW",i[i.Automation=62]="Automation",i[i.Embed=63]="Embed",i[i.Popout=64]="Popout",i[i.Minimized=65]="Minimized",i[i.Maximized=66]="Maximized",i[i.Search=67]="Search",i[i.Generator=68]="Generator",i[i.Groove=69]="Groove",i[i.Table=70]="Table",i[i.Note=71]="Note",i[i.Exit=72]="Exit",i[i.Start=73]="Start",i[i.Duration=74]="Duration",i[i.Velocity=75]="Velocity",i[i.Random=76]="Random",i[i.Divide=77]="Divide",i[i.Curve=78]="Curve",i[i.Primary=79]="Primary",i[i.Clips=80]="Clips",i[i.NoAudio=81]="NoAudio",i[i.Unknown=82]="Unknown",i[i.UserFolder=83]="UserFolder",i[i.CloudFolder=84]="CloudFolder",i[i.Run=85]="Run",i[i.Insert=86]="Insert",i[i.ArrayDown=87]="ArrayDown",i[i.Sun=88]="Sun",i[i.Book=89]="Book",i[i.Stack=90]="Stack",i[i.EditBox=91]="EditBox",i[i.Delete=92]="Delete",i[i.Time=93]="Time",i[i.EQ=94]="EQ",i[i.Cube=95]="Cube",i[i.NanoWave=96]="NanoWave",i[i.Midi=97]="Midi",i[i.DinSlot=98]="DinSlot",i[i.VUMeter=99]="VUMeter",i[i.Playfield=100]="Playfield",i[i.Invert=101]="Invert",i[i.Headphone=102]="Headphone",i[i.Stereo=103]="Stereo",i[i.AutoGain=104]="AutoGain",i[i.AudioFile=105]="AudioFile",i[i.Tool=106]="Tool",i[i.Focus=107]="Focus",i[i.Swap=108]="Swap",i[i.Connected=109]="Connected",i[i.Disconnected=110]="Disconnected",i[i.Zeitgeist=111]="Zeitgeist"})(Ae||(Ae={}));(function(i){i.toName=e=>i[e],i.fromName=e=>i[e]??i.Rectangle})(Ae||(Ae={}));var J;(function(i){i[i.Undefined=0]="Undefined",i[i.Notes=1]="Notes",i[i.Audio=2]="Audio",i[i.Value=3]="Value"})(J||(J={}));(function(i){i.toLabelString=e=>{switch(e){case i.Audio:return"Audio";case i.Notes:return"Notes";case i.Value:return"Automation";case i.Undefined:default:return"N/A"}},i.toIconSymbol=e=>{switch(e){case i.Audio:return Ae.Waveform;case i.Notes:return Ae.Piano;case i.Value:return Ae.Automation;case i.Undefined:return Ae.AudioBus;default:return Ae.Unknown}}})(J||(J={}));var zs;(function(i){i.isDeviceBox=e=>"host"in e&&de(e.host,E)&&"label"in e&&de(e.label,T)&&"enabled"in e&&de(e.enabled,B)&&"minimized"in e&&de(e.minimized,B),i.isInstrumentDeviceBox=e=>i.isDeviceBox(e)&&e.host.pointerType===l.InstrumentHost,i.isEffectDeviceBox=e=>i.isDeviceBox(e)&&"index"in e&&de(e.index,x)&&(e.host.pointerType===l.MidiEffectHost||e.host.pointerType===l.AudioEffectHost),i.lookupHostField=e=>D(e)&&"host"in e&&de(e.host,E)?e.host:y(`Could not find 'host' field in '${e?.name}'`),i.lookupLabelField=e=>D(e)&&"label"in e&&de(e.label,T)?e.label:y(`Could not find 'label' field in '${e?.name}'`),i.lookupEnabledField=e=>D(e)&&"enabled"in e&&de(e.enabled,B)?e.enabled:y(`Could not find 'enabled' field in '${e?.name}'`),i.lookupMinimizedField=e=>D(e)&&"minimized"in e&&de(e.minimized,B)?e.minimized:y(`Could not find 'minimized' field in '${e?.name}'`),i.lookupIndexField=e=>D(e)&&"index"in e&&de(e.index,x)?e.index:y(`Could not find 'index' field in '${e?.name}'`)})(zs||(zs={}));var ga;(function(i){i.toTrackType=e=>{switch(e){case"midi":return J.Notes;case"audio":return J.Audio;default:return y()}}})(ga||(ga={}));var W;(function(i){i.isAny=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="bus"||e.type==="instrument"||e.type==="audio-effect"),i.isEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="audio-effect"),i.isInstrument=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="instrument",i.isMidiEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="midi-effect",i.isAudioEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="audio-effect",i.isHost=e=>e!==null&&typeof e=="object"&&"class"in e&&e.class==="device-host",i.deleteEffectDevices=e=>{if(e.length===0)return;b(A.satisfy(e,(s,o)=>s.deviceHost().address.equals(o.deviceHost().address)),"Devices are not connected to the same host");let t=e[0];(t.accepts==="audio"?t.deviceHost().audioEffects.field().pointerHub.filter(l.AudioEffectHost):t.accepts==="midi"?t.deviceHost().midiEffects.field().pointerHub.filter(l.MidiEffectHost):y("unknown type")).map(({box:s})=>zs.lookupIndexField(s)).filter(s=>e.some(o=>v.Comparator(o.uuid,s.address.uuid)!==0)).sort((s,o)=>s.getValue()-o.getValue()).forEach((s,o)=>s.setValue(o)),e.forEach(s=>s.box.delete())}})(W||(W={}));var _s=class{#e;#t=new $;#r;#i;#s;constructor(e,t){this.#e=e,this.#r=Ee.create(e.box.tracks,r=>t.adapterFor(r,me),l.TrackCollection),this.#i=v.newSet(({uuid:r})=>r),this.#s=this.#r.catchupAndSubscribe({onAdd:r=>this.#i.add({uuid:r.uuid,subscription:r.regions.subscribeChanges(()=>this.#t.notify())}),onRemove:({uuid:r})=>this.#i.removeByKey(r).subscription.terminate(),onReorder:r=>{}})}create(e,t,r){let s=this.#e.box.graph,o=this.#e.box.tracks;Fr.create(s,v.generate(),n=>{n.index.setValue(r??this.#r.getMinFreeIndex()),n.type.setValue(e),n.tracks.refer(o),n.target.refer(t)})}controls(e){return m.wrap(this.#r.adapters().find(t=>t.target.targetVertex.contains(e),!1))}delete(e){let t=this.#r.adapters(),r=t.indexOf(e);if(r===-1)return y(`Cannot delete ${e}. Does not exist.`);for(let s=r+1;s<t.length;s++)t[s].indexField.setValue(s-1);e.box.delete()}get collection(){return this.#r}values(){return this.#r.adapters()}catchupAndSubscribe(e){return this.#r.catchupAndSubscribe(e)}subscribeAnyChange(e){return this.#t.subscribe(e)}terminate(){this.#r.terminate(),this.#s.terminate(),this.#i.forEach(({subscription:e})=>e.terminate()),this.#i.clear()}};var Me=class{type="bus";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}catchupAndSubscribe(e){return e(this),this.#t.subscribe(X.Children,()=>e(this))}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get iconField(){return this.#t.icon}get labelField(){return this.#t.label}get colorField(){return this.#t.color}get iconSymbol(){return Ae.fromName(this.iconField.getValue()??"audio-bus")}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.output.targetVertex.unwrap("No AudioUnitBox found").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}toString(){return`{${this.constructor.name}}`}};var Hs=class{#e;#t;#r;#i;#s=O.Empty;constructor(e,t){this.#e=new V,this.#t=this.#e.own(new $),this.#r=this.#e.own(new Pe(Ae.Unknown)),this.#i=this.#e.own(new Pe(m.None)),this.#e.own(this.#i.subscribe(r=>{this.#s.terminate(),this.#s=r.getValue().match({none:()=>(this.#t.notify(m.None),O.Empty),some:({labelField:s,iconField:o})=>O.many(o.catchupAndSubscribe(n=>this.#r.setValue(Ae.fromName(n.getValue()))),s.catchupAndSubscribe(n=>this.#t.notify(m.wrap(n.getValue()))))})})),this.#e.own(e.catchupAndSubscribeTransactual({onAdd:({box:r})=>{b(this.#i.getValue().isEmpty(),"Already set");let s=r instanceof Rr?t.adapterFor(r,Me):t.adapterFor(r,W.isInstrument);this.#i.getValue().unwrapOrNull()!==s&&this.#i.setValue(m.wrap(s))},onRemove:({box:r})=>{b(this.#i.getValue().unwrap("Cannot remove").box.address.equals(r.address),"Unexpected value to remove"),this.#i.setValue(m.None)}},l.InstrumentHost,l.AudioOutput))}getValue(){return this.#i.getValue()}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.#i),this.subscribe(e)}catchupAndSubscribeLabelChange(e){return e(this.label),this.#t.subscribe(e)}catchupAndSubscribeIconChange(e){return this.#r.catchupAndSubscribe(e)}set label(e){this.getValue().ifSome(t=>t.labelField.setValue(e))}get label(){return this.getValue().map(e=>e.labelField.getValue())}set icon(e){this.getValue().ifSome(t=>t.iconField.setValue(Ae.toName(e)))}get icon(){return this.getValue().match({none:()=>Ae.Unknown,some:e=>Ae.fromName(e.iconField.getValue())})}get iconValue(){return this.#r}terminate(){this.#e.terminate(),this.#s.terminate()}};var te=class{#e;#t;constructor(e){this.#e=e,this.#t=new wt(t=>t.address.fieldKeys,Tn)}terminate(){this.#t.forEach(e=>e.terminate()),this.#t.clear()}parameters(){return this.#t.values()}parameterAt(e){return this.#t.getOrThrow(e,()=>new Error(`No ParameterAdapter found at [${e}]`))}createParameter(e,t,r,s,o){let n=new ur(this.#e,e,t,r,s,o),a=this.#t.add(n);return b(a,`Could not add adapter for ${e}`),n}removeParameter(e){this.#t.removeByValue(e)}};var Dr=class{#e;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=this.#r.own(new $),this.#r.own(t.targetBus.catchupAndSubscribe(()=>{this.#n.terminate(),this.#n=this.optTargetBus.match({none:()=>(this.#i.notify(m.None),O.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(m.wrap(s)))})})),this.#s=this.#r.own(new ur(this.#e,this.#t.sendPan,R.bipolar(),C.percent({unit:"%",fractionDigits:0}),"panning")),this.#o=this.#r.own(new ur(this.#e,this.#t.sendGain,R.DefaultDecibel,C.numeric({unit:"dB",fractionDigits:1}),"gain"))}catchupAndSubscribeBusChanges(e){return e(this.optTargetBus),this.#i.subscribe(e)}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get indexField(){return this.#t.index}get sendPan(){return this.#s}get sendGain(){return this.#o}get targetBus(){return this.#e.boxAdapters.adapterFor(this.#t.targetBus.targetVertex.unwrap("no audioUnit").box,Me)}get optTargetBus(){return this.#t.targetBus.targetVertex.flatMap(e=>m.wrap(e.box.accept({visitAudioBusBox:t=>this.#e.boxAdapters.adapterFor(t,Me)})))}delete(){this.#t.delete()}terminate(){this.#r.terminate(),this.#n.terminate()}};var Gs=class{#e;#t;#r;#i;#s=O.Empty;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=this.#r.own(new $),this.#r.own(e.catchupAndSubscribe(()=>{this.#s.terminate(),this.#s=this.adapter.match({none:()=>(this.#i.notify(m.None),O.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(m.wrap(s)))})}))}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.adapter),this.subscribe(e)}get adapter(){return this.#e.targetVertex.flatMap(e=>m.wrap(e.box.accept({visitAudioBusBox:t=>this.#t.adapterFor(t,Me)})))}terminate(){this.#r.terminate(),this.#s.terminate()}};var Ze=class i{static VolumeMapper=R.decibel(-96,-9,6);class="device-host";#e=new V;#t;#r;#i;#s;#o;#n;#a;#l;#u;namedParameter;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new te(this.#t)),this.#s=this.#e.own(new _s(this,this.#t.boxAdapters)),this.#o=this.#e.own(new Hs(this.#r.input.pointerHub,this.#t.boxAdapters)),this.#n=this.#e.own(Ee.create(this.#r.midiEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isMidiEffect),l.MidiEffectHost)),this.#a=this.#e.own(Ee.create(this.#r.audioEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isAudioEffect),l.AudioEffectHost)),this.#l=this.#e.own(Ee.create(this.#r.auxSends,r=>this.#t.boxAdapters.adapterFor(r,Dr),l.AuxSend)),this.#u=this.#e.own(new Gs(this.#r.output,this.#t.boxAdapters)),this.namedParameter=this.#h(t),this.#c()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get type(){return this.#r.type.getValue()}get captureBox(){return this.#r.capture.targetVertex}get tracks(){return this.#s}get input(){return this.#o}get midiEffects(){return this.#n}get audioEffects(){return this.#a}get inputAdapter(){return this.#o.getValue()}get auxSends(){return this.#l}get output(){return this.#u}get isBus(){return this.input.getValue().mapOr(e=>e.type==="bus",!1)}get isInstrument(){return this.input.getValue().mapOr(e=>e.type==="instrument",!1)}get isOutput(){return this.#r.output.targetVertex.mapOr(e=>e.box.address.equals(this.#t.rootBoxAdapter.address),!1)}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.#r.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.#r.tracks}get minimizedField(){return this.#o.getValue().unwrap().minimizedField}get isAudioUnit(){return!0}get label(){return this.#o.getValue().mapOr(e=>e.labelField.getValue(),"")}audioUnitBoxAdapter(){return this}indicesLimit(){let e=this.#t.rootBoxAdapter.audioUnits.adapters(),t=this.indexField.getValue(),r=this.type,s=t,o=t;for(;s>0&&e[s-1].type===r;)s--;for(;o<e.length-1&&e[o+1].type===r;)o++;return[s,o+1]}move(e){this.#t.rootBoxAdapter.audioUnits.move(this,e)}moveTrack(e,t){this.#s.collection.move(e,t)}deleteTrack(e){this.#s.delete(e)}toString(){return`{${this.constructor.name}}`}terminate(){this.#e.terminate()}#h(e){return{volume:this.#i.createParameter(e.volume,i.VolumeMapper,C.decible,"volume"),panning:this.#i.createParameter(e.panning,R.bipolar(),C.panning,"panning",.5),mute:this.#i.createParameter(e.mute,R.bool,C.bool,"mute"),solo:this.#i.createParameter(e.solo,R.bool,C.bool,"solo")}}#c(){let e=this.address.toString(),t=this.#r.capture.targetAddress.unwrapOrUndefined(),r=()=>`AudioUnit '${e}' must have a capture. AudioUnit is typed ${this.type} and has input ${this.#r.input.pointerHub.incoming().at(0)?.box.name}, but capture is ${t}`;b(this.type!==Zi.Instrument||this.#r.capture.targetAddress.nonEmpty(),r)}};var Ws=G.fromSignature(1,384);var me=class{#e;#t;#r;#i;#s;#o;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=this.#r.own(new $s(this,e.boxAdapters)),this.#s=this.#r.own(new qs(this,e.boxAdapters)),this.#o=this.#r.own(new Pe(-1))}catchupAndSubscribePath(e){let t=[m.None,m.None],r=()=>{t.every(s=>s.nonEmpty())?e(m.wrap(t.map(s=>s.unwrap()))):e(m.None)};return O.many(this.#n(s=>{t[0].equals(s)||(t[0]=s,r())}),this.#a(s=>{t[1].equals(s)||(t[1]=s,r())}))}set targetDeviceName(e){this.#t.target.targetVertex.ifSome(t=>{let r=t.box;if(r instanceof pt)return this.#e.boxAdapters.adapterFor(r,Ze).input.getValue().ifSome(({labelField:o})=>o.setValue(e));if("label"in r&&r.label instanceof T)return r.label.setValue(e)})}get targetDeviceName(){return this.#t.target.targetVertex.flatMap(e=>{let t=e.box;return t instanceof pt?this.#e.boxAdapters.adapterFor(t,Ze).input.label:"label"in t&&t.label instanceof T?m.wrap(t.label.getValue()):m.wrap(t.name)})}#n(e){let t=this.#t.target.targetVertex;if(t.nonEmpty()){let r=t.unwrap().box;return r instanceof pt?this.#e.boxAdapters.adapterFor(r,Ze).input.catchupAndSubscribeLabelChange(o=>e(o)):"label"in r&&r.label instanceof T?r.label.catchupAndSubscribe(s=>e(m.wrap(s.getValue()))):(e(m.wrap(r.name)),O.Empty)}return e(m.None),O.Empty}#a(e){let t=this.type;switch(t){case J.Audio:case J.Notes:return e(m.wrap(J[t])),O.Empty;case J.Value:{let r=this.#t.target.targetVertex.unwrap();if(r.isField())e(this.#e.parameterFieldAdapters.opt(r.address).map(s=>s.name));else if(r.isBox())e(m.wrap(r.name));else return y("Illegal State. Vertex is not a field nor box.");return O.Empty}case J.Undefined:return e(m.wrap("")),O.Empty;default:return e(m.None),O.Empty}}terminate(){this.#r.terminate()}get audioUnit(){return Qt(this.#t.tracks.targetVertex.unwrap().box,pt)}get target(){return this.#t.target}get clips(){return this.#i}get regions(){return this.#s}get enabled(){return this.#t.enabled}get indexField(){return this.#t.index}get type(){return this.#t.type.getValue()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get listIndex(){return this.#o.getValue()}set listIndex(e){this.#o.setValue(e)}accepts(e){switch(e.type){case"audio-clip":return this.type===J.Audio;case"note-clip":return this.type===J.Notes;case"value-clip":return this.type===J.Value;case"audio-region":return this.type===J.Audio;case"note-region":return this.type===J.Notes;case"value-region":return this.type===J.Value}}valueAt(e,t){if(!this.enabled.getValue())return t;let r=t,s=this.#e.clipSequencing.iterate(this.uuid,e,e+Ws);for(let{optClip:o,sectionFrom:n}of s)r=o.match({none:()=>{let a=this.regions.collection.lowerEqual(e,u=>!u.mute);if(a===null){let u=this.regions.collection.optAt(0);return de(u,mt)?u.incomingValue(t):t}else if(de(a,mt))return e<a.complete?a.valueAt(e,t):a.outgoingValue(t);return t},some:a=>n===e&&de(a,Vt)?a.valueAt(e,t):t});return r}};var xa=[l.Automation,l.Modulation,l.MidiControl,l.ParameterController],ur=class{#e;#t;#r;#i;#s;#o;#n=new V;#a;#l;#u=m.None;#h=m.None;#c=null;#d=!1;constructor(e,t,r,s,o,n){this.#e=e,this.#t=t,this.#r=r,this.#i=s,this.#s=o,this.#o=n??0,this.#n.own(this.#e.parameterFieldAdapters.register(this)),this.#a=this.#n.own(new $),this.#l=new ve,this.#n.own(this.#t.subscribe(()=>this.#a.notify(this))),this.#n.own(this.#t.pointerHub.catchupAndSubscribeTransactual({onAdd:a=>{this.#l.proxy.onControlSourceAdd(xn(a.pointerType)),a.box.accept({visitTrackBox:u=>{b(this.#u.isEmpty(),"Already assigned");let h=this.#e.boxAdapters.adapterFor(u,me);this.#u=m.wrap(h),this.#e.isMainThread&&(this.#h=m.wrap(this.#e.liveStreamReceiver.subscribeFloat(this.#t.address,d=>{this.#c!==d&&(this.#c=d,this.#a.notify(this))})))}})},onRemove:a=>{this.#l.proxy.onControlSourceRemove(xn(a.pointerType)),a.box.accept({visitTrackBox:u=>{b(this.#u.unwrapOrNull()?.address?.equals(u.address)===!0,`Unknown ${u}`),this.#u=m.None,this.#e.isMainThread&&(this.#h.ifSome(h=>h.terminate()),this.#h=m.None,this.#c=null,this.#a.notify(this))}})}},...xa)),t.getValue()!==r.clamp(t.getValue())&&console.warn(`${o} (${t.getValue()}) is out of bounds`,r)}registerMidiControl(){return this.#l.proxy.onControlSourceAdd("midi"),this.#d=!0,{terminate:()=>{this.#d=!1,this.#l.proxy.onControlSourceRemove("midi")}}}get field(){return this.#t}get valueMapping(){return this.#r}get stringMapping(){return this.#i}get name(){return this.#s}get anchor(){return this.#o}get type(){return this.#t.type}get address(){return this.#t.address}get track(){return this.#u}valueAt(e){let t=this.#u;if(t.nonEmpty()){let r=t.unwrap();if(r.enabled)return this.valueMapping.y(r.valueAt(e,this.getUnitValue()))}return this.getValue()}subscribe(e){return this.#a.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}catchupAndSubscribeControlSources(e){return this.#d&&e.onControlSourceAdd("midi"),this.#t.pointerHub.filter(...xa).forEach(t=>e.onControlSourceAdd(xn(t.pointerType))),this.#l.subscribe(e)}getValue(){return this.#t.getValue()}setValue(e){this.#t.setValue(e)}setUnitValue(e){this.setValue(this.#r.y(e))}getUnitValue(){return this.#r.x(this.getValue())}getControlledValue(){return this.#r.y(this.getControlledUnitValue())}getControlledUnitValue(){return this.#c??this.getUnitValue()}getControlledPrintValue(){return this.#i.x(this.getControlledValue())}getPrintValue(){return this.#i.x(this.getValue())}setPrintValue(e){let t=this.#i.y(e);t.type==="unitValue"?this.setUnitValue(L(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#r.clamp(this.#t.initValue))}terminate(){this.#h.ifSome(e=>e.terminate()),this.#h=m.None,this.#n.terminate()}},xn=i=>{switch(i){case l.Automation:return"automated";case l.Modulation:return"modulated";case l.MidiControl:return"midi";case l.ParameterController:return"external";default:return y(`${i.toString()} is an unknown pointer type`)}};var js=class{#e;#t;#r;constructor(e,t,r){this.#e=v.newSet(s=>s.uuid),this.#t=new ve,this.#r=e.catchupAndSubscribeTransactual({onAdd:s=>{let o=t(s.box),n=this.#e.add(o);b(n,`Could not add ${o}`),this.#t.proxy.onAdd(o)},onRemove:s=>{let o=s.box.address.uuid;this.#t.proxy.onRemove(this.#e.removeByKey(o))}},r)}subscribe(e){return this.#t.subscribe(e)}catchupAndSubscribe(e){return this.#e.forEach(t=>e.onAdd(t)),this.subscribe(e)}adapters(){return this.#e.values()}size(){return this.#e.size()}isEmpty(){return this.size()===0}terminate(){this.#e.clear(),this.#t.terminate(),this.#r.terminate()}};var ft=class i{static OffsetFractions=ze.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static OffsetStringMapping=C.indices("",this.OffsetFractions.map(([e,t])=>`${e}/${t}`));type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{delay:this.#r.createParameter(e.delay,R.linearInteger(0,i.OffsetFractions.length-1),i.OffsetStringMapping,"delay"),feedback:this.#r.createParameter(e.feedback,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"feedback"),cross:this.#r.createParameter(e.cross,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"cross"),filter:this.#r.createParameter(e.filter,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter",.5),dry:this.#r.createParameter(e.dry,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var Ir=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{decay:this.#r.createParameter(e.decay,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"Room-Size"),preDelay:this.#r.createParameter(e.preDelay,R.exponential(.001,.5),C.numeric({unit:"s",fractionDigits:1,unitPrefix:!0}),"Pre-Delay"),damp:this.#r.createParameter(e.damp,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"damping"),filter:this.#r.createParameter(e.filter,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter"),dry:this.#r.createParameter(e.dry,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var Or=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get spectrum(){return this.#t.address.append(4095)}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{highPass:ya(this.#r,e.highPass,"High-Pass"),lowShelf:va(this.#r,e.lowShelf,"Low-Shelf"),lowBell:yn(this.#r,e.lowBell,"Low-Bell"),midBell:yn(this.#r,e.midBell,"Mid-Bell"),highBell:yn(this.#r,e.highBell,"High-Bell"),highShelf:va(this.#r,e.highShelf,"High-Shelf"),lowPass:ya(this.#r,e.lowPass,"Low-Pass")}}},vn=R.exponential(20,2e4),ba=R.linear(-24,24),wa=R.exponential(.01,10),ya=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,vn,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),order:i.createParameter(e.order,R.linearInteger(1,4),C.indices("db",["12","24","36","48"]),`${t} Order`),q:i.createParameter(e.q,wa,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)}),va=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,vn,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,ba,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5)}),yn=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,vn,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,ba,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5),q:i.createParameter(e.q,wa,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)});var hr=class{static Comparator=(e,t)=>e.position-t.position;type="marker-event";#e=new V;#t;#r;constructor(e,t){this.#t=e,this.#r=t,this.#e.own(this.#r.subscribe(X.Children,r=>{if(!this.trackAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackAdapter.unwrap();this.#r.position.address.equals(r.address)?s.onSortingChanged():s.dispatchChange()}}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get plays(){return this.#r.plays.getValue()}get hue(){return this.#r.hue.getValue()}get label(){return this.#r.label.getValue()}get trackAdapter(){return this.#r.track.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Je).markerTrack)}terminate(){this.#e.terminate()}toString(){return`{MarkerBoxAdapter ${v.toString(this.#r.address.uuid).substring(0,4)}, plays: ${this.plays}`}};var Qs=class{#e;#t;changeNotifier;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=t,this.changeNotifier=new $,this.#r=v.newSet(r=>r.uuid),this.#i=Et.create(hr.Comparator),this.#s=this.#t.markers.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{if(r instanceof Cr){let s=this.#e.boxAdapters.adapterFor(r,hr),o=this.#r.add(s);b(o,"Could not add adapter"),this.#i.add(s),this.dispatchChange()}},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#r.removeByKey(r)),this.dispatchChange()}})}subscribe(e){return this.changeNotifier.subscribe(e)}get context(){return this.#e}get enabled(){return this.#t.enabled.getValue()}get events(){return this.#i}get object(){return this.#t}dispatchChange(){this.changeNotifier.notify()}onSortingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}terminate(){this.#s.terminate()}};var Je=class{#e;#t;constructor(e,t){this.#e=t,this.#t=new Qs(e,this.#e.markerTrack)}terminate(){}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get markerTrack(){return this.#t}};var kt=class{#e;constructor(e,t){this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get source(){return this.#e.source.targetVertex.unwrap("Insufficient Vertex")}get target(){return this.#e.target.targetVertex.unwrap("Insufficient Vertex")}terminate(){}};var Le=class{#e;#t;#r;#i;#s;#o=!1;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=t.attributes,this.#s=this.#r.own(new te(e))}get inputs(){throw new Error("Method not implemented.")}get outputs(){throw new Error("Method not implemented.")}own(e){return this.#r.own(e)}ownAll(...e){this.#r.ownAll(...e)}onSelected(){this.#o=!0}onDeselected(){this.#o=!1}isSelected(){return this.#o}get box(){return this.#t}get attributes(){return this.#i}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get parameters(){return this.#s}get modular(){return this.#e.boxAdapters.adapterFor(this.#t.attributes.collection.targetVertex.unwrap().box,Ut)}terminate(){this.#r.terminate()}};var Be;(function(i){i.Input="input",i.Output="output"})(Be||(Be={}));var Ne=class i{static create(e,t,r,s){return new i(e,t,r,s??t.fieldName)}#e;#t;#r;#i;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#r=r,this.#i=s}matches(e){return this.direction!==e.direction&&this.field.pointerRules.accepts.some(t=>e.field.pointerRules.accepts.some(r=>r===t))}get connections(){return this.#t.pointerHub.isEmpty()?A.empty():this.#t.pointerHub.filter(l.VoltageConnection).map(({box:e})=>this.#e.adapterFor(e,kt))}get field(){return this.#t}get address(){return this.#t.address}get direction(){return this.#r}get name(){return this.#i}toString(){return`{ModuleConnectorAdapter address: ${this.#t.address.toString()}, direction: ${this.#r}}`}};var kr=class extends Le{#e;#t;#r;constructor(e,t){super(e,t),this.#e=this.parameters.createParameter(t.time,R.exponential(1,1e4),C.numeric({unit:"ms"}),"Time"),this.#t=Ne.create(e.boxAdapters,t.voltageInput,Be.Input,"Input"),this.#r=Ne.create(e.boxAdapters,t.voltageOutput,Be.Output,"Output")}get parameterTime(){return this.#e}get voltageInput(){return this.#t}get voltageOutput(){return this.#r}get inputs(){return[this.#t]}get outputs(){return[this.#r]}};var Ur=class extends Le{#e;constructor(e,t){super(e,t),this.#e=Ne.create(e.boxAdapters,t.input,Be.Input,"Input")}get voltageInput(){return this.#e}get inputs(){return[this.#e]}get outputs(){return A.empty()}};var Kr=class extends Le{#e;#t;#r;constructor(e,t){super(e,t),this.#e=this.parameters.createParameter(t.gain,R.DefaultDecibel,C.numeric({unit:"db"}),"Gain"),this.#t=Ne.create(e.boxAdapters,t.voltageInput,Be.Input,"Input"),this.#r=Ne.create(e.boxAdapters,t.voltageOutput,Be.Output,"Output")}get parameterGain(){return this.#e}get voltageInput(){return this.#t}get voltageOutput(){return this.#r}get inputs(){return[this.#t]}get outputs(){return[this.#r]}};var Lr=class extends Le{#e;#t;#r;constructor(e,t){super(e,t),this.#e=Ne.create(e.boxAdapters,t.voltageInputX,Be.Input,"X"),this.#t=Ne.create(e.boxAdapters,t.voltageInputY,Be.Input,"Y"),this.#r=Ne.create(e.boxAdapters,t.voltageOutput,Be.Output,"Result")}get inputs(){return[this.#e,this.#t]}get outputs(){return[this.#r]}};var $r=class extends Le{#e;constructor(e,t){super(e,t),this.#e=Ne.create(e.boxAdapters,t.output,Be.Output,"Output")}get voltageOutput(){return this.#e}get inputs(){return A.empty()}get outputs(){return[this.#e]}};var qr;(function(i){i.isVertexOfModule=e=>e.box.accept({visitModuleGainBox:()=>!0,visitModuleDelayBox:()=>!0,visitModuleMultiplierBox:()=>!0,visitModularAudioInputBox:()=>!0,visitModularAudioOutputBox:()=>!0})??!1,i.adapterFor=(e,t)=>U(t.accept({visitModuleGainBox:r=>e.adapterFor(r,Kr),visitModuleDelayBox:r=>e.adapterFor(r,kr),visitModuleMultiplierBox:r=>e.adapterFor(r,Lr),visitModularAudioInputBox:r=>e.adapterFor(r,$r),visitModularAudioOutputBox:r=>e.adapterFor(r,Ur)}),`Could not find ModuleAdapter for ${t.name}`)})(qr||(qr={}));var zr=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get moduleAdapter(){return qr.adapterFor(this.#e.boxAdapters,this.#r.box)}get parameterAdapter(){return this.moduleAdapter.parameters.parameterAt(this.#r.address.fieldKeys)}get#r(){return this.#t.parameter.targetVertex.unwrap("Parameter not assigned")}terminate(){}};var Kt=class{type="audio-effect";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}parameterAt(e){return y("Not yet implemented")}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}modular(){return this.#e.boxAdapters.adapterFor(this.#t.modularSetup.targetVertex.unwrap("No Modular found").box,Ut)}elements(){return this.#t.userInterface.elements.pointerHub.filter(l.DeviceUserInterface).map(e=>this.#e.boxAdapters.adapterFor(e.box,zr))}terminate(){}};var Ut=class{#e=new V;#t;#r;#i;#s;#o;constructor(e,t){this.#r=e,this.#i=t,this.#t=this.#e.own(new ve),this.#s=v.newSet(a=>a.uuid),this.#o=v.newSet(a=>a.uuid);let r=a=>{let u=qr.adapterFor(this.#r.boxAdapters,a.box);this.#s.add(u)&&this.#t.proxy.onModuleAdded(u)},s=a=>this.#t.proxy.onModuleRemoved(this.#s.removeByKey(a.address.uuid)),o=a=>{let u=this.#r.boxAdapters.adapterFor(a.box,kt);this.#o.add(u)&&this.#t.proxy.onConnectionAdded(u)},n=a=>this.#t.proxy.onConnectionRemoved(this.#o.removeByKey(a.address.uuid));this.#i.modules.pointerHub.filter(l.ModuleCollection).forEach(r),this.#i.connections.pointerHub.filter(l.ConnectionCollection).forEach(o),this.#e.own(this.#i.modules.pointerHub.subscribeTransactual({onAdd:r,onRemove:s},l.ModuleCollection)),this.#e.own(this.#i.connections.pointerHub.subscribeTransactual({onAdd:o,onRemove:n},l.ConnectionCollection))}catchupAndSubscribe(e){return Yo(e.onModuleAdded,t=>this.#s.forEach(r=>t(r))),Yo(e.onConnectionAdded,t=>this.#o.forEach(r=>t(r))),this.#t.subscribe(e)}get box(){return this.#i}get address(){return this.#i.address}get uuid(){return this.#i.address.uuid}get editingField(){return this.#i.editing}get labelField(){return this.#i.label}get modules(){return this.#s.values()}get connections(){return this.#o.values()}get device(){return this.#r.boxAdapters.adapterFor(U(this.#i.device.pointerHub.incoming().at(0),"No device found").box,Kt)}terminate(){console.debug(`terminate ${this}`),this.#e.terminate()}};var _r=class i{static Durations=[[1,8],[1,4],[1,4],[1,2],[1,1],[2,1],[4,1],[8,1],[16,1]];static DurationPPQNs=i.Durations.map(([e,t])=>G.fromSignature(e,t));static DurationStrings=i.Durations.map(([e,t])=>`${e}/${t}`);type="groove-adapter";#e=new V;#t;#r;#i;namedParameter;#s=new Li({duration:()=>this.#n,fx:e=>tn(e,this.#o),fy:e=>tn(e,1-this.#o)});#o=0;#n=G.SemiQuaver*2;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new te(this.#t)),this.namedParameter=this.#a(t),this.#e.ownAll(this.namedParameter.duration.catchupAndSubscribe(r=>this.#n=r.getValue()),this.namedParameter.amount.catchupAndSubscribe(r=>this.#o=Vn(r.getValue(),.01)))}unwarp(e){return this.#s.unwarp(e)}warp(e){return this.#s.warp(e)}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#e.terminate()}#a(e){return{duration:this.#i.createParameter(e.duration,R.values(i.DurationPPQNs),C.values("",i.DurationPPQNs,i.DurationStrings),"duration"),amount:this.#i.createParameter(e.amount,R.unipolar(),C.percent({fractionDigits:0}),"amount")}}};var Lt=class{#e;#t;#r;#i;#s;#o=new V;#n;#a=m.None;constructor(e,t,r,s,o){this.#e=e,this.#t=t,this.#r=r,this.#i=s,this.#s=o??0,this.#n=this.#o.own(new $),this.#o.own(this.#e.subscribe(()=>this.#n.notify(this))),e.getValue()!==t.clamp(e.getValue())&&console.warn(`${s} (${e.getValue()}) is out of bounds`,t)}get field(){return this.#e}get valueMapping(){return this.#t}get stringMapping(){return this.#r}get name(){return this.#i}get anchor(){return this.#s}get type(){return this.#e.type}get address(){return this.#e.address}get track(){return this.#a}subscribe(e){return this.#n.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}getValue(){return this.#e.getValue()}setValue(e){this.#e.setValue(this.#t.clamp(e))}setUnitValue(e){this.setValue(this.#t.y(e))}getUnitValue(){return this.#t.x(this.getValue())}getPrintValue(){return this.#r.x(this.getValue())}setPrintValue(e){let t=this.#r.y(e);t.type==="unitValue"?this.setUnitValue(L(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#t.clamp(this.#e.initValue))}terminate(){this.#o.terminate()}};var Ys=class{#e;#t;#r;#i;#s;#o;constructor(e){this.#e=e,this.#t=new Lt(this.#e.keyboard,R.values([88,76,61,49]),C.numeric({fractionDigits:1}),"Keyboard Type"),this.#r=new Lt(this.#e.timeRangeInQuarters,R.exponential(1,64),C.numeric({fractionDigits:1}),"Time-Range"),this.#i=new Lt(this.#e.noteScale,R.exponential(.5,2),C.numeric({fractionDigits:1}),"Note Scale"),this.#s=new Lt(this.#e.noteLabels,R.bool,C.bool,"Note Labels"),this.#o=new Lt(this.#e.transpose,R.linearInteger(-48,48),C.numeric({fractionDigits:0}),"Transpose")}subscribe(e){return this.#e.box.subscribe(X.Children,()=>e(this))}get object(){return this.#e}get keyboard(){return this.#t}get timeRangeInQuarters(){return this.#r}get noteScale(){return this.#i}get noteLabels(){return this.#s}get transpose(){return this.#o}};var Hr=class{#e;#t;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=t,this.#r=Ee.create(this.#t.audioUnits,r=>this.#e.boxAdapters.adapterFor(r,Ze),l.AudioUnits),this.#i=new js(this.#t.audioBusses.pointerHub,r=>this.#e.boxAdapters.adapterFor(r,Me),l.AudioBusses),this.#s=new Ys(this.#t.pianoMode)}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get audioBusses(){return this.#i}get audioUnits(){return this.#r}get clips(){return this.#r.adapters().flatMap(e=>e.tracks.collection.adapters()).flatMap(e=>e.clips.collection.adapters())}get groove(){return this.#e.boxAdapters.adapterFor(this.#t.groove.targetVertex.unwrap("no groove").box,_r)}get timeline(){return this.#e.boxAdapters.adapterFor(this.#t.timeline.targetVertex.unwrap("no timeline").box,Je)}get pianoMode(){return this.#s}get created(){return new Date(this.#t.created.getValue())}terminate(){this.#r.terminate()}};var Gr=class{type="instrument";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Audio}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!1}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{flutter:this.#r.createParameter(e.flutter,R.unipolar(),C.percent(),"flutter"),wow:this.#r.createParameter(e.wow,R.unipolar(),C.percent(),"wow"),noise:this.#r.createParameter(e.noise,R.unipolar(),C.percent(),"noise"),saturation:this.#r.createParameter(e.saturation,R.unipolar(),C.percent(),"saturation")}}};var Wr=class{type="instrument";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),octave:this.#r.createParameter(e.octave,R.linearInteger(-3,3),C.numeric(),"octave",.5),tune:this.#r.createParameter(e.tune,R.linear(-1200,1200),C.numeric({unit:"cent",fractionDigits:0}),"tune",.5),waveform:this.#r.createParameter(e.waveform,R.linearInteger(0,3),C.indices("",["sine","triangle","sawtooth","square"]),"waveform"),cutoff:this.#r.createParameter(e.cutoff,R.exponential(20,18e3),C.numeric({unit:"Hz"}),"cutoff"),resonance:this.#r.createParameter(e.resonance,R.exponential(.1,20),C.numeric({unit:"q",fractionDigits:1}),"resonance"),attack:this.#r.createParameter(e.attack,R.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"attack"),release:this.#r.createParameter(e.release,R.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"release"),filterEnvelope:this.#r.createParameter(e.filterEnvelope,R.linear(-.5,.5),C.percent(),"filter env",.5)}}};var $t=class i{static RateFractions=ze.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static RateStringMapping=C.indices("",this.RateFractions.map(([e,t])=>`${e}/${t}`));type="midi-effect";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}parameterAt(e){return this.#r.parameterAt(e)}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{modeIndex:this.#r.createParameter(e.modeIndex,R.linearInteger(0,2),C.indices("",["Up","Down","UpDown"]),"mode"),numOctaves:this.#r.createParameter(e.numOctaves,R.linearInteger(1,5),C.numeric({unit:"",fractionDigits:0}),"Octaves"),rate:this.#r.createParameter(e.rateIndex,R.linearInteger(0,i.RateFractions.length-1),i.RateStringMapping,"Rate"),gate:this.#r.createParameter(e.gate,R.linear(0,2),C.percent({fractionDigits:0}),"Gate"),repeat:this.#r.createParameter(e.repeat,R.linearInteger(1,16),C.numeric({fractionDigits:0}),"Repeat"),velocity:this.#r.createParameter(e.velocity,R.bipolar(),C.percent({fractionDigits:0,bipolar:!1}),"Velocity")}}};var jr=class{type="midi-effect";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{octaves:this.#r.createParameter(e.octaves,R.linearInteger(-7,7),C.numeric({unit:"oct",fractionDigits:0}),"octaves"),semiTones:this.#r.createParameter(e.semiTones,R.linearInteger(-36,36),C.numeric({unit:"st",fractionDigits:0}),"semi-tones"),cent:this.#r.createParameter(e.cents,R.linear(-50,50),C.numeric({unit:"cents",fractionDigits:1}),"cents")}}};var Qr=class{type="instrument";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),release:this.#r.createParameter(e.release,R.exponential(.001,8),C.numeric({unit:"s",fractionDigits:3}),"release")}}};var Yr=class{class="device-host";accepts=!1;type="instrument";#e=new V;#t;#r;#i;#s;#o;namedParameter;#n=m.None;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(Ee.create(this.#r.midiEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isMidiEffect),l.MidiEffectHost)),this.#s=this.#e.own(Ee.create(this.#r.audioEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isAudioEffect),l.AudioEffectHost)),this.#o=this.#e.own(new te(this.#t)),this.namedParameter=this.#a(t),this.#e.own(this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(({box:s})=>this.#t.boxAdapters.adapterFor(s,Xe)),this.#n.unwrapOrNull()?.getOrCreateLoader()}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get peakAddress(){return this.#r.address.append(1001)}get indexField(){return this.#r.index}get gate(){return this.#r.gate.getValue()}get exclude(){return this.#r.exclude.getValue()}get label(){return`${this.device().labelField.getValue()} > ${this.#n.mapOr(e=>e.box.fileName.getValue(),"No file")}`}get iconField(){return this.#r.icon}get defaultTrackType(){return J.Notes}get acceptsMidiEvents(){return!0}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.audioUnitBoxAdapter().box.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.audioUnitBoxAdapter().box.tracks}get isAudioUnit(){return!1}file(){return this.#n}fileUUID(){return this.#r.file.targetAddress.unwrap().uuid}resetParameters(){this.#r.mute.reset(),this.#r.solo.reset(),this.#r.exclude.reset(),this.#r.polyphone.reset(),this.#r.pitch.reset(),this.#r.attack.reset(),this.#r.release.reset(),this.#r.sampleStart.reset(),this.#r.sampleEnd.reset(),this.#r.gate.reset()}copyToIndex(e){Mr.create(this.#r.graph,v.generate(),t=>{t.file.refer(this.#r.file.targetVertex.unwrap()),t.device.refer(this.#r.device.targetVertex.unwrap()),t.index.setValue(e),t.mute.setValue(this.#r.mute.getValue()),t.solo.setValue(this.#r.solo.getValue()),t.sampleStart.setValue(this.#r.sampleStart.getValue()),t.sampleEnd.setValue(this.#r.sampleEnd.getValue()),t.attack.setValue(this.#r.attack.getValue()),t.release.setValue(this.#r.release.getValue()),t.pitch.setValue(this.#r.pitch.getValue()),t.exclude.setValue(this.#r.exclude.getValue()),t.gate.setValue(this.#r.gate.getValue())})}get midiEffects(){return this.#i}get inputAdapter(){return m.wrap(this)}get audioEffects(){return this.#s}get labelField(){return this.#r.label}get enabledField(){return this.#r.enabled}get minimizedField(){return this.#r.minimized}device(){return this.#t.boxAdapters.adapterFor(this.#r.device.targetVertex.unwrap().box,qt)}deviceHost(){return this.device().deviceHost()}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#e.terminate()}#a(e){return{gate:this.#o.createParameter(e.gate,R.linearInteger(0,2),C.indices("",["Off","On","Loop"]),"Gate"),mute:this.#o.createParameter(e.mute,R.bool,C.bool,"Mute"),solo:this.#o.createParameter(e.solo,R.bool,C.bool,"Solo"),polyphone:this.#o.createParameter(e.polyphone,R.bool,C.bool,"Polyphone"),exclude:this.#o.createParameter(e.exclude,R.bool,C.bool,"Exclude"),pitch:this.#o.createParameter(e.pitch,R.linear(-1200,1200),C.numeric({unit:"cents",bipolar:!0,fractionDigits:0}),"Pitch",0),sampleStart:this.#o.createParameter(e.sampleStart,R.unipolar(),C.percent(),"Start",0),sampleEnd:this.#o.createParameter(e.sampleEnd,R.unipolar(),C.percent(),"End",1),attack:this.#o.createParameter(e.attack,R.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Attack"),release:this.#o.createParameter(e.release,R.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Release")}}};var qt=class{type="instrument";accepts="midi";#e;#t;#r;#i;constructor(e,t){this.#e=e,this.#t=t,this.#r=Ee.create(t.samples,r=>e.boxAdapters.adapterFor(r,Yr),l.Sample),this.#i=new te(this.#e)}reset(){this.#r.adapters().forEach(e=>e.box.delete())}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get notesAddress(){return this.#t.address.append(1e3)}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}get samples(){return this.#r}get context(){return this.#e}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#i.terminate()}};var Xr=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.decibel(-72,0,12),C.numeric({unit:"db",fractionDigits:1}),"Volume"),panning:this.#r.createParameter(e.panning,R.bipolar(),C.panning,"Panning",.5),stereo:this.#r.createParameter(e.stereo,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"stereo",.5),invertL:this.#r.createParameter(e.invertL,R.bool,C.bool,"Invert Left"),invertR:this.#r.createParameter(e.invertR,R.bool,C.bool,"Invert Right"),swap:this.#r.createParameter(e.swap,R.bool,C.bool,"Swap")}}};var cr;(function(i){i.checkType=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="groove-adapter"})(cr||(cr={}));var Zr=class{type="midi-effect";accepts="midi";#e;#t;constructor(e,t){this.#e=e,this.#t=t,this.groove()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}groove(){return this.#e.boxAdapters.adapterFor(this.#t.groove.targetVertex.unwrap("no groove").box,cr.checkType)}catchupAndSubscribeGroove(e){return this.#t.groove.catchupAndSubscribe(t=>e(this.#e.boxAdapters.adapterFor(t.targetVertex.unwrap("No groove found").box,cr.checkType)))}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var Jr=class{type="audio-effect";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get commentField(){return this.#t.comment}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var ei=class{type="midi-effect";accepts="midi";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get commentField(){return this.#t.comment}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var Xs=class{#e;#t;#r;#i;constructor(e){this.#e=e,this.#t=v.newSet(t=>t.uuid),this.#r=new Set,this.#i=this.#e.boxGraph.subscribeToAllUpdates({onUpdate:t=>{if(t.type==="delete"){let r=this.#t.getOrNull(t.uuid);D(r)&&(this.#r.add(r.box),this.#t.removeByValue(r).terminate())}}})}terminate(){this.#t.values().forEach(e=>e.terminate()),this.#t.clear(),this.#i.terminate()}adapterFor(e,t){if(this.#r.has(e))return y(`Cannot resolve adapter for already deleted box: ${e}`);let r=this.#t.getOrNull(e.address.uuid);if(r===null){r=this.#s(e);let s=this.#t.add(r);b(s,`Could not add adapter for ${e}`)}return typeof t=="function"?Object.hasOwn(t,"prototype")?r instanceof t?r:y(`${r} is not instance of ${t}`):t(r)?r:y(`${r} did not pass custom type guard`):y("Unknown checkType method")}#s(e){return U(e.accept({visitRootBox:t=>new Hr(this.#e,t),visitArpeggioDeviceBox:t=>new $t(this.#e,t),visitPitchDeviceBox:t=>new jr(this.#e,t),visitStereoToolDeviceBox:t=>new Xr(this.#e,t),visitDelayDeviceBox:t=>new ft(this.#e,t),visitReverbDeviceBox:t=>new Ir(this.#e,t),visitRevampDeviceBox:t=>new Or(this.#e,t),visitUnknownAudioEffectDeviceBox:t=>new Jr(this.#e,t),visitPlayfieldDeviceBox:t=>new qt(this.#e,t),visitPlayfieldSampleBox:t=>new Yr(this.#e,t),visitModularDeviceBox:t=>new Kt(this.#e,t),visitTapeDeviceBox:t=>new Gr(this.#e,t),visitNanoDeviceBox:t=>new Qr(this.#e,t),visitVaporisateurDeviceBox:t=>new Wr(this.#e,t),visitModularBox:t=>new Ut(this.#e,t),visitModuleConnectionBox:t=>new kt(this.#e,t),visitModuleDelayBox:t=>new kr(this.#e,t),visitModuleGainBox:t=>new Kr(this.#e,t),visitModuleMultiplierBox:t=>new Lr(this.#e,t),visitModularAudioInputBox:t=>new $r(this.#e,t),visitModularAudioOutputBox:t=>new Ur(this.#e,t),visitDeviceInterfaceKnobBox:t=>new zr(this.#e,t),visitAudioUnitBox:t=>new Ze(this.#e,t),visitAudioBusBox:t=>new Me(this.#e,t),visitAuxSendBox:t=>new Dr(this.#e,t),visitAudioFileBox:t=>new Xe(this.#e,t),visitAudioClipBox:t=>new Dt(this.#e,t),visitAudioRegionBox:t=>new It(this.#e,t),visitNoteEventBox:t=>new lr(this.#e,t),visitNoteEventCollectionBox:t=>new Ke(this.#e,t),visitNoteClipBox:t=>new Vr(this.#e,t),visitNoteRegionBox:t=>new Ot(this.#e,t),visitValueEventBox:t=>new Tt(this.#e,t),visitValueEventCollectionBox:t=>new Ue(this.#e,t),visitValueClipBox:t=>new Vt(this.#e,t),visitValueRegionBox:t=>new mt(this.#e,t),visitTrackBox:t=>new me(this.#e,t),visitTimelineBox:t=>new Je(this.#e,t),visitMarkerBox:t=>new hr(this.#e,t),visitZeitgeistDeviceBox:t=>new Zr(this.#e,t),visitUnknownMidiEffectDeviceBox:t=>new ei(this.#e,t),visitGrooveShuffleBox:t=>new _r(this.#e,t)}),`Could not find factory for ${e}`)}};var Aa;(function(i){i.countStems=e=>e.match({none:()=>1,some:t=>Object.keys(t).length}),i.sanitizeFileName=e=>e.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_").trim(),i.sanitizeExportNamesInPlace=e=>{let t=new Map,r=s=>{let o=t.get(s)??0,n=s;for(;t.has(n);)o++,n=`${s} ${o}`;return t.set(s,o),t.set(n,1),n};Object.keys(e).forEach(s=>{let o=e[s];o.fileName=r(i.sanitizeFileName(o.fileName))})}})(Aa||(Aa={}));var Ea=Se.createBuilder({position:Se.float,playbackTimestamp:Se.float,countInBeatsRemaining:Se.float,countInBeatsTotal:Se.float,isPlaying:Se.bool,isCountingIn:Se.bool,isRecording:Se.bool});var et=class{#e=new V;#t;#r;#i;constructor(e,t){this.#t=e,this.#r=t,this.#i=new ye(128),this.#e.own(this.#t.broadcastIntegers(this.#r,new Int32Array(this.#i.buffer),Xt))}noteOn(e){e>=0&&e<128&&this.#i.setBit(e,!0)}noteOff(e){e>=0&&e<128&&this.#i.setBit(e,!1)}reset(){}clear(){this.#i.clear()}terminate(){this.#e.terminate()}toString(){return`{${this.constructor.name}}`}};var gt;(function(i){i[i.MTHD=1297377380]="MTHD",i[i.MTRK=1297379947]="MTRK"})(gt||(gt={}));var Fe;(function(i){i[i.NOTE_ON=144]="NOTE_ON",i[i.NOTE_OFF=128]="NOTE_OFF",i[i.NOTE_AFTER_TOUCH=160]="NOTE_AFTER_TOUCH",i[i.CONTROLLER=176]="CONTROLLER",i[i.PROGRAM_CHANGE=192]="PROGRAM_CHANGE",i[i.CHANNEL_AFTER_TOUCH=208]="CHANNEL_AFTER_TOUCH",i[i.PITCH_BEND=224]="PITCH_BEND"})(Fe||(Fe={}));var Zs=class i{ticks;type;param0;param1;static Comparator=(e,t)=>e.ticks-t.ticks;constructor(e,t,r,s){this.ticks=e,this.type=t,this.param0=r,this.param1=s}static decode(e,t,r){switch(t){case Fe.NOTE_ON:case Fe.NOTE_OFF:case Fe.CONTROLLER:case Fe.PITCH_BEND:case Fe.NOTE_AFTER_TOUCH:return new i(r,t,e.readByte(),e.readByte());case Fe.PROGRAM_CHANGE:case Fe.CHANNEL_AFTER_TOUCH:return new i(r,t,e.readByte(),0)}{let s;do s=e.readByte()&255;while(s<128);e.skip(-1)}return null}accept(e){switch(this.type){case Fe.NOTE_ON:{this.param1===0?g(e.noteOff,this.param0):g(e.noteOn,this.param0,this.param1/127);break}case Fe.NOTE_OFF:{g(e.noteOff,this.param0);break}case Fe.PITCH_BEND:{let t=this.param0&127,r=this.param1&127,s=t|r<<7;g(e.pitchBend,8192>=s?s/8192-1:(s-8191)/8192);break}case Fe.CONTROLLER:{g(e.controller,this.param0,this.param1/127);break}default:break}}toString(){return`ControlEvent{ticks: ${this.ticks}, type: ${this.type}, param0: ${this.param0}, param1: ${this.param1}}`}};var xe;(function(i){i[i.SEQUENCE_NUMBER=0]="SEQUENCE_NUMBER",i[i.TEXT_EVENT=1]="TEXT_EVENT",i[i.COPYRIGHT_NOTICE=2]="COPYRIGHT_NOTICE",i[i.SEQUENCE_TRACK_NAME=3]="SEQUENCE_TRACK_NAME",i[i.INSTRUMENT_NAME=4]="INSTRUMENT_NAME",i[i.LYRICS=5]="LYRICS",i[i.MARKER=6]="MARKER",i[i.CUE_POINT=7]="CUE_POINT",i[i.CHANNEL_PREFIX=32]="CHANNEL_PREFIX",i[i.SET_TEMPO=81]="SET_TEMPO",i[i.SMPTE_OFFSET=84]="SMPTE_OFFSET",i[i.TIME_SIGNATURE=88]="TIME_SIGNATURE",i[i.KEY_SIGNATURE=89]="KEY_SIGNATURE",i[i.SEQUENCER_SPECIFIC=127]="SEQUENCER_SPECIFIC",i[i.PREFIX_PORT=33]="PREFIX_PORT",i[i.END_OF_TRACK=47]="END_OF_TRACK"})(xe||(xe={}));var Js=class i{ticks;type;value;constructor(e,t,r){this.ticks=e,this.type=t,this.value=r}static decode(e,t){let r=e.readByte()&255,s=e.readVarLen();switch(r){case xe.SET_TEMPO:return new i(t,r,e.readTempo());case xe.TIME_SIGNATURE:return new i(t,r,e.readSignature());case xe.END_OF_TRACK:return new i(t,r,null);case xe.TEXT_EVENT:case xe.COPYRIGHT_NOTICE:case xe.SEQUENCE_TRACK_NAME:case xe.INSTRUMENT_NAME:case xe.LYRICS:case xe.MARKER:case xe.CUE_POINT:case xe.SEQUENCE_NUMBER:case xe.CHANNEL_PREFIX:case xe.KEY_SIGNATURE:case xe.SEQUENCER_SPECIFIC:case xe.PREFIX_PORT:case xe.SMPTE_OFFSET:default:e.skip(s)}return null}toString(){return`MetaEvent{ticks: ${this.ticks}, type: ${this.type}, value: ${this.value}}`}};var zt;(function(i){let e;(function(t){t[t.NoteOn=144]="NoteOn",t[t.NoteOff=128]="NoteOff",t[t.PitchBend=224]="PitchBend",t[t.Controller=176]="Controller"})(e=i.Command||(i.Command={})),i.readCommand=t=>t[0]&240,i.readChannel=t=>t[0]&15,i.readParam1=t=>1<t.length?t[1]&255:0,i.readParam2=t=>2<t.length?t[2]&255:0,i.readPitch=t=>t[1],i.readVelocity=t=>t[2]/127,i.isNoteOn=t=>i.readCommand(t)===e.NoteOn&&i.readVelocity(t)>0,i.isNoteOff=t=>i.readCommand(t)===e.NoteOff||i.readCommand(t)===e.NoteOn&&i.readVelocity(t)===0,i.isPitchWheel=t=>i.readCommand(t)===e.PitchBend,i.asPitchBend=t=>{let r=i.readParam1(t)&127,s=i.readParam2(t)&127,o=r|s<<7;return 8192>=o?o/8192-1:(o-8191)/8192},i.isController=t=>i.readCommand(t)===e.Controller,i.asValue=t=>{let r=i.readParam2(t);return 64<r?.5+(r-63)/128:64>r?r/128:.5},i.noteOn=(t,r,s)=>{let o=new Uint8Array(3);return o[0]=t|e.NoteOn,o[1]=r|0,o[2]=s|0,o},i.noteOff=(t,r)=>{let s=new Uint8Array(3);return s[0]=t|e.NoteOff,s[1]=r,s},i.accept=(t,r)=>{if(!pr(t))if(i.isNoteOn(t))g(r.noteOn,i.readPitch(t),i.readVelocity(t));else if(i.isNoteOff(t))g(r.noteOff,i.readPitch(t));else if(i.isPitchWheel(t)){let s=i.readParam1(t)&127,o=i.readParam2(t)&127,n=s|o<<7;g(r.pitchBend,8192>=n?n/8192-1:(n-8191)/8192)}else i.isController(t)&&g(r.controller,i.readParam1(t),i.readParam2(t)/127)},i.debug=t=>t===null?"null":i.isNoteOn(t)?`NoteOn #${i.readChannel(t)} ${i.readPitch(t)} : ${i.readVelocity(t).toFixed(2)}`:i.isNoteOff(t)?`NoteOff #${i.readChannel(t)} ${i.readPitch(t)}`:i.isPitchWheel(t)?`PitchWheel #${i.readChannel(t)} ${i.asPitchBend(t)}`:i.isController(t)?`Control #${i.readChannel(t)} ${i.asValue(t)}`:"Unknown"})(zt||(zt={}));var eo=class{tracks;formatType;timeDivision;constructor(e,t,r){this.tracks=e,this.formatType=t,this.timeDivision=r}};var to=class i{controlEvents;metaEvents;static decode(e){let t=new Zt,r=[],s=0,o=0,n=0;for(;;){let a=e.readVarLen(),u=e.readByte()&255;if(u<240){s+=a,u<128?e.skip(-1):(o=u&240,n=u&15);let h=Zs.decode(e,o,s);D(h)&&t.add(n,h)}else if(u<248)e.skipSysEx(u);else{s+=a;let h=Js.decode(e,s);if(h!==null&&(r.push(h),h.type===xe.END_OF_TRACK))break}}return new i(t,r)}static createEmpty(){return new i(new Zt,[])}constructor(e,t){this.controlEvents=e,this.metaEvents=t}encode(){let e=ue.create(),t=r=>{if(r<=127)e.writeByte(r);else{let s=r,o=[];for(o.push(s&127),s>>=7;s;){let n=s&127|128;o.push(n),s>>=7}o.reverse().forEach(n=>e.writeByte(n))}};return this.controlEvents.forEach((r,s)=>{let o=0,n=-1;s.forEach(a=>{let u=a.ticks-o;if(t(u),a.type===Fe.NOTE_ON){let h=144|r;h!==n&&e.writeByte(h),e.writeByte(a.param0),e.writeByte(a.param1)}else if(a.type===Fe.NOTE_OFF){let h=144|r;h!==n&&e.writeByte(h),e.writeByte(a.param0),e.writeByte(a.param1)}else console.warn("Unknown ControlType");o=a.ticks})}),e.toArrayBuffer()}};var ro=class{input;#e=!1;#t=!1;constructor(e){this.input=e}decode(){this.input.littleEndian=!1;let e=this.input.readInt();if(e===gt.MTHD){if(this.input.readInt()!==6)throw new Error("2nd int in header must be 6")}else throw console.warn(`Unsupported midi format ${e} !== ${gt.MTHD}`),new Error("Unsupported midi format");let t=this.input.readShort(),r=this.input.readShort(),s=this.input.readShort(),o=[];for(let n=0;n<r;n++){let a=this.input.readInt(),u=this.input.readInt(),h=this.input.position;a===gt.MTRK&&(o[n]=to.decode(this)),this.input.position=h+u}return 0<this.input.remaining()&&console.warn(`${this.input.remaining()} bytes remaining.`),new eo(o,t,s)}readVarLen(){let e=this.input.readByte()&255,t;if(0<(e&128)){e&=127;do t=this.input.readByte()&255,e=(e<<7)+(t&127);while(0<(t&128))}return e}readSignature(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255,s=this.input.readByte()&255;return this.#e,[e,1<<t]}readTempo(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255;return 6e7/(e<<16|t<<8|r)}skipSysEx(e){if(e===240){if(this.#t)throw new Error("System message already in progress");this.input.skip(this.readVarLen()-1),this.#t=!0}else e===247&&(this.#t?this.#t=!1:(this.input.skip(this.readVarLen()-1),this.#t=!0))}skip(e){this.input.skip(e)}readByte(){return this.input.readByte()}};var Fa;(function(i){i.decoder=t=>new ro(new ge(t)),i.encoder=()=>new e;class e{static writeVarLen(r,s){let o=[];for(;s>127;)o.push(s&127|128),s>>=7;o.push(s&127);for(let n=o.length-1;n>=0;n--)r.writeByte(o[n])}#e=[];addTrack(r){return this.#e.push(r),this}encode(){let r=ue.create();return r.littleEndian=!1,r.writeInt(gt.MTHD),r.writeInt(6),r.writeShort(0),r.writeShort(this.#e.length),r.writeShort(96),this.#e.forEach(s=>{r.writeInt(gt.MTRK);let o=s.encode();r.writeInt(o.byteLength),r.writeBytes(new Int8Array(o))}),r}}})(Fa||(Fa={}));var io=Symbol.for("@openDAW/lib-midi");globalThis[io]?console.debug(`%c${io.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[io]=!0,console.debug(`%c${io.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var _t;(function(i){i.on=(e,t,r)=>({type:"note-on",uuid:e,pitch:t,velocity:r}),i.off=(e,t)=>({type:"note-off",uuid:e,pitch:t}),i.isOn=e=>e.type==="note-on",i.isOff=e=>e.type==="note-off",i.fromEvent=(e,t)=>{let r=e.data;if(zt.isNoteOn(r)){let s=zt.readPitch(r),o=zt.readVelocity(r);return{type:"note-on",uuid:t,pitch:s,velocity:o}}else if(zt.isNoteOff(r)){let s=zt.readPitch(r);return{type:"note-off",uuid:t,pitch:s}}return y("Unknown MIDI event")}})(_t||(_t={}));var Ba;(function(i){i.start=(e,t,r,s=1)=>{let o=!0;return e(_t.on(t,r,s)),{terminate:()=>{o&&(e(_t.off(t,r)),o=!1)}}}})(Ba||(Ba={}));var so=class{#e;constructor(){this.#e=Q.newSet(e=>e.field.address)}register(e){return this.#e.add(e),{terminate:()=>this.#e.removeByValue(e)}}get(e){return this.#e.get(e)}opt(e){return this.#e.opt(e)}};var oo;(function(i){i.MAGIC_HEADER_OPEN=1330660686,i.FORMAT_VERSION=2,i.decode=t=>{let r=new ge(t);b(r.readInt()===i.MAGIC_HEADER_OPEN,"Corrupt header. Probably not an openDAW project file."),b(r.readInt()===i.FORMAT_VERSION,"Deprecated Format");let s=r.readInt(),o=new Int8Array(s);r.readBytes(o);let n=new ji(m.wrap(Ji.create));return n.fromArrayBuffer(o.buffer),{boxGraph:n,mandatoryBoxes:e(n,r)}};let e=(t,r)=>{let s=t.findBox(v.fromDataInput(r)).unwrap("RootBox not found"),o=t.findBox(v.fromDataInput(r)).unwrap("UserInterfaceBox not found"),n=t.findBox(v.fromDataInput(r)).unwrap("AudioBusBox not found"),a=t.findBox(v.fromDataInput(r)).unwrap("AudioUnitBox not found"),u=t.findBox(v.fromDataInput(r)).unwrap("TimelineBox not found");return{rootBox:s,userInterfaceBox:o,masterBusBox:n,masterAudioUnit:a,timelineBox:u}}})(oo||(oo={}));var no;(function(i){i.reader=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s},o)=>{let n=!0,a=new Int32Array(e,0,2),u=new Float32Array(e,8),h=new Float32Array(r*s),d=typeof document>"u",p=()=>{if(!n)return;let f=Atomics.load(a,1),w=Atomics.load(a,0);if(f===w){if(d)Atomics.wait(a,0,w);else{setTimeout(p,1);return}w=Atomics.load(a,0)}for(;f!==w;){let N=f*r*s;h.set(u.subarray(N,N+r*s));let S=[];for(let M=0;M<r;M++){let k=M*s,K=k+s;S.push(h.slice(k,K))}if(f=(f+1)%t,Atomics.store(a,1,f),!n)return;o(S)}p()};return p(),{stop:()=>n=!1}},i.writer=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s})=>{let o=new Int32Array(e,0,2),n=new Float32Array(e,8);return Object.freeze({write:a=>{if(a.length!==r)return;for(let d of a)if(d.length!==s)return y("Each channel buffer must contain 'bufferSize' samples");let u=Atomics.load(o,0),h=u*r*s;a.forEach((d,p)=>n.set(d,h+p*s)),Atomics.store(o,0,(u+1)%t),Atomics.notify(o,0)}})}})(no||(no={}));var bn={isClipBox:i=>i.accept({visitNoteClipBox:e=>!0,visitAudioClipBox:e=>!0,visitValueClipBox:e=>!0})??!1,isRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1,isLoopableRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1};var wn={isRegion:i=>bn.isRegionBox(i.box),isLoopableRegion:i=>bn.isLoopableRegionBox(i.box)};var tt;(function(i){i[i.Off=0]="Off",i[i.On=1]="On",i[i.Loop=2]="Loop"})(tt||(tt={}));var Na;(function(i){i.cut=(e,t,r)=>{if(!(e.position>=t||t>=e.complete))if(wn.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;e.box.duration.setValue(t-s),e.copyTo({position:t,duration:o-t,loopOffset:ai(n+(t-s),a),consolidate:r})}else return y("Not yet implemented")},i.clip=(e,t,r)=>{if(wn.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;if(o-r<=0)return y(`duration will zero or negative(${o-r})`);e.box.duration.setValue(t-s),e.copyTo({position:r,duration:o-r,loopOffset:ai(n+(r-s),a)})}else return y("Not yet implemented")}})(Na||(Na={}));var wi;(e=>e.create=(t,r,s,o)=>0|(t?1:0)|(r?2:0)|(s?4:0)|(o?8:0))(wi||={});var re=class i{static Empty=new i(2);#e;constructor(e=2){this.#e=A.create(()=>new Float32Array(128),e)}clear(e,t){this.#e.forEach(r=>r.fill(0,e,t))}numChannels(){return this.#e.length}getChannel(e){return e<this.numChannels()?this.#e[e]:this.#e[this.numChannels()-1]}assertSanity(){b(!this.#e.some(e=>e.some(t=>isNaN(t))),"AudioBuffer is invalid (NaN)")}channels(){return this.#e}replace(e){this.replaceInto(e.#e)}replaceInto(e){b(e.length===2,"mixLayout: target.length must be 2"),b(this.#e.length===1||this.#e.length===2,"mixLayout: target.length must be 1 or 2"),this.#e.length===1?(e[0].set(this.#e[0]),e[1].set(this.#e[0])):(e[0].set(this.#e[0]),e[1].set(this.#e[1]))}mixInto(e){b(e.length===2,"mixLayout: target.length must be 2"),b(this.#e.length===1||this.#e.length===2,"mixLayout: target.length must be 1 or 2");let[t,r]=e;if(this.#e.length===1){let[s]=this.#e;for(let o=0;o<128;o++)t[o]+=s[o],r[o]+=s[o]}else{let[s,o]=this.#e;for(let n=0;n<128;n++)t[n]+=s[n],r[n]+=o[n]}}};var ne=class i{static PEAK_DECAY=Math.exp(-1/(sampleRate*.25));static RMS_WINDOW=Math.floor(sampleRate*.1);#e;#t;#r;#i;#s;#o=0;#n=0;#a=0;#l=0;constructor(e,t){this.#e=e,this.#t=t,this.#r=new Float32Array(4),this.#i=A.create(()=>new wr(i.RMS_WINDOW),2),this.#s=this.#e.broadcastFloats(this.#t,this.#r,()=>{this.#r[0]=this.#o,this.#r[1]=this.#n,this.#r[2]=this.#a,this.#r[3]=this.#l})}clear(){this.#i[0].clear(),this.#i[1].clear(),this.#o=0,this.#n=0}process(e,t,r=0,s=128){let[o,n]=this.#i;for(let a=r;a<s;a++){let u=e[a],h=t[a];this.#o<u?this.#o=u:this.#o*=i.PEAK_DECAY,this.#n<h?this.#n=h:this.#n*=i.PEAK_DECAY,this.#a=o.pushPop(u),this.#l=n.pushPop(h)}}processStereo([e,t],r=0,s=128){this.process(e,t,r,s)}terminate(){this.#s.terminate()}};var ao=class{#e=new V;#t;#r;#i;#s=m.None;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#o=this.#r.getValue(),this.#e.own(this.#r.subscribe(r=>{this.#o=r.getValue(),this.#i.notify(this)}))}subscribe(e){return this.#i.subscribe(e)}getValue(){return this.#o}getUnitValue(){return this.#r.valueMapping.x(this.#o)}onStartAutomation(){b(this.#s.isEmpty(),"Already broadcasting"),this.#s=m.wrap(this.#t.broadcaster.broadcastFloat(this.#r.address,()=>this.getUnitValue()))}updateAutomation(e){let t=this.#r.valueAt(e);return this.#o!==t?(this.#o=t,!0):!1}onStopAutomation(){b(this.#s.nonEmpty(),"Never started broadcasting"),this.#s.unwrap().terminate(),this.#s=m.None,this.#o=this.#r.getValue()}own(e){return this.#e.own(e)}ownAll(...e){this.#e.ownAll(...e)}spawn(){return this.#e.spawn()}terminate(){this.#e.terminate()}};var ti=class{#e;constructor(){this.#e=new Zt(A.empty(),tr.Comparator)}add(e,t){this.#e.add(e,t)}get(e){return this.#e.get(e)}forEach(e){return this.#e.forEach(e)}clear(){this.#e.clear()}};var Ve=class{#e=new V;#t;#r;#i;#s;#o=m.None;constructor(e){this.#t=e,this.#r=new ti,this.#i=[],this.#s=[]}parameterChanged(e){return y(`Got update event for ${e}, but has no parameter change method`)}get context(){return this.#t}get eventInput(){return this.#r}bindParameter(e){let t=new ao(this.#t,e);return t.ownAll(e.field.pointerHub.catchupAndSubscribeTransactual({onAdd:r=>{this.#o.isEmpty()&&(this.#o=m.wrap(this.#t.updateClock.addEventOutput(this.#r))),this.#s.push(t),t.onStartAutomation()},onRemove:r=>{A.remove(this.#s,t),this.#s.length===0&&(this.#o.ifSome(s=>s.terminate()),this.#o=m.None),t.onStopAutomation()}},l.Automation),t.subscribe(()=>this.parameterChanged(t))),this.#i.push(t),t}updateParameter(e){this.#s.forEach(t=>{t.updateAutomation(e)&&this.parameterChanged(t)})}readAllParameters(){this.#i.forEach(e=>this.parameterChanged(e))}own(e){return this.#e.own(e)}ownAll(...e){return this.#e.ownAll(...e)}spawn(){return this.#e.spawn()}terminate(){this.#o.ifSome(e=>e.terminate()),this.#o=m.None,this.#i.length=0,this.#e.terminate()}toString(){return`{${this.constructor.name}}`}};var Ei;(e=>e.isOfType=t=>t.type==="update-event")(Ei||={});var lo=class extends Ve{#e=[];constructor(e){super(e),this.own(this.context.registerProcessor(this))}reset(){this.eventInput.clear()}addEventOutput(e){return this.#e.push(e),{terminate:()=>A.remove(this.#e,e)}}process({blocks:e}){e.forEach(({p0:t,p1:r,flags:s},o)=>{if(ye.every(s,1))for(let n of Bt.iterate(t,r,Ws)){let a={type:"update-event",position:n};this.#e.forEach(u=>u.add(o,a))}})}toString(){return`{${this.constructor.name}}`}};var fe=class extends Ve{constructor(e){super(e)}process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,s0:o,s1:n,bpm:a}=t,u=null,h=o;for(let d of this.eventInput.get(r)){let p=d.position-s,f=Math.abs(p)<1e-7?o:o+Math.floor(G.pulsesToSamples(p,a,sampleRate));b(o<=f&&f<=n,()=>`${f} out of bounds. event: ${d.position} (${d.type}), p0: ${s}`),u?.forEach(w=>this.handleEvent(w)),u=null,h<f&&(this.processAudio(t,h,f),h=f),Ei.isOfType(d)?this.updateParameter(d.position):(u??=[]).push(d)}u?.forEach(d=>this.handleEvent(d)),u=null,h<n&&this.processAudio(t,h,n)}),this.eventInput.clear(),this.finishProcess()}introduceBlock(e){}handleEvent(e){return y(`${this} received an event but has no accepting method.`)}finishProcess(){}};var uo=class i{static#e=R.exponential(20/sampleRate,2e4/sampleRate);#t;#r;#i;#s;#o;feedback=.7;cross=0;wet=.75;dry=.75;#n=0;#a=0;#l=0;#u=0;#h=0;#c=!1;#d=!1;constructor(e,t){let r=ot(e);this.#t=r,this.#r=[new Float32Array(r),new Float32Array(r)],this.#i=[new be,new be],this.#s=new At,this.#o=t}reset(){this.#a=0,this.#c&&(this.#i.forEach(e=>e.reset()),this.#r.forEach(e=>e.fill(0)),this.#c=!1,this.#d=!1),this.#f()}set offset(e){b(0<=e&&e<this.#t,"Out of bounds"),this.#u!==e&&(this.#u=e,this.#c?this.#x():this.#f())}get offset(){return this.#u}set filter(e){e===0?this.#s.identity():e>0?this.#s.setHighpassParams(i.#e.y(e),.001):e<0&&this.#s.setLowpassParams(i.#e.y(1+e),.001)}process(e,t,r,s){this.#d?this.#g(e,t,r,s):this.#p(e,t,r,s),this.#c=!0}#p(e,t,r,s){let o=this.#t-1,n=this.#r,a=this.feedback,u=this.wet,h=this.dry,d=this.#a,p=d-Math.floor(this.#l);p<0&&(p+=this.#t);let f=e[0],w=e[1],N=t[0],S=t[1],M=this.#i[0],k=this.#i[1],K=n[0],q=n[1];for(let z=r;z<s;++z){let ee=f[z],he=w[z],ce=M.processFrame(this.#s,K[p]*.96),_=k.processFrame(this.#s,q[p]*.96),j=this.cross*(_-ce),H=ce+j,Y=_-j;K[d]=(ee+H)*a+1e-18-1e-18,q[d]=(he+Y)*a+1e-18-1e-18,N[z]=H*u+ee*h,S[z]=Y*u+he*h,p=++p&o,d=++d&o}this.#a=d}#g(e,t,r,s){let o=this.#t-1,n=this.#r,a=this.feedback,u=this.wet,h=this.dry,d=this.#a;for(let p=r;p<s;++p){0<this.#h?(this.#l+=this.#n,this.#h--):(this.#l=this.#u,this.#d=!1);let f=d-this.#l;f<0&&(f+=this.#t);let w=f|0,N=f-w,S=e[0][p],M=e[1][p],k=n[0][w],K=n[0][w],q=this.#i[0].processFrame(this.#s,k+N*(n[0][w+1&o]-k)),z=this.#i[1].processFrame(this.#s,K+N*(n[1][w+1&o]-K));n[0][d]=S+q*a+1e-18-1e-18,n[1][d]=M+q*a+1e-18-1e-18,t[0][p]=q*u+S*h,t[1][p]=z*u+M*h,d=++d&o}this.#a=d}#f(){this.#l=this.#u,this.#h=0,this.#d=!1}#x(){this.#u!==this.#l&&(this.#h=this.#o,this.#n=(this.#u-this.#l)/this.#h,this.#d=!0)}};var ho=class i extends fe{static ID=0;#e=i.ID++;#t;parameterDelay;parameterFeedback;parameterCross;parameterFilter;parameterDry;parameterWet;#r;#i;#s;#o=m.None;#n=!0;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address));let{delay:r,feedback:s,cross:o,filter:n,dry:a,wet:u}=t.namedParameter;this.parameterDelay=this.own(this.bindParameter(r)),this.parameterFeedback=this.own(this.bindParameter(s)),this.parameterCross=this.own(this.bindParameter(o)),this.parameterFilter=this.own(this.bindParameter(n)),this.parameterDry=this.own(this.bindParameter(a)),this.parameterWet=this.own(this.bindParameter(u));let h=G.pulsesToSamples(ze.toPPQN(ft.OffsetFractions[0]),30,sampleRate),d=Math.floor(.5*sampleRate);this.#s=new uo(h,d),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.reset(),this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#o=m.wrap(e),{terminate:()=>this.#o=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}handleEvent(e){}processAudio({bpm:e,flags:t},r,s){if(this.#o.isEmpty())return;if(this.#n||ye.some(t,8)){let n=this.parameterDelay.getValue(),a=ze.toPPQN(ft.OffsetFractions[n]);this.#s.offset=G.pulsesToSamples(a,e,sampleRate),this.#n=!1}let o=this.#o.unwrap();this.#s.process(o.channels(),this.#r.channels(),r,s),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1),r,s)}parameterChanged(e){e===this.parameterDelay?this.#n=!0:e===this.parameterFeedback?this.#s.feedback=this.parameterFeedback.getValue():e===this.parameterCross?this.#s.cross=this.parameterCross.getValue():e===this.parameterFilter?this.#s.filter=this.parameterFilter.getValue():e===this.parameterDry?this.#s.dry=we(this.parameterDry.getValue()):e===this.parameterWet&&(this.#s.wet=we(this.parameterWet.getValue()))}toString(){return`{${this.constructor.name} (${this.#e})}`}};var Fi=class i extends Ve{static ID=0;#e=i.ID++;#t;#r;#i;#s=m.None;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#s=m.wrap(e),{terminate:()=>this.#s=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}process(e){if(this.#s.isEmpty())return;let t=this.#s.unwrap(),[r,s]=t.channels(),[o,n]=this.#r.channels();for(let a=0;a<128;a++)o[a]=r[a],n[a]=s[a];this.#i.process(o,n)}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#e})`}};var ri=class i extends Ve{static ID=0;#e=i.ID++;#t;#r;#i;#s;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=[],this.own(e.registerProcessor(this))}get noteEventTarget(){return m.None}get incoming(){return this}get outgoing(){return this}get uuid(){return this.#t.uuid}reset(){this.#i.clear(),this.#r.clear()}addAudioSource(e){return this.#s.push(e),{terminate:()=>{A.remove(this.#s,e),this.#r.clear()}}}get adapter(){return this.#t}get audioOutput(){return this.#r}process(e){this.#r.clear();let[t,r]=this.#r.channels();for(let s of this.#s){let[o,n]=s.channels();for(let a=0;a<128;a++)t[a]+=o[a],r[a]+=n[a]}this.#r.assertSanity(),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1))}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#e})}`}};var Z;(n=>{n.start=(a,u,h,d,p=0)=>({type:"note-event",position:a,duration:u,pitch:h,velocity:d,cent:p,id:++o}),n.startWith=(a,u,h)=>({type:"note-event",position:u??a.position,duration:h??a.duration,pitch:a.pitch,cent:a.cent,velocity:a.velocity,id:++o}),n.stop=({id:a,pitch:u},h)=>({type:"note-complete-event",position:h,pitch:u,id:a}),n.isStart=a=>a.type==="note-event"&&"id"in a&&typeof a.id=="number",n.isStop=a=>a.type==="note-complete-event";let o=0})(Z||={});var Ht=class{#e=new V;#t;#r;#i=m.None;constructor(e,t,r){this.#t=e,this.#r=this.#e.own(new et(t,r))}setNoteEventSource(e){return b(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=m.wrap(e),this.#t.reset(),O.create(()=>{this.#i=m.None,this.#t.reset()})}introduceBlock({index:e,p0:t,p1:r,flags:s}){if(!this.#i.isEmpty())for(let o of this.#i.unwrap().processNotes(t,r,s))o.pitch>=0&&o.pitch<=127&&(this.#t.eventInput.add(e,o),this.#s(o))}clear(){}terminate(){this.#e.terminate()}#s(e){Z.isStart(e)?this.#r.noteOn(e.pitch):Z.isStop(e)&&this.#r.noteOff(e.pitch)}};var co=class extends fe{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h;#c;#d;#p;gain=1;freqMult=1;attack=1;release=1;waveform=ut.sine;cutoff=1;resonance=1;filterEnvelope=0;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new Ht(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#i=new re,this.#s=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.octave)),this.#a=this.own(this.bindParameter(this.#e.namedParameter.tune)),this.#l=this.own(this.bindParameter(this.#e.namedParameter.attack)),this.#u=this.own(this.bindParameter(this.#e.namedParameter.release)),this.#h=this.own(this.bindParameter(this.#e.namedParameter.waveform)),this.#c=this.own(this.bindParameter(this.#e.namedParameter.cutoff)),this.#d=this.own(this.bindParameter(this.#e.namedParameter.resonance)),this.#p=this.own(this.bindParameter(this.#e.namedParameter.filterEnvelope)),this.own(e.registerProcessor(this)),this.readAllParameters()}get noteEventTarget(){return m.wrap(this)}introduceBlock(e){this.#r.introduceBlock(e)}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.clear(),this.#t.length=0,this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#i}get adapter(){return this.#e}handleEvent(e){Z.isStart(e)?this.#t.push(new An(this,e)):Z.isStop(e)&&this.#t.find(t=>t.event.id===e.id)?.stop()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#t.length-1;s>=0;s--)this.#t[s].processAdd(this.#i,t,r)&&this.#t.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=we(this.#o.getValue()):e===this.#n||e===this.#a?this.freqMult=2**(this.#n.getValue()+this.#a.getValue()/1200):e===this.#l?this.attack=Math.floor(this.#l.getValue()*sampleRate):e===this.#u?this.release=Math.floor(this.#u.getValue()*sampleRate):e===this.#h?this.waveform=Cn(this.#h.getValue(),ut):e===this.#c?this.cutoff=this.#c.getValue():e===this.#d?this.resonance=this.#d.getValue():e===this.#p&&(this.filterEnvelope=this.#p.getValue())}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return"{VaporisateurDevice}"}},An=class{device;event;osc;buffer;filterCoeff;filterProcessor;phase=0;position=0;decayPosition=Number.POSITIVE_INFINITY;constructor(e,t){this.device=e,this.event=t,this.osc=new $i,this.buffer=new Float32Array(128),this.filterCoeff=new At,this.filterProcessor=new be}stop(){this.decayPosition=this.position-this.device.attack}processAdd(e,t,r){let s=Jn(this.event.pitch+this.event.cent/100,440)*this.device.freqMult,o=qi(this.event.velocity)*this.device.gain*we(-15),n=this.device.waveform,a=this.device.attack,u=this.device.release,h=this.device.adapter.namedParameter.cutoff.valueMapping,d=h.x(this.device.cutoff),p=this.device.resonance,f=this.device.filterEnvelope,w=e.getChannel(0),N=e.getChannel(1);this.osc.generate(this.buffer,s/sampleRate,n,t,r);for(let S=t;S<r;S++){let M=Math.min(this.position/a,1-(this.position-(this.decayPosition+a))/u,1)**2;this.filterCoeff.setLowpassParams(h.y(L(d+M*f,0,1))/sampleRate,p);let k=this.filterProcessor.processFrame(this.filterCoeff,this.buffer[S])*o*M;if(w[S]+=k,N[S]+=k,++this.position-this.decayPosition>a+u)return!0}return!1}};var po=class extends Ve{#e;#t;#r;constructor(e,t){super(e),this.#e=t,this.#t=new re(2),this.#r=this.own(new ne(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get noteEventTarget(){return m.None}reset(){this.#r.clear(),this.#t.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#t}process({blocks:e}){this.#t.clear(0,128);let[t,r]=this.#t.channels();this.#e.deviceHost().audioUnitBoxAdapter().tracks.collection.adapters().filter(s=>s.type===J.Audio&&s.enabled.getValue()).forEach(s=>e.forEach(o=>{let{p0:n,p1:a,flags:u}=o;if(!ye.every(u,5))return;let h=this.context.clipSequencing.iterate(s.uuid,n,a);for(let{optClip:d,sectionFrom:p,sectionTo:f}of h)d.match({none:()=>{for(let w of s.regions.collection.iterateRange(n,a)){if(w.mute||!de(w,It))continue;let S=w.file.getOrCreateLoader().data;if(S.isEmpty())return;let M=S.unwrap();for(let k of Te.locateLoops(w,n,a))this.#i(this.#t,M,k,o)}},some:w=>{if(!de(w,Dt))return;let N=w.file.getOrCreateLoader().data;if(N.isEmpty())return;let S=N.unwrap();for(let M of Te.locateLoops({position:0,loopDuration:w.duration,loopOffset:0,complete:Number.POSITIVE_INFINITY},p,f))this.#i(this.#t,S,M,o)}})})),this.#t.assertSanity(),this.#r.process(t,r)}parameterChanged(e){}#i(e,t,r,{p0:s,p1:o,s0:n,s1:a}){let[u,h]=e.channels(),{numberOfFrames:d,frames:p}=t,f=p[0],w=p.length===1?p[0]:p[1],N=a-n,S=o-s,M=d*r.resultStartValue,k=d*r.resultEndValue,K=(r.resultStart-s)/S,q=(r.resultEnd-s)/S,z=n+N*K,ee=n+N*q,he=ee-z|0,ce=(k-M)/he;b(n<=z&&ee<=a,`Out of bounds ${z}, ${ee}`);for(let _=0,j=z|0;_<he;_++,j++){let H=M+_*ce,Y=H|0,ae=H-Y,He=f[Y],rt=w[Y];u[j]+=He+ae*(f[(Y+1)%d]-He),h[j]+=rt+ae*(w[(Y+1)%d]-rt)}}};var $e=class extends Ve{process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,p1:o}=t,n=null,a=s;for(let u of this.eventInput.get(r))n?.forEach(h=>this.handleEvent(t,h)),n=null,a<u.position&&(this.processEvents(t,a,u.position),a=u.position),Ei.isOfType(u)?this.updateParameter(u.position):(n??=[]).push(u);n?.forEach(u=>this.handleEvent(t,u)),n=null,a<o&&this.processEvents(t,a,o)}),this.eventInput.clear()}introduceBlock(e){}};var ii;(t=>(t.create=()=>({mult:1,add:0}),t.apply=(r,s)=>s*r.mult+r.add))(ii||={});var mo=Object.freeze([{name:"up",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,u=t%n,h=Math.floor(t%a/n),d=i[u];return Z.start(r,s,d.pitch+h*12,ii.apply(o,d.velocity))}},{name:"down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,u=n-1-t%n,h=e-1-Math.floor(t%a/n),d=i[u];return Z.start(r,s,d.pitch+h*12,ii.apply(o,d.velocity))}},{name:"up-down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,u=Math.max(1,a*2-2),h=t%u,d=h<a?h:u-h,p=d%n,f=Math.floor(d/n),w=i[p];return Z.start(r,s,w.pitch+f*12,ii.apply(o,w.velocity))}}]);var fo=class extends $e{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u=ii.create();#h=m.None;#c=mo[0];#d=NaN;#p=1;#g=1;#f=1;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new br,this.#i=this.own(this.bindParameter(t.namedParameter.modeIndex)),this.#s=this.own(this.bindParameter(t.namedParameter.rate)),this.#o=this.own(this.bindParameter(t.namedParameter.gate)),this.#n=this.own(this.bindParameter(t.namedParameter.repeat)),this.#a=this.own(this.bindParameter(t.namedParameter.numOctaves)),this.#l=this.own(this.bindParameter(t.namedParameter.velocity)),this.ownAll(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get noteEventTarget(){return m.wrap(this)}setNoteEventSource(e){return b(this.#h.isEmpty(),"NoteEventSource already set"),this.#h=m.wrap(e),O.create(()=>this.#h=m.None)}*processNotes(e,t,r){if(this.#r.nonEmpty())if(ye.every(r,2))for(let o of this.#r.releaseAll())yield Z.stop(o,e);else for(let o of this.#r.releaseLinearCompleted(t))yield Z.stop(o,o.position+o.duration);if(this.#h.nonEmpty()){let s=this.#h.unwrap();for(let n of s.processNotes(e,t,r));let o=!ye.every(r,1);for(let{position:n,index:a}of Bt.iterateWithIndex(e,t,this.#d)){let u=Array.from(s.iterateActiveNotesAt(n,o));if(u.length===0)continue;let h=Math.floor(a/this.#g),d=Math.max(1,Math.floor(this.#d*this.#p)),p=this.#c.run(u,this.#f,h,n,d,this.#u);this.#r.addAndRetain({...p}),yield p}for(let n of this.#r.releaseLinearCompleted(t))yield Z.stop(n,n.position+n.duration)}}*iterateActiveNotesAt(e,t){this.#h.isEmpty()||t||(yield*this.#r.overlapping(e,Ce.Comparator))}reset(){this.#t.length=0,this.#r.clear(),this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){if(e===this.#i)this.#c=mo.at(this.#i.getValue())??mo[0];else if(e===this.#s)this.#d=ze.toPPQN($t.RateFractions[this.#s.getValue()]);else if(e===this.#o)this.#p=this.#o.getValue();else if(e===this.#n)this.#g=this.#n.getValue();else if(e===this.#a)this.#f=this.#a.getValue();else if(e===this.#l){let t=this.#l.getValue();t<=0?(this.#u.add=1+t,this.#u.mult=0):(this.#u.add=1-t,this.#u.mult=t)}}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var go=class extends $e{#e;#t;#r;#i;#s;#o=m.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new et(e.broadcaster,t.address)),this.#r=this.own(this.bindParameter(t.namedParameter.octaves)),this.#i=this.own(this.bindParameter(t.namedParameter.semiTones)),this.#s=this.own(this.bindParameter(t.namedParameter.cent)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return b(this.#o.isEmpty(),"NoteEventSource already set"),this.#o=m.wrap(e),O.create(()=>this.#o=m.None)}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#o.isEmpty())for(let s of this.#o.unwrap().processNotes(e,t,r))if(Z.isStart(s)){this.#t.noteOn(s.pitch);let{cent:o,octaves:n,semiTones:a}=this.#e.namedParameter;yield bt.overwrite(s,{pitch:s.pitch+n.valueAt(s.position)*12+a.valueAt(s.position),cent:s.cent+o.valueAt(s.position)})}else this.#t.noteOff(s.pitch),yield s}*iterateActiveNotesAt(e,t){if(!this.#o.isEmpty()){for(let r of this.#o.unwrap().iterateActiveNotesAt(e,t))if(r.type==="note-event"){let{cent:s,octaves:o,semiTones:n}=this.#e.namedParameter;yield bt.overwrite(r,{pitch:r.pitch+o.valueAt(r.position)*12+n.valueAt(r.position),cent:r.cent+s.valueAt(r.position)})}}}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var xo=class i{static DEFAULT_SIZE=1024;#e;#t;#r;#i;#s;#o;#n;#a=0;decay=!1;constructor(e=i.DEFAULT_SIZE){this.#e=e,this.#r=new ki(this.#e),this.#i=new Float32Array(this.#e),this.#s=new Float32Array(this.#e),this.#o=di.create(di.Type.Blackman,this.#e),this.#t=this.#e>>1,this.#n=new Float32Array(this.#t)}clear(){this.#n.fill(0),this.#a=0}numBins(){return this.#t}bins(){return this.#n}process(e,t,r,s){for(let o=r;o<s;++o)this.#i[this.#a]=this.#o[this.#a]*(e[o]+t[o]),++this.#a===this.#e&&this.#l()}#l(){this.#r.process(this.#i,this.#s);let e=1/this.#t;for(let t=0;t<this.#t;++t){let r=this.#i[t],s=this.#s[t],o=Math.sqrt(r*r+s*s)*e;this.#n[t]<o?this.#n[t]=o:this.decay&&(this.#n[t]*=.9)}this.#a=0,this.#s.fill(0),this.decay=!1}};var yo=class i extends fe{static ID=0;#e=i.ID++;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h;#c;#d;#p;#g;#f;#x;#F;#N;#P;#B;#V;#S;#v;#y;#b;#C;#R;#M;#w;#E;#A;#T;#D;#O;#k;#U;#I=m.None;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=new xo,this.#o=new Float32Array(this.#s.numBins()),this.#n=A.create(()=>new At,7),this.#a=[new er(4),new er(4)],this.#l=[new er(4),new er(4)],this.#u=[this.#l,[new be,new be],[new be,new be],[new be,new be],[new be,new be],[new be,new be],this.#a],this.#h=A.create(()=>!0,7);let r=this.#t.namedParameter;this.#c=this.own(this.bindParameter(r.highPass.enabled)),this.#p=this.own(this.bindParameter(r.highPass.q)),this.#d=this.own(this.bindParameter(r.highPass.frequency)),this.#g=this.own(this.bindParameter(r.highPass.order)),this.#f=this.own(this.bindParameter(r.lowShelf.enabled)),this.#x=this.own(this.bindParameter(r.lowShelf.frequency)),this.#F=this.own(this.bindParameter(r.lowShelf.gain)),this.#N=this.own(this.bindParameter(r.lowBell.enabled)),this.#P=this.own(this.bindParameter(r.lowBell.frequency)),this.#B=this.own(this.bindParameter(r.lowBell.gain)),this.#V=this.own(this.bindParameter(r.lowBell.q)),this.#S=this.own(this.bindParameter(r.midBell.enabled)),this.#v=this.own(this.bindParameter(r.midBell.frequency)),this.#y=this.own(this.bindParameter(r.midBell.gain)),this.#b=this.own(this.bindParameter(r.midBell.q)),this.#C=this.own(this.bindParameter(r.highBell.enabled)),this.#R=this.own(this.bindParameter(r.highBell.frequency)),this.#M=this.own(this.bindParameter(r.highBell.gain)),this.#w=this.own(this.bindParameter(r.highBell.q)),this.#E=this.own(this.bindParameter(r.highShelf.enabled)),this.#A=this.own(this.bindParameter(r.highShelf.frequency)),this.#T=this.own(this.bindParameter(r.highShelf.gain)),this.#D=this.own(this.bindParameter(r.lowPass.enabled)),this.#O=this.own(this.bindParameter(r.lowPass.frequency)),this.#k=this.own(this.bindParameter(r.lowPass.q)),this.#U=this.own(this.bindParameter(r.lowPass.order)),this.own(e.registerProcessor(this)),e.broadcaster.broadcastFloats(t.spectrum,this.#o,()=>{this.#o.set(this.#s.bins()),this.#s.decay=!0}),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.#u.forEach(e=>e.forEach(t=>t.reset())),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#I=m.wrap(e),{terminate:()=>this.#I=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#I.isEmpty())return;let[s,o]=this.#r.channels(),n=this.#I.unwrap();if(this.#h.some(a=>a)){let[a,u]=n.channels();this.#n.forEach((h,d)=>{if(this.#h[d]){let[p,f]=this.#u[d];p.process(h,a,s,t,r),f.process(h,u,o,t,r),a=s,u=o}})}else{let[a,u]=n.channels();for(let h=t;h<r;h++)s[h]=a[h],o[h]=u[h]}this.#i.process(s,o,t,r),this.#s.process(s,o,t,r)}parameterChanged(e){if(e===this.#U){let t=this.#U.getValue();this.#a[0].order=t,this.#a[1].order=t}else if(e===this.#g){let t=this.#g.getValue();this.#l[0].order=t,this.#l[1].order=t}else if(e===this.#d||e===this.#p){let t=this.#d.getValue(),r=this.#p.getValue();this.#n[0].setHighpassParams(t/sampleRate,r)}else if(e===this.#x||e===this.#F){let t=this.#x.getValue(),r=this.#F.getValue();this.#n[1].setLowShelfParams(t/sampleRate,r)}else if(e===this.#P||e===this.#B||e===this.#V){let t=this.#P.getValue(),r=this.#B.getValue(),s=this.#V.getValue();this.#n[2].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#v||e===this.#y||e===this.#b){let t=this.#v.getValue(),r=this.#y.getValue(),s=this.#b.getValue();this.#n[3].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#R||e===this.#M||e===this.#w){let t=this.#R.getValue(),r=this.#M.getValue(),s=this.#w.getValue();this.#n[4].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#A||e===this.#T){let t=this.#A.getValue(),r=this.#T.getValue();this.#n[5].setHighShelfParams(t/sampleRate,r)}else if(e===this.#O||e===this.#k){let t=this.#O.getValue(),r=this.#k.getValue();this.#n[6].setLowpassParams(t/sampleRate,r)}else e===this.#c?this.#h[0]=this.#c.getValue():e===this.#f?this.#h[1]=this.#f.getValue():e===this.#N?this.#h[2]=this.#N.getValue():e===this.#S?this.#h[3]=this.#S.getValue():e===this.#C?this.#h[4]=this.#C.getValue():e===this.#E?this.#h[5]=this.#E.getValue():e===this.#D&&(this.#h[6]=this.#D.getValue())}toString(){return`{${this.constructor.name} (${this.#e})`}};var vo=class{roomSize;damp;predelayInSamples;wetGain;dryGain;#e=new Float32Array(2048);#t=new Float32Array(2048);#r=new Float32Array(2048);#i=new Float32Array(2048);#s=new Float32Array(2048);#o=new Float32Array(2048);#n=new Float32Array(2048);#a=new Float32Array(2048);#l=new Float32Array(1024);#u=new Float32Array(512);#h=new Float32Array(512);#c=new Float32Array(256);#d=new Float32Array(2048);#p=new Float32Array(2048);#g=new Float32Array(2048);#f=new Float32Array(2048);#x=new Float32Array(2048);#F=new Float32Array(2048);#N=new Float32Array(2048);#P=new Float32Array(2048);#B=new Float32Array(1024);#V=new Float32Array(512);#S=new Float32Array(512);#v=new Float32Array(256);#y;#b;#C=0;#R=0;#M=0;#w=0;#E=0;#A=0;#T=0;#D=0;#O=0;#k=0;#U=0;#I=0;#L=0;#$=0;#q=0;#z=0;#_=0;#H=0;#G=0;#W=0;#j=0;#Q=0;#Y=0;#X=0;#Z=0;#J=0;#ee=0;#te=0;#re=0;#ie=0;#se=0;#oe=0;#ne=0;#ae=0;#le=0;#ue=0;#he=0;#ce=0;#de=0;#pe=0;#m=0;#K=0;constructor(e=.5){this.#y=ot(Math.ceil(e*sampleRate)),this.#b=new Float32Array(this.#y<<1),this.damp=0,this.roomSize=.5,this.wetGain=.3333,this.dryGain=1-this.wetGain,this.#m=0,this.#K=0,this.predelayInSamples=.008*sampleRate,this.clearHistory()}clear(){this.#m=0,this.#K=0,this.clearHistory(),this.clearBuffers()}process(e,t,r,s){let[o,n]=t.channels(),[a,u]=e.channels(),h=.4*this.damp,d=1-h,p=.7+.28*this.roomSize;for(let f=r;f<s;++f){let w=o[f],N=n[f],S=this.#K-this.predelayInSamples;S<0&&(S+=this.#y);let M;M=S<<1;let k=.01,K=this.#b[M]*k,q=this.#b[M+1]*k;M=this.#K<<1,this.#b[M]=w,this.#b[M+1]=N,this.#K=this.#K+1&this.#y-1;let z=this.#m&2047;this.#C=d*this.#R+h*this.#C,this.#e[z]=K+p*this.#C,this.#R=this.#e[this.#m-1617&2047],this.#M=d*this.#w+h*this.#M,this.#t[z]=K+p*this.#M,this.#w=this.#t[this.#m-1557&2047],this.#E=d*this.#A+h*this.#E,this.#r[z]=K+p*this.#E,this.#A=this.#r[this.#m-1491&2047],this.#T=d*this.#D+h*this.#T,this.#i[z]=K+p*this.#T,this.#D=this.#i[this.#m-1422&2047],this.#O=d*this.#k+h*this.#O,this.#s[z]=K+p*this.#O,this.#k=this.#s[this.#m-1356&2047],this.#U=d*this.#I+h*this.#U,this.#o[z]=K+p*this.#U,this.#I=this.#o[this.#m-1277&2047],this.#L=d*this.#$+h*this.#L,this.#n[z]=K+p*this.#L,this.#$=this.#n[this.#m-1188&2047],this.#q=d*this.#z+h*this.#q,this.#a[z]=K+p*this.#q,this.#z=this.#a[this.#m-1116&2047];let ee=this.#z+this.#$+this.#I+this.#k+this.#D+this.#A+this.#w+this.#R,he=this.#_-ee,ce=this.#H-he,_=this.#G-ce;this.#l[this.#m&1023]=ee+.5*this.#_,this.#_=this.#l[this.#m-556&1023],this.#u[this.#m&511]=he+.5*this.#H,this.#H=this.#u[this.#m-441&511],this.#h[this.#m&511]=ce+.5*this.#G,this.#G=this.#h[this.#m-341&511],this.#c[this.#m&255]=_+.5*this.#W,this.#W=this.#c[this.#m-225&255],a[f]=this.dryGain*w+this.wetGain*(this.#W-_),this.#j=d*this.#Q+h*this.#j,this.#d[z]=q+p*this.#j,this.#Q=this.#d[this.#m-1640&2047],this.#Y=d*this.#X+h*this.#Y,this.#p[z]=q+p*this.#Y,this.#X=this.#p[this.#m-1580&2047],this.#Z=d*this.#J+h*this.#Z,this.#g[z]=q+p*this.#Z,this.#J=this.#g[this.#m-1514&2047],this.#ee=d*this.#te+h*this.#ee,this.#f[z]=q+p*this.#ee,this.#te=this.#f[this.#m-1445&2047],this.#re=d*this.#ie+h*this.#re,this.#x[z]=q+p*this.#re,this.#ie=this.#x[this.#m-1379&2047],this.#se=d*this.#oe+h*this.#se,this.#F[z]=q+p*this.#se,this.#oe=this.#F[this.#m-1300&2047],this.#ne=d*this.#ae+h*this.#ne,this.#N[z]=q+p*this.#ne,this.#ae=this.#N[this.#m-1211&2047],this.#le=d*this.#ue+h*this.#le,this.#P[z]=q+p*this.#le,this.#ue=this.#P[this.#m-1139&2047];let j=this.#ue+this.#ae+this.#oe+this.#ie+this.#te+this.#J+this.#X+this.#Q,H=this.#he-j,Y=this.#ce-H,ae=this.#de-Y;this.#B[this.#m&1023]=j+.5*this.#he,this.#he=this.#B[this.#m-579&1023],this.#V[this.#m&511]=H+.5*this.#ce,this.#ce=this.#V[this.#m-464&511],this.#S[this.#m&511]=Y+.5*this.#de,this.#de=this.#S[this.#m-364&511],this.#v[this.#m&255]=ae+.5*this.#pe,this.#pe=this.#v[this.#m-248&255],u[f]=this.dryGain*N+this.wetGain*(this.#pe-ae),this.#m++}}clearBuffers(){this.#e.fill(0),this.#t.fill(0),this.#r.fill(0),this.#i.fill(0),this.#s.fill(0),this.#o.fill(0),this.#n.fill(0),this.#a.fill(0),this.#l.fill(0),this.#u.fill(0),this.#h.fill(0),this.#c.fill(0),this.#d.fill(0),this.#p.fill(0),this.#g.fill(0),this.#f.fill(0),this.#x.fill(0),this.#F.fill(0),this.#N.fill(0),this.#P.fill(0),this.#B.fill(0),this.#V.fill(0),this.#S.fill(0),this.#v.fill(0),this.#b.fill(0)}clearHistory(){this.#C=0,this.#R=0,this.#M=0,this.#w=0,this.#E=0,this.#A=0,this.#T=0,this.#D=0,this.#O=0,this.#k=0,this.#U=0,this.#I=0,this.#L=0,this.#$=0,this.#q=0,this.#z=0,this.#_=0,this.#H=0,this.#G=0,this.#W=0,this.#j=0,this.#Q=0,this.#Y=0,this.#X=0,this.#Z=0,this.#J=0,this.#ee=0,this.#te=0,this.#re=0,this.#ie=0,this.#se=0,this.#oe=0,this.#ne=0,this.#ae=0,this.#le=0,this.#ue=0,this.#he=0,this.#ce=0,this.#de=0,this.#pe=0}};var bo=class i extends fe{static ID=0;#e=i.ID++;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h=m.None;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=new vo;let{decay:r,preDelay:s,damp:o,wet:n,dry:a}=this.#t.namedParameter;this.#o=this.own(this.bindParameter(r)),this.#n=this.own(this.bindParameter(s)),this.#a=this.own(this.bindParameter(o)),this.#l=this.own(this.bindParameter(n)),this.#u=this.own(this.bindParameter(a)),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#s.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#h=m.wrap(e),{terminate:()=>this.#h=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#h.isEmpty())return;this.#s.process(this.#r,this.#h.unwrap(),t,r);let[s,o]=this.#r.channels();this.#i.process(s,o,t,r)}parameterChanged(e){this.#o===e?this.#s.roomSize=this.#o.getValue():this.#n===e?this.#s.predelayInSamples=Math.ceil(this.#n.getValue()*sampleRate):this.#a===e?this.#s.damp=this.#a.getValue():this.#l===e?this.#s.wetGain=we(this.#l.getValue()):this.#u===e&&(this.#s.dryGain=we(this.#u.getValue()))}toString(){return`{${this.constructor.name} (${this.#e})`}};var wo=class extends fe{#e;#t;#r;#i;#s;#o;#n;gain=1;release=1;loader=m.None;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new re,this.#i=new Ht(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#s=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.release)),this.ownAll(e.registerProcessor(this),t.box.file.catchupAndSubscribe(r=>this.loader=r.targetVertex.map(({box:s})=>e.sampleManager.getOrCreate(s.address.uuid)))),this.readAllParameters()}get noteEventTarget(){return m.wrap(this)}introduceBlock(e){this.#i.introduceBlock(e)}setNoteEventSource(e){return this.#i.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#t.length=0,this.#r.clear(),this.eventInput.clear(),this.#i.clear(),this.#s.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}get adapter(){return this.#e}handleEvent(e){Z.isStart(e)?this.#t.push(new En(this,e)):Z.isStop(e)&&this.#t.find(t=>t.event().id===e.id)?.stop()}processAudio(e,t,r){this.#r.clear(t,r);for(let s=this.#t.length-1;s>=0;s--)this.#t[s].processAdd(this.#r,t,r)&&this.#t.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=we(this.#o.getValue()):e===this.#n&&(this.release=this.#n.getValue()*sampleRate)}finishProcess(){this.#r.assertSanity(),this.#s.process(this.#r.getChannel(0),this.#r.getChannel(1))}toString(){return"{NanoDevice}"}},En=class{#e;#t;#r=1;#i=0;#s=0;#o=Number.POSITIVE_INFINITY;constructor(e,t){this.#e=e,this.#t=t,this.#r=Math.pow(2,(t.pitch+t.cent/100)/12-5)}event(){return this.#t}stop(){this.#o=this.#s}processAdd(e,t,r){let s=this.#e.loader;if(s.isEmpty())return!0;let o=s.unwrap();return o.data.isEmpty()?!0:this.processSimple(e.channels(),o.data.unwrap(),t,r)}processSimple(e,t,r,s){let[o,n]=e,a=t.frames[0],u=t.frames[1]??a,h=t.numberOfFrames,d=t.sampleRate/sampleRate,p=this.#e.gain,f=this.#e.release,w=1/f;for(let N=r;N<s;N++){let S=this.#i|0;if(S>=h-1)return!0;let M=this.#i-S,k=Math.min(1-(this.#s-this.#o)*w,1)**2,K=a[S]*(1-M)+a[S+1]*M,q=u[S]*(1-M)+u[S+1]*M;if(o[N]+=K*p*k,n[N]+=q*p*k,this.#i+=this.#r*d,++this.#s-this.#o>f)return!0}return!1}};var Ao=class extends $e{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=new Ht(this,e.broadcaster,t.adapter.audioUnitBoxAdapter().address),this.own(e.registerProcessor(this)),this.readAllParameters()}introduceBlock(e){this.#t.introduceBlock(e)}setNoteEventSource(e){return this.#t.setNoteEventSource(e)}reset(){this.eventInput.clear(),this.#t.clear()}processEvents(e,t,r){}handleEvent({index:e},t){Z.isStart(t)?this.#e.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t)):Z.isStop(t)&&this.#e.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t))}toString(){return"{PlayfieldSequencer}"}};var Eo=class extends fe{#e;#t;#r;#i;#s;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=this.own(new ne(e.broadcaster,t.adapter.address)),this.#i=[],this.#s=new ti,this.own(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}setAudioSource(e){return this.#i.push(e),{terminate:()=>{A.remove(this.#i,e),this.#t.clear()}}}get audioOutput(){return this.#t}get eventInput(){return this.#s}processAudio(e,t,r){}reset(){this.#r.clear()}finishProcess(){this.#t.clear();let[e,t]=this.#t.channels();for(let r of this.#i){let[s,o]=r.channels();for(let n=0;n<128;n++)e[n]+=s[n],t[n]+=o[n]}this.#t.assertSanity(),this.#r.process(this.#t.getChannel(0),this.#t.getChannel(1))}toString(){return"{PlayfieldMixProcessor}"}};var Fo=class i{static create(e,t,r,s){return new i(e,t,r,s)}#e=new V;#t;#r;#i=[];#s=!0;constructor(e,t,r,s){this.#t=v.newSet(({device:o})=>o.uuid),this.#r=this.#e.own(new V),this.#e.ownAll(t.catchupAndSubscribe({onAdd:o=>{this.invalidateWiring();let n=Bi.create(e,o.box),a=this.#t.add({device:n,subscription:n.adapter().enabledField.subscribe(()=>this.invalidateWiring())});b(a,"Could not add.")},onRemove:o=>{this.invalidateWiring();let{device:n,subscription:a}=this.#t.removeByKey(o.uuid);a.terminate(),n.terminate()},onReorder:o=>this.invalidateWiring()}),e.subscribeProcessPhase(o=>{if(o===0&&this.#s){let n=r;A.replace(this.#i,t.adapters().map(({uuid:a})=>this.#t.get(a).device));for(let a of this.#i)a.adapter().enabledField.getValue()&&(this.#r.own(a.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,a.incoming)),n=a);this.#r.own(s.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,s.incoming)),this.#s=!1}}))}invalidateWiring(){this.#r.terminate(),this.#s=!0}terminate(){this.#e.terminate(),this.#t.forEach(({device:e})=>e.terminate()),this.#t.clear(),this.#i=[]}toString(){return`{${this.constructor.name}}`}};var Ni=Math.floor(.005*sampleRate),No=class{#e;#t;#r;#i;#s;#o;#n=0;#a=Number.POSITIVE_INFINITY;#l;#u;#h;#c;#d;#p;#g=!0;#f=!1;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#i=r,this.#r=s,this.#s=e.gate,this.#o=qi(this.#r.velocity);let{attack:o,release:n,sampleStart:a,sampleEnd:u}=this.#t;this.#l=o.getValue()*sampleRate,this.#u=n.getValue()*sampleRate,this.#h=(r.numberOfFrames-1)*a.getValue(),this.#c=(r.numberOfFrames-1)*u.getValue(),this.#d=this.#h,this.#p=0}get sample(){return this.#e}get event(){return this.#r}get position(){return this.#d}get envelope(){return this.#p}release(e=!1){this.#g&&(e?(this.#u=Ni,this.#x(),this.#g=!1):this.#s!==tt.Off&&this.#x())}processAdd(e,t,r){let[s,o]=e,{frames:n,numberOfFrames:a}=this.#i,u=n[0],h=n[1]??u,{pitch:d}=this.#t,p=this.#c-this.#h,f=Math.sign(p),w=this.#i.sampleRate/sampleRate*f*2**(d.getValue()/1200),N=0;for(let S=t;S<r;S++){let M=this.#d|0,k=this.#d-M,K=u[M]*(1-k)+(u[M+1]??0)*k,q=h[M]*(1-k)+(h[M+1]??0)*k;if(N=Math.min(this.#n/this.#l,1-(this.#n-(this.#a+this.#l))/this.#u,1),this.#d+=w,f>0){if(this.#s===tt.Off){if(this.#d>=a)return!0;!this.#f&&this.#d>=this.#c&&this.#x()}else if(this.#s===tt.On){if(this.#d>=this.#c-Ni){if(this.#d>=this.#c)return!0;N*=(this.#c-this.#d)/Ni}}else if(this.#s===tt.Loop)for(;this.#d>=this.#c;)this.#d-=p}else if(f<0){if(this.#s===tt.Off){if(this.#d<=0)return!0;!this.#f&&this.#d<=this.#c&&this.#x()}else if(this.#s===tt.On){if(this.#d<=this.#c+Ni){if(this.#d<=this.#c)return!0;N*=(this.#c-this.#d)/Ni}}else if(this.#s===tt.Loop)for(;this.#d<=this.#c;)this.#d-=p}if(++this.#n-this.#a>this.#l+this.#u)return!0;N*=this.#o*N,s[S]+=K*N,o[S]+=q*N}return this.#p=N,!1}toString(){return"{PlayfieldSampleVoice}"}#x(){this.#f||(this.#f=!0,this.#a=this.#n<this.#l?this.#n-this.#l:this.#n)}};var Po=class extends fe{#e;#t;#r;#i;#s;#o;constructor(e,t,r,s){super(e),this.#e=t,this.#t=r,this.#r=[],this.#i=new re,this.#s=this.own(new ne(e.broadcaster,r.peakAddress));let{sampleStart:o,sampleEnd:n,attack:a,release:u,pitch:h}=r.namedParameter;this.#o=Object.freeze({sampleStart:this.own(this.bindParameter(o)),sampleEnd:this.own(this.bindParameter(n)),attack:this.own(this.bindParameter(a)),release:this.own(this.bindParameter(u)),pitch:this.own(this.bindParameter(h))});let d=new Float32Array(16);this.ownAll(Fo.create(e,r.audioEffects,this,s),e.broadcaster.broadcastFloats(r.address,d,()=>{let p=this.#r.length<d.length?this.#r:this.#r.slice(0,d.length);p.forEach(({position:f},w)=>d[w]=f),d[p.length]=-1}),e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#i}get adapter(){return this.#t}handleEvent(e){if(Z.isStart(e)){let t=this.#t.file().flatMap(d=>d.getOrCreateLoader().data);if(t.isEmpty())return;let{mute:r,solo:s,polyphone:o,exclude:n}=this.#t.namedParameter,a=r.getValue(),u=s.getValue();if(a||this.#e.hasSolo()&&!u)return;o.getValue()||this.#r.forEach(d=>d.release(!0)),n.getValue()&&this.#e.stopExcludeOthers(this.#t),this.#r.push(new No(this.#t,this.#o,t.unwrap(),e))}else Z.isStop(e)&&this.#r.find(t=>t.event.id===e.id)?.release()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#r.length-1;s>=0;s--)this.#r[s].processAdd(this.#i.channels(),t,r)&&this.#r.splice(s,1)}forceStop(){this.#r.forEach(e=>e.release(!0))}parameterChanged(e){}reset(){this.#r.length=0,this.#i.clear(),this.#s.clear()}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return`{PlayfieldSampleProcessor note: ${this.#t.indexField.getValue()}}`}};var So=class{#e=new V;#t;#r;#i;#s;constructor(e,t){this.#t=t,this.#r=this.#e.own(new Ao(e,this)),this.#i=this.#e.own(new Eo(e,this)),this.#s=v.newSet(r=>r.uuid),this.#e.ownAll(t.samples.catchupAndSubscribe({onAdd:r=>{let s=new Po(e,this,r,this.#i);this.#s.add({uuid:r.uuid,processor:s,terminable:e.registerEdge(this.#r,s)}),e.sampleManager.getOrCreate(r.fileUUID())},onRemove:r=>{let{terminable:s,processor:o}=this.#s.removeByKey(r.uuid);s.terminate(),o.terminate()},onReorder:r=>{}}),{terminate:()=>{this.#s.forEach(({terminable:r,processor:s})=>{r.terminate(),s.terminate()}),this.#s.clear()}})}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get noteEventTarget(){return m.wrap(this)}get incoming(){return this.#r}get outgoing(){return this.#i}optSampleProcessor(e){return this.#t.samples.getAdapterByIndex(e).flatMap(t=>this.#s.opt(t.uuid)).map(t=>t.processor)}hasSolo(){return this.#t.samples.adapters().some(e=>e.namedParameter.solo.getValue())}stopExcludeOthers(e){for(let t of this.#t.samples.adapters())t.exclude&&t!==e&&this.#s.opt(t.uuid).ifSome(({processor:r})=>r.forceStop())}get uuid(){return this.#t.uuid}get adapter(){return this.#t}get audioOutput(){return this.#i.audioOutput}parameterChanged(e){}terminate(){this.#e.terminate()}toString(){return"{PlayfieldDeviceProcessor}"}};var Co=class extends fe{#e;#t;#r;#i=_e.stereoMatrix(sampleRate);#s={gain:0,panning:0,stereo:0,invertL:!1,invertR:!1,swap:!1};#o;#n;#a;#l;#u;#h;#c=m.None;#d=ht.Mixing.Linear;#p=!0;#g=!1;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(t.namedParameter.volume)),this.#n=this.own(this.bindParameter(t.namedParameter.panning)),this.#a=this.own(this.bindParameter(t.namedParameter.stereo)),this.#l=this.own(this.bindParameter(t.namedParameter.invertL)),this.#u=this.own(this.bindParameter(t.namedParameter.invertR)),this.#h=this.own(this.bindParameter(t.namedParameter.swap)),this.ownAll(t.box.panningMixing.catchupAndSubscribe(r=>{this.#d=r.getValue(),this.#p=!0}),e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#t.clear(),this.eventInput.clear(),this.#g=!1}get uuid(){return this.#e.uuid}get audioOutput(){return this.#t}setAudioSource(e){return this.#c=m.wrap(e),{terminate:()=>this.#c=m.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}processAudio(e,t,r){if(this.#c.isEmpty())return;this.#p&&(this.#i.update(this.#s,this.#d,this.#g),this.#p=!1);let s=this.#c.unwrap().channels(),o=this.#t.channels();this.#i.processFrames(s,o,t,r),this.#r.processStereo(o,t,r),this.#g=!0}parameterChanged(e){switch(e){case this.#o:this.#s.gain=we(this.#o.getValue()),this.#p=!0;return;case this.#n:this.#s.panning=this.#n.getValue(),this.#p=!0;return;case this.#a:this.#s.stereo=this.#a.getValue(),this.#p=!0;return;case this.#l:this.#s.invertL=this.#l.getValue(),this.#p=!0;return;case this.#u:this.#s.invertR=this.#u.getValue(),this.#p=!0;return;case this.#h:this.#s.swap=this.#h.getValue(),this.#p=!0;return}}toString(){return`{${this.constructor.name}}`}};var Ro=class extends $e{#e;#t;#r=m.None;#i=m.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new et(e.broadcaster,t.address)),this.ownAll(t.box.groove.catchupAndSubscribe(r=>{this.#r.ifSome(s=>s.terminate()),this.#r=m.wrap(r.targetVertex.isEmpty()?null:e.boxAdapters.adapterFor(r.targetVertex.unwrap().box,cr.checkType))}),O.create(()=>{this.#r.ifSome(r=>r.terminate()),this.#r=m.None}),e.registerProcessor(this))}get uuid(){return this.#e.uuid}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}setNoteEventSource(e){return b(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=m.wrap(e),O.create(()=>this.#i=m.None)}*processNotes(e,t,r){if(this.#i.isEmpty())return;let s=this.#i.unwrap(),o=this.#r.mapOr(ni,ci.Identity);for(let n of s.processNotes(o.unwarp(e),o.unwarp(t),r))Z.isStart(n)?this.#t.noteOn(n.pitch):this.#t.noteOff(n.pitch),yield bt.overwrite(n,{position:L(o.warp(n.position),e,t)})}*iterateActiveNotesAt(e,t){if(this.#i.isEmpty())return;let r=this.#i.unwrap(),s=this.#r.mapOr(ni,ci.Identity);for(let o of r.iterateActiveNotesAt(s.unwarp(e),t))yield bt.overwrite(o,{position:s.warp(o.position)})}reset(){this.eventInput.clear()}parameterChanged(e){}handleEvent(e,t){}processEvents(e,t,r){}};var Mo=class extends $e{#e;#t;#r=m.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new et(e.broadcaster,t.address)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return b(this.#r.isEmpty(),"NoteEventSource already set"),this.#r=m.wrap(e),O.create(()=>this.#r=m.None)}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#r.isEmpty())for(let s of this.#r.unwrap().processNotes(e,t,r))yield s}*iterateActiveNotesAt(e,t){if(!this.#r.isEmpty())for(let r of this.#r.unwrap().iterateActiveNotesAt(e,t))yield r}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var Fn;(e=>e.create=(t,r)=>r.accept({visitAudioBusBox:s=>new ri(t,t.boxAdapters.adapterFor(s,Me)),visitVaporisateurDeviceBox:s=>new co(t,t.boxAdapters.adapterFor(s,Wr)),visitNanoDeviceBox:s=>new wo(t,t.boxAdapters.adapterFor(s,Qr)),visitTapeDeviceBox:s=>new po(t,t.boxAdapters.adapterFor(s,Gr)),visitPlayfieldDeviceBox:s=>new So(t,t.boxAdapters.adapterFor(s,qt))}))(Fn||={});var Bn;(e=>e.create=(t,r)=>U(r.accept({visitUnknownMidiEffectDeviceBox:s=>new Mo(t,t.boxAdapters.adapterFor(s,ei)),visitArpeggioDeviceBox:s=>new fo(t,t.boxAdapters.adapterFor(s,$t)),visitPitchDeviceBox:s=>new go(t,t.boxAdapters.adapterFor(s,jr)),visitZeitgeistDeviceBox:s=>new Ro(t,t.boxAdapters.adapterFor(s,Zr))}),`Could not create midi-effect for'${r.name}'`))(Bn||={});var Bi;(e=>e.create=(t,r)=>U(r.accept({visitUnknownAudioEffectDeviceBox:s=>new Fi(t,t.boxAdapters.adapterFor(s,Jr)),visitStereoToolDeviceBox:s=>new Co(t,t.boxAdapters.adapterFor(s,Xr)),visitDelayDeviceBox:s=>new ho(t,t.boxAdapters.adapterFor(s,ft)),visitReverbDeviceBox:s=>new bo(t,t.boxAdapters.adapterFor(s,Ir)),visitRevampDeviceBox:s=>new yo(t,t.boxAdapters.adapterFor(s,Or)),visitModularDeviceBox:s=>new Fi(t,t.boxAdapters.adapterFor(s,Kt))}),`Could not create audio-effect for'${r.name}'`))(Bi||={});var To=class extends fe{#e;#t;#r;#i;#s;#o;#n=m.None;#a=!0;#l=!1;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=_e.linear(sampleRate),this.#i=_e.linear(sampleRate),this.#s=this.own(this.bindParameter(t.sendGain)),this.#o=this.own(this.bindParameter(t.sendPan)),this.own(e.registerProcessor(this)),this.readAllParameters()}reset(){this.#t.clear()}get adapter(){return this.#e}setAudioSource(e){return this.#n=m.wrap(e),{terminate:()=>this.#n=m.None}}get audioOutput(){return this.#t}processAudio(e,t,r){if(this.#n.isEmpty())return;if(this.#a){let h=we(this.#s.getValue()),d=this.#o.getValue();this.#r.set((1-Math.max(0,d))*h,this.#l),this.#i.set((1+Math.min(0,d))*h,this.#l),this.#a=!1}let s=this.#t.getChannel(0),o=this.#t.getChannel(1),n=this.#n.unwrap(),a=n.getChannel(0),u=n.getChannel(1);if(this.#r.isInterpolating()||this.#i.isInterpolating())for(let h=t;h<r;h++)s[h]=a[h]*this.#r.moveAndGet(),o[h]=u[h]*this.#i.moveAndGet();else{let h=this.#r.get(),d=this.#i.get();for(let p=t;p<r;p++)s[p]=a[p]*h,o[p]=u[p]*d}this.#l=!0}parameterChanged(e){this.#a=!0}};var Vo=class extends fe{#e;#t;#r;#i;#s;#o;#n;#a;#l=_e.linear(sampleRate);#u=_e.linear(sampleRate);#h=_e.linear(sampleRate);#c=m.None;#d=!0;#p=!1;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=[new Float32Array(128),new Float32Array(128)],this.#i=this.own(new ne(e.broadcaster,this.#e.address)),this.#s=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.panning)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.mute)),this.#a=this.own(this.bindParameter(this.#e.namedParameter.solo)),this.ownAll(e.registerProcessor(this),e.mixer.attachChannelStrip(this)),this.readAllParameters()}reset(){this.#i.clear(),this.#t.clear(),this.#r[0].fill(0),this.#r[1].fill(0),this.#p=!1}get isMute(){return this.#n.getValue()}get isSolo(){return this.#a.getValue()}get adapter(){return this.#e}get audioOutput(){return this.#t}handleEvent(e){}processAudio(e,t,r){if(this.#c.isEmpty())return;if(this.#d){let p=this.context.mixer;p.updateSolo();let f=this.isSolo||p.isVirtualSolo(this),w=this.isMute||p.hasChannelSolo()&&!f&&!this.#e.isOutput,N=we(this.#s.getValue()),S=this.#o.getValue();this.#l.set((1-Math.max(0,S))*N,this.#p),this.#u.set((1+Math.min(0,S))*N,this.#p),this.#h.set(w?0:1,this.#p),this.#d=!1}let s=this.#c.unwrap(),[o,n]=s.channels(),[a,u]=this.#t.channels(),[h,d]=this.#r;if(this.#l.isInterpolating()||this.#u.isInterpolating()||this.#h.isInterpolating())for(let p=t;p<r;p++){let f=this.#h.moveAndGet(),w=o[p]*this.#l.moveAndGet(),N=n[p]*this.#u.moveAndGet();a[p]=w*f,u[p]=N*f,h[p]=w,d[p]=N}else{let p=this.#l.get(),f=this.#u.get(),w=this.#h.get();for(let N=t;N<r;N++){let S=o[N]*p,M=n[N]*f;h[N]=S,d[N]=M,a[N]=S*w,u[N]=M*w}}this.#i.process(h,d,t,r),this.#p=!0}finishProcess(){this.#t.assertSanity()}parameterChanged(e){e===this.#s?this.requestGainUpdate():e===this.#o?this.requestGainUpdate():e===this.#n?this.requestGainUpdate():e===this.#a&&this.context.mixer.onChannelStripSoloChanged(this)}requestGainUpdate(){this.#d=!0}requestSoloUpdate(){this.#d=!0}setAudioSource(e){return this.#c=m.wrap(e),{terminate:()=>this.#c=m.None}}toString(){return`{${this.constructor.name}}`}};var Do=class{#e=new V;#t;#r;#i;#s;#o;#n;#a=[];#l=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=v.newSet(r=>r.adapter.uuid),this.#s=this.#e.own(new Vo(this.#t.context,this.#t.adapter)),this.#o=v.newSet(({device:r})=>r.uuid),this.#n=this.#e.own(new V),this.#e.ownAll(this.#t.adapter.audioEffects.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=Bi.create(this.#t.context,r.box),o=this.#o.add({device:s,subscription:s.adapter().enabledField.subscribe(()=>this.invalidateWiring())});b(o,"Could not add.")},onRemove:r=>{this.invalidateWiring();let{device:s,subscription:o}=this.#o.removeByKey(r.uuid);o.terminate(),s.terminate()},onReorder:r=>this.invalidateWiring()}),this.#t.adapter.auxSends.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=this.#i.add(new To(this.#t.context,r));b(s,"Could not add.")},onRemove:({uuid:r})=>{this.invalidateWiring(),this.#i.removeByKey(r).terminate()},onReorder:r=>{}}),this.#t.adapter.output.catchupAndSubscribe(r=>this.invalidateWiring()),this.#t.context.subscribeProcessPhase(r=>{r===0&&this.#l&&(this.#u(),this.#l=!1)}))}get channelStrip(){return this.#s}invalidateWiring(){this.#n.terminate(),this.#l=!0}terminate(){this.#e.terminate(),this.#o.forEach(({device:e})=>e.terminate()),this.#o.clear(),this.#a=[]}toString(){return`{${this.constructor.name}}`}#u(){let e=this.#t.adapter.isOutput,t=this.#t.context,r=this.#t.input(),s=this.#t.adapter.output.adapter.map(n=>t.getAudioUnit(n.deviceHost().uuid).inputAsAudioBus());if(r.isEmpty()||s.isEmpty()&&!e)return;let o=r.unwrap();if(this.#r.includeAudioEffects){A.replace(this.#a,this.#t.adapter.audioEffects.adapters().map(({uuid:n})=>this.#o.get(n).device));for(let n of this.#a)n.adapter().enabledField.getValue()&&(this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n.incoming)),o=n)}if(this.#r.includeSends&&this.#i.forEach(n=>{let a=t.getAudioUnit(n.adapter.targetBus.deviceHost().uuid);this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(a.inputAsAudioBus().addAudioSource(n.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n)),this.#n.own(t.registerEdge(n,a.inputAsAudioBus()))}),this.#n.own(this.#s.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,this.#s)),s.nonEmpty()&&!e){let n=s.unwrap();this.#n.own(n.addAudioSource(this.#s.audioOutput)),this.#n.own(t.registerEdge(this.#s,n))}}};var Io=class{#e=new V;#t;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=Di.create(268431651),this.#s=new Set,this.#o=new br,this.#e.ownAll(this.#t.subscribeProcessPhase(r=>{if(r===1)for(let s of this.#s)s.gate||this.#s.delete(s)}))}get uuid(){return this.#r.uuid}terminate(){this.#e.terminate()}pushRawNoteOn(e,t){this.#s.add({pitch:e,velocity:t,gate:!0,running:m.None})}pushRawNoteOff(e){for(let t of this.#s)if(t.running.isEmpty())this.#s.delete(t);else if(t.pitch===e){t.gate=!1;return}}*processNotes(e,t,r){let s=ye.every(r,5);if(this.#o.nonEmpty()&&(!s||ye.every(r,2)?yield*this.#u(e):yield*this.#h(e,t)),this.#s.size>0)for(let o of this.#s){if(o.running.isEmpty()){let{pitch:n,velocity:a}=o,u=Number.POSITIVE_INFINITY,h=Z.start(e,u,n,a);o.running=m.wrap(h),yield h}o.gate||(this.#s.delete(o),yield Z.stop(o.running.unwrap("raw note never started"),e))}if(s){let o=this.#r.tracks.collection.adapters().filter(n=>n.type===J.Notes&&n.enabled.getValue());for(let n of o)for(let{optClip:a,sectionFrom:u,sectionTo:h}of this.#t.clipSequencing.iterate(n.uuid,e,t))a.isEmpty()?yield*this.#a(n,u,h):yield*this.#n(a.unwrap(),u,h);yield*this.#h(e,t)}}*iterateActiveNotesAt(e,t){if(this.#s.size>0)for(let{pitch:r,velocity:s}of this.#s)yield{type:"note-event",position:e,duration:Number.POSITIVE_INFINITY,pitch:r,velocity:s,cent:0};t||(yield*this.#o.overlapping(e,Ce.Comparator))}reset(){this.#o.clear(),this.#s.clear()}toString(){return`{${this.constructor.name}}`}*#n(e,t,r){if(e.optCollection.isEmpty())return;let s=e.optCollection.unwrap(),o=e.duration,n=st(t,o),a=n+o;r>a?(yield*this.#l(s,t,a,n),yield*this.#l(s,a,r,a)):yield*this.#l(s,t,r,n)}*#a(e,t,r){for(let s of e.regions.collection.iterateRange(t,r)){if(this.#t.ignoresRegion(s.address.uuid)||s.mute||!de(s,Ot))continue;let o=s.optCollection;if(o.isEmpty())continue;let n=o.unwrap();for(let{resultStart:a,resultEnd:u,rawStart:h}of Te.locateLoops(s,t,r))yield*this.#l(n,a,u,h)}}*#l(e,t,r,s){let o=t-s,n=r-s;for(let a of e.events.iterateRange(o-e.maxDuration,n)){if(!Ce.isOfType(a))continue;let{position:u,duration:h,chance:d,playCount:p,playCurve:f}=a;if(!(d<100&&this.#i.nextDouble(0,100)>d)){if(p>1){let w=Ce.inverseCurveFunc((o-u)/h,f),N=Ce.inverseCurveFunc((n-u)/h,f),S=Math.floor(w*p),M=S/p;for(;M<N;){if(M>=w){let k=Ce.curveFunc(M,f)*h;if(k>=h)break;let K=Ce.curveFunc(M+1/p,f)*h,q=Z.startWith(a,u+k+s,K-k);this.#o.addAndRetain({...q}),yield q}M=++S/p}}else if(o<=u&&u<n){let w=Z.startWith(a,u+s);this.#o.addAndRetain({...w}),yield w}}}}*#u(e){for(let t of this.#o.releaseAll())yield Z.stop(t,e)}*#h(e,t){for(let r of this.#o.releaseLinearCompleted(t)){let s=L(r.position+r.duration,e,t);yield Z.stop(r,s)}}};var Oo=class{#e=new V;#t;#r;#i;#s;#o=!1;constructor(e){this.#t=e,this.#r=this.#e.own(new Io(this.#t.context,this.#t.adapter)),this.#i=v.newSet(({device:t})=>t.uuid),this.#s=this.#e.own(new V),this.#e.ownAll(this.#t.adapter.midiEffects.catchupAndSubscribe({onAdd:t=>{this.invalidateWiring();let r=Bn.create(this.#t.context,t.box),s=this.#i.add({device:r,subscription:r.adapter().enabledField.subscribe(()=>this.invalidateWiring())});b(s,"Could not add.")},onRemove:t=>{this.invalidateWiring();let{device:r,subscription:s}=this.#i.removeByKey(t.uuid);s.terminate(),r.terminate()},onReorder:t=>this.invalidateWiring()}),this.#t.context.subscribeProcessPhase(t=>{t===0&&this.#o&&(this.#n(),this.#o=!1)}))}get noteSequencer(){return this.#r}invalidateWiring(){this.#s.terminate(),this.#o=!0}terminate(){this.#e.terminate()}toString(){return`{${this.constructor.name}}`}#n(){let e=this.#t.input().flatMap(s=>s.noteEventTarget);if(e.isEmpty())return;let t=e.unwrap(),r=this.#r;this.#t.adapter.midiEffects.adapters().map(s=>this.#i.get(s.uuid).device).forEach(s=>{s.adapter().enabledField.getValue()&&(this.#s.ownAll(s.setNoteEventSource(r),this.#t.context.registerEdge(s,t.incoming)),r=s)}),this.#s.own(t.setNoteEventSource(r))}};var ko=class i{static ID=0;#e=i.ID++;#t=new V;#r;#i;#s;#o;#n=m.None;constructor(e,t,r){this.#r=e,this.#i=t,this.#s=this.#t.own(new Oo(this)),this.#o=this.#t.own(new Do(this,r)),this.#t.ownAll(this.#i.input.catchupAndSubscribe(s=>{this.#s.invalidateWiring(),this.#o.invalidateWiring(),this.#n.ifSome(o=>o.terminate()),this.#n=s.getValue().flatMap(o=>m.wrap(Fn.create(e,o.box.box)))}))}input(){return this.#n}inputAsAudioBus(){return Qt(this.#n.unwrap("No input available"),ri)}audioOutput(){return this.#o.channelStrip.audioOutput}get midiDeviceChain(){return this.#s}get audioDeviceChain(){return this.#o}get context(){return this.#r}get adapter(){return this.#i}terminate(){console.debug(`terminate ${this}`),this.#t.terminate(),this.#n.ifSome(e=>e.terminate()),this.#n=m.None}toString(){return`{${this.constructor.name}(${this.#e})}`}};var Uo=class{#e;#t;#r;#i=!1;constructor(){this.#e=v.newSet(e=>e.adapter.uuid),this.#t=new Set,this.#r=new Set}attachChannelStrip(e){return this.#e.add(e),O.many(e.adapter.input.subscribe(()=>this.#s()),e.adapter.output.subscribe(()=>this.#s()),{terminate:()=>{this.#t.delete(e),this.#e.removeByValue(e),this.#s()}})}onChannelStripSoloChanged(e){e.isSolo?this.#t.add(e):this.#t.delete(e),this.#s()}hasChannelSolo(){return this.#t.size>0}isVirtualSolo(e){return this.#r.has(e)}#s(){this.#i||(this.#i=!0,this.#e.forEach(e=>e.requestSoloUpdate()))}updateSolo(){if(!this.#i)return;this.#r.clear();let e=new Set,t=r=>{e.has(r)||(e.add(r),r.adapter.input.getValue().ifSome(s=>{s.type==="bus"&&s.box.input.pointerHub.filter(l.AudioOutput).map(o=>U(o.box.accept({visitAudioUnitBox:({address:{uuid:n}})=>this.#e.get(n),visitAuxSendBox:({audioUnit:{targetVertex:n}})=>this.#e.get(n.unwrap().address.uuid)}),"Could not resolve channel-strip")).forEach(o=>{o.isSolo||this.#r.add(o),t(o)})}))};this.#e.forEach(r=>{r.isSolo&&t(r)}),this.#i=!1}};var Gt;(function(i){let e=typeof self<"u"&&"location"in self&&typeof self.location!==void 0,t=typeof self<"u"&&"navigator"in self&&typeof self.navigator!==void 0;i.isLocalHost=()=>e&&location.host.includes("localhost"),i.isMacOS=()=>t&&navigator.userAgent.includes("Mac OS X"),i.isWindows=()=>t&&navigator.userAgent.includes("Windows"),i.isFirefox=()=>t&&navigator.userAgent.toLowerCase().includes("firefox"),i.isWeb=()=>!i.isTauriApp(),i.isVitest=typeof process<"u"&&process.env?.VITEST==="true",i.isTauriApp=()=>"__TAURI__"in window,i.userAgent=t?navigator.userAgent.replace(/^Mozilla\/[\d.]+\s*/,"").replace(/\bAppleWebKit\/[\d.]+\s*/g,"").replace(/\(KHTML, like Gecko\)\s*/g,"").replace(/\bSafari\/[\d.]+\s*/g,"").replace(/\s+/g," ").trim():"N/A"})(Gt||(Gt={}));var Pa;(function(i){i.encode=async(e,t="gzip")=>{let r=new CompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()},i.decode=async(e,t="gzip")=>{let r=new DecompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()}})(Pa||(Pa={}));var Sa;(function(i){i.exportMethod=(s,o)=>r(s,{value:o}),i.exportBoolean=(s,o=!1)=>{let n=new Pe(o);return i.exportAccessor(s,()=>n.getValue(),a=>{let u=!!a;console.debug(`set to ${u}`),n.setValue(u)}),n},i.exportAccessor=(s,o,n=Rn)=>r(s,{get:()=>{try{return console.debug(o()),0}catch(a){return console.error(a),1}},set:a=>{try{return n(a),o()}catch(u){return console.error(u),1}},enumerable:!1,configurable:!1});let e=(()=>{try{return self}catch{return{}}})(),t=e.opendaw??={},r=(s,o)=>{let n=s.split("."),a=n.splice(-1)[0],u=t;for(let h of n)u=u[h]??={};Object.defineProperty(u,a,o),console.debug(`Console command 'opendaw.${s}' exported`)}})(Sa||(Sa={}));var Ca;(function(i){i.resolveString=e=>{if(!pr(e)){if(typeof e=="string")return e;if(Array.isArray(e))return e.join(",");if(typeof e=="object"){if(typeof e.exact=="string")return e.exact;if(Array.isArray(e.exact))return e.exact.join(",");if(typeof e.ideal=="string")return e.ideal;if(Array.isArray(e.ideal))return e.ideal.join(",")}}}})(Ca||(Ca={}));var Ra;(function(i){i.truncateText=(e,t,r)=>{if(t.length===0)return{text:"",width:0};let s=e.measureText(t).width;if(s<=r)return{text:t,width:s};let o=e.measureText("\u2026").width,n=0,a=t.length|0;for(;n<a;){let h=a+n>>>1;s=e.measureText(t.substring(0,h+1)).width+o,s<=r?n=h+1:a=h}if(n===0)return{text:"",width:0};let u=t.substring(0,n);return{text:u+"\u2026",width:e.measureText(u).width+o}}})(Ra||(Ra={}));var Ma;(function(i){i.calc=(t,r,s)=>{let o=/([0-9]*\.?[0-9]+)([a-zA-Z%]*)/g,n=t;return n.split(/\+|(?<!\d)-/).flatMap(a=>Array.from(a.matchAll(o))).forEach(([a,u,h])=>{let d=parseFloat(u);if(isNaN(d))return y(`${a} does not contain a number`);if(h==="em")n=n.replaceAll(a,`${d*s}`);else if(h==="%")n=n.replaceAll(a,`${d/100*r}`);else if(h==="px")n=n.replaceAll(a,`${d}`);else return y(`Unknown unit '${h}'`)}),Function(`return ${n}`)()};let e=new Map;i.registerCustomCursor=(t,r)=>e.set(t,r),i.setCursor=(t,r=document)=>{r.documentElement.style.cursor=typeof t=="number"?e.get(t)??"auto":t}})(Ma||(Ma={}));var Pi;(function(i){let e=new Set,t=new Set,r=new Array,s=-1;i.add=o=>(t.add(o),{terminate:()=>t.delete(o)}),i.once=o=>{e.add(o)},i.start=()=>{console.debug("AnimationFrame start");let o=()=>{(t.size>0||e.size>0)&&(t.forEach(n=>r.push(n)),e.forEach(n=>r.push(n)),e.clear(),r.forEach(n=>n()),r.length=0),s=requestAnimationFrame(o)};s=requestAnimationFrame(o)},i.terminate=()=>{console.debug("AnimationFrame terminate"),e.clear(),t.clear(),r.length=0,cancelAnimationFrame(s)}})(Pi||(Pi={}));var De=class{static subscribe(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static subscribeAny(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static DOUBLE_DOWN_THRESHOLD=200;static subscribeDblDwn=(e,t)=>{let r=0;return this.subscribe(e,"pointerdown",s=>{let o=performance.now();o-r<this.DOUBLE_DOWN_THRESHOLD&&t(s),r=o},{capture:!0})};static PreventDefault=e=>e.preventDefault();static isTextInput=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&D(e.getAttribute("contenteditable"))};var Wt;(function(i){i.isControlKey=({ctrlKey:e,metaKey:t})=>Gt.isMacOS()?t:e,i.isCopyKey=({altKey:e})=>e,i.GlobalShortcut=Object.freeze({isDelete:e=>!De.isTextInput(e.target)&&(e.code==="Delete"||e.code==="Backspace"),isSelectAll:e=>i.isControlKey(e)&&!e.shiftKey&&e.code==="KeyA",isDeselectAll:e=>i.isControlKey(e)&&e.shiftKey&&e.code==="KeyA"})})(Wt||(Wt={}));var Ta;(function(i){i.attach=(e,t,r)=>{let s=new V;return O.many(s,De.subscribe(e,"pointerdown",o=>{if(r?.multiTouch!==!0&&!o.isPrimary||o.buttons!==1||Gt.isMacOS()&&o.ctrlKey)return;let n=t(o);if(n.isEmpty())return;let a=n.unwrap(),u=o.pointerId;o.stopPropagation(),o.stopImmediatePropagation(),e.setPointerCapture(u);let h={clientX:o.clientX,clientY:o.clientY,altKey:o.altKey,shiftKey:o.shiftKey,ctrlKey:Wt.isControlKey(o)};r?.immediate===!0&&a.update(h),r?.permanentUpdates===!0?(s.own(Pi.add(()=>a.update(h))),s.own(De.subscribe(e,"pointermove",p=>{p.pointerId===u&&(h.clientX=p.clientX,h.clientY=p.clientY,h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p))}))):s.own(De.subscribe(e,"pointermove",p=>{p.pointerId===u&&(h.clientX=p.clientX,h.clientY=p.clientY,h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p),a.update(h))}));let d=()=>{a.cancel?.call(a),a.finally?.call(a),s.terminate()};s.ownAll(De.subscribe(e,"pointerup",p=>{p.pointerId===u&&(a.approve?.call(a),a.finally?.call(a),s.terminate())},{capture:!0}),De.subscribe(e,"pointercancel",p=>{console.debug(p.type),p.pointerId===u&&(e.releasePointerCapture(u),d())},{capture:!0}),De.subscribe(self,"beforeunload",p=>{e.releasePointerCapture(u),d()},{capture:!0}),De.subscribe(window,"keydown",p=>{h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p),p.key==="Escape"?d():a.update(h)}),De.subscribe(window,"keyup",p=>{h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p),a.update(h)})),a.abortSignal&&s.own(De.subscribe(a.abortSignal,"abort",()=>{e.releasePointerCapture(u),d()}))}))}})(Ta||(Ta={}));var Va;(function(i){i.AbortError=typeof DOMException>"u"?NaN:Object.freeze(new DOMException("AbortError")),i.isAbort=e=>e===i.AbortError||e instanceof DOMException&&e.name==="AbortError",i.CatchAbort=e=>e===i.AbortError?void 0:y(e)})(Va||(Va={}));var Da;(function(i){i.save=async(e,t)=>{if(D(window.showSaveFilePicker)){let r=await window.showSaveFilePicker(t),s=await r.createWritable();return await s.truncate(0),await s.write(e),await s.close(),r.name??"unknown"}else{let r=new Blob([e]),s=URL.createObjectURL(r),o=document.createElement("a");return o.href=s,o.download=t?.suggestedName??"unknown",o.click(),URL.revokeObjectURL(s),t?.suggestedName??"Unknown"}},i.open=async e=>{if(D(window.showOpenFilePicker)){let{status:t,value:r,error:s}=await Qe.tryCatch(window.showOpenFilePicker(e));return t==="rejected"?Promise.reject(s):Promise.all(r.map(o=>o.getFile()))}else return new Promise((t,r)=>{D(e)&&console.warn("FileApi.showOpenFilePicker is emulated in this browser. OpenFilePickerOptions are ignored.");let s=document.createElement("input");s.type="file",s.multiple=e?.multiple??!1,s.style.display="none",s.addEventListener("cancel",async()=>{s.remove(),r(new DOMException("cancel","AbortError"))}),s.addEventListener("change",async o=>{let a=o.target.files;D(a)?t(A.create(u=>U(a.item(u),`No file at index ${u}`),a.length)):r(new DOMException("cancel","AbortError")),s.remove()}),document.body.appendChild(s),s.click()})}})(Da||(Da={}));var Ia;(function(i){i.parse=e=>{let t=document.createElement("div");if(t.innerHTML=e,t.childElementCount!==1)return y(`Source html has more than one root elements: '${e}'`);let r=t.firstChild;return r instanceof HTMLElement||r instanceof SVGSVGElement?r:y(`Cannot parse to HTMLOrSVGElement from '${e}'`)},i.empty=e=>{for(;e.firstChild!==null;)e.firstChild.remove()},i.query=(e,t=document)=>U(t.querySelector(e)),i.queryAll=(e,t=document)=>Array.from(t.querySelectorAll(e)),i.sanitize=e=>{e.querySelectorAll("script").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(r=>{r.name.toLowerCase().startsWith("on")&&t.removeAttribute(r.name)})})},i.nextID=(()=>{let e=0;return()=>(++e).toString(16).padStart(4,"0")})(),i.adoptStyleSheet=(e,t)=>{b(e.includes("component"),`No 'component' found in: ${e}`);let r=`${t??"C"}${i.nextID()}`,s=new CSSStyleSheet;return s.replaceSync(e.replaceAll("component",`.${r}`)),s.cssRules.length===0?y(`No cssRules found in: ${e}`):(document.adoptedStyleSheets.push(s),r)},i.buildClassList=(...e)=>e.filter(t=>t!==!1&&t!==void 0).join(" "),i.readCssVarColor=(...e)=>{let t=document.createElement("div");document.body.appendChild(t);let r=e.map(s=>(t.style.color=s,Ci.parseCssRgbOrRgba(getComputedStyle(t).color)));return t.remove(),r},i.watchResize=(e,t,r)=>{let s=new ResizeObserver(([o],n)=>t(o,n));return s.observe(e,r),{terminate:()=>s.disconnect()}},i.watchIntersection=(e,t,r)=>{let s=new IntersectionObserver(t,r);return s.observe(e),{terminate:()=>s.disconnect()}},i.secureBoundingBox=e=>{let t=e.getBoundingClientRect();if(!li.isEmpty(t))return t;for(let r of e.children)li.union(t,i.secureBoundingBox(r));return t},i.unfocus=(e=self)=>{let t=e.document.activeElement;t!==null&&"blur"in t&&typeof t.blur=="function"&&t.blur()},i.selectContent=e=>{let t=document.createRange(),r=window.getSelection();D(r)&&(t.selectNodeContents(e),r.removeAllRanges(),r.addRange(t))},i.unselectContent=e=>{let t=window.getSelection();!D(t)||t.rangeCount===0||e.contains(t.getRangeAt(0).commonAncestorContainer)&&t.removeAllRanges()},i.limitChars=(e,t,r)=>{if(!(t in e))return y(`${t} not found in ${e}`);if(typeof e[t]!="string")return y(`${t} in ${e} is not a string`);if(e[t].length>r)if(e[t]=e[t].substring(0,r),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.setSelectionRange(r,r);else{let s=e.ownerDocument,o=s.createRange(),n=s.defaultView?.getSelection();if(!D(n))return;o.selectNodeContents(e),o.collapse(!1),n.removeAllRanges(),n.addRange(o)}},i.EmptyGif="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})(Ia||(Ia={}));var TI=(()=>{let i={Cmd:"\u2318",Opt:"\u2325",Shift:"\u21E7"},e={Cmd:"Ctrl",Opt:"Alt",Shift:"\u21E7"};return Object.freeze({Mac:i,Win:e,System:Gt.isMacOS()?i:e})})();var Oa;(function(i){i.read=async e=>{let t=[];for(;;){let{done:n,value:a}=await e.read();if(n)break;t.push(a)}let r=t.reduce((n,a)=>n+a.length,0),s=new Uint8Array(r),o=0;for(let n of t)s.set(n,o),o+=n.length;return s.buffer}})(Oa||(Oa={}));var ka;(function(i){i.pathBuilder=()=>new class{#e="";moveTo(e,t){return this.#e+=`M${e.toFixed(3)} ${t.toFixed(3)}`,this}lineTo(e,t){return this.#e+=`L${e.toFixed(3)} ${t.toFixed(3)}`,this}quadratic(e,t,r,s){return this.#e+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)}`,this}quadraticTo(e,t){return this.#e+=`T${e.toFixed(3)} ${t.toFixed(3)}`,this}cubic(e,t,r,s,o,n){return this.#e+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)} ${o.toFixed(3)} ${n.toFixed(3)}`,this}arc(e,t,r,s,o,n,a){return this.#e+=`A${e} ${t} ${r} ${s?1:0} ${o?1:0} ${n.toFixed(3)} ${a.toFixed(3)}`,this}circleSegment(e,t,r,s,o){let n=e+Math.cos(s)*r,a=t+Math.sin(s)*r,u=e+Math.cos(o)*r,h=t+Math.sin(o)*r,d=o-s;for(;d<0;)d+=Math.PI*2;return this.moveTo(n,a).arc(r,r,0,d>Math.PI,!0,u,h)}close(){return this.#e+="Z",this}get(){return this.#e}}})(ka||(ka={}));var Ua;(function(i){let e=new Array;i.watchWeak=(r,s)=>{let o=new WeakRef(r),n=s(o);return e.push([o,n]),e.length===1&&t(),r};let t=()=>{console.debug("start weak watching");let r=setInterval(()=>{let s=e.length;for(;--s>=0;){let o=e[s];o[0].deref()===void 0&&(o[1].terminate(),e.splice(s,1),e.length===0&&clearInterval(r))}},1e3)}})(Ua||(Ua={}));var Ko=Symbol.for("@openDAW/lib-dom");globalThis[Ko]?console.debug(`%c${Ko.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Ko]=!0,console.debug(`%c${Ko.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var xt;(function(i){i[i.Float=0]="Float",i[i.FloatArray=1]="FloatArray",i[i.Integer=2]="Integer",i[i.IntegerArray=3]="IntegerArray",i[i.ByteArray=4]="ByteArray"})(xt||(xt={}));var si;(function(i){i[i.WRITE=0]="WRITE",i[i.READ=1]="READ"})(si||(si={}));var dr;(function(i){i[i.ID=15793935]="ID",i[i.START=15790320]="START",i[i.END=986895]="END"})(dr||(dr={}));var Lo=class i{static create(e,t){return new i(e.channel(t))}#e=[];#t=new SharedArrayBuffer(1);#r=new Int8Array(this.#t);#i;#s=ue.create(0);#o=m.None;#n=m.None;#a=-1;#l=-1;#u=!1;#h=!1;constructor(e){this.#i=Re.sender(e,({dispatchAndForget:t})=>new class{sendShareLock(r){t(this.sendShareLock,r)}sendUpdateData(r){t(this.sendUpdateData,r)}sendUpdateStructure(r){t(this.sendUpdateStructure,r)}})}flush(){let e=this.#c();if(e.nonEmpty()){this.#h||(this.#i.sendShareLock(this.#t),this.#h=!0),this.#i.sendUpdateStructure(e.unwrap());let t=this.#d();if(this.#s.remaining<t){let r=ot(t),s=new SharedArrayBuffer(r);this.#s=ue.use(s),this.#o=m.wrap(s),this.#i.sendUpdateData(s)}}this.#o.isEmpty()||Atomics.load(this.#r,0)===si.WRITE&&(this.#p(this.#s),this.#s.position=0,Atomics.store(this.#r,0,si.READ))}broadcastFloat(e,t){return this.#f(new class{type=xt.Float;address=e;capacity=8;put(r){r.writeFloat(t())}})}broadcastInteger(e,t){return this.#f(new class{type=xt.Integer;address=e;capacity=8;put(r){r.writeInt(t())}})}broadcastFloats(e,t,r){return this.#f(new class{type=xt.FloatArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length);for(let o of t)s.writeFloat(o)}})}broadcastIntegers(e,t,r){return this.#f(new class{type=xt.IntegerArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length),t.forEach(o=>s.writeInt(o))}})}broadcastByteArray(e,t,r){return this.#f(new class{type=xt.ByteArray;address=e;capacity=4+t.byteLength;put(s){r(),s.writeInt(t.byteLength),s.writeBytes(t)}})}#c(){if(this.#u){try{this.#n=m.wrap(this.#F())}catch(e){throw e}this.#u=!1}if(this.#n.nonEmpty()){let e=this.#n;return this.#n=m.None,e}return m.None}#d(){return this.#l===-1&&(this.#l=this.#g()+12),this.#l}terminate(){A.clear(this.#e),this.#n=m.None,this.#u=!1,this.#l=0}#p(e){b(!this.#u&&this.#n.isEmpty(),"Cannot flush while update is available");let t=this.#d();b(e.remaining>=t,"Insufficient data"),e.writeInt(this.#a),e.writeInt(dr.START);for(let r of this.#e)r.put(e);e.writeInt(dr.END)}#g(){return this.#e.reduce((e,t)=>e+t.capacity,0)}#f(e){return this.#e.push(e),this.#x(),{terminate:()=>{A.removeOpt(this.#e,e),this.#x()}}}#x(){this.#l=-1,this.#u=!0}#F(){let e=ue.create();e.writeInt(dr.ID),e.writeInt(++this.#a),e.writeInt(this.#e.length);for(let{address:t,type:r}of this.#e)t.write(e),e.writeByte(r);return e.toArrayBuffer()}};var jt;(function(i){class e{shift;numPeaks;dataOffset;constructor(r,s,o){this.shift=r,this.numPeaks=s,this.dataOffset=o}unitsEachPeak(){return 1<<this.shift}}i.Stage=e,i.unpack=(t,r)=>{switch(r){case 0:return vt.intBitsToFloat(t);case 1:return vt.intBitsToFloat(t>>16);default:return it(r)}}})(jt||(jt={}));var $o=class i{stages;data;numFrames;numChannels;static from(e){b(e.readString()==="PEAKS","Wrong header");let t=e.readInt(),r=[];for(let u=0;u<t;u++){let h=e.readInt(),d=e.readInt(),p=e.readInt();e.readInt(),r[u]=new jt.Stage(p,d,h)}let s=e.readInt(),o=[];for(let u=0;u<s;u++){let h=new Int8Array(e.readInt());e.readBytes(h),o[u]=new Int32Array(h.buffer)}let n=e.readInt(),a=e.readInt();return new i(r,o,n,a)}static None=new i([],[],0,0);static findBestFit=(e,t=1200)=>{let r=e/t;if(r<=1)return new Uint8Array(0);let s=3,o=Math.floor(Math.log(r)/Math.LN2),n=Math.max(1,Math.floor(o/s));return new Uint8Array(A.create(a=>s*(a+1),n))};constructor(e,t,r,s){this.stages=e,this.data=t,this.numFrames=r,this.numChannels=s}nearest(e){if(this.stages.length===0)return null;let t=Math.floor(Math.log(Math.abs(e))/Math.LN2),r=this.stages.length;for(;--r>-1;)if(t>=this.stages[r].shift)return this.stages[r];return this.stages[0]}toArrayBuffer(){let e=ue.create();e.writeString("PEAKS"),e.writeInt(this.stages.length);for(let t=0;t<this.stages.length;t++){let{dataOffset:r,numPeaks:s,shift:o}=this.stages[t];e.writeInt(r),e.writeInt(s),e.writeInt(o),e.writeInt((1<<o)-1)}e.writeInt(this.data.length);for(let t=0;t<this.data.length;t++){let r=new Int8Array(this.data[t].buffer);e.writeInt(r.length),e.writeBytes(r)}return e.writeInt(this.numFrames),e.writeInt(this.numChannels),e.toArrayBuffer()}toString(){return`{SamplePeaks num-stages: ${this.stages.length}}`}};var Ka;(function(i){i.install=r=>Re.executor(r.channel("peaks"),new class{async generateAsync(s,o,n,a,u){return e(s,o,n,a,u).toArrayBuffer()}});let e=(r,s,o,n,a)=>{if(o.length!==a)return y(`Invalid numberOfChannels. Expected: ${a}. Got ${o.length}`);class u{min=Number.POSITIVE_INFINITY;max=Number.NEGATIVE_INFINITY;index=0}let h=la(),d=s.length,[p,f]=t(s,n),w=A.create(()=>new Int32Array(f),a),N=(1<<p[0].shift)-1,S=a*n,M=0;for(let k=0;k<a;++k){let K=w[k],q=o[k],z=A.create(()=>new u,d),ee=Number.POSITIVE_INFINITY,he=Number.NEGATIVE_INFINITY,ce=0;for(let _=0;_<n;++_){let j=q[_];if(ee=Math.min(j,ee),he=Math.max(j,he),(++ce&N)===0){for(let H=0;H<d;++H){let Y=p[H],ae=z[H];ae.min=Math.min(ae.min,ee),ae.max=Math.max(ae.max,he),((1<<Y.shift)-1&ce)===0&&(K[Y.dataOffset+ae.index++]=i.pack(ae.min,ae.max),ae.min=Number.POSITIVE_INFINITY,ae.max=Number.NEGATIVE_INFINITY)}ee=Number.POSITIVE_INFINITY,he=Number.NEGATIVE_INFINITY}(++M&65535)===0&&r(M/S)}}return r(1),h.lab(`SamplePeaks '${self.constructor.name}'`),new $o(p,w,n,a)},t=(r,s)=>{let o=0;return[A.create(a=>{let u=r[a],h=Math.ceil(s/(1<<u)),d=new jt.Stage(u,h,o);return o+=h,d},r.length),o]};i.pack=(r,s)=>{let o=vt.floatToIntBits(r),n=vt.floatToIntBits(s);return o|n<<16}})(Ka||(Ka={}));var La;(function(i){i.renderBlocks=(e,t,r,{u0:s,u1:o,v0:n,v1:a,x0:u,x1:h,y0:d,y1:p})=>{let f=(o-s)/(h-u),w=t.nearest(f);if(w===null)return;let N=(p-d-1)/(a-n),S=w.unitsEachPeak(),M=u-Math.floor(u),k=f/S,K=(s-M*f)/f*k,q=Math.floor(K),z=0,ee=0,he=t.data[r];for(let ce=Math.floor(u);ce<Math.floor(h);ce++){let _=K+k,j=Math.floor(_),H=!1;for(;q<j;){let Ge=he[w.dataOffset+q++];z=Math.min(jt.unpack(Ge,0),z),ee=Math.max(jt.unpack(Ge,1),ee),H=!0}let Y=d+Math.floor((z-n)*N),ae=d+Math.floor((ee-n)*N),He=Math.max(d,Math.min(Y,ae)),rt=Math.min(p,Math.max(Y,ae));if(e.fillRect(ce,He,1,rt===He?1:rt-He),H){let Ge=ee;ee=z,z=Ge}K=_,q=j}}})(La||(La={}));var $a;(function(i){let t=new Qe.Limit(1),r=new Qe.Limit(1);i.init=o=>Re.executor(o.channel("opfs"),new class{async write(n,a){return r.add(()=>this.#e(n,{create:!0}).then(u=>{u.truncate(a.length),u.write(a.buffer,{at:0}),u.flush(),u.close()}))}async read(n){return t.add(()=>this.#e(n).then(a=>{let u=a.getSize(),h=new Uint8Array(u);return a.read(h),a.close(),h}))}async delete(n){let a=s(n);return this.#t(a.slice(0,-1)).then(u=>u.removeEntry(U(a.at(-1)),{recursive:!0}))}async list(n){let a=s(n),{status:u,value:h}=await Qe.tryCatch(this.#t(a));if(u==="rejected")return A.empty();let d=[];for await(let{name:p,kind:f}of h.values())d.push({name:p,kind:f});return d}async#e(n,a){let u=s(n);return this.#t(u.slice(0,-1),a).then(h=>h.getFileHandle(U(u.at(-1)),a).then(d=>d.createSyncAccessHandle()))}async#t(n,a){let u=await navigator.storage.getDirectory();for(let h of n)u=await u.getDirectoryHandle(h,a);return u}});let s=o=>{let n=o.replace(/^\/+|\/+$/g,"");return n===""?[]:n.split("/")}})($a||($a={}));var qo=Symbol.for("@openDAW/lib-fusion");globalThis[qo]?console.debug(`%c${qo.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[qo]=!0,console.debug(`%c${qo.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var zo=class{#e;#t=new re;#r=[];constructor(e){this.#e=e}process({blocks:e}){e.forEach(({p0:t,p1:r,bpm:s,s0:o,s1:n,flags:a})=>{if(this.#e.metronomeEnabled&&ye.every(a,1))for(let u of Bt.iterate(t,r,G.Quarter)){b(t<=u&&u<r,`${u} out of bounds (${t}, ${r})`);let h=Math.floor(G.pulsesToSamples(u-t,s,sampleRate));this.#r.push(new Nn(u,o+h))}this.#t.clear(o,n);for(let u=this.#r.length-1;u>=0;u--)this.#r[u].processAdd(this.#t,o,n)&&this.#r.splice(u,1)})}get output(){return this.#t}},Nn=class{#e;#t=0;#r=0;constructor(e,t){b(t>=0&&t<128,`${t} out of bounds`),this.#e=G.toParts(e).beats===0?880:440,this.#r=t}processAdd(e,t,r){let[s,o]=e.channels(),n=Math.floor(.002*sampleRate),a=Math.floor(.05*sampleRate);for(let u=Math.max(this.#r,t);u<r;u++){let h=Math.min(this.#t/n,1-(this.#t-n)/a),d=Math.sin(this.#t/sampleRate*qe*this.#e)*.25*h*h;if(s[u]+=d,o[u]+=d,++this.#t>n+a)return!0}return this.#r=0,!1}};var _o=class{#e;#t;#r=!1;#i=null;#s=!1;#o=0;constructor(e){this.#e=e,this.#e.timelineBoxAdapter.markerTrack.subscribe(()=>this.#s=!0),this.#e.timelineBoxAdapter.box.bpm.subscribe(()=>this.#r=!0),this.#t=new Ti}setCallback(e,t){return this.#t.add(e,t),O.create(()=>this.#t.remove(e,t))}reset(){this.#r=!1,this.#s=!1,this.#o=0,this.#i=null}process(e){let t=!1,{timeInfo:r,timelineBoxAdapter:{box:s,markerTrack:o}}=this.#e,n=s.bpm.getValue(),a=r.transporting;if(a){let u=[],h=r.position,d=0,p=0,f=r.getLeapStateAndReset();for(;d<128;){if(this.#s||f){this.#s=!1;let _=o.events.lowerEqual(h);(this.#i?.at(0)??null)!==_&&(this.#i=D(_)?[_,0]:null,t=!0)}let w=128-d,N=h+G.samplesToPulses(w,n,sampleRate),S=null,M=Number.POSITIVE_INFINITY;if(o.enabled){let _=Array.from(se.take(o.events.iterateFrom(h),2));if(_.length>0){let[j,H]=_;this.#i===null?j.position>=h&&j.position<N&&(S={type:"marker",prev:j,next:H},M=j.position):D(H)&&H!==this.#i[0]&&j.position<h&&H.position<N&&(S={type:"marker",prev:j,next:H},M=H.position)}}let{isRecording:k,isCountingIn:K}=this.#e.timeInfo,{from:q,to:z,enabled:ee}=s.loopArea;if(ee.getValue()&&!(k||K)){let _=z.getValue();h<_&&N>_&&_<M&&(S={type:"loop",target:q.getValue()},M=_)}if(this.#t.keyCount()>0)for(let _ of this.#t.keys())h<_&&N>_&&_<M&&(S={type:"callback",position:_,callbacks:this.#t.get(_)},M=_);let ce=!r.isCountingIn;if(S===null){let _=d+w;u.push({index:p++,p0:h,p1:N,s0:d,s1:_,bpm:n,flags:wi.create(a,f,ce,this.#r)}),f=!1,h=N,d=_}else{let _=()=>{if(M>h){let j=d+G.pulsesToSamples(M-h,n,sampleRate)|0;u.push({index:p++,p0:h,p1:M,s0:d,s1:j,bpm:n,flags:wi.create(a,f,ce,this.#r)}),f=!1,h=M,d=j}};switch(S.type){case"loop":{_(),h=S.target,f=!0;break}case"marker":{let{prev:j,next:H}=S;!D(this.#i)||this.#i[0]!==j?this.#i=[j,0]:++this.#i[1]<j.plays||j.plays===0?(_(),h=j.position,f=!0):this.#i=[H,0],t=!0;break}case"callback":{_(),S.callbacks.forEach(j=>j());break}}}this.#r=!1}e({blocks:u}),r.advanceTo(h),this.#o=h}else{if(this.#s||r.getLeapStateAndReset()){this.#s=!1;let p=o.events.lowerEqual(r.position);p!==null&&this.#i?.at(0)!==p&&(this.#i=[p,0],t=!0)}let u=this.#o,h=u+G.samplesToPulses(128,n,sampleRate),d={blocks:[{index:0,p0:u,p1:h,s0:0,s1:128,bpm:n,flags:wi.create(!1,!1,!1,!1)}]};e(d),this.#o=h}t&&this.#e.engineToClient.switchMarkerState(D(this.#i)?[this.#i[0].uuid,this.#i[1]]:null)}};var Pn=class{constructor(e,t){this.uuid=e;this.engineToClient=t;t.fetchAudio(e).then(r=>this.#t=m.wrap(r))}peaks=m.None;#e={type:"idle"};#t=m.None;get data(){return this.#t}get state(){return this.#e}subscribe(e){return O.Empty}invalidate(){}toString(){return"{AudioLoaderWorklet}"}},Ho=class{#e;#t;constructor(e){this.#e=e,this.#t=v.newSet(t=>t.uuid)}record(e){}getOrCreate(e){return this.#t.getOrCreate(e,t=>new Pn(t,this.#e))}remove(e){}invalidate(e){}};var Go=class{constructor(e){this.uuid=e}waiting=m.None;playing=m.None},Wo=class{#e;#t;#r=[];#i=[];#s=[];constructor(e){this.#e=e,this.#e.subscribeToAllUpdatesImmediate({onUpdate:t=>{if(t.type==="delete"){let r=t.uuid;this.#t.opt(r).ifSome(s=>{s.playing.ifSome(o=>this.#n(o.uuid)),s.playing=m.None,s.waiting=m.None}),this.#t.forEach(s=>{s.playing.nonEmpty()&&v.equals(s.playing.unwrap().uuid,r)&&(s.playing=m.None,this.#n(r));let o=s.waiting.flatMap(ni);o.nonEmpty()&&v.equals(o.unwrap().uuid,r)&&(s.waiting=m.None)})}}}),this.#t=v.newSet(t=>t.uuid)}schedulePlay(e){e.trackBoxAdapter.ifSome(({uuid:t})=>{let r=this.#t.getOrCreate(t,o=>new Go(o));if(r.playing.nonEmpty()&&r.playing.unwrap()===e){console.debug(`${e} is already playing (ignore)`);return}let s=r.waiting.flatMap(o=>o);s.nonEmpty()&&(console.debug("obsolete",s.unwrap()),this.#s.push(s.unwrap().uuid),r.waiting=m.None),console.debug(`schedulePlay(${v.toString(r.uuid)} > ${e})`),A.removeOpt(this.#s,e.uuid),r.waiting=m.wrap(m.wrap(e))})}scheduleStop({uuid:e}){let t=this.#t.getOrCreate(e,s=>new Go(s)),r=t.waiting.flatMap(s=>s);r.nonEmpty()&&(console.debug("obsolete",r.unwrap()),this.#s.push(r.unwrap().uuid),t.waiting=m.None),t.playing.nonEmpty()&&(console.debug(`scheduleStop(${v.toString(e)})`),t.waiting=m.wrap(m.None))}reset(){this.#t.forEach(e=>{e.waiting.ifSome(t=>t.ifSome(r=>this.#s.push(r.uuid))),e.waiting=m.None,e.playing.ifSome(t=>this.#n(t.uuid)),e.playing=m.None}),this.#t.clear()}*iterate(e,t,r){let s=this.#t.getOrNull(e);if(s===null){yield{optClip:m.None,sectionFrom:t,sectionTo:r};return}if(s.waiting.nonEmpty()){let o=s.waiting.unwrap(),n=s.playing.mapOr(u=>u.duration,G.Bar),a=st(r,n);a>=t?(t<a&&(yield{optClip:s.playing,sectionFrom:t,sectionTo:a}),s.waiting=m.None,s.playing.ifSome(u=>this.#n(u.uuid)),o.nonEmpty()?(s.playing=o,this.#o(o.unwrap().uuid)):s.playing=m.None,yield{optClip:s.playing,sectionFrom:a,sectionTo:r}):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}else if(s.playing.nonEmpty()){let o=s.playing.unwrap();if(o.box.playback.loop.getValue())yield{optClip:s.playing,sectionFrom:t,sectionTo:r};else{let n=st(t,o.duration)+o.duration;n<=r?(yield{optClip:s.playing,sectionFrom:t,sectionTo:n},s.playing=m.None,this.#n(o.uuid),n<r&&(yield{optClip:m.None,sectionFrom:n,sectionTo:r})):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}}else yield{optClip:m.None,sectionFrom:t,sectionTo:r}}changes(){if(this.#r.length>0||this.#i.length>0||this.#s.length>0){let e=m.wrap({started:this.#r.slice(),stopped:this.#i.slice(),obsolete:this.#s.slice()});return this.#r.length=0,this.#i.length=0,this.#s.length=0,e}return m.None}terminate(){this.#t.clear(),this.#r.length=0,this.#i.length=0,this.#s.length=0}#o(e){this.#r.push(e)}#n(e){this.#i.push(e)}};var Sn;(e=>e.Default={includeAudioEffects:!0,includeSends:!0})(Sn||={});var ja=!1,jo=class extends AudioWorkletProcessor{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h;#c;#d;#p;#g;#f;#x;#F;#N;#P;#B;#V;#S;#v;#y=m.None;#b=m.None;#C=m.None;#R=!1;#M=!0;#w=!1;#E=0;#A=0;#T=4;constructor({processorOptions:{sab:e,project:t,exportConfiguration:r}}){super();let{boxGraph:s,mandatoryBoxes:{rootBox:o,timelineBox:n}}=oo.decode(t);this.#e=new V,this.#t=na.for(this.port),this.#r=s,this.#i=new Xi,this.#s=Re.sender(this.#t.channel("engine-to-client"),a=>new class{log(u){a.dispatchAndForget(this.log,u)}fetchAudio(u){return a.dispatchAndReturn(this.fetchAudio,u)}notifyClipSequenceChanges(u){a.dispatchAndForget(this.notifyClipSequenceChanges,u)}switchMarkerState(u){a.dispatchAndForget(this.switchMarkerState,u)}ready(){a.dispatchAndForget(this.ready)}}),this.#n=new Ho(this.#s),this.#a=v.newSet(a=>a.adapter.uuid),this.#h=new so,this.#o=this.#e.own(new Xs(this)),this.#l=this.#o.adapterFor(o,Hr),this.#u=this.#o.adapterFor(n,Je),this.#c=new Ui,this.#d=new Ki(this.#c),this.#p=new $,this.#g=new Uo,this.#P=new zo(this.#i),this.#B=new _o(this),this.#v=v.newSet(a=>a),this.#V=vr.writer(Ea(),e,a=>{let{transporting:u,isCountingIn:h,isRecording:d,position:p}=this.#i;a.position=p,a.playbackTimestamp=this.#A,a.countInBeatsTotal=this.#T,a.countInBeatsRemaining=h?(this.#E-p)/G.Quarter:0,a.isPlaying=u,a.isRecording=d,a.isCountingIn=h}),this.#f=this.#e.own(Lo.create(this.#t,"engine-live-data")),this.#F=new lo(this),this.#N=this.#e.own(new ne(this.#f,Q.compose(v.Lowest))),this.#x=this.#e.own(new Wo(this.#r)),this.#e.ownAll(ca(this.#r,this.#t.channel("engine-sync")),Re.executor(this.#t.channel("engine-commands"),{play:()=>{this.#i.position=this.#A,this.#i.transporting=!0},stop:a=>{(this.#i.isRecording||this.#i.isCountingIn)&&(this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.position=this.#A);let u=this.#i.transporting;this.#i.transporting=!1,this.#i.metronomeEnabled=this.#w,this.#v.clear(),(a||!u)&&this.#D()},setPosition:a=>{this.#i.isRecording||(this.#i.position=this.#A=a)},startRecording:a=>{if(!(this.#i.isRecording||this.#i.isCountingIn))if(!this.#i.transporting&&a){let u=this.#i.position,h=this.#u.box.signature.nominator.getValue(),d=this.#u.box.signature.denominator.getValue();this.#E=st(u,G.fromSignature(h,d)),this.#i.isCountingIn=!0,this.#i.metronomeEnabled=!0,this.#i.transporting=!0,this.#i.position=this.#E-G.fromSignature(this.#T,d);let p=this.#B.setCallback(this.#E,()=>{this.#i.isCountingIn=!1,this.#i.isRecording=!0,this.#i.metronomeEnabled=this.#w,p.terminate()})}else this.#i.transporting=!0,this.#i.isRecording=!0},stopRecording:()=>{!this.#i.isRecording&&!this.#i.isCountingIn||(console.debug("STOP RECORDING"),this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#w,this.#i.transporting=!1,this.#v.clear())},setMetronomeEnabled:a=>this.#i.metronomeEnabled=this.#w=a,queryLoadingComplete:()=>Promise.resolve(this.#r.boxes().every(a=>a.accept({visitAudioFileBox:u=>this.#n.getOrCreate(u.address.uuid).data.nonEmpty()&&u.pointerHub.nonEmpty()})??!0)),panic:()=>this.#R=!0,noteSignal:a=>{if(_t.isOn(a)){let{uuid:u,pitch:h,velocity:d}=a;this.optAudioUnit(u).ifSome(p=>p.midiDeviceChain.noteSequencer.pushRawNoteOn(h,d))}else if(_t.isOff(a)){let{uuid:u,pitch:h}=a;this.optAudioUnit(u).ifSome(d=>d.midiDeviceChain.noteSequencer.pushRawNoteOff(h))}},ignoreNoteRegion:a=>this.#v.add(a),scheduleClipPlay:a=>{a.forEach(u=>{let h=this.#r.findBox(u);if(h.isEmpty())console.warn(`Could not scheduleClipPlay. Cannot find clip: '${v.toString(u)}'`);else{let d=Ls.for(this.#o,h.unwrap());this.#x.schedulePlay(d)}}),this.#i.transporting=!0},scheduleClipStop:a=>{a.forEach(u=>{let h=this.#r.findBox(u);h.isEmpty()?console.warn(`Could not scheduleClipStop. Cannot find track: '${v.toString(u)}'`):this.#x.scheduleStop(this.#o.adapterFor(h.unwrap(),me))})},terminate:()=>{this.#C.ifSome(a=>a.terminate()),this.#C=m.None,this.#M=!1,this.#v.clear(),this.#e.terminate()}}),this.#l.audioUnits.catchupAndSubscribe({onAdd:a=>{let u=v.toString(a.uuid),h=D(r?.[u])?r[u]:Sn.Default,d=new ko(this,a,h),p=this.#a.add(d);if(b(p,`Could not add ${d}`),d.adapter.isOutput){b(this.#b.isEmpty(),"Output can only assigned once."),this.#b=m.wrap(d);return}},onRemove:({uuid:a})=>this.#a.removeByKey(a).terminate(),onReorder:Xt})),this.#S=m.wrap(r).match({none:()=>A.empty(),some:a=>Object.keys(a).map(u=>this.#a.get(v.parse(u)))}),this.#s.ready(),console.log=(...a)=>this.#s.log(a.join(", "))}ignoresRegion(e){return this.#v.hasKey(e)}process(e,t){try{return this.render(e,t)}catch(r){throw this.#s.log(r),r}}render(e,[t]){if(!this.#M)return!1;if(this.#R)return y("Manual Panic");let r=this.#i.metronomeEnabled;this.#p.notify(0),this.#y.isEmpty()&&(this.#d.update(),this.#y=m.wrap(this.#d.sorted().concat()),ja&&console.debug(`%cAudio-Graph%c
3
+ `),this));for(let r of t)r.defer();for(let r of e)r.unstage();this.unstage()}unstage(){this.graph.unstageBox(this)}toString(){return`${this.constructor.name} ${this.address.toString()}`}};Ya([gr,sa("design:type",je),sa("design:paramtypes",[])],P.prototype,"pointerHub",null);var X;(function(i){i[i.This=0]="This",i[i.Parent=1]="Parent",i[i.Children=2]="Children"})(X||(X={}));var Gi;(function(i){i.create=()=>new pn})(Gi||(Gi={}));var pn=class{#e=new pi(ir.equals);#t=new pi(ir.startsWith);#r=new pi(ir.endsWith);#i=[];#s=0;#o=!1;subscribe(e,t,r){let s=new mn(t,e,this.#s++,r);if(this.#o){let o=new fn(s,e);return this.#i.push(o),o}else return this.subscribeMonitor(s,e)}dispatch(e){this.#o=!0,[...this.#e.filter(e),...this.#t.filter(e),...this.#r.filter(e)].sort(({order:r},{order:s})=>r-s).forEach(r=>r.procedure(e)),this.#o=!1,this.#i.forEach(r=>r.subscribe(this)),this.#i.length=0}subscribeMonitor(e,t){switch(t){case X.This:return this.#e.subscribe(e);case X.Parent:return this.#t.subscribe(e);case X.Children:return this.#r.subscribe(e);default:return it(t)}}countStations(){return this.#e.count()+this.#t.count()+this.#r.count()}},mn=class{address;propagation;order;procedure;constructor(e,t,r,s){this.address=e,this.propagation=t,this.order=r,this.procedure=s}toString(){return`{ Monitor address: ${this.address}, propagation: ${X[this.propagation]}, order: ${this.order} }`}},pi=class{filterStrategy;#e=[];#t=!0;constructor(e){this.filterStrategy=e}subscribe(e){return this.#e.push(e),this.#t=this.#e.length<2,{terminate:()=>{let t=this.#e.length;for(;--t>=0;)this.#e[t]===e&&this.#e.splice(t,1)}}}stations(){return this.#t||(this.#e.sort(ir.Comparator),this.#t=!0),this.#e}filter(e){return this.filterStrategy(e.address,this.stations())}count(){return this.#e.length}},fn=class{monitor;propagation;#e=new V;#t=!1;constructor(e,t){this.monitor=e,this.propagation=t}subscribe(e){this.#t||(this.#e.terminate(),this.#e.own(e.subscribeMonitor(this.monitor,this.propagation)))}terminate(){this.#t=!0,this.#e.terminate()}};var pe;(function(i){i.Boolean="boolean",i.Float32="float32",i.Int32="int32",i.String="string",i.Bytes="bytes"})(pe||(pe={}));var or={[pe.Boolean]:{type:pe.Boolean,encode:(i,e)=>i.writeBoolean(e),decode:i=>i.readBoolean()},[pe.Float32]:{type:pe.Float32,encode:(i,e)=>i.writeFloat(e),decode:i=>i.readFloat()},[pe.Int32]:{type:pe.Int32,encode:(i,e)=>i.writeInt(e),decode:i=>i.readInt()},[pe.String]:{type:pe.String,encode:(i,e)=>i.writeString(e),decode:i=>i.readString()},[pe.Bytes]:{type:pe.Bytes,encode:(i,e)=>{i.writeInt(e.length),i.writeBytes(e)},decode:i=>{let e=new Int8Array(i.readInt());return i.readBytes(e),e}}},sr=class extends I{#e;#t;#r;constructor(e,t,r){super(e),this.#e=t,this.#t=this.clamp(r),this.#r=this.#t}accept(e){return g(e.visitPrimitiveField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(X.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.subscribe(e)}get type(){return this.#e}get initValue(){return this.#t}setInitValue(e){v(this.graph.constructingBox(),"Cannot change initial value at runtime"),this.setValue(this.#t=e)}getValue(){return this.#r}setValue(e){let t=this.#r,r=this.clamp(e);this.equals(r)||(this.#r=e,this.graph.onPrimitiveValueUpdate(this,t,r))}writeValue(e,t){this.serialization().encode(e,t)}readValue(e){return this.serialization().decode(e)}reset(){this.setValue(this.#t)}},B=class i extends sr{static create(e,t=!1){return new i(e,t)}constructor(e,t){super(e,pe.Boolean,t)}toggle(){this.setValue(!this.getValue())}serialization(){return or[pe.Boolean]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readBoolean())}write(e){e.writeBoolean(this.getValue())}},F=class i extends sr{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,pe.Float32,t)}serialization(){return or[pe.Float32]}equals(e){return this.getValue()===e}clamp(e){return nt.toFloat32(e)}read(e){this.setValue(e.readFloat())}write(e){e.writeFloat(this.getValue())}},x=class i extends sr{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,pe.Int32,t)}serialization(){return or[pe.Int32]}equals(e){return this.getValue()===e}clamp(e){return Ie.toInt(e)}read(e){this.setValue(e.readInt())}write(e){e.writeInt(this.getValue())}},T=class i extends sr{static create(e,t=""){return new i(e,t)}constructor(e,t){super(e,pe.String,t)}serialization(){return or[pe.String]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readString())}write(e){e.writeString(this.getValue())}},oa=class i extends sr{static create(e,t=this.#e){return new i(e,t)}static#e=Object.freeze(new Int8Array(0));constructor(e,t){super(e,pe.Bytes,t)}serialization(){return or[pe.Bytes]}equals(e){return this.getValue().length===e.length&&this.getValue().every((t,r)=>e[r]===t)}clamp(e){return e}read(e){let t=new Int8Array(e.readInt());e.readBytes(t),this.setValue(t)}write(e){let t=this.getValue();e.writeInt(t.length),e.writeBytes(t)}};var na;(function(i){i.decode=e=>{let t=e.readInt();return w.create(()=>{switch(e.readString()){case"new":{let s=b.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new mi(s,o,n.buffer)}case"pointer":{let s=Q.read(e),o=e.readBoolean()?m.wrap(Q.read(e)):m.None,n=e.readBoolean()?m.wrap(Q.read(e)):m.None;return new gi(s,o,n)}case"primitive":{let s=Q.read(e),o=e.readString(),n=or[o],a=n.decode(e),u=n.decode(e);return new fi(s,n,a,u)}case"delete":{let s=b.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new xi(s,o,n.buffer)}}},t)}})(na||(na={}));var mi=class{type="new";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get uuid(){return this.#e}get name(){return this.#t}get settings(){return this.#r}forward(e){e.createBox(this.#t,this.#e,t=>t.read(new ge(this.#r)))}inverse(e){e.findBox(this.#e).unwrap(()=>`Could not find ${this.#t}`).unstage()}write(e){e.writeString(this.type),b.toDataOutput(e,this.#e),e.writeString(this.#t),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{NewUpdate uuid: ${b.toString(this.#e)}, attachment: ${this.settings.byteLength}b`}toDebugString(e){return this.toString()}},fi=class{type="primitive";#e;#t;#r;#i;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#r=r,this.#i=s}get address(){return this.#e}get oldValue(){return this.#r}get newValue(){return this.#i}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).setValue(this.#r)}forward(e){this.field(e).setValue(this.#i)}field(e){return e.findVertex(this.#e).unwrap(()=>`Could not find PrimitiveField at ${this.#e}`)}write(e){e.writeString(this.type),this.#e.write(e),e.writeString(this.#t.type),this.#t.encode(e,this.#r),this.#t.encode(e,this.#i)}toString(){return`{PrimitiveUpdate oldValue: ${this.#r}, newValue: ${this.#i}`}},gi=class{type="pointer";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get address(){return this.#e}get oldAddress(){return this.#t}get newAddress(){return this.#r}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).targetAddress=this.#t}forward(e){this.field(e).targetAddress=this.#r}field(e){return e.findVertex(this.#e).unwrap(()=>`Could not find PointerField at ${this.#e}`)}write(e){e.writeString(this.type),this.#e.write(e),this.#t.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}}),this.#r.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}toString(){return`{PointerUpdate oldValue: ${this.#t.unwrapOrNull()}, newValue: ${this.#r.unwrapOrNull()}`}},xi=class{type="delete";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get uuid(){return this.#e}get name(){return this.#t}get settings(){return this.#r}forward(e){e.findBox(this.#e).unwrap(()=>`Could not find ${this.#t}`).unstage()}inverse(e){e.createBox(this.#t,this.#e,t=>t.read(new ge(this.#r)))}write(e){e.writeString(this.type),b.toDataOutput(e,this.#e),e.writeString(this.#t),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{DeleteUpdate uuid: ${b.toString(this.#e)}, attachment: ${this.settings.byteLength}b`}};var ap=Symbol("Unreferenceable"),E=class i extends I{static create(e,t,r){return new i(e,t,r)}static encodeWith(e,t){v(this.#e.isEmpty(),"SerializationEncoder already in use"),this.#e=m.wrap(e);let r=Yt(t);if(this.#e=m.None,r.status==="failure")throw r.error;return r.value}static decodeWith(e,t){v(this.#t.isEmpty(),"SerializationDecoder already in use"),this.#t=m.wrap(e);let r=Yt(t);if(this.#t=m.None,r.status==="failure")throw r.error;return r.value}static#e=m.None;static#t=m.None;#r;#i;#s=m.None;#o=m.None;constructor(e,t,r){super(e),this.#r=t,this.#i=r,r&&this.graph.edges().watchVertex(this)}get pointerHub(){return y(`${this} cannot be pointed to`)}get pointerType(){return this.#r}get mandatory(){return this.#i}accept(e){return g(e.visitPointerField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(X.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.graph.subscribeVertexUpdates(X.This,this.address,()=>this.graph.subscribeEndTransaction(()=>e(this)))}refer(e){this.targetVertex=m.wrap(e)}defer(){this.targetVertex=m.None}get targetVertex(){return this.graph.inTransaction()?this.#o.flatMap(e=>this.graph.findVertex(e)):this.#s}set targetVertex(e){if(e.nonEmpty()){let t=je.validate(this,e.unwrap());t.nonEmpty()&&y(t.unwrap())}this.targetAddress=e.map(t=>t.address)}get targetAddress(){return this.#o}set targetAddress(e){let t=this.#o;t.isEmpty()&&e.isEmpty()||(e.nonEmpty()&&t.unwrapOrNull()?.equals(e.unwrap()))===!0||(this.#o=e,this.graph.onPointerAddressUpdated(this,t,e))}isEmpty(){return this.targetAddress.isEmpty()}nonEmpty(){return this.targetAddress.nonEmpty()}resolvedTo(e){this.#s=e}read(e){let t=e.readBoolean()?m.wrap(Q.read(e)):m.None;this.targetAddress=i.#t.match({none:()=>t,some:r=>r.map(this,t)})}write(e){i.#e.match({none:()=>this.#o,some:t=>t.map(this)}).match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}};var Wi=class{#e;#t;#r;#i;constructor(){this.#e=Q.newSet(e=>e.address),this.#t=Q.newSet(e=>e.address),this.#r=Q.newSet(([e])=>e),this.#i=Q.newSet(([e])=>e.address)}watchVertex(e){if(de(e,E)){if(!e.mandatory)return y("watchVertex called but has no edge requirement");this.#e.add(e)}else{if(!e.pointerRules.mandatory)return y("watchVertex called but has no edge requirement");this.#t.add(e)}}unwatchVerticesOf(...e){let t=({box:{address:{uuid:r}}})=>r;for(let{address:{uuid:r}}of e)this.#o(this.#e,r,t),this.#o(this.#t,r,t);for(let r of e){let s=this.outgoingEdgesOf(r);if(s.length>0)return y(`${r} has outgoing edges: ${s.map(([n,a])=>`[${n.toString()}, ${a.toString()}]`)}`);let o=this.incomingEdgesOf(r);if(o.length>0)return y(`${r} has incoming edges from: ${o.map(n=>n.toString())}`)}}connect(e,t){this.#i.add([e,t]),this.#r.opt(t).match({none:()=>this.#r.add([t,[e]]),some:([,r])=>r.push(e)})}disconnect(e){let[,t]=this.#i.removeByKey(e.address),[,r]=this.#r.get(t);w.remove(r,e),r.length===0&&this.#r.removeByKey(t)}outgoingEdgesOf(e){return this.#s(this.#i,e.address.uuid,([{box:{address:{uuid:t}}}])=>t)}incomingEdgesOf(e){return e.isBox()?this.#s(this.#r,e.address.uuid,([{uuid:t}])=>t).flatMap(([t,r])=>r):this.#r.opt(e.address).mapOr(([t,r])=>r,w.empty())}validateRequirements(){this.#e.forEach(e=>{if(v(e.isAttached(),`Pointer ${e.address.toString()} is not attached`),e.isEmpty())return e.mandatory?y(`Pointer ${e.toString()} requires an edge.`):y(`Illegal state: ${e} has no edge requirements.`)}),this.#t.forEach(e=>{if(v(e.isAttached(),`Target ${e.address.toString()} is not attached`),e.pointerHub.isEmpty())return e.pointerRules.mandatory?y(`Target ${e.toString()} requires an edge.`):y(`Illegal state: ${e} has no edge requirements.`)})}#s(e,t,r){let s=Q.boxRange(e,t,r);return D(s)?e.values().slice(s[0],s[1]):w.empty()}#o(e,t,r){let s=Q.boxRange(e,t,r);D(s)&&e.removeRange(s[0],s[1])}};var ji=class{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u=!1;#h=!1;constructor(e=m.None){this.#e=e,this.#t=b.newSet(t=>t.address.uuid),this.#r=[],this.#n=Gi.create(),this.#i=new ve,this.#s=new ve,this.#o=new ve,this.#a=new Wi,this.#l=[]}beginTransaction(){v(!this.#u,"Transaction already in progress"),this.#u=!0,this.#o.proxy.onBeginTransaction()}endTransaction(){for(v(this.#u,"No transaction in progress"),this.#u=!1,this.#r.length>0&&(this.#r.forEach(({pointerField:e,update:t})=>this.#c(e,t)),this.#r.length=0);this.#l.length>0;)this.#l.splice(0).forEach(e=>e()),this.#l.length>0&&console.debug(`${this.#l.length} new observers while notifying`);this.#o.proxy.onEndTransaction()}inTransaction(){return this.#u}constructingBox(){return this.#h}createBox(e,t,r){return this.#e.unwrap("No box-factory installed")(e,this,t,r)}stageBox(e,t){this.#d(),v(!this.#h,"Cannot construct box while other box is constructing"),D(t)&&(this.#h=!0,t(e),this.#h=!1);let r=this.#t.add(e);v(r,`${e} already staged`);let s=new mi(e.address.uuid,e.name,e.toArrayBuffer());return this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s),e}subscribeTransaction(e){return this.#o.subscribe(e)}subscribeToAllUpdates(e){return this.#i.subscribe(e)}subscribeToAllUpdatesImmediate(e){return this.#s.subscribe(e)}subscribeVertexUpdates(e,t,r){return this.#n.subscribe(e,t,r)}subscribeEndTransaction(e){this.#l.push(e)}unstageBox(e){this.#d();let t=this.#t.removeByKey(e.address.uuid);v(t===e,`${e} could not be found to unstage`),this.#a.unwatchVerticesOf(e);let r=new xi(e.address.uuid,e.name,e.toArrayBuffer());this.#i.proxy.onUpdate(r),this.#s.proxy.onUpdate(r)}findBox(e){return this.#t.opt(e)}findVertex(e){return this.#t.opt(e.uuid).flatMap(t=>t.searchVertex(e.fieldKeys))}boxes(){return this.#t.values()}edges(){return this.#a}checksum(){let e=new Mi;return this.boxes().forEach(t=>t.write(e)),e.result()}onPrimitiveValueUpdate(e,t,r){if(this.#d(),e.isAttached()&&!this.#h){let s=new fi(e.address,e.serialization(),t,r);this.#n.dispatch(s),this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s)}}onPointerAddressUpdated(e,t,r){this.#d(),t.nonEmpty()&&this.#a.disconnect(e),r.nonEmpty()&&this.#a.connect(e,r.unwrap());let s=new gi(e.address,t,r);this.#h?this.#r.push({pointerField:e,update:s}):(this.#c(e,s),this.#s.proxy.onUpdate(s))}#c(e,t){let{oldAddress:r,newAddress:s}=t,o=r.flatMap(a=>this.findVertex(a)),n=s.flatMap(a=>this.findVertex(a));e.resolvedTo(n),o.equals(n)||(o.ifSome(a=>a.pointerHub.onRemoved(e)),n.ifSome(a=>a.pointerHub.onAdded(e))),this.#n.dispatch(t),this.#i.proxy.onUpdate(t)}dependenciesOf(e){let t=new Set,r=new Set,s=o=>{t.has(o)||(t.add(o),o.outgoingEdges().filter(([n])=>!r.has(n)).forEach(([n,a])=>{let u=this.findVertex(a).unwrap(`Could not find target of ${n.toString()}`);if(r.add(n),u.pointerRules.mandatory&&u.pointerHub.incoming().every(h=>r.has(h)))return s(u.box)}),o.incomingEdges().forEach(n=>{r.add(n),n.mandatory&&s(n.box)}))};return s(e),t.delete(e),{boxes:t,pointers:Array.from(r).reverse()}}verifyPointers(){this.#a.validateRequirements();let e=0,t=r=>{for(let s of r.fields())s.accept({visitPointerField:o=>{if(o.targetAddress.nonEmpty()){let n=o.targetVertex.nonEmpty(),a=this.findVertex(o.targetAddress.unwrap()).nonEmpty();v(n,`pointer ${o.address} is broken`),v(a,`Cannot find target for pointer ${o.address}`),e++}},visitObjectField:o=>t(o)})};return this.#t.forEach(r=>t(r)),console.debug("verification complete."),{count:e}}debugBoxes(){console.table(this.#t.values().reduce((e,t)=>(e[b.toString(t.address.uuid)]={class:t.name,"incoming links":t.incomingEdges().length,"outgoing links":t.outgoingEdges().length,"est. memory (bytes)":t.estimateMemory()},e),{}))}debugDependencies(){console.debug("Dependencies:"),this.boxes().forEach(e=>{console.debug(` ${e}`);for(let t of this.dependenciesOf(e).boxes)console.debug(` ${t}`)})}addressToDebugPath(e){return e.flatMap(t=>t.isBox()?this.findBox(t.uuid).map(r=>r.name):this.findBox(t.uuid).flatMap(r=>r.searchVertex(t.fieldKeys).map(s=>s.isField()?s.debugPath:y("Unknown address"))))}toArrayBuffer(){let e=ue.create(),t=this.#t.values();return e.writeInt(t.length),t.forEach(r=>{let s=r.serialize();e.writeInt(s.byteLength),e.writeBytes(new Int8Array(s))}),e.toArrayBuffer()}fromArrayBuffer(e){v(this.#t.isEmpty(),"Cannot call fromArrayBuffer if boxes is not empty");let t=new ge(e),r=t.readInt();this.beginTransaction();let s=[];for(let o=0;o<r;o++){let n=t.readInt(),a=new Int8Array(n);t.readBytes(a);let u=new ge(a.buffer),h=u.readInt(),d=u.readString(),p=b.fromDataInput(u);s.push({creationIndex:h,name:d,uuid:p,boxStream:u})}s.sort((o,n)=>o.creationIndex-n.creationIndex).forEach(({name:o,uuid:n,boxStream:a})=>this.createBox(o,n,u=>u.read(a))),this.endTransaction()}#d(){v(this.#u,()=>"Modification only prohibited in transaction mode.")}};var aa;(function(i){i.insertOrder=(e,t=Number.MAX_SAFE_INTEGER)=>{let r=i.collectIndexedBoxes(e),s=L(t,0,r.length);if(s<r.length)for(let o=s;o<r.length;o++)r[o].index.setValue(o+1);return s},i.removeOrder=(e,t)=>{let r=i.collectIndexedBoxes(e);if(t<r.length)for(let s=t+1;s<r.length;s++)r[s].index.setValue(s-1)},i.moveIndex=(e,t,r)=>{let s=i.collectIndexedBoxes(e),o=s[t];if(r<0){let n=L(t+r,0,s.length-1);for(let a=n;a<t;a++)s[a].index.setValue(a+1);o.index.setValue(n)}else if(r>1){let n=L(t+(r-1),0,s.length-1);for(let a=t;a<n;a++)s[a+1].index.setValue(a);o.index.setValue(n)}else console.warn(`moveIndex had no effect: startIndex: ${t}, delta: ${r}`)},i.isIndexedBox=e=>"index"in e&&e.index instanceof x,i.collectIndexedBoxes=(e,t)=>e.pointerHub.incoming().map(({box:r})=>i.isIndexedBox(r)&&(t===void 0||r instanceof t)?r:y(`${r} has no index field`)).sort((r,s)=>r.index.getValue()-s.index.getValue())})(aa||(aa={}));var le=class extends I{#e;constructor(e){super(e),this.#e=this.initializeFields()}accept(e){return g(e.visitObjectField,this)}fields(){return Object.values(this.#e)}getField(e){return U(this.#e[e])}optField(e){return m.wrap(this.#e[e])}read(e){Pt.readFields(e,this.#e)}write(e){Pt.writeFields(e,this.#e)}toJSON(){return this.#e}};var Re;(function(i){i.sender=(r,s)=>s(new e(r)),i.executor=(r,s)=>new t(r,s);class e{#e;#t=new Map;#r;#i=0;constructor(s){this.#e=s,this.#r=s.subscribe(this.#s)}terminate(){this.#r.terminate()}dispatchAndForget=(s,...o)=>this.#e.send({type:"send",returnId:!1,func:s.name,args:Array.from(se.map(o,n=>({value:n})))});dispatchAndReturn=(s,...o)=>new Promise((n,a)=>{let u=se.reduce(o,(h,d,p)=>(typeof d=="function"&&h.push([p,d]),h),[]);this.#t.set(this.#i,{executorTuple:{resolve:n,reject:a},callbacks:new Map(u)}),this.#e.send({type:"send",returnId:this.#i,func:s.name,args:Array.from(se.map(o,(h,d)=>typeof h=="function"?{callback:d}:{value:h}))}),this.#i++});#s=s=>{let o=this.#t.get(s.returnId);D(o)?s.type==="resolve"?(o.executorTuple.resolve(s.resolve),this.#t.delete(s.returnId)):s.type==="reject"?(o.executorTuple.reject(s.reject),this.#t.delete(s.returnId)):s.type==="callback"&&o.callbacks?.get(s.funcAt).apply(this,s.args):y(`Promise has already been resolved. ${JSON.stringify(s)}`)}}class t{#e;#t;#r;constructor(s,o){this.#e=s,this.#t=o,this.#r=s.subscribe(this.#i)}terminate(){this.#r.terminate()}#i=s=>{v(s.type==="send",()=>"Message type must be 'send'");let o=Object.getPrototypeOf(this.#t)===Object.getPrototypeOf({})?this.#t:Object.getPrototypeOf(this.#t),n=U(o[s.func],`${s.func.toString()} does not exists on ${this.#t}`),a=s.returnId;if(a===!1)n.apply(this.#t,s.args.map(u=>"value"in u?u.value:y(`${s.func.toString()} has no promise.`)));else try{n.apply(this.#t,s.args.map(h=>"callback"in h?(...d)=>this.#n(a,h.callback,d):h.value)).then(h=>this.#s(a,h),h=>this.#o(a,h))}catch(u){this.#o(a,u)}};#s=(s,o)=>this.#e.send({type:"resolve",returnId:s,resolve:o});#o=(s,o)=>this.#e.send({type:"reject",returnId:s,reject:o});#n=(s,o,n)=>this.#e.send({type:"callback",returnId:s,funcAt:o,args:n})}i.Executor=t})(Re||(Re={}));var la;(function(i){i.ProgressArrayBuffer=e=>async t=>{if(!t.headers.has("Content-Length"))return console.debug("No Content-Length"),t.arrayBuffer();let r=parseInt(t.headers.get("Content-Length"));if(console.debug(`Content-Length: ${r}b`),isNaN(r)||r<4096)return t.arrayBuffer();e(0);let s=ue.create(r),o=U(t.body,"response.body is empty").getReader();for(;;){let{done:n,value:a}=await o.read();if(n)break;a.forEach(u=>s.writeByte(u)),e(s.position/r)}return e(1),s.toArrayBuffer()}})(la||(la={}));var ua;(function(i){i.debounce=(()=>{let e;return(t,r=1e3)=>{clearTimeout(e),e=setTimeout(t,r)}})(),i.scheduleInterval=(e,t,...r)=>{let s=setInterval(e,t,...r);return{terminate:()=>clearInterval(s)}},i.scheduleTimeout=(e,t,...r)=>{let s=setTimeout(e,t,...r);return{terminate:()=>clearTimeout(s)}}})(ua||(ua={}));var ha={for:i=>new gn(i)},gn=class{#e;#t=new $;constructor(e){if(this.#e=e,D(e.onmessage)||D(e.onmessageerror))throw console.error(e),new Error(`${e} is already wrapped.`);e.onmessage=t=>this.#t.notify(t.data),e.onmessageerror=t=>{throw new Error(t.type)}}send(e){this.#e.postMessage(e)}channel(e){return new xn(this,e)}subscribe(e){return this.#t.subscribe(e)}terminate(){this.#t.terminate(),this.#e.onmessage=null,this.#e.onmessageerror=null}},xn=class i{#e;#t;#r=new $;#i;constructor(e,t){this.#e=e,this.#t=t,this.#i=e.subscribe(r=>{"message"in r&&"channel"in r&&r.channel===t&&this.#r.notify(r.message)})}send(e){this.#e.send({channel:this.#t,message:e})}channel(e){return new i(this,e)}subscribe(e){return this.#r.subscribe(e)}terminate(){this.#i.terminate(),this.#r.terminate()}};var yn=class{maxRetry;timeSpan;#e=0;constructor(e,t){this.maxRetry=e,this.timeSpan=t}retry(e,t){return++this.#e===this.maxRetry?!1:(console.debug(`${e} > will retry in ${this.timeSpan.toString()}`),setTimeout(t,this.timeSpan.millis()),!0)}},Qe;(function(i){class e{value;status="resolved";constructor(n){this.value=n}error=en("Cannot access error when promise is resolved")}i.ResolveResult=e;class t{error;status="rejected";constructor(n){this.error=n}value=en("Cannot access value when promise is rejected")}i.RejectedResult=t,i.makeAbortable=async(o,n)=>{let a=!0;return o.own(O.create(()=>a=!1)),new Promise((u,h)=>n.then(d=>{a&&u(d)},d=>{a&&h(d)}))},i.tryCatch=o=>o.then(n=>new e(n),n=>new t(n)),i.retry=(o,n=new yn(3,Jt.seconds(3)))=>o().catch(a=>new Promise((u,h)=>{let d=p=>{n.retry(p,()=>o().then(f=>u(f),d))||h(p)};d(a)})),i.fail=(o,n)=>{let a=()=>new Promise((u,h)=>setTimeout(()=>h("fails first"),o.millis()));return()=>{let u=a();return a=n,u}},i.timeout=(o,n,a)=>new Promise((u,h)=>{let d=!0,p=setTimeout(()=>{d=!1,h(new Error(a??"timeout"))},n.millis());o.then(f=>{d&&u(f)},f=>{d&&h(f)}).finally(()=>clearTimeout(p))}),i.sequential=o=>{let n=Promise.resolve(null);return a=>n=n.then(()=>o(a))},i.memoizeAsync=o=>{let n=null;return()=>(Mn(n)&&(n=o(),n.catch(a=>{throw n=null,a})),n)};class r{max;#e;#t=0;constructor(n=1){this.max=n,this.#e=[]}async add(n){if(this.#t<this.max)return this.#t++,n().finally(()=>this.#r());{let a=Promise.withResolvers();return this.#e.push([n,a]),a.promise.finally(()=>this.#r())}}#r(){if(v(this.#t>0,"Internal Error in Promises.Limit"),--this.#t<this.max&&this.#e.length>0){let[n,{resolve:a,reject:u}]=this.#e.shift();this.#t++,n().then(a,u)}}}i.Limit=r;class s{#e;#t;#r;#i=m.None;constructor(n,a,u){this.#e=n,this.#t=a,this.#r=u}update(n){this.#i=m.wrap(n),n.then(a=>{this.#i.contains(n)&&this.#e(a)}).catch(a=>{this.#i.contains(n)&&this.#t(a)}).finally(()=>{this.#i.contains(n)&&(this.terminate(),g(this.#r))})}terminate(){this.#i=m.None}}i.Latest=s})(Qe||(Qe={}));var ca;(function(i){let e=new Qe.Limit(4);i.limitFetch=(t,r)=>e.add(()=>fetch(t,r))})(ca||(ca={}));var da=(i="debug")=>{let e=performance.now();return{lab:t=>console[i].call(console,`${t} in ${(performance.now()-e).toFixed(1)}ms`)}};var pa;(function(i){i.startEstimator=()=>{let e=performance.now();return t=>{if(t===0)return Jt.POSITIVE_INFINITY;let r=performance.now()-e;return Jt.millis(r/t-r)}}})(pa||(pa={}));var ma;(function(i){i.frame=()=>new Promise(e=>requestAnimationFrame(()=>e())),i.frames=e=>new Promise(t=>{let r=e,s=()=>{--r<=0?t():requestAnimationFrame(s)};requestAnimationFrame(s)}),i.timeSpan=(e,...t)=>new Promise(r=>setTimeout(r,e.millis(),...t)),i.event=(e,t)=>new Promise(r=>e.addEventListener(t,r,{once:!0})),i.observable=e=>new Promise(t=>{let r=e.subscribe(()=>{r.terminate(),t()})}),i.complete=e=>new Promise((t,r)=>{let s=setInterval(()=>{let{status:o,value:n,error:a}=Yt(()=>e.next());if(o==="success"){let{done:u,value:h}=n;u&&(clearInterval(s),t(h))}else clearInterval(s),r(a)},0)})})(ma||(ma={}));var Qi=Symbol.for("@openDAW/lib-runtime");globalThis[Qi]?console.debug(`%c${Qi.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Qi]=!0,console.debug(`%c${Qi.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var fa=(i,e)=>Re.executor(e,new class{sendUpdates(t){i.beginTransaction(),t.forEach(r=>{let s=r.type;s==="new"?i.createBox(r.name,r.uuid,o=>o.read(new ge(r.buffer))):s==="update-primitive"?i.findVertex(Q.reconstruct(r.address)).unwrap(()=>`Could not find primitive field ${r.address}`).setValue(r.value):s==="update-pointer"?i.findVertex(Q.reconstruct(r.address)).unwrap(()=>`Could not find pointer field ${r.address}`).targetAddress=D(r.target)?m.wrap(Q.reconstruct(r.target)):m.None:r.type==="delete"&&i.unstageBox(i.findBox(r.uuid).unwrap(()=>`Could not find box ${b.toString(r.uuid)}`))}),i.endTransaction()}checksum(t){return w.equals(i.checksum(),t)?Promise.resolve():Promise.reject("Checksum mismatch")}});var Yi=Symbol.for("@openDAW/lib-box");globalThis[Yi]?console.debug(`%c${Yi.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Yi]=!0,console.debug(`%c${Yi.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Xi=class{#e=0;#t=!1;#r=!1;isRecording=!1;isCountingIn=!1;metronomeEnabled=!1;getLeapStateAndReset(){let e=this.#r;return this.#r=!1,e}get position(){return this.#e}set position(e){this.#e=e,this.#r=!0}get transporting(){return this.#t}set transporting(e){this.#t!==e&&(this.#t=e)}advanceTo(e){this.#e=e}};var l;(function(i){i[i.Timeline=0]="Timeline",i[i.Selection=1]="Selection",i[i.PianoMode=2]="PianoMode",i[i.User=3]="User",i[i.AudioConnection=4]="AudioConnection",i[i.InstrumentHost=5]="InstrumentHost",i[i.AudioOutput=6]="AudioOutput",i[i.Capture=7]="Capture",i[i.NotesConnection=8]="NotesConnection",i[i.VoltageConnection=9]="VoltageConnection",i[i.AudioUnits=10]="AudioUnits",i[i.MidiEffectHost=11]="MidiEffectHost",i[i.AudioEffectHost=12]="AudioEffectHost",i[i.AudioBusses=13]="AudioBusses",i[i.AuxSend=14]="AuxSend",i[i.Modulation=15]="Modulation",i[i.Automation=16]="Automation",i[i.ParameterController=17]="ParameterController",i[i.MidiControl=18]="MidiControl",i[i.StepAutomation=19]="StepAutomation",i[i.Editing=20]="Editing",i[i.AudioFile=21]="AudioFile",i[i.AudioUnit=22]="AudioUnit",i[i.MarkerTrack=23]="MarkerTrack",i[i.MarkerEvents=24]="MarkerEvents",i[i.ClipCollection=25]="ClipCollection",i[i.RegionCollection=26]="RegionCollection",i[i.TrackCollection=27]="TrackCollection",i[i.Device=28]="Device",i[i.Groove=29]="Groove",i[i.ModularSetup=30]="ModularSetup",i[i.ModuleCollection=31]="ModuleCollection",i[i.ConnectionCollection=32]="ConnectionCollection",i[i.DeviceUserInterface=33]="DeviceUserInterface",i[i.NoteEvents=34]="NoteEvents",i[i.NoteEventFeature=35]="NoteEventFeature",i[i.NoteEventCollection=36]="NoteEventCollection",i[i.ValueEvents=37]="ValueEvents",i[i.ValueEventCollection=38]="ValueEventCollection",i[i.ValueInterpolation=39]="ValueInterpolation",i[i.Sample=40]="Sample"})(l||(l={}));var ga;(function(i){i[i.Pre=0]="Pre",i[i.Post=1]="Post"})(ga||(ga={}));var Zi;(function(i){i.Instrument="instrument",i.Bus="bus",i.Aux="aux",i.Output="output"})(Zi||(Zi={}));var xa=(i,e)=>{if(i===e)return 0;let t=i-e;return t===0?y(`Indices cannot be equal (${i}, ${e})`):t};var Ee=class i{static create(e,t,r){return new i(e,t,r)}#e;#t;#r;#i;#s=null;constructor(e,t,r){this.#e=e,this.#t=b.newSet(s=>s.adapter.uuid),this.#r=new ve,this.#i=e.pointerHub.catchupAndSubscribeTransactual({onAdd:s=>{this.#s=null;let o=t(s.box),n=o.indexField.subscribe(()=>{this.#s=null,this.#r.proxy.onReorder(o)}),a=this.#t.add({adapter:o,subscription:n});v(a,`Could not add ${o}`),this.#r.proxy.onAdd(o)},onRemove:s=>{this.#s=null;let o=s.box.address.uuid,{adapter:n,subscription:a}=this.#t.removeByKey(o);a.terminate(),this.#r.proxy.onRemove(n)}},r)}field(){return this.#e}subscribe(e){return this.#r.subscribe(e)}catchupAndSubscribe(e){return this.#t.forEach(({adapter:t})=>e.onAdd(t)),this.subscribe(e)}getAdapterByIndex(e){let t=ie.exactMapped(this.adapters(),e,xa,r=>r.indexField.getValue());return t===-1?m.None:m.wrap(this.adapters()[t])}getAdapterById(e){return this.#t.opt(e).map(({adapter:t})=>t)}getMinFreeIndex(){let e=this.adapters();for(let t=0;t<e.length;t++)if(e[t].indexField.getValue()>t)return t;return e.length}adapters(){return this.#s===null&&(this.#s=this.#t.values().map(({adapter:e})=>e).sort((e,t)=>e.indexField.getValue()-t.indexField.getValue())),this.#s}move(e,t){this.moveIndex(e.indexField.getValue(),t)}moveIndex(e,t){let r=this.adapters(),s=r[e];if(t<0){let o=L(e+t,0,r.length-1);for(let n=o;n<e;n++)r[n].indexField.setValue(n+1);s.indexField.setValue(o)}else if(t>1){let o=L(e+(t-1),0,r.length-1);for(let n=e;n<o;n++)r[n+1].indexField.setValue(n);s.indexField.setValue(o)}else console.warn(`moveIndex had no effect: startIndex: ${e}, delta: ${t}`)}size(){return this.#t.size()}isEmpty(){return this.size()===0}terminate(){this.#s=null,this.#t.forEach(({subscription:e})=>e.terminate()),this.#t.clear(),this.#r.terminate(),this.#i.terminate()}};var Ji;(function(i){i.create=(e,t,r,s)=>{switch(e){case"RootBox":return es.create(t,r,s);case"SelectionBox":return yi.create(t,r,s);case"UserInterfaceBox":return ts.create(t,r,s);case"TimelineBox":return rs.create(t,r,s);case"TrackBox":return Fr.create(t,r,s);case"NoteEventBox":return St.create(t,r,s);case"NoteEventRepeatBox":return is.create(t,r,s);case"NoteEventCollectionBox":return ct.create(t,r,s);case"NoteRegionBox":return nr.create(t,r,s);case"NoteClipBox":return Br.create(t,r,s);case"ValueEventBox":return Ct.create(t,r,s);case"ValueEventCollectionBox":return dt.create(t,r,s);case"ValueEventCurveBox":return Rt.create(t,r,s);case"ValueRegionBox":return ar.create(t,r,s);case"ValueClipBox":return Nr.create(t,r,s);case"AudioRegionBox":return Pr.create(t,r,s);case"AudioClipBox":return Sr.create(t,r,s);case"MarkerBox":return Cr.create(t,r,s);case"AudioFileBox":return ss.create(t,r,s);case"AudioUnitBox":return pt.create(t,r,s);case"CaptureAudioBox":return os.create(t,r,s);case"CaptureMidiBox":return ns.create(t,r,s);case"AudioBusBox":return Rr.create(t,r,s);case"AuxSendBox":return as.create(t,r,s);case"StepAutomationBox":return ls.create(t,r,s);case"GrooveShuffleBox":return us.create(t,r,s);case"UnknownAudioEffectDeviceBox":return hs.create(t,r,s);case"UnknownMidiEffectDeviceBox":return cs.create(t,r,s);case"DeviceInterfaceKnobBox":return ds.create(t,r,s);case"ModularDeviceBox":return ps.create(t,r,s);case"DeviceClashBox":return ms.create(t,r,s);case"StereoToolDeviceBox":return fs.create(t,r,s);case"DelayDeviceBox":return gs.create(t,r,s);case"RevampDeviceBox":return xs.create(t,r,s);case"ReverbDeviceBox":return ys.create(t,r,s);case"VaporisateurDeviceBox":return vs.create(t,r,s);case"NanoDeviceBox":return bs.create(t,r,s);case"PlayfieldDeviceBox":return As.create(t,r,s);case"PlayfieldSampleBox":return Mr.create(t,r,s);case"TapeDeviceBox":return ws.create(t,r,s);case"ArpeggioDeviceBox":return Es.create(t,r,s);case"PitchDeviceBox":return Fs.create(t,r,s);case"ZeitgeistDeviceBox":return Bs.create(t,r,s);case"ModularBox":return Ns.create(t,r,s);case"ModuleConnectionBox":return Ps.create(t,r,s);case"ModularAudioInputBox":return Ss.create(t,r,s);case"ModularAudioOutputBox":return Cs.create(t,r,s);case"ModuleDelayBox":return Rs.create(t,r,s);case"ModuleMultiplierBox":return Ms.create(t,r,s);case"ModuleGainBox":return Ts.create(t,r,s);default:return y(`Unknown box class '${e}'`)}},i.deserialize=(e,t)=>{let r=new ge(t),s=r.readString(),o=b.fromDataInput(r),n=i.create(s,e,o);return n.read(r),n}})(Ji||(Ji={}));var Vs=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get keyboard(){return this.getField(1)}get timeRangeInQuarters(){return this.getField(2)}get noteScale(){return this.getField(3)}get noteLabels(){return this.getField(4)}get transpose(){return this.getField(5)}initializeFields(){return{1:x.create({parent:this,fieldKey:1,fieldName:"keyboard",pointerRules:c},0),2:F.create({parent:this,fieldKey:2,fieldName:"timeRangeInQuarters",pointerRules:c},8),3:F.create({parent:this,fieldKey:3,fieldName:"noteScale",pointerRules:c},1.5),4:B.create({parent:this,fieldKey:4,fieldName:"noteLabels",pointerRules:c},!0),5:x.create({parent:this,fieldKey:5,fieldName:"transpose",pointerRules:c},0)}}};var es=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RootBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitRootBox,this)}get timeline(){return this.getField(1)}get users(){return this.getField(2)}get created(){return this.getField(3)}get groove(){return this.getField(4)}get modularSetups(){return this.getField(10)}get audioUnits(){return this.getField(20)}get audioBusses(){return this.getField(21)}get outputDevice(){return this.getField(30)}get pianoMode(){return this.getField(40)}get editingChannel(){return this.getField(111)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"timeline",pointerRules:c},l.Timeline,!0),2:I.hook({parent:this,fieldKey:2,fieldName:"users",pointerRules:{accepts:[l.User],mandatory:!0}}),3:T.create({parent:this,fieldKey:3,fieldName:"created",pointerRules:c}),4:E.create({parent:this,fieldKey:4,fieldName:"groove",pointerRules:c},l.Groove,!0),10:I.hook({parent:this,fieldKey:10,fieldName:"modularSetups",pointerRules:{accepts:[l.ModularSetup],mandatory:!1}}),20:I.hook({parent:this,fieldKey:20,fieldName:"audioUnits",pointerRules:{accepts:[l.AudioUnits],mandatory:!1}}),21:I.hook({parent:this,fieldKey:21,fieldName:"audioBusses",pointerRules:{accepts:[l.AudioBusses],mandatory:!1}}),30:I.hook({parent:this,fieldKey:30,fieldName:"outputDevice",pointerRules:{accepts:[l.AudioOutput],mandatory:!0}}),40:Vs.create({parent:this,fieldKey:40,fieldName:"pianoMode",pointerRules:c}),111:E.create({parent:this,fieldKey:111,fieldName:"editingChannel",pointerRules:c},l.Editing,!1)}}};var yi=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"SelectionBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitSelectionBox,this)}get selection(){return this.getField(1)}get selectable(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"selection",pointerRules:c},l.Selection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"selectable",pointerRules:c},l.Selection,!0)}}};var ts=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UserInterfaceBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitUserInterfaceBox,this)}get root(){return this.getField(1)}get selection(){return this.getField(10)}get editingDeviceChain(){return this.getField(21)}get editingTimelineRegion(){return this.getField(22)}get editingModularSystem(){return this.getField(23)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"root",pointerRules:c},l.User,!0),10:I.hook({parent:this,fieldKey:10,fieldName:"selection",pointerRules:{accepts:[l.Selection],mandatory:!1}}),21:E.create({parent:this,fieldKey:21,fieldName:"editingDeviceChain",pointerRules:c},l.Editing,!1),22:E.create({parent:this,fieldKey:22,fieldName:"editingTimelineRegion",pointerRules:c},l.Editing,!1),23:E.create({parent:this,fieldKey:23,fieldName:"editingModularSystem",pointerRules:c},l.Editing,!1)}}};var Ds=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get nominator(){return this.getField(1)}get denominator(){return this.getField(2)}initializeFields(){return{1:x.create({parent:this,fieldKey:1,fieldName:"nominator",pointerRules:c},4),2:x.create({parent:this,fieldKey:2,fieldName:"denominator",pointerRules:c},4)}}};var Is=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get from(){return this.getField(2)}get to(){return this.getField(3)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:c},!0),2:x.create({parent:this,fieldKey:2,fieldName:"from",pointerRules:c},0),3:x.create({parent:this,fieldKey:3,fieldName:"to",pointerRules:c},15360)}}};var Os=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get markers(){return this.getField(1)}get index(){return this.getField(10)}get enabled(){return this.getField(20)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"markers",pointerRules:{accepts:[l.MarkerTrack],mandatory:!1}}),10:x.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:c}),20:B.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:c},!0)}}};var rs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TimelineBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitTimelineBox,this)}get root(){return this.getField(1)}get signature(){return this.getField(10)}get loopArea(){return this.getField(11)}get deprecatedMarkerTrack(){return this.getField(20)}get markerTrack(){return this.getField(21)}get durationInPulses(){return this.getField(30)}get bpm(){return this.getField(31)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"root",pointerRules:{accepts:[l.Timeline],mandatory:!0}}),10:Ds.create({parent:this,fieldKey:10,fieldName:"signature",pointerRules:c}),11:Is.create({parent:this,fieldKey:11,fieldName:"loopArea",pointerRules:c}),20:I.hook({parent:this,fieldKey:20,fieldName:"deprecatedMarkerTrack",pointerRules:{accepts:[l.MarkerTrack],mandatory:!1}}),21:Os.create({parent:this,fieldKey:21,fieldName:"markerTrack",pointerRules:c}),30:x.create({parent:this,fieldKey:30,fieldName:"durationInPulses",pointerRules:c},491520),31:F.create({parent:this,fieldKey:31,fieldName:"bpm",pointerRules:c},120)}}};var Fr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TrackBox",pointerRules:{accepts:[l.Selection,l.PianoMode],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitTrackBox,this)}get tracks(){return this.getField(1)}get target(){return this.getField(2)}get regions(){return this.getField(3)}get clips(){return this.getField(4)}get index(){return this.getField(10)}get type(){return this.getField(11)}get enabled(){return this.getField(20)}get excludePianoMode(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"tracks",pointerRules:c},l.TrackCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"target",pointerRules:c},l.Automation,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"regions",pointerRules:{accepts:[l.RegionCollection],mandatory:!1}}),4:I.hook({parent:this,fieldKey:4,fieldName:"clips",pointerRules:{accepts:[l.ClipCollection],mandatory:!1}}),10:x.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"type",pointerRules:c}),20:B.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:c},!0),30:B.create({parent:this,fieldKey:30,fieldName:"excludePianoMode",pointerRules:c},!1)}}};var St=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventBox",pointerRules:{accepts:[l.Selection,l.NoteEventFeature],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get pitch(){return this.getField(20)}get velocity(){return this.getField(21)}get playCount(){return this.getField(22)}get playCurve(){return this.getField(23)}get cent(){return this.getField(24)}get chance(){return this.getField(25)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:c},l.NoteEvents,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c},240),20:x.create({parent:this,fieldKey:20,fieldName:"pitch",pointerRules:c},60),21:F.create({parent:this,fieldKey:21,fieldName:"velocity",pointerRules:c},.7874015748031497),22:x.create({parent:this,fieldKey:22,fieldName:"playCount",pointerRules:c},1),23:F.create({parent:this,fieldKey:23,fieldName:"playCurve",pointerRules:c},0),24:F.create({parent:this,fieldKey:24,fieldName:"cent",pointerRules:c},0),25:x.create({parent:this,fieldKey:25,fieldName:"chance",pointerRules:c},100)}}};var is=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventRepeatBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteEventRepeatBox,this)}get event(){return this.getField(1)}get count(){return this.getField(2)}get curve(){return this.getField(3)}get length(){return this.getField(4)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:c},l.NoteEventFeature,!0),2:x.create({parent:this,fieldKey:2,fieldName:"count",pointerRules:c},1),3:F.create({parent:this,fieldKey:3,fieldName:"curve",pointerRules:c},0),4:F.create({parent:this,fieldKey:4,fieldName:"length",pointerRules:c},1)}}};var ct=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventCollectionBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[l.NoteEvents],mandatory:!1}}),2:I.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[l.NoteEventCollection],mandatory:!0}})}}};var nr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteRegionBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get eventOffset(){return this.getField(14)}get mute(){return this.getField(15)}get label(){return this.getField(16)}get hue(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:c},l.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.NoteEventCollection,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:c}),14:x.create({parent:this,fieldKey:14,fieldName:"eventOffset",pointerRules:c}),15:B.create({parent:this,fieldKey:15,fieldName:"mute",pointerRules:c}),16:T.create({parent:this,fieldKey:16,fieldName:"label",pointerRules:c}),17:x.create({parent:this,fieldKey:17,fieldName:"hue",pointerRules:c})}}};var Mt=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get loop(){return this.getField(1)}get reverse(){return this.getField(2)}get mute(){return this.getField(3)}get speed(){return this.getField(4)}get quantise(){return this.getField(5)}get trigger(){return this.getField(6)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"loop",pointerRules:c},!0),2:B.create({parent:this,fieldKey:2,fieldName:"reverse",pointerRules:c}),3:B.create({parent:this,fieldKey:3,fieldName:"mute",pointerRules:c}),4:x.create({parent:this,fieldKey:4,fieldName:"speed",pointerRules:c}),5:x.create({parent:this,fieldKey:5,fieldName:"quantise",pointerRules:c}),6:x.create({parent:this,fieldKey:6,fieldName:"trigger",pointerRules:c})}}};var Br=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteClipBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNoteClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:c},l.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.NoteEventCollection,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:Mt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:c}),10:x.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:c}),11:B.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:c}),12:T.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:c})}}};var Ct=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get index(){return this.getField(11)}get interpolation(){return this.getField(12)}get value(){return this.getField(13)}get slope(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:c},l.ValueEvents,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"interpolation",pointerRules:{accepts:[l.ValueInterpolation],mandatory:!1}},1),13:F.create({parent:this,fieldKey:13,fieldName:"value",pointerRules:c}),14:F.create({parent:this,fieldKey:14,fieldName:"slope",pointerRules:c})}}};var dt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCollectionBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[l.ValueEvents],mandatory:!1}}),2:I.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[l.ValueEventCollection],mandatory:!0}})}}};var Rt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCurveBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueEventCurveBox,this)}get event(){return this.getField(1)}get slope(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:c},l.ValueInterpolation,!0),2:F.create({parent:this,fieldKey:2,fieldName:"slope",pointerRules:c},.5)}}};var ar=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueRegionBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:c},l.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.ValueEventCollection,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:c}),14:B.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:c}),15:T.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:c}),16:x.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:c})}}};var Nr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueClipBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitValueClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:c},l.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:c},l.ValueEventCollection,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:Mt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:c}),10:x.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:c}),11:B.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:c}),12:T.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:c})}}};var Pr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioRegionBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioRegionBox,this)}get regions(){return this.getField(1)}get file(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:c},l.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:c},l.AudioFile,!0),10:x.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:c}),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:c}),12:x.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:c}),14:B.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:c}),15:T.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:c}),16:x.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:c}),17:F.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:c})}}};var Sr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioClipBox",pointerRules:{accepts:[l.Selection,l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioClipBox,this)}get clips(){return this.getField(1)}get file(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}get gain(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:c},l.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:c},l.AudioFile,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:Mt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:c}),10:x.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:c}),11:B.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:c}),12:T.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:c}),13:x.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:c}),14:F.create({parent:this,fieldKey:14,fieldName:"gain",pointerRules:c})}}};var Cr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"MarkerBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitMarkerBox,this)}get track(){return this.getField(1)}get position(){return this.getField(2)}get plays(){return this.getField(3)}get label(){return this.getField(4)}get hue(){return this.getField(5)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"track",pointerRules:c},l.MarkerTrack,!0),2:x.create({parent:this,fieldKey:2,fieldName:"position",pointerRules:c}),3:x.create({parent:this,fieldKey:3,fieldName:"plays",pointerRules:c},1),4:T.create({parent:this,fieldKey:4,fieldName:"label",pointerRules:c}),5:x.create({parent:this,fieldKey:5,fieldName:"hue",pointerRules:c})}}};var ss=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioFileBox",pointerRules:{accepts:[l.AudioFile],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioFileBox,this)}get startInSeconds(){return this.getField(1)}get endInSeconds(){return this.getField(2)}get fileName(){return this.getField(3)}initializeFields(){return{1:x.create({parent:this,fieldKey:1,fieldName:"startInSeconds",pointerRules:c}),2:x.create({parent:this,fieldKey:2,fieldName:"endInSeconds",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"fileName",pointerRules:c})}}};var pt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioUnitBox",pointerRules:{accepts:[l.Selection,l.Automation],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioUnitBox,this)}get type(){return this.getField(1)}get collection(){return this.getField(2)}get editing(){return this.getField(3)}get index(){return this.getField(11)}get volume(){return this.getField(12)}get panning(){return this.getField(13)}get mute(){return this.getField(14)}get solo(){return this.getField(15)}get tracks(){return this.getField(20)}get midiEffects(){return this.getField(21)}get input(){return this.getField(22)}get audioEffects(){return this.getField(23)}get auxSends(){return this.getField(24)}get output(){return this.getField(25)}get capture(){return this.getField(26)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"type",pointerRules:c},"instrument"),2:E.create({parent:this,fieldKey:2,fieldName:"collection",pointerRules:c},l.AudioUnits,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[l.Editing],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:c}),12:F.create({parent:this,fieldKey:12,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:F.create({parent:this,fieldKey:13,fieldName:"panning",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),14:B.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),15:B.create({parent:this,fieldKey:15,fieldName:"solo",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),20:I.hook({parent:this,fieldKey:20,fieldName:"tracks",pointerRules:{accepts:[l.TrackCollection],mandatory:!1}}),21:I.hook({parent:this,fieldKey:21,fieldName:"midiEffects",pointerRules:{accepts:[l.MidiEffectHost],mandatory:!1}}),22:I.hook({parent:this,fieldKey:22,fieldName:"input",pointerRules:{accepts:[l.InstrumentHost,l.AudioOutput],mandatory:!1}}),23:I.hook({parent:this,fieldKey:23,fieldName:"audioEffects",pointerRules:{accepts:[l.AudioEffectHost],mandatory:!1}}),24:I.hook({parent:this,fieldKey:24,fieldName:"auxSends",pointerRules:{accepts:[l.AuxSend],mandatory:!1}}),25:E.create({parent:this,fieldKey:25,fieldName:"output",pointerRules:c},l.AudioOutput,!1),26:E.create({parent:this,fieldKey:26,fieldName:"capture",pointerRules:c},l.Capture,!1)}}};var os=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureAudioBox",pointerRules:{accepts:[l.Capture],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitCaptureAudioBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get requestChannels(){return this.getField(10)}get gainDb(){return this.getField(11)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:c}),2:T.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:c},"normal"),10:x.create({parent:this,fieldKey:10,fieldName:"requestChannels",pointerRules:c},1),11:F.create({parent:this,fieldKey:11,fieldName:"gainDb",pointerRules:c},0)}}};var ns=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureMidiBox",pointerRules:{accepts:[l.Capture],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitCaptureMidiBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get channel(){return this.getField(10)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:c}),2:T.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:c},"normal"),10:x.create({parent:this,fieldKey:10,fieldName:"channel",pointerRules:c},-1)}}};var Rr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioBusBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitAudioBusBox,this)}get collection(){return this.getField(1)}get output(){return this.getField(2)}get input(){return this.getField(3)}get enabled(){return this.getField(4)}get icon(){return this.getField(5)}get label(){return this.getField(6)}get color(){return this.getField(7)}get minimized(){return this.getField(8)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.AudioBusses,!0),2:E.create({parent:this,fieldKey:2,fieldName:"output",pointerRules:c},l.AudioOutput,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"input",pointerRules:{accepts:[l.AudioOutput],mandatory:!1}}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:T.create({parent:this,fieldKey:5,fieldName:"icon",pointerRules:c}),6:T.create({parent:this,fieldKey:6,fieldName:"label",pointerRules:c}),7:T.create({parent:this,fieldKey:7,fieldName:"color",pointerRules:c},"red"),8:B.create({parent:this,fieldKey:8,fieldName:"minimized",pointerRules:c})}}};var as=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AuxSendBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitAuxSendBox,this)}get audioUnit(){return this.getField(1)}get targetBus(){return this.getField(2)}get index(){return this.getField(3)}get routing(){return this.getField(4)}get sendGain(){return this.getField(5)}get sendPan(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"audioUnit",pointerRules:c},l.AuxSend,!0),2:E.create({parent:this,fieldKey:2,fieldName:"targetBus",pointerRules:c},l.AudioOutput,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),4:x.create({parent:this,fieldKey:4,fieldName:"routing",pointerRules:c},1),5:F.create({parent:this,fieldKey:5,fieldName:"sendGain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),6:F.create({parent:this,fieldKey:6,fieldName:"sendPan",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var ls=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StepAutomationBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitStepAutomationBox,this)}get step(){return this.getField(1)}get parameter(){return this.getField(2)}get value(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"step",pointerRules:c},l.StepAutomation,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:c},l.StepAutomation,!0),3:F.create({parent:this,fieldKey:3,fieldName:"value",pointerRules:c})}}};var us=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"GrooveShuffleBox",pointerRules:{accepts:[l.Groove],mandatory:!0}}),r)}constructor(e){super(e)}accept(e){return g(e.visitGrooveShuffleBox,this)}get label(){return this.getField(1)}get amount(){return this.getField(10)}get duration(){return this.getField(11)}initializeFields(){return{1:T.create({parent:this,fieldKey:1,fieldName:"label",pointerRules:c}),10:F.create({parent:this,fieldKey:10,fieldName:"amount",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.6),11:x.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},480)}}};var hs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownAudioEffectDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitUnknownAudioEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:T.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:c})}}};var cs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownMidiEffectDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitUnknownMidiEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:T.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:c})}}};var ds=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceInterfaceKnobBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitDeviceInterfaceKnobBox,this)}get userInterface(){return this.getField(1)}get parameter(){return this.getField(2)}get index(){return this.getField(3)}get anchor(){return this.getField(10)}get color(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"userInterface",pointerRules:c},l.DeviceUserInterface,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:c},l.ParameterController,!0),3:x.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:c}),10:F.create({parent:this,fieldKey:10,fieldName:"anchor",pointerRules:c}),11:T.create({parent:this,fieldKey:11,fieldName:"color",pointerRules:c})}}};var ks=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get elements(){return this.getField(1)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"elements",pointerRules:{accepts:[l.DeviceUserInterface],mandatory:!1}})}}};var ps=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modularSetup(){return this.getField(10)}get userInterface(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:E.create({parent:this,fieldKey:10,fieldName:"modularSetup",pointerRules:c},l.ModularSetup,!0),11:ks.create({parent:this,fieldKey:11,fieldName:"userInterface",pointerRules:c})}}};var Us=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get active(){return this.getField(1)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"active",pointerRules:{accepts:[l.StepAutomation],mandatory:!1}})}}};var Ks=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get steps(){return this.getField(10)}get length(){return this.getField(11)}get scale(){return this.getField(12)}initializeFields(){return{10:Er.create({parent:this,fieldKey:10,fieldName:"steps",pointerRules:c},e=>Us.create(e),128),11:x.create({parent:this,fieldKey:11,fieldName:"length",pointerRules:c},16),12:x.create({parent:this,fieldKey:12,fieldName:"scale",pointerRules:c},960)}}};var ms=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceClashBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitDeviceClashBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}get patterns(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},.5),11:F.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},.9),12:F.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},0),13:F.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},0),14:F.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},-3),15:F.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[l.Modulation,l.Automation,l.StepAutomation],mandatory:!1}},-3),30:Er.create({parent:this,fieldKey:30,fieldName:"patterns",pointerRules:c},e=>Ks.create(e),16)}}};var fs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StereoToolDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitStereoToolDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get panning(){return this.getField(11)}get stereo(){return this.getField(12)}get invertL(){return this.getField(13)}get invertR(){return this.getField(14)}get swap(){return this.getField(15)}get panningMixing(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"panning",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"stereo",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:B.create({parent:this,fieldKey:13,fieldName:"invertL",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),14:B.create({parent:this,fieldKey:14,fieldName:"invertR",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),15:B.create({parent:this,fieldKey:15,fieldName:"swap",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),20:x.create({parent:this,fieldKey:20,fieldName:"panningMixing",pointerRules:c},1)}}};var gs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DelayDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitDelayDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},4),11:F.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.5),12:F.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),13:F.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),14:F.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},-6),15:F.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0)}}};var vi=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get order(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),10:F.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"order",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var bi=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),10:F.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Tr=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:B.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),10:F.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var xs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RevampDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitRevampDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get highPass(){return this.getField(10)}get lowShelf(){return this.getField(11)}get lowBell(){return this.getField(12)}get midBell(){return this.getField(13)}get highBell(){return this.getField(14)}get highShelf(){return this.getField(15)}get lowPass(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:vi.create({parent:this,fieldKey:10,fieldName:"highPass",pointerRules:c}),11:bi.create({parent:this,fieldKey:11,fieldName:"lowShelf",pointerRules:c}),12:Tr.create({parent:this,fieldKey:12,fieldName:"lowBell",pointerRules:c}),13:Tr.create({parent:this,fieldKey:13,fieldName:"midBell",pointerRules:c}),14:Tr.create({parent:this,fieldKey:14,fieldName:"highBell",pointerRules:c}),15:bi.create({parent:this,fieldKey:15,fieldName:"highShelf",pointerRules:c}),16:vi.create({parent:this,fieldKey:16,fieldName:"lowPass",pointerRules:c}),17:F.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var ys=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ReverbDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitReverbDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get decay(){return this.getField(10)}get preDelay(){return this.getField(11)}get damp(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.AudioEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"decay",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.5),11:F.create({parent:this,fieldKey:11,fieldName:"preDelay",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),12:F.create({parent:this,fieldKey:12,fieldName:"damp",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.5),13:F.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),14:F.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},-3),15:F.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0)}}};var vs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"VaporisateurDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitVaporisateurDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get octave(){return this.getField(11)}get tune(){return this.getField(12)}get waveform(){return this.getField(13)}get cutoff(){return this.getField(14)}get resonance(){return this.getField(15)}get attack(){return this.getField(16)}get release(){return this.getField(17)}get filterEnvelope(){return this.getField(18)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"octave",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"tune",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:x.create({parent:this,fieldKey:13,fieldName:"waveform",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),14:F.create({parent:this,fieldKey:14,fieldName:"cutoff",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),15:F.create({parent:this,fieldKey:15,fieldName:"resonance",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),16:F.create({parent:this,fieldKey:16,fieldName:"attack",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),17:F.create({parent:this,fieldKey:17,fieldName:"release",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),18:F.create({parent:this,fieldKey:18,fieldName:"filterEnvelope",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var bs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NanoDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitNanoDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get file(){return this.getField(15)}get release(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},-3),15:E.create({parent:this,fieldKey:15,fieldName:"file",pointerRules:c},l.AudioFile,!1),20:F.create({parent:this,fieldKey:20,fieldName:"release",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.1)}}};var As=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitPlayfieldDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get samples(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:I.hook({parent:this,fieldKey:10,fieldName:"samples",pointerRules:{accepts:[l.Sample],mandatory:!1}})}}};var Mr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldSampleBox",pointerRules:{accepts:[l.Editing],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitPlayfieldSampleBox,this)}get device(){return this.getField(10)}get file(){return this.getField(11)}get midiEffects(){return this.getField(12)}get audioEffects(){return this.getField(13)}get index(){return this.getField(15)}get label(){return this.getField(20)}get icon(){return this.getField(21)}get enabled(){return this.getField(22)}get minimized(){return this.getField(23)}get mute(){return this.getField(40)}get solo(){return this.getField(41)}get exclude(){return this.getField(42)}get polyphone(){return this.getField(43)}get gate(){return this.getField(44)}get pitch(){return this.getField(45)}get sampleStart(){return this.getField(46)}get sampleEnd(){return this.getField(47)}get attack(){return this.getField(48)}get release(){return this.getField(49)}initializeFields(){return{10:E.create({parent:this,fieldKey:10,fieldName:"device",pointerRules:c},l.Sample,!0),11:E.create({parent:this,fieldKey:11,fieldName:"file",pointerRules:c},l.AudioFile,!0),12:I.hook({parent:this,fieldKey:12,fieldName:"midiEffects",pointerRules:{accepts:[l.MidiEffectHost],mandatory:!1}}),13:I.hook({parent:this,fieldKey:13,fieldName:"audioEffects",pointerRules:{accepts:[l.AudioEffectHost],mandatory:!1}}),15:x.create({parent:this,fieldKey:15,fieldName:"index",pointerRules:c},60),20:T.create({parent:this,fieldKey:20,fieldName:"label",pointerRules:c}),21:T.create({parent:this,fieldKey:21,fieldName:"icon",pointerRules:c}),22:B.create({parent:this,fieldKey:22,fieldName:"enabled",pointerRules:c},!0),23:B.create({parent:this,fieldKey:23,fieldName:"minimized",pointerRules:c},!1),40:B.create({parent:this,fieldKey:40,fieldName:"mute",pointerRules:c}),41:B.create({parent:this,fieldKey:41,fieldName:"solo",pointerRules:c}),42:B.create({parent:this,fieldKey:42,fieldName:"exclude",pointerRules:c}),43:B.create({parent:this,fieldKey:43,fieldName:"polyphone",pointerRules:c}),44:x.create({parent:this,fieldKey:44,fieldName:"gate",pointerRules:c},0),45:F.create({parent:this,fieldKey:45,fieldName:"pitch",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),46:F.create({parent:this,fieldKey:46,fieldName:"sampleStart",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},0),47:F.create({parent:this,fieldKey:47,fieldName:"sampleEnd",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),48:F.create({parent:this,fieldKey:48,fieldName:"attack",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.001),49:F.create({parent:this,fieldKey:49,fieldName:"release",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},.02)}}};var ws=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TapeDeviceBox",pointerRules:{accepts:[l.Device,l.Selection,l.Automation],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitTapeDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get flutter(){return this.getField(10)}get wow(){return this.getField(11)}get noise(){return this.getField(12)}get saturation(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.InstrumentHost,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:F.create({parent:this,fieldKey:10,fieldName:"flutter",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"wow",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:F.create({parent:this,fieldKey:12,fieldName:"noise",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),13:F.create({parent:this,fieldKey:13,fieldName:"saturation",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Es=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ArpeggioDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitArpeggioDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modeIndex(){return this.getField(10)}get numOctaves(){return this.getField(11)}get rateIndex(){return this.getField(12)}get gate(){return this.getField(13)}get repeat(){return this.getField(14)}get velocity(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:x.create({parent:this,fieldKey:10,fieldName:"modeIndex",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:x.create({parent:this,fieldKey:11,fieldName:"numOctaves",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),12:x.create({parent:this,fieldKey:12,fieldName:"rateIndex",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},9),13:F.create({parent:this,fieldKey:13,fieldName:"gate",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),14:x.create({parent:this,fieldKey:14,fieldName:"repeat",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}},1),15:F.create({parent:this,fieldKey:15,fieldName:"velocity",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Fs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PitchDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitPitchDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get semiTones(){return this.getField(10)}get cents(){return this.getField(11)}get octaves(){return this.getField(12)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:x.create({parent:this,fieldKey:10,fieldName:"semiTones",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),11:F.create({parent:this,fieldKey:11,fieldName:"cents",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}}),12:x.create({parent:this,fieldKey:12,fieldName:"octaves",pointerRules:{accepts:[l.Modulation,l.Automation,l.MidiControl],mandatory:!1}})}}};var Bs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ZeitgeistDeviceBox",pointerRules:{accepts:[l.Device,l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitZeitgeistDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get groove(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:c},l.MidiEffectHost,!0),2:x.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:c}),3:T.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:c}),4:B.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:c},!0),5:B.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:c},!1),10:E.create({parent:this,fieldKey:10,fieldName:"groove",pointerRules:c},l.Groove,!0)}}};var Ns=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularBox,this)}get collection(){return this.getField(1)}get device(){return this.getField(2)}get editing(){return this.getField(3)}get modules(){return this.getField(11)}get connections(){return this.getField(12)}get label(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.ModularSetup,!0),2:I.hook({parent:this,fieldKey:2,fieldName:"device",pointerRules:{accepts:[l.ModularSetup],mandatory:!0}}),3:I.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[l.Editing],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"modules",pointerRules:{accepts:[l.ModuleCollection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"connections",pointerRules:{accepts:[l.ConnectionCollection],mandatory:!1}}),13:T.create({parent:this,fieldKey:13,fieldName:"label",pointerRules:c})}}};var Ps=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleConnectionBox",pointerRules:c}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleConnectionBox,this)}get collection(){return this.getField(1)}get source(){return this.getField(2)}get target(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.ConnectionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"source",pointerRules:c},l.VoltageConnection,!0),3:E.create({parent:this,fieldKey:3,fieldName:"target",pointerRules:c},l.VoltageConnection,!0)}}};var ke=class i extends le{static create(e){return new i(e)}constructor(e){super(e)}get collection(){return this.getField(1)}get label(){return this.getField(2)}get x(){return this.getField(3)}get y(){return this.getField(4)}get collapsed(){return this.getField(5)}get removable(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:c},l.ModuleCollection,!0),2:T.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:c}),3:x.create({parent:this,fieldKey:3,fieldName:"x",pointerRules:c}),4:x.create({parent:this,fieldKey:4,fieldName:"y",pointerRules:c}),5:B.create({parent:this,fieldKey:5,fieldName:"collapsed",pointerRules:c},!1),6:B.create({parent:this,fieldKey:6,fieldName:"removable",pointerRules:c},!0)}}};var Ss=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioInputBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularAudioInputBox,this)}get attributes(){return this.getField(1)}get output(){return this.getField(10)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"output",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}})}}};var Cs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioOutputBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModularAudioOutputBox,this)}get attributes(){return this.getField(1)}get input(){return this.getField(10)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"input",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}})}}};var Rs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleDelayBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleDelayBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(11)}get time(){return this.getField(20)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"voltageOutput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),20:F.create({parent:this,fieldKey:20,fieldName:"time",pointerRules:{accepts:[l.ParameterController],mandatory:!1}},500)}}};var Ms=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleMultiplierBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleMultiplierBox,this)}get attributes(){return this.getField(1)}get voltageInputX(){return this.getField(10)}get voltageInputY(){return this.getField(11)}get voltageOutput(){return this.getField(12)}get multiplier(){return this.getField(20)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInputX",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"voltageInputY",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),20:F.create({parent:this,fieldKey:20,fieldName:"multiplier",pointerRules:c})}}};var Ts=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleGainBox",pointerRules:{accepts:[l.Selection],mandatory:!1}}),r)}constructor(e){super(e)}accept(e){return g(e.visitModuleGainBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(12)}get gain(){return this.getField(20)}initializeFields(){return{1:ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:c}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[l.VoltageConnection],mandatory:!1}}),20:F.create({parent:this,fieldKey:20,fieldName:"gain",pointerRules:{accepts:[l.ParameterController],mandatory:!1}})}}};var Ye;(function(i){i.write=(e,t)=>{if(t.type==="none")e.disconnect(),e.setValue(0);else if(t.type==="linear")e.disconnect(),e.setValue(1);else if(t.type==="curve"){e.setValue(0);let r=e.pointerHub.filter(l.ValueInterpolation).at(0)?.box;D(r)?(Xo(r,Rt),r.slope.setValue(t.slope)):Rt.create(e.box.graph,b.generate(),s=>{s.slope.setValue(t.slope),s.event.refer(e)})}},i.read=e=>{let t=e.pointerHub.incoming().at(0)?.box;return D(t)?(Xo(t,Rt),{type:"curve",slope:t.slope.getValue()}):e.getValue()===0?Nt.None:e.getValue()===1?Nt.Linear:y("Unknown Interpolation value")}})(Ye||(Ye={}));var Tt=class i{static Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.index-t.index;if(s!==0)return s;throw new Error(`${e} and ${t} are identical in terms of comparison`)};type="value-event";#e=new V;#t;#r;#i;#s;#o=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new Si(()=>Ye.read(this.#r.interpolation)));let r=()=>{this.#i.invalidate(),this.collection.ifSome(s=>s.onEventPropertyChanged())};this.#e.ownAll(this.#r.subscribe(X.Children,s=>{if(!this.collection.isEmpty()&&(s.type==="primitive"||s.type==="pointer")){let o=this.collection.unwrap(),n=s.address.fieldKeys,a=w.equals(this.#r.index.address.fieldKeys,n),u=w.equals(this.#r.position.address.fieldKeys,n);a||u?o.requestSorting():o.onEventPropertyChanged()}}),this.#r.interpolation.subscribe(r),this.#r.interpolation.pointerHub.subscribeImmediate({onAdd:({targetVertex:s})=>{this.#s.terminate(),this.#s=s.unwrap().box.subscribe(X.Children,r),r()},onRemove:()=>{this.#s.terminate(),this.#s=O.Empty,r()}})),this.#s=this.#r.interpolation.pointerHub.filter(l.ValueInterpolation).at(0)?.box.subscribe(X.Children,r)??O.Empty}onSelected(){this.#o=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#o=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#s.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get index(){return this.#r.index.getValue()}set interpolation(e){Ye.write(this.#r.interpolation,e)}get interpolation(){return this.#i.get()}get value(){return this.#r.value.getValue()}get isSelected(){return this.#o}get collection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ue))}copyTo(e){let t=Ct.create(this.#t.boxGraph,b.generate(),r=>{r.position.setValue(e?.position??this.position),r.index.setValue(e?.index??this.index),r.events.refer(e?.events??this.collection.unwrap().box.events),r.value.setValue(e?.value??this.value)});return Ye.write(t.interpolation,e?.interpolation??this.interpolation),this.#t.boxAdapters.adapterFor(t,i)}copyFrom(e){return this.#r.position.setValue(e?.position??this.position),this.#r.index.setValue(e?.index??this.index),this.#r.events.refer(e?.events??this.collection.unwrap().box.events),this.#r.value.setValue(e?.value??this.value),Ye.write(this.#r.interpolation,e?.interpolation??this.interpolation),this}toString(){return`{ValueEventBoxAdapter position: ${this.position} index: ${this.index}}`}};var Ue=class i{#e=new V;#t;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#s=b.newSet(s=>s.uuid),this.#o=Et.create(Tt.Comparator);let r=s=>{let o=U(s.accept({visitValueEventBox:n=>this.#t.boxAdapters.adapterFor(n,Tt)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#n())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#e.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#n()}})),this.#e.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}valueAt(e,t){return zi.valueAt(this.#o,e,t)}copy(){let e=this.#t.boxGraph,t=dt.create(e,b.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#t.boxAdapters.adapterFor(t,i)}cut(e){let t=this.events.lowerEqual(e),r=this.events.greaterEqual(e);if(r===null)return t===null?m.None:m.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t===null)return m.wrap(this.createEvent({position:e,value:r.value,index:r.index,interpolation:r.interpolation}));if(t.position===e)return m.wrap(t);if(t.interpolation.type==="none")return m.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t.interpolation.type==="linear"){let{position:s,value:o}=t,{position:n,value:a}=r;return m.wrap(this.createEvent({position:e,value:kn(o,a,(e-s)/(n-s)),index:0,interpolation:t.interpolation}))}if(t.interpolation.type==="curve"){let{position:s,value:o}=t,{position:n,value:a}=r,u=n-s,h=e-s,d=Oe.byHalf(u,o,Oe.valueAt({slope:t.interpolation.slope,steps:u,y0:o,y1:a},u*.5),a),p=Oe.valueAt(d,h),f=Oe.slopeByHalf(o,Oe.valueAt(d,h*.5),p);return Ye.write(t.box.interpolation,Nt.Curve(f)),m.wrap(this.createEvent({position:e,value:p,index:0,interpolation:Nt.Curve(Oe.slopeByHalf(p,Oe.valueAt(d,(h+u)*.5),a))}))}return y("Unknown interpolation type")}subscribeChange(e){return this.#i.subscribe(e)}createEvent({position:e,index:t,value:r,interpolation:s}){let o=Ct.create(this.#t.boxGraph,b.generate(),n=>{n.position.setValue(e),n.index.setValue(t),n.value.setValue(r),n.events.refer(this.#r.events)});return Ye.write(o.interpolation,s),this.#t.boxAdapters.adapterFor(o,Tt)}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#n()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(l.ValueEventCollection).length}get events(){return this.#o}toString(){return`{ValueEventCollectionBox ${b.toString(this.#r.address.uuid)}}`}#n(){this.#i.notify(this)}};var Vt=class{type="value-clip";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Pe(!1)),this.#s=this.#e.own(new $),this.#e.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#e.own(this.#r.subscribe(X.Children,r=>this.#a())),this.#e.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ue).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(e%this.duration,t)}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return g(e.visitValueClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Nr.create(this.#t.boxGraph,b.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ue))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{ValueClipBoxAdapter ${b.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var Xe=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get startInSeconds(){return this.#t.startInSeconds.getValue()}get endInSeconds(){return this.#t.endInSeconds.getValue()}get data(){return this.getOrCreateLoader().data}get peaks(){return this.getOrCreateLoader().peaks}getOrCreateLoader(){return this.#e.sampleManager.getOrCreate(this.#t.address.uuid)}terminate(){}};var Dt=class{type="audio-clip";#e=new V;#t;#r;#i;#s;#o;#n=m.None;#a=m.None;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Pe(!1)),this.#s=this.#e.own(new $),this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(s=>this.#t.boxAdapters.adapterFor(s.box,Xe)),this.#a.ifSome(s=>s.terminate()),this.#a=this.#n.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(X.Children,r=>this.#l()),{terminate:()=>{this.#a.ifSome(r=>r.terminate()),this.#a=m.None}}),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return g(e.visitAudioClipBoxAdapter,this)}consolidate(){}clone(e){Sr.create(this.#t.boxGraph,b.generate(),t=>{t.index.setValue(this.indexField.getValue()),t.gain.setValue(this.gain),t.label.setValue(this.label),t.hue.setValue(this.hue),t.duration.setValue(this.duration),t.mute.setValue(this.mute),t.clips.refer(this.#r.clips.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap())})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#n.unwrap("Cannot access file.")}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return m.None}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return!1}get canMirror(){return!1}toString(){return`{AudioClipBoxAdapter ${b.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#l(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var lr=class i{type="note-event";#e;#t;#r;#i=!1;constructor(e,t){this.#e=e,this.#t=t,this.#r=this.#t.subscribe(X.Children,r=>{if(!this.collection.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.collection.unwrap(),o=r.address.fieldKeys,n=w.equals(this.#t.pitch.address.fieldKeys,o),a=w.equals(this.#t.position.address.fieldKeys,o);n||a?s.requestSorting():s.onEventPropertyChanged()}})}onSelected(){this.#i=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#i=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#r.terminate()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get position(){return this.#t.position.getValue()}get duration(){return this.#t.duration.getValue()}get complete(){return this.position+this.duration}get velocity(){return this.#t.velocity.getValue()}get pitch(){return this.#t.pitch.getValue()}get cent(){return this.#t.cent.getValue()}get chance(){return this.#t.chance.getValue()}get playCount(){return this.#t.playCount.getValue()}get playCurve(){return this.#t.playCurve.getValue()}get isSelected(){return this.#i}get collection(){return this.#t.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,Ke))}normalizedPitch(){if(this.collection.isEmpty())return .5;let{minPitch:e,maxPitch:t}=this.collection.unwrap();return e===t?.5:1-(this.pitch-e)/(t-e)}copyAsNoteEvent(){return{type:"note-event",position:this.position,duration:this.duration,pitch:this.pitch,cent:this.cent,velocity:this.velocity}}copyTo(e){return this.#e.boxAdapters.adapterFor(St.create(this.#e.boxGraph,b.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.pitch.setValue(e?.pitch??this.pitch),t.playCount.setValue(e?.playCount??this.playCount),t.events.refer(e?.events??this.collection.unwrap().box.events),t.velocity.setValue(this.velocity),t.cent.setValue(this.cent),t.chance.setValue(this.chance)}),i)}computeCurveValue(e){return Ce.curveFunc(e,this.playCurve)}canConsolidate(){return this.playCount>1}consolidate(){let e=this.playCount,t=this.collection.unwrap().box.events,r=w.create(s=>{let o=Math.floor(this.computeCurveValue(s/e)*this.duration),n=Math.floor(this.computeCurveValue((s+1)/e)*this.duration);return this.copyTo({position:Math.floor(this.position+o),duration:Math.max(1,n-o),playCount:1,events:t})},e);return this.#t.delete(),r}};var Ke=class i{#e=new V;#t;#r;#i;#s;#o;#n=60;#a=60;#l=0;#u=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#s=b.newSet(s=>s.uuid),this.#o=Et.create(Ce.Comparator);let r=s=>{let o=U(s.accept({visitNoteEventBox:n=>this.#t.boxAdapters.adapterFor(n,lr)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#h())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#e.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#h()}})),this.#e.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}copy(){let e=this.#t.boxGraph,t=ct.create(e,b.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#t.boxAdapters.adapterFor(t,i)}createEvent({position:e,duration:t,velocity:r,pitch:s,chance:o,playCount:n,cent:a}){return this.#t.boxAdapters.adapterFor(St.create(this.#t.boxGraph,b.generate(),u=>{u.position.setValue(e),u.duration.setValue(t),u.velocity.setValue(r),u.pitch.setValue(s),u.chance.setValue(o),u.playCount.setValue(n),u.cent.setValue(a),u.events.refer(this.#r.events)}),lr)}subscribeChange(e){return this.#i.subscribe(e)}selectable(){return this.#o.asArray()}selectableAt(e){for(let t of this.#o.asArray())if(t.position<=e.u&&e.u<t.complete&&t.pitch===e.v)return se.one(t);return se.empty()}selectablesBetween(e,t){let r=[];for(let s of this.#o.asArray())ui.intersect1D(s.position,s.complete,e.u,t.u)&&ui.intersect1D(s.pitch,s.pitch,e.v,t.v)&&r.push(s);return r}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#h()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(l.NoteEventCollection).length}get events(){return this.#u||this.#c(),this.#o}get minPitch(){return this.#u||this.#c(),this.#n}get maxPitch(){return this.#u||this.#c(),this.#a}get maxDuration(){return this.#u||this.#c(),this.#l}toString(){return`{NoteEventCollectionBox ${b.toString(this.#r.address.uuid)}}`}#h(){this.#u=!1,this.#i.notify(this)}#c(){let e=127,t=0,r=0;this.#o.asArray().forEach(({pitch:s,duration:o})=>{e=Math.min(e,s),t=Math.max(t,s),r=Math.max(r,o)}),this.#n=e,this.#a=t,this.#l=r,this.#u=!0}};var Vr=class{type="note-clip";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Pe(!1)),this.#s=this.#e.own(new $),this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(X.Children,r=>this.#a()),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ke).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return g(e.visitNoteClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Br.create(this.#t.boxGraph,b.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get events(){return this.optCollection.map(e=>e.events)}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ke))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{NoteClipBoxAdapter ${b.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var Ls={for:(i,e)=>U(e.accept({visitNoteClipBox:t=>i.adapterFor(t,Vr),visitValueClipBox:t=>i.adapterFor(t,Vt),visitAudioClipBox:t=>i.adapterFor(t,Dt)}),"")};var $s=class{#e;#t;#r;#i;constructor(e,t){this.#e=e,this.#t=new V,this.#r=this.#t.own(new $),this.#i=this.#t.own(Ee.create(e.box.clips,r=>Ls.for(t,r),l.ClipCollection)),this.#i.subscribe({onAdd:()=>this.dispatchChange(),onRemove:()=>this.dispatchChange(),onReorder:()=>this.dispatchChange()})}get trackBoxAdapter(){return this.#e}get collection(){return this.#i}dispatchChange(){this.#r.notify()}subscribeChanges(e){return this.#r.subscribe(e)}terminate(){this.#t.terminate()}};var It=class i{type="audio-region";#e;#t;#r;#i;#s=m.None;#o=m.None;#n;#a;constructor(e,t){this.#t=e,this.#r=t,this.#e=new V,this.#i=new $,this.#n=!1,this.#a=!0,this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#s=r.targetVertex.map(s=>this.#t.boxAdapters.adapterFor(s.box,Xe)),this.#o.ifSome(s=>s.terminate()),this.#o=this.#s.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(X.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#l()):this.#l()}}),{terminate:()=>{this.#o.ifSome(r=>r.terminate()),this.#o=m.None}}),this.#a=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return g(e.visitAudioRegionBoxAdapter,this)}onSelected(){this.#n=!0,this.#l()}onDeselected(){this.#n=!1,this.#l()}get isSelected(){return this.#n}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){let e=this.#r.duration.getValue();if(e===0){let t=this.#s.unwrap("Cannot compute duration without file"),r=t.startInSeconds,o=t.endInSeconds-r;return G.secondsToPulses(o,this.#t.bpm)}return e}get complete(){return this.position+this.duration}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#s.unwrap("Cannot access file.")}get hasCollection(){return this.#s.nonEmpty()}get optCollection(){return m.None}get label(){if(this.#s.isEmpty())return"No Audio File";let e=this.#s.unwrap().getOrCreateLoader().state;return e.type==="progress"?`${Math.round(e.progress*100)}%`:e.type==="error"?String(e.reason):this.#r.label.getValue()}get isMirrowed(){return!1}get canMirror(){return!1}get trackBoxAdapter(){return this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}copyTo(e){return this.#t.boxAdapters.adapterFor(Pr.create(this.#t.boxGraph,b.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.loopOffset.setValue(e?.loopOffset??this.loopOffset),t.loopDuration.setValue(e?.loopDuration??this.loopDuration),t.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap()),t.mute.setValue(this.mute),t.hue.setValue(this.hue),t.label.setValue(this.label),t.gain.setValue(this.gain)}),i)}consolidate(){}canFlatten(e){return!1}flatten(e){return m.None}toString(){return`{AudioRegionBoxAdapter ${b.toString(this.#r.address.uuid)}}`}#l(){this.#a||(this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange())}};var Ot=class i{type="note-region";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#o=!1,this.#s=!0,this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(X.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}}),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ke).subscribeChange(()=>this.#a())}),this.#a()})),this.#s=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return g(e.visitNoteRegionBoxAdapter,this)}onSelected(){this.#o=!0,this.#a()}onDeselected(){this.#o=!1,this.#a()}get isSelected(){return this.#o}*iterateActiveNotesAt(e){let t=this.optCollection;if(t.isEmpty())return;let r=t.unwrap(),s=Te.globalToLocal(this,e);for(let o of r.events.iterateFrom(s-r.maxDuration)){if(s<o.position)return;s<o.complete&&(yield o.copyAsNoteEvent())}}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return this.optCollection.nonEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ke))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#s?m.None:this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#t.boxAdapters.adapterFor(nr.create(this.#t.boxGraph,b.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.optCollection.ifSome(e=>{let t=this.#t.boxGraph,r=ct.create(t,b.generate());e.events.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return e.length>0&&w.satisfy(e,(t,r)=>t.trackBoxAdapter.contains(r.trackBoxAdapter.unwrap()))&&e.every(t=>t.isSelected&&t instanceof i)}flatten(e){if(!this.canFlatten(e))return m.None;let t=this.#t.boxGraph,r=e.toSorted(Ft.Comparator),s=w.getFirst(r,"Internal error (no first)"),o=w.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,u=s.trackBoxAdapter.unwrap(),h=ct.create(t,b.generate()),d=Array.from(u.regions.collection.iterateRange(n,a));return d.filter(p=>p.isSelected).forEach(p=>{let f=p;for(let{resultStart:A,resultEnd:N,rawStart:S}of Te.locateLoops(f,f.position,f.complete)){let M=Math.floor(A-S),k=Math.floor(N-S);for(let K of f.optCollection.unwrap().events.iterateRange(M,k))K.copyTo({position:K.position+S-s.position,events:h.events})}}),d.forEach(({box:p})=>p.delete()),m.wrap(nr.create(t,b.generate(),p=>{p.position.setValue(n),p.duration.setValue(a-n),p.loopDuration.setValue(a-n),p.loopOffset.setValue(0),p.hue.setValue(this.hue),p.mute.setValue(this.mute),p.label.setValue(this.label),p.events.refer(h.owners),p.regions.refer(u.box.regions)}))}toString(){return`{NoteRegionBoxAdapter ${b.toString(this.#r.address.uuid)} p: ${G.toString(this.position)}, c: ${G.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var mt=class i{type="value-region";#e=new V;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=new $,this.#s=!1,this.#e.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#e.own(this.#r.subscribe(X.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}})),this.#e.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Ue).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(Te.globalToLocal(this,e),t)}incomingValue(e){return this.valueAt(this.position,e)}outgoingValue(e){let t=this.optCollection;if(t.isEmpty())return e;let r=t.unwrap();return(this.complete-this.offset)%this.loopDuration===0?r.valueAt(this.loopDuration,e):r.valueAt(Te.globalToLocal(this,this.complete),e)}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return g(e.visitValueRegionBoxAdapter,this)}onSelected(){this.#s=!0,this.#a()}onDeselected(){this.#s=!1,this.#a()}get isSelected(){return this.#s}onValuesPropertyChanged(){this.#a()}onValuesSortingChanged(){this.onValuesPropertyChanged()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Ue))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?m.None:this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#t.boxAdapters.adapterFor(ar.create(this.#t.boxGraph,b.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.events.ifSome(e=>{let t=this.#t.boxGraph,r=dt.create(t,b.generate());e.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return!1}flatten(e){if(!this.canFlatten(e))return m.None;let t=this.#t.boxGraph,r=e.toSorted(Ft.Comparator),s=w.getFirst(r,"Internal error (no first)"),o=w.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,u=s.trackBoxAdapter.unwrap(),h=dt.create(t,b.generate()),d=Array.from(u.regions.collection.iterateRange(n,a));return d.filter(p=>p.isSelected).forEach(p=>{let f=p;for(let{resultStart:A,resultEnd:N,rawStart:S}of Te.locateLoops(f,f.position,f.complete)){let M=Math.floor(A-S),k=Math.floor(N-S);for(let K of f.events.unwrap().iterateRange(M,k));}}),d.forEach(({box:p})=>p.delete()),m.wrap(ar.create(t,b.generate(),p=>{p.position.setValue(n),p.duration.setValue(a-n),p.loopDuration.setValue(a-n),p.loopOffset.setValue(0),p.hue.setValue(this.hue),p.mute.setValue(this.mute),p.label.setValue(this.label),p.events.refer(h.owners),p.regions.refer(u.box.regions)}))}toString(){return`{ValueRegionBoxAdapter ${b.toString(this.#r.address.uuid)} p: ${G.toString(this.position)}, c: ${G.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var ya=(i,e)=>i.position-e.position,va={for:(i,e)=>U(e.accept({visitNoteRegionBox:t=>i.adapterFor(t,Ot),visitAudioRegionBox:t=>i.adapterFor(t,It),visitValueRegionBox:t=>i.adapterFor(t,mt)}),"")};var qs=class{#e;#t;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=new V,this.#r=this.#t.own(new $),this.#i=Ft.create(ya),this.#s=b.newSet(r=>r.uuid),this.#t.ownAll(this.#e.box.regions.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{let s=va.for(t,r),o=this.#s.add(s);v(o,`Cannot add ${r}`),this.#i.add(s),this.dispatchChange()},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#s.removeByKey(r)),this.dispatchChange()}},l.RegionCollection))}get trackBoxAdapter(){return this.#e}get collection(){return this.#i}get adapters(){return this.#s}onIndexingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}subscribeChanges(e){return this.#r.subscribe(e)}dispatchChange(){this.#r.notify()}terminate(){this.#t.terminate()}};var we;(function(i){i[i.Rectangle=0]="Rectangle",i[i.Checkbox=1]="Checkbox",i[i.Panel=2]="Panel",i[i.MainMenu=3]="MainMenu",i[i.Dropdown=4]="Dropdown",i[i.AudioDevice=5]="AudioDevice",i[i.GuitarTab=6]="GuitarTab",i[i.Effects=7]="Effects",i[i.Flask=8]="Flask",i[i.Robot=9]="Robot",i[i.NotePad=10]="NotePad",i[i.Pencil=11]="Pencil",i[i.Waveform=12]="Waveform",i[i.Mix=13]="Mix",i[i.Adsr=14]="Adsr",i[i.Dial=15]="Dial",i[i.Record=16]="Record",i[i.Play=17]="Play",i[i.Stop=18]="Stop",i[i.Loop=19]="Loop",i[i.Timeline=20]="Timeline",i[i.Region=21]="Region",i[i.Box=22]="Box",i[i.Mixing=23]="Mixing",i[i.Vinyl=24]="Vinyl",i[i.Help=25]="Help",i[i.Metronome=26]="Metronome",i[i.System=27]="System",i[i.Add=28]="Add",i[i.Subtract=29]="Subtract",i[i.Peak=30]="Peak",i[i.LowPass=31]="LowPass",i[i.HighPass=32]="HighPass",i[i.LowShelf=33]="LowShelf",i[i.HighShelf=34]="HighShelf",i[i.RoundUp=35]="RoundUp",i[i.RoundDown=36]="RoundDown",i[i.Mute=37]="Mute",i[i.Solo=38]="Solo",i[i.Exclude=39]="Exclude",i[i.Menu=40]="Menu",i[i.Pointer=41]="Pointer",i[i.Eraser=42]="Eraser",i[i.Scissors=43]="Scissors",i[i.Tape=44]="Tape",i[i.CollapseDown=45]="CollapseDown",i[i.FileList=46]="FileList",i[i.Close=47]="Close",i[i.DragConnections=48]="DragConnections",i[i.Heart=49]="Heart",i[i.Merge=50]="Merge",i[i.SpeakerHeadphone=51]="SpeakerHeadphone",i[i.AudioBus=52]="AudioBus",i[i.DrumSet=53]="DrumSet",i[i.BassGuitar=54]="BassGuitar",i[i.Guitar=55]="Guitar",i[i.Saxophone=56]="Saxophone",i[i.Microphone=57]="Microphone",i[i.New=58]="New",i[i.Piano=59]="Piano",i[i.ExpandWidth=60]="ExpandWidth",i[i.OpenDAW=61]="OpenDAW",i[i.Automation=62]="Automation",i[i.Embed=63]="Embed",i[i.Popout=64]="Popout",i[i.Minimized=65]="Minimized",i[i.Maximized=66]="Maximized",i[i.Search=67]="Search",i[i.Generator=68]="Generator",i[i.Groove=69]="Groove",i[i.Table=70]="Table",i[i.Note=71]="Note",i[i.Exit=72]="Exit",i[i.Start=73]="Start",i[i.Duration=74]="Duration",i[i.Velocity=75]="Velocity",i[i.Random=76]="Random",i[i.Divide=77]="Divide",i[i.Curve=78]="Curve",i[i.Primary=79]="Primary",i[i.Clips=80]="Clips",i[i.NoAudio=81]="NoAudio",i[i.Unknown=82]="Unknown",i[i.UserFolder=83]="UserFolder",i[i.CloudFolder=84]="CloudFolder",i[i.Run=85]="Run",i[i.Insert=86]="Insert",i[i.ArrayDown=87]="ArrayDown",i[i.Sun=88]="Sun",i[i.Book=89]="Book",i[i.Stack=90]="Stack",i[i.EditBox=91]="EditBox",i[i.Delete=92]="Delete",i[i.Time=93]="Time",i[i.EQ=94]="EQ",i[i.Cube=95]="Cube",i[i.NanoWave=96]="NanoWave",i[i.Midi=97]="Midi",i[i.DinSlot=98]="DinSlot",i[i.VUMeter=99]="VUMeter",i[i.Playfield=100]="Playfield",i[i.Invert=101]="Invert",i[i.Headphone=102]="Headphone",i[i.Stereo=103]="Stereo",i[i.AutoGain=104]="AutoGain",i[i.AudioFile=105]="AudioFile",i[i.Tool=106]="Tool",i[i.Focus=107]="Focus",i[i.Swap=108]="Swap",i[i.Connected=109]="Connected",i[i.Disconnected=110]="Disconnected",i[i.Zeitgeist=111]="Zeitgeist"})(we||(we={}));(function(i){i.toName=e=>i[e],i.fromName=e=>i[e]??i.Rectangle})(we||(we={}));var J;(function(i){i[i.Undefined=0]="Undefined",i[i.Notes=1]="Notes",i[i.Audio=2]="Audio",i[i.Value=3]="Value"})(J||(J={}));(function(i){i.toLabelString=e=>{switch(e){case i.Audio:return"Audio";case i.Notes:return"Notes";case i.Value:return"Automation";case i.Undefined:default:return"N/A"}},i.toIconSymbol=e=>{switch(e){case i.Audio:return we.Waveform;case i.Notes:return we.Piano;case i.Value:return we.Automation;case i.Undefined:return we.AudioBus;default:return we.Unknown}}})(J||(J={}));var zs;(function(i){i.isDeviceBox=e=>"host"in e&&de(e.host,E)&&"label"in e&&de(e.label,T)&&"enabled"in e&&de(e.enabled,B)&&"minimized"in e&&de(e.minimized,B),i.isInstrumentDeviceBox=e=>i.isDeviceBox(e)&&e.host.pointerType===l.InstrumentHost,i.isEffectDeviceBox=e=>i.isDeviceBox(e)&&"index"in e&&de(e.index,x)&&(e.host.pointerType===l.MidiEffectHost||e.host.pointerType===l.AudioEffectHost),i.lookupHostField=e=>D(e)&&"host"in e&&de(e.host,E)?e.host:y(`Could not find 'host' field in '${e?.name}'`),i.lookupLabelField=e=>D(e)&&"label"in e&&de(e.label,T)?e.label:y(`Could not find 'label' field in '${e?.name}'`),i.lookupEnabledField=e=>D(e)&&"enabled"in e&&de(e.enabled,B)?e.enabled:y(`Could not find 'enabled' field in '${e?.name}'`),i.lookupMinimizedField=e=>D(e)&&"minimized"in e&&de(e.minimized,B)?e.minimized:y(`Could not find 'minimized' field in '${e?.name}'`),i.lookupIndexField=e=>D(e)&&"index"in e&&de(e.index,x)?e.index:y(`Could not find 'index' field in '${e?.name}'`)})(zs||(zs={}));var ba;(function(i){i.toTrackType=e=>{switch(e){case"midi":return J.Notes;case"audio":return J.Audio;default:return y()}}})(ba||(ba={}));var W;(function(i){i.isAny=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="bus"||e.type==="instrument"||e.type==="audio-effect"),i.isEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="audio-effect"),i.isInstrument=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="instrument",i.isMidiEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="midi-effect",i.isAudioEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="audio-effect",i.isHost=e=>e!==null&&typeof e=="object"&&"class"in e&&e.class==="device-host",i.deleteEffectDevices=e=>{if(e.length===0)return;v(w.satisfy(e,(s,o)=>s.deviceHost().address.equals(o.deviceHost().address)),"Devices are not connected to the same host");let t=e[0];(t.accepts==="audio"?t.deviceHost().audioEffects.field().pointerHub.filter(l.AudioEffectHost):t.accepts==="midi"?t.deviceHost().midiEffects.field().pointerHub.filter(l.MidiEffectHost):y("unknown type")).map(({box:s})=>zs.lookupIndexField(s)).filter(s=>e.some(o=>b.Comparator(o.uuid,s.address.uuid)!==0)).sort((s,o)=>s.getValue()-o.getValue()).forEach((s,o)=>s.setValue(o)),e.forEach(s=>s.box.delete())}})(W||(W={}));var _s=class{#e;#t=new $;#r;#i;#s;constructor(e,t){this.#e=e,this.#r=Ee.create(e.box.tracks,r=>t.adapterFor(r,me),l.TrackCollection),this.#i=b.newSet(({uuid:r})=>r),this.#s=this.#r.catchupAndSubscribe({onAdd:r=>this.#i.add({uuid:r.uuid,subscription:r.regions.subscribeChanges(()=>this.#t.notify())}),onRemove:({uuid:r})=>this.#i.removeByKey(r).subscription.terminate(),onReorder:r=>{}})}create(e,t,r){let s=this.#e.box.graph,o=this.#e.box.tracks;Fr.create(s,b.generate(),n=>{n.index.setValue(r??this.#r.getMinFreeIndex()),n.type.setValue(e),n.tracks.refer(o),n.target.refer(t)})}controls(e){return m.wrap(this.#r.adapters().find(t=>t.target.targetVertex.contains(e),!1))}delete(e){let t=this.#r.adapters(),r=t.indexOf(e);if(r===-1)return y(`Cannot delete ${e}. Does not exist.`);for(let s=r+1;s<t.length;s++)t[s].indexField.setValue(s-1);e.box.delete()}get collection(){return this.#r}values(){return this.#r.adapters()}catchupAndSubscribe(e){return this.#r.catchupAndSubscribe(e)}subscribeAnyChange(e){return this.#t.subscribe(e)}terminate(){this.#r.terminate(),this.#s.terminate(),this.#i.forEach(({subscription:e})=>e.terminate()),this.#i.clear()}};var Me=class{type="bus";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}catchupAndSubscribe(e){return e(this),this.#t.subscribe(X.Children,()=>e(this))}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get iconField(){return this.#t.icon}get labelField(){return this.#t.label}get colorField(){return this.#t.color}get iconSymbol(){return we.fromName(this.iconField.getValue()??"audio-bus")}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.output.targetVertex.unwrap("No AudioUnitBox found").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}toString(){return`{${this.constructor.name}}`}};var Hs=class{#e;#t;#r;#i;#s=O.Empty;constructor(e,t){this.#e=new V,this.#t=this.#e.own(new $),this.#r=this.#e.own(new Pe(we.Unknown)),this.#i=this.#e.own(new Pe(m.None)),this.#e.own(this.#i.subscribe(r=>{this.#s.terminate(),this.#s=r.getValue().match({none:()=>(this.#t.notify(m.None),O.Empty),some:({labelField:s,iconField:o})=>O.many(o.catchupAndSubscribe(n=>this.#r.setValue(we.fromName(n.getValue()))),s.catchupAndSubscribe(n=>this.#t.notify(m.wrap(n.getValue()))))})})),this.#e.own(e.catchupAndSubscribeTransactual({onAdd:({box:r})=>{v(this.#i.getValue().isEmpty(),"Already set");let s=r instanceof Rr?t.adapterFor(r,Me):t.adapterFor(r,W.isInstrument);this.#i.getValue().unwrapOrNull()!==s&&this.#i.setValue(m.wrap(s))},onRemove:({box:r})=>{v(this.#i.getValue().unwrap("Cannot remove").box.address.equals(r.address),"Unexpected value to remove"),this.#i.setValue(m.None)}},l.InstrumentHost,l.AudioOutput))}getValue(){return this.#i.getValue()}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.#i),this.subscribe(e)}catchupAndSubscribeLabelChange(e){return e(this.label),this.#t.subscribe(e)}catchupAndSubscribeIconChange(e){return this.#r.catchupAndSubscribe(e)}set label(e){this.getValue().ifSome(t=>t.labelField.setValue(e))}get label(){return this.getValue().map(e=>e.labelField.getValue())}set icon(e){this.getValue().ifSome(t=>t.iconField.setValue(we.toName(e)))}get icon(){return this.getValue().match({none:()=>we.Unknown,some:e=>we.fromName(e.iconField.getValue())})}get iconValue(){return this.#r}terminate(){this.#e.terminate(),this.#s.terminate()}};var te=class{#e;#t;constructor(e){this.#e=e,this.#t=new At(t=>t.address.fieldKeys,In)}terminate(){this.#t.forEach(e=>e.terminate()),this.#t.clear()}parameters(){return this.#t.values()}parameterAt(e){return this.#t.getOrThrow(e,()=>new Error(`No ParameterAdapter found at [${e}]`))}createParameter(e,t,r,s,o){let n=new ur(this.#e,e,t,r,s,o),a=this.#t.add(n);return v(a,`Could not add adapter for ${e}`),n}removeParameter(e){this.#t.removeByValue(e)}};var Dr=class{#e;#t;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=this.#r.own(new $),this.#r.own(t.targetBus.catchupAndSubscribe(()=>{this.#n.terminate(),this.#n=this.optTargetBus.match({none:()=>(this.#i.notify(m.None),O.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(m.wrap(s)))})})),this.#s=this.#r.own(new ur(this.#e,this.#t.sendPan,R.bipolar(),C.percent({unit:"%",fractionDigits:0}),"panning")),this.#o=this.#r.own(new ur(this.#e,this.#t.sendGain,R.DefaultDecibel,C.numeric({unit:"dB",fractionDigits:1}),"gain"))}catchupAndSubscribeBusChanges(e){return e(this.optTargetBus),this.#i.subscribe(e)}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get indexField(){return this.#t.index}get sendPan(){return this.#s}get sendGain(){return this.#o}get targetBus(){return this.#e.boxAdapters.adapterFor(this.#t.targetBus.targetVertex.unwrap("no audioUnit").box,Me)}get optTargetBus(){return this.#t.targetBus.targetVertex.flatMap(e=>m.wrap(e.box.accept({visitAudioBusBox:t=>this.#e.boxAdapters.adapterFor(t,Me)})))}delete(){this.#t.delete()}terminate(){this.#r.terminate(),this.#n.terminate()}};var Gs=class{#e;#t;#r;#i;#s=O.Empty;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=this.#r.own(new $),this.#r.own(e.catchupAndSubscribe(()=>{this.#s.terminate(),this.#s=this.adapter.match({none:()=>(this.#i.notify(m.None),O.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(m.wrap(s)))})}))}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.adapter),this.subscribe(e)}get adapter(){return this.#e.targetVertex.flatMap(e=>m.wrap(e.box.accept({visitAudioBusBox:t=>this.#t.adapterFor(t,Me)})))}terminate(){this.#r.terminate(),this.#s.terminate()}};var Ze=class i{static VolumeMapper=R.decibel(-96,-9,6);class="device-host";#e=new V;#t;#r;#i;#s;#o;#n;#a;#l;#u;namedParameter;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new te(this.#t)),this.#s=this.#e.own(new _s(this,this.#t.boxAdapters)),this.#o=this.#e.own(new Hs(this.#r.input.pointerHub,this.#t.boxAdapters)),this.#n=this.#e.own(Ee.create(this.#r.midiEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isMidiEffect),l.MidiEffectHost)),this.#a=this.#e.own(Ee.create(this.#r.audioEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isAudioEffect),l.AudioEffectHost)),this.#l=this.#e.own(Ee.create(this.#r.auxSends,r=>this.#t.boxAdapters.adapterFor(r,Dr),l.AuxSend)),this.#u=this.#e.own(new Gs(this.#r.output,this.#t.boxAdapters)),this.namedParameter=this.#h(t),this.#c()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get type(){return this.#r.type.getValue()}get captureBox(){return this.#r.capture.targetVertex}get tracks(){return this.#s}get input(){return this.#o}get midiEffects(){return this.#n}get audioEffects(){return this.#a}get inputAdapter(){return this.#o.getValue()}get auxSends(){return this.#l}get output(){return this.#u}get isBus(){return this.input.getValue().mapOr(e=>e.type==="bus",!1)}get isInstrument(){return this.input.getValue().mapOr(e=>e.type==="instrument",!1)}get isOutput(){return this.#r.output.targetVertex.mapOr(e=>e.box.address.equals(this.#t.rootBoxAdapter.address),!1)}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.#r.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.#r.tracks}get minimizedField(){return this.#o.getValue().unwrap().minimizedField}get isAudioUnit(){return!0}get label(){return this.#o.getValue().mapOr(e=>e.labelField.getValue(),"")}audioUnitBoxAdapter(){return this}indicesLimit(){let e=this.#t.rootBoxAdapter.audioUnits.adapters(),t=this.indexField.getValue(),r=this.type,s=t,o=t;for(;s>0&&e[s-1].type===r;)s--;for(;o<e.length-1&&e[o+1].type===r;)o++;return[s,o+1]}move(e){this.#t.rootBoxAdapter.audioUnits.move(this,e)}moveTrack(e,t){this.#s.collection.move(e,t)}deleteTrack(e){this.#s.delete(e)}toString(){return`{${this.constructor.name}}`}terminate(){this.#e.terminate()}#h(e){return{volume:this.#i.createParameter(e.volume,i.VolumeMapper,C.decible,"volume"),panning:this.#i.createParameter(e.panning,R.bipolar(),C.panning,"panning",.5),mute:this.#i.createParameter(e.mute,R.bool,C.bool,"mute"),solo:this.#i.createParameter(e.solo,R.bool,C.bool,"solo")}}#c(){let e=this.address.toString(),t=this.#r.capture.targetAddress.unwrapOrUndefined(),r=()=>`AudioUnit '${e}' must have a capture. AudioUnit is typed ${this.type} and has input ${this.#r.input.pointerHub.incoming().at(0)?.box.name}, but capture is ${t}`;v(this.type!==Zi.Instrument||this.#r.capture.targetAddress.nonEmpty(),r)}};var Ws=G.fromSignature(1,384);var me=class{#e;#t;#r;#i;#s;#o;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=this.#r.own(new $s(this,e.boxAdapters)),this.#s=this.#r.own(new qs(this,e.boxAdapters)),this.#o=this.#r.own(new Pe(-1))}catchupAndSubscribePath(e){let t=[m.None,m.None],r=()=>{t.every(s=>s.nonEmpty())?e(m.wrap(t.map(s=>s.unwrap()))):e(m.None)};return O.many(this.#n(s=>{t[0].equals(s)||(t[0]=s,r())}),this.#a(s=>{t[1].equals(s)||(t[1]=s,r())}))}set targetDeviceName(e){this.#t.target.targetVertex.ifSome(t=>{let r=t.box;if(r instanceof pt)return this.#e.boxAdapters.adapterFor(r,Ze).input.getValue().ifSome(({labelField:o})=>o.setValue(e));if("label"in r&&r.label instanceof T)return r.label.setValue(e)})}get targetDeviceName(){return this.#t.target.targetVertex.flatMap(e=>{let t=e.box;return t instanceof pt?this.#e.boxAdapters.adapterFor(t,Ze).input.label:"label"in t&&t.label instanceof T?m.wrap(t.label.getValue()):m.wrap(t.name)})}#n(e){let t=this.#t.target.targetVertex;if(t.nonEmpty()){let r=t.unwrap().box;return r instanceof pt?this.#e.boxAdapters.adapterFor(r,Ze).input.catchupAndSubscribeLabelChange(o=>e(o)):"label"in r&&r.label instanceof T?r.label.catchupAndSubscribe(s=>e(m.wrap(s.getValue()))):(e(m.wrap(r.name)),O.Empty)}return e(m.None),O.Empty}#a(e){let t=this.type;switch(t){case J.Audio:case J.Notes:return e(m.wrap(J[t])),O.Empty;case J.Value:{let r=this.#t.target.targetVertex.unwrap();if(r.isField())e(this.#e.parameterFieldAdapters.opt(r.address).map(s=>s.name));else if(r.isBox())e(m.wrap(r.name));else return y("Illegal State. Vertex is not a field nor box.");return O.Empty}case J.Undefined:return e(m.wrap("")),O.Empty;default:return e(m.None),O.Empty}}terminate(){this.#r.terminate()}get audioUnit(){return Qt(this.#t.tracks.targetVertex.unwrap().box,pt)}get target(){return this.#t.target}get clips(){return this.#i}get regions(){return this.#s}get enabled(){return this.#t.enabled}get indexField(){return this.#t.index}get type(){return this.#t.type.getValue()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get listIndex(){return this.#o.getValue()}set listIndex(e){this.#o.setValue(e)}accepts(e){switch(e.type){case"audio-clip":return this.type===J.Audio;case"note-clip":return this.type===J.Notes;case"value-clip":return this.type===J.Value;case"audio-region":return this.type===J.Audio;case"note-region":return this.type===J.Notes;case"value-region":return this.type===J.Value}}valueAt(e,t){if(!this.enabled.getValue())return t;let r=t,s=this.#e.clipSequencing.iterate(this.uuid,e,e+Ws);for(let{optClip:o,sectionFrom:n}of s)r=o.match({none:()=>{let a=this.regions.collection.lowerEqual(e,u=>!u.mute);if(a===null){let u=this.regions.collection.optAt(0);return de(u,mt)?u.incomingValue(t):t}else if(de(a,mt))return e<a.complete?a.valueAt(e,t):a.outgoingValue(t);return t},some:a=>n===e&&de(a,Vt)?a.valueAt(e,t):t});return r}};var Aa=[l.Automation,l.Modulation,l.MidiControl,l.ParameterController],ur=class{#e;#t;#r;#i;#s;#o;#n=new V;#a;#l;#u=m.None;#h=m.None;#c=null;#d=!1;constructor(e,t,r,s,o,n){this.#e=e,this.#t=t,this.#r=r,this.#i=s,this.#s=o,this.#o=n??0,this.#n.own(this.#e.parameterFieldAdapters.register(this)),this.#a=this.#n.own(new $),this.#l=new ve,this.#n.own(this.#t.subscribe(()=>this.#a.notify(this))),this.#n.own(this.#t.pointerHub.catchupAndSubscribeTransactual({onAdd:a=>{this.#l.proxy.onControlSourceAdd(vn(a.pointerType)),a.box.accept({visitTrackBox:u=>{v(this.#u.isEmpty(),"Already assigned");let h=this.#e.boxAdapters.adapterFor(u,me);this.#u=m.wrap(h),this.#e.isMainThread&&(this.#h=m.wrap(this.#e.liveStreamReceiver.subscribeFloat(this.#t.address,d=>{this.#c!==d&&(this.#c=d,this.#a.notify(this))})))}})},onRemove:a=>{this.#l.proxy.onControlSourceRemove(vn(a.pointerType)),a.box.accept({visitTrackBox:u=>{v(this.#u.unwrapOrNull()?.address?.equals(u.address)===!0,`Unknown ${u}`),this.#u=m.None,this.#e.isMainThread&&(this.#h.ifSome(h=>h.terminate()),this.#h=m.None,this.#c=null,this.#a.notify(this))}})}},...Aa)),t.getValue()!==r.clamp(t.getValue())&&console.warn(`${o} (${t.getValue()}) is out of bounds`,r)}registerMidiControl(){return this.#l.proxy.onControlSourceAdd("midi"),this.#d=!0,{terminate:()=>{this.#d=!1,this.#l.proxy.onControlSourceRemove("midi")}}}get field(){return this.#t}get valueMapping(){return this.#r}get stringMapping(){return this.#i}get name(){return this.#s}get anchor(){return this.#o}get type(){return this.#t.type}get address(){return this.#t.address}get track(){return this.#u}valueAt(e){let t=this.#u;if(t.nonEmpty()){let r=t.unwrap();if(r.enabled)return this.valueMapping.y(r.valueAt(e,this.getUnitValue()))}return this.getValue()}subscribe(e){return this.#a.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}catchupAndSubscribeControlSources(e){return this.#d&&e.onControlSourceAdd("midi"),this.#t.pointerHub.filter(...Aa).forEach(t=>e.onControlSourceAdd(vn(t.pointerType))),this.#l.subscribe(e)}getValue(){return this.#t.getValue()}setValue(e){this.#t.setValue(e)}setUnitValue(e){this.setValue(this.#r.y(e))}getUnitValue(){return this.#r.x(this.getValue())}getControlledValue(){return this.#r.y(this.getControlledUnitValue())}getControlledUnitValue(){return this.#c??this.getUnitValue()}getControlledPrintValue(){return this.#i.x(this.getControlledValue())}getPrintValue(){return this.#i.x(this.getValue())}setPrintValue(e){let t=this.#i.y(e);t.type==="unitValue"?this.setUnitValue(L(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#r.clamp(this.#t.initValue))}terminate(){this.#h.ifSome(e=>e.terminate()),this.#h=m.None,this.#n.terminate()}},vn=i=>{switch(i){case l.Automation:return"automated";case l.Modulation:return"modulated";case l.MidiControl:return"midi";case l.ParameterController:return"external";default:return y(`${i.toString()} is an unknown pointer type`)}};var js=class{#e;#t;#r;constructor(e,t,r){this.#e=b.newSet(s=>s.uuid),this.#t=new ve,this.#r=e.catchupAndSubscribeTransactual({onAdd:s=>{let o=t(s.box),n=this.#e.add(o);v(n,`Could not add ${o}`),this.#t.proxy.onAdd(o)},onRemove:s=>{let o=s.box.address.uuid;this.#t.proxy.onRemove(this.#e.removeByKey(o))}},r)}subscribe(e){return this.#t.subscribe(e)}catchupAndSubscribe(e){return this.#e.forEach(t=>e.onAdd(t)),this.subscribe(e)}adapters(){return this.#e.values()}size(){return this.#e.size()}isEmpty(){return this.size()===0}terminate(){this.#e.clear(),this.#t.terminate(),this.#r.terminate()}};var ft=class i{static OffsetFractions=ze.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static OffsetStringMapping=C.indices("",this.OffsetFractions.map(([e,t])=>`${e}/${t}`));type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{delay:this.#r.createParameter(e.delay,R.linearInteger(0,i.OffsetFractions.length-1),i.OffsetStringMapping,"delay"),feedback:this.#r.createParameter(e.feedback,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"feedback"),cross:this.#r.createParameter(e.cross,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"cross"),filter:this.#r.createParameter(e.filter,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter",.5),dry:this.#r.createParameter(e.dry,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var Ir=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{decay:this.#r.createParameter(e.decay,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"Room-Size"),preDelay:this.#r.createParameter(e.preDelay,R.exponential(.001,.5),C.numeric({unit:"s",fractionDigits:1,unitPrefix:!0}),"Pre-Delay"),damp:this.#r.createParameter(e.damp,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"damping"),filter:this.#r.createParameter(e.filter,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter"),dry:this.#r.createParameter(e.dry,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var Or=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get spectrum(){return this.#t.address.append(4095)}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{highPass:wa(this.#r,e.highPass,"High-Pass"),lowShelf:Ea(this.#r,e.lowShelf,"Low-Shelf"),lowBell:bn(this.#r,e.lowBell,"Low-Bell"),midBell:bn(this.#r,e.midBell,"Mid-Bell"),highBell:bn(this.#r,e.highBell,"High-Bell"),highShelf:Ea(this.#r,e.highShelf,"High-Shelf"),lowPass:wa(this.#r,e.lowPass,"Low-Pass")}}},An=R.exponential(20,2e4),Fa=R.linear(-24,24),Ba=R.exponential(.01,10),wa=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,An,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),order:i.createParameter(e.order,R.linearInteger(1,4),C.indices("db",["12","24","36","48"]),`${t} Order`),q:i.createParameter(e.q,Ba,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)}),Ea=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,An,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,Fa,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5)}),bn=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,An,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,Fa,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5),q:i.createParameter(e.q,Ba,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)});var hr=class{static Comparator=(e,t)=>e.position-t.position;type="marker-event";#e=new V;#t;#r;constructor(e,t){this.#t=e,this.#r=t,this.#e.own(this.#r.subscribe(X.Children,r=>{if(!this.trackAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackAdapter.unwrap();this.#r.position.address.equals(r.address)?s.onSortingChanged():s.dispatchChange()}}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get plays(){return this.#r.plays.getValue()}get hue(){return this.#r.hue.getValue()}get label(){return this.#r.label.getValue()}get trackAdapter(){return this.#r.track.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Je).markerTrack)}terminate(){this.#e.terminate()}toString(){return`{MarkerBoxAdapter ${b.toString(this.#r.address.uuid).substring(0,4)}, plays: ${this.plays}`}};var Qs=class{#e;#t;changeNotifier;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=t,this.changeNotifier=new $,this.#r=b.newSet(r=>r.uuid),this.#i=Et.create(hr.Comparator),this.#s=this.#t.markers.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{if(r instanceof Cr){let s=this.#e.boxAdapters.adapterFor(r,hr),o=this.#r.add(s);v(o,"Could not add adapter"),this.#i.add(s),this.dispatchChange()}},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#r.removeByKey(r)),this.dispatchChange()}})}subscribe(e){return this.changeNotifier.subscribe(e)}get context(){return this.#e}get enabled(){return this.#t.enabled.getValue()}get events(){return this.#i}get object(){return this.#t}dispatchChange(){this.changeNotifier.notify()}onSortingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}terminate(){this.#s.terminate()}};var Je=class{#e;#t;constructor(e,t){this.#e=t,this.#t=new Qs(e,this.#e.markerTrack)}terminate(){}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get markerTrack(){return this.#t}};var kt=class{#e;constructor(e,t){this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get source(){return this.#e.source.targetVertex.unwrap("Insufficient Vertex")}get target(){return this.#e.target.targetVertex.unwrap("Insufficient Vertex")}terminate(){}};var Le=class{#e;#t;#r;#i;#s;#o=!1;constructor(e,t){this.#e=e,this.#t=t,this.#r=new V,this.#i=t.attributes,this.#s=this.#r.own(new te(e))}get inputs(){throw new Error("Method not implemented.")}get outputs(){throw new Error("Method not implemented.")}own(e){return this.#r.own(e)}ownAll(...e){this.#r.ownAll(...e)}onSelected(){this.#o=!0}onDeselected(){this.#o=!1}isSelected(){return this.#o}get box(){return this.#t}get attributes(){return this.#i}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get parameters(){return this.#s}get modular(){return this.#e.boxAdapters.adapterFor(this.#t.attributes.collection.targetVertex.unwrap().box,Ut)}terminate(){this.#r.terminate()}};var Be;(function(i){i.Input="input",i.Output="output"})(Be||(Be={}));var Ne=class i{static create(e,t,r,s){return new i(e,t,r,s??t.fieldName)}#e;#t;#r;#i;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#r=r,this.#i=s}matches(e){return this.direction!==e.direction&&this.field.pointerRules.accepts.some(t=>e.field.pointerRules.accepts.some(r=>r===t))}get connections(){return this.#t.pointerHub.isEmpty()?w.empty():this.#t.pointerHub.filter(l.VoltageConnection).map(({box:e})=>this.#e.adapterFor(e,kt))}get field(){return this.#t}get address(){return this.#t.address}get direction(){return this.#r}get name(){return this.#i}toString(){return`{ModuleConnectorAdapter address: ${this.#t.address.toString()}, direction: ${this.#r}}`}};var kr=class extends Le{#e;#t;#r;constructor(e,t){super(e,t),this.#e=this.parameters.createParameter(t.time,R.exponential(1,1e4),C.numeric({unit:"ms"}),"Time"),this.#t=Ne.create(e.boxAdapters,t.voltageInput,Be.Input,"Input"),this.#r=Ne.create(e.boxAdapters,t.voltageOutput,Be.Output,"Output")}get parameterTime(){return this.#e}get voltageInput(){return this.#t}get voltageOutput(){return this.#r}get inputs(){return[this.#t]}get outputs(){return[this.#r]}};var Ur=class extends Le{#e;constructor(e,t){super(e,t),this.#e=Ne.create(e.boxAdapters,t.input,Be.Input,"Input")}get voltageInput(){return this.#e}get inputs(){return[this.#e]}get outputs(){return w.empty()}};var Kr=class extends Le{#e;#t;#r;constructor(e,t){super(e,t),this.#e=this.parameters.createParameter(t.gain,R.DefaultDecibel,C.numeric({unit:"db"}),"Gain"),this.#t=Ne.create(e.boxAdapters,t.voltageInput,Be.Input,"Input"),this.#r=Ne.create(e.boxAdapters,t.voltageOutput,Be.Output,"Output")}get parameterGain(){return this.#e}get voltageInput(){return this.#t}get voltageOutput(){return this.#r}get inputs(){return[this.#t]}get outputs(){return[this.#r]}};var Lr=class extends Le{#e;#t;#r;constructor(e,t){super(e,t),this.#e=Ne.create(e.boxAdapters,t.voltageInputX,Be.Input,"X"),this.#t=Ne.create(e.boxAdapters,t.voltageInputY,Be.Input,"Y"),this.#r=Ne.create(e.boxAdapters,t.voltageOutput,Be.Output,"Result")}get inputs(){return[this.#e,this.#t]}get outputs(){return[this.#r]}};var $r=class extends Le{#e;constructor(e,t){super(e,t),this.#e=Ne.create(e.boxAdapters,t.output,Be.Output,"Output")}get voltageOutput(){return this.#e}get inputs(){return w.empty()}get outputs(){return[this.#e]}};var qr;(function(i){i.isVertexOfModule=e=>e.box.accept({visitModuleGainBox:()=>!0,visitModuleDelayBox:()=>!0,visitModuleMultiplierBox:()=>!0,visitModularAudioInputBox:()=>!0,visitModularAudioOutputBox:()=>!0})??!1,i.adapterFor=(e,t)=>U(t.accept({visitModuleGainBox:r=>e.adapterFor(r,Kr),visitModuleDelayBox:r=>e.adapterFor(r,kr),visitModuleMultiplierBox:r=>e.adapterFor(r,Lr),visitModularAudioInputBox:r=>e.adapterFor(r,$r),visitModularAudioOutputBox:r=>e.adapterFor(r,Ur)}),`Could not find ModuleAdapter for ${t.name}`)})(qr||(qr={}));var zr=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get moduleAdapter(){return qr.adapterFor(this.#e.boxAdapters,this.#r.box)}get parameterAdapter(){return this.moduleAdapter.parameters.parameterAt(this.#r.address.fieldKeys)}get#r(){return this.#t.parameter.targetVertex.unwrap("Parameter not assigned")}terminate(){}};var Kt=class{type="audio-effect";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}parameterAt(e){return y("Not yet implemented")}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}modular(){return this.#e.boxAdapters.adapterFor(this.#t.modularSetup.targetVertex.unwrap("No Modular found").box,Ut)}elements(){return this.#t.userInterface.elements.pointerHub.filter(l.DeviceUserInterface).map(e=>this.#e.boxAdapters.adapterFor(e.box,zr))}terminate(){}};var Ut=class{#e=new V;#t;#r;#i;#s;#o;constructor(e,t){this.#r=e,this.#i=t,this.#t=this.#e.own(new ve),this.#s=b.newSet(a=>a.uuid),this.#o=b.newSet(a=>a.uuid);let r=a=>{let u=qr.adapterFor(this.#r.boxAdapters,a.box);this.#s.add(u)&&this.#t.proxy.onModuleAdded(u)},s=a=>this.#t.proxy.onModuleRemoved(this.#s.removeByKey(a.address.uuid)),o=a=>{let u=this.#r.boxAdapters.adapterFor(a.box,kt);this.#o.add(u)&&this.#t.proxy.onConnectionAdded(u)},n=a=>this.#t.proxy.onConnectionRemoved(this.#o.removeByKey(a.address.uuid));this.#i.modules.pointerHub.filter(l.ModuleCollection).forEach(r),this.#i.connections.pointerHub.filter(l.ConnectionCollection).forEach(o),this.#e.own(this.#i.modules.pointerHub.subscribeTransactual({onAdd:r,onRemove:s},l.ModuleCollection)),this.#e.own(this.#i.connections.pointerHub.subscribeTransactual({onAdd:o,onRemove:n},l.ConnectionCollection))}catchupAndSubscribe(e){return Yo(e.onModuleAdded,t=>this.#s.forEach(r=>t(r))),Yo(e.onConnectionAdded,t=>this.#o.forEach(r=>t(r))),this.#t.subscribe(e)}get box(){return this.#i}get address(){return this.#i.address}get uuid(){return this.#i.address.uuid}get editingField(){return this.#i.editing}get labelField(){return this.#i.label}get modules(){return this.#s.values()}get connections(){return this.#o.values()}get device(){return this.#r.boxAdapters.adapterFor(U(this.#i.device.pointerHub.incoming().at(0),"No device found").box,Kt)}terminate(){console.debug(`terminate ${this}`),this.#e.terminate()}};var _r=class i{static Durations=[[1,8],[1,4],[1,4],[1,2],[1,1],[2,1],[4,1],[8,1],[16,1]];static DurationPPQNs=i.Durations.map(([e,t])=>G.fromSignature(e,t));static DurationStrings=i.Durations.map(([e,t])=>`${e}/${t}`);type="groove-adapter";#e=new V;#t;#r;#i;namedParameter;#s=new Li({duration:()=>this.#n,fx:e=>sn(e,this.#o),fy:e=>sn(e,1-this.#o)});#o=0;#n=G.SemiQuaver*2;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new te(this.#t)),this.namedParameter=this.#a(t),this.#e.ownAll(this.namedParameter.duration.catchupAndSubscribe(r=>this.#n=r.getValue()),this.namedParameter.amount.catchupAndSubscribe(r=>this.#o=On(r.getValue(),.01)))}unwarp(e){return this.#s.unwarp(e)}warp(e){return this.#s.warp(e)}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#e.terminate()}#a(e){return{duration:this.#i.createParameter(e.duration,R.values(i.DurationPPQNs),C.values("",i.DurationPPQNs,i.DurationStrings),"duration"),amount:this.#i.createParameter(e.amount,R.unipolar(),C.percent({fractionDigits:0}),"amount")}}};var Lt=class{#e;#t;#r;#i;#s;#o=new V;#n;#a=m.None;constructor(e,t,r,s,o){this.#e=e,this.#t=t,this.#r=r,this.#i=s,this.#s=o??0,this.#n=this.#o.own(new $),this.#o.own(this.#e.subscribe(()=>this.#n.notify(this))),e.getValue()!==t.clamp(e.getValue())&&console.warn(`${s} (${e.getValue()}) is out of bounds`,t)}get field(){return this.#e}get valueMapping(){return this.#t}get stringMapping(){return this.#r}get name(){return this.#i}get anchor(){return this.#s}get type(){return this.#e.type}get address(){return this.#e.address}get track(){return this.#a}subscribe(e){return this.#n.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}getValue(){return this.#e.getValue()}setValue(e){this.#e.setValue(this.#t.clamp(e))}setUnitValue(e){this.setValue(this.#t.y(e))}getUnitValue(){return this.#t.x(this.getValue())}getPrintValue(){return this.#r.x(this.getValue())}setPrintValue(e){let t=this.#r.y(e);t.type==="unitValue"?this.setUnitValue(L(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#t.clamp(this.#e.initValue))}terminate(){this.#o.terminate()}};var Ys=class{#e;#t;#r;#i;#s;#o;constructor(e){this.#e=e,this.#t=new Lt(this.#e.keyboard,R.values([88,76,61,49]),C.numeric({fractionDigits:1}),"Keyboard Type"),this.#r=new Lt(this.#e.timeRangeInQuarters,R.exponential(1,64),C.numeric({fractionDigits:1}),"Time-Range"),this.#i=new Lt(this.#e.noteScale,R.exponential(.5,2),C.numeric({fractionDigits:1}),"Note Scale"),this.#s=new Lt(this.#e.noteLabels,R.bool,C.bool,"Note Labels"),this.#o=new Lt(this.#e.transpose,R.linearInteger(-48,48),C.numeric({fractionDigits:0}),"Transpose")}subscribe(e){return this.#e.box.subscribe(X.Children,()=>e(this))}get object(){return this.#e}get keyboard(){return this.#t}get timeRangeInQuarters(){return this.#r}get noteScale(){return this.#i}get noteLabels(){return this.#s}get transpose(){return this.#o}};var Hr=class{#e;#t;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=t,this.#r=Ee.create(this.#t.audioUnits,r=>this.#e.boxAdapters.adapterFor(r,Ze),l.AudioUnits),this.#i=new js(this.#t.audioBusses.pointerHub,r=>this.#e.boxAdapters.adapterFor(r,Me),l.AudioBusses),this.#s=new Ys(this.#t.pianoMode)}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get audioBusses(){return this.#i}get audioUnits(){return this.#r}get clips(){return this.#r.adapters().flatMap(e=>e.tracks.collection.adapters()).flatMap(e=>e.clips.collection.adapters())}get groove(){return this.#e.boxAdapters.adapterFor(this.#t.groove.targetVertex.unwrap("no groove").box,_r)}get timeline(){return this.#e.boxAdapters.adapterFor(this.#t.timeline.targetVertex.unwrap("no timeline").box,Je)}get pianoMode(){return this.#s}get created(){return new Date(this.#t.created.getValue())}terminate(){this.#r.terminate()}};var Gr=class{type="instrument";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Audio}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!1}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{flutter:this.#r.createParameter(e.flutter,R.unipolar(),C.percent(),"flutter"),wow:this.#r.createParameter(e.wow,R.unipolar(),C.percent(),"wow"),noise:this.#r.createParameter(e.noise,R.unipolar(),C.percent(),"noise"),saturation:this.#r.createParameter(e.saturation,R.unipolar(),C.percent(),"saturation")}}};var Wr=class{type="instrument";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),octave:this.#r.createParameter(e.octave,R.linearInteger(-3,3),C.numeric(),"octave",.5),tune:this.#r.createParameter(e.tune,R.linear(-1200,1200),C.numeric({unit:"cent",fractionDigits:0}),"tune",.5),waveform:this.#r.createParameter(e.waveform,R.linearInteger(0,3),C.indices("",["sine","triangle","sawtooth","square"]),"waveform"),cutoff:this.#r.createParameter(e.cutoff,R.exponential(20,18e3),C.numeric({unit:"Hz"}),"cutoff"),resonance:this.#r.createParameter(e.resonance,R.exponential(.1,20),C.numeric({unit:"q",fractionDigits:1}),"resonance"),attack:this.#r.createParameter(e.attack,R.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"attack"),release:this.#r.createParameter(e.release,R.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"release"),filterEnvelope:this.#r.createParameter(e.filterEnvelope,R.linear(-.5,.5),C.percent(),"filter env",.5)}}};var $t=class i{static RateFractions=ze.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static RateStringMapping=C.indices("",this.RateFractions.map(([e,t])=>`${e}/${t}`));type="midi-effect";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}parameterAt(e){return this.#r.parameterAt(e)}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{modeIndex:this.#r.createParameter(e.modeIndex,R.linearInteger(0,2),C.indices("",["Up","Down","UpDown"]),"mode"),numOctaves:this.#r.createParameter(e.numOctaves,R.linearInteger(1,5),C.numeric({unit:"",fractionDigits:0}),"Octaves"),rate:this.#r.createParameter(e.rateIndex,R.linearInteger(0,i.RateFractions.length-1),i.RateStringMapping,"Rate"),gate:this.#r.createParameter(e.gate,R.linear(0,2),C.percent({fractionDigits:0}),"Gate"),repeat:this.#r.createParameter(e.repeat,R.linearInteger(1,16),C.numeric({fractionDigits:0}),"Repeat"),velocity:this.#r.createParameter(e.velocity,R.bipolar(),C.percent({fractionDigits:0,bipolar:!1}),"Velocity")}}};var jr=class{type="midi-effect";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{octaves:this.#r.createParameter(e.octaves,R.linearInteger(-7,7),C.numeric({unit:"oct",fractionDigits:0}),"octaves"),semiTones:this.#r.createParameter(e.semiTones,R.linearInteger(-36,36),C.numeric({unit:"st",fractionDigits:0}),"semi-tones"),cent:this.#r.createParameter(e.cents,R.linear(-50,50),C.numeric({unit:"cents",fractionDigits:1}),"cents")}}};var Qr=class{type="instrument";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),release:this.#r.createParameter(e.release,R.exponential(.001,8),C.numeric({unit:"s",fractionDigits:3}),"release")}}};var Yr=class{class="device-host";accepts=!1;type="instrument";#e=new V;#t;#r;#i;#s;#o;namedParameter;#n=m.None;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(Ee.create(this.#r.midiEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isMidiEffect),l.MidiEffectHost)),this.#s=this.#e.own(Ee.create(this.#r.audioEffects,r=>this.#t.boxAdapters.adapterFor(r,W.isAudioEffect),l.AudioEffectHost)),this.#o=this.#e.own(new te(this.#t)),this.namedParameter=this.#a(t),this.#e.own(this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(({box:s})=>this.#t.boxAdapters.adapterFor(s,Xe)),this.#n.unwrapOrNull()?.getOrCreateLoader()}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get peakAddress(){return this.#r.address.append(1001)}get indexField(){return this.#r.index}get gate(){return this.#r.gate.getValue()}get exclude(){return this.#r.exclude.getValue()}get label(){return`${this.device().labelField.getValue()} > ${this.#n.mapOr(e=>e.box.fileName.getValue(),"No file")}`}get iconField(){return this.#r.icon}get defaultTrackType(){return J.Notes}get acceptsMidiEvents(){return!0}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.audioUnitBoxAdapter().box.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.audioUnitBoxAdapter().box.tracks}get isAudioUnit(){return!1}file(){return this.#n}fileUUID(){return this.#r.file.targetAddress.unwrap().uuid}resetParameters(){this.#r.mute.reset(),this.#r.solo.reset(),this.#r.exclude.reset(),this.#r.polyphone.reset(),this.#r.pitch.reset(),this.#r.attack.reset(),this.#r.release.reset(),this.#r.sampleStart.reset(),this.#r.sampleEnd.reset(),this.#r.gate.reset()}copyToIndex(e){Mr.create(this.#r.graph,b.generate(),t=>{t.file.refer(this.#r.file.targetVertex.unwrap()),t.device.refer(this.#r.device.targetVertex.unwrap()),t.index.setValue(e),t.mute.setValue(this.#r.mute.getValue()),t.solo.setValue(this.#r.solo.getValue()),t.sampleStart.setValue(this.#r.sampleStart.getValue()),t.sampleEnd.setValue(this.#r.sampleEnd.getValue()),t.attack.setValue(this.#r.attack.getValue()),t.release.setValue(this.#r.release.getValue()),t.pitch.setValue(this.#r.pitch.getValue()),t.exclude.setValue(this.#r.exclude.getValue()),t.gate.setValue(this.#r.gate.getValue())})}get midiEffects(){return this.#i}get inputAdapter(){return m.wrap(this)}get audioEffects(){return this.#s}get labelField(){return this.#r.label}get enabledField(){return this.#r.enabled}get minimizedField(){return this.#r.minimized}device(){return this.#t.boxAdapters.adapterFor(this.#r.device.targetVertex.unwrap().box,qt)}deviceHost(){return this.device().deviceHost()}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#e.terminate()}#a(e){return{gate:this.#o.createParameter(e.gate,R.linearInteger(0,2),C.indices("",["Off","On","Loop"]),"Gate"),mute:this.#o.createParameter(e.mute,R.bool,C.bool,"Mute"),solo:this.#o.createParameter(e.solo,R.bool,C.bool,"Solo"),polyphone:this.#o.createParameter(e.polyphone,R.bool,C.bool,"Polyphone"),exclude:this.#o.createParameter(e.exclude,R.bool,C.bool,"Exclude"),pitch:this.#o.createParameter(e.pitch,R.linear(-1200,1200),C.numeric({unit:"cents",bipolar:!0,fractionDigits:0}),"Pitch",0),sampleStart:this.#o.createParameter(e.sampleStart,R.unipolar(),C.percent(),"Start",0),sampleEnd:this.#o.createParameter(e.sampleEnd,R.unipolar(),C.percent(),"End",1),attack:this.#o.createParameter(e.attack,R.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Attack"),release:this.#o.createParameter(e.release,R.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Release")}}};var qt=class{type="instrument";accepts="midi";#e;#t;#r;#i;constructor(e,t){this.#e=e,this.#t=t,this.#r=Ee.create(t.samples,r=>e.boxAdapters.adapterFor(r,Yr),l.Sample),this.#i=new te(this.#e)}reset(){this.#r.adapters().forEach(e=>e.box.delete())}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get notesAddress(){return this.#t.address.append(1e3)}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return J.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}get samples(){return this.#r}get context(){return this.#e}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#i.terminate()}};var Xr=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new te(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.decibel(-72,0,12),C.numeric({unit:"db",fractionDigits:1}),"Volume"),panning:this.#r.createParameter(e.panning,R.bipolar(),C.panning,"Panning",.5),stereo:this.#r.createParameter(e.stereo,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"stereo",.5),invertL:this.#r.createParameter(e.invertL,R.bool,C.bool,"Invert Left"),invertR:this.#r.createParameter(e.invertR,R.bool,C.bool,"Invert Right"),swap:this.#r.createParameter(e.swap,R.bool,C.bool,"Swap")}}};var cr;(function(i){i.checkType=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="groove-adapter"})(cr||(cr={}));var Zr=class{type="midi-effect";accepts="midi";#e;#t;constructor(e,t){this.#e=e,this.#t=t,this.groove()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}groove(){return this.#e.boxAdapters.adapterFor(this.#t.groove.targetVertex.unwrap("no groove").box,cr.checkType)}catchupAndSubscribeGroove(e){return this.#t.groove.catchupAndSubscribe(t=>e(this.#e.boxAdapters.adapterFor(t.targetVertex.unwrap("No groove found").box,cr.checkType)))}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var Jr=class{type="audio-effect";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get commentField(){return this.#t.comment}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var ei=class{type="midi-effect";accepts="midi";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get commentField(){return this.#t.comment}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,W.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var Xs=class{#e;#t;#r;#i;constructor(e){this.#e=e,this.#t=b.newSet(t=>t.uuid),this.#r=new Set,this.#i=this.#e.boxGraph.subscribeToAllUpdates({onUpdate:t=>{if(t.type==="delete"){let r=this.#t.getOrNull(t.uuid);D(r)&&(this.#r.add(r.box),this.#t.removeByValue(r).terminate())}}})}terminate(){this.#t.values().forEach(e=>e.terminate()),this.#t.clear(),this.#i.terminate()}adapterFor(e,t){if(this.#r.has(e))return y(`Cannot resolve adapter for already deleted box: ${e}`);let r=this.#t.getOrNull(e.address.uuid);if(r===null){r=this.#s(e);let s=this.#t.add(r);v(s,`Could not add adapter for ${e}`)}return typeof t=="function"?Object.hasOwn(t,"prototype")?r instanceof t?r:y(`${r} is not instance of ${t}`):t(r)?r:y(`${r} did not pass custom type guard`):y("Unknown checkType method")}#s(e){return U(e.accept({visitRootBox:t=>new Hr(this.#e,t),visitArpeggioDeviceBox:t=>new $t(this.#e,t),visitPitchDeviceBox:t=>new jr(this.#e,t),visitStereoToolDeviceBox:t=>new Xr(this.#e,t),visitDelayDeviceBox:t=>new ft(this.#e,t),visitReverbDeviceBox:t=>new Ir(this.#e,t),visitRevampDeviceBox:t=>new Or(this.#e,t),visitUnknownAudioEffectDeviceBox:t=>new Jr(this.#e,t),visitPlayfieldDeviceBox:t=>new qt(this.#e,t),visitPlayfieldSampleBox:t=>new Yr(this.#e,t),visitModularDeviceBox:t=>new Kt(this.#e,t),visitTapeDeviceBox:t=>new Gr(this.#e,t),visitNanoDeviceBox:t=>new Qr(this.#e,t),visitVaporisateurDeviceBox:t=>new Wr(this.#e,t),visitModularBox:t=>new Ut(this.#e,t),visitModuleConnectionBox:t=>new kt(this.#e,t),visitModuleDelayBox:t=>new kr(this.#e,t),visitModuleGainBox:t=>new Kr(this.#e,t),visitModuleMultiplierBox:t=>new Lr(this.#e,t),visitModularAudioInputBox:t=>new $r(this.#e,t),visitModularAudioOutputBox:t=>new Ur(this.#e,t),visitDeviceInterfaceKnobBox:t=>new zr(this.#e,t),visitAudioUnitBox:t=>new Ze(this.#e,t),visitAudioBusBox:t=>new Me(this.#e,t),visitAuxSendBox:t=>new Dr(this.#e,t),visitAudioFileBox:t=>new Xe(this.#e,t),visitAudioClipBox:t=>new Dt(this.#e,t),visitAudioRegionBox:t=>new It(this.#e,t),visitNoteEventBox:t=>new lr(this.#e,t),visitNoteEventCollectionBox:t=>new Ke(this.#e,t),visitNoteClipBox:t=>new Vr(this.#e,t),visitNoteRegionBox:t=>new Ot(this.#e,t),visitValueEventBox:t=>new Tt(this.#e,t),visitValueEventCollectionBox:t=>new Ue(this.#e,t),visitValueClipBox:t=>new Vt(this.#e,t),visitValueRegionBox:t=>new mt(this.#e,t),visitTrackBox:t=>new me(this.#e,t),visitTimelineBox:t=>new Je(this.#e,t),visitMarkerBox:t=>new hr(this.#e,t),visitZeitgeistDeviceBox:t=>new Zr(this.#e,t),visitUnknownMidiEffectDeviceBox:t=>new ei(this.#e,t),visitGrooveShuffleBox:t=>new _r(this.#e,t)}),`Could not find factory for ${e}`)}};var Na;(function(i){i.countStems=e=>e.match({none:()=>1,some:t=>Object.keys(t).length}),i.sanitizeFileName=e=>e.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_").trim(),i.sanitizeExportNamesInPlace=e=>{let t=new Map,r=s=>{let o=t.get(s)??0,n=s;for(;t.has(n);)o++,n=`${s} ${o}`;return t.set(s,o),t.set(n,1),n};Object.keys(e).forEach(s=>{let o=e[s];o.fileName=r(i.sanitizeFileName(o.fileName))})}})(Na||(Na={}));var Pa=Se.createBuilder({position:Se.float,playbackTimestamp:Se.float,countInBeatsRemaining:Se.float,countInBeatsTotal:Se.float,isPlaying:Se.bool,isCountingIn:Se.bool,isRecording:Se.bool});var et=class{#e=new V;#t;#r;#i;constructor(e,t){this.#t=e,this.#r=t,this.#i=new ye(128),this.#e.own(this.#t.broadcastIntegers(this.#r,new Int32Array(this.#i.buffer),Xt))}noteOn(e){e>=0&&e<128&&this.#i.setBit(e,!0)}noteOff(e){e>=0&&e<128&&this.#i.setBit(e,!1)}reset(){}clear(){this.#i.clear()}terminate(){this.#e.terminate()}toString(){return`{${this.constructor.name}}`}};var gt;(function(i){i[i.MTHD=1297377380]="MTHD",i[i.MTRK=1297379947]="MTRK"})(gt||(gt={}));var Fe;(function(i){i[i.NOTE_ON=144]="NOTE_ON",i[i.NOTE_OFF=128]="NOTE_OFF",i[i.NOTE_AFTER_TOUCH=160]="NOTE_AFTER_TOUCH",i[i.CONTROLLER=176]="CONTROLLER",i[i.PROGRAM_CHANGE=192]="PROGRAM_CHANGE",i[i.CHANNEL_AFTER_TOUCH=208]="CHANNEL_AFTER_TOUCH",i[i.PITCH_BEND=224]="PITCH_BEND"})(Fe||(Fe={}));var Zs=class i{ticks;type;param0;param1;static Comparator=(e,t)=>e.ticks-t.ticks;constructor(e,t,r,s){this.ticks=e,this.type=t,this.param0=r,this.param1=s}static decode(e,t,r){switch(t){case Fe.NOTE_ON:case Fe.NOTE_OFF:case Fe.CONTROLLER:case Fe.PITCH_BEND:case Fe.NOTE_AFTER_TOUCH:return new i(r,t,e.readByte(),e.readByte());case Fe.PROGRAM_CHANGE:case Fe.CHANNEL_AFTER_TOUCH:return new i(r,t,e.readByte(),0)}{let s;do s=e.readByte()&255;while(s<128);e.skip(-1)}return null}accept(e){switch(this.type){case Fe.NOTE_ON:{this.param1===0?g(e.noteOff,this.param0):g(e.noteOn,this.param0,this.param1/127);break}case Fe.NOTE_OFF:{g(e.noteOff,this.param0);break}case Fe.PITCH_BEND:{let t=this.param0&127,r=this.param1&127,s=t|r<<7;g(e.pitchBend,8192>=s?s/8192-1:(s-8191)/8192);break}case Fe.CONTROLLER:{g(e.controller,this.param0,this.param1/127);break}default:break}}toString(){return`ControlEvent{ticks: ${this.ticks}, type: ${this.type}, param0: ${this.param0}, param1: ${this.param1}}`}};var xe;(function(i){i[i.SEQUENCE_NUMBER=0]="SEQUENCE_NUMBER",i[i.TEXT_EVENT=1]="TEXT_EVENT",i[i.COPYRIGHT_NOTICE=2]="COPYRIGHT_NOTICE",i[i.SEQUENCE_TRACK_NAME=3]="SEQUENCE_TRACK_NAME",i[i.INSTRUMENT_NAME=4]="INSTRUMENT_NAME",i[i.LYRICS=5]="LYRICS",i[i.MARKER=6]="MARKER",i[i.CUE_POINT=7]="CUE_POINT",i[i.CHANNEL_PREFIX=32]="CHANNEL_PREFIX",i[i.SET_TEMPO=81]="SET_TEMPO",i[i.SMPTE_OFFSET=84]="SMPTE_OFFSET",i[i.TIME_SIGNATURE=88]="TIME_SIGNATURE",i[i.KEY_SIGNATURE=89]="KEY_SIGNATURE",i[i.SEQUENCER_SPECIFIC=127]="SEQUENCER_SPECIFIC",i[i.PREFIX_PORT=33]="PREFIX_PORT",i[i.END_OF_TRACK=47]="END_OF_TRACK"})(xe||(xe={}));var Js=class i{ticks;type;value;constructor(e,t,r){this.ticks=e,this.type=t,this.value=r}static decode(e,t){let r=e.readByte()&255,s=e.readVarLen();switch(r){case xe.SET_TEMPO:return new i(t,r,e.readTempo());case xe.TIME_SIGNATURE:return new i(t,r,e.readSignature());case xe.END_OF_TRACK:return new i(t,r,null);case xe.TEXT_EVENT:case xe.COPYRIGHT_NOTICE:case xe.SEQUENCE_TRACK_NAME:case xe.INSTRUMENT_NAME:case xe.LYRICS:case xe.MARKER:case xe.CUE_POINT:case xe.SEQUENCE_NUMBER:case xe.CHANNEL_PREFIX:case xe.KEY_SIGNATURE:case xe.SEQUENCER_SPECIFIC:case xe.PREFIX_PORT:case xe.SMPTE_OFFSET:default:e.skip(s)}return null}toString(){return`MetaEvent{ticks: ${this.ticks}, type: ${this.type}, value: ${this.value}}`}};var zt;(function(i){let e;(function(t){t[t.NoteOn=144]="NoteOn",t[t.NoteOff=128]="NoteOff",t[t.PitchBend=224]="PitchBend",t[t.Controller=176]="Controller"})(e=i.Command||(i.Command={})),i.readCommand=t=>t[0]&240,i.readChannel=t=>t[0]&15,i.readParam1=t=>1<t.length?t[1]&255:0,i.readParam2=t=>2<t.length?t[2]&255:0,i.readPitch=t=>t[1],i.readVelocity=t=>t[2]/127,i.isNoteOn=t=>i.readCommand(t)===e.NoteOn&&i.readVelocity(t)>0,i.isNoteOff=t=>i.readCommand(t)===e.NoteOff||i.readCommand(t)===e.NoteOn&&i.readVelocity(t)===0,i.isPitchWheel=t=>i.readCommand(t)===e.PitchBend,i.asPitchBend=t=>{let r=i.readParam1(t)&127,s=i.readParam2(t)&127,o=r|s<<7;return 8192>=o?o/8192-1:(o-8191)/8192},i.isController=t=>i.readCommand(t)===e.Controller,i.asValue=t=>{let r=i.readParam2(t);return 64<r?.5+(r-63)/128:64>r?r/128:.5},i.noteOn=(t,r,s)=>{let o=new Uint8Array(3);return o[0]=t|e.NoteOn,o[1]=r|0,o[2]=s|0,o},i.noteOff=(t,r)=>{let s=new Uint8Array(3);return s[0]=t|e.NoteOff,s[1]=r,s},i.accept=(t,r)=>{if(!pr(t))if(i.isNoteOn(t))g(r.noteOn,i.readPitch(t),i.readVelocity(t));else if(i.isNoteOff(t))g(r.noteOff,i.readPitch(t));else if(i.isPitchWheel(t)){let s=i.readParam1(t)&127,o=i.readParam2(t)&127,n=s|o<<7;g(r.pitchBend,8192>=n?n/8192-1:(n-8191)/8192)}else i.isController(t)&&g(r.controller,i.readParam1(t),i.readParam2(t)/127)},i.debug=t=>t===null?"null":i.isNoteOn(t)?`NoteOn #${i.readChannel(t)} ${i.readPitch(t)} : ${i.readVelocity(t).toFixed(2)}`:i.isNoteOff(t)?`NoteOff #${i.readChannel(t)} ${i.readPitch(t)}`:i.isPitchWheel(t)?`PitchWheel #${i.readChannel(t)} ${i.asPitchBend(t)}`:i.isController(t)?`Control #${i.readChannel(t)} ${i.asValue(t)}`:"Unknown"})(zt||(zt={}));var eo=class{tracks;formatType;timeDivision;constructor(e,t,r){this.tracks=e,this.formatType=t,this.timeDivision=r}};var to=class i{controlEvents;metaEvents;static decode(e){let t=new Zt,r=[],s=0,o=0,n=0;for(;;){let a=e.readVarLen(),u=e.readByte()&255;if(u<240){s+=a,u<128?e.skip(-1):(o=u&240,n=u&15);let h=Zs.decode(e,o,s);D(h)&&t.add(n,h)}else if(u<248)e.skipSysEx(u);else{s+=a;let h=Js.decode(e,s);if(h!==null&&(r.push(h),h.type===xe.END_OF_TRACK))break}}return new i(t,r)}static createEmpty(){return new i(new Zt,[])}constructor(e,t){this.controlEvents=e,this.metaEvents=t}encode(){let e=ue.create(),t=r=>{if(r<=127)e.writeByte(r);else{let s=r,o=[];for(o.push(s&127),s>>=7;s;){let n=s&127|128;o.push(n),s>>=7}o.reverse().forEach(n=>e.writeByte(n))}};return this.controlEvents.forEach((r,s)=>{let o=0,n=-1;s.forEach(a=>{let u=a.ticks-o;if(t(u),a.type===Fe.NOTE_ON){let h=144|r;h!==n&&e.writeByte(h),e.writeByte(a.param0),e.writeByte(a.param1)}else if(a.type===Fe.NOTE_OFF){let h=144|r;h!==n&&e.writeByte(h),e.writeByte(a.param0),e.writeByte(a.param1)}else console.warn("Unknown ControlType");o=a.ticks})}),e.toArrayBuffer()}};var ro=class{input;#e=!1;#t=!1;constructor(e){this.input=e}decode(){this.input.littleEndian=!1;let e=this.input.readInt();if(e===gt.MTHD){if(this.input.readInt()!==6)throw new Error("2nd int in header must be 6")}else throw console.warn(`Unsupported midi format ${e} !== ${gt.MTHD}`),new Error("Unsupported midi format");let t=this.input.readShort(),r=this.input.readShort(),s=this.input.readShort(),o=[];for(let n=0;n<r;n++){let a=this.input.readInt(),u=this.input.readInt(),h=this.input.position;a===gt.MTRK&&(o[n]=to.decode(this)),this.input.position=h+u}return 0<this.input.remaining()&&console.warn(`${this.input.remaining()} bytes remaining.`),new eo(o,t,s)}readVarLen(){let e=this.input.readByte()&255,t;if(0<(e&128)){e&=127;do t=this.input.readByte()&255,e=(e<<7)+(t&127);while(0<(t&128))}return e}readSignature(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255,s=this.input.readByte()&255;return this.#e,[e,1<<t]}readTempo(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255;return 6e7/(e<<16|t<<8|r)}skipSysEx(e){if(e===240){if(this.#t)throw new Error("System message already in progress");this.input.skip(this.readVarLen()-1),this.#t=!0}else e===247&&(this.#t?this.#t=!1:(this.input.skip(this.readVarLen()-1),this.#t=!0))}skip(e){this.input.skip(e)}readByte(){return this.input.readByte()}};var Sa;(function(i){i.decoder=t=>new ro(new ge(t)),i.encoder=()=>new e;class e{static writeVarLen(r,s){let o=[];for(;s>127;)o.push(s&127|128),s>>=7;o.push(s&127);for(let n=o.length-1;n>=0;n--)r.writeByte(o[n])}#e=[];addTrack(r){return this.#e.push(r),this}encode(){let r=ue.create();return r.littleEndian=!1,r.writeInt(gt.MTHD),r.writeInt(6),r.writeShort(0),r.writeShort(this.#e.length),r.writeShort(96),this.#e.forEach(s=>{r.writeInt(gt.MTRK);let o=s.encode();r.writeInt(o.byteLength),r.writeBytes(new Int8Array(o))}),r}}})(Sa||(Sa={}));var io=Symbol.for("@openDAW/lib-midi");globalThis[io]?console.debug(`%c${io.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[io]=!0,console.debug(`%c${io.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var _t;(function(i){i.on=(e,t,r)=>({type:"note-on",uuid:e,pitch:t,velocity:r}),i.off=(e,t)=>({type:"note-off",uuid:e,pitch:t}),i.isOn=e=>e.type==="note-on",i.isOff=e=>e.type==="note-off",i.fromEvent=(e,t)=>{let r=e.data;if(zt.isNoteOn(r)){let s=zt.readPitch(r),o=zt.readVelocity(r);return{type:"note-on",uuid:t,pitch:s,velocity:o}}else if(zt.isNoteOff(r)){let s=zt.readPitch(r);return{type:"note-off",uuid:t,pitch:s}}return y("Unknown MIDI event")}})(_t||(_t={}));var Ca;(function(i){i.start=(e,t,r,s=1)=>{let o=!0;return e(_t.on(t,r,s)),{terminate:()=>{o&&(e(_t.off(t,r)),o=!1)}}}})(Ca||(Ca={}));var so=class{#e;constructor(){this.#e=Q.newSet(e=>e.field.address)}register(e){return this.#e.add(e),{terminate:()=>this.#e.removeByValue(e)}}get(e){return this.#e.get(e)}opt(e){return this.#e.opt(e)}};var oo;(function(i){i.MAGIC_HEADER_OPEN=1330660686,i.FORMAT_VERSION=2,i.decode=t=>{let r=new ge(t);v(r.readInt()===i.MAGIC_HEADER_OPEN,"Corrupt header. Probably not an openDAW project file."),v(r.readInt()===i.FORMAT_VERSION,"Deprecated Format");let s=r.readInt(),o=new Int8Array(s);r.readBytes(o);let n=new ji(m.wrap(Ji.create));return n.fromArrayBuffer(o.buffer),{boxGraph:n,mandatoryBoxes:e(n,r)}};let e=(t,r)=>{let s=t.findBox(b.fromDataInput(r)).unwrap("RootBox not found"),o=t.findBox(b.fromDataInput(r)).unwrap("UserInterfaceBox not found"),n=t.findBox(b.fromDataInput(r)).unwrap("AudioBusBox not found"),a=t.findBox(b.fromDataInput(r)).unwrap("AudioUnitBox not found"),u=t.findBox(b.fromDataInput(r)).unwrap("TimelineBox not found");return{rootBox:s,userInterfaceBox:o,masterBusBox:n,masterAudioUnit:a,timelineBox:u}}})(oo||(oo={}));var no;(function(i){i.reader=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s},o)=>{let n=!0,a=new Int32Array(e,0,2),u=new Float32Array(e,8),h=new Float32Array(r*s),d=typeof document>"u",p=()=>{if(!n)return;let f=Atomics.load(a,1),A=Atomics.load(a,0);if(f===A){if(d)Atomics.wait(a,0,A);else{setTimeout(p,1);return}A=Atomics.load(a,0)}for(;f!==A;){let N=f*r*s;h.set(u.subarray(N,N+r*s));let S=[];for(let M=0;M<r;M++){let k=M*s,K=k+s;S.push(h.slice(k,K))}if(f=(f+1)%t,Atomics.store(a,1,f),!n)return;o(S)}p()};return p(),{stop:()=>n=!1}},i.writer=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s})=>{let o=new Int32Array(e,0,2),n=new Float32Array(e,8);return Object.freeze({write:a=>{if(a.length!==r)return;for(let d of a)if(d.length!==s)return y("Each channel buffer must contain 'bufferSize' samples");let u=Atomics.load(o,0),h=u*r*s;a.forEach((d,p)=>n.set(d,h+p*s)),Atomics.store(o,0,(u+1)%t),Atomics.notify(o,0)}})}})(no||(no={}));var wn={isClipBox:i=>i.accept({visitNoteClipBox:e=>!0,visitAudioClipBox:e=>!0,visitValueClipBox:e=>!0})??!1,isRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1,isLoopableRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1};var En={isRegion:i=>wn.isRegionBox(i.box),isLoopableRegion:i=>wn.isLoopableRegionBox(i.box)};var tt;(function(i){i[i.Off=0]="Off",i[i.On=1]="On",i[i.Loop=2]="Loop"})(tt||(tt={}));var Ra;(function(i){i.cut=(e,t,r)=>{if(!(e.position>=t||t>=e.complete))if(En.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;e.box.duration.setValue(t-s),e.copyTo({position:t,duration:o-t,loopOffset:ai(n+(t-s),a),consolidate:r})}else return y("Not yet implemented")},i.clip=(e,t,r)=>{if(En.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;if(o-r<=0)return y(`duration will zero or negative(${o-r})`);e.box.duration.setValue(t-s),e.copyTo({position:r,duration:o-r,loopOffset:ai(n+(r-s),a)})}else return y("Not yet implemented")}})(Ra||(Ra={}));var Ai;(e=>e.create=(t,r,s,o)=>0|(t?1:0)|(r?2:0)|(s?4:0)|(o?8:0))(Ai||={});var re=class i{static Empty=new i(2);#e;constructor(e=2){this.#e=w.create(()=>new Float32Array(128),e)}clear(e,t){this.#e.forEach(r=>r.fill(0,e,t))}numChannels(){return this.#e.length}getChannel(e){return e<this.numChannels()?this.#e[e]:this.#e[this.numChannels()-1]}assertSanity(){v(!this.#e.some(e=>e.some(t=>isNaN(t))),"AudioBuffer is invalid (NaN)")}channels(){return this.#e}replace(e){this.replaceInto(e.#e)}replaceInto(e){v(e.length===2,"mixLayout: target.length must be 2"),v(this.#e.length===1||this.#e.length===2,"mixLayout: target.length must be 1 or 2"),this.#e.length===1?(e[0].set(this.#e[0]),e[1].set(this.#e[0])):(e[0].set(this.#e[0]),e[1].set(this.#e[1]))}mixInto(e){v(e.length===2,"mixLayout: target.length must be 2"),v(this.#e.length===1||this.#e.length===2,"mixLayout: target.length must be 1 or 2");let[t,r]=e;if(this.#e.length===1){let[s]=this.#e;for(let o=0;o<128;o++)t[o]+=s[o],r[o]+=s[o]}else{let[s,o]=this.#e;for(let n=0;n<128;n++)t[n]+=s[n],r[n]+=o[n]}}};var ne=class i{static PEAK_DECAY=Math.exp(-1/(sampleRate*.25));static RMS_WINDOW=Math.floor(sampleRate*.1);#e;#t;#r;#i;#s;#o=0;#n=0;#a=0;#l=0;constructor(e,t){this.#e=e,this.#t=t,this.#r=new Float32Array(4),this.#i=w.create(()=>new Ar(i.RMS_WINDOW),2),this.#s=this.#e.broadcastFloats(this.#t,this.#r,()=>{this.#r[0]=this.#o,this.#r[1]=this.#n,this.#r[2]=this.#a,this.#r[3]=this.#l})}clear(){this.#i[0].clear(),this.#i[1].clear(),this.#o=0,this.#n=0}process(e,t,r=0,s=128){let[o,n]=this.#i;for(let a=r;a<s;a++){let u=e[a],h=t[a];this.#o<u?this.#o=u:this.#o*=i.PEAK_DECAY,this.#n<h?this.#n=h:this.#n*=i.PEAK_DECAY,this.#a=o.pushPop(u),this.#l=n.pushPop(h)}}processStereo([e,t],r=0,s=128){this.process(e,t,r,s)}terminate(){this.#s.terminate()}};var ao=class{#e=new V;#t;#r;#i;#s=m.None;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=new $,this.#o=this.#r.getValue(),this.#e.own(this.#r.subscribe(r=>{this.#o=r.getValue(),this.#i.notify(this)}))}subscribe(e){return this.#i.subscribe(e)}getValue(){return this.#o}getUnitValue(){return this.#r.valueMapping.x(this.#o)}onStartAutomation(){v(this.#s.isEmpty(),"Already broadcasting"),this.#s=m.wrap(this.#t.broadcaster.broadcastFloat(this.#r.address,()=>this.getUnitValue()))}updateAutomation(e){let t=this.#r.valueAt(e);return this.#o!==t?(this.#o=t,!0):!1}onStopAutomation(){v(this.#s.nonEmpty(),"Never started broadcasting"),this.#s.unwrap().terminate(),this.#s=m.None,this.#o=this.#r.getValue()}own(e){return this.#e.own(e)}ownAll(...e){this.#e.ownAll(...e)}spawn(){return this.#e.spawn()}terminate(){this.#e.terminate()}};var ti=class{#e;constructor(){this.#e=new Zt(w.empty(),tr.Comparator)}add(e,t){this.#e.add(e,t)}get(e){return this.#e.get(e)}forEach(e){return this.#e.forEach(e)}clear(){this.#e.clear()}};var Ve=class{#e=new V;#t;#r;#i;#s;#o=m.None;constructor(e){this.#t=e,this.#r=new ti,this.#i=[],this.#s=[]}parameterChanged(e){return y(`Got update event for ${e}, but has no parameter change method`)}get context(){return this.#t}get eventInput(){return this.#r}bindParameter(e){let t=new ao(this.#t,e);return t.ownAll(e.field.pointerHub.catchupAndSubscribeTransactual({onAdd:r=>{this.#o.isEmpty()&&(this.#o=m.wrap(this.#t.updateClock.addEventOutput(this.#r))),this.#s.push(t),t.onStartAutomation()},onRemove:r=>{w.remove(this.#s,t),this.#s.length===0&&(this.#o.ifSome(s=>s.terminate()),this.#o=m.None),t.onStopAutomation()}},l.Automation),t.subscribe(()=>this.parameterChanged(t))),this.#i.push(t),t}updateParameter(e){this.#s.forEach(t=>{t.updateAutomation(e)&&this.parameterChanged(t)})}readAllParameters(){this.#i.forEach(e=>this.parameterChanged(e))}own(e){return this.#e.own(e)}ownAll(...e){return this.#e.ownAll(...e)}spawn(){return this.#e.spawn()}terminate(){this.#o.ifSome(e=>e.terminate()),this.#o=m.None,this.#i.length=0,this.#e.terminate()}toString(){return`{${this.constructor.name}}`}};var Ei;(e=>e.isOfType=t=>t.type==="update-event")(Ei||={});var lo=class extends Ve{#e=[];constructor(e){super(e),this.own(this.context.registerProcessor(this))}reset(){this.eventInput.clear()}addEventOutput(e){return this.#e.push(e),{terminate:()=>w.remove(this.#e,e)}}process({blocks:e}){e.forEach(({p0:t,p1:r,flags:s},o)=>{if(ye.every(s,1))for(let n of Bt.iterate(t,r,Ws)){let a={type:"update-event",position:n};this.#e.forEach(u=>u.add(o,a))}})}toString(){return`{${this.constructor.name}}`}};var fe=class extends Ve{constructor(e){super(e)}process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,s0:o,s1:n,bpm:a}=t,u=null,h=o;for(let d of this.eventInput.get(r)){let p=d.position-s,f=Math.abs(p)<1e-7?o:o+Math.floor(G.pulsesToSamples(p,a,sampleRate));v(o<=f&&f<=n,()=>`${f} out of bounds. event: ${d.position} (${d.type}), p0: ${s}`),u?.forEach(A=>this.handleEvent(A)),u=null,h<f&&(this.processAudio(t,h,f),h=f),Ei.isOfType(d)?this.updateParameter(d.position):(u??=[]).push(d)}u?.forEach(d=>this.handleEvent(d)),u=null,h<n&&this.processAudio(t,h,n)}),this.eventInput.clear(),this.finishProcess()}introduceBlock(e){}handleEvent(e){return y(`${this} received an event but has no accepting method.`)}finishProcess(){}};var uo=class i{static#e=R.exponential(20/sampleRate,2e4/sampleRate);#t;#r;#i;#s;#o;feedback=.7;cross=0;wet=.75;dry=.75;#n=0;#a=0;#l=0;#u=0;#h=0;#c=!1;#d=!1;constructor(e,t){let r=ot(e);this.#t=r,this.#r=[new Float32Array(r),new Float32Array(r)],this.#i=[new be,new be],this.#s=new wt,this.#o=t}reset(){this.#a=0,this.#c&&(this.#i.forEach(e=>e.reset()),this.#r.forEach(e=>e.fill(0)),this.#c=!1,this.#d=!1),this.#f()}set offset(e){v(0<=e&&e<this.#t,"Out of bounds"),this.#u!==e&&(this.#u=e,this.#c?this.#x():this.#f())}get offset(){return this.#u}set filter(e){e===0?this.#s.identity():e>0?this.#s.setHighpassParams(i.#e.y(e),.001):e<0&&this.#s.setLowpassParams(i.#e.y(1+e),.001)}process(e,t,r,s){this.#d?this.#g(e,t,r,s):this.#p(e,t,r,s),this.#c=!0}#p(e,t,r,s){let o=this.#t-1,n=this.#r,a=this.feedback,u=this.wet,h=this.dry,d=this.#a,p=d-Math.floor(this.#l);p<0&&(p+=this.#t);let f=e[0],A=e[1],N=t[0],S=t[1],M=this.#i[0],k=this.#i[1],K=n[0],q=n[1];for(let z=r;z<s;++z){let ee=f[z],he=A[z],ce=M.processFrame(this.#s,K[p]*.96),_=k.processFrame(this.#s,q[p]*.96),j=this.cross*(_-ce),H=ce+j,Y=_-j;K[d]=(ee+H)*a+1e-18-1e-18,q[d]=(he+Y)*a+1e-18-1e-18,N[z]=H*u+ee*h,S[z]=Y*u+he*h,p=++p&o,d=++d&o}this.#a=d}#g(e,t,r,s){let o=this.#t-1,n=this.#r,a=this.feedback,u=this.wet,h=this.dry,d=this.#a;for(let p=r;p<s;++p){0<this.#h?(this.#l+=this.#n,this.#h--):(this.#l=this.#u,this.#d=!1);let f=d-this.#l;f<0&&(f+=this.#t);let A=f|0,N=f-A,S=e[0][p],M=e[1][p],k=n[0][A],K=n[0][A],q=this.#i[0].processFrame(this.#s,k+N*(n[0][A+1&o]-k)),z=this.#i[1].processFrame(this.#s,K+N*(n[1][A+1&o]-K));n[0][d]=S+q*a+1e-18-1e-18,n[1][d]=M+q*a+1e-18-1e-18,t[0][p]=q*u+S*h,t[1][p]=z*u+M*h,d=++d&o}this.#a=d}#f(){this.#l=this.#u,this.#h=0,this.#d=!1}#x(){this.#u!==this.#l&&(this.#h=this.#o,this.#n=(this.#u-this.#l)/this.#h,this.#d=!0)}};var ho=class i extends fe{static ID=0;#e=i.ID++;#t;parameterDelay;parameterFeedback;parameterCross;parameterFilter;parameterDry;parameterWet;#r;#i;#s;#o=m.None;#n=!0;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address));let{delay:r,feedback:s,cross:o,filter:n,dry:a,wet:u}=t.namedParameter;this.parameterDelay=this.own(this.bindParameter(r)),this.parameterFeedback=this.own(this.bindParameter(s)),this.parameterCross=this.own(this.bindParameter(o)),this.parameterFilter=this.own(this.bindParameter(n)),this.parameterDry=this.own(this.bindParameter(a)),this.parameterWet=this.own(this.bindParameter(u));let h=G.pulsesToSamples(ze.toPPQN(ft.OffsetFractions[0]),30,sampleRate),d=Math.floor(.5*sampleRate);this.#s=new uo(h,d),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.reset(),this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#o=m.wrap(e),{terminate:()=>this.#o=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}handleEvent(e){}processAudio({bpm:e,flags:t},r,s){if(this.#o.isEmpty())return;if(this.#n||ye.some(t,8)){let n=this.parameterDelay.getValue(),a=ze.toPPQN(ft.OffsetFractions[n]);this.#s.offset=G.pulsesToSamples(a,e,sampleRate),this.#n=!1}let o=this.#o.unwrap();this.#s.process(o.channels(),this.#r.channels(),r,s),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1),r,s)}parameterChanged(e){e===this.parameterDelay?this.#n=!0:e===this.parameterFeedback?this.#s.feedback=this.parameterFeedback.getValue():e===this.parameterCross?this.#s.cross=this.parameterCross.getValue():e===this.parameterFilter?this.#s.filter=this.parameterFilter.getValue():e===this.parameterDry?this.#s.dry=Ae(this.parameterDry.getValue()):e===this.parameterWet&&(this.#s.wet=Ae(this.parameterWet.getValue()))}toString(){return`{${this.constructor.name} (${this.#e})}`}};var Fi=class i extends Ve{static ID=0;#e=i.ID++;#t;#r;#i;#s=m.None;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#s=m.wrap(e),{terminate:()=>this.#s=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}process(e){if(this.#s.isEmpty())return;let t=this.#s.unwrap(),[r,s]=t.channels(),[o,n]=this.#r.channels();for(let a=0;a<128;a++)o[a]=r[a],n[a]=s[a];this.#i.process(o,n)}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#e})`}};var ri=class i extends Ve{static ID=0;#e=i.ID++;#t;#r;#i;#s;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=[],this.own(e.registerProcessor(this))}get noteEventTarget(){return m.None}get incoming(){return this}get outgoing(){return this}get uuid(){return this.#t.uuid}reset(){this.#i.clear(),this.#r.clear()}addAudioSource(e){return this.#s.push(e),{terminate:()=>{w.remove(this.#s,e),this.#r.clear()}}}get adapter(){return this.#t}get audioOutput(){return this.#r}process(e){this.#r.clear();let[t,r]=this.#r.channels();for(let s of this.#s){let[o,n]=s.channels();for(let a=0;a<128;a++)t[a]+=o[a],r[a]+=n[a]}this.#r.assertSanity(),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1))}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#e})}`}};var Z;(n=>{n.start=(a,u,h,d,p=0)=>({type:"note-event",position:a,duration:u,pitch:h,velocity:d,cent:p,id:++o}),n.startWith=(a,u,h)=>({type:"note-event",position:u??a.position,duration:h??a.duration,pitch:a.pitch,cent:a.cent,velocity:a.velocity,id:++o}),n.stop=({id:a,pitch:u},h)=>({type:"note-complete-event",position:h,pitch:u,id:a}),n.isStart=a=>a.type==="note-event"&&"id"in a&&typeof a.id=="number",n.isStop=a=>a.type==="note-complete-event";let o=0})(Z||={});var Ht=class{#e=new V;#t;#r;#i=m.None;constructor(e,t,r){this.#t=e,this.#r=this.#e.own(new et(t,r))}setNoteEventSource(e){return v(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=m.wrap(e),this.#t.reset(),O.create(()=>{this.#i=m.None,this.#t.reset()})}introduceBlock({index:e,p0:t,p1:r,flags:s}){if(!this.#i.isEmpty())for(let o of this.#i.unwrap().processNotes(t,r,s))o.pitch>=0&&o.pitch<=127&&(this.#t.eventInput.add(e,o),this.#s(o))}clear(){}terminate(){this.#e.terminate()}#s(e){Z.isStart(e)?this.#r.noteOn(e.pitch):Z.isStop(e)&&this.#r.noteOff(e.pitch)}};var co=class extends fe{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h;#c;#d;#p;gain=1;freqMult=1;attack=1;release=1;waveform=ut.sine;cutoff=1;resonance=1;filterEnvelope=0;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new Ht(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#i=new re,this.#s=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.octave)),this.#a=this.own(this.bindParameter(this.#e.namedParameter.tune)),this.#l=this.own(this.bindParameter(this.#e.namedParameter.attack)),this.#u=this.own(this.bindParameter(this.#e.namedParameter.release)),this.#h=this.own(this.bindParameter(this.#e.namedParameter.waveform)),this.#c=this.own(this.bindParameter(this.#e.namedParameter.cutoff)),this.#d=this.own(this.bindParameter(this.#e.namedParameter.resonance)),this.#p=this.own(this.bindParameter(this.#e.namedParameter.filterEnvelope)),this.own(e.registerProcessor(this)),this.readAllParameters()}get noteEventTarget(){return m.wrap(this)}introduceBlock(e){this.#r.introduceBlock(e)}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.clear(),this.#t.length=0,this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#i}get adapter(){return this.#e}handleEvent(e){Z.isStart(e)?this.#t.push(new Fn(this,e)):Z.isStop(e)&&this.#t.find(t=>t.event.id===e.id)?.stop()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#t.length-1;s>=0;s--)this.#t[s].processAdd(this.#i,t,r)&&this.#t.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=Ae(this.#o.getValue()):e===this.#n||e===this.#a?this.freqMult=2**(this.#n.getValue()+this.#a.getValue()/1200):e===this.#l?this.attack=Math.floor(this.#l.getValue()*sampleRate):e===this.#u?this.release=Math.floor(this.#u.getValue()*sampleRate):e===this.#h?this.waveform=Tn(this.#h.getValue(),ut):e===this.#c?this.cutoff=this.#c.getValue():e===this.#d?this.resonance=this.#d.getValue():e===this.#p&&(this.filterEnvelope=this.#p.getValue())}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return"{VaporisateurDevice}"}},Fn=class{device;event;osc;buffer;filterCoeff;filterProcessor;phase=0;position=0;decayPosition=Number.POSITIVE_INFINITY;constructor(e,t){this.device=e,this.event=t,this.osc=new $i,this.buffer=new Float32Array(128),this.filterCoeff=new wt,this.filterProcessor=new be}stop(){this.decayPosition=this.position-this.device.attack}processAdd(e,t,r){let s=ia(this.event.pitch+this.event.cent/100,440)*this.device.freqMult,o=qi(this.event.velocity)*this.device.gain*Ae(-15),n=this.device.waveform,a=this.device.attack,u=this.device.release,h=this.device.adapter.namedParameter.cutoff.valueMapping,d=h.x(this.device.cutoff),p=this.device.resonance,f=this.device.filterEnvelope,A=e.getChannel(0),N=e.getChannel(1);this.osc.generate(this.buffer,s/sampleRate,n,t,r);for(let S=t;S<r;S++){let M=Math.min(this.position/a,1-(this.position-(this.decayPosition+a))/u,1)**2;this.filterCoeff.setLowpassParams(h.y(L(d+M*f,0,1))/sampleRate,p);let k=this.filterProcessor.processFrame(this.filterCoeff,this.buffer[S])*o*M;if(A[S]+=k,N[S]+=k,++this.position-this.decayPosition>a+u)return!0}return!1}};var po=class extends Ve{#e;#t;#r;constructor(e,t){super(e),this.#e=t,this.#t=new re(2),this.#r=this.own(new ne(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get noteEventTarget(){return m.None}reset(){this.#r.clear(),this.#t.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#t}process({blocks:e}){this.#t.clear(0,128);let[t,r]=this.#t.channels();this.#e.deviceHost().audioUnitBoxAdapter().tracks.collection.adapters().filter(s=>s.type===J.Audio&&s.enabled.getValue()).forEach(s=>e.forEach(o=>{let{p0:n,p1:a,flags:u}=o;if(!ye.every(u,5))return;let h=this.context.clipSequencing.iterate(s.uuid,n,a);for(let{optClip:d,sectionFrom:p,sectionTo:f}of h)d.match({none:()=>{for(let A of s.regions.collection.iterateRange(n,a)){if(A.mute||!de(A,It))continue;let S=A.file.getOrCreateLoader().data;if(S.isEmpty())return;let M=S.unwrap();for(let k of Te.locateLoops(A,n,a))this.#i(this.#t,M,k,o)}},some:A=>{if(!de(A,Dt))return;let N=A.file.getOrCreateLoader().data;if(N.isEmpty())return;let S=N.unwrap();for(let M of Te.locateLoops({position:0,loopDuration:A.duration,loopOffset:0,complete:Number.POSITIVE_INFINITY},p,f))this.#i(this.#t,S,M,o)}})})),this.#t.assertSanity(),this.#r.process(t,r)}parameterChanged(e){}#i(e,t,r,{p0:s,p1:o,s0:n,s1:a}){let[u,h]=e.channels(),{numberOfFrames:d,frames:p}=t,f=p[0],A=p.length===1?p[0]:p[1],N=a-n,S=o-s,M=d*r.resultStartValue,k=d*r.resultEndValue,K=(r.resultStart-s)/S,q=(r.resultEnd-s)/S,z=n+N*K,ee=n+N*q,he=ee-z|0,ce=(k-M)/he;v(n<=z&&ee<=a,`Out of bounds ${z}, ${ee}`);for(let _=0,j=z|0;_<he;_++,j++){let H=M+_*ce,Y=H|0,ae=H-Y,He=f[Y],rt=A[Y];u[j]+=He+ae*(f[(Y+1)%d]-He),h[j]+=rt+ae*(A[(Y+1)%d]-rt)}}};var $e=class extends Ve{process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,p1:o}=t,n=null,a=s;for(let u of this.eventInput.get(r))n?.forEach(h=>this.handleEvent(t,h)),n=null,a<u.position&&(this.processEvents(t,a,u.position),a=u.position),Ei.isOfType(u)?this.updateParameter(u.position):(n??=[]).push(u);n?.forEach(u=>this.handleEvent(t,u)),n=null,a<o&&this.processEvents(t,a,o)}),this.eventInput.clear()}introduceBlock(e){}};var ii;(t=>(t.create=()=>({mult:1,add:0}),t.apply=(r,s)=>s*r.mult+r.add))(ii||={});var mo=Object.freeze([{name:"up",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,u=t%n,h=Math.floor(t%a/n),d=i[u];return Z.start(r,s,d.pitch+h*12,ii.apply(o,d.velocity))}},{name:"down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,u=n-1-t%n,h=e-1-Math.floor(t%a/n),d=i[u];return Z.start(r,s,d.pitch+h*12,ii.apply(o,d.velocity))}},{name:"up-down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,u=Math.max(1,a*2-2),h=t%u,d=h<a?h:u-h,p=d%n,f=Math.floor(d/n),A=i[p];return Z.start(r,s,A.pitch+f*12,ii.apply(o,A.velocity))}}]);var fo=class extends $e{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u=ii.create();#h=m.None;#c=mo[0];#d=NaN;#p=1;#g=1;#f=1;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new br,this.#i=this.own(this.bindParameter(t.namedParameter.modeIndex)),this.#s=this.own(this.bindParameter(t.namedParameter.rate)),this.#o=this.own(this.bindParameter(t.namedParameter.gate)),this.#n=this.own(this.bindParameter(t.namedParameter.repeat)),this.#a=this.own(this.bindParameter(t.namedParameter.numOctaves)),this.#l=this.own(this.bindParameter(t.namedParameter.velocity)),this.ownAll(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get noteEventTarget(){return m.wrap(this)}setNoteEventSource(e){return v(this.#h.isEmpty(),"NoteEventSource already set"),this.#h=m.wrap(e),O.create(()=>this.#h=m.None)}*processNotes(e,t,r){if(this.#r.nonEmpty())if(ye.every(r,2))for(let o of this.#r.releaseAll())yield Z.stop(o,e);else for(let o of this.#r.releaseLinearCompleted(t))yield Z.stop(o,o.position+o.duration);if(this.#h.nonEmpty()){let s=this.#h.unwrap();for(let n of s.processNotes(e,t,r));let o=!ye.every(r,1);for(let{position:n,index:a}of Bt.iterateWithIndex(e,t,this.#d)){let u=Array.from(s.iterateActiveNotesAt(n,o));if(u.length===0)continue;let h=Math.floor(a/this.#g),d=Math.max(1,Math.floor(this.#d*this.#p)),p=this.#c.run(u,this.#f,h,n,d,this.#u);this.#r.addAndRetain({...p}),yield p}for(let n of this.#r.releaseLinearCompleted(t))yield Z.stop(n,n.position+n.duration)}}*iterateActiveNotesAt(e,t){this.#h.isEmpty()||t||(yield*this.#r.overlapping(e,Ce.Comparator))}reset(){this.#t.length=0,this.#r.clear(),this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){if(e===this.#i)this.#c=mo.at(this.#i.getValue())??mo[0];else if(e===this.#s)this.#d=ze.toPPQN($t.RateFractions[this.#s.getValue()]);else if(e===this.#o)this.#p=this.#o.getValue();else if(e===this.#n)this.#g=this.#n.getValue();else if(e===this.#a)this.#f=this.#a.getValue();else if(e===this.#l){let t=this.#l.getValue();t<=0?(this.#u.add=1+t,this.#u.mult=0):(this.#u.add=1-t,this.#u.mult=t)}}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var go=class extends $e{#e;#t;#r;#i;#s;#o=m.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new et(e.broadcaster,t.address)),this.#r=this.own(this.bindParameter(t.namedParameter.octaves)),this.#i=this.own(this.bindParameter(t.namedParameter.semiTones)),this.#s=this.own(this.bindParameter(t.namedParameter.cent)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return v(this.#o.isEmpty(),"NoteEventSource already set"),this.#o=m.wrap(e),O.create(()=>this.#o=m.None)}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#o.isEmpty())for(let s of this.#o.unwrap().processNotes(e,t,r))if(Z.isStart(s)){this.#t.noteOn(s.pitch);let{cent:o,octaves:n,semiTones:a}=this.#e.namedParameter;yield bt.overwrite(s,{pitch:s.pitch+n.valueAt(s.position)*12+a.valueAt(s.position),cent:s.cent+o.valueAt(s.position)})}else this.#t.noteOff(s.pitch),yield s}*iterateActiveNotesAt(e,t){if(!this.#o.isEmpty()){for(let r of this.#o.unwrap().iterateActiveNotesAt(e,t))if(r.type==="note-event"){let{cent:s,octaves:o,semiTones:n}=this.#e.namedParameter;yield bt.overwrite(r,{pitch:r.pitch+o.valueAt(r.position)*12+n.valueAt(r.position),cent:r.cent+s.valueAt(r.position)})}}}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var xo=class i{static DEFAULT_SIZE=1024;#e;#t;#r;#i;#s;#o;#n;#a=0;decay=!1;constructor(e=i.DEFAULT_SIZE){this.#e=e,this.#r=new ki(this.#e),this.#i=new Float32Array(this.#e),this.#s=new Float32Array(this.#e),this.#o=di.create(di.Type.Blackman,this.#e),this.#t=this.#e>>1,this.#n=new Float32Array(this.#t)}clear(){this.#n.fill(0),this.#a=0}numBins(){return this.#t}bins(){return this.#n}process(e,t,r,s){for(let o=r;o<s;++o)this.#i[this.#a]=this.#o[this.#a]*(e[o]+t[o]),++this.#a===this.#e&&this.#l()}#l(){this.#r.process(this.#i,this.#s);let e=1/this.#t;for(let t=0;t<this.#t;++t){let r=this.#i[t],s=this.#s[t],o=Math.sqrt(r*r+s*s)*e;this.#n[t]<o?this.#n[t]=o:this.decay&&(this.#n[t]*=.9)}this.#a=0,this.#s.fill(0),this.decay=!1}};var yo=class i extends fe{static ID=0;#e=i.ID++;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h;#c;#d;#p;#g;#f;#x;#F;#N;#P;#B;#V;#S;#v;#y;#b;#C;#R;#M;#A;#E;#w;#T;#D;#O;#k;#U;#I=m.None;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=new xo,this.#o=new Float32Array(this.#s.numBins()),this.#n=w.create(()=>new wt,7),this.#a=[new er(4),new er(4)],this.#l=[new er(4),new er(4)],this.#u=[this.#l,[new be,new be],[new be,new be],[new be,new be],[new be,new be],[new be,new be],this.#a],this.#h=w.create(()=>!0,7);let r=this.#t.namedParameter;this.#c=this.own(this.bindParameter(r.highPass.enabled)),this.#p=this.own(this.bindParameter(r.highPass.q)),this.#d=this.own(this.bindParameter(r.highPass.frequency)),this.#g=this.own(this.bindParameter(r.highPass.order)),this.#f=this.own(this.bindParameter(r.lowShelf.enabled)),this.#x=this.own(this.bindParameter(r.lowShelf.frequency)),this.#F=this.own(this.bindParameter(r.lowShelf.gain)),this.#N=this.own(this.bindParameter(r.lowBell.enabled)),this.#P=this.own(this.bindParameter(r.lowBell.frequency)),this.#B=this.own(this.bindParameter(r.lowBell.gain)),this.#V=this.own(this.bindParameter(r.lowBell.q)),this.#S=this.own(this.bindParameter(r.midBell.enabled)),this.#v=this.own(this.bindParameter(r.midBell.frequency)),this.#y=this.own(this.bindParameter(r.midBell.gain)),this.#b=this.own(this.bindParameter(r.midBell.q)),this.#C=this.own(this.bindParameter(r.highBell.enabled)),this.#R=this.own(this.bindParameter(r.highBell.frequency)),this.#M=this.own(this.bindParameter(r.highBell.gain)),this.#A=this.own(this.bindParameter(r.highBell.q)),this.#E=this.own(this.bindParameter(r.highShelf.enabled)),this.#w=this.own(this.bindParameter(r.highShelf.frequency)),this.#T=this.own(this.bindParameter(r.highShelf.gain)),this.#D=this.own(this.bindParameter(r.lowPass.enabled)),this.#O=this.own(this.bindParameter(r.lowPass.frequency)),this.#k=this.own(this.bindParameter(r.lowPass.q)),this.#U=this.own(this.bindParameter(r.lowPass.order)),this.own(e.registerProcessor(this)),e.broadcaster.broadcastFloats(t.spectrum,this.#o,()=>{this.#o.set(this.#s.bins()),this.#s.decay=!0}),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.#u.forEach(e=>e.forEach(t=>t.reset())),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#I=m.wrap(e),{terminate:()=>this.#I=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#I.isEmpty())return;let[s,o]=this.#r.channels(),n=this.#I.unwrap();if(this.#h.some(a=>a)){let[a,u]=n.channels();this.#n.forEach((h,d)=>{if(this.#h[d]){let[p,f]=this.#u[d];p.process(h,a,s,t,r),f.process(h,u,o,t,r),a=s,u=o}})}else{let[a,u]=n.channels();for(let h=t;h<r;h++)s[h]=a[h],o[h]=u[h]}this.#i.process(s,o,t,r),this.#s.process(s,o,t,r)}parameterChanged(e){if(e===this.#U){let t=this.#U.getValue();this.#a[0].order=t,this.#a[1].order=t}else if(e===this.#g){let t=this.#g.getValue();this.#l[0].order=t,this.#l[1].order=t}else if(e===this.#d||e===this.#p){let t=this.#d.getValue(),r=this.#p.getValue();this.#n[0].setHighpassParams(t/sampleRate,r)}else if(e===this.#x||e===this.#F){let t=this.#x.getValue(),r=this.#F.getValue();this.#n[1].setLowShelfParams(t/sampleRate,r)}else if(e===this.#P||e===this.#B||e===this.#V){let t=this.#P.getValue(),r=this.#B.getValue(),s=this.#V.getValue();this.#n[2].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#v||e===this.#y||e===this.#b){let t=this.#v.getValue(),r=this.#y.getValue(),s=this.#b.getValue();this.#n[3].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#R||e===this.#M||e===this.#A){let t=this.#R.getValue(),r=this.#M.getValue(),s=this.#A.getValue();this.#n[4].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#w||e===this.#T){let t=this.#w.getValue(),r=this.#T.getValue();this.#n[5].setHighShelfParams(t/sampleRate,r)}else if(e===this.#O||e===this.#k){let t=this.#O.getValue(),r=this.#k.getValue();this.#n[6].setLowpassParams(t/sampleRate,r)}else e===this.#c?this.#h[0]=this.#c.getValue():e===this.#f?this.#h[1]=this.#f.getValue():e===this.#N?this.#h[2]=this.#N.getValue():e===this.#S?this.#h[3]=this.#S.getValue():e===this.#C?this.#h[4]=this.#C.getValue():e===this.#E?this.#h[5]=this.#E.getValue():e===this.#D&&(this.#h[6]=this.#D.getValue())}toString(){return`{${this.constructor.name} (${this.#e})`}};var vo=class{roomSize;damp;predelayInSamples;wetGain;dryGain;#e=new Float32Array(2048);#t=new Float32Array(2048);#r=new Float32Array(2048);#i=new Float32Array(2048);#s=new Float32Array(2048);#o=new Float32Array(2048);#n=new Float32Array(2048);#a=new Float32Array(2048);#l=new Float32Array(1024);#u=new Float32Array(512);#h=new Float32Array(512);#c=new Float32Array(256);#d=new Float32Array(2048);#p=new Float32Array(2048);#g=new Float32Array(2048);#f=new Float32Array(2048);#x=new Float32Array(2048);#F=new Float32Array(2048);#N=new Float32Array(2048);#P=new Float32Array(2048);#B=new Float32Array(1024);#V=new Float32Array(512);#S=new Float32Array(512);#v=new Float32Array(256);#y;#b;#C=0;#R=0;#M=0;#A=0;#E=0;#w=0;#T=0;#D=0;#O=0;#k=0;#U=0;#I=0;#L=0;#$=0;#q=0;#z=0;#_=0;#H=0;#G=0;#W=0;#j=0;#Q=0;#Y=0;#X=0;#Z=0;#J=0;#ee=0;#te=0;#re=0;#ie=0;#se=0;#oe=0;#ne=0;#ae=0;#le=0;#ue=0;#he=0;#ce=0;#de=0;#pe=0;#m=0;#K=0;constructor(e=.5){this.#y=ot(Math.ceil(e*sampleRate)),this.#b=new Float32Array(this.#y<<1),this.damp=0,this.roomSize=.5,this.wetGain=.3333,this.dryGain=1-this.wetGain,this.#m=0,this.#K=0,this.predelayInSamples=.008*sampleRate,this.clearHistory()}clear(){this.#m=0,this.#K=0,this.clearHistory(),this.clearBuffers()}process(e,t,r,s){let[o,n]=t.channels(),[a,u]=e.channels(),h=.4*this.damp,d=1-h,p=.7+.28*this.roomSize;for(let f=r;f<s;++f){let A=o[f],N=n[f],S=this.#K-this.predelayInSamples;S<0&&(S+=this.#y);let M;M=S<<1;let k=.01,K=this.#b[M]*k,q=this.#b[M+1]*k;M=this.#K<<1,this.#b[M]=A,this.#b[M+1]=N,this.#K=this.#K+1&this.#y-1;let z=this.#m&2047;this.#C=d*this.#R+h*this.#C,this.#e[z]=K+p*this.#C,this.#R=this.#e[this.#m-1617&2047],this.#M=d*this.#A+h*this.#M,this.#t[z]=K+p*this.#M,this.#A=this.#t[this.#m-1557&2047],this.#E=d*this.#w+h*this.#E,this.#r[z]=K+p*this.#E,this.#w=this.#r[this.#m-1491&2047],this.#T=d*this.#D+h*this.#T,this.#i[z]=K+p*this.#T,this.#D=this.#i[this.#m-1422&2047],this.#O=d*this.#k+h*this.#O,this.#s[z]=K+p*this.#O,this.#k=this.#s[this.#m-1356&2047],this.#U=d*this.#I+h*this.#U,this.#o[z]=K+p*this.#U,this.#I=this.#o[this.#m-1277&2047],this.#L=d*this.#$+h*this.#L,this.#n[z]=K+p*this.#L,this.#$=this.#n[this.#m-1188&2047],this.#q=d*this.#z+h*this.#q,this.#a[z]=K+p*this.#q,this.#z=this.#a[this.#m-1116&2047];let ee=this.#z+this.#$+this.#I+this.#k+this.#D+this.#w+this.#A+this.#R,he=this.#_-ee,ce=this.#H-he,_=this.#G-ce;this.#l[this.#m&1023]=ee+.5*this.#_,this.#_=this.#l[this.#m-556&1023],this.#u[this.#m&511]=he+.5*this.#H,this.#H=this.#u[this.#m-441&511],this.#h[this.#m&511]=ce+.5*this.#G,this.#G=this.#h[this.#m-341&511],this.#c[this.#m&255]=_+.5*this.#W,this.#W=this.#c[this.#m-225&255],a[f]=this.dryGain*A+this.wetGain*(this.#W-_),this.#j=d*this.#Q+h*this.#j,this.#d[z]=q+p*this.#j,this.#Q=this.#d[this.#m-1640&2047],this.#Y=d*this.#X+h*this.#Y,this.#p[z]=q+p*this.#Y,this.#X=this.#p[this.#m-1580&2047],this.#Z=d*this.#J+h*this.#Z,this.#g[z]=q+p*this.#Z,this.#J=this.#g[this.#m-1514&2047],this.#ee=d*this.#te+h*this.#ee,this.#f[z]=q+p*this.#ee,this.#te=this.#f[this.#m-1445&2047],this.#re=d*this.#ie+h*this.#re,this.#x[z]=q+p*this.#re,this.#ie=this.#x[this.#m-1379&2047],this.#se=d*this.#oe+h*this.#se,this.#F[z]=q+p*this.#se,this.#oe=this.#F[this.#m-1300&2047],this.#ne=d*this.#ae+h*this.#ne,this.#N[z]=q+p*this.#ne,this.#ae=this.#N[this.#m-1211&2047],this.#le=d*this.#ue+h*this.#le,this.#P[z]=q+p*this.#le,this.#ue=this.#P[this.#m-1139&2047];let j=this.#ue+this.#ae+this.#oe+this.#ie+this.#te+this.#J+this.#X+this.#Q,H=this.#he-j,Y=this.#ce-H,ae=this.#de-Y;this.#B[this.#m&1023]=j+.5*this.#he,this.#he=this.#B[this.#m-579&1023],this.#V[this.#m&511]=H+.5*this.#ce,this.#ce=this.#V[this.#m-464&511],this.#S[this.#m&511]=Y+.5*this.#de,this.#de=this.#S[this.#m-364&511],this.#v[this.#m&255]=ae+.5*this.#pe,this.#pe=this.#v[this.#m-248&255],u[f]=this.dryGain*N+this.wetGain*(this.#pe-ae),this.#m++}}clearBuffers(){this.#e.fill(0),this.#t.fill(0),this.#r.fill(0),this.#i.fill(0),this.#s.fill(0),this.#o.fill(0),this.#n.fill(0),this.#a.fill(0),this.#l.fill(0),this.#u.fill(0),this.#h.fill(0),this.#c.fill(0),this.#d.fill(0),this.#p.fill(0),this.#g.fill(0),this.#f.fill(0),this.#x.fill(0),this.#F.fill(0),this.#N.fill(0),this.#P.fill(0),this.#B.fill(0),this.#V.fill(0),this.#S.fill(0),this.#v.fill(0),this.#b.fill(0)}clearHistory(){this.#C=0,this.#R=0,this.#M=0,this.#A=0,this.#E=0,this.#w=0,this.#T=0,this.#D=0,this.#O=0,this.#k=0,this.#U=0,this.#I=0,this.#L=0,this.#$=0,this.#q=0,this.#z=0,this.#_=0,this.#H=0,this.#G=0,this.#W=0,this.#j=0,this.#Q=0,this.#Y=0,this.#X=0,this.#Z=0,this.#J=0,this.#ee=0,this.#te=0,this.#re=0,this.#ie=0,this.#se=0,this.#oe=0,this.#ne=0,this.#ae=0,this.#le=0,this.#ue=0,this.#he=0,this.#ce=0,this.#de=0,this.#pe=0}};var bo=class i extends fe{static ID=0;#e=i.ID++;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h=m.None;constructor(e,t){super(e),this.#t=t,this.#r=new re,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=new vo;let{decay:r,preDelay:s,damp:o,wet:n,dry:a}=this.#t.namedParameter;this.#o=this.own(this.bindParameter(r)),this.#n=this.own(this.bindParameter(s)),this.#a=this.own(this.bindParameter(o)),this.#l=this.own(this.bindParameter(n)),this.#u=this.own(this.bindParameter(a)),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#s.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#h=m.wrap(e),{terminate:()=>this.#h=m.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#h.isEmpty())return;this.#s.process(this.#r,this.#h.unwrap(),t,r);let[s,o]=this.#r.channels();this.#i.process(s,o,t,r)}parameterChanged(e){this.#o===e?this.#s.roomSize=this.#o.getValue():this.#n===e?this.#s.predelayInSamples=Math.ceil(this.#n.getValue()*sampleRate):this.#a===e?this.#s.damp=this.#a.getValue():this.#l===e?this.#s.wetGain=Ae(this.#l.getValue()):this.#u===e&&(this.#s.dryGain=Ae(this.#u.getValue()))}toString(){return`{${this.constructor.name} (${this.#e})`}};var Ao=class extends fe{#e;#t;#r;#i;#s;#o;#n;gain=1;release=1;loader=m.None;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new re,this.#i=new Ht(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#s=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.release)),this.ownAll(e.registerProcessor(this),t.box.file.catchupAndSubscribe(r=>this.loader=r.targetVertex.map(({box:s})=>e.sampleManager.getOrCreate(s.address.uuid)))),this.readAllParameters()}get noteEventTarget(){return m.wrap(this)}introduceBlock(e){this.#i.introduceBlock(e)}setNoteEventSource(e){return this.#i.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#t.length=0,this.#r.clear(),this.eventInput.clear(),this.#i.clear(),this.#s.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}get adapter(){return this.#e}handleEvent(e){Z.isStart(e)?this.#t.push(new Bn(this,e)):Z.isStop(e)&&this.#t.find(t=>t.event().id===e.id)?.stop()}processAudio(e,t,r){this.#r.clear(t,r);for(let s=this.#t.length-1;s>=0;s--)this.#t[s].processAdd(this.#r,t,r)&&this.#t.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=Ae(this.#o.getValue()):e===this.#n&&(this.release=this.#n.getValue()*sampleRate)}finishProcess(){this.#r.assertSanity(),this.#s.process(this.#r.getChannel(0),this.#r.getChannel(1))}toString(){return"{NanoDevice}"}},Bn=class{#e;#t;#r=1;#i=0;#s=0;#o=Number.POSITIVE_INFINITY;constructor(e,t){this.#e=e,this.#t=t,this.#r=Math.pow(2,(t.pitch+t.cent/100)/12-5)}event(){return this.#t}stop(){this.#o=this.#s}processAdd(e,t,r){let s=this.#e.loader;if(s.isEmpty())return!0;let o=s.unwrap();return o.data.isEmpty()?!0:this.processSimple(e.channels(),o.data.unwrap(),t,r)}processSimple(e,t,r,s){let[o,n]=e,a=t.frames[0],u=t.frames[1]??a,h=t.numberOfFrames,d=t.sampleRate/sampleRate,p=this.#e.gain,f=this.#e.release,A=1/f;for(let N=r;N<s;N++){let S=this.#i|0;if(S>=h-1)return!0;let M=this.#i-S,k=Math.min(1-(this.#s-this.#o)*A,1)**2,K=a[S]*(1-M)+a[S+1]*M,q=u[S]*(1-M)+u[S+1]*M;if(o[N]+=K*p*k,n[N]+=q*p*k,this.#i+=this.#r*d,++this.#s-this.#o>f)return!0}return!1}};var wo=class extends $e{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=new Ht(this,e.broadcaster,t.adapter.audioUnitBoxAdapter().address),this.own(e.registerProcessor(this)),this.readAllParameters()}introduceBlock(e){this.#t.introduceBlock(e)}setNoteEventSource(e){return this.#t.setNoteEventSource(e)}reset(){this.eventInput.clear(),this.#t.clear()}processEvents(e,t,r){}handleEvent({index:e},t){Z.isStart(t)?this.#e.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t)):Z.isStop(t)&&this.#e.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t))}toString(){return"{PlayfieldSequencer}"}};var Eo=class extends fe{#e;#t;#r;#i;#s;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=this.own(new ne(e.broadcaster,t.adapter.address)),this.#i=[],this.#s=new ti,this.own(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}setAudioSource(e){return this.#i.push(e),{terminate:()=>{w.remove(this.#i,e),this.#t.clear()}}}get audioOutput(){return this.#t}get eventInput(){return this.#s}processAudio(e,t,r){}reset(){this.#r.clear()}finishProcess(){this.#t.clear();let[e,t]=this.#t.channels();for(let r of this.#i){let[s,o]=r.channels();for(let n=0;n<128;n++)e[n]+=s[n],t[n]+=o[n]}this.#t.assertSanity(),this.#r.process(this.#t.getChannel(0),this.#t.getChannel(1))}toString(){return"{PlayfieldMixProcessor}"}};var Fo=class i{static create(e,t,r,s){return new i(e,t,r,s)}#e=new V;#t;#r;#i=[];#s=!0;constructor(e,t,r,s){this.#t=b.newSet(({device:o})=>o.uuid),this.#r=this.#e.own(new V),this.#e.ownAll(t.catchupAndSubscribe({onAdd:o=>{this.invalidateWiring();let n=Bi.create(e,o.box),a=this.#t.add({device:n,subscription:n.adapter().enabledField.subscribe(()=>this.invalidateWiring())});v(a,"Could not add.")},onRemove:o=>{this.invalidateWiring();let{device:n,subscription:a}=this.#t.removeByKey(o.uuid);a.terminate(),n.terminate()},onReorder:o=>this.invalidateWiring()}),e.subscribeProcessPhase(o=>{if(o===0&&this.#s){let n=r;w.replace(this.#i,t.adapters().map(({uuid:a})=>this.#t.get(a).device));for(let a of this.#i)a.adapter().enabledField.getValue()&&(this.#r.own(a.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,a.incoming)),n=a);this.#r.own(s.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,s.incoming)),this.#s=!1}}))}invalidateWiring(){this.#r.terminate(),this.#s=!0}terminate(){this.#e.terminate(),this.#t.forEach(({device:e})=>e.terminate()),this.#t.clear(),this.#i=[]}toString(){return`{${this.constructor.name}}`}};var Ni=Math.floor(.005*sampleRate),No=class{#e;#t;#r;#i;#s;#o;#n=0;#a=Number.POSITIVE_INFINITY;#l;#u;#h;#c;#d;#p;#g=!0;#f=!1;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#i=r,this.#r=s,this.#s=e.gate,this.#o=qi(this.#r.velocity);let{attack:o,release:n,sampleStart:a,sampleEnd:u}=this.#t;this.#l=o.getValue()*sampleRate,this.#u=n.getValue()*sampleRate,this.#h=(r.numberOfFrames-1)*a.getValue(),this.#c=(r.numberOfFrames-1)*u.getValue(),this.#d=this.#h,this.#p=0}get sample(){return this.#e}get event(){return this.#r}get position(){return this.#d}get envelope(){return this.#p}release(e=!1){this.#g&&(e?(this.#u=Ni,this.#x(),this.#g=!1):this.#s!==tt.Off&&this.#x())}processAdd(e,t,r){let[s,o]=e,{frames:n,numberOfFrames:a}=this.#i,u=n[0],h=n[1]??u,{pitch:d}=this.#t,p=this.#c-this.#h,f=Math.sign(p),A=this.#i.sampleRate/sampleRate*f*2**(d.getValue()/1200),N=0;for(let S=t;S<r;S++){let M=this.#d|0,k=this.#d-M,K=u[M]*(1-k)+(u[M+1]??0)*k,q=h[M]*(1-k)+(h[M+1]??0)*k;if(N=Math.min(this.#n/this.#l,1-(this.#n-(this.#a+this.#l))/this.#u,1),this.#d+=A,f>0){if(this.#s===tt.Off){if(this.#d>=a)return!0;!this.#f&&this.#d>=this.#c&&this.#x()}else if(this.#s===tt.On){if(this.#d>=this.#c-Ni){if(this.#d>=this.#c)return!0;N*=(this.#c-this.#d)/Ni}}else if(this.#s===tt.Loop)for(;this.#d>=this.#c;)this.#d-=p}else if(f<0){if(this.#s===tt.Off){if(this.#d<=0)return!0;!this.#f&&this.#d<=this.#c&&this.#x()}else if(this.#s===tt.On){if(this.#d<=this.#c+Ni){if(this.#d<=this.#c)return!0;N*=(this.#c-this.#d)/Ni}}else if(this.#s===tt.Loop)for(;this.#d<=this.#c;)this.#d-=p}if(++this.#n-this.#a>this.#l+this.#u)return!0;N*=this.#o*N,s[S]+=K*N,o[S]+=q*N}return this.#p=N,!1}toString(){return"{PlayfieldSampleVoice}"}#x(){this.#f||(this.#f=!0,this.#a=this.#n<this.#l?this.#n-this.#l:this.#n)}};var Po=class extends fe{#e;#t;#r;#i;#s;#o;constructor(e,t,r,s){super(e),this.#e=t,this.#t=r,this.#r=[],this.#i=new re,this.#s=this.own(new ne(e.broadcaster,r.peakAddress));let{sampleStart:o,sampleEnd:n,attack:a,release:u,pitch:h}=r.namedParameter;this.#o=Object.freeze({sampleStart:this.own(this.bindParameter(o)),sampleEnd:this.own(this.bindParameter(n)),attack:this.own(this.bindParameter(a)),release:this.own(this.bindParameter(u)),pitch:this.own(this.bindParameter(h))});let d=new Float32Array(16);this.ownAll(Fo.create(e,r.audioEffects,this,s),e.broadcaster.broadcastFloats(r.address,d,()=>{let p=this.#r.length<d.length?this.#r:this.#r.slice(0,d.length);p.forEach(({position:f},A)=>d[A]=f),d[p.length]=-1}),e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#i}get adapter(){return this.#t}handleEvent(e){if(Z.isStart(e)){let t=this.#t.file().flatMap(d=>d.getOrCreateLoader().data);if(t.isEmpty())return;let{mute:r,solo:s,polyphone:o,exclude:n}=this.#t.namedParameter,a=r.getValue(),u=s.getValue();if(a||this.#e.hasSolo()&&!u)return;o.getValue()||this.#r.forEach(d=>d.release(!0)),n.getValue()&&this.#e.stopExcludeOthers(this.#t),this.#r.push(new No(this.#t,this.#o,t.unwrap(),e))}else Z.isStop(e)&&this.#r.find(t=>t.event.id===e.id)?.release()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#r.length-1;s>=0;s--)this.#r[s].processAdd(this.#i.channels(),t,r)&&this.#r.splice(s,1)}forceStop(){this.#r.forEach(e=>e.release(!0))}parameterChanged(e){}reset(){this.#r.length=0,this.#i.clear(),this.#s.clear()}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return`{PlayfieldSampleProcessor note: ${this.#t.indexField.getValue()}}`}};var So=class{#e=new V;#t;#r;#i;#s;constructor(e,t){this.#t=t,this.#r=this.#e.own(new wo(e,this)),this.#i=this.#e.own(new Eo(e,this)),this.#s=b.newSet(r=>r.uuid),this.#e.ownAll(t.samples.catchupAndSubscribe({onAdd:r=>{let s=new Po(e,this,r,this.#i);this.#s.add({uuid:r.uuid,processor:s,terminable:e.registerEdge(this.#r,s)}),e.sampleManager.getOrCreate(r.fileUUID())},onRemove:r=>{let{terminable:s,processor:o}=this.#s.removeByKey(r.uuid);s.terminate(),o.terminate()},onReorder:r=>{}}),{terminate:()=>{this.#s.forEach(({terminable:r,processor:s})=>{r.terminate(),s.terminate()}),this.#s.clear()}})}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get noteEventTarget(){return m.wrap(this)}get incoming(){return this.#r}get outgoing(){return this.#i}optSampleProcessor(e){return this.#t.samples.getAdapterByIndex(e).flatMap(t=>this.#s.opt(t.uuid)).map(t=>t.processor)}hasSolo(){return this.#t.samples.adapters().some(e=>e.namedParameter.solo.getValue())}stopExcludeOthers(e){for(let t of this.#t.samples.adapters())t.exclude&&t!==e&&this.#s.opt(t.uuid).ifSome(({processor:r})=>r.forceStop())}get uuid(){return this.#t.uuid}get adapter(){return this.#t}get audioOutput(){return this.#i.audioOutput}parameterChanged(e){}terminate(){this.#e.terminate()}toString(){return"{PlayfieldDeviceProcessor}"}};var Co=class extends fe{#e;#t;#r;#i=_e.stereoMatrix(sampleRate);#s={gain:0,panning:0,stereo:0,invertL:!1,invertR:!1,swap:!1};#o;#n;#a;#l;#u;#h;#c=m.None;#d=ht.Mixing.Linear;#p=!0;#g=!1;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(t.namedParameter.volume)),this.#n=this.own(this.bindParameter(t.namedParameter.panning)),this.#a=this.own(this.bindParameter(t.namedParameter.stereo)),this.#l=this.own(this.bindParameter(t.namedParameter.invertL)),this.#u=this.own(this.bindParameter(t.namedParameter.invertR)),this.#h=this.own(this.bindParameter(t.namedParameter.swap)),this.ownAll(t.box.panningMixing.catchupAndSubscribe(r=>{this.#d=r.getValue(),this.#p=!0}),e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#t.clear(),this.eventInput.clear(),this.#g=!1}get uuid(){return this.#e.uuid}get audioOutput(){return this.#t}setAudioSource(e){return this.#c=m.wrap(e),{terminate:()=>this.#c=m.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}processAudio(e,t,r){if(this.#c.isEmpty())return;this.#p&&(this.#i.update(this.#s,this.#d,this.#g),this.#p=!1);let s=this.#c.unwrap().channels(),o=this.#t.channels();this.#i.processFrames(s,o,t,r),this.#r.processStereo(o,t,r),this.#g=!0}parameterChanged(e){switch(e){case this.#o:this.#s.gain=Ae(this.#o.getValue()),this.#p=!0;return;case this.#n:this.#s.panning=this.#n.getValue(),this.#p=!0;return;case this.#a:this.#s.stereo=this.#a.getValue(),this.#p=!0;return;case this.#l:this.#s.invertL=this.#l.getValue(),this.#p=!0;return;case this.#u:this.#s.invertR=this.#u.getValue(),this.#p=!0;return;case this.#h:this.#s.swap=this.#h.getValue(),this.#p=!0;return}}toString(){return`{${this.constructor.name}}`}};var Ro=class extends $e{#e;#t;#r=m.None;#i=m.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new et(e.broadcaster,t.address)),this.ownAll(t.box.groove.catchupAndSubscribe(r=>{this.#r.ifSome(s=>s.terminate()),this.#r=m.wrap(r.targetVertex.isEmpty()?null:e.boxAdapters.adapterFor(r.targetVertex.unwrap().box,cr.checkType))}),O.create(()=>{this.#r.ifSome(r=>r.terminate()),this.#r=m.None}),e.registerProcessor(this))}get uuid(){return this.#e.uuid}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}setNoteEventSource(e){return v(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=m.wrap(e),O.create(()=>this.#i=m.None)}*processNotes(e,t,r){if(this.#i.isEmpty())return;let s=this.#i.unwrap(),o=this.#r.mapOr(ni,ci.Identity);for(let n of s.processNotes(o.unwarp(e),o.unwarp(t),r))Z.isStart(n)?this.#t.noteOn(n.pitch):this.#t.noteOff(n.pitch),yield bt.overwrite(n,{position:L(o.warp(n.position),e,t)})}*iterateActiveNotesAt(e,t){if(this.#i.isEmpty())return;let r=this.#i.unwrap(),s=this.#r.mapOr(ni,ci.Identity);for(let o of r.iterateActiveNotesAt(s.unwarp(e),t))yield bt.overwrite(o,{position:s.warp(o.position)})}reset(){this.eventInput.clear()}parameterChanged(e){}handleEvent(e,t){}processEvents(e,t,r){}};var Mo=class extends $e{#e;#t;#r=m.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new et(e.broadcaster,t.address)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return v(this.#r.isEmpty(),"NoteEventSource already set"),this.#r=m.wrap(e),O.create(()=>this.#r=m.None)}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#r.isEmpty())for(let s of this.#r.unwrap().processNotes(e,t,r))yield s}*iterateActiveNotesAt(e,t){if(!this.#r.isEmpty())for(let r of this.#r.unwrap().iterateActiveNotesAt(e,t))yield r}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var Nn;(e=>e.create=(t,r)=>r.accept({visitAudioBusBox:s=>new ri(t,t.boxAdapters.adapterFor(s,Me)),visitVaporisateurDeviceBox:s=>new co(t,t.boxAdapters.adapterFor(s,Wr)),visitNanoDeviceBox:s=>new Ao(t,t.boxAdapters.adapterFor(s,Qr)),visitTapeDeviceBox:s=>new po(t,t.boxAdapters.adapterFor(s,Gr)),visitPlayfieldDeviceBox:s=>new So(t,t.boxAdapters.adapterFor(s,qt))}))(Nn||={});var Pn;(e=>e.create=(t,r)=>U(r.accept({visitUnknownMidiEffectDeviceBox:s=>new Mo(t,t.boxAdapters.adapterFor(s,ei)),visitArpeggioDeviceBox:s=>new fo(t,t.boxAdapters.adapterFor(s,$t)),visitPitchDeviceBox:s=>new go(t,t.boxAdapters.adapterFor(s,jr)),visitZeitgeistDeviceBox:s=>new Ro(t,t.boxAdapters.adapterFor(s,Zr))}),`Could not create midi-effect for'${r.name}'`))(Pn||={});var Bi;(e=>e.create=(t,r)=>U(r.accept({visitUnknownAudioEffectDeviceBox:s=>new Fi(t,t.boxAdapters.adapterFor(s,Jr)),visitStereoToolDeviceBox:s=>new Co(t,t.boxAdapters.adapterFor(s,Xr)),visitDelayDeviceBox:s=>new ho(t,t.boxAdapters.adapterFor(s,ft)),visitReverbDeviceBox:s=>new bo(t,t.boxAdapters.adapterFor(s,Ir)),visitRevampDeviceBox:s=>new yo(t,t.boxAdapters.adapterFor(s,Or)),visitModularDeviceBox:s=>new Fi(t,t.boxAdapters.adapterFor(s,Kt))}),`Could not create audio-effect for'${r.name}'`))(Bi||={});var To=class extends fe{#e;#t;#r;#i;#s;#o;#n=m.None;#a=!0;#l=!1;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=_e.linear(sampleRate),this.#i=_e.linear(sampleRate),this.#s=this.own(this.bindParameter(t.sendGain)),this.#o=this.own(this.bindParameter(t.sendPan)),this.own(e.registerProcessor(this)),this.readAllParameters()}reset(){this.#t.clear()}get adapter(){return this.#e}setAudioSource(e){return this.#n=m.wrap(e),{terminate:()=>this.#n=m.None}}get audioOutput(){return this.#t}processAudio(e,t,r){if(this.#n.isEmpty())return;if(this.#a){let h=Ae(this.#s.getValue()),d=this.#o.getValue();this.#r.set((1-Math.max(0,d))*h,this.#l),this.#i.set((1+Math.min(0,d))*h,this.#l),this.#a=!1}let s=this.#t.getChannel(0),o=this.#t.getChannel(1),n=this.#n.unwrap(),a=n.getChannel(0),u=n.getChannel(1);if(this.#r.isInterpolating()||this.#i.isInterpolating())for(let h=t;h<r;h++)s[h]=a[h]*this.#r.moveAndGet(),o[h]=u[h]*this.#i.moveAndGet();else{let h=this.#r.get(),d=this.#i.get();for(let p=t;p<r;p++)s[p]=a[p]*h,o[p]=u[p]*d}this.#l=!0}parameterChanged(e){this.#a=!0}};var Vo=class extends fe{#e;#t;#r;#i;#s;#o;#n;#a;#l=_e.linear(sampleRate);#u=_e.linear(sampleRate);#h=_e.linear(sampleRate);#c=m.None;#d=!0;#p=!1;constructor(e,t){super(e),this.#e=t,this.#t=new re,this.#r=[new Float32Array(128),new Float32Array(128)],this.#i=this.own(new ne(e.broadcaster,this.#e.address)),this.#s=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.panning)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.mute)),this.#a=this.own(this.bindParameter(this.#e.namedParameter.solo)),this.ownAll(e.registerProcessor(this),e.mixer.attachChannelStrip(this)),this.readAllParameters()}reset(){this.#i.clear(),this.#t.clear(),this.#r[0].fill(0),this.#r[1].fill(0),this.#p=!1}get isMute(){return this.#n.getValue()}get isSolo(){return this.#a.getValue()}get adapter(){return this.#e}get audioOutput(){return this.#t}handleEvent(e){}processAudio(e,t,r){if(this.#c.isEmpty())return;if(this.#d){let p=this.context.mixer;p.updateSolo();let f=this.isSolo||p.isVirtualSolo(this),A=this.isMute||p.hasChannelSolo()&&!f&&!this.#e.isOutput,N=Ae(this.#s.getValue()),S=this.#o.getValue();this.#l.set((1-Math.max(0,S))*N,this.#p),this.#u.set((1+Math.min(0,S))*N,this.#p),this.#h.set(A?0:1,this.#p),this.#d=!1}let s=this.#c.unwrap(),[o,n]=s.channels(),[a,u]=this.#t.channels(),[h,d]=this.#r;if(this.#l.isInterpolating()||this.#u.isInterpolating()||this.#h.isInterpolating())for(let p=t;p<r;p++){let f=this.#h.moveAndGet(),A=o[p]*this.#l.moveAndGet(),N=n[p]*this.#u.moveAndGet();a[p]=A*f,u[p]=N*f,h[p]=A,d[p]=N}else{let p=this.#l.get(),f=this.#u.get(),A=this.#h.get();for(let N=t;N<r;N++){let S=o[N]*p,M=n[N]*f;h[N]=S,d[N]=M,a[N]=S*A,u[N]=M*A}}this.#i.process(h,d,t,r),this.#p=!0}finishProcess(){this.#t.assertSanity()}parameterChanged(e){e===this.#s?this.requestGainUpdate():e===this.#o?this.requestGainUpdate():e===this.#n?this.requestGainUpdate():e===this.#a&&this.context.mixer.onChannelStripSoloChanged(this)}requestGainUpdate(){this.#d=!0}requestSoloUpdate(){this.#d=!0}setAudioSource(e){return this.#c=m.wrap(e),{terminate:()=>this.#c=m.None}}toString(){return`{${this.constructor.name}}`}};var Do=class{#e=new V;#t;#r;#i;#s;#o;#n;#a=[];#l=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=b.newSet(r=>r.adapter.uuid),this.#s=this.#e.own(new Vo(this.#t.context,this.#t.adapter)),this.#o=b.newSet(({device:r})=>r.uuid),this.#n=this.#e.own(new V),this.#e.ownAll(this.#t.adapter.audioEffects.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=Bi.create(this.#t.context,r.box),o=this.#o.add({device:s,subscription:s.adapter().enabledField.subscribe(()=>this.invalidateWiring())});v(o,"Could not add.")},onRemove:r=>{this.invalidateWiring();let{device:s,subscription:o}=this.#o.removeByKey(r.uuid);o.terminate(),s.terminate()},onReorder:r=>this.invalidateWiring()}),this.#t.adapter.auxSends.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=this.#i.add(new To(this.#t.context,r));v(s,"Could not add.")},onRemove:({uuid:r})=>{this.invalidateWiring(),this.#i.removeByKey(r).terminate()},onReorder:r=>{}}),this.#t.adapter.output.catchupAndSubscribe(r=>this.invalidateWiring()),this.#t.context.subscribeProcessPhase(r=>{r===0&&this.#l&&(this.#u(),this.#l=!1)}))}get channelStrip(){return this.#s}invalidateWiring(){this.#n.terminate(),this.#l=!0}terminate(){this.#e.terminate(),this.#o.forEach(({device:e})=>e.terminate()),this.#o.clear(),this.#a=[]}toString(){return`{${this.constructor.name}}`}#u(){let e=this.#t.adapter.isOutput,t=this.#t.context,r=this.#t.input(),s=this.#t.adapter.output.adapter.map(n=>t.getAudioUnit(n.deviceHost().uuid).inputAsAudioBus());if(r.isEmpty()||s.isEmpty()&&!e)return;let o=r.unwrap();if(this.#r.includeAudioEffects){w.replace(this.#a,this.#t.adapter.audioEffects.adapters().map(({uuid:n})=>this.#o.get(n).device));for(let n of this.#a)n.adapter().enabledField.getValue()&&(this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n.incoming)),o=n)}if(this.#r.includeSends&&this.#i.forEach(n=>{let a=t.getAudioUnit(n.adapter.targetBus.deviceHost().uuid);this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(a.inputAsAudioBus().addAudioSource(n.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n)),this.#n.own(t.registerEdge(n,a.inputAsAudioBus()))}),this.#n.own(this.#s.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,this.#s)),s.nonEmpty()&&!e){let n=s.unwrap();this.#n.own(n.addAudioSource(this.#s.audioOutput)),this.#n.own(t.registerEdge(this.#s,n))}}};var Io=class{#e=new V;#t;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=Di.create(268431651),this.#s=new Set,this.#o=new br,this.#e.ownAll(this.#t.subscribeProcessPhase(r=>{if(r===1)for(let s of this.#s)s.gate||this.#s.delete(s)}))}get uuid(){return this.#r.uuid}terminate(){this.#e.terminate()}pushRawNoteOn(e,t){this.#s.add({pitch:e,velocity:t,gate:!0,running:m.None})}pushRawNoteOff(e){for(let t of this.#s)if(t.running.isEmpty())this.#s.delete(t);else if(t.pitch===e){t.gate=!1;return}}*processNotes(e,t,r){let s=ye.every(r,5);if(this.#o.nonEmpty()&&(!s||ye.every(r,2)?yield*this.#u(e):yield*this.#h(e,t)),this.#s.size>0)for(let o of this.#s){if(o.running.isEmpty()){let{pitch:n,velocity:a}=o,u=Number.POSITIVE_INFINITY,h=Z.start(e,u,n,a);o.running=m.wrap(h),yield h}o.gate||(this.#s.delete(o),yield Z.stop(o.running.unwrap("raw note never started"),e))}if(s){let o=this.#r.tracks.collection.adapters().filter(n=>n.type===J.Notes&&n.enabled.getValue());for(let n of o)for(let{optClip:a,sectionFrom:u,sectionTo:h}of this.#t.clipSequencing.iterate(n.uuid,e,t))a.isEmpty()?yield*this.#a(n,u,h):yield*this.#n(a.unwrap(),u,h);yield*this.#h(e,t)}}*iterateActiveNotesAt(e,t){if(this.#s.size>0)for(let{pitch:r,velocity:s}of this.#s)yield{type:"note-event",position:e,duration:Number.POSITIVE_INFINITY,pitch:r,velocity:s,cent:0};t||(yield*this.#o.overlapping(e,Ce.Comparator))}reset(){this.#o.clear(),this.#s.clear()}toString(){return`{${this.constructor.name}}`}*#n(e,t,r){if(e.optCollection.isEmpty())return;let s=e.optCollection.unwrap(),o=e.duration,n=st(t,o),a=n+o;r>a?(yield*this.#l(s,t,a,n),yield*this.#l(s,a,r,a)):yield*this.#l(s,t,r,n)}*#a(e,t,r){for(let s of e.regions.collection.iterateRange(t,r)){if(this.#t.ignoresRegion(s.address.uuid)||s.mute||!de(s,Ot))continue;let o=s.optCollection;if(o.isEmpty())continue;let n=o.unwrap();for(let{resultStart:a,resultEnd:u,rawStart:h}of Te.locateLoops(s,t,r))yield*this.#l(n,a,u,h)}}*#l(e,t,r,s){let o=t-s,n=r-s;for(let a of e.events.iterateRange(o-e.maxDuration,n)){if(!Ce.isOfType(a))continue;let{position:u,duration:h,chance:d,playCount:p,playCurve:f}=a;if(!(d<100&&this.#i.nextDouble(0,100)>d)){if(p>1){let A=Ce.inverseCurveFunc((o-u)/h,f),N=Ce.inverseCurveFunc((n-u)/h,f),S=Math.floor(A*p),M=S/p;for(;M<N;){if(M>=A){let k=Ce.curveFunc(M,f)*h;if(k>=h)break;let K=Ce.curveFunc(M+1/p,f)*h,q=Z.startWith(a,u+k+s,K-k);this.#o.addAndRetain({...q}),yield q}M=++S/p}}else if(o<=u&&u<n){let A=Z.startWith(a,u+s);this.#o.addAndRetain({...A}),yield A}}}}*#u(e){for(let t of this.#o.releaseAll())yield Z.stop(t,e)}*#h(e,t){for(let r of this.#o.releaseLinearCompleted(t)){let s=L(r.position+r.duration,e,t);yield Z.stop(r,s)}}};var Oo=class{#e=new V;#t;#r;#i;#s;#o=!1;constructor(e){this.#t=e,this.#r=this.#e.own(new Io(this.#t.context,this.#t.adapter)),this.#i=b.newSet(({device:t})=>t.uuid),this.#s=this.#e.own(new V),this.#e.ownAll(this.#t.adapter.midiEffects.catchupAndSubscribe({onAdd:t=>{this.invalidateWiring();let r=Pn.create(this.#t.context,t.box),s=this.#i.add({device:r,subscription:r.adapter().enabledField.subscribe(()=>this.invalidateWiring())});v(s,"Could not add.")},onRemove:t=>{this.invalidateWiring();let{device:r,subscription:s}=this.#i.removeByKey(t.uuid);s.terminate(),r.terminate()},onReorder:t=>this.invalidateWiring()}),this.#t.context.subscribeProcessPhase(t=>{t===0&&this.#o&&(this.#n(),this.#o=!1)}))}get noteSequencer(){return this.#r}invalidateWiring(){this.#s.terminate(),this.#o=!0}terminate(){this.#e.terminate()}toString(){return`{${this.constructor.name}}`}#n(){let e=this.#t.input().flatMap(s=>s.noteEventTarget);if(e.isEmpty())return;let t=e.unwrap(),r=this.#r;this.#t.adapter.midiEffects.adapters().map(s=>this.#i.get(s.uuid).device).forEach(s=>{s.adapter().enabledField.getValue()&&(this.#s.ownAll(s.setNoteEventSource(r),this.#t.context.registerEdge(s,t.incoming)),r=s)}),this.#s.own(t.setNoteEventSource(r))}};var ko=class i{static ID=0;#e=i.ID++;#t=new V;#r;#i;#s;#o;#n=m.None;constructor(e,t,r){this.#r=e,this.#i=t,this.#s=this.#t.own(new Oo(this)),this.#o=this.#t.own(new Do(this,r)),this.#t.ownAll(this.#i.input.catchupAndSubscribe(s=>{this.#s.invalidateWiring(),this.#o.invalidateWiring(),this.#n.ifSome(o=>o.terminate()),this.#n=s.getValue().flatMap(o=>m.wrap(Nn.create(e,o.box.box)))}))}input(){return this.#n}inputAsAudioBus(){return Qt(this.#n.unwrap("No input available"),ri)}audioOutput(){return this.#o.channelStrip.audioOutput}get midiDeviceChain(){return this.#s}get audioDeviceChain(){return this.#o}get context(){return this.#r}get adapter(){return this.#i}terminate(){console.debug(`terminate ${this}`),this.#t.terminate(),this.#n.ifSome(e=>e.terminate()),this.#n=m.None}toString(){return`{${this.constructor.name}(${this.#e})}`}};var Uo=class{#e;#t;#r;#i=!1;constructor(){this.#e=b.newSet(e=>e.adapter.uuid),this.#t=new Set,this.#r=new Set}attachChannelStrip(e){return this.#e.add(e),O.many(e.adapter.input.subscribe(()=>this.#s()),e.adapter.output.subscribe(()=>this.#s()),{terminate:()=>{this.#t.delete(e),this.#e.removeByValue(e),this.#s()}})}onChannelStripSoloChanged(e){e.isSolo?this.#t.add(e):this.#t.delete(e),this.#s()}hasChannelSolo(){return this.#t.size>0}isVirtualSolo(e){return this.#r.has(e)}#s(){this.#i||(this.#i=!0,this.#e.forEach(e=>e.requestSoloUpdate()))}updateSolo(){if(!this.#i)return;this.#r.clear();let e=new Set,t=r=>{e.has(r)||(e.add(r),r.adapter.input.getValue().ifSome(s=>{s.type==="bus"&&s.box.input.pointerHub.filter(l.AudioOutput).map(o=>U(o.box.accept({visitAudioUnitBox:({address:{uuid:n}})=>this.#e.get(n),visitAuxSendBox:({audioUnit:{targetVertex:n}})=>this.#e.get(n.unwrap().address.uuid)}),"Could not resolve channel-strip")).forEach(o=>{o.isSolo||this.#r.add(o),t(o)})}))};this.#e.forEach(r=>{r.isSolo&&t(r)}),this.#i=!1}};var Gt;(function(i){let e=typeof self<"u"&&"location"in self&&typeof self.location!==void 0,t=typeof self<"u"&&"navigator"in self&&typeof self.navigator!==void 0;i.isLocalHost=()=>e&&location.host.includes("localhost"),i.isMacOS=()=>t&&navigator.userAgent.includes("Mac OS X"),i.isWindows=()=>t&&navigator.userAgent.includes("Windows"),i.isFirefox=()=>t&&navigator.userAgent.toLowerCase().includes("firefox"),i.isWeb=()=>!i.isTauriApp(),i.isVitest=typeof process<"u"&&process.env?.VITEST==="true",i.isTauriApp=()=>"__TAURI__"in window,i.userAgent=t?navigator.userAgent.replace(/^Mozilla\/[\d.]+\s*/,"").replace(/\bAppleWebKit\/[\d.]+\s*/g,"").replace(/\(KHTML, like Gecko\)\s*/g,"").replace(/\bSafari\/[\d.]+\s*/g,"").replace(/\s+/g," ").trim():"N/A"})(Gt||(Gt={}));var Ma;(function(i){i.encode=async(e,t="gzip")=>{let r=new CompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()},i.decode=async(e,t="gzip")=>{let r=new DecompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()}})(Ma||(Ma={}));var Ta;(function(i){i.exportMethod=(s,o)=>r(s,{value:o}),i.exportBoolean=(s,o=!1)=>{let n=new Pe(o);return i.exportAccessor(s,()=>n.getValue(),a=>{let u=!!a;console.debug(`set to ${u}`),n.setValue(u)}),n},i.exportAccessor=(s,o,n=Vn)=>r(s,{get:()=>{try{return console.debug(o()),0}catch(a){return console.error(a),1}},set:a=>{try{return n(a),o()}catch(u){return console.error(u),1}},enumerable:!1,configurable:!1});let e=(()=>{try{return self}catch{return{}}})(),t=e.opendaw??={},r=(s,o)=>{let n=s.split("."),a=n.splice(-1)[0],u=t;for(let h of n)u=u[h]??={};Object.defineProperty(u,a,o),console.debug(`Console command 'opendaw.${s}' exported`)}})(Ta||(Ta={}));var Va;(function(i){i.resolveString=e=>{if(!pr(e)){if(typeof e=="string")return e;if(Array.isArray(e))return e.join(",");if(typeof e=="object"){if(typeof e.exact=="string")return e.exact;if(Array.isArray(e.exact))return e.exact.join(",");if(typeof e.ideal=="string")return e.ideal;if(Array.isArray(e.ideal))return e.ideal.join(",")}}}})(Va||(Va={}));var Da;(function(i){i.truncateText=(e,t,r)=>{if(t.length===0)return{text:"",width:0};let s=e.measureText(t).width;if(s<=r)return{text:t,width:s};let o=e.measureText("\u2026").width,n=0,a=t.length|0;for(;n<a;){let h=a+n>>>1;s=e.measureText(t.substring(0,h+1)).width+o,s<=r?n=h+1:a=h}if(n===0)return{text:"",width:0};let u=t.substring(0,n);return{text:u+"\u2026",width:e.measureText(u).width+o}}})(Da||(Da={}));var Ia;(function(i){i.calc=(t,r,s)=>{let o=/([0-9]*\.?[0-9]+)([a-zA-Z%]*)/g,n=t;return n.split(/\+|(?<!\d)-/).flatMap(a=>Array.from(a.matchAll(o))).forEach(([a,u,h])=>{let d=parseFloat(u);if(isNaN(d))return y(`${a} does not contain a number`);if(h==="em")n=n.replaceAll(a,`${d*s}`);else if(h==="%")n=n.replaceAll(a,`${d/100*r}`);else if(h==="px")n=n.replaceAll(a,`${d}`);else return y(`Unknown unit '${h}'`)}),Function(`return ${n}`)()};let e=new Map;i.registerCustomCursor=(t,r)=>e.set(t,r),i.setCursor=(t,r=document)=>{r.documentElement.style.cursor=typeof t=="number"?e.get(t)??"auto":t}})(Ia||(Ia={}));var Pi;(function(i){let e=new Set,t=new Set,r=new Array,s=-1;i.add=o=>(t.add(o),{terminate:()=>t.delete(o)}),i.once=o=>{e.add(o)},i.start=()=>{console.debug("AnimationFrame start");let o=()=>{(t.size>0||e.size>0)&&(t.forEach(n=>r.push(n)),e.forEach(n=>r.push(n)),e.clear(),r.forEach(n=>n()),r.length=0),s=requestAnimationFrame(o)};s=requestAnimationFrame(o)},i.terminate=()=>{console.debug("AnimationFrame terminate"),e.clear(),t.clear(),r.length=0,cancelAnimationFrame(s)}})(Pi||(Pi={}));var De=class{static subscribe(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static subscribeAny(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static DOUBLE_DOWN_THRESHOLD=200;static subscribeDblDwn=(e,t)=>{let r=0;return this.subscribe(e,"pointerdown",s=>{let o=performance.now();o-r<this.DOUBLE_DOWN_THRESHOLD&&t(s),r=o},{capture:!0})};static PreventDefault=e=>e.preventDefault();static isTextInput=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&D(e.getAttribute("contenteditable"))};var Wt;(function(i){i.isControlKey=({ctrlKey:e,metaKey:t})=>Gt.isMacOS()?t:e,i.isCopyKey=({altKey:e})=>e,i.GlobalShortcut=Object.freeze({isDelete:e=>!De.isTextInput(e.target)&&(e.code==="Delete"||e.code==="Backspace"),isSelectAll:e=>i.isControlKey(e)&&!e.shiftKey&&e.code==="KeyA",isDeselectAll:e=>i.isControlKey(e)&&e.shiftKey&&e.code==="KeyA"})})(Wt||(Wt={}));var Oa;(function(i){i.attach=(e,t,r)=>{let s=new V;return O.many(s,De.subscribe(e,"pointerdown",o=>{if(r?.multiTouch!==!0&&!o.isPrimary||o.buttons!==1||Gt.isMacOS()&&o.ctrlKey)return;let n=t(o);if(n.isEmpty())return;let a=n.unwrap(),u=o.pointerId;o.stopPropagation(),o.stopImmediatePropagation(),e.setPointerCapture(u);let h={clientX:o.clientX,clientY:o.clientY,altKey:o.altKey,shiftKey:o.shiftKey,ctrlKey:Wt.isControlKey(o)};r?.immediate===!0&&a.update(h),r?.permanentUpdates===!0?(s.own(Pi.add(()=>a.update(h))),s.own(De.subscribe(e,"pointermove",p=>{p.pointerId===u&&(h.clientX=p.clientX,h.clientY=p.clientY,h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p))}))):s.own(De.subscribe(e,"pointermove",p=>{p.pointerId===u&&(h.clientX=p.clientX,h.clientY=p.clientY,h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p),a.update(h))}));let d=()=>{a.cancel?.call(a),a.finally?.call(a),s.terminate()};s.ownAll(De.subscribe(e,"pointerup",p=>{p.pointerId===u&&(a.approve?.call(a),a.finally?.call(a),s.terminate())},{capture:!0}),De.subscribe(e,"pointercancel",p=>{console.debug(p.type),p.pointerId===u&&(e.releasePointerCapture(u),d())},{capture:!0}),De.subscribe(self,"beforeunload",p=>{e.releasePointerCapture(u),d()},{capture:!0}),De.subscribe(window,"keydown",p=>{h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p),p.key==="Escape"?d():a.update(h)}),De.subscribe(window,"keyup",p=>{h.altKey=p.altKey,h.shiftKey=p.shiftKey,h.ctrlKey=Wt.isControlKey(p),a.update(h)})),a.abortSignal&&s.own(De.subscribe(a.abortSignal,"abort",()=>{e.releasePointerCapture(u),d()}))}))}})(Oa||(Oa={}));var ka;(function(i){i.save=async(e,t)=>{if(D(window.showSaveFilePicker)){let r=await window.showSaveFilePicker(t),s=await r.createWritable();return await s.truncate(0),await s.write(e),await s.close(),r.name??"unknown"}else{let r=new Blob([e]),s=URL.createObjectURL(r),o=document.createElement("a");return o.href=s,o.download=t?.suggestedName??"unknown",o.click(),URL.revokeObjectURL(s),t?.suggestedName??"Unknown"}},i.open=async e=>{if(D(window.showOpenFilePicker)){let{status:t,value:r,error:s}=await Qe.tryCatch(window.showOpenFilePicker(e));return t==="rejected"?Promise.reject(s):Promise.all(r.map(o=>o.getFile()))}else return new Promise((t,r)=>{D(e)&&console.warn("FileApi.showOpenFilePicker is emulated in this browser. OpenFilePickerOptions are ignored.");let s=document.createElement("input");s.type="file",s.multiple=e?.multiple??!1,s.style.display="none",s.addEventListener("cancel",async()=>{s.remove(),r(new DOMException("cancel","AbortError"))}),s.addEventListener("change",async o=>{let a=o.target.files;D(a)?t(w.create(u=>U(a.item(u),`No file at index ${u}`),a.length)):r(new DOMException("cancel","AbortError")),s.remove()}),document.body.appendChild(s),s.click()})}})(ka||(ka={}));var Ua;(function(i){i.parse=e=>{let t=document.createElement("div");if(t.innerHTML=e,t.childElementCount!==1)return y(`Source html has more than one root elements: '${e}'`);let r=t.firstChild;return r instanceof HTMLElement||r instanceof SVGSVGElement?r:y(`Cannot parse to HTMLOrSVGElement from '${e}'`)},i.empty=e=>{for(;e.firstChild!==null;)e.firstChild.remove()},i.query=(e,t=document)=>U(t.querySelector(e)),i.queryAll=(e,t=document)=>Array.from(t.querySelectorAll(e)),i.sanitize=e=>{e.querySelectorAll("script").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(r=>{r.name.toLowerCase().startsWith("on")&&t.removeAttribute(r.name)})})},i.nextID=(()=>{let e=0;return()=>(++e).toString(16).padStart(4,"0")})(),i.adoptStyleSheet=(e,t)=>{v(e.includes("component"),`No 'component' found in: ${e}`);let r=`${t??"C"}${i.nextID()}`,s=new CSSStyleSheet;return s.replaceSync(e.replaceAll("component",`.${r}`)),s.cssRules.length===0?y(`No cssRules found in: ${e}`):(document.adoptedStyleSheets.push(s),r)},i.buildClassList=(...e)=>e.filter(t=>t!==!1&&t!==void 0).join(" "),i.readCssVarColor=(...e)=>{let t=document.createElement("div");document.body.appendChild(t);let r=e.map(s=>(t.style.color=s,Ci.parseCssRgbOrRgba(getComputedStyle(t).color)));return t.remove(),r},i.watchResize=(e,t,r)=>{let s=new ResizeObserver(([o],n)=>t(o,n));return s.observe(e,r),{terminate:()=>s.disconnect()}},i.watchIntersection=(e,t,r)=>{let s=new IntersectionObserver(t,r);return s.observe(e),{terminate:()=>s.disconnect()}},i.secureBoundingBox=e=>{let t=e.getBoundingClientRect();if(!li.isEmpty(t))return t;for(let r of e.children)li.union(t,i.secureBoundingBox(r));return t},i.unfocus=(e=self)=>{let t=e.document.activeElement;t!==null&&"blur"in t&&typeof t.blur=="function"&&t.blur()},i.selectContent=e=>{let t=document.createRange(),r=window.getSelection();D(r)&&(t.selectNodeContents(e),r.removeAllRanges(),r.addRange(t))},i.unselectContent=e=>{let t=window.getSelection();!D(t)||t.rangeCount===0||e.contains(t.getRangeAt(0).commonAncestorContainer)&&t.removeAllRanges()},i.limitChars=(e,t,r)=>{if(!(t in e))return y(`${t} not found in ${e}`);if(typeof e[t]!="string")return y(`${t} in ${e} is not a string`);if(e[t].length>r)if(e[t]=e[t].substring(0,r),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.setSelectionRange(r,r);else{let s=e.ownerDocument,o=s.createRange(),n=s.defaultView?.getSelection();if(!D(n))return;o.selectNodeContents(e),o.collapse(!1),n.removeAllRanges(),n.addRange(o)}},i.EmptyGif="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})(Ua||(Ua={}));var LI=(()=>{let i={Cmd:"\u2318",Opt:"\u2325",Shift:"\u21E7"},e={Cmd:"Ctrl",Opt:"Alt",Shift:"\u21E7"};return Object.freeze({Mac:i,Win:e,System:Gt.isMacOS()?i:e})})();var Ka;(function(i){i.read=async e=>{let t=[];for(;;){let{done:n,value:a}=await e.read();if(n)break;t.push(a)}let r=t.reduce((n,a)=>n+a.length,0),s=new Uint8Array(r),o=0;for(let n of t)s.set(n,o),o+=n.length;return s.buffer}})(Ka||(Ka={}));var La;(function(i){i.pathBuilder=()=>new class{#e="";moveTo(e,t){return this.#e+=`M${e.toFixed(3)} ${t.toFixed(3)}`,this}lineTo(e,t){return this.#e+=`L${e.toFixed(3)} ${t.toFixed(3)}`,this}quadratic(e,t,r,s){return this.#e+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)}`,this}quadraticTo(e,t){return this.#e+=`T${e.toFixed(3)} ${t.toFixed(3)}`,this}cubic(e,t,r,s,o,n){return this.#e+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)} ${o.toFixed(3)} ${n.toFixed(3)}`,this}arc(e,t,r,s,o,n,a){return this.#e+=`A${e} ${t} ${r} ${s?1:0} ${o?1:0} ${n.toFixed(3)} ${a.toFixed(3)}`,this}circleSegment(e,t,r,s,o){let n=e+Math.cos(s)*r,a=t+Math.sin(s)*r,u=e+Math.cos(o)*r,h=t+Math.sin(o)*r,d=o-s;for(;d<0;)d+=Math.PI*2;return this.moveTo(n,a).arc(r,r,0,d>Math.PI,!0,u,h)}close(){return this.#e+="Z",this}get(){return this.#e}}})(La||(La={}));var $a;(function(i){let e=new Array;i.watchWeak=(r,s)=>{let o=new WeakRef(r),n=s(o);return e.push([o,n]),e.length===1&&t(),r};let t=()=>{console.debug("start weak watching");let r=setInterval(()=>{let s=e.length;for(;--s>=0;){let o=e[s];o[0].deref()===void 0&&(o[1].terminate(),e.splice(s,1),e.length===0&&clearInterval(r))}},1e3)}})($a||($a={}));var Ko=Symbol.for("@openDAW/lib-dom");globalThis[Ko]?console.debug(`%c${Ko.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Ko]=!0,console.debug(`%c${Ko.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var xt;(function(i){i[i.Float=0]="Float",i[i.FloatArray=1]="FloatArray",i[i.Integer=2]="Integer",i[i.IntegerArray=3]="IntegerArray",i[i.ByteArray=4]="ByteArray"})(xt||(xt={}));var si;(function(i){i[i.WRITE=0]="WRITE",i[i.READ=1]="READ"})(si||(si={}));var dr;(function(i){i[i.ID=15793935]="ID",i[i.START=15790320]="START",i[i.END=986895]="END"})(dr||(dr={}));var Lo=class i{static create(e,t){return new i(e.channel(t))}#e=[];#t=new SharedArrayBuffer(1);#r=new Int8Array(this.#t);#i;#s=ue.create(0);#o=m.None;#n=m.None;#a=-1;#l=-1;#u=!1;#h=!1;constructor(e){this.#i=Re.sender(e,({dispatchAndForget:t})=>new class{sendShareLock(r){t(this.sendShareLock,r)}sendUpdateData(r){t(this.sendUpdateData,r)}sendUpdateStructure(r){t(this.sendUpdateStructure,r)}})}flush(){let e=this.#c();if(e.nonEmpty()){this.#h||(this.#i.sendShareLock(this.#t),this.#h=!0),this.#i.sendUpdateStructure(e.unwrap());let t=this.#d();if(this.#s.remaining<t){let r=ot(t),s=new SharedArrayBuffer(r);this.#s=ue.use(s),this.#o=m.wrap(s),this.#i.sendUpdateData(s)}}this.#o.isEmpty()||Atomics.load(this.#r,0)===si.WRITE&&(this.#p(this.#s),this.#s.position=0,Atomics.store(this.#r,0,si.READ))}broadcastFloat(e,t){return this.#f(new class{type=xt.Float;address=e;capacity=8;put(r){r.writeFloat(t())}})}broadcastInteger(e,t){return this.#f(new class{type=xt.Integer;address=e;capacity=8;put(r){r.writeInt(t())}})}broadcastFloats(e,t,r){return this.#f(new class{type=xt.FloatArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length);for(let o of t)s.writeFloat(o)}})}broadcastIntegers(e,t,r){return this.#f(new class{type=xt.IntegerArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length),t.forEach(o=>s.writeInt(o))}})}broadcastByteArray(e,t,r){return this.#f(new class{type=xt.ByteArray;address=e;capacity=4+t.byteLength;put(s){r(),s.writeInt(t.byteLength),s.writeBytes(t)}})}#c(){if(this.#u){try{this.#n=m.wrap(this.#F())}catch(e){throw e}this.#u=!1}if(this.#n.nonEmpty()){let e=this.#n;return this.#n=m.None,e}return m.None}#d(){return this.#l===-1&&(this.#l=this.#g()+12),this.#l}terminate(){w.clear(this.#e),this.#n=m.None,this.#u=!1,this.#l=0}#p(e){v(!this.#u&&this.#n.isEmpty(),"Cannot flush while update is available");let t=this.#d();v(e.remaining>=t,"Insufficient data"),e.writeInt(this.#a),e.writeInt(dr.START);for(let r of this.#e)r.put(e);e.writeInt(dr.END)}#g(){return this.#e.reduce((e,t)=>e+t.capacity,0)}#f(e){return this.#e.push(e),this.#x(),{terminate:()=>{w.removeOpt(this.#e,e),this.#x()}}}#x(){this.#l=-1,this.#u=!0}#F(){let e=ue.create();e.writeInt(dr.ID),e.writeInt(++this.#a),e.writeInt(this.#e.length);for(let{address:t,type:r}of this.#e)t.write(e),e.writeByte(r);return e.toArrayBuffer()}};var jt;(function(i){class e{shift;numPeaks;dataOffset;constructor(r,s,o){this.shift=r,this.numPeaks=s,this.dataOffset=o}unitsEachPeak(){return 1<<this.shift}}i.Stage=e,i.unpack=(t,r)=>{switch(r){case 0:return vt.intBitsToFloat(t);case 1:return vt.intBitsToFloat(t>>16);default:return it(r)}}})(jt||(jt={}));var $o=class i{stages;data;numFrames;numChannels;static from(e){v(e.readString()==="PEAKS","Wrong header");let t=e.readInt(),r=[];for(let u=0;u<t;u++){let h=e.readInt(),d=e.readInt(),p=e.readInt();e.readInt(),r[u]=new jt.Stage(p,d,h)}let s=e.readInt(),o=[];for(let u=0;u<s;u++){let h=new Int8Array(e.readInt());e.readBytes(h),o[u]=new Int32Array(h.buffer)}let n=e.readInt(),a=e.readInt();return new i(r,o,n,a)}static None=new i([],[],0,0);static findBestFit=(e,t=1200)=>{let r=e/t;if(r<=1)return new Uint8Array(0);let s=3,o=Math.floor(Math.log(r)/Math.LN2),n=Math.max(1,Math.floor(o/s));return new Uint8Array(w.create(a=>s*(a+1),n))};constructor(e,t,r,s){this.stages=e,this.data=t,this.numFrames=r,this.numChannels=s}nearest(e){if(this.stages.length===0)return null;let t=Math.floor(Math.log(Math.abs(e))/Math.LN2),r=this.stages.length;for(;--r>-1;)if(t>=this.stages[r].shift)return this.stages[r];return this.stages[0]}toArrayBuffer(){let e=ue.create();e.writeString("PEAKS"),e.writeInt(this.stages.length);for(let t=0;t<this.stages.length;t++){let{dataOffset:r,numPeaks:s,shift:o}=this.stages[t];e.writeInt(r),e.writeInt(s),e.writeInt(o),e.writeInt((1<<o)-1)}e.writeInt(this.data.length);for(let t=0;t<this.data.length;t++){let r=new Int8Array(this.data[t].buffer);e.writeInt(r.length),e.writeBytes(r)}return e.writeInt(this.numFrames),e.writeInt(this.numChannels),e.toArrayBuffer()}toString(){return`{SamplePeaks num-stages: ${this.stages.length}}`}};var qa;(function(i){i.install=r=>Re.executor(r.channel("peaks"),new class{async generateAsync(s,o,n,a,u){return e(s,o,n,a,u).toArrayBuffer()}});let e=(r,s,o,n,a)=>{if(o.length!==a)return y(`Invalid numberOfChannels. Expected: ${a}. Got ${o.length}`);class u{min=Number.POSITIVE_INFINITY;max=Number.NEGATIVE_INFINITY;index=0}let h=da(),d=s.length,[p,f]=t(s,n),A=w.create(()=>new Int32Array(f),a),N=(1<<p[0].shift)-1,S=a*n,M=0;for(let k=0;k<a;++k){let K=A[k],q=o[k],z=w.create(()=>new u,d),ee=Number.POSITIVE_INFINITY,he=Number.NEGATIVE_INFINITY,ce=0;for(let _=0;_<n;++_){let j=q[_];if(ee=Math.min(j,ee),he=Math.max(j,he),(++ce&N)===0){for(let H=0;H<d;++H){let Y=p[H],ae=z[H];ae.min=Math.min(ae.min,ee),ae.max=Math.max(ae.max,he),((1<<Y.shift)-1&ce)===0&&(K[Y.dataOffset+ae.index++]=i.pack(ae.min,ae.max),ae.min=Number.POSITIVE_INFINITY,ae.max=Number.NEGATIVE_INFINITY)}ee=Number.POSITIVE_INFINITY,he=Number.NEGATIVE_INFINITY}(++M&65535)===0&&r(M/S)}}return r(1),h.lab(`SamplePeaks '${self.constructor.name}'`),new $o(p,A,n,a)},t=(r,s)=>{let o=0;return[w.create(a=>{let u=r[a],h=Math.ceil(s/(1<<u)),d=new jt.Stage(u,h,o);return o+=h,d},r.length),o]};i.pack=(r,s)=>{let o=vt.floatToIntBits(r),n=vt.floatToIntBits(s);return o|n<<16}})(qa||(qa={}));var za;(function(i){i.renderBlocks=(e,t,r,{u0:s,u1:o,v0:n,v1:a,x0:u,x1:h,y0:d,y1:p})=>{let f=(o-s)/(h-u),A=t.nearest(f);if(A===null)return;let N=(p-d-1)/(a-n),S=A.unitsEachPeak(),M=u-Math.floor(u),k=f/S,K=(s-M*f)/f*k,q=Math.floor(K),z=0,ee=0,he=t.data[r];for(let ce=Math.floor(u);ce<Math.floor(h);ce++){let _=K+k,j=Math.floor(_),H=!1;for(;q<j;){let Ge=he[A.dataOffset+q++];z=Math.min(jt.unpack(Ge,0),z),ee=Math.max(jt.unpack(Ge,1),ee),H=!0}let Y=d+Math.floor((z-n)*N),ae=d+Math.floor((ee-n)*N),He=Math.max(d,Math.min(Y,ae)),rt=Math.min(p,Math.max(Y,ae));if(e.fillRect(ce,He,1,rt===He?1:rt-He),H){let Ge=ee;ee=z,z=Ge}K=_,q=j}}})(za||(za={}));var _a;(function(i){let t=new Qe.Limit(1),r=new Qe.Limit(1);i.init=o=>Re.executor(o.channel("opfs"),new class{async write(n,a){return r.add(()=>this.#e(n,{create:!0}).then(u=>{u.truncate(a.length),u.write(a.buffer,{at:0}),u.flush(),u.close()}))}async read(n){return t.add(()=>this.#e(n).then(a=>{let u=a.getSize(),h=new Uint8Array(u);return a.read(h),a.close(),h}))}async delete(n){let a=s(n);return this.#t(a.slice(0,-1)).then(u=>u.removeEntry(U(a.at(-1)),{recursive:!0}))}async list(n){let a=s(n),{status:u,value:h}=await Qe.tryCatch(this.#t(a));if(u==="rejected")return w.empty();let d=[];for await(let{name:p,kind:f}of h.values())d.push({name:p,kind:f});return d}async#e(n,a){let u=s(n);return this.#t(u.slice(0,-1),a).then(h=>h.getFileHandle(U(u.at(-1)),a).then(d=>d.createSyncAccessHandle()))}async#t(n,a){let u=await navigator.storage.getDirectory();for(let h of n)u=await u.getDirectoryHandle(h,a);return u}});let s=o=>{let n=o.replace(/^\/+|\/+$/g,"");return n===""?[]:n.split("/")}})(_a||(_a={}));var qo=Symbol.for("@openDAW/lib-fusion");globalThis[qo]?console.debug(`%c${qo.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[qo]=!0,console.debug(`%c${qo.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var zo=class{#e;#t=new re;#r=[];constructor(e){this.#e=e}process({blocks:e}){e.forEach(({p0:t,p1:r,bpm:s,s0:o,s1:n,flags:a})=>{if(this.#e.metronomeEnabled&&ye.every(a,1))for(let u of Bt.iterate(t,r,G.Quarter)){v(t<=u&&u<r,`${u} out of bounds (${t}, ${r})`);let h=Math.floor(G.pulsesToSamples(u-t,s,sampleRate));this.#r.push(new Sn(u,o+h))}this.#t.clear(o,n);for(let u=this.#r.length-1;u>=0;u--)this.#r[u].processAdd(this.#t,o,n)&&this.#r.splice(u,1)})}get output(){return this.#t}},Sn=class{#e;#t=0;#r=0;constructor(e,t){v(t>=0&&t<128,`${t} out of bounds`),this.#e=G.toParts(e).beats===0?880:440,this.#r=t}processAdd(e,t,r){let[s,o]=e.channels(),n=Math.floor(.002*sampleRate),a=Math.floor(.05*sampleRate);for(let u=Math.max(this.#r,t);u<r;u++){let h=Math.min(this.#t/n,1-(this.#t-n)/a),d=Math.sin(this.#t/sampleRate*qe*this.#e)*.25*h*h;if(s[u]+=d,o[u]+=d,++this.#t>n+a)return!0}return this.#r=0,!1}};var _o=class{#e;#t;#r=!1;#i=null;#s=!1;#o=0;constructor(e){this.#e=e,this.#e.timelineBoxAdapter.markerTrack.subscribe(()=>this.#s=!0),this.#e.timelineBoxAdapter.box.bpm.subscribe(()=>this.#r=!0),this.#t=new Ti}setCallback(e,t){return this.#t.add(e,t),O.create(()=>this.#t.remove(e,t))}reset(){this.#r=!1,this.#s=!1,this.#o=0,this.#i=null}process(e){let t=!1,{timeInfo:r,timelineBoxAdapter:{box:s,markerTrack:o}}=this.#e,n=s.bpm.getValue(),a=r.transporting;if(a){let u=[],h=r.position,d=0,p=0,f=r.getLeapStateAndReset();for(;d<128;){if(this.#s||f){this.#s=!1;let _=o.events.lowerEqual(h);(this.#i?.at(0)??null)!==_&&(this.#i=D(_)?[_,0]:null,t=!0)}let A=128-d,N=h+G.samplesToPulses(A,n,sampleRate),S=null,M=Number.POSITIVE_INFINITY;if(o.enabled){let _=Array.from(se.take(o.events.iterateFrom(h),2));if(_.length>0){let[j,H]=_;this.#i===null?j.position>=h&&j.position<N&&(S={type:"marker",prev:j,next:H},M=j.position):D(H)&&H!==this.#i[0]&&j.position<h&&H.position<N&&(S={type:"marker",prev:j,next:H},M=H.position)}}let{isRecording:k,isCountingIn:K}=this.#e.timeInfo,{from:q,to:z,enabled:ee}=s.loopArea;if(ee.getValue()&&!(k||K)){let _=z.getValue();h<_&&N>_&&_<M&&(S={type:"loop",target:q.getValue()},M=_)}if(this.#t.keyCount()>0)for(let _ of this.#t.keys())h<_&&N>_&&_<M&&(S={type:"callback",position:_,callbacks:this.#t.get(_)},M=_);let ce=!r.isCountingIn;if(S===null){let _=d+A;u.push({index:p++,p0:h,p1:N,s0:d,s1:_,bpm:n,flags:Ai.create(a,f,ce,this.#r)}),f=!1,h=N,d=_}else{let _=()=>{if(M>h){let j=d+G.pulsesToSamples(M-h,n,sampleRate)|0;u.push({index:p++,p0:h,p1:M,s0:d,s1:j,bpm:n,flags:Ai.create(a,f,ce,this.#r)}),f=!1,h=M,d=j}};switch(S.type){case"loop":{_(),h=S.target,f=!0;break}case"marker":{let{prev:j,next:H}=S;!D(this.#i)||this.#i[0]!==j?this.#i=[j,0]:++this.#i[1]<j.plays||j.plays===0?(_(),h=j.position,f=!0):this.#i=[H,0],t=!0;break}case"callback":{_(),S.callbacks.forEach(j=>j());break}}}this.#r=!1}e({blocks:u}),r.advanceTo(h),this.#o=h}else{if(this.#s||r.getLeapStateAndReset()){this.#s=!1;let p=o.events.lowerEqual(r.position);p!==null&&this.#i?.at(0)!==p&&(this.#i=[p,0],t=!0)}let u=this.#o,h=u+G.samplesToPulses(128,n,sampleRate),d={blocks:[{index:0,p0:u,p1:h,s0:0,s1:128,bpm:n,flags:Ai.create(!1,!1,!1,!1)}]};e(d),this.#o=h}t&&this.#e.engineToClient.switchMarkerState(D(this.#i)?[this.#i[0].uuid,this.#i[1]]:null)}};var Cn=class{constructor(e,t){this.uuid=e;this.engineToClient=t;t.fetchAudio(e).then(r=>this.#t=m.wrap(r))}peaks=m.None;#e={type:"idle"};#t=m.None;get data(){return this.#t}get state(){return this.#e}subscribe(e){return O.Empty}invalidate(){}toString(){return"{AudioLoaderWorklet}"}},Ho=class{#e;#t;constructor(e){this.#e=e,this.#t=b.newSet(t=>t.uuid)}record(e){}getOrCreate(e){return this.#t.getOrCreate(e,t=>new Cn(t,this.#e))}remove(e){}invalidate(e){}};var Go=class{constructor(e){this.uuid=e}waiting=m.None;playing=m.None},Wo=class{#e;#t;#r=[];#i=[];#s=[];constructor(e){this.#e=e,this.#e.subscribeToAllUpdatesImmediate({onUpdate:t=>{if(t.type==="delete"){let r=t.uuid;this.#t.opt(r).ifSome(s=>{s.playing.ifSome(o=>this.#n(o.uuid)),s.playing=m.None,s.waiting=m.None}),this.#t.forEach(s=>{s.playing.nonEmpty()&&b.equals(s.playing.unwrap().uuid,r)&&(s.playing=m.None,this.#n(r));let o=s.waiting.flatMap(ni);o.nonEmpty()&&b.equals(o.unwrap().uuid,r)&&(s.waiting=m.None)})}}}),this.#t=b.newSet(t=>t.uuid)}schedulePlay(e){e.trackBoxAdapter.ifSome(({uuid:t})=>{let r=this.#t.getOrCreate(t,o=>new Go(o));if(r.playing.nonEmpty()&&r.playing.unwrap()===e){console.debug(`${e} is already playing (ignore)`);return}let s=r.waiting.flatMap(o=>o);s.nonEmpty()&&(console.debug("obsolete",s.unwrap()),this.#s.push(s.unwrap().uuid),r.waiting=m.None),console.debug(`schedulePlay(${b.toString(r.uuid)} > ${e})`),w.removeOpt(this.#s,e.uuid),r.waiting=m.wrap(m.wrap(e))})}scheduleStop({uuid:e}){let t=this.#t.getOrCreate(e,s=>new Go(s)),r=t.waiting.flatMap(s=>s);r.nonEmpty()&&(console.debug("obsolete",r.unwrap()),this.#s.push(r.unwrap().uuid),t.waiting=m.None),t.playing.nonEmpty()&&(console.debug(`scheduleStop(${b.toString(e)})`),t.waiting=m.wrap(m.None))}reset(){this.#t.forEach(e=>{e.waiting.ifSome(t=>t.ifSome(r=>this.#s.push(r.uuid))),e.waiting=m.None,e.playing.ifSome(t=>this.#n(t.uuid)),e.playing=m.None}),this.#t.clear()}*iterate(e,t,r){let s=this.#t.getOrNull(e);if(s===null){yield{optClip:m.None,sectionFrom:t,sectionTo:r};return}if(s.waiting.nonEmpty()){let o=s.waiting.unwrap(),n=s.playing.mapOr(u=>u.duration,G.Bar),a=st(r,n);a>=t?(t<a&&(yield{optClip:s.playing,sectionFrom:t,sectionTo:a}),s.waiting=m.None,s.playing.ifSome(u=>this.#n(u.uuid)),o.nonEmpty()?(s.playing=o,this.#o(o.unwrap().uuid)):s.playing=m.None,yield{optClip:s.playing,sectionFrom:a,sectionTo:r}):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}else if(s.playing.nonEmpty()){let o=s.playing.unwrap();if(o.box.playback.loop.getValue())yield{optClip:s.playing,sectionFrom:t,sectionTo:r};else{let n=st(t,o.duration)+o.duration;n<=r?(yield{optClip:s.playing,sectionFrom:t,sectionTo:n},s.playing=m.None,this.#n(o.uuid),n<r&&(yield{optClip:m.None,sectionFrom:n,sectionTo:r})):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}}else yield{optClip:m.None,sectionFrom:t,sectionTo:r}}changes(){if(this.#r.length>0||this.#i.length>0||this.#s.length>0){let e=m.wrap({started:this.#r.slice(),stopped:this.#i.slice(),obsolete:this.#s.slice()});return this.#r.length=0,this.#i.length=0,this.#s.length=0,e}return m.None}terminate(){this.#t.clear(),this.#r.length=0,this.#i.length=0,this.#s.length=0}#o(e){this.#r.push(e)}#n(e){this.#i.push(e)}};var Rn;(e=>e.Default={includeAudioEffects:!0,includeSends:!0})(Rn||={});var Xa=!1,jo=class extends AudioWorkletProcessor{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u;#h;#c;#d;#p;#g;#f;#x;#F;#N;#P;#B;#V;#S;#v;#y=m.None;#b=m.None;#C=m.None;#R=!1;#M=!0;#A=!1;#E=0;#w=0;#T=4;constructor({processorOptions:{sab:e,project:t,exportConfiguration:r}}){super();let{boxGraph:s,mandatoryBoxes:{rootBox:o,timelineBox:n}}=oo.decode(t);this.#e=new V,this.#t=ha.for(this.port),this.#r=s,this.#i=new Xi,this.#s=Re.sender(this.#t.channel("engine-to-client"),a=>new class{log(u){a.dispatchAndForget(this.log,u)}fetchAudio(u){return a.dispatchAndReturn(this.fetchAudio,u)}notifyClipSequenceChanges(u){a.dispatchAndForget(this.notifyClipSequenceChanges,u)}switchMarkerState(u){a.dispatchAndForget(this.switchMarkerState,u)}ready(){a.dispatchAndForget(this.ready)}}),this.#n=new Ho(this.#s),this.#a=b.newSet(a=>a.adapter.uuid),this.#h=new so,this.#o=this.#e.own(new Xs(this)),this.#l=this.#o.adapterFor(o,Hr),this.#u=this.#o.adapterFor(n,Je),this.#c=new Ui,this.#d=new Ki(this.#c),this.#p=new $,this.#g=new Uo,this.#P=new zo(this.#i),this.#B=new _o(this),this.#v=b.newSet(a=>a),this.#V=vr.writer(Pa(),e,a=>{let{transporting:u,isCountingIn:h,isRecording:d,position:p}=this.#i;a.position=p,a.playbackTimestamp=this.#w,a.countInBeatsTotal=this.#T,a.countInBeatsRemaining=h?(this.#E-p)/G.Quarter:0,a.isPlaying=u,a.isRecording=d,a.isCountingIn=h}),this.#f=this.#e.own(Lo.create(this.#t,"engine-live-data")),this.#F=new lo(this),this.#N=this.#e.own(new ne(this.#f,Q.compose(b.Lowest))),this.#x=this.#e.own(new Wo(this.#r)),this.#e.ownAll(fa(this.#r,this.#t.channel("engine-sync")),Re.executor(this.#t.channel("engine-commands"),{play:()=>{this.#i.position=this.#w,this.#i.transporting=!0},stop:a=>{(this.#i.isRecording||this.#i.isCountingIn)&&(this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.position=this.#w);let u=this.#i.transporting;this.#i.transporting=!1,this.#i.metronomeEnabled=this.#A,this.#v.clear(),(a||!u)&&this.#D()},setPosition:a=>{this.#i.isRecording||(this.#i.position=this.#w=a)},startRecording:a=>{if(!(this.#i.isRecording||this.#i.isCountingIn))if(!this.#i.transporting&&a){let u=this.#i.position,h=this.#u.box.signature.nominator.getValue(),d=this.#u.box.signature.denominator.getValue();this.#E=st(u,G.fromSignature(h,d)),this.#i.isCountingIn=!0,this.#i.metronomeEnabled=!0,this.#i.transporting=!0,this.#i.position=this.#E-G.fromSignature(this.#T,d);let p=this.#B.setCallback(this.#E,()=>{this.#i.isCountingIn=!1,this.#i.isRecording=!0,this.#i.metronomeEnabled=this.#A,p.terminate()})}else this.#i.transporting=!0,this.#i.isRecording=!0},stopRecording:()=>{!this.#i.isRecording&&!this.#i.isCountingIn||(console.debug("STOP RECORDING"),this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#A,this.#i.transporting=!1,this.#v.clear())},setMetronomeEnabled:a=>this.#i.metronomeEnabled=this.#A=a,queryLoadingComplete:()=>Promise.resolve(this.#r.boxes().every(a=>a.accept({visitAudioFileBox:u=>this.#n.getOrCreate(u.address.uuid).data.nonEmpty()&&u.pointerHub.nonEmpty()})??!0)),panic:()=>this.#R=!0,noteSignal:a=>{if(_t.isOn(a)){let{uuid:u,pitch:h,velocity:d}=a;this.optAudioUnit(u).ifSome(p=>p.midiDeviceChain.noteSequencer.pushRawNoteOn(h,d))}else if(_t.isOff(a)){let{uuid:u,pitch:h}=a;this.optAudioUnit(u).ifSome(d=>d.midiDeviceChain.noteSequencer.pushRawNoteOff(h))}},ignoreNoteRegion:a=>this.#v.add(a),scheduleClipPlay:a=>{a.forEach(u=>{let h=this.#r.findBox(u);if(h.isEmpty())console.warn(`Could not scheduleClipPlay. Cannot find clip: '${b.toString(u)}'`);else{let d=Ls.for(this.#o,h.unwrap());this.#x.schedulePlay(d)}}),this.#i.transporting=!0},scheduleClipStop:a=>{a.forEach(u=>{let h=this.#r.findBox(u);h.isEmpty()?console.warn(`Could not scheduleClipStop. Cannot find track: '${b.toString(u)}'`):this.#x.scheduleStop(this.#o.adapterFor(h.unwrap(),me))})},terminate:()=>{this.#C.ifSome(a=>a.terminate()),this.#C=m.None,this.#M=!1,this.#v.clear(),this.#e.terminate()}}),this.#l.audioUnits.catchupAndSubscribe({onAdd:a=>{let u=b.toString(a.uuid),h=D(r?.[u])?r[u]:Rn.Default,d=new ko(this,a,h),p=this.#a.add(d);if(v(p,`Could not add ${d}`),d.adapter.isOutput){v(this.#b.isEmpty(),"Output can only assigned once."),this.#b=m.wrap(d);return}},onRemove:({uuid:a})=>this.#a.removeByKey(a).terminate(),onReorder:Xt})),this.#S=m.wrap(r).match({none:()=>w.empty(),some:a=>Object.keys(a).map(u=>this.#a.get(b.parse(u)))}),this.#s.ready(),console.log=(...a)=>this.#s.log(a.join(", "))}ignoresRegion(e){return this.#v.hasKey(e)}process(e,t){try{return this.render(e,t)}catch(r){throw this.#s.log(r),r}}render(e,[t]){if(!this.#M)return!1;if(this.#R)return y("Manual Panic");let r=this.#i.metronomeEnabled;this.#p.notify(0),this.#y.isEmpty()&&(this.#d.update(),this.#y=m.wrap(this.#d.sorted().concat()),Xa&&console.debug(`%cAudio-Graph%c
4
4
  ${this.#y.unwrap().map((o,n)=>`${n+1}: ${o}`).join(`
5
- `)}`,"color: hsl(200, 83%, 60%)","color: inherit"));let s=this.#y.unwrap();return this.#B.process(o=>{s.forEach(n=>n.process(o)),r&&this.#P.process(o)}),this.#S.length===0?(this.#b.unwrap().audioOutput().replaceInto(t),r&&this.#P.output.mixInto(t),this.#N.process(t[0],t[1])):this.#S.forEach((o,n)=>{let[a,u]=o.audioOutput().channels();t[n*2].set(a),t[n*2+1].set(u)}),this.#p.notify(1),this.#x.changes().ifSome(o=>this.#s.notifyClipSequenceChanges(o)),this.#V.tryWrite(),this.#f.flush(),!0}getAudioUnit(e){return this.#a.get(e)}optAudioUnit(e){return this.#a.opt(e)}subscribeProcessPhase(e){return this.#p.subscribe(e)}registerProcessor(e){return this.#c.addVertex(e),this.#y=m.None,{terminate:()=>{this.#c.removeVertex(e),this.#y=m.None}}}registerEdge(e,t){return this.#c.addEdge([e,t]),this.#y=m.None,{terminate:()=>{this.#c.removeEdge([e,t]),this.#y=m.None}}}get boxGraph(){return this.#r}get boxAdapters(){return this.#o}get sampleManager(){return this.#n}get rootBoxAdapter(){return this.#l}get timelineBoxAdapter(){return this.#u}get bpm(){return this.#u.box.bpm.getValue()}get liveStreamBroadcaster(){return this.#f}get liveStreamReceiver(){return y("Only available in main thread")}get parameterFieldAdapters(){return this.#h}get clipSequencing(){return this.#x}get broadcaster(){return this.#f}get updateClock(){return this.#F}get timeInfo(){return this.#i}get mixer(){return this.#g}get engineToClient(){return this.#s}get isMainThread(){return!1}get isAudioContext(){return!0}terminate(){console.debug(`terminate: ${this}`),this.#e.terminate(),this.#a.forEach(e=>e.terminate()),this.#a.clear()}#D(){this.#A=0,this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#w,this.#i.position=0,this.#i.transporting=!1,this.#B.reset(),this.#x.reset(),this.#d.sorted().forEach(e=>e.reset()),this.#N.clear()}};var Qo=class extends AudioWorkletProcessor{#e;constructor({processorOptions:e}){super(),this.#e=no.writer(e)}process(e){return this.#e.write(e[0]),!0}};registerProcessor("meter-processor",Hi);registerProcessor("engine-processor",jo);registerProcessor("recording-processor",Qo);
5
+ `)}`,"color: hsl(200, 83%, 60%)","color: inherit"));let s=this.#y.unwrap();return this.#B.process(o=>{s.forEach(n=>n.process(o)),r&&this.#P.process(o)}),this.#S.length===0?(this.#b.unwrap().audioOutput().replaceInto(t),r&&this.#P.output.mixInto(t),this.#N.process(t[0],t[1])):this.#S.forEach((o,n)=>{let[a,u]=o.audioOutput().channels();t[n*2].set(a),t[n*2+1].set(u)}),this.#p.notify(1),this.#x.changes().ifSome(o=>this.#s.notifyClipSequenceChanges(o)),this.#V.tryWrite(),this.#f.flush(),!0}getAudioUnit(e){return this.#a.get(e)}optAudioUnit(e){return this.#a.opt(e)}subscribeProcessPhase(e){return this.#p.subscribe(e)}registerProcessor(e){return this.#c.addVertex(e),this.#y=m.None,{terminate:()=>{this.#c.removeVertex(e),this.#y=m.None}}}registerEdge(e,t){return this.#c.addEdge([e,t]),this.#y=m.None,{terminate:()=>{this.#c.removeEdge([e,t]),this.#y=m.None}}}get boxGraph(){return this.#r}get boxAdapters(){return this.#o}get sampleManager(){return this.#n}get rootBoxAdapter(){return this.#l}get timelineBoxAdapter(){return this.#u}get bpm(){return this.#u.box.bpm.getValue()}get liveStreamBroadcaster(){return this.#f}get liveStreamReceiver(){return y("Only available in main thread")}get parameterFieldAdapters(){return this.#h}get clipSequencing(){return this.#x}get broadcaster(){return this.#f}get updateClock(){return this.#F}get timeInfo(){return this.#i}get mixer(){return this.#g}get engineToClient(){return this.#s}get isMainThread(){return!1}get isAudioContext(){return!0}terminate(){console.debug(`terminate: ${this}`),this.#e.terminate(),this.#a.forEach(e=>e.terminate()),this.#a.clear()}#D(){this.#w=0,this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#A,this.#i.position=0,this.#i.transporting=!1,this.#B.reset(),this.#x.reset(),this.#d.sorted().forEach(e=>e.reset()),this.#N.clear()}};var Qo=class extends AudioWorkletProcessor{#e;constructor({processorOptions:e}){super(),this.#e=no.writer(e)}process(e){return this.#e.write(e[0]),!0}};registerProcessor("meter-processor",Hi);registerProcessor("engine-processor",jo);registerProcessor("recording-processor",Qo);
6
6
  //# sourceMappingURL=processors.js.map