@milaboratories/pl-drivers 1.5.51 → 1.5.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,35 +1,35 @@
1
- var st = Object.defineProperty;
2
- var it = (s, e, t) => e in s ? st(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var d = (s, e, t) => it(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { addRTypeToMetadata as P, bigintToResourceId as he, stringifyWithResourceId as y, resourceIdToString as at, isNotNullResourceId as lt } from "@milaboratories/pl-client";
1
+ var it = Object.defineProperty;
2
+ var at = (s, e, t) => e in s ? it(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var d = (s, e, t) => at(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { addRTypeToMetadata as P, bigintToResourceId as ue, stringifyWithResourceId as y, resourceIdToString as lt, isNotNullResourceId as ct } from "@milaboratories/pl-client";
5
5
  import * as m from "node:fs/promises";
6
- import { request as Ne } from "undici";
6
+ import { request as $e } from "undici";
7
7
  import { ServiceType as _, stackIntercept as T } from "@protobuf-ts/runtime-rpc";
8
- import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as D, typeofJsonValue as Be, assertNever as ct } from "@protobuf-ts/runtime";
9
- import { notEmpty as H, CallersCounter as v, ensureDirExists as ue, fileExists as pe, createPathAtomically as ge, mapGet as Pe, mapEntries as dt, TaskProcessor as j, asyncPool as fe, assertNever as ht } from "@milaboratories/ts-helpers";
10
- import * as me from "node:fs";
11
- import ie from "node:fs";
8
+ import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as D, typeofJsonValue as Be, assertNever as dt } from "@protobuf-ts/runtime";
9
+ import { notEmpty as H, CallersCounter as v, ensureDirExists as pe, fileExists as ge, createPathAtomically as fe, mapGet as Ue, mapEntries as ht, TaskProcessor as j, asyncPool as me, assertNever as ut } from "@milaboratories/ts-helpers";
10
+ import * as we from "node:fs";
11
+ import ae from "node:fs";
12
12
  import * as b from "node:path";
13
13
  import L from "node:path";
14
- import { Readable as we, Writable as S, Transform as $e } from "node:stream";
15
- import { text as ut, buffer as Ce } from "node:stream/consumers";
16
- import { ChangeSource as N, Computable as w, PollingComputableHooks as _e } from "@milaboratories/computable";
17
- import { rsSchema as G, treeEntryToResourceInfo as R, isPlTreeEntry as E, makeResourceSnapshot as x, isPlTreeEntryAccessor as Ee } from "@milaboratories/pl-tree";
18
- import pt from "denque";
19
- import { randomUUID as U, createHash as gt } from "node:crypto";
20
- import * as Ue from "node:os";
21
- import ft from "node:os";
22
- import * as mt from "node:readline/promises";
14
+ import { Readable as ye, Writable as S, Transform as Ce } from "node:stream";
15
+ import { text as pt, buffer as _e } from "node:stream/consumers";
16
+ import { ChangeSource as N, Computable as w, PollingComputableHooks as Ee } from "@milaboratories/computable";
17
+ import { rsSchema as G, treeEntryToResourceInfo as R, isPlTreeEntry as E, makeResourceSnapshot as x, isPlTreeEntryAccessor as Oe } from "@milaboratories/pl-tree";
18
+ import gt from "denque";
19
+ import { randomUUID as U, createHash as ft } from "node:crypto";
20
+ import * as De from "node:os";
21
+ import mt from "node:os";
22
+ import * as wt from "node:readline/promises";
23
23
  import { z as k } from "zod";
24
- import * as Oe from "node:zlib";
25
- import * as ae from "tar-fs";
26
- import wt from "decompress";
27
- import { scheduler as Fe } from "node:timers/promises";
28
- import yt from "node:assert";
29
- import { isImportFileHandleIndex as bt } from "@milaboratories/pl-model-common";
30
- import Tt from "node:util";
31
- import { exec as kt } from "node:child_process";
32
- class Lt extends g {
24
+ import * as Fe from "node:zlib";
25
+ import * as le from "tar-fs";
26
+ import yt from "decompress";
27
+ import { scheduler as We } from "node:timers/promises";
28
+ import bt from "node:assert";
29
+ import { isImportFileHandleIndex as Tt } from "@milaboratories/pl-model-common";
30
+ import kt from "node:util";
31
+ import { exec as Lt } from "node:child_process";
32
+ class Pt extends g {
33
33
  constructor() {
34
34
  super("MiLaboratories.Controller.Shared.uploadapi", []);
35
35
  }
@@ -49,8 +49,8 @@ class Lt extends g {
49
49
  ), t;
50
50
  }
51
51
  }
52
- new Lt();
53
- class Pt extends g {
52
+ new Pt();
53
+ class Ut extends g {
54
54
  constructor() {
55
55
  super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
56
56
  }
@@ -70,8 +70,8 @@ class Pt extends g {
70
70
  ), t;
71
71
  }
72
72
  }
73
- new Pt();
74
- class Ut extends g {
73
+ new Ut();
74
+ class Dt extends g {
75
75
  constructor() {
76
76
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
77
77
  {
@@ -125,8 +125,8 @@ class Ut extends g {
125
125
  ), t;
126
126
  }
127
127
  }
128
- const Dt = new Ut();
129
- class Rt extends g {
128
+ const Rt = new Dt();
129
+ class St extends g {
130
130
  constructor() {
131
131
  super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
132
132
  {
@@ -201,8 +201,8 @@ class Rt extends g {
201
201
  ), t;
202
202
  }
203
203
  }
204
- const St = new Rt();
205
- class It extends g {
204
+ const It = new St();
205
+ class vt extends g {
206
206
  constructor() {
207
207
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
208
208
  }
@@ -222,8 +222,8 @@ class It extends g {
222
222
  ), t;
223
223
  }
224
224
  }
225
- new It();
226
- class vt extends g {
225
+ new vt();
226
+ class Nt extends g {
227
227
  constructor() {
228
228
  super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
229
229
  {
@@ -293,7 +293,7 @@ class vt extends g {
293
293
  ), t;
294
294
  }
295
295
  }
296
- const Nt = new vt();
296
+ const $t = new Nt();
297
297
  class Bt extends g {
298
298
  constructor() {
299
299
  super(
@@ -321,8 +321,8 @@ class Bt extends g {
321
321
  ), t;
322
322
  }
323
323
  }
324
- const $t = new Bt();
325
- class Ct extends g {
324
+ const Ct = new Bt();
325
+ class _t extends g {
326
326
  constructor() {
327
327
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
328
328
  }
@@ -342,8 +342,8 @@ class Ct extends g {
342
342
  ), t;
343
343
  }
344
344
  }
345
- new Ct();
346
- class _t extends g {
345
+ new _t();
346
+ class Et extends g {
347
347
  constructor() {
348
348
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
349
349
  {
@@ -425,8 +425,8 @@ class _t extends g {
425
425
  ), t;
426
426
  }
427
427
  }
428
- const Et = new _t();
429
- class Ot extends g {
428
+ const Ot = new Et();
429
+ class Ft extends g {
430
430
  constructor() {
431
431
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
432
432
  {
@@ -496,8 +496,8 @@ class Ot extends g {
496
496
  ), t;
497
497
  }
498
498
  }
499
- const Z = new Ot();
500
- class Ft extends g {
499
+ const Z = new Ft();
500
+ class Wt extends g {
501
501
  constructor() {
502
502
  super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
503
503
  {
@@ -613,8 +613,8 @@ class Ft extends g {
613
613
  ), t;
614
614
  }
615
615
  }
616
- const Wt = new Ft();
617
- class zt extends g {
616
+ const zt = new Wt();
617
+ class xt extends g {
618
618
  constructor() {
619
619
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
620
620
  }
@@ -634,8 +634,8 @@ class zt extends g {
634
634
  ), t;
635
635
  }
636
636
  }
637
- new zt();
638
- class xt extends g {
637
+ new xt();
638
+ class At extends g {
639
639
  constructor() {
640
640
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
641
641
  {
@@ -689,8 +689,8 @@ class xt extends g {
689
689
  ), t;
690
690
  }
691
691
  }
692
- const At = new xt();
693
- class Mt extends g {
692
+ const Mt = new At();
693
+ class Ht extends g {
694
694
  constructor() {
695
695
  super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
696
696
  }
@@ -710,36 +710,36 @@ class Mt extends g {
710
710
  ), t;
711
711
  }
712
712
  }
713
- const Ht = new Mt(), Q = new _(
713
+ const jt = new Ht(), Q = new _(
714
714
  "MiLaboratories.Controller.Shared.Upload",
715
715
  [
716
716
  {
717
717
  name: "Init",
718
718
  options: {},
719
- I: Dt,
720
- O: St
719
+ I: Rt,
720
+ O: It
721
721
  },
722
722
  {
723
723
  name: "GetPartURL",
724
724
  options: {},
725
- I: Et,
726
- O: Wt
725
+ I: Ot,
726
+ O: zt
727
727
  },
728
728
  {
729
729
  name: "UpdateProgress",
730
730
  options: {},
731
- I: Nt,
732
- O: $t
731
+ I: $t,
732
+ O: Ct
733
733
  },
734
734
  {
735
735
  name: "Finalize",
736
736
  options: {},
737
- I: At,
738
- O: Ht
737
+ I: Mt,
738
+ O: jt
739
739
  }
740
740
  ]
741
741
  );
742
- class jt {
742
+ class Gt {
743
743
  constructor(e) {
744
744
  d(this, "typeName", Q.typeName);
745
745
  d(this, "methods", Q.methods);
@@ -800,10 +800,9 @@ class jt {
800
800
  return T("unary", this._transport, o, n, e);
801
801
  }
802
802
  }
803
- function We(s) {
804
- return Object.fromEntries(s.map(({ name: e, value: t }) => [e, t]));
805
- }
806
- class ze extends Error {
803
+ function ze(s, e, t) {
804
+ const o = Object.fromEntries(s.map(({ name: n, value: r }) => [n, r]));
805
+ return e !== void 0 && t !== void 0 && (o.Range = `bytes=${e}-${t}`), o;
807
806
  }
808
807
  class xe extends Error {
809
808
  }
@@ -811,10 +810,12 @@ class Ae extends Error {
811
810
  }
812
811
  class Me extends Error {
813
812
  }
814
- class Gt {
813
+ class He extends Error {
814
+ }
815
+ class Vt {
815
816
  constructor(e, t, o, n) {
816
817
  d(this, "grpcClient");
817
- this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new jt(this.grpcTransport);
818
+ this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Gt(this.grpcTransport);
818
819
  }
819
820
  close() {
820
821
  }
@@ -832,14 +833,14 @@ class Gt {
832
833
  0n,
833
834
  // we update progress as a separate call later.
834
835
  a
835
- ), c = await Vt(o, i.chunkStart, i.chunkEnd);
836
- await Jt(o, n);
836
+ ), c = await qt(o, i.chunkStart, i.chunkEnd);
837
+ await Zt(o, n);
837
838
  try {
838
839
  const {
839
840
  body: l,
840
841
  statusCode: p,
841
842
  headers: J
842
- } = await Ne(i.uploadUrl, {
843
+ } = await $e(i.uploadUrl, {
843
844
  dispatcher: this.httpClient,
844
845
  body: c,
845
846
  // We got headers only after we send
@@ -848,12 +849,12 @@ class Gt {
848
849
  // that's why we got big timeout here.
849
850
  headersTimeout: 6e4,
850
851
  bodyTimeout: 6e4,
851
- headers: We(i.headers),
852
+ headers: ze(i.headers),
852
853
  method: i.method.toUpperCase()
853
- }), rt = await l.text();
854
- Zt(p, rt, J, i);
854
+ }), st = await l.text();
855
+ Qt(p, st, J, i);
855
856
  } catch (l) {
856
- throw l instanceof Ae ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
857
+ throw l instanceof Me ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
857
858
  }
858
859
  await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), a);
859
860
  }
@@ -890,19 +891,19 @@ class Gt {
890
891
  return await this.grpcClient.finalize({ resourceId: e }, P(t, o)).response;
891
892
  }
892
893
  }
893
- async function Vt(s, e, t) {
894
+ async function qt(s, e, t) {
894
895
  let o;
895
896
  try {
896
897
  o = await m.open(s);
897
- const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await qt(o, a, n, r);
898
+ const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await Jt(o, a, n, r);
898
899
  return a.subarray(0, i);
899
900
  } catch (n) {
900
- throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new Me(`there is no file ${s} for uploading`) : n;
901
+ throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new He(`there is no file ${s} for uploading`) : n;
901
902
  } finally {
902
903
  await (o == null ? void 0 : o.close());
903
904
  }
904
905
  }
905
- async function qt(s, e, t, o) {
906
+ async function Jt(s, e, t, o) {
906
907
  let n = 0;
907
908
  for (; n < t; ) {
908
909
  const { bytesRead: r } = await s.read(
@@ -912,23 +913,23 @@ async function qt(s, e, t, o) {
912
913
  o + n
913
914
  );
914
915
  if (r === 0)
915
- throw new xe("file ended earlier than expected.");
916
+ throw new Ae("file ended earlier than expected.");
916
917
  n += r;
917
918
  }
918
919
  return n;
919
920
  }
920
- async function Jt(s, e) {
921
+ async function Zt(s, e) {
921
922
  const t = BigInt(Math.floor((await m.stat(s)).mtimeMs / 1e3));
922
923
  if (t > e)
923
- throw new ze(`file was modified, expected mtime: ${e}, got: ${t}.`);
924
+ throw new xe(`file was modified, expected mtime: ${e}, got: ${t}.`);
924
925
  }
925
- function Zt(s, e, t, o) {
926
+ function Qt(s, e, t, o) {
926
927
  if (s != 200)
927
- throw new Ae(
928
+ throw new Me(
928
929
  `response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${o.uploadUrl}`
929
930
  );
930
931
  }
931
- class Qt extends g {
932
+ class Xt extends g {
932
933
  constructor() {
933
934
  super("google.protobuf.Duration", [
934
935
  {
@@ -1032,8 +1033,8 @@ class Qt extends g {
1032
1033
  ), t;
1033
1034
  }
1034
1035
  }
1035
- const z = new Qt();
1036
- class Xt extends g {
1036
+ const z = new Xt();
1037
+ class Kt extends g {
1037
1038
  constructor() {
1038
1039
  super("MiLaboratories.Controller.Shared.ProgressAPI", []);
1039
1040
  }
@@ -1053,8 +1054,8 @@ class Xt extends g {
1053
1054
  ), t;
1054
1055
  }
1055
1056
  }
1056
- new Xt();
1057
- class Kt extends g {
1057
+ new Kt();
1058
+ class Yt extends g {
1058
1059
  constructor() {
1059
1060
  super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
1060
1061
  {
@@ -1153,8 +1154,8 @@ class Kt extends g {
1153
1154
  ), t;
1154
1155
  }
1155
1156
  }
1156
- const I = new Kt();
1157
- class Yt extends g {
1157
+ const I = new Yt();
1158
+ class eo extends g {
1158
1159
  constructor() {
1159
1160
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
1160
1161
  }
@@ -1174,8 +1175,8 @@ class Yt extends g {
1174
1175
  ), t;
1175
1176
  }
1176
1177
  }
1177
- new Yt();
1178
- class eo extends g {
1178
+ new eo();
1179
+ class to extends g {
1179
1180
  constructor() {
1180
1181
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
1181
1182
  {
@@ -1233,8 +1234,8 @@ class eo extends g {
1233
1234
  ), t;
1234
1235
  }
1235
1236
  }
1236
- const to = new eo();
1237
- class oo extends g {
1237
+ const oo = new to();
1238
+ class no extends g {
1238
1239
  constructor() {
1239
1240
  super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
1240
1241
  { no: 1, name: "report", kind: "message", T: () => I }
@@ -1294,8 +1295,8 @@ class oo extends g {
1294
1295
  ), t;
1295
1296
  }
1296
1297
  }
1297
- const no = new oo();
1298
- class ro extends g {
1298
+ const ro = new no();
1299
+ class so extends g {
1299
1300
  constructor() {
1300
1301
  super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
1301
1302
  }
@@ -1315,8 +1316,8 @@ class ro extends g {
1315
1316
  ), t;
1316
1317
  }
1317
1318
  }
1318
- new ro();
1319
- class so extends g {
1319
+ new so();
1320
+ class io extends g {
1320
1321
  constructor() {
1321
1322
  super(
1322
1323
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
@@ -1391,8 +1392,8 @@ class so extends g {
1391
1392
  ), t;
1392
1393
  }
1393
1394
  }
1394
- const io = new so();
1395
- class ao extends g {
1395
+ const ao = new io();
1396
+ class lo extends g {
1396
1397
  constructor() {
1397
1398
  super(
1398
1399
  "MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
@@ -1453,7 +1454,7 @@ class ao extends g {
1453
1454
  ), t;
1454
1455
  }
1455
1456
  }
1456
- const lo = new ao(), X = new _(
1457
+ const co = new lo(), X = new _(
1457
1458
  "MiLaboratories.Controller.Shared.Progress",
1458
1459
  [
1459
1460
  {
@@ -1461,19 +1462,19 @@ const lo = new ao(), X = new _(
1461
1462
  options: {
1462
1463
  "google.api.http": { get: "/resources/{resource_id}/get-progress" }
1463
1464
  },
1464
- I: to,
1465
- O: no
1465
+ I: oo,
1466
+ O: ro
1466
1467
  },
1467
1468
  {
1468
1469
  name: "RealtimeStatus",
1469
1470
  serverStreaming: !0,
1470
1471
  options: {},
1471
- I: io,
1472
- O: lo
1472
+ I: ao,
1473
+ O: co
1473
1474
  }
1474
1475
  ]
1475
1476
  );
1476
- class co {
1477
+ class ho {
1477
1478
  constructor(e) {
1478
1479
  d(this, "typeName", X.typeName);
1479
1480
  d(this, "methods", X.methods);
@@ -1495,10 +1496,10 @@ class co {
1495
1496
  return T("serverStreaming", this._transport, o, n, e);
1496
1497
  }
1497
1498
  }
1498
- class ho {
1499
+ class uo {
1499
1500
  constructor(e, t, o, n) {
1500
1501
  d(this, "grpcClient");
1501
- this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new co(this.grpcTransport);
1502
+ this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new ho(this.grpcTransport);
1502
1503
  }
1503
1504
  close() {
1504
1505
  }
@@ -1539,25 +1540,25 @@ class ho {
1539
1540
  }
1540
1541
  class V extends Error {
1541
1542
  }
1542
- class He {
1543
+ class je {
1543
1544
  constructor(e) {
1544
1545
  this.httpClient = e;
1545
1546
  }
1546
1547
  async download(e, t, o) {
1547
- const { statusCode: n, body: r, headers: a } = await Ne(e, {
1548
+ const { statusCode: n, body: r, headers: a } = await $e(e, {
1548
1549
  dispatcher: this.httpClient,
1549
1550
  headers: t,
1550
1551
  signal: o
1551
- }), i = we.toWeb(r);
1552
- return await uo(n, i, e), {
1552
+ }), i = ye.toWeb(r);
1553
+ return await po(n, i, e), {
1553
1554
  content: i,
1554
1555
  size: Number(a["content-length"])
1555
1556
  };
1556
1557
  }
1557
1558
  }
1558
- async function uo(s, e, t) {
1559
- if (s != 200) {
1560
- const o = (await ut(e)).substring(0, 1e3);
1559
+ async function po(s, e, t) {
1560
+ if (s != 200 && s != 206) {
1561
+ const o = (await pt(e)).substring(0, 1e3);
1561
1562
  throw 400 <= s && s < 500 ? new V(
1562
1563
  `Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${o}`
1563
1564
  ) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
@@ -1567,7 +1568,7 @@ function C(s) {
1567
1568
  if (!L.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
1568
1569
  return s;
1569
1570
  }
1570
- class po extends g {
1571
+ class go extends g {
1571
1572
  constructor() {
1572
1573
  super("MiLaboratories.Controller.Shared.DownloadAPI", []);
1573
1574
  }
@@ -1587,8 +1588,8 @@ class po extends g {
1587
1588
  ), t;
1588
1589
  }
1589
1590
  }
1590
- new po();
1591
- class go extends g {
1591
+ new go();
1592
+ class fo extends g {
1592
1593
  constructor() {
1593
1594
  super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
1594
1595
  }
@@ -1608,8 +1609,8 @@ class go extends g {
1608
1609
  ), t;
1609
1610
  }
1610
1611
  }
1611
- new go();
1612
- class fo extends g {
1612
+ new fo();
1613
+ class mo extends g {
1613
1614
  constructor() {
1614
1615
  super(
1615
1616
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
@@ -1670,8 +1671,8 @@ class fo extends g {
1670
1671
  ), t;
1671
1672
  }
1672
1673
  }
1673
- const mo = new fo();
1674
- class wo extends g {
1674
+ const wo = new mo();
1675
+ class yo extends g {
1675
1676
  constructor() {
1676
1677
  super(
1677
1678
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
@@ -1744,8 +1745,8 @@ class wo extends g {
1744
1745
  ), t;
1745
1746
  }
1746
1747
  }
1747
- const K = new wo();
1748
- class yo extends g {
1748
+ const K = new yo();
1749
+ class bo extends g {
1749
1750
  constructor() {
1750
1751
  super(
1751
1752
  "MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
@@ -1828,7 +1829,7 @@ class yo extends g {
1828
1829
  ), t;
1829
1830
  }
1830
1831
  }
1831
- const bo = new yo(), Y = new _(
1832
+ const To = new bo(), Y = new _(
1832
1833
  "MiLaboratories.Controller.Shared.Download",
1833
1834
  [
1834
1835
  {
@@ -1836,12 +1837,12 @@ const bo = new yo(), Y = new _(
1836
1837
  options: {
1837
1838
  "google.api.http": { get: "/resources/{resource_id}/get-download-url" }
1838
1839
  },
1839
- I: mo,
1840
- O: bo
1840
+ I: wo,
1841
+ O: To
1841
1842
  }
1842
1843
  ]
1843
1844
  );
1844
- class To {
1845
+ class ko {
1845
1846
  constructor(e) {
1846
1847
  d(this, "typeName", Y.typeName);
1847
1848
  d(this, "methods", Y.methods);
@@ -1856,25 +1857,27 @@ class To {
1856
1857
  return T("unary", this._transport, o, n, e);
1857
1858
  }
1858
1859
  }
1859
- class ko {
1860
+ class Lo {
1860
1861
  constructor(e, t, o, n) {
1861
1862
  d(this, "grpcClient");
1862
1863
  d(this, "remoteFileDownloader");
1863
1864
  /** Helps to find a storage root directory by a storage id from URL scheme. */
1864
1865
  d(this, "localStorageIdsToRoot");
1865
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new To(this.grpcTransport), this.remoteFileDownloader = new He(t), this.localStorageIdsToRoot = Ro(n);
1866
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new ko(this.grpcTransport), this.remoteFileDownloader = new je(t), this.localStorageIdsToRoot = So(n);
1866
1867
  }
1867
1868
  close() {
1868
1869
  }
1869
- async downloadBlob(e, t, o) {
1870
- const { downloadUrl: n, headers: r } = await this.grpcGetDownloadUrl(e, t, o);
1871
- return this.logger.info(`download blob from url ${n}`), Do(n) ? await this.readLocalFile(n) : await this.remoteFileDownloader.download(n, We(r), o);
1870
+ /** Gets a presign URL and downloads the file.
1871
+ * An optional range with 2 numbers from what byte and to what byte to download can be provided. */
1872
+ async downloadBlob(e, t, o, n, r) {
1873
+ const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, o), c = ze(i, n, r);
1874
+ return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`), Ro(a) ? await this.readLocalFile(a, n, r) : await this.remoteFileDownloader.download(a, c, o);
1872
1875
  }
1873
- async readLocalFile(e) {
1874
- const { storageId: t, relativePath: o } = Lo(e), n = Po(t, this.localStorageIdsToRoot, o);
1876
+ async readLocalFile(e, t, o) {
1877
+ const { storageId: n, relativePath: r } = Po(e), a = Uo(n, this.localStorageIdsToRoot, r);
1875
1878
  return {
1876
- content: we.toWeb(me.createReadStream(n)),
1877
- size: (await m.stat(n)).size
1879
+ content: ye.toWeb(we.createReadStream(a, { start: t, end: o })),
1880
+ size: (await m.stat(a)).size
1878
1881
  };
1879
1882
  }
1880
1883
  async grpcGetDownloadUrl({ id: e, type: t }, o, n) {
@@ -1885,35 +1888,35 @@ class ko {
1885
1888
  ).response;
1886
1889
  }
1887
1890
  }
1888
- function Lo(s) {
1891
+ function Po(s) {
1889
1892
  const e = new URL(s);
1890
1893
  if (e.pathname == "")
1891
- throw new ye(`url for local filepath ${s} does not match url scheme`);
1894
+ throw new be(`url for local filepath ${s} does not match url scheme`);
1892
1895
  return {
1893
1896
  storageId: e.host,
1894
1897
  relativePath: decodeURIComponent(e.pathname.slice(1))
1895
1898
  };
1896
1899
  }
1897
- function Po(s, e, t) {
1900
+ function Uo(s, e, t) {
1898
1901
  const o = e.get(s);
1899
- if (o === void 0) throw new be(`Unknown storage location: ${s}`);
1902
+ if (o === void 0) throw new Te(`Unknown storage location: ${s}`);
1900
1903
  return o === "" ? t : b.join(o, t);
1901
1904
  }
1902
- const Uo = "storage://";
1903
- function Do(s) {
1904
- return s.startsWith(Uo);
1905
- }
1906
- class ye extends Error {
1905
+ const Do = "storage://";
1906
+ function Ro(s) {
1907
+ return s.startsWith(Do);
1907
1908
  }
1908
1909
  class be extends Error {
1909
1910
  }
1910
- function Ro(s) {
1911
+ class Te extends Error {
1912
+ }
1913
+ function So(s) {
1911
1914
  const e = /* @__PURE__ */ new Map();
1912
1915
  for (const t of s)
1913
1916
  t.localPath !== "" && C(t.localPath), e.set(t.storageId, t.localPath);
1914
1917
  return e;
1915
1918
  }
1916
- class So extends g {
1919
+ class Io extends g {
1917
1920
  constructor() {
1918
1921
  super("google.protobuf.Timestamp", [
1919
1922
  {
@@ -2046,8 +2049,8 @@ class So extends g {
2046
2049
  ), t;
2047
2050
  }
2048
2051
  }
2049
- const ee = new So();
2050
- class Io extends g {
2052
+ const ee = new Io();
2053
+ class vo extends g {
2051
2054
  constructor() {
2052
2055
  super("MiLaboratories.Controller.Shared.LsAPI", []);
2053
2056
  }
@@ -2067,8 +2070,8 @@ class Io extends g {
2067
2070
  ), t;
2068
2071
  }
2069
2072
  }
2070
- new Io();
2071
- class vo extends g {
2073
+ new vo();
2074
+ class No extends g {
2072
2075
  constructor() {
2073
2076
  super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
2074
2077
  {
@@ -2191,8 +2194,8 @@ class vo extends g {
2191
2194
  ), t;
2192
2195
  }
2193
2196
  }
2194
- const te = new vo();
2195
- class No extends g {
2197
+ const te = new No();
2198
+ class $o extends g {
2196
2199
  constructor() {
2197
2200
  super("MiLaboratories.Controller.Shared.LsAPI.List", []);
2198
2201
  }
@@ -2212,7 +2215,7 @@ class No extends g {
2212
2215
  ), t;
2213
2216
  }
2214
2217
  }
2215
- new No();
2218
+ new $o();
2216
2219
  class Bo extends g {
2217
2220
  constructor() {
2218
2221
  super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
@@ -2278,8 +2281,8 @@ class Bo extends g {
2278
2281
  ), t;
2279
2282
  }
2280
2283
  }
2281
- const $o = new Bo();
2282
- class Co extends g {
2284
+ const Co = new Bo();
2285
+ class _o extends g {
2283
2286
  constructor() {
2284
2287
  super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
2285
2288
  {
@@ -2351,10 +2354,10 @@ class Co extends g {
2351
2354
  ), t;
2352
2355
  }
2353
2356
  }
2354
- const _o = new Co(), oe = new _("MiLaboratories.Controller.Shared.LS", [
2355
- { name: "List", options: {}, I: $o, O: _o }
2357
+ const Eo = new _o(), oe = new _("MiLaboratories.Controller.Shared.LS", [
2358
+ { name: "List", options: {}, I: Co, O: Eo }
2356
2359
  ]);
2357
- class Eo {
2360
+ class Oo {
2358
2361
  constructor(e) {
2359
2362
  d(this, "typeName", oe.typeName);
2360
2363
  d(this, "methods", oe.methods);
@@ -2375,10 +2378,10 @@ class Eo {
2375
2378
  );
2376
2379
  }
2377
2380
  }
2378
- class Oo {
2381
+ class Fo {
2379
2382
  constructor(e, t) {
2380
2383
  d(this, "grpcClient");
2381
- this.logger = t, this.grpcClient = new Eo(e);
2384
+ this.logger = t, this.grpcClient = new Oo(e);
2382
2385
  }
2383
2386
  close() {
2384
2387
  }
@@ -2392,7 +2395,7 @@ class Oo {
2392
2395
  ).response;
2393
2396
  }
2394
2397
  }
2395
- class Fo extends g {
2398
+ class Wo extends g {
2396
2399
  constructor() {
2397
2400
  super("MiLaboratories.Controller.Shared.StreamingAPI", []);
2398
2401
  }
@@ -2412,8 +2415,8 @@ class Fo extends g {
2412
2415
  ), t;
2413
2416
  }
2414
2417
  }
2415
- new Fo();
2416
- class Wo extends g {
2418
+ new Wo();
2419
+ class zo extends g {
2417
2420
  constructor() {
2418
2421
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
2419
2422
  {
@@ -2504,8 +2507,8 @@ class Wo extends g {
2504
2507
  ), t;
2505
2508
  }
2506
2509
  }
2507
- const zo = new Wo();
2508
- class xo extends g {
2510
+ const xo = new zo();
2511
+ class Ao extends g {
2509
2512
  constructor() {
2510
2513
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
2511
2514
  {
@@ -2583,8 +2586,8 @@ class xo extends g {
2583
2586
  ), t;
2584
2587
  }
2585
2588
  }
2586
- const Ao = new xo();
2587
- class Mo extends g {
2589
+ const Mo = new Ao();
2590
+ class Ho extends g {
2588
2591
  constructor() {
2589
2592
  super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
2590
2593
  {
@@ -2687,8 +2690,8 @@ class Mo extends g {
2687
2690
  ), t;
2688
2691
  }
2689
2692
  }
2690
- const Ho = new Mo();
2691
- class jo extends g {
2693
+ const jo = new Ho();
2694
+ class Go extends g {
2692
2695
  constructor() {
2693
2696
  super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
2694
2697
  {
@@ -2791,8 +2794,8 @@ class jo extends g {
2791
2794
  ), t;
2792
2795
  }
2793
2796
  }
2794
- const Go = new jo();
2795
- class Vo extends g {
2797
+ const Vo = new Go();
2798
+ class qo extends g {
2796
2799
  constructor() {
2797
2800
  super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
2798
2801
  {
@@ -2895,8 +2898,8 @@ class Vo extends g {
2895
2898
  ), t;
2896
2899
  }
2897
2900
  }
2898
- const qo = new Vo();
2899
- class Jo extends g {
2901
+ const Jo = new qo();
2902
+ class Zo extends g {
2900
2903
  constructor() {
2901
2904
  super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
2902
2905
  {
@@ -2973,44 +2976,44 @@ class Jo extends g {
2973
2976
  ), t;
2974
2977
  }
2975
2978
  }
2976
- const B = new Jo(), ne = new _(
2979
+ const $ = new Zo(), ne = new _(
2977
2980
  "MiLaboratories.Controller.Shared.Streaming",
2978
2981
  [
2979
2982
  {
2980
2983
  name: "StreamBinary",
2981
2984
  serverStreaming: !0,
2982
2985
  options: {},
2983
- I: zo,
2984
- O: B
2986
+ I: xo,
2987
+ O: $
2985
2988
  },
2986
2989
  {
2987
2990
  name: "ReadBinary",
2988
2991
  options: {},
2989
- I: Ao,
2990
- O: B
2992
+ I: Mo,
2993
+ O: $
2991
2994
  },
2992
2995
  {
2993
2996
  name: "StreamText",
2994
2997
  serverStreaming: !0,
2995
2998
  options: {},
2996
- I: Ho,
2997
- O: B
2999
+ I: jo,
3000
+ O: $
2998
3001
  },
2999
3002
  {
3000
3003
  name: "ReadText",
3001
3004
  options: {},
3002
- I: Go,
3003
- O: B
3005
+ I: Vo,
3006
+ O: $
3004
3007
  },
3005
3008
  {
3006
3009
  name: "LastLines",
3007
3010
  options: {},
3008
- I: qo,
3009
- O: B
3011
+ I: Jo,
3012
+ O: $
3010
3013
  }
3011
3014
  ]
3012
3015
  );
3013
- class Zo {
3016
+ class Qo {
3014
3017
  constructor(e) {
3015
3018
  d(this, "typeName", ne.typeName);
3016
3019
  d(this, "methods", ne.methods);
@@ -3109,10 +3112,10 @@ class Zo {
3109
3112
  );
3110
3113
  }
3111
3114
  }
3112
- class Qo {
3115
+ class Xo {
3113
3116
  constructor(e, t, o) {
3114
3117
  d(this, "grpcClient");
3115
- this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Zo(this.grpcTransport);
3118
+ this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Qo(this.grpcTransport);
3116
3119
  }
3117
3120
  close() {
3118
3121
  }
@@ -3148,34 +3151,34 @@ class Qo {
3148
3151
  function Tr(s, e, t) {
3149
3152
  return e.getDriver({
3150
3153
  name: "DownloadBlob",
3151
- init: (o, n, r) => new ko(n, r, s, t)
3154
+ init: (o, n, r) => new Lo(n, r, s, t)
3152
3155
  });
3153
3156
  }
3154
3157
  function kr(s, e) {
3155
3158
  return s.getDriver({
3156
3159
  name: "StreamLogs",
3157
- init: (t, o, n) => new Qo(o, n, e)
3160
+ init: (t, o, n) => new Xo(o, n, e)
3158
3161
  });
3159
3162
  }
3160
3163
  function Lr(s, e) {
3161
3164
  return s.getDriver({
3162
3165
  name: "UploadProgress",
3163
- init: (t, o, n) => new ho(o, n, s, e)
3166
+ init: (t, o, n) => new uo(o, n, s, e)
3164
3167
  });
3165
3168
  }
3166
3169
  function Pr(s, e) {
3167
3170
  return s.getDriver({
3168
3171
  name: "UploadBlob",
3169
- init: (t, o, n) => new Gt(o, n, s, e)
3172
+ init: (t, o, n) => new Vt(o, n, s, e)
3170
3173
  });
3171
3174
  }
3172
- function Xo(s, e) {
3175
+ function Ko(s, e) {
3173
3176
  return s.getDriver({
3174
3177
  name: "LsFiles",
3175
- init: (t, o, n) => new Oo(o, e)
3178
+ init: (t, o, n) => new Fo(o, e)
3176
3179
  });
3177
3180
  }
3178
- class Ko {
3181
+ class Yo {
3179
3182
  constructor(e, t, o, n, r) {
3180
3183
  d(this, "counter", new v());
3181
3184
  d(this, "change", new N());
@@ -3204,20 +3207,20 @@ class Ko {
3204
3207
  const e = await this.ensureDownloaded();
3205
3208
  this.setDone(e), this.change.markChanged();
3206
3209
  } catch (e) {
3207
- throw Te(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
3210
+ throw ke(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
3208
3211
  }
3209
3212
  }
3210
3213
  async ensureDownloaded() {
3211
- if (await ue(b.dirname(this.path)), await pe(this.path))
3214
+ if (await pe(b.dirname(this.path)), await ge(this.path))
3212
3215
  return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
3213
3216
  const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
3214
- return await ge(this.logger, this.path, async (o) => {
3215
- const n = S.toWeb(ie.createWriteStream(o, { flags: "wx" }));
3217
+ return await fe(this.logger, this.path, async (o) => {
3218
+ const n = S.toWeb(ae.createWriteStream(o, { flags: "wx" }));
3216
3219
  await e.pipeTo(n);
3217
3220
  }), t;
3218
3221
  }
3219
3222
  abort(e) {
3220
- this.signalCtl.abort(new je(e));
3223
+ this.signalCtl.abort(new Ge(e));
3221
3224
  }
3222
3225
  getBlob() {
3223
3226
  return this.done ? this.error ? {
@@ -3241,12 +3244,12 @@ class Ko {
3241
3244
  this.done = !0, this.error = e;
3242
3245
  }
3243
3246
  }
3244
- function Te(s) {
3245
- return s instanceof je || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3247
+ function ke(s) {
3248
+ return s instanceof Ge || s instanceof V || s instanceof Te || s instanceof be || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
3246
3249
  }
3247
- class je extends Error {
3250
+ class Ge extends Error {
3248
3251
  }
3249
- class ke {
3252
+ class Le {
3250
3253
  constructor(e) {
3251
3254
  d(this, "cache", /* @__PURE__ */ new Map());
3252
3255
  d(this, "totalSizeBytes", 0);
@@ -3262,16 +3265,16 @@ class ke {
3262
3265
  /** Decrements a counter in a cache and if we exceeds
3263
3266
  * a soft limit, removes files with zero counters. */
3264
3267
  removeFile(e, t) {
3265
- return Pe(this.cache, e).counter.dec(t), this.toDelete();
3268
+ return Ue(this.cache, e).counter.dec(t), this.toDelete();
3266
3269
  }
3267
3270
  /** Returns what results should be deleted to comply with the soft limit. */
3268
3271
  toDelete() {
3269
3272
  if (this.totalSizeBytes <= this.softSizeBytes) return [];
3270
3273
  const e = [];
3271
3274
  let t = 0;
3272
- return dt(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3275
+ return ht(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
3273
3276
  if (this.totalSizeBytes - t <= this.softSizeBytes) return;
3274
- const r = Pe(this.cache, o);
3277
+ const r = Ue(this.cache, o);
3275
3278
  t += r.size, e.push(r);
3276
3279
  }), e;
3277
3280
  }
@@ -3284,28 +3287,28 @@ class ke {
3284
3287
  this.cache.delete(e.path), this.totalSizeBytes -= e.size;
3285
3288
  }
3286
3289
  }
3287
- const Ge = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3288
- function Yo(s, e) {
3290
+ const Ve = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
3291
+ function en(s, e) {
3289
3292
  return `blob+local://download/${s}#${e.sign(s)}`;
3290
3293
  }
3291
- function en(s) {
3292
- return !!s.match(Ge);
3294
+ function tn(s) {
3295
+ return !!s.match(Ve);
3293
3296
  }
3294
3297
  function re(s, e) {
3295
- const t = s.match(Ge);
3298
+ const t = s.match(Ve);
3296
3299
  if (t === null)
3297
3300
  throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
3298
3301
  const { path: o, signature: n } = t.groups;
3299
3302
  return e.verify(o, n, `Signature verification failed for: ${s}`), { path: o, signature: n };
3300
3303
  }
3301
- const tn = G({
3304
+ const on = G({
3302
3305
  kv: {
3303
3306
  "ctl/file/blobInfo": k.object({
3304
3307
  sizeBytes: k.coerce.number()
3305
3308
  })
3306
3309
  }
3307
3310
  });
3308
- function on(s) {
3311
+ function nn(s) {
3309
3312
  return s.kv["ctl/file/blobInfo"].sizeBytes;
3310
3313
  }
3311
3314
  const q = k.object({
@@ -3317,69 +3320,69 @@ const q = k.object({
3317
3320
  sizeBytes: k.string(),
3318
3321
  /** Modification time unix timestamp in seconds */
3319
3322
  modificationTime: k.string()
3320
- }), Ve = k.object({
3323
+ }), qe = k.object({
3321
3324
  /** Pl storage id */
3322
3325
  storageId: k.string(),
3323
3326
  /** Path inside storage */
3324
3327
  path: k.string()
3325
3328
  }), Ur = k.union([
3326
3329
  q,
3327
- Ve
3328
- ]), nn = G({
3330
+ qe
3331
+ ]), rn = G({
3329
3332
  data: q,
3330
3333
  fields: {
3331
3334
  blob: !1
3332
3335
  }
3333
- }), rn = G({
3336
+ }), sn = G({
3334
3337
  fields: {
3335
3338
  incarnation: !1
3336
3339
  }
3337
- }), qe = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3338
- function sn(s, e) {
3340
+ }), Je = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
3341
+ function an(s, e) {
3339
3342
  const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
3340
3343
  return `blob+remote://download/${t}#${e.sign(t)}`;
3341
3344
  }
3342
- function an(s) {
3343
- return !!s.match(qe);
3345
+ function ln(s) {
3346
+ return !!s.match(Je);
3344
3347
  }
3345
- function ln(s, e) {
3346
- const t = s.match(qe);
3348
+ function cn(s, e) {
3349
+ const t = s.match(Je);
3347
3350
  if (t === null)
3348
3351
  throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
3349
3352
  const { content: o, resourceType: n, resourceVersion: r, resourceId: a, signature: i } = t.groups;
3350
3353
  return e.verify(o, i, `Signature verification failed for ${s}`), {
3351
- id: he(BigInt(a)),
3354
+ id: ue(BigInt(a)),
3352
3355
  type: { name: n, version: r }
3353
3356
  };
3354
3357
  }
3355
- function Je(s, e) {
3358
+ function Ze(s, e) {
3356
3359
  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)}`;
3357
3360
  }
3358
- const Ze = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3361
+ const Qe = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3359
3362
  function A(s) {
3360
- return Ze.test(s);
3361
- }
3362
- const Qe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3363
- function cn(s) {
3364
3363
  return Qe.test(s);
3365
3364
  }
3365
+ const Xe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
3366
+ function dn(s) {
3367
+ return Xe.test(s);
3368
+ }
3366
3369
  function M(s) {
3367
3370
  let e;
3368
3371
  if (A(s))
3369
- e = s.match(Ze);
3370
- else if (cn(s))
3371
3372
  e = s.match(Qe);
3373
+ else if (dn(s))
3374
+ e = s.match(Xe);
3372
3375
  else throw new Error(`Log handle is malformed: ${s}`);
3373
3376
  if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
3374
3377
  const { resourceType: t, resourceVersion: o, resourceId: n } = e.groups;
3375
3378
  return {
3376
- id: he(BigInt(n)),
3379
+ id: ue(BigInt(n)),
3377
3380
  type: { name: t, version: o }
3378
3381
  };
3379
3382
  }
3380
- class Le extends Error {
3383
+ class Pe extends Error {
3381
3384
  }
3382
- class dn {
3385
+ class hn {
3383
3386
  constructor(e) {
3384
3387
  d(this, "updating");
3385
3388
  this.onUpdate = e;
@@ -3409,7 +3412,7 @@ class Dr {
3409
3412
  d(this, "idToLastLines", /* @__PURE__ */ new Map());
3410
3413
  d(this, "idToProgressLog", /* @__PURE__ */ new Map());
3411
3414
  d(this, "saveDir");
3412
- this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new ke(a.cacheSoftSizeBytes), this.downloadQueue = new j(this.logger, a.nConcurrentDownloads), this.saveDir = b.resolve(n);
3415
+ this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new Le(a.cacheSoftSizeBytes), this.downloadQueue = new j(this.logger, a.nConcurrentDownloads), this.saveDir = b.resolve(n);
3413
3416
  }
3414
3417
  getDownloadedBlob(e, t) {
3415
3418
  if (t === void 0) return w.make((a) => this.getDownloadedBlob(e, a));
@@ -3419,13 +3422,13 @@ class Dr {
3419
3422
  return r == null && t.markUnstable("download blob is still undefined"), r;
3420
3423
  }
3421
3424
  getDownloadedBlobNoCtx(e, t, o) {
3422
- $("getDownloadedBlob", t.type);
3425
+ B("getDownloadedBlob", t.type);
3423
3426
  let n = this.idToDownload.get(t.id);
3424
3427
  if (n === void 0) {
3425
3428
  const a = this.setNewDownloadTask(t);
3426
3429
  this.downloadQueue.push({
3427
3430
  fn: () => this.downloadBlob(a, o),
3428
- recoverableErrorPredicate: (i) => !Te(i)
3431
+ recoverableErrorPredicate: (i) => !ke(i)
3429
3432
  }), n = a;
3430
3433
  }
3431
3434
  n.attach(e, o);
@@ -3436,12 +3439,12 @@ class Dr {
3436
3439
  }
3437
3440
  }
3438
3441
  setNewDownloadTask(e) {
3439
- const t = this.getFilePath(e.id), o = new Ko(
3442
+ const t = this.getFilePath(e.id), o = new Yo(
3440
3443
  this.logger,
3441
3444
  this.clientDownload,
3442
3445
  e,
3443
3446
  t,
3444
- Yo(t, this.signer)
3447
+ en(t, this.signer)
3445
3448
  );
3446
3449
  return this.idToDownload.set(e.id, o), o;
3447
3450
  }
@@ -3452,13 +3455,13 @@ class Dr {
3452
3455
  }
3453
3456
  getOnDemandBlob(e, t) {
3454
3457
  if (t === void 0) return w.make((a) => this.getOnDemandBlob(e, a));
3455
- const o = E(e) ? x(e, tn, t) : e, n = U();
3458
+ const o = E(e) ? x(e, on, t) : e, n = U();
3456
3459
  return t.addOnDestroy(() => this.releaseOnDemandBlob(o.id, n)), this.getOnDemandBlobNoCtx(o, n);
3457
3460
  }
3458
3461
  getOnDemandBlobNoCtx(e, t) {
3459
- $("getOnDemandBlob", e.type);
3462
+ B("getOnDemandBlob", e.type);
3460
3463
  let o = this.idToOnDemand.get(e.id);
3461
- return o === void 0 && (o = new hn(on(e), sn(e, this.signer)), this.idToOnDemand.set(e.id, o)), o.attach(t), o.getHandle();
3464
+ return o === void 0 && (o = new un(nn(e), an(e, this.signer)), this.idToOnDemand.set(e.id, o)), o.attach(t), o.getHandle();
3462
3465
  }
3463
3466
  /** Gets a path from a handle. */
3464
3467
  getLocalPath(e) {
@@ -3467,11 +3470,11 @@ class Dr {
3467
3470
  }
3468
3471
  /** Gets a content of a blob by a handle. */
3469
3472
  async getContent(e) {
3470
- if (en(e))
3471
- return await pn(this.getLocalPath(e));
3472
- if (an(e)) {
3473
- const t = ln(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3474
- return await Ce(o);
3473
+ if (tn(e))
3474
+ return await gn(this.getLocalPath(e));
3475
+ if (ln(e)) {
3476
+ const t = cn(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
3477
+ return await _e(o);
3475
3478
  }
3476
3479
  throw new Error("Malformed remote handle");
3477
3480
  }
@@ -3495,13 +3498,13 @@ class Dr {
3495
3498
  return a == null && o.markUnstable("either a file was not downloaded or logs was not read"), a;
3496
3499
  }
3497
3500
  getLastLogsNoCtx(e, t, o, n) {
3498
- $("getLastLogs", t.type);
3501
+ B("getLastLogs", t.type);
3499
3502
  const r = this.getDownloadedBlobNoCtx(e, t, n);
3500
3503
  if (r == null) return;
3501
3504
  const { path: a } = re(r.handle, this.signer);
3502
3505
  let i = this.idToLastLines.get(t.id);
3503
3506
  if (i == null) {
3504
- const l = new De(a, o);
3507
+ const l = new Re(a, o);
3505
3508
  this.idToLastLines.set(t.id, l), i = l;
3506
3509
  }
3507
3510
  const c = i.getOrSchedule(e);
@@ -3522,13 +3525,13 @@ class Dr {
3522
3525
  return a === void 0 && o.markUnstable("either a file was not downloaded or a progress log was not read"), a;
3523
3526
  }
3524
3527
  getProgressLogNoCtx(e, t, o, n) {
3525
- $("getProgressLog", t.type);
3528
+ B("getProgressLog", t.type);
3526
3529
  const r = this.getDownloadedBlobNoCtx(e, t, n);
3527
3530
  if (r == null) return;
3528
3531
  const { path: a } = re(r.handle, this.signer);
3529
3532
  let i = this.idToProgressLog.get(t.id);
3530
3533
  if (i == null) {
3531
- const l = new De(a, 1, o);
3534
+ const l = new Re(a, 1, o);
3532
3535
  this.idToProgressLog.set(t.id, l), i = l;
3533
3536
  }
3534
3537
  const c = i.getOrSchedule(e);
@@ -3541,7 +3544,7 @@ class Dr {
3541
3544
  return this.getLogHandleNoCtx(o);
3542
3545
  }
3543
3546
  getLogHandleNoCtx(e) {
3544
- return $("getLogHandle", e.type), Je(!1, e);
3547
+ return B("getLogHandle", e.type), Ze(!1, e);
3545
3548
  }
3546
3549
  async lastLines(e, t, o, n) {
3547
3550
  const r = await this.clientLogs.lastLines(
@@ -3609,7 +3612,7 @@ class Dr {
3609
3612
  return b.resolve(this.saveDir, String(BigInt(e)));
3610
3613
  }
3611
3614
  }
3612
- class hn {
3615
+ class un {
3613
3616
  constructor(e, t) {
3614
3617
  d(this, "counter", new v());
3615
3618
  this.size = e, this.handle = t;
@@ -3624,13 +3627,13 @@ class hn {
3624
3627
  return this.counter.dec(e);
3625
3628
  }
3626
3629
  }
3627
- class De {
3630
+ class Re {
3628
3631
  constructor(e, t, o) {
3629
3632
  d(this, "updater");
3630
3633
  d(this, "log");
3631
3634
  d(this, "change", new N());
3632
3635
  d(this, "error");
3633
- this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new dn(async () => this.update());
3636
+ this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new hn(async () => this.update());
3634
3637
  }
3635
3638
  getOrSchedule(e) {
3636
3639
  return this.change.attachWatcher(e), this.updater.schedule(), {
@@ -3640,7 +3643,7 @@ class De {
3640
3643
  }
3641
3644
  async update() {
3642
3645
  try {
3643
- const e = await un(this.path, this.lines, this.patternToSearch);
3646
+ const e = await pn(this.path, this.lines, this.patternToSearch);
3644
3647
  this.log != e && this.change.markChanged(), this.log = e;
3645
3648
  } catch (e) {
3646
3649
  if (e.name == "RpcError" && e.code == "NOT_FOUND") {
@@ -3651,51 +3654,51 @@ class De {
3651
3654
  }
3652
3655
  }
3653
3656
  }
3654
- function un(s, e, t) {
3655
- const o = me.createReadStream(s), n = new S();
3657
+ function pn(s, e, t) {
3658
+ const o = we.createReadStream(s), n = new S();
3656
3659
  return new Promise((r, a) => {
3657
- const i = mt.createInterface(o, n), c = new pt();
3660
+ const i = wt.createInterface(o, n), c = new gt();
3658
3661
  i.on("line", function(l) {
3659
3662
  t != null && !l.includes(t) || (c.push(l), c.length > e && c.shift());
3660
3663
  }), i.on("error", a), i.on("close", function() {
3661
- r(c.toArray().join(Ue.EOL) + Ue.EOL);
3664
+ r(c.toArray().join(De.EOL) + De.EOL);
3662
3665
  });
3663
3666
  });
3664
3667
  }
3665
- async function pn(s) {
3666
- return await Ce(we.toWeb(me.createReadStream(s)));
3668
+ async function gn(s) {
3669
+ return await _e(ye.toWeb(we.createReadStream(s)));
3667
3670
  }
3668
- function $(s, e) {
3671
+ function B(s, e) {
3669
3672
  if (!e.name.startsWith("Blob/")) {
3670
3673
  let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
3671
- throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Le(t);
3674
+ throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Pe(t);
3672
3675
  }
3673
3676
  }
3674
- const gn = G({});
3675
- function fn(s, e) {
3676
- const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
3677
- return x(t, gn);
3677
+ const fn = G({});
3678
+ function mn(s, e) {
3679
+ const t = E(s) ? e.accessor(s).node() : Oe(s) ? s.node() : s;
3680
+ return x(t, fn);
3678
3681
  }
3679
- function mn(s, e, t) {
3682
+ function wn(s, e, t) {
3680
3683
  const o = L.relative(e, t);
3681
3684
  return `plblob+folder://${s.sign(o)}.${o}.blob`;
3682
3685
  }
3683
- function wn(s) {
3686
+ function yn(s) {
3684
3687
  return new URL(s).protocol == "plblob+folder:";
3685
3688
  }
3686
- function yn(s, e, t) {
3689
+ function bn(s, e, t) {
3687
3690
  const o = new URL(e), [n, r, a] = o.host.split(".");
3688
3691
  s.verify(r, n, `signature verification failed for url: ${e}, subfolder: ${r}`);
3689
- let i = bn(L.join(t, `${r}`), o.pathname.slice(1));
3692
+ let i = Tn(L.join(t, `${r}`), o.pathname.slice(1));
3690
3693
  return (o.pathname == "" || o.pathname == "/") && (i = L.join(i, "index.html")), L.resolve(i);
3691
3694
  }
3692
- function bn(s, e) {
3695
+ function Tn(s, e) {
3693
3696
  const t = L.resolve(s, e), o = L.resolve(s);
3694
3697
  if (!t.startsWith(o))
3695
3698
  throw new Error("Path validation failed.");
3696
3699
  return t;
3697
3700
  }
3698
- class Tn {
3701
+ class kn {
3699
3702
  constructor(e, t, o, n, r, a, i) {
3700
3703
  d(this, "counter", new v());
3701
3704
  d(this, "change", new N());
@@ -3727,8 +3730,8 @@ class Tn {
3727
3730
  const e = await this.downloadAndDecompress(this.signalCtl.signal);
3728
3731
  this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${y(this.info())}`);
3729
3732
  } catch (e) {
3730
- if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${y(this.info())}`), kn(e)) {
3731
- this.setError(e), this.change.markChanged(), await le(this.path);
3733
+ if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${y(this.info())}`), Ln(e)) {
3734
+ this.setError(e), this.change.markChanged(), await ce(this.path);
3732
3735
  return;
3733
3736
  }
3734
3737
  throw e;
@@ -3736,34 +3739,34 @@ class Tn {
3736
3739
  }
3737
3740
  /** Does the download part and keeps a state of the process. */
3738
3741
  async downloadAndDecompress(e) {
3739
- if (this.state = {}, this.state.parentDir = L.dirname(this.path), await ue(this.state.parentDir), this.state.fileExisted = await pe(this.path), this.state.fileExisted)
3740
- return await Xe(this.path);
3742
+ if (this.state = {}, this.state.parentDir = L.dirname(this.path), await pe(this.state.parentDir), this.state.fileExisted = await ge(this.path), this.state.fileExisted)
3743
+ return await Ke(this.path);
3741
3744
  const { content: t, size: o } = await this.clientDownload.downloadBlob(
3742
3745
  this.rInfo,
3743
3746
  {},
3744
3747
  e
3745
3748
  );
3746
- return this.state.downloaded = !0, await ge(this.logger, this.path, async (n) => {
3749
+ return this.state.downloaded = !0, await fe(this.logger, this.path, async (n) => {
3747
3750
  switch (this.state.tempPath = n, this.state.archiveFormat = this.format, this.format) {
3748
3751
  case "tar":
3749
3752
  await m.mkdir(n);
3750
- const r = S.toWeb(ae.extract(n));
3753
+ const r = S.toWeb(le.extract(n));
3751
3754
  await t.pipeTo(r, { signal: e });
3752
3755
  return;
3753
3756
  case "tgz":
3754
3757
  await m.mkdir(n);
3755
- const a = $e.toWeb(Oe.createGunzip()), i = S.toWeb(ae.extract(n));
3758
+ const a = Ce.toWeb(Fe.createGunzip()), i = S.toWeb(le.extract(n));
3756
3759
  await t.pipeThrough(a, { signal: e }).pipeTo(i, { signal: e });
3757
3760
  return;
3758
3761
  case "zip":
3759
3762
  this.state.zipPath = this.path + ".zip";
3760
- const c = S.toWeb(ie.createWriteStream(this.state.zipPath));
3761
- await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await wt(this.state.zipPath, n, {
3763
+ const c = S.toWeb(ae.createWriteStream(this.state.zipPath));
3764
+ await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await yt(this.state.zipPath, n, {
3762
3765
  filter: (l) => !l.path.endsWith("/")
3763
- }), this.state.zipDecompressed = !0, await ie.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3766
+ }), this.state.zipDecompressed = !0, await ae.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
3764
3767
  return;
3765
3768
  default:
3766
- ct(this.format);
3769
+ dt(this.format);
3767
3770
  }
3768
3771
  }), this.state.pathCreated = !0, o;
3769
3772
  }
@@ -3772,31 +3775,31 @@ class Tn {
3772
3775
  if (this.error) return { error: this.error };
3773
3776
  }
3774
3777
  setDone(e) {
3775
- this.done = !0, this.size = e, this.url = mn(this.signer, this.saveDir, this.path);
3778
+ this.done = !0, this.size = e, this.url = wn(this.signer, this.saveDir, this.path);
3776
3779
  }
3777
3780
  setError(e) {
3778
3781
  this.error = String(e);
3779
3782
  }
3780
3783
  abort(e) {
3781
- this.signalCtl.abort(new Ke(e));
3784
+ this.signalCtl.abort(new Ye(e));
3782
3785
  }
3783
3786
  }
3784
- async function Xe(s) {
3787
+ async function Ke(s) {
3785
3788
  const e = await m.readdir(s, { withFileTypes: !0 });
3786
3789
  return (await Promise.all(
3787
3790
  e.map(async (o) => {
3788
3791
  const n = L.join(s, o.name);
3789
- return o.isDirectory() ? await Xe(n) : (await m.stat(n)).size;
3792
+ return o.isDirectory() ? await Ke(n) : (await m.stat(n)).size;
3790
3793
  })
3791
3794
  )).reduce((o, n) => o + n, 0);
3792
3795
  }
3793
- async function le(s) {
3796
+ async function ce(s) {
3794
3797
  await m.rm(s, { recursive: !0, force: !0 });
3795
3798
  }
3796
- let Ke = class extends Error {
3799
+ let Ye = class extends Error {
3797
3800
  };
3798
- function kn(s) {
3799
- return s instanceof Ke || s instanceof V || s instanceof be || s instanceof ye || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3801
+ function Ln(s) {
3802
+ return s instanceof Ye || s instanceof V || s instanceof Te || s instanceof be || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
3800
3803
  }
3801
3804
  function O(s, e) {
3802
3805
  return `id:${String(BigInt(s))}-${e}`;
@@ -3817,7 +3820,7 @@ class Sr {
3817
3820
  maxDelay: 3e4,
3818
3821
  backoffMultiplier: 1.5,
3819
3822
  jitter: 0.5
3820
- }), this.cache = new ke(this.opts.cacheSoftSizeBytes);
3823
+ }), this.cache = new Le(this.opts.cacheSoftSizeBytes);
3821
3824
  }
3822
3825
  info() {
3823
3826
  return {
@@ -3832,14 +3835,14 @@ class Sr {
3832
3835
  * @returns full path to the referenced file
3833
3836
  */
3834
3837
  getPathForCustomProtocol(e) {
3835
- if (wn(e))
3836
- return yn(this.signer, e, this.saveDir);
3838
+ if (yn(e))
3839
+ return bn(this.signer, e, this.saveDir);
3837
3840
  throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
3838
3841
  }
3839
3842
  extractArchiveAndGetURL(e, t, o) {
3840
3843
  if (o === void 0)
3841
3844
  return w.make((i) => this.extractArchiveAndGetURL(e, t, i));
3842
- const n = E(e) ? fn(e, o) : e, r = U();
3845
+ const n = E(e) ? mn(e, o) : e, r = U();
3843
3846
  o.addOnDestroy(() => this.releasePath(n.id, t, r));
3844
3847
  const a = this.extractArchiveAndGetURLNoCtx(n, t, o.watcher, r);
3845
3848
  if ((a == null ? void 0 : a.url) === void 0 && o.markUnstable(
@@ -3855,7 +3858,7 @@ class Sr {
3855
3858
  const a = this.setNewTask(o, e, t, n);
3856
3859
  return this.downloadQueue.push({
3857
3860
  fn: async () => this.downloadUrl(a, n),
3858
- recoverableErrorPredicate: (i) => !Te(i)
3861
+ recoverableErrorPredicate: (i) => !ke(i)
3859
3862
  }), a.getURL();
3860
3863
  }
3861
3864
  /** Downloads and extracts a tar archive if it wasn't downloaded yet. */
@@ -3872,7 +3875,7 @@ class Sr {
3872
3875
  const r = this.cache.removeFile(n.path, o);
3873
3876
  await Promise.all(
3874
3877
  r.map(async (a) => {
3875
- await le(a.path), this.cache.removeCache(a), this.removeTask(
3878
+ await ce(a.path), this.cache.removeCache(a), this.removeTask(
3876
3879
  a,
3877
3880
  `the task ${y(a.info())} was removedfrom cache along with ${y(r.map((i) => i.info()))}`
3878
3881
  );
@@ -3888,7 +3891,7 @@ class Sr {
3888
3891
  async releaseAll() {
3889
3892
  this.downloadQueue.stop(), await Promise.all(
3890
3893
  Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
3891
- await le(t.path), this.cache.removeCache(t), this.removeTask(
3894
+ await ce(t.path), this.cache.removeCache(t), this.removeTask(
3892
3895
  t,
3893
3896
  `the task ${y(t.info())} was released when the driver was closed`
3894
3897
  );
@@ -3896,7 +3899,7 @@ class Sr {
3896
3899
  );
3897
3900
  }
3898
3901
  setNewTask(e, t, o, n) {
3899
- const r = new Tn(
3902
+ const r = new kn(
3900
3903
  this.logger,
3901
3904
  this.signer,
3902
3905
  this.saveDir,
@@ -3914,7 +3917,7 @@ class Sr {
3914
3917
  return b.join(this.saveDir, `${String(BigInt(e))}_${t}`);
3915
3918
  }
3916
3919
  }
3917
- class Ln {
3920
+ class Pn {
3918
3921
  constructor(e, t, o, n, r, a) {
3919
3922
  d(this, "change", new N());
3920
3923
  d(this, "counter", new v());
@@ -3931,21 +3934,21 @@ class Ln {
3931
3934
  * At this case, the task will show progress == 1.0. */
3932
3935
  d(this, "alreadyExisted", !1);
3933
3936
  this.logger = e, this.clientBlob = t, this.clientProgress = o, this.maxNConcurrentPartsUpload = n, this.res = a, this.nMaxUploads = this.maxNConcurrentPartsUpload;
3934
- const { uploadData: i, progress: c } = Un(a, r);
3937
+ const { uploadData: i, progress: c } = Dn(a, r);
3935
3938
  this.uploadData = i, this.progress = c;
3936
3939
  }
3937
3940
  getProgress(e, t) {
3938
3941
  if (this.incCounter(e, t), this.failed)
3939
3942
  throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
3940
- return Rn(this.progress);
3943
+ return Sn(this.progress);
3941
3944
  }
3942
3945
  shouldScheduleUpload() {
3943
- return Dn(this.progress);
3946
+ return Rn(this.progress);
3944
3947
  }
3945
3948
  /** Uploads a blob if it's not BlobIndex. */
3946
3949
  async uploadBlobTask() {
3947
3950
  try {
3948
- await Pn(
3951
+ await Un(
3949
3952
  this.logger,
3950
3953
  this.clientBlob,
3951
3954
  this.res,
@@ -3959,28 +3962,28 @@ class Ln {
3959
3962
  }
3960
3963
  ), this.change.markChanged();
3961
3964
  } catch (e) {
3962
- if (this.setRetriableError(e), Re(e)) {
3965
+ if (this.setRetriableError(e), Se(e)) {
3963
3966
  this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
3964
3967
  return;
3965
3968
  }
3966
- if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Ye(e)) {
3969
+ if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), et(e)) {
3967
3970
  this.setTerminalError(e);
3968
3971
  return;
3969
3972
  }
3970
- throw Bn(e) && (this.nMaxUploads = Cn(this.logger, this.nMaxUploads, 1)), e;
3973
+ throw Bn(e) && (this.nMaxUploads = _n(this.logger, this.nMaxUploads, 1)), e;
3971
3974
  }
3972
3975
  }
3973
3976
  async updateStatus() {
3974
3977
  var e;
3975
3978
  try {
3976
- const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Nn(this.alreadyExisted, vn(t));
3979
+ const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = $n(this.alreadyExisted, Nn(t));
3977
3980
  this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (o == null ? void 0 : o.progress)) && this.change.markChanged();
3978
3981
  } catch (t) {
3979
3982
  if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
3980
3983
  this.logger.warn("deadline exceeded while getting a status of BlobImport");
3981
3984
  return;
3982
3985
  }
3983
- if (Re(t)) {
3986
+ if (Se(t)) {
3984
3987
  this.logger.warn(
3985
3988
  `resource was not found while updating a status of BlobImport: ${t}, ${y(this.res)}`
3986
3989
  ), this.change.markChanged(), this.setDone(!0);
@@ -3998,7 +4001,7 @@ class Ln {
3998
4001
  this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
3999
4002
  }
4000
4003
  setDoneIfOutputSet(e) {
4001
- Sn(e) && (this.setDone(!0), this.alreadyExisted = !0);
4004
+ In(e) && (this.setDone(!0), this.alreadyExisted = !0);
4002
4005
  }
4003
4006
  setDone(e) {
4004
4007
  this.progress.done = e, e && (this.progress.lastError = void 0);
@@ -4013,8 +4016,8 @@ class Ln {
4013
4016
  return this.counter.isZero();
4014
4017
  }
4015
4018
  }
4016
- async function Pn(s, e, t, o, n, r) {
4017
- yt(ce(t), "the upload operation can be done only for BlobUploads");
4019
+ async function Un(s, e, t, o, n, r) {
4020
+ bt(de(t), "the upload operation can be done only for BlobUploads");
4018
4021
  const a = 1e4;
4019
4022
  if (n()) return;
4020
4023
  const i = await e.initUpload(t, { timeout: a });
@@ -4028,76 +4031,76 @@ async function Pn(s, e, t, o, n, r) {
4028
4031
  BigInt(o.modificationTime),
4029
4032
  l,
4030
4033
  { timeout: a }
4031
- ), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = $n(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
4034
+ ), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = Cn(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
4032
4035
  };
4033
- await fe(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
4036
+ await me(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
4034
4037
  }
4035
- function Un(s, e) {
4038
+ function Dn(s, e) {
4036
4039
  let t, o;
4037
- return ce(s) && (o = q.parse(s.data), t = In(e, o.localPath, o.pathSignature)), {
4040
+ return de(s) && (o = q.parse(s.data), t = vn(e, o.localPath, o.pathSignature)), {
4038
4041
  uploadData: o,
4039
4042
  progress: {
4040
4043
  done: !1,
4041
4044
  status: void 0,
4042
- isUpload: ce(s),
4045
+ isUpload: de(s),
4043
4046
  isUploadSignMatch: t,
4044
4047
  lastError: void 0
4045
4048
  }
4046
4049
  };
4047
4050
  }
4048
- function Dn(s) {
4051
+ function Rn(s) {
4049
4052
  return s.isUpload && (s.isUploadSignMatch ?? !1);
4050
4053
  }
4051
- function Rn(s) {
4054
+ function Sn(s) {
4052
4055
  return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
4053
4056
  }
4054
- function Sn(s) {
4057
+ function In(s) {
4055
4058
  return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
4056
4059
  }
4057
- function ce(s) {
4060
+ function de(s) {
4058
4061
  return s.type.name.startsWith("BlobUpload");
4059
4062
  }
4060
- function In(s, e, t) {
4063
+ function vn(s, e, t) {
4061
4064
  try {
4062
4065
  return s.verify(e, t), !0;
4063
4066
  } catch {
4064
4067
  return !1;
4065
4068
  }
4066
4069
  }
4067
- function vn(s) {
4070
+ function Nn(s) {
4068
4071
  return {
4069
4072
  progress: s.progress ?? 0,
4070
4073
  bytesProcessed: Number(s.bytesProcessed),
4071
4074
  bytesTotal: Number(s.bytesTotal)
4072
4075
  };
4073
4076
  }
4074
- function Nn(s, e) {
4077
+ function $n(s, e) {
4075
4078
  return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
4076
4079
  progress: 1,
4077
4080
  bytesProcessed: Number(e.bytesTotal),
4078
4081
  bytesTotal: Number(e.bytesTotal)
4079
4082
  } : e;
4080
4083
  }
4081
- function Re(s) {
4084
+ function Se(s) {
4082
4085
  return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
4083
4086
  }
4084
- function Ye(s) {
4085
- return s instanceof ze || s instanceof xe || s instanceof Me;
4087
+ function et(s) {
4088
+ return s instanceof xe || s instanceof Ae || s instanceof He;
4086
4089
  }
4087
4090
  function Bn(s) {
4088
4091
  return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
4089
4092
  }
4090
- function $n(s, e, t) {
4093
+ function Cn(s, e, t) {
4091
4094
  const o = Math.min(e + 2, t);
4092
4095
  return o != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${o}`), o;
4093
4096
  }
4094
- function Cn(s, e, t) {
4097
+ function _n(s, e, t) {
4095
4098
  const o = Math.max(Math.round(e / 2), t);
4096
4099
  return o != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${o}`), o;
4097
4100
  }
4098
- function _n(s, e) {
4099
- const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
4100
- return t.resourceType.name.startsWith("BlobUpload") ? x(t, nn) : x(t, rn);
4101
+ function En(s, e) {
4102
+ const t = E(s) ? e.accessor(s).node() : Oe(s) ? s.node() : s;
4103
+ return t.resourceType.name.startsWith("BlobUpload") ? x(t, rn) : x(t, sn);
4101
4104
  }
4102
4105
  class Ir {
4103
4106
  constructor(e, t, o, n, r = {
@@ -4122,7 +4125,7 @@ class Ir {
4122
4125
  // 15 seconds
4123
4126
  backoffMultiplier: 1.5,
4124
4127
  jitter: 0.5
4125
- }), this.hooks = new _e(
4128
+ }), this.hooks = new Ee(
4126
4129
  () => this.startUpdating(),
4127
4130
  () => this.stopUpdating(),
4128
4131
  { stopDebounce: r.stopPollingDelay },
@@ -4131,15 +4134,15 @@ class Ir {
4131
4134
  }
4132
4135
  getProgressId(e, t) {
4133
4136
  if (t == null) return w.make((a) => this.getProgressId(e, a));
4134
- const o = E(e) ? _n(e, t) : e, n = U();
4137
+ const o = E(e) ? En(e, t) : e, n = U();
4135
4138
  return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(o.id, n)), this.getProgressIdNoCtx(t.watcher, o, n);
4136
4139
  }
4137
4140
  getProgressIdNoCtx(e, t, o) {
4138
- On("getProgressId", t.type);
4141
+ Fn("getProgressId", t.type);
4139
4142
  const n = this.idToProgress.get(t.id);
4140
4143
  if (n != null)
4141
4144
  return n.setDoneIfOutputSet(t), n.getProgress(e, o);
4142
- const r = new Ln(
4145
+ const r = new Pn(
4143
4146
  this.logger,
4144
4147
  this.clientBlob,
4145
4148
  this.clientProgress,
@@ -4149,7 +4152,7 @@ class Ir {
4149
4152
  );
4150
4153
  return this.idToProgress.set(t.id, r), r.shouldScheduleUpload() && this.uploadQueue.push({
4151
4154
  fn: () => r.uploadBlobTask(),
4152
- recoverableErrorPredicate: (a) => !Ye(a)
4155
+ recoverableErrorPredicate: (a) => !et(a)
4153
4156
  }), r.setDoneIfOutputSet(t), r.getProgress(e, o);
4154
4157
  }
4155
4158
  /** Decrement counters for the file and remove an uploading if counter == 0. */
@@ -4178,7 +4181,7 @@ class Ir {
4178
4181
  const e = this.scheduledOnNextState;
4179
4182
  this.scheduledOnNextState = [];
4180
4183
  try {
4181
- await fe(
4184
+ await me(
4182
4185
  this.opts.nConcurrentGetProgresses,
4183
4186
  this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
4184
4187
  ), e.forEach((t) => t.resolve());
@@ -4186,21 +4189,21 @@ class Ir {
4186
4189
  console.error(t), e.forEach((o) => o.reject(t));
4187
4190
  }
4188
4191
  if (!this.keepRunning) break;
4189
- await Fe.wait(this.opts.pollingInterval);
4192
+ await We.wait(this.opts.pollingInterval);
4190
4193
  }
4191
4194
  this.currentLoop = void 0;
4192
4195
  }
4193
4196
  getAllNotDoneProgresses() {
4194
- return Array.from(this.idToProgress.entries()).filter(([e, t]) => !En(t.progress)).map(([e, t]) => t);
4197
+ return Array.from(this.idToProgress.entries()).filter(([e, t]) => !On(t.progress)).map(([e, t]) => t);
4195
4198
  }
4196
4199
  }
4197
- function En(s) {
4200
+ function On(s) {
4198
4201
  var e;
4199
4202
  return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
4200
4203
  }
4201
- function On(s, e) {
4204
+ function Fn(s, e) {
4202
4205
  if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
4203
- throw new Le(
4206
+ throw new Pe(
4204
4207
  `${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
4205
4208
  );
4206
4209
  }
@@ -4221,7 +4224,7 @@ class vr {
4221
4224
  d(this, "keepRunning", !1);
4222
4225
  /** Actual state of main loop. */
4223
4226
  d(this, "currentLoop");
4224
- this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new _e(
4227
+ this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new Ee(
4225
4228
  () => this.startUpdating(),
4226
4229
  () => this.stopUpdating(),
4227
4230
  { stopDebounce: o.stopPollingDelay },
@@ -4241,7 +4244,7 @@ class vr {
4241
4244
  se("getLastLogs", t.type);
4242
4245
  let r = this.idToLastLines.get(t.id);
4243
4246
  if (r == null) {
4244
- const i = new Se(this.logger, this.clientLogs, t, o);
4247
+ const i = new Ie(this.logger, this.clientLogs, t, o);
4245
4248
  this.idToLastLines.set(t.id, i), r = i;
4246
4249
  }
4247
4250
  r.attach(e, n);
@@ -4263,7 +4266,7 @@ class vr {
4263
4266
  se("getProgressLog", t.type);
4264
4267
  let r = this.idToProgressLog.get(t.id);
4265
4268
  if (r == null) {
4266
- const i = new Se(this.logger, this.clientLogs, t, 1, o);
4269
+ const i = new Ie(this.logger, this.clientLogs, t, 1, o);
4267
4270
  this.idToProgressLog.set(t.id, i), r = i;
4268
4271
  }
4269
4272
  r.attach(e, n);
@@ -4274,10 +4277,10 @@ class vr {
4274
4277
  getLogHandle(e, t) {
4275
4278
  if (t == null) return w.make((r) => this.getLogHandle(e, r));
4276
4279
  const o = R(e, t), n = this.getLogHandleNoCtx(o);
4277
- return t.markUnstable(`live_log:${at(o.id)}`), n;
4280
+ return t.markUnstable(`live_log:${lt(o.id)}`), n;
4278
4281
  }
4279
4282
  getLogHandleNoCtx(e) {
4280
- return se("getLogHandle", e.type), Je(!0, e);
4283
+ return se("getLogHandle", e.type), Ze(!0, e);
4281
4284
  }
4282
4285
  async lastLines(e, t, o, n) {
4283
4286
  return await this.tryWithNotFound(
@@ -4346,7 +4349,7 @@ class vr {
4346
4349
  this.scheduledOnNextState = [];
4347
4350
  try {
4348
4351
  const t = this.getAllLogs();
4349
- await fe(
4352
+ await me(
4350
4353
  this.opts.nConcurrentGetLogs,
4351
4354
  t.map((o) => async () => await o.update())
4352
4355
  ), e.forEach((o) => o.resolve());
@@ -4354,7 +4357,7 @@ class vr {
4354
4357
  console.error(t), e.forEach((o) => o.reject(t));
4355
4358
  }
4356
4359
  if (!this.keepRunning) break;
4357
- await Fe.wait(this.opts.pollingInterval);
4360
+ await We.wait(this.opts.pollingInterval);
4358
4361
  }
4359
4362
  this.currentLoop = void 0;
4360
4363
  }
@@ -4362,7 +4365,7 @@ class vr {
4362
4365
  return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
4363
4366
  }
4364
4367
  }
4365
- class Se {
4368
+ class Ie {
4366
4369
  constructor(e, t, o, n, r) {
4367
4370
  d(this, "logs");
4368
4371
  d(this, "error");
@@ -4405,7 +4408,7 @@ class Se {
4405
4408
  }
4406
4409
  function se(s, e) {
4407
4410
  if (!e.name.startsWith("StreamWorkdir"))
4408
- throw new Le(
4411
+ throw new Pe(
4409
4412
  `${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
4410
4413
  );
4411
4414
  }
@@ -4499,7 +4502,7 @@ function W(s, e) {
4499
4502
  var t;
4500
4503
  return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
4501
4504
  }
4502
- class Br {
4505
+ class $r {
4503
4506
  constructor(e, t, o, n = {
4504
4507
  cacheSoftSizeBytes: 50 * 1024 * 1024,
4505
4508
  withGunzip: !0,
@@ -4511,7 +4514,7 @@ class Br {
4511
4514
  /** Writes and removes files to a hard drive and holds a counter for every
4512
4515
  * file that should be kept. */
4513
4516
  d(this, "cache");
4514
- this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads), this.cache = new ke(this.opts.cacheSoftSizeBytes), this.downloadHelper = new He(t);
4517
+ this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new j(this.logger, this.opts.nConcurrentDownloads), this.cache = new Le(this.opts.cacheSoftSizeBytes), this.downloadHelper = new je(t);
4515
4518
  }
4516
4519
  getPath(e, t) {
4517
4520
  if (t === void 0) return w.make((r) => this.getPath(e, r));
@@ -4546,7 +4549,7 @@ class Br {
4546
4549
  const r = this.cache.removeFile(n.path, t);
4547
4550
  await Promise.all(
4548
4551
  r.map(async (a) => {
4549
- await de(a.path), this.cache.removeCache(a), this.removeTask(
4552
+ await he(a.path), this.cache.removeCache(a), this.removeTask(
4550
4553
  a,
4551
4554
  `the task ${y(a.info())} was removedfrom cache along with ${y(r.map((i) => i.info()))}`
4552
4555
  );
@@ -4562,7 +4565,7 @@ class Br {
4562
4565
  async releaseAll() {
4563
4566
  this.downloadQueue.stop(), await Promise.all(
4564
4567
  Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
4565
- await de(t.path), this.cache.removeCache(t), this.removeTask(
4568
+ await he(t.path), this.cache.removeCache(t), this.removeTask(
4566
4569
  t,
4567
4570
  `the task ${y(t.info())} was released when the driver was closed`
4568
4571
  );
@@ -4570,18 +4573,18 @@ class Br {
4570
4573
  );
4571
4574
  }
4572
4575
  setNewTask(e, t, o) {
4573
- const n = new Fn(this.logger, this.getFilePath(t), t);
4576
+ const n = new Wn(this.logger, this.getFilePath(t), t);
4574
4577
  return n.attach(e, o), this.urlToDownload.set(t.toString(), n), n;
4575
4578
  }
4576
4579
  removeTask(e, t) {
4577
4580
  e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
4578
4581
  }
4579
4582
  getFilePath(e) {
4580
- const t = gt("sha256").update(e.toString()).digest("hex");
4583
+ const t = ft("sha256").update(e.toString()).digest("hex");
4581
4584
  return b.join(this.saveDir, t);
4582
4585
  }
4583
4586
  }
4584
- class Fn {
4587
+ class Wn {
4585
4588
  constructor(e, t, o) {
4586
4589
  d(this, "counter", new v());
4587
4590
  d(this, "change", new N());
@@ -4608,25 +4611,25 @@ class Fn {
4608
4611
  const o = await this.downloadAndUntar(e, t, this.signalCtl.signal);
4609
4612
  this.setDone(o), this.change.markChanged();
4610
4613
  } catch (o) {
4611
- if (o instanceof Ie || o instanceof V) {
4612
- this.setError(o), this.change.markChanged(), await de(this.path);
4614
+ if (o instanceof ve || o instanceof V) {
4615
+ this.setError(o), this.change.markChanged(), await he(this.path);
4613
4616
  return;
4614
4617
  }
4615
4618
  throw o;
4616
4619
  }
4617
4620
  }
4618
4621
  async downloadAndUntar(e, t, o) {
4619
- if (await ue(b.dirname(this.path)), await pe(this.path))
4620
- return await et(this.path);
4622
+ if (await pe(b.dirname(this.path)), await ge(this.path))
4623
+ return await tt(this.path);
4621
4624
  const n = await e.download(this.url.toString(), {}, o);
4622
4625
  let r = n.content;
4623
4626
  if (t) {
4624
- const a = $e.toWeb(Oe.createGunzip());
4627
+ const a = Ce.toWeb(Fe.createGunzip());
4625
4628
  r = r.pipeThrough(a, { signal: o });
4626
4629
  }
4627
- return await ge(this.logger, this.path, async (a) => {
4630
+ return await fe(this.logger, this.path, async (a) => {
4628
4631
  await m.mkdir(a);
4629
- const i = S.toWeb(ae.extract(a));
4632
+ const i = S.toWeb(le.extract(a));
4630
4633
  await r.pipeTo(i, { signal: o });
4631
4634
  }), n.size;
4632
4635
  }
@@ -4641,30 +4644,30 @@ class Fn {
4641
4644
  this.error = String(e);
4642
4645
  }
4643
4646
  abort(e) {
4644
- this.signalCtl.abort(new Ie(e));
4647
+ this.signalCtl.abort(new ve(e));
4645
4648
  }
4646
4649
  }
4647
- class Ie extends Error {
4650
+ class ve extends Error {
4648
4651
  }
4649
- async function et(s) {
4652
+ async function tt(s) {
4650
4653
  const e = await m.readdir(s, { withFileTypes: !0 });
4651
4654
  return (await Promise.all(
4652
4655
  e.map(async (o) => {
4653
4656
  const n = b.join(s, o.name);
4654
- return o.isDirectory() ? await et(n) : (await m.stat(n)).size;
4657
+ return o.isDirectory() ? await tt(n) : (await m.stat(n)).size;
4655
4658
  })
4656
4659
  )).reduce((o, n) => o + n, 0);
4657
4660
  }
4658
- async function de(s) {
4661
+ async function he(s) {
4659
4662
  await m.rm(s, { recursive: !0, force: !0 });
4660
4663
  }
4661
- function ve(s, e) {
4664
+ function ie(s, e) {
4662
4665
  return `index://index/${encodeURIComponent(JSON.stringify({
4663
4666
  storageId: s,
4664
4667
  path: e
4665
4668
  }))}`;
4666
4669
  }
4667
- function Wn(s, e, t, o) {
4670
+ function zn(s, e, t, o) {
4668
4671
  const n = {
4669
4672
  localPath: s,
4670
4673
  pathSignature: e.sign(s),
@@ -4673,32 +4676,32 @@ function Wn(s, e, t, o) {
4673
4676
  };
4674
4677
  return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
4675
4678
  }
4676
- function zn(s) {
4679
+ function xn(s) {
4677
4680
  const e = new URL(s);
4678
4681
  return q.parse(
4679
4682
  JSON.parse(decodeURIComponent(e.pathname.substring(1)))
4680
4683
  );
4681
4684
  }
4682
- function xn(s) {
4685
+ function An(s) {
4683
4686
  const e = new URL(s);
4684
- return Ve.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4687
+ return qe.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
4685
4688
  }
4686
- function An(s) {
4689
+ function Ne(s) {
4687
4690
  if (Gn(s))
4688
4691
  return qn(s);
4689
4692
  if (Mn(s))
4690
4693
  return jn(s);
4691
- ht(s);
4694
+ ut(s);
4692
4695
  }
4693
- const tt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4696
+ const ot = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
4694
4697
  function Mn(s) {
4695
- return tt.test(s);
4698
+ return ot.test(s);
4696
4699
  }
4697
4700
  function Hn(s, e) {
4698
4701
  return `local://${s}/${encodeURIComponent(e)}`;
4699
4702
  }
4700
4703
  function jn(s) {
4701
- const e = s.match(tt);
4704
+ const e = s.match(ot);
4702
4705
  if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
4703
4706
  const { name: t, path: o } = e.groups;
4704
4707
  return {
@@ -4707,19 +4710,19 @@ function jn(s) {
4707
4710
  isRemote: !1
4708
4711
  };
4709
4712
  }
4710
- const ot = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4713
+ const nt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
4711
4714
  function Gn(s) {
4712
- return ot.test(s);
4715
+ return nt.test(s);
4713
4716
  }
4714
4717
  function Vn(s, e) {
4715
4718
  return `remote://${s}/${BigInt(e)}`;
4716
4719
  }
4717
4720
  function qn(s) {
4718
- const e = s.match(ot);
4721
+ const e = s.match(nt);
4719
4722
  if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
4720
4723
  const { name: t, resourceId: o } = e.groups;
4721
4724
  return {
4722
- id: he(BigInt(o)),
4725
+ id: ue(BigInt(o)),
4723
4726
  type: Jn(t),
4724
4727
  name: t,
4725
4728
  isRemote: !0
@@ -4729,7 +4732,7 @@ function Jn(s) {
4729
4732
  return { name: `LS/${s}`, version: "1" };
4730
4733
  }
4731
4734
  async function Zn() {
4732
- const s = ft.homedir();
4735
+ const s = mt.homedir();
4733
4736
  if (L.sep == "/")
4734
4737
  return [
4735
4738
  {
@@ -4741,7 +4744,7 @@ async function Zn() {
4741
4744
  {
4742
4745
  const t = L.parse(s).root.replaceAll(":\\", "");
4743
4746
  try {
4744
- return (await Tt.promisify(kt)("wmic logicaldisk get name")).stdout.split(`\r
4747
+ return (await kt.promisify(Lt)("wmic logicaldisk get name")).stdout.split(`\r
4745
4748
  `).filter((r) => r.includes(":")).map((r) => r.trim().replaceAll(":", "")).map((r) => {
4746
4749
  const a = r == t;
4747
4750
  return {
@@ -4761,7 +4764,7 @@ async function Zn() {
4761
4764
  }
4762
4765
  }
4763
4766
  }
4764
- class nt {
4767
+ class rt {
4765
4768
  constructor(e, t, o, n, r, a, i) {
4766
4769
  this.logger = e, this.lsClient = t, this.storageIdToResourceId = o, this.signer = n, this.virtualStoragesMap = r, this.localProjectionsMap = a, this.openFileDialogCallback = i;
4767
4770
  }
@@ -4793,13 +4796,13 @@ class nt {
4793
4796
  * @private
4794
4797
  */
4795
4798
  async tryResolveLocalFileHandle(e) {
4796
- if (bt(e)) {
4797
- const t = xn(e), o = this.localProjectionsMap.get(t.storageId);
4799
+ if (Tt(e)) {
4800
+ const t = An(e), o = this.localProjectionsMap.get(t.storageId);
4798
4801
  if (!o)
4799
4802
  throw new Error(`Storage ${t.storageId} is not mounted locally.`);
4800
4803
  return b.join(o.localPath, t.path);
4801
4804
  } else {
4802
- const t = zn(e);
4805
+ const t = xn(e);
4803
4806
  this.signer.verify(
4804
4807
  t.localPath,
4805
4808
  t.pathSignature,
@@ -4816,13 +4819,13 @@ class nt {
4816
4819
  for (const o of this.localProjectionsMap.values())
4817
4820
  if (e.startsWith(o.localPath)) {
4818
4821
  const n = o.localPath === "" ? e : b.relative(o.localPath, e);
4819
- return ve(
4822
+ return ie(
4820
4823
  o.storageId,
4821
4824
  n
4822
4825
  );
4823
4826
  }
4824
4827
  const t = await m.stat(e, { bigint: !0 });
4825
- return Wn(
4828
+ return zn(
4826
4829
  e,
4827
4830
  this.signer,
4828
4831
  t.size,
@@ -4847,14 +4850,14 @@ class nt {
4847
4850
  return [...e, ...o];
4848
4851
  }
4849
4852
  async listFiles(e, t) {
4850
- const o = An(e);
4853
+ const o = Ne(e);
4851
4854
  if (o.isRemote)
4852
4855
  return {
4853
4856
  entries: (await this.lsClient.list(o, t)).items.map((i) => ({
4854
4857
  type: i.isDir ? "dir" : "file",
4855
4858
  name: i.name,
4856
4859
  fullPath: i.fullName,
4857
- handle: ve(o.name, i.fullName)
4860
+ handle: ie(o.name, i.fullName)
4858
4861
  }))
4859
4862
  };
4860
4863
  b.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && C(t);
@@ -4871,13 +4874,27 @@ class nt {
4871
4874
  }
4872
4875
  return { entries: r };
4873
4876
  }
4877
+ async listRemoteFilesWithAdditionalInfo(e, t) {
4878
+ const o = Ne(e);
4879
+ if (!o.isRemote)
4880
+ throw new Error(`Storage ${o.name} is not remote`);
4881
+ return {
4882
+ entries: (await this.lsClient.list(o, t)).items.map((r) => ({
4883
+ type: r.isDir ? "dir" : "file",
4884
+ name: r.name,
4885
+ fullPath: r.fullName,
4886
+ handle: ie(o.name, r.fullName),
4887
+ size: Number(r.size)
4888
+ }))
4889
+ };
4890
+ }
4874
4891
  async fileToImportHandle(e) {
4875
4892
  throw new Error(
4876
4893
  "Not implemented. This method must be implemented and intercepted in desktop preload script."
4877
4894
  );
4878
4895
  }
4879
4896
  static async init(e, t, o, n, r, a) {
4880
- const i = Xo(t, e);
4897
+ const i = Ko(t, e);
4881
4898
  a || (a = await Zn());
4882
4899
  for (const p of a) C(p.root);
4883
4900
  for (const p of n) p.localPath !== "" && C(p.localPath);
@@ -4886,7 +4903,7 @@ class nt {
4886
4903
  throw new Error(
4887
4904
  "Intersection between local projection storage ids and virtual storages names detected."
4888
4905
  );
4889
- return new nt(
4906
+ return new rt(
4890
4907
  e,
4891
4908
  i,
4892
4909
  await Qn(t),
@@ -4905,54 +4922,54 @@ async function Qn(s) {
4905
4922
  }
4906
4923
  function Xn(s) {
4907
4924
  return Object.fromEntries(
4908
- s.fields.filter((e) => e.type == "Dynamic" && lt(e.value)).map((e) => [e.name.substring(8), e.value])
4925
+ s.fields.filter((e) => e.type == "Dynamic" && ct(e.value)).map((e) => [e.name.substring(8), e.value])
4909
4926
  );
4910
4927
  }
4911
4928
  export {
4912
- ko as ClientDownload,
4913
- Qo as ClientLogs,
4914
- Oo as ClientLs,
4915
- ho as ClientProgress,
4916
- Gt as ClientUpload,
4929
+ Lo as ClientDownload,
4930
+ Xo as ClientLogs,
4931
+ Fo as ClientLs,
4932
+ uo as ClientProgress,
4933
+ Vt as ClientUpload,
4917
4934
  Zn as DefaultVirtualLocalStorages,
4918
4935
  Sr as DownloadBlobToURLDriver,
4919
4936
  Dr as DownloadDriver,
4920
- Br as DownloadUrlDriver,
4921
- gn as DownloadableBlobSnapshot,
4937
+ $r as DownloadUrlDriver,
4938
+ fn as DownloadableBlobSnapshot,
4922
4939
  Ur as ImportFileHandleData,
4923
- Ve as ImportFileHandleIndexData,
4940
+ qe as ImportFileHandleIndexData,
4924
4941
  q as ImportFileHandleUploadData,
4925
- rn as IndexResourceSnapshot,
4942
+ sn as IndexResourceSnapshot,
4926
4943
  Nr as LogsDriver,
4927
4944
  vr as LogsStreamDriver,
4928
- nt as LsDriver,
4929
- ze as MTimeError,
4930
- Ae as NetworkError,
4931
- Me as NoFileForUploading,
4932
- tn as OnDemandBlobResourceSnapshot,
4933
- xe as UnexpectedEOF,
4934
- be as UnknownStorageError,
4935
- dn as Updater,
4945
+ rt as LsDriver,
4946
+ xe as MTimeError,
4947
+ Me as NetworkError,
4948
+ He as NoFileForUploading,
4949
+ on as OnDemandBlobResourceSnapshot,
4950
+ Ae as UnexpectedEOF,
4951
+ Te as UnknownStorageError,
4952
+ hn as Updater,
4936
4953
  Ir as UploadDriver,
4937
- nn as UploadResourceSnapshot,
4938
- Ln as UploadTask,
4939
- ye as WrongLocalFileUrl,
4940
- Le as WrongResourceTypeError,
4954
+ rn as UploadResourceSnapshot,
4955
+ Pn as UploadTask,
4956
+ be as WrongLocalFileUrl,
4957
+ Pe as WrongResourceTypeError,
4941
4958
  Tr as createDownloadClient,
4942
4959
  kr as createLogsClient,
4943
- Xo as createLsFilesClient,
4960
+ Ko as createLsFilesClient,
4944
4961
  Pr as createUploadBlobClient,
4945
4962
  Lr as createUploadProgressClient,
4946
- Po as getFullPath,
4947
- on as getSize,
4948
- Dn as isMyUpload,
4949
- Re as isResourceWasDeletedError,
4950
- _n as makeBlobImportSnapshot,
4951
- fn as makeDownloadableBlobSnapshot,
4952
- Ro as newLocalStorageIdsToRoot,
4953
- Ye as nonRecoverableError,
4954
- Lo as parseLocalUrl,
4955
- Pn as uploadBlob,
4963
+ Uo as getFullPath,
4964
+ nn as getSize,
4965
+ Rn as isMyUpload,
4966
+ Se as isResourceWasDeletedError,
4967
+ En as makeBlobImportSnapshot,
4968
+ mn as makeDownloadableBlobSnapshot,
4969
+ So as newLocalStorageIdsToRoot,
4970
+ et as nonRecoverableError,
4971
+ Po as parseLocalUrl,
4972
+ Un as uploadBlob,
4956
4973
  C as validateAbsolute
4957
4974
  };
4958
4975
  //# sourceMappingURL=index.mjs.map