@opendaw/studio-core 0.0.25 → 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.
@@ -10,6 +10,8 @@ import { CaptureDevices } from "../capture/CaptureDevices";
10
10
  import { EngineFacade } from "../EngineFacade";
11
11
  import { EngineWorklet } from "../EngineWorklet";
12
12
  import { AudioWorklets } from "../AudioWorklets";
13
+ import { MIDILearning } from "../midi/MIDILearning";
14
+ import { ppqn } from "@opendaw/lib-dsp";
13
15
  export type RestartWorklet = {
14
16
  unload: Procedure<unknown>;
15
17
  load: Procedure<EngineWorklet>;
@@ -33,6 +35,7 @@ export declare class Project implements BoxAdaptersContext, Terminable, Terminab
33
35
  readonly userEditingManager: UserEditingManager;
34
36
  readonly parameterFieldAdapters: ParameterFieldAdapters;
35
37
  readonly liveStreamReceiver: LiveStreamReceiver;
38
+ readonly midiLearning: MIDILearning;
36
39
  readonly mixer: Mixer;
37
40
  readonly engine: EngineFacade;
38
41
  private constructor();
@@ -51,6 +54,10 @@ export declare class Project implements BoxAdaptersContext, Terminable, Terminab
51
54
  get isMainThread(): boolean;
52
55
  get liveStreamBroadcaster(): LiveStreamBroadcaster;
53
56
  get skeleton(): ProjectDecoder.Skeleton;
57
+ merge(options: {
58
+ insert: ppqn;
59
+ }, ...projects: ReadonlyArray<Project>): Promise<Project>;
60
+ extractIntoNew(): Promise<Project>;
54
61
  toArrayBuffer(): ArrayBufferLike;
55
62
  copy(): Project;
56
63
  terminate(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Project.d.ts","sourceRoot":"","sources":["../../src/project/Project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,SAAS,EAET,UAAU,EACV,eAAe,EACf,UAAU,EAEb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EACH,WAAW,EACX,YAAY,EACZ,KAAK,EAEL,OAAO,EACP,WAAW,EACX,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,cAAc,EAGd,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,qBAAqB,CAAA;AAE7E,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAA;AAG9C,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,CAAA;CAAE,CAAA;AAG3F,qBAAa,OAAQ,YAAW,kBAAkB,EAAE,UAAU,EAAE,eAAe;;IAC3E,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO;IAuCpC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO;IAM/D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAAG,OAAO;IAQ5E,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAE1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;IAC3C,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAA;IAClC,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAA;IACtC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IAEjC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;IACxB,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAA;IACnC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAA;IACvD,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,eAAqB;IAEpC,OAAO;IA8BP,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa;IAoBnF,cAAc,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAM7C,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC;IAC3C,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;IAC5D,KAAK,IAAI,UAAU;IAEnB,IAAI,GAAG,IAAI,UAAU,CAAmB;IACxC,IAAI,GAAG,IAAI,MAAM,CAAyC;IAC1D,IAAI,cAAc,IAAI,cAAc,CAAmE;IACvG,IAAI,kBAAkB,IAAI,kBAAkB,CAA2E;IACvH,IAAI,aAAa,IAAI,aAAa,CAAiC;IACnE,IAAI,cAAc,IAAI,cAAc,CAAkD;IACtF,IAAI,cAAc,IAAI,OAAO,CAAe;IAC5C,IAAI,YAAY,IAAI,OAAO,CAAc;IACzC,IAAI,qBAAqB,IAAI,qBAAqB,CAAkD;IAEpG,IAAI,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAWtC;IAED,aAAa,IAAI,eAAe;IAiBhC,IAAI,IAAI,OAAO;IAEf,SAAS,IAAI,IAAI;CACpB"}
1
+ {"version":3,"file":"Project.d.ts","sourceRoot":"","sources":["../../src/project/Project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,SAAS,EAET,UAAU,EACV,eAAe,EACf,UAAU,EAEb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EACH,WAAW,EACX,YAAY,EACZ,KAAK,EAEL,OAAO,EACP,WAAW,EACX,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,cAAc,EAGd,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,qBAAqB,CAAA;AAE7E,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAErC,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,CAAA;CAAE,CAAA;AAG3F,qBAAa,OAAQ,YAAW,kBAAkB,EAAE,UAAU,EAAE,eAAe;;IAC3E,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO;IAuCpC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO;IAM/D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAAG,OAAO;IAQ5E,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAE1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;IAC3C,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAA;IAClC,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAA;IACtC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IAEjC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;IACxB,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAA;IACnC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAA;IACvD,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,eAAqB;IAEpC,OAAO;IA+BP,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa;IAoBnF,cAAc,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAM7C,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC;IAC3C,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;IAC5D,KAAK,IAAI,UAAU;IAEnB,IAAI,GAAG,IAAI,UAAU,CAAmB;IACxC,IAAI,GAAG,IAAI,MAAM,CAAyC;IAC1D,IAAI,cAAc,IAAI,cAAc,CAAmE;IACvG,IAAI,kBAAkB,IAAI,kBAAkB,CAA2E;IACvH,IAAI,aAAa,IAAI,aAAa,CAAiC;IACnE,IAAI,cAAc,IAAI,cAAc,CAAkD;IACtF,IAAI,cAAc,IAAI,OAAO,CAAe;IAC5C,IAAI,YAAY,IAAI,OAAO,CAAc;IACzC,IAAI,qBAAqB,IAAI,qBAAqB,CAAkD;IAEpG,IAAI,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAWtC;IAED,KAAK,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,EAAE,GAAG,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAKvF,cAAc,IAAoB,OAAO,CAAC,OAAO,CAAC;IAKlD,aAAa,IAAI,eAAe;IAiBhC,IAAI,IAAI,OAAO;IAEf,SAAS,IAAI,IAAI;CACpB"}
@@ -10,6 +10,7 @@ import { ProjectMigration } from "./ProjectMigration";
10
10
  import { CaptureDevices } from "../capture/CaptureDevices";
11
11
  import { EngineFacade } from "../EngineFacade";
12
12
  import { Recording } from "../capture/Recording";
13
+ import { MIDILearning } from "../midi/MIDILearning";
13
14
  // Main Entry Point for a Project
14
15
  export class Project {
15
16
  static new(env) {
@@ -75,6 +76,7 @@ export class Project {
75
76
  userEditingManager;
76
77
  parameterFieldAdapters;
77
78
  liveStreamReceiver;
79
+ midiLearning;
78
80
  mixer;
79
81
  engine = new EngineFacade();
80
82
  constructor(env, boxGraph, { rootBox, userInterfaceBox, masterBusBox, masterAudioUnit, timelineBox }) {
@@ -94,6 +96,7 @@ export class Project {
94
96
  this.userEditingManager.follow(this.userInterfaceBox);
95
97
  this.selection.switch(this.userInterfaceBox.selection);
96
98
  this.liveStreamReceiver = this.#terminator.own(new LiveStreamReceiver());
99
+ this.midiLearning = this.#terminator.own(new MIDILearning(this));
97
100
  this.captureDevices = this.#terminator.own(new CaptureDevices(this));
98
101
  this.mixer = new Mixer(this.rootBoxAdapter.audioUnits);
99
102
  console.debug(`Project was created on ${this.rootBoxAdapter.created.toString()}`);
@@ -148,6 +151,14 @@ export class Project {
148
151
  }
149
152
  };
150
153
  }
154
+ merge(options, ...projects) {
155
+ // TODO
156
+ return Promise.reject("Not implemented");
157
+ }
158
+ extractIntoNew( /*Something ;)*/) {
159
+ // TODO
160
+ return Promise.reject("Not implemented");
161
+ }
151
162
  toArrayBuffer() {
152
163
  const output = ByteArrayOutput.create();
153
164
  output.writeInt(ProjectDecoder.MAGIC_HEADER_OPEN);
@@ -3,6 +3,6 @@ import { ProjectEnv } from "./ProjectEnv";
3
3
  import { ProjectProfile } from "./ProjectProfile";
4
4
  export declare namespace ProjectBundle {
5
5
  const encode: ({ uuid, project, meta, cover }: ProjectProfile, progress: MutableObservableValue<unitValue>) => Promise<ArrayBuffer>;
6
- const decode: (env: ProjectEnv, arrayBuffer: ArrayBuffer, exclude?: UUID.Format) => Promise<ProjectProfile>;
6
+ const decode: (env: ProjectEnv, arrayBuffer: ArrayBuffer, openProfileUUID?: UUID.Format) => Promise<ProjectProfile>;
7
7
  }
8
8
  //# sourceMappingURL=ProjectBundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectBundle.d.ts","sourceRoot":"","sources":["../../src/project/ProjectBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,sBAAsB,EAAiB,SAAS,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAInH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAM/C,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAU,gCAA8B,cAAc,EAC5C,UAAU,sBAAsB,CAAC,SAAS,CAAC,KAAG,OAAO,CAAC,WAAW,CAuB7F,CAAA;IAEM,MAAM,MAAM,GAAU,KAAK,UAAU,EACf,aAAa,WAAW,EACxB,UAAU,IAAI,CAAC,MAAM,KAAG,OAAO,CAAC,cAAc,CA8B1E,CAAA;CAyBJ"}
1
+ {"version":3,"file":"ProjectBundle.d.ts","sourceRoot":"","sources":["../../src/project/ProjectBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,sBAAsB,EAAiB,SAAS,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAInH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAM/C,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAU,gCAA8B,cAAc,EAC5C,UAAU,sBAAsB,CAAC,SAAS,CAAC,KAAG,OAAO,CAAC,WAAW,CAuB7F,CAAA;IAEM,MAAM,MAAM,GAAU,KAAK,UAAU,EACf,aAAa,WAAW,EACxB,kBAAkB,IAAI,CAAC,MAAM,KAAG,OAAO,CAAC,cAAc,CA0BlF,CAAA;CAyBJ"}
@@ -31,35 +31,33 @@ export var ProjectBundle;
31
31
  progress.setValue(1.0);
32
32
  return blob.arrayBuffer();
33
33
  };
34
- ProjectBundle.decode = async (env, arrayBuffer, exclude) => {
34
+ ProjectBundle.decode = async (env, arrayBuffer, openProfileUUID) => {
35
35
  const { default: JSZip } = await import("jszip");
36
36
  const zip = await JSZip.loadAsync(arrayBuffer);
37
37
  if (await asDefined(zip.file("version")).async("text") !== "1") {
38
38
  return panic("Unknown bundle version");
39
39
  }
40
40
  const bundleUUID = UUID.validate(await asDefined(zip.file("uuid")).async("uint8array"));
41
- console.debug(UUID.toString(bundleUUID), exclude ? UUID.toString(exclude) : "none");
42
- if (isDefined(exclude) && UUID.equals(exclude, bundleUUID)) {
41
+ console.debug(UUID.toString(bundleUUID), openProfileUUID ? UUID.toString(openProfileUUID) : "none");
42
+ if (isDefined(openProfileUUID) && UUID.equals(openProfileUUID, bundleUUID)) {
43
43
  return panic("Project is already open");
44
44
  }
45
45
  console.debug("loading samples...");
46
46
  const samples = asDefined(zip.folder("samples"), "Could not find samples");
47
47
  const promises = [];
48
48
  samples.forEach((path, file) => {
49
- if (!file.dir) {
50
- promises.push(file
51
- .async("arraybuffer")
52
- .then(arrayBuffer => WorkerAgents.Opfs
53
- .write(`${SampleStorage.Folder}/${path}`, new Uint8Array(arrayBuffer))));
49
+ if (file.dir) {
50
+ return;
54
51
  }
52
+ promises.push(file.async("arraybuffer")
53
+ .then(arrayBuffer => WorkerAgents.Opfs
54
+ .write(`${SampleStorage.Folder}/${path}`, new Uint8Array(arrayBuffer))));
55
55
  });
56
56
  await Promise.all(promises);
57
57
  const project = Project.load(env, await asDefined(zip.file(ProjectPaths.ProjectFile)).async("arraybuffer"));
58
58
  const meta = JSON.parse(await asDefined(zip.file(ProjectPaths.ProjectMetaFile)).async("text"));
59
59
  const coverFile = zip.file(ProjectPaths.ProjectCoverFile);
60
- const cover = isDefined(coverFile)
61
- ? Option.wrap(await coverFile.async("arraybuffer"))
62
- : Option.None;
60
+ const cover = Option.wrap(await coverFile?.async("arraybuffer"));
63
61
  return new ProjectProfile(bundleUUID, project, meta, cover);
64
62
  };
65
63
  const pipeSampleLoaderInto = async (loader, zip) => {
@@ -36,9 +36,9 @@ export class ProjectProfile {
36
36
  const uuid = UUID.generate();
37
37
  const project = this.project.copy();
38
38
  const meta = ProjectMeta.copy(this.meta);
39
- const session = new ProjectProfile(uuid, project, meta, Option.None, true);
40
- await ProjectProfile.#writeFiles(session);
41
- return Option.wrap(session);
39
+ const profile = new ProjectProfile(uuid, project, meta, Option.None, true);
40
+ await ProjectProfile.#writeFiles(profile);
41
+ return Option.wrap(profile);
42
42
  }
43
43
  else {
44
44
  return ProjectProfile.#writeFiles(this).then(() => {
package/dist/workers.js CHANGED
@@ -1,4 +1,4 @@
1
- var p=s=>s!=null,It=s=>s==null;var w=(s,t="asDefined failed")=>s??u(t);var we=(s,t)=>s instanceof t?s:u(`${s} is not instance of ${t}`);var st=s=>s instanceof Function?s():s;var N=(s,...t)=>s?.apply(null,t);var k=s=>{throw new Error(`Unhandled ${s}`)},u=s=>{throw typeof s=="string"?new Error(s):s},m=(s,t)=>s?void 0:u(st(t));var Wt=s=>new Proxy({},{get(){return u(s)}});var G=s=>{try{return{error:null,value:s(),status:"success"}}catch(t){return{error:t,value:null,status:"failure"}}};var Yt=()=>{};var xe=s=>{};var Ht;(function(s){s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Ht||(Ht={}));var g=class{static#t=Object.freeze(new Array(0));static empty=()=>this.#t;static clear=t=>{t.length=0};static replace=(t,e)=>{t.length=0,t.push(...e)};static consume=(t,e)=>{for(let r=0;r<t.length;)e(t[r])?t.splice(r,1):r++};static peekFirst=t=>t.at(0)??null;static peekLast=t=>t.at(-1)??null;static getFirst=(t,e)=>w(t.at(0),e);static getLast=(t,e)=>w(t.at(-1),e);static getPrev=(t,e)=>{let r=t.indexOf(e);return r===-1?u(`${e} not found in ${t}`):w(t.at((r-1)%t.length),"Internal Error")};static getNext=(t,e)=>{let r=t.indexOf(e);return r===-1?u(`${e} not found in ${t}`):w(t.at((r+1)%t.length),"Internal Error")};static removeLast=(t,e)=>w(t.pop(),e);static create=(t,e)=>{let r=new Array(e);for(let n=0;n<e;n++)r[n]=t(n);return r};static equals=(t,e)=>{if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0};static satisfy=(t,e)=>{if(t.length<2)return!0;let r=t[0];for(let n=1;n<t.length;n++)if(!e(r,t[n]))return!1;return!0};static remove=(t,e)=>{let r=t.indexOf(e);if(r===-1)return u(`${e} not found in ${t}`);t.splice(r,1)};static removeOpt=(t,e)=>{let r=t.indexOf(e);return r===-1?!1:(t.splice(r,1),!0)};static hasDuplicates=t=>new Set(t).size<t.length;static removeDuplicates=t=>{let e=0,r=new Set;for(let n of t)r.has(n)||(r.add(n),t[e++]=n);return t.length=e,t};static removeDuplicateKeys=(t,e)=>{let r=0,n=new Set;for(let i of t){let o=i[e];n.has(o)||(n.add(o),t[r++]=i)}return t.length=r,t};static*iterate(t){for(let e=0;e<t.length;e++)yield t[e]}static*iterateReverse(t){for(let e=t.length-1;e>=0;e--)yield t[e]}static*iterateStateFull(t){let e=t.length-1;for(let r=0;r<=e;r++)yield{value:t[r],isFirst:r===0,isLast:r===e}}static isSorted(t,e=Ht.Ascending){if(t.length<2)return!0;let r=t[0];for(let n=1;n<t.length;n++){let i=t[n];if(Math.sign(r-i)===e)return!1;r=i}return!0}};var d;(function(s){s.wrap=e=>p(e)?new t(e):s.None,s.from=e=>s.wrap(e()),s.tryFrom=e=>{try{return s.wrap(e())}catch{return s.None}},s.execute=(e,...r)=>s.wrap(e?.apply(null,r)),s.async=e=>e.then(r=>s.wrap(r),()=>s.None);class t{#t;constructor(r){this.#t=w(r)}unwrap(){return this.#t}unwrapOrElse(r){return this.#t}unwrapOrNull(){return this.#t}unwrapOrUndefined(){return this.#t}contains(r){return r===this.#t}match(r){return r.some(this.#t)}ifSome(r){return r(this.#t)}isEmpty(){return!1}nonEmpty(){return!0}map(r){return s.wrap(r(this.#t))}mapOr(r,n){return r(this.#t)}flatMap(r){return r(this.#t)}equals(r){return this.unwrapOrNull()===r.unwrapOrNull()}assert(r){return this}toString(){return`{Option.Some(${this.#t})}`}get[Symbol.toStringTag](){return this.toString()}}s.Some=t,s.None=new class{unwrap=e=>u(p(e)?st(e):"unwrap failed");unwrapOrElse=e=>st(e);unwrapOrNull=()=>null;unwrapOrUndefined=()=>{};contains=e=>!1;match=e=>e.none();ifSome=e=>{};isEmpty=()=>!0;nonEmpty=()=>!1;map=e=>s.None;mapOr=(e,r)=>st(r);flatMap=e=>s.None;equals=e=>e.isEmpty();assert=e=>u(st(e)??"assert failed");toString=()=>"{Option.None}";get[Symbol.toStringTag](){return this.toString()}}})(d||(d={}));var be;(function(s){s.async=t=>t.then(e=>s.ok(e),e=>s.err(e)),s.tryGet=t=>{try{return s.ok(t())}catch(e){return s.err(e)}},s.ok=t=>new class{value;constructor(e){this.value=e}asOption=()=>d.wrap(this.value);failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>this.value;map=e=>{try{return s.ok(e(this.value))}catch(r){return s.err(r)}};flatMap=e=>e(this.value);match=e=>e.ok(this.value);toVoid=()=>s.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>`{Success: ${this.value}`;get[Symbol.toStringTag](){return"Success"}}(t),s.Ok=new class{constructor(){}asOption=()=>d.None;failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>{};map=t=>s.ok(t());flatMap=t=>t();match=t=>t.ok();toVoid=()=>s.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>"{Success: Ok";get[Symbol.toStringTag](){return"Success"}},s.err=t=>new class{reason;constructor(e){this.reason=e}asOption=()=>d.None;failureReason=()=>this.reason;isFailure=()=>!0;isSuccess=()=>!1;result=()=>{throw new Error(`No result because '${this.reason}'`)};map=()=>this;flatMap=()=>this;match=e=>e.err(this.reason);toVoid=()=>s.err(this.reason);failure=()=>this;toString=()=>`{Failure: ${this.reason}`;get[Symbol.toStringTag](){return"Failure"}}(t)})(be||(be={}));var A;(function(s){s.exact=(t,e,r)=>{let n=0,i=t.length-1;for(;n<=i;){let o=n+i>>>1,a=r(t[o],e);if(a===0)return o;a<0?n=o+1:i=o-1}return-1},s.exactMapped=(t,e,r,n)=>{let i=0,o=t.length-1;for(;i<=o;){let a=i+o>>>1,c=r(n(t[a]),e);if(c===0)return a;c<0?i=a+1:o=a-1}return-1},s.leftMost=(t,e,r)=>{let n=0,i=t.length;for(;n<i;){let o=n+i>>>1;r(t[o],e)<0?n=o+1:i=o}return n},s.rightMost=(t,e,r)=>{let n=0,i=t.length;for(;n<i;){let o=n+i>>>1;r(t[o],e)<=0?n=o+1:i=o}return i-1},s.leftMostMapped=(t,e,r,n)=>{let i=0,o=t.length;for(;i<o;){let a=i+o>>>1;r(n(t[a]),e)<0?i=a+1:o=a}return i},s.rightMostMapped=(t,e,r,n)=>{let i=0,o=t.length;for(;i<o;){let a=i+o>>>1;r(n(t[a]),e)<=0?i=a+1:o=a}return o-1},s.rangeMapped=(t,e,r,n)=>[s.leftMostMapped(t,e,r,n),s.rightMostMapped(t,e,r,n)]})(A||(A={}));var vt;(function(s){s.parseCssRgbOrRgba=t=>{let e=t.match(/\(([^)]+)\)/)?.at(1)?.split(",")?.map(Number);if(p(e)&&e.every(r=>!isNaN(r))){if(e.length===3)return[e[0]/255,e[1]/255,e[2]/255,1];if(e.length===4)return[e[0]/255,e[1]/255,e[2]/255,e[3]]}throw new Error(`${t} is not proper formatted. Example: 'rgb(255, 255, 255)' or 'rgba(255, 255, 255, 1)'`)},s.hslToHex=(t,e,r)=>{let n=c=>(c+t/30)%12,i=e*Math.min(r,1-r),o=c=>r-i*Math.max(-1,Math.min(n(c)-3,Math.min(9-n(c),1))),a=c=>Math.round(c*255).toString(16).padStart(2,"0");return`#${a(o(0))}${a(o(8))}${a(o(4))}`},s.hexToHsl=t=>{let e=t.startsWith("#")?t.slice(1):t,r=parseInt(e.slice(0,2),16)/255,n=parseInt(e.slice(2,4),16)/255,i=parseInt(e.slice(4,6),16)/255,o=Math.max(r,n,i),a=Math.min(r,n,i),c=(o+a)/2,h=0,l=0;if(o!==a){let f=o-a;switch(l=c>.5?f/(2-o-a):f/(o+a),o){case r:h=((n-i)/f+(n<i?6:0))*60;break;case n:h=((i-r)/f+2)*60;break;case i:h=((r-n)/f+4)*60;break}}return{h,s:l,l:c}},s.hslStringToHex=t=>{let[e,r,n]=t.match(/\d+(\.\d+)?/g).map(Number);return s.hslToHex(e,r/100,n/100)}})(vt||(vt={}));var Gt=(s,t)=>s-t;var Rr=Math.PI*2,Vr=Math.PI/2,Lr=Math.PI/4,Pr=1/Math.sqrt(2),y=(s,t,e)=>Math.max(t,Math.min(s,e));var Xt=s=>Math.pow(2,Math.ceil(Math.log(s)/Math.log(2)));var Ee;(function(s){s.valueAt=({slope:n,steps:i,y0:o,y1:a},c)=>s.normalizedAt(c/i,n)*(a-o)+o,s.normalizedAt=(n,i)=>{if(i>.499999&&i<.500001)return n;{let o=y(i,1e-15,.999999999999999);return o*o/(1-o*2)*(Math.pow((1-o)/o,2*n)-1)}},s.inverseAt=(n,i)=>{let o=y(i,1e-15,.999999999999999);return Math.log(n*(1-2*o)/(o*o)+1)/(2*Math.log((1-o)/o))},s.coefficients=n=>{let i=s.valueAt(n,1),a=(s.valueAt(n,2)-i)/(i-n.y0),c=i-a*n.y0;return{m:a,q:c}};function*e(n,i,o,a){let{m:c,q:h}=s.coefficients({slope:n,steps:i,y0:o,y1:a});for(let l=0,f=o;l<i;l++)yield f=c*f+h}s.walk=e;function*r(n,i){let o=1/i,a=s.normalizedAt(o,n),h=(s.normalizedAt(2*o,n)-a)/a;for(let l=0,f=0;l<i;l++)yield f=h*f+a}s.walkNormalized=r,s.byHalf=(n,i,o,a)=>({slope:s.slopeByHalf(i,o,a),steps:n,y0:i,y1:a}),s.slopeByHalf=(n,i,o)=>Math.abs(o-n)<1e-6?.5:(i-n)/(o-n)})(Ee||(Ee={}));var L=new DataView(new ArrayBuffer(8)),_;(function(s){s.MIN_VALUE=-2147483648,s.MAX_VALUE=2147483647,s.toByte=t=>(L.setInt8(0,t),L.getInt8(0)),s.toShort=t=>(L.setInt16(0,t),L.getInt16(0)),s.toInt=t=>(L.setInt32(0,t),L.getInt32(0))})(_||(_={}));var X;(function(s){let r=new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT),n=new Float32Array(r),i=new Int32Array(r);s.floatToIntBits=o=>{let a=s.floatToRawIntBits(o);return(a&2139095040)===2139095040&&(a&8388607)!==0?2143289344:a},s.intBitsToFloat=o=>(i[0]=o,n[0]),s.floatToRawIntBits=o=>(n[0]=o,i[0]),s.toFloat32=o=>(L.setFloat32(0,o),L.getFloat32(0))})(X||(X={}));var j;(function(s){s.floatToIntBits=t=>{let e=X.floatToIntBits(t),r=e>>>16&32768,n=(e&2147483647)+4096;return n>=1199570944?(e&2147483647)>=1199570944?n<2139095040?r|31744:r|31744|(e&8388607)>>>13:r|31743:n>=947912704?r|n-939524096>>>13:n<855638016?r:(n=(e&2147483647)>>>23,r|(e&8388607|8388608)+(8388608>>>n-102)>>>126-n)},s.intBitsToFloat=t=>{let e=t&1023,r=t&31744;if(r===31744)r=261120;else if(r!==0){if(r+=114688,e===0&&r>115712)return X.intBitsToFloat((t&32768)<<16|r<<13|1023)}else if(e!==0){r=115712;do e<<=1,r-=1024;while((e&1024)===0);e&=1023}return X.intBitsToFloat((t&32768)<<16|(r|e)<<13)}})(j||(j={}));var Qt;(function(s){let t=9218868437227405312n,e=4503599627370495n,r=new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT),n=new Float64Array(r),i=new BigInt64Array(r);s.float64ToLongBits=o=>{let a=s.float64ToRawLongBits(o);return(a&t)===t&&(a&e)!==0n?0x7ff8000000000000n:a},s.longBitsToFloat64=o=>(i[0]=o,n[0]),s.float64ToRawLongBits=o=>(n[0]=o,i[0]),s.clamp=o=>(L.setFloat64(0,o),L.getFloat64(0))})(Qt||(Qt={}));var B=class{static*empty(){}static one(t){return[t]}static count(t){let e=0;for(let r of t)e++;return e}static some(t,e){for(let r of t)if(e(r))return!0;return!1}static every(t,e){for(let r of t)if(!e(r))return!1;return!0}static reduce(t,e,r){let n=r,i=0;for(let o of t)n=e(n,o,i++);return n}static includes(t,e){for(let r of t)if(r===e)return!0;return!1}static forEach(t,e){for(let r of t)e(r)}static*map(t,e){let r=0;for(let n of t)yield e(n,r++)}static*take(t,e){let r=0;for(let n of t){if(r++>=e)return;yield n}}static filter(t,e){let r=[];for(let n of t)e(n)&&r.push(n);return r}static filterMap(t,e){let r=[];for(let n of t){let i=e(n);p(i)&&r.push(i)}return r}static reverse(t){let e=[];for(let r of t)e.push(r);return e.reverse()}static*pairWise(t){let e=t[Symbol.iterator](),{done:r,value:n}=e.next(),i=n;if(r!==!0)for(;;){let{done:o,value:a}=e.next();if(o===!0){yield[i,null];return}yield[i,a],i=a}}};var v=class s{static create(t=1024){return this.use(new ArrayBuffer(t))}static use(t,e=0){return new s(new DataView(t,e))}littleEndian=!1;#t;#e=0;constructor(t){this.#t=t}get remaining(){return this.#t.byteLength-this.#e}get position(){return this.#e}set position(t){t<0?u(`position(${t}) cannot be negative.`):t>this.#t.byteLength?u(`position(${t}) is outside range (${this.#t.byteLength}).`):this.#e=t}writeBoolean(t){this.writeByte(t?1:0)}writeByte(t){this.#r(1),this.#t.setInt8(this.#e++,t)}writeShort(t){this.#r(Int16Array.BYTES_PER_ELEMENT),this.#t.setInt16(this.#e,t,this.littleEndian),this.#e+=Int16Array.BYTES_PER_ELEMENT}writeInt(t){this.#r(Int32Array.BYTES_PER_ELEMENT),this.#t.setInt32(this.#e,t,this.littleEndian),this.#e+=Int32Array.BYTES_PER_ELEMENT}writeLong(t){this.#r(BigInt64Array.BYTES_PER_ELEMENT),this.#t.setBigInt64(this.#e,t,this.littleEndian),this.#e+=BigInt64Array.BYTES_PER_ELEMENT}writeFloat(t){this.#r(Float32Array.BYTES_PER_ELEMENT),this.#t.setFloat32(this.#e,t,this.littleEndian),this.#e+=Float32Array.BYTES_PER_ELEMENT}writeDouble(t){this.#r(Float64Array.BYTES_PER_ELEMENT),this.#t.setFloat64(this.#e,t,this.littleEndian),this.#e+=Float64Array.BYTES_PER_ELEMENT}writeBytes(t){this.#r(t.length);for(let e=0;e<t.length;++e)this.#t.setInt8(this.#e++,t[e])}writeString(t){let e=t.length;this.#r(Int32Array.BYTES_PER_ELEMENT+e*Int16Array.BYTES_PER_ELEMENT),this.writeInt(e);for(let r=0;r<e;r++)this.writeShort(t.charCodeAt(r))}toArrayBuffer(){return this.#t.buffer.slice(0,this.#e)}#r(t){let e=this.#t.byteLength;if(this.#e+t>e){let r=this.#t;this.#t=new DataView(new ArrayBuffer(Xt(e+t)));for(let n=0;n<this.#e;n++)this.#t.setInt8(n,r.getInt8(n))}}},nt=class{#t=0;writeByte(t){this.#t++}writeShort(t){this.#t+=2}writeInt(t){this.#t+=4}writeLong(t){this.#t+=8}writeFloat(t){this.#t+=4}writeDouble(t){this.#t+=8}writeBoolean(t){this.#t++}writeBytes(t){this.#t+=t.length}writeString(t){this.#t+=t.length+4}get count(){return this.#t}};var F=class{littleEndian=!1;#t;#e=0;constructor(t,e=0){this.#t=new DataView(t,e)}get position(){return this.#e}set position(t){t<0?u(`position(${t}) cannot be negative.`):t>this.#t.byteLength?u(`position(${t}) is outside range (${this.#t.byteLength}).`):this.#e=t}readByte(){return this.#t.getInt8(this.#e++)}readShort(){let t=this.#t.getInt16(this.#e,this.littleEndian);return this.#e+=Int16Array.BYTES_PER_ELEMENT,t}readInt(){let t=this.#t.getInt32(this.#e,this.littleEndian);return this.#e+=Int32Array.BYTES_PER_ELEMENT,t}readLong(){let t=this.#t.getBigInt64(this.#e,this.littleEndian);return this.#e+=BigInt64Array.BYTES_PER_ELEMENT,t}readFloat(){let t=this.#t.getFloat32(this.#e,this.littleEndian);return this.#e+=Float32Array.BYTES_PER_ELEMENT,t}readDouble(){let t=this.#t.getFloat64(this.#e,this.littleEndian);return this.#e+=Float64Array.BYTES_PER_ELEMENT,t}readBoolean(){return this.readByte()===1}readBytes(t){for(let e=0;e<t.length;e++)t[e]=this.readByte()}readString(){let t=this.readInt(),e="";for(let r=0;r<t;r++)e+=String.fromCharCode(this.readShort());return e}available(t){return this.#e+t<=this.#t.byteLength}remaining(){return this.#t.byteLength-this.#e}skip(t){this.position+=t}};var fr=s=>p(s)?s.value!==void 0?"value":s.get!==void 0?"get":u(`Cannot resolve method key of ${s}`):u("Cannot resolve method key of undefined descriptor"),it=(s,t,e)=>{if(!p(e))return function(i,o){if(o&&o.kind==="getter")return function(){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this),t);if(!p(a?.get))return u(`Cannot find getter for property '${t}'`);let c=a.get.apply(this);return Object.defineProperty(this,t,{value:c,configurable:!1,writable:!1,enumerable:!1}),c}};let r=fr(e),n=w(e[r]);return{[r]:function(...i){if(i.length>0)return u("lazy accessory must not have any construction parameters");let o=n.apply(this);return Object.defineProperty(this,t,{value:r==="get"?o:()=>o,configurable:!1,writable:!1,enumerable:!1}),o}}};var Ae;(function(s){function*t(){}s.empty=t,s.next=r=>{let{value:n,done:i}=r.next();return i?null:n};function*e(...r){for(let n of r)for(let i of n)yield i}s.flatten=e})(Ae||(Ae={}));var ot;(function(s){s[s.T=0]="T",s[s.R=1]="R",s[s.B=2]="B",s[s.L=3]="L"})(ot||(ot={}));var at;(function(s){s[s.TL=0]="TL",s[s.TR=1]="TR",s[s.BR=2]="BR",s[s.BL=3]="BL"})(at||(at={}));var Ie;(function(s){s.outerTangentPoints=(t,e)=>{let r=e.x-t.x,n=e.y-t.y,i=Math.atan2(n,r)+Math.acos((t.r-e.r)/Math.sqrt(r*r+n*n)),o=Math.cos(i),a=Math.sin(i);return[{x:t.x+t.r*o,y:t.y+t.r*a},{x:e.x+e.r*o,y:e.y+e.r*a}]}})(Ie||(Ie={}));var ve;(function(s){s.zero=()=>({x:0,y:0}),s.create=(t,e)=>({x:t,y:e}),s.clone=t=>({...t}),s.floor=t=>({x:Math.floor(t.x),y:Math.floor(t.y)}),s.length=t=>Math.sqrt(t.x*t.x+t.y*t.y),s.distance=(t,e)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),s.add=(t,e)=>({x:t.x+e.x,y:t.y+e.y}),s.subtract=(t,e)=>({x:t.x-e.x,y:t.y-e.y}),s.scaleBy=(t,e)=>({x:t.x*e,y:t.y*e}),s.scaleTo=(t,e)=>{let r=e/s.length(t);return{x:t.x*r,y:t.y*r}},s.fromClient=t=>({x:t.clientX,y:t.clientY})})(ve||(ve={}));var gt;(function(s){s.Empty=Object.freeze({x:0,y:0,width:0,height:0}),s.corners=t=>{let e=t.x,r=t.y,n=e+t.width,i=r+t.height;return[{x:e,y:r},{x:n,y:r},{x:n,y:i},{x:e,y:i}]},s.inflate=(t,e)=>({x:t.x-e,y:t.y-e,width:t.width+e*2,height:t.height+e*2}),s.contains=(t,e)=>{let r=e.x>=t.x&&e.y>=t.y,n=e.x+e.width<=t.x+t.width&&e.y+e.height<=t.y+t.height;return r&&n},s.isPointInside=(t,e)=>t.x>=e.x&&t.x<=e.x+e.width&&t.y>=e.y&&t.y<=e.y+e.height,s.intersect=(t,e)=>{let r=Math.max(t.x,e.x),n=Math.min(t.x+t.width,e.x+e.width),i=Math.min(t.y+t.height,e.y+e.height),o=Math.max(t.y,e.y);return n>r&&i>o},s.axis=(t,e)=>{switch(e){case ot.T:return t.y;case ot.R:return t.x+t.width;case ot.B:return t.y+t.height;case ot.L:return t.x;default:return k(e)}},s.corner=(t,e)=>{switch(e){case at.TL:return{x:t.x,y:t.y};case at.TR:return{x:t.x+t.width,y:t.y};case at.BR:return{x:t.x+t.width,y:t.y+t.height};case at.BL:return{x:t.x,y:t.y+t.height};default:return k(e)}},s.center=t=>({x:t.x+t.width*.5,y:t.y+t.height*.5}),s.isEmpty=t=>t.width===0||t.height===0,s.union=(t,e)=>{if(s.isEmpty(t))s.isEmpty(e)||(t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height);else if(!s.isEmpty(e)){let r=e.x,n=e.y,i=Math.min(t.x,r),o=Math.min(t.y,n);t.width=Math.max(t.x+t.width,r+e.width)-i,t.height=Math.max(t.y+t.height,n+e.height)-o,t.x=i,t.y=o}}})(gt||(gt={}));var Se;(function(s){s.width=t=>t.xMax-t.xMin,s.height=t=>t.yMax-t.yMin,s.from=(t,e)=>{t.xMin=e.xMin,t.xMax=e.xMax,t.yMin=e.yMin,t.yMax=e.yMax},s.extend=(t,e)=>{t.xMin-=e,t.yMin-=e,t.xMax+=e,t.yMax+=e},s.padding=(t,[e,r,n,i])=>(t.xMin+=i,t.yMin+=e,t.xMax-=r,t.yMax-=n,t),s.intersectPoint=(t,e)=>t.xMin<=e.x&&e.x<t.xMax&&t.yMin<=e.y&&e.y<t.yMax,s.intersectThat=(t,e)=>e.xMin<t.xMax&&e.xMax>t.xMin&&e.yMin<t.yMax&&e.yMax>t.yMin,s.center=t=>({x:(t.xMin+t.xMax)*.5,y:(t.yMin+t.yMax)*.5})})(Se||(Se={}));var Te;(function(s){s.Identity=Object.freeze([0,0,0,0])})(Te||(Te={}));var Me;(function(s){s.intersects=(r,n,i,o,a,c,h,l)=>{let f=t(r,n,i,o,a,c),E=t(r,n,i,o,h,l);if((f|E)===0||(f&E)!==0)return!1;let R=e(a,c,h,l,r,i);return R!==e(a,c,h,l,n,i)||R!==e(a,c,h,l,n,o)||R!==e(a,c,h,l,r,o)};let t=(r,n,i,o,a,c)=>{let h=0;return a<=r?h|=1:a>=n&&(h|=2),c<=i?h|=8:c>=o&&(h|=4),h},e=(r,n,i,o,a,c)=>(i-r)*(c-n)-(a-r)*(o-n)>=0})(Me||(Me={}));var Ne;(function(s){s.Identity={valueToAxis:t=>t,axisToValue:t=>t},s.toClamped=(t,e,r)=>({valueToAxis:n=>t.valueToAxis(y(n,e,r)),axisToValue:n=>y(t.axisToValue(n),e,r)}),s.createClamped=(t,e)=>({valueToAxis:r=>y(r,t,e),axisToValue:r=>y(r,t,e)})})(Ne||(Ne={}));var Be;(function(s){s.fromBuffers=async(...t)=>{let e=t.reduce((i,o)=>i+o.byteLength,0),r=new Uint8Array(e),n=0;for(let i of t)r.set(new Uint8Array(i),n),n+=i.byteLength;return await crypto.subtle.digest("SHA-256",r)},s.equals=(t,e)=>{m(t.byteLength===32,"First hash has invalid length"),m(e.byteLength===32,"Second hash has invalid length");let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<32;i++)if(r[i]!==n[i])return!1;return!0},s.toString=t=>Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")})(Be||(Be={}));var Fe;(function(s){s.intersect1D=(t,e,r,n)=>Math.max(t,r)<=Math.min(e,n)})(Fe||(Fe={}));var ct=class{#t=new Set;#e;constructor(){this.#e=new Proxy({},{get:(t,e)=>(...r)=>this.#t.forEach(n=>Object.getPrototypeOf(n)===Object.getPrototypeOf({})?N(n[e],...r):n[e]?.apply(n,r))})}get proxy(){return this.#e}get size(){return this.#t.size}subscribe(t){return this.#t.add(t),{terminate:()=>this.#t.delete(t)}}forEach(t){this.#t.forEach(t)}terminate(){this.#t.clear()}};var yt=class{static createIfAbsent(t,e,r){let n=t.get(e);return n===void 0&&(n=r(e),t.set(e,n)),n}};var Jt=class s{static#t=Object.freeze(new Set);static empty=()=>s.#t};var S=Object.freeze({Empty:{terminate:Yt},create:s=>({terminate:s}),many:(...s)=>({terminate:()=>{for(;s.length>0;)s.pop().terminate()}})}),Q=class s{#t=[];own(t){return this.#t.push(t),t}ownAll(...t){for(let e of t)this.#t.push(e)}spawn(){let t=new s;return t.own({terminate:()=>g.removeOpt(this.#t,t)}),this.own(t)}terminate(){for(;this.#t.length>0;)this.#t.pop().terminate()}};var U=class{static subscribeMany(t,...e){return S.many(...e.map(r=>r.subscribe(()=>t(r))))}#t=new Set;subscribe(t){return this.#t.add(t),{terminate:()=>this.#t.delete(t)}}isEmpty(){return this.#t.size===0}notify(t){this.#t.forEach(e=>e(t))}observers(){return this.#t}terminate(){this.#t.clear()}};var Oe;(function(s){s.mergeNoOverlap=(t,e)=>{let r=new Set(Object.keys(t));for(let n of Object.keys(e))if(r.has(n))return u(`'${n}' is an overlapping key`);return{...t,...e}},s.include=(t,...e)=>e.reduce((r,n)=>(r[n]=t[n],r),{}),s.exclude=(t,...e)=>{let r=new Set(e);return Object.entries(t).reduce((n,[i,o])=>(r.has(i)||(n[i]=o),n),{})},s.overwrite=(t,e)=>Object.assign(t,e)})(Oe||(Oe={}));var $e;(function(s){s.make=t=>new class{getValue(){return t}subscribe(e){return S.Empty}catchupAndSubscribe(e){return e(this),S.Empty}}})($e||($e={}));var Re;(function(s){s.False=new class{getValue(){return!1}setValue(t){}subscribe(t){return S.Empty}catchupAndSubscribe(t){return t(this),S.Empty}},s.inverseBoolean=t=>new class{getValue(){return!t.getValue()}setValue(e){t.setValue(!e)}subscribe(e){return t.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}}})(Re||(Re={}));var St=class{#t;#e=d.None;#r;constructor(t,e){this.#t=new U,this.#r=e?.guard(t)??t,this.#e=d.wrap(e)}setValue(t){this.#e.nonEmpty()&&(t=this.#e.unwrap().guard(t)),this.#r!==t&&(this.#r=t,this.#t.notify(this))}getValue(){return this.#r}subscribe(t){return this.#t.subscribe(t)}catchupAndSubscribe(t){return t(this),this.#t.subscribe(t)}terminate(){this.#t.terminate()}toString(){return`{DefaultObservableValue value: ${this.#r}`}};var Zt=class{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=e,this.#r=e-t}x(t){return(this.clamp(t)-this.#t)/this.#r}y(t){return this.#t+y(t,0,1)*this.#r}clamp(t){return y(t,this.#t,this.#e)}floating(){return!0}},te=class{#t;#e;#r;constructor(t,e){this.#t=y(Math.round(t),_.MIN_VALUE,_.MAX_VALUE),this.#e=y(Math.round(e),_.MIN_VALUE,_.MAX_VALUE),this.#r=this.#e-this.#t}x(t){return(this.clamp(t)-this.#t)/this.#r}y(t){return this.#t+Math.round(y(t,0,1)*this.#r)}clamp(t){return y(Math.round(t),this.#t,this.#e)}floating(){return!1}},ee=class{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=e,this.#r=Math.log(e/t)}x(t){return Math.log(y(t,this.#t,this.#e)/this.#t)/this.#r}y(t){return this.#t*Math.exp(y(t,0,1)*this.#r)}clamp(t){return Math.min(this.#e,Math.max(this.#t,t))}floating(){return!0}},re=class{#t;constructor(t){this.#t=t}x(t){let e=this.#t.findIndex(r=>r===t);return e===-1?u(`Could not find index for ${t}`):e/(this.#t.length-1)}y(t){let e=Math.round(y(t,0,1)*(this.#t.length-1));return e>-1?w(this.#t.at(e),`Could not find value for ${t}`):u(`Index ${e} is out of box.`)}clamp(t){return t}floating(){return!1}},se=class{#t;#e;#r;#s;#n;constructor(t,e,r){this.#t=t,this.#e=r;let n=t*t,i=r*r,o=e*e,a=t+r-2*e,c=r-e;this.#r=((2*r-e)*t-e*r)/a,this.#s=(c*n+(o-i)*t+e*i-o*r)/(n+(2*r-4*e)*t+i-4*e*r+4*o),this.#n=-c/a}y(t){return t<=0?Number.NEGATIVE_INFINITY:t>=1?this.#e:this.#r-this.#s/(t+this.#n)}x(t){return this.#t>=t?0:this.#e<=t?1:-this.#s/(t-this.#r)-this.#n}clamp(t){return Math.min(this.#e,t)}floating(){return!0}},ne;(function(s){s.linear=(i,o)=>new Zt(i,o),s.linearInteger=(i,o)=>new te(i,o),s.exponential=(i,o)=>new ee(i,o),s.values=i=>new re(i),s.decibel=(i,o,a)=>new se(i,o,a);let t=new class{x(i){return i?1:0}y(i){return i>=.5}clamp(i){return i}floating(){return!1}},e=s.linear(0,1),r=s.linear(-1,1);s.bool=t;let n=s.decibel(-72,-12,0);s.unipolar=()=>e,s.bipolar=()=>r,s.DefaultDecibel=n})(ne||(ne={}));var ie;(function(s){s.percent=({bipolar:i,fractionDigits:o}={})=>new t("%",o,!1,i),s.numeric=({unit:i,fractionDigits:o,unitPrefix:a,bipolar:c}={})=>new t(i,o,a,c),s.indices=(i,o)=>new class{x(a){return{unit:i,value:o[a]}}y(a){let c=o.indexOf(a);return c===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:c}}},s.values=(i,o,a)=>new class{x(c){return{unit:i,value:a.at(o.indexOf(c))??"N/A"}}y(c){let h=a.indexOf(c);return h===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:o[h]}}},s.bool=new class{y(i){switch(i.trim()){case"on":case"yes":case"true":return{type:"explicit",value:!0};default:return{type:"explicit",value:!1}}}x(i){return{value:String(i),unit:""}}};class t{#t;#e;#r;#s;constructor(o,a,c,h){this.#t=o??"",this.#e=a??0,this.#r=c??!1,this.#s=h??!1}y(o){let a=o.trim(),c=parseFloat(a);if(isNaN(c))return{type:"unknown",value:a};if(this.#t==="%")return{type:"explicit",value:c/100};if(a.endsWith("%"))return{type:"unitValue",value:this.#s?y(c/200+.5,0,1):y(c/100,0,1)};{a.endsWith(this.#t)&&this.#t.length>0&&(a=a.slice(0,-this.#t.length));let f=/(\d+)(\D+)/.exec(a)?.at(2)?.at(0);if(p(f)){let E=e.indexOf(f);if(E>-1)return{type:"explicit",value:c*Math.pow(10,(E-4)*3)}}return{type:"explicit",value:c}}}x(o){if(Number.isNaN(o))return{value:"\u{1F4A3}",unit:this.#t};if(Number.isFinite(o)){if(this.#t==="%")return this.#s?{value:(o*200-100).toFixed(this.#e),unit:this.#t}:{value:(o*100).toFixed(this.#e),unit:this.#t};if(this.#r){let{value:a,prefix:c}=n(o);return{value:a.toFixed(this.#e),unit:`${c}${this.#t}`}}else return{value:o.toFixed(this.#e),unit:this.#t}}else return{value:o===Number.POSITIVE_INFINITY?"\u221E":"-\u221E",unit:this.#t}}}let e=Object.freeze(["p","n","\u03BC","m","","k","M","G","T"]),r=i=>Math.log(i)/Math.log(9.999999999999998),n=i=>{let o=Math.floor(r(i)/3),a=e[o+4];return p(a)?{value:i*Math.pow(10,o*-3),prefix:a}:{value:i,prefix:""}};s.decible=s.numeric({unit:"db",fractionDigits:1}),s.panning=s.percent({unit:"%",fractionDigits:0})})(ie||(ie={}));var Ve;(function(s){s.alwaysTrue=()=>!0,s.alwaysFalse=()=>!1,s.definedPredicate=t=>t!=null})(Ve||(Ve={}));var Le;(function(s){s.Empty=Object.freeze(t=>{}),s.split=(t,e)=>{let r=new Float32Array(e);return g.create(n=>i=>{r[n]=i,t(r.reduce((o,a)=>o+a,0)/e)},e)}})(Le||(Le={}));var Pe;(function(s){s.create=(t=252854082)=>new oe(t),s.monotoneAscending=(t,e=128,r=s.create())=>{let n=t.length;if(n<2)return u("Array must have at least 2 elements");let i=0;for(let a=1;a<n;a++){let c=Math.floor(r.uniform()*(1+e))+1;t[a]=c,i+=c}let o=0;t[0]=0;for(let a=1;a<n;a++)o+=t[a],t[a]=o/i;return t}})(Pe||(Pe={}));var oe=class{#t=0;constructor(t){this.setSeed(t)}setSeed(t){this.#t=t&4294967295}nextDouble(t,e){return t+this.uniform()*(e-t)}nextInt(t,e){return t+Math.floor(this.uniform()*(e-t))}nextElement(t){return t[Math.floor(this.uniform()*t.length)]}nextBoolean(){return this.uniform()<.5}uniform(){let t=this.#t+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}};var Ce;(function(s){class t{}s.createBuilder=r=>{let n=i=>{let o=i instanceof Array?[]:{};return Object.entries(i).forEach(([a,c])=>{c instanceof t?o[a]=c.initialValue():typeof c=="object"&&(o[a]=n(c))}),o};return()=>new e(r,Object.seal(n(r)))},s.bool=new class extends t{read(r){return r.readByte()===1}write(r,n){r.writeByte(n?1:0)}initialValue(){return!1}},s.int8=new class extends t{read(r){return r.readByte()}write(r,n){r.writeByte(n)}initialValue(){return 0}},s.int16=new class extends t{read(r){return r.readShort()}write(r,n){r.writeShort(n)}initialValue(){return 0}},s.int32=new class extends t{read(r){return r.readInt()}write(r,n){r.writeInt(n)}initialValue(){return 0}},s.float=new class extends t{read(r){return r.readFloat()}write(r,n){r.writeFloat(n)}initialValue(){return 0}},s.double=new class extends t{read(r){return r.readDouble()}write(r,n){r.writeDouble(n)}initialValue(){return 0}},s.int64=new class extends t{read(r){return r.readLong()}write(r,n){r.writeLong(n)}initialValue(){return 0n}},s.floats=r=>new class extends t{read(n,i){for(let o=0;o<i.length;o++)i[o]=n.readFloat();return i}write(n,i){for(let o=0;o<i.length;o++)n.writeFloat(i[o])}initialValue(){return new Float32Array(r)}},s.doubles=r=>new class extends t{read(n,i){for(let o=0;o<i.length;o++)i[o]=n.readDouble();return i}write(n,i){for(let o=0;o<i.length;o++)n.writeDouble(i[o])}initialValue(){return new Float64Array(r)}};class e{#t;#e;#r;constructor(n,i){this.#t=n,this.#e=i,this.#r=this.#s()}get object(){return this.#e}get bytesTotal(){return this.#r}read(n){let i=(o,a)=>{Object.entries(o).forEach(([c,h])=>{let l=a;h instanceof t?l[c]=h.read(n,l[c]):typeof h=="object"&&i(h,l[c])})};i(this.#t,this.#e)}write(n){let i=(o,a)=>{Object.entries(o).forEach(([c,h])=>{let l=a;h instanceof t?h.write(n,l[c]):typeof h=="object"&&i(h,l[c])})};i(this.#t,this.#e)}#s(){let n=new nt;return this.write(n),n.count}}})(Ce||(Ce={}));var ht=class{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=e,this.#r=[]}add(t,e=!1){let r=this.#t(t),n=A.leftMostMapped(this.#r,r,this.#e,this.#t),i=this.#r[n];return p(i)&&this.#e(this.#t(i),r)===0?e?(this.#r.splice(n,1,t),!0):!1:(this.#r.splice(n,0,t),!0)}getOrCreate(t,e){let r=A.leftMostMapped(this.#r,t,this.#e,this.#t),n=this.#r[r];if(p(n)&&this.#e(this.#t(n),t)===0)return n;let i=e(t);return this.#r.splice(r,0,i),i}addMany(t){for(let e of t)this.#r.push(e);try{return this.#r.sort((e,r)=>{let n=this.#e(this.#t(e),this.#t(r));if(n===0)throw"cancel";return n}),!0}catch(e){if(e==="cancel"){let r=new Map(this.entries());return this.#r.splice(0,this.#r.length,...r.values()),this.#r.sort((n,i)=>this.#e(this.#t(n),this.#t(i))),!1}return u(e)}}removeByValue(t){return this.removeByKey(this.#t(t))}removeByKey(t){let e=A.leftMostMapped(this.#r,t,this.#e,this.#t),r=this.#r[e];return p(r)&&this.#e(this.#t(r),t)===0?(this.#r.splice(e,1),r):u(`Could not remove ${t}`)}removeByKeyIfExist(t){let e=A.leftMostMapped(this.#r,t,this.#e,this.#t),r=this.#r[e];return p(r)&&this.#e(this.#t(r),t)===0?(this.#r.splice(e,1),r):null}removeRange(t,e){this.#r.splice(t,(e??this.#r.length)-t)}removeByPredicate(t){let e=0,r=this.#r.length;for(;--r>=0;)t(this.#r[r])&&(this.#r.splice(r,1),e++);return e}get(t){return w(this.#s(t),`Unknown key: ${t}`)}getOrThrow(t,e){let r=this.#s(t);if(p(r))return r;throw e()}opt(t){return d.wrap(this.#s(t))}getOrNull(t){return this.#s(t)??null}getByIndex(t){return this.#r[t]}hasKey(t){return p(this.#s(t))}hasValue(t){return p(this.#s(this.#t(t)))}size(){return this.#r.length}isEmpty(){return this.#r.length===0}forEach(t){this.values().forEach(t)}values(){return this.#r}entries(){return this.#r.map(t=>[this.#t(t),t])}clear(){g.clear(this.#r)}[Symbol.iterator](){return this.#r.values()}#s(t){let e=A.leftMostMapped(this.#r,t,this.#e,this.#t),r=this.#r[e];return p(r)&&this.#e(this.#t(r),t)===0?r:void 0}};var De;(function(s){s.hyphenToCamelCase=t=>t.replace(/-([a-z])/g,e=>e[1].toUpperCase()),s.fallback=(t,e)=>p(t)&&t.length>0?t:e,s.endsWithDigit=t=>/\d$/.test(t),s.nonEmpty=(t,e)=>p(t)&&t.trim().length>0?t:e,s.toArrayBuffer=t=>{let e=new ArrayBuffer(t.length),r=new Uint8Array(e);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return e},s.getUniqueName=(t,e)=>{let r=new Set(t),n=e,i=1;if(r.has(e)||r.has(`${e} 1`))i=2;else return e;for(;r.has(n=`${e} ${i++}`););return n}})(De||(De={}));var En=(()=>{let s=d.None;return{info:t=>s.match({none:()=>Promise.resolve(),some:e=>e.info(t)}),approve:t=>s.match({none:()=>Promise.resolve(!0),some:e=>e.approve(t)}),progress:t=>s.match({none:()=>S.Empty,some:e=>e.progress(t)}),install:t=>{m(s.isEmpty(),"RuntimeNotification already installed"),s=d.wrap(t)}}})();var J=class s{static POSITIVE_INFINITY=new s(Number.POSITIVE_INFINITY);static millis=t=>new s(t);static seconds=t=>new s(t*s.#t);static minutes=t=>new s(t*s.#e);static hours=t=>new s(t*s.#r);static days=t=>new s(t*s.#s);static#t=1e3;static#e=6e4;static#r=36e5;static#s=864e5;#n;constructor(t){this.#n=t}millis(){return this.#n}absSeconds(){return Math.abs(this.#n)/s.#t}absMinutes(){return Math.abs(this.#n)/s.#e}absHours(){return Math.abs(this.#n)/s.#r}absDays(){return Math.abs(this.#n)/s.#s}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.#n===0}isPast(){return this.#n<0}isFuture(){return this.#n>0}toUnitString(){let t,e,r=Math.floor(Math.abs(this.#n)/1e3),n=Math.floor(r/60),i=Math.floor(n/60),o=Math.floor(i/24);return r<60?(t=r,e="second"):n<60?(t=n,e="minute"):i<24?(t=i,e="hour"):(t=o,e="day"),new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"long"}).format(t*Math.sign(this.#n),e)}toString(){if(isNaN(this.#n))return"NaN";if(!isFinite(this.#n))return"\u221E";let{d:t,h:e,m:r,s:n}=this.split();return t>0?[s.#i("d",t),s.#i("h",e),s.#i("m",r),s.#i("s",n)].join(", "):e>0?[s.#i("h",e),s.#i("m",r),s.#i("s",n)].join(", "):r>0?[s.#i("m",r),s.#i("s",n)].join(", "):n>0?s.#i("s",n):"now"}static#i=(t,e)=>{switch(t){case"d":return`${e} ${e<2?"day":"days"}`;case"h":return`${e} ${e<2?"hour":"hours"}`;case"m":return`${e} ${e<2?"minute":"minutes"}`;case"s":return`${e} ${e<2?"second":"seconds"}`;default:return k(t)}}};var ke;(function(s){let t;(function(e){e[e.READING=0]="READING",e[e.READ=1]="READ",e[e.WRITING=2]="WRITING",e[e.WRITTEN=3]="WRITTEN"})(t||(t={})),s.writer=(e,r,n)=>{if(e.bytesTotal+1>r.byteLength)return u("Insufficient memory allocated.");let i=new Uint8Array(r),o=v.use(r,1);return Atomics.store(i,0,t.READ),{tryWrite:()=>Atomics.compareExchange(i,0,t.READ,t.WRITING)===t.WRITING?(n(e.object),o.position=0,e.write(o),Atomics.store(i,0,t.WRITTEN),!0):!1}},s.reader=(e,r)=>{let n=new SharedArrayBuffer(e.bytesTotal+1),i=new Uint8Array(n),o=new F(n,1);return{buffer:n,tryRead:()=>Atomics.compareExchange(i,0,t.WRITTEN,t.READING)===t.READING?(o.position=0,e.read(o),r(e.object),Atomics.store(i,0,t.READ),!0):!1}}})(ke||(ke={}));var b;(function(s){s.length=16,s.generate=()=>e(crypto.getRandomValues(new Uint8Array(s.length))),s.sha256=async r=>{let n=typeof process<"u"&&process.env?.VITEST==="true";return crypto.subtle.digest("SHA-256",n?new Uint8Array(r.slice(0)):r).then(i=>e(new Uint8Array(i.slice(0,s.length))))},s.validate=r=>s.parse(s.toString(r)),s.fromDataInput=r=>{let n=new Uint8Array(s.length);return r.readBytes(new Int8Array(n.buffer)),n},s.toDataOutput=(r,n)=>r.writeBytes(new Int8Array(n.buffer)),s.toString=r=>{let n=g.create(i=>(i+256).toString(16).substring(1),256);return n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},s.parse=r=>{let n=r.replace(/-/g,"").toLowerCase();if(n.length!==32)return u("Invalid UUID format");let i=new Uint8Array(s.length);for(let o=0,a=0;o<32;o+=2,a++)i[a]=parseInt(n.slice(o,o+2),16);return i},s.Comparator=(r,n)=>{if(r.length!==s.length||n.length!==s.length)return u("Unexpected array length for uuid(v4)");for(let i=0;i<s.length;i++){let o=r[i]-n[i];if(o!==0)return o}return 0},s.equals=(r,n)=>s.Comparator(r,n)===0,s.newSet=r=>new ht(r,s.Comparator),s.Lowest=s.parse("00000000-0000-4000-8000-000000000000"),s.Highest=s.parse("FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"),s.fromInt=r=>{let n=new Uint8Array(s.Lowest),i=new Uint8Array(new Uint32Array([r]).buffer);for(let o=0;o<4;o++)n[o]=i[o];return n};class t{#t;constructor(){this.#t=new Map}getOrCreate(n){return yt.createIfAbsent(this.#t,n,()=>s.generate())}}s.SimpleIdDecoder=t;let e=r=>(m(r.length===s.length,"UUID must be 16 bytes long"),r[6]=r[6]&15|64,r[8]=r[8]&63|128,r)})(b||(b={}));var _e;(function(s){s.create=i=>p(i)?p(i?.snap)?s.snap(i?.trackLength,i?.snap?.snapLength,Array.isArray(i?.snap?.threshold)?i?.snap.threshold:[i?.snap?.threshold]):s.identity(i?.trackLength):s.identity(),s.snap=(i=t,o=e,a)=>new n(i,o/i,a),s.identity=(i=t)=>new r(i);let t=128,e=24;class r{length;#t=NaN;#e=NaN;#r=1;constructor(o){this.length=o}begin(o){this.#e=this.#t=o}moveBy(o){m(!isNaN(this.#e),()=>"value has never been set"),this.#t+=o/this.length*this.#r,this.#e=y(this.#t,0,1)}ratio(o){this.#r=o}value(){return m(!isNaN(this.#e),()=>"value has never been set"),this.#e}disable(){}enable(){}}class n{#t;#e;#r;#s;#n=NaN;#i=NaN;#a=1;#o=!0;constructor(o,a,c){m(a>0,()=>`margin(${a}) must be greater then 0`),m(g.isSorted(c),()=>"thresholds are not sorted"),m(a<o,()=>`margin(${a}) must be lower then length(${o})`),this.#t=o,this.#e=a,this.#r=c,this.#s=c.map((h,l)=>h+l*this.#e)}begin(o){this.#o&&(this.#n=this.valueToX(o)),this.#i=o}moveBy(o){m(!isNaN(this.#i),()=>"value has never been set"),this.#n+=o/this.#t*this.#a,this.#i=this.#o?this.xToValue(this.#n):y(this.#n,0,1)}ratio(o){this.#a=o}value(){return m(!isNaN(this.#i),()=>"value has never been set"),this.#i}disable(){this.#o&&(this.#o=!1,this.#n=this.xToValue(this.#n))}enable(){this.#o||(this.#o=!0,this.#n=this.valueToX(this.#n))}valueToX(o){let a=A.rightMost(this.#r,o,Gt);if(a<0)return o;{let c=this.#s[a],h=this.#r[a];return o===h?c+this.#e/2:c+this.#e+(o-h)}}xToValue(o){let a=y(o,0,1+this.#e*this.#r.length),c=A.rightMost(this.#s,a,Gt);if(c<0)return a;{let h=this.#s[c],l=this.#r[c];return a>h+this.#e?a-(h+this.#e)+l:l}}get margin(){return this.#e}}})(_e||(_e={}));var Tt=Symbol.for("@openDAW/lib-std");globalThis[Tt]?console.debug(`%c${Tt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Tt]=!0,console.debug(`%c${Tt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var P;(function(s){s.sender=(r,n)=>n(new t(r)),s.executor=(r,n)=>new e(r,n);class t{#t;#e=new Map;#r;#s=0;constructor(n){this.#t=n,this.#r=n.subscribe(this.#n)}terminate(){this.#r.terminate()}dispatchAndForget=(n,...i)=>this.#t.send({type:"send",returnId:!1,func:n.name,args:Array.from(B.map(i,o=>({value:o})))});dispatchAndReturn=(n,...i)=>new Promise((o,a)=>{let c=B.reduce(i,(h,l,f)=>(typeof l=="function"&&h.push([f,l]),h),[]);this.#e.set(this.#s,{executorTuple:{resolve:o,reject:a},callbacks:new Map(c)}),this.#t.send({type:"send",returnId:this.#s,func:n.name,args:Array.from(B.map(i,(h,l)=>typeof h=="function"?{callback:l}:{value:h}))}),this.#s++});#n=n=>{let i=this.#e.get(n.returnId);p(i)?n.type==="resolve"?(i.executorTuple.resolve(n.resolve),this.#e.delete(n.returnId)):n.type==="reject"?(i.executorTuple.reject(n.reject),this.#e.delete(n.returnId)):n.type==="callback"&&i.callbacks?.get(n.funcAt).apply(this,n.args):u(`Promise has already been resolved. ${JSON.stringify(n)}`)}}class e{#t;#e;#r;constructor(n,i){this.#t=n,this.#e=i,this.#r=n.subscribe(this.#s)}terminate(){this.#r.terminate()}#s=n=>{m(n.type==="send",()=>"Message type must be 'send'");let i=Object.getPrototypeOf(this.#e)===Object.getPrototypeOf({})?this.#e:Object.getPrototypeOf(this.#e),o=w(i[n.func],`${n.func.toString()} does not exists on ${this.#e}`),a=n.returnId;if(a===!1)o.apply(this.#e,n.args.map(c=>"value"in c?c.value:u(`${n.func.toString()} has no promise.`)));else try{o.apply(this.#e,n.args.map(h=>"callback"in h?(...l)=>this.#a(a,h.callback,l):h.value)).then(h=>this.#n(a,h),h=>this.#i(a,h))}catch(c){this.#i(a,c)}};#n=(n,i)=>this.#t.send({type:"resolve",returnId:n,resolve:i});#i=(n,i)=>this.#t.send({type:"reject",returnId:n,reject:i});#a=(n,i,o)=>this.#t.send({type:"callback",returnId:n,funcAt:i,args:o})}s.Executor=e})(P||(P={}));var Ue;(function(s){s.ProgressArrayBuffer=t=>async e=>{if(!e.headers.has("Content-Length"))return console.debug("No Content-Length"),e.arrayBuffer();let r=parseInt(e.headers.get("Content-Length"));if(console.debug(`Content-Length: ${r}b`),isNaN(r)||r<4096)return e.arrayBuffer();t(0);let n=v.create(r),i=w(e.body,"response.body is empty").getReader();for(;;){let{done:o,value:a}=await i.read();if(o)break;a.forEach(c=>n.writeByte(c)),t(n.position/r)}return t(1),n.toArrayBuffer()}})(Ue||(Ue={}));var Ke;(function(s){s.debounce=(()=>{let t;return(e,r=1e3)=>{clearTimeout(t),t=setTimeout(e,r)}})(),s.scheduleInterval=(t,e,...r)=>{let n=setInterval(t,e,...r);return{terminate:()=>clearInterval(n)}},s.scheduleTimeout=(t,e,...r)=>{let n=setTimeout(t,e,...r);return{terminate:()=>clearTimeout(n)}}})(Ke||(Ke={}));var je={for:s=>new ae(s)},ae=class{#t;#e=new U;constructor(t){if(this.#t=t,p(t.onmessage)||p(t.onmessageerror))throw console.error(t),new Error(`${t} is already wrapped.`);t.onmessage=e=>this.#e.notify(e.data),t.onmessageerror=e=>{throw new Error(e.type)}}send(t){this.#t.postMessage(t)}channel(t){return new ce(this,t)}subscribe(t){return this.#e.subscribe(t)}terminate(){this.#e.terminate(),this.#t.onmessage=null,this.#t.onmessageerror=null}},ce=class s{#t;#e;#r=new U;#s;constructor(t,e){this.#t=t,this.#e=e,this.#s=t.subscribe(r=>{"message"in r&&"channel"in r&&r.channel===e&&this.#r.notify(r.message)})}send(t){this.#t.send({channel:this.#e,message:t})}channel(t){return new s(this,t)}subscribe(t){return this.#r.subscribe(t)}terminate(){this.#s.terminate(),this.#r.terminate()}};var he=class{maxRetry;timeSpan;#t=0;constructor(t,e){this.maxRetry=t,this.timeSpan=e}retry(t,e){return++this.#t===this.maxRetry?!1:(console.debug(`${t} > will retry in ${this.timeSpan.toString()}`),setTimeout(e,this.timeSpan.millis()),!0)}},C;(function(s){class t{value;status="resolved";constructor(o){this.value=o}error=Wt("Cannot access error when promise is resolved")}s.ResolveResult=t;class e{error;status="rejected";constructor(o){this.error=o}value=Wt("Cannot access value when promise is rejected")}s.RejectedResult=e,s.makeAbortable=async(i,o)=>{let a=!0;return i.own(S.create(()=>a=!1)),new Promise((c,h)=>o.then(l=>{a&&c(l)},l=>{a&&h(l)}))},s.tryCatch=i=>i.then(o=>new t(o),o=>new e(o)),s.retry=(i,o=new he(3,J.seconds(3)))=>i().catch(a=>new Promise((c,h)=>{let l=f=>{o.retry(f,()=>i().then(E=>c(E),l))||h(f)};l(a)})),s.fail=(i,o)=>{let a=()=>new Promise((c,h)=>setTimeout(()=>h("fails first"),i.millis()));return()=>{let c=a();return a=o,c}},s.timeout=(i,o,a)=>new Promise((c,h)=>{let l=!0,f=setTimeout(()=>{l=!1,h(new Error(a??"timeout"))},o.millis());i.then(E=>{l&&c(E)},E=>{l&&h(E)}).finally(()=>clearTimeout(f))}),s.sequential=i=>{let o=Promise.resolve(null);return a=>o=o.then(()=>i(a))};class r{max;#t;#e=0;constructor(o=1){this.max=o,this.#t=[]}async add(o){if(this.#e<this.max)return this.#e++,o().finally(()=>this.#r());{let a=Promise.withResolvers();return this.#t.push([o,a]),a.promise.finally(()=>this.#r())}}#r(){if(m(this.#e>0,"Internal Error in Promises.Limit"),--this.#e<this.max&&this.#t.length>0){let[o,{resolve:a,reject:c}]=this.#t.shift();this.#e++,o().then(a,c)}}}s.Limit=r;class n{#t;#e;#r;#s=d.None;constructor(o,a,c){this.#t=o,this.#e=a,this.#r=c}update(o){this.#s=d.wrap(o),o.then(a=>{this.#s.contains(o)&&this.#t(a)}).catch(a=>{this.#s.contains(o)&&this.#e(a)}).finally(()=>{this.#s.contains(o)&&(this.terminate(),N(this.#r))})}terminate(){this.#s=d.None}}s.Latest=n})(C||(C={}));var ze;(function(s){let t=new C.Limit(4);s.limitFetch=(e,r)=>t.add(()=>fetch(e,r))})(ze||(ze={}));var qe=(s="debug")=>{let t=performance.now();return{lab:e=>console[s].call(console,`${e} in ${(performance.now()-t).toFixed(1)}ms`)}};var We;(function(s){s.startEstimator=()=>{let t=performance.now();return e=>{if(e===0)return J.POSITIVE_INFINITY;let r=performance.now()-t;return J.millis(r/e-r)}}})(We||(We={}));var Ye;(function(s){s.frame=()=>new Promise(t=>requestAnimationFrame(()=>t())),s.frames=t=>new Promise(e=>{let r=t,n=()=>{--r<=0?e():requestAnimationFrame(n)};requestAnimationFrame(n)}),s.timeSpan=(t,...e)=>new Promise(r=>setTimeout(r,t.millis(),...e)),s.event=(t,e)=>new Promise(r=>t.addEventListener(e,r,{once:!0})),s.observable=t=>new Promise(e=>{let r=t.subscribe(()=>{r.terminate(),e()})}),s.complete=t=>new Promise((e,r)=>{let n=setInterval(()=>{let{status:i,value:o,error:a}=G(()=>t.next());if(i==="success"){let{done:c,value:h}=o;c&&(clearInterval(n),e(h))}else clearInterval(n),r(a)},0)})})(Ye||(Ye={}));var Mt=Symbol.for("@openDAW/lib-runtime");globalThis[Mt]?console.debug(`%c${Mt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Mt]=!0,console.debug(`%c${Mt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var x=class s{static newSet(t){return new ht(t,s.Comparator)}static compose=(t,...e)=>{let r=e.length===0?this.#t:new Int16Array(e);return m(r.every((n,i)=>n===e[i]),`fieldKeys (${r.join(",")}) only allows i16`),new s(t,r)};static decode(t){let e=t.split("/");return m(e.length>0,"Unable to parse Address"),s.compose(b.parse(e[0]),...e.slice(1).map(r=>parseInt(r)))}static reconstruct(t){return this.compose(t[0],...t[1])}static boxRange(t,e,r){let n=t.values(),i=A.leftMostMapped(n,e,b.Comparator,r),o=n.length;if(i<0||i>=o)return null;for(let a=i;a<o;a++)if(b.Comparator(r(n[a]),e)!==0)return i<a?[i,a]:null;return[i,o]}static Comparator=(t,e)=>{let r=b.Comparator(t.#e,e.#e);if(r!==0)return r;let n=Math.min(t.#r.length,e.#r.length);for(let i=0;i<n;i++){let o=t.#r[i]-e.#r[i];if(o!==0)return o}return t.#r.length-e.#r.length};static MinimalComparator=(t,e)=>{let r=b.Comparator(t.#e,e.#e);if(r!==0)return r;let n=Math.min(t.#r.length,e.#r.length);for(let i=0;i<n;i++){let o=t.#r[i]-e.#r[i];if(o!==0)return o}return 0};static LengthComparator=(t,e)=>{let r=b.Comparator(t.#e,e.#e);return r!==0?r:e.#r.length-t.#r.length};static#t=new Int16Array(0);#e;#r;constructor(t,e){this.#e=t,this.#r=e}get uuid(){return this.#e}get fieldKeys(){return this.#r}isBox(){return this.#r.length===0}isContent(){return!this.isBox()}equals(t){return s.Comparator(this,t)===0}compareTo(t){return s.Comparator(this,t)}append(t){return new s(this.#e,new Int16Array([...this.#r,t]))}startsWith(t){return b.Comparator(t.#e,this.#e)===0&&t.#r.length<=this.#r.length&&t.#r.every((e,r)=>this.#r[r]===e)}write(t){t.writeBytes(new Int8Array(this.#e.buffer)),t.writeByte(this.#r.length),this.#r.forEach(e=>t.writeShort(e))}moveTo(t){return new s(t,this.#r)}decompose(){return[this.#e,this.#r]}toJSON(){return{uuid:Array.from(this.#e.values()),fields:Array.from(this.#r.values())}}toArrayBuffer(){let t=new Uint8Array(b.length+this.#r.length);return t.set(this.#e,0),t.set(this.#r,b.length),t.buffer}toString(){return[b.toString(this.#e),...this.#r].join("/")}static read(t){let e=b.fromDataInput(t),r=t.readByte();return s.compose(e,...g.create(()=>t.readShort(),r))}},Z;(function(s){s.AddressReader=t=>t.address,s.Comparator=({address:t},{address:e})=>x.Comparator(t,e),s.equals=(t,e)=>{let[r,n]=A.rangeMapped(e,t,x.Comparator,s.AddressReader);return e.slice(r,n+1)},s.startsWith=(t,e)=>{let[r,n]=A.rangeMapped(e,t,x.MinimalComparator,s.AddressReader);return e.slice(r,n+1).filter(i=>i.address.startsWith(t))},s.endsWith=(t,e)=>{let r=A.leftMostMapped(e,t,x.LengthComparator,s.AddressReader),n=A.rightMostMapped(e,t,x.MinimalComparator,s.AddressReader);return e.slice(r,n+1).filter(i=>t.startsWith(i.address))}})(Z||(Z={}));var D=class s{static validate(t,e){if(t.address.equals(e.address))return d.wrap(`PointerField cannot point to itself: ${t}`);if(!e.pointerRules.accepts.some(r=>r===t.pointerType)){let r=e.pointerRules.accepts.join(", ");return d.wrap(`${String(t.pointerType)} does not satisfy any of the allowed types (${r}).`)}return d.None}#t;#e;#r;#s=d.None;constructor(t){this.#t=t,this.#e=new ct,this.#r=new ct}subscribeImmediate(t,...e){return this.#n(this.#e,t,e)}subscribeTransactual(t,...e){return this.#n(this.#r,t,e)}catchupAndSubscribeTransactual(t,...e){let r=x.newSet(n=>n.address);return r.addMany(this.filter(...e)),r.forEach(n=>t.onAdd(n)),this.subscribeTransactual({onAdd:n=>{r.add(n)&&t.onAdd(n)},onRemove:n=>{r.removeByKey(n.address),t.onRemove(n)}},...e)}filter(...t){return t.length===0?this.incoming():B.filter(this.incoming().values(),e=>t.some(r=>r===e.pointerType))}size(){return this.incoming().length}isEmpty(){return this.size()===0}nonEmpty(){return this.size()>0}contains(t){return this.incoming().some(e=>t.address.equals(e.address))}incoming(){return this.#t.graph.edges().incomingEdgesOf(this.#t)}onAdded(t){let e=s.validate(t,this.#t);if(e.nonEmpty())return u(e.unwrap());this.#s.isEmpty()?(this.#s=d.wrap([{type:"add",pointerField:t}]),this.#t.graph.subscribeEndTransaction(this.#i)):this.#s.unwrap().push({type:"add",pointerField:t}),this.#e.proxy.onAdd(t)}onRemoved(t){this.#s.isEmpty()?(this.#s=d.wrap([{type:"remove",pointerField:t}]),this.#t.graph.subscribeEndTransaction(this.#i)):this.#s.unwrap().push({type:"remove",pointerField:t}),this.#e.proxy.onRemove(t)}toString(){return`{Pointers ${this.#t.address}, pointers: ${this.incoming().values().map(t=>t.toString())}}`}#n(t,e,r){return t.subscribe({onAdd:n=>{(r.length===0||r.some(i=>i===n.pointerType))&&e.onAdd(n)},onRemove:n=>{(r.length===0||r.some(i=>i===n.pointerType))&&e.onRemove(n)}})}#i=()=>{if(this.#t.isAttached()){let t=this.#s.unwrap("Callback without ChangeLog");t.forEach(({type:e,pointerField:r})=>{e==="add"?this.#r.proxy.onAdd(r):e==="remove"?this.#r.proxy.onRemove(r):u(`Unknown type: ${e}`)}),t.length=0}this.#s=d.None}};var le=function(s,t,e,r){var n=arguments.length,i=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(t,e,i):o(t,e))||i);return n>3&&i&&Object.defineProperty(t,e,i),i},lt=function(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)},O=class s{static hook(t){return new s(t)}#t;#e;#r;#s;constructor({parent:t,fieldKey:e,fieldName:r,pointerRules:n}){this.#t=t,this.#e=e,this.#r=r,this.#s=n,n.mandatory&&this.graph.edges().watchVertex(this)}accept(t){return N(t.visitField,this)}get box(){return this.#t.box}get graph(){return this.#t.graph}get parent(){return this.#t}get fieldKey(){return this.#e}get fieldName(){return this.#r}get pointerRules(){return this.#s}get pointerHub(){return new D(this)}get address(){return this.#t.address.append(this.#e)}get debugPath(){return`${this.box.name}:${this.box.mapFields(t=>t.fieldName,...this.address.fieldKeys).join("/")}`}isBox(){return!1}isField(){return!0}isAttached(){return this.graph.findBox(this.address.uuid).nonEmpty()}fields(){return B.empty()}getField(t){return u()}optField(t){return d.None}read(t){}write(t){}disconnect(){if(this.pointerHub.isEmpty())return;let t=this.pointerHub.incoming();t.forEach(e=>{e.defer(),(e.mandatory||this.pointerRules.mandatory&&t.length===1)&&e.box.delete()})}toString(){return`{${this.box.constructor.name}:${this.constructor.name} (${this.fieldName}) ${this.address.toString()}`}};le([it,lt("design:type",D),lt("design:paramtypes",[])],O.prototype,"pointerHub",null);le([it,lt("design:type",x),lt("design:paramtypes",[])],O.prototype,"address",null);le([it,lt("design:type",String),lt("design:paramtypes",[])],O.prototype,"debugPath",null);var dr=Object.freeze({mandatory:!1,accepts:[]});var ut;(function(s){s.writeFields=(e,r)=>{let n=Object.entries(r);e.writeInt(1179403347),e.writeShort(n.length),n.forEach(([i,o])=>{let a=v.create();o.write(a);let c=new Int8Array(a.toArrayBuffer());e.writeShort(Number(i)),e.writeInt(c.length),e.writeBytes(c)})},s.readFields=(e,r)=>{m(e.readInt()===1179403347,"Serializer header is corrupt");let n=e.readShort();for(let i=0;i<n;i++){let o=e.readShort();if(It(r[o]))continue;let a=e.readInt(),c=new Int8Array(a);e.readBytes(c);let{status:h,error:l}=G(()=>r[o]?.read(new F(c.buffer)));h==="failure"&&console.warn(l)}}})(ut||(ut={}));var pr=function(s,t,e,r){var n=arguments.length,i=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(t,e,i):o(t,e))||i);return n>3&&i&&Object.defineProperty(t,e,i),i},He=function(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)},ue=class s{static DEBUG_DELETION=!1;static Index=0;#t;#e;#r;#s;#n;#i=s.Index++;constructor({uuid:t,graph:e,name:r,pointerRules:n}){this.#t=x.compose(t),this.#e=e,this.#r=r,this.#s=n,this.#n=this.initializeFields(),n.mandatory&&this.graph.edges().watchVertex(this)}fields(){return Object.values(this.#n)}getField(t){return w(this.#n[t])}optField(t){return d.wrap(this.#n[t])}subscribe(t,e){return this.graph.subscribeVertexUpdates(t,this.address,e)}get box(){return this}get name(){return this.#r}get graph(){return this.#e}get parent(){return this}get address(){return this.#t}get pointerRules(){return this.#s}get creationIndex(){return this.#i}get pointerHub(){return new D(this)}estimateMemory(){let t=new nt;return this.write(t),t.count}isBox(){return!0}asBox(t){return we(this,t)}isField(){return!1}isAttached(){return this.#e.findBox(this.address.uuid).nonEmpty()}read(t){ut.readFields(t,this.#n)}write(t){ut.writeFields(t,this.#n)}serialize(){let t=v.create();return t.writeInt(this.#i),t.writeString(this.name),t.writeBytes(new Int8Array(this.address.uuid.buffer)),this.write(t),t.toArrayBuffer()}toArrayBuffer(){let t=v.create();return this.write(t),t.toArrayBuffer()}incomingEdges(){return this.graph.edges().incomingEdgesOf(this)}outgoingEdges(){return this.graph.edges().outgoingEdgesOf(this)}mapFields(t,...e){if(e.length===0)return g.empty();let r=this.getField(e[0]),n=[t(r)];for(let i=1;i<e.length;i++)r=r.getField(e[i]),n.push(t(r));return n}searchVertex(t){if(t.length===0)return d.wrap(this);let e=this.optField(t[0]);if(e.isEmpty())return d.None;for(let r=1;r<t.length;r++)if(e=e.unwrap().optField(t[r]),e.isEmpty())return d.None;return e}delete(){let{boxes:t,pointers:e}=this.graph.dependenciesOf(this);s.DEBUG_DELETION&&(console.debug(`Delete ${this.toString()}`),console.debug(" unplugs",[...e].map(r=>r.toString()).join(`
1
+ var p=s=>s!=null,It=s=>s==null,be=s=>s===null;var w=(s,t="asDefined failed")=>s??u(t);var Ee=(s,t)=>s instanceof t?s:u(`${s} is not instance of ${t}`);var st=s=>s instanceof Function?s():s;var N=(s,...t)=>s?.apply(null,t),Wt=s=>p(s)&&typeof s=="object",Yt=(s,t,e)=>{if(!(t in s))return!1;let r=s[t];return e==="null"?r===null:typeof r===e};var k=s=>{throw new Error(`Unhandled ${s}`)},u=s=>{throw typeof s=="string"?new Error(s):s},m=(s,t)=>s?void 0:u(st(t));var Ht=s=>new Proxy({},{get(){return u(s)}});var G=s=>{try{return{error:null,value:s(),status:"success"}}catch(t){return{error:t,value:null,status:"failure"}}};var Gt=()=>{};var Ae=s=>{};var Xt;(function(s){s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Xt||(Xt={}));var g=class{static#t=Object.freeze(new Array(0));static empty=()=>this.#t;static clear=t=>{t.length=0};static replace=(t,e)=>{t.length=0,t.push(...e)};static consume=(t,e)=>{for(let r=0;r<t.length;)e(t[r])?t.splice(r,1):r++};static peekFirst=t=>t.at(0)??null;static peekLast=t=>t.at(-1)??null;static getFirst=(t,e)=>w(t.at(0),e);static getLast=(t,e)=>w(t.at(-1),e);static getPrev=(t,e)=>{let r=t.indexOf(e);return r===-1?u(`${e} not found in ${t}`):w(t.at((r-1)%t.length),"Internal Error")};static getNext=(t,e)=>{let r=t.indexOf(e);return r===-1?u(`${e} not found in ${t}`):w(t.at((r+1)%t.length),"Internal Error")};static removeLast=(t,e)=>w(t.pop(),e);static create=(t,e)=>{let r=new Array(e);for(let n=0;n<e;n++)r[n]=t(n);return r};static equals=(t,e)=>{if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0};static satisfy=(t,e)=>{if(t.length<2)return!0;let r=t[0];for(let n=1;n<t.length;n++)if(!e(r,t[n]))return!1;return!0};static remove=(t,e)=>{let r=t.indexOf(e);if(r===-1)return u(`${e} not found in ${t}`);t.splice(r,1)};static removeOpt=(t,e)=>{let r=t.indexOf(e);return r===-1?!1:(t.splice(r,1),!0)};static hasDuplicates=t=>new Set(t).size<t.length;static removeDuplicates=t=>{let e=0,r=new Set;for(let n of t)r.has(n)||(r.add(n),t[e++]=n);return t.length=e,t};static removeDuplicateKeys=(t,e)=>{let r=0,n=new Set;for(let i of t){let o=i[e];n.has(o)||(n.add(o),t[r++]=i)}return t.length=r,t};static*iterate(t){for(let e=0;e<t.length;e++)yield t[e]}static*iterateReverse(t){for(let e=t.length-1;e>=0;e--)yield t[e]}static*iterateStateFull(t){let e=t.length-1;for(let r=0;r<=e;r++)yield{value:t[r],isFirst:r===0,isLast:r===e}}static isSorted(t,e=Xt.Ascending){if(t.length<2)return!0;let r=t[0];for(let n=1;n<t.length;n++){let i=t[n];if(Math.sign(r-i)===e)return!1;r=i}return!0}};var d;(function(s){s.wrap=e=>p(e)?new t(e):s.None,s.from=e=>s.wrap(e()),s.tryFrom=e=>{try{return s.wrap(e())}catch{return s.None}},s.execute=(e,...r)=>s.wrap(e?.apply(null,r)),s.async=e=>e.then(r=>s.wrap(r),()=>s.None);class t{#t;constructor(r){this.#t=w(r)}unwrap(){return this.#t}unwrapOrElse(r){return this.#t}unwrapOrNull(){return this.#t}unwrapOrUndefined(){return this.#t}contains(r){return r===this.#t}match(r){return r.some(this.#t)}ifSome(r){return r(this.#t)}isEmpty(){return!1}nonEmpty(){return!0}map(r){return s.wrap(r(this.#t))}mapOr(r,n){return r(this.#t)}flatMap(r){return r(this.#t)}equals(r){return this.unwrapOrNull()===r.unwrapOrNull()}assert(r){return this}toString(){return`{Option.Some(${this.#t})}`}get[Symbol.toStringTag](){return this.toString()}}s.Some=t,s.None=new class{unwrap=e=>u(p(e)?st(e):"unwrap failed");unwrapOrElse=e=>st(e);unwrapOrNull=()=>null;unwrapOrUndefined=()=>{};contains=e=>!1;match=e=>e.none();ifSome=e=>{};isEmpty=()=>!0;nonEmpty=()=>!1;map=e=>s.None;mapOr=(e,r)=>st(r);flatMap=e=>s.None;equals=e=>e.isEmpty();assert=e=>u(st(e)??"assert failed");toString=()=>"{Option.None}";get[Symbol.toStringTag](){return this.toString()}}})(d||(d={}));var Ie;(function(s){s.async=t=>t.then(e=>s.ok(e),e=>s.err(e)),s.tryGet=t=>{try{return s.ok(t())}catch(e){return s.err(e)}},s.ok=t=>new class{value;constructor(e){this.value=e}asOption=()=>d.wrap(this.value);failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>this.value;map=e=>{try{return s.ok(e(this.value))}catch(r){return s.err(r)}};flatMap=e=>e(this.value);match=e=>e.ok(this.value);toVoid=()=>s.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>`{Success: ${this.value}`;get[Symbol.toStringTag](){return"Success"}}(t),s.Ok=new class{constructor(){}asOption=()=>d.None;failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>{};map=t=>s.ok(t());flatMap=t=>t();match=t=>t.ok();toVoid=()=>s.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>"{Success: Ok";get[Symbol.toStringTag](){return"Success"}},s.err=t=>new class{reason;constructor(e){this.reason=e}asOption=()=>d.None;failureReason=()=>this.reason;isFailure=()=>!0;isSuccess=()=>!1;result=()=>{throw new Error(`No result because '${this.reason}'`)};map=()=>this;flatMap=()=>this;match=e=>e.err(this.reason);toVoid=()=>s.err(this.reason);failure=()=>this;toString=()=>`{Failure: ${this.reason}`;get[Symbol.toStringTag](){return"Failure"}}(t)})(Ie||(Ie={}));var A;(function(s){s.exact=(t,e,r)=>{let n=0,i=t.length-1;for(;n<=i;){let o=n+i>>>1,a=r(t[o],e);if(a===0)return o;a<0?n=o+1:i=o-1}return-1},s.exactMapped=(t,e,r,n)=>{let i=0,o=t.length-1;for(;i<=o;){let a=i+o>>>1,c=r(n(t[a]),e);if(c===0)return a;c<0?i=a+1:o=a-1}return-1},s.leftMost=(t,e,r)=>{let n=0,i=t.length;for(;n<i;){let o=n+i>>>1;r(t[o],e)<0?n=o+1:i=o}return n},s.rightMost=(t,e,r)=>{let n=0,i=t.length;for(;n<i;){let o=n+i>>>1;r(t[o],e)<=0?n=o+1:i=o}return i-1},s.leftMostMapped=(t,e,r,n)=>{let i=0,o=t.length;for(;i<o;){let a=i+o>>>1;r(n(t[a]),e)<0?i=a+1:o=a}return i},s.rightMostMapped=(t,e,r,n)=>{let i=0,o=t.length;for(;i<o;){let a=i+o>>>1;r(n(t[a]),e)<=0?i=a+1:o=a}return o-1},s.rangeMapped=(t,e,r,n)=>[s.leftMostMapped(t,e,r,n),s.rightMostMapped(t,e,r,n)]})(A||(A={}));var vt;(function(s){s.parseCssRgbOrRgba=t=>{let e=t.match(/\(([^)]+)\)/)?.at(1)?.split(",")?.map(Number);if(p(e)&&e.every(r=>!isNaN(r))){if(e.length===3)return[e[0]/255,e[1]/255,e[2]/255,1];if(e.length===4)return[e[0]/255,e[1]/255,e[2]/255,e[3]]}throw new Error(`${t} is not proper formatted. Example: 'rgb(255, 255, 255)' or 'rgba(255, 255, 255, 1)'`)},s.hslToHex=(t,e,r)=>{let n=c=>(c+t/30)%12,i=e*Math.min(r,1-r),o=c=>r-i*Math.max(-1,Math.min(n(c)-3,Math.min(9-n(c),1))),a=c=>Math.round(c*255).toString(16).padStart(2,"0");return`#${a(o(0))}${a(o(8))}${a(o(4))}`},s.hexToHsl=t=>{let e=t.startsWith("#")?t.slice(1):t,r=parseInt(e.slice(0,2),16)/255,n=parseInt(e.slice(2,4),16)/255,i=parseInt(e.slice(4,6),16)/255,o=Math.max(r,n,i),a=Math.min(r,n,i),c=(o+a)/2,h=0,l=0;if(o!==a){let f=o-a;switch(l=c>.5?f/(2-o-a):f/(o+a),o){case r:h=((n-i)/f+(n<i?6:0))*60;break;case n:h=((i-r)/f+2)*60;break;case i:h=((r-n)/f+4)*60;break}}return{h,s:l,l:c}},s.hslStringToHex=t=>{let[e,r,n]=t.match(/\d+(\.\d+)?/g).map(Number);return s.hslToHex(e,r/100,n/100)}})(vt||(vt={}));var Qt=(s,t)=>s-t;var Pr=Math.PI*2,Cr=Math.PI/2,Dr=Math.PI/4,kr=1/Math.sqrt(2),y=(s,t,e)=>Math.max(t,Math.min(s,e));var Jt=s=>Math.pow(2,Math.ceil(Math.log(s)/Math.log(2)));var ve;(function(s){s.valueAt=({slope:n,steps:i,y0:o,y1:a},c)=>s.normalizedAt(c/i,n)*(a-o)+o,s.normalizedAt=(n,i)=>{if(i>.499999&&i<.500001)return n;{let o=y(i,1e-15,.999999999999999);return o*o/(1-o*2)*(Math.pow((1-o)/o,2*n)-1)}},s.inverseAt=(n,i)=>{let o=y(i,1e-15,.999999999999999);return Math.log(n*(1-2*o)/(o*o)+1)/(2*Math.log((1-o)/o))},s.coefficients=n=>{let i=s.valueAt(n,1),a=(s.valueAt(n,2)-i)/(i-n.y0),c=i-a*n.y0;return{m:a,q:c}};function*e(n,i,o,a){let{m:c,q:h}=s.coefficients({slope:n,steps:i,y0:o,y1:a});for(let l=0,f=o;l<i;l++)yield f=c*f+h}s.walk=e;function*r(n,i){let o=1/i,a=s.normalizedAt(o,n),h=(s.normalizedAt(2*o,n)-a)/a;for(let l=0,f=0;l<i;l++)yield f=h*f+a}s.walkNormalized=r,s.byHalf=(n,i,o,a)=>({slope:s.slopeByHalf(i,o,a),steps:n,y0:i,y1:a}),s.slopeByHalf=(n,i,o)=>Math.abs(o-n)<1e-6?.5:(i-n)/(o-n)})(ve||(ve={}));var L=new DataView(new ArrayBuffer(8)),_;(function(s){s.MIN_VALUE=-2147483648,s.MAX_VALUE=2147483647,s.toByte=t=>(L.setInt8(0,t),L.getInt8(0)),s.toShort=t=>(L.setInt16(0,t),L.getInt16(0)),s.toInt=t=>(L.setInt32(0,t),L.getInt32(0))})(_||(_={}));var X;(function(s){let r=new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT),n=new Float32Array(r),i=new Int32Array(r);s.floatToIntBits=o=>{let a=s.floatToRawIntBits(o);return(a&2139095040)===2139095040&&(a&8388607)!==0?2143289344:a},s.intBitsToFloat=o=>(i[0]=o,n[0]),s.floatToRawIntBits=o=>(n[0]=o,i[0]),s.toFloat32=o=>(L.setFloat32(0,o),L.getFloat32(0))})(X||(X={}));var j;(function(s){s.floatToIntBits=t=>{let e=X.floatToIntBits(t),r=e>>>16&32768,n=(e&2147483647)+4096;return n>=1199570944?(e&2147483647)>=1199570944?n<2139095040?r|31744:r|31744|(e&8388607)>>>13:r|31743:n>=947912704?r|n-939524096>>>13:n<855638016?r:(n=(e&2147483647)>>>23,r|(e&8388607|8388608)+(8388608>>>n-102)>>>126-n)},s.intBitsToFloat=t=>{let e=t&1023,r=t&31744;if(r===31744)r=261120;else if(r!==0){if(r+=114688,e===0&&r>115712)return X.intBitsToFloat((t&32768)<<16|r<<13|1023)}else if(e!==0){r=115712;do e<<=1,r-=1024;while((e&1024)===0);e&=1023}return X.intBitsToFloat((t&32768)<<16|(r|e)<<13)}})(j||(j={}));var Zt;(function(s){let t=9218868437227405312n,e=4503599627370495n,r=new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT),n=new Float64Array(r),i=new BigInt64Array(r);s.float64ToLongBits=o=>{let a=s.float64ToRawLongBits(o);return(a&t)===t&&(a&e)!==0n?0x7ff8000000000000n:a},s.longBitsToFloat64=o=>(i[0]=o,n[0]),s.float64ToRawLongBits=o=>(n[0]=o,i[0]),s.clamp=o=>(L.setFloat64(0,o),L.getFloat64(0))})(Zt||(Zt={}));var B=class{static*empty(){}static one(t){return[t]}static count(t){let e=0;for(let r of t)e++;return e}static some(t,e){for(let r of t)if(e(r))return!0;return!1}static every(t,e){for(let r of t)if(!e(r))return!1;return!0}static reduce(t,e,r){let n=r,i=0;for(let o of t)n=e(n,o,i++);return n}static includes(t,e){for(let r of t)if(r===e)return!0;return!1}static forEach(t,e){for(let r of t)e(r)}static*map(t,e){let r=0;for(let n of t)yield e(n,r++)}static*take(t,e){let r=0;for(let n of t){if(r++>=e)return;yield n}}static filter(t,e){let r=[];for(let n of t)e(n)&&r.push(n);return r}static filterMap(t,e){let r=[];for(let n of t){let i=e(n);p(i)&&r.push(i)}return r}static reverse(t){let e=[];for(let r of t)e.push(r);return e.reverse()}static*pairWise(t){let e=t[Symbol.iterator](),{done:r,value:n}=e.next(),i=n;if(r!==!0)for(;;){let{done:o,value:a}=e.next();if(o===!0){yield[i,null];return}yield[i,a],i=a}}};var v=class s{static create(t=1024){return this.use(new ArrayBuffer(t))}static use(t,e=0){return new s(new DataView(t,e))}littleEndian=!1;#t;#e=0;constructor(t){this.#t=t}get remaining(){return this.#t.byteLength-this.#e}get position(){return this.#e}set position(t){t<0?u(`position(${t}) cannot be negative.`):t>this.#t.byteLength?u(`position(${t}) is outside range (${this.#t.byteLength}).`):this.#e=t}writeBoolean(t){this.writeByte(t?1:0)}writeByte(t){this.#r(1),this.#t.setInt8(this.#e++,t)}writeShort(t){this.#r(Int16Array.BYTES_PER_ELEMENT),this.#t.setInt16(this.#e,t,this.littleEndian),this.#e+=Int16Array.BYTES_PER_ELEMENT}writeInt(t){this.#r(Int32Array.BYTES_PER_ELEMENT),this.#t.setInt32(this.#e,t,this.littleEndian),this.#e+=Int32Array.BYTES_PER_ELEMENT}writeLong(t){this.#r(BigInt64Array.BYTES_PER_ELEMENT),this.#t.setBigInt64(this.#e,t,this.littleEndian),this.#e+=BigInt64Array.BYTES_PER_ELEMENT}writeFloat(t){this.#r(Float32Array.BYTES_PER_ELEMENT),this.#t.setFloat32(this.#e,t,this.littleEndian),this.#e+=Float32Array.BYTES_PER_ELEMENT}writeDouble(t){this.#r(Float64Array.BYTES_PER_ELEMENT),this.#t.setFloat64(this.#e,t,this.littleEndian),this.#e+=Float64Array.BYTES_PER_ELEMENT}writeBytes(t){this.#r(t.length);for(let e=0;e<t.length;++e)this.#t.setInt8(this.#e++,t[e])}writeString(t){let e=t.length;this.#r(Int32Array.BYTES_PER_ELEMENT+e*Int16Array.BYTES_PER_ELEMENT),this.writeInt(e);for(let r=0;r<e;r++)this.writeShort(t.charCodeAt(r))}toArrayBuffer(){return this.#t.buffer.slice(0,this.#e)}#r(t){let e=this.#t.byteLength;if(this.#e+t>e){let r=this.#t;this.#t=new DataView(new ArrayBuffer(Jt(e+t)));for(let n=0;n<this.#e;n++)this.#t.setInt8(n,r.getInt8(n))}}},nt=class{#t=0;writeByte(t){this.#t++}writeShort(t){this.#t+=2}writeInt(t){this.#t+=4}writeLong(t){this.#t+=8}writeFloat(t){this.#t+=4}writeDouble(t){this.#t+=8}writeBoolean(t){this.#t++}writeBytes(t){this.#t+=t.length}writeString(t){this.#t+=t.length+4}get count(){return this.#t}};var F=class{littleEndian=!1;#t;#e=0;constructor(t,e=0){this.#t=new DataView(t,e)}get position(){return this.#e}set position(t){t<0?u(`position(${t}) cannot be negative.`):t>this.#t.byteLength?u(`position(${t}) is outside range (${this.#t.byteLength}).`):this.#e=t}readByte(){return this.#t.getInt8(this.#e++)}readShort(){let t=this.#t.getInt16(this.#e,this.littleEndian);return this.#e+=Int16Array.BYTES_PER_ELEMENT,t}readInt(){let t=this.#t.getInt32(this.#e,this.littleEndian);return this.#e+=Int32Array.BYTES_PER_ELEMENT,t}readLong(){let t=this.#t.getBigInt64(this.#e,this.littleEndian);return this.#e+=BigInt64Array.BYTES_PER_ELEMENT,t}readFloat(){let t=this.#t.getFloat32(this.#e,this.littleEndian);return this.#e+=Float32Array.BYTES_PER_ELEMENT,t}readDouble(){let t=this.#t.getFloat64(this.#e,this.littleEndian);return this.#e+=Float64Array.BYTES_PER_ELEMENT,t}readBoolean(){return this.readByte()===1}readBytes(t){for(let e=0;e<t.length;e++)t[e]=this.readByte()}readString(){let t=this.readInt(),e="";for(let r=0;r<t;r++)e+=String.fromCharCode(this.readShort());return e}available(t){return this.#e+t<=this.#t.byteLength}remaining(){return this.#t.byteLength-this.#e}skip(t){this.position+=t}};var mr=s=>p(s)?s.value!==void 0?"value":s.get!==void 0?"get":u(`Cannot resolve method key of ${s}`):u("Cannot resolve method key of undefined descriptor"),it=(s,t,e)=>{if(!p(e))return function(i,o){if(o&&o.kind==="getter")return function(){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this),t);if(!p(a?.get))return u(`Cannot find getter for property '${t}'`);let c=a.get.apply(this);return Object.defineProperty(this,t,{value:c,configurable:!1,writable:!1,enumerable:!1}),c}};let r=mr(e),n=w(e[r]);return{[r]:function(...i){if(i.length>0)return u("lazy accessory must not have any construction parameters");let o=n.apply(this);return Object.defineProperty(this,t,{value:r==="get"?o:()=>o,configurable:!1,writable:!1,enumerable:!1}),o}}};var Se;(function(s){function*t(){}s.empty=t,s.next=r=>{let{value:n,done:i}=r.next();return i?null:n};function*e(...r){for(let n of r)for(let i of n)yield i}s.flatten=e})(Se||(Se={}));var ot;(function(s){s[s.T=0]="T",s[s.R=1]="R",s[s.B=2]="B",s[s.L=3]="L"})(ot||(ot={}));var at;(function(s){s[s.TL=0]="TL",s[s.TR=1]="TR",s[s.BR=2]="BR",s[s.BL=3]="BL"})(at||(at={}));var Te;(function(s){s.outerTangentPoints=(t,e)=>{let r=e.x-t.x,n=e.y-t.y,i=Math.atan2(n,r)+Math.acos((t.r-e.r)/Math.sqrt(r*r+n*n)),o=Math.cos(i),a=Math.sin(i);return[{x:t.x+t.r*o,y:t.y+t.r*a},{x:e.x+e.r*o,y:e.y+e.r*a}]}})(Te||(Te={}));var Me;(function(s){s.zero=()=>({x:0,y:0}),s.create=(t,e)=>({x:t,y:e}),s.clone=t=>({...t}),s.floor=t=>({x:Math.floor(t.x),y:Math.floor(t.y)}),s.length=t=>Math.sqrt(t.x*t.x+t.y*t.y),s.distance=(t,e)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),s.add=(t,e)=>({x:t.x+e.x,y:t.y+e.y}),s.subtract=(t,e)=>({x:t.x-e.x,y:t.y-e.y}),s.scaleBy=(t,e)=>({x:t.x*e,y:t.y*e}),s.scaleTo=(t,e)=>{let r=e/s.length(t);return{x:t.x*r,y:t.y*r}},s.fromClient=t=>({x:t.clientX,y:t.clientY})})(Me||(Me={}));var gt;(function(s){s.Empty=Object.freeze({x:0,y:0,width:0,height:0}),s.corners=t=>{let e=t.x,r=t.y,n=e+t.width,i=r+t.height;return[{x:e,y:r},{x:n,y:r},{x:n,y:i},{x:e,y:i}]},s.inflate=(t,e)=>({x:t.x-e,y:t.y-e,width:t.width+e*2,height:t.height+e*2}),s.contains=(t,e)=>{let r=e.x>=t.x&&e.y>=t.y,n=e.x+e.width<=t.x+t.width&&e.y+e.height<=t.y+t.height;return r&&n},s.isPointInside=(t,e)=>t.x>=e.x&&t.x<=e.x+e.width&&t.y>=e.y&&t.y<=e.y+e.height,s.intersect=(t,e)=>{let r=Math.max(t.x,e.x),n=Math.min(t.x+t.width,e.x+e.width),i=Math.min(t.y+t.height,e.y+e.height),o=Math.max(t.y,e.y);return n>r&&i>o},s.axis=(t,e)=>{switch(e){case ot.T:return t.y;case ot.R:return t.x+t.width;case ot.B:return t.y+t.height;case ot.L:return t.x;default:return k(e)}},s.corner=(t,e)=>{switch(e){case at.TL:return{x:t.x,y:t.y};case at.TR:return{x:t.x+t.width,y:t.y};case at.BR:return{x:t.x+t.width,y:t.y+t.height};case at.BL:return{x:t.x,y:t.y+t.height};default:return k(e)}},s.center=t=>({x:t.x+t.width*.5,y:t.y+t.height*.5}),s.isEmpty=t=>t.width===0||t.height===0,s.union=(t,e)=>{if(s.isEmpty(t))s.isEmpty(e)||(t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height);else if(!s.isEmpty(e)){let r=e.x,n=e.y,i=Math.min(t.x,r),o=Math.min(t.y,n);t.width=Math.max(t.x+t.width,r+e.width)-i,t.height=Math.max(t.y+t.height,n+e.height)-o,t.x=i,t.y=o}}})(gt||(gt={}));var Ne;(function(s){s.width=t=>t.xMax-t.xMin,s.height=t=>t.yMax-t.yMin,s.from=(t,e)=>{t.xMin=e.xMin,t.xMax=e.xMax,t.yMin=e.yMin,t.yMax=e.yMax},s.extend=(t,e)=>{t.xMin-=e,t.yMin-=e,t.xMax+=e,t.yMax+=e},s.padding=(t,[e,r,n,i])=>(t.xMin+=i,t.yMin+=e,t.xMax-=r,t.yMax-=n,t),s.intersectPoint=(t,e)=>t.xMin<=e.x&&e.x<t.xMax&&t.yMin<=e.y&&e.y<t.yMax,s.intersectThat=(t,e)=>e.xMin<t.xMax&&e.xMax>t.xMin&&e.yMin<t.yMax&&e.yMax>t.yMin,s.center=t=>({x:(t.xMin+t.xMax)*.5,y:(t.yMin+t.yMax)*.5})})(Ne||(Ne={}));var Be;(function(s){s.Identity=Object.freeze([0,0,0,0])})(Be||(Be={}));var Fe;(function(s){s.intersects=(r,n,i,o,a,c,h,l)=>{let f=t(r,n,i,o,a,c),E=t(r,n,i,o,h,l);if((f|E)===0||(f&E)!==0)return!1;let R=e(a,c,h,l,r,i);return R!==e(a,c,h,l,n,i)||R!==e(a,c,h,l,n,o)||R!==e(a,c,h,l,r,o)};let t=(r,n,i,o,a,c)=>{let h=0;return a<=r?h|=1:a>=n&&(h|=2),c<=i?h|=8:c>=o&&(h|=4),h},e=(r,n,i,o,a,c)=>(i-r)*(c-n)-(a-r)*(o-n)>=0})(Fe||(Fe={}));var Oe;(function(s){s.Identity={valueToAxis:t=>t,axisToValue:t=>t},s.toClamped=(t,e,r)=>({valueToAxis:n=>t.valueToAxis(y(n,e,r)),axisToValue:n=>y(t.axisToValue(n),e,r)}),s.createClamped=(t,e)=>({valueToAxis:r=>y(r,t,e),axisToValue:r=>y(r,t,e)})})(Oe||(Oe={}));var $e;(function(s){s.fromBuffers=async(...t)=>{let e=t.reduce((i,o)=>i+o.byteLength,0),r=new Uint8Array(e),n=0;for(let i of t)r.set(new Uint8Array(i),n),n+=i.byteLength;return await crypto.subtle.digest("SHA-256",r)},s.equals=(t,e)=>{m(t.byteLength===32,"First hash has invalid length"),m(e.byteLength===32,"Second hash has invalid length");let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<32;i++)if(r[i]!==n[i])return!1;return!0},s.toString=t=>Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")})($e||($e={}));var Re;(function(s){s.intersect1D=(t,e,r,n)=>Math.max(t,r)<=Math.min(e,n)})(Re||(Re={}));var ct=class{#t=new Set;#e;constructor(){this.#e=new Proxy({},{get:(t,e)=>(...r)=>this.#t.forEach(n=>Object.getPrototypeOf(n)===Object.getPrototypeOf({})?N(n[e],...r):n[e]?.apply(n,r))})}get proxy(){return this.#e}get size(){return this.#t.size}subscribe(t){return this.#t.add(t),{terminate:()=>this.#t.delete(t)}}forEach(t){this.#t.forEach(t)}terminate(){this.#t.clear()}};var yt=class{static createIfAbsent(t,e,r){let n=t.get(e);return n===void 0&&(n=r(e),t.set(e,n)),n}};var te=class s{static#t=Object.freeze(new Set);static empty=()=>s.#t};var S=Object.freeze({Empty:{terminate:Gt},create:s=>({terminate:s}),many:(...s)=>({terminate:()=>{for(;s.length>0;)s.pop().terminate()}})}),Q=class s{#t=[];own(t){return this.#t.push(t),t}ownAll(...t){for(let e of t)this.#t.push(e)}spawn(){let t=new s;return t.own({terminate:()=>g.removeOpt(this.#t,t)}),this.own(t)}terminate(){for(;this.#t.length>0;)this.#t.pop().terminate()}};var U=class{static subscribeMany(t,...e){return S.many(...e.map(r=>r.subscribe(()=>t(r))))}#t=new Set;subscribe(t){return this.#t.add(t),{terminate:()=>this.#t.delete(t)}}isEmpty(){return this.#t.size===0}notify(t){this.#t.forEach(e=>e(t))}observers(){return this.#t}terminate(){this.#t.clear()}};var Ve;(function(s){s.mergeNoOverlap=(t,e)=>{let r=new Set(Object.keys(t));for(let n of Object.keys(e))if(r.has(n))return u(`'${n}' is an overlapping key`);return{...t,...e}},s.include=(t,...e)=>e.reduce((r,n)=>(r[n]=t[n],r),{}),s.exclude=(t,...e)=>{let r=new Set(e);return Object.entries(t).reduce((n,[i,o])=>(r.has(i)||(n[i]=o),n),{})},s.overwrite=(t,e)=>Object.assign(t,e)})(Ve||(Ve={}));var Le;(function(s){s.make=t=>new class{getValue(){return t}subscribe(e){return S.Empty}catchupAndSubscribe(e){return e(this),S.Empty}}})(Le||(Le={}));var Pe;(function(s){s.False=new class{getValue(){return!1}setValue(t){}subscribe(t){return S.Empty}catchupAndSubscribe(t){return t(this),S.Empty}},s.inverseBoolean=t=>new class{getValue(){return!t.getValue()}setValue(e){t.setValue(!e)}subscribe(e){return t.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}}})(Pe||(Pe={}));var St=class{#t;#e=d.None;#r;constructor(t,e){this.#t=new U,this.#r=e?.guard(t)??t,this.#e=d.wrap(e)}setValue(t){this.#e.nonEmpty()&&(t=this.#e.unwrap().guard(t)),this.#r!==t&&(this.#r=t,this.#t.notify(this))}getValue(){return this.#r}subscribe(t){return this.#t.subscribe(t)}catchupAndSubscribe(t){return t(this),this.#t.subscribe(t)}terminate(){this.#t.terminate()}toString(){return`{DefaultObservableValue value: ${this.#r}`}};var ee=class{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=e,this.#r=e-t}x(t){return(this.clamp(t)-this.#t)/this.#r}y(t){return this.#t+y(t,0,1)*this.#r}clamp(t){return y(t,this.#t,this.#e)}floating(){return!0}},re=class{#t;#e;#r;constructor(t,e){this.#t=y(Math.round(t),_.MIN_VALUE,_.MAX_VALUE),this.#e=y(Math.round(e),_.MIN_VALUE,_.MAX_VALUE),this.#r=this.#e-this.#t}x(t){return(this.clamp(t)-this.#t)/this.#r}y(t){return this.#t+Math.round(y(t,0,1)*this.#r)}clamp(t){return y(Math.round(t),this.#t,this.#e)}floating(){return!1}},se=class{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=e,this.#r=Math.log(e/t)}x(t){return Math.log(y(t,this.#t,this.#e)/this.#t)/this.#r}y(t){return this.#t*Math.exp(y(t,0,1)*this.#r)}clamp(t){return Math.min(this.#e,Math.max(this.#t,t))}floating(){return!0}},ne=class{#t;constructor(t){this.#t=t}x(t){let e=this.#t.findIndex(r=>r===t);return e===-1?u(`Could not find index for ${t}`):e/(this.#t.length-1)}y(t){let e=Math.round(y(t,0,1)*(this.#t.length-1));return e>-1?w(this.#t.at(e),`Could not find value for ${t}`):u(`Index ${e} is out of box.`)}clamp(t){return t}floating(){return!1}},ie=class{#t;#e;#r;#s;#n;constructor(t,e,r){this.#t=t,this.#e=r;let n=t*t,i=r*r,o=e*e,a=t+r-2*e,c=r-e;this.#r=((2*r-e)*t-e*r)/a,this.#s=(c*n+(o-i)*t+e*i-o*r)/(n+(2*r-4*e)*t+i-4*e*r+4*o),this.#n=-c/a}y(t){return t<=0?Number.NEGATIVE_INFINITY:t>=1?this.#e:this.#r-this.#s/(t+this.#n)}x(t){return this.#t>=t?0:this.#e<=t?1:-this.#s/(t-this.#r)-this.#n}clamp(t){return Math.min(this.#e,t)}floating(){return!0}},oe;(function(s){s.linear=(i,o)=>new ee(i,o),s.linearInteger=(i,o)=>new re(i,o),s.exponential=(i,o)=>new se(i,o),s.values=i=>new ne(i),s.decibel=(i,o,a)=>new ie(i,o,a);let t=new class{x(i){return i?1:0}y(i){return i>=.5}clamp(i){return i}floating(){return!1}},e=s.linear(0,1),r=s.linear(-1,1);s.bool=t;let n=s.decibel(-72,-12,0);s.unipolar=()=>e,s.bipolar=()=>r,s.DefaultDecibel=n})(oe||(oe={}));var ae;(function(s){s.percent=({bipolar:i,fractionDigits:o}={})=>new t("%",o,!1,i),s.numeric=({unit:i,fractionDigits:o,unitPrefix:a,bipolar:c}={})=>new t(i,o,a,c),s.indices=(i,o)=>new class{x(a){return{unit:i,value:o[a]}}y(a){let c=o.indexOf(a);return c===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:c}}},s.values=(i,o,a)=>new class{x(c){return{unit:i,value:a.at(o.indexOf(c))??"N/A"}}y(c){let h=a.indexOf(c);return h===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:o[h]}}},s.bool=new class{y(i){switch(i.trim()){case"on":case"yes":case"true":return{type:"explicit",value:!0};default:return{type:"explicit",value:!1}}}x(i){return{value:String(i),unit:""}}};class t{#t;#e;#r;#s;constructor(o,a,c,h){this.#t=o??"",this.#e=a??0,this.#r=c??!1,this.#s=h??!1}y(o){let a=o.trim(),c=parseFloat(a);if(isNaN(c))return{type:"unknown",value:a};if(this.#t==="%")return{type:"explicit",value:c/100};if(a.endsWith("%"))return{type:"unitValue",value:this.#s?y(c/200+.5,0,1):y(c/100,0,1)};{a.endsWith(this.#t)&&this.#t.length>0&&(a=a.slice(0,-this.#t.length));let f=/(\d+)(\D+)/.exec(a)?.at(2)?.at(0);if(p(f)){let E=e.indexOf(f);if(E>-1)return{type:"explicit",value:c*Math.pow(10,(E-4)*3)}}return{type:"explicit",value:c}}}x(o){if(Number.isNaN(o))return{value:"\u{1F4A3}",unit:this.#t};if(Number.isFinite(o)){if(this.#t==="%")return this.#s?{value:(o*200-100).toFixed(this.#e),unit:this.#t}:{value:(o*100).toFixed(this.#e),unit:this.#t};if(this.#r){let{value:a,prefix:c}=n(o);return{value:a.toFixed(this.#e),unit:`${c}${this.#t}`}}else return{value:o.toFixed(this.#e),unit:this.#t}}else return{value:o===Number.POSITIVE_INFINITY?"\u221E":"-\u221E",unit:this.#t}}}let e=Object.freeze(["p","n","\u03BC","m","","k","M","G","T"]),r=i=>Math.log(i)/Math.log(9.999999999999998),n=i=>{let o=Math.floor(r(i)/3),a=e[o+4];return p(a)?{value:i*Math.pow(10,o*-3),prefix:a}:{value:i,prefix:""}};s.decible=s.numeric({unit:"db",fractionDigits:1}),s.panning=s.percent({unit:"%",fractionDigits:0})})(ae||(ae={}));var Ce;(function(s){s.alwaysTrue=()=>!0,s.alwaysFalse=()=>!1,s.definedPredicate=t=>t!=null})(Ce||(Ce={}));var De;(function(s){s.Empty=Object.freeze(t=>{}),s.split=(t,e)=>{let r=new Float32Array(e);return g.create(n=>i=>{r[n]=i,t(r.reduce((o,a)=>o+a,0)/e)},e)}})(De||(De={}));var ke;(function(s){s.create=(t=252854082)=>new ce(t),s.monotoneAscending=(t,e=128,r=s.create())=>{let n=t.length;if(n<2)return u("Array must have at least 2 elements");let i=0;for(let a=1;a<n;a++){let c=Math.floor(r.uniform()*(1+e))+1;t[a]=c,i+=c}let o=0;t[0]=0;for(let a=1;a<n;a++)o+=t[a],t[a]=o/i;return t}})(ke||(ke={}));var ce=class{#t=0;constructor(t){this.setSeed(t)}setSeed(t){this.#t=t&4294967295}nextDouble(t,e){return t+this.uniform()*(e-t)}nextInt(t,e){return t+Math.floor(this.uniform()*(e-t))}nextElement(t){return t[Math.floor(this.uniform()*t.length)]}nextBoolean(){return this.uniform()<.5}uniform(){let t=this.#t+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}};var _e;(function(s){class t{}s.createBuilder=r=>{let n=i=>{let o=i instanceof Array?[]:{};return Object.entries(i).forEach(([a,c])=>{c instanceof t?o[a]=c.initialValue():typeof c=="object"&&(o[a]=n(c))}),o};return()=>new e(r,Object.seal(n(r)))},s.bool=new class extends t{read(r){return r.readByte()===1}write(r,n){r.writeByte(n?1:0)}initialValue(){return!1}},s.int8=new class extends t{read(r){return r.readByte()}write(r,n){r.writeByte(n)}initialValue(){return 0}},s.int16=new class extends t{read(r){return r.readShort()}write(r,n){r.writeShort(n)}initialValue(){return 0}},s.int32=new class extends t{read(r){return r.readInt()}write(r,n){r.writeInt(n)}initialValue(){return 0}},s.float=new class extends t{read(r){return r.readFloat()}write(r,n){r.writeFloat(n)}initialValue(){return 0}},s.double=new class extends t{read(r){return r.readDouble()}write(r,n){r.writeDouble(n)}initialValue(){return 0}},s.int64=new class extends t{read(r){return r.readLong()}write(r,n){r.writeLong(n)}initialValue(){return 0n}},s.floats=r=>new class extends t{read(n,i){for(let o=0;o<i.length;o++)i[o]=n.readFloat();return i}write(n,i){for(let o=0;o<i.length;o++)n.writeFloat(i[o])}initialValue(){return new Float32Array(r)}},s.doubles=r=>new class extends t{read(n,i){for(let o=0;o<i.length;o++)i[o]=n.readDouble();return i}write(n,i){for(let o=0;o<i.length;o++)n.writeDouble(i[o])}initialValue(){return new Float64Array(r)}};class e{#t;#e;#r;constructor(n,i){this.#t=n,this.#e=i,this.#r=this.#s()}get object(){return this.#e}get bytesTotal(){return this.#r}read(n){let i=(o,a)=>{Object.entries(o).forEach(([c,h])=>{let l=a;h instanceof t?l[c]=h.read(n,l[c]):typeof h=="object"&&i(h,l[c])})};i(this.#t,this.#e)}write(n){let i=(o,a)=>{Object.entries(o).forEach(([c,h])=>{let l=a;h instanceof t?h.write(n,l[c]):typeof h=="object"&&i(h,l[c])})};i(this.#t,this.#e)}#s(){let n=new nt;return this.write(n),n.count}}})(_e||(_e={}));var ht=class{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=e,this.#r=[]}add(t,e=!1){let r=this.#t(t),n=A.leftMostMapped(this.#r,r,this.#e,this.#t),i=this.#r[n];return p(i)&&this.#e(this.#t(i),r)===0?e?(this.#r.splice(n,1,t),!0):!1:(this.#r.splice(n,0,t),!0)}getOrCreate(t,e){let r=A.leftMostMapped(this.#r,t,this.#e,this.#t),n=this.#r[r];if(p(n)&&this.#e(this.#t(n),t)===0)return n;let i=e(t);return this.#r.splice(r,0,i),i}addMany(t){for(let e of t)this.#r.push(e);try{return this.#r.sort((e,r)=>{let n=this.#e(this.#t(e),this.#t(r));if(n===0)throw"cancel";return n}),!0}catch(e){if(e==="cancel"){let r=new Map(this.entries());return this.#r.splice(0,this.#r.length,...r.values()),this.#r.sort((n,i)=>this.#e(this.#t(n),this.#t(i))),!1}return u(e)}}removeByValue(t){return this.removeByKey(this.#t(t))}removeByKey(t){let e=A.leftMostMapped(this.#r,t,this.#e,this.#t),r=this.#r[e];return p(r)&&this.#e(this.#t(r),t)===0?(this.#r.splice(e,1),r):u(`Could not remove ${t}`)}removeByKeyIfExist(t){let e=A.leftMostMapped(this.#r,t,this.#e,this.#t),r=this.#r[e];return p(r)&&this.#e(this.#t(r),t)===0?(this.#r.splice(e,1),r):null}removeRange(t,e){this.#r.splice(t,(e??this.#r.length)-t)}removeByPredicate(t){let e=0,r=this.#r.length;for(;--r>=0;)t(this.#r[r])&&(this.#r.splice(r,1),e++);return e}get(t){return w(this.#s(t),`Unknown key: ${t}`)}getOrThrow(t,e){let r=this.#s(t);if(p(r))return r;throw e()}opt(t){return d.wrap(this.#s(t))}getOrNull(t){return this.#s(t)??null}getByIndex(t){return this.#r[t]}hasKey(t){return p(this.#s(t))}hasValue(t){return p(this.#s(this.#t(t)))}size(){return this.#r.length}isEmpty(){return this.#r.length===0}forEach(t){this.values().forEach(t)}values(){return this.#r}entries(){return this.#r.map(t=>[this.#t(t),t])}clear(){g.clear(this.#r)}[Symbol.iterator](){return this.#r.values()}#s(t){let e=A.leftMostMapped(this.#r,t,this.#e,this.#t),r=this.#r[e];return p(r)&&this.#e(this.#t(r),t)===0?r:void 0}};var Ue;(function(s){s.hyphenToCamelCase=t=>t.replace(/-([a-z])/g,e=>e[1].toUpperCase()),s.fallback=(t,e)=>p(t)&&t.length>0?t:e,s.endsWithDigit=t=>/\d$/.test(t),s.nonEmpty=(t,e)=>p(t)&&t.trim().length>0?t:e,s.toArrayBuffer=t=>{let e=new ArrayBuffer(t.length),r=new Uint8Array(e);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return e},s.getUniqueName=(t,e)=>{let r=new Set(t),n=e,i=1;if(r.has(e)||r.has(`${e} 1`))i=2;else return e;for(;r.has(n=`${e} ${i++}`););return n}})(Ue||(Ue={}));var vn=(()=>{let s=d.None;return{info:t=>s.match({none:()=>Promise.resolve(),some:e=>e.info(t)}),approve:t=>s.match({none:()=>Promise.resolve(!0),some:e=>e.approve(t)}),progress:t=>s.match({none:()=>S.Empty,some:e=>e.progress(t)}),install:t=>{m(s.isEmpty(),"RuntimeNotification already installed"),s=d.wrap(t)}}})();var J=class s{static POSITIVE_INFINITY=new s(Number.POSITIVE_INFINITY);static millis=t=>new s(t);static seconds=t=>new s(t*s.#t);static minutes=t=>new s(t*s.#e);static hours=t=>new s(t*s.#r);static days=t=>new s(t*s.#s);static#t=1e3;static#e=6e4;static#r=36e5;static#s=864e5;#n;constructor(t){this.#n=t}millis(){return this.#n}absSeconds(){return Math.abs(this.#n)/s.#t}absMinutes(){return Math.abs(this.#n)/s.#e}absHours(){return Math.abs(this.#n)/s.#r}absDays(){return Math.abs(this.#n)/s.#s}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.#n===0}isPast(){return this.#n<0}isFuture(){return this.#n>0}toUnitString(){let t,e,r=Math.floor(Math.abs(this.#n)/1e3),n=Math.floor(r/60),i=Math.floor(n/60),o=Math.floor(i/24);return r<60?(t=r,e="second"):n<60?(t=n,e="minute"):i<24?(t=i,e="hour"):(t=o,e="day"),new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"long"}).format(t*Math.sign(this.#n),e)}toString(){if(isNaN(this.#n))return"NaN";if(!isFinite(this.#n))return"\u221E";let{d:t,h:e,m:r,s:n}=this.split();return t>0?[s.#i("d",t),s.#i("h",e),s.#i("m",r),s.#i("s",n)].join(", "):e>0?[s.#i("h",e),s.#i("m",r),s.#i("s",n)].join(", "):r>0?[s.#i("m",r),s.#i("s",n)].join(", "):n>0?s.#i("s",n):"now"}static#i=(t,e)=>{switch(t){case"d":return`${e} ${e<2?"day":"days"}`;case"h":return`${e} ${e<2?"hour":"hours"}`;case"m":return`${e} ${e<2?"minute":"minutes"}`;case"s":return`${e} ${e<2?"second":"seconds"}`;default:return k(t)}}};var Ke;(function(s){let t;(function(e){e[e.READING=0]="READING",e[e.READ=1]="READ",e[e.WRITING=2]="WRITING",e[e.WRITTEN=3]="WRITTEN"})(t||(t={})),s.writer=(e,r,n)=>{if(e.bytesTotal+1>r.byteLength)return u("Insufficient memory allocated.");let i=new Uint8Array(r),o=v.use(r,1);return Atomics.store(i,0,t.READ),{tryWrite:()=>Atomics.compareExchange(i,0,t.READ,t.WRITING)===t.WRITING?(n(e.object),o.position=0,e.write(o),Atomics.store(i,0,t.WRITTEN),!0):!1}},s.reader=(e,r)=>{let n=new SharedArrayBuffer(e.bytesTotal+1),i=new Uint8Array(n),o=new F(n,1);return{buffer:n,tryRead:()=>Atomics.compareExchange(i,0,t.WRITTEN,t.READING)===t.READING?(o.position=0,e.read(o),r(e.object),Atomics.store(i,0,t.READ),!0):!1}}})(Ke||(Ke={}));var b;(function(s){s.length=16,s.generate=()=>e(crypto.getRandomValues(new Uint8Array(s.length))),s.sha256=async r=>{let n=typeof process<"u"&&process.env?.VITEST==="true";return crypto.subtle.digest("SHA-256",n?new Uint8Array(r.slice(0)):r).then(i=>e(new Uint8Array(i.slice(0,s.length))))},s.validate=r=>s.parse(s.toString(r)),s.fromDataInput=r=>{let n=new Uint8Array(s.length);return r.readBytes(new Int8Array(n.buffer)),n},s.toDataOutput=(r,n)=>r.writeBytes(new Int8Array(n.buffer)),s.toString=r=>{let n=g.create(i=>(i+256).toString(16).substring(1),256);return n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},s.parse=r=>{let n=r.replace(/-/g,"").toLowerCase();if(n.length!==32)return u("Invalid UUID format");let i=new Uint8Array(s.length);for(let o=0,a=0;o<32;o+=2,a++)i[a]=parseInt(n.slice(o,o+2),16);return i},s.Comparator=(r,n)=>{if(r.length!==s.length||n.length!==s.length)return u("Unexpected array length for uuid(v4)");for(let i=0;i<s.length;i++){let o=r[i]-n[i];if(o!==0)return o}return 0},s.equals=(r,n)=>s.Comparator(r,n)===0,s.newSet=r=>new ht(r,s.Comparator),s.Lowest=s.parse("00000000-0000-4000-8000-000000000000"),s.Highest=s.parse("FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"),s.fromInt=r=>{let n=new Uint8Array(s.Lowest),i=new Uint8Array(new Uint32Array([r]).buffer);for(let o=0;o<4;o++)n[o]=i[o];return n};class t{#t;constructor(){this.#t=new Map}getOrCreate(n){return yt.createIfAbsent(this.#t,n,()=>s.generate())}}s.SimpleIdDecoder=t;let e=r=>(m(r.length===s.length,"UUID must be 16 bytes long"),r[6]=r[6]&15|64,r[8]=r[8]&63|128,r)})(b||(b={}));var je;(function(s){s.create=i=>p(i)?p(i?.snap)?s.snap(i?.trackLength,i?.snap?.snapLength,Array.isArray(i?.snap?.threshold)?i?.snap.threshold:[i?.snap?.threshold]):s.identity(i?.trackLength):s.identity(),s.snap=(i=t,o=e,a)=>new n(i,o/i,a),s.identity=(i=t)=>new r(i);let t=128,e=24;class r{length;#t=NaN;#e=NaN;#r=1;constructor(o){this.length=o}begin(o){this.#e=this.#t=o}moveBy(o){m(!isNaN(this.#e),()=>"value has never been set"),this.#t+=o/this.length*this.#r,this.#e=y(this.#t,0,1)}ratio(o){this.#r=o}value(){return m(!isNaN(this.#e),()=>"value has never been set"),this.#e}disable(){}enable(){}}class n{#t;#e;#r;#s;#n=NaN;#i=NaN;#a=1;#o=!0;constructor(o,a,c){m(a>0,()=>`margin(${a}) must be greater then 0`),m(g.isSorted(c),()=>"thresholds are not sorted"),m(a<o,()=>`margin(${a}) must be lower then length(${o})`),this.#t=o,this.#e=a,this.#r=c,this.#s=c.map((h,l)=>h+l*this.#e)}begin(o){this.#o&&(this.#n=this.valueToX(o)),this.#i=o}moveBy(o){m(!isNaN(this.#i),()=>"value has never been set"),this.#n+=o/this.#t*this.#a,this.#i=this.#o?this.xToValue(this.#n):y(this.#n,0,1)}ratio(o){this.#a=o}value(){return m(!isNaN(this.#i),()=>"value has never been set"),this.#i}disable(){this.#o&&(this.#o=!1,this.#n=this.xToValue(this.#n))}enable(){this.#o||(this.#o=!0,this.#n=this.valueToX(this.#n))}valueToX(o){let a=A.rightMost(this.#r,o,Qt);if(a<0)return o;{let c=this.#s[a],h=this.#r[a];return o===h?c+this.#e/2:c+this.#e+(o-h)}}xToValue(o){let a=y(o,0,1+this.#e*this.#r.length),c=A.rightMost(this.#s,a,Qt);if(c<0)return a;{let h=this.#s[c],l=this.#r[c];return a>h+this.#e?a-(h+this.#e)+l:l}}get margin(){return this.#e}}})(je||(je={}));var ze;(function(s){class t extends Error{}s.Warning=t,s.warn=e=>{throw new t(e)},s.AbortError=typeof DOMException>"u"?NaN:Object.freeze(new DOMException("AbortError")),s.isAbort=e=>e===s.AbortError||s.isDOMException(e)&&e.name==="AbortError",s.CatchAbort=e=>e===s.AbortError?void 0:u(e),s.isOverconstrained=e=>Wt(e)&&"constraint"in e,s.isDOMException=e=>Wt(e)&&Yt(e,"name","string")&&Yt(e,"message","string")})(ze||(ze={}));var Tt=Symbol.for("@openDAW/lib-std");globalThis[Tt]?console.debug(`%c${Tt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Tt]=!0,console.debug(`%c${Tt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var P;(function(s){s.sender=(r,n)=>n(new t(r)),s.executor=(r,n)=>new e(r,n);class t{#t;#e=new Map;#r;#s=0;constructor(n){this.#t=n,this.#r=n.subscribe(this.#n)}terminate(){this.#r.terminate()}dispatchAndForget=(n,...i)=>this.#t.send({type:"send",returnId:!1,func:n.name,args:Array.from(B.map(i,o=>({value:o})))});dispatchAndReturn=(n,...i)=>new Promise((o,a)=>{let c=B.reduce(i,(h,l,f)=>(typeof l=="function"&&h.push([f,l]),h),[]);this.#e.set(this.#s,{executorTuple:{resolve:o,reject:a},callbacks:new Map(c)}),this.#t.send({type:"send",returnId:this.#s,func:n.name,args:Array.from(B.map(i,(h,l)=>typeof h=="function"?{callback:l}:{value:h}))}),this.#s++});#n=n=>{let i=this.#e.get(n.returnId);p(i)?n.type==="resolve"?(i.executorTuple.resolve(n.resolve),this.#e.delete(n.returnId)):n.type==="reject"?(i.executorTuple.reject(n.reject),this.#e.delete(n.returnId)):n.type==="callback"&&i.callbacks?.get(n.funcAt).apply(this,n.args):u(`Promise has already been resolved. ${JSON.stringify(n)}`)}}class e{#t;#e;#r;constructor(n,i){this.#t=n,this.#e=i,this.#r=n.subscribe(this.#s)}terminate(){this.#r.terminate()}#s=n=>{m(n.type==="send",()=>"Message type must be 'send'");let i=Object.getPrototypeOf(this.#e)===Object.getPrototypeOf({})?this.#e:Object.getPrototypeOf(this.#e),o=w(i[n.func],`${n.func.toString()} does not exists on ${this.#e}`),a=n.returnId;if(a===!1)o.apply(this.#e,n.args.map(c=>"value"in c?c.value:u(`${n.func.toString()} has no promise.`)));else try{o.apply(this.#e,n.args.map(h=>"callback"in h?(...l)=>this.#a(a,h.callback,l):h.value)).then(h=>this.#n(a,h),h=>this.#i(a,h))}catch(c){this.#i(a,c)}};#n=(n,i)=>this.#t.send({type:"resolve",returnId:n,resolve:i});#i=(n,i)=>this.#t.send({type:"reject",returnId:n,reject:i});#a=(n,i,o)=>this.#t.send({type:"callback",returnId:n,funcAt:i,args:o})}s.Executor=e})(P||(P={}));var qe;(function(s){s.ProgressArrayBuffer=t=>async e=>{if(!e.headers.has("Content-Length"))return console.debug("No Content-Length"),e.arrayBuffer();let r=parseInt(e.headers.get("Content-Length"));if(console.debug(`Content-Length: ${r}b`),isNaN(r)||r<4096)return e.arrayBuffer();t(0);let n=v.create(r),i=w(e.body,"response.body is empty").getReader();for(;;){let{done:o,value:a}=await i.read();if(o)break;a.forEach(c=>n.writeByte(c)),t(n.position/r)}return t(1),n.toArrayBuffer()}})(qe||(qe={}));var We;(function(s){s.debounce=(()=>{let t;return(e,r=1e3)=>{clearTimeout(t),t=setTimeout(e,r)}})(),s.scheduleInterval=(t,e,...r)=>{let n=setInterval(t,e,...r);return{terminate:()=>clearInterval(n)}},s.scheduleTimeout=(t,e,...r)=>{let n=setTimeout(t,e,...r);return{terminate:()=>clearTimeout(n)}}})(We||(We={}));var Ye={for:s=>new he(s)},he=class{#t;#e=new U;constructor(t){if(this.#t=t,p(t.onmessage)||p(t.onmessageerror))throw console.error(t),new Error(`${t} is already wrapped.`);t.onmessage=e=>this.#e.notify(e.data),t.onmessageerror=e=>{throw new Error(e.type)}}send(t){this.#t.postMessage(t)}channel(t){return new le(this,t)}subscribe(t){return this.#e.subscribe(t)}terminate(){this.#e.terminate(),this.#t.onmessage=null,this.#t.onmessageerror=null}},le=class s{#t;#e;#r=new U;#s;constructor(t,e){this.#t=t,this.#e=e,this.#s=t.subscribe(r=>{"message"in r&&"channel"in r&&r.channel===e&&this.#r.notify(r.message)})}send(t){this.#t.send({channel:this.#e,message:t})}channel(t){return new s(this,t)}subscribe(t){return this.#r.subscribe(t)}terminate(){this.#s.terminate(),this.#r.terminate()}};var ue=class{maxRetry;timeSpan;#t=0;constructor(t,e){this.maxRetry=t,this.timeSpan=e}retry(t,e){return++this.#t===this.maxRetry?!1:(console.debug(`${t} > will retry in ${this.timeSpan.toString()}`),setTimeout(e,this.timeSpan.millis()),!0)}},C;(function(s){class t{value;status="resolved";constructor(o){this.value=o}error=Ht("Cannot access error when promise is resolved")}s.ResolveResult=t;class e{error;status="rejected";constructor(o){this.error=o}value=Ht("Cannot access value when promise is rejected")}s.RejectedResult=e,s.makeAbortable=async(i,o)=>{let a=!0;return i.own(S.create(()=>a=!1)),new Promise((c,h)=>o.then(l=>{a&&c(l)},l=>{a&&h(l)}))},s.tryCatch=i=>i.then(o=>new t(o),o=>new e(o)),s.retry=(i,o=new ue(3,J.seconds(3)))=>i().catch(a=>new Promise((c,h)=>{let l=f=>{o.retry(f,()=>i().then(E=>c(E),l))||h(f)};l(a)})),s.fail=(i,o)=>{let a=()=>new Promise((c,h)=>setTimeout(()=>h("fails first"),i.millis()));return()=>{let c=a();return a=o,c}},s.timeout=(i,o,a)=>new Promise((c,h)=>{let l=!0,f=setTimeout(()=>{l=!1,h(new Error(a??"timeout"))},o.millis());i.then(E=>{l&&c(E)},E=>{l&&h(E)}).finally(()=>clearTimeout(f))}),s.sequential=i=>{let o=Promise.resolve(null);return a=>o=o.then(()=>i(a))},s.memoizeAsync=i=>{let o=null;return()=>(be(o)&&(o=i(),o.catch(a=>{throw o=null,a})),o)};class r{max;#t;#e=0;constructor(o=1){this.max=o,this.#t=[]}async add(o){if(this.#e<this.max)return this.#e++,o().finally(()=>this.#r());{let a=Promise.withResolvers();return this.#t.push([o,a]),a.promise.finally(()=>this.#r())}}#r(){if(m(this.#e>0,"Internal Error in Promises.Limit"),--this.#e<this.max&&this.#t.length>0){let[o,{resolve:a,reject:c}]=this.#t.shift();this.#e++,o().then(a,c)}}}s.Limit=r;class n{#t;#e;#r;#s=d.None;constructor(o,a,c){this.#t=o,this.#e=a,this.#r=c}update(o){this.#s=d.wrap(o),o.then(a=>{this.#s.contains(o)&&this.#t(a)}).catch(a=>{this.#s.contains(o)&&this.#e(a)}).finally(()=>{this.#s.contains(o)&&(this.terminate(),N(this.#r))})}terminate(){this.#s=d.None}}s.Latest=n})(C||(C={}));var He;(function(s){let t=new C.Limit(4);s.limitFetch=(e,r)=>t.add(()=>fetch(e,r))})(He||(He={}));var Ge=(s="debug")=>{let t=performance.now();return{lab:e=>console[s].call(console,`${e} in ${(performance.now()-t).toFixed(1)}ms`)}};var Xe;(function(s){s.startEstimator=()=>{let t=performance.now();return e=>{if(e===0)return J.POSITIVE_INFINITY;let r=performance.now()-t;return J.millis(r/e-r)}}})(Xe||(Xe={}));var Qe;(function(s){s.frame=()=>new Promise(t=>requestAnimationFrame(()=>t())),s.frames=t=>new Promise(e=>{let r=t,n=()=>{--r<=0?e():requestAnimationFrame(n)};requestAnimationFrame(n)}),s.timeSpan=(t,...e)=>new Promise(r=>setTimeout(r,t.millis(),...e)),s.event=(t,e)=>new Promise(r=>t.addEventListener(e,r,{once:!0})),s.observable=t=>new Promise(e=>{let r=t.subscribe(()=>{r.terminate(),e()})}),s.complete=t=>new Promise((e,r)=>{let n=setInterval(()=>{let{status:i,value:o,error:a}=G(()=>t.next());if(i==="success"){let{done:c,value:h}=o;c&&(clearInterval(n),e(h))}else clearInterval(n),r(a)},0)})})(Qe||(Qe={}));var Mt=Symbol.for("@openDAW/lib-runtime");globalThis[Mt]?console.debug(`%c${Mt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Mt]=!0,console.debug(`%c${Mt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var x=class s{static newSet(t){return new ht(t,s.Comparator)}static compose=(t,...e)=>{let r=e.length===0?this.#t:new Int16Array(e);return m(r.every((n,i)=>n===e[i]),`fieldKeys (${r.join(",")}) only allows i16`),new s(t,r)};static decode(t){let e=t.split("/");return m(e.length>0,"Unable to parse Address"),s.compose(b.parse(e[0]),...e.slice(1).map(r=>parseInt(r)))}static reconstruct(t){return this.compose(t[0],...t[1])}static boxRange(t,e,r){let n=t.values(),i=A.leftMostMapped(n,e,b.Comparator,r),o=n.length;if(i<0||i>=o)return null;for(let a=i;a<o;a++)if(b.Comparator(r(n[a]),e)!==0)return i<a?[i,a]:null;return[i,o]}static Comparator=(t,e)=>{let r=b.Comparator(t.#e,e.#e);if(r!==0)return r;let n=Math.min(t.#r.length,e.#r.length);for(let i=0;i<n;i++){let o=t.#r[i]-e.#r[i];if(o!==0)return o}return t.#r.length-e.#r.length};static MinimalComparator=(t,e)=>{let r=b.Comparator(t.#e,e.#e);if(r!==0)return r;let n=Math.min(t.#r.length,e.#r.length);for(let i=0;i<n;i++){let o=t.#r[i]-e.#r[i];if(o!==0)return o}return 0};static LengthComparator=(t,e)=>{let r=b.Comparator(t.#e,e.#e);return r!==0?r:e.#r.length-t.#r.length};static#t=new Int16Array(0);#e;#r;constructor(t,e){this.#e=t,this.#r=e}get uuid(){return this.#e}get fieldKeys(){return this.#r}isBox(){return this.#r.length===0}isContent(){return!this.isBox()}equals(t){return s.Comparator(this,t)===0}compareTo(t){return s.Comparator(this,t)}append(t){return new s(this.#e,new Int16Array([...this.#r,t]))}startsWith(t){return b.Comparator(t.#e,this.#e)===0&&t.#r.length<=this.#r.length&&t.#r.every((e,r)=>this.#r[r]===e)}write(t){t.writeBytes(new Int8Array(this.#e.buffer)),t.writeByte(this.#r.length),this.#r.forEach(e=>t.writeShort(e))}moveTo(t){return new s(t,this.#r)}decompose(){return[this.#e,this.#r]}toJSON(){return{uuid:Array.from(this.#e.values()),fields:Array.from(this.#r.values())}}toArrayBuffer(){let t=new Uint8Array(b.length+this.#r.length);return t.set(this.#e,0),t.set(this.#r,b.length),t.buffer}toString(){return[b.toString(this.#e),...this.#r].join("/")}static read(t){let e=b.fromDataInput(t),r=t.readByte();return s.compose(e,...g.create(()=>t.readShort(),r))}},Z;(function(s){s.AddressReader=t=>t.address,s.Comparator=({address:t},{address:e})=>x.Comparator(t,e),s.equals=(t,e)=>{let[r,n]=A.rangeMapped(e,t,x.Comparator,s.AddressReader);return e.slice(r,n+1)},s.startsWith=(t,e)=>{let[r,n]=A.rangeMapped(e,t,x.MinimalComparator,s.AddressReader);return e.slice(r,n+1).filter(i=>i.address.startsWith(t))},s.endsWith=(t,e)=>{let r=A.leftMostMapped(e,t,x.LengthComparator,s.AddressReader),n=A.rightMostMapped(e,t,x.MinimalComparator,s.AddressReader);return e.slice(r,n+1).filter(i=>t.startsWith(i.address))}})(Z||(Z={}));var D=class s{static validate(t,e){if(t.address.equals(e.address))return d.wrap(`PointerField cannot point to itself: ${t}`);if(!e.pointerRules.accepts.some(r=>r===t.pointerType)){let r=e.pointerRules.accepts.join(", ");return d.wrap(`${String(t.pointerType)} does not satisfy any of the allowed types (${r}).`)}return d.None}#t;#e;#r;#s=d.None;constructor(t){this.#t=t,this.#e=new ct,this.#r=new ct}subscribeImmediate(t,...e){return this.#n(this.#e,t,e)}subscribeTransactual(t,...e){return this.#n(this.#r,t,e)}catchupAndSubscribeTransactual(t,...e){let r=x.newSet(n=>n.address);return r.addMany(this.filter(...e)),r.forEach(n=>t.onAdd(n)),this.subscribeTransactual({onAdd:n=>{r.add(n)&&t.onAdd(n)},onRemove:n=>{r.removeByKey(n.address),t.onRemove(n)}},...e)}filter(...t){return t.length===0?this.incoming():B.filter(this.incoming().values(),e=>t.some(r=>r===e.pointerType))}size(){return this.incoming().length}isEmpty(){return this.size()===0}nonEmpty(){return this.size()>0}contains(t){return this.incoming().some(e=>t.address.equals(e.address))}incoming(){return this.#t.graph.edges().incomingEdgesOf(this.#t)}onAdded(t){let e=s.validate(t,this.#t);if(e.nonEmpty())return u(e.unwrap());this.#s.isEmpty()?(this.#s=d.wrap([{type:"add",pointerField:t}]),this.#t.graph.subscribeEndTransaction(this.#i)):this.#s.unwrap().push({type:"add",pointerField:t}),this.#e.proxy.onAdd(t)}onRemoved(t){this.#s.isEmpty()?(this.#s=d.wrap([{type:"remove",pointerField:t}]),this.#t.graph.subscribeEndTransaction(this.#i)):this.#s.unwrap().push({type:"remove",pointerField:t}),this.#e.proxy.onRemove(t)}toString(){return`{Pointers ${this.#t.address}, pointers: ${this.incoming().values().map(t=>t.toString())}}`}#n(t,e,r){return t.subscribe({onAdd:n=>{(r.length===0||r.some(i=>i===n.pointerType))&&e.onAdd(n)},onRemove:n=>{(r.length===0||r.some(i=>i===n.pointerType))&&e.onRemove(n)}})}#i=()=>{if(this.#t.isAttached()){let t=this.#s.unwrap("Callback without ChangeLog");t.forEach(({type:e,pointerField:r})=>{e==="add"?this.#r.proxy.onAdd(r):e==="remove"?this.#r.proxy.onRemove(r):u(`Unknown type: ${e}`)}),t.length=0}this.#s=d.None}};var fe=function(s,t,e,r){var n=arguments.length,i=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(t,e,i):o(t,e))||i);return n>3&&i&&Object.defineProperty(t,e,i),i},lt=function(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)},O=class s{static hook(t){return new s(t)}#t;#e;#r;#s;constructor({parent:t,fieldKey:e,fieldName:r,pointerRules:n}){this.#t=t,this.#e=e,this.#r=r,this.#s=n,n.mandatory&&this.graph.edges().watchVertex(this)}accept(t){return N(t.visitField,this)}get box(){return this.#t.box}get graph(){return this.#t.graph}get parent(){return this.#t}get fieldKey(){return this.#e}get fieldName(){return this.#r}get pointerRules(){return this.#s}get pointerHub(){return new D(this)}get address(){return this.#t.address.append(this.#e)}get debugPath(){return`${this.box.name}:${this.box.mapFields(t=>t.fieldName,...this.address.fieldKeys).join("/")}`}isBox(){return!1}isField(){return!0}isAttached(){return this.graph.findBox(this.address.uuid).nonEmpty()}fields(){return B.empty()}getField(t){return u()}optField(t){return d.None}read(t){}write(t){}disconnect(){if(this.pointerHub.isEmpty())return;let t=this.pointerHub.incoming();t.forEach(e=>{e.defer(),(e.mandatory||this.pointerRules.mandatory&&t.length===1)&&e.box.delete()})}toString(){return`{${this.box.constructor.name}:${this.constructor.name} (${this.fieldName}) ${this.address.toString()}`}};fe([it,lt("design:type",D),lt("design:paramtypes",[])],O.prototype,"pointerHub",null);fe([it,lt("design:type",x),lt("design:paramtypes",[])],O.prototype,"address",null);fe([it,lt("design:type",String),lt("design:paramtypes",[])],O.prototype,"debugPath",null);var gr=Object.freeze({mandatory:!1,accepts:[]});var ut;(function(s){s.writeFields=(e,r)=>{let n=Object.entries(r);e.writeInt(1179403347),e.writeShort(n.length),n.forEach(([i,o])=>{let a=v.create();o.write(a);let c=new Int8Array(a.toArrayBuffer());e.writeShort(Number(i)),e.writeInt(c.length),e.writeBytes(c)})},s.readFields=(e,r)=>{m(e.readInt()===1179403347,"Serializer header is corrupt");let n=e.readShort();for(let i=0;i<n;i++){let o=e.readShort();if(It(r[o]))continue;let a=e.readInt(),c=new Int8Array(a);e.readBytes(c);let{status:h,error:l}=G(()=>r[o]?.read(new F(c.buffer)));h==="failure"&&console.warn(l)}}})(ut||(ut={}));var yr=function(s,t,e,r){var n=arguments.length,i=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,r);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(i=(n<3?o(i):n>3?o(t,e,i):o(t,e))||i);return n>3&&i&&Object.defineProperty(t,e,i),i},Je=function(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)},de=class s{static DEBUG_DELETION=!1;static Index=0;#t;#e;#r;#s;#n;#i=s.Index++;constructor({uuid:t,graph:e,name:r,pointerRules:n}){this.#t=x.compose(t),this.#e=e,this.#r=r,this.#s=n,this.#n=this.initializeFields(),n.mandatory&&this.graph.edges().watchVertex(this)}fields(){return Object.values(this.#n)}getField(t){return w(this.#n[t])}optField(t){return d.wrap(this.#n[t])}subscribe(t,e){return this.graph.subscribeVertexUpdates(t,this.address,e)}get box(){return this}get name(){return this.#r}get graph(){return this.#e}get parent(){return this}get address(){return this.#t}get pointerRules(){return this.#s}get creationIndex(){return this.#i}get pointerHub(){return new D(this)}estimateMemory(){let t=new nt;return this.write(t),t.count}isBox(){return!0}asBox(t){return Ee(this,t)}isField(){return!1}isAttached(){return this.#e.findBox(this.address.uuid).nonEmpty()}read(t){ut.readFields(t,this.#n)}write(t){ut.writeFields(t,this.#n)}serialize(){let t=v.create();return t.writeInt(this.#i),t.writeString(this.name),t.writeBytes(new Int8Array(this.address.uuid.buffer)),this.write(t),t.toArrayBuffer()}toArrayBuffer(){let t=v.create();return this.write(t),t.toArrayBuffer()}incomingEdges(){return this.graph.edges().incomingEdgesOf(this)}outgoingEdges(){return this.graph.edges().outgoingEdgesOf(this)}mapFields(t,...e){if(e.length===0)return g.empty();let r=this.getField(e[0]),n=[t(r)];for(let i=1;i<e.length;i++)r=r.getField(e[i]),n.push(t(r));return n}searchVertex(t){if(t.length===0)return d.wrap(this);let e=this.optField(t[0]);if(e.isEmpty())return d.None;for(let r=1;r<t.length;r++)if(e=e.unwrap().optField(t[r]),e.isEmpty())return d.None;return e}delete(){let{boxes:t,pointers:e}=this.graph.dependenciesOf(this);s.DEBUG_DELETION&&(console.debug(`Delete ${this.toString()}`),console.debug(" unplugs",[...e].map(r=>r.toString()).join(`
2
2
  `)),console.debug(" unstages",[...t].map(r=>r.toString()).join(`
3
- `),this));for(let r of e)r.defer();for(let r of t)r.unstage();this.unstage()}unstage(){this.graph.unstageBox(this)}toString(){return`${this.constructor.name} ${this.address.toString()}`}};pr([it,He("design:type",D),He("design:paramtypes",[])],ue.prototype,"pointerHub",null);var $;(function(s){s[s.This=0]="This",s[s.Parent=1]="Parent",s[s.Children=2]="Children"})($||($={}));var fe;(function(s){s.create=()=>new de})(fe||(fe={}));var de=class{#t=new wt(Z.equals);#e=new wt(Z.startsWith);#r=new wt(Z.endsWith);#s=[];#n=0;#i=!1;subscribe(t,e,r){let n=new pe(e,t,this.#n++,r);if(this.#i){let i=new me(n,t);return this.#s.push(i),i}else return this.subscribeMonitor(n,t)}dispatch(t){this.#i=!0,[...this.#t.filter(t),...this.#e.filter(t),...this.#r.filter(t)].sort(({order:r},{order:n})=>r-n).forEach(r=>r.procedure(t)),this.#i=!1,this.#s.forEach(r=>r.subscribe(this)),this.#s.length=0}subscribeMonitor(t,e){switch(e){case $.This:return this.#t.subscribe(t);case $.Parent:return this.#e.subscribe(t);case $.Children:return this.#r.subscribe(t);default:return k(e)}}countStations(){return this.#t.count()+this.#e.count()+this.#r.count()}},pe=class{address;propagation;order;procedure;constructor(t,e,r,n){this.address=t,this.propagation=e,this.order=r,this.procedure=n}toString(){return`{ Monitor address: ${this.address}, propagation: ${$[this.propagation]}, order: ${this.order} }`}},wt=class{filterStrategy;#t=[];#e=!0;constructor(t){this.filterStrategy=t}subscribe(t){return this.#t.push(t),this.#e=this.#t.length<2,{terminate:()=>{let e=this.#t.length;for(;--e>=0;)this.#t[e]===t&&this.#t.splice(e,1)}}}stations(){return this.#e||(this.#t.sort(Z.Comparator),this.#e=!0),this.#t}filter(t){return this.filterStrategy(t.address,this.stations())}count(){return this.#t.length}},me=class{monitor;propagation;#t=new Q;#e=!1;constructor(t,e){this.monitor=t,this.propagation=e}subscribe(t){this.#e||(this.#t.terminate(),this.#t.own(t.subscribeMonitor(this.monitor,this.propagation)))}terminate(){this.#e=!0,this.#t.terminate()}};var I;(function(s){s.Boolean="boolean",s.Float32="float32",s.Int32="int32",s.String="string",s.Bytes="bytes"})(I||(I={}));var Ft={[I.Boolean]:{type:I.Boolean,encode:(s,t)=>s.writeBoolean(t),decode:s=>s.readBoolean()},[I.Float32]:{type:I.Float32,encode:(s,t)=>s.writeFloat(t),decode:s=>s.readFloat()},[I.Int32]:{type:I.Int32,encode:(s,t)=>s.writeInt(t),decode:s=>s.readInt()},[I.String]:{type:I.String,encode:(s,t)=>s.writeString(t),decode:s=>s.readString()},[I.Bytes]:{type:I.Bytes,encode:(s,t)=>{s.writeInt(t.length),s.writeBytes(t)},decode:s=>{let t=new Int8Array(s.readInt());return s.readBytes(t),t}}},Nt=class extends O{#t;#e;#r;constructor(t,e,r){super(t),this.#t=e,this.#e=this.clamp(r),this.#r=this.#e}accept(t){return N(t.visitPrimitiveField,this)}subscribe(t){return this.graph.subscribeVertexUpdates($.This,this.address,()=>t(this))}catchupAndSubscribe(t){return t(this),this.subscribe(t)}get type(){return this.#t}get initValue(){return this.#e}setInitValue(t){m(this.graph.constructingBox(),"Cannot change initial value at runtime"),this.setValue(this.#e=t)}getValue(){return this.#r}setValue(t){let e=this.#r,r=this.clamp(t);this.equals(r)||(this.#r=t,this.graph.onPrimitiveValueUpdate(this,e,r))}writeValue(t,e){this.serialization().encode(t,e)}readValue(t){return this.serialization().decode(t)}reset(){this.setValue(this.#e)}};var Bt=class s extends Nt{static create(t,e=0){return new s(t,e)}constructor(t,e){super(t,I.Int32,e)}serialization(){return Ft[I.Int32]}equals(t){return this.getValue()===t}clamp(t){return _.toInt(t)}read(t){this.setValue(t.readInt())}write(t){t.writeInt(this.getValue())}};var Ge=class s extends Nt{static create(t,e=this.#t){return new s(t,e)}static#t=Object.freeze(new Int8Array(0));constructor(t,e){super(t,I.Bytes,e)}serialization(){return Ft[I.Bytes]}equals(t){return this.getValue().length===t.length&&this.getValue().every((e,r)=>t[r]===e)}clamp(t){return t}read(t){let e=new Int8Array(t.readInt());t.readBytes(e),this.setValue(e)}write(t){let e=this.getValue();t.writeInt(e.length),t.writeBytes(e)}};var Xe;(function(s){s.decode=t=>{let e=t.readInt();return g.create(()=>{switch(t.readString()){case"new":{let n=b.fromDataInput(t),i=t.readString(),o=new Int8Array(t.readInt());return t.readBytes(o),new Ot(n,i,o.buffer)}case"pointer":{let n=x.read(t),i=t.readBoolean()?d.wrap(x.read(t)):d.None,o=t.readBoolean()?d.wrap(x.read(t)):d.None;return new Rt(n,i,o)}case"primitive":{let n=x.read(t),i=t.readString(),o=Ft[i],a=o.decode(t),c=o.decode(t);return new $t(n,o,a,c)}case"delete":{let n=b.fromDataInput(t),i=t.readString(),o=new Int8Array(t.readInt());return t.readBytes(o),new Vt(n,i,o.buffer)}}},e)}})(Xe||(Xe={}));var Ot=class{type="new";#t;#e;#r;constructor(t,e,r){this.#t=t,this.#e=e,this.#r=r}get uuid(){return this.#t}get name(){return this.#e}get settings(){return this.#r}forward(t){t.createBox(this.#e,this.#t,e=>e.read(new F(this.#r)))}inverse(t){t.findBox(this.#t).unwrap(()=>`Could not find ${this.#e}`).unstage()}write(t){t.writeString(this.type),b.toDataOutput(t,this.#t),t.writeString(this.#e),t.writeInt(this.#r.byteLength),t.writeBytes(new Int8Array(this.#r))}toString(){return`{NewUpdate uuid: ${b.toString(this.#t)}, attachment: ${this.settings.byteLength}b`}toDebugString(t){return this.toString()}},$t=class{type="primitive";#t;#e;#r;#s;constructor(t,e,r,n){this.#t=t,this.#e=e,this.#r=r,this.#s=n}get address(){return this.#t}get oldValue(){return this.#r}get newValue(){return this.#s}matches(t){return t.address.equals(this.address)}inverse(t){this.field(t).setValue(this.#r)}forward(t){this.field(t).setValue(this.#s)}field(t){return t.findVertex(this.#t).unwrap(()=>`Could not find PrimitiveField at ${this.#t}`)}write(t){t.writeString(this.type),this.#t.write(t),t.writeString(this.#e.type),this.#e.encode(t,this.#r),this.#e.encode(t,this.#s)}toString(){return`{PrimitiveUpdate oldValue: ${this.#r}, newValue: ${this.#s}`}},Rt=class{type="pointer";#t;#e;#r;constructor(t,e,r){this.#t=t,this.#e=e,this.#r=r}get address(){return this.#t}get oldAddress(){return this.#e}get newAddress(){return this.#r}matches(t){return t.address.equals(this.address)}inverse(t){this.field(t).targetAddress=this.#e}forward(t){this.field(t).targetAddress=this.#r}field(t){return t.findVertex(this.#t).unwrap(()=>`Could not find PointerField at ${this.#t}`)}write(t){t.writeString(this.type),this.#t.write(t),this.#e.match({none:()=>t.writeBoolean(!1),some:e=>{t.writeBoolean(!0),e.write(t)}}),this.#r.match({none:()=>t.writeBoolean(!1),some:e=>{t.writeBoolean(!0),e.write(t)}})}toString(){return`{PointerUpdate oldValue: ${this.#e.unwrapOrNull()}, newValue: ${this.#r.unwrapOrNull()}`}},Vt=class{type="delete";#t;#e;#r;constructor(t,e,r){this.#t=t,this.#e=e,this.#r=r}get uuid(){return this.#t}get name(){return this.#e}get settings(){return this.#r}forward(t){t.findBox(this.#t).unwrap(()=>`Could not find ${this.#e}`).unstage()}inverse(t){t.createBox(this.#e,this.#t,e=>e.read(new F(this.#r)))}write(t){t.writeString(this.type),b.toDataOutput(t,this.#t),t.writeString(this.#e),t.writeInt(this.#r.byteLength),t.writeBytes(new Int8Array(this.#r))}toString(){return`{DeleteUpdate uuid: ${b.toString(this.#t)}, attachment: ${this.settings.byteLength}b`}};var qo=Symbol("Unreferenceable"),ge=class s extends O{static create(t,e,r){return new s(t,e,r)}static encodeWith(t,e){m(this.#t.isEmpty(),"SerializationEncoder already in use"),this.#t=d.wrap(t);let r=G(e);if(this.#t=d.None,r.status==="failure")throw r.error;return r.value}static decodeWith(t,e){m(this.#e.isEmpty(),"SerializationDecoder already in use"),this.#e=d.wrap(t);let r=G(e);if(this.#e=d.None,r.status==="failure")throw r.error;return r.value}static#t=d.None;static#e=d.None;#r;#s;#n=d.None;#i=d.None;constructor(t,e,r){super(t),this.#r=e,this.#s=r,r&&this.graph.edges().watchVertex(this)}get pointerHub(){return u(`${this} cannot be pointed to`)}get pointerType(){return this.#r}get mandatory(){return this.#s}accept(t){return N(t.visitPointerField,this)}subscribe(t){return this.graph.subscribeVertexUpdates($.This,this.address,()=>t(this))}catchupAndSubscribe(t){return t(this),this.graph.subscribeVertexUpdates($.This,this.address,()=>this.graph.subscribeEndTransaction(()=>t(this)))}refer(t){this.targetVertex=d.wrap(t)}defer(){this.targetVertex=d.None}get targetVertex(){return this.graph.inTransaction()?this.#i.flatMap(t=>this.graph.findVertex(t)):this.#n}set targetVertex(t){if(t.nonEmpty()){let e=D.validate(this,t.unwrap());e.nonEmpty()&&u(e.unwrap())}this.targetAddress=t.map(e=>e.address)}get targetAddress(){return this.#i}set targetAddress(t){let e=this.#i;e.isEmpty()&&t.isEmpty()||(t.nonEmpty()&&e.unwrapOrNull()?.equals(t.unwrap()))===!0||(this.#i=t,this.graph.onPointerAddressUpdated(this,e,t))}isEmpty(){return this.targetAddress.isEmpty()}nonEmpty(){return this.targetAddress.nonEmpty()}resolvedTo(t){this.#n=t}read(t){let e=t.readBoolean()?d.wrap(x.read(t)):d.None;this.targetAddress=s.#e.match({none:()=>e,some:r=>r.map(this,e)})}write(t){s.#t.match({none:()=>this.#i,some:e=>e.map(this)}).match({none:()=>t.writeBoolean(!1),some:e=>{t.writeBoolean(!0),e.write(t)}})}};var Qe;(function(s){s.insertOrder=(t,e=Number.MAX_SAFE_INTEGER)=>{let r=s.collectIndexedBoxes(t),n=y(e,0,r.length);if(n<r.length)for(let i=n;i<r.length;i++)r[i].index.setValue(i+1);return n},s.removeOrder=(t,e)=>{let r=s.collectIndexedBoxes(t);if(e<r.length)for(let n=e+1;n<r.length;n++)r[n].index.setValue(n-1)},s.moveIndex=(t,e,r)=>{let n=s.collectIndexedBoxes(t),i=n[e];if(r<0){let o=y(e+r,0,n.length-1);for(let a=o;a<e;a++)n[a].index.setValue(a+1);i.index.setValue(o)}else if(r>1){let o=y(e+(r-1),0,n.length-1);for(let a=e;a<o;a++)n[a+1].index.setValue(a);i.index.setValue(o)}else console.warn(`moveIndex had no effect: startIndex: ${e}, delta: ${r}`)},s.isIndexedBox=t=>"index"in t&&t.index instanceof Bt,s.collectIndexedBoxes=(t,e)=>t.pointerHub.incoming().map(({box:r})=>s.isIndexedBox(r)&&(e===void 0||r instanceof e)?r:u(`${r} has no index field`)).sort((r,n)=>r.index.getValue()-n.index.getValue())})(Qe||(Qe={}));var Lt=Symbol.for("@openDAW/lib-box");globalThis[Lt]?console.debug(`%c${Lt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Lt]=!0,console.debug(`%c${Lt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var z;(function(s){let t=typeof self<"u"&&"location"in self&&typeof self.location!==void 0,e=typeof self<"u"&&"navigator"in self&&typeof self.navigator!==void 0;s.isLocalHost=()=>t&&location.host.includes("localhost"),s.isMacOS=()=>e&&navigator.userAgent.includes("Mac OS X"),s.isWindows=()=>e&&navigator.userAgent.includes("Windows"),s.isFirefox=()=>e&&navigator.userAgent.toLowerCase().includes("firefox"),s.isWeb=()=>!s.isTauriApp(),s.isVitest=typeof process<"u"&&process.env?.VITEST==="true",s.isTauriApp=()=>"__TAURI__"in window,s.userAgent=e?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"})(z||(z={}));var Je;(function(s){s.encode=async(t,e="gzip")=>{let r=new CompressionStream(e),n=r.writable.getWriter();return n.write(new Uint8Array(t)),n.close(),new Response(r.readable).arrayBuffer()},s.decode=async(t,e="gzip")=>{let r=new DecompressionStream(e),n=r.writable.getWriter();return n.write(new Uint8Array(t)),n.close(),new Response(r.readable).arrayBuffer()}})(Je||(Je={}));var Ze;(function(s){s.exportMethod=(n,i)=>r(n,{value:i}),s.exportBoolean=(n,i=!1)=>{let o=new St(i);return s.exportAccessor(n,()=>o.getValue(),a=>{let c=!!a;console.debug(`set to ${c}`),o.setValue(c)}),o},s.exportAccessor=(n,i,o=xe)=>r(n,{get:()=>{try{return console.debug(i()),0}catch(a){return console.error(a),1}},set:a=>{try{return o(a),i()}catch(c){return console.error(c),1}},enumerable:!1,configurable:!1});let t=(()=>{try{return self}catch{return{}}})(),e=t.opendaw??={},r=(n,i)=>{let o=n.split("."),a=o.splice(-1)[0],c=e;for(let h of o)c=c[h]??={};Object.defineProperty(c,a,i),console.debug(`Console command 'opendaw.${n}' exported`)}})(Ze||(Ze={}));var tr;(function(s){s.resolveString=t=>{if(!It(t)){if(typeof t=="string")return t;if(Array.isArray(t))return t.join(",");if(typeof t=="object"){if(typeof t.exact=="string")return t.exact;if(Array.isArray(t.exact))return t.exact.join(",");if(typeof t.ideal=="string")return t.ideal;if(Array.isArray(t.ideal))return t.ideal.join(",")}}}})(tr||(tr={}));var er;(function(s){s.truncateText=(t,e,r)=>{if(e.length===0)return{text:"",width:0};let n=t.measureText(e).width;if(n<=r)return{text:e,width:n};let i=t.measureText("\u2026").width,o=0,a=e.length|0;for(;o<a;){let h=a+o>>>1;n=t.measureText(e.substring(0,h+1)).width+i,n<=r?o=h+1:a=h}if(o===0)return{text:"",width:0};let c=e.substring(0,o);return{text:c+"\u2026",width:t.measureText(c).width+i}}})(er||(er={}));var rr;(function(s){s.calc=(e,r,n)=>{let i=/([0-9]*\.?[0-9]+)([a-zA-Z%]*)/g,o=e;return o.split(/\+|(?<!\d)-/).flatMap(a=>Array.from(a.matchAll(i))).forEach(([a,c,h])=>{let l=parseFloat(c);if(isNaN(l))return u(`${a} does not contain a number`);if(h==="em")o=o.replaceAll(a,`${l*n}`);else if(h==="%")o=o.replaceAll(a,`${l/100*r}`);else if(h==="px")o=o.replaceAll(a,`${l}`);else return u(`Unknown unit '${h}'`)}),Function(`return ${o}`)()};let t=new Map;s.registerCustomCursor=(e,r)=>t.set(e,r),s.setCursor=(e,r=document)=>{r.documentElement.style.cursor=typeof e=="number"?t.get(e)??"auto":e}})(rr||(rr={}));var xt;(function(s){let t=new Set,e=new Set,r=new Array,n=-1;s.add=i=>(e.add(i),{terminate:()=>e.delete(i)}),s.once=i=>{t.add(i)},s.start=()=>{console.debug("AnimationFrame start");let i=()=>{(e.size>0||t.size>0)&&(e.forEach(o=>r.push(o)),t.forEach(o=>r.push(o)),t.clear(),r.forEach(o=>o()),r.length=0),n=requestAnimationFrame(i)};n=requestAnimationFrame(i)},s.terminate=()=>{console.debug("AnimationFrame terminate"),t.clear(),e.clear(),r.length=0,cancelAnimationFrame(n)}})(xt||(xt={}));var T=class{static subscribe(t,e,r,n){return t.addEventListener(e,r,n),{terminate:()=>t.removeEventListener(e,r,n)}}static subscribeAny(t,e,r,n){return t.addEventListener(e,r,n),{terminate:()=>t.removeEventListener(e,r,n)}}static DOUBLE_DOWN_THRESHOLD=200;static subscribeDblDwn=(t,e)=>{let r=0;return this.subscribe(t,"pointerdown",n=>{let i=performance.now();i-r<this.DOUBLE_DOWN_THRESHOLD&&e(n),r=i},{capture:!0})};static PreventDefault=t=>t.preventDefault();static isTextInput=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLElement&&p(t.getAttribute("contenteditable"))};var q;(function(s){s.isControlKey=({ctrlKey:t,metaKey:e})=>z.isMacOS()?e:t,s.isCopyKey=({altKey:t})=>t,s.GlobalShortcut=Object.freeze({isDelete:t=>!T.isTextInput(t.target)&&(t.code==="Delete"||t.code==="Backspace"),isSelectAll:t=>s.isControlKey(t)&&!t.shiftKey&&t.code==="KeyA",isDeselectAll:t=>s.isControlKey(t)&&t.shiftKey&&t.code==="KeyA"})})(q||(q={}));var sr;(function(s){s.attach=(t,e,r)=>{let n=new Q;return S.many(n,T.subscribe(t,"pointerdown",i=>{if(r?.multiTouch!==!0&&!i.isPrimary||i.buttons!==1||z.isMacOS()&&i.ctrlKey)return;let o=e(i);if(o.isEmpty())return;let a=o.unwrap(),c=i.pointerId;i.stopPropagation(),i.stopImmediatePropagation(),t.setPointerCapture(c);let h={clientX:i.clientX,clientY:i.clientY,altKey:i.altKey,shiftKey:i.shiftKey,ctrlKey:q.isControlKey(i)};r?.immediate===!0&&a.update(h),r?.permanentUpdates===!0?(n.own(xt.add(()=>a.update(h))),n.own(T.subscribe(t,"pointermove",f=>{f.pointerId===c&&(h.clientX=f.clientX,h.clientY=f.clientY,h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f))}))):n.own(T.subscribe(t,"pointermove",f=>{f.pointerId===c&&(h.clientX=f.clientX,h.clientY=f.clientY,h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f),a.update(h))}));let l=()=>{a.cancel?.call(a),a.finally?.call(a),n.terminate()};n.ownAll(T.subscribe(t,"pointerup",f=>{f.pointerId===c&&(a.approve?.call(a),a.finally?.call(a),n.terminate())},{capture:!0}),T.subscribe(t,"pointercancel",f=>{console.debug(f.type),f.pointerId===c&&(t.releasePointerCapture(c),l())},{capture:!0}),T.subscribe(self,"beforeunload",f=>{t.releasePointerCapture(c),l()},{capture:!0}),T.subscribe(window,"keydown",f=>{h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f),f.key==="Escape"?l():a.update(h)}),T.subscribe(window,"keyup",f=>{h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f),a.update(h)})),a.abortSignal&&n.own(T.subscribe(a.abortSignal,"abort",()=>{t.releasePointerCapture(c),l()}))}))}})(sr||(sr={}));var nr;(function(s){s.AbortError=typeof DOMException>"u"?NaN:Object.freeze(new DOMException("AbortError")),s.isAbort=t=>t===s.AbortError||t instanceof DOMException&&t.name==="AbortError",s.CatchAbort=t=>t===s.AbortError?void 0:u(t)})(nr||(nr={}));var ir;(function(s){s.save=async(t,e)=>{if(p(window.showSaveFilePicker)){let r=await window.showSaveFilePicker(e),n=await r.createWritable();return await n.truncate(0),await n.write(t),await n.close(),r.name??"unknown"}else{let r=new Blob([t]),n=URL.createObjectURL(r),i=document.createElement("a");return i.href=n,i.download=e?.suggestedName??"unknown",i.click(),URL.revokeObjectURL(n),e?.suggestedName??"Unknown"}},s.open=async t=>{if(p(window.showOpenFilePicker)){let{status:e,value:r,error:n}=await C.tryCatch(window.showOpenFilePicker(t));return e==="rejected"?Promise.reject(n):Promise.all(r.map(i=>i.getFile()))}else return new Promise((e,r)=>{p(t)&&console.warn("FileApi.showOpenFilePicker is emulated in this browser. OpenFilePickerOptions are ignored.");let n=document.createElement("input");n.type="file",n.multiple=t?.multiple??!1,n.style.display="none",n.addEventListener("cancel",async()=>{n.remove(),r(new DOMException("cancel","AbortError"))}),n.addEventListener("change",async i=>{let a=i.target.files;p(a)?e(g.create(c=>w(a.item(c),`No file at index ${c}`),a.length)):r(new DOMException("cancel","AbortError")),n.remove()}),document.body.appendChild(n),n.click()})}})(ir||(ir={}));var or;(function(s){s.parse=t=>{let e=document.createElement("div");if(e.innerHTML=t,e.childElementCount!==1)return u(`Source html has more than one root elements: '${t}'`);let r=e.firstChild;return r instanceof HTMLElement||r instanceof SVGSVGElement?r:u(`Cannot parse to HTMLOrSVGElement from '${t}'`)},s.empty=t=>{for(;t.firstChild!==null;)t.firstChild.remove()},s.query=(t,e=document)=>w(e.querySelector(t)),s.queryAll=(t,e=document)=>Array.from(e.querySelectorAll(t)),s.sanitize=t=>{t.querySelectorAll("script").forEach(e=>e.remove()),t.querySelectorAll("*").forEach(e=>{[...e.attributes].forEach(r=>{r.name.toLowerCase().startsWith("on")&&e.removeAttribute(r.name)})})},s.nextID=(()=>{let t=0;return()=>(++t).toString(16).padStart(4,"0")})(),s.adoptStyleSheet=(t,e)=>{m(t.includes("component"),`No 'component' found in: ${t}`);let r=`${e??"C"}${s.nextID()}`,n=new CSSStyleSheet;return n.replaceSync(t.replaceAll("component",`.${r}`)),n.cssRules.length===0?u(`No cssRules found in: ${t}`):(document.adoptedStyleSheets.push(n),r)},s.buildClassList=(...t)=>t.filter(e=>e!==!1&&e!==void 0).join(" "),s.readCssVarColor=(...t)=>{let e=document.createElement("div");document.body.appendChild(e);let r=t.map(n=>(e.style.color=n,vt.parseCssRgbOrRgba(getComputedStyle(e).color)));return e.remove(),r},s.watchResize=(t,e,r)=>{let n=new ResizeObserver(([i],o)=>e(i,o));return n.observe(t,r),{terminate:()=>n.disconnect()}},s.watchIntersection=(t,e,r)=>{let n=new IntersectionObserver(e,r);return n.observe(t),{terminate:()=>n.disconnect()}},s.secureBoundingBox=t=>{let e=t.getBoundingClientRect();if(!gt.isEmpty(e))return e;for(let r of t.children)gt.union(e,s.secureBoundingBox(r));return e},s.unfocus=(t=self)=>{let e=t.document.activeElement;e!==null&&"blur"in e&&typeof e.blur=="function"&&e.blur()},s.selectContent=t=>{let e=document.createRange(),r=window.getSelection();p(r)&&(e.selectNodeContents(t),r.removeAllRanges(),r.addRange(e))},s.unselectContent=t=>{let e=window.getSelection();!p(e)||e.rangeCount===0||t.contains(e.getRangeAt(0).commonAncestorContainer)&&e.removeAllRanges()},s.limitChars=(t,e,r)=>{if(!(e in t))return u(`${e} not found in ${t}`);if(typeof t[e]!="string")return u(`${e} in ${t} is not a string`);if(t[e].length>r)if(t[e]=t[e].substring(0,r),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)t.setSelectionRange(r,r);else{let n=t.ownerDocument,i=n.createRange(),o=n.defaultView?.getSelection();if(!p(o))return;i.selectNodeContents(t),i.collapse(!1),o.removeAllRanges(),o.addRange(i)}},s.EmptyGif="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})(or||(or={}));var pc=(()=>{let s={Cmd:"\u2318",Opt:"\u2325",Shift:"\u21E7"},t={Cmd:"Ctrl",Opt:"Alt",Shift:"\u21E7"};return Object.freeze({Mac:s,Win:t,System:z.isMacOS()?s:t})})();var ar;(function(s){s.read=async t=>{let e=[];for(;;){let{done:o,value:a}=await t.read();if(o)break;e.push(a)}let r=e.reduce((o,a)=>o+a.length,0),n=new Uint8Array(r),i=0;for(let o of e)n.set(o,i),i+=o.length;return n.buffer}})(ar||(ar={}));var cr;(function(s){s.pathBuilder=()=>new class{#t="";moveTo(t,e){return this.#t+=`M${t.toFixed(3)} ${e.toFixed(3)}`,this}lineTo(t,e){return this.#t+=`L${t.toFixed(3)} ${e.toFixed(3)}`,this}quadratic(t,e,r,n){return this.#t+=`Q${t.toFixed(3)} ${e.toFixed(3)} ${r.toFixed(3)} ${n.toFixed(3)}`,this}quadraticTo(t,e){return this.#t+=`T${t.toFixed(3)} ${e.toFixed(3)}`,this}cubic(t,e,r,n,i,o){return this.#t+=`Q${t.toFixed(3)} ${e.toFixed(3)} ${r.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)} ${o.toFixed(3)}`,this}arc(t,e,r,n,i,o,a){return this.#t+=`A${t} ${e} ${r} ${n?1:0} ${i?1:0} ${o.toFixed(3)} ${a.toFixed(3)}`,this}circleSegment(t,e,r,n,i){let o=t+Math.cos(n)*r,a=e+Math.sin(n)*r,c=t+Math.cos(i)*r,h=e+Math.sin(i)*r,l=i-n;for(;l<0;)l+=Math.PI*2;return this.moveTo(o,a).arc(r,r,0,l>Math.PI,!0,c,h)}close(){return this.#t+="Z",this}get(){return this.#t}}})(cr||(cr={}));var hr;(function(s){let t=new Array;s.watchWeak=(r,n)=>{let i=new WeakRef(r),o=n(i);return t.push([i,o]),t.length===1&&e(),r};let e=()=>{console.debug("start weak watching");let r=setInterval(()=>{let n=t.length;for(;--n>=0;){let i=t[n];i[0].deref()===void 0&&(i[1].terminate(),t.splice(n,1),t.length===0&&clearInterval(r))}},1e3)}})(hr||(hr={}));var Pt=Symbol.for("@openDAW/lib-dom");globalThis[Pt]?console.debug(`%c${Pt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Pt]=!0,console.debug(`%c${Pt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Ct;(function(s){s[s.Float=0]="Float",s[s.FloatArray=1]="FloatArray",s[s.Integer=2]="Integer",s[s.IntegerArray=3]="IntegerArray",s[s.ByteArray=4]="ByteArray"})(Ct||(Ct={}));var Dt;(function(s){s[s.WRITE=0]="WRITE",s[s.READ=1]="READ"})(Dt||(Dt={}));var kt;(function(s){s[s.ID=15793935]="ID",s[s.START=15790320]="START",s[s.END=986895]="END"})(kt||(kt={}));var W;(function(s){class t{shift;numPeaks;dataOffset;constructor(r,n,i){this.shift=r,this.numPeaks=n,this.dataOffset=i}unitsEachPeak(){return 1<<this.shift}}s.Stage=t,s.unpack=(e,r)=>{switch(r){case 0:return j.intBitsToFloat(e);case 1:return j.intBitsToFloat(e>>16);default:return k(r)}}})(W||(W={}));var _t=class s{stages;data;numFrames;numChannels;static from(t){m(t.readString()==="PEAKS","Wrong header");let e=t.readInt(),r=[];for(let c=0;c<e;c++){let h=t.readInt(),l=t.readInt(),f=t.readInt();t.readInt(),r[c]=new W.Stage(f,l,h)}let n=t.readInt(),i=[];for(let c=0;c<n;c++){let h=new Int8Array(t.readInt());t.readBytes(h),i[c]=new Int32Array(h.buffer)}let o=t.readInt(),a=t.readInt();return new s(r,i,o,a)}static None=new s([],[],0,0);static findBestFit=(t,e=1200)=>{let r=t/e;if(r<=1)return new Uint8Array(0);let n=3,i=Math.floor(Math.log(r)/Math.LN2),o=Math.max(1,Math.floor(i/n));return new Uint8Array(g.create(a=>n*(a+1),o))};constructor(t,e,r,n){this.stages=t,this.data=e,this.numFrames=r,this.numChannels=n}nearest(t){if(this.stages.length===0)return null;let e=Math.floor(Math.log(Math.abs(t))/Math.LN2),r=this.stages.length;for(;--r>-1;)if(e>=this.stages[r].shift)return this.stages[r];return this.stages[0]}toArrayBuffer(){let t=v.create();t.writeString("PEAKS"),t.writeInt(this.stages.length);for(let e=0;e<this.stages.length;e++){let{dataOffset:r,numPeaks:n,shift:i}=this.stages[e];t.writeInt(r),t.writeInt(n),t.writeInt(i),t.writeInt((1<<i)-1)}t.writeInt(this.data.length);for(let e=0;e<this.data.length;e++){let r=new Int8Array(this.data[e].buffer);t.writeInt(r.length),t.writeBytes(r)}return t.writeInt(this.numFrames),t.writeInt(this.numChannels),t.toArrayBuffer()}toString(){return`{SamplePeaks num-stages: ${this.stages.length}}`}};var Ut;(function(s){s.install=r=>P.executor(r.channel("peaks"),new class{async generateAsync(n,i,o,a,c){return t(n,i,o,a,c).toArrayBuffer()}});let t=(r,n,i,o,a)=>{if(i.length!==a)return u(`Invalid numberOfChannels. Expected: ${a}. Got ${i.length}`);class c{min=Number.POSITIVE_INFINITY;max=Number.NEGATIVE_INFINITY;index=0}let h=qe(),l=n.length,[f,E]=e(n,o),R=g.create(()=>new Int32Array(E),a),bt=(1<<f[0].shift)-1,zt=a*o,Et=0;for(let K=0;K<a;++K){let ft=R[K],dt=i[K],Y=g.create(()=>new c,l),V=Number.POSITIVE_INFINITY,tt=Number.NEGATIVE_INFINITY,et=0;for(let rt=0;rt<o;++rt){let pt=dt[rt];if(V=Math.min(pt,V),tt=Math.max(pt,tt),(++et&bt)===0){for(let H=0;H<l;++H){let mt=f[H],M=Y[H];M.min=Math.min(M.min,V),M.max=Math.max(M.max,tt),((1<<mt.shift)-1&et)===0&&(ft[mt.dataOffset+M.index++]=s.pack(M.min,M.max),M.min=Number.POSITIVE_INFINITY,M.max=Number.NEGATIVE_INFINITY)}V=Number.POSITIVE_INFINITY,tt=Number.NEGATIVE_INFINITY}(++Et&65535)===0&&r(Et/zt)}}return r(1),h.lab(`SamplePeaks '${self.constructor.name}'`),new _t(f,R,o,a)},e=(r,n)=>{let i=0;return[g.create(a=>{let c=r[a],h=Math.ceil(n/(1<<c)),l=new W.Stage(c,h,i);return i+=h,l},r.length),i]};s.pack=(r,n)=>{let i=j.floatToIntBits(r),o=j.floatToIntBits(n);return i|o<<16}})(Ut||(Ut={}));var lr;(function(s){s.renderBlocks=(t,e,r,{u0:n,u1:i,v0:o,v1:a,x0:c,x1:h,y0:l,y1:f})=>{let E=(i-n)/(h-c),R=e.nearest(E);if(R===null)return;let bt=(f-l-1)/(a-o),zt=R.unitsEachPeak(),Et=c-Math.floor(c),K=E/zt,ft=(n-Et*E)/E*K,dt=Math.floor(ft),Y=0,V=0,tt=e.data[r];for(let et=Math.floor(c);et<Math.floor(h);et++){let rt=ft+K,pt=Math.floor(rt),H=!1;for(;dt<pt;){let At=tt[R.dataOffset+dt++];Y=Math.min(W.unpack(At,0),Y),V=Math.max(W.unpack(At,1),V),H=!0}let mt=l+Math.floor((Y-o)*bt),M=l+Math.floor((V-o)*bt),qt=Math.max(l,Math.min(mt,M)),ye=Math.min(f,Math.max(mt,M));if(t.fillRect(et,qt,1,ye===qt?1:ye-qt),H){let At=V;V=Y,Y=At}ft=rt,dt=pt}}})(lr||(lr={}));var Kt;(function(s){let e=new C.Limit(1),r=new C.Limit(1);s.init=i=>P.executor(i.channel("opfs"),new class{async write(o,a){return r.add(()=>this.#t(o,{create:!0}).then(c=>{c.truncate(a.length),c.write(a.buffer,{at:0}),c.flush(),c.close()}))}async read(o){return e.add(()=>this.#t(o).then(a=>{let c=a.getSize(),h=new Uint8Array(c);return a.read(h),a.close(),h}))}async delete(o){let a=n(o);return this.#e(a.slice(0,-1)).then(c=>c.removeEntry(w(a.at(-1)),{recursive:!0}))}async list(o){let a=n(o),{status:c,value:h}=await C.tryCatch(this.#e(a));if(c==="rejected")return g.empty();let l=[];for await(let{name:f,kind:E}of h.values())l.push({name:f,kind:E});return l}async#t(o,a){let c=n(o);return this.#e(c.slice(0,-1),a).then(h=>h.getFileHandle(w(c.at(-1)),a).then(l=>l.createSyncAccessHandle()))}async#e(o,a){let c=await navigator.storage.getDirectory();for(let h of o)c=await c.getDirectoryHandle(h,a);return c}});let n=i=>{let o=i.replace(/^\/+|\/+$/g,"");return o===""?[]:o.split("/")}})(Kt||(Kt={}));var jt=Symbol.for("@openDAW/lib-fusion");globalThis[jt]?console.debug(`%c${jt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[jt]=!0,console.debug(`%c${jt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var ur=je.for(self);Kt.init(ur);Ut.install(ur);
3
+ `),this));for(let r of e)r.defer();for(let r of t)r.unstage();this.unstage()}unstage(){this.graph.unstageBox(this)}toString(){return`${this.constructor.name} ${this.address.toString()}`}};yr([it,Je("design:type",D),Je("design:paramtypes",[])],de.prototype,"pointerHub",null);var $;(function(s){s[s.This=0]="This",s[s.Parent=1]="Parent",s[s.Children=2]="Children"})($||($={}));var pe;(function(s){s.create=()=>new me})(pe||(pe={}));var me=class{#t=new wt(Z.equals);#e=new wt(Z.startsWith);#r=new wt(Z.endsWith);#s=[];#n=0;#i=!1;subscribe(t,e,r){let n=new ge(e,t,this.#n++,r);if(this.#i){let i=new ye(n,t);return this.#s.push(i),i}else return this.subscribeMonitor(n,t)}dispatch(t){this.#i=!0,[...this.#t.filter(t),...this.#e.filter(t),...this.#r.filter(t)].sort(({order:r},{order:n})=>r-n).forEach(r=>r.procedure(t)),this.#i=!1,this.#s.forEach(r=>r.subscribe(this)),this.#s.length=0}subscribeMonitor(t,e){switch(e){case $.This:return this.#t.subscribe(t);case $.Parent:return this.#e.subscribe(t);case $.Children:return this.#r.subscribe(t);default:return k(e)}}countStations(){return this.#t.count()+this.#e.count()+this.#r.count()}},ge=class{address;propagation;order;procedure;constructor(t,e,r,n){this.address=t,this.propagation=e,this.order=r,this.procedure=n}toString(){return`{ Monitor address: ${this.address}, propagation: ${$[this.propagation]}, order: ${this.order} }`}},wt=class{filterStrategy;#t=[];#e=!0;constructor(t){this.filterStrategy=t}subscribe(t){return this.#t.push(t),this.#e=this.#t.length<2,{terminate:()=>{let e=this.#t.length;for(;--e>=0;)this.#t[e]===t&&this.#t.splice(e,1)}}}stations(){return this.#e||(this.#t.sort(Z.Comparator),this.#e=!0),this.#t}filter(t){return this.filterStrategy(t.address,this.stations())}count(){return this.#t.length}},ye=class{monitor;propagation;#t=new Q;#e=!1;constructor(t,e){this.monitor=t,this.propagation=e}subscribe(t){this.#e||(this.#t.terminate(),this.#t.own(t.subscribeMonitor(this.monitor,this.propagation)))}terminate(){this.#e=!0,this.#t.terminate()}};var I;(function(s){s.Boolean="boolean",s.Float32="float32",s.Int32="int32",s.String="string",s.Bytes="bytes"})(I||(I={}));var Ft={[I.Boolean]:{type:I.Boolean,encode:(s,t)=>s.writeBoolean(t),decode:s=>s.readBoolean()},[I.Float32]:{type:I.Float32,encode:(s,t)=>s.writeFloat(t),decode:s=>s.readFloat()},[I.Int32]:{type:I.Int32,encode:(s,t)=>s.writeInt(t),decode:s=>s.readInt()},[I.String]:{type:I.String,encode:(s,t)=>s.writeString(t),decode:s=>s.readString()},[I.Bytes]:{type:I.Bytes,encode:(s,t)=>{s.writeInt(t.length),s.writeBytes(t)},decode:s=>{let t=new Int8Array(s.readInt());return s.readBytes(t),t}}},Nt=class extends O{#t;#e;#r;constructor(t,e,r){super(t),this.#t=e,this.#e=this.clamp(r),this.#r=this.#e}accept(t){return N(t.visitPrimitiveField,this)}subscribe(t){return this.graph.subscribeVertexUpdates($.This,this.address,()=>t(this))}catchupAndSubscribe(t){return t(this),this.subscribe(t)}get type(){return this.#t}get initValue(){return this.#e}setInitValue(t){m(this.graph.constructingBox(),"Cannot change initial value at runtime"),this.setValue(this.#e=t)}getValue(){return this.#r}setValue(t){let e=this.#r,r=this.clamp(t);this.equals(r)||(this.#r=t,this.graph.onPrimitiveValueUpdate(this,e,r))}writeValue(t,e){this.serialization().encode(t,e)}readValue(t){return this.serialization().decode(t)}reset(){this.setValue(this.#e)}};var Bt=class s extends Nt{static create(t,e=0){return new s(t,e)}constructor(t,e){super(t,I.Int32,e)}serialization(){return Ft[I.Int32]}equals(t){return this.getValue()===t}clamp(t){return _.toInt(t)}read(t){this.setValue(t.readInt())}write(t){t.writeInt(this.getValue())}};var Ze=class s extends Nt{static create(t,e=this.#t){return new s(t,e)}static#t=Object.freeze(new Int8Array(0));constructor(t,e){super(t,I.Bytes,e)}serialization(){return Ft[I.Bytes]}equals(t){return this.getValue().length===t.length&&this.getValue().every((e,r)=>t[r]===e)}clamp(t){return t}read(t){let e=new Int8Array(t.readInt());t.readBytes(e),this.setValue(e)}write(t){let e=this.getValue();t.writeInt(e.length),t.writeBytes(e)}};var tr;(function(s){s.decode=t=>{let e=t.readInt();return g.create(()=>{switch(t.readString()){case"new":{let n=b.fromDataInput(t),i=t.readString(),o=new Int8Array(t.readInt());return t.readBytes(o),new Ot(n,i,o.buffer)}case"pointer":{let n=x.read(t),i=t.readBoolean()?d.wrap(x.read(t)):d.None,o=t.readBoolean()?d.wrap(x.read(t)):d.None;return new Rt(n,i,o)}case"primitive":{let n=x.read(t),i=t.readString(),o=Ft[i],a=o.decode(t),c=o.decode(t);return new $t(n,o,a,c)}case"delete":{let n=b.fromDataInput(t),i=t.readString(),o=new Int8Array(t.readInt());return t.readBytes(o),new Vt(n,i,o.buffer)}}},e)}})(tr||(tr={}));var Ot=class{type="new";#t;#e;#r;constructor(t,e,r){this.#t=t,this.#e=e,this.#r=r}get uuid(){return this.#t}get name(){return this.#e}get settings(){return this.#r}forward(t){t.createBox(this.#e,this.#t,e=>e.read(new F(this.#r)))}inverse(t){t.findBox(this.#t).unwrap(()=>`Could not find ${this.#e}`).unstage()}write(t){t.writeString(this.type),b.toDataOutput(t,this.#t),t.writeString(this.#e),t.writeInt(this.#r.byteLength),t.writeBytes(new Int8Array(this.#r))}toString(){return`{NewUpdate uuid: ${b.toString(this.#t)}, attachment: ${this.settings.byteLength}b`}toDebugString(t){return this.toString()}},$t=class{type="primitive";#t;#e;#r;#s;constructor(t,e,r,n){this.#t=t,this.#e=e,this.#r=r,this.#s=n}get address(){return this.#t}get oldValue(){return this.#r}get newValue(){return this.#s}matches(t){return t.address.equals(this.address)}inverse(t){this.field(t).setValue(this.#r)}forward(t){this.field(t).setValue(this.#s)}field(t){return t.findVertex(this.#t).unwrap(()=>`Could not find PrimitiveField at ${this.#t}`)}write(t){t.writeString(this.type),this.#t.write(t),t.writeString(this.#e.type),this.#e.encode(t,this.#r),this.#e.encode(t,this.#s)}toString(){return`{PrimitiveUpdate oldValue: ${this.#r}, newValue: ${this.#s}`}},Rt=class{type="pointer";#t;#e;#r;constructor(t,e,r){this.#t=t,this.#e=e,this.#r=r}get address(){return this.#t}get oldAddress(){return this.#e}get newAddress(){return this.#r}matches(t){return t.address.equals(this.address)}inverse(t){this.field(t).targetAddress=this.#e}forward(t){this.field(t).targetAddress=this.#r}field(t){return t.findVertex(this.#t).unwrap(()=>`Could not find PointerField at ${this.#t}`)}write(t){t.writeString(this.type),this.#t.write(t),this.#e.match({none:()=>t.writeBoolean(!1),some:e=>{t.writeBoolean(!0),e.write(t)}}),this.#r.match({none:()=>t.writeBoolean(!1),some:e=>{t.writeBoolean(!0),e.write(t)}})}toString(){return`{PointerUpdate oldValue: ${this.#e.unwrapOrNull()}, newValue: ${this.#r.unwrapOrNull()}`}},Vt=class{type="delete";#t;#e;#r;constructor(t,e,r){this.#t=t,this.#e=e,this.#r=r}get uuid(){return this.#t}get name(){return this.#e}get settings(){return this.#r}forward(t){t.findBox(this.#t).unwrap(()=>`Could not find ${this.#e}`).unstage()}inverse(t){t.createBox(this.#e,this.#t,e=>e.read(new F(this.#r)))}write(t){t.writeString(this.type),b.toDataOutput(t,this.#t),t.writeString(this.#e),t.writeInt(this.#r.byteLength),t.writeBytes(new Int8Array(this.#r))}toString(){return`{DeleteUpdate uuid: ${b.toString(this.#t)}, attachment: ${this.settings.byteLength}b`}};var Go=Symbol("Unreferenceable"),we=class s extends O{static create(t,e,r){return new s(t,e,r)}static encodeWith(t,e){m(this.#t.isEmpty(),"SerializationEncoder already in use"),this.#t=d.wrap(t);let r=G(e);if(this.#t=d.None,r.status==="failure")throw r.error;return r.value}static decodeWith(t,e){m(this.#e.isEmpty(),"SerializationDecoder already in use"),this.#e=d.wrap(t);let r=G(e);if(this.#e=d.None,r.status==="failure")throw r.error;return r.value}static#t=d.None;static#e=d.None;#r;#s;#n=d.None;#i=d.None;constructor(t,e,r){super(t),this.#r=e,this.#s=r,r&&this.graph.edges().watchVertex(this)}get pointerHub(){return u(`${this} cannot be pointed to`)}get pointerType(){return this.#r}get mandatory(){return this.#s}accept(t){return N(t.visitPointerField,this)}subscribe(t){return this.graph.subscribeVertexUpdates($.This,this.address,()=>t(this))}catchupAndSubscribe(t){return t(this),this.graph.subscribeVertexUpdates($.This,this.address,()=>this.graph.subscribeEndTransaction(()=>t(this)))}refer(t){this.targetVertex=d.wrap(t)}defer(){this.targetVertex=d.None}get targetVertex(){return this.graph.inTransaction()?this.#i.flatMap(t=>this.graph.findVertex(t)):this.#n}set targetVertex(t){if(t.nonEmpty()){let e=D.validate(this,t.unwrap());e.nonEmpty()&&u(e.unwrap())}this.targetAddress=t.map(e=>e.address)}get targetAddress(){return this.#i}set targetAddress(t){let e=this.#i;e.isEmpty()&&t.isEmpty()||(t.nonEmpty()&&e.unwrapOrNull()?.equals(t.unwrap()))===!0||(this.#i=t,this.graph.onPointerAddressUpdated(this,e,t))}isEmpty(){return this.targetAddress.isEmpty()}nonEmpty(){return this.targetAddress.nonEmpty()}resolvedTo(t){this.#n=t}read(t){let e=t.readBoolean()?d.wrap(x.read(t)):d.None;this.targetAddress=s.#e.match({none:()=>e,some:r=>r.map(this,e)})}write(t){s.#t.match({none:()=>this.#i,some:e=>e.map(this)}).match({none:()=>t.writeBoolean(!1),some:e=>{t.writeBoolean(!0),e.write(t)}})}};var er;(function(s){s.insertOrder=(t,e=Number.MAX_SAFE_INTEGER)=>{let r=s.collectIndexedBoxes(t),n=y(e,0,r.length);if(n<r.length)for(let i=n;i<r.length;i++)r[i].index.setValue(i+1);return n},s.removeOrder=(t,e)=>{let r=s.collectIndexedBoxes(t);if(e<r.length)for(let n=e+1;n<r.length;n++)r[n].index.setValue(n-1)},s.moveIndex=(t,e,r)=>{let n=s.collectIndexedBoxes(t),i=n[e];if(r<0){let o=y(e+r,0,n.length-1);for(let a=o;a<e;a++)n[a].index.setValue(a+1);i.index.setValue(o)}else if(r>1){let o=y(e+(r-1),0,n.length-1);for(let a=e;a<o;a++)n[a+1].index.setValue(a);i.index.setValue(o)}else console.warn(`moveIndex had no effect: startIndex: ${e}, delta: ${r}`)},s.isIndexedBox=t=>"index"in t&&t.index instanceof Bt,s.collectIndexedBoxes=(t,e)=>t.pointerHub.incoming().map(({box:r})=>s.isIndexedBox(r)&&(e===void 0||r instanceof e)?r:u(`${r} has no index field`)).sort((r,n)=>r.index.getValue()-n.index.getValue())})(er||(er={}));var Lt=Symbol.for("@openDAW/lib-box");globalThis[Lt]?console.debug(`%c${Lt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Lt]=!0,console.debug(`%c${Lt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var z;(function(s){let t=typeof self<"u"&&"location"in self&&typeof self.location!==void 0,e=typeof self<"u"&&"navigator"in self&&typeof self.navigator!==void 0;s.isLocalHost=()=>t&&location.host.includes("localhost"),s.isMacOS=()=>e&&navigator.userAgent.includes("Mac OS X"),s.isWindows=()=>e&&navigator.userAgent.includes("Windows"),s.isFirefox=()=>e&&navigator.userAgent.toLowerCase().includes("firefox"),s.isWeb=()=>!s.isTauriApp(),s.isVitest=typeof process<"u"&&process.env?.VITEST==="true",s.isTauriApp=()=>"__TAURI__"in window,s.userAgent=e?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"})(z||(z={}));var rr;(function(s){s.encode=async(t,e="gzip")=>{let r=new CompressionStream(e),n=r.writable.getWriter();return n.write(new Uint8Array(t)),n.close(),new Response(r.readable).arrayBuffer()},s.decode=async(t,e="gzip")=>{let r=new DecompressionStream(e),n=r.writable.getWriter();return n.write(new Uint8Array(t)),n.close(),new Response(r.readable).arrayBuffer()}})(rr||(rr={}));var sr;(function(s){s.exportMethod=(n,i)=>r(n,{value:i}),s.exportBoolean=(n,i=!1)=>{let o=new St(i);return s.exportAccessor(n,()=>o.getValue(),a=>{let c=!!a;console.debug(`set to ${c}`),o.setValue(c)}),o},s.exportAccessor=(n,i,o=Ae)=>r(n,{get:()=>{try{return console.debug(i()),0}catch(a){return console.error(a),1}},set:a=>{try{return o(a),i()}catch(c){return console.error(c),1}},enumerable:!1,configurable:!1});let t=(()=>{try{return self}catch{return{}}})(),e=t.opendaw??={},r=(n,i)=>{let o=n.split("."),a=o.splice(-1)[0],c=e;for(let h of o)c=c[h]??={};Object.defineProperty(c,a,i),console.debug(`Console command 'opendaw.${n}' exported`)}})(sr||(sr={}));var nr;(function(s){s.resolveString=t=>{if(!It(t)){if(typeof t=="string")return t;if(Array.isArray(t))return t.join(",");if(typeof t=="object"){if(typeof t.exact=="string")return t.exact;if(Array.isArray(t.exact))return t.exact.join(",");if(typeof t.ideal=="string")return t.ideal;if(Array.isArray(t.ideal))return t.ideal.join(",")}}}})(nr||(nr={}));var ir;(function(s){s.truncateText=(t,e,r)=>{if(e.length===0)return{text:"",width:0};let n=t.measureText(e).width;if(n<=r)return{text:e,width:n};let i=t.measureText("\u2026").width,o=0,a=e.length|0;for(;o<a;){let h=a+o>>>1;n=t.measureText(e.substring(0,h+1)).width+i,n<=r?o=h+1:a=h}if(o===0)return{text:"",width:0};let c=e.substring(0,o);return{text:c+"\u2026",width:t.measureText(c).width+i}}})(ir||(ir={}));var or;(function(s){s.calc=(e,r,n)=>{let i=/([0-9]*\.?[0-9]+)([a-zA-Z%]*)/g,o=e;return o.split(/\+|(?<!\d)-/).flatMap(a=>Array.from(a.matchAll(i))).forEach(([a,c,h])=>{let l=parseFloat(c);if(isNaN(l))return u(`${a} does not contain a number`);if(h==="em")o=o.replaceAll(a,`${l*n}`);else if(h==="%")o=o.replaceAll(a,`${l/100*r}`);else if(h==="px")o=o.replaceAll(a,`${l}`);else return u(`Unknown unit '${h}'`)}),Function(`return ${o}`)()};let t=new Map;s.registerCustomCursor=(e,r)=>t.set(e,r),s.setCursor=(e,r=document)=>{r.documentElement.style.cursor=typeof e=="number"?t.get(e)??"auto":e}})(or||(or={}));var xt;(function(s){let t=new Set,e=new Set,r=new Array,n=-1;s.add=i=>(e.add(i),{terminate:()=>e.delete(i)}),s.once=i=>{t.add(i)},s.start=()=>{console.debug("AnimationFrame start");let i=()=>{(e.size>0||t.size>0)&&(e.forEach(o=>r.push(o)),t.forEach(o=>r.push(o)),t.clear(),r.forEach(o=>o()),r.length=0),n=requestAnimationFrame(i)};n=requestAnimationFrame(i)},s.terminate=()=>{console.debug("AnimationFrame terminate"),t.clear(),e.clear(),r.length=0,cancelAnimationFrame(n)}})(xt||(xt={}));var T=class{static subscribe(t,e,r,n){return t.addEventListener(e,r,n),{terminate:()=>t.removeEventListener(e,r,n)}}static subscribeAny(t,e,r,n){return t.addEventListener(e,r,n),{terminate:()=>t.removeEventListener(e,r,n)}}static DOUBLE_DOWN_THRESHOLD=200;static subscribeDblDwn=(t,e)=>{let r=0;return this.subscribe(t,"pointerdown",n=>{let i=performance.now();i-r<this.DOUBLE_DOWN_THRESHOLD&&e(n),r=i},{capture:!0})};static PreventDefault=t=>t.preventDefault();static isTextInput=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLElement&&p(t.getAttribute("contenteditable"))};var q;(function(s){s.isControlKey=({ctrlKey:t,metaKey:e})=>z.isMacOS()?e:t,s.isCopyKey=({altKey:t})=>t,s.GlobalShortcut=Object.freeze({isDelete:t=>!T.isTextInput(t.target)&&(t.code==="Delete"||t.code==="Backspace"),isSelectAll:t=>s.isControlKey(t)&&!t.shiftKey&&t.code==="KeyA",isDeselectAll:t=>s.isControlKey(t)&&t.shiftKey&&t.code==="KeyA"})})(q||(q={}));var ar;(function(s){s.attach=(t,e,r)=>{let n=new Q;return S.many(n,T.subscribe(t,"pointerdown",i=>{if(r?.multiTouch!==!0&&!i.isPrimary||i.buttons!==1||z.isMacOS()&&i.ctrlKey)return;let o=e(i);if(o.isEmpty())return;let a=o.unwrap(),c=i.pointerId;i.stopPropagation(),i.stopImmediatePropagation(),t.setPointerCapture(c);let h={clientX:i.clientX,clientY:i.clientY,altKey:i.altKey,shiftKey:i.shiftKey,ctrlKey:q.isControlKey(i)};r?.immediate===!0&&a.update(h),r?.permanentUpdates===!0?(n.own(xt.add(()=>a.update(h))),n.own(T.subscribe(t,"pointermove",f=>{f.pointerId===c&&(h.clientX=f.clientX,h.clientY=f.clientY,h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f))}))):n.own(T.subscribe(t,"pointermove",f=>{f.pointerId===c&&(h.clientX=f.clientX,h.clientY=f.clientY,h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f),a.update(h))}));let l=()=>{a.cancel?.call(a),a.finally?.call(a),n.terminate()};n.ownAll(T.subscribe(t,"pointerup",f=>{f.pointerId===c&&(a.approve?.call(a),a.finally?.call(a),n.terminate())},{capture:!0}),T.subscribe(t,"pointercancel",f=>{console.debug(f.type),f.pointerId===c&&(t.releasePointerCapture(c),l())},{capture:!0}),T.subscribe(self,"beforeunload",f=>{t.releasePointerCapture(c),l()},{capture:!0}),T.subscribe(window,"keydown",f=>{h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f),f.key==="Escape"?l():a.update(h)}),T.subscribe(window,"keyup",f=>{h.altKey=f.altKey,h.shiftKey=f.shiftKey,h.ctrlKey=q.isControlKey(f),a.update(h)})),a.abortSignal&&n.own(T.subscribe(a.abortSignal,"abort",()=>{t.releasePointerCapture(c),l()}))}))}})(ar||(ar={}));var cr;(function(s){s.save=async(t,e)=>{if(p(window.showSaveFilePicker)){let r=await window.showSaveFilePicker(e),n=await r.createWritable();return await n.truncate(0),await n.write(t),await n.close(),r.name??"unknown"}else{let r=new Blob([t]),n=URL.createObjectURL(r),i=document.createElement("a");return i.href=n,i.download=e?.suggestedName??"unknown",i.click(),URL.revokeObjectURL(n),e?.suggestedName??"Unknown"}},s.open=async t=>{if(p(window.showOpenFilePicker)){let{status:e,value:r,error:n}=await C.tryCatch(window.showOpenFilePicker(t));return e==="rejected"?Promise.reject(n):Promise.all(r.map(i=>i.getFile()))}else return new Promise((e,r)=>{p(t)&&console.warn("FileApi.showOpenFilePicker is emulated in this browser. OpenFilePickerOptions are ignored.");let n=document.createElement("input");n.type="file",n.multiple=t?.multiple??!1,n.style.display="none",n.addEventListener("cancel",async()=>{n.remove(),r(new DOMException("cancel","AbortError"))}),n.addEventListener("change",async i=>{let a=i.target.files;p(a)?e(g.create(c=>w(a.item(c),`No file at index ${c}`),a.length)):r(new DOMException("cancel","AbortError")),n.remove()}),document.body.appendChild(n),n.click()})}})(cr||(cr={}));var hr;(function(s){s.parse=t=>{let e=document.createElement("div");if(e.innerHTML=t,e.childElementCount!==1)return u(`Source html has more than one root elements: '${t}'`);let r=e.firstChild;return r instanceof HTMLElement||r instanceof SVGSVGElement?r:u(`Cannot parse to HTMLOrSVGElement from '${t}'`)},s.empty=t=>{for(;t.firstChild!==null;)t.firstChild.remove()},s.query=(t,e=document)=>w(e.querySelector(t)),s.queryAll=(t,e=document)=>Array.from(e.querySelectorAll(t)),s.sanitize=t=>{t.querySelectorAll("script").forEach(e=>e.remove()),t.querySelectorAll("*").forEach(e=>{[...e.attributes].forEach(r=>{r.name.toLowerCase().startsWith("on")&&e.removeAttribute(r.name)})})},s.nextID=(()=>{let t=0;return()=>(++t).toString(16).padStart(4,"0")})(),s.adoptStyleSheet=(t,e)=>{m(t.includes("component"),`No 'component' found in: ${t}`);let r=`${e??"C"}${s.nextID()}`,n=new CSSStyleSheet;return n.replaceSync(t.replaceAll("component",`.${r}`)),n.cssRules.length===0?u(`No cssRules found in: ${t}`):(document.adoptedStyleSheets.push(n),r)},s.buildClassList=(...t)=>t.filter(e=>e!==!1&&e!==void 0).join(" "),s.readCssVarColor=(...t)=>{let e=document.createElement("div");document.body.appendChild(e);let r=t.map(n=>(e.style.color=n,vt.parseCssRgbOrRgba(getComputedStyle(e).color)));return e.remove(),r},s.watchResize=(t,e,r)=>{let n=new ResizeObserver(([i],o)=>e(i,o));return n.observe(t,r),{terminate:()=>n.disconnect()}},s.watchIntersection=(t,e,r)=>{let n=new IntersectionObserver(e,r);return n.observe(t),{terminate:()=>n.disconnect()}},s.secureBoundingBox=t=>{let e=t.getBoundingClientRect();if(!gt.isEmpty(e))return e;for(let r of t.children)gt.union(e,s.secureBoundingBox(r));return e},s.unfocus=(t=self)=>{let e=t.document.activeElement;e!==null&&"blur"in e&&typeof e.blur=="function"&&e.blur()},s.selectContent=t=>{let e=document.createRange(),r=window.getSelection();p(r)&&(e.selectNodeContents(t),r.removeAllRanges(),r.addRange(e))},s.unselectContent=t=>{let e=window.getSelection();!p(e)||e.rangeCount===0||t.contains(e.getRangeAt(0).commonAncestorContainer)&&e.removeAllRanges()},s.limitChars=(t,e,r)=>{if(!(e in t))return u(`${e} not found in ${t}`);if(typeof t[e]!="string")return u(`${e} in ${t} is not a string`);if(t[e].length>r)if(t[e]=t[e].substring(0,r),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)t.setSelectionRange(r,r);else{let n=t.ownerDocument,i=n.createRange(),o=n.defaultView?.getSelection();if(!p(o))return;i.selectNodeContents(t),i.collapse(!1),o.removeAllRanges(),o.addRange(i)}},s.EmptyGif="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})(hr||(hr={}));var gc=(()=>{let s={Cmd:"\u2318",Opt:"\u2325",Shift:"\u21E7"},t={Cmd:"Ctrl",Opt:"Alt",Shift:"\u21E7"};return Object.freeze({Mac:s,Win:t,System:z.isMacOS()?s:t})})();var lr;(function(s){s.read=async t=>{let e=[];for(;;){let{done:o,value:a}=await t.read();if(o)break;e.push(a)}let r=e.reduce((o,a)=>o+a.length,0),n=new Uint8Array(r),i=0;for(let o of e)n.set(o,i),i+=o.length;return n.buffer}})(lr||(lr={}));var ur;(function(s){s.pathBuilder=()=>new class{#t="";moveTo(t,e){return this.#t+=`M${t.toFixed(3)} ${e.toFixed(3)}`,this}lineTo(t,e){return this.#t+=`L${t.toFixed(3)} ${e.toFixed(3)}`,this}quadratic(t,e,r,n){return this.#t+=`Q${t.toFixed(3)} ${e.toFixed(3)} ${r.toFixed(3)} ${n.toFixed(3)}`,this}quadraticTo(t,e){return this.#t+=`T${t.toFixed(3)} ${e.toFixed(3)}`,this}cubic(t,e,r,n,i,o){return this.#t+=`Q${t.toFixed(3)} ${e.toFixed(3)} ${r.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)} ${o.toFixed(3)}`,this}arc(t,e,r,n,i,o,a){return this.#t+=`A${t} ${e} ${r} ${n?1:0} ${i?1:0} ${o.toFixed(3)} ${a.toFixed(3)}`,this}circleSegment(t,e,r,n,i){let o=t+Math.cos(n)*r,a=e+Math.sin(n)*r,c=t+Math.cos(i)*r,h=e+Math.sin(i)*r,l=i-n;for(;l<0;)l+=Math.PI*2;return this.moveTo(o,a).arc(r,r,0,l>Math.PI,!0,c,h)}close(){return this.#t+="Z",this}get(){return this.#t}}})(ur||(ur={}));var fr;(function(s){let t=new Array;s.watchWeak=(r,n)=>{let i=new WeakRef(r),o=n(i);return t.push([i,o]),t.length===1&&e(),r};let e=()=>{console.debug("start weak watching");let r=setInterval(()=>{let n=t.length;for(;--n>=0;){let i=t[n];i[0].deref()===void 0&&(i[1].terminate(),t.splice(n,1),t.length===0&&clearInterval(r))}},1e3)}})(fr||(fr={}));var Pt=Symbol.for("@openDAW/lib-dom");globalThis[Pt]?console.debug(`%c${Pt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Pt]=!0,console.debug(`%c${Pt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Ct;(function(s){s[s.Float=0]="Float",s[s.FloatArray=1]="FloatArray",s[s.Integer=2]="Integer",s[s.IntegerArray=3]="IntegerArray",s[s.ByteArray=4]="ByteArray"})(Ct||(Ct={}));var Dt;(function(s){s[s.WRITE=0]="WRITE",s[s.READ=1]="READ"})(Dt||(Dt={}));var kt;(function(s){s[s.ID=15793935]="ID",s[s.START=15790320]="START",s[s.END=986895]="END"})(kt||(kt={}));var W;(function(s){class t{shift;numPeaks;dataOffset;constructor(r,n,i){this.shift=r,this.numPeaks=n,this.dataOffset=i}unitsEachPeak(){return 1<<this.shift}}s.Stage=t,s.unpack=(e,r)=>{switch(r){case 0:return j.intBitsToFloat(e);case 1:return j.intBitsToFloat(e>>16);default:return k(r)}}})(W||(W={}));var _t=class s{stages;data;numFrames;numChannels;static from(t){m(t.readString()==="PEAKS","Wrong header");let e=t.readInt(),r=[];for(let c=0;c<e;c++){let h=t.readInt(),l=t.readInt(),f=t.readInt();t.readInt(),r[c]=new W.Stage(f,l,h)}let n=t.readInt(),i=[];for(let c=0;c<n;c++){let h=new Int8Array(t.readInt());t.readBytes(h),i[c]=new Int32Array(h.buffer)}let o=t.readInt(),a=t.readInt();return new s(r,i,o,a)}static None=new s([],[],0,0);static findBestFit=(t,e=1200)=>{let r=t/e;if(r<=1)return new Uint8Array(0);let n=3,i=Math.floor(Math.log(r)/Math.LN2),o=Math.max(1,Math.floor(i/n));return new Uint8Array(g.create(a=>n*(a+1),o))};constructor(t,e,r,n){this.stages=t,this.data=e,this.numFrames=r,this.numChannels=n}nearest(t){if(this.stages.length===0)return null;let e=Math.floor(Math.log(Math.abs(t))/Math.LN2),r=this.stages.length;for(;--r>-1;)if(e>=this.stages[r].shift)return this.stages[r];return this.stages[0]}toArrayBuffer(){let t=v.create();t.writeString("PEAKS"),t.writeInt(this.stages.length);for(let e=0;e<this.stages.length;e++){let{dataOffset:r,numPeaks:n,shift:i}=this.stages[e];t.writeInt(r),t.writeInt(n),t.writeInt(i),t.writeInt((1<<i)-1)}t.writeInt(this.data.length);for(let e=0;e<this.data.length;e++){let r=new Int8Array(this.data[e].buffer);t.writeInt(r.length),t.writeBytes(r)}return t.writeInt(this.numFrames),t.writeInt(this.numChannels),t.toArrayBuffer()}toString(){return`{SamplePeaks num-stages: ${this.stages.length}}`}};var Ut;(function(s){s.install=r=>P.executor(r.channel("peaks"),new class{async generateAsync(n,i,o,a,c){return t(n,i,o,a,c).toArrayBuffer()}});let t=(r,n,i,o,a)=>{if(i.length!==a)return u(`Invalid numberOfChannels. Expected: ${a}. Got ${i.length}`);class c{min=Number.POSITIVE_INFINITY;max=Number.NEGATIVE_INFINITY;index=0}let h=Ge(),l=n.length,[f,E]=e(n,o),R=g.create(()=>new Int32Array(E),a),bt=(1<<f[0].shift)-1,zt=a*o,Et=0;for(let K=0;K<a;++K){let ft=R[K],dt=i[K],Y=g.create(()=>new c,l),V=Number.POSITIVE_INFINITY,tt=Number.NEGATIVE_INFINITY,et=0;for(let rt=0;rt<o;++rt){let pt=dt[rt];if(V=Math.min(pt,V),tt=Math.max(pt,tt),(++et&bt)===0){for(let H=0;H<l;++H){let mt=f[H],M=Y[H];M.min=Math.min(M.min,V),M.max=Math.max(M.max,tt),((1<<mt.shift)-1&et)===0&&(ft[mt.dataOffset+M.index++]=s.pack(M.min,M.max),M.min=Number.POSITIVE_INFINITY,M.max=Number.NEGATIVE_INFINITY)}V=Number.POSITIVE_INFINITY,tt=Number.NEGATIVE_INFINITY}(++Et&65535)===0&&r(Et/zt)}}return r(1),h.lab(`SamplePeaks '${self.constructor.name}'`),new _t(f,R,o,a)},e=(r,n)=>{let i=0;return[g.create(a=>{let c=r[a],h=Math.ceil(n/(1<<c)),l=new W.Stage(c,h,i);return i+=h,l},r.length),i]};s.pack=(r,n)=>{let i=j.floatToIntBits(r),o=j.floatToIntBits(n);return i|o<<16}})(Ut||(Ut={}));var dr;(function(s){s.renderBlocks=(t,e,r,{u0:n,u1:i,v0:o,v1:a,x0:c,x1:h,y0:l,y1:f})=>{let E=(i-n)/(h-c),R=e.nearest(E);if(R===null)return;let bt=(f-l-1)/(a-o),zt=R.unitsEachPeak(),Et=c-Math.floor(c),K=E/zt,ft=(n-Et*E)/E*K,dt=Math.floor(ft),Y=0,V=0,tt=e.data[r];for(let et=Math.floor(c);et<Math.floor(h);et++){let rt=ft+K,pt=Math.floor(rt),H=!1;for(;dt<pt;){let At=tt[R.dataOffset+dt++];Y=Math.min(W.unpack(At,0),Y),V=Math.max(W.unpack(At,1),V),H=!0}let mt=l+Math.floor((Y-o)*bt),M=l+Math.floor((V-o)*bt),qt=Math.max(l,Math.min(mt,M)),xe=Math.min(f,Math.max(mt,M));if(t.fillRect(et,qt,1,xe===qt?1:xe-qt),H){let At=V;V=Y,Y=At}ft=rt,dt=pt}}})(dr||(dr={}));var Kt;(function(s){let e=new C.Limit(1),r=new C.Limit(1);s.init=i=>P.executor(i.channel("opfs"),new class{async write(o,a){return r.add(()=>this.#t(o,{create:!0}).then(c=>{c.truncate(a.length),c.write(a.buffer,{at:0}),c.flush(),c.close()}))}async read(o){return e.add(()=>this.#t(o).then(a=>{let c=a.getSize(),h=new Uint8Array(c);return a.read(h),a.close(),h}))}async delete(o){let a=n(o);return this.#e(a.slice(0,-1)).then(c=>c.removeEntry(w(a.at(-1)),{recursive:!0}))}async list(o){let a=n(o),{status:c,value:h}=await C.tryCatch(this.#e(a));if(c==="rejected")return g.empty();let l=[];for await(let{name:f,kind:E}of h.values())l.push({name:f,kind:E});return l}async#t(o,a){let c=n(o);return this.#e(c.slice(0,-1),a).then(h=>h.getFileHandle(w(c.at(-1)),a).then(l=>l.createSyncAccessHandle()))}async#e(o,a){let c=await navigator.storage.getDirectory();for(let h of o)c=await c.getDirectoryHandle(h,a);return c}});let n=i=>{let o=i.replace(/^\/+|\/+$/g,"");return o===""?[]:o.split("/")}})(Kt||(Kt={}));var jt=Symbol.for("@openDAW/lib-fusion");globalThis[jt]?console.debug(`%c${jt.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[jt]=!0,console.debug(`%c${jt.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var pr=Ye.for(self);Kt.init(pr);Ut.install(pr);
4
4
  //# sourceMappingURL=workers.js.map