@ikonai/sdk 1.0.79 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/app-messaging.d.ts +1 -1
  2. package/assets/audio-capture-worker-D-0X2Dy8.js +1 -0
  3. package/assets/audio-playback-worker-DivBZPfS.js +1 -0
  4. package/assets/libopus-CnBCihDi.js +1 -0
  5. package/assets/protocol-worker-BH93CVck.js +1 -0
  6. package/assets/src-BKYD07QQ.js +1 -0
  7. package/assets/src-DOUWsCWT.js +1 -0
  8. package/assets/video-capture-worker-BQGOFbZt.js +1 -0
  9. package/assets/video-playback-worker-tC5nUVnw.js +1 -0
  10. package/assets/viseme-worker-Cd-JqTVM.js +1 -0
  11. package/capabilities-BtJblfdG.js +108 -0
  12. package/channel/channel-manager.d.ts +1 -1
  13. package/channel/channel.d.ts +1 -1
  14. package/client/endpoint-selector.d.ts +1 -1
  15. package/client/ikon-client-config.d.ts +13 -11
  16. package/client/ikon-client.d.ts +98 -4
  17. package/connection/authenticator.d.ts +3 -3
  18. package/connection/urls.d.ts +7 -18
  19. package/errors/index.d.ts +22 -13
  20. package/functions/browser-functions.d.ts +1 -1
  21. package/functions/function-registry.d.ts +1 -1
  22. package/functions/types.d.ts +2 -2
  23. package/ikon-media-zqob_QeE.js +3160 -0
  24. package/index.d.ts +8 -8
  25. package/index.js +8119 -12502
  26. package/media/ikon-audio-capture.d.ts +15 -3
  27. package/media/ikon-audio-playback.d.ts +37 -0
  28. package/media/ikon-video-playback.d.ts +24 -0
  29. package/media/media-session-helper.d.ts +8 -0
  30. package/media/video-constants.d.ts +11 -1
  31. package/media/viseme-tracker.d.ts +10 -1
  32. package/package.json +1 -1
  33. package/storage.d.ts +13 -0
  34. package/transport/transport.d.ts +1 -1
  35. package/transport/web-socket-transport.d.ts +1 -1
  36. package/transport/web-transport-transport.d.ts +1 -1
  37. package/utils/inspect-mode.d.ts +4 -0
  38. package/utils/log-sender.d.ts +1 -1
  39. package/utils/platform.d.ts +4 -0
  40. package/utils/query-params.d.ts +8 -4
  41. package/vite.config.d.ts +2 -0
  42. package/webrtc/webrtc-signaling.d.ts +11 -2
  43. package/worker/audio-playback-worker.d.ts +14 -1
  44. package/worker/video-capture-worker.d.ts +2 -2
  45. package/worker/video-playback-worker.d.ts +14 -2
  46. package/worker/viseme-worker.d.ts +10 -2
  47. package/assets/audio-capture-worker-Brmt2Z7a.js +0 -1279
  48. package/assets/audio-playback-worker-DDtsnLoq.js +0 -1473
  49. package/assets/index-Ca9sTcGt.js +0 -119
  50. package/assets/index-D_vz6N3U.js +0 -267
  51. package/assets/libopus-ChbDZJKA.js +0 -139
  52. package/assets/protocol-worker-BoZcMF0x.js +0 -1674
  53. package/assets/video-capture-worker-DxgvFTcw.js +0 -1126
  54. package/assets/video-playback-worker-Ca4XVGqt.js +0 -1005
  55. package/assets/viseme-worker-DVWM4pRh.js +0 -831
@@ -1,1473 +0,0 @@
1
- const ht = {
2
- Compressed: 8
3
- };
4
- function Nt(t) {
5
- if (t.length < 8)
6
- throw new Error("Protocol message too short");
7
- return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
8
- }
9
- function et(t) {
10
- const e = d(t), r = new DataView(e.buffer, e.byteOffset, e.byteLength);
11
- if (e.length < 27)
12
- throw new Error("Protocol payload too short");
13
- const s = r.getUint32(0, !0), n = r.getUint32(4, !0), a = r.getUint32(8, !0), i = r.getUint32(12, !0), _ = r.getUint32(16, !0), E = r.getUint32(20, !0), I = r.getUint8(24), A = r.getUint8(25), o = r.getUint8(26);
14
- if (27 + E * 4 > e.length)
15
- throw new Error("Protocol header exceeds payload length");
16
- const C = [];
17
- let w = 27;
18
- for (let L = 0; L < E; L++)
19
- C.push(r.getUint32(w, !0)), w += 4;
20
- return {
21
- length: s,
22
- opcode: n,
23
- senderId: a,
24
- trackId: i,
25
- sequenceId: _,
26
- targetIds: C,
27
- payloadVersion: I,
28
- payloadType: A,
29
- flags: o
30
- };
31
- }
32
- async function rt(t, e, r) {
33
- const s = d(t), n = et(s);
34
- if (e !== void 0 && n.opcode !== e)
35
- throw new Error(`Unexpected opcode ${n.opcode}`);
36
- if (n.payloadType !== 8)
37
- throw new Error(`Unexpected payload type ${n.payloadType}`);
38
- const a = 27 + n.targetIds.length * 4;
39
- let i = s.subarray(a, n.length);
40
- return (n.flags & ht.Compressed) !== 0 && (i = await Ct(i)), i;
41
- }
42
- async function Ct(t) {
43
- if (typeof DecompressionStream > "u")
44
- throw new Error("DecompressionStream not supported");
45
- const e = new DecompressionStream("gzip"), r = e.writable.getWriter(), s = new Uint8Array(t);
46
- r.write(s), r.close();
47
- const n = e.readable.getReader(), a = [];
48
- let i = 0;
49
- for (; ; ) {
50
- const { done: I, value: A } = await n.read();
51
- if (I) break;
52
- a.push(A), i += A.length;
53
- }
54
- const _ = new Uint8Array(i);
55
- let E = 0;
56
- for (let I = 0; I < a.length; I++)
57
- _.set(a[I], E), E += a[I].length;
58
- return _;
59
- }
60
- var P = /* @__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))(P || {});
61
- const Rt = 161, St = 162;
62
- new TextEncoder();
63
- const ct = new TextDecoder("utf-8", { fatal: !0 });
64
- class M {
65
- constructor(e, r, s) {
66
- this.buffer = e, this.version = r, this.offset = s, this.end = e.length - 1;
67
- }
68
- offset;
69
- end;
70
- static create(e) {
71
- const r = d(e);
72
- if (r.length < 2)
73
- throw new Error("Teleport payload too short");
74
- if (r[0] !== Rt || r[r.length - 1] !== St)
75
- throw new Error("Teleport object missing markers");
76
- const s = { offset: 1 }, n = f(r, s, "InvalidLength");
77
- return new M(r, n, s.offset);
78
- }
79
- next() {
80
- if (this.offset >= this.end)
81
- return null;
82
- if (this.offset + 5 > this.buffer.length)
83
- throw new Error("Teleport object truncated");
84
- const e = Dt(this.buffer, this.offset);
85
- this.offset += 4;
86
- const r = this.buffer[this.offset++], s = r >> 4 & 15;
87
- if ((r & 15) !== 0)
88
- throw new Error("Teleport field flags must be zero");
89
- const n = O(s);
90
- let a;
91
- if (n >= 0)
92
- u(this.buffer, this.offset, n), a = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
93
- else {
94
- const i = { offset: this.offset }, _ = f(this.buffer, i, "InvalidLength");
95
- u(this.buffer, i.offset, _), a = this.buffer.subarray(i.offset, i.offset + _), this.offset = i.offset + _;
96
- }
97
- return new Ut(e, s, a);
98
- }
99
- }
100
- class R {
101
- constructor(e, r) {
102
- this.type = e, this.payload = r;
103
- }
104
- asInt32() {
105
- return this.ensureType(
106
- 3
107
- /* Int32 */
108
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getInt32(0, !0);
109
- }
110
- asUInt32() {
111
- return this.ensureType(
112
- 5
113
- /* UInt32 */
114
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getUint32(0, !0);
115
- }
116
- asInt64() {
117
- return this.ensureType(
118
- 4
119
- /* Int64 */
120
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigInt64(0, !0);
121
- }
122
- asUInt64() {
123
- return this.ensureType(
124
- 6
125
- /* UInt64 */
126
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigUint64(0, !0);
127
- }
128
- asFloat32() {
129
- return this.ensureType(
130
- 7
131
- /* Float32 */
132
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getFloat32(0, !0);
133
- }
134
- asFloat64() {
135
- return this.ensureType(
136
- 8
137
- /* Float64 */
138
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getFloat64(0, !0);
139
- }
140
- asBool() {
141
- return this.ensureType(
142
- 2
143
- /* Bool */
144
- ), this.payload.length > 0 && this.payload[0] !== 0;
145
- }
146
- asBinary() {
147
- return this.ensureType(
148
- 13
149
- /* Binary */
150
- ), this.payload;
151
- }
152
- asUtf8() {
153
- return this.ensureType(
154
- 12
155
- /* String */
156
- ), this.payload;
157
- }
158
- asString() {
159
- return this.ensureType(
160
- 12
161
- /* String */
162
- ), ct.decode(this.payload);
163
- }
164
- asGuid() {
165
- return this.ensureType(
166
- 14
167
- /* Guid */
168
- ), l.fromBytes(this.payload);
169
- }
170
- asObject() {
171
- return this.ensureType(
172
- 11
173
- /* Object */
174
- ), M.create(this.payload);
175
- }
176
- asArray() {
177
- return this.ensureType(
178
- 9
179
- /* Array */
180
- ), x.create(this.payload);
181
- }
182
- asDictionary() {
183
- return this.ensureType(
184
- 10
185
- /* Dict */
186
- ), W.create(this.payload);
187
- }
188
- ensureType(e) {
189
- if (this.type !== e)
190
- throw new Error(`Teleport value has type ${P[this.type]}, expected ${P[e]}`);
191
- }
192
- }
193
- class Ut extends R {
194
- constructor(e, r, s) {
195
- super(r, s), this.fieldId = e;
196
- }
197
- get isNull() {
198
- return this.type === 1;
199
- }
200
- }
201
- class x {
202
- payload;
203
- elementType;
204
- count;
205
- offset;
206
- index = 0;
207
- constructor(e) {
208
- if (this.payload = e, e.length === 0)
209
- throw new Error("Array payload too short");
210
- const r = e[0];
211
- if (this.elementType = r >> 4 & 15, (r & 15) !== 0)
212
- throw new Error("Array flags must be zero");
213
- const s = { offset: 1 };
214
- this.count = f(e, s, "ArrayMalformed"), this.offset = s.offset;
215
- }
216
- static create(e) {
217
- return new x(d(e));
218
- }
219
- next() {
220
- if (this.index >= this.count) {
221
- if (this.offset !== this.payload.length)
222
- throw new Error("Array payload contains trailing data");
223
- return null;
224
- }
225
- const e = this.readValue();
226
- return this.index++, e;
227
- }
228
- readValue() {
229
- switch (this.elementType) {
230
- case 3:
231
- case 5:
232
- case 7:
233
- case 8:
234
- case 2:
235
- case 4:
236
- case 6:
237
- case 14: {
238
- const e = O(this.elementType);
239
- u(this.payload, this.offset, e);
240
- const r = this.payload.subarray(this.offset, this.offset + e);
241
- return this.offset += e, new g(this.elementType, r);
242
- }
243
- case 12:
244
- case 13: {
245
- const e = { offset: this.offset }, r = f(this.payload, e, "ArrayMalformed");
246
- u(this.payload, e.offset, r);
247
- const s = this.payload.subarray(e.offset, e.offset + r);
248
- return this.offset = e.offset + r, new g(this.elementType, s);
249
- }
250
- case 11: {
251
- const e = { offset: this.offset }, r = f(this.payload, e, "ArrayMalformed");
252
- u(this.payload, e.offset, r);
253
- const s = this.payload.subarray(e.offset, e.offset + r);
254
- return this.offset = e.offset + r, new g(11, s);
255
- }
256
- case 9: {
257
- const e = K(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
258
- return this.offset += e, new g(9, r);
259
- }
260
- case 10: {
261
- const e = X(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
262
- return this.offset += e, new g(10, r);
263
- }
264
- default:
265
- throw new Error(`Unsupported array element type ${P[this.elementType]}`);
266
- }
267
- }
268
- }
269
- class g extends R {
270
- constructor(e, r) {
271
- super(e, r);
272
- }
273
- }
274
- class W {
275
- payload;
276
- keyType;
277
- valueType;
278
- count;
279
- offset;
280
- index = 0;
281
- constructor(e) {
282
- if (this.payload = e, e.length < 2)
283
- throw new Error("Dictionary payload too short");
284
- if (this.keyType = e[0] >> 4 & 15, this.valueType = e[1] >> 4 & 15, (e[0] & 15) !== 0 || (e[1] & 15) !== 0)
285
- throw new Error("Dictionary key/value flags must be zero");
286
- st(this.keyType);
287
- const r = { offset: 2 };
288
- this.count = f(e, r, "DictMalformed"), this.offset = r.offset;
289
- }
290
- static create(e) {
291
- return new W(d(e));
292
- }
293
- next() {
294
- if (this.index >= this.count) {
295
- if (this.offset !== this.payload.length)
296
- throw new Error("Dictionary payload contains trailing data");
297
- return null;
298
- }
299
- const e = this.readKey(), r = this.readValue();
300
- return this.index++, new Lt(e, r);
301
- }
302
- readKey() {
303
- const e = O(this.keyType);
304
- if (e >= 0) {
305
- u(this.payload, this.offset, e);
306
- const r = this.payload.subarray(this.offset, this.offset + e);
307
- return this.offset += e, new R(this.keyType, r);
308
- }
309
- if (this.keyType === 12 || this.keyType === 13) {
310
- const r = { offset: this.offset }, s = f(this.payload, r, "DictMalformed");
311
- u(this.payload, r.offset, s);
312
- const n = this.payload.subarray(r.offset, r.offset + s);
313
- return this.offset = r.offset + s, new R(this.keyType, n);
314
- }
315
- throw new Error("Unsupported dictionary key type");
316
- }
317
- readValue() {
318
- switch (this.valueType) {
319
- case 12:
320
- case 13: {
321
- const e = { offset: this.offset }, r = f(this.payload, e, "DictMalformed");
322
- u(this.payload, e.offset, r);
323
- const s = this.payload.subarray(e.offset, e.offset + r);
324
- return this.offset = e.offset + r, new R(this.valueType, s);
325
- }
326
- case 11: {
327
- const e = { offset: this.offset }, r = f(this.payload, e, "DictMalformed");
328
- u(this.payload, e.offset, r);
329
- const s = this.payload.subarray(e.offset, e.offset + r);
330
- return this.offset = e.offset + r, new R(11, s);
331
- }
332
- case 9: {
333
- const e = K(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
334
- return this.offset += e, new R(9, r);
335
- }
336
- case 10: {
337
- const e = X(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
338
- return this.offset += e, new R(10, r);
339
- }
340
- case 3:
341
- case 5:
342
- case 7:
343
- case 8:
344
- case 2:
345
- case 4:
346
- case 6:
347
- case 14:
348
- case 1: {
349
- const e = O(this.valueType);
350
- u(this.payload, this.offset, e);
351
- const r = this.payload.subarray(this.offset, this.offset + e);
352
- return this.offset += e, new R(this.valueType, r);
353
- }
354
- default:
355
- throw new Error(`Unsupported dictionary value type ${P[this.valueType]}`);
356
- }
357
- }
358
- }
359
- class Lt {
360
- constructor(e, r) {
361
- this.key = e, this.value = r;
362
- }
363
- }
364
- class l {
365
- constructor(e) {
366
- this.bytes = e;
367
- }
368
- static fromString(e) {
369
- if (!e)
370
- throw new Error("Guid string is empty");
371
- const r = e.replace(/-/g, "");
372
- if (r.length !== 32)
373
- throw new Error("Guid string must be 32 hex characters");
374
- const s = new Uint8Array(16), n = l.parseHexSlice(r, 0, 8), a = l.parseHexSlice(r, 8, 4), i = l.parseHexSlice(r, 12, 4);
375
- l.writeUInt32LE(s, 0, n), l.writeUInt16LE(s, 4, a), l.writeUInt16LE(s, 6, i);
376
- for (let _ = 0; _ < 8; _++)
377
- s[8 + _] = l.parseHexSlice(r, 16 + _ * 2, 2);
378
- return new l(s);
379
- }
380
- static fromBytes(e) {
381
- if (e.length !== 16)
382
- throw new Error("Guid byte array must be 16 bytes");
383
- return new l(Uint8Array.from(e));
384
- }
385
- static createZero() {
386
- return new l(new Uint8Array(16));
387
- }
388
- static createRandom() {
389
- const e = new Uint8Array(16), r = globalThis.crypto;
390
- if (r?.getRandomValues)
391
- r.getRandomValues(e);
392
- else
393
- for (let s = 0; s < e.length; s++)
394
- e[s] = Math.floor(Math.random() * 256);
395
- return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new l(e);
396
- }
397
- toString() {
398
- const e = this.bytes;
399
- return [
400
- l.toHex(l.readUInt32LE(e, 0), 8),
401
- l.toHex(l.readUInt16LE(e, 4), 4),
402
- l.toHex(l.readUInt16LE(e, 6), 4),
403
- Q(e.subarray(8, 10)),
404
- Q(e.subarray(10, 16))
405
- ].join("-");
406
- }
407
- asBytes() {
408
- return this.bytes.slice();
409
- }
410
- static parseHexSlice(e, r, s) {
411
- const n = e.substr(r, s), a = Number.parseInt(n, 16);
412
- if (Number.isNaN(a))
413
- throw new Error("Guid string contains invalid characters");
414
- return a >>> 0;
415
- }
416
- static writeUInt32LE(e, r, s) {
417
- const n = s >>> 0;
418
- e[r] = n & 255, e[r + 1] = n >>> 8 & 255, e[r + 2] = n >>> 16 & 255, e[r + 3] = n >>> 24 & 255;
419
- }
420
- static writeUInt16LE(e, r, s) {
421
- const n = s & 65535;
422
- e[r] = n & 255, e[r + 1] = n >>> 8 & 255;
423
- }
424
- static readUInt32LE(e, r) {
425
- return (e[r] | e[r + 1] << 8 | e[r + 2] << 16 | e[r + 3] << 24) >>> 0;
426
- }
427
- static readUInt16LE(e, r) {
428
- return (e[r] | e[r + 1] << 8) & 65535;
429
- }
430
- static toHex(e, r) {
431
- return (e >>> 0).toString(16).padStart(r, "0");
432
- }
433
- }
434
- function f(t, e, r) {
435
- if (e.offset >= t.length)
436
- throw new Error(r);
437
- let s = 0, n = 0, a = 0;
438
- for (; e.offset < t.length; ) {
439
- const i = t[e.offset++];
440
- if (a++, s |= (i & 127) << n, (i & 128) === 0) {
441
- if (a !== mt(s))
442
- throw new Error("Teleport VarUInt is not canonical");
443
- return s >>> 0;
444
- }
445
- if (n += 7, n >= 35)
446
- throw new Error("Teleport VarUInt exceeds 32-bit range");
447
- }
448
- throw new Error(r);
449
- }
450
- function mt(t) {
451
- return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
452
- }
453
- function O(t) {
454
- switch (t) {
455
- case 3:
456
- case 5:
457
- case 7:
458
- return 4;
459
- case 4:
460
- case 6:
461
- case 8:
462
- return 8;
463
- case 14:
464
- return 16;
465
- case 2:
466
- return 1;
467
- case 1:
468
- return 0;
469
- default:
470
- return -1;
471
- }
472
- }
473
- function st(t) {
474
- if (t === 9 || t === 11 || t === 10 || t === 1)
475
- throw new Error("Dictionary keys must be primitive Teleport types");
476
- }
477
- function u(t, e, r) {
478
- if (e < 0 || r < 0 || e + r > t.length)
479
- throw new Error("Teleport payload exceeds bounds");
480
- }
481
- function Dt(t, e) {
482
- return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0;
483
- }
484
- function K(t, e) {
485
- if (e >= t.length)
486
- throw new Error("Array payload exceeds bounds");
487
- const r = t[e], s = r >> 4 & 15;
488
- if ((r & 15) !== 0)
489
- throw new Error("Array flags must be zero");
490
- const n = { offset: e + 1 }, a = f(t, n, "ArrayMalformed"), i = O(s);
491
- if (i >= 0) {
492
- const E = i * a;
493
- return u(t, n.offset, E), n.offset + E - e;
494
- }
495
- let _ = n.offset;
496
- for (let E = 0; E < a; E++)
497
- _ = H(s, t, _, "ArrayMalformed");
498
- return _ - e;
499
- }
500
- function X(t, e) {
501
- if (e + 2 > t.length)
502
- throw new Error("Dictionary payload too short");
503
- const r = t[e] >> 4 & 15, s = t[e + 1] >> 4 & 15;
504
- if ((t[e] & 15) !== 0 || (t[e + 1] & 15) !== 0)
505
- throw new Error("Dictionary key/value flags must be zero");
506
- st(r);
507
- const n = { offset: e + 2 }, a = f(t, n, "DictMalformed");
508
- let i = n.offset;
509
- for (let _ = 0; _ < a; _++)
510
- i = H(r, t, i, "DictMalformed"), i = H(s, t, i, "DictMalformed");
511
- return i - e;
512
- }
513
- function H(t, e, r, s) {
514
- const n = O(t);
515
- if (n >= 0)
516
- return u(e, r, n), r + n;
517
- switch (t) {
518
- case 12:
519
- case 13: {
520
- const a = { offset: r }, i = f(e, a, s);
521
- return u(e, a.offset, i), a.offset + i;
522
- }
523
- case 11: {
524
- const a = { offset: r }, i = f(e, a, s);
525
- return u(e, a.offset, i), a.offset + i;
526
- }
527
- case 9:
528
- return r + K(e, r);
529
- case 10:
530
- return r + X(e, r);
531
- default:
532
- throw new Error(`Unsupported Teleport type ${P[t]}`);
533
- }
534
- }
535
- function Q(t) {
536
- return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
537
- }
538
- function d(t) {
539
- return t instanceof Uint8Array ? t : new Uint8Array(t);
540
- }
541
- var h = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(h || {}), V = /* @__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.CORE_UPDATE_CLIENT_CONTEXT = 65558] = "CORE_UPDATE_CLIENT_CONTEXT", t[t.CORE_BACKGROUND_WORK_ACTIVE = 65559] = "CORE_BACKGROUND_WORK_ACTIVE", t[t.CORE_RESET_IDLE = 65560] = "CORE_RESET_IDLE", t[t.CORE_CLIENT_DISCONNECTING = 65561] = "CORE_CLIENT_DISCONNECTING", t[t.CORE_ON_APP_READY = 65562] = "CORE_ON_APP_READY", t[t.CORE_ON_FRONTEND_RELOADED = 65563] = "CORE_ON_FRONTEND_RELOADED", t[t.CORE_WEBRTC_OFFER = 65566] = "CORE_WEBRTC_OFFER", t[t.CORE_WEBRTC_ANSWER = 65567] = "CORE_WEBRTC_ANSWER", t[t.CORE_WEBRTC_ICE_CANDIDATE = 65568] = "CORE_WEBRTC_ICE_CANDIDATE", t[t.CORE_WEBRTC_READY = 65569] = "CORE_WEBRTC_READY", t[t.CORE_WEBRTC_AUDIO_SEGMENT = 65570] = "CORE_WEBRTC_AUDIO_SEGMENT", t[t.CORE_WEBRTC_TRACK_MAP = 65571] = "CORE_WEBRTC_TRACK_MAP", t[t.CORE_WEBRTC_VIDEO_CAPTURE = 65572] = "CORE_WEBRTC_VIDEO_CAPTURE", t[t.CORE_WEBRTC_ICE_SERVERS_REQUEST = 65573] = "CORE_WEBRTC_ICE_SERVERS_REQUEST", t[t.CORE_WEBRTC_ICE_SERVERS_RESPONSE = 65574] = "CORE_WEBRTC_ICE_SERVERS_RESPONSE", t[t.CORE_WEBRTC_CLOSE = 65575] = "CORE_WEBRTC_CLOSE", t[t.CORE_RELAY_AGENT_AUTH = 65576] = "CORE_RELAY_AGENT_AUTH", t[t.CORE_RELAY_AGENT_AUTH_RESULT = 65577] = "CORE_RELAY_AGENT_AUTH_RESULT", t[t.CORE_RELAY_HEARTBEAT = 65578] = "CORE_RELAY_HEARTBEAT", t[t.CORE_RELAY_TCP_CONNECTION_OPENED = 65579] = "CORE_RELAY_TCP_CONNECTION_OPENED", t[t.CORE_RELAY_TCP_CONNECTION_CLOSED = 65580] = "CORE_RELAY_TCP_CONNECTION_CLOSED", t[t.CORE_RELAY_TCP_DATA = 65581] = "CORE_RELAY_TCP_DATA", t[t.CORE_RELAY_UDP_DATA = 65582] = "CORE_RELAY_UDP_DATA", t[t.CORE_RELAY_ADD_TUNNEL = 65583] = "CORE_RELAY_ADD_TUNNEL", t[t.CORE_RELAY_TUNNEL_ADDED = 65584] = "CORE_RELAY_TUNNEL_ADDED", t[t.CORE_RELAY_REMOVE_TUNNEL = 65585] = "CORE_RELAY_REMOVE_TUNNEL", t[t.CORE_IKON_SERVER_ENDPOINT_HOST_INFO = 65586] = "CORE_IKON_SERVER_ENDPOINT_HOST_INFO", t[t.CORE_CLIENT_INITIALIZATION = 65587] = "CORE_CLIENT_INITIALIZATION", t[t.CORE_CLIENT_LIFECYCLE_BATCH = 65588] = "CORE_CLIENT_LIFECYCLE_BATCH", t[t.CORE_APP_CONFIG = 65589] = "CORE_APP_CONFIG", 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_IKON_RELAY_SERVER_STATS = 524297] = "ANALYTICS_IKON_RELAY_SERVER_STATS", t[t.ANALYTICS_IKON_TURN_SERVER_STATS = 524298] = "ANALYTICS_IKON_TURN_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_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.ACTION_CUSTOM_USER_MESSAGE = 1048641] = "ACTION_CUSTOM_USER_MESSAGE", t[t.ACTION_URL_CHANGED = 1048642] = "ACTION_URL_CHANGED", t[t.ACTION_FILE_UPLOAD_PRE_START2 = 1048643] = "ACTION_FILE_UPLOAD_PRE_START2", t[t.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2 = 1048644] = "ACTION_FILE_UPLOAD_PRE_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_START2 = 1048645] = "ACTION_FILE_UPLOAD_START2", t[t.ACTION_FILE_UPLOAD_START_RESPONSE2 = 1048646] = "ACTION_FILE_UPLOAD_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_DATA2 = 1048647] = "ACTION_FILE_UPLOAD_DATA2", t[t.ACTION_FILE_UPLOAD_ACK2 = 1048648] = "ACTION_FILE_UPLOAD_ACK2", t[t.ACTION_FILE_UPLOAD_END2 = 1048649] = "ACTION_FILE_UPLOAD_END2", t[t.ACTION_FILE_UPLOAD_COMPLETE2 = 1048650] = "ACTION_FILE_UPLOAD_COMPLETE2", t[t.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH = 1048651] = "ACTION_FUNCTION_ENUMERATION_ITEM_BATCH", t[t.ACTION_CALL_ACK = 1048652] = "ACTION_CALL_ACK", t[t.ACTION_TRIGGER_CRON = 1048653] = "ACTION_TRIGGER_CRON", t[t.ACTION_RESULT = 1048654] = "ACTION_RESULT", t[t.UI_RESYNC_REQUEST = 1048655] = "UI_RESYNC_REQUEST", 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.AUDIO_SHAPE_FRAME = 4194310] = "AUDIO_SHAPE_FRAME", 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.GROUP_APP_LOCAL = 1073741824] = "GROUP_APP_LOCAL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(V || {});
542
- const Pt = 4194309, Ot = 205938238, yt = 1594075008, wt = 2026534360, gt = 3409001585, Ft = 3466650495, Mt = 4007456593, dt = 4017217601, Bt = 4065417427, bt = 4086360332;
543
- function Gt(t) {
544
- const e = {};
545
- return nt(e), e;
546
- }
547
- function nt(t) {
548
- return t.Samples = new Uint8Array(0), t.Epoch = 0, t.Sequence = 0, t.FrameSizeInInterleavedSamples = 0, t.TimeStampInInterleavedSamples = 0n, t.IsFirst = !1, t.IsLast = !1, t.AverageVolume = 0, t.AudioEventEstimatedDuration = 0, t;
549
- }
550
- function Vt(t, e) {
551
- const r = M.create(t);
552
- return vt(r, e);
553
- }
554
- function vt(t, e) {
555
- const r = e ?? Gt();
556
- return nt(r), kt(t, r), r;
557
- }
558
- function kt(t, e) {
559
- let r;
560
- for (; (r = t.next()) !== null; )
561
- switch (r.fieldId) {
562
- case Ot: {
563
- if (r.isNull) throw new Error();
564
- e.AverageVolume = r.asFloat32();
565
- break;
566
- }
567
- case yt: {
568
- if (r.isNull) throw new Error();
569
- e.IsFirst = r.asBool();
570
- break;
571
- }
572
- case wt: {
573
- if (r.isNull) throw new Error();
574
- e.TimeStampInInterleavedSamples = r.asUInt64();
575
- break;
576
- }
577
- case gt: {
578
- if (r.isNull) throw new Error();
579
- e.Samples = r.asBinary();
580
- break;
581
- }
582
- case Ft: {
583
- if (r.isNull) throw new Error();
584
- e.AudioEventEstimatedDuration = r.asFloat32();
585
- break;
586
- }
587
- case Mt: {
588
- if (r.isNull) throw new Error();
589
- e.FrameSizeInInterleavedSamples = r.asUInt32();
590
- break;
591
- }
592
- case dt: {
593
- if (r.isNull) throw new Error();
594
- e.IsLast = r.asBool();
595
- break;
596
- }
597
- case Bt: {
598
- if (r.isNull) throw new Error();
599
- e.Sequence = r.asUInt32();
600
- break;
601
- }
602
- case bt: {
603
- if (r.isNull) throw new Error();
604
- e.Epoch = r.asUInt32();
605
- break;
606
- }
607
- }
608
- }
609
- async function Yt(t, e) {
610
- const r = await rt(t, Pt);
611
- return Vt(r, e);
612
- }
613
- const Ht = 4194305, xt = 161083277, Wt = 265814330, Kt = 1368629611, Xt = 2431514951, zt = 2514959030, $t = 2745379226, jt = 3282782683, Qt = 3284746250, Zt = 4101844078;
614
- function Jt(t) {
615
- const e = {};
616
- return it(e), e;
617
- }
618
- function it(t) {
619
- return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = h.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t.CorrelationId = void 0, t;
620
- }
621
- function qt(t, e) {
622
- const r = M.create(t);
623
- return pt(r, e);
624
- }
625
- function pt(t, e) {
626
- const r = e ?? Jt();
627
- return it(r), te(t, r), r;
628
- }
629
- function te(t, e) {
630
- let r;
631
- for (; (r = t.next()) !== null; )
632
- switch (r.fieldId) {
633
- case xt: {
634
- if (r.isNull) throw new Error();
635
- e.StreamId = r.asString();
636
- break;
637
- }
638
- case Wt: {
639
- if (r.isNull) {
640
- e.ShapeSets = void 0;
641
- break;
642
- }
643
- e.ShapeSets = re(r.asArray());
644
- break;
645
- }
646
- case Kt: {
647
- if (r.isNull) throw new Error();
648
- e.Description = r.asString();
649
- break;
650
- }
651
- case Xt: {
652
- if (r.isNull) throw new Error();
653
- e.Channels = r.asInt32();
654
- break;
655
- }
656
- case zt: {
657
- if (r.isNull) {
658
- e.CorrelationId = void 0;
659
- break;
660
- }
661
- e.CorrelationId = r.asString();
662
- break;
663
- }
664
- case $t: {
665
- if (r.isNull) throw new Error();
666
- e.CodecDetails = r.asString();
667
- break;
668
- }
669
- case jt: {
670
- if (r.isNull) throw new Error();
671
- e.SourceType = r.asString();
672
- break;
673
- }
674
- case Qt: {
675
- if (r.isNull) throw new Error();
676
- e.Codec = r.asInt32();
677
- break;
678
- }
679
- case Zt: {
680
- if (r.isNull) throw new Error();
681
- e.SampleRate = r.asInt32();
682
- break;
683
- }
684
- }
685
- }
686
- async function ee(t, e) {
687
- const r = await rt(t, Ht);
688
- return qt(r, e);
689
- }
690
- function re(t) {
691
- const e = [];
692
- let r;
693
- for (; (r = t.next()) !== null; )
694
- e.push(_e(r.asObject()));
695
- return e;
696
- }
697
- const se = 1107713536, ne = 1154362099, ie = 1185721362;
698
- function ae(t) {
699
- const e = {};
700
- return at(e), e;
701
- }
702
- function at(t) {
703
- return t.SetId = 0, t.Name = "", t.ShapeNames = [], t;
704
- }
705
- function _e(t, e) {
706
- const r = e ?? ae();
707
- return at(r), Ee(t, r), r;
708
- }
709
- function Ee(t, e) {
710
- let r;
711
- for (; (r = t.next()) !== null; )
712
- switch (r.fieldId) {
713
- case se: {
714
- if (r.isNull) throw new Error();
715
- e.Name = r.asString();
716
- break;
717
- }
718
- case ne: {
719
- if (r.isNull) throw new Error();
720
- e.SetId = r.asUInt32();
721
- break;
722
- }
723
- case ie: {
724
- if (r.isNull) throw new Error();
725
- e.ShapeNames = Ie(r.asArray());
726
- break;
727
- }
728
- }
729
- }
730
- function Ie(t) {
731
- const e = [];
732
- let r;
733
- for (; (r = t.next()) !== null; )
734
- e.push(r.asString());
735
- return e;
736
- }
737
- class Z {
738
- static getStorageForCapacity(e, r) {
739
- const s = Int32Array.BYTES_PER_ELEMENT * 2, n = r.BYTES_PER_ELEMENT * e;
740
- return new SharedArrayBuffer(s + n);
741
- }
742
- readWrite;
743
- storage;
744
- buf;
745
- constructor(e, r) {
746
- this.buf = e, this.readWrite = new Int32Array(e, 0, 2);
747
- const s = Int32Array.BYTES_PER_ELEMENT * 2, n = (e.byteLength - s) / Float32Array.BYTES_PER_ELEMENT;
748
- this.storage = new r(e, s, n);
749
- }
750
- get capacity() {
751
- return this.storage.length;
752
- }
753
- flush() {
754
- Atomics.store(this.readWrite, 0, 0), Atomics.store(this.readWrite, 1, 0);
755
- }
756
- availableRead() {
757
- const e = Atomics.load(this.readWrite, 0), r = Atomics.load(this.readWrite, 1);
758
- return r >= e ? r - e : this.capacity - (e - r);
759
- }
760
- availableWrite() {
761
- return this.capacity - this.availableRead() - 1;
762
- }
763
- push(e) {
764
- const r = Math.min(this.availableWrite(), e.length);
765
- if (r <= 0)
766
- return 0;
767
- let s = Atomics.load(this.readWrite, 1);
768
- const n = Math.min(r, this.capacity - s);
769
- this.storage.set(e.subarray(0, n), s);
770
- const a = r - n;
771
- return a > 0 && this.storage.set(e.subarray(n, n + a), 0), s = (s + r) % this.capacity, Atomics.store(this.readWrite, 1, s), Atomics.notify(this.readWrite, 1), r;
772
- }
773
- pop(e) {
774
- const r = Math.min(this.availableRead(), e.length);
775
- if (r <= 0)
776
- return 0;
777
- let s = Atomics.load(this.readWrite, 0);
778
- const n = Math.min(r, this.capacity - s);
779
- e.set(this.storage.subarray(s, s + n), 0);
780
- const a = r - n;
781
- return a > 0 && e.set(this.storage.subarray(0, a), n), s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
782
- }
783
- skip(e) {
784
- const r = Math.min(this.availableRead(), e);
785
- if (r <= 0)
786
- return 0;
787
- let s = Atomics.load(this.readWrite, 0);
788
- return s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
789
- }
790
- }
791
- let Ae = 1;
792
- const oe = /* @__PURE__ */ new Map(), le = {
793
- 0: "DEBUG",
794
- 1: "INFO",
795
- 2: "WARN",
796
- 3: "ERROR",
797
- 4: "NONE"
798
- };
799
- function Te(t, e) {
800
- return `[${t}] ${e}`;
801
- }
802
- function b(t, e, r, s) {
803
- const n = (/* @__PURE__ */ new Date()).toISOString(), a = le[t], i = {
804
- timestamp: n,
805
- level: t,
806
- levelName: a,
807
- component: e,
808
- message: r,
809
- args: s
810
- };
811
- for (const [_, E] of oe) {
812
- const I = E?.minLevel ?? 2;
813
- if (t >= I)
814
- try {
815
- _(i);
816
- } catch {
817
- }
818
- }
819
- if (Ae <= t) {
820
- const _ = Te(e, r);
821
- switch (t) {
822
- case 0:
823
- console.debug(_, ...s);
824
- break;
825
- case 1:
826
- console.info(_, ...s);
827
- break;
828
- case 2:
829
- console.warn(_, ...s);
830
- break;
831
- case 3:
832
- console.error(_, ...s);
833
- break;
834
- }
835
- }
836
- }
837
- function _t(t) {
838
- return {
839
- debug(e, ...r) {
840
- b(0, t, e, r);
841
- },
842
- info(e, ...r) {
843
- b(1, t, e, r);
844
- },
845
- warn(e, ...r) {
846
- b(2, t, e, r);
847
- },
848
- error(e, ...r) {
849
- b(3, t, e, r);
850
- }
851
- };
852
- }
853
- const G = _t("Capabilities"), ue = globalThis;
854
- function fe() {
855
- if (typeof SharedArrayBuffer > "u")
856
- return G.debug("SharedArrayBuffer not supported: SharedArrayBuffer is undefined"), !1;
857
- if (typeof Atomics > "u")
858
- return G.debug("SharedArrayBuffer not supported: Atomics is undefined"), !1;
859
- if (ue.crossOriginIsolated === !1)
860
- return G.debug("SharedArrayBuffer not supported: crossOriginIsolated is false (missing COOP/COEP headers)"), !1;
861
- try {
862
- new SharedArrayBuffer(1);
863
- } catch (t) {
864
- return G.debug(`SharedArrayBuffer not supported: construction failed - ${t instanceof Error ? t.message : String(t)}`), !1;
865
- }
866
- return !0;
867
- }
868
- const Et = 48e3, It = 2, he = 1500, Ne = 10, J = 80, Ce = 50, q = 64, z = _t("AudioPlaybackWorker"), y = (t, e) => {
869
- self.postMessage(t, e ?? []);
870
- }, Re = fe();
871
- let v = "pcm", At = !0, ot = !1, c = Et, S = It, D = null;
872
- function m(t, e) {
873
- const r = t instanceof Error ? t : new Error(String(t));
874
- y({ type: "error", error: { name: r.name, message: r.message, stack: r.stack }, streamId: e });
875
- }
876
- function $(t) {
877
- const e = et(t);
878
- return `${e.senderId}_${e.trackId}`;
879
- }
880
- class Se {
881
- mode;
882
- ring = null;
883
- sab = void 0;
884
- streamId;
885
- outputSampleRate;
886
- outputChannels;
887
- closed = !1;
888
- // Pre-allocated batch buffer for PCM mode to avoid per-frame allocations
889
- pcmBatchBuffer = null;
890
- pcmBatchOffset = 0;
891
- lastPcmFlushTimeMs = 0;
892
- constructor(e) {
893
- this.streamId = e, this.mode = "pcm", this.outputSampleRate = c, this.outputChannels = S, this.rebind(v);
894
- }
895
- close() {
896
- this.closed = !0, this.pcmBatchBuffer = null, this.pcmBatchOffset = 0, this.ring = null, this.sab = void 0;
897
- }
898
- setOutputFormat(e, r) {
899
- this.outputSampleRate = e, this.outputChannels = r;
900
- }
901
- rebind(e) {
902
- if (!this.closed) {
903
- if (this.mode = e, e === "sab" && Re) {
904
- const r = Math.floor(he * this.outputSampleRate * this.outputChannels / 1e3), s = Z.getStorageForCapacity(r, Float32Array), n = new Z(s, Float32Array);
905
- n.flush(), this.sab = s, this.ring = n;
906
- return;
907
- }
908
- this.sab = void 0, this.ring = null;
909
- }
910
- }
911
- flushPendingPcm(e) {
912
- if (this.closed || this.mode !== "pcm" || this.pcmBatchOffset <= 0)
913
- return;
914
- const r = performance.now(), s = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * J / 1e3));
915
- if (!(e || this.pcmBatchOffset >= s || this.lastPcmFlushTimeMs > 0 && r - this.lastPcmFlushTimeMs >= Ce))
916
- return;
917
- const a = new Float32Array(this.pcmBatchOffset);
918
- a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = r, y({ type: "pcm", streamId: this.streamId, pcm: a }, [a.buffer]);
919
- }
920
- drainPcm() {
921
- this.flushPendingPcm(!0);
922
- }
923
- writePcm(e) {
924
- if (this.closed)
925
- return;
926
- if (this.mode === "sab" && this.ring) {
927
- const n = this.ring, a = this.outputChannels;
928
- let i = e;
929
- const _ = Math.floor(Math.max(0, n.capacity - 1) / a) * a;
930
- i.length > _ && (i = i.subarray(i.length - _));
931
- const E = Math.floor(n.availableWrite() / a) * a;
932
- if (E <= 0)
933
- return;
934
- i.length > E && (i = i.subarray(i.length - E)), n.push(i);
935
- return;
936
- }
937
- const r = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * J / 1e3)), s = this.pcmBatchOffset + e.length;
938
- if (!this.pcmBatchBuffer || this.pcmBatchBuffer.length < s) {
939
- const n = Math.max(s, r * 2), a = new Float32Array(n);
940
- this.pcmBatchBuffer && this.pcmBatchOffset > 0 && a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchBuffer = a;
941
- }
942
- this.pcmBatchBuffer.set(e, this.pcmBatchOffset), this.pcmBatchOffset += e.length, this.lastPcmFlushTimeMs === 0 && (this.lastPcmFlushTimeMs = performance.now()), this.flushPendingPcm(!1);
943
- }
944
- getSharedArrayBuffer() {
945
- return this.sab;
946
- }
947
- flush() {
948
- this.closed || (this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = 0, this.ring?.flush());
949
- }
950
- }
951
- function ce(t) {
952
- switch (t) {
953
- case h.Opus:
954
- return "opus";
955
- case h.Mp3:
956
- return "mp3";
957
- default:
958
- return null;
959
- }
960
- }
961
- let F = null;
962
- function Ue(t) {
963
- const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = Math.floor(t.byteLength / 2);
964
- (!F || F.length < r) && (F = new Float32Array(r));
965
- for (let s = 0; s < r; s++)
966
- F[s] = e.getInt16(s * 2, !0) / 32768;
967
- return F.subarray(0, r);
968
- }
969
- class j {
970
- inputSampleRate;
971
- inputChannels;
972
- sink;
973
- // Pre-allocated grow-only buffers for conversion pipeline
974
- _resampleBuffer = null;
975
- _remixBuffer = null;
976
- _interleavedBuffer = null;
977
- constructor(e) {
978
- this.inputSampleRate = e.inputSampleRate, this.inputChannels = e.inputChannels, this.sink = e.sink;
979
- }
980
- getResampleBuffer(e) {
981
- return (!this._resampleBuffer || this._resampleBuffer.length < e) && (this._resampleBuffer = new Float32Array(e)), this._resampleBuffer;
982
- }
983
- getRemixBuffer(e) {
984
- return (!this._remixBuffer || this._remixBuffer.length < e) && (this._remixBuffer = new Float32Array(e)), this._remixBuffer;
985
- }
986
- getInterleavedBuffer(e) {
987
- return (!this._interleavedBuffer || this._interleavedBuffer.length < e) && (this._interleavedBuffer = new Float32Array(e)), this._interleavedBuffer;
988
- }
989
- reset() {
990
- }
991
- writeConvertedPcm(e, r, s) {
992
- const n = this.convertPcmBuffer(e, r, s);
993
- n.length > 0 && this.sink.writePcm(n);
994
- }
995
- convertAudioData(e) {
996
- const r = e.numberOfFrames, s = e.numberOfChannels, n = e.format, a = typeof n == "string" && n.includes("planar"), i = "f32-planar", _ = "f32", E = () => {
997
- const o = new Array(s);
998
- for (let T = 0; T < s; T++) {
999
- const C = new Float32Array(r);
1000
- e.copyTo(C, { planeIndex: T, format: i }), o[T] = C;
1001
- }
1002
- return Be(o, r);
1003
- }, I = () => {
1004
- const o = new Float32Array(r * s);
1005
- return e.copyTo(o, { planeIndex: 0, format: _ }), o;
1006
- };
1007
- let A;
1008
- if (a)
1009
- try {
1010
- A = E();
1011
- } catch (o) {
1012
- z.debug(`Failed to read planar audio data, falling back to interleaved copy: ${o}`), A = I();
1013
- }
1014
- else
1015
- A = I();
1016
- return A;
1017
- }
1018
- convertPcmBuffer(e, r, s) {
1019
- if (e.length === 0)
1020
- return e;
1021
- let n = e, a = e.length, i = r;
1022
- if (s !== c) {
1023
- const _ = a / i, I = Math.max(1, Math.round(_ * c / s)) * i, A = this.getResampleBuffer(I);
1024
- a = Ge(n, A, i, s, c), n = A;
1025
- }
1026
- if (i !== S) {
1027
- const E = a / i * S, I = this.getRemixBuffer(E);
1028
- a = Ve(n.subarray(0, a), I, i, S), n = I, i = S;
1029
- }
1030
- return n.subarray(0, a);
1031
- }
1032
- }
1033
- class Le extends j {
1034
- feedChunk(e) {
1035
- e.isFirst && this.reset();
1036
- const r = Ue(e.data);
1037
- this.writeConvertedPcm(r, this.inputChannels, this.inputSampleRate), e.isLast && this.reset();
1038
- }
1039
- close() {
1040
- }
1041
- }
1042
- class me extends j {
1043
- decoder;
1044
- codec;
1045
- constructor(e) {
1046
- super({ inputChannels: e.inputChannels, inputSampleRate: e.inputSampleRate, sink: e.sink }), this.codec = e.codec, this.decoder = new AudioDecoder({
1047
- output: (r) => {
1048
- try {
1049
- const s = this.convertAudioData(r);
1050
- this.writeConvertedPcm(s, r.numberOfChannels, r.sampleRate);
1051
- } catch (s) {
1052
- m(s);
1053
- } finally {
1054
- try {
1055
- r.close();
1056
- } catch {
1057
- }
1058
- }
1059
- },
1060
- error: (r) => {
1061
- m(r);
1062
- }
1063
- }), this.decoder.configure({ codec: e.codec, numberOfChannels: e.inputChannels, sampleRate: e.inputSampleRate });
1064
- }
1065
- feedChunk(e) {
1066
- try {
1067
- if (e.isFirst && this.reset(), this.decoder.state !== "configured")
1068
- return;
1069
- this.decoder.decode(
1070
- new EncodedAudioChunk({
1071
- type: "key",
1072
- timestamp: e.timestampUs,
1073
- duration: e.durationUs,
1074
- data: e.data
1075
- })
1076
- ), e.isLast && this.decoder.flush().catch(() => {
1077
- });
1078
- } catch (r) {
1079
- m(r);
1080
- try {
1081
- this.reset();
1082
- } catch {
1083
- }
1084
- }
1085
- }
1086
- reset() {
1087
- super.reset();
1088
- try {
1089
- this.decoder.reset(), this.decoder.configure({ codec: this.codec, numberOfChannels: this.inputChannels, sampleRate: this.inputSampleRate });
1090
- } catch (e) {
1091
- m(e);
1092
- }
1093
- }
1094
- close() {
1095
- try {
1096
- this.decoder.close();
1097
- } catch {
1098
- }
1099
- }
1100
- }
1101
- class De extends j {
1102
- decoder = null;
1103
- isReady = !1;
1104
- decoderSampleRate = 48e3;
1105
- pendingChunks = [];
1106
- async initialise(e, r) {
1107
- const { OpusDecoder: s, getOpusModule: n } = await import("./index-Ca9sTcGt.js");
1108
- await n();
1109
- const i = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((_, E) => Math.abs(E - r) < Math.abs(_ - r) ? E : _);
1110
- this.decoderSampleRate = i, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0, this.flushPendingChunks();
1111
- }
1112
- flushPendingChunks() {
1113
- if (!this.isReady || !this.decoder) {
1114
- this.pendingChunks.length = 0;
1115
- return;
1116
- }
1117
- const e = this.pendingChunks, r = e.length;
1118
- if (r !== 0) {
1119
- for (let s = 0; s < r; s++)
1120
- this.decodeChunk(e[s]);
1121
- e.length = 0;
1122
- }
1123
- }
1124
- reset() {
1125
- super.reset();
1126
- try {
1127
- this.decoder?.reset();
1128
- } catch {
1129
- }
1130
- }
1131
- decodeChunk(e) {
1132
- if (!(!this.isReady || !this.decoder))
1133
- try {
1134
- if (e.data.byteLength === 0)
1135
- return;
1136
- const s = this.decoder.decodeFrame(e.data), n = s.channelData, a = s.samplesDecoded, i = n.length;
1137
- if (!i || !a)
1138
- return;
1139
- const _ = a * i, E = this.getInterleavedBuffer(_);
1140
- if (i === 2) {
1141
- const I = n[0], A = n[1];
1142
- for (let o = 0, T = 0; o < a; o++)
1143
- E[T++] = I[o], E[T++] = A[o];
1144
- } else if (i === 1)
1145
- E.set(n[0].subarray(0, a));
1146
- else {
1147
- let I = 0;
1148
- for (let A = 0; A < a; A++)
1149
- for (let o = 0; o < i; o++)
1150
- E[I++] = n[o][A];
1151
- }
1152
- this.writeConvertedPcm(E.subarray(0, _), i, this.decoderSampleRate), e.isLast && this.reset();
1153
- } catch (r) {
1154
- m(r), this.reset();
1155
- }
1156
- }
1157
- feedChunk(e) {
1158
- if (!this.isReady || !this.decoder) {
1159
- this.pendingChunks.push(e);
1160
- return;
1161
- }
1162
- e.isFirst && this.reset(), this.decodeChunk(e);
1163
- }
1164
- close() {
1165
- try {
1166
- this.decoder?.destroy();
1167
- } catch {
1168
- }
1169
- this.decoder = null, this.pendingChunks.length = 0;
1170
- }
1171
- }
1172
- const N = /* @__PURE__ */ new Map();
1173
- async function Pe(t) {
1174
- if (t.closed || t.decoder)
1175
- return;
1176
- if (t.codec === h.RawPcm16) {
1177
- t.decoder = new Le({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1178
- return;
1179
- }
1180
- if (t.codec !== h.Opus && t.codec !== h.Mp3)
1181
- throw new Error(`Unsupported audio codec: ${h[t.codec] ?? t.codec}`);
1182
- const e = ce(t.codec);
1183
- if (At && typeof AudioDecoder < "u" && e !== null)
1184
- try {
1185
- if ((await AudioDecoder.isConfigSupported({ codec: e, numberOfChannels: t.inputChannels, sampleRate: t.inputSampleRate })).supported) {
1186
- const n = new me({
1187
- codec: e,
1188
- inputChannels: t.inputChannels,
1189
- inputSampleRate: t.inputSampleRate,
1190
- sink: t.sink
1191
- });
1192
- if (t.closed) {
1193
- n.close();
1194
- return;
1195
- }
1196
- t.decoder = n;
1197
- return;
1198
- }
1199
- } catch (s) {
1200
- z.warn(`WebCodecs AudioDecoder failed, falling back to WASM: ${s instanceof Error ? s.message : String(s)}`);
1201
- }
1202
- if (t.codec === h.Opus) {
1203
- const s = new De({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1204
- if (await s.initialise(t.inputChannels, t.inputSampleRate), t.closed) {
1205
- s.close();
1206
- return;
1207
- }
1208
- t.decoder = s;
1209
- return;
1210
- }
1211
- throw new Error(`No available decoder for codec: ${h[t.codec] ?? t.codec}`);
1212
- }
1213
- function Oe(t) {
1214
- if (t.closed) {
1215
- t.pendingFrames.splice(0);
1216
- try {
1217
- t.decoder?.close();
1218
- } catch {
1219
- }
1220
- t.decoder = null;
1221
- return;
1222
- }
1223
- if (!t.decoder)
1224
- return;
1225
- const e = t.pendingFrames.splice(0);
1226
- for (const r of e)
1227
- lt(t, r);
1228
- }
1229
- function lt(t, e) {
1230
- if (t.closed || !t.decoder)
1231
- return;
1232
- const r = e.Epoch, s = Number(e.TimeStampInInterleavedSamples), n = e.FrameSizeInInterleavedSamples;
1233
- if (t.currentEpoch !== r && (t.currentEpoch = r, t.epochSet = !1, t.lastArrivalTimeMs = 0, t.jitterMs = 0, t.sink.flush(), t.decoder.reset()), !t.epochSet) {
1234
- t.epochSet = !0;
1235
- const T = t.inputSampleRate * t.inputChannels;
1236
- t.expectedIntervalMs = n * 1e3 / T;
1237
- }
1238
- const a = performance.now();
1239
- if (t.lastArrivalTimeMs > 0) {
1240
- const T = a - t.lastArrivalTimeMs, C = Math.abs(T - t.expectedIntervalMs);
1241
- t.jitterMs = t.jitterMs + (C - t.jitterMs) / Ne;
1242
- }
1243
- t.lastArrivalTimeMs = a;
1244
- const i = t.inputSampleRate * t.inputChannels, _ = c * S, E = Math.round(s * _ / i), I = Math.round(n * _ / i), A = Math.round(s * 1e6 / i), o = Math.round(n * 1e6 / i);
1245
- y({
1246
- type: "frame",
1247
- streamId: t.streamId,
1248
- epoch: r,
1249
- timestampInterleavedSamples: E,
1250
- frameSizeInterleavedSamples: I,
1251
- isFirst: e.IsFirst,
1252
- isLast: e.IsLast,
1253
- jitterMs: t.jitterMs
1254
- }), t.decoder.feedChunk({
1255
- data: e.Samples,
1256
- isFirst: e.IsFirst,
1257
- isLast: e.IsLast,
1258
- timestampUs: A,
1259
- durationUs: o
1260
- });
1261
- }
1262
- async function ye(t) {
1263
- const e = $(t), r = await ee(t), s = N.get(e);
1264
- if (s) {
1265
- s.closed = !0, s.pendingFrames.splice(0);
1266
- try {
1267
- s.decoder?.close();
1268
- } catch {
1269
- }
1270
- try {
1271
- s.sink.drainPcm(), s.sink.close();
1272
- } catch {
1273
- }
1274
- N.delete(e);
1275
- }
1276
- const n = new Se(e), a = {
1277
- streamId: e,
1278
- codec: r.Codec,
1279
- inputSampleRate: r.SampleRate,
1280
- inputChannels: r.Channels,
1281
- sink: n,
1282
- decoder: null,
1283
- pendingFrames: [],
1284
- initTask: null,
1285
- currentEpoch: -1,
1286
- epochSet: !1,
1287
- closed: !1,
1288
- lastArrivalTimeMs: 0,
1289
- jitterMs: 0,
1290
- expectedIntervalMs: 20
1291
- };
1292
- N.set(e, a), y({
1293
- type: "streamBegin",
1294
- streamId: e,
1295
- sharedArrayBuffer: n.getSharedArrayBuffer()
1296
- });
1297
- }
1298
- function we() {
1299
- for (const t of N.values())
1300
- y({
1301
- type: "streamBegin",
1302
- streamId: t.streamId,
1303
- sharedArrayBuffer: t.sink.getSharedArrayBuffer()
1304
- });
1305
- }
1306
- function ge(t) {
1307
- const e = $(t), r = N.get(e);
1308
- if (r) {
1309
- r.closed = !0, r.pendingFrames.splice(0);
1310
- try {
1311
- r.sink.drainPcm(), r.sink.close();
1312
- } catch {
1313
- }
1314
- try {
1315
- r.decoder?.close();
1316
- } catch {
1317
- }
1318
- r.decoder = null, N.delete(e), y({ type: "streamEnd", streamId: e });
1319
- }
1320
- }
1321
- async function Fe(t) {
1322
- const e = $(t), r = N.get(e);
1323
- if (!r || r.closed)
1324
- return;
1325
- const s = await Yt(t);
1326
- if (!ot) {
1327
- if (!r.decoder) {
1328
- if (r.pendingFrames.length >= q) {
1329
- const n = r.pendingFrames.length - q + 1;
1330
- r.pendingFrames.splice(0, n), z.warn(`Dropped ${n} frames waiting for decoder, streamId=${e.substring(0, 8)}`);
1331
- }
1332
- r.pendingFrames.push(s), r.initTask || (r.initTask = Pe(r).then(() => Oe(r)).catch((n) => {
1333
- r.closed || m(n, e);
1334
- }));
1335
- return;
1336
- }
1337
- lt(r, s);
1338
- }
1339
- }
1340
- function Me(t) {
1341
- switch (Nt(t)) {
1342
- case V.AUDIO_STREAM_BEGIN:
1343
- ye(t);
1344
- return;
1345
- case V.AUDIO_STREAM_END:
1346
- ge(t);
1347
- return;
1348
- case V.AUDIO_FRAME2:
1349
- Fe(t);
1350
- return;
1351
- default:
1352
- return;
1353
- }
1354
- }
1355
- function Tt() {
1356
- if (D) {
1357
- try {
1358
- D.close();
1359
- } catch {
1360
- }
1361
- D = null;
1362
- }
1363
- }
1364
- function de() {
1365
- Tt();
1366
- for (const t of N.values()) {
1367
- try {
1368
- t.sink.drainPcm(), t.sink.close();
1369
- } catch {
1370
- }
1371
- try {
1372
- t.decoder?.close();
1373
- } catch {
1374
- }
1375
- }
1376
- N.clear();
1377
- }
1378
- self.addEventListener("message", (t) => {
1379
- const e = t.data;
1380
- if (e.type === "configure") {
1381
- v = e.transport, At = e.preferWebCodecs ?? !0, ot = e.webRtcEnabled ?? !1, c = Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 ? e.outputSampleRate : Et, S = Number.isFinite(e.outputChannels) && e.outputChannels > 0 ? e.outputChannels : It;
1382
- return;
1383
- }
1384
- if (e.type === "attachProtocolPort") {
1385
- Tt(), D = e.port, D.addEventListener("message", (r) => {
1386
- const s = r.data;
1387
- s?.type === "protocol" && s.message instanceof ArrayBuffer && Me(new Uint8Array(s.message));
1388
- }), D.start?.();
1389
- return;
1390
- }
1391
- if (e.type === "rebind") {
1392
- v = e.transport, typeof e.outputSampleRate == "number" && Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 && (c = e.outputSampleRate), typeof e.outputChannels == "number" && Number.isFinite(e.outputChannels) && e.outputChannels > 0 && (S = e.outputChannels);
1393
- for (const r of N.values())
1394
- r.sink.setOutputFormat(c, S), r.sink.rebind(v);
1395
- we();
1396
- return;
1397
- }
1398
- e.type === "dispose" && de();
1399
- });
1400
- let U = null;
1401
- function Be(t, e) {
1402
- const r = t.length;
1403
- if (r === 1)
1404
- return t[0];
1405
- const s = e * r;
1406
- if ((!U || U.length < s) && (U = new Float32Array(s)), r === 2) {
1407
- const n = t[0], a = t[1];
1408
- for (let i = 0, _ = 0; i < e; i++)
1409
- U[_++] = n[i], U[_++] = a[i];
1410
- } else {
1411
- let n = 0;
1412
- for (let a = 0; a < e; a++)
1413
- for (let i = 0; i < r; i++)
1414
- U[n++] = t[i][a];
1415
- }
1416
- return U.subarray(0, s);
1417
- }
1418
- const p = 3;
1419
- function tt(t) {
1420
- if (t === 0)
1421
- return 1;
1422
- const e = Math.PI * t;
1423
- return Math.sin(e) / e;
1424
- }
1425
- function be(t, e) {
1426
- return t === 0 ? 1 : Math.abs(t) >= e ? 0 : tt(t) * tt(t / e);
1427
- }
1428
- function Ge(t, e, r, s, n) {
1429
- if (s === n)
1430
- return e.set(t), t.length;
1431
- const a = t.length / r, i = Math.max(1, Math.round(a * n / s)), _ = s / n, E = _ > 1 ? _ : 1, I = Math.ceil(p * E);
1432
- for (let A = 0; A < r; A++)
1433
- for (let o = 0; o < i; o++) {
1434
- const T = o * _, C = Math.floor(T);
1435
- let w = 0, L = 0;
1436
- for (let k = -I + 1; k <= I; k++) {
1437
- const B = C + k;
1438
- if (B < 0 || B >= a)
1439
- continue;
1440
- const ut = (T - B) / E, Y = be(ut, p);
1441
- if (Y !== 0) {
1442
- const ft = t[B * r + A] ?? 0;
1443
- w += ft * Y, L += Y;
1444
- }
1445
- }
1446
- e[o * r + A] = L > 0 ? w / L : 0;
1447
- }
1448
- return i * r;
1449
- }
1450
- function Ve(t, e, r, s) {
1451
- const n = t.length / r;
1452
- if (r === s)
1453
- return e.set(t), t.length;
1454
- if (r === 1 && s === 2) {
1455
- for (let i = 0; i < n; i++) {
1456
- const _ = t[i] ?? 0;
1457
- e[i * 2] = _, e[i * 2 + 1] = _;
1458
- }
1459
- return n * 2;
1460
- }
1461
- if (r === 2 && s === 1) {
1462
- for (let i = 0; i < n; i++) {
1463
- const _ = t[i * 2] ?? 0, E = t[i * 2 + 1] ?? 0;
1464
- e[i] = (_ + E) * 0.5;
1465
- }
1466
- return n;
1467
- }
1468
- const a = Math.min(r, s);
1469
- for (let i = 0; i < n; i++)
1470
- for (let _ = 0; _ < a; _++)
1471
- e[i * s + _] = t[i * r + _] ?? 0;
1472
- return n * s;
1473
- }