@ikonai/sdk 1.0.3 → 1.0.5

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,42 +1,62 @@
1
- function J(t) {
1
+ const J = {
2
+ Compressed: 8
3
+ };
4
+ function Z(t) {
2
5
  const r = O(t), e = new DataView(r.buffer, r.byteOffset, r.byteLength);
3
6
  if (r.length < 27)
4
7
  throw new Error("Protocol payload too short");
5
- const n = e.getUint32(0, !0), s = e.getUint32(4, !0), E = e.getUint32(8, !0), _ = e.getUint32(12, !0), I = e.getUint32(16, !0), f = e.getUint32(20, !0), q = e.getUint8(24), j = e.getUint8(25), Q = e.getUint8(26);
6
- if (27 + f * 4 > r.length)
8
+ const n = e.getUint32(0, !0), s = e.getUint32(4, !0), E = e.getUint32(8, !0), _ = e.getUint32(12, !0), i = e.getUint32(16, !0), N = e.getUint32(20, !0), o = e.getUint8(24), m = e.getUint8(25), Q = e.getUint8(26);
9
+ if (27 + N * 4 > r.length)
7
10
  throw new Error("Protocol header exceeds payload length");
8
- const G = [];
9
- let B = 27;
10
- for (let b = 0; b < f; b++)
11
- G.push(e.getUint32(B, !0)), B += 4;
11
+ const d = [];
12
+ let b = 27;
13
+ for (let H = 0; H < N; H++)
14
+ d.push(e.getUint32(b, !0)), b += 4;
12
15
  return {
13
16
  length: n,
14
17
  opcode: s,
15
18
  senderId: E,
16
19
  trackId: _,
17
- sequenceId: I,
18
- targetIds: G,
19
- payloadVersion: q,
20
- payloadType: j,
20
+ sequenceId: i,
21
+ targetIds: d,
22
+ payloadVersion: o,
23
+ payloadType: m,
21
24
  flags: Q
22
25
  };
23
26
  }
24
- function K(t, r, e) {
25
- const n = O(t), s = J(n);
27
+ async function x(t, r, e) {
28
+ const n = O(t), s = Z(n);
26
29
  if (r !== void 0 && s.opcode !== r)
27
30
  throw new Error(`Unexpected opcode ${s.opcode}`);
28
- if (s.payloadVersion !== e)
29
- throw new Error(`Unexpected payload version ${s.payloadVersion}`);
30
31
  if (s.payloadType !== 8)
31
32
  throw new Error(`Unexpected payload type ${s.payloadType}`);
32
33
  const E = 27 + s.targetIds.length * 4;
33
- return n.subarray(E, s.length);
34
- }
35
- var R = /* @__PURE__ */ ((t) => (t[t.Null = 1] = "Null", t[t.Bool = 2] = "Bool", t[t.Int32 = 3] = "Int32", t[t.Int64 = 4] = "Int64", t[t.UInt32 = 5] = "UInt32", t[t.UInt64 = 6] = "UInt64", t[t.Float32 = 7] = "Float32", t[t.Float64 = 8] = "Float64", t[t.Array = 9] = "Array", t[t.Dict = 10] = "Dict", t[t.Object = 11] = "Object", t[t.String = 12] = "String", t[t.Binary = 13] = "Binary", t[t.Guid = 14] = "Guid", t))(R || {});
36
- const Z = 161, p = 162;
34
+ let _ = n.subarray(E, s.length);
35
+ return (s.flags & J.Compressed) !== 0 && (_ = await p(_)), _;
36
+ }
37
+ async function p(t) {
38
+ if (typeof DecompressionStream > "u")
39
+ throw new Error("DecompressionStream not supported");
40
+ const r = new DecompressionStream("gzip"), e = r.writable.getWriter(), n = new Uint8Array(t);
41
+ e.write(n), e.close();
42
+ const s = r.readable.getReader(), E = [];
43
+ let _ = 0;
44
+ for (; ; ) {
45
+ const { done: o, value: m } = await s.read();
46
+ if (o) break;
47
+ E.push(m), _ += m.length;
48
+ }
49
+ const i = new Uint8Array(_);
50
+ let N = 0;
51
+ for (let o = 0; o < E.length; o++)
52
+ i.set(E[o], N), N += E[o].length;
53
+ return i;
54
+ }
55
+ var U = /* @__PURE__ */ ((t) => (t[t.Null = 1] = "Null", t[t.Bool = 2] = "Bool", t[t.Int32 = 3] = "Int32", t[t.Int64 = 4] = "Int64", t[t.UInt32 = 5] = "UInt32", t[t.UInt64 = 6] = "UInt64", t[t.Float32 = 7] = "Float32", t[t.Float64 = 8] = "Float64", t[t.Array = 9] = "Array", t[t.Dict = 10] = "Dict", t[t.Object = 11] = "Object", t[t.String = 12] = "String", t[t.Binary = 13] = "Binary", t[t.Guid = 14] = "Guid", t))(U || {});
56
+ const tt = 161, rt = 162;
37
57
  new TextEncoder();
38
- const tt = new TextDecoder("utf-8", { fatal: !0 });
39
- class w {
58
+ const et = new TextDecoder("utf-8", { fatal: !0 });
59
+ class P {
40
60
  constructor(r, e, n) {
41
61
  this.buffer = r, this.version = e, this.offset = n, this.end = r.length - 1;
42
62
  }
@@ -46,33 +66,33 @@ class w {
46
66
  const e = O(r);
47
67
  if (e.length < 2)
48
68
  throw new Error("Teleport payload too short");
49
- if (e[0] !== Z || e[e.length - 1] !== p)
69
+ if (e[0] !== tt || e[e.length - 1] !== rt)
50
70
  throw new Error("Teleport object missing markers");
51
- const n = { offset: 1 }, s = T(e, n, "InvalidLength");
52
- return new w(e, s, n.offset);
71
+ const n = { offset: 1 }, s = A(e, n, "InvalidLength");
72
+ return new P(e, s, n.offset);
53
73
  }
54
74
  next() {
55
75
  if (this.offset >= this.end)
56
76
  return null;
57
77
  if (this.offset + 5 > this.buffer.length)
58
78
  throw new Error("Teleport object truncated");
59
- const r = st(this.buffer, this.offset);
79
+ const r = _t(this.buffer, this.offset);
60
80
  this.offset += 4;
61
81
  const e = this.buffer[this.offset++], n = e >> 4 & 15;
62
82
  if ((e & 15) !== 0)
63
83
  throw new Error("Teleport field flags must be zero");
64
- const s = U(n);
84
+ const s = l(n);
65
85
  let E;
66
86
  if (s >= 0)
67
- a(this.buffer, this.offset, s), E = this.buffer.subarray(this.offset, this.offset + s), this.offset += s;
87
+ I(this.buffer, this.offset, s), E = this.buffer.subarray(this.offset, this.offset + s), this.offset += s;
68
88
  else {
69
- const _ = { offset: this.offset }, I = T(this.buffer, _, "InvalidLength");
70
- a(this.buffer, _.offset, I), E = this.buffer.subarray(_.offset, _.offset + I), this.offset = _.offset + I;
89
+ const _ = { offset: this.offset }, i = A(this.buffer, _, "InvalidLength");
90
+ I(this.buffer, _.offset, i), E = this.buffer.subarray(_.offset, _.offset + i), this.offset = _.offset + i;
71
91
  }
72
- return new rt(r, n, E);
92
+ return new nt(r, n, E);
73
93
  }
74
94
  }
75
- class N {
95
+ class f {
76
96
  constructor(r, e) {
77
97
  this.type = r, this.payload = e;
78
98
  }
@@ -134,38 +154,38 @@ class N {
134
154
  return this.ensureType(
135
155
  12
136
156
  /* String */
137
- ), tt.decode(this.payload);
157
+ ), et.decode(this.payload);
138
158
  }
139
159
  asGuid() {
140
160
  return this.ensureType(
141
161
  14
142
162
  /* Guid */
143
- ), i.fromBytes(this.payload);
163
+ ), a.fromBytes(this.payload);
144
164
  }
145
165
  asObject() {
146
166
  return this.ensureType(
147
167
  11
148
168
  /* Object */
149
- ), w.create(this.payload);
169
+ ), P.create(this.payload);
150
170
  }
151
171
  asArray() {
152
172
  return this.ensureType(
153
173
  9
154
174
  /* Array */
155
- ), m.create(this.payload);
175
+ ), V.create(this.payload);
156
176
  }
157
177
  asDictionary() {
158
178
  return this.ensureType(
159
179
  10
160
180
  /* Dict */
161
- ), F.create(this.payload);
181
+ ), M.create(this.payload);
162
182
  }
163
183
  ensureType(r) {
164
184
  if (this.type !== r)
165
- throw new Error(`Teleport value has type ${R[this.type]}, expected ${R[r]}`);
185
+ throw new Error(`Teleport value has type ${U[this.type]}, expected ${U[r]}`);
166
186
  }
167
187
  }
168
- class rt extends N {
188
+ class nt extends f {
169
189
  constructor(r, e, n) {
170
190
  super(e, n), this.fieldId = r;
171
191
  }
@@ -173,7 +193,7 @@ class rt extends N {
173
193
  return this.type === 1;
174
194
  }
175
195
  }
176
- class m {
196
+ class V {
177
197
  payload;
178
198
  elementType;
179
199
  count;
@@ -186,10 +206,10 @@ class m {
186
206
  if (this.elementType = e >> 4 & 15, (e & 15) !== 0)
187
207
  throw new Error("Array flags must be zero");
188
208
  const n = { offset: 1 };
189
- this.count = T(r, n, "ArrayMalformed"), this.offset = n.offset;
209
+ this.count = A(r, n, "ArrayMalformed"), this.offset = n.offset;
190
210
  }
191
211
  static create(r) {
192
- return new m(O(r));
212
+ return new V(O(r));
193
213
  }
194
214
  next() {
195
215
  if (this.index >= this.count) {
@@ -210,43 +230,43 @@ class m {
210
230
  case 4:
211
231
  case 6:
212
232
  case 14: {
213
- const r = U(this.elementType);
214
- a(this.payload, this.offset, r);
233
+ const r = l(this.elementType);
234
+ I(this.payload, this.offset, r);
215
235
  const e = this.payload.subarray(this.offset, this.offset + r);
216
236
  return this.offset += r, new D(this.elementType, e);
217
237
  }
218
238
  case 12:
219
239
  case 13: {
220
- const r = { offset: this.offset }, e = T(this.payload, r, "ArrayMalformed");
221
- a(this.payload, r.offset, e);
240
+ const r = { offset: this.offset }, e = A(this.payload, r, "ArrayMalformed");
241
+ I(this.payload, r.offset, e);
222
242
  const n = this.payload.subarray(r.offset, r.offset + e);
223
243
  return this.offset = r.offset + e, new D(this.elementType, n);
224
244
  }
225
245
  case 11: {
226
- const r = { offset: this.offset }, e = T(this.payload, r, "ArrayMalformed");
227
- a(this.payload, r.offset, e);
246
+ const r = { offset: this.offset }, e = A(this.payload, r, "ArrayMalformed");
247
+ I(this.payload, r.offset, e);
228
248
  const n = this.payload.subarray(r.offset, r.offset + e);
229
249
  return this.offset = r.offset + e, new D(11, n);
230
250
  }
231
251
  case 9: {
232
- const r = V(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
252
+ const r = G(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
233
253
  return this.offset += r, new D(9, e);
234
254
  }
235
255
  case 10: {
236
- const r = M(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
256
+ const r = B(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
237
257
  return this.offset += r, new D(10, e);
238
258
  }
239
259
  default:
240
- throw new Error(`Unsupported array element type ${R[this.elementType]}`);
260
+ throw new Error(`Unsupported array element type ${U[this.elementType]}`);
241
261
  }
242
262
  }
243
263
  }
244
- class D extends N {
264
+ class D extends f {
245
265
  constructor(r, e) {
246
266
  super(r, e);
247
267
  }
248
268
  }
249
- class F {
269
+ class M {
250
270
  payload;
251
271
  keyType;
252
272
  valueType;
@@ -258,12 +278,12 @@ class F {
258
278
  throw new Error("Dictionary payload too short");
259
279
  if (this.keyType = r[0] >> 4 & 15, this.valueType = r[1] >> 4 & 15, (r[0] & 15) !== 0 || (r[1] & 15) !== 0)
260
280
  throw new Error("Dictionary key/value flags must be zero");
261
- x(this.keyType);
281
+ k(this.keyType);
262
282
  const e = { offset: 2 };
263
- this.count = T(r, e, "DictMalformed"), this.offset = e.offset;
283
+ this.count = A(r, e, "DictMalformed"), this.offset = e.offset;
264
284
  }
265
285
  static create(r) {
266
- return new F(O(r));
286
+ return new M(O(r));
267
287
  }
268
288
  next() {
269
289
  if (this.index >= this.count) {
@@ -272,20 +292,20 @@ class F {
272
292
  return null;
273
293
  }
274
294
  const r = this.readKey(), e = this.readValue();
275
- return this.index++, new et(r, e);
295
+ return this.index++, new st(r, e);
276
296
  }
277
297
  readKey() {
278
- const r = U(this.keyType);
298
+ const r = l(this.keyType);
279
299
  if (r >= 0) {
280
- a(this.payload, this.offset, r);
300
+ I(this.payload, this.offset, r);
281
301
  const e = this.payload.subarray(this.offset, this.offset + r);
282
- return this.offset += r, new N(this.keyType, e);
302
+ return this.offset += r, new f(this.keyType, e);
283
303
  }
284
304
  if (this.keyType === 12 || this.keyType === 13) {
285
- const e = { offset: this.offset }, n = T(this.payload, e, "DictMalformed");
286
- a(this.payload, e.offset, n);
305
+ const e = { offset: this.offset }, n = A(this.payload, e, "DictMalformed");
306
+ I(this.payload, e.offset, n);
287
307
  const s = this.payload.subarray(e.offset, e.offset + n);
288
- return this.offset = e.offset + n, new N(this.keyType, s);
308
+ return this.offset = e.offset + n, new f(this.keyType, s);
289
309
  }
290
310
  throw new Error("Unsupported dictionary key type");
291
311
  }
@@ -293,24 +313,24 @@ class F {
293
313
  switch (this.valueType) {
294
314
  case 12:
295
315
  case 13: {
296
- const r = { offset: this.offset }, e = T(this.payload, r, "DictMalformed");
297
- a(this.payload, r.offset, e);
316
+ const r = { offset: this.offset }, e = A(this.payload, r, "DictMalformed");
317
+ I(this.payload, r.offset, e);
298
318
  const n = this.payload.subarray(r.offset, r.offset + e);
299
- return this.offset = r.offset + e, new N(this.valueType, n);
319
+ return this.offset = r.offset + e, new f(this.valueType, n);
300
320
  }
301
321
  case 11: {
302
- const r = { offset: this.offset }, e = T(this.payload, r, "DictMalformed");
303
- a(this.payload, r.offset, e);
322
+ const r = { offset: this.offset }, e = A(this.payload, r, "DictMalformed");
323
+ I(this.payload, r.offset, e);
304
324
  const n = this.payload.subarray(r.offset, r.offset + e);
305
- return this.offset = r.offset + e, new N(11, n);
325
+ return this.offset = r.offset + e, new f(11, n);
306
326
  }
307
327
  case 9: {
308
- const r = V(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
309
- return this.offset += r, new N(9, e);
328
+ const r = G(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
329
+ return this.offset += r, new f(9, e);
310
330
  }
311
331
  case 10: {
312
- const r = M(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
313
- return this.offset += r, new N(10, e);
332
+ const r = B(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
333
+ return this.offset += r, new f(10, e);
314
334
  }
315
335
  case 3:
316
336
  case 5:
@@ -321,22 +341,22 @@ class F {
321
341
  case 6:
322
342
  case 14:
323
343
  case 1: {
324
- const r = U(this.valueType);
325
- a(this.payload, this.offset, r);
344
+ const r = l(this.valueType);
345
+ I(this.payload, this.offset, r);
326
346
  const e = this.payload.subarray(this.offset, this.offset + r);
327
- return this.offset += r, new N(this.valueType, e);
347
+ return this.offset += r, new f(this.valueType, e);
328
348
  }
329
349
  default:
330
- throw new Error(`Unsupported dictionary value type ${R[this.valueType]}`);
350
+ throw new Error(`Unsupported dictionary value type ${U[this.valueType]}`);
331
351
  }
332
352
  }
333
353
  }
334
- class et {
354
+ class st {
335
355
  constructor(r, e) {
336
356
  this.key = r, this.value = e;
337
357
  }
338
358
  }
339
- class i {
359
+ class a {
340
360
  constructor(r) {
341
361
  this.bytes = r;
342
362
  }
@@ -346,19 +366,19 @@ class i {
346
366
  const e = r.replace(/-/g, "");
347
367
  if (e.length !== 32)
348
368
  throw new Error("Guid string must be 32 hex characters");
349
- const n = new Uint8Array(16), s = i.parseHexSlice(e, 0, 8), E = i.parseHexSlice(e, 8, 4), _ = i.parseHexSlice(e, 12, 4);
350
- i.writeUInt32LE(n, 0, s), i.writeUInt16LE(n, 4, E), i.writeUInt16LE(n, 6, _);
351
- for (let I = 0; I < 8; I++)
352
- n[8 + I] = i.parseHexSlice(e, 16 + I * 2, 2);
353
- return new i(n);
369
+ const n = new Uint8Array(16), s = a.parseHexSlice(e, 0, 8), E = a.parseHexSlice(e, 8, 4), _ = a.parseHexSlice(e, 12, 4);
370
+ a.writeUInt32LE(n, 0, s), a.writeUInt16LE(n, 4, E), a.writeUInt16LE(n, 6, _);
371
+ for (let i = 0; i < 8; i++)
372
+ n[8 + i] = a.parseHexSlice(e, 16 + i * 2, 2);
373
+ return new a(n);
354
374
  }
355
375
  static fromBytes(r) {
356
376
  if (r.length !== 16)
357
377
  throw new Error("Guid byte array must be 16 bytes");
358
- return new i(Uint8Array.from(r));
378
+ return new a(Uint8Array.from(r));
359
379
  }
360
380
  static createZero() {
361
- return new i(new Uint8Array(16));
381
+ return new a(new Uint8Array(16));
362
382
  }
363
383
  static createRandom() {
364
384
  const r = new Uint8Array(16), e = globalThis.crypto;
@@ -367,16 +387,16 @@ class i {
367
387
  else
368
388
  for (let n = 0; n < r.length; n++)
369
389
  r[n] = Math.floor(Math.random() * 256);
370
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, new i(r);
390
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, new a(r);
371
391
  }
372
392
  toString() {
373
393
  const r = this.bytes;
374
394
  return [
375
- i.toHex(i.readUInt32LE(r, 0), 8),
376
- i.toHex(i.readUInt16LE(r, 4), 4),
377
- i.toHex(i.readUInt16LE(r, 6), 4),
378
- d(r.subarray(8, 10)),
379
- d(r.subarray(10, 16))
395
+ a.toHex(a.readUInt32LE(r, 0), 8),
396
+ a.toHex(a.readUInt16LE(r, 4), 4),
397
+ a.toHex(a.readUInt16LE(r, 6), 4),
398
+ K(r.subarray(8, 10)),
399
+ K(r.subarray(10, 16))
380
400
  ].join("-");
381
401
  }
382
402
  asBytes() {
@@ -406,14 +426,14 @@ class i {
406
426
  return (r >>> 0).toString(16).padStart(e, "0");
407
427
  }
408
428
  }
409
- function T(t, r, e) {
429
+ function A(t, r, e) {
410
430
  if (r.offset >= t.length)
411
431
  throw new Error(e);
412
432
  let n = 0, s = 0, E = 0;
413
433
  for (; r.offset < t.length; ) {
414
434
  const _ = t[r.offset++];
415
435
  if (E++, n |= (_ & 127) << s, (_ & 128) === 0) {
416
- if (E !== nt(n))
436
+ if (E !== Et(n))
417
437
  throw new Error("Teleport VarUInt is not canonical");
418
438
  return n >>> 0;
419
439
  }
@@ -422,10 +442,10 @@ function T(t, r, e) {
422
442
  }
423
443
  throw new Error(e);
424
444
  }
425
- function nt(t) {
445
+ function Et(t) {
426
446
  return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
427
447
  }
428
- function U(t) {
448
+ function l(t) {
429
449
  switch (t) {
430
450
  case 3:
431
451
  case 5:
@@ -445,96 +465,96 @@ function U(t) {
445
465
  return -1;
446
466
  }
447
467
  }
448
- function x(t) {
468
+ function k(t) {
449
469
  if (t === 9 || t === 11 || t === 10 || t === 1)
450
470
  throw new Error("Dictionary keys must be primitive Teleport types");
451
471
  }
452
- function a(t, r, e) {
472
+ function I(t, r, e) {
453
473
  if (r < 0 || e < 0 || r + e > t.length)
454
474
  throw new Error("Teleport payload exceeds bounds");
455
475
  }
456
- function st(t, r) {
476
+ function _t(t, r) {
457
477
  return (t[r] | t[r + 1] << 8 | t[r + 2] << 16 | t[r + 3] << 24) >>> 0;
458
478
  }
459
- function V(t, r) {
479
+ function G(t, r) {
460
480
  if (r >= t.length)
461
481
  throw new Error("Array payload exceeds bounds");
462
482
  const e = t[r], n = e >> 4 & 15;
463
483
  if ((e & 15) !== 0)
464
484
  throw new Error("Array flags must be zero");
465
- const s = { offset: r + 1 }, E = T(t, s, "ArrayMalformed"), _ = U(n);
485
+ const s = { offset: r + 1 }, E = A(t, s, "ArrayMalformed"), _ = l(n);
466
486
  if (_ >= 0) {
467
- const f = _ * E;
468
- return a(t, s.offset, f), s.offset + f - r;
487
+ const N = _ * E;
488
+ return I(t, s.offset, N), s.offset + N - r;
469
489
  }
470
- let I = s.offset;
471
- for (let f = 0; f < E; f++)
472
- I = g(n, t, I, "ArrayMalformed");
473
- return I - r;
490
+ let i = s.offset;
491
+ for (let N = 0; N < E; N++)
492
+ i = F(n, t, i, "ArrayMalformed");
493
+ return i - r;
474
494
  }
475
- function M(t, r) {
495
+ function B(t, r) {
476
496
  if (r + 2 > t.length)
477
497
  throw new Error("Dictionary payload too short");
478
498
  const e = t[r] >> 4 & 15, n = t[r + 1] >> 4 & 15;
479
499
  if ((t[r] & 15) !== 0 || (t[r + 1] & 15) !== 0)
480
500
  throw new Error("Dictionary key/value flags must be zero");
481
- x(e);
482
- const s = { offset: r + 2 }, E = T(t, s, "DictMalformed");
501
+ k(e);
502
+ const s = { offset: r + 2 }, E = A(t, s, "DictMalformed");
483
503
  let _ = s.offset;
484
- for (let I = 0; I < E; I++)
485
- _ = g(e, t, _, "DictMalformed"), _ = g(n, t, _, "DictMalformed");
504
+ for (let i = 0; i < E; i++)
505
+ _ = F(e, t, _, "DictMalformed"), _ = F(n, t, _, "DictMalformed");
486
506
  return _ - r;
487
507
  }
488
- function g(t, r, e, n) {
489
- const s = U(t);
508
+ function F(t, r, e, n) {
509
+ const s = l(t);
490
510
  if (s >= 0)
491
- return a(r, e, s), e + s;
511
+ return I(r, e, s), e + s;
492
512
  switch (t) {
493
513
  case 12:
494
514
  case 13: {
495
- const E = { offset: e }, _ = T(r, E, n);
496
- return a(r, E.offset, _), E.offset + _;
515
+ const E = { offset: e }, _ = A(r, E, n);
516
+ return I(r, E.offset, _), E.offset + _;
497
517
  }
498
518
  case 11: {
499
- const E = { offset: e }, _ = T(r, E, n);
500
- return a(r, E.offset, _), E.offset + _;
519
+ const E = { offset: e }, _ = A(r, E, n);
520
+ return I(r, E.offset, _), E.offset + _;
501
521
  }
502
522
  case 9:
503
- return e + V(r, e);
523
+ return e + G(r, e);
504
524
  case 10:
505
- return e + M(r, e);
525
+ return e + B(r, e);
506
526
  default:
507
- throw new Error(`Unsupported Teleport type ${R[t]}`);
527
+ throw new Error(`Unsupported Teleport type ${U[t]}`);
508
528
  }
509
529
  }
510
- function d(t) {
530
+ function K(t) {
511
531
  return Array.from(t).map((r) => r.toString(16).padStart(2, "0")).join("");
512
532
  }
513
533
  function O(t) {
514
534
  return t instanceof Uint8Array ? t : new Uint8Array(t);
515
535
  }
516
- var u = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Vp8 = 2] = "Vp8", t[t.Vp9 = 3] = "Vp9", t[t.Av1 = 4] = "Av1", t))(u || {}), L = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.CONSTANT_GROUP_BITS = 15] = "CONSTANT_GROUP_BITS", t[t.CONSTANT_GROUP_OFFSET = 16] = "CONSTANT_GROUP_OFFSET", t[t.GROUP_CORE = 65536] = "GROUP_CORE", t[t.CORE_AUTH_RESPONSE = 65537] = "CORE_AUTH_RESPONSE", t[t.CORE_AUTH_TICKET = 65538] = "CORE_AUTH_TICKET", t[t.CORE_GLOBAL_STATE = 65539] = "CORE_GLOBAL_STATE", t[t.CORE_ON_SERVER_STATUS_PING = 65540] = "CORE_ON_SERVER_STATUS_PING", t[t.CORE_ON_USER_JOINED = 65541] = "CORE_ON_USER_JOINED", t[t.CORE_ON_USER_LEFT = 65542] = "CORE_ON_USER_LEFT", t[t.CORE_ON_CLIENT_JOINED = 65543] = "CORE_ON_CLIENT_JOINED", t[t.CORE_ON_CLIENT_LEFT = 65544] = "CORE_ON_CLIENT_LEFT", t[t.CORE_ON_SERVER_STARTED = 65545] = "CORE_ON_SERVER_STARTED", t[t.CORE_ON_SERVER_STOPPED = 65546] = "CORE_ON_SERVER_STOPPED", t[t.CORE_ON_SERVER_STOPPING = 65547] = "CORE_ON_SERVER_STOPPING", t[t.CORE_ON_CLIENT_READY = 65548] = "CORE_ON_CLIENT_READY", t[t.CORE_CLIENT_READY = 65549] = "CORE_CLIENT_READY", t[t.CORE_SERVER_INIT = 65550] = "CORE_SERVER_INIT", t[t.CORE_ON_PLUGIN_RELOADED = 65551] = "CORE_ON_PLUGIN_RELOADED", t[t.CORE_SERVER_START = 65552] = "CORE_SERVER_START", t[t.CORE_SERVER_STOP = 65553] = "CORE_SERVER_STOP", t[t.CORE_ON_HOSTED_SERVER_EXIT = 65554] = "CORE_ON_HOSTED_SERVER_EXIT", t[t.CORE_DYNAMIC_CONFIG = 65555] = "CORE_DYNAMIC_CONFIG", t[t.CORE_PROXY_RPC_AUTH_TICKET = 65556] = "CORE_PROXY_RPC_AUTH_TICKET", t[t.CORE_SERVER_INIT2 = 65557] = "CORE_SERVER_INIT2", t[t.GROUP_KEEPALIVE = 131072] = "GROUP_KEEPALIVE", t[t.KEEPALIVE_REQUEST = 131073] = "KEEPALIVE_REQUEST", t[t.KEEPALIVE_RESPONSE = 131074] = "KEEPALIVE_RESPONSE", t[t.GROUP_EVENTS = 262144] = "GROUP_EVENTS", t[t.EVENTS_PROFILE_UPDATE = 262145] = "EVENTS_PROFILE_UPDATE", t[t.EVENTS_CHANNEL_COMPLETE = 262146] = "EVENTS_CHANNEL_COMPLETE", t[t.EVENTS_SPEECH_PLAYBACK_COMPLETE = 262147] = "EVENTS_SPEECH_PLAYBACK_COMPLETE", t[t.GROUP_ANALYTICS = 524288] = "GROUP_ANALYTICS", t[t.ANALYTICS_LOGS = 524289] = "ANALYTICS_LOGS", t[t.ANALYTICS_EVENTS = 524290] = "ANALYTICS_EVENTS", t[t.ANALYTICS_USAGES = 524291] = "ANALYTICS_USAGES", t[t.ANALYTICS_USAGE = 524292] = "ANALYTICS_USAGE", t[t.ANALYTICS_SPECIAL_LOG = 524293] = "ANALYTICS_SPECIAL_LOG", t[t.ANALYTICS_PROCESSING_UPDATE = 524294] = "ANALYTICS_PROCESSING_UPDATE", t[t.ANALYTICS_REACTIVE_PROCESSING_UPDATE = 524295] = "ANALYTICS_REACTIVE_PROCESSING_UPDATE", t[t.ANALYTICS_IKON_PROXY_SERVER_STATS = 524296] = "ANALYTICS_IKON_PROXY_SERVER_STATS", t[t.ANALYTICS_DEVTOOLS_CONSOLE_OUTPUT = 524297] = "ANALYTICS_DEVTOOLS_CONSOLE_OUTPUT", t[t.GROUP_ACTIONS = 1048576] = "GROUP_ACTIONS", t[t.ACTION_CALL = 1048577] = "ACTION_CALL", t[t.ACTION_ACTIVE = 1048578] = "ACTION_ACTIVE", t[t.ACTION_TEXT_OUTPUT = 1048579] = "ACTION_TEXT_OUTPUT", t[t.ACTION_TEXT_OUTPUT_DELTA = 1048580] = "ACTION_TEXT_OUTPUT_DELTA", t[t.ACTION_TEXT_OUTPUT_DELTA_FULL = 1048581] = "ACTION_TEXT_OUTPUT_DELTA_FULL", t[t.ACTION_SET_STATE = 1048582] = "ACTION_SET_STATE", t[t.ACTION_TAP = 1048583] = "ACTION_TAP", t[t.ACTION_PAN = 1048584] = "ACTION_PAN", t[t.ACTION_ZOOM = 1048585] = "ACTION_ZOOM", t[t.ACTION_FILE_UPLOAD_BEGIN = 1048586] = "ACTION_FILE_UPLOAD_BEGIN", t[t.ACTION_FILE_UPLOAD_DATA = 1048587] = "ACTION_FILE_UPLOAD_DATA", t[t.ACTION_FILE_UPLOAD_ACK = 1048588] = "ACTION_FILE_UPLOAD_ACK", t[t.ACTION_FILE_UPLOAD_END = 1048589] = "ACTION_FILE_UPLOAD_END", t[t.ACTION_FILE_UPLOAD_RESULT = 1048590] = "ACTION_FILE_UPLOAD_RESULT", t[t.ACTION_OPEN_CHANNEL = 1048591] = "ACTION_OPEN_CHANNEL", t[t.ACTION_OPEN_EXTERNAL_URL = 1048592] = "ACTION_OPEN_EXTERNAL_URL", t[t.ACTION_UI_OPEN_VIEW = 1048593] = "ACTION_UI_OPEN_VIEW", t[t.ACTION_UI_CLOSE_VIEW = 1048594] = "ACTION_UI_CLOSE_VIEW", t[t.ACTION_UI_BLOCKING_BEGIN = 1048595] = "ACTION_UI_BLOCKING_BEGIN", t[t.ACTION_UI_BLOCKING_END = 1048596] = "ACTION_UI_BLOCKING_END", t[t.ACTION_UI_UPDATE_TEXT_DELTA = 1048597] = "ACTION_UI_UPDATE_TEXT_DELTA", t[t.ACTION_UI_DELETE_CONTAINER = 1048598] = "ACTION_UI_DELETE_CONTAINER", t[t.ACTION_UPDATE_GFX_SHADER = 1048599] = "ACTION_UPDATE_GFX_SHADER", t[t.ACTION_FUNCTION_REGISTER = 1048600] = "ACTION_FUNCTION_REGISTER", t[t.ACTION_FUNCTION_CALL = 1048601] = "ACTION_FUNCTION_CALL", t[t.ACTION_FUNCTION_RESULT = 1048602] = "ACTION_FUNCTION_RESULT", t[t.ACTION_GENERATE_ANSWER = 1048603] = "ACTION_GENERATE_ANSWER", t[t.ACTION_REGENERATE_ANSWER = 1048604] = "ACTION_REGENERATE_ANSWER", t[t.ACTION_CLEAR_CHAT_MESSAGE_HISTORY = 1048605] = "ACTION_CLEAR_CHAT_MESSAGE_HISTORY", t[t.ACTION_CLEAR_STATE = 1048606] = "ACTION_CLEAR_STATE", t[t.ACTION_RELOAD_CHANNELS = 1048607] = "ACTION_RELOAD_CHANNELS", t[t.ACTION_RELOAD_PROFILE = 1048608] = "ACTION_RELOAD_PROFILE", t[t.ACTION_CLASSIFICATION_RESULT = 1048609] = "ACTION_CLASSIFICATION_RESULT", t[t.ACTION_AUDIO_STOP = 1048610] = "ACTION_AUDIO_STOP", t[t.ACTION_CALL_TEXT = 1048611] = "ACTION_CALL_TEXT", t[t.ACTION_RELOAD_APPLICATION = 1048612] = "ACTION_RELOAD_APPLICATION", t[t.ACTION_CANCEL_GENERATION = 1048613] = "ACTION_CANCEL_GENERATION", t[t.ACTION_UI_SET_CONTAINER_STABLE = 1048614] = "ACTION_UI_SET_CONTAINER_STABLE", t[t.ACTION_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", t[t.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", t[t.ACTION_RELOAD_PROVIDER = 1048617] = "ACTION_RELOAD_PROVIDER", t[t.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", t[t.ACTION_SCROLL_TO_CONTAINER = 1048619] = "ACTION_SCROLL_TO_CONTAINER", t[t.ACTION_UI_CLEAR_STREAM = 1048620] = "ACTION_UI_CLEAR_STREAM", t[t.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", t[t.ACTION_ENTER_FULLSCREEN = 1048622] = "ACTION_ENTER_FULLSCREEN", t[t.ACTION_STOP_SOUND = 1048623] = "ACTION_STOP_SOUND", t[t.ACTION_START_RECORDING = 1048624] = "ACTION_START_RECORDING", t[t.ACTION_STOP_RECORDING = 1048625] = "ACTION_STOP_RECORDING", t[t.ACTION_OPTIMISTIC_CLIENT_CALLS = 1048626] = "ACTION_OPTIMISTIC_CLIENT_CALLS", t[t.ACTION_FUNCTION_ENUMERATION_ITEM = 1048627] = "ACTION_FUNCTION_ENUMERATION_ITEM", t[t.ACTION_FUNCTION_ENUMERATION_END = 1048628] = "ACTION_FUNCTION_ENUMERATION_END", t[t.ACTION_FUNCTION_CANCEL = 1048629] = "ACTION_FUNCTION_CANCEL", t[t.ACTION_FUNCTION_DISPOSE = 1048630] = "ACTION_FUNCTION_DISPOSE", t[t.ACTION_FUNCTION_ERROR = 1048631] = "ACTION_FUNCTION_ERROR", t[t.ACTION_FUNCTION_ACK = 1048632] = "ACTION_FUNCTION_ACK", t[t.ACTION_FUNCTION_AWAITING_APPROVAL = 1048633] = "ACTION_FUNCTION_AWAITING_APPROVAL", t[t.ACTION_FUNCTION_APPROVAL_REQUIRED = 1048634] = "ACTION_FUNCTION_APPROVAL_REQUIRED", t[t.ACTION_FUNCTION_APPROVAL_RESPONSE = 1048635] = "ACTION_FUNCTION_APPROVAL_RESPONSE", t[t.UI_UPDATE_ACK = 1048636] = "UI_UPDATE_ACK", t[t.ACTION_CALL2 = 1048637] = "ACTION_CALL2", t[t.ACTION_FUNCTION_REGISTER_BATCH = 1048638] = "ACTION_FUNCTION_REGISTER_BATCH", t[t.ACTION_TRIGGER_GIT_PULL = 1048639] = "ACTION_TRIGGER_GIT_PULL", t[t.GROUP_UI = 2097152] = "GROUP_UI", t[t.UI_STREAM_BEGIN = 2097153] = "UI_STREAM_BEGIN", t[t.UI_STREAM_END = 2097154] = "UI_STREAM_END", t[t.UI_CONTAINER_BEGIN = 2097155] = "UI_CONTAINER_BEGIN", t[t.UI_CONTAINER_END = 2097156] = "UI_CONTAINER_END", t[t.UI_SECTION_BEGIN = 2097157] = "UI_SECTION_BEGIN", t[t.UI_SECTION_END = 2097158] = "UI_SECTION_END", t[t.UI_LIST_BEGIN = 2097159] = "UI_LIST_BEGIN", t[t.UI_LIST_ITEM = 2097160] = "UI_LIST_ITEM", t[t.UI_LIST_END = 2097161] = "UI_LIST_END", t[t.UI_TEXT = 2097162] = "UI_TEXT", t[t.UI_HEADER = 2097163] = "UI_HEADER", t[t.UI_SEPARATOR = 2097164] = "UI_SEPARATOR", t[t.UI_BUTTON = 2097165] = "UI_BUTTON", t[t.UI_ICON_BUTTON = 2097166] = "UI_ICON_BUTTON", t[t.UI_IMAGE = 2097167] = "UI_IMAGE", t[t.UI_FILE = 2097168] = "UI_FILE", t[t.UI_BADGE = 2097169] = "UI_BADGE", t[t.UI_CONTENT_LINK = 2097170] = "UI_CONTENT_LINK", t[t.UI_MAP = 2097171] = "UI_MAP", t[t.UI_VEGA_CHART = 2097172] = "UI_VEGA_CHART", t[t.UI_ICON = 2097173] = "UI_ICON", t[t.UI_FILE_UPLOAD_SECTION_BEGIN = 2097174] = "UI_FILE_UPLOAD_SECTION_BEGIN", t[t.UI_FILE_UPLOAD_SECTION_END = 2097175] = "UI_FILE_UPLOAD_SECTION_END", t[t.UI_MATERIAL_SYMBOL = 2097176] = "UI_MATERIAL_SYMBOL", t[t.UI_BUTTON_BEGIN = 2097177] = "UI_BUTTON_BEGIN", t[t.UI_BUTTON_END = 2097178] = "UI_BUTTON_END", t[t.UI_CONTAINER_DELETE = 2097179] = "UI_CONTAINER_DELETE", t[t.UI_INPUT_TEXT = 2097180] = "UI_INPUT_TEXT", t[t.UI_PROGRESS_BAR = 2097181] = "UI_PROGRESS_BAR", t[t.UI_UPDATE_BEGIN = 2097182] = "UI_UPDATE_BEGIN", t[t.UI_UPDATE_END = 2097183] = "UI_UPDATE_END", t[t.UI_AUTOCOMPLETE = 2097184] = "UI_AUTOCOMPLETE", t[t.UI_CHECKBOX = 2097185] = "UI_CHECKBOX", t[t.UI_QS = 2097186] = "UI_QS", t[t.UI_ELEMENT = 2097187] = "UI_ELEMENT", t[t.UI_STYLES = 2097188] = "UI_STYLES", t[t.UI_SVG = 2097189] = "UI_SVG", t[t.UI_UPDATE = 2097190] = "UI_UPDATE", t[t.UI_INIT = 2097191] = "UI_INIT", t[t.UI_STYLES_BATCH = 2097192] = "UI_STYLES_BATCH", t[t.UI_STYLES_DELETE = 2097193] = "UI_STYLES_DELETE", t[t.GROUP_COMMON = 4128768] = "GROUP_COMMON", t[t.GROUP_AUDIO = 4194304] = "GROUP_AUDIO", t[t.AUDIO_STREAM_BEGIN = 4194305] = "AUDIO_STREAM_BEGIN", t[t.AUDIO_STREAM_END = 4194306] = "AUDIO_STREAM_END", t[t.AUDIO_FRAME = 4194307] = "AUDIO_FRAME", t[t.AUDIO_FRAME_VOLUME = 4194308] = "AUDIO_FRAME_VOLUME", t[t.AUDIO_FRAME2 = 4194309] = "AUDIO_FRAME2", t[t.GROUP_VIDEO = 8388608] = "GROUP_VIDEO", t[t.VIDEO_STREAM_BEGIN = 8388609] = "VIDEO_STREAM_BEGIN", t[t.VIDEO_STREAM_END = 8388610] = "VIDEO_STREAM_END", t[t.VIDEO_FRAME = 8388611] = "VIDEO_FRAME", t[t.VIDEO_REQUEST_IDR_FRAME = 8388612] = "VIDEO_REQUEST_IDR_FRAME", t[t.VIDEO_INVALIDATE_FRAME = 8388613] = "VIDEO_INVALIDATE_FRAME", t[t.GROUP_TRACKING = 16777216] = "GROUP_TRACKING", t[t.TRACKING_STREAM_BEGIN = 16777217] = "TRACKING_STREAM_BEGIN", t[t.TRACKING_STREAM_END = 16777218] = "TRACKING_STREAM_END", t[t.TRACKING_FRAME = 16777219] = "TRACKING_FRAME", t[t.GROUP_SCENE = 33554432] = "GROUP_SCENE", t[t.SCENE_MESH = 33554433] = "SCENE_MESH", t[t.SCENE_ARRAY = 33554434] = "SCENE_ARRAY", t[t.GROUP_ALL = 67043328] = "GROUP_ALL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(L || {});
517
- const Et = 1, _t = 8388609, it = 164808083, It = 1368629611, at = 2739413426, Tt = 2768375929, At = 2950031986, Nt = 3284746250, ft = 4065070594;
518
- function ot(t) {
536
+ var h = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Vp8 = 2] = "Vp8", t[t.Vp9 = 3] = "Vp9", t[t.Av1 = 4] = "Av1", t))(h || {}), L = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.CONSTANT_GROUP_BITS = 15] = "CONSTANT_GROUP_BITS", t[t.CONSTANT_GROUP_OFFSET = 16] = "CONSTANT_GROUP_OFFSET", t[t.GROUP_CORE = 65536] = "GROUP_CORE", t[t.CORE_AUTH_RESPONSE = 65537] = "CORE_AUTH_RESPONSE", t[t.CORE_AUTH_TICKET = 65538] = "CORE_AUTH_TICKET", t[t.CORE_GLOBAL_STATE = 65539] = "CORE_GLOBAL_STATE", t[t.CORE_ON_SERVER_STATUS_PING = 65540] = "CORE_ON_SERVER_STATUS_PING", t[t.CORE_ON_USER_JOINED = 65541] = "CORE_ON_USER_JOINED", t[t.CORE_ON_USER_LEFT = 65542] = "CORE_ON_USER_LEFT", t[t.CORE_ON_CLIENT_JOINED = 65543] = "CORE_ON_CLIENT_JOINED", t[t.CORE_ON_CLIENT_LEFT = 65544] = "CORE_ON_CLIENT_LEFT", t[t.CORE_ON_SERVER_STARTED = 65545] = "CORE_ON_SERVER_STARTED", t[t.CORE_ON_SERVER_STOPPED = 65546] = "CORE_ON_SERVER_STOPPED", t[t.CORE_ON_SERVER_STOPPING = 65547] = "CORE_ON_SERVER_STOPPING", t[t.CORE_ON_CLIENT_READY = 65548] = "CORE_ON_CLIENT_READY", t[t.CORE_CLIENT_READY = 65549] = "CORE_CLIENT_READY", t[t.CORE_SERVER_INIT = 65550] = "CORE_SERVER_INIT", t[t.CORE_ON_PLUGIN_RELOADED = 65551] = "CORE_ON_PLUGIN_RELOADED", t[t.CORE_SERVER_START = 65552] = "CORE_SERVER_START", t[t.CORE_SERVER_STOP = 65553] = "CORE_SERVER_STOP", t[t.CORE_ON_HOSTED_SERVER_EXIT = 65554] = "CORE_ON_HOSTED_SERVER_EXIT", t[t.CORE_DYNAMIC_CONFIG = 65555] = "CORE_DYNAMIC_CONFIG", t[t.CORE_PROXY_RPC_AUTH_TICKET = 65556] = "CORE_PROXY_RPC_AUTH_TICKET", t[t.CORE_SERVER_INIT2 = 65557] = "CORE_SERVER_INIT2", t[t.GROUP_KEEPALIVE = 131072] = "GROUP_KEEPALIVE", t[t.KEEPALIVE_REQUEST = 131073] = "KEEPALIVE_REQUEST", t[t.KEEPALIVE_RESPONSE = 131074] = "KEEPALIVE_RESPONSE", t[t.GROUP_EVENTS = 262144] = "GROUP_EVENTS", t[t.EVENTS_PROFILE_UPDATE = 262145] = "EVENTS_PROFILE_UPDATE", t[t.EVENTS_CHANNEL_COMPLETE = 262146] = "EVENTS_CHANNEL_COMPLETE", t[t.EVENTS_SPEECH_PLAYBACK_COMPLETE = 262147] = "EVENTS_SPEECH_PLAYBACK_COMPLETE", t[t.GROUP_ANALYTICS = 524288] = "GROUP_ANALYTICS", t[t.ANALYTICS_LOGS = 524289] = "ANALYTICS_LOGS", t[t.ANALYTICS_EVENTS = 524290] = "ANALYTICS_EVENTS", t[t.ANALYTICS_USAGES = 524291] = "ANALYTICS_USAGES", t[t.ANALYTICS_USAGE = 524292] = "ANALYTICS_USAGE", t[t.ANALYTICS_SPECIAL_LOG = 524293] = "ANALYTICS_SPECIAL_LOG", t[t.ANALYTICS_PROCESSING_UPDATE = 524294] = "ANALYTICS_PROCESSING_UPDATE", t[t.ANALYTICS_REACTIVE_PROCESSING_UPDATE = 524295] = "ANALYTICS_REACTIVE_PROCESSING_UPDATE", t[t.ANALYTICS_IKON_PROXY_SERVER_STATS = 524296] = "ANALYTICS_IKON_PROXY_SERVER_STATS", t[t.GROUP_ACTIONS = 1048576] = "GROUP_ACTIONS", t[t.ACTION_CALL = 1048577] = "ACTION_CALL", t[t.ACTION_ACTIVE = 1048578] = "ACTION_ACTIVE", t[t.ACTION_TEXT_OUTPUT = 1048579] = "ACTION_TEXT_OUTPUT", t[t.ACTION_TEXT_OUTPUT_DELTA = 1048580] = "ACTION_TEXT_OUTPUT_DELTA", t[t.ACTION_TEXT_OUTPUT_DELTA_FULL = 1048581] = "ACTION_TEXT_OUTPUT_DELTA_FULL", t[t.ACTION_SET_STATE = 1048582] = "ACTION_SET_STATE", t[t.ACTION_TAP = 1048583] = "ACTION_TAP", t[t.ACTION_PAN = 1048584] = "ACTION_PAN", t[t.ACTION_ZOOM = 1048585] = "ACTION_ZOOM", t[t.ACTION_FILE_UPLOAD_BEGIN = 1048586] = "ACTION_FILE_UPLOAD_BEGIN", t[t.ACTION_FILE_UPLOAD_DATA = 1048587] = "ACTION_FILE_UPLOAD_DATA", t[t.ACTION_FILE_UPLOAD_ACK = 1048588] = "ACTION_FILE_UPLOAD_ACK", t[t.ACTION_FILE_UPLOAD_END = 1048589] = "ACTION_FILE_UPLOAD_END", t[t.ACTION_FILE_UPLOAD_RESULT = 1048590] = "ACTION_FILE_UPLOAD_RESULT", t[t.ACTION_OPEN_CHANNEL = 1048591] = "ACTION_OPEN_CHANNEL", t[t.ACTION_OPEN_EXTERNAL_URL = 1048592] = "ACTION_OPEN_EXTERNAL_URL", t[t.ACTION_UI_OPEN_VIEW = 1048593] = "ACTION_UI_OPEN_VIEW", t[t.ACTION_UI_CLOSE_VIEW = 1048594] = "ACTION_UI_CLOSE_VIEW", t[t.ACTION_UI_BLOCKING_BEGIN = 1048595] = "ACTION_UI_BLOCKING_BEGIN", t[t.ACTION_UI_BLOCKING_END = 1048596] = "ACTION_UI_BLOCKING_END", t[t.ACTION_UI_UPDATE_TEXT_DELTA = 1048597] = "ACTION_UI_UPDATE_TEXT_DELTA", t[t.ACTION_UI_DELETE_CONTAINER = 1048598] = "ACTION_UI_DELETE_CONTAINER", t[t.ACTION_UPDATE_GFX_SHADER = 1048599] = "ACTION_UPDATE_GFX_SHADER", t[t.ACTION_FUNCTION_REGISTER = 1048600] = "ACTION_FUNCTION_REGISTER", t[t.ACTION_FUNCTION_CALL = 1048601] = "ACTION_FUNCTION_CALL", t[t.ACTION_FUNCTION_RESULT = 1048602] = "ACTION_FUNCTION_RESULT", t[t.ACTION_GENERATE_ANSWER = 1048603] = "ACTION_GENERATE_ANSWER", t[t.ACTION_REGENERATE_ANSWER = 1048604] = "ACTION_REGENERATE_ANSWER", t[t.ACTION_CLEAR_CHAT_MESSAGE_HISTORY = 1048605] = "ACTION_CLEAR_CHAT_MESSAGE_HISTORY", t[t.ACTION_CLEAR_STATE = 1048606] = "ACTION_CLEAR_STATE", t[t.ACTION_RELOAD_CHANNELS = 1048607] = "ACTION_RELOAD_CHANNELS", t[t.ACTION_RELOAD_PROFILE = 1048608] = "ACTION_RELOAD_PROFILE", t[t.ACTION_CLASSIFICATION_RESULT = 1048609] = "ACTION_CLASSIFICATION_RESULT", t[t.ACTION_AUDIO_STOP = 1048610] = "ACTION_AUDIO_STOP", t[t.ACTION_CALL_TEXT = 1048611] = "ACTION_CALL_TEXT", t[t.ACTION_RELOAD_APPLICATION = 1048612] = "ACTION_RELOAD_APPLICATION", t[t.ACTION_CANCEL_GENERATION = 1048613] = "ACTION_CANCEL_GENERATION", t[t.ACTION_UI_SET_CONTAINER_STABLE = 1048614] = "ACTION_UI_SET_CONTAINER_STABLE", t[t.ACTION_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", t[t.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", t[t.ACTION_RELOAD_PROVIDER = 1048617] = "ACTION_RELOAD_PROVIDER", t[t.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", t[t.ACTION_SCROLL_TO_CONTAINER = 1048619] = "ACTION_SCROLL_TO_CONTAINER", t[t.ACTION_UI_CLEAR_STREAM = 1048620] = "ACTION_UI_CLEAR_STREAM", t[t.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", t[t.ACTION_ENTER_FULLSCREEN = 1048622] = "ACTION_ENTER_FULLSCREEN", t[t.ACTION_STOP_SOUND = 1048623] = "ACTION_STOP_SOUND", t[t.ACTION_START_RECORDING = 1048624] = "ACTION_START_RECORDING", t[t.ACTION_STOP_RECORDING = 1048625] = "ACTION_STOP_RECORDING", t[t.ACTION_OPTIMISTIC_CLIENT_CALLS = 1048626] = "ACTION_OPTIMISTIC_CLIENT_CALLS", t[t.ACTION_FUNCTION_ENUMERATION_ITEM = 1048627] = "ACTION_FUNCTION_ENUMERATION_ITEM", t[t.ACTION_FUNCTION_ENUMERATION_END = 1048628] = "ACTION_FUNCTION_ENUMERATION_END", t[t.ACTION_FUNCTION_CANCEL = 1048629] = "ACTION_FUNCTION_CANCEL", t[t.ACTION_FUNCTION_DISPOSE = 1048630] = "ACTION_FUNCTION_DISPOSE", t[t.ACTION_FUNCTION_ERROR = 1048631] = "ACTION_FUNCTION_ERROR", t[t.ACTION_FUNCTION_ACK = 1048632] = "ACTION_FUNCTION_ACK", t[t.ACTION_FUNCTION_AWAITING_APPROVAL = 1048633] = "ACTION_FUNCTION_AWAITING_APPROVAL", t[t.ACTION_FUNCTION_APPROVAL_REQUIRED = 1048634] = "ACTION_FUNCTION_APPROVAL_REQUIRED", t[t.ACTION_FUNCTION_APPROVAL_RESPONSE = 1048635] = "ACTION_FUNCTION_APPROVAL_RESPONSE", t[t.UI_UPDATE_ACK = 1048636] = "UI_UPDATE_ACK", t[t.ACTION_CALL2 = 1048637] = "ACTION_CALL2", t[t.ACTION_FUNCTION_REGISTER_BATCH = 1048638] = "ACTION_FUNCTION_REGISTER_BATCH", t[t.ACTION_TRIGGER_GIT_PULL = 1048639] = "ACTION_TRIGGER_GIT_PULL", t[t.ACTION_FILE_UPLOAD_CALLBACK = 1048640] = "ACTION_FILE_UPLOAD_CALLBACK", t[t.GROUP_UI = 2097152] = "GROUP_UI", t[t.UI_STREAM_BEGIN = 2097153] = "UI_STREAM_BEGIN", t[t.UI_STREAM_END = 2097154] = "UI_STREAM_END", t[t.UI_CONTAINER_BEGIN = 2097155] = "UI_CONTAINER_BEGIN", t[t.UI_CONTAINER_END = 2097156] = "UI_CONTAINER_END", t[t.UI_SECTION_BEGIN = 2097157] = "UI_SECTION_BEGIN", t[t.UI_SECTION_END = 2097158] = "UI_SECTION_END", t[t.UI_LIST_BEGIN = 2097159] = "UI_LIST_BEGIN", t[t.UI_LIST_ITEM = 2097160] = "UI_LIST_ITEM", t[t.UI_LIST_END = 2097161] = "UI_LIST_END", t[t.UI_TEXT = 2097162] = "UI_TEXT", t[t.UI_HEADER = 2097163] = "UI_HEADER", t[t.UI_SEPARATOR = 2097164] = "UI_SEPARATOR", t[t.UI_BUTTON = 2097165] = "UI_BUTTON", t[t.UI_ICON_BUTTON = 2097166] = "UI_ICON_BUTTON", t[t.UI_IMAGE = 2097167] = "UI_IMAGE", t[t.UI_FILE = 2097168] = "UI_FILE", t[t.UI_BADGE = 2097169] = "UI_BADGE", t[t.UI_CONTENT_LINK = 2097170] = "UI_CONTENT_LINK", t[t.UI_MAP = 2097171] = "UI_MAP", t[t.UI_VEGA_CHART = 2097172] = "UI_VEGA_CHART", t[t.UI_ICON = 2097173] = "UI_ICON", t[t.UI_FILE_UPLOAD_SECTION_BEGIN = 2097174] = "UI_FILE_UPLOAD_SECTION_BEGIN", t[t.UI_FILE_UPLOAD_SECTION_END = 2097175] = "UI_FILE_UPLOAD_SECTION_END", t[t.UI_MATERIAL_SYMBOL = 2097176] = "UI_MATERIAL_SYMBOL", t[t.UI_BUTTON_BEGIN = 2097177] = "UI_BUTTON_BEGIN", t[t.UI_BUTTON_END = 2097178] = "UI_BUTTON_END", t[t.UI_CONTAINER_DELETE = 2097179] = "UI_CONTAINER_DELETE", t[t.UI_INPUT_TEXT = 2097180] = "UI_INPUT_TEXT", t[t.UI_PROGRESS_BAR = 2097181] = "UI_PROGRESS_BAR", t[t.UI_UPDATE_BEGIN = 2097182] = "UI_UPDATE_BEGIN", t[t.UI_UPDATE_END = 2097183] = "UI_UPDATE_END", t[t.UI_AUTOCOMPLETE = 2097184] = "UI_AUTOCOMPLETE", t[t.UI_CHECKBOX = 2097185] = "UI_CHECKBOX", t[t.UI_QS = 2097186] = "UI_QS", t[t.UI_ELEMENT = 2097187] = "UI_ELEMENT", t[t.UI_STYLES = 2097188] = "UI_STYLES", t[t.UI_SVG = 2097189] = "UI_SVG", t[t.UI_UPDATE = 2097190] = "UI_UPDATE", t[t.UI_INIT = 2097191] = "UI_INIT", t[t.UI_STYLES_BATCH = 2097192] = "UI_STYLES_BATCH", t[t.UI_STYLES_DELETE = 2097193] = "UI_STYLES_DELETE", t[t.GROUP_COMMON = 4128768] = "GROUP_COMMON", t[t.GROUP_AUDIO = 4194304] = "GROUP_AUDIO", t[t.AUDIO_STREAM_BEGIN = 4194305] = "AUDIO_STREAM_BEGIN", t[t.AUDIO_STREAM_END = 4194306] = "AUDIO_STREAM_END", t[t.AUDIO_FRAME = 4194307] = "AUDIO_FRAME", t[t.AUDIO_FRAME_VOLUME = 4194308] = "AUDIO_FRAME_VOLUME", t[t.AUDIO_FRAME2 = 4194309] = "AUDIO_FRAME2", t[t.GROUP_VIDEO = 8388608] = "GROUP_VIDEO", t[t.VIDEO_STREAM_BEGIN = 8388609] = "VIDEO_STREAM_BEGIN", t[t.VIDEO_STREAM_END = 8388610] = "VIDEO_STREAM_END", t[t.VIDEO_FRAME = 8388611] = "VIDEO_FRAME", t[t.VIDEO_REQUEST_IDR_FRAME = 8388612] = "VIDEO_REQUEST_IDR_FRAME", t[t.VIDEO_INVALIDATE_FRAME = 8388613] = "VIDEO_INVALIDATE_FRAME", t[t.GROUP_TRACKING = 16777216] = "GROUP_TRACKING", t[t.TRACKING_STREAM_BEGIN = 16777217] = "TRACKING_STREAM_BEGIN", t[t.TRACKING_STREAM_END = 16777218] = "TRACKING_STREAM_END", t[t.TRACKING_FRAME = 16777219] = "TRACKING_FRAME", t[t.GROUP_SCENE = 33554432] = "GROUP_SCENE", t[t.SCENE_MESH = 33554433] = "SCENE_MESH", t[t.SCENE_ARRAY = 33554434] = "SCENE_ARRAY", t[t.GROUP_ALL = 67043328] = "GROUP_ALL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(L || {});
537
+ const it = 8388609, at = 164808083, It = 1368629611, At = 2739413426, Tt = 2768375929, Nt = 2950031986, ft = 3284746250, ot = 4065070594;
538
+ function Ct(t) {
519
539
  const r = {};
520
- return v(r), r;
521
- }
522
- function v(t) {
523
- return t.Description = "", t.Codec = u.H264, t.Width = 0, t.Height = 0, t.Framerate = 30, t.Bitrate = 0, t.IsHardwareAccelerated = !1, t;
540
+ return Y(r), r;
524
541
  }
525
- function Ct(t, r) {
526
- const e = w.create(t);
527
- return ut(e, r);
542
+ function Y(t) {
543
+ return t.Description = "", t.Codec = h.H264, t.Width = 0, t.Height = 0, t.Framerate = 30, t.Bitrate = 0, t.IsHardwareAccelerated = !1, t;
528
544
  }
529
545
  function ut(t, r) {
530
- const e = r ?? ot();
531
- return v(e), ht(t, e), e;
546
+ const e = P.create(t);
547
+ return ht(e, r);
532
548
  }
533
549
  function ht(t, r) {
550
+ const e = r ?? Ct();
551
+ return Y(e), Rt(t, e), e;
552
+ }
553
+ function Rt(t, r) {
534
554
  let e;
535
555
  for (; (e = t.next()) !== null; )
536
556
  switch (e.fieldId) {
537
- case it: {
557
+ case at: {
538
558
  if (e.isNull) throw new Error();
539
559
  r.Framerate = e.asInt32();
540
560
  break;
@@ -544,7 +564,7 @@ function ht(t, r) {
544
564
  r.Description = e.asString();
545
565
  break;
546
566
  }
547
- case at: {
567
+ case At: {
548
568
  if (e.isNull) throw new Error();
549
569
  r.IsHardwareAccelerated = e.asBool();
550
570
  break;
@@ -554,42 +574,42 @@ function ht(t, r) {
554
574
  r.Bitrate = e.asInt32();
555
575
  break;
556
576
  }
557
- case At: {
577
+ case Nt: {
558
578
  if (e.isNull) throw new Error();
559
579
  r.Height = e.asInt32();
560
580
  break;
561
581
  }
562
- case Nt: {
582
+ case ft: {
563
583
  if (e.isNull) throw new Error();
564
584
  r.Codec = e.asInt32();
565
585
  break;
566
586
  }
567
- case ft: {
587
+ case ot: {
568
588
  if (e.isNull) throw new Error();
569
589
  r.Width = e.asInt32();
570
590
  break;
571
591
  }
572
592
  }
573
593
  }
574
- function Rt(t, r) {
575
- const e = K(t, _t, Et);
576
- return Ct(e, r);
594
+ async function Ut(t, r) {
595
+ const e = await x(t, it);
596
+ return ut(e, r);
577
597
  }
578
- const Ut = 1, lt = 8388611, St = 271275304, Dt = 2541432218, Lt = 2986785889, ct = 3105403172, yt = 3456383222;
598
+ const lt = 8388611, St = 271275304, ct = 2541432218, Dt = 2986785889, Lt = 3105403172, yt = 3456383222;
579
599
  function wt(t) {
580
600
  const r = {};
581
- return Y(r), r;
601
+ return X(r), r;
582
602
  }
583
- function Y(t) {
603
+ function X(t) {
584
604
  return t.Data = new Uint8Array(0), t.FrameNumber = 0, t.IsKey = !1, t.TimestampInUs = 0n, t.DurationInUs = 0, t;
585
605
  }
586
- function Ot(t, r) {
587
- const e = w.create(t);
588
- return Pt(e, r);
589
- }
590
606
  function Pt(t, r) {
607
+ const e = P.create(t);
608
+ return Ot(e, r);
609
+ }
610
+ function Ot(t, r) {
591
611
  const e = r ?? wt();
592
- return Y(e), gt(t, e), e;
612
+ return X(e), gt(t, e), e;
593
613
  }
594
614
  function gt(t, r) {
595
615
  let e;
@@ -600,17 +620,17 @@ function gt(t, r) {
600
620
  r.TimestampInUs = e.asUInt64();
601
621
  break;
602
622
  }
603
- case Dt: {
623
+ case ct: {
604
624
  if (e.isNull) throw new Error();
605
625
  r.DurationInUs = e.asUInt32();
606
626
  break;
607
627
  }
608
- case Lt: {
628
+ case Dt: {
609
629
  if (e.isNull) throw new Error();
610
630
  r.Data = e.asBinary();
611
631
  break;
612
632
  }
613
- case ct: {
633
+ case Lt: {
614
634
  if (e.isNull) throw new Error();
615
635
  r.IsKey = e.asBool();
616
636
  break;
@@ -622,25 +642,25 @@ function gt(t, r) {
622
642
  }
623
643
  }
624
644
  }
625
- function mt(t, r) {
626
- const e = K(t, lt, Ut);
627
- return Ot(e, r);
645
+ async function mt(t, r) {
646
+ const e = await x(t, lt);
647
+ return Pt(e, r);
628
648
  }
629
- const Ft = "avc1.42E01E", Vt = "vp8", Mt = "vp09.00.10.08", Gt = "av01.0.04M.08", Bt = 3, l = (t, r) => self.postMessage(t, r ?? []);
630
- let h = null, y = !0;
631
- const A = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
632
- function o(t) {
649
+ const Ft = "avc1.42E01E", Vt = "vp8", Mt = "vp09.00.10.08", Gt = "av01.0.04M.08", Bt = 3, S = (t, r) => self.postMessage(t, r ?? []);
650
+ let R = null, w = !0;
651
+ const T = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
652
+ function C(t) {
633
653
  const r = t instanceof Error ? t : new Error(String(t));
634
- l({ type: "error", error: { name: r.name, message: r.message, stack: r.stack } });
654
+ S({ type: "error", error: { name: r.name, message: r.message, stack: r.stack } });
635
655
  }
636
- function P(t, r) {
656
+ function g(t, r) {
637
657
  return t << 16 | r & 65535;
638
658
  }
639
- function k(t, r) {
659
+ function W(t, r) {
640
660
  return `${t}_${r}`;
641
661
  }
642
- function X(t, r) {
643
- const e = A.get(t);
662
+ function z(t, r) {
663
+ const e = T.get(t);
644
664
  if (e)
645
665
  return e;
646
666
  const n = {
@@ -659,38 +679,38 @@ function X(t, r) {
659
679
  isKeyFrameRequired: !0,
660
680
  pendingDecodeCount: 0
661
681
  };
662
- return A.set(t, n), S.set(r, t), n;
682
+ return T.set(t, n), c.set(r, t), n;
663
683
  }
664
- function H(t) {
665
- const r = S.get(t);
684
+ function v(t) {
685
+ const r = c.get(t);
666
686
  if (r !== void 0) {
667
- const _ = A.get(r);
687
+ const _ = T.get(r);
668
688
  if (_)
669
689
  return _;
670
690
  }
671
- const e = t.split("_"), n = Number(e[0]) || 0, s = Number(e[1]) || 0, E = P(n, s);
672
- return X(E, t);
691
+ const e = t.split("_"), n = Number(e[0]) || 0, s = Number(e[1]) || 0, E = g(n, s);
692
+ return z(E, t);
673
693
  }
674
- function bt(t) {
675
- if (t === u.H264) return Ft;
676
- if (t === u.Vp8) return Vt;
677
- if (t === u.Vp9) return Mt;
678
- if (t === u.Av1) return Gt;
694
+ function dt(t) {
695
+ if (t === h.H264) return Ft;
696
+ if (t === h.Vp8) return Vt;
697
+ if (t === h.Vp9) return Mt;
698
+ if (t === h.Av1) return Gt;
679
699
  throw new Error(`Unknown codec: ${t}`);
680
700
  }
681
- function C(t) {
682
- l({ type: "requestIdr", streamId: t });
701
+ function u(t) {
702
+ S({ type: "requestIdr", streamId: t });
683
703
  }
684
- async function dt(t, r) {
704
+ async function bt(t, r) {
685
705
  try {
686
- if (!y || !t.watched)
706
+ if (!w || !t.watched)
687
707
  return;
688
708
  if (typeof createImageBitmap == "function") {
689
709
  const e = await createImageBitmap(r);
690
- l({ type: "frame", streamId: t.streamId, width: t.width, height: t.height, bitmap: e }, [e]);
710
+ S({ type: "frame", streamId: t.streamId, width: t.width, height: t.height, bitmap: e }, [e]);
691
711
  }
692
712
  } catch (e) {
693
- o(e);
713
+ C(e);
694
714
  } finally {
695
715
  t.pendingDecodeCount--;
696
716
  try {
@@ -723,13 +743,13 @@ async function Ht(t, r, e) {
723
743
  }
724
744
  return null;
725
745
  }
726
- async function c(t) {
746
+ async function y(t) {
727
747
  if (t.codec == null)
728
748
  return;
729
- const r = bt(t.codec);
749
+ const r = dt(t.codec);
730
750
  if (t.decoder || (t.decoder = new VideoDecoder({
731
751
  output: (e) => {
732
- if (t.pendingDecodeCount++, !y || !t.watched) {
752
+ if (t.pendingDecodeCount++, !w || !t.watched) {
733
753
  t.pendingDecodeCount--;
734
754
  try {
735
755
  e.close();
@@ -750,7 +770,7 @@ async function c(t) {
750
770
  try {
751
771
  t.ctx2d.drawImage(e, 0, 0, n, s);
752
772
  } catch (E) {
753
- o(E);
773
+ C(E);
754
774
  } finally {
755
775
  t.pendingDecodeCount--;
756
776
  try {
@@ -760,58 +780,58 @@ async function c(t) {
760
780
  }
761
781
  return;
762
782
  }
763
- dt(t, e);
783
+ bt(t, e);
764
784
  },
765
785
  error: (e) => {
766
- o(e), t.isKeyFrameRequired = !0, C(t.streamId);
786
+ C(e), t.isKeyFrameRequired = !0, u(t.streamId);
767
787
  }
768
788
  })), t.decoderCodec !== r) {
769
789
  const e = await Ht(r, t.width, t.height);
770
790
  if (!e) {
771
- o(new Error(`Decoder not supported for codec ${r}`));
791
+ C(new Error(`Decoder not supported for codec ${r}`));
772
792
  return;
773
793
  }
774
794
  t.decoderCodec = r;
775
795
  try {
776
- t.decoder.configure(e.config), t.isKeyFrameRequired = !0, C(t.streamId);
796
+ t.decoder.configure(e.config), t.isKeyFrameRequired = !0, u(t.streamId);
777
797
  const n = e.isHardwareAccelerated ? "hardware" : "software", s = t.framerate > 0 ? `@${Math.round(t.framerate)}fps` : "";
778
- l({ type: "log", message: `Decoder configured: codec=${r}, ${t.width}x${t.height}${s}, hw=${n}` });
798
+ S({ type: "log", message: `Decoder configured: codec=${r}, ${t.width}x${t.height}${s}, hw=${n}` });
779
799
  } catch (n) {
780
- o(n);
800
+ C(n);
781
801
  }
782
802
  t.surface && t.ctx2d && t.width > 0 && t.height > 0 && (t.surface.width !== t.width || t.surface.height !== t.height) && (t.surface.width = t.width, t.surface.height = t.height);
783
803
  }
784
804
  }
785
- function Kt(t, r) {
786
- const e = P(r.senderId, r.trackId), n = k(r.senderId, r.trackId), s = Rt(t), E = X(e, n);
787
- E.codec = s.Codec, E.width = s.Width, E.height = s.Height, E.framerate = s.Framerate, E.bitrate = s.Bitrate, l({ type: "streamBegin", streamId: n, width: s.Width, height: s.Height, codec: s.Codec }), E.watched && (E.surface && E.ctx2d && s.Width > 0 && s.Height > 0 && (E.surface.width !== s.Width || E.surface.height !== s.Height) && (E.surface.width = s.Width, E.surface.height = s.Height), c(E));
805
+ async function Kt(t, r) {
806
+ const e = g(r.senderId, r.trackId), n = W(r.senderId, r.trackId), s = await Ut(t), E = z(e, n);
807
+ E.codec = s.Codec, E.width = s.Width, E.height = s.Height, E.framerate = s.Framerate, E.bitrate = s.Bitrate, S({ type: "streamBegin", streamId: n, width: s.Width, height: s.Height, codec: s.Codec }), E.watched && (E.surface && E.ctx2d && s.Width > 0 && s.Height > 0 && (E.surface.width !== s.Width || E.surface.height !== s.Height) && (E.surface.width = s.Width, E.surface.height = s.Height), y(E));
788
808
  }
789
- function xt(t) {
790
- const r = P(t.senderId, t.trackId), e = k(t.senderId, t.trackId);
791
- l({ type: "streamEnd", streamId: e });
792
- const n = A.get(r);
809
+ function vt(t) {
810
+ const r = g(t.senderId, t.trackId), e = W(t.senderId, t.trackId);
811
+ S({ type: "streamEnd", streamId: e });
812
+ const n = T.get(r);
793
813
  if (n) {
794
814
  if (n.decoder)
795
815
  try {
796
816
  n.decoder.close();
797
817
  } catch {
798
818
  }
799
- A.delete(r), S.delete(e);
819
+ T.delete(r), c.delete(e);
800
820
  }
801
821
  }
802
- function W(t) {
803
- const r = S.get(t);
822
+ function $(t) {
823
+ const r = c.get(t);
804
824
  if (r === void 0)
805
825
  return;
806
- const e = A.get(r);
826
+ const e = T.get(r);
807
827
  e && (e.surface = null, e.ctx2d = null);
808
828
  }
809
- function z(t) {
810
- const r = S.get(t);
829
+ function q(t) {
830
+ const r = c.get(t);
811
831
  if (r === void 0)
812
832
  return;
813
- const e = A.get(r);
814
- if (e && (e.watched = !1, e.isKeyFrameRequired = !0, W(t), e.decoder)) {
833
+ const e = T.get(r);
834
+ if (e && (e.watched = !1, e.isKeyFrameRequired = !0, $(t), e.decoder)) {
815
835
  try {
816
836
  e.decoder.close();
817
837
  } catch {
@@ -819,11 +839,11 @@ function z(t) {
819
839
  e.decoder = null, e.decoderCodec = null;
820
840
  }
821
841
  }
822
- function vt(t, r) {
823
- const e = P(r.senderId, r.trackId), n = A.get(e);
824
- if (!n || !y || !n.watched || ((!n.decoder || !n.decoderCodec) && c(n), !n.decoder || !n.decoderCodec))
842
+ async function xt(t, r) {
843
+ const e = g(r.senderId, r.trackId), n = T.get(e);
844
+ if (!n || !w || !n.watched || ((!n.decoder || !n.decoderCodec) && y(n), !n.decoder || !n.decoderCodec))
825
845
  return;
826
- const s = mt(t);
846
+ const s = await mt(t);
827
847
  if (n.isKeyFrameRequired) {
828
848
  if (!s.IsKey)
829
849
  return;
@@ -839,84 +859,84 @@ function vt(t, r) {
839
859
  })
840
860
  );
841
861
  } catch (E) {
842
- n.isKeyFrameRequired = !0, C(n.streamId), o(E);
862
+ n.isKeyFrameRequired = !0, u(n.streamId), C(E);
843
863
  }
844
864
  }
845
- function Yt(t) {
846
- const r = P(t.senderId, t.trackId), e = A.get(r);
847
- e && (e.isKeyFrameRequired = !0, e.watched && C(e.streamId));
865
+ function kt(t) {
866
+ const r = g(t.senderId, t.trackId), e = T.get(r);
867
+ e && (e.isKeyFrameRequired = !0, e.watched && u(e.streamId));
848
868
  }
849
- function kt(t, r) {
869
+ function Yt(t, r) {
850
870
  switch (r.opcode) {
851
871
  case L.VIDEO_STREAM_BEGIN:
852
872
  Kt(t, r);
853
873
  return;
854
874
  case L.VIDEO_STREAM_END:
855
- xt(r);
875
+ vt(r);
856
876
  return;
857
877
  case L.VIDEO_FRAME:
858
- vt(t, r);
878
+ xt(t, r);
859
879
  return;
860
880
  case L.VIDEO_INVALIDATE_FRAME:
861
- Yt(r);
881
+ kt(r);
862
882
  return;
863
883
  default:
864
884
  return;
865
885
  }
866
886
  }
867
- function $() {
868
- if (h) {
887
+ function j() {
888
+ if (R) {
869
889
  try {
870
- h.close();
890
+ R.close();
871
891
  } catch {
872
892
  }
873
- h = null;
893
+ R = null;
874
894
  }
875
895
  }
876
896
  function Xt() {
877
- $();
878
- for (const t of A.values())
879
- z(t.streamId);
880
- A.clear(), S.clear();
897
+ j();
898
+ for (const t of T.values())
899
+ q(t.streamId);
900
+ T.clear(), c.clear();
881
901
  }
882
902
  self.addEventListener("message", (t) => {
883
903
  const r = t.data;
884
904
  if (r.type !== "configure") {
885
905
  if (r.type === "attachSurface") {
886
- const e = r.streamId, n = H(e);
906
+ const e = r.streamId, n = v(e);
887
907
  n.watched = !0, n.surface = r.canvas;
888
908
  try {
889
909
  n.ctx2d = n.surface.getContext("2d", { alpha: !1, desynchronized: !0 });
890
910
  } catch (s) {
891
- o(s), n.ctx2d = null;
911
+ C(s), n.ctx2d = null;
892
912
  }
893
- n.isKeyFrameRequired = !0, c(n), C(e);
913
+ n.isKeyFrameRequired = !0, y(n), u(e);
894
914
  return;
895
915
  }
896
916
  if (r.type === "detachSurface") {
897
- W(r.streamId);
917
+ $(r.streamId);
898
918
  return;
899
919
  }
900
920
  if (r.type === "attachProtocolPort") {
901
- $(), h = r.port, h.addEventListener("message", (e) => {
921
+ j(), R = r.port, R.addEventListener("message", (e) => {
902
922
  const n = e.data;
903
- n?.type === "protocol" && n.message instanceof ArrayBuffer && n.headers && kt(new Uint8Array(n.message), n.headers);
904
- }), h.start?.();
923
+ n?.type === "protocol" && n.message instanceof ArrayBuffer && n.headers && Yt(new Uint8Array(n.message), n.headers);
924
+ }), R.start?.();
905
925
  return;
906
926
  }
907
927
  if (r.type === "watchStream") {
908
- const e = H(r.streamId);
909
- e.watched = !0, e.isKeyFrameRequired = !0, c(e), C(e.streamId);
928
+ const e = v(r.streamId);
929
+ e.watched = !0, e.isKeyFrameRequired = !0, y(e), u(e.streamId);
910
930
  return;
911
931
  }
912
932
  if (r.type === "unwatchStream") {
913
- z(r.streamId);
933
+ q(r.streamId);
914
934
  return;
915
935
  }
916
936
  if (r.type === "setEnabled") {
917
- if (y = r.enabled, y)
918
- for (const e of A.values())
919
- e.watched && (e.isKeyFrameRequired = !0, c(e), C(e.streamId));
937
+ if (w = r.enabled, w)
938
+ for (const e of T.values())
939
+ e.watched && (e.isKeyFrameRequired = !0, y(e), u(e.streamId));
920
940
  return;
921
941
  }
922
942
  r.type === "dispose" && Xt();