@milaboratories/pl-drivers 1.2.34 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/clients/download.d.ts +5 -2
  2. package/dist/clients/download.d.ts.map +1 -1
  3. package/dist/clients/helpers.d.ts +2 -2
  4. package/dist/clients/helpers.d.ts.map +1 -1
  5. package/dist/drivers/helpers/ls_list_entry.d.ts +8 -13
  6. package/dist/drivers/helpers/ls_list_entry.d.ts.map +1 -1
  7. package/dist/drivers/helpers/ls_storage_entry.d.ts +6 -8
  8. package/dist/drivers/helpers/ls_storage_entry.d.ts.map +1 -1
  9. package/dist/drivers/ls.d.ts +40 -12
  10. package/dist/drivers/ls.d.ts.map +1 -1
  11. package/dist/drivers/types.d.ts +80 -0
  12. package/dist/drivers/types.d.ts.map +1 -0
  13. package/dist/drivers/upload.d.ts +18 -26
  14. package/dist/drivers/upload.d.ts.map +1 -1
  15. package/dist/helpers/validate.d.ts +2 -0
  16. package/dist/helpers/validate.d.ts.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +943 -918
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +5 -5
  24. package/src/clients/download.test.ts +5 -14
  25. package/src/clients/download.ts +13 -5
  26. package/src/clients/helpers.ts +13 -43
  27. package/src/drivers/download_blob.test.ts +4 -4
  28. package/src/drivers/helpers/ls_list_entry.test.ts +5 -7
  29. package/src/drivers/helpers/ls_list_entry.ts +31 -36
  30. package/src/drivers/helpers/ls_storage_entry.ts +18 -62
  31. package/src/drivers/logs.test.ts +3 -3
  32. package/src/drivers/ls.test.ts +112 -30
  33. package/src/drivers/ls.ts +233 -83
  34. package/src/drivers/types.ts +41 -0
  35. package/src/drivers/upload.test.ts +43 -82
  36. package/src/drivers/upload.ts +59 -111
  37. package/src/helpers/validate.ts +6 -0
  38. package/src/index.ts +3 -0
package/dist/index.mjs CHANGED
@@ -1,27 +1,29 @@
1
- var ze = Object.defineProperty;
2
- var xe = (s, e, t) => e in s ? ze(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var c = (s, e, t) => xe(s, typeof e != "symbol" ? e + "" : e, t);
4
- import * as b from "node:fs/promises";
5
- import { addRTypeToMetadata as T, valErr as Me, getField as He, isNullResourceId as je, bigintToResourceId as Q, stringifyWithResourceId as B, isNotNullResourceId as Ge } from "@milaboratories/pl-client";
6
- import { ServiceType as v, stackIntercept as w } from "@protobuf-ts/runtime-rpc";
7
- import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as ge } from "@protobuf-ts/runtime";
8
- import { request as fe } from "undici";
9
- import { notEmpty as O, mapGet as oe, mapEntries as Ve, TaskProcessor as X, CallersCounter as D, asyncPool as Y, fileExists as qe, assertNever as Ze } from "@milaboratories/ts-helpers";
10
- import { Readable as K, Writable as ee, Transform as Je } from "node:stream";
11
- import * as E from "node:fs";
12
- import * as m from "node:path";
13
- import { text as Qe, buffer as me } from "node:stream/consumers";
14
- import { Computable as y, ChangeSource as S, PollingComputableHooks as we } from "@milaboratories/computable";
15
- import { scheduler as te } from "node:timers/promises";
16
- import * as Xe from "node:readline/promises";
17
- import Ye from "denque";
18
- import * as se from "node:os";
19
- import { randomUUID as k, createHash as Ke } from "node:crypto";
20
- import { rsSchema as ye, treeEntryToResourceInfo as N, isPlTreeEntry as be, makeResourceSnapshot as Te } from "@milaboratories/pl-tree";
21
- import { z as L } from "zod";
22
- import * as et from "node:zlib";
23
- import * as tt from "tar-fs";
24
- class rt extends g {
1
+ var He = Object.defineProperty;
2
+ var je = (s, e, t) => e in s ? He(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var d = (s, e, t) => je(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import * as m from "node:fs/promises";
5
+ import { addRTypeToMetadata as k, valErr as Ge, getField as Ve, isNullResourceId as qe, bigintToResourceId as Y, stringifyWithResourceId as Je, isNotNullResourceId as Ze } from "@milaboratories/pl-client";
6
+ import { ServiceType as D, stackIntercept as y } from "@protobuf-ts/runtime-rpc";
7
+ import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as be } from "@protobuf-ts/runtime";
8
+ import { request as Te } from "undici";
9
+ import { notEmpty as K, mapGet as ce, mapEntries as Qe, TaskProcessor as ee, CallersCounter as v, asyncPool as te, fileExists as Xe, assertNever as Ye } from "@milaboratories/ts-helpers";
10
+ import { Readable as re, Writable as ne, Transform as Ke } from "node:stream";
11
+ import * as O from "node:fs";
12
+ import * as w from "node:path";
13
+ import et from "node:path";
14
+ import { text as tt, buffer as ke } from "node:stream/consumers";
15
+ import { Computable as b, ChangeSource as N, PollingComputableHooks as Le } from "@milaboratories/computable";
16
+ import { scheduler as oe } from "node:timers/promises";
17
+ import * as rt from "node:readline/promises";
18
+ import nt from "denque";
19
+ import * as Z from "node:os";
20
+ import { randomUUID as L, createHash as ot } from "node:crypto";
21
+ import { rsSchema as se, treeEntryToResourceInfo as R, isPlTreeEntry as ie, makeResourceSnapshot as Q, isPlTreeEntryAccessor as st } from "@milaboratories/pl-tree";
22
+ import { z as T } from "zod";
23
+ import * as it from "node:zlib";
24
+ import * as at from "tar-fs";
25
+ import { isImportFileHandleIndex as lt } from "@milaboratories/pl-model-common";
26
+ class ct extends g {
25
27
  constructor() {
26
28
  super("MiLaboratories.Controller.Shared.uploadapi", []);
27
29
  }
@@ -41,8 +43,8 @@ class rt extends g {
41
43
  ), t;
42
44
  }
43
45
  }
44
- new rt();
45
- class nt extends g {
46
+ new ct();
47
+ class dt extends g {
46
48
  constructor() {
47
49
  super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
48
50
  }
@@ -62,8 +64,8 @@ class nt extends g {
62
64
  ), t;
63
65
  }
64
66
  }
65
- new nt();
66
- class ot extends g {
67
+ new dt();
68
+ class ht extends g {
67
69
  constructor() {
68
70
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
69
71
  {
@@ -81,9 +83,9 @@ class ot extends g {
81
83
  return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
82
84
  }
83
85
  internalBinaryRead(e, t, n, r) {
84
- let o = r ?? this.create(), d = e.pos + t;
85
- for (; e.pos < d; ) {
86
- let [i, l] = e.tag();
86
+ let o = r ?? this.create(), l = e.pos + t;
87
+ for (; e.pos < l; ) {
88
+ let [i, c] = e.tag();
87
89
  switch (i) {
88
90
  case /* uint64 resource_id */
89
91
  1:
@@ -93,14 +95,14 @@ class ot extends g {
93
95
  let a = n.readUnknownField;
94
96
  if (a === "throw")
95
97
  throw new globalThis.Error(
96
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
98
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
97
99
  );
98
- let p = e.skip(l);
100
+ let p = e.skip(c);
99
101
  a !== !1 && (a === !0 ? u.onRead : a)(
100
102
  this.typeName,
101
103
  o,
102
104
  i,
103
- l,
105
+ c,
104
106
  p
105
107
  );
106
108
  }
@@ -117,8 +119,8 @@ class ot extends g {
117
119
  ), t;
118
120
  }
119
121
  }
120
- const st = new ot();
121
- class it extends g {
122
+ const ut = new ht();
123
+ class pt extends g {
122
124
  constructor() {
123
125
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
124
126
  {
@@ -145,9 +147,9 @@ class it extends g {
145
147
  return t.partsCount = 0n, t.uploadedParts = [], e !== void 0 && f(this, t, e), t;
146
148
  }
147
149
  internalBinaryRead(e, t, n, r) {
148
- let o = r ?? this.create(), d = e.pos + t;
149
- for (; e.pos < d; ) {
150
- let [i, l] = e.tag();
150
+ let o = r ?? this.create(), l = e.pos + t;
151
+ for (; e.pos < l; ) {
152
+ let [i, c] = e.tag();
151
153
  switch (i) {
152
154
  case /* uint64 parts_count */
153
155
  1:
@@ -155,7 +157,7 @@ class it extends g {
155
157
  break;
156
158
  case /* repeated uint64 uploaded_parts */
157
159
  2:
158
- if (l === h.LengthDelimited)
160
+ if (c === h.LengthDelimited)
159
161
  for (let P = e.int32() + e.pos; e.pos < P; )
160
162
  o.uploadedParts.push(e.uint64().toBigInt());
161
163
  else o.uploadedParts.push(e.uint64().toBigInt());
@@ -164,14 +166,14 @@ class it extends g {
164
166
  let a = n.readUnknownField;
165
167
  if (a === "throw")
166
168
  throw new globalThis.Error(
167
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
169
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
168
170
  );
169
- let p = e.skip(l);
171
+ let p = e.skip(c);
170
172
  a !== !1 && (a === !0 ? u.onRead : a)(
171
173
  this.typeName,
172
174
  o,
173
175
  i,
174
- l,
176
+ c,
175
177
  p
176
178
  );
177
179
  }
@@ -193,8 +195,8 @@ class it extends g {
193
195
  ), t;
194
196
  }
195
197
  }
196
- const at = new it();
197
- class lt extends g {
198
+ const gt = new pt();
199
+ class ft extends g {
198
200
  constructor() {
199
201
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
200
202
  }
@@ -214,8 +216,8 @@ class lt extends g {
214
216
  ), t;
215
217
  }
216
218
  }
217
- new lt();
218
- class dt extends g {
219
+ new ft();
220
+ class mt extends g {
219
221
  constructor() {
220
222
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
221
223
  {
@@ -245,9 +247,9 @@ class dt extends g {
245
247
  ), t;
246
248
  }
247
249
  internalBinaryRead(e, t, n, r) {
248
- let o = r ?? this.create(), d = e.pos + t;
249
- for (; e.pos < d; ) {
250
- let [i, l] = e.tag();
250
+ let o = r ?? this.create(), l = e.pos + t;
251
+ for (; e.pos < l; ) {
252
+ let [i, c] = e.tag();
251
253
  switch (i) {
252
254
  case /* uint64 resource_id */
253
255
  1:
@@ -261,14 +263,14 @@ class dt extends g {
261
263
  let a = n.readUnknownField;
262
264
  if (a === "throw")
263
265
  throw new globalThis.Error(
264
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
266
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
265
267
  );
266
- let p = e.skip(l);
268
+ let p = e.skip(c);
267
269
  a !== !1 && (a === !0 ? u.onRead : a)(
268
270
  this.typeName,
269
271
  o,
270
272
  i,
271
- l,
273
+ c,
272
274
  p
273
275
  );
274
276
  }
@@ -285,8 +287,8 @@ class dt extends g {
285
287
  ), t;
286
288
  }
287
289
  }
288
- const ct = new dt();
289
- class ht extends g {
290
+ const wt = new mt();
291
+ class yt extends g {
290
292
  constructor() {
291
293
  super(
292
294
  "MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
@@ -313,8 +315,8 @@ class ht extends g {
313
315
  ), t;
314
316
  }
315
317
  }
316
- const ut = new ht();
317
- class pt extends g {
318
+ const bt = new yt();
319
+ class Tt extends g {
318
320
  constructor() {
319
321
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
320
322
  }
@@ -334,8 +336,8 @@ class pt extends g {
334
336
  ), t;
335
337
  }
336
338
  }
337
- new pt();
338
- class gt extends g {
339
+ new Tt();
340
+ class kt extends g {
339
341
  constructor() {
340
342
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
341
343
  {
@@ -373,9 +375,9 @@ class gt extends g {
373
375
  ), t;
374
376
  }
375
377
  internalBinaryRead(e, t, n, r) {
376
- let o = r ?? this.create(), d = e.pos + t;
377
- for (; e.pos < d; ) {
378
- let [i, l] = e.tag();
378
+ let o = r ?? this.create(), l = e.pos + t;
379
+ for (; e.pos < l; ) {
380
+ let [i, c] = e.tag();
379
381
  switch (i) {
380
382
  case /* uint64 resource_id */
381
383
  1:
@@ -393,14 +395,14 @@ class gt extends g {
393
395
  let a = n.readUnknownField;
394
396
  if (a === "throw")
395
397
  throw new globalThis.Error(
396
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
398
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
397
399
  );
398
- let p = e.skip(l);
400
+ let p = e.skip(c);
399
401
  a !== !1 && (a === !0 ? u.onRead : a)(
400
402
  this.typeName,
401
403
  o,
402
404
  i,
403
- l,
405
+ c,
404
406
  p
405
407
  );
406
408
  }
@@ -417,8 +419,8 @@ class gt extends g {
417
419
  ), t;
418
420
  }
419
421
  }
420
- const ft = new gt();
421
- class mt extends g {
422
+ const Lt = new kt();
423
+ class Pt extends g {
422
424
  constructor() {
423
425
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
424
426
  {
@@ -448,9 +450,9 @@ class mt extends g {
448
450
  ), t;
449
451
  }
450
452
  internalBinaryRead(e, t, n, r) {
451
- let o = r ?? this.create(), d = e.pos + t;
452
- for (; e.pos < d; ) {
453
- let [i, l] = e.tag();
453
+ let o = r ?? this.create(), l = e.pos + t;
454
+ for (; e.pos < l; ) {
455
+ let [i, c] = e.tag();
454
456
  switch (i) {
455
457
  case /* string Name = 1 [json_name = "Name"];*/
456
458
  1:
@@ -464,14 +466,14 @@ class mt extends g {
464
466
  let a = n.readUnknownField;
465
467
  if (a === "throw")
466
468
  throw new globalThis.Error(
467
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
469
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
468
470
  );
469
- let p = e.skip(l);
471
+ let p = e.skip(c);
470
472
  a !== !1 && (a === !0 ? u.onRead : a)(
471
473
  this.typeName,
472
474
  o,
473
475
  i,
474
- l,
476
+ c,
475
477
  p
476
478
  );
477
479
  }
@@ -488,8 +490,8 @@ class mt extends g {
488
490
  ), t;
489
491
  }
490
492
  }
491
- const F = new mt();
492
- class wt extends g {
493
+ const E = new Pt();
494
+ class It extends g {
493
495
  constructor() {
494
496
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
495
497
  {
@@ -511,7 +513,7 @@ class wt extends g {
511
513
  name: "headers",
512
514
  kind: "message",
513
515
  repeat: 1,
514
- T: () => F
516
+ T: () => E
515
517
  },
516
518
  {
517
519
  no: 4,
@@ -540,9 +542,9 @@ class wt extends g {
540
542
  ), t;
541
543
  }
542
544
  internalBinaryRead(e, t, n, r) {
543
- let o = r ?? this.create(), d = e.pos + t;
544
- for (; e.pos < d; ) {
545
- let [i, l] = e.tag();
545
+ let o = r ?? this.create(), l = e.pos + t;
546
+ for (; e.pos < l; ) {
547
+ let [i, c] = e.tag();
546
548
  switch (i) {
547
549
  case /* string upload_url */
548
550
  1:
@@ -555,7 +557,7 @@ class wt extends g {
555
557
  case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
556
558
  3:
557
559
  o.headers.push(
558
- F.internalBinaryRead(
560
+ E.internalBinaryRead(
559
561
  e,
560
562
  e.uint32(),
561
563
  n
@@ -574,14 +576,14 @@ class wt extends g {
574
576
  let a = n.readUnknownField;
575
577
  if (a === "throw")
576
578
  throw new globalThis.Error(
577
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
579
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
578
580
  );
579
- let p = e.skip(l);
581
+ let p = e.skip(c);
580
582
  a !== !1 && (a === !0 ? u.onRead : a)(
581
583
  this.typeName,
582
584
  o,
583
585
  i,
584
- l,
586
+ c,
585
587
  p
586
588
  );
587
589
  }
@@ -591,7 +593,7 @@ class wt extends g {
591
593
  internalBinaryWrite(e, t, n) {
592
594
  e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
593
595
  for (let o = 0; o < e.headers.length; o++)
594
- F.internalBinaryWrite(
596
+ E.internalBinaryWrite(
595
597
  e.headers[o],
596
598
  t.tag(3, h.LengthDelimited).fork(),
597
599
  n
@@ -605,8 +607,8 @@ class wt extends g {
605
607
  ), t;
606
608
  }
607
609
  }
608
- const yt = new wt();
609
- class bt extends g {
610
+ const Rt = new It();
611
+ class St extends g {
610
612
  constructor() {
611
613
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
612
614
  }
@@ -626,8 +628,8 @@ class bt extends g {
626
628
  ), t;
627
629
  }
628
630
  }
629
- new bt();
630
- class Tt extends g {
631
+ new St();
632
+ class Nt extends g {
631
633
  constructor() {
632
634
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
633
635
  {
@@ -645,9 +647,9 @@ class Tt extends g {
645
647
  return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
646
648
  }
647
649
  internalBinaryRead(e, t, n, r) {
648
- let o = r ?? this.create(), d = e.pos + t;
649
- for (; e.pos < d; ) {
650
- let [i, l] = e.tag();
650
+ let o = r ?? this.create(), l = e.pos + t;
651
+ for (; e.pos < l; ) {
652
+ let [i, c] = e.tag();
651
653
  switch (i) {
652
654
  case /* uint64 resource_id */
653
655
  1:
@@ -657,14 +659,14 @@ class Tt extends g {
657
659
  let a = n.readUnknownField;
658
660
  if (a === "throw")
659
661
  throw new globalThis.Error(
660
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
662
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
661
663
  );
662
- let p = e.skip(l);
664
+ let p = e.skip(c);
663
665
  a !== !1 && (a === !0 ? u.onRead : a)(
664
666
  this.typeName,
665
667
  o,
666
668
  i,
667
- l,
669
+ c,
668
670
  p
669
671
  );
670
672
  }
@@ -681,8 +683,8 @@ class Tt extends g {
681
683
  ), t;
682
684
  }
683
685
  }
684
- const kt = new Tt();
685
- class Lt extends g {
686
+ const Ut = new Nt();
687
+ class Bt extends g {
686
688
  constructor() {
687
689
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
688
690
  }
@@ -702,40 +704,40 @@ class Lt extends g {
702
704
  ), t;
703
705
  }
704
706
  }
705
- const Pt = new Lt(), W = new v(
707
+ const Dt = new Bt(), W = new D(
706
708
  "MiLaboratories.Controller.Shared.Upload",
707
709
  [
708
710
  {
709
711
  name: "Init",
710
712
  options: {},
711
- I: st,
712
- O: at
713
+ I: ut,
714
+ O: gt
713
715
  },
714
716
  {
715
717
  name: "GetPartURL",
716
718
  options: {},
717
- I: ft,
718
- O: yt
719
+ I: Lt,
720
+ O: Rt
719
721
  },
720
722
  {
721
723
  name: "UpdateProgress",
722
724
  options: {},
723
- I: ct,
724
- O: ut
725
+ I: wt,
726
+ O: bt
725
727
  },
726
728
  {
727
729
  name: "Finalize",
728
730
  options: {},
729
- I: kt,
730
- O: Pt
731
+ I: Ut,
732
+ O: Dt
731
733
  }
732
734
  ]
733
735
  );
734
- class It {
736
+ class vt {
735
737
  constructor(e) {
736
- c(this, "typeName", W.typeName);
737
- c(this, "methods", W.methods);
738
- c(this, "options", W.options);
738
+ d(this, "typeName", W.typeName);
739
+ d(this, "methods", W.methods);
740
+ d(this, "options", W.options);
739
741
  this._transport = e;
740
742
  }
741
743
  /**
@@ -747,7 +749,7 @@ class It {
747
749
  */
748
750
  init(e, t) {
749
751
  const n = this.methods[0], r = this._transport.mergeOptions(t);
750
- return w(
752
+ return y(
751
753
  "unary",
752
754
  this._transport,
753
755
  n,
@@ -765,7 +767,7 @@ class It {
765
767
  */
766
768
  getPartURL(e, t) {
767
769
  const n = this.methods[1], r = this._transport.mergeOptions(t);
768
- return w("unary", this._transport, n, r, e);
770
+ return y("unary", this._transport, n, r, e);
769
771
  }
770
772
  /**
771
773
  *
@@ -776,7 +778,7 @@ class It {
776
778
  */
777
779
  updateProgress(e, t) {
778
780
  const n = this.methods[2], r = this._transport.mergeOptions(t);
779
- return w("unary", this._transport, n, r, e);
781
+ return y("unary", this._transport, n, r, e);
780
782
  }
781
783
  /**
782
784
  *
@@ -789,84 +791,84 @@ class It {
789
791
  */
790
792
  finalize(e, t) {
791
793
  const n = this.methods[3], r = this._transport.mergeOptions(t);
792
- return w("unary", this._transport, n, r, e);
794
+ return y("unary", this._transport, n, r, e);
793
795
  }
794
796
  }
795
- class ke extends Error {
797
+ class Pe extends Error {
796
798
  }
797
- class Le extends Error {
799
+ class Ie extends Error {
798
800
  }
799
- class Nt extends Error {
801
+ class $t extends Error {
800
802
  }
801
- class Pe extends Error {
803
+ class Re extends Error {
802
804
  }
803
- class Rt {
805
+ class _t {
804
806
  constructor(e, t, n, r) {
805
- c(this, "grpcClient");
806
- this.grpcTransport = e, this.httpClient = t, this.logger = r, this.grpcClient = new It(this.grpcTransport);
807
+ d(this, "grpcClient");
808
+ this.grpcTransport = e, this.httpClient = t, this.logger = r, this.grpcClient = new vt(this.grpcTransport);
807
809
  }
808
810
  close() {
809
811
  }
810
812
  async initUpload({ id: e, type: t }, n) {
811
813
  const r = await this.grpcClient.init(
812
814
  { resourceId: e },
813
- T(t, n)
815
+ k(t, n)
814
816
  );
815
817
  return this.partsToUpload(r.response);
816
818
  }
817
- async partUpload({ id: e, type: t }, n, r, o, d, i) {
818
- const l = await this.grpcClient.getPartURL(
819
+ async partUpload({ id: e, type: t }, n, r, o, l, i) {
820
+ const c = await this.grpcClient.getPartURL(
819
821
  {
820
822
  resourceId: e,
821
823
  partNumber: r,
822
824
  uploadedPartSize: 0n
823
825
  // we update progress as a separate call later.
824
826
  },
825
- T(t, i)
827
+ k(t, i)
826
828
  ).response, { chunk: a, mTime: p } = await this.readChunk(
827
829
  n,
828
- l.chunkStart,
829
- l.chunkEnd
830
+ c.chunkStart,
831
+ c.chunkEnd
830
832
  );
831
- if (p > d)
832
- throw new ke(
833
- "file was modified, expected mtime: " + d + ", got: " + p + "."
833
+ if (p > l)
834
+ throw new Pe(
835
+ "file was modified, expected mtime: " + l + ", got: " + p + "."
834
836
  );
835
- const P = await fe(
836
- l.uploadUrl,
837
- this.prepareUploadOpts(l, a)
838
- ), ne = await P.body.text();
837
+ const P = await Te(
838
+ c.uploadUrl,
839
+ this.prepareUploadOpts(c, a)
840
+ ), le = await P.body.text();
839
841
  if (this.logger.info(
840
- `uploaded chunk ${r} from ${o} of resource: ${e}, response: '${ne.toString()}', status code: ${P.statusCode}`
842
+ `uploaded chunk ${r} from ${o} of resource: ${e}, response: '${le.toString()}', status code: ${P.statusCode}`
841
843
  ), P.statusCode != 200)
842
- throw new Nt(
843
- `response is not ok, status code: ${P.statusCode}, body: ${ne}, headers: ${P.headers}, url: ${l.uploadUrl}`
844
+ throw new $t(
845
+ `response is not ok, status code: ${P.statusCode}, body: ${le}, headers: ${P.headers}, url: ${c.uploadUrl}`
844
846
  );
845
847
  await this.grpcClient.updateProgress(
846
848
  {
847
849
  resourceId: e,
848
- bytesProcessed: l.chunkEnd - l.chunkStart
850
+ bytesProcessed: c.chunkEnd - c.chunkStart
849
851
  },
850
- T(t, i)
852
+ k(t, i)
851
853
  );
852
854
  }
853
855
  async finalizeUpload({ id: e, type: t }, n) {
854
856
  return await this.grpcClient.finalize(
855
857
  { resourceId: e },
856
- T(t, n)
858
+ k(t, n)
857
859
  );
858
860
  }
859
861
  async readChunk(e, t, n) {
860
862
  let r;
861
863
  try {
862
- r = await b.open(e);
863
- const o = Number(n - t), d = Number(t), i = Buffer.alloc(o), l = await this.readBytesFromPosition(r, i, o, d), a = await b.stat(e);
864
+ r = await m.open(e);
865
+ const o = Number(n - t), l = Number(t), i = Buffer.alloc(o), c = await this.readBytesFromPosition(r, i, o, l), a = await m.stat(e);
864
866
  return {
865
- chunk: i.subarray(0, l),
867
+ chunk: i.subarray(0, c),
866
868
  mTime: BigInt(Math.floor(a.mtimeMs / 1e3))
867
869
  };
868
870
  } catch (o) {
869
- throw o.code == "ENOENT" ? new Pe(`there is no file ${e} for uploading`) : o;
871
+ throw o.code == "ENOENT" ? new Re(`there is no file ${e} for uploading`) : o;
870
872
  } finally {
871
873
  r == null || r.close();
872
874
  }
@@ -876,15 +878,15 @@ class Rt {
876
878
  async readBytesFromPosition(e, t, n, r) {
877
879
  let o = 0;
878
880
  for (; o < n; ) {
879
- const { bytesRead: d } = await e.read(
881
+ const { bytesRead: l } = await e.read(
880
882
  t,
881
883
  o,
882
884
  n - o,
883
885
  r + o
884
886
  );
885
- if (d === 0)
886
- throw new Le("file ended earlier than expected.");
887
- o += d;
887
+ if (l === 0)
888
+ throw new Ie("file ended earlier than expected.");
889
+ o += l;
888
890
  }
889
891
  return o;
890
892
  }
@@ -906,7 +908,7 @@ class Rt {
906
908
  };
907
909
  }
908
910
  }
909
- class St extends g {
911
+ class Ct extends g {
910
912
  constructor() {
911
913
  super("google.protobuf.Duration", [
912
914
  {
@@ -946,7 +948,7 @@ class St extends g {
946
948
  internalJsonRead(e, t, n) {
947
949
  if (typeof e != "string")
948
950
  throw new Error(
949
- "Unable to parse Duration from JSON " + ge(e) + ". Expected string."
951
+ "Unable to parse Duration from JSON " + be(e) + ". Expected string."
950
952
  );
951
953
  let r = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
952
954
  if (r === null)
@@ -954,12 +956,12 @@ class St extends g {
954
956
  "Unable to parse Duration from JSON string. Invalid format."
955
957
  );
956
958
  n || (n = this.create());
957
- let [, o, d, i] = r, l = I.from(o + d);
958
- if (l.toNumber() > 315576e6 || l.toNumber() < -315576e6)
959
+ let [, o, l, i] = r, c = I.from(o + l);
960
+ if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
959
961
  throw new Error(
960
962
  "Unable to parse Duration from JSON string. Value out of range."
961
963
  );
962
- if (n.seconds = l.toBigInt(), typeof i == "string") {
964
+ if (n.seconds = c.toBigInt(), typeof i == "string") {
963
965
  let a = o + i + "0".repeat(9 - i.length);
964
966
  n.nanos = parseInt(a);
965
967
  }
@@ -970,9 +972,9 @@ class St extends g {
970
972
  return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
971
973
  }
972
974
  internalBinaryRead(e, t, n, r) {
973
- let o = r ?? this.create(), d = e.pos + t;
974
- for (; e.pos < d; ) {
975
- let [i, l] = e.tag();
975
+ let o = r ?? this.create(), l = e.pos + t;
976
+ for (; e.pos < l; ) {
977
+ let [i, c] = e.tag();
976
978
  switch (i) {
977
979
  case /* int64 seconds */
978
980
  1:
@@ -986,14 +988,14 @@ class St extends g {
986
988
  let a = n.readUnknownField;
987
989
  if (a === "throw")
988
990
  throw new globalThis.Error(
989
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
991
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
990
992
  );
991
- let p = e.skip(l);
993
+ let p = e.skip(c);
992
994
  a !== !1 && (a === !0 ? u.onRead : a)(
993
995
  this.typeName,
994
996
  o,
995
997
  i,
996
- l,
998
+ c,
997
999
  p
998
1000
  );
999
1001
  }
@@ -1010,8 +1012,8 @@ class St extends g {
1010
1012
  ), t;
1011
1013
  }
1012
1014
  }
1013
- const $ = new St();
1014
- class Ut extends g {
1015
+ const $ = new Ct();
1016
+ class Ot extends g {
1015
1017
  constructor() {
1016
1018
  super("MiLaboratories.Controller.Shared.ProgressAPI", []);
1017
1019
  }
@@ -1031,8 +1033,8 @@ class Ut extends g {
1031
1033
  ), t;
1032
1034
  }
1033
1035
  }
1034
- new Ut();
1035
- class Bt extends g {
1036
+ new Ot();
1037
+ class Ft extends g {
1036
1038
  constructor() {
1037
1039
  super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
1038
1040
  {
@@ -1079,9 +1081,9 @@ class Bt extends g {
1079
1081
  return t.progress = 0, t.bytesProcessed = 0n, t.bytesTotal = 0n, t.done = !1, t.name = "", e !== void 0 && f(this, t, e), t;
1080
1082
  }
1081
1083
  internalBinaryRead(e, t, n, r) {
1082
- let o = r ?? this.create(), d = e.pos + t;
1083
- for (; e.pos < d; ) {
1084
- let [i, l] = e.tag();
1084
+ let o = r ?? this.create(), l = e.pos + t;
1085
+ for (; e.pos < l; ) {
1086
+ let [i, c] = e.tag();
1085
1087
  switch (i) {
1086
1088
  case /* float progress */
1087
1089
  1:
@@ -1107,14 +1109,14 @@ class Bt extends g {
1107
1109
  let a = n.readUnknownField;
1108
1110
  if (a === "throw")
1109
1111
  throw new globalThis.Error(
1110
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1112
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1111
1113
  );
1112
- let p = e.skip(l);
1114
+ let p = e.skip(c);
1113
1115
  a !== !1 && (a === !0 ? u.onRead : a)(
1114
1116
  this.typeName,
1115
1117
  o,
1116
1118
  i,
1117
- l,
1119
+ c,
1118
1120
  p
1119
1121
  );
1120
1122
  }
@@ -1131,8 +1133,8 @@ class Bt extends g {
1131
1133
  ), t;
1132
1134
  }
1133
1135
  }
1134
- const R = new Bt();
1135
- class vt extends g {
1136
+ const S = new Ft();
1137
+ class Et extends g {
1136
1138
  constructor() {
1137
1139
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
1138
1140
  }
@@ -1152,8 +1154,8 @@ class vt extends g {
1152
1154
  ), t;
1153
1155
  }
1154
1156
  }
1155
- new vt();
1156
- class Dt extends g {
1157
+ new Et();
1158
+ class Wt extends g {
1157
1159
  constructor() {
1158
1160
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
1159
1161
  {
@@ -1175,9 +1177,9 @@ class Dt extends g {
1175
1177
  ), t;
1176
1178
  }
1177
1179
  internalBinaryRead(e, t, n, r) {
1178
- let o = r ?? this.create(), d = e.pos + t;
1179
- for (; e.pos < d; ) {
1180
- let [i, l] = e.tag();
1180
+ let o = r ?? this.create(), l = e.pos + t;
1181
+ for (; e.pos < l; ) {
1182
+ let [i, c] = e.tag();
1181
1183
  switch (i) {
1182
1184
  case /* uint64 resource_id */
1183
1185
  1:
@@ -1187,14 +1189,14 @@ class Dt extends g {
1187
1189
  let a = n.readUnknownField;
1188
1190
  if (a === "throw")
1189
1191
  throw new globalThis.Error(
1190
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1192
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1191
1193
  );
1192
- let p = e.skip(l);
1194
+ let p = e.skip(c);
1193
1195
  a !== !1 && (a === !0 ? u.onRead : a)(
1194
1196
  this.typeName,
1195
1197
  o,
1196
1198
  i,
1197
- l,
1199
+ c,
1198
1200
  p
1199
1201
  );
1200
1202
  }
@@ -1211,11 +1213,11 @@ class Dt extends g {
1211
1213
  ), t;
1212
1214
  }
1213
1215
  }
1214
- const $t = new Dt();
1215
- class _t extends g {
1216
+ const zt = new Wt();
1217
+ class xt extends g {
1216
1218
  constructor() {
1217
1219
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
1218
- { no: 1, name: "report", kind: "message", T: () => R }
1220
+ { no: 1, name: "report", kind: "message", T: () => S }
1219
1221
  ]);
1220
1222
  }
1221
1223
  create(e) {
@@ -1227,13 +1229,13 @@ class _t extends g {
1227
1229
  ), t;
1228
1230
  }
1229
1231
  internalBinaryRead(e, t, n, r) {
1230
- let o = r ?? this.create(), d = e.pos + t;
1231
- for (; e.pos < d; ) {
1232
- let [i, l] = e.tag();
1232
+ let o = r ?? this.create(), l = e.pos + t;
1233
+ for (; e.pos < l; ) {
1234
+ let [i, c] = e.tag();
1233
1235
  switch (i) {
1234
1236
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1235
1237
  1:
1236
- o.report = R.internalBinaryRead(
1238
+ o.report = S.internalBinaryRead(
1237
1239
  e,
1238
1240
  e.uint32(),
1239
1241
  n,
@@ -1244,14 +1246,14 @@ class _t extends g {
1244
1246
  let a = n.readUnknownField;
1245
1247
  if (a === "throw")
1246
1248
  throw new globalThis.Error(
1247
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1249
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1248
1250
  );
1249
- let p = e.skip(l);
1251
+ let p = e.skip(c);
1250
1252
  a !== !1 && (a === !0 ? u.onRead : a)(
1251
1253
  this.typeName,
1252
1254
  o,
1253
1255
  i,
1254
- l,
1256
+ c,
1255
1257
  p
1256
1258
  );
1257
1259
  }
@@ -1259,7 +1261,7 @@ class _t extends g {
1259
1261
  return o;
1260
1262
  }
1261
1263
  internalBinaryWrite(e, t, n) {
1262
- e.report && R.internalBinaryWrite(
1264
+ e.report && S.internalBinaryWrite(
1263
1265
  e.report,
1264
1266
  t.tag(1, h.LengthDelimited).fork(),
1265
1267
  n
@@ -1272,8 +1274,8 @@ class _t extends g {
1272
1274
  ), t;
1273
1275
  }
1274
1276
  }
1275
- const Ct = new _t();
1276
- class Ot extends g {
1277
+ const At = new xt();
1278
+ class Mt extends g {
1277
1279
  constructor() {
1278
1280
  super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
1279
1281
  }
@@ -1293,8 +1295,8 @@ class Ot extends g {
1293
1295
  ), t;
1294
1296
  }
1295
1297
  }
1296
- new Ot();
1297
- class Et extends g {
1298
+ new Mt();
1299
+ class Ht extends g {
1298
1300
  constructor() {
1299
1301
  super(
1300
1302
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
@@ -1320,9 +1322,9 @@ class Et extends g {
1320
1322
  ), t;
1321
1323
  }
1322
1324
  internalBinaryRead(e, t, n, r) {
1323
- let o = r ?? this.create(), d = e.pos + t;
1324
- for (; e.pos < d; ) {
1325
- let [i, l] = e.tag();
1325
+ let o = r ?? this.create(), l = e.pos + t;
1326
+ for (; e.pos < l; ) {
1327
+ let [i, c] = e.tag();
1326
1328
  switch (i) {
1327
1329
  case /* uint64 resource_id */
1328
1330
  1:
@@ -1341,14 +1343,14 @@ class Et extends g {
1341
1343
  let a = n.readUnknownField;
1342
1344
  if (a === "throw")
1343
1345
  throw new globalThis.Error(
1344
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1346
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1345
1347
  );
1346
- let p = e.skip(l);
1348
+ let p = e.skip(c);
1347
1349
  a !== !1 && (a === !0 ? u.onRead : a)(
1348
1350
  this.typeName,
1349
1351
  o,
1350
1352
  i,
1351
- l,
1353
+ c,
1352
1354
  p
1353
1355
  );
1354
1356
  }
@@ -1369,12 +1371,12 @@ class Et extends g {
1369
1371
  ), t;
1370
1372
  }
1371
1373
  }
1372
- const Ft = new Et();
1373
- class Wt extends g {
1374
+ const jt = new Ht();
1375
+ class Gt extends g {
1374
1376
  constructor() {
1375
1377
  super(
1376
1378
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
1377
- [{ no: 1, name: "report", kind: "message", T: () => R }]
1379
+ [{ no: 1, name: "report", kind: "message", T: () => S }]
1378
1380
  );
1379
1381
  }
1380
1382
  create(e) {
@@ -1386,13 +1388,13 @@ class Wt extends g {
1386
1388
  ), t;
1387
1389
  }
1388
1390
  internalBinaryRead(e, t, n, r) {
1389
- let o = r ?? this.create(), d = e.pos + t;
1390
- for (; e.pos < d; ) {
1391
- let [i, l] = e.tag();
1391
+ let o = r ?? this.create(), l = e.pos + t;
1392
+ for (; e.pos < l; ) {
1393
+ let [i, c] = e.tag();
1392
1394
  switch (i) {
1393
1395
  case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
1394
1396
  1:
1395
- o.report = R.internalBinaryRead(
1397
+ o.report = S.internalBinaryRead(
1396
1398
  e,
1397
1399
  e.uint32(),
1398
1400
  n,
@@ -1403,14 +1405,14 @@ class Wt extends g {
1403
1405
  let a = n.readUnknownField;
1404
1406
  if (a === "throw")
1405
1407
  throw new globalThis.Error(
1406
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1408
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1407
1409
  );
1408
- let p = e.skip(l);
1410
+ let p = e.skip(c);
1409
1411
  a !== !1 && (a === !0 ? u.onRead : a)(
1410
1412
  this.typeName,
1411
1413
  o,
1412
1414
  i,
1413
- l,
1415
+ c,
1414
1416
  p
1415
1417
  );
1416
1418
  }
@@ -1418,7 +1420,7 @@ class Wt extends g {
1418
1420
  return o;
1419
1421
  }
1420
1422
  internalBinaryWrite(e, t, n) {
1421
- e.report && R.internalBinaryWrite(
1423
+ e.report && S.internalBinaryWrite(
1422
1424
  e.report,
1423
1425
  t.tag(1, h.LengthDelimited).fork(),
1424
1426
  n
@@ -1431,7 +1433,7 @@ class Wt extends g {
1431
1433
  ), t;
1432
1434
  }
1433
1435
  }
1434
- const At = new Wt(), A = new v(
1436
+ const Vt = new Gt(), z = new D(
1435
1437
  "MiLaboratories.Controller.Shared.Progress",
1436
1438
  [
1437
1439
  {
@@ -1439,23 +1441,23 @@ const At = new Wt(), A = new v(
1439
1441
  options: {
1440
1442
  "google.api.http": { get: "/resources/{resource_id}/get-progress" }
1441
1443
  },
1442
- I: $t,
1443
- O: Ct
1444
+ I: zt,
1445
+ O: At
1444
1446
  },
1445
1447
  {
1446
1448
  name: "RealtimeStatus",
1447
1449
  serverStreaming: !0,
1448
1450
  options: {},
1449
- I: Ft,
1450
- O: At
1451
+ I: jt,
1452
+ O: Vt
1451
1453
  }
1452
1454
  ]
1453
1455
  );
1454
- class zt {
1456
+ class qt {
1455
1457
  constructor(e) {
1456
- c(this, "typeName", A.typeName);
1457
- c(this, "methods", A.methods);
1458
- c(this, "options", A.options);
1458
+ d(this, "typeName", z.typeName);
1459
+ d(this, "methods", z.methods);
1460
+ d(this, "options", z.options);
1459
1461
  this._transport = e;
1460
1462
  }
1461
1463
  /**
@@ -1463,20 +1465,20 @@ class zt {
1463
1465
  */
1464
1466
  getStatus(e, t) {
1465
1467
  const n = this.methods[0], r = this._transport.mergeOptions(t);
1466
- return w("unary", this._transport, n, r, e);
1468
+ return y("unary", this._transport, n, r, e);
1467
1469
  }
1468
1470
  /**
1469
1471
  * @generated from protobuf rpc: RealtimeStatus(MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request) returns (stream MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response);
1470
1472
  */
1471
1473
  realtimeStatus(e, t) {
1472
1474
  const n = this.methods[1], r = this._transport.mergeOptions(t);
1473
- return w("serverStreaming", this._transport, n, r, e);
1475
+ return y("serverStreaming", this._transport, n, r, e);
1474
1476
  }
1475
1477
  }
1476
- class xt {
1478
+ class Jt {
1477
1479
  constructor(e, t, n, r) {
1478
- c(this, "grpcClient");
1479
- this.grpcTransport = e, this.client = n, this.logger = r, this.grpcClient = new zt(this.grpcTransport);
1480
+ d(this, "grpcClient");
1481
+ this.grpcTransport = e, this.client = n, this.logger = r, this.grpcClient = new qt(this.grpcTransport);
1480
1482
  }
1481
1483
  close() {
1482
1484
  }
@@ -1484,8 +1486,8 @@ class xt {
1484
1486
  async getStatus({ id: e, type: t }, n) {
1485
1487
  const r = await this.grpcClient.getStatus(
1486
1488
  { resourceId: e },
1487
- T(t, n)
1488
- ), o = O(r.response.report);
1489
+ k(t, n)
1490
+ ), o = K(r.response.report);
1489
1491
  return {
1490
1492
  done: o.done,
1491
1493
  progress: o.progress,
@@ -1496,26 +1498,26 @@ class xt {
1496
1498
  // realtimeStatus returns a async generator that takes statuses from
1497
1499
  // GRPC stream every updateIntervalMs milliseconds.
1498
1500
  async *realtimeStatus({ id: e, type: t }, n = 100, r) {
1499
- r = T(t, r);
1500
- const o = Math.floor(n / 1e3), d = (n - o * 1e3) * 1e6, i = $.create({
1501
+ r = k(t, r);
1502
+ const o = Math.floor(n / 1e3), l = (n - o * 1e3) * 1e6, i = $.create({
1501
1503
  seconds: BigInt(o),
1502
- nanos: d
1504
+ nanos: l
1503
1505
  });
1504
1506
  try {
1505
- const { responses: l } = this.grpcClient.realtimeStatus(
1507
+ const { responses: c } = this.grpcClient.realtimeStatus(
1506
1508
  {
1507
1509
  resourceId: e,
1508
1510
  updateInterval: i
1509
1511
  },
1510
1512
  r
1511
1513
  );
1512
- yield* l;
1513
- } catch (l) {
1514
- throw this.logger.warn("Failed to get realtime status" + l), l;
1514
+ yield* c;
1515
+ } catch (c) {
1516
+ throw this.logger.warn("Failed to get realtime status" + c), c;
1515
1517
  }
1516
1518
  }
1517
1519
  }
1518
- class Mt extends g {
1520
+ class Zt extends g {
1519
1521
  constructor() {
1520
1522
  super("MiLaboratories.Controller.Shared.DownloadAPI", []);
1521
1523
  }
@@ -1535,8 +1537,8 @@ class Mt extends g {
1535
1537
  ), t;
1536
1538
  }
1537
1539
  }
1538
- new Mt();
1539
- class Ht extends g {
1540
+ new Zt();
1541
+ class Qt extends g {
1540
1542
  constructor() {
1541
1543
  super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
1542
1544
  }
@@ -1556,8 +1558,8 @@ class Ht extends g {
1556
1558
  ), t;
1557
1559
  }
1558
1560
  }
1559
- new Ht();
1560
- class jt extends g {
1561
+ new Qt();
1562
+ class Xt extends g {
1561
1563
  constructor() {
1562
1564
  super(
1563
1565
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
@@ -1582,9 +1584,9 @@ class jt extends g {
1582
1584
  ), t;
1583
1585
  }
1584
1586
  internalBinaryRead(e, t, n, r) {
1585
- let o = r ?? this.create(), d = e.pos + t;
1586
- for (; e.pos < d; ) {
1587
- let [i, l] = e.tag();
1587
+ let o = r ?? this.create(), l = e.pos + t;
1588
+ for (; e.pos < l; ) {
1589
+ let [i, c] = e.tag();
1588
1590
  switch (i) {
1589
1591
  case /* uint64 resource_id */
1590
1592
  1:
@@ -1594,14 +1596,14 @@ class jt extends g {
1594
1596
  let a = n.readUnknownField;
1595
1597
  if (a === "throw")
1596
1598
  throw new globalThis.Error(
1597
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1599
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1598
1600
  );
1599
- let p = e.skip(l);
1601
+ let p = e.skip(c);
1600
1602
  a !== !1 && (a === !0 ? u.onRead : a)(
1601
1603
  this.typeName,
1602
1604
  o,
1603
1605
  i,
1604
- l,
1606
+ c,
1605
1607
  p
1606
1608
  );
1607
1609
  }
@@ -1618,8 +1620,8 @@ class jt extends g {
1618
1620
  ), t;
1619
1621
  }
1620
1622
  }
1621
- const Gt = new jt();
1622
- class Vt extends g {
1623
+ const Yt = new Xt();
1624
+ class Kt extends g {
1623
1625
  constructor() {
1624
1626
  super(
1625
1627
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
@@ -1652,9 +1654,9 @@ class Vt extends g {
1652
1654
  ), t;
1653
1655
  }
1654
1656
  internalBinaryRead(e, t, n, r) {
1655
- let o = r ?? this.create(), d = e.pos + t;
1656
- for (; e.pos < d; ) {
1657
- let [i, l] = e.tag();
1657
+ let o = r ?? this.create(), l = e.pos + t;
1658
+ for (; e.pos < l; ) {
1659
+ let [i, c] = e.tag();
1658
1660
  switch (i) {
1659
1661
  case /* string Name = 1 [json_name = "Name"];*/
1660
1662
  1:
@@ -1668,14 +1670,14 @@ class Vt extends g {
1668
1670
  let a = n.readUnknownField;
1669
1671
  if (a === "throw")
1670
1672
  throw new globalThis.Error(
1671
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1673
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1672
1674
  );
1673
- let p = e.skip(l);
1675
+ let p = e.skip(c);
1674
1676
  a !== !1 && (a === !0 ? u.onRead : a)(
1675
1677
  this.typeName,
1676
1678
  o,
1677
1679
  i,
1678
- l,
1680
+ c,
1679
1681
  p
1680
1682
  );
1681
1683
  }
@@ -1692,8 +1694,8 @@ class Vt extends g {
1692
1694
  ), t;
1693
1695
  }
1694
1696
  }
1695
- const z = new Vt();
1696
- class qt extends g {
1697
+ const x = new Kt();
1698
+ class er extends g {
1697
1699
  constructor() {
1698
1700
  super(
1699
1701
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
@@ -1710,7 +1712,7 @@ class qt extends g {
1710
1712
  name: "headers",
1711
1713
  kind: "message",
1712
1714
  repeat: 1,
1713
- T: () => z
1715
+ T: () => x
1714
1716
  }
1715
1717
  ]
1716
1718
  );
@@ -1724,9 +1726,9 @@ class qt extends g {
1724
1726
  ), t;
1725
1727
  }
1726
1728
  internalBinaryRead(e, t, n, r) {
1727
- let o = r ?? this.create(), d = e.pos + t;
1728
- for (; e.pos < d; ) {
1729
- let [i, l] = e.tag();
1729
+ let o = r ?? this.create(), l = e.pos + t;
1730
+ for (; e.pos < l; ) {
1731
+ let [i, c] = e.tag();
1730
1732
  switch (i) {
1731
1733
  case /* string download_url */
1732
1734
  1:
@@ -1735,7 +1737,7 @@ class qt extends g {
1735
1737
  case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
1736
1738
  2:
1737
1739
  o.headers.push(
1738
- z.internalBinaryRead(
1740
+ x.internalBinaryRead(
1739
1741
  e,
1740
1742
  e.uint32(),
1741
1743
  n
@@ -1746,14 +1748,14 @@ class qt extends g {
1746
1748
  let a = n.readUnknownField;
1747
1749
  if (a === "throw")
1748
1750
  throw new globalThis.Error(
1749
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
1751
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1750
1752
  );
1751
- let p = e.skip(l);
1753
+ let p = e.skip(c);
1752
1754
  a !== !1 && (a === !0 ? u.onRead : a)(
1753
1755
  this.typeName,
1754
1756
  o,
1755
1757
  i,
1756
- l,
1758
+ c,
1757
1759
  p
1758
1760
  );
1759
1761
  }
@@ -1763,7 +1765,7 @@ class qt extends g {
1763
1765
  internalBinaryWrite(e, t, n) {
1764
1766
  e.downloadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.downloadUrl);
1765
1767
  for (let o = 0; o < e.headers.length; o++)
1766
- z.internalBinaryWrite(
1768
+ x.internalBinaryWrite(
1767
1769
  e.headers[o],
1768
1770
  t.tag(2, h.LengthDelimited).fork(),
1769
1771
  n
@@ -1776,7 +1778,7 @@ class qt extends g {
1776
1778
  ), t;
1777
1779
  }
1778
1780
  }
1779
- const Zt = new qt(), x = new v(
1781
+ const tr = new er(), A = new D(
1780
1782
  "MiLaboratories.Controller.Shared.Download",
1781
1783
  [
1782
1784
  {
@@ -1784,16 +1786,16 @@ const Zt = new qt(), x = new v(
1784
1786
  options: {
1785
1787
  "google.api.http": { get: "/resources/{resource_id}/get-download-url" }
1786
1788
  },
1787
- I: Gt,
1788
- O: Zt
1789
+ I: Yt,
1790
+ O: tr
1789
1791
  }
1790
1792
  ]
1791
1793
  );
1792
- class Jt {
1794
+ class rr {
1793
1795
  constructor(e) {
1794
- c(this, "typeName", x.typeName);
1795
- c(this, "methods", x.methods);
1796
- c(this, "options", x.options);
1796
+ d(this, "typeName", A.typeName);
1797
+ d(this, "methods", A.methods);
1798
+ d(this, "options", A.options);
1797
1799
  this._transport = e;
1798
1800
  }
1799
1801
  /**
@@ -1801,24 +1803,24 @@ class Jt {
1801
1803
  */
1802
1804
  getDownloadURL(e, t) {
1803
1805
  const n = this.methods[0], r = this._transport.mergeOptions(t);
1804
- return w("unary", this._transport, n, r, e);
1806
+ return y("unary", this._transport, n, r, e);
1805
1807
  }
1806
1808
  }
1807
- class re extends Error {
1809
+ class ae extends Error {
1808
1810
  }
1809
- class Ie {
1811
+ class Se {
1810
1812
  constructor(e) {
1811
1813
  this.httpClient = e;
1812
1814
  }
1813
1815
  async downloadRemoteFile(e, t, n) {
1814
- const { statusCode: r, body: o, headers: d } = await fe(e, {
1816
+ const { statusCode: r, body: o, headers: l } = await Te(e, {
1815
1817
  dispatcher: this.httpClient,
1816
1818
  headers: t,
1817
1819
  signal: n
1818
- }), i = K.toWeb(o);
1820
+ }), i = re.toWeb(o);
1819
1821
  if (r != 200) {
1820
- const l = await Qe(i), a = l.substring(0, Math.min(l.length, 1e3));
1821
- throw 400 <= r && r < 500 ? new re(
1822
+ const c = await tt(i), a = c.substring(0, Math.min(c.length, 1e3));
1823
+ throw 400 <= r && r < 500 ? new ae(
1822
1824
  `Http error: statusCode: ${r} url: ${e.toString()}, beginning of body: ${a}`
1823
1825
  ) : new Error(
1824
1826
  `Http error: statusCode: ${r} url: ${e.toString()}`
@@ -1826,21 +1828,30 @@ class Ie {
1826
1828
  }
1827
1829
  return {
1828
1830
  content: i,
1829
- size: Number(d["content-length"])
1831
+ size: Number(l["content-length"])
1830
1832
  };
1831
1833
  }
1832
1834
  }
1833
- const Qt = "storage://", ie = /storage:\/\/(?<storageId>.*?)\/(?<localPath>.*)/;
1835
+ function B(s) {
1836
+ if (!et.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1837
+ return s;
1838
+ }
1839
+ const nr = "storage://", de = /storage:\/\/(?<storageId>.*?)\/(?<localPath>.*)/;
1834
1840
  class Ne extends Error {
1835
1841
  }
1836
- class Re extends Error {
1842
+ class Ue extends Error {
1837
1843
  }
1838
- class Xt {
1844
+ class or {
1839
1845
  constructor(e, t, n, r) {
1840
- c(this, "grpcClient");
1841
- c(this, "downloadHelper");
1842
- c(this, "isLocal", (e) => e.startsWith(Qt));
1843
- this.grpcTransport = e, this.httpClient = t, this.logger = n, this.localStorageIdsToRoot = r, this.grpcClient = new Jt(this.grpcTransport), this.downloadHelper = new Ie(t);
1846
+ d(this, "grpcClient");
1847
+ d(this, "downloadHelper");
1848
+ d(this, "localStorageIdsToRoot");
1849
+ d(this, "isLocal", (e) => e.startsWith(nr));
1850
+ this.grpcTransport = e, this.httpClient = t, this.logger = n;
1851
+ for (const o of r) o.localPath !== "" && B(o.localPath);
1852
+ this.grpcClient = new rr(this.grpcTransport), this.downloadHelper = new Se(t), this.localStorageIdsToRoot = new Map(
1853
+ r.map((o) => [o.storageId, o.localPath])
1854
+ );
1844
1855
  }
1845
1856
  close() {
1846
1857
  }
@@ -1848,37 +1859,37 @@ class Xt {
1848
1859
  const o = n ?? {};
1849
1860
  return o.abort = r, await this.grpcClient.getDownloadURL(
1850
1861
  { resourceId: e },
1851
- T(t, o)
1862
+ k(t, o)
1852
1863
  ).response;
1853
1864
  }
1854
1865
  async downloadBlob(e, t, n) {
1855
1866
  const { downloadUrl: r, headers: o } = await this.getUrl(e, t, n);
1856
1867
  return this.logger.info(`download from url ${r}`), this.isLocal(r) ? await this.readLocalFile(r) : await this.downloadHelper.downloadRemoteFile(
1857
1868
  r,
1858
- Yt(o),
1869
+ sr(o),
1859
1870
  n
1860
1871
  );
1861
1872
  }
1862
1873
  async readLocalFile(e) {
1863
- const t = e.match(ie);
1874
+ const t = e.match(de);
1864
1875
  if (t === null || t.length != 3)
1865
- throw new Re(
1866
- `url for local filepath ${e} does not match regex ${ie}, parsed: ${t}`
1876
+ throw new Ue(
1877
+ `url for local filepath ${e} does not match regex ${de}, parsed: ${t}`
1867
1878
  );
1868
- const [n, r, o] = t;
1869
- if (this.localStorageIdsToRoot[r] == null)
1879
+ const [n, r, o] = t, l = this.localStorageIdsToRoot.get(r);
1880
+ if (l === void 0)
1870
1881
  throw new Ne(`Unknown storage location: ${r}`);
1871
- const d = this.localStorageIdsToRoot[r], i = m.join(d, o), a = (await b.stat(i)).size;
1882
+ const i = l === "" ? o : w.join(l, o), a = (await m.stat(i)).size;
1872
1883
  return {
1873
- content: K.toWeb(E.createReadStream(i)),
1884
+ content: re.toWeb(O.createReadStream(i)),
1874
1885
  size: a
1875
1886
  };
1876
1887
  }
1877
1888
  }
1878
- function Yt(s) {
1889
+ function sr(s) {
1879
1890
  return Object.fromEntries(s.map(({ name: e, value: t }) => [e, t]));
1880
1891
  }
1881
- class Kt extends g {
1892
+ class ir extends g {
1882
1893
  constructor() {
1883
1894
  super("google.protobuf.Timestamp", [
1884
1895
  {
@@ -1948,7 +1959,7 @@ class Kt extends g {
1948
1959
  internalJsonRead(e, t, n) {
1949
1960
  if (typeof e != "string")
1950
1961
  throw new Error(
1951
- "Unable to parse Timestamp from JSON " + ge(e) + "."
1962
+ "Unable to parse Timestamp from JSON " + be(e) + "."
1952
1963
  );
1953
1964
  let r = e.match(
1954
1965
  /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/
@@ -1971,9 +1982,9 @@ class Kt extends g {
1971
1982
  return t.seconds = 0n, t.nanos = 0, e !== void 0 && f(this, t, e), t;
1972
1983
  }
1973
1984
  internalBinaryRead(e, t, n, r) {
1974
- let o = r ?? this.create(), d = e.pos + t;
1975
- for (; e.pos < d; ) {
1976
- let [i, l] = e.tag();
1985
+ let o = r ?? this.create(), l = e.pos + t;
1986
+ for (; e.pos < l; ) {
1987
+ let [i, c] = e.tag();
1977
1988
  switch (i) {
1978
1989
  case /* int64 seconds */
1979
1990
  1:
@@ -1987,14 +1998,14 @@ class Kt extends g {
1987
1998
  let a = n.readUnknownField;
1988
1999
  if (a === "throw")
1989
2000
  throw new globalThis.Error(
1990
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2001
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
1991
2002
  );
1992
- let p = e.skip(l);
2003
+ let p = e.skip(c);
1993
2004
  a !== !1 && (a === !0 ? u.onRead : a)(
1994
2005
  this.typeName,
1995
2006
  o,
1996
2007
  i,
1997
- l,
2008
+ c,
1998
2009
  p
1999
2010
  );
2000
2011
  }
@@ -2011,8 +2022,8 @@ class Kt extends g {
2011
2022
  ), t;
2012
2023
  }
2013
2024
  }
2014
- const M = new Kt();
2015
- class er extends g {
2025
+ const M = new ir();
2026
+ class ar extends g {
2016
2027
  constructor() {
2017
2028
  super("MiLaboratories.Controller.Shared.LsAPI", []);
2018
2029
  }
@@ -2032,8 +2043,8 @@ class er extends g {
2032
2043
  ), t;
2033
2044
  }
2034
2045
  }
2035
- new er();
2036
- class tr extends g {
2046
+ new ar();
2047
+ class lr extends g {
2037
2048
  constructor() {
2038
2049
  super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
2039
2050
  {
@@ -2087,9 +2098,9 @@ class tr extends g {
2087
2098
  return t.name = "", t.size = 0n, t.isDir = !1, t.fullName = "", t.directory = "", t.version = "", e !== void 0 && f(this, t, e), t;
2088
2099
  }
2089
2100
  internalBinaryRead(e, t, n, r) {
2090
- let o = r ?? this.create(), d = e.pos + t;
2091
- for (; e.pos < d; ) {
2092
- let [i, l] = e.tag();
2101
+ let o = r ?? this.create(), l = e.pos + t;
2102
+ for (; e.pos < l; ) {
2103
+ let [i, c] = e.tag();
2093
2104
  switch (i) {
2094
2105
  case /* string name */
2095
2106
  1:
@@ -2128,14 +2139,14 @@ class tr extends g {
2128
2139
  let a = n.readUnknownField;
2129
2140
  if (a === "throw")
2130
2141
  throw new globalThis.Error(
2131
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2142
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2132
2143
  );
2133
- let p = e.skip(l);
2144
+ let p = e.skip(c);
2134
2145
  a !== !1 && (a === !0 ? u.onRead : a)(
2135
2146
  this.typeName,
2136
2147
  o,
2137
2148
  i,
2138
- l,
2149
+ c,
2139
2150
  p
2140
2151
  );
2141
2152
  }
@@ -2156,8 +2167,8 @@ class tr extends g {
2156
2167
  ), t;
2157
2168
  }
2158
2169
  }
2159
- const H = new tr();
2160
- class rr extends g {
2170
+ const H = new lr();
2171
+ class cr extends g {
2161
2172
  constructor() {
2162
2173
  super("MiLaboratories.Controller.Shared.LsAPI.List", []);
2163
2174
  }
@@ -2177,8 +2188,8 @@ class rr extends g {
2177
2188
  ), t;
2178
2189
  }
2179
2190
  }
2180
- new rr();
2181
- class nr extends g {
2191
+ new cr();
2192
+ class dr extends g {
2182
2193
  constructor() {
2183
2194
  super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
2184
2195
  {
@@ -2203,9 +2214,9 @@ class nr extends g {
2203
2214
  return t.resourceId = 0n, t.location = "", e !== void 0 && f(this, t, e), t;
2204
2215
  }
2205
2216
  internalBinaryRead(e, t, n, r) {
2206
- let o = r ?? this.create(), d = e.pos + t;
2207
- for (; e.pos < d; ) {
2208
- let [i, l] = e.tag();
2217
+ let o = r ?? this.create(), l = e.pos + t;
2218
+ for (; e.pos < l; ) {
2219
+ let [i, c] = e.tag();
2209
2220
  switch (i) {
2210
2221
  case /* uint64 resource_id */
2211
2222
  1:
@@ -2219,14 +2230,14 @@ class nr extends g {
2219
2230
  let a = n.readUnknownField;
2220
2231
  if (a === "throw")
2221
2232
  throw new globalThis.Error(
2222
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2233
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2223
2234
  );
2224
- let p = e.skip(l);
2235
+ let p = e.skip(c);
2225
2236
  a !== !1 && (a === !0 ? u.onRead : a)(
2226
2237
  this.typeName,
2227
2238
  o,
2228
2239
  i,
2229
- l,
2240
+ c,
2230
2241
  p
2231
2242
  );
2232
2243
  }
@@ -2243,8 +2254,8 @@ class nr extends g {
2243
2254
  ), t;
2244
2255
  }
2245
2256
  }
2246
- const or = new nr();
2247
- class sr extends g {
2257
+ const hr = new dr();
2258
+ class ur extends g {
2248
2259
  constructor() {
2249
2260
  super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
2250
2261
  {
@@ -2268,9 +2279,9 @@ class sr extends g {
2268
2279
  return t.items = [], t.delimiter = "", e !== void 0 && f(this, t, e), t;
2269
2280
  }
2270
2281
  internalBinaryRead(e, t, n, r) {
2271
- let o = r ?? this.create(), d = e.pos + t;
2272
- for (; e.pos < d; ) {
2273
- let [i, l] = e.tag();
2282
+ let o = r ?? this.create(), l = e.pos + t;
2283
+ for (; e.pos < l; ) {
2284
+ let [i, c] = e.tag();
2274
2285
  switch (i) {
2275
2286
  case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
2276
2287
  1:
@@ -2286,14 +2297,14 @@ class sr extends g {
2286
2297
  let a = n.readUnknownField;
2287
2298
  if (a === "throw")
2288
2299
  throw new globalThis.Error(
2289
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2300
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2290
2301
  );
2291
- let p = e.skip(l);
2302
+ let p = e.skip(c);
2292
2303
  a !== !1 && (a === !0 ? u.onRead : a)(
2293
2304
  this.typeName,
2294
2305
  o,
2295
2306
  i,
2296
- l,
2307
+ c,
2297
2308
  p
2298
2309
  );
2299
2310
  }
@@ -2316,14 +2327,14 @@ class sr extends g {
2316
2327
  ), t;
2317
2328
  }
2318
2329
  }
2319
- const ir = new sr(), j = new v("MiLaboratories.Controller.Shared.LS", [
2320
- { name: "List", options: {}, I: or, O: ir }
2330
+ const pr = new ur(), j = new D("MiLaboratories.Controller.Shared.LS", [
2331
+ { name: "List", options: {}, I: hr, O: pr }
2321
2332
  ]);
2322
- class ar {
2333
+ class gr {
2323
2334
  constructor(e) {
2324
- c(this, "typeName", j.typeName);
2325
- c(this, "methods", j.methods);
2326
- c(this, "options", j.options);
2335
+ d(this, "typeName", j.typeName);
2336
+ d(this, "methods", j.methods);
2337
+ d(this, "options", j.options);
2327
2338
  this._transport = e;
2328
2339
  }
2329
2340
  /**
@@ -2331,7 +2342,7 @@ class ar {
2331
2342
  */
2332
2343
  list(e, t) {
2333
2344
  const n = this.methods[0], r = this._transport.mergeOptions(t);
2334
- return w(
2345
+ return y(
2335
2346
  "unary",
2336
2347
  this._transport,
2337
2348
  n,
@@ -2340,10 +2351,10 @@ class ar {
2340
2351
  );
2341
2352
  }
2342
2353
  }
2343
- class lr {
2354
+ class fr {
2344
2355
  constructor(e, t) {
2345
- c(this, "grpcClient");
2346
- this.logger = t, this.grpcClient = new ar(e);
2356
+ d(this, "grpcClient");
2357
+ this.logger = t, this.grpcClient = new gr(e);
2347
2358
  }
2348
2359
  close() {
2349
2360
  }
@@ -2353,11 +2364,11 @@ class lr {
2353
2364
  resourceId: e.id,
2354
2365
  location: t
2355
2366
  },
2356
- T(e.type, n)
2367
+ k(e.type, n)
2357
2368
  ).response;
2358
2369
  }
2359
2370
  }
2360
- class dr extends g {
2371
+ class mr extends g {
2361
2372
  constructor() {
2362
2373
  super("MiLaboratories.Controller.Shared.StreamingAPI", []);
2363
2374
  }
@@ -2377,8 +2388,8 @@ class dr extends g {
2377
2388
  ), t;
2378
2389
  }
2379
2390
  }
2380
- new dr();
2381
- class cr extends g {
2391
+ new mr();
2392
+ class wr extends g {
2382
2393
  constructor() {
2383
2394
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
2384
2395
  {
@@ -2421,9 +2432,9 @@ class cr extends g {
2421
2432
  return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
2422
2433
  }
2423
2434
  internalBinaryRead(e, t, n, r) {
2424
- let o = r ?? this.create(), d = e.pos + t;
2425
- for (; e.pos < d; ) {
2426
- let [i, l] = e.tag();
2435
+ let o = r ?? this.create(), l = e.pos + t;
2436
+ for (; e.pos < l; ) {
2437
+ let [i, c] = e.tag();
2427
2438
  switch (i) {
2428
2439
  case /* uint64 resource_id */
2429
2440
  1:
@@ -2445,14 +2456,14 @@ class cr extends g {
2445
2456
  let a = n.readUnknownField;
2446
2457
  if (a === "throw")
2447
2458
  throw new globalThis.Error(
2448
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2459
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2449
2460
  );
2450
- let p = e.skip(l);
2461
+ let p = e.skip(c);
2451
2462
  a !== !1 && (a === !0 ? u.onRead : a)(
2452
2463
  this.typeName,
2453
2464
  o,
2454
2465
  i,
2455
- l,
2466
+ c,
2456
2467
  p
2457
2468
  );
2458
2469
  }
@@ -2469,8 +2480,8 @@ class cr extends g {
2469
2480
  ), t;
2470
2481
  }
2471
2482
  }
2472
- const hr = new cr();
2473
- class ur extends g {
2483
+ const yr = new wr();
2484
+ class br extends g {
2474
2485
  constructor() {
2475
2486
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
2476
2487
  {
@@ -2504,9 +2515,9 @@ class ur extends g {
2504
2515
  return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
2505
2516
  }
2506
2517
  internalBinaryRead(e, t, n, r) {
2507
- let o = r ?? this.create(), d = e.pos + t;
2508
- for (; e.pos < d; ) {
2509
- let [i, l] = e.tag();
2518
+ let o = r ?? this.create(), l = e.pos + t;
2519
+ for (; e.pos < l; ) {
2520
+ let [i, c] = e.tag();
2510
2521
  switch (i) {
2511
2522
  case /* uint64 resource_id */
2512
2523
  1:
@@ -2524,14 +2535,14 @@ class ur extends g {
2524
2535
  let a = n.readUnknownField;
2525
2536
  if (a === "throw")
2526
2537
  throw new globalThis.Error(
2527
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2538
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2528
2539
  );
2529
- let p = e.skip(l);
2540
+ let p = e.skip(c);
2530
2541
  a !== !1 && (a === !0 ? u.onRead : a)(
2531
2542
  this.typeName,
2532
2543
  o,
2533
2544
  i,
2534
- l,
2545
+ c,
2535
2546
  p
2536
2547
  );
2537
2548
  }
@@ -2548,8 +2559,8 @@ class ur extends g {
2548
2559
  ), t;
2549
2560
  }
2550
2561
  }
2551
- const pr = new ur();
2552
- class gr extends g {
2562
+ const Tr = new br();
2563
+ class kr extends g {
2553
2564
  constructor() {
2554
2565
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
2555
2566
  {
@@ -2600,9 +2611,9 @@ class gr extends g {
2600
2611
  return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
2601
2612
  }
2602
2613
  internalBinaryRead(e, t, n, r) {
2603
- let o = r ?? this.create(), d = e.pos + t;
2604
- for (; e.pos < d; ) {
2605
- let [i, l] = e.tag();
2614
+ let o = r ?? this.create(), l = e.pos + t;
2615
+ for (; e.pos < l; ) {
2616
+ let [i, c] = e.tag();
2606
2617
  switch (i) {
2607
2618
  case /* uint64 resource_id */
2608
2619
  1:
@@ -2628,14 +2639,14 @@ class gr extends g {
2628
2639
  let a = n.readUnknownField;
2629
2640
  if (a === "throw")
2630
2641
  throw new globalThis.Error(
2631
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2642
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2632
2643
  );
2633
- let p = e.skip(l);
2644
+ let p = e.skip(c);
2634
2645
  a !== !1 && (a === !0 ? u.onRead : a)(
2635
2646
  this.typeName,
2636
2647
  o,
2637
2648
  i,
2638
- l,
2649
+ c,
2639
2650
  p
2640
2651
  );
2641
2652
  }
@@ -2652,8 +2663,8 @@ class gr extends g {
2652
2663
  ), t;
2653
2664
  }
2654
2665
  }
2655
- const fr = new gr();
2656
- class mr extends g {
2666
+ const Lr = new kr();
2667
+ class Pr extends g {
2657
2668
  constructor() {
2658
2669
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
2659
2670
  {
@@ -2704,9 +2715,9 @@ class mr extends g {
2704
2715
  return t.resourceId = 0n, t.offset = 0n, e !== void 0 && f(this, t, e), t;
2705
2716
  }
2706
2717
  internalBinaryRead(e, t, n, r) {
2707
- let o = r ?? this.create(), d = e.pos + t;
2708
- for (; e.pos < d; ) {
2709
- let [i, l] = e.tag();
2718
+ let o = r ?? this.create(), l = e.pos + t;
2719
+ for (; e.pos < l; ) {
2720
+ let [i, c] = e.tag();
2710
2721
  switch (i) {
2711
2722
  case /* uint64 resource_id */
2712
2723
  1:
@@ -2732,14 +2743,14 @@ class mr extends g {
2732
2743
  let a = n.readUnknownField;
2733
2744
  if (a === "throw")
2734
2745
  throw new globalThis.Error(
2735
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2746
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2736
2747
  );
2737
- let p = e.skip(l);
2748
+ let p = e.skip(c);
2738
2749
  a !== !1 && (a === !0 ? u.onRead : a)(
2739
2750
  this.typeName,
2740
2751
  o,
2741
2752
  i,
2742
- l,
2753
+ c,
2743
2754
  p
2744
2755
  );
2745
2756
  }
@@ -2756,8 +2767,8 @@ class mr extends g {
2756
2767
  ), t;
2757
2768
  }
2758
2769
  }
2759
- const wr = new mr();
2760
- class yr extends g {
2770
+ const Ir = new Pr();
2771
+ class Rr extends g {
2761
2772
  constructor() {
2762
2773
  super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
2763
2774
  {
@@ -2808,9 +2819,9 @@ class yr extends g {
2808
2819
  return t.resourceId = 0n, e !== void 0 && f(this, t, e), t;
2809
2820
  }
2810
2821
  internalBinaryRead(e, t, n, r) {
2811
- let o = r ?? this.create(), d = e.pos + t;
2812
- for (; e.pos < d; ) {
2813
- let [i, l] = e.tag();
2822
+ let o = r ?? this.create(), l = e.pos + t;
2823
+ for (; e.pos < l; ) {
2824
+ let [i, c] = e.tag();
2814
2825
  switch (i) {
2815
2826
  case /* uint64 resource_id */
2816
2827
  1:
@@ -2836,14 +2847,14 @@ class yr extends g {
2836
2847
  let a = n.readUnknownField;
2837
2848
  if (a === "throw")
2838
2849
  throw new globalThis.Error(
2839
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2850
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2840
2851
  );
2841
- let p = e.skip(l);
2852
+ let p = e.skip(c);
2842
2853
  a !== !1 && (a === !0 ? u.onRead : a)(
2843
2854
  this.typeName,
2844
2855
  o,
2845
2856
  i,
2846
- l,
2857
+ c,
2847
2858
  p
2848
2859
  );
2849
2860
  }
@@ -2860,8 +2871,8 @@ class yr extends g {
2860
2871
  ), t;
2861
2872
  }
2862
2873
  }
2863
- const br = new yr();
2864
- class Tr extends g {
2874
+ const Sr = new Rr();
2875
+ class Nr extends g {
2865
2876
  constructor() {
2866
2877
  super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
2867
2878
  {
@@ -2894,9 +2905,9 @@ class Tr extends g {
2894
2905
  return t.data = new Uint8Array(0), t.size = 0n, t.newOffset = 0n, e !== void 0 && f(this, t, e), t;
2895
2906
  }
2896
2907
  internalBinaryRead(e, t, n, r) {
2897
- let o = r ?? this.create(), d = e.pos + t;
2898
- for (; e.pos < d; ) {
2899
- let [i, l] = e.tag();
2908
+ let o = r ?? this.create(), l = e.pos + t;
2909
+ for (; e.pos < l; ) {
2910
+ let [i, c] = e.tag();
2900
2911
  switch (i) {
2901
2912
  case /* bytes data */
2902
2913
  1:
@@ -2914,14 +2925,14 @@ class Tr extends g {
2914
2925
  let a = n.readUnknownField;
2915
2926
  if (a === "throw")
2916
2927
  throw new globalThis.Error(
2917
- `Unknown field ${i} (wire type ${l}) for ${this.typeName}`
2928
+ `Unknown field ${i} (wire type ${c}) for ${this.typeName}`
2918
2929
  );
2919
- let p = e.skip(l);
2930
+ let p = e.skip(c);
2920
2931
  a !== !1 && (a === !0 ? u.onRead : a)(
2921
2932
  this.typeName,
2922
2933
  o,
2923
2934
  i,
2924
- l,
2935
+ c,
2925
2936
  p
2926
2937
  );
2927
2938
  }
@@ -2938,48 +2949,48 @@ class Tr extends g {
2938
2949
  ), t;
2939
2950
  }
2940
2951
  }
2941
- const U = new Tr(), G = new v(
2952
+ const U = new Nr(), G = new D(
2942
2953
  "MiLaboratories.Controller.Shared.Streaming",
2943
2954
  [
2944
2955
  {
2945
2956
  name: "StreamBinary",
2946
2957
  serverStreaming: !0,
2947
2958
  options: {},
2948
- I: hr,
2959
+ I: yr,
2949
2960
  O: U
2950
2961
  },
2951
2962
  {
2952
2963
  name: "ReadBinary",
2953
2964
  options: {},
2954
- I: pr,
2965
+ I: Tr,
2955
2966
  O: U
2956
2967
  },
2957
2968
  {
2958
2969
  name: "StreamText",
2959
2970
  serverStreaming: !0,
2960
2971
  options: {},
2961
- I: fr,
2972
+ I: Lr,
2962
2973
  O: U
2963
2974
  },
2964
2975
  {
2965
2976
  name: "ReadText",
2966
2977
  options: {},
2967
- I: wr,
2978
+ I: Ir,
2968
2979
  O: U
2969
2980
  },
2970
2981
  {
2971
2982
  name: "LastLines",
2972
2983
  options: {},
2973
- I: br,
2984
+ I: Sr,
2974
2985
  O: U
2975
2986
  }
2976
2987
  ]
2977
2988
  );
2978
- class kr {
2989
+ class Ur {
2979
2990
  constructor(e) {
2980
- c(this, "typeName", G.typeName);
2981
- c(this, "methods", G.methods);
2982
- c(this, "options", G.options);
2991
+ d(this, "typeName", G.typeName);
2992
+ d(this, "methods", G.methods);
2993
+ d(this, "options", G.options);
2983
2994
  this._transport = e;
2984
2995
  }
2985
2996
  /**
@@ -2991,7 +3002,7 @@ class kr {
2991
3002
  */
2992
3003
  streamBinary(e, t) {
2993
3004
  const n = this.methods[0], r = this._transport.mergeOptions(t);
2994
- return w(
3005
+ return y(
2995
3006
  "serverStreaming",
2996
3007
  this._transport,
2997
3008
  n,
@@ -3009,7 +3020,7 @@ class kr {
3009
3020
  */
3010
3021
  readBinary(e, t) {
3011
3022
  const n = this.methods[1], r = this._transport.mergeOptions(t);
3012
- return w(
3023
+ return y(
3013
3024
  "unary",
3014
3025
  this._transport,
3015
3026
  n,
@@ -3025,7 +3036,7 @@ class kr {
3025
3036
  */
3026
3037
  streamText(e, t) {
3027
3038
  const n = this.methods[2], r = this._transport.mergeOptions(t);
3028
- return w(
3039
+ return y(
3029
3040
  "serverStreaming",
3030
3041
  this._transport,
3031
3042
  n,
@@ -3043,7 +3054,7 @@ class kr {
3043
3054
  */
3044
3055
  readText(e, t) {
3045
3056
  const n = this.methods[3], r = this._transport.mergeOptions(t);
3046
- return w(
3057
+ return y(
3047
3058
  "unary",
3048
3059
  this._transport,
3049
3060
  n,
@@ -3065,7 +3076,7 @@ class kr {
3065
3076
  */
3066
3077
  lastLines(e, t) {
3067
3078
  const n = this.methods[4], r = this._transport.mergeOptions(t);
3068
- return w(
3079
+ return y(
3069
3080
  "unary",
3070
3081
  this._transport,
3071
3082
  n,
@@ -3074,17 +3085,17 @@ class kr {
3074
3085
  );
3075
3086
  }
3076
3087
  }
3077
- class Lr {
3088
+ class Br {
3078
3089
  constructor(e, t, n) {
3079
- c(this, "grpcClient");
3080
- this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new kr(this.grpcTransport);
3090
+ d(this, "grpcClient");
3091
+ this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Ur(this.grpcTransport);
3081
3092
  }
3082
3093
  close() {
3083
3094
  }
3084
3095
  /** Reads text back and returns the text,
3085
3096
  * the new offset
3086
3097
  * and the total size of the (currently existing) file. */
3087
- async lastLines({ id: e, type: t }, n, r = 0n, o, d) {
3098
+ async lastLines({ id: e, type: t }, n, r = 0n, o, l) {
3088
3099
  return (await this.grpcClient.lastLines(
3089
3100
  {
3090
3101
  resourceId: e,
@@ -3092,77 +3103,69 @@ class Lr {
3092
3103
  offset: r,
3093
3104
  search: o
3094
3105
  },
3095
- T(t, d)
3106
+ k(t, l)
3096
3107
  )).response;
3097
3108
  }
3098
3109
  /** Reads the file forward and returns the text,
3099
3110
  * the new offset
3100
3111
  * and the total size of the (currently existing) file. */
3101
- async readText({ id: e, type: t }, n, r = 0n, o, d) {
3112
+ async readText({ id: e, type: t }, n, r = 0n, o, l) {
3102
3113
  return (await this.grpcClient.readText(
3103
3114
  {
3104
- resourceId: O(e),
3115
+ resourceId: K(e),
3105
3116
  readLimit: BigInt(n),
3106
3117
  offset: r,
3107
3118
  search: o
3108
3119
  },
3109
- T(t, d)
3120
+ k(t, l)
3110
3121
  )).response;
3111
3122
  }
3112
3123
  }
3113
- const Pr = process.env.PL_STORAGE_TO_PATH ? Object.fromEntries(
3114
- process.env.PL_STORAGE_TO_PATH.split(";").map((s) => s.split(":"))
3115
- ) : {};
3116
- function In(s, e, t) {
3117
- return t === void 0 && (t = Pr), e.getDriver({
3124
+ function Nn(s, e, t) {
3125
+ return e.getDriver({
3118
3126
  name: "DownloadBlob",
3119
- init: (r, o, d) => new Xt(
3120
- o,
3121
- d,
3122
- s,
3123
- t
3124
- )
3127
+ init: (n, r, o) => new or(r, o, s, t)
3125
3128
  });
3126
3129
  }
3127
- function Nn(s, e) {
3130
+ function Un(s, e) {
3128
3131
  return s.getDriver({
3129
3132
  name: "StreamLogs",
3130
- init: (t, n, r) => new Lr(n, r, e)
3133
+ init: (t, n, r) => new Br(n, r, e)
3131
3134
  });
3132
3135
  }
3133
- function Rn(s, e) {
3136
+ function Bn(s, e) {
3134
3137
  return s.getDriver({
3135
3138
  name: "UploadProgress",
3136
- init: (t, n, r) => new xt(n, r, s, e)
3139
+ init: (t, n, r) => new Jt(n, r, s, e)
3137
3140
  });
3138
3141
  }
3139
- function Sn(s, e) {
3142
+ function Dn(s, e) {
3140
3143
  return s.getDriver({
3141
3144
  name: "UploadBlob",
3142
- init: (t, n, r) => new Rt(n, r, s, e)
3145
+ init: (t, n, r) => new _t(n, r, s, e)
3143
3146
  });
3144
3147
  }
3145
- function Un(s, e) {
3148
+ function Dr(s, e) {
3146
3149
  return s.getDriver({
3147
3150
  name: "LsFiles",
3148
- init: (t, n, r) => new lr(n, e)
3151
+ init: (t, n, r) => new fr(n, e)
3149
3152
  });
3150
3153
  }
3151
- class Bn {
3154
+ class vn {
3152
3155
  constructor(e, t) {
3153
- c(this, "updater");
3154
- c(this, "schedule", () => this.updater.schedule());
3155
- this.onUpdate = e, this.sleepMs = t, this.updater = new Se(async () => {
3156
+ d(this, "updater");
3157
+ d(this, "schedule", () => this.updater.schedule());
3158
+ this.onUpdate = e, this.sleepMs = t, this.updater = new Be(async () => {
3156
3159
  for (; ; ) {
3157
3160
  if (await this.onUpdate()) return;
3158
- await te.wait(this.sleepMs);
3161
+ await oe.wait(this.sleepMs);
3159
3162
  }
3160
3163
  });
3161
3164
  }
3162
3165
  }
3163
- class Se {
3166
+ class Be {
3164
3167
  constructor(e) {
3165
- c(this, "updating");
3168
+ d(this, "updating");
3166
3169
  this.onUpdate = e;
3167
3170
  }
3168
3171
  schedule() {
@@ -3177,36 +3180,36 @@ class Se {
3177
3180
  })());
3178
3181
  }
3179
3182
  }
3180
- async function vn(s, e) {
3183
+ async function $n(s, e) {
3181
3184
  return s.withReadTx("LogsDriverGetStream", async (t) => {
3182
- const n = await t.getResourceData(e, !0), r = await Me(t, He(n, "stream"));
3185
+ const n = await t.getResourceData(e, !0), r = await Ge(t, Ve(n, "stream"));
3183
3186
  if (r.error != "")
3184
3187
  throw new Error(`while getting stream: ${r.error}`);
3185
- if (!je(r.valueId))
3188
+ if (!qe(r.valueId))
3186
3189
  return await t.getResourceData(r.valueId, !1);
3187
3190
  });
3188
3191
  }
3189
- const Ue = "8C7#F1328%9E089B3D22", Ir = /(?<stage>.*):\s*(?<progress>[\d.]+%)\s.*(?<eta>ETA:.*)/g;
3190
- function Nr(s) {
3191
- const t = s.replace(Ue, "").match(Ir);
3192
+ const De = "8C7#F1328%9E089B3D22", vr = /(?<stage>.*):\s*(?<progress>[\d.]+%)\s.*(?<eta>ETA:.*)/g;
3193
+ function $r(s) {
3194
+ const t = s.replace(De, "").match(vr);
3192
3195
  if (t == null || t.length != 4)
3193
3196
  return;
3194
- const [n, r, o, d] = t;
3197
+ const [n, r, o, l] = t;
3195
3198
  return {
3196
3199
  stage: r,
3197
3200
  // For example, 'Building pre-clones from tag groups'
3198
3201
  progress: o,
3199
3202
  // 35.3%
3200
- eta: d
3203
+ eta: l
3201
3204
  // ETA: 00:00:07
3202
3205
  };
3203
3206
  }
3204
- async function Dn(s, e, t) {
3207
+ async function _n(s, e, t) {
3205
3208
  const n = await e.lastLines(
3206
3209
  s,
3207
3210
  1,
3208
3211
  0n,
3209
- Ue,
3212
+ De,
3210
3213
  t
3211
3214
  );
3212
3215
  if (n.data == null || n.data.length == 0)
@@ -3214,13 +3217,13 @@ async function Dn(s, e, t) {
3214
3217
  const r = n.data.toString().split(/\r?\n/)[0];
3215
3218
  if (r == null)
3216
3219
  return { found: !1 };
3217
- const o = Nr(r);
3220
+ const o = $r(r);
3218
3221
  return o === void 0 ? { found: !1 } : { found: !0, ...o };
3219
3222
  }
3220
- class Be {
3223
+ class ve {
3221
3224
  constructor(e) {
3222
- c(this, "cache", /* @__PURE__ */ new Map());
3223
- c(this, "totalSizeBytes", 0);
3225
+ d(this, "cache", /* @__PURE__ */ new Map());
3226
+ d(this, "totalSizeBytes", 0);
3224
3227
  this.softSizeBytes = e;
3225
3228
  }
3226
3229
  existsFile(e) {
@@ -3233,16 +3236,16 @@ class Be {
3233
3236
  /** Decrements a counter in a cache and if we exceeds
3234
3237
  * a soft limit, removes files with zero counters. */
3235
3238
  removeFile(e, t) {
3236
- return oe(this.cache, e).counter.dec(t), this.toDelete();
3239
+ return ce(this.cache, e).counter.dec(t), this.toDelete();
3237
3240
  }
3238
3241
  /** Returns what results should be deleted to comply with the soft limit. */
3239
3242
  toDelete() {
3240
3243
  if (this.totalSizeBytes <= this.softSizeBytes) return [];
3241
3244
  const e = [];
3242
3245
  let t = 0;
3243
- return Ve(this.cache).filter(([n, r]) => r.counter.isZero()).forEach(([n, r]) => {
3246
+ return Qe(this.cache).filter(([n, r]) => r.counter.isZero()).forEach(([n, r]) => {
3244
3247
  if (this.totalSizeBytes - t <= this.softSizeBytes) return;
3245
- const o = oe(this.cache, n);
3248
+ const o = ce(this.cache, n);
3246
3249
  t += o.sizeBytes, e.push(o);
3247
3250
  }), e;
3248
3251
  }
@@ -3255,13 +3258,13 @@ class Be {
3255
3258
  this.cache.delete(e.path), this.totalSizeBytes -= e.sizeBytes;
3256
3259
  }
3257
3260
  }
3258
- class $n {
3261
+ class Cn {
3259
3262
  constructor(e, t) {
3260
3263
  this.logsStreamDriver = e, this.downloadDriver = t;
3261
3264
  }
3262
3265
  getLastLogs(e, t, n) {
3263
3266
  if (n === void 0)
3264
- return y.make((o) => this.getLastLogs(e, t, o));
3267
+ return b.make((o) => this.getLastLogs(e, t, o));
3265
3268
  const r = q(n, e);
3266
3269
  if (r === void 0) {
3267
3270
  n.markUnstable("no stream in stream manager");
@@ -3283,7 +3286,7 @@ class $n {
3283
3286
  }
3284
3287
  getProgressLog(e, t, n) {
3285
3288
  if (n === void 0)
3286
- return y.make(
3289
+ return b.make(
3287
3290
  (o) => this.getProgressLog(e, t, o)
3288
3291
  );
3289
3292
  const r = q(n, e);
@@ -3307,7 +3310,7 @@ class $n {
3307
3310
  }
3308
3311
  getLogHandle(e, t) {
3309
3312
  if (t === void 0)
3310
- return y.make((r) => this.getLogHandle(e, r));
3313
+ return b.make((r) => this.getLogHandle(e, r));
3311
3314
  const n = q(t, e);
3312
3315
  if (n === void 0) {
3313
3316
  t.markUnstable("no stream in stream manager");
@@ -3352,57 +3355,57 @@ function q(s, e) {
3352
3355
  function _(s) {
3353
3356
  let e;
3354
3357
  if (C(s))
3355
- e = s.match(De);
3356
- else if (Rr(s))
3357
- e = s.match($e);
3358
+ e = s.match(_e);
3359
+ else if (_r(s))
3360
+ e = s.match(Ce);
3358
3361
  else throw new Error(`Log handle is malformed: ${s}`);
3359
3362
  if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
3360
3363
  const { resourceType: t, resourceVersion: n, resourceId: r } = e.groups;
3361
3364
  return {
3362
- id: Q(BigInt(r)),
3365
+ id: Y(BigInt(r)),
3363
3366
  type: { name: t, version: n }
3364
3367
  };
3365
3368
  }
3366
- function ve(s, e) {
3369
+ function $e(s, e) {
3367
3370
  return s ? `log+live://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}` : `log+ready://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}`;
3368
3371
  }
3369
- const De = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3372
+ const _e = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3370
3373
  function C(s) {
3371
- return De.test(s);
3374
+ return _e.test(s);
3372
3375
  }
3373
- const $e = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3374
- function Rr(s) {
3375
- return $e.test(s);
3376
+ const Ce = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3377
+ function _r(s) {
3378
+ return Ce.test(s);
3376
3379
  }
3377
- const Sr = ye({
3380
+ const Cr = se({
3378
3381
  kv: {
3379
- "ctl/file/blobInfo": L.object({
3380
- sizeBytes: L.coerce.number()
3382
+ "ctl/file/blobInfo": T.object({
3383
+ sizeBytes: T.coerce.number()
3381
3384
  })
3382
3385
  }
3383
3386
  });
3384
- class _n {
3385
- constructor(e, t, n, r, o, d) {
3387
+ class On {
3388
+ constructor(e, t, n, r, o, l) {
3386
3389
  /** Represents a Resource Id to the path of a blob as a map. */
3387
- c(this, "idToDownload", /* @__PURE__ */ new Map());
3390
+ d(this, "idToDownload", /* @__PURE__ */ new Map());
3388
3391
  /** Writes and removes files to a hard drive and holds a counter for every
3389
3392
  * file that should be kept. */
3390
- c(this, "cache");
3393
+ d(this, "cache");
3391
3394
  /** Downloads files and writes them to the local dir. */
3392
- c(this, "downloadQueue");
3393
- c(this, "idToOnDemand", /* @__PURE__ */ new Map());
3394
- c(this, "idToLastLines", /* @__PURE__ */ new Map());
3395
- c(this, "idToProgressLog", /* @__PURE__ */ new Map());
3396
- c(this, "saveDir");
3397
- this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new Be(d.cacheSoftSizeBytes), this.downloadQueue = new X(
3395
+ d(this, "downloadQueue");
3396
+ d(this, "idToOnDemand", /* @__PURE__ */ new Map());
3397
+ d(this, "idToLastLines", /* @__PURE__ */ new Map());
3398
+ d(this, "idToProgressLog", /* @__PURE__ */ new Map());
3399
+ d(this, "saveDir");
3400
+ this.logger = e, this.clientDownload = t, this.clientLogs = n, this.signer = o, this.cache = new ve(l.cacheSoftSizeBytes), this.downloadQueue = new ee(
3398
3401
  this.logger,
3399
- d.nConcurrentDownloads
3400
- ), this.saveDir = m.resolve(r);
3402
+ l.nConcurrentDownloads
3403
+ ), this.saveDir = w.resolve(r);
3401
3404
  }
3402
3405
  getDownloadedBlob(e, t) {
3403
3406
  if (t === void 0)
3404
- return y.make((d) => this.getDownloadedBlob(e, d));
3405
- const n = N(e, t), r = k();
3407
+ return b.make((l) => this.getDownloadedBlob(e, l));
3408
+ const n = R(e, t), r = L();
3406
3409
  t.addOnDestroy(() => this.releaseBlob(n.id, r));
3407
3410
  const o = this.getDownloadedBlobNoCtx(
3408
3411
  t.watcher,
@@ -3413,27 +3416,27 @@ class _n {
3413
3416
  }
3414
3417
  getOnDemandBlob(e, t) {
3415
3418
  if (t === void 0)
3416
- return y.make((d) => this.getOnDemandBlob(e, d));
3417
- const n = be(e) ? Te(e, Sr, t) : e, r = k();
3419
+ return b.make((l) => this.getOnDemandBlob(e, l));
3420
+ const n = ie(e) ? Q(e, Cr, t) : e, r = L();
3418
3421
  return t.addOnDestroy(() => this.releaseOnDemandBlob(n.id, r)), this.getOnDemandBlobNoCtx(t.watcher, n, r);
3419
3422
  }
3420
3423
  getLocalPath(e) {
3421
- return Z(e, this.signer);
3424
+ return J(e, this.signer);
3422
3425
  }
3423
3426
  async getContent(e) {
3424
- if ($r(e)) return await Br(this.getLocalPath(e));
3425
- if (!Cr(e)) throw new Error("Malformed remote handle");
3426
- const t = Or(e, this.signer), { content: n } = await this.clientDownload.downloadBlob(t);
3427
- return await me(n);
3427
+ if (zr(e)) return await Fr(this.getLocalPath(e));
3428
+ if (!Ar(e)) throw new Error("Malformed remote handle");
3429
+ const t = Mr(e, this.signer), { content: n } = await this.clientDownload.downloadBlob(t);
3430
+ return await ke(n);
3428
3431
  }
3429
3432
  getDownloadedBlobNoCtx(e, t, n) {
3430
3433
  let r = this.idToDownload.get(t.id);
3431
3434
  if (r === void 0) {
3432
- const d = this.setNewDownloadTask(e, t, n);
3435
+ const l = this.setNewDownloadTask(e, t, n);
3433
3436
  this.downloadQueue.push({
3434
- fn: () => this.downloadBlob(d, n),
3437
+ fn: () => this.downloadBlob(l, n),
3435
3438
  recoverableErrorPredicate: (i) => !0
3436
- }), r = d;
3439
+ }), r = l;
3437
3440
  }
3438
3441
  r.attach(e, n);
3439
3442
  const o = r.getBlob();
@@ -3443,11 +3446,11 @@ class _n {
3443
3446
  }
3444
3447
  }
3445
3448
  setNewDownloadTask(e, t, n) {
3446
- const r = this.getFilePath(t.id), o = new Dr(
3449
+ const r = this.getFilePath(t.id), o = new Wr(
3447
3450
  this.clientDownload,
3448
3451
  t,
3449
3452
  r,
3450
- _r(r, this.signer)
3453
+ xr(r, this.signer)
3451
3454
  );
3452
3455
  return this.idToDownload.set(t.id, o), o;
3453
3456
  }
@@ -3457,75 +3460,75 @@ class _n {
3457
3460
  }
3458
3461
  getOnDemandBlobNoCtx(e, t, n) {
3459
3462
  let r = this.idToOnDemand.get(t.id);
3460
- return r === void 0 && (r = new Ur(
3463
+ return r === void 0 && (r = new Or(
3461
3464
  t.kv["ctl/file/blobInfo"].sizeBytes,
3462
- Er(t, this.signer)
3465
+ Hr(t, this.signer)
3463
3466
  ), this.idToOnDemand.set(t.id, r)), r.attach(e, n), r.getHandle();
3464
3467
  }
3465
3468
  getLastLogs(e, t, n) {
3466
3469
  if (n == null)
3467
- return y.make((i) => this.getLastLogs(e, t, i));
3468
- const r = N(e, n), o = k();
3470
+ return b.make((i) => this.getLastLogs(e, t, i));
3471
+ const r = R(e, n), o = L();
3469
3472
  n.addOnDestroy(() => this.releaseBlob(r.id, o));
3470
- const d = this.getLastLogsNoCtx(
3473
+ const l = this.getLastLogsNoCtx(
3471
3474
  n.watcher,
3472
3475
  r,
3473
3476
  t,
3474
3477
  o
3475
3478
  );
3476
- return d == null && n.markUnstable("either a file was not downloaded or logs was not read"), d;
3479
+ return l == null && n.markUnstable("either a file was not downloaded or logs was not read"), l;
3477
3480
  }
3478
3481
  getLastLogsNoCtx(e, t, n, r) {
3479
3482
  const o = this.getDownloadedBlobNoCtx(e, t, r);
3480
3483
  if (o == null) return;
3481
- const d = Z(o.handle, this.signer);
3484
+ const l = J(o.handle, this.signer);
3482
3485
  let i = this.idToLastLines.get(t.id);
3483
3486
  if (i == null) {
3484
- const a = new ae(d, n);
3487
+ const a = new he(l, n);
3485
3488
  this.idToLastLines.set(t.id, a), i = a;
3486
3489
  }
3487
- const l = i.getOrSchedule(e);
3488
- if (l.error) throw l.error;
3489
- return l.log;
3490
+ const c = i.getOrSchedule(e);
3491
+ if (c.error) throw c.error;
3492
+ return c.log;
3490
3493
  }
3491
3494
  getProgressLog(e, t, n) {
3492
3495
  if (n == null)
3493
- return y.make(
3496
+ return b.make(
3494
3497
  (i) => this.getProgressLog(e, t, i)
3495
3498
  );
3496
- const r = N(e, n), o = k();
3499
+ const r = R(e, n), o = L();
3497
3500
  n.addOnDestroy(() => this.releaseBlob(r.id, o));
3498
- const d = this.getProgressLogNoCtx(
3501
+ const l = this.getProgressLogNoCtx(
3499
3502
  n.watcher,
3500
3503
  r,
3501
3504
  t,
3502
3505
  o
3503
3506
  );
3504
- return d === void 0 && n.markUnstable(
3507
+ return l === void 0 && n.markUnstable(
3505
3508
  "either a file was not downloaded or a progress log was not read"
3506
- ), d;
3509
+ ), l;
3507
3510
  }
3508
3511
  getProgressLogNoCtx(e, t, n, r) {
3509
3512
  const o = this.getDownloadedBlobNoCtx(e, t, r);
3510
3513
  if (o == null) return;
3511
- const d = Z(o.handle, this.signer);
3514
+ const l = J(o.handle, this.signer);
3512
3515
  let i = this.idToProgressLog.get(t.id);
3513
3516
  if (i == null) {
3514
- const a = new ae(d, 1, n);
3517
+ const a = new he(l, 1, n);
3515
3518
  this.idToProgressLog.set(t.id, a), i = a;
3516
3519
  }
3517
- const l = i.getOrSchedule(e);
3518
- if (l.error) throw l.error;
3519
- return l.log;
3520
+ const c = i.getOrSchedule(e);
3521
+ if (c.error) throw c.error;
3522
+ return c.log;
3520
3523
  }
3521
3524
  getLogHandle(e, t) {
3522
3525
  if (t == null)
3523
- return y.make((r) => this.getLogHandle(e, r));
3524
- const n = N(e, t);
3526
+ return b.make((r) => this.getLogHandle(e, r));
3527
+ const n = R(e, t);
3525
3528
  return this.getLogHandleNoCtx(n);
3526
3529
  }
3527
3530
  getLogHandleNoCtx(e) {
3528
- return ve(!1, e);
3531
+ return $e(!1, e);
3529
3532
  }
3530
3533
  async lastLines(e, t, n, r) {
3531
3534
  const o = await this.clientLogs.lastLines(
@@ -3564,9 +3567,9 @@ class _n {
3564
3567
  const r = this.cache.removeFile(n.path, t);
3565
3568
  await Promise.all(
3566
3569
  r.map(async (o) => {
3567
- await b.rm(o.path), this.cache.removeCache(o), this.removeTask(
3570
+ await m.rm(o.path), this.cache.removeCache(o), this.removeTask(
3568
3571
  o,
3569
- `the task ${o.path} was removedfrom cache along with ${r.map((d) => d.path)}`
3572
+ `the task ${o.path} was removedfrom cache along with ${r.map((l) => l.path)}`
3570
3573
  );
3571
3574
  })
3572
3575
  );
@@ -3587,13 +3590,13 @@ class _n {
3587
3590
  });
3588
3591
  }
3589
3592
  getFilePath(e) {
3590
- return m.resolve(m.join(this.saveDir, String(BigInt(e))));
3593
+ return w.resolve(w.join(this.saveDir, String(BigInt(e))));
3591
3594
  }
3592
3595
  }
3593
- class Ur {
3596
+ class Or {
3594
3597
  constructor(e, t) {
3595
- c(this, "change", new S());
3596
- c(this, "counter", new D());
3598
+ d(this, "change", new N());
3599
+ d(this, "counter", new v());
3597
3600
  this.size = e, this.handle = t;
3598
3601
  }
3599
3602
  getHandle() {
@@ -3606,13 +3609,13 @@ class Ur {
3606
3609
  return this.counter.dec(e);
3607
3610
  }
3608
3611
  }
3609
- class ae {
3612
+ class he {
3610
3613
  constructor(e, t, n) {
3611
- c(this, "updater");
3612
- c(this, "log");
3613
- c(this, "change", new S());
3614
- c(this, "error");
3615
- this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new Se(async () => this.update());
3614
+ d(this, "updater");
3615
+ d(this, "log");
3616
+ d(this, "change", new N());
3617
+ d(this, "error");
3618
+ this.path = e, this.lines = t, this.patternToSearch = n, this.updater = new Be(async () => this.update());
3616
3619
  }
3617
3620
  getOrSchedule(e) {
3618
3621
  return this.change.attachWatcher(e), this.updater.schedule(), {
@@ -3622,7 +3625,7 @@ class ae {
3622
3625
  }
3623
3626
  async update() {
3624
3627
  try {
3625
- const e = await vr(
3628
+ const e = await Er(
3626
3629
  this.path,
3627
3630
  this.lines,
3628
3631
  this.patternToSearch
@@ -3637,35 +3640,35 @@ class ae {
3637
3640
  }
3638
3641
  }
3639
3642
  }
3640
- async function le(s) {
3643
+ async function ue(s) {
3641
3644
  try {
3642
- return await b.access(s), !0;
3645
+ return await m.access(s), !0;
3643
3646
  } catch {
3644
3647
  return !1;
3645
3648
  }
3646
3649
  }
3647
- async function Br(s) {
3648
- return await me(K.toWeb(E.createReadStream(s)));
3650
+ async function Fr(s) {
3651
+ return await ke(re.toWeb(O.createReadStream(s)));
3649
3652
  }
3650
- function vr(s, e, t) {
3651
- const n = E.createReadStream(s), r = new ee();
3652
- return new Promise((o, d) => {
3653
- const i = Xe.createInterface(n, r), l = new Ye();
3653
+ function Er(s, e, t) {
3654
+ const n = O.createReadStream(s), r = new ne();
3655
+ return new Promise((o, l) => {
3656
+ const i = rt.createInterface(n, r), c = new nt();
3654
3657
  i.on("line", function(a) {
3655
- t != null && !a.includes(t) || (l.push(a), l.length > e && l.shift());
3656
- }), i.on("error", d), i.on("close", function() {
3657
- o(l.toArray().join(se.EOL) + se.EOL);
3658
+ t != null && !a.includes(t) || (c.push(a), c.length > e && c.shift());
3659
+ }), i.on("error", l), i.on("close", function() {
3660
+ o(c.toArray().join(Z.EOL) + Z.EOL);
3658
3661
  });
3659
3662
  });
3660
3663
  }
3661
- let Dr = class {
3664
+ let Wr = class {
3662
3665
  constructor(e, t, n, r) {
3663
- c(this, "counter", new D());
3664
- c(this, "change", new S());
3665
- c(this, "signalCtl", new AbortController());
3666
- c(this, "error");
3667
- c(this, "done", !1);
3668
- c(this, "sizeBytes", 0);
3666
+ d(this, "counter", new v());
3667
+ d(this, "change", new N());
3668
+ d(this, "signalCtl", new AbortController());
3669
+ d(this, "error");
3670
+ d(this, "done", !1);
3671
+ d(this, "sizeBytes", 0);
3669
3672
  this.clientDownload = e, this.rInfo = t, this.path = n, this.handle = r;
3670
3673
  }
3671
3674
  attach(e, t) {
@@ -3676,16 +3679,16 @@ let Dr = class {
3676
3679
  const { content: e, size: t } = await this.clientDownload.downloadBlob(
3677
3680
  this.rInfo
3678
3681
  );
3679
- if (await le(m.dirname(this.path)) || await b.mkdir(m.dirname(this.path), { recursive: !0 }), await le(this.path))
3682
+ if (await ue(w.dirname(this.path)) || await m.mkdir(w.dirname(this.path), { recursive: !0 }), await ue(this.path))
3680
3683
  await e.cancel("the file already existed");
3681
3684
  else {
3682
- const n = ee.toWeb(E.createWriteStream(this.path));
3685
+ const n = ne.toWeb(O.createWriteStream(this.path));
3683
3686
  await e.pipeTo(n);
3684
3687
  }
3685
3688
  this.setDone(t);
3686
3689
  } catch (e) {
3687
- if (e instanceof de || e instanceof re || e instanceof Ne || e instanceof Re || e.code == "ENOENT") {
3688
- this.setError(e), await b.rm(this.path);
3690
+ if (e instanceof pe || e instanceof ae || e instanceof Ne || e instanceof Ue || e.code == "ENOENT") {
3691
+ this.setError(e), await m.rm(this.path);
3689
3692
  return;
3690
3693
  }
3691
3694
  throw e;
@@ -3710,20 +3713,20 @@ let Dr = class {
3710
3713
  this.done = !0, this.sizeBytes = e, this.change.markChanged();
3711
3714
  }
3712
3715
  abort(e) {
3713
- this.signalCtl.abort(new de(e));
3716
+ this.signalCtl.abort(new pe(e));
3714
3717
  }
3715
3718
  setError(e) {
3716
3719
  this.error = e, this.change.markChanged();
3717
3720
  }
3718
3721
  };
3719
- class de extends Error {
3722
+ class pe extends Error {
3720
3723
  }
3721
- const _e = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3722
- function $r(s) {
3723
- return !!s.match(_e);
3724
+ const Oe = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3725
+ function zr(s) {
3726
+ return !!s.match(Oe);
3724
3727
  }
3725
- function Z(s, e) {
3726
- const t = s.match(_e);
3728
+ function J(s, e) {
3729
+ const t = s.match(Oe);
3727
3730
  if (t === null)
3728
3731
  throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
3729
3732
  const { path: n, signature: r } = t.groups;
@@ -3733,91 +3736,106 @@ function Z(s, e) {
3733
3736
  `Signature verification failed for: ${s}`
3734
3737
  ), n;
3735
3738
  }
3736
- function _r(s, e) {
3739
+ function xr(s, e) {
3737
3740
  return `blob+local://download/${s}#${e.sign(s)}`;
3738
3741
  }
3739
- const Ce = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3740
- function Cr(s) {
3741
- return !!s.match(Ce);
3742
+ const Fe = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3743
+ function Ar(s) {
3744
+ return !!s.match(Fe);
3742
3745
  }
3743
- function Or(s, e) {
3744
- const t = s.match(Ce);
3746
+ function Mr(s, e) {
3747
+ const t = s.match(Fe);
3745
3748
  if (t === null)
3746
3749
  throw new Error(
3747
3750
  `Remote handle is malformed: ${s}, matches: ${t}`
3748
3751
  );
3749
- const { content: n, resourceType: r, resourceVersion: o, resourceId: d, signature: i } = t.groups;
3752
+ const { content: n, resourceType: r, resourceVersion: o, resourceId: l, signature: i } = t.groups;
3750
3753
  return e.verify(
3751
3754
  n,
3752
3755
  i,
3753
3756
  `Signature verification failed for ${s}`
3754
3757
  ), {
3755
- id: Q(BigInt(d)),
3758
+ id: Y(BigInt(l)),
3756
3759
  type: { name: r, version: o }
3757
3760
  };
3758
3761
  }
3759
- function Er(s, e) {
3762
+ function Hr(s, e) {
3760
3763
  const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
3761
3764
  return `blob+remote://download/${t}#${e.sign(t)}`;
3762
3765
  }
3763
- const Fr = L.object({
3764
- localPath: L.string(),
3765
- pathSignature: L.string(),
3766
- modificationTime: L.string()
3767
- }), Wr = L.union([Fr, L.object({})]), Ar = ye({
3768
- data: Wr,
3766
+ const F = T.object({
3767
+ /** Local file path, to take data for upload */
3768
+ localPath: T.string(),
3769
+ /** Path signature, to check this data was generated by us */
3770
+ pathSignature: T.string(),
3771
+ /** File size in bytes */
3772
+ sizeBytes: T.string(),
3773
+ /** Modification time unix timestamp in seconds */
3774
+ modificationTime: T.string()
3775
+ }), Ee = T.object({
3776
+ /** Pl storage id */
3777
+ storageId: T.string(),
3778
+ /** Path inside storage */
3779
+ path: T.string()
3780
+ }), En = T.union([
3781
+ F,
3782
+ Ee
3783
+ ]), jr = se({
3784
+ data: F,
3785
+ fields: {
3786
+ blob: !1
3787
+ }
3788
+ }), Gr = se({
3769
3789
  fields: {
3770
- blob: !1,
3771
- // for BlobUpload
3772
3790
  incarnation: !1
3773
- // for BlobIndex
3774
3791
  }
3775
3792
  });
3776
- class On {
3793
+ function Vr(s, e) {
3794
+ const t = ie(s) ? e.accessor(s).node() : st(s) ? s.node() : s;
3795
+ return t.resourceType.name.startsWith("BlobUpload") ? Q(t, jr) : Q(t, Gr);
3796
+ }
3797
+ class Wn {
3777
3798
  constructor(e, t, n, r, o = {
3778
3799
  nConcurrentPartUploads: 10,
3779
3800
  nConcurrentGetProgresses: 10,
3780
3801
  pollingInterval: 1e3,
3781
3802
  stopPollingDelay: 1e3
3782
3803
  }) {
3783
- c(this, "idToProgress", /* @__PURE__ */ new Map());
3804
+ d(this, "idToProgress", /* @__PURE__ */ new Map());
3784
3805
  /** Holds a queue that upload blobs. */
3785
- c(this, "uploadQueue");
3786
- c(this, "hooks");
3787
- c(this, "scheduledOnNextState", []);
3806
+ d(this, "uploadQueue");
3807
+ d(this, "hooks");
3808
+ d(this, "scheduledOnNextState", []);
3788
3809
  /** If true, main loop will continue polling pl state. */
3789
- c(this, "keepRunning", !1);
3810
+ d(this, "keepRunning", !1);
3790
3811
  /** Actual state of main loop. */
3791
- c(this, "currentLoop");
3792
- this.logger = e, this.signer = t, this.clientBlob = n, this.clientProgress = r, this.opts = o, this.uploadQueue = new X(this.logger, 1, {
3812
+ d(this, "currentLoop");
3813
+ this.logger = e, this.signer = t, this.clientBlob = n, this.clientProgress = r, this.opts = o, this.uploadQueue = new ee(this.logger, 1, {
3793
3814
  type: "exponentialWithMaxDelayBackoff",
3794
3815
  initialDelay: 20,
3795
3816
  maxDelay: 15e3,
3796
3817
  // 15 seconds
3797
3818
  backoffMultiplier: 1.5,
3798
3819
  jitter: 0.5
3799
- }), this.hooks = new we(
3820
+ }), this.hooks = new Le(
3800
3821
  () => this.startUpdating(),
3801
3822
  () => this.stopUpdating(),
3802
3823
  { stopDebounce: o.stopPollingDelay },
3803
- (d, i) => this.scheduleOnNextState(d, i)
3824
+ (l, i) => this.scheduleOnNextState(l, i)
3804
3825
  );
3805
3826
  }
3806
3827
  getProgressId(e, t) {
3807
- if (t == null)
3808
- return y.make((d) => this.getProgressId(e, d));
3809
- const n = be(e) ? Te(e, Ar, t) : e, r = k();
3828
+ if (t == null) return b.make((l) => this.getProgressId(e, l));
3829
+ const n = ie(e) ? Vr(e, t) : e, r = L();
3810
3830
  t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(n.id, r));
3811
3831
  const o = this.getProgressIdNoCtx(t.watcher, n, r);
3812
- return ce(o) || t.markUnstable(
3813
- `upload/index progress was got, but it's not stable: ${o}`
3814
- ), o;
3832
+ return ge(o) || t.markUnstable(`upload/index progress was got, but it's not stable: ${o}`), o;
3815
3833
  }
3816
3834
  getProgressIdNoCtx(e, t, n) {
3817
- const r = t.fields.blob != null || t.fields.incarnation != null, o = this.idToProgress.get(t.id);
3835
+ const r = "blob" in t.fields ? t.fields.blob !== void 0 : t.fields.incarnation !== void 0, o = this.idToProgress.get(t.id);
3818
3836
  if (o != null)
3819
3837
  return o.attach(e, n), o.mustGetProgress(r);
3820
- const d = new zr(
3838
+ const l = new qr(
3821
3839
  this.logger,
3822
3840
  this.clientBlob,
3823
3841
  this.clientProgress,
@@ -3825,10 +3843,10 @@ class On {
3825
3843
  this.signer,
3826
3844
  t
3827
3845
  );
3828
- return this.idToProgress.set(t.id, d), d.attach(e, n), d.progress.isUpload && d.progress.isUploadSignMatch && this.uploadQueue.push({
3829
- fn: () => d.uploadBlobTask(),
3830
- recoverableErrorPredicate: (i) => !Oe(i)
3831
- }), d.mustGetProgress(r);
3846
+ return this.idToProgress.set(t.id, l), l.attach(e, n), l.progress.isUpload && l.progress.isUploadSignMatch && this.uploadQueue.push({
3847
+ fn: () => l.uploadBlobTask(),
3848
+ recoverableErrorPredicate: (i) => !We(i)
3849
+ }), l.mustGetProgress(r);
3832
3850
  }
3833
3851
  /** Decrement counters for the file and remove an uploading if counter == 0. */
3834
3852
  async release(e, t) {
@@ -3856,43 +3874,42 @@ class On {
3856
3874
  const e = this.scheduledOnNextState;
3857
3875
  this.scheduledOnNextState = [];
3858
3876
  try {
3859
- await Y(
3877
+ await te(
3860
3878
  this.opts.nConcurrentGetProgresses,
3861
- this.getAllNotDoneProgresses().map(
3862
- (t) => async () => await t.updateStatus()
3863
- )
3879
+ this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
3864
3880
  ), e.forEach((t) => t.resolve());
3865
3881
  } catch (t) {
3866
3882
  console.error(t), e.forEach((n) => n.reject(t));
3867
3883
  }
3868
3884
  if (!this.keepRunning) break;
3869
- await te.wait(this.opts.pollingInterval);
3885
+ await oe.wait(this.opts.pollingInterval);
3870
3886
  }
3871
3887
  this.currentLoop = void 0;
3872
3888
  }
3873
3889
  getAllNotDoneProgresses() {
3874
- return Array.from(this.idToProgress.entries()).filter(([e, t]) => !ce(t.progress)).map(([e, t]) => t);
3890
+ return Array.from(this.idToProgress.entries()).filter(([e, t]) => !ge(t.progress)).map(([e, t]) => t);
3875
3891
  }
3876
3892
  }
3877
- class zr {
3878
- constructor(e, t, n, r, o, d) {
3879
- c(this, "change", new S());
3880
- c(this, "counter", new D());
3881
- c(this, "progress");
3882
- c(this, "uploadOpts");
3883
- c(this, "uploadingTerminallyFailed");
3884
- this.logger = e, this.clientBlob = t, this.clientProgress = n, this.nConcurrentPartsUpload = r, this.res = d;
3885
- const i = d.type.name.startsWith("BlobUpload");
3886
- let l;
3887
- i && (this.uploadOpts = xr(d), l = Hr(
3893
+ class qr {
3894
+ constructor(e, t, n, r, o, l) {
3895
+ d(this, "change", new N());
3896
+ d(this, "counter", new v());
3897
+ d(this, "progress");
3898
+ /** If this is upload progress this field will be defined */
3899
+ d(this, "uploadData");
3900
+ d(this, "uploadingTerminallyFailed");
3901
+ this.logger = e, this.clientBlob = t, this.clientProgress = n, this.nConcurrentPartsUpload = r, this.res = l;
3902
+ const i = l.type.name.startsWith("BlobUpload");
3903
+ let c;
3904
+ i && (this.uploadData = F.parse(l.data), c = Zr(
3888
3905
  o,
3889
- this.uploadOpts.localPath,
3890
- this.uploadOpts.pathSignature
3906
+ this.uploadData.localPath,
3907
+ this.uploadData.pathSignature
3891
3908
  )), this.progress = {
3892
3909
  done: !1,
3893
3910
  status: void 0,
3894
3911
  isUpload: i,
3895
- isUploadSignMatch: l,
3912
+ isUploadSignMatch: c,
3896
3913
  lastError: void 0
3897
3914
  };
3898
3915
  }
@@ -3900,9 +3917,7 @@ class zr {
3900
3917
  if (e)
3901
3918
  return this.setDone(e), this.progress;
3902
3919
  if (this.uploadingTerminallyFailed)
3903
- throw this.logger.error(
3904
- `Uploading terminally failed: ${this.progress.lastError}`
3905
- ), new Error(this.progress.lastError);
3920
+ throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
3906
3921
  return this.progress;
3907
3922
  }
3908
3923
  attach(e, t) {
@@ -3916,30 +3931,28 @@ class zr {
3916
3931
  try {
3917
3932
  await this.uploadBlob();
3918
3933
  } catch (e) {
3919
- if (this.setLastError(e), he(e)) {
3934
+ if (this.setLastError(e), fe(e)) {
3920
3935
  this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
3921
3936
  return;
3922
3937
  }
3923
- throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Oe(e) && this.terminateWithError(e), e;
3938
+ throw this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), We(e) && this.terminateWithError(e), e;
3924
3939
  }
3925
3940
  }
3926
3941
  /** Uploads a blob using client. */
3927
3942
  async uploadBlob() {
3928
3943
  if (this.counter.isZero()) return;
3929
3944
  const e = await this.clientBlob.initUpload(this.res);
3930
- this.logger.info(
3931
- `start to upload blob ${this.res.id}, parts count: ${e.length}`
3932
- );
3945
+ this.logger.info(`start to upload blob ${this.res.id}, parts count: ${e.length}`);
3933
3946
  const t = (n) => async () => {
3934
3947
  this.counter.isZero() || await this.clientBlob.partUpload(
3935
3948
  this.res,
3936
- this.uploadOpts.localPath,
3949
+ this.uploadData.localPath,
3937
3950
  n,
3938
3951
  e.length,
3939
- BigInt(this.uploadOpts.modificationTime)
3952
+ BigInt(this.uploadData.modificationTime)
3940
3953
  );
3941
3954
  };
3942
- await Y(this.nConcurrentPartsUpload, e.map(t)), !this.counter.isZero() && (await this.clientBlob.finalizeUpload(this.res), this.logger.info(`uploading of resource ${this.res.id} finished.`), this.change.markChanged());
3955
+ await te(this.nConcurrentPartsUpload, e.map(t)), !this.counter.isZero() && (await this.clientBlob.finalizeUpload(this.res), this.logger.info(`uploading of resource ${this.res.id} finished.`), this.change.markChanged());
3943
3956
  }
3944
3957
  terminateWithError(e) {
3945
3958
  this.progress.lastError = String(e), this.progress.done = !1, this.uploadingTerminallyFailed = !0;
@@ -3953,17 +3966,15 @@ class zr {
3953
3966
  async updateStatus() {
3954
3967
  try {
3955
3968
  const e = await this.clientProgress.getStatus(this.res), t = this.progress.status;
3956
- this.progress.status = Mr(e), this.setDone(e.done), (e.done || e.progress != (t == null ? void 0 : t.progress)) && this.change.markChanged();
3969
+ this.progress.status = Jr(e), this.setDone(e.done), (e.done || e.progress != (t == null ? void 0 : t.progress)) && this.change.markChanged();
3957
3970
  } catch (e) {
3958
3971
  if (this.setLastError(e), e.name == "RpcError" && e.code == "DEADLINE_EXCEEDED") {
3959
- this.logger.warn(
3960
- "deadline exceeded while getting a status of BlobImport"
3961
- );
3972
+ this.logger.warn("deadline exceeded while getting a status of BlobImport");
3962
3973
  return;
3963
3974
  }
3964
- if (he(e)) {
3975
+ if (fe(e)) {
3965
3976
  this.logger.warn(
3966
- `resource was not found while updating a status of BlobImport: ${e}, ${B(this.res)}`
3977
+ `resource was not found while updating a status of BlobImport: ${e}, ${Je(this.res)}`
3967
3978
  ), this.change.markChanged(), this.setDone(!0);
3968
3979
  return;
3969
3980
  }
@@ -3971,71 +3982,47 @@ class zr {
3971
3982
  }
3972
3983
  }
3973
3984
  }
3974
- function ce(s) {
3985
+ function ge(s) {
3975
3986
  return s.done && s.status !== void 0 && s.status !== null && s.status.progress >= 1;
3976
3987
  }
3977
- function xr(s) {
3978
- if (s.data == null || !("modificationTime" in s.data))
3979
- throw new Error(
3980
- "no upload options in BlobUpload resource data: " + B(s.data)
3981
- );
3982
- const e = s.data;
3983
- if (e.modificationTime === void 0)
3984
- throw new Error(
3985
- "no modification time in data: " + B(s.data)
3986
- );
3987
- if (e.localPath === void 0)
3988
- throw new Error(
3989
- "no local path in data: " + B(s.data)
3990
- );
3991
- if (e.pathSignature === void 0)
3992
- throw new Error(
3993
- "no path signature in data: " + B(s.data)
3994
- );
3995
- return {
3996
- modificationTime: e.modificationTime,
3997
- localPath: e.localPath,
3998
- pathSignature: e.pathSignature
3999
- };
4000
- }
4001
- function Mr(s) {
3988
+ function Jr(s) {
4002
3989
  return {
4003
3990
  progress: s.progress ?? 0,
4004
3991
  bytesProcessed: Number(s.bytesProcessed),
4005
3992
  bytesTotal: Number(s.bytesTotal)
4006
3993
  };
4007
3994
  }
4008
- function Hr(s, e, t) {
3995
+ function Zr(s, e, t) {
4009
3996
  try {
4010
3997
  return s.verify(e, t), !0;
4011
3998
  } catch {
4012
3999
  return !1;
4013
4000
  }
4014
4001
  }
4015
- function Oe(s) {
4016
- return s instanceof ke || s instanceof Le || s instanceof Pe;
4002
+ function We(s) {
4003
+ return s instanceof Pe || s instanceof Ie || s instanceof Re;
4017
4004
  }
4018
- function he(s) {
4005
+ function fe(s) {
4019
4006
  return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
4020
4007
  }
4021
- class En {
4008
+ class zn {
4022
4009
  constructor(e, t = {
4023
4010
  nConcurrentGetLogs: 10,
4024
4011
  pollingInterval: 1e3,
4025
4012
  stopPollingDelay: 1e3
4026
4013
  }) {
4027
4014
  /** Holds a map of StreamManager Resource Id to all logs of this stream. */
4028
- c(this, "idToLastLines", /* @__PURE__ */ new Map());
4015
+ d(this, "idToLastLines", /* @__PURE__ */ new Map());
4029
4016
  /** Holds a map of StreamManager Resource Id to the last log line of this stream. */
4030
- c(this, "idToProgressLog", /* @__PURE__ */ new Map());
4017
+ d(this, "idToProgressLog", /* @__PURE__ */ new Map());
4031
4018
  /** Holds a map of StreamManager Resource Id to log id smart object. */
4032
- c(this, "hooks");
4033
- c(this, "scheduledOnNextState", []);
4019
+ d(this, "hooks");
4020
+ d(this, "scheduledOnNextState", []);
4034
4021
  /** If true, main loop will continue polling pl state. */
4035
- c(this, "keepRunning", !1);
4022
+ d(this, "keepRunning", !1);
4036
4023
  /** Actual state of main loop. */
4037
- c(this, "currentLoop");
4038
- this.clientLogs = e, this.opts = t, this.hooks = new we(
4024
+ d(this, "currentLoop");
4025
+ this.clientLogs = e, this.opts = t, this.hooks = new Le(
4039
4026
  () => this.startUpdating(),
4040
4027
  () => this.stopUpdating(),
4041
4028
  { stopDebounce: t.stopPollingDelay },
@@ -4044,33 +4031,33 @@ class En {
4044
4031
  }
4045
4032
  getLastLogs(e, t, n) {
4046
4033
  if (n == null)
4047
- return y.make((i) => this.getLastLogs(e, t, i));
4048
- const r = N(e, n), o = k();
4034
+ return b.make((i) => this.getLastLogs(e, t, i));
4035
+ const r = R(e, n), o = L();
4049
4036
  n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseLastLogs(r.id, o));
4050
- const d = this.getLastLogsNoCtx(n.watcher, r, t, o);
4037
+ const l = this.getLastLogsNoCtx(n.watcher, r, t, o);
4051
4038
  return n.markUnstable(
4052
4039
  "The logs are from stream, so we consider them unstable. Final values will be got from blobs."
4053
- ), d;
4040
+ ), l;
4054
4041
  }
4055
4042
  getLastLogsNoCtx(e, t, n, r) {
4056
4043
  let o = this.idToLastLines.get(t.id);
4057
4044
  if (o == null) {
4058
- const i = new ue(this.clientLogs, t, n);
4045
+ const i = new me(this.clientLogs, t, n);
4059
4046
  this.idToLastLines.set(t.id, i), o = i;
4060
4047
  }
4061
4048
  o.attach(e, r);
4062
- const d = o.getLog();
4063
- if (d.error != null) throw d.error;
4064
- return d.log;
4049
+ const l = o.getLog();
4050
+ if (l.error != null) throw l.error;
4051
+ return l.log;
4065
4052
  }
4066
4053
  getProgressLog(e, t, n) {
4067
4054
  if (n == null)
4068
- return y.make(
4055
+ return b.make(
4069
4056
  (i) => this.getProgressLog(e, t, i)
4070
4057
  );
4071
- const r = N(e, n), o = k();
4058
+ const r = R(e, n), o = L();
4072
4059
  n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseProgressLog(r.id, o));
4073
- const d = this.getProgressLogNoCtx(
4060
+ const l = this.getProgressLogNoCtx(
4074
4061
  n.watcher,
4075
4062
  r,
4076
4063
  t,
@@ -4078,12 +4065,12 @@ class En {
4078
4065
  );
4079
4066
  return n.markUnstable(
4080
4067
  "The progress log is from the stream, so we consider it unstable. Final value will be got from blobs."
4081
- ), d;
4068
+ ), l;
4082
4069
  }
4083
4070
  getProgressLogNoCtx(e, t, n, r) {
4084
4071
  let o = this.idToProgressLog.get(t.id);
4085
4072
  if (o == null) {
4086
- const i = new ue(
4073
+ const i = new me(
4087
4074
  this.clientLogs,
4088
4075
  t,
4089
4076
  1,
@@ -4092,18 +4079,18 @@ class En {
4092
4079
  this.idToProgressLog.set(t.id, i), o = i;
4093
4080
  }
4094
4081
  o.attach(e, r);
4095
- const d = o.getLog();
4096
- if (d.error) throw d.error;
4097
- return d.log;
4082
+ const l = o.getLog();
4083
+ if (l.error) throw l.error;
4084
+ return l.log;
4098
4085
  }
4099
4086
  getLogHandle(e, t) {
4100
4087
  if (t == null)
4101
- return y.make((o) => this.getLogHandle(e, o));
4102
- const n = N(e, t), r = this.getLogHandleNoCtx(n);
4088
+ return b.make((o) => this.getLogHandle(e, o));
4089
+ const n = R(e, t), r = this.getLogHandleNoCtx(n);
4103
4090
  return t.markUnstable(), r;
4104
4091
  }
4105
4092
  getLogHandleNoCtx(e) {
4106
- return ve(!0, e);
4093
+ return $e(!0, e);
4107
4094
  }
4108
4095
  async lastLines(e, t, n, r) {
4109
4096
  return await this.tryWithNotFound(
@@ -4173,7 +4160,7 @@ class En {
4173
4160
  const e = this.scheduledOnNextState;
4174
4161
  this.scheduledOnNextState = [];
4175
4162
  try {
4176
- await Y(
4163
+ await te(
4177
4164
  this.opts.nConcurrentGetLogs,
4178
4165
  this.getAllNotDoneLogs().map(
4179
4166
  (t) => async () => await t.update()
@@ -4183,7 +4170,7 @@ class En {
4183
4170
  console.error(t), e.forEach((n) => n.reject(t));
4184
4171
  }
4185
4172
  if (!this.keepRunning) break;
4186
- await te.wait(this.opts.pollingInterval);
4173
+ await oe.wait(this.opts.pollingInterval);
4187
4174
  }
4188
4175
  this.currentLoop = void 0;
4189
4176
  }
@@ -4191,13 +4178,13 @@ class En {
4191
4178
  return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).filter(([e, t]) => !t.getLog().done).map(([e, t]) => t);
4192
4179
  }
4193
4180
  }
4194
- class ue {
4181
+ class me {
4195
4182
  constructor(e, t, n, r) {
4196
- c(this, "logs");
4197
- c(this, "error");
4198
- c(this, "done", !1);
4199
- c(this, "change", new S());
4200
- c(this, "counter", new D());
4183
+ d(this, "logs");
4184
+ d(this, "error");
4185
+ d(this, "done", !1);
4186
+ d(this, "change", new N());
4187
+ d(this, "counter", new v());
4201
4188
  this.clientLogs = e, this.rInfo = t, this.lines = n, this.patternToSearch = r;
4202
4189
  }
4203
4190
  getLog() {
@@ -4232,26 +4219,26 @@ class ue {
4232
4219
  }
4233
4220
  }
4234
4221
  }
4235
- class Fn {
4222
+ class xn {
4236
4223
  constructor(e, t, n, r = {
4237
4224
  cacheSoftSizeBytes: 50 * 1024 * 1024,
4238
4225
  withGunzip: !0,
4239
4226
  nConcurrentDownloads: 50
4240
4227
  }) {
4241
- c(this, "downloadHelper");
4242
- c(this, "urlToDownload", /* @__PURE__ */ new Map());
4243
- c(this, "downloadQueue");
4228
+ d(this, "downloadHelper");
4229
+ d(this, "urlToDownload", /* @__PURE__ */ new Map());
4230
+ d(this, "downloadQueue");
4244
4231
  /** Writes and removes files to a hard drive and holds a counter for every
4245
4232
  * file that should be kept. */
4246
- c(this, "cache");
4247
- this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new X(
4233
+ d(this, "cache");
4234
+ this.logger = e, this.saveDir = n, this.opts = r, this.downloadQueue = new ee(
4248
4235
  this.logger,
4249
4236
  this.opts.nConcurrentDownloads
4250
- ), this.cache = new Be(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ie(t);
4237
+ ), this.cache = new ve(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Se(t);
4251
4238
  }
4252
4239
  getPath(e, t) {
4253
- if (t === void 0) return y.make((o) => this.getPath(e, o));
4254
- const n = k();
4240
+ if (t === void 0) return b.make((o) => this.getPath(e, o));
4241
+ const n = L();
4255
4242
  t.addOnDestroy(() => this.releasePath(e, n));
4256
4243
  const r = this.getPathNoCtx(e, t.watcher, n);
4257
4244
  return (r == null ? void 0 : r.path) === void 0 && t.markUnstable(
@@ -4262,11 +4249,11 @@ class Fn {
4262
4249
  const r = e.toString(), o = this.urlToDownload.get(r);
4263
4250
  if (o != null)
4264
4251
  return o.attach(t, n), o.getPath();
4265
- const d = this.setNewTask(t, e, n);
4252
+ const l = this.setNewTask(t, e, n);
4266
4253
  return this.downloadQueue.push({
4267
- fn: async () => this.downloadUrl(d, n),
4254
+ fn: async () => this.downloadUrl(l, n),
4268
4255
  recoverableErrorPredicate: (i) => !0
4269
- }), d.getPath();
4256
+ }), l.getPath();
4270
4257
  }
4271
4258
  /** Downloads and extracts a tar archive if it wasn't downloaded yet. */
4272
4259
  async downloadUrl(e, t) {
@@ -4281,10 +4268,10 @@ class Fn {
4281
4268
  if (this.cache.existsFile(r.path)) {
4282
4269
  const o = this.cache.removeFile(r.path, t);
4283
4270
  await Promise.all(
4284
- o.map(async (d) => {
4285
- await J(d.path), this.cache.removeCache(d), this.removeTask(
4286
- d,
4287
- `the task ${JSON.stringify(d)} was removedfrom cache along with ${JSON.stringify(o)}`
4271
+ o.map(async (l) => {
4272
+ await X(l.path), this.cache.removeCache(l), this.removeTask(
4273
+ l,
4274
+ `the task ${JSON.stringify(l)} was removedfrom cache along with ${JSON.stringify(o)}`
4288
4275
  );
4289
4276
  })
4290
4277
  );
@@ -4298,7 +4285,7 @@ class Fn {
4298
4285
  async releaseAll() {
4299
4286
  this.downloadQueue.stop(), await Promise.all(
4300
4287
  Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
4301
- await J(t.path), this.cache.removeCache(t), this.removeTask(
4288
+ await X(t.path), this.cache.removeCache(t), this.removeTask(
4302
4289
  t,
4303
4290
  `the task ${t} was released when the driver was closed`
4304
4291
  );
@@ -4306,25 +4293,25 @@ class Fn {
4306
4293
  );
4307
4294
  }
4308
4295
  setNewTask(e, t, n) {
4309
- const r = new jr(this.getFilePath(t), t);
4296
+ const r = new Qr(this.getFilePath(t), t);
4310
4297
  return r.attach(e, n), this.urlToDownload.set(t.toString(), r), r;
4311
4298
  }
4312
4299
  removeTask(e, t) {
4313
4300
  e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
4314
4301
  }
4315
4302
  getFilePath(e) {
4316
- const t = Ke("sha256").update(e.toString()).digest("hex");
4317
- return m.join(this.saveDir, t);
4303
+ const t = ot("sha256").update(e.toString()).digest("hex");
4304
+ return w.join(this.saveDir, t);
4318
4305
  }
4319
4306
  }
4320
- class jr {
4307
+ class Qr {
4321
4308
  constructor(e, t) {
4322
- c(this, "counter", new D());
4323
- c(this, "change", new S());
4324
- c(this, "signalCtl", new AbortController());
4325
- c(this, "error");
4326
- c(this, "done", !1);
4327
- c(this, "sizeBytes", 0);
4309
+ d(this, "counter", new v());
4310
+ d(this, "change", new N());
4311
+ d(this, "signalCtl", new AbortController());
4312
+ d(this, "error");
4313
+ d(this, "done", !1);
4314
+ d(this, "sizeBytes", 0);
4328
4315
  this.path = e, this.url = t;
4329
4316
  }
4330
4317
  attach(e, t) {
@@ -4339,16 +4326,16 @@ class jr {
4339
4326
  );
4340
4327
  this.setDone(n);
4341
4328
  } catch (n) {
4342
- if (n instanceof pe || n instanceof re) {
4343
- this.setError(n), await J(this.path);
4329
+ if (n instanceof we || n instanceof ae) {
4330
+ this.setError(n), await X(this.path);
4344
4331
  return;
4345
4332
  }
4346
4333
  throw n;
4347
4334
  }
4348
4335
  }
4349
4336
  async downloadAndUntar(e, t, n) {
4350
- if (await qe(this.path))
4351
- return await Ee(this.path);
4337
+ if (await Xe(this.path))
4338
+ return await ze(this.path);
4352
4339
  const r = await e.downloadRemoteFile(
4353
4340
  this.url.toString(),
4354
4341
  {},
@@ -4356,76 +4343,47 @@ class jr {
4356
4343
  );
4357
4344
  let o = r.content;
4358
4345
  if (t) {
4359
- const i = Je.toWeb(et.createGunzip());
4346
+ const i = Ke.toWeb(it.createGunzip());
4360
4347
  o = o.pipeThrough(i, { signal: n });
4361
4348
  }
4362
- const d = ee.toWeb(tt.extract(this.path));
4363
- return await o.pipeTo(d, { signal: n }), r.size;
4349
+ const l = ne.toWeb(at.extract(this.path));
4350
+ return await o.pipeTo(l, { signal: n }), r.size;
4364
4351
  }
4365
4352
  getPath() {
4366
- if (this.done) return { path: O(this.path) };
4353
+ if (this.done) return { path: K(this.path) };
4367
4354
  if (this.error) return { error: this.error };
4368
4355
  }
4369
4356
  setDone(e) {
4370
4357
  this.done = !0, this.sizeBytes = e, this.change.markChanged();
4371
4358
  }
4372
4359
  abort(e) {
4373
- this.signalCtl.abort(new pe(e));
4360
+ this.signalCtl.abort(new we(e));
4374
4361
  }
4375
4362
  setError(e) {
4376
4363
  this.error = String(e), this.change.markChanged();
4377
4364
  }
4378
4365
  }
4379
- class pe extends Error {
4366
+ class we extends Error {
4380
4367
  }
4381
- async function Ee(s) {
4382
- const e = await b.readdir(s, { withFileTypes: !0 });
4368
+ async function ze(s) {
4369
+ const e = await m.readdir(s, { withFileTypes: !0 });
4383
4370
  return (await Promise.all(
4384
4371
  e.map(async (n) => {
4385
- const r = m.join(s, n.name);
4386
- return n.isDirectory() ? await Ee(r) : (await b.stat(r)).size;
4372
+ const r = w.join(s, n.name);
4373
+ return n.isDirectory() ? await ze(r) : (await m.stat(r)).size;
4387
4374
  })
4388
4375
  )).reduce((n, r) => n + r, 0);
4389
4376
  }
4390
- async function J(s) {
4391
- await b.rm(s, { recursive: !0, force: !0 });
4392
- }
4393
- function Gr(s) {
4394
- var t;
4395
- return {
4396
- parent: s.list.items.length > 0 ? (t = s.list.items[0]) == null ? void 0 : t.directory : void 0,
4397
- entries: s.list.items.map((n) => Vr(n, s))
4398
- };
4399
- }
4400
- function Vr(s, e) {
4401
- return s.isDir ? {
4402
- type: "dir",
4403
- name: s.name,
4404
- fullPath: s.fullName
4405
- } : {
4406
- type: "file",
4407
- name: s.name,
4408
- fullPath: s.fullName,
4409
- handle: qr({ item: s, ...e })
4410
- };
4411
- }
4412
- function qr(s) {
4413
- return s.remote ? Zr(s) : Fe(
4414
- s.item.fullName,
4415
- s.signer,
4416
- s.item.size,
4417
- O(s.item.lastModified).seconds
4418
- );
4377
+ async function X(s) {
4378
+ await m.rm(s, { recursive: !0, force: !0 });
4419
4379
  }
4420
- function Zr(s) {
4421
- return `index://index/${encodeURIComponent(
4422
- JSON.stringify({
4423
- storageId: s.storageName,
4424
- path: s.item.fullName
4425
- })
4426
- )}`;
4380
+ function ye(s, e) {
4381
+ return `index://index/${encodeURIComponent(JSON.stringify({
4382
+ storageId: s,
4383
+ path: e
4384
+ }))}`;
4427
4385
  }
4428
- function Fe(s, e, t, n) {
4386
+ function Xr(s, e, t, n) {
4429
4387
  const r = {
4430
4388
  localPath: s,
4431
4389
  pathSignature: e.sign(s),
@@ -4434,98 +4392,134 @@ function Fe(s, e, t, n) {
4434
4392
  };
4435
4393
  return `upload://upload/${encodeURIComponent(JSON.stringify(r))}`;
4436
4394
  }
4437
- function Jr(s, e) {
4438
- if (!(e.dirent.isFile() || e.dirent.isDirectory())) {
4439
- s.warn(
4440
- `tried to get non-dir and non-file ${e.dirent.name}, skip it`
4441
- );
4442
- return;
4443
- }
4444
- return {
4445
- directory: e.directory,
4446
- isDir: e.dirent.isDirectory(),
4447
- name: e.dirent.name,
4448
- fullName: e.fullName,
4449
- lastModified: {
4450
- seconds: BigInt(Math.floor(e.stat.mtimeMs / 1e3)),
4451
- nanos: 0
4452
- },
4453
- size: BigInt(e.stat.size)
4454
- };
4455
- }
4456
- function Qr(s, e) {
4457
- const t = Object.entries(s).map(Yr), n = Object.entries(e).map(rn);
4458
- return t.concat(n);
4395
+ function Yr(s) {
4396
+ const e = new URL(s);
4397
+ return F.parse(
4398
+ JSON.parse(decodeURIComponent(e.pathname.substring(1)))
4399
+ );
4459
4400
  }
4460
- function Xr(s) {
4461
- if (nn(s))
4462
- return sn(s);
4463
- if (Kr(s))
4464
- return tn(s);
4465
- Ze(s);
4401
+ function Kr(s) {
4402
+ const e = new URL(s);
4403
+ return Ee.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4466
4404
  }
4467
- function Yr([s, e]) {
4468
- return {
4469
- name: s,
4470
- handle: en(s, e),
4471
- initialFullPath: e
4472
- };
4405
+ function en(s) {
4406
+ if (on(s))
4407
+ return an(s);
4408
+ if (tn(s))
4409
+ return nn(s);
4410
+ Ye(s);
4473
4411
  }
4474
- const We = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4475
- function Kr(s) {
4476
- return We.test(s);
4412
+ const xe = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4413
+ function tn(s) {
4414
+ return xe.test(s);
4477
4415
  }
4478
- function en(s, e) {
4416
+ function rn(s, e) {
4479
4417
  return `local://${s}/${encodeURIComponent(e)}`;
4480
4418
  }
4481
- function tn(s) {
4482
- const e = s.match(We);
4483
- if (e == null)
4484
- throw new Error(`Local list handle wasn't parsed: ${s}`);
4419
+ function nn(s) {
4420
+ const e = s.match(xe);
4421
+ if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
4485
4422
  const { name: t, path: n } = e.groups;
4486
4423
  return {
4487
- path: decodeURIComponent(n),
4424
+ rootPath: decodeURIComponent(n),
4488
4425
  name: t,
4489
- remote: !1
4490
- };
4491
- }
4492
- function rn([s, e]) {
4493
- return {
4494
- name: s,
4495
- handle: on(s, e),
4496
- initialFullPath: ""
4426
+ isRemote: !1
4497
4427
  };
4498
4428
  }
4499
4429
  const Ae = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4500
- function nn(s) {
4430
+ function on(s) {
4501
4431
  return Ae.test(s);
4502
4432
  }
4503
- function on(s, e) {
4433
+ function sn(s, e) {
4504
4434
  return `remote://${s}/${BigInt(e)}`;
4505
4435
  }
4506
- function sn(s) {
4436
+ function an(s) {
4507
4437
  const e = s.match(Ae);
4508
- if (e == null)
4509
- throw new Error(`Remote list handle wasn't parsed: ${s}`);
4438
+ if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
4510
4439
  const { name: t, resourceId: n } = e.groups;
4511
4440
  return {
4512
- id: Q(BigInt(n)),
4513
- type: an(t),
4441
+ id: Y(BigInt(n)),
4442
+ type: ln(t),
4514
4443
  name: t,
4515
- remote: !0
4444
+ isRemote: !0
4516
4445
  };
4517
4446
  }
4518
- function an(s) {
4447
+ function ln(s) {
4519
4448
  return { name: `LS/${s}`, version: "1" };
4520
4449
  }
4521
- class Wn {
4522
- constructor(e, t, n, r, o) {
4523
- c(this, "storageIdToResourceId");
4524
- this.logger = e, this.clientLs = t, this.client = n, this.signer = r, this.localStorageToPath = o;
4450
+ function An() {
4451
+ const s = Z.homedir();
4452
+ return w.sep === "/" ? [{ name: "local", root: "/", initialPath: s }] : [
4453
+ {
4454
+ name: "local",
4455
+ root: w.parse(s).root,
4456
+ // disk where home directory resides
4457
+ initialPath: s
4458
+ }
4459
+ ];
4460
+ }
4461
+ class Me {
4462
+ constructor(e, t, n, r, o, l, i) {
4463
+ this.logger = e, this.lsClient = t, this.storageIdToResourceId = n, this.signer = r, this.virtualStoragesMap = o, this.localProjectionsMap = l, this.openFileDialogCallback = i;
4464
+ }
4465
+ async getLocalFileContent(e, t) {
4466
+ const n = await this.tryResolveLocalFileHandle(e);
4467
+ if (t) throw new Error("Range request not yet supported.");
4468
+ return await m.readFile(n);
4469
+ }
4470
+ async getLocalFileSize(e) {
4471
+ const t = await this.tryResolveLocalFileHandle(e);
4472
+ return (await m.stat(t)).size;
4473
+ }
4474
+ async showOpenMultipleFilesDialog(e) {
4475
+ const t = await this.openFileDialogCallback(!0, e);
4476
+ return t === void 0 ? {} : {
4477
+ files: await Promise.all(t.map((n) => this.getLocalFileHandle(n)))
4478
+ };
4479
+ }
4480
+ async showOpenSingleFileDialog(e) {
4481
+ const t = await this.openFileDialogCallback(!1, e);
4482
+ return t === void 0 ? {} : {
4483
+ file: await this.getLocalFileHandle(t[0])
4484
+ };
4485
+ }
4486
+ /**
4487
+ * Resolves local handle to local file path.
4488
+ *
4489
+ * @param handle handle to be resolved
4490
+ * @private
4491
+ */
4492
+ async tryResolveLocalFileHandle(e) {
4493
+ if (lt(e)) {
4494
+ const t = Kr(e), n = this.localProjectionsMap.get(t.storageId);
4495
+ if (!n)
4496
+ throw new Error(`Storage ${t.storageId} is not mounted locally.`);
4497
+ return w.join(n.localPath, t.path);
4498
+ } else {
4499
+ const t = Yr(e);
4500
+ this.signer.verify(
4501
+ t.localPath,
4502
+ t.pathSignature,
4503
+ "Failed to validate local file handle signature."
4504
+ );
4505
+ const n = t.localPath, r = await m.stat(n, { bigint: !0 });
4506
+ if (String(r.mtimeMs / 1000n) !== t.modificationTime)
4507
+ throw new Error("File has changed since the handle was created.");
4508
+ return n;
4509
+ }
4525
4510
  }
4526
4511
  async getLocalFileHandle(e) {
4527
- const t = await b.stat(e, { bigint: !0 });
4528
- return Fe(
4512
+ B(e);
4513
+ for (const n of this.localProjectionsMap.values())
4514
+ if (e.startsWith(n.localPath)) {
4515
+ const r = n.localPath === "" ? e : w.relative(n.localPath, e);
4516
+ return ye(
4517
+ n.storageId,
4518
+ r
4519
+ );
4520
+ }
4521
+ const t = await m.stat(e, { bigint: !0 });
4522
+ return Xr(
4529
4523
  e,
4530
4524
  this.signer,
4531
4525
  t.size,
@@ -4534,42 +4528,68 @@ class Wn {
4534
4528
  );
4535
4529
  }
4536
4530
  async getStorageList() {
4537
- return Qr(
4538
- this.localStorageToPath,
4539
- await this.getAvailableStorageIds()
4540
- );
4531
+ return [
4532
+ ...[...this.virtualStoragesMap.values()].map((e) => ({
4533
+ name: e.name,
4534
+ handle: rn(e.name, e.root),
4535
+ initialFullPath: e.initialPath
4536
+ })),
4537
+ ...Object.entries(this.storageIdToResourceId).map(([e, t]) => ({
4538
+ name: e,
4539
+ handle: sn(e, t),
4540
+ initialFullPath: ""
4541
+ // we don't have any additional information from where to start browsing remote storages
4542
+ }))
4543
+ ];
4541
4544
  }
4542
4545
  async listFiles(e, t) {
4543
- const n = Xr(e);
4544
- let r;
4545
- return n.remote ? r = await this.clientLs.list(n, t) : r = await this.getLocalFiles(this.logger, n.path, t), Gr({
4546
- storageName: n.name,
4547
- list: r,
4548
- signer: this.signer,
4549
- remote: n.remote
4550
- });
4551
- }
4552
- async getAvailableStorageIds() {
4553
- return this.storageIdToResourceId == null && (this.storageIdToResourceId = await ln(this.client)), this.storageIdToResourceId;
4554
- }
4555
- async getLocalFiles(e, t, n) {
4556
- const r = m.resolve(t), o = m.isAbsolute(n) ? n : m.resolve(m.join(r, n)), d = await b.opendir(o), i = [];
4557
- for await (const a of d) {
4558
- const p = m.join(o, a.name);
4559
- i.push({
4560
- directory: o,
4561
- fullName: p,
4562
- dirent: a,
4563
- stat: await b.stat(p)
4564
- });
4546
+ const n = en(e);
4547
+ if (n.isRemote)
4548
+ return {
4549
+ entries: (await this.lsClient.list(n, t)).items.map((o) => ({
4550
+ type: o.isDir ? "dir" : "file",
4551
+ name: o.name,
4552
+ fullPath: o.fullName,
4553
+ handle: ye(n.name, o.fullName)
4554
+ }))
4555
+ };
4556
+ {
4557
+ w.sep === "/" && t === "" && (t = "/");
4558
+ const r = n.rootPath === "" ? B(t) : w.join(n.rootPath, t), o = [];
4559
+ for await (const l of await m.opendir(r)) {
4560
+ if (!l.isFile() && !l.isDirectory()) continue;
4561
+ const i = w.join(r, l.name);
4562
+ o.push({
4563
+ type: l.isFile() ? "file" : "dir",
4564
+ name: l.name,
4565
+ fullPath: i,
4566
+ handle: await this.getLocalFileHandle(i)
4567
+ });
4568
+ }
4569
+ return { entries: o };
4565
4570
  }
4566
- return {
4567
- delimiter: m.sep,
4568
- items: i.map((a) => Jr(e, a)).filter((a) => a != null).map((a) => a)
4569
- };
4571
+ }
4572
+ static async init(e, t, n, r, o, l) {
4573
+ const i = Dr(t, e);
4574
+ for (const p of r) B(p.root);
4575
+ for (const p of o) p.localPath !== "" && B(p.localPath);
4576
+ const c = new Map(r.map((p) => [p.name, p])), a = new Map(o.map((p) => [p.storageId, p]));
4577
+ if ((/* @__PURE__ */ new Set([...c.keys(), ...a.keys()])).size !== c.size + a.size)
4578
+ throw new Error(
4579
+ "Intersection between local projection storage ids and virtual storages names detected."
4580
+ );
4581
+ return new Me(
4582
+ e,
4583
+ i,
4584
+ await cn(t),
4585
+ n,
4586
+ c,
4587
+ a,
4588
+ l
4589
+ );
4570
4590
  }
4571
4591
  }
4572
- async function ln(s) {
4592
+ async function cn(s) {
4573
4593
  return s.withReadTx("GetAvailableStorageIds", async (e) => {
4574
4594
  const t = await e.getResourceByName("LSProvider"), n = await e.getResourceData(t, !0);
4575
4595
  return dn(n);
@@ -4577,46 +4597,51 @@ async function ln(s) {
4577
4597
  }
4578
4598
  function dn(s) {
4579
4599
  return Object.fromEntries(
4580
- s.fields.filter((e) => e.type == "Dynamic" && Ge(e.value)).map((e) => [e.name.substring(8), e.value])
4600
+ s.fields.filter((e) => e.type == "Dynamic" && Ze(e.value)).map((e) => [e.name.substring(8), e.value])
4581
4601
  );
4582
4602
  }
4583
4603
  export {
4584
- Xt as ClientDownload,
4585
- Lr as ClientLogs,
4586
- lr as ClientLs,
4587
- xt as ClientProgress,
4588
- Rt as ClientUpload,
4589
- Dr as Download,
4590
- _n as DownloadDriver,
4591
- Fn as DownloadUrlDriver,
4592
- $n as LogsDriver,
4593
- En as LogsStreamDriver,
4594
- Bn as LongUpdater,
4595
- Wn as LsDriver,
4596
- ke as MTimeError,
4597
- Nt as NetworkError,
4598
- Pe as NoFileForUploading,
4599
- Sr as OnDemandBlobResourceSnapshot,
4600
- Pr as PL_STORAGE_TO_PATH,
4601
- Le as UnexpectedEOF,
4604
+ or as ClientDownload,
4605
+ Br as ClientLogs,
4606
+ fr as ClientLs,
4607
+ Jt as ClientProgress,
4608
+ _t as ClientUpload,
4609
+ An as DefaultVirtualLocalStorages,
4610
+ Wr as Download,
4611
+ On as DownloadDriver,
4612
+ xn as DownloadUrlDriver,
4613
+ En as ImportFileHandleData,
4614
+ Ee as ImportFileHandleIndexData,
4615
+ F as ImportFileHandleUploadData,
4616
+ Gr as IndexResourceSnapshot,
4617
+ Cn as LogsDriver,
4618
+ zn as LogsStreamDriver,
4619
+ vn as LongUpdater,
4620
+ Me as LsDriver,
4621
+ Pe as MTimeError,
4622
+ $t as NetworkError,
4623
+ Re as NoFileForUploading,
4624
+ Cr as OnDemandBlobResourceSnapshot,
4625
+ Ie as UnexpectedEOF,
4602
4626
  Ne as UnknownStorageError,
4603
- Se as Updater,
4604
- On as UploadDriver,
4605
- Ar as UploadResourceSnapshot,
4606
- Re as WrongLocalFileUrl,
4607
- In as createDownloadClient,
4608
- Nn as createLogsClient,
4609
- Un as createLsFilesClient,
4610
- Sn as createUploadBlobClient,
4611
- Rn as createUploadProgressClient,
4612
- ve as dataToHandle,
4613
- vn as getStream,
4627
+ Be as Updater,
4628
+ Wn as UploadDriver,
4629
+ jr as UploadResourceSnapshot,
4630
+ Ue as WrongLocalFileUrl,
4631
+ Nn as createDownloadClient,
4632
+ Un as createLogsClient,
4633
+ Dr as createLsFilesClient,
4634
+ Dn as createUploadBlobClient,
4635
+ Bn as createUploadProgressClient,
4636
+ $e as dataToHandle,
4637
+ $n as getStream,
4614
4638
  _ as handleToData,
4615
- Yt as headersFromProto,
4616
- xr as importToUploadOpts,
4639
+ sr as headersFromProto,
4617
4640
  C as isLiveLogHandle,
4618
- Rr as isReadyLogHandle,
4619
- Nr as lineToProgress,
4620
- Dn as mixcrProgressFromLogs
4641
+ _r as isReadyLogHandle,
4642
+ $r as lineToProgress,
4643
+ Vr as makeBlobImportSnapshot,
4644
+ _n as mixcrProgressFromLogs,
4645
+ B as validateAbsolute
4621
4646
  };
4622
4647
  //# sourceMappingURL=index.mjs.map