@audiotool/nexus 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,17 +4,17 @@ var Qt = (i) => {
4
4
  };
5
5
  var _t = (i, e, t) => e in i ? Zt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
6
  var r = (i, e, t) => _t(i, typeof e != "symbol" ? e + "" : e, t), Wt = (i, e, t) => e.has(i) || Qt("Cannot " + t);
7
- var s = (i, e, t) => (Wt(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? Qt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), h = (i, e, t, n) => (Wt(i, e, "write to private field"), n ? n.call(i, t) : e.set(i, t), t), y = (i, e, t) => (Wt(i, e, "access private method"), t);
8
- import { aS as entityMessageToTypeKey, aT as mustUnpackEntity, aU as packEntity, aV as getEntityTypeKeyFromProtoName, aW as unpackEntity, aX as Preset, aY as anyEntityToTypeKey, aZ as createRetryingPromiseClient, a_ as createAuthorizedKeepaliveTransport, aR as createAudiotoolAPI, a$ as extractUuid, n as neverThrowingFetch } from "./audiotool-api-BeiEe46q.js";
7
+ var s = (i, e, t) => (Wt(i, e, "read from private field"), t ? t.call(i) : e.get(i)), p = (i, e, t) => e.has(i) ? Qt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), h = (i, e, t, n) => (Wt(i, e, "write to private field"), n ? n.call(i, t) : e.set(i, t), t), g = (i, e, t) => (Wt(i, e, "access private method"), t);
8
+ import { aS as entityMessageToTypeKey, aT as mustUnpackEntity, aU as packEntity, aV as getEntityTypeKeyFromProtoName, aW as unpackEntity, aX as Preset, aY as anyEntityToTypeKey, aZ as createRetryingPromiseClient, a_ as createAuthorizedKeepaliveTransport, aR as createAudiotoolAPI, a$ as extractUuid, n as neverThrowingFetch } from "./audiotool-api-o8DnCQiu.js";
9
9
  import { Message, proto3, Any, protoInt64, ScalarType, MethodKind } from "@bufbuild/protobuf";
10
10
  import { P as Pointer, E as Empty, e as entityMessageTypes } from "./types-Cztu157p.js";
11
- import { t as throw_, a as assert, s as sleep } from "./lang-KJQpoj7q.js";
11
+ import { t as throw_, a as assert, b as asyncInterval, s as sleep } from "./lang-BqPY1uAS.js";
12
12
  import { h as hashSymbol, H as HashMap, V as ValueNotifier, N as Notifier, A as AsyncLock } from "./observable-notifier-value-pw47I_2-.js";
13
13
  import { v5 } from "uuid";
14
- import { s as schemaLocationToSchemaPath, a as schemaPathToSchemaLocation, g as getSchemaLocationDetails, _ as _getSchemaLocatorDetails } from "./get-schema-location-details-BSMUliFD.js";
14
+ import { s as schemaLocationToSchemaPath, a as schemaPathToSchemaLocation, g as getSchemaLocationDetails, _ as _getSchemaLocatorDetails } from "./get-schema-location-details-D2lXBgbu.js";
15
15
  import toposort from "toposort";
16
16
  import { ConnectError, Code } from "@connectrpc/connect";
17
- const I = class I extends Message {
17
+ const F = class F extends Message {
18
18
  constructor(t) {
19
19
  super();
20
20
  /**
@@ -34,19 +34,19 @@ const I = class I extends Message {
34
34
  proto3.util.initPartial(t, this);
35
35
  }
36
36
  static fromBinary(t, n) {
37
- return new I().fromBinary(t, n);
37
+ return new F().fromBinary(t, n);
38
38
  }
39
39
  static fromJson(t, n) {
40
- return new I().fromJson(t, n);
40
+ return new F().fromJson(t, n);
41
41
  }
42
42
  static fromJsonString(t, n) {
43
- return new I().fromJsonString(t, n);
43
+ return new F().fromJsonString(t, n);
44
44
  }
45
45
  static equals(t, n) {
46
- return proto3.util.equals(I, t, n);
46
+ return proto3.util.equals(F, t, n);
47
47
  }
48
48
  };
49
- r(I, "runtime", proto3), r(I, "typeName", "audiotool.document.v1.AttachMetadataRequest"), r(I, "fields", proto3.util.newFieldList(() => [
49
+ r(F, "runtime", proto3), r(F, "typeName", "audiotool.document.v1.AttachMetadataRequest"), r(F, "fields", proto3.util.newFieldList(() => [
50
50
  {
51
51
  no: 1,
52
52
  name: "project_name",
@@ -62,8 +62,8 @@ r(I, "runtime", proto3), r(I, "typeName", "audiotool.document.v1.AttachMetadataR
62
62
  /* ScalarType.STRING */
63
63
  }
64
64
  ]));
65
- let AttachMetadataRequest = I;
66
- const N = class N extends Message {
65
+ let AttachMetadataRequest = F;
66
+ const J = class J extends Message {
67
67
  constructor(t) {
68
68
  super();
69
69
  /**
@@ -88,19 +88,19 @@ const N = class N extends Message {
88
88
  proto3.util.initPartial(t, this);
89
89
  }
90
90
  static fromBinary(t, n) {
91
- return new N().fromBinary(t, n);
91
+ return new J().fromBinary(t, n);
92
92
  }
93
93
  static fromJson(t, n) {
94
- return new N().fromJson(t, n);
94
+ return new J().fromJson(t, n);
95
95
  }
96
96
  static fromJsonString(t, n) {
97
- return new N().fromJsonString(t, n);
97
+ return new J().fromJsonString(t, n);
98
98
  }
99
99
  static equals(t, n) {
100
- return proto3.util.equals(N, t, n);
100
+ return proto3.util.equals(J, t, n);
101
101
  }
102
102
  };
103
- r(N, "runtime", proto3), r(N, "typeName", "audiotool.document.v1.AttachMetadataResponse"), r(N, "fields", proto3.util.newFieldList(() => [
103
+ r(J, "runtime", proto3), r(J, "typeName", "audiotool.document.v1.AttachMetadataResponse"), r(J, "fields", proto3.util.newFieldList(() => [
104
104
  {
105
105
  no: 1,
106
106
  name: "source_name",
@@ -117,8 +117,8 @@ r(N, "runtime", proto3), r(N, "typeName", "audiotool.document.v1.AttachMetadataR
117
117
  },
118
118
  { no: 3, name: "client_coordinates", kind: "message", T: ClientCoordinates }
119
119
  ]));
120
- let AttachMetadataResponse = N;
121
- const F = class F extends Message {
120
+ let AttachMetadataResponse = J;
121
+ const C = class C extends Message {
122
122
  constructor(t) {
123
123
  super();
124
124
  /**
@@ -144,19 +144,19 @@ const F = class F extends Message {
144
144
  proto3.util.initPartial(t, this);
145
145
  }
146
146
  static fromBinary(t, n) {
147
- return new F().fromBinary(t, n);
147
+ return new C().fromBinary(t, n);
148
148
  }
149
149
  static fromJson(t, n) {
150
- return new F().fromJson(t, n);
150
+ return new C().fromJson(t, n);
151
151
  }
152
152
  static fromJsonString(t, n) {
153
- return new F().fromJsonString(t, n);
153
+ return new C().fromJsonString(t, n);
154
154
  }
155
155
  static equals(t, n) {
156
- return proto3.util.equals(F, t, n);
156
+ return proto3.util.equals(C, t, n);
157
157
  }
158
158
  };
159
- r(F, "runtime", proto3), r(F, "typeName", "audiotool.document.v1.PutMetadataRequest"), r(F, "fields", proto3.util.newFieldList(() => [
159
+ r(C, "runtime", proto3), r(C, "typeName", "audiotool.document.v1.PutMetadataRequest"), r(C, "fields", proto3.util.newFieldList(() => [
160
160
  {
161
161
  no: 1,
162
162
  name: "project_name",
@@ -173,27 +173,27 @@ r(F, "runtime", proto3), r(F, "typeName", "audiotool.document.v1.PutMetadataRequ
173
173
  },
174
174
  { no: 3, name: "client_coordinates", kind: "message", T: ClientCoordinates }
175
175
  ]));
176
- let PutMetadataRequest = F;
177
- const J = class J extends Message {
176
+ let PutMetadataRequest = C;
177
+ const L = class L extends Message {
178
178
  constructor(e) {
179
179
  super(), proto3.util.initPartial(e, this);
180
180
  }
181
181
  static fromBinary(e, t) {
182
- return new J().fromBinary(e, t);
182
+ return new L().fromBinary(e, t);
183
183
  }
184
184
  static fromJson(e, t) {
185
- return new J().fromJson(e, t);
185
+ return new L().fromJson(e, t);
186
186
  }
187
187
  static fromJsonString(e, t) {
188
- return new J().fromJsonString(e, t);
188
+ return new L().fromJsonString(e, t);
189
189
  }
190
190
  static equals(e, t) {
191
- return proto3.util.equals(J, e, t);
191
+ return proto3.util.equals(L, e, t);
192
192
  }
193
193
  };
194
- r(J, "runtime", proto3), r(J, "typeName", "audiotool.document.v1.PutMetadataResponse"), r(J, "fields", proto3.util.newFieldList(() => []));
195
- let PutMetadataResponse = J;
196
- const C = class C extends Message {
194
+ r(L, "runtime", proto3), r(L, "typeName", "audiotool.document.v1.PutMetadataResponse"), r(L, "fields", proto3.util.newFieldList(() => []));
195
+ let PutMetadataResponse = L;
196
+ const U = class U extends Message {
197
197
  constructor(t) {
198
198
  super();
199
199
  /**
@@ -251,19 +251,19 @@ const C = class C extends Message {
251
251
  proto3.util.initPartial(t, this);
252
252
  }
253
253
  static fromBinary(t, n) {
254
- return new C().fromBinary(t, n);
254
+ return new U().fromBinary(t, n);
255
255
  }
256
256
  static fromJson(t, n) {
257
- return new C().fromJson(t, n);
257
+ return new U().fromJson(t, n);
258
258
  }
259
259
  static fromJsonString(t, n) {
260
- return new C().fromJsonString(t, n);
260
+ return new U().fromJsonString(t, n);
261
261
  }
262
262
  static equals(t, n) {
263
- return proto3.util.equals(C, t, n);
263
+ return proto3.util.equals(U, t, n);
264
264
  }
265
265
  };
266
- r(C, "runtime", proto3), r(C, "typeName", "audiotool.document.v1.ClientCoordinates"), r(C, "fields", proto3.util.newFieldList(() => [
266
+ r(U, "runtime", proto3), r(U, "typeName", "audiotool.document.v1.ClientCoordinates"), r(U, "fields", proto3.util.newFieldList(() => [
267
267
  {
268
268
  no: 1,
269
269
  name: "x",
@@ -314,8 +314,8 @@ r(C, "runtime", proto3), r(C, "typeName", "audiotool.document.v1.ClientCoordinat
314
314
  /* ScalarType.DOUBLE */
315
315
  }
316
316
  ]));
317
- let ClientCoordinates = C;
318
- const U = class U extends Message {
317
+ let ClientCoordinates = U;
318
+ const B = class B extends Message {
319
319
  constructor(t) {
320
320
  super();
321
321
  /**
@@ -333,19 +333,19 @@ const U = class U extends Message {
333
333
  proto3.util.initPartial(t, this);
334
334
  }
335
335
  static fromBinary(t, n) {
336
- return new U().fromBinary(t, n);
336
+ return new B().fromBinary(t, n);
337
337
  }
338
338
  static fromJson(t, n) {
339
- return new U().fromJson(t, n);
339
+ return new B().fromJson(t, n);
340
340
  }
341
341
  static fromJsonString(t, n) {
342
- return new U().fromJsonString(t, n);
342
+ return new B().fromJsonString(t, n);
343
343
  }
344
344
  static equals(t, n) {
345
- return proto3.util.equals(U, t, n);
345
+ return proto3.util.equals(B, t, n);
346
346
  }
347
347
  };
348
- r(U, "runtime", proto3), r(U, "typeName", "audiotool.document.v1.GetEntitiesRequest"), r(U, "fields", proto3.util.newFieldList(() => [
348
+ r(B, "runtime", proto3), r(B, "typeName", "audiotool.document.v1.GetEntitiesRequest"), r(B, "fields", proto3.util.newFieldList(() => [
349
349
  {
350
350
  no: 1,
351
351
  name: "project_name",
@@ -361,8 +361,8 @@ r(U, "runtime", proto3), r(U, "typeName", "audiotool.document.v1.GetEntitiesRequ
361
361
  /* ScalarType.STRING */
362
362
  }
363
363
  ]));
364
- let GetEntitiesRequest = U;
365
- const L = class L extends Message {
364
+ let GetEntitiesRequest = B;
365
+ const A = class A extends Message {
366
366
  constructor(t) {
367
367
  super();
368
368
  /**
@@ -375,23 +375,23 @@ const L = class L extends Message {
375
375
  proto3.util.initPartial(t, this);
376
376
  }
377
377
  static fromBinary(t, n) {
378
- return new L().fromBinary(t, n);
378
+ return new A().fromBinary(t, n);
379
379
  }
380
380
  static fromJson(t, n) {
381
- return new L().fromJson(t, n);
381
+ return new A().fromJson(t, n);
382
382
  }
383
383
  static fromJsonString(t, n) {
384
- return new L().fromJsonString(t, n);
384
+ return new A().fromJsonString(t, n);
385
385
  }
386
386
  static equals(t, n) {
387
- return proto3.util.equals(L, t, n);
387
+ return proto3.util.equals(A, t, n);
388
388
  }
389
389
  };
390
- r(L, "runtime", proto3), r(L, "typeName", "audiotool.document.v1.GetEntitiesResponse"), r(L, "fields", proto3.util.newFieldList(() => [
390
+ r(A, "runtime", proto3), r(A, "typeName", "audiotool.document.v1.GetEntitiesResponse"), r(A, "fields", proto3.util.newFieldList(() => [
391
391
  { no: 1, name: "entities", kind: "message", T: Any, repeated: !0 }
392
392
  ]));
393
- let GetEntitiesResponse = L;
394
- const B = class B extends Message {
393
+ let GetEntitiesResponse = A;
394
+ const D = class D extends Message {
395
395
  constructor(t) {
396
396
  super();
397
397
  /**
@@ -420,19 +420,19 @@ const B = class B extends Message {
420
420
  proto3.util.initPartial(t, this);
421
421
  }
422
422
  static fromBinary(t, n) {
423
- return new B().fromBinary(t, n);
423
+ return new D().fromBinary(t, n);
424
424
  }
425
425
  static fromJson(t, n) {
426
- return new B().fromJson(t, n);
426
+ return new D().fromJson(t, n);
427
427
  }
428
428
  static fromJsonString(t, n) {
429
- return new B().fromJsonString(t, n);
429
+ return new D().fromJsonString(t, n);
430
430
  }
431
431
  static equals(t, n) {
432
- return proto3.util.equals(B, t, n);
432
+ return proto3.util.equals(D, t, n);
433
433
  }
434
434
  };
435
- r(B, "runtime", proto3), r(B, "typeName", "audiotool.document.v1.AttachRequest"), r(B, "fields", proto3.util.newFieldList(() => [
435
+ r(D, "runtime", proto3), r(D, "typeName", "audiotool.document.v1.AttachRequest"), r(D, "fields", proto3.util.newFieldList(() => [
436
436
  {
437
437
  no: 1,
438
438
  name: "project_name",
@@ -448,8 +448,8 @@ r(B, "runtime", proto3), r(B, "typeName", "audiotool.document.v1.AttachRequest")
448
448
  /* ScalarType.UINT32 */
449
449
  }
450
450
  ]));
451
- let AttachRequest = B;
452
- const A = class A extends Message {
451
+ let AttachRequest = D;
452
+ const O = class O extends Message {
453
453
  constructor(t) {
454
454
  super();
455
455
  /**
@@ -461,24 +461,24 @@ const A = class A extends Message {
461
461
  proto3.util.initPartial(t, this);
462
462
  }
463
463
  static fromBinary(t, n) {
464
- return new A().fromBinary(t, n);
464
+ return new O().fromBinary(t, n);
465
465
  }
466
466
  static fromJson(t, n) {
467
- return new A().fromJson(t, n);
467
+ return new O().fromJson(t, n);
468
468
  }
469
469
  static fromJsonString(t, n) {
470
- return new A().fromJsonString(t, n);
470
+ return new O().fromJsonString(t, n);
471
471
  }
472
472
  static equals(t, n) {
473
- return proto3.util.equals(A, t, n);
473
+ return proto3.util.equals(O, t, n);
474
474
  }
475
475
  };
476
- r(A, "runtime", proto3), r(A, "typeName", "audiotool.document.v1.AttachResponse"), r(A, "fields", proto3.util.newFieldList(() => [
476
+ r(O, "runtime", proto3), r(O, "typeName", "audiotool.document.v1.AttachResponse"), r(O, "fields", proto3.util.newFieldList(() => [
477
477
  { no: 1, name: "transaction", kind: "message", T: Transaction, oneof: "message" },
478
478
  { no: 2, name: "noop", kind: "message", T: Noop, oneof: "message" }
479
479
  ]));
480
- let AttachResponse = A;
481
- const D = class D extends Message {
480
+ let AttachResponse = O;
481
+ const q = class q extends Message {
482
482
  constructor(t) {
483
483
  super();
484
484
  /**
@@ -490,19 +490,19 @@ const D = class D extends Message {
490
490
  proto3.util.initPartial(t, this);
491
491
  }
492
492
  static fromBinary(t, n) {
493
- return new D().fromBinary(t, n);
493
+ return new q().fromBinary(t, n);
494
494
  }
495
495
  static fromJson(t, n) {
496
- return new D().fromJson(t, n);
496
+ return new q().fromJson(t, n);
497
497
  }
498
498
  static fromJsonString(t, n) {
499
- return new D().fromJsonString(t, n);
499
+ return new q().fromJsonString(t, n);
500
500
  }
501
501
  static equals(t, n) {
502
- return proto3.util.equals(D, t, n);
502
+ return proto3.util.equals(q, t, n);
503
503
  }
504
504
  };
505
- r(D, "runtime", proto3), r(D, "typeName", "audiotool.document.v1.Noop"), r(D, "fields", proto3.util.newFieldList(() => [
505
+ r(q, "runtime", proto3), r(q, "typeName", "audiotool.document.v1.Noop"), r(q, "fields", proto3.util.newFieldList(() => [
506
506
  {
507
507
  no: 1,
508
508
  name: "server_commit_index",
@@ -511,8 +511,8 @@ r(D, "runtime", proto3), r(D, "typeName", "audiotool.document.v1.Noop"), r(D, "f
511
511
  /* ScalarType.UINT32 */
512
512
  }
513
513
  ]));
514
- let Noop = D;
515
- const O = class O extends Message {
514
+ let Noop = q;
515
+ const j = class j extends Message {
516
516
  constructor(t) {
517
517
  super();
518
518
  /**
@@ -525,24 +525,24 @@ const O = class O extends Message {
525
525
  proto3.util.initPartial(t, this);
526
526
  }
527
527
  static fromBinary(t, n) {
528
- return new O().fromBinary(t, n);
528
+ return new j().fromBinary(t, n);
529
529
  }
530
530
  static fromJson(t, n) {
531
- return new O().fromJson(t, n);
531
+ return new j().fromJson(t, n);
532
532
  }
533
533
  static fromJsonString(t, n) {
534
- return new O().fromJsonString(t, n);
534
+ return new j().fromJsonString(t, n);
535
535
  }
536
536
  static equals(t, n) {
537
- return proto3.util.equals(O, t, n);
537
+ return proto3.util.equals(j, t, n);
538
538
  }
539
539
  };
540
- r(O, "runtime", proto3), r(O, "typeName", "audiotool.document.v1.ModifyRequest"), r(O, "fields", proto3.util.newFieldList(() => [
540
+ r(j, "runtime", proto3), r(j, "typeName", "audiotool.document.v1.ModifyRequest"), r(j, "fields", proto3.util.newFieldList(() => [
541
541
  { no: 1, name: "project_name", kind: "scalar", T: 9, oneof: "message" },
542
542
  { no: 2, name: "transaction", kind: "message", T: Transaction, oneof: "message" }
543
543
  ]));
544
- let ModifyRequest = O;
545
- const q = class q extends Message {
544
+ let ModifyRequest = j;
545
+ const R = class R extends Message {
546
546
  constructor(t) {
547
547
  super();
548
548
  /**
@@ -555,19 +555,19 @@ const q = class q extends Message {
555
555
  proto3.util.initPartial(t, this);
556
556
  }
557
557
  static fromBinary(t, n) {
558
- return new q().fromBinary(t, n);
558
+ return new R().fromBinary(t, n);
559
559
  }
560
560
  static fromJson(t, n) {
561
- return new q().fromJson(t, n);
561
+ return new R().fromJson(t, n);
562
562
  }
563
563
  static fromJsonString(t, n) {
564
- return new q().fromJsonString(t, n);
564
+ return new R().fromJsonString(t, n);
565
565
  }
566
566
  static equals(t, n) {
567
- return proto3.util.equals(q, t, n);
567
+ return proto3.util.equals(R, t, n);
568
568
  }
569
569
  };
570
- r(q, "runtime", proto3), r(q, "typeName", "audiotool.document.v1.ModifyResponse"), r(q, "fields", proto3.util.newFieldList(() => [
570
+ r(R, "runtime", proto3), r(R, "typeName", "audiotool.document.v1.ModifyResponse"), r(R, "fields", proto3.util.newFieldList(() => [
571
571
  {
572
572
  no: 1,
573
573
  name: "error",
@@ -576,8 +576,8 @@ r(q, "runtime", proto3), r(q, "typeName", "audiotool.document.v1.ModifyResponse"
576
576
  /* ScalarType.STRING */
577
577
  }
578
578
  ]));
579
- let ModifyResponse = q;
580
- const j = class j extends Message {
579
+ let ModifyResponse = R;
580
+ const $ = class $ extends Message {
581
581
  constructor(t) {
582
582
  super();
583
583
  /**
@@ -595,19 +595,19 @@ const j = class j extends Message {
595
595
  proto3.util.initPartial(t, this);
596
596
  }
597
597
  static fromBinary(t, n) {
598
- return new j().fromBinary(t, n);
598
+ return new $().fromBinary(t, n);
599
599
  }
600
600
  static fromJson(t, n) {
601
- return new j().fromJson(t, n);
601
+ return new $().fromJson(t, n);
602
602
  }
603
603
  static fromJsonString(t, n) {
604
- return new j().fromJsonString(t, n);
604
+ return new $().fromJsonString(t, n);
605
605
  }
606
606
  static equals(t, n) {
607
- return proto3.util.equals(j, t, n);
607
+ return proto3.util.equals($, t, n);
608
608
  }
609
609
  };
610
- r(j, "runtime", proto3), r(j, "typeName", "audiotool.document.v1.ApplyTransactionsRequest"), r(j, "fields", proto3.util.newFieldList(() => [
610
+ r($, "runtime", proto3), r($, "typeName", "audiotool.document.v1.ApplyTransactionsRequest"), r($, "fields", proto3.util.newFieldList(() => [
611
611
  {
612
612
  no: 1,
613
613
  name: "project_name",
@@ -617,8 +617,8 @@ r(j, "runtime", proto3), r(j, "typeName", "audiotool.document.v1.ApplyTransactio
617
617
  },
618
618
  { no: 2, name: "transactions", kind: "message", T: Transaction, repeated: !0 }
619
619
  ]));
620
- let ApplyTransactionsRequest = j;
621
- const R = class R extends Message {
620
+ let ApplyTransactionsRequest = $;
621
+ const V = class V extends Message {
622
622
  constructor(t) {
623
623
  super();
624
624
  /**
@@ -630,27 +630,27 @@ const R = class R extends Message {
630
630
  proto3.util.initPartial(t, this);
631
631
  }
632
632
  static fromBinary(t, n) {
633
- return new R().fromBinary(t, n);
633
+ return new V().fromBinary(t, n);
634
634
  }
635
635
  static fromJson(t, n) {
636
- return new R().fromJson(t, n);
636
+ return new V().fromJson(t, n);
637
637
  }
638
638
  static fromJsonString(t, n) {
639
- return new R().fromJsonString(t, n);
639
+ return new V().fromJsonString(t, n);
640
640
  }
641
641
  static equals(t, n) {
642
- return proto3.util.equals(R, t, n);
642
+ return proto3.util.equals(V, t, n);
643
643
  }
644
644
  };
645
- r(R, "runtime", proto3), r(R, "typeName", "audiotool.document.v1.ApplyTransactionsResponse"), r(R, "fields", proto3.util.newFieldList(() => [
645
+ r(V, "runtime", proto3), r(V, "typeName", "audiotool.document.v1.ApplyTransactionsResponse"), r(V, "fields", proto3.util.newFieldList(() => [
646
646
  { no: 1, name: "errors", kind: "map", K: 9, V: {
647
647
  kind: "scalar",
648
648
  T: 9
649
649
  /* ScalarType.STRING */
650
650
  } }
651
651
  ]));
652
- let ApplyTransactionsResponse = R;
653
- const $ = class $ extends Message {
652
+ let ApplyTransactionsResponse = V;
653
+ const W = class W extends Message {
654
654
  constructor(t) {
655
655
  super();
656
656
  /**
@@ -676,19 +676,19 @@ const $ = class $ extends Message {
676
676
  proto3.util.initPartial(t, this);
677
677
  }
678
678
  static fromBinary(t, n) {
679
- return new $().fromBinary(t, n);
679
+ return new W().fromBinary(t, n);
680
680
  }
681
681
  static fromJson(t, n) {
682
- return new $().fromJson(t, n);
682
+ return new W().fromJson(t, n);
683
683
  }
684
684
  static fromJsonString(t, n) {
685
- return new $().fromJsonString(t, n);
685
+ return new W().fromJsonString(t, n);
686
686
  }
687
687
  static equals(t, n) {
688
- return proto3.util.equals($, t, n);
688
+ return proto3.util.equals(W, t, n);
689
689
  }
690
690
  };
691
- r($, "runtime", proto3), r($, "typeName", "audiotool.document.v1.Transaction"), r($, "fields", proto3.util.newFieldList(() => [
691
+ r(W, "runtime", proto3), r(W, "typeName", "audiotool.document.v1.Transaction"), r(W, "fields", proto3.util.newFieldList(() => [
692
692
  {
693
693
  no: 1,
694
694
  name: "id",
@@ -705,8 +705,8 @@ r($, "runtime", proto3), r($, "typeName", "audiotool.document.v1.Transaction"),
705
705
  },
706
706
  { no: 3, name: "modifications", kind: "message", T: Modification, repeated: !0 }
707
707
  ]));
708
- let Transaction = $;
709
- const V = class V extends Message {
708
+ let Transaction = W;
709
+ const G = class G extends Message {
710
710
  constructor(t) {
711
711
  super();
712
712
  /**
@@ -718,25 +718,25 @@ const V = class V extends Message {
718
718
  proto3.util.initPartial(t, this);
719
719
  }
720
720
  static fromBinary(t, n) {
721
- return new V().fromBinary(t, n);
721
+ return new G().fromBinary(t, n);
722
722
  }
723
723
  static fromJson(t, n) {
724
- return new V().fromJson(t, n);
724
+ return new G().fromJson(t, n);
725
725
  }
726
726
  static fromJsonString(t, n) {
727
- return new V().fromJsonString(t, n);
727
+ return new G().fromJsonString(t, n);
728
728
  }
729
729
  static equals(t, n) {
730
- return proto3.util.equals(V, t, n);
730
+ return proto3.util.equals(G, t, n);
731
731
  }
732
732
  };
733
- r(V, "runtime", proto3), r(V, "typeName", "audiotool.document.v1.Modification"), r(V, "fields", proto3.util.newFieldList(() => [
733
+ r(G, "runtime", proto3), r(G, "typeName", "audiotool.document.v1.Modification"), r(G, "fields", proto3.util.newFieldList(() => [
734
734
  { no: 2, name: "create", kind: "message", T: Create, oneof: "modification" },
735
735
  { no: 3, name: "delete", kind: "message", T: Delete, oneof: "modification" },
736
736
  { no: 4, name: "update", kind: "message", T: Update, oneof: "modification" }
737
737
  ]));
738
- let Modification = V;
739
- const W = class W extends Message {
738
+ let Modification = G;
739
+ const z = class z extends Message {
740
740
  constructor(t) {
741
741
  super();
742
742
  /**
@@ -748,23 +748,23 @@ const W = class W extends Message {
748
748
  proto3.util.initPartial(t, this);
749
749
  }
750
750
  static fromBinary(t, n) {
751
- return new W().fromBinary(t, n);
751
+ return new z().fromBinary(t, n);
752
752
  }
753
753
  static fromJson(t, n) {
754
- return new W().fromJson(t, n);
754
+ return new z().fromJson(t, n);
755
755
  }
756
756
  static fromJsonString(t, n) {
757
- return new W().fromJsonString(t, n);
757
+ return new z().fromJsonString(t, n);
758
758
  }
759
759
  static equals(t, n) {
760
- return proto3.util.equals(W, t, n);
760
+ return proto3.util.equals(z, t, n);
761
761
  }
762
762
  };
763
- r(W, "runtime", proto3), r(W, "typeName", "audiotool.document.v1.Create"), r(W, "fields", proto3.util.newFieldList(() => [
763
+ r(z, "runtime", proto3), r(z, "typeName", "audiotool.document.v1.Create"), r(z, "fields", proto3.util.newFieldList(() => [
764
764
  { no: 1, name: "entity", kind: "message", T: Any }
765
765
  ]));
766
- let Create = W;
767
- const G = class G extends Message {
766
+ let Create = z;
767
+ const K = class K extends Message {
768
768
  constructor(t) {
769
769
  super();
770
770
  /**
@@ -782,19 +782,19 @@ const G = class G extends Message {
782
782
  proto3.util.initPartial(t, this);
783
783
  }
784
784
  static fromBinary(t, n) {
785
- return new G().fromBinary(t, n);
785
+ return new K().fromBinary(t, n);
786
786
  }
787
787
  static fromJson(t, n) {
788
- return new G().fromJson(t, n);
788
+ return new K().fromJson(t, n);
789
789
  }
790
790
  static fromJsonString(t, n) {
791
- return new G().fromJsonString(t, n);
791
+ return new K().fromJsonString(t, n);
792
792
  }
793
793
  static equals(t, n) {
794
- return proto3.util.equals(G, t, n);
794
+ return proto3.util.equals(K, t, n);
795
795
  }
796
796
  };
797
- r(G, "runtime", proto3), r(G, "typeName", "audiotool.document.v1.Update"), r(G, "fields", proto3.util.newFieldList(() => [
797
+ r(K, "runtime", proto3), r(K, "typeName", "audiotool.document.v1.Update"), r(K, "fields", proto3.util.newFieldList(() => [
798
798
  { no: 1, name: "field", kind: "message", T: Pointer },
799
799
  { no: 2, name: "double", kind: "scalar", T: 1, oneof: "value" },
800
800
  { no: 3, name: "float", kind: "scalar", T: 2, oneof: "value" },
@@ -813,8 +813,8 @@ r(G, "runtime", proto3), r(G, "typeName", "audiotool.document.v1.Update"), r(G,
813
813
  { no: 16, name: "bytes", kind: "scalar", T: 12, oneof: "value" },
814
814
  { no: 17, name: "pointer", kind: "message", T: Pointer, oneof: "value" }
815
815
  ]));
816
- let Update = G;
817
- const z = class z extends Message {
816
+ let Update = K;
817
+ const H = class H extends Message {
818
818
  constructor(t) {
819
819
  super();
820
820
  /**
@@ -826,19 +826,19 @@ const z = class z extends Message {
826
826
  proto3.util.initPartial(t, this);
827
827
  }
828
828
  static fromBinary(t, n) {
829
- return new z().fromBinary(t, n);
829
+ return new H().fromBinary(t, n);
830
830
  }
831
831
  static fromJson(t, n) {
832
- return new z().fromJson(t, n);
832
+ return new H().fromJson(t, n);
833
833
  }
834
834
  static fromJsonString(t, n) {
835
- return new z().fromJsonString(t, n);
835
+ return new H().fromJsonString(t, n);
836
836
  }
837
837
  static equals(t, n) {
838
- return proto3.util.equals(z, t, n);
838
+ return proto3.util.equals(H, t, n);
839
839
  }
840
840
  };
841
- r(z, "runtime", proto3), r(z, "typeName", "audiotool.document.v1.Delete"), r(z, "fields", proto3.util.newFieldList(() => [
841
+ r(H, "runtime", proto3), r(H, "typeName", "audiotool.document.v1.Delete"), r(H, "fields", proto3.util.newFieldList(() => [
842
842
  {
843
843
  no: 1,
844
844
  name: "entity_id",
@@ -847,27 +847,27 @@ r(z, "runtime", proto3), r(z, "typeName", "audiotool.document.v1.Delete"), r(z,
847
847
  /* ScalarType.STRING */
848
848
  }
849
849
  ]));
850
- let Delete = z;
851
- const K = class K extends Message {
850
+ let Delete = H;
851
+ const Q = class Q extends Message {
852
852
  constructor(e) {
853
853
  super(), proto3.util.initPartial(e, this);
854
854
  }
855
855
  static fromBinary(e, t) {
856
- return new K().fromBinary(e, t);
856
+ return new Q().fromBinary(e, t);
857
857
  }
858
858
  static fromJson(e, t) {
859
- return new K().fromJson(e, t);
859
+ return new Q().fromJson(e, t);
860
860
  }
861
861
  static fromJsonString(e, t) {
862
- return new K().fromJsonString(e, t);
862
+ return new Q().fromJsonString(e, t);
863
863
  }
864
864
  static equals(e, t) {
865
- return proto3.util.equals(K, e, t);
865
+ return proto3.util.equals(Q, e, t);
866
866
  }
867
867
  };
868
- r(K, "runtime", proto3), r(K, "typeName", "audiotool.document.v1.GetWasmRequest"), r(K, "fields", proto3.util.newFieldList(() => []));
869
- let GetWasmRequest = K;
870
- const H = class H extends Message {
868
+ r(Q, "runtime", proto3), r(Q, "typeName", "audiotool.document.v1.GetWasmRequest"), r(Q, "fields", proto3.util.newFieldList(() => []));
869
+ let GetWasmRequest = Q;
870
+ const X = class X extends Message {
871
871
  constructor(t) {
872
872
  super();
873
873
  /**
@@ -879,19 +879,19 @@ const H = class H extends Message {
879
879
  proto3.util.initPartial(t, this);
880
880
  }
881
881
  static fromBinary(t, n) {
882
- return new H().fromBinary(t, n);
882
+ return new X().fromBinary(t, n);
883
883
  }
884
884
  static fromJson(t, n) {
885
- return new H().fromJson(t, n);
885
+ return new X().fromJson(t, n);
886
886
  }
887
887
  static fromJsonString(t, n) {
888
- return new H().fromJsonString(t, n);
888
+ return new X().fromJsonString(t, n);
889
889
  }
890
890
  static equals(t, n) {
891
- return proto3.util.equals(H, t, n);
891
+ return proto3.util.equals(X, t, n);
892
892
  }
893
893
  };
894
- r(H, "runtime", proto3), r(H, "typeName", "audiotool.document.v1.GetWasmResponse"), r(H, "fields", proto3.util.newFieldList(() => [
894
+ r(X, "runtime", proto3), r(X, "typeName", "audiotool.document.v1.GetWasmResponse"), r(X, "fields", proto3.util.newFieldList(() => [
895
895
  {
896
896
  no: 1,
897
897
  name: "data",
@@ -900,27 +900,27 @@ r(H, "runtime", proto3), r(H, "typeName", "audiotool.document.v1.GetWasmResponse
900
900
  /* ScalarType.BYTES */
901
901
  }
902
902
  ]));
903
- let GetWasmResponse = H;
904
- const Q = class Q extends Message {
903
+ let GetWasmResponse = X;
904
+ const Y = class Y extends Message {
905
905
  constructor(e) {
906
906
  super(), proto3.util.initPartial(e, this);
907
907
  }
908
908
  static fromBinary(e, t) {
909
- return new Q().fromBinary(e, t);
909
+ return new Y().fromBinary(e, t);
910
910
  }
911
911
  static fromJson(e, t) {
912
- return new Q().fromJson(e, t);
912
+ return new Y().fromJson(e, t);
913
913
  }
914
914
  static fromJsonString(e, t) {
915
- return new Q().fromJsonString(e, t);
915
+ return new Y().fromJsonString(e, t);
916
916
  }
917
917
  static equals(e, t) {
918
- return proto3.util.equals(Q, e, t);
918
+ return proto3.util.equals(Y, e, t);
919
919
  }
920
920
  };
921
- r(Q, "runtime", proto3), r(Q, "typeName", "audiotool.document.v1.GetWasmExecRequest"), r(Q, "fields", proto3.util.newFieldList(() => []));
922
- let GetWasmExecRequest = Q;
923
- const X = class X extends Message {
921
+ r(Y, "runtime", proto3), r(Y, "typeName", "audiotool.document.v1.GetWasmExecRequest"), r(Y, "fields", proto3.util.newFieldList(() => []));
922
+ let GetWasmExecRequest = Y;
923
+ const Z = class Z extends Message {
924
924
  constructor(t) {
925
925
  super();
926
926
  /**
@@ -932,19 +932,19 @@ const X = class X extends Message {
932
932
  proto3.util.initPartial(t, this);
933
933
  }
934
934
  static fromBinary(t, n) {
935
- return new X().fromBinary(t, n);
935
+ return new Z().fromBinary(t, n);
936
936
  }
937
937
  static fromJson(t, n) {
938
- return new X().fromJson(t, n);
938
+ return new Z().fromJson(t, n);
939
939
  }
940
940
  static fromJsonString(t, n) {
941
- return new X().fromJsonString(t, n);
941
+ return new Z().fromJsonString(t, n);
942
942
  }
943
943
  static equals(t, n) {
944
- return proto3.util.equals(X, t, n);
944
+ return proto3.util.equals(Z, t, n);
945
945
  }
946
946
  };
947
- r(X, "runtime", proto3), r(X, "typeName", "audiotool.document.v1.GetWasmExecResponse"), r(X, "fields", proto3.util.newFieldList(() => [
947
+ r(Z, "runtime", proto3), r(Z, "typeName", "audiotool.document.v1.GetWasmExecResponse"), r(Z, "fields", proto3.util.newFieldList(() => [
948
948
  {
949
949
  no: 1,
950
950
  name: "data",
@@ -953,8 +953,8 @@ r(X, "runtime", proto3), r(X, "typeName", "audiotool.document.v1.GetWasmExecResp
953
953
  /* ScalarType.STRING */
954
954
  }
955
955
  ]));
956
- let GetWasmExecResponse = X;
957
- const Y = class Y extends Message {
956
+ let GetWasmExecResponse = Z;
957
+ const _ = class _ extends Message {
958
958
  constructor(t) {
959
959
  super();
960
960
  /**
@@ -979,19 +979,19 @@ const Y = class Y extends Message {
979
979
  proto3.util.initPartial(t, this);
980
980
  }
981
981
  static fromBinary(t, n) {
982
- return new Y().fromBinary(t, n);
982
+ return new _().fromBinary(t, n);
983
983
  }
984
984
  static fromJson(t, n) {
985
- return new Y().fromJson(t, n);
985
+ return new _().fromJson(t, n);
986
986
  }
987
987
  static fromJsonString(t, n) {
988
- return new Y().fromJsonString(t, n);
988
+ return new _().fromJsonString(t, n);
989
989
  }
990
990
  static equals(t, n) {
991
- return proto3.util.equals(Y, t, n);
991
+ return proto3.util.equals(_, t, n);
992
992
  }
993
993
  };
994
- r(Y, "runtime", proto3), r(Y, "typeName", "audiotool.document.v1.PingRequest"), r(Y, "fields", proto3.util.newFieldList(() => [
994
+ r(_, "runtime", proto3), r(_, "typeName", "audiotool.document.v1.PingRequest"), r(_, "fields", proto3.util.newFieldList(() => [
995
995
  {
996
996
  no: 1,
997
997
  name: "project_name",
@@ -1014,27 +1014,27 @@ r(Y, "runtime", proto3), r(Y, "typeName", "audiotool.document.v1.PingRequest"),
1014
1014
  /* ScalarType.UINT32 */
1015
1015
  }
1016
1016
  ]));
1017
- let PingRequest = Y;
1018
- const Z = class Z extends Message {
1017
+ let PingRequest = _;
1018
+ const tt = class tt extends Message {
1019
1019
  constructor(e) {
1020
1020
  super(), proto3.util.initPartial(e, this);
1021
1021
  }
1022
1022
  static fromBinary(e, t) {
1023
- return new Z().fromBinary(e, t);
1023
+ return new tt().fromBinary(e, t);
1024
1024
  }
1025
1025
  static fromJson(e, t) {
1026
- return new Z().fromJson(e, t);
1026
+ return new tt().fromJson(e, t);
1027
1027
  }
1028
1028
  static fromJsonString(e, t) {
1029
- return new Z().fromJsonString(e, t);
1029
+ return new tt().fromJsonString(e, t);
1030
1030
  }
1031
1031
  static equals(e, t) {
1032
- return proto3.util.equals(Z, e, t);
1032
+ return proto3.util.equals(tt, e, t);
1033
1033
  }
1034
1034
  };
1035
- r(Z, "runtime", proto3), r(Z, "typeName", "audiotool.document.v1.PingResponse"), r(Z, "fields", proto3.util.newFieldList(() => []));
1036
- let PingResponse = Z;
1037
- const _ = class _ extends Message {
1035
+ r(tt, "runtime", proto3), r(tt, "typeName", "audiotool.document.v1.PingResponse"), r(tt, "fields", proto3.util.newFieldList(() => []));
1036
+ let PingResponse = tt;
1037
+ const et = class et extends Message {
1038
1038
  constructor(t) {
1039
1039
  super();
1040
1040
  /**
@@ -1046,19 +1046,19 @@ const _ = class _ extends Message {
1046
1046
  proto3.util.initPartial(t, this);
1047
1047
  }
1048
1048
  static fromBinary(t, n) {
1049
- return new _().fromBinary(t, n);
1049
+ return new et().fromBinary(t, n);
1050
1050
  }
1051
1051
  static fromJson(t, n) {
1052
- return new _().fromJson(t, n);
1052
+ return new et().fromJson(t, n);
1053
1053
  }
1054
1054
  static fromJsonString(t, n) {
1055
- return new _().fromJsonString(t, n);
1055
+ return new et().fromJsonString(t, n);
1056
1056
  }
1057
1057
  static equals(t, n) {
1058
- return proto3.util.equals(_, t, n);
1058
+ return proto3.util.equals(et, t, n);
1059
1059
  }
1060
1060
  };
1061
- r(_, "runtime", proto3), r(_, "typeName", "audiotool.document.v1.GetClientStatsRequest"), r(_, "fields", proto3.util.newFieldList(() => [
1061
+ r(et, "runtime", proto3), r(et, "typeName", "audiotool.document.v1.GetClientStatsRequest"), r(et, "fields", proto3.util.newFieldList(() => [
1062
1062
  {
1063
1063
  no: 1,
1064
1064
  name: "project_name",
@@ -1067,8 +1067,8 @@ r(_, "runtime", proto3), r(_, "typeName", "audiotool.document.v1.GetClientStatsR
1067
1067
  /* ScalarType.STRING */
1068
1068
  }
1069
1069
  ]));
1070
- let GetClientStatsRequest = _;
1071
- const tt = class tt extends Message {
1070
+ let GetClientStatsRequest = et;
1071
+ const nt = class nt extends Message {
1072
1072
  constructor(t) {
1073
1073
  super();
1074
1074
  /**
@@ -1080,23 +1080,23 @@ const tt = class tt extends Message {
1080
1080
  proto3.util.initPartial(t, this);
1081
1081
  }
1082
1082
  static fromBinary(t, n) {
1083
- return new tt().fromBinary(t, n);
1083
+ return new nt().fromBinary(t, n);
1084
1084
  }
1085
1085
  static fromJson(t, n) {
1086
- return new tt().fromJson(t, n);
1086
+ return new nt().fromJson(t, n);
1087
1087
  }
1088
1088
  static fromJsonString(t, n) {
1089
- return new tt().fromJsonString(t, n);
1089
+ return new nt().fromJsonString(t, n);
1090
1090
  }
1091
1091
  static equals(t, n) {
1092
- return proto3.util.equals(tt, t, n);
1092
+ return proto3.util.equals(nt, t, n);
1093
1093
  }
1094
1094
  };
1095
- r(tt, "runtime", proto3), r(tt, "typeName", "audiotool.document.v1.GetClientStatsResponse"), r(tt, "fields", proto3.util.newFieldList(() => [
1095
+ r(nt, "runtime", proto3), r(nt, "typeName", "audiotool.document.v1.GetClientStatsResponse"), r(nt, "fields", proto3.util.newFieldList(() => [
1096
1096
  { no: 1, name: "client_info", kind: "message", T: ClientInfo, repeated: !0 }
1097
1097
  ]));
1098
- let GetClientStatsResponse = tt;
1099
- const et = class et extends Message {
1098
+ let GetClientStatsResponse = nt;
1099
+ const it = class it extends Message {
1100
1100
  constructor(t) {
1101
1101
  super();
1102
1102
  /**
@@ -1127,19 +1127,19 @@ const et = class et extends Message {
1127
1127
  proto3.util.initPartial(t, this);
1128
1128
  }
1129
1129
  static fromBinary(t, n) {
1130
- return new et().fromBinary(t, n);
1130
+ return new it().fromBinary(t, n);
1131
1131
  }
1132
1132
  static fromJson(t, n) {
1133
- return new et().fromJson(t, n);
1133
+ return new it().fromJson(t, n);
1134
1134
  }
1135
1135
  static fromJsonString(t, n) {
1136
- return new et().fromJsonString(t, n);
1136
+ return new it().fromJsonString(t, n);
1137
1137
  }
1138
1138
  static equals(t, n) {
1139
- return proto3.util.equals(et, t, n);
1139
+ return proto3.util.equals(it, t, n);
1140
1140
  }
1141
1141
  };
1142
- r(et, "runtime", proto3), r(et, "typeName", "audiotool.document.v1.ClientInfo"), r(et, "fields", proto3.util.newFieldList(() => [
1142
+ r(it, "runtime", proto3), r(it, "typeName", "audiotool.document.v1.ClientInfo"), r(it, "fields", proto3.util.newFieldList(() => [
1143
1143
  {
1144
1144
  no: 1,
1145
1145
  name: "id",
@@ -1169,27 +1169,27 @@ r(et, "runtime", proto3), r(et, "typeName", "audiotool.document.v1.ClientInfo"),
1169
1169
  /* ScalarType.STRING */
1170
1170
  }
1171
1171
  ]));
1172
- let ClientInfo = et;
1173
- const nt = class nt extends Message {
1172
+ let ClientInfo = it;
1173
+ const ot = class ot extends Message {
1174
1174
  constructor(e) {
1175
1175
  super(), proto3.util.initPartial(e, this);
1176
1176
  }
1177
1177
  static fromBinary(e, t) {
1178
- return new nt().fromBinary(e, t);
1178
+ return new ot().fromBinary(e, t);
1179
1179
  }
1180
1180
  static fromJson(e, t) {
1181
- return new nt().fromJson(e, t);
1181
+ return new ot().fromJson(e, t);
1182
1182
  }
1183
1183
  static fromJsonString(e, t) {
1184
- return new nt().fromJsonString(e, t);
1184
+ return new ot().fromJsonString(e, t);
1185
1185
  }
1186
1186
  static equals(e, t) {
1187
- return proto3.util.equals(nt, e, t);
1187
+ return proto3.util.equals(ot, e, t);
1188
1188
  }
1189
1189
  };
1190
- r(nt, "runtime", proto3), r(nt, "typeName", "audiotool.document.v1.GetVersionRequest"), r(nt, "fields", proto3.util.newFieldList(() => []));
1191
- let GetVersionRequest = nt;
1192
- const it = class it extends Message {
1190
+ r(ot, "runtime", proto3), r(ot, "typeName", "audiotool.document.v1.GetVersionRequest"), r(ot, "fields", proto3.util.newFieldList(() => []));
1191
+ let GetVersionRequest = ot;
1192
+ const rt = class rt extends Message {
1193
1193
  constructor(t) {
1194
1194
  super();
1195
1195
  /**
@@ -1201,19 +1201,19 @@ const it = class it extends Message {
1201
1201
  proto3.util.initPartial(t, this);
1202
1202
  }
1203
1203
  static fromBinary(t, n) {
1204
- return new it().fromBinary(t, n);
1204
+ return new rt().fromBinary(t, n);
1205
1205
  }
1206
1206
  static fromJson(t, n) {
1207
- return new it().fromJson(t, n);
1207
+ return new rt().fromJson(t, n);
1208
1208
  }
1209
1209
  static fromJsonString(t, n) {
1210
- return new it().fromJsonString(t, n);
1210
+ return new rt().fromJsonString(t, n);
1211
1211
  }
1212
1212
  static equals(t, n) {
1213
- return proto3.util.equals(it, t, n);
1213
+ return proto3.util.equals(rt, t, n);
1214
1214
  }
1215
1215
  };
1216
- r(it, "runtime", proto3), r(it, "typeName", "audiotool.document.v1.GetVersionResponse"), r(it, "fields", proto3.util.newFieldList(() => [
1216
+ r(rt, "runtime", proto3), r(rt, "typeName", "audiotool.document.v1.GetVersionResponse"), r(rt, "fields", proto3.util.newFieldList(() => [
1217
1217
  {
1218
1218
  no: 1,
1219
1219
  name: "version",
@@ -1222,27 +1222,27 @@ r(it, "runtime", proto3), r(it, "typeName", "audiotool.document.v1.GetVersionRes
1222
1222
  /* ScalarType.STRING */
1223
1223
  }
1224
1224
  ]));
1225
- let GetVersionResponse = it;
1226
- const ot = class ot extends Message {
1225
+ let GetVersionResponse = rt;
1226
+ const at = class at extends Message {
1227
1227
  constructor(e) {
1228
1228
  super(), proto3.util.initPartial(e, this);
1229
1229
  }
1230
1230
  static fromBinary(e, t) {
1231
- return new ot().fromBinary(e, t);
1231
+ return new at().fromBinary(e, t);
1232
1232
  }
1233
1233
  static fromJson(e, t) {
1234
- return new ot().fromJson(e, t);
1234
+ return new at().fromJson(e, t);
1235
1235
  }
1236
1236
  static fromJsonString(e, t) {
1237
- return new ot().fromJsonString(e, t);
1237
+ return new at().fromJsonString(e, t);
1238
1238
  }
1239
1239
  static equals(e, t) {
1240
- return proto3.util.equals(ot, e, t);
1240
+ return proto3.util.equals(at, e, t);
1241
1241
  }
1242
1242
  };
1243
- r(ot, "runtime", proto3), r(ot, "typeName", "audiotool.document.v1.GetTimeRequest"), r(ot, "fields", proto3.util.newFieldList(() => []));
1244
- let GetTimeRequest = ot;
1245
- const rt = class rt extends Message {
1243
+ r(at, "runtime", proto3), r(at, "typeName", "audiotool.document.v1.GetTimeRequest"), r(at, "fields", proto3.util.newFieldList(() => []));
1244
+ let GetTimeRequest = at;
1245
+ const st = class st extends Message {
1246
1246
  constructor(t) {
1247
1247
  super();
1248
1248
  /**
@@ -1254,19 +1254,19 @@ const rt = class rt extends Message {
1254
1254
  proto3.util.initPartial(t, this);
1255
1255
  }
1256
1256
  static fromBinary(t, n) {
1257
- return new rt().fromBinary(t, n);
1257
+ return new st().fromBinary(t, n);
1258
1258
  }
1259
1259
  static fromJson(t, n) {
1260
- return new rt().fromJson(t, n);
1260
+ return new st().fromJson(t, n);
1261
1261
  }
1262
1262
  static fromJsonString(t, n) {
1263
- return new rt().fromJsonString(t, n);
1263
+ return new st().fromJsonString(t, n);
1264
1264
  }
1265
1265
  static equals(t, n) {
1266
- return proto3.util.equals(rt, t, n);
1266
+ return proto3.util.equals(st, t, n);
1267
1267
  }
1268
1268
  };
1269
- r(rt, "runtime", proto3), r(rt, "typeName", "audiotool.document.v1.GetTimeResponse"), r(rt, "fields", proto3.util.newFieldList(() => [
1269
+ r(st, "runtime", proto3), r(st, "typeName", "audiotool.document.v1.GetTimeResponse"), r(st, "fields", proto3.util.newFieldList(() => [
1270
1270
  {
1271
1271
  no: 1,
1272
1272
  name: "time",
@@ -1275,7 +1275,7 @@ r(rt, "runtime", proto3), r(rt, "typeName", "audiotool.document.v1.GetTimeRespon
1275
1275
  /* ScalarType.INT64 */
1276
1276
  }
1277
1277
  ]));
1278
- let GetTimeResponse = rt;
1278
+ let GetTimeResponse = st;
1279
1279
  const wasmUrl = "/document_validator.wasm", wasmJsUrl = "/wasm_exec.js", runningInNode = typeof process < "u";
1280
1280
  let wasmDocumentStateBuilderCache;
1281
1281
  const getWasmDocumentState = async () => {
@@ -1304,17 +1304,17 @@ const getWasmDocumentState = async () => {
1304
1304
  return delete globalThis.createDocumentState, e(() => {
1305
1305
  const l = c();
1306
1306
  return {
1307
- applyTransaction(m) {
1308
- const d = l.applyTransaction(m.toBinary());
1309
- return d instanceof Object && "error" in d ? d.error : new Transaction({
1310
- modifications: d.rollbacks.map((p) => Modification.fromBinary(p))
1307
+ applyTransaction(u) {
1308
+ const m = l.applyTransaction(u.toBinary());
1309
+ return m instanceof Object && "error" in m ? m.error : new Transaction({
1310
+ modifications: m.rollbacks.map((f) => Modification.fromBinary(f))
1311
1311
  });
1312
1312
  }
1313
1313
  };
1314
1314
  }), (await i)();
1315
1315
  }, executeWrapperJs = async () => {
1316
1316
  if (!runningInNode)
1317
- return import("https://cdn.audiotool.com/website-assets/document-service/00ea23af56aad2ae1a0787bd80bd213e161343c3//wasm_exec.js");
1317
+ return import("https://cdn.audiotool.com/website-assets/document-service/5b85be5b151fe1c949845fe34b15f24ab059c736//wasm_exec.js");
1318
1318
  const path = await import("node:path"), url = await import("node:url"), fs = await import("node:fs");
1319
1319
  let filePath;
1320
1320
  filePath = path.resolve(
@@ -1333,7 +1333,7 @@ const getWasmDocumentState = async () => {
1333
1333
  }, loadWasm = async () => {
1334
1334
  if (!runningInNode)
1335
1335
  return await fetch(
1336
- "https://cdn.audiotool.com/website-assets/document-service/00ea23af56aad2ae1a0787bd80bd213e161343c3//document_validator.wasm.gz"
1336
+ "https://cdn.audiotool.com/website-assets/document-service/5b85be5b151fe1c949845fe34b15f24ab059c736//document_validator.wasm.gz"
1337
1337
  ).then(
1338
1338
  async (o) => o.ok ? WebAssembly.compileStreaming(o) : throw_("couldn't fetch wasm module")
1339
1339
  );
@@ -1356,12 +1356,12 @@ const getWasmDocumentState = async () => {
1356
1356
  };
1357
1357
  };
1358
1358
  var Pt;
1359
- const ft = class ft {
1359
+ const pt = class pt {
1360
1360
  constructor(e = void 0, t = void 0, n = []) {
1361
1361
  r(this, "entityId");
1362
1362
  r(this, "fieldIndex");
1363
1363
  r(this, "entityType");
1364
- f(this, Pt);
1364
+ p(this, Pt);
1365
1365
  if (this.entityId = e ?? "", this.fieldIndex = n, this.entityType = t, e !== void 0 && e !== "" && t === void 0)
1366
1366
  throw new Error("entity type is required if id is set");
1367
1367
  }
@@ -1377,14 +1377,14 @@ const ft = class ft {
1377
1377
  }
1378
1378
  /** @internal Returns a copy of this object with an appended field number. */
1379
1379
  withAppendedFieldNumber(e) {
1380
- return new ft(this.entityId, this.entityType, [
1380
+ return new pt(this.entityId, this.entityType, [
1381
1381
  ...this.fieldIndex,
1382
1382
  e
1383
1383
  ]);
1384
1384
  }
1385
1385
  /** @internal */
1386
1386
  withFieldIndex(e) {
1387
- return new ft(this.entityId, this.entityType, [...e]);
1387
+ return new pt(this.entityId, this.entityType, [...e]);
1388
1388
  }
1389
1389
  /** @internal */
1390
1390
  toPointerMessage() {
@@ -1405,27 +1405,27 @@ const ft = class ft {
1405
1405
  }
1406
1406
  /** @internal clones the location, updating only the id */
1407
1407
  withId(e) {
1408
- return new ft(e, this.entityType, this.fieldIndex.slice());
1408
+ return new pt(e, this.entityType, this.fieldIndex.slice());
1409
1409
  }
1410
1410
  /** @internal */
1411
1411
  static fromPointerMessage(e, t) {
1412
1412
  if (t.entityId === void 0 || t.entityId === "")
1413
- return new ft();
1413
+ return new pt();
1414
1414
  const n = e(t.entityId);
1415
1415
  if (n === void 0)
1416
1416
  throw new Error(
1417
1417
  `entity type for ${t.entityId} is undefined for a set pointer: ${t.toJsonString()}`
1418
1418
  );
1419
- return new ft(t.entityId, n, t.fieldIndex.slice());
1419
+ return new pt(t.entityId, n, t.fieldIndex.slice());
1420
1420
  }
1421
1421
  /** @internal */
1422
1422
  static fromSchemaPath(e, t) {
1423
1423
  const { entityType: n, fieldIndex: o } = schemaPathToSchemaLocation(t);
1424
- return new ft(e, n, o);
1424
+ return new pt(e, n, o);
1425
1425
  }
1426
1426
  };
1427
1427
  Pt = new WeakMap();
1428
- let NexusLocation = ft;
1428
+ let NexusLocation = pt;
1429
1429
  const hashNexusLocation = (i, e) => v5(
1430
1430
  `${i}/${e.join(",")}`,
1431
1431
  "4f4aaf81-65f2-4239-b1df-e34a0729f6b8"
@@ -1484,7 +1484,7 @@ class PrimitiveField {
1484
1484
  /** The location of this field within the Nexus document. */
1485
1485
  r(this, "location");
1486
1486
  /** The value of the field; private with a getter to prevent accidenal overwrites. */
1487
- f(this, kt);
1487
+ p(this, kt);
1488
1488
  /** Whether the field is mutable. Updating immutable fields results in a transaction error.
1489
1489
  *
1490
1490
  * If the type fo the field is known at compile time, updating the field using the {@link TransactionBuilder}
@@ -1564,27 +1564,27 @@ const createNexusFields = (i, e, t, n) => {
1564
1564
  return t.getType().fields.list().forEach((a) => {
1565
1565
  if (a.name === "id" && a.no === 1)
1566
1566
  return;
1567
- const c = n.withAppendedFieldNumber(a.no), u = t[a.localName];
1567
+ const c = n.withAppendedFieldNumber(a.no), d = t[a.localName];
1568
1568
  let l;
1569
1569
  if (!a.repeated)
1570
1570
  l = createField(
1571
1571
  i,
1572
1572
  e,
1573
1573
  c,
1574
- u,
1574
+ d,
1575
1575
  a
1576
1576
  );
1577
1577
  else {
1578
- const m = u.map(
1579
- (d, p) => createField(
1578
+ const u = d.map(
1579
+ (m, f) => createField(
1580
1580
  i,
1581
1581
  e,
1582
- c.withAppendedFieldNumber(p),
1583
- d,
1582
+ c.withAppendedFieldNumber(f),
1583
+ m,
1584
1584
  a
1585
1585
  )
1586
1586
  );
1587
- l = new ArrayField(c, m);
1587
+ l = new ArrayField(c, u);
1588
1588
  }
1589
1589
  o[a.localName] = l;
1590
1590
  }), o;
@@ -1726,51 +1726,51 @@ const createNexusFields = (i, e, t, n) => {
1726
1726
  onUpdate: () => {
1727
1727
  },
1728
1728
  ...(i == null ? void 0 : i.callbacks) ?? {}
1729
- }, o = /* @__PURE__ */ new Map(), a = (m) => {
1730
- var d;
1731
- return ((d = e.get(m)) == null ? void 0 : d.entityType) ?? o.get(m);
1732
- }, c = (m) => {
1733
- const d = createEntity(
1729
+ }, o = /* @__PURE__ */ new Map(), a = (u) => {
1730
+ var m;
1731
+ return ((m = e.get(u)) == null ? void 0 : m.entityType) ?? o.get(u);
1732
+ }, c = (u) => {
1733
+ const m = createEntity(
1734
1734
  a,
1735
1735
  mustUnpackEntity(
1736
- m.entity ?? throw_("received empty create modification")
1736
+ u.entity ?? throw_("received empty create modification")
1737
1737
  )
1738
1738
  );
1739
- e.set(d.id, d), visitPointers$1(d, (p, w) => {
1740
- addSourceTarget(t, p, w), n.onStartPointingTo(p, w);
1741
- }), n.onCreate(d);
1742
- }, u = (m) => {
1743
- const d = m.entityId, p = e.get(d) ?? throw_("can't find deleted entity");
1744
- e.delete(d), visitPointers$1(p, (w, v) => {
1745
- removeSourceTarget(t, w, v), n.onStopPointingTo(w, v);
1746
- }), n.onDelete(p);
1747
- }, l = (m) => {
1748
- const d = m.field ?? throw_("received update without pointer"), p = NexusLocation.fromPointerMessage(a, d), w = e.get(p.entityId) ?? throw_("can't find updated entity"), v = extractPbUpdateValue(m.value, a);
1749
- applyUpdate(w, p, v, {
1750
- onStopPointingTo: (g, b) => {
1751
- removeSourceTarget(t, g, b) || throw_(), n.onStopPointingTo(g, b);
1739
+ e.set(m.id, m), visitPointers$1(m, (f, y) => {
1740
+ addSourceTarget(t, f, y), n.onStartPointingTo(f, y);
1741
+ }), n.onCreate(m);
1742
+ }, d = (u) => {
1743
+ const m = u.entityId, f = e.get(m) ?? throw_("can't find deleted entity");
1744
+ e.delete(m), visitPointers$1(f, (y, v) => {
1745
+ removeSourceTarget(t, y, v), n.onStopPointingTo(y, v);
1746
+ }), n.onDelete(f);
1747
+ }, l = (u) => {
1748
+ const m = u.field ?? throw_("received update without pointer"), f = NexusLocation.fromPointerMessage(a, m), y = e.get(f.entityId) ?? throw_("can't find updated entity"), v = extractPbUpdateValue(u.value, a);
1749
+ applyUpdate(y, f, v, {
1750
+ onStopPointingTo: (w, b) => {
1751
+ removeSourceTarget(t, w, b) || throw_(), n.onStopPointingTo(w, b);
1752
1752
  },
1753
- onStartPointingTo: (g, b) => {
1754
- addSourceTarget(t, g, b), n.onStartPointingTo(g, b);
1753
+ onStartPointingTo: (w, b) => {
1754
+ addSourceTarget(t, w, b), n.onStartPointingTo(w, b);
1755
1755
  }
1756
- }), n.onUpdate(p, v);
1756
+ }), n.onUpdate(f, v);
1757
1757
  };
1758
1758
  return {
1759
1759
  entities: e,
1760
1760
  references: t,
1761
- applyModification(m) {
1762
- const d = m.modification;
1763
- switch (d.case) {
1761
+ applyModification(u) {
1762
+ const m = u.modification;
1763
+ switch (m.case) {
1764
1764
  case "create": {
1765
- c(d.value);
1765
+ c(m.value);
1766
1766
  break;
1767
1767
  }
1768
1768
  case "delete": {
1769
- u(d.value);
1769
+ d(m.value);
1770
1770
  break;
1771
1771
  }
1772
1772
  case "update": {
1773
- l(d.value);
1773
+ l(m.value);
1774
1774
  break;
1775
1775
  }
1776
1776
  }
@@ -1778,11 +1778,11 @@ const createNexusFields = (i, e, t, n) => {
1778
1778
  getStats() {
1779
1779
  return {
1780
1780
  entities: e.size,
1781
- references: t.values().reduce((m, d) => m + d.length, 0)
1781
+ references: t.values().reduce((u, m) => u + m.length, 0)
1782
1782
  };
1783
1783
  },
1784
- _addEntityTypeForId(m, d) {
1785
- o.set(m, d);
1784
+ _addEntityTypeForId(u, m) {
1785
+ o.set(u, m);
1786
1786
  }
1787
1787
  };
1788
1788
  }, TerminableBuilder = {
@@ -1793,17 +1793,17 @@ const createNexusFields = (i, e, t, n) => {
1793
1793
  }
1794
1794
  })
1795
1795
  };
1796
- var at, pt, P, st, ct, Bt;
1796
+ var ct, ht, k, lt, dt, At;
1797
1797
  const Et = class Et {
1798
1798
  constructor(e = nexusDocumentState()) {
1799
- f(this, at, new HashMap());
1800
- f(this, pt, /* @__PURE__ */ new Map());
1799
+ p(this, ct, new HashMap());
1800
+ p(this, ht, /* @__PURE__ */ new Map());
1801
1801
  /** contains either: entity id, *, or entity type */
1802
- f(this, P, /* @__PURE__ */ new Map());
1803
- f(this, st, new HashMap());
1804
- f(this, ct, new HashMap());
1805
- f(this, Bt);
1806
- h(this, Bt, e), Et.debugWindowInstance ?? (Et.debugWindowInstance = this);
1802
+ p(this, k, /* @__PURE__ */ new Map());
1803
+ p(this, lt, new HashMap());
1804
+ p(this, dt, new HashMap());
1805
+ p(this, At);
1806
+ h(this, At, e), Et.debugWindowInstance ?? (Et.debugWindowInstance = this);
1807
1807
  }
1808
1808
  /**
1809
1809
  * Subscribe to the event that an entity of a specific type is created.
@@ -1818,18 +1818,18 @@ const Et = class Et {
1818
1818
  );
1819
1819
  c !== void 0 && this.onRemove(a, c);
1820
1820
  };
1821
- return getOrDefault(s(this, pt), e).add(n), TerminableBuilder.terminableFrom(
1821
+ return getOrDefault(s(this, ht), e).add(n), TerminableBuilder.terminableFrom(
1822
1822
  () => {
1823
1823
  var a;
1824
- return (a = s(this, pt).get(e)) == null ? void 0 : a.delete(n);
1824
+ return (a = s(this, ht).get(e)) == null ? void 0 : a.delete(n);
1825
1825
  }
1826
1826
  );
1827
1827
  }
1828
1828
  /** @internal */
1829
1829
  _dispatchCreate(e) {
1830
1830
  [
1831
- ...s(this, pt).get("*") ?? [],
1832
- ...s(this, pt).get(e.entityType) ?? []
1831
+ ...s(this, ht).get("*") ?? [],
1832
+ ...s(this, ht).get(e.entityType) ?? []
1833
1833
  ].forEach((t) => t(e));
1834
1834
  }
1835
1835
  /**
@@ -1839,17 +1839,17 @@ const Et = class Et {
1839
1839
  */
1840
1840
  onUpdate(e, t, n = !0) {
1841
1841
  const o = t;
1842
- return getOrDefault(s(this, at), e.location).add(o), n && t(e.value), TerminableBuilder.terminableFrom(
1842
+ return getOrDefault(s(this, ct), e.location).add(o), n && t(e.value), TerminableBuilder.terminableFrom(
1843
1843
  () => {
1844
1844
  var c;
1845
- return (c = s(this, at).get(e.location)) == null ? void 0 : c.delete(o);
1845
+ return (c = s(this, ct).get(e.location)) == null ? void 0 : c.delete(o);
1846
1846
  }
1847
1847
  );
1848
1848
  }
1849
1849
  /** @internal */
1850
1850
  _dispatchUpdate(e, t) {
1851
1851
  var n;
1852
- (n = s(this, at).get(e)) == null || n.forEach((o) => o(t));
1852
+ (n = s(this, ct).get(e)) == null || n.forEach((o) => o(t));
1853
1853
  }
1854
1854
  /**
1855
1855
  * Subscribe to an event where an entity is removed.
@@ -1866,22 +1866,22 @@ const Et = class Et {
1866
1866
  onRemove(e, t) {
1867
1867
  const n = t;
1868
1868
  return getOrDefault(
1869
- s(this, P),
1869
+ s(this, k),
1870
1870
  typeof e == "string" ? e : e.id
1871
1871
  ).add(n), TerminableBuilder.terminableFrom(
1872
1872
  () => {
1873
1873
  var a;
1874
- return (a = s(this, P).get(typeof e == "string" ? e : e.id)) == null ? void 0 : a.delete(n);
1874
+ return (a = s(this, k).get(typeof e == "string" ? e : e.id)) == null ? void 0 : a.delete(n);
1875
1875
  }
1876
1876
  );
1877
1877
  }
1878
1878
  /** @internal */
1879
1879
  _dispatchRemove(e) {
1880
1880
  [
1881
- ...s(this, P).get("*") ?? [],
1882
- ...s(this, P).get(e.id) ?? [],
1883
- ...s(this, P).get(e.entityType) ?? []
1884
- ].forEach((t) => t(e)), s(this, P).delete(e.id), [...s(this, st).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, st).delete(t)), [...s(this, ct).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, ct).delete(t)), [...s(this, at).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, at).delete(t));
1881
+ ...s(this, k).get("*") ?? [],
1882
+ ...s(this, k).get(e.id) ?? [],
1883
+ ...s(this, k).get(e.entityType) ?? []
1884
+ ].forEach((t) => t(e)), s(this, k).delete(e.id), [...s(this, lt).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, lt).delete(t)), [...s(this, dt).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, dt).delete(t)), [...s(this, ct).keys()].filter((t) => t.entityId === e.id).forEach((t) => s(this, ct).delete(t));
1885
1885
  }
1886
1886
  /** Subscribe to the event that some pointer in the document starts pointing to a given location.
1887
1887
  *
@@ -1903,17 +1903,17 @@ const Et = class Et {
1903
1903
  */
1904
1904
  onPointingTo(e, t, n = !0) {
1905
1905
  var a;
1906
- return getOrDefault(s(this, st), e).add(t), n && ((a = s(this, Bt).references.get(e)) == null || a.forEach((c) => t(c))), TerminableBuilder.terminableFrom(
1906
+ return getOrDefault(s(this, lt), e).add(t), n && ((a = s(this, At).references.get(e)) == null || a.forEach((c) => t(c))), TerminableBuilder.terminableFrom(
1907
1907
  () => {
1908
1908
  var c;
1909
- return (c = s(this, st).get(e)) == null ? void 0 : c.delete(t);
1909
+ return (c = s(this, lt).get(e)) == null ? void 0 : c.delete(t);
1910
1910
  }
1911
1911
  );
1912
1912
  }
1913
1913
  /** @internal */
1914
1914
  _dispatchPointingTo(e, t) {
1915
1915
  var n;
1916
- (n = s(this, st).get(e)) == null || n.forEach((o) => o(t));
1916
+ (n = s(this, lt).get(e)) == null || n.forEach((o) => o(t));
1917
1917
  }
1918
1918
  /** Subscribe to the event that some pointer in the document stops pointing to a given location.
1919
1919
  *
@@ -1930,17 +1930,17 @@ const Et = class Et {
1930
1930
  * @returns A terminable that when terminated will stop dispatching new onStopPointingTo events.
1931
1931
  */
1932
1932
  onStopPointingTo(e, t) {
1933
- return getOrDefault(s(this, ct), e).add(t), TerminableBuilder.terminableFrom(
1933
+ return getOrDefault(s(this, dt), e).add(t), TerminableBuilder.terminableFrom(
1934
1934
  () => {
1935
1935
  var o;
1936
- return (o = s(this, ct).get(e)) == null ? void 0 : o.delete(t);
1936
+ return (o = s(this, dt).get(e)) == null ? void 0 : o.delete(t);
1937
1937
  }
1938
1938
  );
1939
1939
  }
1940
1940
  /** @internal */
1941
1941
  _dispatchStopPointingTo(e, t) {
1942
1942
  var n;
1943
- (n = s(this, ct).get(e)) == null || n.forEach((o) => o(t));
1943
+ (n = s(this, dt).get(e)) == null || n.forEach((o) => o(t));
1944
1944
  }
1945
1945
  /**
1946
1946
  * @internal
@@ -1948,15 +1948,15 @@ const Et = class Et {
1948
1948
  * on large documents. Don't call too often. */
1949
1949
  getStats() {
1950
1950
  return {
1951
- numCreateListeners: sizeOf(s(this, pt)),
1952
- numUpdateListeners: sizeOf(s(this, at)),
1953
- numRemoveListeners: sizeOf(s(this, P)),
1954
- numPointingToListeners: sizeOf(s(this, st)),
1955
- numStopPointingToListeners: sizeOf(s(this, ct))
1951
+ numCreateListeners: sizeOf(s(this, ht)),
1952
+ numUpdateListeners: sizeOf(s(this, ct)),
1953
+ numRemoveListeners: sizeOf(s(this, k)),
1954
+ numPointingToListeners: sizeOf(s(this, lt)),
1955
+ numStopPointingToListeners: sizeOf(s(this, dt))
1956
1956
  };
1957
1957
  }
1958
1958
  };
1959
- at = new WeakMap(), pt = new WeakMap(), P = new WeakMap(), st = new WeakMap(), ct = new WeakMap(), Bt = new WeakMap(), /**
1959
+ ct = new WeakMap(), ht = new WeakMap(), k = new WeakMap(), lt = new WeakMap(), dt = new WeakMap(), At = new WeakMap(), /**
1960
1960
  * @internal
1961
1961
  * For debugging purposes, the first instance of the nexus event manager ever created. */
1962
1962
  r(Et, "debugWindowInstance");
@@ -1970,7 +1970,7 @@ const sizeOf = (i) => i.values().reduce((e, t) => e + t.size, 0), getOrDefault =
1970
1970
  validate: () => {
1971
1971
  }
1972
1972
  });
1973
- var Mt, Tt, It, Nt, mt, Lt, Xt;
1973
+ var Mt, Tt, It, Nt, ft, Bt, Xt;
1974
1974
  const zt = class zt {
1975
1975
  constructor({
1976
1976
  getFields: e,
@@ -1978,34 +1978,34 @@ const zt = class zt {
1978
1978
  filterFields: n,
1979
1979
  documentLock: o
1980
1980
  }) {
1981
- f(this, mt);
1982
- f(this, Mt);
1983
- f(this, Tt);
1984
- f(this, It);
1985
- f(this, Nt);
1981
+ p(this, ft);
1982
+ p(this, Mt);
1983
+ p(this, Tt);
1984
+ p(this, It);
1985
+ p(this, Nt);
1986
1986
  h(this, Mt, e), h(this, Tt, t), h(this, It, n), h(this, Nt, o);
1987
1987
  }
1988
1988
  /** Only keep fields that are marked with target type appearing in `targetTypes`. */
1989
1989
  ofTargetTypes(...e) {
1990
- return y(this, mt, Lt).call(this, (t) => getSchemaLocationDetails(t.location).targetTypes.some(
1990
+ return g(this, ft, Bt).call(this, (t) => getSchemaLocationDetails(t.location).targetTypes.some(
1991
1991
  (n) => e.includes(n)
1992
1992
  ));
1993
1993
  }
1994
1994
  /** Only keep fields that aren't pointed to by any other field in the nexus document. */
1995
1995
  notPointedTo() {
1996
- return y(this, mt, Lt).call(this, (e) => {
1996
+ return g(this, ft, Bt).call(this, (e) => {
1997
1997
  const t = s(this, Tt).call(this).get(e.location);
1998
1998
  return t === void 0 || t.length === 0;
1999
1999
  });
2000
2000
  }
2001
2001
  pointedToBy(e) {
2002
- return y(this, mt, Lt).call(this, (t) => {
2002
+ return g(this, ft, Bt).call(this, (t) => {
2003
2003
  const n = s(this, Tt).call(this).get(t.location);
2004
2004
  return n !== void 0 && n.some((o) => o.equals(e));
2005
2005
  });
2006
2006
  }
2007
2007
  primitiveFields() {
2008
- return y(this, mt, Lt).call(this, (e) => e instanceof PrimitiveField);
2008
+ return g(this, ft, Bt).call(this, (e) => e instanceof PrimitiveField);
2009
2009
  }
2010
2010
  /** Returns all primitive fields selected using this query */
2011
2011
  get() {
@@ -2020,14 +2020,14 @@ const zt = class zt {
2020
2020
  * part of a ComparableMap that maps entity ids to fields for that entity.
2021
2021
  */
2022
2022
  getByEntity() {
2023
- y(this, mt, Xt).call(this);
2023
+ g(this, ft, Xt).call(this);
2024
2024
  const e = /* @__PURE__ */ new Map();
2025
2025
  return this.get().forEach((t) => {
2026
2026
  e.has(t.location.entityId) || e.set(t.location.entityId, []), (e.get(t.location.entityId) ?? throw_()).push(t);
2027
2027
  }), e;
2028
2028
  }
2029
2029
  };
2030
- Mt = new WeakMap(), Tt = new WeakMap(), It = new WeakMap(), Nt = new WeakMap(), mt = new WeakSet(), Lt = function(e) {
2030
+ Mt = new WeakMap(), Tt = new WeakMap(), It = new WeakMap(), Nt = new WeakMap(), ft = new WeakSet(), Bt = function(e) {
2031
2031
  return new zt({
2032
2032
  getFields: s(this, Mt),
2033
2033
  getRefs: s(this, Tt),
@@ -2040,12 +2040,12 @@ Mt = new WeakMap(), Tt = new WeakMap(), It = new WeakMap(), Nt = new WeakMap(),
2040
2040
  throw new Error("Document is not locked");
2041
2041
  };
2042
2042
  let FieldQuery = zt;
2043
- var x, lt, vt, T, E, gt;
2043
+ var x, ut, vt, T, E, gt;
2044
2044
  const Kt = class Kt {
2045
2045
  /** Don't construct this class, it is constructed by NexusDocument. */
2046
2046
  constructor(e) {
2047
- f(this, T);
2048
- f(this, x);
2047
+ p(this, T);
2048
+ p(this, x);
2049
2049
  /** This function filters & transforms entities. When modifying a query,
2050
2050
  * (e.g. with `ofTypes`, we basically "append" another function
2051
2051
  * to this one that filters and casts the entities.
@@ -2053,14 +2053,14 @@ const Kt = class Kt {
2053
2053
  * When calling `run`, we get all entities and filter them using this function
2054
2054
  * before returning all existing entities.
2055
2055
  */
2056
- f(this, lt);
2057
- f(this, vt);
2058
- h(this, x, (e == null ? void 0 : e.documentState) ?? nexusDocumentState()), h(this, lt, (e == null ? void 0 : e.filterEntities) ?? ((t) => t)), h(this, vt, e == null ? void 0 : e.documentLock);
2056
+ p(this, ut);
2057
+ p(this, vt);
2058
+ h(this, x, (e == null ? void 0 : e.documentState) ?? nexusDocumentState()), h(this, ut, (e == null ? void 0 : e.filterEntities) ?? ((t) => t)), h(this, vt, e == null ? void 0 : e.documentLock);
2059
2059
  }
2060
2060
  /** Returns all entities selected by this query, in undefined order.
2061
2061
  */
2062
2062
  get() {
2063
- return y(this, T, gt).call(this), [...s(this, lt).call(this, s(this, x).entities).values()];
2063
+ return g(this, T, gt).call(this), [...s(this, ut).call(this, s(this, x).entities).values()];
2064
2064
  }
2065
2065
  /** Returns the first entity returned by `get()`, if any.
2066
2066
  *
@@ -2069,11 +2069,11 @@ const Kt = class Kt {
2069
2069
  * if it's known that the query will return at most one entity.
2070
2070
  */
2071
2071
  getOne() {
2072
- return y(this, T, gt).call(this), this.get()[0];
2072
+ return g(this, T, gt).call(this), this.get()[0];
2073
2073
  }
2074
2074
  /** Of all selected entities, return the one with id `id`, if it exists. */
2075
2075
  getEntity(e) {
2076
- return y(this, T, gt).call(this), s(this, lt).call(this, s(this, x).entities).get(e);
2076
+ return g(this, T, gt).call(this), s(this, ut).call(this, s(this, x).entities).get(e);
2077
2077
  }
2078
2078
  /**
2079
2079
  * Of all selected entities, return the one with id `id`. Throw if it doesn't
@@ -2087,7 +2087,7 @@ const Kt = class Kt {
2087
2087
  * of the provided types.
2088
2088
  */
2089
2089
  getEntityAs(e, ...t) {
2090
- y(this, T, gt).call(this), assert(t.length > 0, "must provide at least one type");
2090
+ g(this, T, gt).call(this), assert(t.length > 0, "must provide at least one type");
2091
2091
  const n = this.getEntity(e);
2092
2092
  if (n !== void 0 && t.includes(n.entityType))
2093
2093
  return n;
@@ -2097,7 +2097,7 @@ const Kt = class Kt {
2097
2097
  * provided types. Throw if it doesn't exist.
2098
2098
  */
2099
2099
  mustGetEntityAs(e, ...t) {
2100
- y(this, T, gt).call(this), assert(t.length > 0, "must provide at least one type");
2100
+ g(this, T, gt).call(this), assert(t.length > 0, "must provide at least one type");
2101
2101
  const n = this.mustGetEntity(e);
2102
2102
  return t.includes(n.entityType) ? n : throw_(
2103
2103
  `entity with uuid ${e} is not of any of the provided types ${t}`
@@ -2105,7 +2105,7 @@ const Kt = class Kt {
2105
2105
  }
2106
2106
  /** Only keep entities whose id appears in `ids`. */
2107
2107
  withIds(...e) {
2108
- return y(this, T, E).call(this, (t) => filterByUuids(t, e));
2108
+ return g(this, T, E).call(this, (t) => filterByUuids(t, e));
2109
2109
  }
2110
2110
  /** Return the `FieldQuery<NexusField>` that starts with all fields of all
2111
2111
  * currently selected entities.
@@ -2113,7 +2113,7 @@ const Kt = class Kt {
2113
2113
  fields() {
2114
2114
  return new FieldQuery({
2115
2115
  getFields: () => [
2116
- ...s(this, lt).call(this, s(this, x).entities).values()
2116
+ ...s(this, ut).call(this, s(this, x).entities).values()
2117
2117
  ].flatMap((e) => toFields(e)),
2118
2118
  getRefs: () => s(this, x).references,
2119
2119
  filterFields: () => !0,
@@ -2124,7 +2124,7 @@ const Kt = class Kt {
2124
2124
  * in `targetTypes`. Target types of fields of entities are ignored.
2125
2125
  */
2126
2126
  ofTargetTypes(...e) {
2127
- return y(this, T, E).call(this, (t) => {
2127
+ return g(this, T, E).call(this, (t) => {
2128
2128
  const n = /* @__PURE__ */ new Map();
2129
2129
  return t.forEach((o, a) => {
2130
2130
  getSchemaLocationDetails(o.location).targetTypes.some(
@@ -2135,17 +2135,17 @@ const Kt = class Kt {
2135
2135
  }
2136
2136
  /** Check if a specific entity is contained in the current query. */
2137
2137
  has(e) {
2138
- y(this, T, gt).call(this);
2138
+ g(this, T, gt).call(this);
2139
2139
  const t = typeof e == "string" ? e : e.id;
2140
- return s(this, lt).call(this, s(this, x).entities).has(t);
2140
+ return s(this, ut).call(this, s(this, x).entities).has(t);
2141
2141
  }
2142
2142
  /** Only keep entities whose type string appears in `types`. */
2143
2143
  ofTypes(...e) {
2144
- return y(this, T, E).call(this, (t) => filterByType(t, e));
2144
+ return g(this, T, E).call(this, (t) => filterByType(t, e));
2145
2145
  }
2146
2146
  /** Omit entities whose type string appears in `types`. */
2147
2147
  notOfTypes(...e) {
2148
- return y(this, T, E).call(this, (t) => omitByType(t, e));
2148
+ return g(this, T, E).call(this, (t) => omitByType(t, e));
2149
2149
  }
2150
2150
  /** Only keep entities that have some fields that point to:
2151
2151
  * * `entityOfType`: some field of entities of a set of types
@@ -2161,7 +2161,7 @@ const Kt = class Kt {
2161
2161
  */
2162
2162
  get pointingTo() {
2163
2163
  return {
2164
- entityOfType: (...e) => y(this, T, E).call(this, (t) => filterByUuids(
2164
+ entityOfType: (...e) => g(this, T, E).call(this, (t) => filterByUuids(
2165
2165
  t,
2166
2166
  getUuidsPointingToTypes(
2167
2167
  s(this, x).references,
@@ -2169,11 +2169,11 @@ const Kt = class Kt {
2169
2169
  ...e
2170
2170
  )
2171
2171
  )),
2172
- locations: (...e) => y(this, T, E).call(this, (t) => filterByUuids(
2172
+ locations: (...e) => g(this, T, E).call(this, (t) => filterByUuids(
2173
2173
  t,
2174
2174
  getUuidsPointingToLocations(s(this, x).references, e)
2175
2175
  )),
2176
- entities: (...e) => y(this, T, E).call(this, (t) => filterByUuids(
2176
+ entities: (...e) => g(this, T, E).call(this, (t) => filterByUuids(
2177
2177
  t,
2178
2178
  getUuidsPointingToEntities(s(this, x).references, e)
2179
2179
  ))
@@ -2193,7 +2193,7 @@ const Kt = class Kt {
2193
2193
  */
2194
2194
  get pointedToBy() {
2195
2195
  return {
2196
- entityOfType: (...e) => y(this, T, E).call(this, (t) => filterByUuids(
2196
+ entityOfType: (...e) => g(this, T, E).call(this, (t) => filterByUuids(
2197
2197
  t,
2198
2198
  getUuidsPointedToByTypes(
2199
2199
  s(this, x).references,
@@ -2201,25 +2201,25 @@ const Kt = class Kt {
2201
2201
  ...e
2202
2202
  )
2203
2203
  )),
2204
- locations: (...e) => y(this, T, E).call(this, (t) => filterByUuids(
2204
+ locations: (...e) => g(this, T, E).call(this, (t) => filterByUuids(
2205
2205
  t,
2206
2206
  getUuidsPointedToByLocations(s(this, x).references, e)
2207
2207
  )),
2208
- entities: (...e) => y(this, T, E).call(this, (t) => filterByUuids(
2208
+ entities: (...e) => g(this, T, E).call(this, (t) => filterByUuids(
2209
2209
  t,
2210
2210
  getUuidsPointedToByEntities(s(this, x).references, e)
2211
2211
  ))
2212
2212
  };
2213
2213
  }
2214
2214
  };
2215
- x = new WeakMap(), lt = new WeakMap(), vt = new WeakMap(), T = new WeakSet(), /** Return a copy of this class, with a new function "appended" to the
2215
+ x = new WeakMap(), ut = new WeakMap(), vt = new WeakMap(), T = new WeakSet(), /** Return a copy of this class, with a new function "appended" to the
2216
2216
  * filter pipeline. The filter can change the type of the entity, or
2217
2217
  * remove entities from the query.
2218
2218
  */
2219
2219
  E = function(e) {
2220
2220
  return new Kt({
2221
2221
  documentState: s(this, x),
2222
- filterEntities: (t) => e(s(this, lt).call(this, t)),
2222
+ filterEntities: (t) => e(s(this, ut).call(this, t)),
2223
2223
  documentLock: s(this, vt)
2224
2224
  });
2225
2225
  }, gt = function() {
@@ -2363,8 +2363,8 @@ const filterByType = (i, e) => {
2363
2363
  ), assert(
2364
2364
  a.length === c.length,
2365
2365
  `tried overriding repeated field ${n.localName} with array of different length`
2366
- ), a.forEach((u, l) => {
2367
- c[l] = toFieldValue(i, n, c[l], u);
2366
+ ), a.forEach((d, l) => {
2367
+ c[l] = toFieldValue(i, n, c[l], d);
2368
2368
  });
2369
2369
  });
2370
2370
  }, toFieldValue = (i, e, t, n) => {
@@ -2423,24 +2423,24 @@ const filterByType = (i, e) => {
2423
2423
  const n = /* @__PURE__ */ new Map();
2424
2424
  e.forEach((l) => n.set(l.entity.id, l));
2425
2425
  const o = /* @__PURE__ */ new Map(), a = [];
2426
- [...n.values()].forEach(({ entity: l, overwrites: m }) => {
2427
- const d = entityToConstructorType(l), p = createDefaultEntityMessage(l.entityType);
2428
- p.id = t.get(l.id) ?? throw_();
2429
- const w = mapConstructorLocations(d, (v) => {
2430
- const g = t.get(v.entityId);
2431
- return g !== void 0 ? (a.push([p.id, g]), new NexusLocation(g, v.entityType, [
2426
+ [...n.values()].forEach(({ entity: l, overwrites: u }) => {
2427
+ const m = entityToConstructorType(l), f = createDefaultEntityMessage(l.entityType);
2428
+ f.id = t.get(l.id) ?? throw_();
2429
+ const y = mapConstructorLocations(m, (v) => {
2430
+ const w = t.get(v.entityId);
2431
+ return w !== void 0 ? (a.push([f.id, w]), new NexusLocation(w, v.entityType, [
2432
2432
  ...v.fieldIndex
2433
2433
  ])) : v;
2434
2434
  });
2435
- updateEntityMessageWithConstructor(p, w), m !== void 0 && updateEntityMessageWithConstructor(p, m), o.set(p.id, [l.entityType, p]);
2435
+ updateEntityMessageWithConstructor(f, y), u !== void 0 && updateEntityMessageWithConstructor(f, u), o.set(f.id, [l.entityType, f]);
2436
2436
  });
2437
- const c = toposort(a).reverse(), u = [...o.keys()].filter(
2437
+ const c = toposort(a).reverse(), d = [...o.keys()].filter(
2438
2438
  (l) => !c.includes(l)
2439
2439
  );
2440
2440
  return {
2441
- modifications: [...c, ...u].map((l) => {
2442
- const [, m] = o.get(l) ?? throw_();
2443
- return buildCreateModification(m);
2441
+ modifications: [...c, ...d].map((l) => {
2442
+ const [, u] = o.get(l) ?? throw_();
2443
+ return buildCreateModification(u);
2444
2444
  }),
2445
2445
  uuidMap: t
2446
2446
  };
@@ -2697,8 +2697,8 @@ const filterByType = (i, e) => {
2697
2697
  throw new CallAfterSendError("cloneLinked");
2698
2698
  const { modifications: n, uuidMap: o } = buildModificationsForCloneLinkedEntities(...t);
2699
2699
  return n.forEach((a) => i.applyModification(a, !0)), t.map((a) => {
2700
- const c = a instanceof NexusEntity ? a.id : a.entity.id, u = o.get(c) ?? throw_();
2701
- return i.query.mustGetEntity(u);
2700
+ const c = a instanceof NexusEntity ? a.id : a.entity.id, d = o.get(c) ?? throw_();
2701
+ return i.query.mustGetEntity(d);
2702
2702
  });
2703
2703
  },
2704
2704
  update: (t, n) => {
@@ -2770,10 +2770,10 @@ class CallAfterSendError extends Error {
2770
2770
  );
2771
2771
  }
2772
2772
  }
2773
- var dt, ht, ut, yt, xt, At, Dt, Ot, Gt;
2773
+ var mt, P, M, yt, xt, Dt, Ft, Ot, Gt;
2774
2774
  class NexusDocument {
2775
2775
  constructor(e) {
2776
- f(this, Ot);
2776
+ p(this, Ot);
2777
2777
  /** Public field to query the entities in the document.
2778
2778
  *
2779
2779
  * ## Careful
@@ -2817,64 +2817,52 @@ class NexusDocument {
2817
2817
  * If the transaction is incoming `local` is `false`.
2818
2818
  */
2819
2819
  r(this, "onModification", new Notifier());
2820
- /** Public field to query the entities in the document.
2821
- *
2822
- * @deprecated Don't use this field, as it can cause race conditions on the nexus document.
2823
- *
2824
- * Instead, use
2825
- * * for building a transaction: {@link TransactionBuilder.entities}
2826
- * * for other purposes, being aware of caveats: {@link NexusDocument.queryEntitiesWithoutLock}
2827
- *
2828
- */
2829
- r(this, "entities");
2830
2820
  /** Keeps track of all entities currently in the document. */
2831
- f(this, dt);
2821
+ p(this, mt);
2832
2822
  /**
2833
2823
  * Lock that protects transactions. Only one transaction can be created at a time.
2834
2824
  */
2835
- f(this, ht, new AsyncLock());
2825
+ p(this, P, new AsyncLock());
2836
2826
  /** The connection to the backend */
2837
- f(this, ut);
2827
+ p(this, M);
2838
2828
  /** Validates any and all modifications */
2839
- f(this, yt);
2829
+ p(this, yt);
2840
2830
  /**
2841
2831
  * This flag is set to true if {@link takeTransactions} is called. Before that, no transactions
2842
2832
  * from the backend are processed, and no transactions are allowed to be created from the frontend.
2843
2833
  *
2844
2834
  * This is to make sure that all `onCreate` callbacks are attached before any entity is created.
2845
2835
  */
2846
- f(this, xt, !1);
2836
+ p(this, xt, !1);
2847
2837
  /**
2848
2838
  * The number of modifications applied to the document for incoming transactions before control
2849
2839
  * is yield to the scheduler.
2850
2840
  */
2851
- f(this, At);
2841
+ p(this, Dt);
2852
2842
  /** The delay between two gateway.synchronize() calls to sync with backend. */
2853
- f(this, Dt);
2854
- h(this, Dt, (e == null ? void 0 : e.synchronizeEveryMs) ?? 16), h(this, At, (e == null ? void 0 : e.incomingModificationsBatchSize) ?? 20), h(this, dt, nexusDocumentState({
2843
+ p(this, Ft);
2844
+ h(this, Ft, (e == null ? void 0 : e.synchronizeEveryMs) ?? 16), h(this, Dt, (e == null ? void 0 : e.incomingModificationsBatchSize) ?? 20), h(this, mt, nexusDocumentState({
2855
2845
  callbacks: {
2856
- onStartPointingTo: (n, o) => {
2857
- this.events._dispatchPointingTo(o, n);
2846
+ onStartPointingTo: (t, n) => {
2847
+ this.events._dispatchPointingTo(n, t);
2858
2848
  },
2859
- onStopPointingTo: (n, o) => {
2860
- this.events._dispatchStopPointingTo(o, n);
2849
+ onStopPointingTo: (t, n) => {
2850
+ this.events._dispatchStopPointingTo(n, t);
2861
2851
  },
2862
- onUpdate: (n, o) => {
2863
- this.events._dispatchUpdate(n, o);
2852
+ onUpdate: (t, n) => {
2853
+ this.events._dispatchUpdate(t, n);
2864
2854
  },
2865
- onCreate: (n) => {
2866
- this.events._dispatchCreate(n);
2855
+ onCreate: (t) => {
2856
+ this.events._dispatchCreate(t);
2867
2857
  },
2868
- onDelete: (n) => {
2869
- this.events._dispatchRemove(n);
2858
+ onDelete: (t) => {
2859
+ this.events._dispatchRemove(t);
2870
2860
  }
2871
2861
  }
2872
- }));
2873
- const t = new EntityQuery({
2874
- documentState: s(this, dt),
2862
+ })), this.queryEntitiesWithoutLock = new EntityQuery({
2863
+ documentState: s(this, mt),
2875
2864
  documentLock: void 0
2876
- });
2877
- this.entities = t, this.queryEntitiesWithoutLock = t, this.events = new NexusEventManager(s(this, dt));
2865
+ }), this.events = new NexusEventManager(s(this, mt));
2878
2866
  }
2879
2867
  /**
2880
2868
  * This flag is set to true if {@link takeTransactions} is called. Before that, no transactions
@@ -2898,31 +2886,28 @@ class NexusDocument {
2898
2886
  * Note that every transaction by default is undoable, unless the flag in {@link TransactionOptions} is set to false.
2899
2887
  * @returns: {@link TransactionBuilder}
2900
2888
  */
2901
- async createTransaction(e) {
2902
- assert(
2903
- s(this, xt),
2904
- "Transactions not allowed yet - did you call `SyncedDocument.start()`?"
2905
- ), assert(s(this, ut) !== void 0, "Gateway not initialized"), assert(s(this, yt) !== void 0, "Validator not initialized");
2906
- const t = await s(this, ht).acquire(), n = [], o = new EntityQuery({
2907
- documentState: s(this, dt),
2908
- documentLock: s(this, ht)
2909
- }), a = (e == null ? void 0 : e.actionId) ?? Symbol();
2889
+ async createTransaction(e, t = !0) {
2890
+ assert(s(this, xt), "Transactions not allowed yet"), assert(s(this, M) !== void 0, "Gateway not initialized"), assert(s(this, yt) !== void 0, "Validator not initialized");
2891
+ const n = t ? await s(this, P).acquire() : void 0, o = [], a = new EntityQuery({
2892
+ documentState: s(this, mt),
2893
+ documentLock: s(this, P)
2894
+ }), c = (e == null ? void 0 : e.actionId) ?? Symbol();
2910
2895
  return transactionBuilder({
2911
- applyModification: (c, u) => {
2912
- const l = y(this, Ot, Gt).call(this, c, {
2896
+ applyModification: (d, l) => {
2897
+ const u = g(this, Ot, Gt).call(this, d, {
2913
2898
  local: !0,
2914
- throwIfInvalid: u,
2915
- actionId: a
2899
+ throwIfInvalid: l,
2900
+ actionId: c
2916
2901
  });
2917
- if (l !== void 0)
2918
- return l;
2919
- n.push(c);
2902
+ if (u !== void 0)
2903
+ return u;
2904
+ o.push(d);
2920
2905
  },
2921
2906
  finish: () => {
2922
- var c;
2923
- return n.length === 0 ? (t.release(), []) : ((c = s(this, ut)) == null || c.send(new Transaction({ modifications: n })), t.release(), n);
2907
+ var d;
2908
+ return o.length === 0 ? (n == null || n.release(), []) : ((d = s(this, M)) == null || d.send(new Transaction({ modifications: o })), n == null || n.release(), o);
2924
2909
  },
2925
- query: o
2910
+ query: a
2926
2911
  });
2927
2912
  }
2928
2913
  /**
@@ -2957,42 +2942,64 @@ class NexusDocument {
2957
2942
  async takeTransactions(e) {
2958
2943
  if (s(this, xt))
2959
2944
  throw new Error("called `takeTransactions()` twice");
2960
- h(this, yt, (e == null ? void 0 : e.validator) ?? mockNexusValidator()), h(this, ut, (e == null ? void 0 : e.gateway) ?? mockNexusGateway());
2945
+ h(this, yt, (e == null ? void 0 : e.validator) ?? mockNexusValidator()), h(this, M, (e == null ? void 0 : e.gateway) ?? mockNexusGateway());
2961
2946
  let t;
2962
- s(this, ut).blocked.subscribe(async (a) => {
2963
- a ? t === void 0 && (t = await s(this, ht).acquire()) : (t == null || t.release(), t = void 0);
2947
+ s(this, M).blocked.subscribe(async (l) => {
2948
+ l ? t === void 0 && (t = await s(this, P).acquire()) : (t == null || t.release(), t = void 0);
2964
2949
  });
2965
- const { promise: n, resolve: o } = Promise.withResolvers();
2966
- return (async () => {
2967
- for (; ; ) {
2968
- const a = (s(this, ut) ?? throw_()).synchronize();
2969
- await this.applyIncomingTransactions(a), a.length > 0 && o(), await sleep(s(this, Dt));
2950
+ const n = await s(this, P).acquire();
2951
+ h(this, xt, !0);
2952
+ const {
2953
+ promise: o,
2954
+ resolve: a
2955
+ } = Promise.withResolvers(), c = asyncInterval(async () => {
2956
+ const l = (s(this, M) ?? throw_()).synchronize();
2957
+ if (l.length === 0)
2958
+ return;
2959
+ const u = l.flatMap((m) => m.modifications).length;
2960
+ await this.applyIncomingTransactions(l, {
2961
+ _takeTransactionLock: !1
2962
+ }), c.terminate(), a(u > 0);
2963
+ }, s(this, Ft)), d = await o;
2964
+ if ((e == null ? void 0 : e.templateTransaction) !== void 0)
2965
+ if (d)
2966
+ console.error(
2967
+ "Could not apply template transaction to document: Project state from backend is not empty."
2968
+ );
2969
+ else {
2970
+ const l = await e.templateTransaction, u = await this.createTransaction(void 0, !1);
2971
+ l.modifications.forEach((m) => u._addModification(m)), u.send();
2970
2972
  }
2971
- })(), h(this, xt, !0), n;
2973
+ n.release(), asyncInterval(async () => {
2974
+ const l = await s(this, P).acquire(), u = (s(this, M) ?? throw_()).synchronize();
2975
+ await this.applyIncomingTransactions(u, { _takeTransactionLock: !1 }), l.release();
2976
+ }, s(this, Ft));
2972
2977
  }
2973
2978
  /** Apply a transaction that doesn't originate from this document. Yields to the browser
2974
2979
  * scheduler every few modifications applied to make sure we don't block the main thread
2975
2980
  * for too long for big transactions. Throws if the transaction lock isn't taken.
2981
+ *
2976
2982
  */
2977
- async applyIncomingTransactions(e) {
2978
- assert(s(this, ut) !== void 0, "Gateway not initialized"), assert(s(this, yt) !== void 0, "Validator not initialized");
2979
- const t = await s(this, ht).acquire();
2980
- for (const n of e) {
2981
- let o = n.modifications.shift(), a = 0;
2982
- for (; o !== void 0; )
2983
- y(this, Ot, Gt).call(this, o, {
2983
+ async applyIncomingTransactions(e, t) {
2984
+ assert(s(this, M) !== void 0, "Gateway not initialized"), assert(s(this, yt) !== void 0, "Validator not initialized");
2985
+ const n = (t == null ? void 0 : t._takeTransactionLock) ?? !0 ? await s(this, P).acquire() : assert(
2986
+ s(this, P).locked,
2987
+ "if takeTransactionLock is false, the lock must be held."
2988
+ );
2989
+ for (const o of e)
2990
+ for (const [a, c] of o.modifications.entries())
2991
+ g(this, Ot, Gt).call(this, c, {
2984
2992
  local: !1,
2985
2993
  throwIfInvalid: !0
2986
- }), o = n.modifications.shift(), a += 1, a % s(this, At) === 0 && await sleep(0);
2987
- }
2988
- t.release();
2994
+ }), a % s(this, Dt) === 0 && await sleep(0);
2995
+ n == null || n.release();
2989
2996
  }
2990
2997
  /** For debugging purposes */
2991
2998
  getStats() {
2992
- return s(this, dt).getStats();
2999
+ return s(this, mt).getStats();
2993
3000
  }
2994
3001
  }
2995
- dt = new WeakMap(), ht = new WeakMap(), ut = new WeakMap(), yt = new WeakMap(), xt = new WeakMap(), At = new WeakMap(), Dt = new WeakMap(), Ot = new WeakSet(), /**
3002
+ mt = new WeakMap(), P = new WeakMap(), M = new WeakMap(), yt = new WeakMap(), xt = new WeakMap(), Dt = new WeakMap(), Ft = new WeakMap(), Ot = new WeakSet(), /**
2996
3003
  * Apply a modification to the document after validating it, and dispatch events to
2997
3004
  * {@link onModification} listeners. Throws if the modification is invalid, unless `throwIfInvalid` is false;
2998
3005
  * in that case, the function returns `string` on error and doesn't change the document state. If application
@@ -3004,7 +3011,7 @@ Gt = function(e, {
3004
3011
  actionId: o
3005
3012
  }) {
3006
3013
  assert(s(this, yt) !== void 0, "Validator not initialized"), assert(
3007
- s(this, ht).locked,
3014
+ s(this, P).locked,
3008
3015
  "tried applying modification without lock"
3009
3016
  );
3010
3017
  const a = s(this, yt).validate(e);
@@ -3013,16 +3020,16 @@ Gt = function(e, {
3013
3020
  throw new Error(`modification failed validation: ${a}`);
3014
3021
  return a;
3015
3022
  }
3016
- s(this, dt).applyModification(e), this.onModification.notify({ modification: e, local: t, actionId: o });
3023
+ s(this, mt).applyModification(e), this.onModification.notify({ modification: e, local: t, actionId: o });
3017
3024
  };
3018
- var k, S;
3025
+ var I, S;
3019
3026
  class NexusStateConsolidator {
3020
3027
  constructor(e) {
3021
3028
  /**
3022
3029
  * A copy of the document state, to validate that pending transactions can still be applied,
3023
3030
  * and drop them if not.
3024
3031
  */
3025
- f(this, k);
3032
+ p(this, I);
3026
3033
  /**
3027
3034
  * Transactions not yet confirmed or rejected by the remote.
3028
3035
  *
@@ -3030,8 +3037,8 @@ class NexusStateConsolidator {
3030
3037
  * applied to {@link #state}, while backwards contains their respective reverse, so the state
3031
3038
  * before all transactions in {@link #pending} can be restored.
3032
3039
  */
3033
- f(this, S, []);
3034
- h(this, k, e);
3040
+ p(this, S, []);
3041
+ h(this, I, e);
3035
3042
  }
3036
3043
  /**
3037
3044
  * Consolidate the local and remote transaction history.
@@ -3042,11 +3049,11 @@ class NexusStateConsolidator {
3042
3049
  * @returns Transactions needed to sync local & remote, plus transactions created but not yet received
3043
3050
  */
3044
3051
  consolidate(e, t, n) {
3045
- n.forEach((u) => {
3046
- const l = s(this, k).applyTransaction(u);
3052
+ n.forEach((d) => {
3053
+ const l = s(this, I).applyTransaction(d);
3047
3054
  if (!(l instanceof Transaction))
3048
3055
  throw new Error(`Error applying reverse transaction: ${l}`);
3049
- s(this, S).push([u, l]);
3056
+ s(this, S).push([d, l]);
3050
3057
  });
3051
3058
  let o = e[0], a = s(this, S)[0];
3052
3059
  for (; o !== void 0 && a !== void 0 && o.id === a[0].id; )
@@ -3054,47 +3061,50 @@ class NexusStateConsolidator {
3054
3061
  if (e.length === 0) {
3055
3062
  if (t.size === 0)
3056
3063
  return [];
3057
- const u = s(this, S).splice(
3058
- s(this, S).findIndex(
3059
- ([d]) => t.has(d.id)
3060
- )
3061
- ), l = u.map(([, d]) => {
3062
- if (!(s(this, k).applyTransaction(d) instanceof Transaction))
3064
+ const d = s(this, S).findIndex(
3065
+ ([f]) => t.has(f.id)
3066
+ );
3067
+ if (d === -1)
3068
+ throw new Error(
3069
+ "Invariant violation: expected to find rejected transaction in #pending, but didn't. This is a bug."
3070
+ );
3071
+ const l = s(this, S).splice(d), u = l.map(([, f]) => {
3072
+ if (!(s(this, I).applyTransaction(f) instanceof Transaction))
3063
3073
  throw new Error("error applying reversal of transaction");
3064
- return d;
3065
- }).reverse(), m = u.filter(([d]) => !t.has(d.id)).map(([d]) => {
3066
- const p = s(this, k).applyTransaction(d);
3067
- if (p instanceof Transaction)
3068
- return [d, p];
3069
- }).filter((d) => d !== void 0);
3070
- return s(this, S).push(...m), [...l, ...m.map(([d]) => d)];
3074
+ return f;
3075
+ }).reverse(), m = l.filter(([f]) => !t.has(f.id)).map(([f]) => {
3076
+ const y = s(this, I).applyTransaction(f);
3077
+ if (y instanceof Transaction)
3078
+ return [f, y];
3079
+ }).filter((f) => f !== void 0);
3080
+ return s(this, S).push(...m), [...u, ...m.map(([f]) => f)];
3071
3081
  }
3072
- const c = s(this, S).map((u) => u[1].clone()).reverse();
3073
- return c.forEach((u) => {
3074
- const l = s(this, k).applyTransaction(u);
3082
+ const c = s(this, S).map((d) => d[1].clone()).reverse();
3083
+ return c.forEach((d) => {
3084
+ const l = s(this, I).applyTransaction(d);
3075
3085
  if (!(l instanceof Transaction))
3076
3086
  throw new Error(`Error applying reverse transaction: ${l}`);
3077
- }), e.forEach((u) => {
3078
- const l = s(this, k).applyTransaction(u);
3087
+ }), e.forEach((d) => {
3088
+ const l = s(this, I).applyTransaction(d);
3079
3089
  if (!(l instanceof Transaction))
3080
3090
  throw new Error(`Error applying incoming transaction: ${l}`);
3081
- }), h(this, S, s(this, S).filter(([u]) => {
3082
- const l = t.has(u.id), m = e.some(
3083
- (d) => d.id === u.id
3091
+ }), h(this, S, s(this, S).filter(([d]) => {
3092
+ const l = t.has(d.id), u = e.some(
3093
+ (m) => m.id === d.id
3084
3094
  );
3085
- return !l && !m;
3086
- }).map(([u]) => {
3087
- const l = s(this, k).applyTransaction(u);
3088
- return l instanceof Transaction ? [u, l] : void 0;
3089
- }).filter((u) => u !== void 0)), [
3095
+ return !l && !u;
3096
+ }).map(([d]) => {
3097
+ const l = s(this, I).applyTransaction(d);
3098
+ return l instanceof Transaction ? [d, l] : void 0;
3099
+ }).filter((d) => d !== void 0)), [
3090
3100
  ...c,
3091
3101
  ...e,
3092
- ...s(this, S).map(([u]) => u)
3102
+ ...s(this, S).map(([d]) => d)
3093
3103
  ];
3094
3104
  }
3095
3105
  }
3096
- k = new WeakMap(), S = new WeakMap();
3097
- var qt, jt, Rt, $t, Ft, Vt, bt, Jt, Ct;
3106
+ I = new WeakMap(), S = new WeakMap();
3107
+ var qt, jt, Rt, $t, Jt, Vt, bt, Ct, Lt;
3098
3108
  const wt = class wt {
3099
3109
  constructor({
3100
3110
  documentService: e,
@@ -3104,33 +3114,33 @@ const wt = class wt {
3104
3114
  logConsolidatedTransactions: a,
3105
3115
  logRejectedTransactions: c
3106
3116
  }) {
3107
- f(this, qt);
3108
- f(this, jt);
3109
- f(this, Rt, !1);
3117
+ p(this, qt);
3118
+ p(this, jt);
3119
+ p(this, Rt, !1);
3110
3120
  // = false due to ts complaining
3111
- f(this, $t);
3121
+ p(this, $t);
3112
3122
  // the connection to the backend, to send & receive transactions
3113
- f(this, Ft);
3123
+ p(this, Jt);
3114
3124
  r(this, "blocked");
3115
- f(this, Vt);
3116
- f(this, bt, []);
3117
- f(this, Jt, []);
3118
- f(this, Ct, /* @__PURE__ */ new Set());
3119
- h(this, Ft, e), h(this, Vt, new NexusStateConsolidator(t)), h(this, $t, a ?? !1), h(this, Rt, o ?? !1), h(this, jt, n ?? !1), h(this, qt, c ?? !1), (async () => {
3125
+ p(this, Vt);
3126
+ p(this, bt, []);
3127
+ p(this, Ct, []);
3128
+ p(this, Lt, /* @__PURE__ */ new Set());
3129
+ h(this, Jt, e), h(this, Vt, new NexusStateConsolidator(t)), h(this, $t, a ?? !1), h(this, Rt, o ?? !1), h(this, jt, n ?? !1), h(this, qt, c ?? !1), (async () => {
3120
3130
  for (; ; ) {
3121
3131
  const l = await e.receiveNextTransaction();
3122
3132
  s(this, bt).push(l), wt.stats.numReceivedCtr++, s(this, Rt) && console.debug("CollabGateway: received transaction", l);
3123
3133
  }
3124
3134
  })();
3125
- const u = new ValueNotifier(!1);
3126
- s(this, Ft).connectionOk.subscribe((l) => {
3127
- u.setValue(!l);
3128
- }), this.blocked = u;
3135
+ const d = new ValueNotifier(!1);
3136
+ s(this, Jt).connectionOk.subscribe((l) => {
3137
+ d.setValue(!l);
3138
+ }), this.blocked = d;
3129
3139
  }
3130
3140
  /** Send a transaction to the document service. */
3131
3141
  send(e) {
3132
- e.id = crypto.randomUUID(), s(this, Jt).push(e.clone()), wt.stats.numQueuedCtr++, s(this, jt) && console.debug("CollabGateway: sending local transaction", e), s(this, Ft).sendNextTransaction(e).then((t) => {
3133
- wt.stats.numConfirmedCtr++, t !== void 0 && (s(this, Ct).add(e.id), s(this, qt) && console.debug(
3142
+ e.id = crypto.randomUUID(), s(this, Ct).push(e.clone()), wt.stats.numQueuedCtr++, s(this, jt) && console.debug("CollabGateway: sending local transaction", e), s(this, Jt).sendNextTransaction(e).then((t) => {
3143
+ wt.stats.numConfirmedCtr++, t !== void 0 && (s(this, Lt).add(e.id), s(this, qt) && console.debug(
3134
3144
  "CollabGateway: received rejected transaction",
3135
3145
  e,
3136
3146
  t
@@ -3141,13 +3151,13 @@ const wt = class wt {
3141
3151
  synchronize() {
3142
3152
  const e = s(this, bt).length > 0, t = s(this, Vt).consolidate(
3143
3153
  s(this, bt),
3144
- s(this, Ct),
3145
- s(this, Jt)
3154
+ s(this, Lt),
3155
+ s(this, Ct)
3146
3156
  );
3147
- return s(this, bt).length = 0, s(this, Ct).clear(), s(this, Jt).length = 0, s(this, $t) && e && console.debug("CollabGateway: consolidated transactions", t), t;
3157
+ return s(this, bt).length = 0, s(this, Lt).clear(), s(this, Ct).length = 0, s(this, $t) && e && console.debug("CollabGateway: consolidated transactions", t), t;
3148
3158
  }
3149
3159
  };
3150
- qt = new WeakMap(), jt = new WeakMap(), Rt = new WeakMap(), $t = new WeakMap(), Ft = new WeakMap(), Vt = new WeakMap(), bt = new WeakMap(), Jt = new WeakMap(), Ct = new WeakMap(), /**
3160
+ qt = new WeakMap(), jt = new WeakMap(), Rt = new WeakMap(), $t = new WeakMap(), Jt = new WeakMap(), Vt = new WeakMap(), bt = new WeakMap(), Ct = new WeakMap(), Lt = new WeakMap(), /**
3151
3161
  * Some stats, useful for debugging.
3152
3162
  */
3153
3163
  r(wt, "stats", {
@@ -3167,7 +3177,7 @@ class BufferedSender {
3167
3177
  /** Contains data to be sent out during the next batched send. The second element resolves the promise
3168
3178
  * created in `send` for that data.
3169
3179
  */
3170
- f(this, Ut, []);
3180
+ p(this, Ut, []);
3171
3181
  (async () => {
3172
3182
  for (; ; ) {
3173
3183
  const n = s(this, Ut).splice(0, s(this, Ut).length);
@@ -3204,45 +3214,45 @@ const createPingNotifier = (i, e, t, n) => {
3204
3214
  callIsOk: n
3205
3215
  }
3206
3216
  );
3207
- const u = Date.now() - c;
3208
- await sleep(Math.max(0, t - u)), o.setValue(u / 2);
3217
+ const d = Date.now() - c;
3218
+ await sleep(Math.max(0, t - d)), o.setValue(d / 2);
3209
3219
  }
3210
3220
  })(), o;
3211
3221
  }, createReceiveNextTransactionFn = (i, e, t, n, o) => {
3212
3222
  let a = 0;
3213
3223
  const c = () => i.attach({ projectName: e, commitIndex: a }, { signal: o() })[Symbol.asyncIterator]();
3214
- let u = c(), l = !1;
3224
+ let d = c(), l = !1;
3215
3225
  return async () => {
3216
3226
  for (; ; )
3217
3227
  try {
3218
- const { value: m, done: d } = await u.next();
3219
- if (d ?? !1)
3228
+ const { value: u, done: m } = await d.next();
3229
+ if (m ?? !1)
3220
3230
  throw new Error("document service attach stream closed");
3221
- switch (t.setValue(!0), m.message.case) {
3231
+ switch (t.setValue(!0), u.message.case) {
3222
3232
  case "noop": {
3223
3233
  if (l)
3224
3234
  continue;
3225
3235
  return l = !0, new Transaction();
3226
3236
  }
3227
3237
  case "transaction": {
3228
- const p = m.message.value;
3229
- return a = p.commitIndex, l = !0, p;
3238
+ const f = u.message.value;
3239
+ return a = f.commitIndex, l = !0, f;
3230
3240
  }
3231
3241
  default:
3232
3242
  throw new Error(
3233
- `received attach response with unknown message case: ${m.message.case}`
3243
+ `received attach response with unknown message case: ${u.message.case}`
3234
3244
  );
3235
3245
  }
3236
- } catch (m) {
3237
- if (!(m instanceof ConnectError))
3238
- throw m;
3239
- switch (m.code) {
3246
+ } catch (u) {
3247
+ if (!(u instanceof ConnectError))
3248
+ throw u;
3249
+ switch (u.code) {
3240
3250
  case Code.Canceled:
3241
3251
  // happens if abort controller throws
3242
3252
  case Code.Aborted:
3243
3253
  case Code.Unavailable:
3244
3254
  case Code.Unknown: {
3245
- t.setValue(!1), console.debug("Connection lost:", m.message, " - retrying..."), await sleep(n + Math.random() * n * 0.1), u = c();
3255
+ t.setValue(!1), console.debug("Connection lost:", u.message, " - retrying..."), await sleep(n + Math.random() * n * 0.1), d = c();
3246
3256
  continue;
3247
3257
  }
3248
3258
  case Code.OutOfRange:
@@ -3250,7 +3260,7 @@ const createPingNotifier = (i, e, t, n) => {
3250
3260
  "local document state too far in the past, must reload tab"
3251
3261
  );
3252
3262
  default:
3253
- throw m;
3263
+ throw u;
3254
3264
  }
3255
3265
  }
3256
3266
  };
@@ -3262,8 +3272,8 @@ const createPingNotifier = (i, e, t, n) => {
3262
3272
  }) => {
3263
3273
  let o = new AbortController();
3264
3274
  const a = new ValueNotifier(!0);
3265
- a.subscribe((g) => {
3266
- g ? o = new AbortController() : o.abort("ping called failed, connection assumed lost");
3275
+ a.subscribe((w) => {
3276
+ w ? o = new AbortController() : o.abort("ping called failed, connection assumed lost");
3267
3277
  });
3268
3278
  let c;
3269
3279
  c = createPingNotifier(
@@ -3272,39 +3282,39 @@ const createPingNotifier = (i, e, t, n) => {
3272
3282
  e,
3273
3283
  a
3274
3284
  );
3275
- const u = new ValueNotifier(!0), l = createReceiveNextTransactionFn(
3285
+ const d = new ValueNotifier(!0), l = createReceiveNextTransactionFn(
3276
3286
  n,
3277
3287
  i,
3278
- u,
3288
+ d,
3279
3289
  t,
3280
3290
  () => o.signal
3281
- ), m = new ValueNotifier(!0), d = new BufferedSender(
3282
- async (g) => {
3291
+ ), u = new ValueNotifier(!0), m = new BufferedSender(
3292
+ async (w) => {
3283
3293
  const b = await n.applyTransactions(
3284
3294
  {
3285
3295
  projectName: i,
3286
- transactions: g
3296
+ transactions: w
3287
3297
  },
3288
3298
  {
3289
- callIsOk: m
3299
+ callIsOk: u
3290
3300
  }
3291
3301
  );
3292
3302
  if (b instanceof Error)
3293
3303
  throw new Error("error sending transaction", { cause: b });
3294
- return g.map(
3295
- (M) => b.errors[M.id] ?? void 0
3304
+ return w.map(
3305
+ (N) => b.errors[N.id] ?? void 0
3296
3306
  );
3297
3307
  }
3298
- ), p = async (g) => await d.send(g), w = combinedValueNotifiersWithAnd(
3308
+ ), f = async (w) => await m.send(w), y = combinedValueNotifiersWithAnd(
3299
3309
  a,
3300
- u,
3301
- m
3310
+ d,
3311
+ u
3302
3312
  );
3303
3313
  return {
3304
3314
  ping: c,
3305
- connectionOk: w,
3315
+ connectionOk: y,
3306
3316
  receiveNextTransaction: l,
3307
- sendNextTransaction: p
3317
+ sendNextTransaction: f
3308
3318
  };
3309
3319
  }, initCollabGateway = async (i, e) => {
3310
3320
  const t = createDocumentServiceWrapper({
@@ -3486,7 +3496,7 @@ const createPingNotifier = (i, e, t, n) => {
3486
3496
  }
3487
3497
  }
3488
3498
  }, createOnlineDocument = async (i, e, t) => {
3489
- var m;
3499
+ var u;
3490
3500
  let n = createWasmNexusValidator();
3491
3501
  const o = await i.projectService.openSession({
3492
3502
  projectName: e
@@ -3496,7 +3506,7 @@ const createPingNotifier = (i, e, t, n) => {
3496
3506
  const a = createRetryingPromiseClient(
3497
3507
  DocumentService,
3498
3508
  createAuthorizedKeepaliveTransport({
3499
- baseUrl: ((m = o.session) == null ? void 0 : m.documentServiceUrl) ?? throw_("backend returned no document service url"),
3509
+ baseUrl: ((u = o.session) == null ? void 0 : u.documentServiceUrl) ?? throw_("backend returned no document service url"),
3500
3510
  useBinaryFormat: !0,
3501
3511
  getToken: t
3502
3512
  })
@@ -3505,8 +3515,8 @@ const createPingNotifier = (i, e, t, n) => {
3505
3515
  const c = await initCollabGateway(
3506
3516
  e ?? throw_(),
3507
3517
  a
3508
- ), u = new NexusDocument(), l = new ValueNotifier(!1);
3509
- return c.blocked.subscribe((d) => l.setValue(!d)), createSyncedDocument(u, l, await n, c);
3518
+ ), d = new NexusDocument(), l = new ValueNotifier(!1);
3519
+ return c.blocked.subscribe((m) => l.setValue(!m)), createSyncedDocument(d, l, await n, c);
3510
3520
  }, createOfflineDocument = async (i) => {
3511
3521
  const e = i ? await createWasmNexusValidator() : mockNexusValidator(), t = mockNexusGateway(), n = new NexusDocument(), o = new ValueNotifier(!0);
3512
3522
  return createSyncedDocument(n, o, e, t);
@@ -3562,17 +3572,17 @@ const createPingNotifier = (i, e, t, n) => {
3562
3572
  codeVerifier: `oidc_${i}_oidc_code_verifier`,
3563
3573
  userName: `oidc_${i}_oidc_user_name`,
3564
3574
  state: `oidc_${i}_oidc_state`
3565
- }, o = () => redirectUserToLogin(n, i, t, e), a = new URLSearchParams(window.location.search), c = a.get("error"), u = a.get("error_description");
3575
+ }, o = () => redirectUserToLogin(n, i, t, e), a = new URLSearchParams(window.location.search), c = a.get("error"), d = a.get("error_description");
3566
3576
  if (c != null)
3567
3577
  return cleanupUrl(), cleanUpLocalStorage(n), {
3568
3578
  loggedIn: !1,
3569
- error: toError(c, u),
3579
+ error: toError(c, d),
3570
3580
  login: o
3571
3581
  };
3572
3582
  const l = a.get("code");
3573
3583
  if (l != null) {
3574
- const p = a.get("state"), w = localStorage.getItem(n.state);
3575
- if (p == null || w == null || p !== w)
3584
+ const f = a.get("state"), y = localStorage.getItem(n.state);
3585
+ if (f == null || y == null || f !== y)
3576
3586
  return {
3577
3587
  loggedIn: !1,
3578
3588
  error: toError(
@@ -3588,7 +3598,7 @@ const createPingNotifier = (i, e, t, n) => {
3588
3598
  error: toError("Code verifier not found. Restart the auth flow."),
3589
3599
  login: o
3590
3600
  };
3591
- const g = await fetch(TOKEN_ENDPOINT, {
3601
+ const w = await fetch(TOKEN_ENDPOINT, {
3592
3602
  method: "POST",
3593
3603
  headers: {
3594
3604
  "Content-Type": "application/x-www-form-urlencoded"
@@ -3603,47 +3613,47 @@ const createPingNotifier = (i, e, t, n) => {
3603
3613
  })
3604
3614
  }), {
3605
3615
  access_token: b,
3606
- refresh_token: M,
3616
+ refresh_token: N,
3607
3617
  expires_in: St,
3608
3618
  error: Ht,
3609
3619
  error_description: Yt
3610
- } = await g.json();
3620
+ } = await w.json();
3611
3621
  if (Ht)
3612
3622
  return {
3613
3623
  loggedIn: !1,
3614
3624
  error: toError(Ht, Yt),
3615
3625
  login: o
3616
3626
  };
3617
- localStorage.setItem(n.accessToken, b), localStorage.setItem(n.refreshToken, M), localStorage.setItem(
3627
+ localStorage.setItem(n.accessToken, b), localStorage.setItem(n.refreshToken, N), localStorage.setItem(
3618
3628
  n.expiresAt,
3619
3629
  (Date.now() + St * 1e3).toString()
3620
3630
  ), cleanupUrl(), localStorage.removeItem(n.codeVerifier);
3621
3631
  }
3622
3632
  localStorage.removeItem(n.state);
3623
- const m = await getOrFetchValidToken(n, i);
3624
- let d;
3625
- if (typeof m == "string") {
3626
- const p = async () => {
3627
- if (d == null) {
3628
- d = (async () => await getOrFetchValidToken(n, i) ?? new Error("User not logged in."))();
3629
- const v = await d;
3630
- return d = void 0, v;
3633
+ const u = await getOrFetchValidToken(n, i);
3634
+ let m;
3635
+ if (typeof u == "string") {
3636
+ const f = async () => {
3637
+ if (m == null) {
3638
+ m = (async () => await getOrFetchValidToken(n, i) ?? new Error("User not logged in."))();
3639
+ const v = await m;
3640
+ return m = void 0, v;
3631
3641
  }
3632
- return await d;
3642
+ return await m;
3633
3643
  };
3634
- let w;
3644
+ let y;
3635
3645
  return {
3636
3646
  loggedIn: !0,
3637
- getToken: p,
3647
+ getToken: f,
3638
3648
  getUserName: async () => {
3639
- if (w !== void 0)
3640
- return await w;
3641
- const { promise: v, resolve: g } = Promise.withResolvers();
3642
- w = v;
3643
- const b = await p();
3649
+ if (y !== void 0)
3650
+ return await y;
3651
+ const { promise: v, resolve: w } = Promise.withResolvers();
3652
+ y = v;
3653
+ const b = await f();
3644
3654
  if (b instanceof Error)
3645
- return g(b), await w;
3646
- const M = await neverThrowingFetch(
3655
+ return w(b), await y;
3656
+ const N = await neverThrowingFetch(
3647
3657
  `${API_ENDPOINT}/audiotool.auth.v1.AuthService/GetWhoami`,
3648
3658
  {
3649
3659
  method: "POST",
@@ -3654,12 +3664,12 @@ const createPingNotifier = (i, e, t, n) => {
3654
3664
  body: JSON.stringify({})
3655
3665
  }
3656
3666
  );
3657
- if (M instanceof Error)
3658
- return g(M), await w;
3659
- if (!M.ok)
3660
- return g(new Error(`Failed to get user info: ${M.statusText}`)), await w;
3661
- const { whoami: St } = await M.json();
3662
- return console.debug("whoami", St), g((St == null ? void 0 : St.userName) ?? "Unknown User"), await w;
3667
+ if (N instanceof Error)
3668
+ return w(N), await y;
3669
+ if (!N.ok)
3670
+ return w(new Error(`Failed to get user info: ${N.statusText}`)), await y;
3671
+ const { whoami: St } = await N.json();
3672
+ return console.debug("whoami", St), w((St == null ? void 0 : St.userName) ?? "Unknown User"), await y;
3663
3673
  },
3664
3674
  logout() {
3665
3675
  cleanUpLocalStorage(n), cleanupUrl(), window.location.reload();
@@ -3668,7 +3678,7 @@ const createPingNotifier = (i, e, t, n) => {
3668
3678
  }
3669
3679
  return {
3670
3680
  loggedIn: !1,
3671
- error: m,
3681
+ error: u,
3672
3682
  login: o
3673
3683
  };
3674
3684
  }, cleanUpLocalStorage = (i) => {
@@ -3685,8 +3695,8 @@ const createPingNotifier = (i, e, t, n) => {
3685
3695
  localStorage.setItem(i.codeVerifier, o);
3686
3696
  const a = await generateCodeChallenge(o), c = crypto.getRandomValues(new Uint8Array(16)).join("");
3687
3697
  localStorage.setItem(i.state, c);
3688
- const u = new URL(AUTHORIZATION_ENDPOINT);
3689
- u.search = new URLSearchParams({
3698
+ const d = new URL(AUTHORIZATION_ENDPOINT);
3699
+ d.search = new URLSearchParams({
3690
3700
  response_type: "code",
3691
3701
  client_id: e,
3692
3702
  scope: t,
@@ -3694,7 +3704,7 @@ const createPingNotifier = (i, e, t, n) => {
3694
3704
  code_challenge: a,
3695
3705
  redirect_uri: n,
3696
3706
  state: c
3697
- }).toString(), window.location.href = u.toString();
3707
+ }).toString(), window.location.href = d.toString();
3698
3708
  }, toError = (i, e) => (e = e ? `: ${e}` : "", new Error(`${i}${e}`)), generateCodeVerifier = () => {
3699
3709
  const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
3700
3710
  return crypto.getRandomValues(new Uint8Array(64)).reduce(
@@ -3710,8 +3720,8 @@ const createPingNotifier = (i, e, t, n) => {
3710
3720
  return;
3711
3721
  let n = !0;
3712
3722
  {
3713
- const p = localStorage.getItem(i.expiresAt);
3714
- n = p == null ? !0 : Date.now() >= parseInt(p) - 6e4;
3723
+ const f = localStorage.getItem(i.expiresAt);
3724
+ n = f == null ? !0 : Date.now() >= parseInt(f) - 6e4;
3715
3725
  }
3716
3726
  if (!n)
3717
3727
  return t;
@@ -3735,10 +3745,10 @@ const createPingNotifier = (i, e, t, n) => {
3735
3745
  return new Error(`Error during refresh token request: ${a.name}`, {
3736
3746
  cause: a.message
3737
3747
  });
3738
- const { error: c, error_description: u, access_token: l, refresh_token: m, expires_in: d } = await a.json();
3739
- return c ? toError(c, u) : (localStorage.setItem(i.accessToken, l), localStorage.setItem(i.refreshToken, m), localStorage.setItem(
3748
+ const { error: c, error_description: d, access_token: l, refresh_token: u, expires_in: m } = await a.json();
3749
+ return c ? toError(c, d) : (localStorage.setItem(i.accessToken, l), localStorage.setItem(i.refreshToken, u), localStorage.setItem(
3740
3750
  i.expiresAt,
3741
- (Date.now() + d * 1e3).toString()
3751
+ (Date.now() + m * 1e3).toString()
3742
3752
  ), l);
3743
3753
  };
3744
3754
  export {