@ikonai/sdk-ui 1.0.59 → 1.0.61

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.
@@ -0,0 +1,1590 @@
1
+ const Ct = {
2
+ Compressed: 8
3
+ };
4
+ function St(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 rt(t) {
10
+ const e = B(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), i = r.getUint32(8, !0), a = r.getUint32(12, !0), _ = r.getUint32(16, !0), E = r.getUint32(20, !0), o = r.getUint8(24), I = r.getUint8(25), A = r.getUint8(26);
14
+ if (27 + E * 4 > e.length)
15
+ throw new Error("Protocol header exceeds payload length");
16
+ const S = [];
17
+ let d = 27;
18
+ for (let L = 0; L < E; L++)
19
+ S.push(r.getUint32(d, !0)), d += 4;
20
+ return {
21
+ length: s,
22
+ opcode: n,
23
+ senderId: i,
24
+ trackId: a,
25
+ sequenceId: _,
26
+ targetIds: S,
27
+ payloadVersion: o,
28
+ payloadType: I,
29
+ flags: A
30
+ };
31
+ }
32
+ async function p(t, e, r) {
33
+ const s = B(t), n = rt(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 i = 27 + n.targetIds.length * 4;
39
+ let a = s.subarray(i, n.length);
40
+ return (n.flags & Ct.Compressed) !== 0 && (a = await ct(a)), a;
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(), i = [];
48
+ let a = 0;
49
+ for (; ; ) {
50
+ const { done: o, value: I } = await n.read();
51
+ if (o) break;
52
+ i.push(I), a += I.length;
53
+ }
54
+ const _ = new Uint8Array(a);
55
+ let E = 0;
56
+ for (let o = 0; o < i.length; o++)
57
+ _.set(i[o], E), E += i[o].length;
58
+ return _;
59
+ }
60
+ var O = /* @__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))(O || {});
61
+ const Rt = 161, Ut = 162;
62
+ new TextEncoder();
63
+ const mt = new TextDecoder("utf-8", { fatal: !0 });
64
+ class w {
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 = B(e);
72
+ if (r.length < 2)
73
+ throw new Error("Teleport payload too short");
74
+ if (r[0] !== Rt || r[r.length - 1] !== Ut)
75
+ throw new Error("Teleport object missing markers");
76
+ const s = { offset: 1 }, n = h(r, s, "InvalidLength");
77
+ return new w(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 = Ot(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 = y(s);
90
+ let i;
91
+ if (n >= 0)
92
+ T(this.buffer, this.offset, n), i = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
93
+ else {
94
+ const a = { offset: this.offset }, _ = h(this.buffer, a, "InvalidLength");
95
+ T(this.buffer, a.offset, _), i = this.buffer.subarray(a.offset, a.offset + _), this.offset = a.offset + _;
96
+ }
97
+ return new Lt(e, s, i);
98
+ }
99
+ }
100
+ class c {
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
+ ), mt.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
+ ), w.create(this.payload);
175
+ }
176
+ asArray() {
177
+ return this.ensureType(
178
+ 9
179
+ /* Array */
180
+ ), W.create(this.payload);
181
+ }
182
+ asDictionary() {
183
+ return this.ensureType(
184
+ 10
185
+ /* Dict */
186
+ ), K.create(this.payload);
187
+ }
188
+ ensureType(e) {
189
+ if (this.type !== e)
190
+ throw new Error(`Teleport value has type ${O[this.type]}, expected ${O[e]}`);
191
+ }
192
+ }
193
+ class Lt extends c {
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 W {
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 = h(e, s, "ArrayMalformed"), this.offset = s.offset;
215
+ }
216
+ static create(e) {
217
+ return new W(B(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 = y(this.elementType);
239
+ T(this.payload, this.offset, e);
240
+ const r = this.payload.subarray(this.offset, this.offset + e);
241
+ return this.offset += e, new F(this.elementType, r);
242
+ }
243
+ case 12:
244
+ case 13: {
245
+ const e = { offset: this.offset }, r = h(this.payload, e, "ArrayMalformed");
246
+ T(this.payload, e.offset, r);
247
+ const s = this.payload.subarray(e.offset, e.offset + r);
248
+ return this.offset = e.offset + r, new F(this.elementType, s);
249
+ }
250
+ case 11: {
251
+ const e = { offset: this.offset }, r = h(this.payload, e, "ArrayMalformed");
252
+ T(this.payload, e.offset, r);
253
+ const s = this.payload.subarray(e.offset, e.offset + r);
254
+ return this.offset = e.offset + r, new F(11, s);
255
+ }
256
+ case 9: {
257
+ const e = z(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
258
+ return this.offset += e, new F(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 F(10, r);
263
+ }
264
+ default:
265
+ throw new Error(`Unsupported array element type ${O[this.elementType]}`);
266
+ }
267
+ }
268
+ }
269
+ class F extends c {
270
+ constructor(e, r) {
271
+ super(e, r);
272
+ }
273
+ }
274
+ class K {
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 = h(e, r, "DictMalformed"), this.offset = r.offset;
289
+ }
290
+ static create(e) {
291
+ return new K(B(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 Dt(e, r);
301
+ }
302
+ readKey() {
303
+ const e = y(this.keyType);
304
+ if (e >= 0) {
305
+ T(this.payload, this.offset, e);
306
+ const r = this.payload.subarray(this.offset, this.offset + e);
307
+ return this.offset += e, new c(this.keyType, r);
308
+ }
309
+ if (this.keyType === 12 || this.keyType === 13) {
310
+ const r = { offset: this.offset }, s = h(this.payload, r, "DictMalformed");
311
+ T(this.payload, r.offset, s);
312
+ const n = this.payload.subarray(r.offset, r.offset + s);
313
+ return this.offset = r.offset + s, new c(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 = h(this.payload, e, "DictMalformed");
322
+ T(this.payload, e.offset, r);
323
+ const s = this.payload.subarray(e.offset, e.offset + r);
324
+ return this.offset = e.offset + r, new c(this.valueType, s);
325
+ }
326
+ case 11: {
327
+ const e = { offset: this.offset }, r = h(this.payload, e, "DictMalformed");
328
+ T(this.payload, e.offset, r);
329
+ const s = this.payload.subarray(e.offset, e.offset + r);
330
+ return this.offset = e.offset + r, new c(11, s);
331
+ }
332
+ case 9: {
333
+ const e = z(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
334
+ return this.offset += e, new c(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 c(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 = y(this.valueType);
350
+ T(this.payload, this.offset, e);
351
+ const r = this.payload.subarray(this.offset, this.offset + e);
352
+ return this.offset += e, new c(this.valueType, r);
353
+ }
354
+ default:
355
+ throw new Error(`Unsupported dictionary value type ${O[this.valueType]}`);
356
+ }
357
+ }
358
+ }
359
+ class Dt {
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), i = l.parseHexSlice(r, 8, 4), a = l.parseHexSlice(r, 12, 4);
375
+ l.writeUInt32LE(s, 0, n), l.writeUInt16LE(s, 4, i), l.writeUInt16LE(s, 6, a);
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), i = Number.parseInt(n, 16);
412
+ if (Number.isNaN(i))
413
+ throw new Error("Guid string contains invalid characters");
414
+ return i >>> 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 h(t, e, r) {
435
+ if (e.offset >= t.length)
436
+ throw new Error(r);
437
+ let s = 0, n = 0, i = 0;
438
+ for (; e.offset < t.length; ) {
439
+ const a = t[e.offset++];
440
+ if (i++, s |= (a & 127) << n, (a & 128) === 0) {
441
+ if (i !== Pt(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 Pt(t) {
451
+ return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
452
+ }
453
+ function y(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 T(t, e, r) {
478
+ if (e < 0 || r < 0 || e + r > t.length)
479
+ throw new Error("Teleport payload exceeds bounds");
480
+ }
481
+ function Ot(t, e) {
482
+ return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0;
483
+ }
484
+ function z(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 }, i = h(t, n, "ArrayMalformed"), a = y(s);
491
+ if (a >= 0) {
492
+ const E = a * i;
493
+ return T(t, n.offset, E), n.offset + E - e;
494
+ }
495
+ let _ = n.offset;
496
+ for (let E = 0; E < i; E++)
497
+ _ = x(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 }, i = h(t, n, "DictMalformed");
508
+ let a = n.offset;
509
+ for (let _ = 0; _ < i; _++)
510
+ a = x(r, t, a, "DictMalformed"), a = x(s, t, a, "DictMalformed");
511
+ return a - e;
512
+ }
513
+ function x(t, e, r, s) {
514
+ const n = y(t);
515
+ if (n >= 0)
516
+ return T(e, r, n), r + n;
517
+ switch (t) {
518
+ case 12:
519
+ case 13: {
520
+ const i = { offset: r }, a = h(e, i, s);
521
+ return T(e, i.offset, a), i.offset + a;
522
+ }
523
+ case 11: {
524
+ const i = { offset: r }, a = h(e, i, s);
525
+ return T(e, i.offset, a), i.offset + a;
526
+ }
527
+ case 9:
528
+ return r + z(e, r);
529
+ case 10:
530
+ return r + X(e, r);
531
+ default:
532
+ throw new Error(`Unsupported Teleport type ${O[t]}`);
533
+ }
534
+ }
535
+ function Q(t) {
536
+ return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
537
+ }
538
+ function B(t) {
539
+ return t instanceof Uint8Array ? t : new Uint8Array(t);
540
+ }
541
+ var N = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(N || {}), g = /* @__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_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_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.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))(g || {});
542
+ const yt = 4194309, wt = 205938238, dt = 1594075008, Ft = 2026534360, Mt = 3409001585, gt = 3466650495, Bt = 4007456593, bt = 4017217601, Gt = 4065417427, Vt = 4086360332;
543
+ function vt(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 kt(t, e) {
551
+ const r = w.create(t);
552
+ return Ht(r, e);
553
+ }
554
+ function Ht(t, e) {
555
+ const r = e ?? vt();
556
+ return nt(r), Yt(t, r), r;
557
+ }
558
+ function Yt(t, e) {
559
+ let r;
560
+ for (; (r = t.next()) !== null; )
561
+ switch (r.fieldId) {
562
+ case wt: {
563
+ if (r.isNull) throw new Error();
564
+ e.AverageVolume = r.asFloat32();
565
+ break;
566
+ }
567
+ case dt: {
568
+ if (r.isNull) throw new Error();
569
+ e.IsFirst = r.asBool();
570
+ break;
571
+ }
572
+ case Ft: {
573
+ if (r.isNull) throw new Error();
574
+ e.TimeStampInInterleavedSamples = r.asUInt64();
575
+ break;
576
+ }
577
+ case Mt: {
578
+ if (r.isNull) throw new Error();
579
+ e.Samples = r.asBinary();
580
+ break;
581
+ }
582
+ case gt: {
583
+ if (r.isNull) throw new Error();
584
+ e.AudioEventEstimatedDuration = r.asFloat32();
585
+ break;
586
+ }
587
+ case Bt: {
588
+ if (r.isNull) throw new Error();
589
+ e.FrameSizeInInterleavedSamples = r.asUInt32();
590
+ break;
591
+ }
592
+ case bt: {
593
+ if (r.isNull) throw new Error();
594
+ e.IsLast = r.asBool();
595
+ break;
596
+ }
597
+ case Gt: {
598
+ if (r.isNull) throw new Error();
599
+ e.Sequence = r.asUInt32();
600
+ break;
601
+ }
602
+ case Vt: {
603
+ if (r.isNull) throw new Error();
604
+ e.Epoch = r.asUInt32();
605
+ break;
606
+ }
607
+ }
608
+ }
609
+ async function xt(t, e) {
610
+ const r = await p(t, yt);
611
+ return kt(r, e);
612
+ }
613
+ const pt = 4194310, Wt = 717315017, Kt = 2026534360, zt = 4007456593, Xt = 4065417427, $t = 4086360332;
614
+ function jt(t) {
615
+ const e = {};
616
+ return at(e), e;
617
+ }
618
+ function at(t) {
619
+ return t.Epoch = 0, t.Sequence = 0, t.FrameSizeInInterleavedSamples = 0, t.TimeStampInInterleavedSamples = 0n, t.ShapeSetValues = [], t;
620
+ }
621
+ function Qt(t, e) {
622
+ const r = w.create(t);
623
+ return Zt(r, e);
624
+ }
625
+ function Zt(t, e) {
626
+ const r = e ?? jt();
627
+ return at(r), qt(t, r), r;
628
+ }
629
+ function qt(t, e) {
630
+ let r;
631
+ for (; (r = t.next()) !== null; )
632
+ switch (r.fieldId) {
633
+ case Wt: {
634
+ if (r.isNull) throw new Error();
635
+ e.ShapeSetValues = te(r.asArray());
636
+ break;
637
+ }
638
+ case Kt: {
639
+ if (r.isNull) throw new Error();
640
+ e.TimeStampInInterleavedSamples = r.asUInt64();
641
+ break;
642
+ }
643
+ case zt: {
644
+ if (r.isNull) throw new Error();
645
+ e.FrameSizeInInterleavedSamples = r.asUInt32();
646
+ break;
647
+ }
648
+ case Xt: {
649
+ if (r.isNull) throw new Error();
650
+ e.Sequence = r.asUInt32();
651
+ break;
652
+ }
653
+ case $t: {
654
+ if (r.isNull) throw new Error();
655
+ e.Epoch = r.asUInt32();
656
+ break;
657
+ }
658
+ }
659
+ }
660
+ async function Jt(t, e) {
661
+ const r = await p(t, pt);
662
+ return Qt(r, e);
663
+ }
664
+ function te(t) {
665
+ const e = [];
666
+ let r;
667
+ for (; (r = t.next()) !== null; )
668
+ e.push(ne(r.asObject()));
669
+ return e;
670
+ }
671
+ const ee = 1154362099, re = 3974819915;
672
+ function se(t) {
673
+ const e = {};
674
+ return it(e), e;
675
+ }
676
+ function it(t) {
677
+ return t.SetId = 0, t.Values = [], t;
678
+ }
679
+ function ne(t, e) {
680
+ const r = e ?? se();
681
+ return it(r), ae(t, r), r;
682
+ }
683
+ function ae(t, e) {
684
+ let r;
685
+ for (; (r = t.next()) !== null; )
686
+ switch (r.fieldId) {
687
+ case ee: {
688
+ if (r.isNull) throw new Error();
689
+ e.SetId = r.asUInt32();
690
+ break;
691
+ }
692
+ case re: {
693
+ if (r.isNull) throw new Error();
694
+ e.Values = ie(r.asArray());
695
+ break;
696
+ }
697
+ }
698
+ }
699
+ function ie(t) {
700
+ const e = [];
701
+ let r;
702
+ for (; (r = t.next()) !== null; )
703
+ e.push(r.asFloat32());
704
+ return e;
705
+ }
706
+ const _e = 4194305, Ee = 161083277, oe = 265814330, Ie = 1368629611, Ae = 2431514951, le = 2514959030, ue = 2745379226, Te = 3282782683, he = 3284746250, fe = 4101844078;
707
+ function Ne(t) {
708
+ const e = {};
709
+ return _t(e), e;
710
+ }
711
+ function _t(t) {
712
+ return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = N.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t.CorrelationId = void 0, t;
713
+ }
714
+ function Ce(t, e) {
715
+ const r = w.create(t);
716
+ return Se(r, e);
717
+ }
718
+ function Se(t, e) {
719
+ const r = e ?? Ne();
720
+ return _t(r), ce(t, r), r;
721
+ }
722
+ function ce(t, e) {
723
+ let r;
724
+ for (; (r = t.next()) !== null; )
725
+ switch (r.fieldId) {
726
+ case Ee: {
727
+ if (r.isNull) throw new Error();
728
+ e.StreamId = r.asString();
729
+ break;
730
+ }
731
+ case oe: {
732
+ if (r.isNull) {
733
+ e.ShapeSets = void 0;
734
+ break;
735
+ }
736
+ e.ShapeSets = Ue(r.asArray());
737
+ break;
738
+ }
739
+ case Ie: {
740
+ if (r.isNull) throw new Error();
741
+ e.Description = r.asString();
742
+ break;
743
+ }
744
+ case Ae: {
745
+ if (r.isNull) throw new Error();
746
+ e.Channels = r.asInt32();
747
+ break;
748
+ }
749
+ case le: {
750
+ if (r.isNull) {
751
+ e.CorrelationId = void 0;
752
+ break;
753
+ }
754
+ e.CorrelationId = r.asString();
755
+ break;
756
+ }
757
+ case ue: {
758
+ if (r.isNull) throw new Error();
759
+ e.CodecDetails = r.asString();
760
+ break;
761
+ }
762
+ case Te: {
763
+ if (r.isNull) throw new Error();
764
+ e.SourceType = r.asString();
765
+ break;
766
+ }
767
+ case he: {
768
+ if (r.isNull) throw new Error();
769
+ e.Codec = r.asInt32();
770
+ break;
771
+ }
772
+ case fe: {
773
+ if (r.isNull) throw new Error();
774
+ e.SampleRate = r.asInt32();
775
+ break;
776
+ }
777
+ }
778
+ }
779
+ async function Re(t, e) {
780
+ const r = await p(t, _e);
781
+ return Ce(r, e);
782
+ }
783
+ function Ue(t) {
784
+ const e = [];
785
+ let r;
786
+ for (; (r = t.next()) !== null; )
787
+ e.push(Oe(r.asObject()));
788
+ return e;
789
+ }
790
+ const me = 1107713536, Le = 1154362099, De = 1185721362;
791
+ function Pe(t) {
792
+ const e = {};
793
+ return Et(e), e;
794
+ }
795
+ function Et(t) {
796
+ return t.SetId = 0, t.Name = "", t.ShapeNames = [], t;
797
+ }
798
+ function Oe(t, e) {
799
+ const r = e ?? Pe();
800
+ return Et(r), ye(t, r), r;
801
+ }
802
+ function ye(t, e) {
803
+ let r;
804
+ for (; (r = t.next()) !== null; )
805
+ switch (r.fieldId) {
806
+ case me: {
807
+ if (r.isNull) throw new Error();
808
+ e.Name = r.asString();
809
+ break;
810
+ }
811
+ case Le: {
812
+ if (r.isNull) throw new Error();
813
+ e.SetId = r.asUInt32();
814
+ break;
815
+ }
816
+ case De: {
817
+ if (r.isNull) throw new Error();
818
+ e.ShapeNames = we(r.asArray());
819
+ break;
820
+ }
821
+ }
822
+ }
823
+ function we(t) {
824
+ const e = [];
825
+ let r;
826
+ for (; (r = t.next()) !== null; )
827
+ e.push(r.asString());
828
+ return e;
829
+ }
830
+ class Z {
831
+ static getStorageForCapacity(e, r) {
832
+ const s = Int32Array.BYTES_PER_ELEMENT * 2, n = r.BYTES_PER_ELEMENT * e;
833
+ return new SharedArrayBuffer(s + n);
834
+ }
835
+ readWrite;
836
+ storage;
837
+ buf;
838
+ constructor(e, r) {
839
+ this.buf = e, this.readWrite = new Int32Array(e, 0, 2);
840
+ const s = Int32Array.BYTES_PER_ELEMENT * 2, n = (e.byteLength - s) / Float32Array.BYTES_PER_ELEMENT;
841
+ this.storage = new r(e, s, n);
842
+ }
843
+ get capacity() {
844
+ return this.storage.length;
845
+ }
846
+ flush() {
847
+ Atomics.store(this.readWrite, 0, 0), Atomics.store(this.readWrite, 1, 0);
848
+ }
849
+ availableRead() {
850
+ const e = Atomics.load(this.readWrite, 0), r = Atomics.load(this.readWrite, 1);
851
+ return r >= e ? r - e : this.capacity - (e - r);
852
+ }
853
+ availableWrite() {
854
+ return this.capacity - this.availableRead() - 1;
855
+ }
856
+ push(e) {
857
+ const r = Math.min(this.availableWrite(), e.length);
858
+ if (r <= 0)
859
+ return 0;
860
+ let s = Atomics.load(this.readWrite, 1);
861
+ const n = Math.min(r, this.capacity - s);
862
+ this.storage.set(e.subarray(0, n), s);
863
+ const i = r - n;
864
+ return i > 0 && this.storage.set(e.subarray(n, n + i), 0), s = (s + r) % this.capacity, Atomics.store(this.readWrite, 1, s), Atomics.notify(this.readWrite, 1), r;
865
+ }
866
+ pop(e) {
867
+ const r = Math.min(this.availableRead(), e.length);
868
+ if (r <= 0)
869
+ return 0;
870
+ let s = Atomics.load(this.readWrite, 0);
871
+ const n = Math.min(r, this.capacity - s);
872
+ e.set(this.storage.subarray(s, s + n), 0);
873
+ const i = r - n;
874
+ return i > 0 && e.set(this.storage.subarray(0, i), n), s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
875
+ }
876
+ skip(e) {
877
+ const r = Math.min(this.availableRead(), e);
878
+ if (r <= 0)
879
+ return 0;
880
+ let s = Atomics.load(this.readWrite, 0);
881
+ return s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
882
+ }
883
+ }
884
+ let de = 1;
885
+ const Fe = /* @__PURE__ */ new Map(), Me = {
886
+ 0: "DEBUG",
887
+ 1: "INFO",
888
+ 2: "WARN",
889
+ 3: "ERROR",
890
+ 4: "NONE"
891
+ };
892
+ function ge(t, e) {
893
+ return `[${t}] ${e}`;
894
+ }
895
+ function G(t, e, r, s) {
896
+ const n = (/* @__PURE__ */ new Date()).toISOString(), i = Me[t], a = {
897
+ timestamp: n,
898
+ level: t,
899
+ levelName: i,
900
+ component: e,
901
+ message: r,
902
+ args: s
903
+ };
904
+ for (const [_, E] of Fe) {
905
+ const o = E?.minLevel ?? 2;
906
+ if (t >= o)
907
+ try {
908
+ _(a);
909
+ } catch {
910
+ }
911
+ }
912
+ if (de <= t) {
913
+ const _ = ge(e, r);
914
+ switch (t) {
915
+ case 0:
916
+ console.debug(_, ...s);
917
+ break;
918
+ case 1:
919
+ console.info(_, ...s);
920
+ break;
921
+ case 2:
922
+ console.warn(_, ...s);
923
+ break;
924
+ case 3:
925
+ console.error(_, ...s);
926
+ break;
927
+ }
928
+ }
929
+ }
930
+ function ot(t) {
931
+ return {
932
+ debug(e, ...r) {
933
+ G(0, t, e, r);
934
+ },
935
+ info(e, ...r) {
936
+ G(1, t, e, r);
937
+ },
938
+ warn(e, ...r) {
939
+ G(2, t, e, r);
940
+ },
941
+ error(e, ...r) {
942
+ G(3, t, e, r);
943
+ }
944
+ };
945
+ }
946
+ const V = ot("Capabilities"), Be = globalThis;
947
+ function be() {
948
+ if (typeof SharedArrayBuffer > "u")
949
+ return V.debug("SharedArrayBuffer not supported: SharedArrayBuffer is undefined"), !1;
950
+ if (typeof Atomics > "u")
951
+ return V.debug("SharedArrayBuffer not supported: Atomics is undefined"), !1;
952
+ if (Be.crossOriginIsolated === !1)
953
+ return V.debug("SharedArrayBuffer not supported: crossOriginIsolated is false (missing COOP/COEP headers)"), !1;
954
+ try {
955
+ new SharedArrayBuffer(1);
956
+ } catch (t) {
957
+ return V.debug(`SharedArrayBuffer not supported: construction failed - ${t instanceof Error ? t.message : String(t)}`), !1;
958
+ }
959
+ return !0;
960
+ }
961
+ const It = 48e3, At = 2, Ge = 1500, Ve = 10, q = 80, ve = 50, J = 64, $ = ot("AudioPlaybackWorker"), m = (t, e) => {
962
+ self.postMessage(t, e ?? []);
963
+ }, ke = be();
964
+ let v = "pcm", lt = !0, ut = !1, R = It, C = At, P = null;
965
+ function D(t, e) {
966
+ const r = t instanceof Error ? t : new Error(String(t));
967
+ m({ type: "error", error: { name: r.name, message: r.message, stack: r.stack }, streamId: e });
968
+ }
969
+ function k(t) {
970
+ const e = rt(t);
971
+ return `${e.senderId}_${e.trackId}`;
972
+ }
973
+ class He {
974
+ mode;
975
+ ring = null;
976
+ sab = void 0;
977
+ streamId;
978
+ outputSampleRate;
979
+ outputChannels;
980
+ closed = !1;
981
+ // Pre-allocated batch buffer for PCM mode to avoid per-frame allocations
982
+ pcmBatchBuffer = null;
983
+ pcmBatchOffset = 0;
984
+ lastPcmFlushTimeMs = 0;
985
+ constructor(e) {
986
+ this.streamId = e, this.mode = "pcm", this.outputSampleRate = R, this.outputChannels = C, this.rebind(v);
987
+ }
988
+ close() {
989
+ this.closed = !0, this.pcmBatchBuffer = null, this.pcmBatchOffset = 0, this.ring = null, this.sab = void 0;
990
+ }
991
+ setOutputFormat(e, r) {
992
+ this.outputSampleRate = e, this.outputChannels = r;
993
+ }
994
+ rebind(e) {
995
+ if (!this.closed) {
996
+ if (this.mode = e, e === "sab" && ke) {
997
+ const r = Math.floor(Ge * this.outputSampleRate * this.outputChannels / 1e3), s = Z.getStorageForCapacity(r, Float32Array), n = new Z(s, Float32Array);
998
+ n.flush(), this.sab = s, this.ring = n;
999
+ return;
1000
+ }
1001
+ this.sab = void 0, this.ring = null;
1002
+ }
1003
+ }
1004
+ flushPendingPcm(e) {
1005
+ if (this.closed || this.mode !== "pcm" || this.pcmBatchOffset <= 0)
1006
+ return;
1007
+ const r = performance.now(), s = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * q / 1e3));
1008
+ if (!(e || this.pcmBatchOffset >= s || this.lastPcmFlushTimeMs > 0 && r - this.lastPcmFlushTimeMs >= ve))
1009
+ return;
1010
+ const i = new Float32Array(this.pcmBatchOffset);
1011
+ i.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = r, m({ type: "pcm", streamId: this.streamId, pcm: i }, [i.buffer]);
1012
+ }
1013
+ drainPcm() {
1014
+ this.flushPendingPcm(!0);
1015
+ }
1016
+ writePcm(e) {
1017
+ if (this.closed)
1018
+ return;
1019
+ if (this.mode === "sab" && this.ring) {
1020
+ const n = this.ring, i = this.outputChannels;
1021
+ let a = e;
1022
+ const _ = Math.floor(Math.max(0, n.capacity - 1) / i) * i;
1023
+ a.length > _ && (a = a.subarray(a.length - _));
1024
+ const E = Math.floor(n.availableWrite() / i) * i;
1025
+ if (E <= 0)
1026
+ return;
1027
+ a.length > E && (a = a.subarray(a.length - E)), n.push(a);
1028
+ return;
1029
+ }
1030
+ const r = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * q / 1e3)), s = this.pcmBatchOffset + e.length;
1031
+ if (!this.pcmBatchBuffer || this.pcmBatchBuffer.length < s) {
1032
+ const n = Math.max(s, r * 2), i = new Float32Array(n);
1033
+ this.pcmBatchBuffer && this.pcmBatchOffset > 0 && i.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchBuffer = i;
1034
+ }
1035
+ this.pcmBatchBuffer.set(e, this.pcmBatchOffset), this.pcmBatchOffset += e.length, this.lastPcmFlushTimeMs === 0 && (this.lastPcmFlushTimeMs = performance.now()), this.flushPendingPcm(!1);
1036
+ }
1037
+ getSharedArrayBuffer() {
1038
+ return this.sab;
1039
+ }
1040
+ flush() {
1041
+ this.closed || (this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = 0, this.ring?.flush());
1042
+ }
1043
+ }
1044
+ function Ye(t) {
1045
+ switch (t) {
1046
+ case N.Opus:
1047
+ return "opus";
1048
+ case N.Mp3:
1049
+ return "mp3";
1050
+ default:
1051
+ return null;
1052
+ }
1053
+ }
1054
+ let M = null;
1055
+ function xe(t) {
1056
+ const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = Math.floor(t.byteLength / 2);
1057
+ (!M || M.length < r) && (M = new Float32Array(r));
1058
+ for (let s = 0; s < r; s++)
1059
+ M[s] = e.getInt16(s * 2, !0) / 32768;
1060
+ return M.subarray(0, r);
1061
+ }
1062
+ class j {
1063
+ inputSampleRate;
1064
+ inputChannels;
1065
+ sink;
1066
+ // Pre-allocated grow-only buffers for conversion pipeline
1067
+ _resampleBuffer = null;
1068
+ _remixBuffer = null;
1069
+ _interleavedBuffer = null;
1070
+ constructor(e) {
1071
+ this.inputSampleRate = e.inputSampleRate, this.inputChannels = e.inputChannels, this.sink = e.sink;
1072
+ }
1073
+ getResampleBuffer(e) {
1074
+ return (!this._resampleBuffer || this._resampleBuffer.length < e) && (this._resampleBuffer = new Float32Array(e)), this._resampleBuffer;
1075
+ }
1076
+ getRemixBuffer(e) {
1077
+ return (!this._remixBuffer || this._remixBuffer.length < e) && (this._remixBuffer = new Float32Array(e)), this._remixBuffer;
1078
+ }
1079
+ getInterleavedBuffer(e) {
1080
+ return (!this._interleavedBuffer || this._interleavedBuffer.length < e) && (this._interleavedBuffer = new Float32Array(e)), this._interleavedBuffer;
1081
+ }
1082
+ reset() {
1083
+ }
1084
+ writeConvertedPcm(e, r, s) {
1085
+ const n = this.convertPcmBuffer(e, r, s);
1086
+ n.length > 0 && this.sink.writePcm(n);
1087
+ }
1088
+ convertAudioData(e) {
1089
+ const r = e.numberOfFrames, s = e.numberOfChannels, n = e.format, i = typeof n == "string" && n.includes("planar"), a = "f32-planar", _ = "f32", E = () => {
1090
+ const A = new Array(s);
1091
+ for (let u = 0; u < s; u++) {
1092
+ const S = new Float32Array(r);
1093
+ e.copyTo(S, { planeIndex: u, format: a }), A[u] = S;
1094
+ }
1095
+ return er(A, r);
1096
+ }, o = () => {
1097
+ const A = new Float32Array(r * s);
1098
+ return e.copyTo(A, { planeIndex: 0, format: _ }), A;
1099
+ };
1100
+ let I;
1101
+ if (i)
1102
+ try {
1103
+ I = E();
1104
+ } catch (A) {
1105
+ $.debug(`Failed to read planar audio data, falling back to interleaved copy: ${A}`), I = o();
1106
+ }
1107
+ else
1108
+ I = o();
1109
+ return I;
1110
+ }
1111
+ convertPcmBuffer(e, r, s) {
1112
+ if (e.length === 0)
1113
+ return e;
1114
+ let n = e, i = e.length, a = r;
1115
+ if (s !== R) {
1116
+ const _ = i / a, o = Math.max(1, Math.round(_ * R / s)) * a, I = this.getResampleBuffer(o);
1117
+ i = sr(n, I, a, s, R), n = I;
1118
+ }
1119
+ if (a !== C) {
1120
+ const E = i / a * C, o = this.getRemixBuffer(E);
1121
+ i = nr(n.subarray(0, i), o, a, C), n = o, a = C;
1122
+ }
1123
+ return n.subarray(0, i);
1124
+ }
1125
+ }
1126
+ class pe extends j {
1127
+ feedChunk(e) {
1128
+ e.isFirst && this.reset();
1129
+ const r = xe(e.data);
1130
+ this.writeConvertedPcm(r, this.inputChannels, this.inputSampleRate), e.isLast && this.reset();
1131
+ }
1132
+ close() {
1133
+ }
1134
+ }
1135
+ class We extends j {
1136
+ decoder;
1137
+ codec;
1138
+ constructor(e) {
1139
+ super({ inputChannels: e.inputChannels, inputSampleRate: e.inputSampleRate, sink: e.sink }), this.codec = e.codec, this.decoder = new AudioDecoder({
1140
+ output: (r) => {
1141
+ try {
1142
+ const s = this.convertAudioData(r);
1143
+ this.writeConvertedPcm(s, r.numberOfChannels, r.sampleRate);
1144
+ } catch (s) {
1145
+ D(s);
1146
+ } finally {
1147
+ try {
1148
+ r.close();
1149
+ } catch {
1150
+ }
1151
+ }
1152
+ },
1153
+ error: (r) => {
1154
+ D(r);
1155
+ }
1156
+ }), this.decoder.configure({ codec: e.codec, numberOfChannels: e.inputChannels, sampleRate: e.inputSampleRate });
1157
+ }
1158
+ feedChunk(e) {
1159
+ try {
1160
+ if (e.isFirst && this.reset(), this.decoder.state !== "configured")
1161
+ return;
1162
+ this.decoder.decode(
1163
+ new EncodedAudioChunk({
1164
+ type: "key",
1165
+ timestamp: e.timestampUs,
1166
+ duration: e.durationUs,
1167
+ data: e.data
1168
+ })
1169
+ ), e.isLast && this.decoder.flush().catch(() => {
1170
+ });
1171
+ } catch (r) {
1172
+ D(r);
1173
+ try {
1174
+ this.reset();
1175
+ } catch {
1176
+ }
1177
+ }
1178
+ }
1179
+ reset() {
1180
+ super.reset();
1181
+ try {
1182
+ this.decoder.reset(), this.decoder.configure({ codec: this.codec, numberOfChannels: this.inputChannels, sampleRate: this.inputSampleRate });
1183
+ } catch (e) {
1184
+ D(e);
1185
+ }
1186
+ }
1187
+ close() {
1188
+ try {
1189
+ this.decoder.close();
1190
+ } catch {
1191
+ }
1192
+ }
1193
+ }
1194
+ class Ke extends j {
1195
+ decoder = null;
1196
+ isReady = !1;
1197
+ decoderSampleRate = 48e3;
1198
+ pendingChunks = [];
1199
+ async initialise(e, r) {
1200
+ const { OpusDecoder: s, getOpusModule: n } = await import("./index-Ca9sTcGt.js");
1201
+ await n();
1202
+ const a = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((_, E) => Math.abs(E - r) < Math.abs(_ - r) ? E : _);
1203
+ this.decoderSampleRate = a, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0, this.flushPendingChunks();
1204
+ }
1205
+ flushPendingChunks() {
1206
+ if (!this.isReady || !this.decoder) {
1207
+ this.pendingChunks.length = 0;
1208
+ return;
1209
+ }
1210
+ const e = this.pendingChunks, r = e.length;
1211
+ if (r !== 0) {
1212
+ for (let s = 0; s < r; s++)
1213
+ this.decodeChunk(e[s]);
1214
+ e.length = 0;
1215
+ }
1216
+ }
1217
+ reset() {
1218
+ super.reset();
1219
+ try {
1220
+ this.decoder?.reset();
1221
+ } catch {
1222
+ }
1223
+ }
1224
+ decodeChunk(e) {
1225
+ if (!(!this.isReady || !this.decoder))
1226
+ try {
1227
+ if (e.data.byteLength === 0)
1228
+ return;
1229
+ const s = this.decoder.decodeFrame(e.data), n = s.channelData, i = s.samplesDecoded, a = n.length;
1230
+ if (!a || !i)
1231
+ return;
1232
+ const _ = i * a, E = this.getInterleavedBuffer(_);
1233
+ if (a === 2) {
1234
+ const o = n[0], I = n[1];
1235
+ for (let A = 0, u = 0; A < i; A++)
1236
+ E[u++] = o[A], E[u++] = I[A];
1237
+ } else if (a === 1)
1238
+ E.set(n[0].subarray(0, i));
1239
+ else {
1240
+ let o = 0;
1241
+ for (let I = 0; I < i; I++)
1242
+ for (let A = 0; A < a; A++)
1243
+ E[o++] = n[A][I];
1244
+ }
1245
+ this.writeConvertedPcm(E.subarray(0, _), a, this.decoderSampleRate), e.isLast && this.reset();
1246
+ } catch (r) {
1247
+ D(r), this.reset();
1248
+ }
1249
+ }
1250
+ feedChunk(e) {
1251
+ if (!this.isReady || !this.decoder) {
1252
+ this.pendingChunks.push(e);
1253
+ return;
1254
+ }
1255
+ e.isFirst && this.reset(), this.decodeChunk(e);
1256
+ }
1257
+ close() {
1258
+ try {
1259
+ this.decoder?.destroy();
1260
+ } catch {
1261
+ }
1262
+ this.decoder = null, this.pendingChunks.length = 0;
1263
+ }
1264
+ }
1265
+ const f = /* @__PURE__ */ new Map();
1266
+ async function ze(t) {
1267
+ if (t.closed || t.decoder)
1268
+ return;
1269
+ if (t.codec === N.RawPcm16) {
1270
+ t.decoder = new pe({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1271
+ return;
1272
+ }
1273
+ if (t.codec !== N.Opus && t.codec !== N.Mp3)
1274
+ throw new Error(`Unsupported audio codec: ${N[t.codec] ?? t.codec}`);
1275
+ const e = Ye(t.codec);
1276
+ if (lt && typeof AudioDecoder < "u" && e !== null)
1277
+ try {
1278
+ if ((await AudioDecoder.isConfigSupported({ codec: e, numberOfChannels: t.inputChannels, sampleRate: t.inputSampleRate })).supported) {
1279
+ const n = new We({
1280
+ codec: e,
1281
+ inputChannels: t.inputChannels,
1282
+ inputSampleRate: t.inputSampleRate,
1283
+ sink: t.sink
1284
+ });
1285
+ if (t.closed) {
1286
+ n.close();
1287
+ return;
1288
+ }
1289
+ t.decoder = n;
1290
+ return;
1291
+ }
1292
+ } catch (s) {
1293
+ $.warn(`WebCodecs AudioDecoder failed, falling back to WASM: ${s instanceof Error ? s.message : String(s)}`);
1294
+ }
1295
+ if (t.codec === N.Opus) {
1296
+ const s = new Ke({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1297
+ if (await s.initialise(t.inputChannels, t.inputSampleRate), t.closed) {
1298
+ s.close();
1299
+ return;
1300
+ }
1301
+ t.decoder = s;
1302
+ return;
1303
+ }
1304
+ throw new Error(`No available decoder for codec: ${N[t.codec] ?? t.codec}`);
1305
+ }
1306
+ function Xe(t) {
1307
+ if (t.closed) {
1308
+ t.pendingFrames.splice(0);
1309
+ try {
1310
+ t.decoder?.close();
1311
+ } catch {
1312
+ }
1313
+ t.decoder = null;
1314
+ return;
1315
+ }
1316
+ if (!t.decoder)
1317
+ return;
1318
+ const e = t.pendingFrames.splice(0);
1319
+ for (const r of e)
1320
+ Tt(t, r);
1321
+ }
1322
+ function Tt(t, e) {
1323
+ if (t.closed || !t.decoder)
1324
+ return;
1325
+ const r = e.Epoch, s = Number(e.TimeStampInInterleavedSamples), n = e.FrameSizeInInterleavedSamples;
1326
+ if (t.currentEpoch !== r && (t.currentEpoch = r, t.epochSet = !1, t.lastArrivalTimeMs = 0, t.jitterMs = 0, t.sink.flush(), t.decoder.reset()), !t.epochSet) {
1327
+ t.epochSet = !0;
1328
+ const u = t.inputSampleRate * t.inputChannels;
1329
+ t.expectedIntervalMs = n * 1e3 / u;
1330
+ }
1331
+ const i = performance.now();
1332
+ if (t.lastArrivalTimeMs > 0) {
1333
+ const u = i - t.lastArrivalTimeMs, S = Math.abs(u - t.expectedIntervalMs);
1334
+ t.jitterMs = t.jitterMs + (S - t.jitterMs) / Ve;
1335
+ }
1336
+ t.lastArrivalTimeMs = i;
1337
+ const a = t.inputSampleRate * t.inputChannels, _ = R * C, E = Math.round(s * _ / a), o = Math.round(n * _ / a), I = Math.round(s * 1e6 / a), A = Math.round(n * 1e6 / a);
1338
+ m({
1339
+ type: "frame",
1340
+ streamId: t.streamId,
1341
+ epoch: r,
1342
+ timestampInterleavedSamples: E,
1343
+ frameSizeInterleavedSamples: o,
1344
+ isFirst: e.IsFirst,
1345
+ isLast: e.IsLast,
1346
+ jitterMs: t.jitterMs
1347
+ }), t.decoder.feedChunk({
1348
+ data: e.Samples,
1349
+ isFirst: e.IsFirst,
1350
+ isLast: e.IsLast,
1351
+ timestampUs: I,
1352
+ durationUs: A
1353
+ });
1354
+ }
1355
+ async function $e(t) {
1356
+ const e = k(t), r = await Re(t), s = f.get(e);
1357
+ if (s) {
1358
+ s.closed = !0, s.pendingFrames.splice(0);
1359
+ try {
1360
+ s.decoder?.close();
1361
+ } catch {
1362
+ }
1363
+ try {
1364
+ s.sink.drainPcm(), s.sink.close();
1365
+ } catch {
1366
+ }
1367
+ f.delete(e);
1368
+ }
1369
+ const n = new He(e), i = {
1370
+ streamId: e,
1371
+ codec: r.Codec,
1372
+ inputSampleRate: r.SampleRate,
1373
+ inputChannels: r.Channels,
1374
+ sink: n,
1375
+ decoder: null,
1376
+ pendingFrames: [],
1377
+ initTask: null,
1378
+ currentEpoch: -1,
1379
+ epochSet: !1,
1380
+ closed: !1,
1381
+ lastArrivalTimeMs: 0,
1382
+ jitterMs: 0,
1383
+ expectedIntervalMs: 20,
1384
+ shapeSets: r.ShapeSets
1385
+ };
1386
+ f.set(e, i), m({
1387
+ type: "streamBegin",
1388
+ streamId: e,
1389
+ sharedArrayBuffer: n.getSharedArrayBuffer(),
1390
+ shapeSets: r.ShapeSets
1391
+ });
1392
+ }
1393
+ function je() {
1394
+ for (const t of f.values())
1395
+ m({
1396
+ type: "streamBegin",
1397
+ streamId: t.streamId,
1398
+ sharedArrayBuffer: t.sink.getSharedArrayBuffer(),
1399
+ shapeSets: t.shapeSets
1400
+ });
1401
+ }
1402
+ function Qe(t) {
1403
+ const e = k(t), r = f.get(e);
1404
+ if (r) {
1405
+ r.closed = !0, r.pendingFrames.splice(0);
1406
+ try {
1407
+ r.sink.drainPcm(), r.sink.close();
1408
+ } catch {
1409
+ }
1410
+ try {
1411
+ r.decoder?.close();
1412
+ } catch {
1413
+ }
1414
+ r.decoder = null, f.delete(e), m({ type: "streamEnd", streamId: e });
1415
+ }
1416
+ }
1417
+ async function Ze(t) {
1418
+ const e = k(t), r = f.get(e);
1419
+ if (!r || r.closed)
1420
+ return;
1421
+ const s = await xt(t);
1422
+ if (!ut) {
1423
+ if (!r.decoder) {
1424
+ if (r.pendingFrames.length >= J) {
1425
+ const n = r.pendingFrames.length - J + 1;
1426
+ r.pendingFrames.splice(0, n), $.warn(`Dropped ${n} frames waiting for decoder, streamId=${e.substring(0, 8)}`);
1427
+ }
1428
+ r.pendingFrames.push(s), r.initTask || (r.initTask = ze(r).then(() => Xe(r)).catch((n) => {
1429
+ r.closed || D(n, e);
1430
+ }));
1431
+ return;
1432
+ }
1433
+ Tt(r, s);
1434
+ }
1435
+ }
1436
+ async function qe(t) {
1437
+ const e = k(t), r = f.get(e);
1438
+ if (!r || r.closed) return;
1439
+ const s = await Jt(t), n = r.inputSampleRate * r.inputChannels, i = R * C;
1440
+ m({
1441
+ type: "shapeFrame",
1442
+ streamId: e,
1443
+ epoch: s.Epoch,
1444
+ sequence: s.Sequence,
1445
+ timestampInterleavedSamples: Math.round(
1446
+ Number(s.TimeStampInInterleavedSamples) * i / n
1447
+ ),
1448
+ frameSizeInterleavedSamples: Math.round(
1449
+ s.FrameSizeInInterleavedSamples * i / n
1450
+ ),
1451
+ shapeSetValues: s.ShapeSetValues
1452
+ });
1453
+ }
1454
+ function Je(t) {
1455
+ switch (St(t)) {
1456
+ case g.AUDIO_STREAM_BEGIN:
1457
+ $e(t);
1458
+ return;
1459
+ case g.AUDIO_STREAM_END:
1460
+ Qe(t);
1461
+ return;
1462
+ case g.AUDIO_FRAME2:
1463
+ Ze(t);
1464
+ return;
1465
+ case g.AUDIO_SHAPE_FRAME:
1466
+ qe(t);
1467
+ return;
1468
+ default:
1469
+ return;
1470
+ }
1471
+ }
1472
+ function ht() {
1473
+ if (P) {
1474
+ try {
1475
+ P.close();
1476
+ } catch {
1477
+ }
1478
+ P = null;
1479
+ }
1480
+ }
1481
+ function tr() {
1482
+ ht();
1483
+ for (const t of f.values()) {
1484
+ try {
1485
+ t.sink.drainPcm(), t.sink.close();
1486
+ } catch {
1487
+ }
1488
+ try {
1489
+ t.decoder?.close();
1490
+ } catch {
1491
+ }
1492
+ }
1493
+ f.clear();
1494
+ }
1495
+ self.addEventListener("message", (t) => {
1496
+ const e = t.data;
1497
+ if (e.type === "configure") {
1498
+ v = e.transport, lt = e.preferWebCodecs ?? !0, ut = e.webRtcEnabled ?? !1, R = Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 ? e.outputSampleRate : It, C = Number.isFinite(e.outputChannels) && e.outputChannels > 0 ? e.outputChannels : At;
1499
+ return;
1500
+ }
1501
+ if (e.type === "attachProtocolPort") {
1502
+ ht(), P = e.port, P.addEventListener("message", (r) => {
1503
+ const s = r.data;
1504
+ s?.type === "protocol" && s.message instanceof ArrayBuffer && Je(new Uint8Array(s.message));
1505
+ }), P.start?.();
1506
+ return;
1507
+ }
1508
+ if (e.type === "rebind") {
1509
+ v = e.transport, typeof e.outputSampleRate == "number" && Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 && (R = e.outputSampleRate), typeof e.outputChannels == "number" && Number.isFinite(e.outputChannels) && e.outputChannels > 0 && (C = e.outputChannels);
1510
+ for (const r of f.values())
1511
+ r.sink.setOutputFormat(R, C), r.sink.rebind(v);
1512
+ je();
1513
+ return;
1514
+ }
1515
+ e.type === "dispose" && tr();
1516
+ });
1517
+ let U = null;
1518
+ function er(t, e) {
1519
+ const r = t.length;
1520
+ if (r === 1)
1521
+ return t[0];
1522
+ const s = e * r;
1523
+ if ((!U || U.length < s) && (U = new Float32Array(s)), r === 2) {
1524
+ const n = t[0], i = t[1];
1525
+ for (let a = 0, _ = 0; a < e; a++)
1526
+ U[_++] = n[a], U[_++] = i[a];
1527
+ } else {
1528
+ let n = 0;
1529
+ for (let i = 0; i < e; i++)
1530
+ for (let a = 0; a < r; a++)
1531
+ U[n++] = t[a][i];
1532
+ }
1533
+ return U.subarray(0, s);
1534
+ }
1535
+ const tt = 3;
1536
+ function et(t) {
1537
+ if (t === 0)
1538
+ return 1;
1539
+ const e = Math.PI * t;
1540
+ return Math.sin(e) / e;
1541
+ }
1542
+ function rr(t, e) {
1543
+ return t === 0 ? 1 : Math.abs(t) >= e ? 0 : et(t) * et(t / e);
1544
+ }
1545
+ function sr(t, e, r, s, n) {
1546
+ if (s === n)
1547
+ return e.set(t), t.length;
1548
+ const i = t.length / r, a = Math.max(1, Math.round(i * n / s)), _ = s / n, E = _ > 1 ? _ : 1, o = Math.ceil(tt * E);
1549
+ for (let I = 0; I < r; I++)
1550
+ for (let A = 0; A < a; A++) {
1551
+ const u = A * _, S = Math.floor(u);
1552
+ let d = 0, L = 0;
1553
+ for (let H = -o + 1; H <= o; H++) {
1554
+ const b = S + H;
1555
+ if (b < 0 || b >= i)
1556
+ continue;
1557
+ const ft = (u - b) / E, Y = rr(ft, tt);
1558
+ if (Y !== 0) {
1559
+ const Nt = t[b * r + I] ?? 0;
1560
+ d += Nt * Y, L += Y;
1561
+ }
1562
+ }
1563
+ e[A * r + I] = L > 0 ? d / L : 0;
1564
+ }
1565
+ return a * r;
1566
+ }
1567
+ function nr(t, e, r, s) {
1568
+ const n = t.length / r;
1569
+ if (r === s)
1570
+ return e.set(t), t.length;
1571
+ if (r === 1 && s === 2) {
1572
+ for (let a = 0; a < n; a++) {
1573
+ const _ = t[a] ?? 0;
1574
+ e[a * 2] = _, e[a * 2 + 1] = _;
1575
+ }
1576
+ return n * 2;
1577
+ }
1578
+ if (r === 2 && s === 1) {
1579
+ for (let a = 0; a < n; a++) {
1580
+ const _ = t[a * 2] ?? 0, E = t[a * 2 + 1] ?? 0;
1581
+ e[a] = (_ + E) * 0.5;
1582
+ }
1583
+ return n;
1584
+ }
1585
+ const i = Math.min(r, s);
1586
+ for (let a = 0; a < n; a++)
1587
+ for (let _ = 0; _ < i; _++)
1588
+ e[a * s + _] = t[a * r + _] ?? 0;
1589
+ return n * s;
1590
+ }