@formant/data-sdk 1.11.1 → 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";
7
- import { RtcClient as j, SignalingPromiseClient as N } 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) {
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
+ import { RtcClient as A, SignalingPromiseClient as j } from "@formant/realtime-sdk";
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 be(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 be(a, e) {
337
366
  };
338
367
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
339
368
  }
340
- function Ae(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 je(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 Ne(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 Ne(a) {
364
393
  };
365
394
  return window.addEventListener("message", t), () => window.removeEventListener("message", t);
366
395
  }
367
- function De(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 De(a) {
372
401
  };
373
402
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
374
403
  }
375
- const Pe = 1, F = 1e3, W = 60 * F, H = 60 * W, I = 24 * H, Ie = 7 * I, Le = 30 * I, _e = 365 * I, L = {
376
- millisecond: Pe,
377
- second: F,
378
- minute: W,
379
- hour: H,
380
- day: I,
381
- week: Ie,
382
- month: Le,
383
- year: _e
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,
409
+ day: L,
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");
406
- this.capacity = e || 1e4, this.timeout = t || L.minute;
431
+ s(this, "entries", /* @__PURE__ */ new Map());
432
+ s(this, "metadata", /* @__PURE__ */ new Map());
433
+ s(this, "capacity");
434
+ s(this, "timeout");
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
- timeout: 20 * L.second
496
+ timeout: 20 * I.second
468
497
  }));
469
- r(this, "liveQueryStoreCache", new x({
498
+ s(this, "liveQueryStoreCache", new J({
470
499
  capacity: 1e4,
471
- timeout: 200 * L.millisecond
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
- }, p = this.query(d, i, s, c);
480
- return p === void 0 || p === "too much data" ? p : $e(p, 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,59 +629,62 @@ 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
- let y = q;
611
- r(y, "getCurrentModuleContext", k), // senders
612
- r(y, "disableAnalyticsBottomBar", ve), r(y, "goToDevice", Te), r(y, "goToTime", Ce), r(y, "refreshAuthToken", V), r(y, "requestModuleData", Se), r(y, "sendChannelData", Ee), r(y, "setModuleDateTimeRange", ke), r(y, "setupModuleMenus", Oe), r(y, "showMessage", Re), // listeners
613
- r(y, "addAccessTokenRefreshListener", G), r(y, "addChannelDataListener", be), r(y, "addMenuListener", Ae), r(y, "addModuleConfigurationListener", je), r(y, "addModuleDataListener", Ne), r(y, "addOverviewDeviceListener", De), r(y, "addStreamListener", qe), // bidirectional
614
- r(y, "getDate", xe), r(y, "prompt", Ue), r(y, "_isOnline", null);
639
+ let g = q;
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;
618
647
  throw new Error(e || "Value is undefined");
619
648
  }
620
- const g = {
649
+ const p = {
621
650
  UNKNOWN: 0,
622
651
  TELEOP: 1,
623
652
  PORT_FORWARD: 2,
624
- OBSERVE: 3
625
- }, Xt = {
626
- ...g,
627
- Unknown: g.UNKNOWN,
628
- Teleop: g.TELEOP,
629
- PortForward: g.PORT_FORWARD,
630
- Observe: g.OBSERVE,
631
- unknown: g.UNKNOWN,
632
- teleop: g.TELEOP,
633
- portForward: g.PORT_FORWARD,
634
- observe: g.OBSERVE
653
+ OBSERVE: 3,
654
+ HEADLESS: 4
655
+ }, Zt = {
656
+ ...p,
657
+ Unknown: p.UNKNOWN,
658
+ Teleop: p.TELEOP,
659
+ PortForward: p.PORT_FORWARD,
660
+ Observe: p.OBSERVE,
661
+ Headless: p.HEADLESS,
662
+ unknown: p.UNKNOWN,
663
+ teleop: p.TELEOP,
664
+ portForward: p.PORT_FORWARD,
665
+ observe: p.OBSERVE,
666
+ headless: p.HEADLESS
635
667
  }, O = Symbol("RtcClientPool.instance");
636
- var Jt;
637
- class D {
668
+ var Gt;
669
+ class N {
638
670
  constructor(e) {
639
- r(this, Jt, null);
640
- r(this, "createClient");
641
- r(this, "ttlMs");
642
- r(this, "proxyHandler");
643
- r(this, "proxyReceivers", /* @__PURE__ */ new Map());
644
- r(this, "teardownTimeout", null);
645
- 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) => {
646
678
  this.proxyReceivers.forEach((n) => n == null ? void 0 : n(e, t));
647
679
  });
648
680
  const { createClient: t, ttlMs: n = 0 } = e;
649
681
  this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
650
- get: (i, s, c) => {
651
- switch (s) {
682
+ get: (i, o, c) => {
683
+ switch (o) {
652
684
  case "shutdown":
653
685
  return () => this.releaseInstance(c);
654
686
  default:
655
- return Reflect.get(i, s, c);
687
+ return Reflect.get(i, o, c);
656
688
  }
657
689
  }
658
690
  };
@@ -691,57 +723,67 @@ class D {
691
723
  }, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
692
724
  }
693
725
  }
694
- Jt = O;
695
- const P = async () => f(o.token, "Realtime when user isn't authorized"), R = {
696
- [g.UNKNOWN]: new D({
726
+ Gt = O;
727
+ const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
728
+ [p.UNKNOWN]: new N({
729
+ ttlMs: 2500,
730
+ createClient: (a) => new A({
731
+ signalingClient: new j(h),
732
+ getToken: P,
733
+ sessionType: p.UNKNOWN,
734
+ receive: a
735
+ })
736
+ }),
737
+ [p.TELEOP]: new N({
697
738
  ttlMs: 2500,
698
- createClient: (a) => new j({
699
- signalingClient: new N(h),
739
+ createClient: (a) => new A({
740
+ signalingClient: new j(h),
700
741
  getToken: P,
701
- sessionType: g.UNKNOWN,
742
+ sessionType: p.TELEOP,
702
743
  receive: a
703
744
  })
704
745
  }),
705
- [g.TELEOP]: new D({
746
+ [p.PORT_FORWARD]: new N({
706
747
  ttlMs: 2500,
707
- createClient: (a) => new j({
708
- signalingClient: new N(h),
748
+ createClient: (a) => new A({
749
+ signalingClient: new j(h),
709
750
  getToken: P,
710
- sessionType: g.TELEOP,
751
+ sessionType: p.PORT_FORWARD,
711
752
  receive: a
712
753
  })
713
754
  }),
714
- [g.PORT_FORWARD]: new D({
755
+ [p.OBSERVE]: new N({
715
756
  ttlMs: 2500,
716
- createClient: (a) => new j({
717
- signalingClient: new N(h),
757
+ createClient: (a) => new A({
758
+ signalingClient: new j(h),
718
759
  getToken: P,
719
- sessionType: g.PORT_FORWARD,
760
+ sessionType: p.OBSERVE,
720
761
  receive: a
721
762
  })
722
763
  }),
723
- [g.OBSERVE]: new D({
764
+ [p.HEADLESS]: new N({
724
765
  ttlMs: 2500,
725
- createClient: (a) => new j({
726
- signalingClient: new N(h),
766
+ createClient: (a) => new A({
767
+ signalingClient: new j(h),
727
768
  getToken: P,
728
- sessionType: g.OBSERVE,
769
+ sessionType: p.HEADLESS,
729
770
  receive: a
730
771
  })
731
772
  })
732
- }, Je = {
773
+ }, Ge = {
733
774
  ...R,
734
- unknown: R[g.UNKNOWN],
735
- teleop: R[g.TELEOP],
736
- portForward: R[g.PORT_FORWARD],
737
- observe: R[g.OBSERVE]
738
- }, $ = R[g.TELEOP], Ve = (a) => {
775
+ unknown: R[p.UNKNOWN],
776
+ teleop: R[p.TELEOP],
777
+ portForward: R[p.PORT_FORWARD],
778
+ observe: R[p.OBSERVE],
779
+ headless: R[p.HEADLESS]
780
+ }, $ = R[p.TELEOP], He = (a) => {
739
781
  const { sessionType: e } = a;
740
- return e ? Je[e] : $;
782
+ return e ? Ge[e] : $;
741
783
  };
742
- class Ge {
784
+ class Fe {
743
785
  constructor(e) {
744
- r(this, "token");
786
+ s(this, "token");
745
787
  this.captureSession = e;
746
788
  }
747
789
  async ingestJSON(e) {
@@ -772,17 +814,17 @@ class Ge {
772
814
  function b(a) {
773
815
  return new Promise((e) => setTimeout(e, a));
774
816
  }
775
- const Fe = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
776
- class We {
817
+ const We = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
818
+ class Ke {
777
819
  constructor(e) {
778
- r(this, "ready", !1);
779
- r(this, "listeners", []);
780
- r(this, "openListeners", []);
781
- r(this, "closeListeners", []);
782
- r(this, "errorListeners", []);
783
- r(this, "binaryListeners", []);
784
- r(this, "error");
785
- 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());
786
828
  this.dataChannel = e, this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = () => {
787
829
  this.setReady();
788
830
  }, this.dataChannel.onclose = () => {
@@ -791,8 +833,8 @@ class We {
791
833
  console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
792
834
  }, this.dataChannel.onmessage = (t) => {
793
835
  this.listeners.forEach((n) => {
794
- const i = new Uint8Array(t.data), s = this.decoder.decode(i);
795
- n(s);
836
+ const i = new Uint8Array(t.data), o = this.decoder.decode(i);
837
+ n(o);
796
838
  }), this.binaryListeners.forEach((n) => {
797
839
  n(new Uint8Array(t.data));
798
840
  });
@@ -859,10 +901,10 @@ class We {
859
901
  this.binaryListeners.splice(t, 1);
860
902
  }
861
903
  }
862
- class He {
904
+ class Qe {
863
905
  constructor(e, t) {
864
- r(this, "currentListeners", []);
865
- r(this, "onRealtimeMessage", (e, t) => {
906
+ s(this, "currentListeners", []);
907
+ s(this, "onRealtimeMessage", (e, t) => {
866
908
  t.payload.jointState && this.currentListeners.forEach((n) => {
867
909
  t.payload.jointState && n(t.payload.jointState);
868
910
  });
@@ -883,10 +925,10 @@ class He {
883
925
  this.currentListeners.push(e);
884
926
  }
885
927
  }
886
- class K {
928
+ class X {
887
929
  constructor(e, t, n) {
888
- r(this, "channel");
889
- r(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
930
+ s(this, "channel");
931
+ s(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
890
932
  this.device = e, this.channel_name = t, this.timeout = n;
891
933
  }
892
934
  addOpenListener(e) {
@@ -914,11 +956,11 @@ class K {
914
956
  );
915
957
  }
916
958
  }
917
- class Ke extends K {
959
+ class Xe extends X {
918
960
  constructor() {
919
961
  super(...arguments);
920
- r(this, "RESPONSE_SUCCESS_BYTE", 0);
921
- r(this, "decoder", new TextDecoder());
962
+ s(this, "RESPONSE_SUCCESS_BYTE", 0);
963
+ s(this, "decoder", new TextDecoder());
922
964
  }
923
965
  /*
924
966
  Request binary payload layout:
@@ -940,21 +982,21 @@ class Ke extends K {
940
982
  const i = t.slice(0, 16).toString();
941
983
  if (i.length === 0)
942
984
  throw new Error("Invalid response");
943
- const s = t.slice(16);
944
- if (s.length === 0)
985
+ const o = t.slice(16);
986
+ if (o.length === 0)
945
987
  throw new Error("Invalid response");
946
- this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, s);
988
+ this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, o);
947
989
  });
948
990
  }
949
991
  async request(t) {
950
992
  if (this.channel || await this.initialize(), !this.channel)
951
993
  throw new Error("Failed to create channel");
952
- const { channel: n, requestIdToResponseMap: i, timeout: s } = this;
994
+ const { channel: n, requestIdToResponseMap: i, timeout: o } = this;
953
995
  await n.waitTilReady();
954
996
  const c = this.generateBinaryId(), d = c.toString();
955
997
  i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
956
- const p = (/* @__PURE__ */ new Date()).getTime();
957
- for (; (/* @__PURE__ */ new Date()).getTime() < p + s; )
998
+ const y = (/* @__PURE__ */ new Date()).getTime();
999
+ for (; (/* @__PURE__ */ new Date()).getTime() < y + o; )
958
1000
  if (await b(50), i.has(d)) {
959
1001
  const m = i.get(d);
960
1002
  if (m !== !0) {
@@ -970,20 +1012,20 @@ class Ke extends K {
970
1012
  }
971
1013
  throw i.delete(d), console.error({
972
1014
  name: "TimeoutError",
973
- message: `Request timed out after ${s / 1e3} seconds`
1015
+ message: `Request timed out after ${o / 1e3} seconds`
974
1016
  }), new Error("Binary request data channel request timed out");
975
1017
  }
976
1018
  }
977
- class Qe extends K {
1019
+ class Ye extends X {
978
1020
  generateTextId() {
979
1021
  return Math.random().toString(36).substring(2) + "-" + Math.random().toString(36).substring(2);
980
1022
  }
981
1023
  async initialize() {
982
1024
  this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
983
- 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;
984
1026
  if (!n)
985
1027
  throw new Error("Invalid response");
986
- if (!i && !s)
1028
+ if (!i && !o)
987
1029
  throw new Error("Invalid response");
988
1030
  this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
989
1031
  });
@@ -993,22 +1035,22 @@ class Qe extends K {
993
1035
  throw new Error("Failed to create channel");
994
1036
  const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
995
1037
  await t.waitTilReady();
996
- const s = this.generateTextId();
997
- n.set(s, !0), t.send(
1038
+ const o = this.generateTextId();
1039
+ n.set(o, !0), t.send(
998
1040
  JSON.stringify({
999
- id: s,
1041
+ id: o,
1000
1042
  data: e
1001
1043
  })
1002
1044
  );
1003
1045
  const c = (/* @__PURE__ */ new Date()).getTime();
1004
1046
  for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
1005
- if (await b(50), n.has(s)) {
1006
- const d = n.get(s);
1047
+ if (await b(50), n.has(o)) {
1048
+ const d = n.get(o);
1007
1049
  if (d !== !0) {
1008
- n.delete(s);
1009
- const { data: p, error: m } = d;
1010
- if (p)
1011
- return p;
1050
+ n.delete(o);
1051
+ const { data: y, error: m } = d;
1052
+ if (y)
1053
+ return y;
1012
1054
  if (m)
1013
1055
  throw console.error({
1014
1056
  name: "AdapterError",
@@ -1016,20 +1058,20 @@ class Qe extends K {
1016
1058
  }), new Error("Text request datachannel adapter error");
1017
1059
  }
1018
1060
  }
1019
- throw n.delete(s), console.error({
1061
+ throw n.delete(o), console.error({
1020
1062
  name: "TimeoutError",
1021
1063
  message: `Request timed out after ${i / 1e3} seconds`
1022
1064
  }), new Error("Text request datachannel request timed out");
1023
1065
  }
1024
1066
  }
1025
- class Q extends le {
1067
+ class Y extends fe {
1026
1068
  constructor() {
1027
1069
  super(...arguments);
1028
- r(this, "rtcClient");
1029
- r(this, "remoteDevicePeerId", null);
1030
- r(this, "realtimeListeners", []);
1031
- r(this, "connectionMonitorInterval");
1032
- 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) => {
1033
1075
  this.realtimeListeners.forEach((i) => i(t, n));
1034
1076
  });
1035
1077
  }
@@ -1063,7 +1105,7 @@ class Q extends le {
1063
1105
  const t = await this.getConfiguration(), n = [];
1064
1106
  for (const i of t.teleop.rosStreams ?? [])
1065
1107
  i.topicType == "sensor_msgs/JointState" && n.push(
1066
- new He(this, {
1108
+ new Qe(this, {
1067
1109
  currentJointStateStream: { name: i.topicName },
1068
1110
  plannedJointStateStream: i.plannedTopic ? { name: i.plannedTopic } : void 0,
1069
1111
  planValidStream: i.planValidTopic ? { name: i.planValidTopic } : void 0,
@@ -1076,13 +1118,13 @@ class Q extends le {
1076
1118
  return n;
1077
1119
  }
1078
1120
  async getRealtimeVideoStreams() {
1079
- var i, s, c;
1121
+ var i, o, c;
1080
1122
  const t = await this.getConfiguration(), n = [];
1081
1123
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1082
1124
  d.rtcStreamType === "h264-video-frame" && n.push({
1083
1125
  name: d.name
1084
1126
  });
1085
- 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) ?? [])
1086
1128
  d.topicType == "formant/H264VideoFrame" && n.push({
1087
1129
  name: d.topicName
1088
1130
  }), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
@@ -1095,10 +1137,10 @@ class Q extends le {
1095
1137
  return n;
1096
1138
  }
1097
1139
  createCustomRequestDataChannel(t, n = 3e3) {
1098
- return new Qe(this, t, n);
1140
+ return new Ye(this, t, n);
1099
1141
  }
1100
1142
  createCustomBinaryRequestDataChannel(t, n = 3e3) {
1101
- return new Ke(this, t, n);
1143
+ return new Xe(this, t, n);
1102
1144
  }
1103
1145
  async startListeningToRealtimeVideo(t) {
1104
1146
  const n = f(
@@ -1170,8 +1212,8 @@ class Q extends le {
1170
1212
  const i = f(
1171
1213
  this.rtcClient,
1172
1214
  "Realtime connection has not been started"
1173
- ), s = await this.getRemotePeer();
1174
- i.controlRemoteStream(f(s).id, {
1215
+ ), o = await this.getRemotePeer();
1216
+ i.controlRemoteStream(f(o).id, {
1175
1217
  streamName: t,
1176
1218
  setAudioFormat: n
1177
1219
  });
@@ -1180,17 +1222,17 @@ class Q extends le {
1180
1222
  const i = f(
1181
1223
  this.rtcClient,
1182
1224
  "Realtime connection has not been started"
1183
- ), s = await this.getRemotePeer(), c = await new Promise((d) => {
1225
+ ), o = await this.getRemotePeer(), c = await new Promise((d) => {
1184
1226
  i.createCustomDataChannel(
1185
- f(s).id,
1227
+ f(o).id,
1186
1228
  t,
1187
1229
  {
1188
1230
  ordered: !0,
1189
1231
  ...n
1190
1232
  },
1191
1233
  !1,
1192
- (p, m) => {
1193
- const w = new We(m);
1234
+ (y, m) => {
1235
+ const w = new Ke(m);
1194
1236
  d(w);
1195
1237
  }
1196
1238
  );
@@ -1203,17 +1245,17 @@ class Q extends le {
1203
1245
  const i = f(
1204
1246
  this.rtcClient,
1205
1247
  "Realtime connection has not been started"
1206
- ), s = await this.getRemotePeer();
1207
- i.send(f(s).id, t, n);
1248
+ ), o = await this.getRemotePeer();
1249
+ i.send(f(o).id, t, n);
1208
1250
  }
1209
1251
  async getRealtimeAudioStreams() {
1210
- var i, s, c;
1252
+ var i, o, c;
1211
1253
  const t = await this.getConfiguration(), n = [];
1212
1254
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1213
1255
  d.rtcStreamType === "audio-chunk" && n.push({
1214
1256
  name: d.name
1215
1257
  });
1216
- 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) ?? [])
1217
1259
  d.topicType == "audio_common_msgs/AudioData" && n.push({
1218
1260
  name: d.topicName
1219
1261
  });
@@ -1224,27 +1266,27 @@ class Q extends le {
1224
1266
  return n;
1225
1267
  }
1226
1268
  }
1227
- const Xe = new TextEncoder();
1269
+ const Ze = new TextEncoder();
1228
1270
  new TextDecoder();
1229
- function Ye(a) {
1230
- const e = JSON.stringify(a), t = Xe.encode(e), n = me(t);
1231
- return fe(n);
1271
+ function et(a) {
1272
+ const e = JSON.stringify(a), t = Ze.encode(e), n = we(t);
1273
+ return pe(n);
1232
1274
  }
1233
- async function X() {
1234
- if (!o.token)
1275
+ async function Z() {
1276
+ if (!r.token)
1235
1277
  throw new Error("Not authenticated");
1236
1278
  return (await (await fetch(`${h}/v1/admin/views`, {
1237
1279
  method: "GET",
1238
1280
  headers: {
1239
1281
  "Content-Type": "application/json",
1240
- Authorization: "Bearer " + o.token
1282
+ Authorization: "Bearer " + r.token
1241
1283
  }
1242
1284
  })).json()).items;
1243
1285
  }
1244
- async function Y(a, e) {
1245
- if (!o.token)
1286
+ async function ee(a, e) {
1287
+ if (!r.token)
1246
1288
  throw new Error("Not authenticated");
1247
- const n = (await X()).filter((d) => d.name === e);
1289
+ const n = (await Z()).filter((d) => d.name === e);
1248
1290
  if (n.length === 0)
1249
1291
  return console.warn("View does not exist or it is misspell"), null;
1250
1292
  const i = await fetch(`${h}/v1/admin/shares`, {
@@ -1252,14 +1294,14 @@ async function Y(a, e) {
1252
1294
  body: JSON.stringify(a),
1253
1295
  headers: {
1254
1296
  "Content-Type": "application/json",
1255
- Authorization: "Bearer " + o.token
1297
+ Authorization: "Bearer " + r.token
1256
1298
  }
1257
- }), s = h.replace("api", "app"), { code: c } = await i.json();
1258
- return `${s}/shares/${c}#${Ye({
1299
+ }), o = h.replace("api", "app"), { code: c } = await i.json();
1300
+ return `${o}/shares/${c}#${et({
1259
1301
  viewId: n[0].id
1260
1302
  })}`;
1261
1303
  }
1262
- const Yt = [
1304
+ const en = [
1263
1305
  "day",
1264
1306
  "week",
1265
1307
  "month",
@@ -1267,92 +1309,92 @@ const Yt = [
1267
1309
  "hour",
1268
1310
  "minute",
1269
1311
  "quarter"
1270
- ], Zt = [
1312
+ ], tn = [
1271
1313
  "interval",
1272
1314
  "start",
1273
1315
  "end",
1274
1316
  "sub",
1275
1317
  "get"
1276
1318
  ];
1277
- function Ze(a) {
1319
+ function tt(a) {
1278
1320
  return a.count < 2 ? 0 : a.sumOfSquares / (a.count - 1);
1279
1321
  }
1280
- function et(a) {
1281
- return Math.sqrt(Ze(a));
1322
+ function nt(a) {
1323
+ return Math.sqrt(tt(a));
1282
1324
  }
1283
- function tt(a) {
1325
+ function at(a) {
1284
1326
  return a.max;
1285
1327
  }
1286
- function nt(a) {
1328
+ function it(a) {
1287
1329
  return a.min;
1288
1330
  }
1289
- function at(a) {
1331
+ function ot(a) {
1290
1332
  return a.count === 0 ? -1 : a.sum / a.count;
1291
1333
  }
1292
- function it(a) {
1334
+ function rt(a) {
1293
1335
  return a.sum;
1294
1336
  }
1295
- function ot(a) {
1337
+ function st(a) {
1296
1338
  return a.count;
1297
1339
  }
1298
- const en = {
1299
- min: nt,
1300
- max: tt,
1301
- "standard deviation": et,
1302
- average: at,
1303
- sum: it,
1304
- count: ot
1305
- }, 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 = {
1306
1348
  day: {
1307
- interval: l.eachDayOfInterval,
1308
- start: l.startOfDay,
1309
- end: l.endOfDay,
1310
- sub: l.subDays,
1311
- get: l.getDay
1349
+ interval: u.eachDayOfInterval,
1350
+ start: u.startOfDay,
1351
+ end: u.endOfDay,
1352
+ sub: u.subDays,
1353
+ get: u.getDay
1312
1354
  },
1313
1355
  week: {
1314
- interval: l.eachWeekOfInterval,
1315
- start: l.startOfWeek,
1316
- end: l.endOfWeek,
1317
- sub: l.subWeeks,
1318
- get: l.getWeek
1356
+ interval: u.eachWeekOfInterval,
1357
+ start: u.startOfWeek,
1358
+ end: u.endOfWeek,
1359
+ sub: u.subWeeks,
1360
+ get: u.getWeek
1319
1361
  },
1320
1362
  month: {
1321
- interval: l.eachMonthOfInterval,
1322
- start: l.startOfMonth,
1323
- end: l.endOfMonth,
1324
- sub: l.subMonths,
1325
- get: l.getMonth
1363
+ interval: u.eachMonthOfInterval,
1364
+ start: u.startOfMonth,
1365
+ end: u.endOfMonth,
1366
+ sub: u.subMonths,
1367
+ get: u.getMonth
1326
1368
  },
1327
1369
  year: {
1328
- interval: l.eachYearOfInterval,
1329
- start: l.startOfYear,
1330
- end: l.endOfYear,
1331
- sub: l.subYears,
1332
- get: l.getYear
1370
+ interval: u.eachYearOfInterval,
1371
+ start: u.startOfYear,
1372
+ end: u.endOfYear,
1373
+ sub: u.subYears,
1374
+ get: u.getYear
1333
1375
  },
1334
1376
  hour: {
1335
- interval: l.eachHourOfInterval,
1336
- start: l.startOfHour,
1337
- end: l.endOfHour,
1338
- sub: l.subHours,
1339
- get: l.getHours
1377
+ interval: u.eachHourOfInterval,
1378
+ start: u.startOfHour,
1379
+ end: u.endOfHour,
1380
+ sub: u.subHours,
1381
+ get: u.getHours
1340
1382
  },
1341
1383
  minute: {
1342
- interval: l.eachMinuteOfInterval,
1343
- start: l.startOfMinute,
1344
- end: l.endOfMinute,
1345
- sub: l.subMinutes,
1346
- get: l.getMinutes
1384
+ interval: u.eachMinuteOfInterval,
1385
+ start: u.startOfMinute,
1386
+ end: u.endOfMinute,
1387
+ sub: u.subMinutes,
1388
+ get: u.getMinutes
1347
1389
  },
1348
1390
  quarter: {
1349
- interval: l.eachQuarterOfInterval,
1350
- start: l.startOfQuarter,
1351
- end: l.endOfQuarter,
1352
- sub: l.subQuarters,
1353
- get: l.getQuarter
1391
+ interval: u.eachQuarterOfInterval,
1392
+ start: u.startOfQuarter,
1393
+ end: u.endOfQuarter,
1394
+ sub: u.subQuarters,
1395
+ get: u.getQuarter
1354
1396
  }
1355
- }, rt = (a, e) => (
1397
+ }, ct = (a, e) => (
1356
1398
  // FIXME this doesn't work for *a lot* locales, other than en-US
1357
1399
  // en-GB: 'dd/mm/YYYY'
1358
1400
  // ja-jp: 'YYYY/mm/dd'
@@ -1360,28 +1402,28 @@ const en = {
1360
1402
  a.split("/")[0] + "/" + a.split("/")[1] + "–" + e.split("/")[0] + "/" + e.split("/")[1]
1361
1403
  );
1362
1404
  async function z(a) {
1363
- if (!o.token)
1405
+ if (!r.token)
1364
1406
  throw new Error("Not authenticated");
1365
1407
  return (await (await fetch(`${h}/v1/admin/events/query`, {
1366
1408
  method: "POST",
1367
1409
  body: JSON.stringify(a),
1368
1410
  headers: {
1369
1411
  "Content-Type": "application/json",
1370
- Authorization: "Bearer " + o.token
1412
+ Authorization: "Bearer " + r.token
1371
1413
  }
1372
1414
  })).json()).items;
1373
1415
  }
1374
- async function ee(a, e, t, n, i) {
1375
- const s = Z[e];
1416
+ async function ne(a, e, t, n, i) {
1417
+ const o = te[e];
1376
1418
  return await Promise.all(
1377
1419
  Array(t).fill(0).map(async (c, d) => {
1378
- const p = new Date(n), m = s.sub(
1379
- s.start(p),
1420
+ const y = new Date(n), m = o.sub(
1421
+ o.start(y),
1380
1422
  t - d - 1
1381
- ), w = s.sub(
1382
- s.end(p),
1423
+ ), w = o.sub(
1424
+ o.end(y),
1383
1425
  t - d - 1
1384
- ), v = rt(
1426
+ ), v = ct(
1385
1427
  m.toLocaleDateString(),
1386
1428
  w.toLocaleDateString()
1387
1429
  ), C = await z({
@@ -1399,14 +1441,14 @@ async function B(a, e) {
1399
1441
  ...a,
1400
1442
  eventTypes: ["annotation"]
1401
1443
  })).filter(
1402
- (s) => !!s.tags && Object.keys(s.tags).includes(e)
1403
- ).reduce((s, c) => {
1444
+ (o) => !!o.tags && Object.keys(o.tags).includes(e)
1445
+ ).reduce((o, c) => {
1404
1446
  const d = c.tags[e];
1405
- 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);
1406
1448
  }, {});
1407
1449
  }
1408
- async function te(a, e, t) {
1409
- 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({
1410
1452
  start: new Date(i),
1411
1453
  end: new Date(n)
1412
1454
  }), d = c.map((m, w) => {
@@ -1419,20 +1461,20 @@ async function te(a, e, t) {
1419
1461
  },
1420
1462
  e
1421
1463
  );
1422
- }), p = await Promise.all(d);
1464
+ }), y = await Promise.all(d);
1423
1465
  return c.map((m, w) => ({
1424
1466
  date: new Date(m).toISOString(),
1425
- annotations: p[w]
1467
+ annotations: y[w]
1426
1468
  }));
1427
1469
  }
1428
- async function ne(a, e, t, n, i) {
1429
- let s = a;
1430
- Array.isArray(a) || (s = [a]);
1470
+ async function ie(a, e, t, n, i) {
1471
+ let o = a;
1472
+ Array.isArray(a) || (o = [a]);
1431
1473
  let c = e;
1432
1474
  return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
1433
1475
  method: "POST",
1434
1476
  body: JSON.stringify({
1435
- deviceIds: s,
1477
+ deviceIds: o,
1436
1478
  end: n.toISOString(),
1437
1479
  names: c,
1438
1480
  start: t.toISOString(),
@@ -1440,12 +1482,12 @@ async function ne(a, e, t, n, i) {
1440
1482
  }),
1441
1483
  headers: {
1442
1484
  "Content-Type": "application/json",
1443
- Authorization: "Bearer " + o.token
1485
+ Authorization: "Bearer " + r.token
1444
1486
  }
1445
1487
  })).json()).items;
1446
1488
  }
1447
- async function ae() {
1448
- if (!o.token)
1489
+ async function oe() {
1490
+ if (!r.token)
1449
1491
  throw new Error("Not authenticated");
1450
1492
  const a = $.get();
1451
1493
  try {
@@ -1454,8 +1496,8 @@ async function ae() {
1454
1496
  await a.shutdown();
1455
1497
  }
1456
1498
  }
1457
- async function ie() {
1458
- if (!o.token)
1499
+ async function re() {
1500
+ if (!r.token)
1459
1501
  throw new Error("Not authenticated");
1460
1502
  const a = $.get();
1461
1503
  try {
@@ -1464,56 +1506,56 @@ async function ie() {
1464
1506
  await a.shutdown();
1465
1507
  }
1466
1508
  }
1467
- async function st(a) {
1468
- if (!o.token)
1509
+ async function dt(a) {
1510
+ if (!r.token)
1469
1511
  throw new Error("Not authenticated");
1470
1512
  return await (await fetch(`${h}/v1/admin/devices`, {
1471
1513
  method: "POST",
1472
1514
  body: JSON.stringify(a),
1473
1515
  headers: {
1474
1516
  "Content-Type": "application/json",
1475
- Authorization: "Bearer " + o.token
1517
+ Authorization: "Bearer " + r.token
1476
1518
  }
1477
1519
  })).json();
1478
1520
  }
1479
- async function ct(a, e) {
1480
- if (!o.token)
1521
+ async function ht(a, e) {
1522
+ if (!r.token)
1481
1523
  throw new Error("Not authenticated");
1482
1524
  return await (await fetch(`${h}/v1/admin/devices/${a}`, {
1483
1525
  method: "PATCH",
1484
1526
  body: JSON.stringify(e),
1485
1527
  headers: {
1486
1528
  "Content-Type": "application/json",
1487
- Authorization: "Bearer " + o.token
1529
+ Authorization: "Bearer " + r.token
1488
1530
  }
1489
1531
  })).json();
1490
1532
  }
1491
- async function dt() {
1492
- if (!o.token)
1533
+ async function lt() {
1534
+ if (!r.token)
1493
1535
  throw new Error("Not authenticated");
1494
1536
  return (await (await fetch(`${h}/v1/admin/device-details/query`, {
1495
1537
  method: "POST",
1496
1538
  body: JSON.stringify({ enabled: !0, type: "default" }),
1497
1539
  headers: {
1498
1540
  "Content-Type": "application/json",
1499
- Authorization: "Bearer " + o.token
1541
+ Authorization: "Bearer " + r.token
1500
1542
  }
1501
1543
  })).json()).items;
1502
1544
  }
1503
- async function ht(a) {
1504
- if (!o.token)
1545
+ async function ut(a) {
1546
+ if (!r.token)
1505
1547
  throw new Error("Not authenticated");
1506
1548
  return (await (await fetch(`${h}/v1/admin/devices/query`, {
1507
1549
  method: "POST",
1508
1550
  body: JSON.stringify(a),
1509
1551
  headers: {
1510
1552
  "Content-Type": "application/json",
1511
- Authorization: "Bearer " + o.token
1553
+ Authorization: "Bearer " + r.token
1512
1554
  }
1513
1555
  })).json()).items;
1514
1556
  }
1515
- async function ut(a) {
1516
- if (!o.token)
1557
+ async function mt(a) {
1558
+ if (!r.token)
1517
1559
  throw new Error("Not authenticated");
1518
1560
  return await (await fetch(
1519
1561
  `${h}/v1/admin/devices/${a}/disable`,
@@ -1521,12 +1563,12 @@ async function ut(a) {
1521
1563
  method: "POST",
1522
1564
  headers: {
1523
1565
  "Content-Type": "application/json",
1524
- Authorization: "Bearer " + o.token
1566
+ Authorization: "Bearer " + r.token
1525
1567
  }
1526
1568
  }
1527
1569
  )).json();
1528
1570
  }
1529
- class S extends Q {
1571
+ class S extends Y {
1530
1572
  constructor(e, t, n, i) {
1531
1573
  super(), this.id = e, this.name = t, this.organizationId = n, this.tags = i;
1532
1574
  }
@@ -1540,7 +1582,7 @@ class S extends Q {
1540
1582
  }),
1541
1583
  headers: {
1542
1584
  "Content-Type": "application/json",
1543
- Authorization: "Bearer " + o.token
1585
+ Authorization: "Bearer " + r.token
1544
1586
  }
1545
1587
  }
1546
1588
  )).json()).items;
@@ -1550,7 +1592,7 @@ class S extends Q {
1550
1592
  method: "GET",
1551
1593
  headers: {
1552
1594
  "Content-Type": "application/json",
1553
- Authorization: "Bearer " + o.token
1595
+ Authorization: "Bearer " + r.token
1554
1596
  }
1555
1597
  });
1556
1598
  const t = await e.json();
@@ -1565,7 +1607,7 @@ class S extends Q {
1565
1607
  method: "GET",
1566
1608
  headers: {
1567
1609
  "Content-Type": "application/json",
1568
- Authorization: "Bearer " + o.token
1610
+ Authorization: "Bearer " + r.token
1569
1611
  }
1570
1612
  }
1571
1613
  ), (await e.json()).document;
@@ -1578,7 +1620,7 @@ class S extends Q {
1578
1620
  }),
1579
1621
  headers: {
1580
1622
  "Content-Type": "application/json",
1581
- Authorization: "Bearer " + o.token
1623
+ Authorization: "Bearer " + r.token
1582
1624
  }
1583
1625
  })).json()).fileUrls;
1584
1626
  }
@@ -1600,11 +1642,11 @@ class S extends Q {
1600
1642
  sessionType: t,
1601
1643
  deadlineMs: n = 1e4,
1602
1644
  maxConnectRetries: i = 3
1603
- } = typeof e == "number" ? { sessionType: e } : e, c = Ve({
1645
+ } = typeof e == "number" ? { sessionType: e } : e, c = He({
1604
1646
  sessionType: t
1605
1647
  }).get(this.handleMessage);
1606
1648
  let d = !1;
1607
- const p = new Promise(
1649
+ const y = new Promise(
1608
1650
  (w, v) => setTimeout(() => {
1609
1651
  d = !0, v(
1610
1652
  new Error(
@@ -1619,7 +1661,7 @@ class S extends Q {
1619
1661
  const w = await this.getRemoteDevicePeerId(c);
1620
1662
  this.assertNotCancelled(d);
1621
1663
  let v;
1622
- for (let A = 0; A < i && (v = await c.connect(w), !v); A++)
1664
+ for (let D = 0; D < i && (v = await c.connect(w), !v); D++)
1623
1665
  b(100), this.assertNotCancelled(d);
1624
1666
  if (!v)
1625
1667
  throw new Error(
@@ -1632,7 +1674,7 @@ class S extends Q {
1632
1674
  `${(/* @__PURE__ */ new Date()).toISOString()} :: Connection completed after ${C} retries`
1633
1675
  ), w;
1634
1676
  };
1635
- return Promise.race([m(), p]).then((w) => {
1677
+ return Promise.race([m(), y]).then((w) => {
1636
1678
  this.remoteDevicePeerId = w, this.initConnectionMonitoring(), this.rtcClient = c, this.emit("connect");
1637
1679
  }).catch((w) => {
1638
1680
  throw console.debug(
@@ -1645,7 +1687,7 @@ class S extends Q {
1645
1687
  }
1646
1688
  async getRemoteDevicePeerId(e) {
1647
1689
  const n = (await e.getPeers()).find((i) => i.deviceId === this.id);
1648
- if (!Fe(n))
1690
+ if (!We(n))
1649
1691
  throw new Error("Cannot find peer, is the robot offline?");
1650
1692
  return n.id;
1651
1693
  }
@@ -1689,7 +1731,7 @@ class S extends Q {
1689
1731
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1690
1732
  }
1691
1733
  async isInRealtimeSession() {
1692
- 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);
1693
1735
  return n ? t[n.id].length > 0 : !1;
1694
1736
  }
1695
1737
  async getAvailableCommands() {
@@ -1699,7 +1741,7 @@ class S extends Q {
1699
1741
  method: "GET",
1700
1742
  headers: {
1701
1743
  "Content-Type": "application/json",
1702
- Authorization: "Bearer " + o.token
1744
+ Authorization: "Bearer " + r.token
1703
1745
  }
1704
1746
  }
1705
1747
  )).json()).items.map((n) => ({
@@ -1721,7 +1763,7 @@ class S extends Q {
1721
1763
  throw new Error(`Could not find command with name "${e}"`);
1722
1764
  let d = "";
1723
1765
  t === void 0 ? c.parameterEnabled && c.parameterValue && (d = c.parameterValue) : d = t;
1724
- let p = {
1766
+ let y = {
1725
1767
  value: d,
1726
1768
  scrubberTime: (n || /* @__PURE__ */ new Date()).toISOString(),
1727
1769
  meta: {
@@ -1736,12 +1778,12 @@ class S extends Q {
1736
1778
  organizationId: this.organizationId,
1737
1779
  deviceId: this.id,
1738
1780
  command: c.command,
1739
- parameter: p,
1740
- userId: (w = o.currentUser) == null ? void 0 : w.id
1781
+ parameter: y,
1782
+ userId: (w = r.currentUser) == null ? void 0 : w.id
1741
1783
  }),
1742
1784
  headers: {
1743
1785
  "Content-Type": "application/json",
1744
- Authorization: "Bearer " + o.token
1786
+ Authorization: "Bearer " + r.token
1745
1787
  }
1746
1788
  });
1747
1789
  }
@@ -1750,7 +1792,7 @@ class S extends Q {
1750
1792
  method: "GET",
1751
1793
  headers: {
1752
1794
  "Content-Type": "application/json",
1753
- Authorization: "Bearer " + o.token
1795
+ Authorization: "Bearer " + r.token
1754
1796
  }
1755
1797
  });
1756
1798
  }
@@ -1764,13 +1806,13 @@ class S extends Q {
1764
1806
  }),
1765
1807
  headers: {
1766
1808
  "Content-Type": "application/json",
1767
- Authorization: "Bearer " + o.token
1809
+ Authorization: "Bearer " + r.token
1768
1810
  }
1769
1811
  })).json();
1770
- return new Ge(n);
1812
+ return new Fe(n);
1771
1813
  }
1772
1814
  async getTelemetry(e, t, n, i) {
1773
- return await ne(
1815
+ return await ie(
1774
1816
  this.id,
1775
1817
  e,
1776
1818
  t,
@@ -1779,7 +1821,7 @@ class S extends Q {
1779
1821
  );
1780
1822
  }
1781
1823
  async getTelemetryStreams() {
1782
- var d, p;
1824
+ var d, y;
1783
1825
  const e = await this.getConfiguration(), t = await fetch(
1784
1826
  `${h}/v1/queries/metadata/stream-names`,
1785
1827
  {
@@ -1789,11 +1831,11 @@ class S extends Q {
1789
1831
  }),
1790
1832
  headers: {
1791
1833
  "Content-Type": "application/json",
1792
- Authorization: "Bearer " + o.token
1834
+ Authorization: "Bearer " + r.token
1793
1835
  }
1794
1836
  }
1795
1837
  ), n = [], i = [];
1796
- return (p = (d = e.telemetry) == null ? void 0 : d.streams) == null || p.forEach((m) => {
1838
+ return (y = (d = e.telemetry) == null ? void 0 : d.streams) == null || y.forEach((m) => {
1797
1839
  m.disabled !== !0 && n.push(m.name), m.onDemand === !0 && i.push(m.name);
1798
1840
  }), console.log(i), (await t.json()).items.filter((m) => !n.includes(m)).map((m) => ({ name: m, onDemand: i.includes(m) }));
1799
1841
  }
@@ -1812,7 +1854,7 @@ class S extends Q {
1812
1854
  }),
1813
1855
  headers: {
1814
1856
  "Content-Type": "application/json",
1815
- Authorization: "Bearer " + o.token
1857
+ Authorization: "Bearer " + r.token
1816
1858
  }
1817
1859
  }
1818
1860
  )).json();
@@ -1829,7 +1871,7 @@ class S extends Q {
1829
1871
  }),
1830
1872
  headers: {
1831
1873
  "Content-Type": "application/json",
1832
- Authorization: "Bearer " + o.token
1874
+ Authorization: "Bearer " + r.token
1833
1875
  }
1834
1876
  }
1835
1877
  )).json();
@@ -1838,40 +1880,40 @@ class S extends Q {
1838
1880
  return await B({ ...e, deviceIds: [this.id] }, t);
1839
1881
  }
1840
1882
  async getAnnotationCountByIntervals(e, t, n) {
1841
- return await te(
1883
+ return await ae(
1842
1884
  { ...e, deviceIds: [this.id] },
1843
1885
  t,
1844
1886
  n
1845
1887
  );
1846
1888
  }
1847
- async eventsCounter(e, t, n, i, s) {
1848
- return await ee(e, t, n, i, {
1849
- ...s,
1889
+ async eventsCounter(e, t, n, i, o) {
1890
+ return await ne(e, t, n, i, {
1891
+ ...o,
1850
1892
  deviceIds: [this.id]
1851
1893
  });
1852
1894
  }
1853
1895
  async createShareLink(e, t) {
1854
- return e.scope.deviceIds = [this.id], await Y(e, t);
1896
+ return e.scope.deviceIds = [this.id], await ee(e, t);
1855
1897
  }
1856
1898
  }
1857
- r(S, "createDevice", st), r(S, "patchDevice", ct), r(S, "getDevicesData", dt), r(S, "queryDevicesData", ht), r(S, "disableDevice", ut);
1858
- 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 {
1859
1901
  constructor(t) {
1860
1902
  super();
1861
- r(this, "id");
1862
- r(this, "telemetryStreamActive", !1);
1863
- r(this, "streamTelemetry", {});
1903
+ s(this, "id");
1904
+ s(this, "telemetryStreamActive", !1);
1905
+ s(this, "streamTelemetry", {});
1864
1906
  this.peerUrl = t;
1865
1907
  }
1866
1908
  async getLatestTelemetry() {
1867
1909
  this.telemetryStreamActive || this.subscribeToTelemetry();
1868
1910
  const t = this.streamTelemetry;
1869
- return Object.entries(t).map(([i, s]) => ({
1911
+ return Object.entries(t).map(([i, o]) => ({
1870
1912
  deviceId: this.id,
1871
1913
  streamName: i,
1872
1914
  streamType: "json",
1873
- currentValue: s,
1874
- currentValueTime: s.timestamp,
1915
+ currentValue: o,
1916
+ currentValueTime: o.timestamp,
1875
1917
  tags: {}
1876
1918
  }));
1877
1919
  }
@@ -1888,15 +1930,15 @@ class lt extends Q {
1888
1930
  }), n.addEventListener("readystatechange", (i) => {
1889
1931
  n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
1890
1932
  }), n.addEventListener("progress", (i) => {
1891
- const s = i.loaded, c = s - t;
1892
- t = s, n.responseText.substr(-c).split(`
1933
+ const o = i.loaded, c = o - t;
1934
+ t = o, n.responseText.substr(-c).split(`
1893
1935
  `).forEach((m) => {
1894
1936
  var w;
1895
1937
  if (m.length > 0) {
1896
1938
  const v = JSON.parse(m);
1897
1939
  if ((w = v.result) != null && w.datapoint) {
1898
- const C = v.result.datapoint, A = C.stream;
1899
- delete C.stream, this.streamTelemetry[A] = C;
1940
+ const C = v.result.datapoint, D = C.stream;
1941
+ delete C.stream, this.streamTelemetry[D] = C;
1900
1942
  }
1901
1943
  }
1902
1944
  });
@@ -1919,7 +1961,7 @@ class lt extends Q {
1919
1961
  this.rtcClient && console.warn(
1920
1962
  "overwriting existing rtcClient due to missing connectionMonitorInterval"
1921
1963
  );
1922
- const n = new j({
1964
+ const n = new A({
1923
1965
  lanOnlyMode: !0,
1924
1966
  receive: this.handleMessage,
1925
1967
  sessionType: t
@@ -1958,11 +2000,11 @@ class lt extends Q {
1958
2000
  if (t)
1959
2001
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1960
2002
  }
1961
- async sendCommand(t, n, i, s) {
2003
+ async sendCommand(t, n, i, o) {
1962
2004
  const c = {
1963
2005
  value: n,
1964
2006
  scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
1965
- meta: s
2007
+ meta: o
1966
2008
  };
1967
2009
  return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
1968
2010
  method: "POST",
@@ -1976,43 +2018,43 @@ class lt extends Q {
1976
2018
  });
1977
2019
  }
1978
2020
  }
1979
- async function mt(a, e) {
1980
- if (!o.token)
2021
+ async function wt(a, e) {
2022
+ if (!r.token)
1981
2023
  throw new Error("Not authenticated");
1982
2024
  return await (await fetch(`${h}/v1/admin/devices/${a}`, {
1983
2025
  method: "PATCH",
1984
2026
  body: JSON.stringify({ fleetId: e }),
1985
2027
  headers: {
1986
2028
  "Content-Type": "application/json",
1987
- Authorization: "Bearer " + o.token
2029
+ Authorization: "Bearer " + r.token
1988
2030
  }
1989
2031
  })).json();
1990
2032
  }
1991
- async function ft(a) {
1992
- if (!o.token)
2033
+ async function pt(a) {
2034
+ if (!r.token)
1993
2035
  throw new Error("Not authenticated");
1994
2036
  return (await (await fetch(`${h}/v1/queries/queries`, {
1995
2037
  method: "POST",
1996
2038
  body: JSON.stringify(a),
1997
2039
  headers: {
1998
2040
  "Content-Type": "application/json",
1999
- Authorization: "Bearer " + o.token
2041
+ Authorization: "Bearer " + r.token
2000
2042
  }
2001
2043
  })).json()).aggregates;
2002
2044
  }
2003
- async function wt(a) {
2004
- if (!o.token)
2045
+ async function yt(a) {
2046
+ if (!r.token)
2005
2047
  throw new Error("Not authenticated");
2006
2048
  await fetch(`${h}/v1/admin/fleets/${a}`, {
2007
2049
  method: "DELETE",
2008
2050
  headers: {
2009
2051
  "Content-Type": "application/json",
2010
- Authorization: "Bearer " + o.token
2052
+ Authorization: "Bearer " + r.token
2011
2053
  }
2012
2054
  });
2013
2055
  }
2014
- async function pt() {
2015
- if (!o.token)
2056
+ async function gt() {
2057
+ if (!r.token)
2016
2058
  throw new Error("Not authenticated");
2017
2059
  return (await (await fetch(
2018
2060
  `${h}/v1/queries/analytics/streams`,
@@ -2020,13 +2062,13 @@ async function pt() {
2020
2062
  method: "GET",
2021
2063
  headers: {
2022
2064
  "Content-Type": "application/json",
2023
- Authorization: "Bearer " + o.token
2065
+ Authorization: "Bearer " + r.token
2024
2066
  }
2025
2067
  }
2026
2068
  )).json()).items;
2027
2069
  }
2028
- async function yt() {
2029
- if (!o.token)
2070
+ async function vt() {
2071
+ if (!r.token)
2030
2072
  throw new Error("Not authenticated");
2031
2073
  return (await (await fetch(
2032
2074
  `${h}/v1/admin/analytics-modules`,
@@ -2034,39 +2076,39 @@ async function yt() {
2034
2076
  method: "GET",
2035
2077
  headers: {
2036
2078
  "Content-Type": "application/json",
2037
- Authorization: "Bearer " + o.token
2079
+ Authorization: "Bearer " + r.token
2038
2080
  }
2039
2081
  }
2040
2082
  )).json()).items;
2041
2083
  }
2042
- async function gt(a) {
2043
- if (!o.token)
2084
+ async function Tt(a) {
2085
+ if (!r.token)
2044
2086
  throw new Error("Not authenticated");
2045
2087
  return await (await fetch(`${h}/v1/queries/analytics/rows`, {
2046
2088
  method: "POST",
2047
2089
  body: JSON.stringify(a),
2048
2090
  headers: {
2049
2091
  "Content-Type": "application/json",
2050
- Authorization: "Bearer " + o.token
2092
+ Authorization: "Bearer " + r.token
2051
2093
  }
2052
2094
  })).json();
2053
2095
  }
2054
- async function oe(a) {
2055
- if (!o.token)
2096
+ async function se(a) {
2097
+ if (!r.token)
2056
2098
  throw new Error("Not authenticated");
2057
2099
  return (await (await fetch(`${h}/v1/admin/devices/query`, {
2058
2100
  method: "POST",
2059
2101
  body: JSON.stringify(a),
2060
2102
  headers: {
2061
2103
  "Content-Type": "application/json",
2062
- Authorization: "Bearer " + o.token
2104
+ Authorization: "Bearer " + r.token
2063
2105
  }
2064
2106
  })).json()).items.map(
2065
2107
  (n) => new S(n.id, n.name, n.organizationId, n.tags)
2066
2108
  );
2067
2109
  }
2068
- async function vt() {
2069
- if (!o.token)
2110
+ async function Ct() {
2111
+ if (!r.token)
2070
2112
  throw new Error("Not authenticated");
2071
2113
  let a = new URLSearchParams("");
2072
2114
  typeof window < "u" && window.location && (a = new URLSearchParams(window.location.search));
@@ -2078,37 +2120,37 @@ async function vt() {
2078
2120
  {
2079
2121
  headers: {
2080
2122
  "Content-Type": "application/json",
2081
- Authorization: "Bearer " + o.token
2123
+ Authorization: "Bearer " + r.token
2082
2124
  }
2083
2125
  }
2084
2126
  ), { tagKey: n, tagValue: i } = await t.json();
2085
- return await oe({
2127
+ return await se({
2086
2128
  tags: { [n]: [i] },
2087
2129
  enabled: !0,
2088
2130
  type: "default"
2089
2131
  });
2090
2132
  }
2091
- async function Tt(a) {
2092
- if (!o.token)
2133
+ async function St(a) {
2134
+ if (!r.token)
2093
2135
  throw new Error("Not authenticated");
2094
2136
  const t = await (await fetch(`${h}/v1/admin/devices/${a}`, {
2095
2137
  method: "GET",
2096
2138
  headers: {
2097
2139
  "Content-Type": "application/json",
2098
- Authorization: "Bearer " + o.token
2140
+ Authorization: "Bearer " + r.token
2099
2141
  }
2100
2142
  })).json(), n = t.name;
2101
2143
  return new S(a, n, t.organizationId, t.tags);
2102
2144
  }
2103
2145
  async function M() {
2104
- if (!o.token)
2146
+ if (!r.token)
2105
2147
  throw new Error("Not authenticated");
2106
2148
  const e = await (await fetch(`${h}/v1/admin/device-details/query`, {
2107
2149
  method: "POST",
2108
2150
  body: JSON.stringify({ enabled: !0, type: "default" }),
2109
2151
  headers: {
2110
2152
  "Content-Type": "application/json",
2111
- Authorization: "Bearer " + o.token
2153
+ Authorization: "Bearer " + r.token
2112
2154
  }
2113
2155
  })).json();
2114
2156
  return e.items, e.items.map(
@@ -2120,8 +2162,8 @@ async function M() {
2120
2162
  )
2121
2163
  );
2122
2164
  }
2123
- async function Ct(a) {
2124
- if (!o.token)
2165
+ async function Et(a) {
2166
+ if (!r.token)
2125
2167
  throw new Error("Not authenticated");
2126
2168
  return (await (await fetch(
2127
2169
  `${h}/v1/admin/events/query/id=${a}`,
@@ -2129,12 +2171,12 @@ async function Ct(a) {
2129
2171
  method: "GET",
2130
2172
  headers: {
2131
2173
  "Content-Type": "application/json",
2132
- Authorization: "Bearer " + o.token
2174
+ Authorization: "Bearer " + r.token
2133
2175
  }
2134
2176
  }
2135
2177
  )).json()).items;
2136
2178
  }
2137
- async function St(a) {
2179
+ async function kt(a) {
2138
2180
  const t = await (await fetch(`${h}/v1/admin/files/query`, {
2139
2181
  method: "POST",
2140
2182
  body: JSON.stringify({
@@ -2142,37 +2184,37 @@ async function St(a) {
2142
2184
  }),
2143
2185
  headers: {
2144
2186
  "Content-Type": "application/json",
2145
- Authorization: "Bearer " + o.token
2187
+ Authorization: "Bearer " + r.token
2146
2188
  }
2147
2189
  })).json();
2148
2190
  if (t.fileUrls.length === 0)
2149
2191
  throw new Error("File not found");
2150
2192
  return t.fileUrls[0];
2151
2193
  }
2152
- async function Et(a) {
2153
- if (!o.token)
2194
+ async function Ot(a) {
2195
+ if (!r.token)
2154
2196
  throw new Error("Not authenticated");
2155
2197
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
2156
2198
  method: "GET",
2157
2199
  headers: {
2158
2200
  "Content-Type": "application/json",
2159
- Authorization: "Bearer " + o.token
2201
+ Authorization: "Bearer " + r.token
2160
2202
  }
2161
2203
  })).json();
2162
2204
  }
2163
- async function kt(a) {
2164
- if (!o.token)
2205
+ async function Rt(a) {
2206
+ if (!r.token)
2165
2207
  throw new Error("Not authenticated");
2166
2208
  return (await (await fetch(`${h}/v1/admin/fleets/${a}/devices`, {
2167
2209
  method: "GET",
2168
2210
  headers: {
2169
2211
  "Content-Type": "application/json",
2170
- Authorization: "Bearer " + o.token
2212
+ Authorization: "Bearer " + r.token
2171
2213
  }
2172
2214
  })).json()).items;
2173
2215
  }
2174
- async function Ot() {
2175
- if (!o.token)
2216
+ async function At() {
2217
+ if (!r.token)
2176
2218
  throw new Error("Not authenticated");
2177
2219
  return (await (await fetch(
2178
2220
  `${h}/v1/admin/intervention-requests`,
@@ -2180,12 +2222,12 @@ async function Ot() {
2180
2222
  method: "GET",
2181
2223
  headers: {
2182
2224
  "Content-Type": "application/json",
2183
- Authorization: "Bearer " + o.token
2225
+ Authorization: "Bearer " + r.token
2184
2226
  }
2185
2227
  }
2186
2228
  )).json()).items;
2187
2229
  }
2188
- async function Rt(...a) {
2230
+ async function bt(...a) {
2189
2231
  const e = a.flat().filter((i) => !!i);
2190
2232
  return e.length === 0 ? [] : (await (await fetch(
2191
2233
  `${h}/v1/queries/stream-current-value`,
@@ -2196,52 +2238,52 @@ async function Rt(...a) {
2196
2238
  }),
2197
2239
  headers: {
2198
2240
  "Content-Type": "application/json",
2199
- Authorization: "Bearer " + o.token
2241
+ Authorization: "Bearer " + r.token
2200
2242
  }
2201
2243
  }
2202
2244
  )).json()).items;
2203
2245
  }
2204
- async function bt() {
2205
- if (!o.token)
2246
+ async function Dt() {
2247
+ if (!r.token)
2206
2248
  throw new Error("Not authenticated");
2207
2249
  const t = (await (await fetch(`${h}/v1/queries/online-devices`, {
2208
2250
  method: "GET",
2209
2251
  headers: {
2210
2252
  "Content-Type": "application/json",
2211
- Authorization: "Bearer " + o.token
2253
+ Authorization: "Bearer " + r.token
2212
2254
  }
2213
2255
  })).json()).items;
2214
2256
  return (await M()).filter((i) => t.includes(i.id));
2215
2257
  }
2216
- async function At() {
2217
- if (!o.token)
2258
+ async function jt() {
2259
+ if (!r.token)
2218
2260
  throw new Error("Not authenticated");
2219
2261
  const t = (await (await fetch(`${h}/v1/signaling/peers`, {
2220
2262
  method: "GET",
2221
2263
  headers: {
2222
2264
  "Content-Type": "application/json",
2223
- Authorization: "Bearer " + o.token
2265
+ Authorization: "Bearer " + r.token
2224
2266
  }
2225
2267
  })).json()).items.map(
2226
2268
  (i) => i.deviceId
2227
2269
  );
2228
2270
  return (await M()).filter((i) => t.includes(i.id));
2229
2271
  }
2230
- async function jt() {
2231
- if (!o.token)
2272
+ async function Nt() {
2273
+ if (!r.token)
2232
2274
  throw new Error("Not authenticated");
2233
2275
  return (await (await fetch(`${h}/v1/admin/streams`, {
2234
2276
  method: "GET",
2235
2277
  headers: {
2236
2278
  "Content-Type": "application/json",
2237
- Authorization: "Bearer " + o.token
2279
+ Authorization: "Bearer " + r.token
2238
2280
  }
2239
2281
  })).json()).items.filter(
2240
2282
  (t) => t.enabled
2241
2283
  );
2242
2284
  }
2243
- async function Nt(a) {
2244
- if (!o.token)
2285
+ async function Pt(a) {
2286
+ if (!r.token)
2245
2287
  throw new Error("Not authenticated");
2246
2288
  return await (await fetch(
2247
2289
  `${h}/v1/queries/analytics/task-report-rows`,
@@ -2250,13 +2292,13 @@ async function Nt(a) {
2250
2292
  body: JSON.stringify(a),
2251
2293
  headers: {
2252
2294
  "Content-Type": "application/json",
2253
- Authorization: "Bearer " + o.token
2295
+ Authorization: "Bearer " + r.token
2254
2296
  }
2255
2297
  }
2256
2298
  )).json();
2257
2299
  }
2258
- async function Dt() {
2259
- if (!o.token)
2300
+ async function Lt() {
2301
+ if (!r.token)
2260
2302
  throw new Error("Not authenticated");
2261
2303
  return (await (await fetch(
2262
2304
  `${h}/v1/queries/analytics/task-reports`,
@@ -2264,36 +2306,36 @@ async function Dt() {
2264
2306
  method: "GET",
2265
2307
  headers: {
2266
2308
  "Content-Type": "application/json",
2267
- Authorization: "Bearer " + o.token
2309
+ Authorization: "Bearer " + r.token
2268
2310
  }
2269
2311
  }
2270
2312
  )).json()).items;
2271
2313
  }
2272
- async function Pt() {
2273
- if (!o.token)
2314
+ async function It() {
2315
+ if (!r.token)
2274
2316
  throw new Error("Not authenticated");
2275
2317
  return (await (await fetch(`${h}/v1/admin/fleets`, {
2276
2318
  method: "GET",
2277
2319
  headers: {
2278
2320
  "Content-Type": "application/json",
2279
- Authorization: "Bearer " + o.token
2321
+ Authorization: "Bearer " + r.token
2280
2322
  }
2281
2323
  })).json()).items;
2282
2324
  }
2283
- async function It(a, e) {
2284
- if (!o.token)
2325
+ async function _t(a, e) {
2326
+ if (!r.token)
2285
2327
  throw new Error("Not authenticated");
2286
2328
  return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
2287
2329
  method: "PATCH",
2288
2330
  body: JSON.stringify(e),
2289
2331
  headers: {
2290
2332
  "Content-Type": "application/json",
2291
- Authorization: "Bearer " + o.token
2333
+ Authorization: "Bearer " + r.token
2292
2334
  }
2293
2335
  })).json();
2294
2336
  }
2295
- async function Lt(a) {
2296
- if (!o.token)
2337
+ async function $t(a) {
2338
+ if (!r.token)
2297
2339
  throw new Error("Not authenticated");
2298
2340
  return await (await fetch(
2299
2341
  `${h}/v1/admin/streams/${a.id}`,
@@ -2302,60 +2344,60 @@ async function Lt(a) {
2302
2344
  body: JSON.stringify(a),
2303
2345
  headers: {
2304
2346
  "Content-Type": "application/json",
2305
- Authorization: "Bearer " + o.token
2347
+ Authorization: "Bearer " + r.token
2306
2348
  }
2307
2349
  }
2308
2350
  )).json();
2309
2351
  }
2310
- async function _t(a) {
2311
- if (!o.token)
2352
+ async function zt(a) {
2353
+ if (!r.token)
2312
2354
  throw new Error("Not authenticated");
2313
2355
  return await (await fetch(`${h}/v1/admin/views/${a.id}`, {
2314
2356
  method: "PATCH",
2315
2357
  body: JSON.stringify(a),
2316
2358
  headers: {
2317
2359
  "Content-Type": "application/json",
2318
- Authorization: "Bearer " + o.token
2360
+ Authorization: "Bearer " + r.token
2319
2361
  }
2320
2362
  })).json();
2321
2363
  }
2322
- async function $t(a) {
2323
- if (!o.token)
2364
+ async function Bt(a) {
2365
+ if (!r.token)
2324
2366
  throw new Error("Not authenticated");
2325
2367
  return await (await fetch(`${h}/v1/queries/analytics`, {
2326
2368
  method: "POST",
2327
2369
  body: JSON.stringify(a),
2328
2370
  headers: {
2329
2371
  "Content-Type": "application/json",
2330
- Authorization: "Bearer " + o.token
2372
+ Authorization: "Bearer " + r.token
2331
2373
  }
2332
2374
  })).json();
2333
2375
  }
2334
- async function zt(a) {
2335
- if (!o.token)
2376
+ async function Mt(a) {
2377
+ if (!r.token)
2336
2378
  throw new Error("Not authenticated");
2337
2379
  return await (await fetch(`${h}/v1/admin/fleets`, {
2338
2380
  method: "POST",
2339
2381
  body: JSON.stringify(a),
2340
2382
  headers: {
2341
2383
  "Content-Type": "application/json",
2342
- Authorization: "Bearer " + o.token
2384
+ Authorization: "Bearer " + r.token
2343
2385
  }
2344
2386
  })).json();
2345
2387
  }
2346
- async function Bt() {
2347
- if (!o.token)
2388
+ async function qt() {
2389
+ if (!r.token)
2348
2390
  throw new Error("Not authenticated");
2349
2391
  return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
2350
2392
  method: "GET",
2351
2393
  headers: {
2352
2394
  "Content-Type": "application/json",
2353
- Authorization: "Bearer " + o.token
2395
+ Authorization: "Bearer " + r.token
2354
2396
  }
2355
2397
  })).json()).items;
2356
2398
  }
2357
- async function Mt(a) {
2358
- if (!o.token)
2399
+ async function xt(a) {
2400
+ if (!r.token)
2359
2401
  throw new Error("Not authenticated");
2360
2402
  return await (await fetch(
2361
2403
  `${h}/v1/admin/event-trigger-groups/${a}`,
@@ -2363,13 +2405,13 @@ async function Mt(a) {
2363
2405
  method: "GET",
2364
2406
  headers: {
2365
2407
  "Content-Type": "application/json",
2366
- Authorization: "Bearer " + o.token
2408
+ Authorization: "Bearer " + r.token
2367
2409
  }
2368
2410
  }
2369
2411
  )).json();
2370
2412
  }
2371
- async function qt(a, e) {
2372
- if (!o.token)
2413
+ async function Ut(a, e) {
2414
+ if (!r.token)
2373
2415
  throw new Error("Not authenticated");
2374
2416
  return await (await fetch(
2375
2417
  `${h}/v1/admin/event-trigger-groups/${a}`,
@@ -2378,7 +2420,7 @@ async function qt(a, e) {
2378
2420
  body: JSON.stringify(e),
2379
2421
  headers: {
2380
2422
  "Content-Type": "application/json",
2381
- Authorization: "Bearer " + o.token
2423
+ Authorization: "Bearer " + r.token
2382
2424
  }
2383
2425
  }
2384
2426
  )).json();
@@ -2388,7 +2430,7 @@ const E = class {
2388
2430
  E.defaultDeviceId = e;
2389
2431
  }
2390
2432
  static async getCurrentDevice() {
2391
- if (!o.token)
2433
+ if (!r.token)
2392
2434
  throw new Error("Not authenticated");
2393
2435
  if (!E.defaultDeviceId)
2394
2436
  throw new Error("No known default device");
@@ -2398,48 +2440,48 @@ const E = class {
2398
2440
  method: "POST",
2399
2441
  headers: {
2400
2442
  "Content-Type": "application/json",
2401
- Authorization: "Bearer " + o.token
2443
+ Authorization: "Bearer " + r.token
2402
2444
  }
2403
2445
  }
2404
2446
  )).json()).items.find(
2405
2447
  (c) => c.id === E.defaultDeviceId
2406
- ), i = n.name, s = new S(
2448
+ ), i = n.name, o = new S(
2407
2449
  E.defaultDeviceId,
2408
2450
  i,
2409
- f(o.currentOrganization),
2451
+ f(r.currentOrganization),
2410
2452
  n.tags
2411
2453
  );
2412
- return E.knownContext.push(new WeakRef(s)), s;
2454
+ return E.knownContext.push(new WeakRef(o)), o;
2413
2455
  }
2414
2456
  static async getPeerDevice(e) {
2415
- const t = new lt(e);
2457
+ const t = new ft(e);
2416
2458
  return t.id = await t.getDeviceId(), t;
2417
2459
  }
2418
2460
  static async getDevice(e) {
2419
- const t = await Tt(e);
2461
+ const t = await St(e);
2420
2462
  return E.knownContext.push(new WeakRef(t)), t;
2421
2463
  }
2422
2464
  };
2423
- let u = E;
2424
- r(u, "defaultDeviceId"), r(u, "knownContext", []), r(u, "createFleet", zt), r(u, "listFleets", Pt), r(u, "getFleet", Et), r(u, "patchFleet", It), 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", bt), r(u, "getPeers", ie), r(u, "getRealtimeDevices", At), r(u, "getRealtimeSessions", ae), r(u, "getStreams", jt), r(u, "getTaskReportRows", Nt), r(u, "getTaskReportTables", Dt), r(u, "getTelemetry", ne), r(u, "getViews", X), r(u, "patchStream", Lt), 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);
2425
- 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 {
2426
2468
  static async set(e, t, n) {
2427
2469
  try {
2428
2470
  const i = await fetch(h + "/v1/admin/key-value", {
2429
2471
  method: "POST",
2430
2472
  body: JSON.stringify({
2431
- organizationId: f(o.currentUser).organizationId,
2473
+ organizationId: f(r.currentUser).organizationId,
2432
2474
  key: e,
2433
2475
  value: t,
2434
2476
  tags: n
2435
2477
  }),
2436
2478
  headers: {
2437
2479
  "Content-Type": "application/json",
2438
- Authorization: "Bearer " + o.token
2480
+ Authorization: "Bearer " + r.token
2439
2481
  }
2440
- }), s = await i.json();
2482
+ }), o = await i.json();
2441
2483
  if (i.status !== 200)
2442
- throw new Error(s.message);
2484
+ throw new Error(o.message);
2443
2485
  } catch (i) {
2444
2486
  throw i;
2445
2487
  }
@@ -2452,7 +2494,7 @@ class tn {
2452
2494
  method: "GET",
2453
2495
  headers: {
2454
2496
  "Content-Type": "application/json",
2455
- Authorization: "Bearer " + o.token
2497
+ Authorization: "Bearer " + r.token
2456
2498
  }
2457
2499
  }
2458
2500
  ), n = await t.json();
@@ -2469,7 +2511,7 @@ class tn {
2469
2511
  method: "GET",
2470
2512
  headers: {
2471
2513
  "Content-Type": "application/json",
2472
- Authorization: "Bearer " + o.token
2514
+ Authorization: "Bearer " + r.token
2473
2515
  }
2474
2516
  }), t = await e.json();
2475
2517
  if (e.status !== 200)
@@ -2487,7 +2529,7 @@ class tn {
2487
2529
  method: "DELETE",
2488
2530
  headers: {
2489
2531
  "Content-Type": "application/json",
2490
- Authorization: "Bearer " + o.token
2532
+ Authorization: "Bearer " + r.token
2491
2533
  }
2492
2534
  }
2493
2535
  )).ok)
@@ -2506,7 +2548,7 @@ class tn {
2506
2548
  body: JSON.stringify({ keys: e }),
2507
2549
  headers: {
2508
2550
  "Content-Type": "application/json",
2509
- Authorization: "Bearer " + o.token
2551
+ Authorization: "Bearer " + r.token
2510
2552
  }
2511
2553
  }
2512
2554
  );
@@ -2518,37 +2560,37 @@ class tn {
2518
2560
  }
2519
2561
  }
2520
2562
  }
2521
- function xt(a) {
2522
- return Uint8Array.from(J(a), (e) => e.charCodeAt(0));
2563
+ function Jt(a) {
2564
+ return Uint8Array.from(G(a), (e) => e.charCodeAt(0));
2523
2565
  }
2524
- function U() {
2566
+ function V() {
2525
2567
  const { userAgent: a } = navigator;
2526
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";
2527
2569
  }
2528
- const Ut = "audio-chunk";
2529
- class nn {
2570
+ const Vt = "audio-chunk";
2571
+ class on {
2530
2572
  constructor(e, t) {
2531
- r(this, "muted", !1);
2532
- r(this, "hasReceivedData", !1);
2533
- r(this, "audioContext");
2534
- r(this, "chunks", []);
2535
- r(this, "isPlaying", !1);
2536
- r(this, "startTime", 0);
2537
- r(this, "lastChunkOffset", 0);
2538
- r(this, "bufferSize", 3);
2539
- 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) => {
2540
2582
  var c;
2541
2583
  const t = (c = e.payload.audioChunk) == null ? void 0 : c.chunk_data;
2542
2584
  if (!t)
2543
2585
  return;
2544
2586
  this.hasReceivedData || (this.hasReceivedData = !0);
2545
2587
  const { audioContext: n, muted: i } = this;
2546
- if (!n || e.header.stream.streamType !== Ut || i !== !1)
2588
+ if (!n || e.header.stream.streamType !== Vt || i !== !1)
2547
2589
  return;
2548
- const s = xt(t);
2590
+ const o = Jt(t);
2549
2591
  try {
2550
2592
  await n.decodeAudioData(
2551
- s.buffer,
2593
+ o.buffer,
2552
2594
  this.scheduleChunk
2553
2595
  );
2554
2596
  } catch (d) {
@@ -2558,7 +2600,7 @@ class nn {
2558
2600
  ), this.changeAudioWireFormat("wav");
2559
2601
  }
2560
2602
  });
2561
- r(this, "scheduleChunk", (e) => {
2603
+ s(this, "scheduleChunk", (e) => {
2562
2604
  const { audioContext: t } = this;
2563
2605
  if (!t)
2564
2606
  return;
@@ -2568,9 +2610,9 @@ class nn {
2568
2610
  const n = this.createChunk(e);
2569
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));
2570
2612
  });
2571
- this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, s) => {
2572
- this.receive(s);
2573
- }), 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");
2574
2616
  const n = window.AudioContext || window.webkitAudioContext;
2575
2617
  this.audioContext = new n();
2576
2618
  }
@@ -2598,66 +2640,66 @@ class nn {
2598
2640
  (async () => await this.device.changeStreamAudioType(t.name, e))();
2599
2641
  }
2600
2642
  }
2601
- class an {
2643
+ class rn {
2602
2644
  static async listAccounts() {
2603
- if (!o.token)
2645
+ if (!r.token)
2604
2646
  throw new Error("Not authenticated");
2605
2647
  return (await (await fetch(`${h}/v1/admin/accounts`, {
2606
2648
  method: "GET",
2607
2649
  headers: {
2608
2650
  "Content-Type": "application/json",
2609
- Authorization: "Bearer " + o.token
2651
+ Authorization: "Bearer " + r.token
2610
2652
  }
2611
2653
  })).json()).items;
2612
2654
  }
2613
2655
  static async createAccounts(e) {
2614
- if (!o.token)
2656
+ if (!r.token)
2615
2657
  throw new Error("Not authenticated");
2616
2658
  return await (await fetch(`${h}/v1/admin/accounts`, {
2617
2659
  method: "POST",
2618
2660
  body: JSON.stringify(e),
2619
2661
  headers: {
2620
2662
  "Content-Type": "application/json",
2621
- Authorization: "Bearer " + o.token
2663
+ Authorization: "Bearer " + r.token
2622
2664
  }
2623
2665
  })).json();
2624
2666
  }
2625
2667
  static async getAccount(e) {
2626
- if (!o.token)
2668
+ if (!r.token)
2627
2669
  throw new Error("Not authenticated");
2628
2670
  return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
2629
2671
  method: "GET",
2630
2672
  headers: {
2631
2673
  "Content-Type": "application/json",
2632
- Authorization: "Bearer " + o.token
2674
+ Authorization: "Bearer " + r.token
2633
2675
  }
2634
2676
  })).json();
2635
2677
  }
2636
2678
  static async patchAccount(e, t) {
2637
- if (!o.token)
2679
+ if (!r.token)
2638
2680
  throw new Error("Not authenticated");
2639
2681
  return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
2640
2682
  method: "PATCH",
2641
2683
  body: JSON.stringify(t),
2642
2684
  headers: {
2643
2685
  "Content-Type": "application/json",
2644
- Authorization: "Bearer " + o.token
2686
+ Authorization: "Bearer " + r.token
2645
2687
  }
2646
2688
  })).json();
2647
2689
  }
2648
2690
  static async deleteAccount(e) {
2649
- if (!o.token)
2691
+ if (!r.token)
2650
2692
  throw new Error("Not authenticated");
2651
2693
  await fetch(`${h}/v1/admin/accounts/${e}`, {
2652
2694
  method: "DELETE",
2653
2695
  headers: {
2654
2696
  "Content-Type": "application/json",
2655
- Authorization: "Bearer " + o.token
2697
+ Authorization: "Bearer " + r.token
2656
2698
  }
2657
2699
  });
2658
2700
  }
2659
2701
  static async getAccountTree(e) {
2660
- if (!o.token)
2702
+ if (!r.token)
2661
2703
  throw new Error("Not authenticated");
2662
2704
  return await (await fetch(
2663
2705
  `${h}/v1/admin/accounts/${e}/tree`,
@@ -2665,139 +2707,139 @@ class an {
2665
2707
  method: "GET",
2666
2708
  headers: {
2667
2709
  "Content-Type": "application/json",
2668
- Authorization: "Bearer " + o.token
2710
+ Authorization: "Bearer " + r.token
2669
2711
  }
2670
2712
  }
2671
2713
  )).json();
2672
2714
  }
2673
2715
  }
2674
- class on {
2716
+ class sn {
2675
2717
  static async listRoles() {
2676
- if (!o.token)
2718
+ if (!r.token)
2677
2719
  throw new Error("Not authenticated");
2678
2720
  return (await (await fetch(`${h}/v1/admin/roles`, {
2679
2721
  method: "GET",
2680
2722
  headers: {
2681
2723
  "Content-Type": "application/json",
2682
- Authorization: "Bearer " + o.token
2724
+ Authorization: "Bearer " + r.token
2683
2725
  }
2684
2726
  })).json()).items;
2685
2727
  }
2686
2728
  static async createRole(e) {
2687
- if (!o.token)
2729
+ if (!r.token)
2688
2730
  throw new Error("Not authenticated");
2689
2731
  return await (await fetch(`${h}/v1/admin/roles`, {
2690
2732
  method: "POST",
2691
2733
  body: JSON.stringify(e),
2692
2734
  headers: {
2693
2735
  "Content-Type": "application/json",
2694
- Authorization: "Bearer " + o.token
2736
+ Authorization: "Bearer " + r.token
2695
2737
  }
2696
2738
  })).json();
2697
2739
  }
2698
2740
  static async getRole(e) {
2699
- if (!o.token)
2741
+ if (!r.token)
2700
2742
  throw new Error("Not authenticated");
2701
2743
  return await (await fetch(`${h}/v1/admin/roles/${e}`, {
2702
2744
  method: "GET",
2703
2745
  headers: {
2704
2746
  "Content-Type": "application/json",
2705
- Authorization: "Bearer " + o.token
2747
+ Authorization: "Bearer " + r.token
2706
2748
  }
2707
2749
  })).json();
2708
2750
  }
2709
2751
  static async patchRole(e, t) {
2710
- if (!o.token)
2752
+ if (!r.token)
2711
2753
  throw new Error("Not authenticated");
2712
2754
  return await (await fetch(`${h}/v1/admin/roles/${e}`, {
2713
2755
  method: "PATCH",
2714
2756
  body: JSON.stringify(t),
2715
2757
  headers: {
2716
2758
  "Content-Type": "application/json",
2717
- Authorization: "Bearer " + o.token
2759
+ Authorization: "Bearer " + r.token
2718
2760
  }
2719
2761
  })).json();
2720
2762
  }
2721
2763
  static async deleteRole(e) {
2722
- if (!o.token)
2764
+ if (!r.token)
2723
2765
  throw new Error("Not authenticated");
2724
2766
  await fetch(`${h}/v1/admin/roles/${e}`, {
2725
2767
  method: "DELETE",
2726
2768
  headers: {
2727
2769
  "Content-Type": "application/json",
2728
- Authorization: "Bearer " + o.token
2770
+ Authorization: "Bearer " + r.token
2729
2771
  }
2730
2772
  });
2731
2773
  }
2732
2774
  }
2733
- class rn {
2775
+ class cn {
2734
2776
  static async listUsers() {
2735
- if (!o.token)
2777
+ if (!r.token)
2736
2778
  throw new Error("Not authenticated");
2737
2779
  return (await (await fetch(`${h}/v1/admin/users`, {
2738
2780
  method: "GET",
2739
2781
  headers: {
2740
2782
  "Content-Type": "application/json",
2741
- Authorization: "Bearer " + o.token
2783
+ Authorization: "Bearer " + r.token
2742
2784
  }
2743
2785
  })).json()).items;
2744
2786
  }
2745
2787
  static async createUser(e) {
2746
- if (!o.token)
2788
+ if (!r.token)
2747
2789
  throw new Error("Not authenticated");
2748
2790
  return await (await fetch(`${h}/v1/admin/users`, {
2749
2791
  method: "POST",
2750
2792
  body: JSON.stringify(e),
2751
2793
  headers: {
2752
2794
  "Content-Type": "application/json",
2753
- Authorization: "Bearer " + o.token
2795
+ Authorization: "Bearer " + r.token
2754
2796
  }
2755
2797
  })).json();
2756
2798
  }
2757
2799
  static async getUser(e) {
2758
- if (!o.token)
2800
+ if (!r.token)
2759
2801
  throw new Error("Not authenticated");
2760
2802
  return await (await fetch(`${h}/v1/admin/users/${e}`, {
2761
2803
  method: "GET",
2762
2804
  headers: {
2763
2805
  "Content-Type": "application/json",
2764
- Authorization: "Bearer " + o.token
2806
+ Authorization: "Bearer " + r.token
2765
2807
  }
2766
2808
  })).json();
2767
2809
  }
2768
2810
  static async patchUser(e, t) {
2769
- if (!o.token)
2811
+ if (!r.token)
2770
2812
  throw new Error("Not authenticated");
2771
2813
  return await (await fetch(`${h}/v1/admin/users/${e}`, {
2772
2814
  method: "PATCH",
2773
2815
  body: JSON.stringify(t),
2774
2816
  headers: {
2775
2817
  "Content-Type": "application/json",
2776
- Authorization: "Bearer " + o.token
2818
+ Authorization: "Bearer " + r.token
2777
2819
  }
2778
2820
  })).json();
2779
2821
  }
2780
2822
  static async deleteUser(e) {
2781
- if (!o.token)
2823
+ if (!r.token)
2782
2824
  throw new Error("Not authenticated");
2783
2825
  await fetch(`${h}/v1/admin/users/${e}`, {
2784
2826
  method: "PATCH",
2785
2827
  body: JSON.stringify({ enabled: !1, roleId: null, teamId: null }),
2786
2828
  headers: {
2787
2829
  "Content-Type": "application/json",
2788
- Authorization: "Bearer " + o.token
2830
+ Authorization: "Bearer " + r.token
2789
2831
  }
2790
2832
  });
2791
2833
  }
2792
2834
  }
2793
- 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 = [
2794
2836
  "year",
2795
2837
  "month",
2796
2838
  "week",
2797
2839
  "day",
2798
2840
  "hour",
2799
2841
  "minute"
2800
- ], ln = ["tag", "sheet", "user"], mn = [
2842
+ ], fn = ["tag", "sheet", "user"], wn = [
2801
2843
  "triggered-event",
2802
2844
  "intervention-request",
2803
2845
  "teleop-session-record",
@@ -2809,59 +2851,59 @@ const sn = ["viewer", "operator", "administrator"], cn = "viewer", dn = "operato
2809
2851
  "comment",
2810
2852
  "system",
2811
2853
  "annotation"
2812
- ], fn = [
2854
+ ], pn = [
2813
2855
  "unknown",
2814
2856
  "operational",
2815
2857
  "offline",
2816
2858
  "error"
2817
- ], 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));
2818
2860
  try {
2819
2861
  const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
2820
- e && u.setDefaultDevice(e);
2862
+ e && l.setDefaultDevice(e);
2821
2863
  const t = a.get("auth");
2822
- t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && y.listenForConnectionEvents();
2864
+ t && r.loginWithToken(t), a.get("module") && r.listenForRefresh(), typeof window < "u" && g.listenForConnectionEvents();
2823
2865
  } catch {
2824
2866
  }
2825
2867
  export {
2826
- an as Account,
2827
- y as App,
2828
- nn as AudioPlayer,
2829
- o as Authentication,
2830
- Ke as BinaryRequestDataChannel,
2831
- Ge as CaptureStream,
2832
- We as DataChannel,
2868
+ rn as Account,
2869
+ g as App,
2870
+ on as AudioPlayer,
2871
+ r as Authentication,
2872
+ Xe as BinaryRequestDataChannel,
2873
+ Fe as CaptureStream,
2874
+ Ke as DataChannel,
2833
2875
  S as Device,
2834
- u as Fleet,
2835
- tn as KeyValue,
2836
- He as Manipulator,
2837
- lt as PeerDevice,
2838
- on as Role,
2839
- Xt as SessionType,
2840
- Qe as TextRequestDataChannel,
2841
- rn as User,
2842
- sn as accessLevels,
2843
- hn as administrator,
2844
- Z as aggregateByDateFunctions,
2845
- en as aggregateFunctionMap,
2846
- Zt as aggregateFunctions,
2847
- un as aggregateLevels,
2848
- ln as annotationTypes,
2849
- mn as eventTypes,
2850
- rt as formatTimeFrameText,
2851
- at as getAverage,
2852
- ot as getCount,
2853
- tt as getMax,
2854
- nt as getMin,
2855
- et as getStandardDeviation,
2856
- it as getSum,
2857
- Ze as getVariance,
2858
- fn as healthStatuses,
2859
- wn as interventionTypes,
2860
- dn as operator,
2861
- pn as severities,
2862
- gn as timeout,
2863
- Yt as vailableAggregationIntervals,
2864
- yn as videoMimeTypes,
2865
- 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
2866
2908
  };
2867
2909
  //# sourceMappingURL=data-sdk.es.js.map