@formant/data-sdk 1.12.0 → 1.13.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.
@@ -1,15 +1,15 @@
1
- var re = Object.defineProperty;
2
- var se = (a, e, t) => e in a ? re(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var r = (a, e, t) => (se(a, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { decode as J } from "base-64";
5
- import * as l from "date-fns";
6
- import { startOfMinute as ce, addMinutes as de, roundToNearestMinutes as he, addSeconds as ue } from "date-fns";
1
+ var ce = Object.defineProperty;
2
+ var de = (a, e, t) => e in a ? ce(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var s = (a, e, t) => (de(a, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { decode as G } from "base-64";
5
+ import * as u from "date-fns";
6
+ import { startOfMinute as he, addMinutes as le, roundToNearestMinutes as ue, addSeconds as me } from "date-fns";
7
7
  import { RtcClient as A, SignalingPromiseClient as j } from "@formant/realtime-sdk";
8
- import { EventEmitter as le } from "eventemitter3";
9
- import { deflate as me } from "pako";
10
- import { fromByteArray as fe } from "base64-js";
11
- const we = "https://api.formant.io";
12
- function pe(a, e) {
8
+ import { EventEmitter as fe } from "eventemitter3";
9
+ import { deflate as we } from "pako";
10
+ import { fromByteArray as pe } from "base64-js";
11
+ const ye = "https://api.formant.io";
12
+ function ge(a, e) {
13
13
  try {
14
14
  if (e.get("formant_stage"))
15
15
  return "https://api-stage.formant.io";
@@ -30,31 +30,45 @@ function pe(a, e) {
30
30
  }
31
31
  } catch {
32
32
  }
33
- return typeof a < "u" && "FORMANT_API_URL" in a && typeof a.FORMANT_API_URL == "string" ? a.FORMANT_API_URL : we;
33
+ return typeof a < "u" && "FORMANT_API_URL" in a && typeof a.FORMANT_API_URL == "string" ? a.FORMANT_API_URL : ye;
34
34
  }
35
- const h = pe(
35
+ const h = ge(
36
36
  typeof window < "u" ? window : globalThis,
37
37
  new URLSearchParams(
38
38
  typeof window < "u" && window.location ? window.location.search : void 0
39
39
  )
40
40
  );
41
- class ye {
41
+ class x extends Error {
42
+ constructor(t) {
43
+ super("login failed");
44
+ s(this, "reason");
45
+ this.reason = t, this.name = "LoginFailureError", Object.setPrototypeOf(this, new.target.prototype);
46
+ }
47
+ }
48
+ class U extends Error {
49
+ constructor(t) {
50
+ super("login challenged");
51
+ s(this, "challenge");
52
+ this.challenge = t, this.name = "LoginChallengedError", Object.setPrototypeOf(this, new.target.prototype);
53
+ }
54
+ }
55
+ class ve {
42
56
  constructor({
43
57
  apiUrl: e,
44
58
  refreshAuthToken: t,
45
59
  addAccessTokenRefreshListener: n
46
60
  }) {
47
- r(this, "_refreshToken");
48
- r(this, "_isShareToken", !1);
49
- r(this, "_currentOrganization");
50
- r(this, "_currentUser");
51
- r(this, "_defaultDeviceId");
52
- r(this, "_token");
53
- r(this, "_waitingForAuth", /* @__PURE__ */ new Set());
54
- r(this, "_refreshTimer");
55
- r(this, "_apiUrl");
56
- r(this, "_refreshAuthToken");
57
- r(this, "_addAccessTokenRefreshListener");
61
+ s(this, "_refreshToken");
62
+ s(this, "_isShareToken", !1);
63
+ s(this, "_currentOrganization");
64
+ s(this, "_currentUser");
65
+ s(this, "_defaultDeviceId");
66
+ s(this, "_token");
67
+ s(this, "_waitingForAuth", /* @__PURE__ */ new Set());
68
+ s(this, "_refreshTimer");
69
+ s(this, "_apiUrl");
70
+ s(this, "_refreshAuthToken");
71
+ s(this, "_addAccessTokenRefreshListener");
58
72
  this._apiUrl = e, this._refreshAuthToken = t, this._addAccessTokenRefreshListener = n;
59
73
  }
60
74
  get token() {
@@ -81,32 +95,47 @@ class ye {
81
95
  get isShareToken() {
82
96
  return this._isShareToken;
83
97
  }
84
- async login(e, t) {
98
+ async login(e, t, n = {}) {
99
+ const { advanced: i = !1 } = n;
85
100
  try {
86
- const n = await fetch(`${this._apiUrl}/v1/admin/auth/login`, {
101
+ const o = await fetch(`${this._apiUrl}/v1/admin/auth/login`, {
87
102
  method: "POST",
88
103
  body: JSON.stringify({ email: e, password: t }),
89
104
  headers: {
90
105
  "Content-Type": "application/json"
91
106
  }
92
- }), i = await n.json();
93
- if (n.status !== 200)
94
- throw new Error(i.message);
107
+ }), c = await o.json();
108
+ if (o.status !== 200)
109
+ throw new x(c.message);
110
+ if ("challenge" in c)
111
+ throw new U(c.challenge);
112
+ const { authentication: d } = c;
95
113
  return await this.loginWithToken(
96
- i.authentication.accessToken,
97
- i.authentication.refreshToken
98
- ), i.authentication;
99
- } catch (n) {
100
- return console.error("login() failed", { err: n }), this._waitingForAuth.forEach((i) => i(!1)), this._waitingForAuth.clear(), Promise.reject(n);
114
+ d.accessToken,
115
+ d.refreshToken
116
+ ), i ? {
117
+ result: "success",
118
+ authentication: d
119
+ } : d;
120
+ } catch (o) {
121
+ if (i || console.error("login() failed", { err: o }), this._waitingForAuth.forEach((c) => c(!1)), this._waitingForAuth.clear(), !i)
122
+ throw o;
123
+ return o instanceof U ? {
124
+ result: "challenged",
125
+ challenge: o.challenge
126
+ } : {
127
+ result: "failure",
128
+ reason: o instanceof x ? o.reason : o instanceof Error ? o.message : String(o)
129
+ };
101
130
  }
102
131
  }
103
132
  async loginWithToken(e, t) {
104
133
  var i;
105
- const n = JSON.parse(J(e.split(".")[1]));
134
+ const n = JSON.parse(G(e.split(".")[1]));
106
135
  try {
107
- let s;
108
- if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (s = n.sub), n["formant:claims"] && n["formant:claims"].userId && (s = n["formant:claims"].userId), s && ((i = this._currentUser) == null ? void 0 : i.id) !== s) {
109
- const c = await fetch(`${this._apiUrl}/v1/admin/users/${s}`, {
136
+ let o;
137
+ if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (o = n.sub), n["formant:claims"] && n["formant:claims"].userId && (o = n["formant:claims"].userId), o && ((i = this._currentUser) == null ? void 0 : i.id) !== o) {
138
+ const c = await fetch(`${this._apiUrl}/v1/admin/users/${o}`, {
110
139
  method: "GET",
111
140
  headers: {
112
141
  "Content-Type": "application/json",
@@ -118,8 +147,8 @@ class ye {
118
147
  this._currentUser = d;
119
148
  }
120
149
  this._token = e, this._waitingForAuth.forEach((c) => c(!0));
121
- } catch (s) {
122
- console.error("loginWithToken() failed", { err: s }), this._waitingForAuth.forEach((c) => c(!1));
150
+ } catch (o) {
151
+ console.error("loginWithToken() failed", { err: o }), this._waitingForAuth.forEach((c) => c(!1));
123
152
  } finally {
124
153
  this._waitingForAuth.clear();
125
154
  }
@@ -232,7 +261,7 @@ function T(a) {
232
261
  throw new Error("cannot send message to non-existent parent");
233
262
  window.parent.postMessage(a, "*");
234
263
  }
235
- function V() {
264
+ function H() {
236
265
  const a = k();
237
266
  if (!a)
238
267
  throw new Error("No module context");
@@ -241,7 +270,7 @@ function V() {
241
270
  module: a
242
271
  });
243
272
  }
244
- function G(a) {
273
+ function F(a) {
245
274
  function e(t) {
246
275
  const n = t.data;
247
276
  n.type === "auth_token" && a(n.token);
@@ -250,40 +279,40 @@ function G(a) {
250
279
  window.removeEventListener("message", e);
251
280
  };
252
281
  }
253
- const o = new ye({
282
+ const r = new ve({
254
283
  apiUrl: h,
255
- refreshAuthToken: V,
256
- addAccessTokenRefreshListener: G
284
+ refreshAuthToken: H,
285
+ addAccessTokenRefreshListener: F
257
286
  });
258
- async function ge(a) {
287
+ async function Te(a) {
259
288
  return (await (await fetch(
260
289
  `${h}/v1/admin/module-configurations/${a}`,
261
290
  {
262
291
  headers: {
263
292
  "Content-Type": "application/json",
264
- Authorization: "Bearer " + o.token
293
+ Authorization: "Bearer " + r.token
265
294
  }
266
295
  }
267
296
  )).json()).configuration;
268
297
  }
269
- function ve() {
298
+ function Ce() {
270
299
  T({
271
300
  type: "hide_analytics_date_picker"
272
301
  });
273
302
  }
274
- function Te(a) {
303
+ function Se(a) {
275
304
  T({
276
305
  type: "go_to_device",
277
306
  deviceId: a
278
307
  });
279
308
  }
280
- function Ce(a) {
309
+ function Ee(a) {
281
310
  T({
282
311
  type: "go_to_time",
283
312
  time: a.getTime()
284
313
  });
285
314
  }
286
- function Se() {
315
+ function ke() {
287
316
  const a = k();
288
317
  if (!a)
289
318
  throw new Error("No module context");
@@ -292,7 +321,7 @@ function Se() {
292
321
  module: a
293
322
  });
294
323
  }
295
- function Ee(a, e) {
324
+ function Oe(a, e) {
296
325
  const t = k();
297
326
  if (!t)
298
327
  throw new Error("No module context");
@@ -303,7 +332,7 @@ function Ee(a, e) {
303
332
  data: e
304
333
  });
305
334
  }
306
- function ke(a, e) {
335
+ function Re(a, e) {
307
336
  const t = k();
308
337
  if (!t)
309
338
  throw new Error("No module context");
@@ -314,7 +343,7 @@ function ke(a, e) {
314
343
  after: e || 0
315
344
  });
316
345
  }
317
- function Oe(a) {
346
+ function Ae(a) {
318
347
  const e = k();
319
348
  if (!e)
320
349
  throw new Error("No module context");
@@ -324,10 +353,10 @@ function Oe(a) {
324
353
  menus: a
325
354
  });
326
355
  }
327
- function Re(a) {
356
+ function be(a) {
328
357
  T({ type: "show_message", message: a });
329
358
  }
330
- function Ae(a, e) {
359
+ function De(a, e) {
331
360
  const t = (n) => {
332
361
  const i = n.data;
333
362
  i.type === "channel_data" && i.channel === a && e({
@@ -337,21 +366,21 @@ function Ae(a, e) {
337
366
  };
338
367
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
339
368
  }
340
- function be(a) {
369
+ function je(a) {
341
370
  const e = (t) => {
342
371
  const n = t.data;
343
372
  n.type === "module_menu_item_clicked" && a(n.menu);
344
373
  };
345
374
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
346
375
  }
347
- function De(a) {
376
+ function Ne(a) {
348
377
  const e = (t) => {
349
378
  const n = t.data;
350
379
  n.type === "module_configuration" && a(n);
351
380
  };
352
381
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
353
382
  }
354
- function je(a) {
383
+ function Pe(a) {
355
384
  const e = k();
356
385
  e && T({ type: "request_module_data", module: e });
357
386
  const t = (n) => {
@@ -364,7 +393,7 @@ function je(a) {
364
393
  };
365
394
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
366
395
  }
367
- function Ne(a) {
396
+ function Le(a) {
368
397
  T({ type: "request_devices" });
369
398
  const e = (t) => {
370
399
  const n = t.data;
@@ -372,42 +401,42 @@ function Ne(a) {
372
401
  };
373
402
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
374
403
  }
375
- const Pe = 1, H = 1e3, F = 60 * H, W = 60 * F, L = 24 * W, Le = 7 * L, Ie = 30 * L, _e = 365 * L, I = {
376
- millisecond: Pe,
377
- second: H,
378
- minute: F,
379
- hour: W,
404
+ const Ie = 1, W = 1e3, K = 60 * W, Q = 60 * K, L = 24 * Q, _e = 7 * L, $e = 30 * L, ze = 365 * L, I = {
405
+ millisecond: Ie,
406
+ second: W,
407
+ minute: K,
408
+ hour: Q,
380
409
  day: L,
381
- week: Le,
382
- month: Ie,
383
- year: _e
410
+ week: _e,
411
+ month: $e,
412
+ year: ze
384
413
  };
385
- function $e(a, e) {
414
+ function Be(a, e) {
386
415
  return a.filter((t) => e.includes(t.type));
387
416
  }
388
- function ze(a, e, t) {
417
+ function Me(a, e, t) {
389
418
  const n = e.getTime(), i = t.getTime();
390
- return a.map((s) => ({
391
- ...s,
392
- points: s.points.filter(
419
+ return a.map((o) => ({
420
+ ...o,
421
+ points: o.points.filter(
393
422
  ([c]) => c >= n && c < i
394
423
  )
395
- })).filter(({ points: s }) => s.length > 0);
424
+ })).filter(({ points: o }) => o.length > 0);
396
425
  }
397
- class x {
426
+ class J {
398
427
  constructor({
399
428
  capacity: e,
400
429
  timeout: t
401
430
  } = {}) {
402
- r(this, "entries", /* @__PURE__ */ new Map());
403
- r(this, "metadata", /* @__PURE__ */ new Map());
404
- r(this, "capacity");
405
- r(this, "timeout");
431
+ s(this, "entries", /* @__PURE__ */ new Map());
432
+ s(this, "metadata", /* @__PURE__ */ new Map());
433
+ s(this, "capacity");
434
+ s(this, "timeout");
406
435
  this.capacity = e || 1e4, this.timeout = t || I.minute;
407
436
  }
408
437
  get(e, t) {
409
- const n = this.keyToCacheKey(e), i = this.entries.get(n), s = this.metadata.get(n);
410
- return (i === void 0 || s && (s == null ? void 0 : s.expiration.getTime()) < Date.now()) && !(s != null && s.generating) && t && this.generate(e, t()), i === void 0 && s && s.lastValue !== void 0 ? s.lastValue : i;
438
+ const n = this.keyToCacheKey(e), i = this.entries.get(n), o = this.metadata.get(n);
439
+ return (i === void 0 || o && (o == null ? void 0 : o.expiration.getTime()) < Date.now()) && !(o != null && o.generating) && t && this.generate(e, t()), i === void 0 && o && o.lastValue !== void 0 ? o.lastValue : i;
411
440
  }
412
441
  set(e, t) {
413
442
  const n = this.keyToCacheKey(e);
@@ -430,7 +459,7 @@ class x {
430
459
  if (this.metadata.size < 1)
431
460
  return;
432
461
  const [e] = [...this.metadata.entries()].reduce(
433
- ([t, n], [i, s]) => s.expiration.getTime() < n.expiration.getTime() ? [i, s] : [t, n]
462
+ ([t, n], [i, o]) => o.expiration.getTime() < n.expiration.getTime() ? [i, o] : [t, n]
434
463
  );
435
464
  this.clearKey(e);
436
465
  }
@@ -441,53 +470,53 @@ class x {
441
470
  generating: !0,
442
471
  expiration: new Date(Date.now() + this.timeout)
443
472
  }), setTimeout(() => {
444
- t.then((s) => {
473
+ t.then((o) => {
445
474
  const c = this.metadata.get(n);
446
- !(c != null && c.generating) || this.set(e, s);
475
+ !(c != null && c.generating) || this.set(e, o);
447
476
  });
448
477
  }, 0);
449
478
  }
450
479
  }
451
480
  async function _(a) {
452
- if (!o.token)
481
+ if (!r.token)
453
482
  throw new Error("Not authenticated");
454
483
  return (await (await fetch(`${h}/v1/queries/queries`, {
455
484
  method: "POST",
456
485
  body: JSON.stringify(a),
457
486
  headers: {
458
487
  "Content-Type": "application/json",
459
- Authorization: "Bearer " + o.token
488
+ Authorization: "Bearer " + r.token
460
489
  }
461
490
  })).json()).items;
462
491
  }
463
- class Be {
492
+ class qe {
464
493
  constructor() {
465
- r(this, "queryStoreCache", new x({
494
+ s(this, "queryStoreCache", new J({
466
495
  capacity: 1e4,
467
496
  timeout: 20 * I.second
468
497
  }));
469
- r(this, "liveQueryStoreCache", new x({
498
+ s(this, "liveQueryStoreCache", new J({
470
499
  capacity: 1e4,
471
500
  timeout: 200 * I.millisecond
472
501
  }));
473
502
  }
474
- moduleQuery(e, t, n, i, s, c = !1) {
503
+ moduleQuery(e, t, n, i, o, c = !1) {
475
504
  const d = {
476
505
  ...e,
477
506
  names: [...t],
478
507
  types: [...n]
479
- }, y = this.query(d, i, s, c);
480
- return y === void 0 || y === "too much data" ? y : $e(y, n);
508
+ }, y = this.query(d, i, o, c);
509
+ return y === void 0 || y === "too much data" ? y : Be(y, n);
481
510
  }
482
511
  query(e, t, n, i = !1) {
483
- const s = {
512
+ const o = {
484
513
  ...e,
485
- start: ce(t).toISOString(),
486
- end: i ? n.toISOString() : de(he(n), 1).toISOString(),
514
+ start: he(t).toISOString(),
515
+ end: i ? n.toISOString() : le(ue(n), 1).toISOString(),
487
516
  latestOnly: i
488
- }, c = n > ue(/* @__PURE__ */ new Date(), -20);
517
+ }, c = n > me(/* @__PURE__ */ new Date(), -20);
489
518
  let d;
490
- return c ? d = this.liveQueryCache(s) : d = this.queryCache(s), !d || d === "too much data" || i ? d : ze(d, t, n);
519
+ return c ? d = this.liveQueryCache(o) : d = this.queryCache(o), !d || d === "too much data" || i ? d : Me(d, t, n);
491
520
  }
492
521
  queryCache(e) {
493
522
  return this.queryStoreCache.get(e, async () => {
@@ -508,14 +537,14 @@ class Be {
508
537
  });
509
538
  }
510
539
  }
511
- const Me = new Be();
512
- function qe(a, e, t) {
540
+ const xe = new qe();
541
+ function Ue(a, e, t) {
513
542
  const n = (i) => {
514
- const s = i.data;
515
- if (s.type === "module_data") {
516
- const { start: c, end: d } = s.queryRange;
543
+ const o = i.data;
544
+ if (o.type === "module_data") {
545
+ const { start: c, end: d } = o.queryRange;
517
546
  t(
518
- Me.moduleQuery(
547
+ xe.moduleQuery(
519
548
  {},
520
549
  a,
521
550
  e,
@@ -528,7 +557,7 @@ function qe(a, e, t) {
528
557
  };
529
558
  return window.addEventListener("message", n), () => window.removeEventListener("message", n);
530
559
  }
531
- async function xe(a, e, t) {
560
+ async function Je(a, e, t) {
532
561
  return new Promise((n) => {
533
562
  T({
534
563
  type: "request_date",
@@ -536,14 +565,14 @@ async function xe(a, e, t) {
536
565
  maxTime: t,
537
566
  time: a
538
567
  });
539
- const i = (s) => {
540
- const c = s.data;
568
+ const i = (o) => {
569
+ const c = o.data;
541
570
  c.type === "date_response" && (window.removeEventListener("message", i), n(c.data));
542
571
  };
543
572
  window.addEventListener("message", i);
544
573
  });
545
574
  }
546
- async function Ue(a, e) {
575
+ async function Ve(a, e) {
547
576
  return new Promise((t) => {
548
577
  const n = Math.random().toString();
549
578
  T({
@@ -553,8 +582,8 @@ async function Ue(a, e) {
553
582
  okText: e == null ? void 0 : e.okText,
554
583
  cancelText: e == null ? void 0 : e.cancelText
555
584
  });
556
- const i = (s) => {
557
- const c = s.data;
585
+ const i = (o) => {
586
+ const c = o.data;
558
587
  c.type === "prompt_response" && c.promptId === n && t(c.data), window.removeEventListener("message", i);
559
588
  };
560
589
  window.addEventListener("message", i);
@@ -569,7 +598,7 @@ const q = class {
569
598
  typeof window < "u" && window.location && (e = new URLSearchParams(window.location.search));
570
599
  const t = e.get("configuration");
571
600
  if (!(t === null || t.trim() === ""))
572
- return ge(t.trim());
601
+ return Te(t.trim());
573
602
  }
574
603
  static get isOnline() {
575
604
  return q._isOnline;
@@ -586,12 +615,12 @@ const q = class {
586
615
  const i = setTimeout(
587
616
  () => n(new Error("deadline expired: took too long")),
588
617
  e
589
- ), s = (c) => {
590
- window.removeEventListener("message", s), clearTimeout(i);
618
+ ), o = (c) => {
619
+ window.removeEventListener("message", o), clearTimeout(i);
591
620
  const { data: d } = c;
592
621
  d.type === "formant_online" && (this._isOnline = d.online, t(d.online));
593
622
  };
594
- window.addEventListener("message", s), T({ type: "formant_online" });
623
+ window.addEventListener("message", o), T({ type: "formant_online" });
595
624
  });
596
625
  }
597
626
  static waitForConnection(e = 5e3) {
@@ -600,18 +629,18 @@ const q = class {
600
629
  setTimeout(() => {
601
630
  t = !0, d(new Error("deadline expired: took too long"));
602
631
  }, e);
603
- }), i = (c) => new Promise((d) => setTimeout(d, c)), s = async () => {
632
+ }), i = (c) => new Promise((d) => setTimeout(d, c)), o = async () => {
604
633
  for (await i(50); !t && !(this.isOnline || await this.checkConnection); )
605
634
  await i(500);
606
635
  };
607
- return Promise.race([n, s()]);
636
+ return Promise.race([n, o()]);
608
637
  }
609
638
  };
610
639
  let g = q;
611
- r(g, "getCurrentModuleContext", k), // senders
612
- r(g, "disableAnalyticsBottomBar", ve), r(g, "goToDevice", Te), r(g, "goToTime", Ce), r(g, "refreshAuthToken", V), r(g, "requestModuleData", Se), r(g, "sendChannelData", Ee), r(g, "setModuleDateTimeRange", ke), r(g, "setupModuleMenus", Oe), r(g, "showMessage", Re), // listeners
613
- r(g, "addAccessTokenRefreshListener", G), r(g, "addChannelDataListener", Ae), r(g, "addMenuListener", be), r(g, "addModuleConfigurationListener", De), r(g, "addModuleDataListener", je), r(g, "addOverviewDeviceListener", Ne), r(g, "addStreamListener", qe), // bidirectional
614
- r(g, "getDate", xe), r(g, "prompt", Ue), r(g, "_isOnline", null);
640
+ s(g, "getCurrentModuleContext", k), // senders
641
+ s(g, "disableAnalyticsBottomBar", Ce), s(g, "goToDevice", Se), s(g, "goToTime", Ee), s(g, "refreshAuthToken", H), s(g, "requestModuleData", ke), s(g, "sendChannelData", Oe), s(g, "setModuleDateTimeRange", Re), s(g, "setupModuleMenus", Ae), s(g, "showMessage", be), // listeners
642
+ s(g, "addAccessTokenRefreshListener", F), s(g, "addChannelDataListener", De), s(g, "addMenuListener", je), s(g, "addModuleConfigurationListener", Ne), s(g, "addModuleDataListener", Pe), s(g, "addOverviewDeviceListener", Le), s(g, "addStreamListener", Ue), // bidirectional
643
+ s(g, "getDate", Je), s(g, "prompt", Ve), s(g, "_isOnline", null);
615
644
  function f(a, e) {
616
645
  if (a !== void 0)
617
646
  return a;
@@ -623,7 +652,7 @@ const p = {
623
652
  PORT_FORWARD: 2,
624
653
  OBSERVE: 3,
625
654
  HEADLESS: 4
626
- }, Xt = {
655
+ }, Zt = {
627
656
  ...p,
628
657
  Unknown: p.UNKNOWN,
629
658
  Teleop: p.TELEOP,
@@ -636,26 +665,26 @@ const p = {
636
665
  observe: p.OBSERVE,
637
666
  headless: p.HEADLESS
638
667
  }, O = Symbol("RtcClientPool.instance");
639
- var Jt;
668
+ var Gt;
640
669
  class N {
641
670
  constructor(e) {
642
- r(this, Jt, null);
643
- r(this, "createClient");
644
- r(this, "ttlMs");
645
- r(this, "proxyHandler");
646
- r(this, "proxyReceivers", /* @__PURE__ */ new Map());
647
- r(this, "teardownTimeout", null);
648
- r(this, "dispatch", (e, t) => {
671
+ s(this, Gt, null);
672
+ s(this, "createClient");
673
+ s(this, "ttlMs");
674
+ s(this, "proxyHandler");
675
+ s(this, "proxyReceivers", /* @__PURE__ */ new Map());
676
+ s(this, "teardownTimeout", null);
677
+ s(this, "dispatch", (e, t) => {
649
678
  this.proxyReceivers.forEach((n) => n == null ? void 0 : n(e, t));
650
679
  });
651
680
  const { createClient: t, ttlMs: n = 0 } = e;
652
681
  this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
653
- get: (i, s, c) => {
654
- switch (s) {
682
+ get: (i, o, c) => {
683
+ switch (o) {
655
684
  case "shutdown":
656
685
  return () => this.releaseInstance(c);
657
686
  default:
658
- return Reflect.get(i, s, c);
687
+ return Reflect.get(i, o, c);
659
688
  }
660
689
  }
661
690
  };
@@ -694,8 +723,8 @@ class N {
694
723
  }, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
695
724
  }
696
725
  }
697
- Jt = O;
698
- const P = async () => f(o.token, "Realtime when user isn't authorized"), R = {
726
+ Gt = O;
727
+ const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
699
728
  [p.UNKNOWN]: new N({
700
729
  ttlMs: 2500,
701
730
  createClient: (a) => new A({
@@ -741,20 +770,20 @@ const P = async () => f(o.token, "Realtime when user isn't authorized"), R = {
741
770
  receive: a
742
771
  })
743
772
  })
744
- }, Je = {
773
+ }, Ge = {
745
774
  ...R,
746
775
  unknown: R[p.UNKNOWN],
747
776
  teleop: R[p.TELEOP],
748
777
  portForward: R[p.PORT_FORWARD],
749
778
  observe: R[p.OBSERVE],
750
779
  headless: R[p.HEADLESS]
751
- }, $ = R[p.TELEOP], Ve = (a) => {
780
+ }, $ = R[p.TELEOP], He = (a) => {
752
781
  const { sessionType: e } = a;
753
- return e ? Je[e] : $;
782
+ return e ? Ge[e] : $;
754
783
  };
755
- class Ge {
784
+ class Fe {
756
785
  constructor(e) {
757
- r(this, "token");
786
+ s(this, "token");
758
787
  this.captureSession = e;
759
788
  }
760
789
  async ingestJSON(e) {
@@ -785,17 +814,17 @@ class Ge {
785
814
  function b(a) {
786
815
  return new Promise((e) => setTimeout(e, a));
787
816
  }
788
- const He = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
789
- class Fe {
817
+ const We = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
818
+ class Ke {
790
819
  constructor(e) {
791
- r(this, "ready", !1);
792
- r(this, "listeners", []);
793
- r(this, "openListeners", []);
794
- r(this, "closeListeners", []);
795
- r(this, "errorListeners", []);
796
- r(this, "binaryListeners", []);
797
- r(this, "error");
798
- r(this, "decoder", new TextDecoder());
820
+ s(this, "ready", !1);
821
+ s(this, "listeners", []);
822
+ s(this, "openListeners", []);
823
+ s(this, "closeListeners", []);
824
+ s(this, "errorListeners", []);
825
+ s(this, "binaryListeners", []);
826
+ s(this, "error");
827
+ s(this, "decoder", new TextDecoder());
799
828
  this.dataChannel = e, this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = () => {
800
829
  this.setReady();
801
830
  }, this.dataChannel.onclose = () => {
@@ -804,8 +833,8 @@ class Fe {
804
833
  console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
805
834
  }, this.dataChannel.onmessage = (t) => {
806
835
  this.listeners.forEach((n) => {
807
- const i = new Uint8Array(t.data), s = this.decoder.decode(i);
808
- n(s);
836
+ const i = new Uint8Array(t.data), o = this.decoder.decode(i);
837
+ n(o);
809
838
  }), this.binaryListeners.forEach((n) => {
810
839
  n(new Uint8Array(t.data));
811
840
  });
@@ -872,10 +901,10 @@ class Fe {
872
901
  this.binaryListeners.splice(t, 1);
873
902
  }
874
903
  }
875
- class We {
904
+ class Qe {
876
905
  constructor(e, t) {
877
- r(this, "currentListeners", []);
878
- r(this, "onRealtimeMessage", (e, t) => {
906
+ s(this, "currentListeners", []);
907
+ s(this, "onRealtimeMessage", (e, t) => {
879
908
  t.payload.jointState && this.currentListeners.forEach((n) => {
880
909
  t.payload.jointState && n(t.payload.jointState);
881
910
  });
@@ -896,10 +925,10 @@ class We {
896
925
  this.currentListeners.push(e);
897
926
  }
898
927
  }
899
- class K {
928
+ class X {
900
929
  constructor(e, t, n) {
901
- r(this, "channel");
902
- r(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
930
+ s(this, "channel");
931
+ s(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
903
932
  this.device = e, this.channel_name = t, this.timeout = n;
904
933
  }
905
934
  addOpenListener(e) {
@@ -927,11 +956,11 @@ class K {
927
956
  );
928
957
  }
929
958
  }
930
- class Ke extends K {
959
+ class Xe extends X {
931
960
  constructor() {
932
961
  super(...arguments);
933
- r(this, "RESPONSE_SUCCESS_BYTE", 0);
934
- r(this, "decoder", new TextDecoder());
962
+ s(this, "RESPONSE_SUCCESS_BYTE", 0);
963
+ s(this, "decoder", new TextDecoder());
935
964
  }
936
965
  /*
937
966
  Request binary payload layout:
@@ -953,21 +982,21 @@ class Ke extends K {
953
982
  const i = t.slice(0, 16).toString();
954
983
  if (i.length === 0)
955
984
  throw new Error("Invalid response");
956
- const s = t.slice(16);
957
- if (s.length === 0)
985
+ const o = t.slice(16);
986
+ if (o.length === 0)
958
987
  throw new Error("Invalid response");
959
- this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, s);
988
+ this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, o);
960
989
  });
961
990
  }
962
991
  async request(t) {
963
992
  if (this.channel || await this.initialize(), !this.channel)
964
993
  throw new Error("Failed to create channel");
965
- const { channel: n, requestIdToResponseMap: i, timeout: s } = this;
994
+ const { channel: n, requestIdToResponseMap: i, timeout: o } = this;
966
995
  await n.waitTilReady();
967
996
  const c = this.generateBinaryId(), d = c.toString();
968
997
  i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
969
998
  const y = (/* @__PURE__ */ new Date()).getTime();
970
- for (; (/* @__PURE__ */ new Date()).getTime() < y + s; )
999
+ for (; (/* @__PURE__ */ new Date()).getTime() < y + o; )
971
1000
  if (await b(50), i.has(d)) {
972
1001
  const m = i.get(d);
973
1002
  if (m !== !0) {
@@ -983,20 +1012,20 @@ class Ke extends K {
983
1012
  }
984
1013
  throw i.delete(d), console.error({
985
1014
  name: "TimeoutError",
986
- message: `Request timed out after ${s / 1e3} seconds`
1015
+ message: `Request timed out after ${o / 1e3} seconds`
987
1016
  }), new Error("Binary request data channel request timed out");
988
1017
  }
989
1018
  }
990
- class Qe extends K {
1019
+ class Ye extends X {
991
1020
  generateTextId() {
992
1021
  return Math.random().toString(36).substring(2) + "-" + Math.random().toString(36).substring(2);
993
1022
  }
994
1023
  async initialize() {
995
1024
  this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
996
- const t = JSON.parse(e), { id: n, data: i, error: s } = t;
1025
+ const t = JSON.parse(e), { id: n, data: i, error: o } = t;
997
1026
  if (!n)
998
1027
  throw new Error("Invalid response");
999
- if (!i && !s)
1028
+ if (!i && !o)
1000
1029
  throw new Error("Invalid response");
1001
1030
  this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
1002
1031
  });
@@ -1006,19 +1035,19 @@ class Qe extends K {
1006
1035
  throw new Error("Failed to create channel");
1007
1036
  const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
1008
1037
  await t.waitTilReady();
1009
- const s = this.generateTextId();
1010
- n.set(s, !0), t.send(
1038
+ const o = this.generateTextId();
1039
+ n.set(o, !0), t.send(
1011
1040
  JSON.stringify({
1012
- id: s,
1041
+ id: o,
1013
1042
  data: e
1014
1043
  })
1015
1044
  );
1016
1045
  const c = (/* @__PURE__ */ new Date()).getTime();
1017
1046
  for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
1018
- if (await b(50), n.has(s)) {
1019
- const d = n.get(s);
1047
+ if (await b(50), n.has(o)) {
1048
+ const d = n.get(o);
1020
1049
  if (d !== !0) {
1021
- n.delete(s);
1050
+ n.delete(o);
1022
1051
  const { data: y, error: m } = d;
1023
1052
  if (y)
1024
1053
  return y;
@@ -1029,20 +1058,20 @@ class Qe extends K {
1029
1058
  }), new Error("Text request datachannel adapter error");
1030
1059
  }
1031
1060
  }
1032
- throw n.delete(s), console.error({
1061
+ throw n.delete(o), console.error({
1033
1062
  name: "TimeoutError",
1034
1063
  message: `Request timed out after ${i / 1e3} seconds`
1035
1064
  }), new Error("Text request datachannel request timed out");
1036
1065
  }
1037
1066
  }
1038
- class Q extends le {
1067
+ class Y extends fe {
1039
1068
  constructor() {
1040
1069
  super(...arguments);
1041
- r(this, "rtcClient");
1042
- r(this, "remoteDevicePeerId", null);
1043
- r(this, "realtimeListeners", []);
1044
- r(this, "connectionMonitorInterval");
1045
- r(this, "handleMessage", (t, n) => {
1070
+ s(this, "rtcClient");
1071
+ s(this, "remoteDevicePeerId", null);
1072
+ s(this, "realtimeListeners", []);
1073
+ s(this, "connectionMonitorInterval");
1074
+ s(this, "handleMessage", (t, n) => {
1046
1075
  this.realtimeListeners.forEach((i) => i(t, n));
1047
1076
  });
1048
1077
  }
@@ -1076,7 +1105,7 @@ class Q extends le {
1076
1105
  const t = await this.getConfiguration(), n = [];
1077
1106
  for (const i of t.teleop.rosStreams ?? [])
1078
1107
  i.topicType == "sensor_msgs/JointState" && n.push(
1079
- new We(this, {
1108
+ new Qe(this, {
1080
1109
  currentJointStateStream: { name: i.topicName },
1081
1110
  plannedJointStateStream: i.plannedTopic ? { name: i.plannedTopic } : void 0,
1082
1111
  planValidStream: i.planValidTopic ? { name: i.planValidTopic } : void 0,
@@ -1089,13 +1118,13 @@ class Q extends le {
1089
1118
  return n;
1090
1119
  }
1091
1120
  async getRealtimeVideoStreams() {
1092
- var i, s, c;
1121
+ var i, o, c;
1093
1122
  const t = await this.getConfiguration(), n = [];
1094
1123
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1095
1124
  d.rtcStreamType === "h264-video-frame" && n.push({
1096
1125
  name: d.name
1097
1126
  });
1098
- for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
1127
+ for (const d of ((o = t.teleop) == null ? void 0 : o.rosStreams) ?? [])
1099
1128
  d.topicType == "formant/H264VideoFrame" && n.push({
1100
1129
  name: d.topicName
1101
1130
  }), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
@@ -1108,10 +1137,10 @@ class Q extends le {
1108
1137
  return n;
1109
1138
  }
1110
1139
  createCustomRequestDataChannel(t, n = 3e3) {
1111
- return new Qe(this, t, n);
1140
+ return new Ye(this, t, n);
1112
1141
  }
1113
1142
  createCustomBinaryRequestDataChannel(t, n = 3e3) {
1114
- return new Ke(this, t, n);
1143
+ return new Xe(this, t, n);
1115
1144
  }
1116
1145
  async startListeningToRealtimeVideo(t) {
1117
1146
  const n = f(
@@ -1183,8 +1212,8 @@ class Q extends le {
1183
1212
  const i = f(
1184
1213
  this.rtcClient,
1185
1214
  "Realtime connection has not been started"
1186
- ), s = await this.getRemotePeer();
1187
- i.controlRemoteStream(f(s).id, {
1215
+ ), o = await this.getRemotePeer();
1216
+ i.controlRemoteStream(f(o).id, {
1188
1217
  streamName: t,
1189
1218
  setAudioFormat: n
1190
1219
  });
@@ -1193,9 +1222,9 @@ class Q extends le {
1193
1222
  const i = f(
1194
1223
  this.rtcClient,
1195
1224
  "Realtime connection has not been started"
1196
- ), s = await this.getRemotePeer(), c = await new Promise((d) => {
1225
+ ), o = await this.getRemotePeer(), c = await new Promise((d) => {
1197
1226
  i.createCustomDataChannel(
1198
- f(s).id,
1227
+ f(o).id,
1199
1228
  t,
1200
1229
  {
1201
1230
  ordered: !0,
@@ -1203,7 +1232,7 @@ class Q extends le {
1203
1232
  },
1204
1233
  !1,
1205
1234
  (y, m) => {
1206
- const w = new Fe(m);
1235
+ const w = new Ke(m);
1207
1236
  d(w);
1208
1237
  }
1209
1238
  );
@@ -1216,17 +1245,17 @@ class Q extends le {
1216
1245
  const i = f(
1217
1246
  this.rtcClient,
1218
1247
  "Realtime connection has not been started"
1219
- ), s = await this.getRemotePeer();
1220
- i.send(f(s).id, t, n);
1248
+ ), o = await this.getRemotePeer();
1249
+ i.send(f(o).id, t, n);
1221
1250
  }
1222
1251
  async getRealtimeAudioStreams() {
1223
- var i, s, c;
1252
+ var i, o, c;
1224
1253
  const t = await this.getConfiguration(), n = [];
1225
1254
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1226
1255
  d.rtcStreamType === "audio-chunk" && n.push({
1227
1256
  name: d.name
1228
1257
  });
1229
- for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
1258
+ for (const d of ((o = t.teleop) == null ? void 0 : o.rosStreams) ?? [])
1230
1259
  d.topicType == "audio_common_msgs/AudioData" && n.push({
1231
1260
  name: d.topicName
1232
1261
  });
@@ -1237,27 +1266,27 @@ class Q extends le {
1237
1266
  return n;
1238
1267
  }
1239
1268
  }
1240
- const Xe = new TextEncoder();
1269
+ const Ze = new TextEncoder();
1241
1270
  new TextDecoder();
1242
- function Ye(a) {
1243
- const e = JSON.stringify(a), t = Xe.encode(e), n = me(t);
1244
- return fe(n);
1271
+ function et(a) {
1272
+ const e = JSON.stringify(a), t = Ze.encode(e), n = we(t);
1273
+ return pe(n);
1245
1274
  }
1246
- async function X() {
1247
- if (!o.token)
1275
+ async function Z() {
1276
+ if (!r.token)
1248
1277
  throw new Error("Not authenticated");
1249
1278
  return (await (await fetch(`${h}/v1/admin/views`, {
1250
1279
  method: "GET",
1251
1280
  headers: {
1252
1281
  "Content-Type": "application/json",
1253
- Authorization: "Bearer " + o.token
1282
+ Authorization: "Bearer " + r.token
1254
1283
  }
1255
1284
  })).json()).items;
1256
1285
  }
1257
- async function Y(a, e) {
1258
- if (!o.token)
1286
+ async function ee(a, e) {
1287
+ if (!r.token)
1259
1288
  throw new Error("Not authenticated");
1260
- const n = (await X()).filter((d) => d.name === e);
1289
+ const n = (await Z()).filter((d) => d.name === e);
1261
1290
  if (n.length === 0)
1262
1291
  return console.warn("View does not exist or it is misspell"), null;
1263
1292
  const i = await fetch(`${h}/v1/admin/shares`, {
@@ -1265,14 +1294,14 @@ async function Y(a, e) {
1265
1294
  body: JSON.stringify(a),
1266
1295
  headers: {
1267
1296
  "Content-Type": "application/json",
1268
- Authorization: "Bearer " + o.token
1297
+ Authorization: "Bearer " + r.token
1269
1298
  }
1270
- }), s = h.replace("api", "app"), { code: c } = await i.json();
1271
- return `${s}/shares/${c}#${Ye({
1299
+ }), o = h.replace("api", "app"), { code: c } = await i.json();
1300
+ return `${o}/shares/${c}#${et({
1272
1301
  viewId: n[0].id
1273
1302
  })}`;
1274
1303
  }
1275
- const Yt = [
1304
+ const en = [
1276
1305
  "day",
1277
1306
  "week",
1278
1307
  "month",
@@ -1280,92 +1309,92 @@ const Yt = [
1280
1309
  "hour",
1281
1310
  "minute",
1282
1311
  "quarter"
1283
- ], Zt = [
1312
+ ], tn = [
1284
1313
  "interval",
1285
1314
  "start",
1286
1315
  "end",
1287
1316
  "sub",
1288
1317
  "get"
1289
1318
  ];
1290
- function Ze(a) {
1319
+ function tt(a) {
1291
1320
  return a.count < 2 ? 0 : a.sumOfSquares / (a.count - 1);
1292
1321
  }
1293
- function et(a) {
1294
- return Math.sqrt(Ze(a));
1322
+ function nt(a) {
1323
+ return Math.sqrt(tt(a));
1295
1324
  }
1296
- function tt(a) {
1325
+ function at(a) {
1297
1326
  return a.max;
1298
1327
  }
1299
- function nt(a) {
1328
+ function it(a) {
1300
1329
  return a.min;
1301
1330
  }
1302
- function at(a) {
1331
+ function ot(a) {
1303
1332
  return a.count === 0 ? -1 : a.sum / a.count;
1304
1333
  }
1305
- function it(a) {
1334
+ function rt(a) {
1306
1335
  return a.sum;
1307
1336
  }
1308
- function ot(a) {
1337
+ function st(a) {
1309
1338
  return a.count;
1310
1339
  }
1311
- const en = {
1312
- min: nt,
1313
- max: tt,
1314
- "standard deviation": et,
1315
- average: at,
1316
- sum: it,
1317
- count: ot
1318
- }, Z = {
1340
+ const nn = {
1341
+ min: it,
1342
+ max: at,
1343
+ "standard deviation": nt,
1344
+ average: ot,
1345
+ sum: rt,
1346
+ count: st
1347
+ }, te = {
1319
1348
  day: {
1320
- interval: l.eachDayOfInterval,
1321
- start: l.startOfDay,
1322
- end: l.endOfDay,
1323
- sub: l.subDays,
1324
- get: l.getDay
1349
+ interval: u.eachDayOfInterval,
1350
+ start: u.startOfDay,
1351
+ end: u.endOfDay,
1352
+ sub: u.subDays,
1353
+ get: u.getDay
1325
1354
  },
1326
1355
  week: {
1327
- interval: l.eachWeekOfInterval,
1328
- start: l.startOfWeek,
1329
- end: l.endOfWeek,
1330
- sub: l.subWeeks,
1331
- get: l.getWeek
1356
+ interval: u.eachWeekOfInterval,
1357
+ start: u.startOfWeek,
1358
+ end: u.endOfWeek,
1359
+ sub: u.subWeeks,
1360
+ get: u.getWeek
1332
1361
  },
1333
1362
  month: {
1334
- interval: l.eachMonthOfInterval,
1335
- start: l.startOfMonth,
1336
- end: l.endOfMonth,
1337
- sub: l.subMonths,
1338
- get: l.getMonth
1363
+ interval: u.eachMonthOfInterval,
1364
+ start: u.startOfMonth,
1365
+ end: u.endOfMonth,
1366
+ sub: u.subMonths,
1367
+ get: u.getMonth
1339
1368
  },
1340
1369
  year: {
1341
- interval: l.eachYearOfInterval,
1342
- start: l.startOfYear,
1343
- end: l.endOfYear,
1344
- sub: l.subYears,
1345
- get: l.getYear
1370
+ interval: u.eachYearOfInterval,
1371
+ start: u.startOfYear,
1372
+ end: u.endOfYear,
1373
+ sub: u.subYears,
1374
+ get: u.getYear
1346
1375
  },
1347
1376
  hour: {
1348
- interval: l.eachHourOfInterval,
1349
- start: l.startOfHour,
1350
- end: l.endOfHour,
1351
- sub: l.subHours,
1352
- get: l.getHours
1377
+ interval: u.eachHourOfInterval,
1378
+ start: u.startOfHour,
1379
+ end: u.endOfHour,
1380
+ sub: u.subHours,
1381
+ get: u.getHours
1353
1382
  },
1354
1383
  minute: {
1355
- interval: l.eachMinuteOfInterval,
1356
- start: l.startOfMinute,
1357
- end: l.endOfMinute,
1358
- sub: l.subMinutes,
1359
- get: l.getMinutes
1384
+ interval: u.eachMinuteOfInterval,
1385
+ start: u.startOfMinute,
1386
+ end: u.endOfMinute,
1387
+ sub: u.subMinutes,
1388
+ get: u.getMinutes
1360
1389
  },
1361
1390
  quarter: {
1362
- interval: l.eachQuarterOfInterval,
1363
- start: l.startOfQuarter,
1364
- end: l.endOfQuarter,
1365
- sub: l.subQuarters,
1366
- get: l.getQuarter
1391
+ interval: u.eachQuarterOfInterval,
1392
+ start: u.startOfQuarter,
1393
+ end: u.endOfQuarter,
1394
+ sub: u.subQuarters,
1395
+ get: u.getQuarter
1367
1396
  }
1368
- }, rt = (a, e) => (
1397
+ }, ct = (a, e) => (
1369
1398
  // FIXME this doesn't work for *a lot* locales, other than en-US
1370
1399
  // en-GB: 'dd/mm/YYYY'
1371
1400
  // ja-jp: 'YYYY/mm/dd'
@@ -1373,28 +1402,28 @@ const en = {
1373
1402
  a.split("/")[0] + "/" + a.split("/")[1] + "–" + e.split("/")[0] + "/" + e.split("/")[1]
1374
1403
  );
1375
1404
  async function z(a) {
1376
- if (!o.token)
1405
+ if (!r.token)
1377
1406
  throw new Error("Not authenticated");
1378
1407
  return (await (await fetch(`${h}/v1/admin/events/query`, {
1379
1408
  method: "POST",
1380
1409
  body: JSON.stringify(a),
1381
1410
  headers: {
1382
1411
  "Content-Type": "application/json",
1383
- Authorization: "Bearer " + o.token
1412
+ Authorization: "Bearer " + r.token
1384
1413
  }
1385
1414
  })).json()).items;
1386
1415
  }
1387
- async function ee(a, e, t, n, i) {
1388
- const s = Z[e];
1416
+ async function ne(a, e, t, n, i) {
1417
+ const o = te[e];
1389
1418
  return await Promise.all(
1390
1419
  Array(t).fill(0).map(async (c, d) => {
1391
- const y = new Date(n), m = s.sub(
1392
- s.start(y),
1420
+ const y = new Date(n), m = o.sub(
1421
+ o.start(y),
1393
1422
  t - d - 1
1394
- ), w = s.sub(
1395
- s.end(y),
1423
+ ), w = o.sub(
1424
+ o.end(y),
1396
1425
  t - d - 1
1397
- ), v = rt(
1426
+ ), v = ct(
1398
1427
  m.toLocaleDateString(),
1399
1428
  w.toLocaleDateString()
1400
1429
  ), C = await z({
@@ -1412,14 +1441,14 @@ async function B(a, e) {
1412
1441
  ...a,
1413
1442
  eventTypes: ["annotation"]
1414
1443
  })).filter(
1415
- (s) => !!s.tags && Object.keys(s.tags).includes(e)
1416
- ).reduce((s, c) => {
1444
+ (o) => !!o.tags && Object.keys(o.tags).includes(e)
1445
+ ).reduce((o, c) => {
1417
1446
  const d = c.tags[e];
1418
- return d in s ? (s[d] += 1, s) : (s[d] = 1, s);
1447
+ return d in o ? (o[d] += 1, o) : (o[d] = 1, o);
1419
1448
  }, {});
1420
1449
  }
1421
- async function te(a, e, t) {
1422
- const { end: n, start: i } = a, c = Z[t].interval({
1450
+ async function ae(a, e, t) {
1451
+ const { end: n, start: i } = a, c = te[t].interval({
1423
1452
  start: new Date(i),
1424
1453
  end: new Date(n)
1425
1454
  }), d = c.map((m, w) => {
@@ -1438,14 +1467,14 @@ async function te(a, e, t) {
1438
1467
  annotations: y[w]
1439
1468
  }));
1440
1469
  }
1441
- async function ne(a, e, t, n, i) {
1442
- let s = a;
1443
- Array.isArray(a) || (s = [a]);
1470
+ async function ie(a, e, t, n, i) {
1471
+ let o = a;
1472
+ Array.isArray(a) || (o = [a]);
1444
1473
  let c = e;
1445
1474
  return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
1446
1475
  method: "POST",
1447
1476
  body: JSON.stringify({
1448
- deviceIds: s,
1477
+ deviceIds: o,
1449
1478
  end: n.toISOString(),
1450
1479
  names: c,
1451
1480
  start: t.toISOString(),
@@ -1453,12 +1482,12 @@ async function ne(a, e, t, n, i) {
1453
1482
  }),
1454
1483
  headers: {
1455
1484
  "Content-Type": "application/json",
1456
- Authorization: "Bearer " + o.token
1485
+ Authorization: "Bearer " + r.token
1457
1486
  }
1458
1487
  })).json()).items;
1459
1488
  }
1460
- async function ae() {
1461
- if (!o.token)
1489
+ async function oe() {
1490
+ if (!r.token)
1462
1491
  throw new Error("Not authenticated");
1463
1492
  const a = $.get();
1464
1493
  try {
@@ -1467,8 +1496,8 @@ async function ae() {
1467
1496
  await a.shutdown();
1468
1497
  }
1469
1498
  }
1470
- async function ie() {
1471
- if (!o.token)
1499
+ async function re() {
1500
+ if (!r.token)
1472
1501
  throw new Error("Not authenticated");
1473
1502
  const a = $.get();
1474
1503
  try {
@@ -1477,56 +1506,56 @@ async function ie() {
1477
1506
  await a.shutdown();
1478
1507
  }
1479
1508
  }
1480
- async function st(a) {
1481
- if (!o.token)
1509
+ async function dt(a) {
1510
+ if (!r.token)
1482
1511
  throw new Error("Not authenticated");
1483
1512
  return await (await fetch(`${h}/v1/admin/devices`, {
1484
1513
  method: "POST",
1485
1514
  body: JSON.stringify(a),
1486
1515
  headers: {
1487
1516
  "Content-Type": "application/json",
1488
- Authorization: "Bearer " + o.token
1517
+ Authorization: "Bearer " + r.token
1489
1518
  }
1490
1519
  })).json();
1491
1520
  }
1492
- async function ct(a, e) {
1493
- if (!o.token)
1521
+ async function ht(a, e) {
1522
+ if (!r.token)
1494
1523
  throw new Error("Not authenticated");
1495
1524
  return await (await fetch(`${h}/v1/admin/devices/${a}`, {
1496
1525
  method: "PATCH",
1497
1526
  body: JSON.stringify(e),
1498
1527
  headers: {
1499
1528
  "Content-Type": "application/json",
1500
- Authorization: "Bearer " + o.token
1529
+ Authorization: "Bearer " + r.token
1501
1530
  }
1502
1531
  })).json();
1503
1532
  }
1504
- async function dt() {
1505
- if (!o.token)
1533
+ async function lt() {
1534
+ if (!r.token)
1506
1535
  throw new Error("Not authenticated");
1507
1536
  return (await (await fetch(`${h}/v1/admin/device-details/query`, {
1508
1537
  method: "POST",
1509
1538
  body: JSON.stringify({ enabled: !0, type: "default" }),
1510
1539
  headers: {
1511
1540
  "Content-Type": "application/json",
1512
- Authorization: "Bearer " + o.token
1541
+ Authorization: "Bearer " + r.token
1513
1542
  }
1514
1543
  })).json()).items;
1515
1544
  }
1516
- async function ht(a) {
1517
- if (!o.token)
1545
+ async function ut(a) {
1546
+ if (!r.token)
1518
1547
  throw new Error("Not authenticated");
1519
1548
  return (await (await fetch(`${h}/v1/admin/devices/query`, {
1520
1549
  method: "POST",
1521
1550
  body: JSON.stringify(a),
1522
1551
  headers: {
1523
1552
  "Content-Type": "application/json",
1524
- Authorization: "Bearer " + o.token
1553
+ Authorization: "Bearer " + r.token
1525
1554
  }
1526
1555
  })).json()).items;
1527
1556
  }
1528
- async function ut(a) {
1529
- if (!o.token)
1557
+ async function mt(a) {
1558
+ if (!r.token)
1530
1559
  throw new Error("Not authenticated");
1531
1560
  return await (await fetch(
1532
1561
  `${h}/v1/admin/devices/${a}/disable`,
@@ -1534,12 +1563,12 @@ async function ut(a) {
1534
1563
  method: "POST",
1535
1564
  headers: {
1536
1565
  "Content-Type": "application/json",
1537
- Authorization: "Bearer " + o.token
1566
+ Authorization: "Bearer " + r.token
1538
1567
  }
1539
1568
  }
1540
1569
  )).json();
1541
1570
  }
1542
- class S extends Q {
1571
+ class S extends Y {
1543
1572
  constructor(e, t, n, i) {
1544
1573
  super(), this.id = e, this.name = t, this.organizationId = n, this.tags = i;
1545
1574
  }
@@ -1553,7 +1582,7 @@ class S extends Q {
1553
1582
  }),
1554
1583
  headers: {
1555
1584
  "Content-Type": "application/json",
1556
- Authorization: "Bearer " + o.token
1585
+ Authorization: "Bearer " + r.token
1557
1586
  }
1558
1587
  }
1559
1588
  )).json()).items;
@@ -1563,7 +1592,7 @@ class S extends Q {
1563
1592
  method: "GET",
1564
1593
  headers: {
1565
1594
  "Content-Type": "application/json",
1566
- Authorization: "Bearer " + o.token
1595
+ Authorization: "Bearer " + r.token
1567
1596
  }
1568
1597
  });
1569
1598
  const t = await e.json();
@@ -1578,7 +1607,7 @@ class S extends Q {
1578
1607
  method: "GET",
1579
1608
  headers: {
1580
1609
  "Content-Type": "application/json",
1581
- Authorization: "Bearer " + o.token
1610
+ Authorization: "Bearer " + r.token
1582
1611
  }
1583
1612
  }
1584
1613
  ), (await e.json()).document;
@@ -1591,7 +1620,7 @@ class S extends Q {
1591
1620
  }),
1592
1621
  headers: {
1593
1622
  "Content-Type": "application/json",
1594
- Authorization: "Bearer " + o.token
1623
+ Authorization: "Bearer " + r.token
1595
1624
  }
1596
1625
  })).json()).fileUrls;
1597
1626
  }
@@ -1613,7 +1642,7 @@ class S extends Q {
1613
1642
  sessionType: t,
1614
1643
  deadlineMs: n = 1e4,
1615
1644
  maxConnectRetries: i = 3
1616
- } = typeof e == "number" ? { sessionType: e } : e, c = Ve({
1645
+ } = typeof e == "number" ? { sessionType: e } : e, c = He({
1617
1646
  sessionType: t
1618
1647
  }).get(this.handleMessage);
1619
1648
  let d = !1;
@@ -1658,7 +1687,7 @@ class S extends Q {
1658
1687
  }
1659
1688
  async getRemoteDevicePeerId(e) {
1660
1689
  const n = (await e.getPeers()).find((i) => i.deviceId === this.id);
1661
- if (!He(n))
1690
+ if (!We(n))
1662
1691
  throw new Error("Cannot find peer, is the robot offline?");
1663
1692
  return n.id;
1664
1693
  }
@@ -1702,7 +1731,7 @@ class S extends Q {
1702
1731
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1703
1732
  }
1704
1733
  async isInRealtimeSession() {
1705
- const e = await ie(), t = await ae(), n = e.find((i) => i.deviceId === this.id);
1734
+ const e = await re(), t = await oe(), n = e.find((i) => i.deviceId === this.id);
1706
1735
  return n ? t[n.id].length > 0 : !1;
1707
1736
  }
1708
1737
  async getAvailableCommands() {
@@ -1712,7 +1741,7 @@ class S extends Q {
1712
1741
  method: "GET",
1713
1742
  headers: {
1714
1743
  "Content-Type": "application/json",
1715
- Authorization: "Bearer " + o.token
1744
+ Authorization: "Bearer " + r.token
1716
1745
  }
1717
1746
  }
1718
1747
  )).json()).items.map((n) => ({
@@ -1750,11 +1779,11 @@ class S extends Q {
1750
1779
  deviceId: this.id,
1751
1780
  command: c.command,
1752
1781
  parameter: y,
1753
- userId: (w = o.currentUser) == null ? void 0 : w.id
1782
+ userId: (w = r.currentUser) == null ? void 0 : w.id
1754
1783
  }),
1755
1784
  headers: {
1756
1785
  "Content-Type": "application/json",
1757
- Authorization: "Bearer " + o.token
1786
+ Authorization: "Bearer " + r.token
1758
1787
  }
1759
1788
  });
1760
1789
  }
@@ -1763,7 +1792,7 @@ class S extends Q {
1763
1792
  method: "GET",
1764
1793
  headers: {
1765
1794
  "Content-Type": "application/json",
1766
- Authorization: "Bearer " + o.token
1795
+ Authorization: "Bearer " + r.token
1767
1796
  }
1768
1797
  });
1769
1798
  }
@@ -1777,13 +1806,13 @@ class S extends Q {
1777
1806
  }),
1778
1807
  headers: {
1779
1808
  "Content-Type": "application/json",
1780
- Authorization: "Bearer " + o.token
1809
+ Authorization: "Bearer " + r.token
1781
1810
  }
1782
1811
  })).json();
1783
- return new Ge(n);
1812
+ return new Fe(n);
1784
1813
  }
1785
1814
  async getTelemetry(e, t, n, i) {
1786
- return await ne(
1815
+ return await ie(
1787
1816
  this.id,
1788
1817
  e,
1789
1818
  t,
@@ -1802,7 +1831,7 @@ class S extends Q {
1802
1831
  }),
1803
1832
  headers: {
1804
1833
  "Content-Type": "application/json",
1805
- Authorization: "Bearer " + o.token
1834
+ Authorization: "Bearer " + r.token
1806
1835
  }
1807
1836
  }
1808
1837
  ), n = [], i = [];
@@ -1825,7 +1854,7 @@ class S extends Q {
1825
1854
  }),
1826
1855
  headers: {
1827
1856
  "Content-Type": "application/json",
1828
- Authorization: "Bearer " + o.token
1857
+ Authorization: "Bearer " + r.token
1829
1858
  }
1830
1859
  }
1831
1860
  )).json();
@@ -1842,7 +1871,7 @@ class S extends Q {
1842
1871
  }),
1843
1872
  headers: {
1844
1873
  "Content-Type": "application/json",
1845
- Authorization: "Bearer " + o.token
1874
+ Authorization: "Bearer " + r.token
1846
1875
  }
1847
1876
  }
1848
1877
  )).json();
@@ -1851,40 +1880,40 @@ class S extends Q {
1851
1880
  return await B({ ...e, deviceIds: [this.id] }, t);
1852
1881
  }
1853
1882
  async getAnnotationCountByIntervals(e, t, n) {
1854
- return await te(
1883
+ return await ae(
1855
1884
  { ...e, deviceIds: [this.id] },
1856
1885
  t,
1857
1886
  n
1858
1887
  );
1859
1888
  }
1860
- async eventsCounter(e, t, n, i, s) {
1861
- return await ee(e, t, n, i, {
1862
- ...s,
1889
+ async eventsCounter(e, t, n, i, o) {
1890
+ return await ne(e, t, n, i, {
1891
+ ...o,
1863
1892
  deviceIds: [this.id]
1864
1893
  });
1865
1894
  }
1866
1895
  async createShareLink(e, t) {
1867
- return e.scope.deviceIds = [this.id], await Y(e, t);
1896
+ return e.scope.deviceIds = [this.id], await ee(e, t);
1868
1897
  }
1869
1898
  }
1870
- r(S, "createDevice", st), r(S, "patchDevice", ct), r(S, "getDevicesData", dt), r(S, "queryDevicesData", ht), r(S, "disableDevice", ut);
1871
- class lt extends Q {
1899
+ s(S, "createDevice", dt), s(S, "patchDevice", ht), s(S, "getDevicesData", lt), s(S, "queryDevicesData", ut), s(S, "disableDevice", mt);
1900
+ class ft extends Y {
1872
1901
  constructor(t) {
1873
1902
  super();
1874
- r(this, "id");
1875
- r(this, "telemetryStreamActive", !1);
1876
- r(this, "streamTelemetry", {});
1903
+ s(this, "id");
1904
+ s(this, "telemetryStreamActive", !1);
1905
+ s(this, "streamTelemetry", {});
1877
1906
  this.peerUrl = t;
1878
1907
  }
1879
1908
  async getLatestTelemetry() {
1880
1909
  this.telemetryStreamActive || this.subscribeToTelemetry();
1881
1910
  const t = this.streamTelemetry;
1882
- return Object.entries(t).map(([i, s]) => ({
1911
+ return Object.entries(t).map(([i, o]) => ({
1883
1912
  deviceId: this.id,
1884
1913
  streamName: i,
1885
1914
  streamType: "json",
1886
- currentValue: s,
1887
- currentValueTime: s.timestamp,
1915
+ currentValue: o,
1916
+ currentValueTime: o.timestamp,
1888
1917
  tags: {}
1889
1918
  }));
1890
1919
  }
@@ -1901,8 +1930,8 @@ class lt extends Q {
1901
1930
  }), n.addEventListener("readystatechange", (i) => {
1902
1931
  n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
1903
1932
  }), n.addEventListener("progress", (i) => {
1904
- const s = i.loaded, c = s - t;
1905
- t = s, n.responseText.substr(-c).split(`
1933
+ const o = i.loaded, c = o - t;
1934
+ t = o, n.responseText.substr(-c).split(`
1906
1935
  `).forEach((m) => {
1907
1936
  var w;
1908
1937
  if (m.length > 0) {
@@ -1971,11 +2000,11 @@ class lt extends Q {
1971
2000
  if (t)
1972
2001
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1973
2002
  }
1974
- async sendCommand(t, n, i, s) {
2003
+ async sendCommand(t, n, i, o) {
1975
2004
  const c = {
1976
2005
  value: n,
1977
2006
  scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
1978
- meta: s
2007
+ meta: o
1979
2008
  };
1980
2009
  return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
1981
2010
  method: "POST",
@@ -1989,43 +2018,43 @@ class lt extends Q {
1989
2018
  });
1990
2019
  }
1991
2020
  }
1992
- async function mt(a, e) {
1993
- if (!o.token)
2021
+ async function wt(a, e) {
2022
+ if (!r.token)
1994
2023
  throw new Error("Not authenticated");
1995
2024
  return await (await fetch(`${h}/v1/admin/devices/${a}`, {
1996
2025
  method: "PATCH",
1997
2026
  body: JSON.stringify({ fleetId: e }),
1998
2027
  headers: {
1999
2028
  "Content-Type": "application/json",
2000
- Authorization: "Bearer " + o.token
2029
+ Authorization: "Bearer " + r.token
2001
2030
  }
2002
2031
  })).json();
2003
2032
  }
2004
- async function ft(a) {
2005
- if (!o.token)
2033
+ async function pt(a) {
2034
+ if (!r.token)
2006
2035
  throw new Error("Not authenticated");
2007
2036
  return (await (await fetch(`${h}/v1/queries/queries`, {
2008
2037
  method: "POST",
2009
2038
  body: JSON.stringify(a),
2010
2039
  headers: {
2011
2040
  "Content-Type": "application/json",
2012
- Authorization: "Bearer " + o.token
2041
+ Authorization: "Bearer " + r.token
2013
2042
  }
2014
2043
  })).json()).aggregates;
2015
2044
  }
2016
- async function wt(a) {
2017
- if (!o.token)
2045
+ async function yt(a) {
2046
+ if (!r.token)
2018
2047
  throw new Error("Not authenticated");
2019
2048
  await fetch(`${h}/v1/admin/fleets/${a}`, {
2020
2049
  method: "DELETE",
2021
2050
  headers: {
2022
2051
  "Content-Type": "application/json",
2023
- Authorization: "Bearer " + o.token
2052
+ Authorization: "Bearer " + r.token
2024
2053
  }
2025
2054
  });
2026
2055
  }
2027
- async function pt() {
2028
- if (!o.token)
2056
+ async function gt() {
2057
+ if (!r.token)
2029
2058
  throw new Error("Not authenticated");
2030
2059
  return (await (await fetch(
2031
2060
  `${h}/v1/queries/analytics/streams`,
@@ -2033,13 +2062,13 @@ async function pt() {
2033
2062
  method: "GET",
2034
2063
  headers: {
2035
2064
  "Content-Type": "application/json",
2036
- Authorization: "Bearer " + o.token
2065
+ Authorization: "Bearer " + r.token
2037
2066
  }
2038
2067
  }
2039
2068
  )).json()).items;
2040
2069
  }
2041
- async function yt() {
2042
- if (!o.token)
2070
+ async function vt() {
2071
+ if (!r.token)
2043
2072
  throw new Error("Not authenticated");
2044
2073
  return (await (await fetch(
2045
2074
  `${h}/v1/admin/analytics-modules`,
@@ -2047,39 +2076,39 @@ async function yt() {
2047
2076
  method: "GET",
2048
2077
  headers: {
2049
2078
  "Content-Type": "application/json",
2050
- Authorization: "Bearer " + o.token
2079
+ Authorization: "Bearer " + r.token
2051
2080
  }
2052
2081
  }
2053
2082
  )).json()).items;
2054
2083
  }
2055
- async function gt(a) {
2056
- if (!o.token)
2084
+ async function Tt(a) {
2085
+ if (!r.token)
2057
2086
  throw new Error("Not authenticated");
2058
2087
  return await (await fetch(`${h}/v1/queries/analytics/rows`, {
2059
2088
  method: "POST",
2060
2089
  body: JSON.stringify(a),
2061
2090
  headers: {
2062
2091
  "Content-Type": "application/json",
2063
- Authorization: "Bearer " + o.token
2092
+ Authorization: "Bearer " + r.token
2064
2093
  }
2065
2094
  })).json();
2066
2095
  }
2067
- async function oe(a) {
2068
- if (!o.token)
2096
+ async function se(a) {
2097
+ if (!r.token)
2069
2098
  throw new Error("Not authenticated");
2070
2099
  return (await (await fetch(`${h}/v1/admin/devices/query`, {
2071
2100
  method: "POST",
2072
2101
  body: JSON.stringify(a),
2073
2102
  headers: {
2074
2103
  "Content-Type": "application/json",
2075
- Authorization: "Bearer " + o.token
2104
+ Authorization: "Bearer " + r.token
2076
2105
  }
2077
2106
  })).json()).items.map(
2078
2107
  (n) => new S(n.id, n.name, n.organizationId, n.tags)
2079
2108
  );
2080
2109
  }
2081
- async function vt() {
2082
- if (!o.token)
2110
+ async function Ct() {
2111
+ if (!r.token)
2083
2112
  throw new Error("Not authenticated");
2084
2113
  let a = new URLSearchParams("");
2085
2114
  typeof window < "u" && window.location && (a = new URLSearchParams(window.location.search));
@@ -2091,37 +2120,37 @@ async function vt() {
2091
2120
  {
2092
2121
  headers: {
2093
2122
  "Content-Type": "application/json",
2094
- Authorization: "Bearer " + o.token
2123
+ Authorization: "Bearer " + r.token
2095
2124
  }
2096
2125
  }
2097
2126
  ), { tagKey: n, tagValue: i } = await t.json();
2098
- return await oe({
2127
+ return await se({
2099
2128
  tags: { [n]: [i] },
2100
2129
  enabled: !0,
2101
2130
  type: "default"
2102
2131
  });
2103
2132
  }
2104
- async function Tt(a) {
2105
- if (!o.token)
2133
+ async function St(a) {
2134
+ if (!r.token)
2106
2135
  throw new Error("Not authenticated");
2107
2136
  const t = await (await fetch(`${h}/v1/admin/devices/${a}`, {
2108
2137
  method: "GET",
2109
2138
  headers: {
2110
2139
  "Content-Type": "application/json",
2111
- Authorization: "Bearer " + o.token
2140
+ Authorization: "Bearer " + r.token
2112
2141
  }
2113
2142
  })).json(), n = t.name;
2114
2143
  return new S(a, n, t.organizationId, t.tags);
2115
2144
  }
2116
2145
  async function M() {
2117
- if (!o.token)
2146
+ if (!r.token)
2118
2147
  throw new Error("Not authenticated");
2119
2148
  const e = await (await fetch(`${h}/v1/admin/device-details/query`, {
2120
2149
  method: "POST",
2121
2150
  body: JSON.stringify({ enabled: !0, type: "default" }),
2122
2151
  headers: {
2123
2152
  "Content-Type": "application/json",
2124
- Authorization: "Bearer " + o.token
2153
+ Authorization: "Bearer " + r.token
2125
2154
  }
2126
2155
  })).json();
2127
2156
  return e.items, e.items.map(
@@ -2133,8 +2162,8 @@ async function M() {
2133
2162
  )
2134
2163
  );
2135
2164
  }
2136
- async function Ct(a) {
2137
- if (!o.token)
2165
+ async function Et(a) {
2166
+ if (!r.token)
2138
2167
  throw new Error("Not authenticated");
2139
2168
  return (await (await fetch(
2140
2169
  `${h}/v1/admin/events/query/id=${a}`,
@@ -2142,12 +2171,12 @@ async function Ct(a) {
2142
2171
  method: "GET",
2143
2172
  headers: {
2144
2173
  "Content-Type": "application/json",
2145
- Authorization: "Bearer " + o.token
2174
+ Authorization: "Bearer " + r.token
2146
2175
  }
2147
2176
  }
2148
2177
  )).json()).items;
2149
2178
  }
2150
- async function St(a) {
2179
+ async function kt(a) {
2151
2180
  const t = await (await fetch(`${h}/v1/admin/files/query`, {
2152
2181
  method: "POST",
2153
2182
  body: JSON.stringify({
@@ -2155,37 +2184,37 @@ async function St(a) {
2155
2184
  }),
2156
2185
  headers: {
2157
2186
  "Content-Type": "application/json",
2158
- Authorization: "Bearer " + o.token
2187
+ Authorization: "Bearer " + r.token
2159
2188
  }
2160
2189
  })).json();
2161
2190
  if (t.fileUrls.length === 0)
2162
2191
  throw new Error("File not found");
2163
2192
  return t.fileUrls[0];
2164
2193
  }
2165
- async function Et(a) {
2166
- if (!o.token)
2194
+ async function Ot(a) {
2195
+ if (!r.token)
2167
2196
  throw new Error("Not authenticated");
2168
2197
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
2169
2198
  method: "GET",
2170
2199
  headers: {
2171
2200
  "Content-Type": "application/json",
2172
- Authorization: "Bearer " + o.token
2201
+ Authorization: "Bearer " + r.token
2173
2202
  }
2174
2203
  })).json();
2175
2204
  }
2176
- async function kt(a) {
2177
- if (!o.token)
2205
+ async function Rt(a) {
2206
+ if (!r.token)
2178
2207
  throw new Error("Not authenticated");
2179
2208
  return (await (await fetch(`${h}/v1/admin/fleets/${a}/devices`, {
2180
2209
  method: "GET",
2181
2210
  headers: {
2182
2211
  "Content-Type": "application/json",
2183
- Authorization: "Bearer " + o.token
2212
+ Authorization: "Bearer " + r.token
2184
2213
  }
2185
2214
  })).json()).items;
2186
2215
  }
2187
- async function Ot() {
2188
- if (!o.token)
2216
+ async function At() {
2217
+ if (!r.token)
2189
2218
  throw new Error("Not authenticated");
2190
2219
  return (await (await fetch(
2191
2220
  `${h}/v1/admin/intervention-requests`,
@@ -2193,12 +2222,12 @@ async function Ot() {
2193
2222
  method: "GET",
2194
2223
  headers: {
2195
2224
  "Content-Type": "application/json",
2196
- Authorization: "Bearer " + o.token
2225
+ Authorization: "Bearer " + r.token
2197
2226
  }
2198
2227
  }
2199
2228
  )).json()).items;
2200
2229
  }
2201
- async function Rt(...a) {
2230
+ async function bt(...a) {
2202
2231
  const e = a.flat().filter((i) => !!i);
2203
2232
  return e.length === 0 ? [] : (await (await fetch(
2204
2233
  `${h}/v1/queries/stream-current-value`,
@@ -2209,52 +2238,52 @@ async function Rt(...a) {
2209
2238
  }),
2210
2239
  headers: {
2211
2240
  "Content-Type": "application/json",
2212
- Authorization: "Bearer " + o.token
2241
+ Authorization: "Bearer " + r.token
2213
2242
  }
2214
2243
  }
2215
2244
  )).json()).items;
2216
2245
  }
2217
- async function At() {
2218
- if (!o.token)
2246
+ async function Dt() {
2247
+ if (!r.token)
2219
2248
  throw new Error("Not authenticated");
2220
2249
  const t = (await (await fetch(`${h}/v1/queries/online-devices`, {
2221
2250
  method: "GET",
2222
2251
  headers: {
2223
2252
  "Content-Type": "application/json",
2224
- Authorization: "Bearer " + o.token
2253
+ Authorization: "Bearer " + r.token
2225
2254
  }
2226
2255
  })).json()).items;
2227
2256
  return (await M()).filter((i) => t.includes(i.id));
2228
2257
  }
2229
- async function bt() {
2230
- if (!o.token)
2258
+ async function jt() {
2259
+ if (!r.token)
2231
2260
  throw new Error("Not authenticated");
2232
2261
  const t = (await (await fetch(`${h}/v1/signaling/peers`, {
2233
2262
  method: "GET",
2234
2263
  headers: {
2235
2264
  "Content-Type": "application/json",
2236
- Authorization: "Bearer " + o.token
2265
+ Authorization: "Bearer " + r.token
2237
2266
  }
2238
2267
  })).json()).items.map(
2239
2268
  (i) => i.deviceId
2240
2269
  );
2241
2270
  return (await M()).filter((i) => t.includes(i.id));
2242
2271
  }
2243
- async function Dt() {
2244
- if (!o.token)
2272
+ async function Nt() {
2273
+ if (!r.token)
2245
2274
  throw new Error("Not authenticated");
2246
2275
  return (await (await fetch(`${h}/v1/admin/streams`, {
2247
2276
  method: "GET",
2248
2277
  headers: {
2249
2278
  "Content-Type": "application/json",
2250
- Authorization: "Bearer " + o.token
2279
+ Authorization: "Bearer " + r.token
2251
2280
  }
2252
2281
  })).json()).items.filter(
2253
2282
  (t) => t.enabled
2254
2283
  );
2255
2284
  }
2256
- async function jt(a) {
2257
- if (!o.token)
2285
+ async function Pt(a) {
2286
+ if (!r.token)
2258
2287
  throw new Error("Not authenticated");
2259
2288
  return await (await fetch(
2260
2289
  `${h}/v1/queries/analytics/task-report-rows`,
@@ -2263,13 +2292,13 @@ async function jt(a) {
2263
2292
  body: JSON.stringify(a),
2264
2293
  headers: {
2265
2294
  "Content-Type": "application/json",
2266
- Authorization: "Bearer " + o.token
2295
+ Authorization: "Bearer " + r.token
2267
2296
  }
2268
2297
  }
2269
2298
  )).json();
2270
2299
  }
2271
- async function Nt() {
2272
- if (!o.token)
2300
+ async function Lt() {
2301
+ if (!r.token)
2273
2302
  throw new Error("Not authenticated");
2274
2303
  return (await (await fetch(
2275
2304
  `${h}/v1/queries/analytics/task-reports`,
@@ -2277,36 +2306,36 @@ async function Nt() {
2277
2306
  method: "GET",
2278
2307
  headers: {
2279
2308
  "Content-Type": "application/json",
2280
- Authorization: "Bearer " + o.token
2309
+ Authorization: "Bearer " + r.token
2281
2310
  }
2282
2311
  }
2283
2312
  )).json()).items;
2284
2313
  }
2285
- async function Pt() {
2286
- if (!o.token)
2314
+ async function It() {
2315
+ if (!r.token)
2287
2316
  throw new Error("Not authenticated");
2288
2317
  return (await (await fetch(`${h}/v1/admin/fleets`, {
2289
2318
  method: "GET",
2290
2319
  headers: {
2291
2320
  "Content-Type": "application/json",
2292
- Authorization: "Bearer " + o.token
2321
+ Authorization: "Bearer " + r.token
2293
2322
  }
2294
2323
  })).json()).items;
2295
2324
  }
2296
- async function Lt(a, e) {
2297
- if (!o.token)
2325
+ async function _t(a, e) {
2326
+ if (!r.token)
2298
2327
  throw new Error("Not authenticated");
2299
2328
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
2300
2329
  method: "PATCH",
2301
2330
  body: JSON.stringify(e),
2302
2331
  headers: {
2303
2332
  "Content-Type": "application/json",
2304
- Authorization: "Bearer " + o.token
2333
+ Authorization: "Bearer " + r.token
2305
2334
  }
2306
2335
  })).json();
2307
2336
  }
2308
- async function It(a) {
2309
- if (!o.token)
2337
+ async function $t(a) {
2338
+ if (!r.token)
2310
2339
  throw new Error("Not authenticated");
2311
2340
  return await (await fetch(
2312
2341
  `${h}/v1/admin/streams/${a.id}`,
@@ -2315,60 +2344,60 @@ async function It(a) {
2315
2344
  body: JSON.stringify(a),
2316
2345
  headers: {
2317
2346
  "Content-Type": "application/json",
2318
- Authorization: "Bearer " + o.token
2347
+ Authorization: "Bearer " + r.token
2319
2348
  }
2320
2349
  }
2321
2350
  )).json();
2322
2351
  }
2323
- async function _t(a) {
2324
- if (!o.token)
2352
+ async function zt(a) {
2353
+ if (!r.token)
2325
2354
  throw new Error("Not authenticated");
2326
2355
  return await (await fetch(`${h}/v1/admin/views/${a.id}`, {
2327
2356
  method: "PATCH",
2328
2357
  body: JSON.stringify(a),
2329
2358
  headers: {
2330
2359
  "Content-Type": "application/json",
2331
- Authorization: "Bearer " + o.token
2360
+ Authorization: "Bearer " + r.token
2332
2361
  }
2333
2362
  })).json();
2334
2363
  }
2335
- async function $t(a) {
2336
- if (!o.token)
2364
+ async function Bt(a) {
2365
+ if (!r.token)
2337
2366
  throw new Error("Not authenticated");
2338
2367
  return await (await fetch(`${h}/v1/queries/analytics`, {
2339
2368
  method: "POST",
2340
2369
  body: JSON.stringify(a),
2341
2370
  headers: {
2342
2371
  "Content-Type": "application/json",
2343
- Authorization: "Bearer " + o.token
2372
+ Authorization: "Bearer " + r.token
2344
2373
  }
2345
2374
  })).json();
2346
2375
  }
2347
- async function zt(a) {
2348
- if (!o.token)
2376
+ async function Mt(a) {
2377
+ if (!r.token)
2349
2378
  throw new Error("Not authenticated");
2350
2379
  return await (await fetch(`${h}/v1/admin/fleets`, {
2351
2380
  method: "POST",
2352
2381
  body: JSON.stringify(a),
2353
2382
  headers: {
2354
2383
  "Content-Type": "application/json",
2355
- Authorization: "Bearer " + o.token
2384
+ Authorization: "Bearer " + r.token
2356
2385
  }
2357
2386
  })).json();
2358
2387
  }
2359
- async function Bt() {
2360
- if (!o.token)
2388
+ async function qt() {
2389
+ if (!r.token)
2361
2390
  throw new Error("Not authenticated");
2362
2391
  return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
2363
2392
  method: "GET",
2364
2393
  headers: {
2365
2394
  "Content-Type": "application/json",
2366
- Authorization: "Bearer " + o.token
2395
+ Authorization: "Bearer " + r.token
2367
2396
  }
2368
2397
  })).json()).items;
2369
2398
  }
2370
- async function Mt(a) {
2371
- if (!o.token)
2399
+ async function xt(a) {
2400
+ if (!r.token)
2372
2401
  throw new Error("Not authenticated");
2373
2402
  return await (await fetch(
2374
2403
  `${h}/v1/admin/event-trigger-groups/${a}`,
@@ -2376,13 +2405,13 @@ async function Mt(a) {
2376
2405
  method: "GET",
2377
2406
  headers: {
2378
2407
  "Content-Type": "application/json",
2379
- Authorization: "Bearer " + o.token
2408
+ Authorization: "Bearer " + r.token
2380
2409
  }
2381
2410
  }
2382
2411
  )).json();
2383
2412
  }
2384
- async function qt(a, e) {
2385
- if (!o.token)
2413
+ async function Ut(a, e) {
2414
+ if (!r.token)
2386
2415
  throw new Error("Not authenticated");
2387
2416
  return await (await fetch(
2388
2417
  `${h}/v1/admin/event-trigger-groups/${a}`,
@@ -2391,7 +2420,7 @@ async function qt(a, e) {
2391
2420
  body: JSON.stringify(e),
2392
2421
  headers: {
2393
2422
  "Content-Type": "application/json",
2394
- Authorization: "Bearer " + o.token
2423
+ Authorization: "Bearer " + r.token
2395
2424
  }
2396
2425
  }
2397
2426
  )).json();
@@ -2401,7 +2430,7 @@ const E = class {
2401
2430
  E.defaultDeviceId = e;
2402
2431
  }
2403
2432
  static async getCurrentDevice() {
2404
- if (!o.token)
2433
+ if (!r.token)
2405
2434
  throw new Error("Not authenticated");
2406
2435
  if (!E.defaultDeviceId)
2407
2436
  throw new Error("No known default device");
@@ -2411,48 +2440,48 @@ const E = class {
2411
2440
  method: "POST",
2412
2441
  headers: {
2413
2442
  "Content-Type": "application/json",
2414
- Authorization: "Bearer " + o.token
2443
+ Authorization: "Bearer " + r.token
2415
2444
  }
2416
2445
  }
2417
2446
  )).json()).items.find(
2418
2447
  (c) => c.id === E.defaultDeviceId
2419
- ), i = n.name, s = new S(
2448
+ ), i = n.name, o = new S(
2420
2449
  E.defaultDeviceId,
2421
2450
  i,
2422
- f(o.currentOrganization),
2451
+ f(r.currentOrganization),
2423
2452
  n.tags
2424
2453
  );
2425
- return E.knownContext.push(new WeakRef(s)), s;
2454
+ return E.knownContext.push(new WeakRef(o)), o;
2426
2455
  }
2427
2456
  static async getPeerDevice(e) {
2428
- const t = new lt(e);
2457
+ const t = new ft(e);
2429
2458
  return t.id = await t.getDeviceId(), t;
2430
2459
  }
2431
2460
  static async getDevice(e) {
2432
- const t = await Tt(e);
2461
+ const t = await St(e);
2433
2462
  return E.knownContext.push(new WeakRef(t)), t;
2434
2463
  }
2435
2464
  };
2436
- let u = E;
2437
- r(u, "defaultDeviceId"), r(u, "knownContext", []), r(u, "createFleet", zt), r(u, "listFleets", Pt), r(u, "getFleet", Et), r(u, "patchFleet", Lt), r(u, "deleteFleet", wt), r(u, "addDeviceToFleet", mt), r(u, "getFleetDevices", kt), r(u, "aggregateTelemetry", ft), r(u, "createShareLink", Y), r(u, "eventsCounter", ee), r(u, "getAnalyticStreams", pt), r(u, "getAnalyticsModules", yt), r(u, "getAnalyticsRows", gt), r(u, "getAnnotationCount", B), r(u, "getAnnotationCountByIntervals", te), r(u, "getCurrentGroup", vt), r(u, "getDevices", M), r(u, "getEvent", Ct), r(u, "getFileUrl", St), r(u, "getInterventions", Ot), r(u, "getLatestTelemetry", Rt), r(u, "getOnlineDevices", At), r(u, "getPeers", ie), r(u, "getRealtimeDevices", bt), r(u, "getRealtimeSessions", ae), r(u, "getStreams", Dt), r(u, "getTaskReportRows", jt), r(u, "getTaskReportTables", Nt), r(u, "getTelemetry", ne), r(u, "getViews", X), r(u, "patchStream", It), r(u, "patchView", _t), r(u, "queryAnalytics", $t), r(u, "queryDevices", oe), r(u, "queryEvents", z), r(u, "queryTelemetry", _), r(u, "getAllEventTriggerGroup", Bt), r(u, "getEventTriggerGroup", Mt), r(u, "patchEventTriggergroup", qt);
2438
- class tn {
2465
+ let l = E;
2466
+ s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "createFleet", Mt), s(l, "listFleets", It), s(l, "getFleet", Ot), s(l, "patchFleet", _t), s(l, "deleteFleet", yt), s(l, "addDeviceToFleet", wt), s(l, "getFleetDevices", Rt), s(l, "aggregateTelemetry", pt), s(l, "createShareLink", ee), s(l, "eventsCounter", ne), s(l, "getAnalyticStreams", gt), s(l, "getAnalyticsModules", vt), s(l, "getAnalyticsRows", Tt), s(l, "getAnnotationCount", B), s(l, "getAnnotationCountByIntervals", ae), s(l, "getCurrentGroup", Ct), s(l, "getDevices", M), s(l, "getEvent", Et), s(l, "getFileUrl", kt), s(l, "getInterventions", At), s(l, "getLatestTelemetry", bt), s(l, "getOnlineDevices", Dt), s(l, "getPeers", re), s(l, "getRealtimeDevices", jt), s(l, "getRealtimeSessions", oe), s(l, "getStreams", Nt), s(l, "getTaskReportRows", Pt), s(l, "getTaskReportTables", Lt), s(l, "getTelemetry", ie), s(l, "getViews", Z), s(l, "patchStream", $t), s(l, "patchView", zt), s(l, "queryAnalytics", Bt), s(l, "queryDevices", se), s(l, "queryEvents", z), s(l, "queryTelemetry", _), s(l, "getAllEventTriggerGroup", qt), s(l, "getEventTriggerGroup", xt), s(l, "patchEventTriggergroup", Ut);
2467
+ class an {
2439
2468
  static async set(e, t, n) {
2440
2469
  try {
2441
2470
  const i = await fetch(h + "/v1/admin/key-value", {
2442
2471
  method: "POST",
2443
2472
  body: JSON.stringify({
2444
- organizationId: f(o.currentUser).organizationId,
2473
+ organizationId: f(r.currentUser).organizationId,
2445
2474
  key: e,
2446
2475
  value: t,
2447
2476
  tags: n
2448
2477
  }),
2449
2478
  headers: {
2450
2479
  "Content-Type": "application/json",
2451
- Authorization: "Bearer " + o.token
2480
+ Authorization: "Bearer " + r.token
2452
2481
  }
2453
- }), s = await i.json();
2482
+ }), o = await i.json();
2454
2483
  if (i.status !== 200)
2455
- throw new Error(s.message);
2484
+ throw new Error(o.message);
2456
2485
  } catch (i) {
2457
2486
  throw i;
2458
2487
  }
@@ -2465,7 +2494,7 @@ class tn {
2465
2494
  method: "GET",
2466
2495
  headers: {
2467
2496
  "Content-Type": "application/json",
2468
- Authorization: "Bearer " + o.token
2497
+ Authorization: "Bearer " + r.token
2469
2498
  }
2470
2499
  }
2471
2500
  ), n = await t.json();
@@ -2482,7 +2511,7 @@ class tn {
2482
2511
  method: "GET",
2483
2512
  headers: {
2484
2513
  "Content-Type": "application/json",
2485
- Authorization: "Bearer " + o.token
2514
+ Authorization: "Bearer " + r.token
2486
2515
  }
2487
2516
  }), t = await e.json();
2488
2517
  if (e.status !== 200)
@@ -2500,7 +2529,7 @@ class tn {
2500
2529
  method: "DELETE",
2501
2530
  headers: {
2502
2531
  "Content-Type": "application/json",
2503
- Authorization: "Bearer " + o.token
2532
+ Authorization: "Bearer " + r.token
2504
2533
  }
2505
2534
  }
2506
2535
  )).ok)
@@ -2519,7 +2548,7 @@ class tn {
2519
2548
  body: JSON.stringify({ keys: e }),
2520
2549
  headers: {
2521
2550
  "Content-Type": "application/json",
2522
- Authorization: "Bearer " + o.token
2551
+ Authorization: "Bearer " + r.token
2523
2552
  }
2524
2553
  }
2525
2554
  );
@@ -2531,37 +2560,37 @@ class tn {
2531
2560
  }
2532
2561
  }
2533
2562
  }
2534
- function xt(a) {
2535
- return Uint8Array.from(J(a), (e) => e.charCodeAt(0));
2563
+ function Jt(a) {
2564
+ return Uint8Array.from(G(a), (e) => e.charCodeAt(0));
2536
2565
  }
2537
- function U() {
2566
+ function V() {
2538
2567
  const { userAgent: a } = navigator;
2539
2568
  return a ? a.includes("Firefox/") ? "Firefox" : a.includes("Edg/") ? "Edge" : a.includes("Chrome/") ? "Chrome" : a.includes("Safari/") ? "Safari" : a.includes("MSIE/") || a.includes("Trident/") ? "IE" : "Other" : "Other";
2540
2569
  }
2541
- const Ut = "audio-chunk";
2542
- class nn {
2570
+ const Vt = "audio-chunk";
2571
+ class on {
2543
2572
  constructor(e, t) {
2544
- r(this, "muted", !1);
2545
- r(this, "hasReceivedData", !1);
2546
- r(this, "audioContext");
2547
- r(this, "chunks", []);
2548
- r(this, "isPlaying", !1);
2549
- r(this, "startTime", 0);
2550
- r(this, "lastChunkOffset", 0);
2551
- r(this, "bufferSize", 3);
2552
- r(this, "receive", async (e) => {
2573
+ s(this, "muted", !1);
2574
+ s(this, "hasReceivedData", !1);
2575
+ s(this, "audioContext");
2576
+ s(this, "chunks", []);
2577
+ s(this, "isPlaying", !1);
2578
+ s(this, "startTime", 0);
2579
+ s(this, "lastChunkOffset", 0);
2580
+ s(this, "bufferSize", 3);
2581
+ s(this, "receive", async (e) => {
2553
2582
  var c;
2554
2583
  const t = (c = e.payload.audioChunk) == null ? void 0 : c.chunk_data;
2555
2584
  if (!t)
2556
2585
  return;
2557
2586
  this.hasReceivedData || (this.hasReceivedData = !0);
2558
2587
  const { audioContext: n, muted: i } = this;
2559
- if (!n || e.header.stream.streamType !== Ut || i !== !1)
2588
+ if (!n || e.header.stream.streamType !== Vt || i !== !1)
2560
2589
  return;
2561
- const s = xt(t);
2590
+ const o = Jt(t);
2562
2591
  try {
2563
2592
  await n.decodeAudioData(
2564
- s.buffer,
2593
+ o.buffer,
2565
2594
  this.scheduleChunk
2566
2595
  );
2567
2596
  } catch (d) {
@@ -2571,7 +2600,7 @@ class nn {
2571
2600
  ), this.changeAudioWireFormat("wav");
2572
2601
  }
2573
2602
  });
2574
- r(this, "scheduleChunk", (e) => {
2603
+ s(this, "scheduleChunk", (e) => {
2575
2604
  const { audioContext: t } = this;
2576
2605
  if (!t)
2577
2606
  return;
@@ -2581,9 +2610,9 @@ class nn {
2581
2610
  const n = this.createChunk(e);
2582
2611
  n && n.buffer && (this.isPlaying === !1 && (this.startTime = t.currentTime, this.lastChunkOffset = 0, this.isPlaying = !0), n.start(this.startTime + this.lastChunkOffset, 0, e.duration), this.lastChunkOffset += n.buffer.duration, this.chunks.push(n));
2583
2612
  });
2584
- this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, s) => {
2585
- this.receive(s);
2586
- }), U() === "Safari" || U() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
2613
+ this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, o) => {
2614
+ this.receive(o);
2615
+ }), V() === "Safari" || V() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
2587
2616
  const n = window.AudioContext || window.webkitAudioContext;
2588
2617
  this.audioContext = new n();
2589
2618
  }
@@ -2611,66 +2640,66 @@ class nn {
2611
2640
  (async () => await this.device.changeStreamAudioType(t.name, e))();
2612
2641
  }
2613
2642
  }
2614
- class an {
2643
+ class rn {
2615
2644
  static async listAccounts() {
2616
- if (!o.token)
2645
+ if (!r.token)
2617
2646
  throw new Error("Not authenticated");
2618
2647
  return (await (await fetch(`${h}/v1/admin/accounts`, {
2619
2648
  method: "GET",
2620
2649
  headers: {
2621
2650
  "Content-Type": "application/json",
2622
- Authorization: "Bearer " + o.token
2651
+ Authorization: "Bearer " + r.token
2623
2652
  }
2624
2653
  })).json()).items;
2625
2654
  }
2626
2655
  static async createAccounts(e) {
2627
- if (!o.token)
2656
+ if (!r.token)
2628
2657
  throw new Error("Not authenticated");
2629
2658
  return await (await fetch(`${h}/v1/admin/accounts`, {
2630
2659
  method: "POST",
2631
2660
  body: JSON.stringify(e),
2632
2661
  headers: {
2633
2662
  "Content-Type": "application/json",
2634
- Authorization: "Bearer " + o.token
2663
+ Authorization: "Bearer " + r.token
2635
2664
  }
2636
2665
  })).json();
2637
2666
  }
2638
2667
  static async getAccount(e) {
2639
- if (!o.token)
2668
+ if (!r.token)
2640
2669
  throw new Error("Not authenticated");
2641
2670
  return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
2642
2671
  method: "GET",
2643
2672
  headers: {
2644
2673
  "Content-Type": "application/json",
2645
- Authorization: "Bearer " + o.token
2674
+ Authorization: "Bearer " + r.token
2646
2675
  }
2647
2676
  })).json();
2648
2677
  }
2649
2678
  static async patchAccount(e, t) {
2650
- if (!o.token)
2679
+ if (!r.token)
2651
2680
  throw new Error("Not authenticated");
2652
2681
  return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
2653
2682
  method: "PATCH",
2654
2683
  body: JSON.stringify(t),
2655
2684
  headers: {
2656
2685
  "Content-Type": "application/json",
2657
- Authorization: "Bearer " + o.token
2686
+ Authorization: "Bearer " + r.token
2658
2687
  }
2659
2688
  })).json();
2660
2689
  }
2661
2690
  static async deleteAccount(e) {
2662
- if (!o.token)
2691
+ if (!r.token)
2663
2692
  throw new Error("Not authenticated");
2664
2693
  await fetch(`${h}/v1/admin/accounts/${e}`, {
2665
2694
  method: "DELETE",
2666
2695
  headers: {
2667
2696
  "Content-Type": "application/json",
2668
- Authorization: "Bearer " + o.token
2697
+ Authorization: "Bearer " + r.token
2669
2698
  }
2670
2699
  });
2671
2700
  }
2672
2701
  static async getAccountTree(e) {
2673
- if (!o.token)
2702
+ if (!r.token)
2674
2703
  throw new Error("Not authenticated");
2675
2704
  return await (await fetch(
2676
2705
  `${h}/v1/admin/accounts/${e}/tree`,
@@ -2678,139 +2707,139 @@ class an {
2678
2707
  method: "GET",
2679
2708
  headers: {
2680
2709
  "Content-Type": "application/json",
2681
- Authorization: "Bearer " + o.token
2710
+ Authorization: "Bearer " + r.token
2682
2711
  }
2683
2712
  }
2684
2713
  )).json();
2685
2714
  }
2686
2715
  }
2687
- class on {
2716
+ class sn {
2688
2717
  static async listRoles() {
2689
- if (!o.token)
2718
+ if (!r.token)
2690
2719
  throw new Error("Not authenticated");
2691
2720
  return (await (await fetch(`${h}/v1/admin/roles`, {
2692
2721
  method: "GET",
2693
2722
  headers: {
2694
2723
  "Content-Type": "application/json",
2695
- Authorization: "Bearer " + o.token
2724
+ Authorization: "Bearer " + r.token
2696
2725
  }
2697
2726
  })).json()).items;
2698
2727
  }
2699
2728
  static async createRole(e) {
2700
- if (!o.token)
2729
+ if (!r.token)
2701
2730
  throw new Error("Not authenticated");
2702
2731
  return await (await fetch(`${h}/v1/admin/roles`, {
2703
2732
  method: "POST",
2704
2733
  body: JSON.stringify(e),
2705
2734
  headers: {
2706
2735
  "Content-Type": "application/json",
2707
- Authorization: "Bearer " + o.token
2736
+ Authorization: "Bearer " + r.token
2708
2737
  }
2709
2738
  })).json();
2710
2739
  }
2711
2740
  static async getRole(e) {
2712
- if (!o.token)
2741
+ if (!r.token)
2713
2742
  throw new Error("Not authenticated");
2714
2743
  return await (await fetch(`${h}/v1/admin/roles/${e}`, {
2715
2744
  method: "GET",
2716
2745
  headers: {
2717
2746
  "Content-Type": "application/json",
2718
- Authorization: "Bearer " + o.token
2747
+ Authorization: "Bearer " + r.token
2719
2748
  }
2720
2749
  })).json();
2721
2750
  }
2722
2751
  static async patchRole(e, t) {
2723
- if (!o.token)
2752
+ if (!r.token)
2724
2753
  throw new Error("Not authenticated");
2725
2754
  return await (await fetch(`${h}/v1/admin/roles/${e}`, {
2726
2755
  method: "PATCH",
2727
2756
  body: JSON.stringify(t),
2728
2757
  headers: {
2729
2758
  "Content-Type": "application/json",
2730
- Authorization: "Bearer " + o.token
2759
+ Authorization: "Bearer " + r.token
2731
2760
  }
2732
2761
  })).json();
2733
2762
  }
2734
2763
  static async deleteRole(e) {
2735
- if (!o.token)
2764
+ if (!r.token)
2736
2765
  throw new Error("Not authenticated");
2737
2766
  await fetch(`${h}/v1/admin/roles/${e}`, {
2738
2767
  method: "DELETE",
2739
2768
  headers: {
2740
2769
  "Content-Type": "application/json",
2741
- Authorization: "Bearer " + o.token
2770
+ Authorization: "Bearer " + r.token
2742
2771
  }
2743
2772
  });
2744
2773
  }
2745
2774
  }
2746
- class rn {
2775
+ class cn {
2747
2776
  static async listUsers() {
2748
- if (!o.token)
2777
+ if (!r.token)
2749
2778
  throw new Error("Not authenticated");
2750
2779
  return (await (await fetch(`${h}/v1/admin/users`, {
2751
2780
  method: "GET",
2752
2781
  headers: {
2753
2782
  "Content-Type": "application/json",
2754
- Authorization: "Bearer " + o.token
2783
+ Authorization: "Bearer " + r.token
2755
2784
  }
2756
2785
  })).json()).items;
2757
2786
  }
2758
2787
  static async createUser(e) {
2759
- if (!o.token)
2788
+ if (!r.token)
2760
2789
  throw new Error("Not authenticated");
2761
2790
  return await (await fetch(`${h}/v1/admin/users`, {
2762
2791
  method: "POST",
2763
2792
  body: JSON.stringify(e),
2764
2793
  headers: {
2765
2794
  "Content-Type": "application/json",
2766
- Authorization: "Bearer " + o.token
2795
+ Authorization: "Bearer " + r.token
2767
2796
  }
2768
2797
  })).json();
2769
2798
  }
2770
2799
  static async getUser(e) {
2771
- if (!o.token)
2800
+ if (!r.token)
2772
2801
  throw new Error("Not authenticated");
2773
2802
  return await (await fetch(`${h}/v1/admin/users/${e}`, {
2774
2803
  method: "GET",
2775
2804
  headers: {
2776
2805
  "Content-Type": "application/json",
2777
- Authorization: "Bearer " + o.token
2806
+ Authorization: "Bearer " + r.token
2778
2807
  }
2779
2808
  })).json();
2780
2809
  }
2781
2810
  static async patchUser(e, t) {
2782
- if (!o.token)
2811
+ if (!r.token)
2783
2812
  throw new Error("Not authenticated");
2784
2813
  return await (await fetch(`${h}/v1/admin/users/${e}`, {
2785
2814
  method: "PATCH",
2786
2815
  body: JSON.stringify(t),
2787
2816
  headers: {
2788
2817
  "Content-Type": "application/json",
2789
- Authorization: "Bearer " + o.token
2818
+ Authorization: "Bearer " + r.token
2790
2819
  }
2791
2820
  })).json();
2792
2821
  }
2793
2822
  static async deleteUser(e) {
2794
- if (!o.token)
2823
+ if (!r.token)
2795
2824
  throw new Error("Not authenticated");
2796
2825
  await fetch(`${h}/v1/admin/users/${e}`, {
2797
2826
  method: "PATCH",
2798
2827
  body: JSON.stringify({ enabled: !1, roleId: null, teamId: null }),
2799
2828
  headers: {
2800
2829
  "Content-Type": "application/json",
2801
- Authorization: "Bearer " + o.token
2830
+ Authorization: "Bearer " + r.token
2802
2831
  }
2803
2832
  });
2804
2833
  }
2805
2834
  }
2806
- const sn = ["viewer", "operator", "administrator"], cn = "viewer", dn = "operator", hn = "administrator", un = [
2835
+ const dn = ["viewer", "operator", "administrator"], hn = "viewer", ln = "operator", un = "administrator", mn = [
2807
2836
  "year",
2808
2837
  "month",
2809
2838
  "week",
2810
2839
  "day",
2811
2840
  "hour",
2812
2841
  "minute"
2813
- ], ln = ["tag", "sheet", "user"], mn = [
2842
+ ], fn = ["tag", "sheet", "user"], wn = [
2814
2843
  "triggered-event",
2815
2844
  "intervention-request",
2816
2845
  "teleop-session-record",
@@ -2822,59 +2851,59 @@ const sn = ["viewer", "operator", "administrator"], cn = "viewer", dn = "operato
2822
2851
  "comment",
2823
2852
  "system",
2824
2853
  "annotation"
2825
- ], fn = [
2854
+ ], pn = [
2826
2855
  "unknown",
2827
2856
  "operational",
2828
2857
  "offline",
2829
2858
  "error"
2830
- ], wn = ["selection", "labeling", "teleop"], pn = ["info", "warning", "error", "critical"], yn = ["video/mp4"], gn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
2859
+ ], yn = ["selection", "labeling", "teleop"], gn = ["info", "warning", "error", "critical"], vn = ["video/mp4"], Tn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
2831
2860
  try {
2832
2861
  const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
2833
- e && u.setDefaultDevice(e);
2862
+ e && l.setDefaultDevice(e);
2834
2863
  const t = a.get("auth");
2835
- t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && g.listenForConnectionEvents();
2864
+ t && r.loginWithToken(t), a.get("module") && r.listenForRefresh(), typeof window < "u" && g.listenForConnectionEvents();
2836
2865
  } catch {
2837
2866
  }
2838
2867
  export {
2839
- an as Account,
2868
+ rn as Account,
2840
2869
  g as App,
2841
- nn as AudioPlayer,
2842
- o as Authentication,
2843
- Ke as BinaryRequestDataChannel,
2844
- Ge as CaptureStream,
2845
- Fe as DataChannel,
2870
+ on as AudioPlayer,
2871
+ r as Authentication,
2872
+ Xe as BinaryRequestDataChannel,
2873
+ Fe as CaptureStream,
2874
+ Ke as DataChannel,
2846
2875
  S as Device,
2847
- u as Fleet,
2848
- tn as KeyValue,
2849
- We as Manipulator,
2850
- lt as PeerDevice,
2851
- on as Role,
2852
- Xt as SessionType,
2853
- Qe as TextRequestDataChannel,
2854
- rn as User,
2855
- sn as accessLevels,
2856
- hn as administrator,
2857
- Z as aggregateByDateFunctions,
2858
- en as aggregateFunctionMap,
2859
- Zt as aggregateFunctions,
2860
- un as aggregateLevels,
2861
- ln as annotationTypes,
2862
- mn as eventTypes,
2863
- rt as formatTimeFrameText,
2864
- at as getAverage,
2865
- ot as getCount,
2866
- tt as getMax,
2867
- nt as getMin,
2868
- et as getStandardDeviation,
2869
- it as getSum,
2870
- Ze as getVariance,
2871
- fn as healthStatuses,
2872
- wn as interventionTypes,
2873
- dn as operator,
2874
- pn as severities,
2875
- gn as timeout,
2876
- Yt as vailableAggregationIntervals,
2877
- yn as videoMimeTypes,
2878
- cn as viewer
2876
+ l as Fleet,
2877
+ an as KeyValue,
2878
+ Qe as Manipulator,
2879
+ ft as PeerDevice,
2880
+ sn as Role,
2881
+ Zt as SessionType,
2882
+ Ye as TextRequestDataChannel,
2883
+ cn as User,
2884
+ dn as accessLevels,
2885
+ un as administrator,
2886
+ te as aggregateByDateFunctions,
2887
+ nn as aggregateFunctionMap,
2888
+ tn as aggregateFunctions,
2889
+ mn as aggregateLevels,
2890
+ fn as annotationTypes,
2891
+ wn as eventTypes,
2892
+ ct as formatTimeFrameText,
2893
+ ot as getAverage,
2894
+ st as getCount,
2895
+ at as getMax,
2896
+ it as getMin,
2897
+ nt as getStandardDeviation,
2898
+ rt as getSum,
2899
+ tt as getVariance,
2900
+ pn as healthStatuses,
2901
+ yn as interventionTypes,
2902
+ ln as operator,
2903
+ gn as severities,
2904
+ Tn as timeout,
2905
+ en as vailableAggregationIntervals,
2906
+ vn as videoMimeTypes,
2907
+ hn as viewer
2879
2908
  };
2880
2909
  //# sourceMappingURL=data-sdk.es.js.map