@ikonai/sdk-ui 1.0.80 → 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.
@@ -1,2855 +0,0 @@
1
- const nt = {
2
- Compressed: 8
3
- };
4
- function ot(e) {
5
- if (e.length < 8)
6
- throw new Error("Protocol message too short");
7
- return (e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24) >>> 0;
8
- }
9
- function Ie(e) {
10
- const r = X(e), t = new DataView(r.buffer, r.byteOffset, r.byteLength);
11
- if (r.length < 27)
12
- throw new Error("Protocol payload too short");
13
- const s = t.getUint32(0, !0), n = t.getUint32(4, !0), o = t.getUint32(8, !0), i = t.getUint32(12, !0), a = t.getUint32(16, !0), E = t.getUint32(20, !0), I = t.getUint8(24), l = t.getUint8(25), _ = t.getUint8(26);
14
- if (27 + E * 4 > r.length)
15
- throw new Error("Protocol header exceeds payload length");
16
- const L = [];
17
- let D = 27;
18
- for (let Q = 0; Q < E; Q++)
19
- L.push(t.getUint32(D, !0)), D += 4;
20
- return {
21
- length: s,
22
- opcode: n,
23
- senderId: o,
24
- trackId: i,
25
- sequenceId: a,
26
- targetIds: L,
27
- payloadVersion: I,
28
- payloadType: l,
29
- flags: _
30
- };
31
- }
32
- async function j(e, r, t) {
33
- const s = X(e), n = Ie(s);
34
- if (r !== void 0 && n.opcode !== r)
35
- throw new Error(`Unexpected opcode ${n.opcode}`);
36
- if (n.payloadType !== 8)
37
- throw new Error(`Unexpected payload type ${n.payloadType}`);
38
- const o = 27 + n.targetIds.length * 4;
39
- let i = s.subarray(o, n.length);
40
- return (n.flags & nt.Compressed) !== 0 && (i = await it(i)), i;
41
- }
42
- async function it(e) {
43
- if (typeof DecompressionStream > "u")
44
- throw new Error("DecompressionStream not supported");
45
- const r = new DecompressionStream("gzip"), t = r.writable.getWriter(), s = new Uint8Array(e);
46
- t.write(s), t.close();
47
- const n = r.readable.getReader(), o = [];
48
- let i = 0;
49
- for (; ; ) {
50
- const { done: I, value: l } = await n.read();
51
- if (I) break;
52
- o.push(l), i += l.length;
53
- }
54
- const a = new Uint8Array(i);
55
- let E = 0;
56
- for (let I = 0; I < o.length; I++)
57
- a.set(o[I], E), E += o[I].length;
58
- return a;
59
- }
60
- var v = /* @__PURE__ */ ((e) => (e[e.Null = 1] = "Null", e[e.Bool = 2] = "Bool", e[e.Int32 = 3] = "Int32", e[e.Int64 = 4] = "Int64", e[e.UInt32 = 5] = "UInt32", e[e.UInt64 = 6] = "UInt64", e[e.Float32 = 7] = "Float32", e[e.Float64 = 8] = "Float64", e[e.Array = 9] = "Array", e[e.Dict = 10] = "Dict", e[e.Object = 11] = "Object", e[e.String = 12] = "String", e[e.Binary = 13] = "Binary", e[e.Guid = 14] = "Guid", e))(v || {});
61
- const at = 161, lt = 162;
62
- new TextEncoder();
63
- const Et = new TextDecoder("utf-8", { fatal: !0 });
64
- class g {
65
- constructor(r, t, s) {
66
- this.buffer = r, this.version = t, this.offset = s, this.end = r.length - 1;
67
- }
68
- offset;
69
- end;
70
- static create(r) {
71
- const t = X(r);
72
- if (t.length < 2)
73
- throw new Error("Teleport payload too short");
74
- if (t[0] !== at || t[t.length - 1] !== lt)
75
- throw new Error("Teleport object missing markers");
76
- const s = { offset: 1 }, n = N(t, s, "InvalidLength");
77
- return new g(t, 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 r = ft(this.buffer, this.offset);
85
- this.offset += 4;
86
- const t = this.buffer[this.offset++], s = t >> 4 & 15;
87
- if ((t & 15) !== 0)
88
- throw new Error("Teleport field flags must be zero");
89
- const n = k(s);
90
- let o;
91
- if (n >= 0)
92
- S(this.buffer, this.offset, n), o = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
93
- else {
94
- const i = { offset: this.offset }, a = N(this.buffer, i, "InvalidLength");
95
- S(this.buffer, i.offset, a), o = this.buffer.subarray(i.offset, i.offset + a), this.offset = i.offset + a;
96
- }
97
- return new It(r, s, o);
98
- }
99
- }
100
- class U {
101
- constructor(r, t) {
102
- this.type = r, this.payload = t;
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
- ), Et.decode(this.payload);
163
- }
164
- asGuid() {
165
- return this.ensureType(
166
- 14
167
- /* Guid */
168
- ), T.fromBytes(this.payload);
169
- }
170
- asObject() {
171
- return this.ensureType(
172
- 11
173
- /* Object */
174
- ), g.create(this.payload);
175
- }
176
- asArray() {
177
- return this.ensureType(
178
- 9
179
- /* Array */
180
- ), re.create(this.payload);
181
- }
182
- asDictionary() {
183
- return this.ensureType(
184
- 10
185
- /* Dict */
186
- ), se.create(this.payload);
187
- }
188
- ensureType(r) {
189
- if (this.type !== r)
190
- throw new Error(`Teleport value has type ${v[this.type]}, expected ${v[r]}`);
191
- }
192
- }
193
- class It extends U {
194
- constructor(r, t, s) {
195
- super(t, s), this.fieldId = r;
196
- }
197
- get isNull() {
198
- return this.type === 1;
199
- }
200
- }
201
- class re {
202
- payload;
203
- elementType;
204
- count;
205
- offset;
206
- index = 0;
207
- constructor(r) {
208
- if (this.payload = r, r.length === 0)
209
- throw new Error("Array payload too short");
210
- const t = r[0];
211
- if (this.elementType = t >> 4 & 15, (t & 15) !== 0)
212
- throw new Error("Array flags must be zero");
213
- const s = { offset: 1 };
214
- this.count = N(r, s, "ArrayMalformed"), this.offset = s.offset;
215
- }
216
- static create(r) {
217
- return new re(X(r));
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 r = this.readValue();
226
- return this.index++, r;
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 r = k(this.elementType);
239
- S(this.payload, this.offset, r);
240
- const t = this.payload.subarray(this.offset, this.offset + r);
241
- return this.offset += r, new V(this.elementType, t);
242
- }
243
- case 12:
244
- case 13: {
245
- const r = { offset: this.offset }, t = N(this.payload, r, "ArrayMalformed");
246
- S(this.payload, r.offset, t);
247
- const s = this.payload.subarray(r.offset, r.offset + t);
248
- return this.offset = r.offset + t, new V(this.elementType, s);
249
- }
250
- case 11: {
251
- const r = { offset: this.offset }, t = N(this.payload, r, "ArrayMalformed");
252
- S(this.payload, r.offset, t);
253
- const s = this.payload.subarray(r.offset, r.offset + t);
254
- return this.offset = r.offset + t, new V(11, s);
255
- }
256
- case 9: {
257
- const r = ne(this.payload, this.offset), t = this.payload.subarray(this.offset, this.offset + r);
258
- return this.offset += r, new V(9, t);
259
- }
260
- case 10: {
261
- const r = oe(this.payload, this.offset), t = this.payload.subarray(this.offset, this.offset + r);
262
- return this.offset += r, new V(10, t);
263
- }
264
- default:
265
- throw new Error(`Unsupported array element type ${v[this.elementType]}`);
266
- }
267
- }
268
- }
269
- class V extends U {
270
- constructor(r, t) {
271
- super(r, t);
272
- }
273
- }
274
- class se {
275
- payload;
276
- keyType;
277
- valueType;
278
- count;
279
- offset;
280
- index = 0;
281
- constructor(r) {
282
- if (this.payload = r, r.length < 2)
283
- throw new Error("Dictionary payload too short");
284
- if (this.keyType = r[0] >> 4 & 15, this.valueType = r[1] >> 4 & 15, (r[0] & 15) !== 0 || (r[1] & 15) !== 0)
285
- throw new Error("Dictionary key/value flags must be zero");
286
- _e(this.keyType);
287
- const t = { offset: 2 };
288
- this.count = N(r, t, "DictMalformed"), this.offset = t.offset;
289
- }
290
- static create(r) {
291
- return new se(X(r));
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 r = this.readKey(), t = this.readValue();
300
- return this.index++, new _t(r, t);
301
- }
302
- readKey() {
303
- const r = k(this.keyType);
304
- if (r >= 0) {
305
- S(this.payload, this.offset, r);
306
- const t = this.payload.subarray(this.offset, this.offset + r);
307
- return this.offset += r, new U(this.keyType, t);
308
- }
309
- if (this.keyType === 12 || this.keyType === 13) {
310
- const t = { offset: this.offset }, s = N(this.payload, t, "DictMalformed");
311
- S(this.payload, t.offset, s);
312
- const n = this.payload.subarray(t.offset, t.offset + s);
313
- return this.offset = t.offset + s, new U(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 r = { offset: this.offset }, t = N(this.payload, r, "DictMalformed");
322
- S(this.payload, r.offset, t);
323
- const s = this.payload.subarray(r.offset, r.offset + t);
324
- return this.offset = r.offset + t, new U(this.valueType, s);
325
- }
326
- case 11: {
327
- const r = { offset: this.offset }, t = N(this.payload, r, "DictMalformed");
328
- S(this.payload, r.offset, t);
329
- const s = this.payload.subarray(r.offset, r.offset + t);
330
- return this.offset = r.offset + t, new U(11, s);
331
- }
332
- case 9: {
333
- const r = ne(this.payload, this.offset), t = this.payload.subarray(this.offset, this.offset + r);
334
- return this.offset += r, new U(9, t);
335
- }
336
- case 10: {
337
- const r = oe(this.payload, this.offset), t = this.payload.subarray(this.offset, this.offset + r);
338
- return this.offset += r, new U(10, t);
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 r = k(this.valueType);
350
- S(this.payload, this.offset, r);
351
- const t = this.payload.subarray(this.offset, this.offset + r);
352
- return this.offset += r, new U(this.valueType, t);
353
- }
354
- default:
355
- throw new Error(`Unsupported dictionary value type ${v[this.valueType]}`);
356
- }
357
- }
358
- }
359
- class _t {
360
- constructor(r, t) {
361
- this.key = r, this.value = t;
362
- }
363
- }
364
- class T {
365
- constructor(r) {
366
- this.bytes = r;
367
- }
368
- static fromString(r) {
369
- if (!r)
370
- throw new Error("Guid string is empty");
371
- const t = r.replace(/-/g, "");
372
- if (t.length !== 32)
373
- throw new Error("Guid string must be 32 hex characters");
374
- const s = new Uint8Array(16), n = T.parseHexSlice(t, 0, 8), o = T.parseHexSlice(t, 8, 4), i = T.parseHexSlice(t, 12, 4);
375
- T.writeUInt32LE(s, 0, n), T.writeUInt16LE(s, 4, o), T.writeUInt16LE(s, 6, i);
376
- for (let a = 0; a < 8; a++)
377
- s[8 + a] = T.parseHexSlice(t, 16 + a * 2, 2);
378
- return new T(s);
379
- }
380
- static fromBytes(r) {
381
- if (r.length !== 16)
382
- throw new Error("Guid byte array must be 16 bytes");
383
- return new T(Uint8Array.from(r));
384
- }
385
- static createZero() {
386
- return new T(new Uint8Array(16));
387
- }
388
- static createRandom() {
389
- const r = new Uint8Array(16), t = globalThis.crypto;
390
- if (t?.getRandomValues)
391
- t.getRandomValues(r);
392
- else
393
- for (let s = 0; s < r.length; s++)
394
- r[s] = Math.floor(Math.random() * 256);
395
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, new T(r);
396
- }
397
- toString() {
398
- const r = this.bytes;
399
- return [
400
- T.toHex(T.readUInt32LE(r, 0), 8),
401
- T.toHex(T.readUInt16LE(r, 4), 4),
402
- T.toHex(T.readUInt16LE(r, 6), 4),
403
- ae(r.subarray(8, 10)),
404
- ae(r.subarray(10, 16))
405
- ].join("-");
406
- }
407
- asBytes() {
408
- return this.bytes.slice();
409
- }
410
- static parseHexSlice(r, t, s) {
411
- const n = r.substr(t, s), o = Number.parseInt(n, 16);
412
- if (Number.isNaN(o))
413
- throw new Error("Guid string contains invalid characters");
414
- return o >>> 0;
415
- }
416
- static writeUInt32LE(r, t, s) {
417
- const n = s >>> 0;
418
- r[t] = n & 255, r[t + 1] = n >>> 8 & 255, r[t + 2] = n >>> 16 & 255, r[t + 3] = n >>> 24 & 255;
419
- }
420
- static writeUInt16LE(r, t, s) {
421
- const n = s & 65535;
422
- r[t] = n & 255, r[t + 1] = n >>> 8 & 255;
423
- }
424
- static readUInt32LE(r, t) {
425
- return (r[t] | r[t + 1] << 8 | r[t + 2] << 16 | r[t + 3] << 24) >>> 0;
426
- }
427
- static readUInt16LE(r, t) {
428
- return (r[t] | r[t + 1] << 8) & 65535;
429
- }
430
- static toHex(r, t) {
431
- return (r >>> 0).toString(16).padStart(t, "0");
432
- }
433
- }
434
- function N(e, r, t) {
435
- if (r.offset >= e.length)
436
- throw new Error(t);
437
- let s = 0, n = 0, o = 0;
438
- for (; r.offset < e.length; ) {
439
- const i = e[r.offset++];
440
- if (o++, s |= (i & 127) << n, (i & 128) === 0) {
441
- if (o !== ct(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(t);
449
- }
450
- function ct(e) {
451
- return e < 128 ? 1 : e < 16384 ? 2 : e < 2097152 ? 3 : e < 268435456 ? 4 : 5;
452
- }
453
- function k(e) {
454
- switch (e) {
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 _e(e) {
474
- if (e === 9 || e === 11 || e === 10 || e === 1)
475
- throw new Error("Dictionary keys must be primitive Teleport types");
476
- }
477
- function S(e, r, t) {
478
- if (r < 0 || t < 0 || r + t > e.length)
479
- throw new Error("Teleport payload exceeds bounds");
480
- }
481
- function ft(e, r) {
482
- return (e[r] | e[r + 1] << 8 | e[r + 2] << 16 | e[r + 3] << 24) >>> 0;
483
- }
484
- function ne(e, r) {
485
- if (r >= e.length)
486
- throw new Error("Array payload exceeds bounds");
487
- const t = e[r], s = t >> 4 & 15;
488
- if ((t & 15) !== 0)
489
- throw new Error("Array flags must be zero");
490
- const n = { offset: r + 1 }, o = N(e, n, "ArrayMalformed"), i = k(s);
491
- if (i >= 0) {
492
- const E = i * o;
493
- return S(e, n.offset, E), n.offset + E - r;
494
- }
495
- let a = n.offset;
496
- for (let E = 0; E < o; E++)
497
- a = Z(s, e, a, "ArrayMalformed");
498
- return a - r;
499
- }
500
- function oe(e, r) {
501
- if (r + 2 > e.length)
502
- throw new Error("Dictionary payload too short");
503
- const t = e[r] >> 4 & 15, s = e[r + 1] >> 4 & 15;
504
- if ((e[r] & 15) !== 0 || (e[r + 1] & 15) !== 0)
505
- throw new Error("Dictionary key/value flags must be zero");
506
- _e(t);
507
- const n = { offset: r + 2 }, o = N(e, n, "DictMalformed");
508
- let i = n.offset;
509
- for (let a = 0; a < o; a++)
510
- i = Z(t, e, i, "DictMalformed"), i = Z(s, e, i, "DictMalformed");
511
- return i - r;
512
- }
513
- function Z(e, r, t, s) {
514
- const n = k(e);
515
- if (n >= 0)
516
- return S(r, t, n), t + n;
517
- switch (e) {
518
- case 12:
519
- case 13: {
520
- const o = { offset: t }, i = N(r, o, s);
521
- return S(r, o.offset, i), o.offset + i;
522
- }
523
- case 11: {
524
- const o = { offset: t }, i = N(r, o, s);
525
- return S(r, o.offset, i), o.offset + i;
526
- }
527
- case 9:
528
- return t + ne(r, t);
529
- case 10:
530
- return t + oe(r, t);
531
- default:
532
- throw new Error(`Unsupported Teleport type ${v[e]}`);
533
- }
534
- }
535
- function ae(e) {
536
- return Array.from(e).map((r) => r.toString(16).padStart(2, "0")).join("");
537
- }
538
- function X(e) {
539
- return e instanceof Uint8Array ? e : new Uint8Array(e);
540
- }
541
- var ce = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.Opus = 1] = "Opus", e[e.Mp3 = 2] = "Mp3", e[e.RawPcm16 = 3] = "RawPcm16", e))(ce || {}), fe = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.MobileWeb = 1] = "MobileWeb", e[e.MobileApp = 2] = "MobileApp", e[e.DesktopWeb = 3] = "DesktopWeb", e[e.DesktopApp = 4] = "DesktopApp", e))(fe || {}), ue = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.Backend = 2] = "Backend", e[e.Server = 4] = "Server", e[e.Plugin = 8] = "Plugin", e[e.Browser = 16] = "Browser", e[e.Native = 32] = "Native", e))(ue || {}), he = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.MessagePack = 1] = "MessagePack", e[e.MemoryPack = 2] = "MemoryPack", e[e.Json = 4] = "Json", e[e.Teleport = 8] = "Teleport", e[e.All = 15] = "All", e))(he || {}), Te = /* @__PURE__ */ ((e) => (e[e.Face = 0] = "Face", e[e.Hands = 1] = "Hands", e[e.Pose = 2] = "Pose", e[e.All = 3] = "All", e))(Te || {}), Ae = /* @__PURE__ */ ((e) => (e[e.Css = 0] = "Css", e[e.Flutter = 1] = "Flutter", e))(Ae || {}), Se = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.Machine = 1] = "Machine", e[e.Human = 2] = "Human", e))(Se || {}), Ne = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.H264 = 1] = "H264", e[e.Vp8 = 2] = "Vp8", e[e.Vp9 = 3] = "Vp9", e[e.Av1 = 4] = "Av1", e))(Ne || {}), de = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.DotNet = 1] = "DotNet", e[e.TypeScript = 2] = "TypeScript", e[e.Cpp = 3] = "Cpp", e[e.Dart = 4] = "Dart", e[e.Rust = 5] = "Rust", e))(de || {}), Ce = /* @__PURE__ */ ((e) => (e[e.Local = 0] = "Local", e[e.Cloud = 1] = "Cloud", e))(Ce || {}), Re = /* @__PURE__ */ ((e) => (e[e.Bundle = 0] = "Bundle", e[e.GitSource = 1] = "GitSource", e))(Re || {}), b = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.CONSTANT_GROUP_BITS = 15] = "CONSTANT_GROUP_BITS", e[e.CONSTANT_GROUP_OFFSET = 16] = "CONSTANT_GROUP_OFFSET", e[e.GROUP_CORE = 65536] = "GROUP_CORE", e[e.CORE_AUTH_RESPONSE = 65537] = "CORE_AUTH_RESPONSE", e[e.CORE_AUTH_TICKET = 65538] = "CORE_AUTH_TICKET", e[e.CORE_GLOBAL_STATE = 65539] = "CORE_GLOBAL_STATE", e[e.CORE_ON_SERVER_STATUS_PING = 65540] = "CORE_ON_SERVER_STATUS_PING", e[e.CORE_ON_USER_JOINED = 65541] = "CORE_ON_USER_JOINED", e[e.CORE_ON_USER_LEFT = 65542] = "CORE_ON_USER_LEFT", e[e.CORE_ON_CLIENT_JOINED = 65543] = "CORE_ON_CLIENT_JOINED", e[e.CORE_ON_CLIENT_LEFT = 65544] = "CORE_ON_CLIENT_LEFT", e[e.CORE_ON_SERVER_STARTED = 65545] = "CORE_ON_SERVER_STARTED", e[e.CORE_ON_SERVER_STOPPED = 65546] = "CORE_ON_SERVER_STOPPED", e[e.CORE_ON_SERVER_STOPPING = 65547] = "CORE_ON_SERVER_STOPPING", e[e.CORE_ON_CLIENT_READY = 65548] = "CORE_ON_CLIENT_READY", e[e.CORE_CLIENT_READY = 65549] = "CORE_CLIENT_READY", e[e.CORE_SERVER_INIT = 65550] = "CORE_SERVER_INIT", e[e.CORE_ON_PLUGIN_RELOADED = 65551] = "CORE_ON_PLUGIN_RELOADED", e[e.CORE_SERVER_START = 65552] = "CORE_SERVER_START", e[e.CORE_SERVER_STOP = 65553] = "CORE_SERVER_STOP", e[e.CORE_ON_HOSTED_SERVER_EXIT = 65554] = "CORE_ON_HOSTED_SERVER_EXIT", e[e.CORE_DYNAMIC_CONFIG = 65555] = "CORE_DYNAMIC_CONFIG", e[e.CORE_PROXY_RPC_AUTH_TICKET = 65556] = "CORE_PROXY_RPC_AUTH_TICKET", e[e.CORE_SERVER_INIT2 = 65557] = "CORE_SERVER_INIT2", e[e.CORE_UPDATE_CLIENT_CONTEXT = 65558] = "CORE_UPDATE_CLIENT_CONTEXT", e[e.CORE_BACKGROUND_WORK_ACTIVE = 65559] = "CORE_BACKGROUND_WORK_ACTIVE", e[e.CORE_RESET_IDLE = 65560] = "CORE_RESET_IDLE", e[e.CORE_CLIENT_DISCONNECTING = 65561] = "CORE_CLIENT_DISCONNECTING", e[e.CORE_ON_APP_READY = 65562] = "CORE_ON_APP_READY", e[e.CORE_ON_FRONTEND_RELOADED = 65563] = "CORE_ON_FRONTEND_RELOADED", e[e.CORE_WEBRTC_OFFER = 65566] = "CORE_WEBRTC_OFFER", e[e.CORE_WEBRTC_ANSWER = 65567] = "CORE_WEBRTC_ANSWER", e[e.CORE_WEBRTC_ICE_CANDIDATE = 65568] = "CORE_WEBRTC_ICE_CANDIDATE", e[e.CORE_WEBRTC_READY = 65569] = "CORE_WEBRTC_READY", e[e.CORE_WEBRTC_AUDIO_SEGMENT = 65570] = "CORE_WEBRTC_AUDIO_SEGMENT", e[e.CORE_WEBRTC_TRACK_MAP = 65571] = "CORE_WEBRTC_TRACK_MAP", e[e.CORE_WEBRTC_VIDEO_CAPTURE = 65572] = "CORE_WEBRTC_VIDEO_CAPTURE", e[e.CORE_WEBRTC_ICE_SERVERS_REQUEST = 65573] = "CORE_WEBRTC_ICE_SERVERS_REQUEST", e[e.CORE_WEBRTC_ICE_SERVERS_RESPONSE = 65574] = "CORE_WEBRTC_ICE_SERVERS_RESPONSE", e[e.CORE_WEBRTC_CLOSE = 65575] = "CORE_WEBRTC_CLOSE", e[e.CORE_RELAY_AGENT_AUTH = 65576] = "CORE_RELAY_AGENT_AUTH", e[e.CORE_RELAY_AGENT_AUTH_RESULT = 65577] = "CORE_RELAY_AGENT_AUTH_RESULT", e[e.CORE_RELAY_HEARTBEAT = 65578] = "CORE_RELAY_HEARTBEAT", e[e.CORE_RELAY_TCP_CONNECTION_OPENED = 65579] = "CORE_RELAY_TCP_CONNECTION_OPENED", e[e.CORE_RELAY_TCP_CONNECTION_CLOSED = 65580] = "CORE_RELAY_TCP_CONNECTION_CLOSED", e[e.CORE_RELAY_TCP_DATA = 65581] = "CORE_RELAY_TCP_DATA", e[e.CORE_RELAY_UDP_DATA = 65582] = "CORE_RELAY_UDP_DATA", e[e.CORE_RELAY_ADD_TUNNEL = 65583] = "CORE_RELAY_ADD_TUNNEL", e[e.CORE_RELAY_TUNNEL_ADDED = 65584] = "CORE_RELAY_TUNNEL_ADDED", e[e.CORE_RELAY_REMOVE_TUNNEL = 65585] = "CORE_RELAY_REMOVE_TUNNEL", e[e.CORE_IKON_SERVER_ENDPOINT_HOST_INFO = 65586] = "CORE_IKON_SERVER_ENDPOINT_HOST_INFO", e[e.CORE_CLIENT_INITIALIZATION = 65587] = "CORE_CLIENT_INITIALIZATION", e[e.CORE_CLIENT_LIFECYCLE_BATCH = 65588] = "CORE_CLIENT_LIFECYCLE_BATCH", e[e.CORE_APP_CONFIG = 65589] = "CORE_APP_CONFIG", e[e.GROUP_KEEPALIVE = 131072] = "GROUP_KEEPALIVE", e[e.KEEPALIVE_REQUEST = 131073] = "KEEPALIVE_REQUEST", e[e.KEEPALIVE_RESPONSE = 131074] = "KEEPALIVE_RESPONSE", e[e.GROUP_EVENTS = 262144] = "GROUP_EVENTS", e[e.EVENTS_PROFILE_UPDATE = 262145] = "EVENTS_PROFILE_UPDATE", e[e.EVENTS_CHANNEL_COMPLETE = 262146] = "EVENTS_CHANNEL_COMPLETE", e[e.EVENTS_SPEECH_PLAYBACK_COMPLETE = 262147] = "EVENTS_SPEECH_PLAYBACK_COMPLETE", e[e.GROUP_ANALYTICS = 524288] = "GROUP_ANALYTICS", e[e.ANALYTICS_LOGS = 524289] = "ANALYTICS_LOGS", e[e.ANALYTICS_EVENTS = 524290] = "ANALYTICS_EVENTS", e[e.ANALYTICS_USAGES = 524291] = "ANALYTICS_USAGES", e[e.ANALYTICS_USAGE = 524292] = "ANALYTICS_USAGE", e[e.ANALYTICS_SPECIAL_LOG = 524293] = "ANALYTICS_SPECIAL_LOG", e[e.ANALYTICS_PROCESSING_UPDATE = 524294] = "ANALYTICS_PROCESSING_UPDATE", e[e.ANALYTICS_REACTIVE_PROCESSING_UPDATE = 524295] = "ANALYTICS_REACTIVE_PROCESSING_UPDATE", e[e.ANALYTICS_IKON_PROXY_SERVER_STATS = 524296] = "ANALYTICS_IKON_PROXY_SERVER_STATS", e[e.ANALYTICS_IKON_RELAY_SERVER_STATS = 524297] = "ANALYTICS_IKON_RELAY_SERVER_STATS", e[e.ANALYTICS_IKON_TURN_SERVER_STATS = 524298] = "ANALYTICS_IKON_TURN_SERVER_STATS", e[e.GROUP_ACTIONS = 1048576] = "GROUP_ACTIONS", e[e.ACTION_CALL = 1048577] = "ACTION_CALL", e[e.ACTION_ACTIVE = 1048578] = "ACTION_ACTIVE", e[e.ACTION_TEXT_OUTPUT = 1048579] = "ACTION_TEXT_OUTPUT", e[e.ACTION_TEXT_OUTPUT_DELTA = 1048580] = "ACTION_TEXT_OUTPUT_DELTA", e[e.ACTION_TEXT_OUTPUT_DELTA_FULL = 1048581] = "ACTION_TEXT_OUTPUT_DELTA_FULL", e[e.ACTION_SET_STATE = 1048582] = "ACTION_SET_STATE", e[e.ACTION_TAP = 1048583] = "ACTION_TAP", e[e.ACTION_PAN = 1048584] = "ACTION_PAN", e[e.ACTION_ZOOM = 1048585] = "ACTION_ZOOM", e[e.ACTION_FILE_UPLOAD_BEGIN = 1048586] = "ACTION_FILE_UPLOAD_BEGIN", e[e.ACTION_FILE_UPLOAD_DATA = 1048587] = "ACTION_FILE_UPLOAD_DATA", e[e.ACTION_FILE_UPLOAD_ACK = 1048588] = "ACTION_FILE_UPLOAD_ACK", e[e.ACTION_FILE_UPLOAD_END = 1048589] = "ACTION_FILE_UPLOAD_END", e[e.ACTION_FILE_UPLOAD_RESULT = 1048590] = "ACTION_FILE_UPLOAD_RESULT", e[e.ACTION_OPEN_CHANNEL = 1048591] = "ACTION_OPEN_CHANNEL", e[e.ACTION_OPEN_EXTERNAL_URL = 1048592] = "ACTION_OPEN_EXTERNAL_URL", e[e.ACTION_FUNCTION_REGISTER = 1048600] = "ACTION_FUNCTION_REGISTER", e[e.ACTION_FUNCTION_CALL = 1048601] = "ACTION_FUNCTION_CALL", e[e.ACTION_FUNCTION_RESULT = 1048602] = "ACTION_FUNCTION_RESULT", e[e.ACTION_GENERATE_ANSWER = 1048603] = "ACTION_GENERATE_ANSWER", e[e.ACTION_REGENERATE_ANSWER = 1048604] = "ACTION_REGENERATE_ANSWER", e[e.ACTION_CLEAR_CHAT_MESSAGE_HISTORY = 1048605] = "ACTION_CLEAR_CHAT_MESSAGE_HISTORY", e[e.ACTION_CLEAR_STATE = 1048606] = "ACTION_CLEAR_STATE", e[e.ACTION_RELOAD_CHANNELS = 1048607] = "ACTION_RELOAD_CHANNELS", e[e.ACTION_RELOAD_PROFILE = 1048608] = "ACTION_RELOAD_PROFILE", e[e.ACTION_CLASSIFICATION_RESULT = 1048609] = "ACTION_CLASSIFICATION_RESULT", e[e.ACTION_AUDIO_STOP = 1048610] = "ACTION_AUDIO_STOP", e[e.ACTION_CALL_TEXT = 1048611] = "ACTION_CALL_TEXT", e[e.ACTION_RELOAD_APPLICATION = 1048612] = "ACTION_RELOAD_APPLICATION", e[e.ACTION_CANCEL_GENERATION = 1048613] = "ACTION_CANCEL_GENERATION", e[e.ACTION_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", e[e.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", e[e.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", e[e.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", e[e.ACTION_STOP_SOUND = 1048623] = "ACTION_STOP_SOUND", e[e.ACTION_START_RECORDING = 1048624] = "ACTION_START_RECORDING", e[e.ACTION_STOP_RECORDING = 1048625] = "ACTION_STOP_RECORDING", e[e.ACTION_FUNCTION_ENUMERATION_ITEM = 1048627] = "ACTION_FUNCTION_ENUMERATION_ITEM", e[e.ACTION_FUNCTION_ENUMERATION_END = 1048628] = "ACTION_FUNCTION_ENUMERATION_END", e[e.ACTION_FUNCTION_CANCEL = 1048629] = "ACTION_FUNCTION_CANCEL", e[e.ACTION_FUNCTION_DISPOSE = 1048630] = "ACTION_FUNCTION_DISPOSE", e[e.ACTION_FUNCTION_ERROR = 1048631] = "ACTION_FUNCTION_ERROR", e[e.ACTION_FUNCTION_ACK = 1048632] = "ACTION_FUNCTION_ACK", e[e.ACTION_FUNCTION_AWAITING_APPROVAL = 1048633] = "ACTION_FUNCTION_AWAITING_APPROVAL", e[e.ACTION_FUNCTION_APPROVAL_REQUIRED = 1048634] = "ACTION_FUNCTION_APPROVAL_REQUIRED", e[e.ACTION_FUNCTION_APPROVAL_RESPONSE = 1048635] = "ACTION_FUNCTION_APPROVAL_RESPONSE", e[e.UI_UPDATE_ACK = 1048636] = "UI_UPDATE_ACK", e[e.ACTION_CALL2 = 1048637] = "ACTION_CALL2", e[e.ACTION_FUNCTION_REGISTER_BATCH = 1048638] = "ACTION_FUNCTION_REGISTER_BATCH", e[e.ACTION_TRIGGER_GIT_PULL = 1048639] = "ACTION_TRIGGER_GIT_PULL", e[e.ACTION_FILE_UPLOAD_CALLBACK = 1048640] = "ACTION_FILE_UPLOAD_CALLBACK", e[e.ACTION_CUSTOM_USER_MESSAGE = 1048641] = "ACTION_CUSTOM_USER_MESSAGE", e[e.ACTION_URL_CHANGED = 1048642] = "ACTION_URL_CHANGED", e[e.ACTION_FILE_UPLOAD_PRE_START2 = 1048643] = "ACTION_FILE_UPLOAD_PRE_START2", e[e.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2 = 1048644] = "ACTION_FILE_UPLOAD_PRE_START_RESPONSE2", e[e.ACTION_FILE_UPLOAD_START2 = 1048645] = "ACTION_FILE_UPLOAD_START2", e[e.ACTION_FILE_UPLOAD_START_RESPONSE2 = 1048646] = "ACTION_FILE_UPLOAD_START_RESPONSE2", e[e.ACTION_FILE_UPLOAD_DATA2 = 1048647] = "ACTION_FILE_UPLOAD_DATA2", e[e.ACTION_FILE_UPLOAD_ACK2 = 1048648] = "ACTION_FILE_UPLOAD_ACK2", e[e.ACTION_FILE_UPLOAD_END2 = 1048649] = "ACTION_FILE_UPLOAD_END2", e[e.ACTION_FILE_UPLOAD_COMPLETE2 = 1048650] = "ACTION_FILE_UPLOAD_COMPLETE2", e[e.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH = 1048651] = "ACTION_FUNCTION_ENUMERATION_ITEM_BATCH", e[e.ACTION_CALL_ACK = 1048652] = "ACTION_CALL_ACK", e[e.ACTION_TRIGGER_CRON = 1048653] = "ACTION_TRIGGER_CRON", e[e.ACTION_RESULT = 1048654] = "ACTION_RESULT", e[e.UI_RESYNC_REQUEST = 1048655] = "UI_RESYNC_REQUEST", e[e.GROUP_UI = 2097152] = "GROUP_UI", e[e.UI_STREAM_BEGIN = 2097153] = "UI_STREAM_BEGIN", e[e.UI_STREAM_END = 2097154] = "UI_STREAM_END", e[e.UI_STYLES = 2097188] = "UI_STYLES", e[e.UI_UPDATE = 2097190] = "UI_UPDATE", e[e.UI_STYLES_BATCH = 2097192] = "UI_STYLES_BATCH", e[e.UI_STYLES_DELETE = 2097193] = "UI_STYLES_DELETE", e[e.GROUP_COMMON = 4128768] = "GROUP_COMMON", e[e.GROUP_AUDIO = 4194304] = "GROUP_AUDIO", e[e.AUDIO_STREAM_BEGIN = 4194305] = "AUDIO_STREAM_BEGIN", e[e.AUDIO_STREAM_END = 4194306] = "AUDIO_STREAM_END", e[e.AUDIO_FRAME = 4194307] = "AUDIO_FRAME", e[e.AUDIO_FRAME_VOLUME = 4194308] = "AUDIO_FRAME_VOLUME", e[e.AUDIO_FRAME2 = 4194309] = "AUDIO_FRAME2", e[e.AUDIO_SHAPE_FRAME = 4194310] = "AUDIO_SHAPE_FRAME", e[e.GROUP_VIDEO = 8388608] = "GROUP_VIDEO", e[e.VIDEO_STREAM_BEGIN = 8388609] = "VIDEO_STREAM_BEGIN", e[e.VIDEO_STREAM_END = 8388610] = "VIDEO_STREAM_END", e[e.VIDEO_FRAME = 8388611] = "VIDEO_FRAME", e[e.VIDEO_REQUEST_IDR_FRAME = 8388612] = "VIDEO_REQUEST_IDR_FRAME", e[e.VIDEO_INVALIDATE_FRAME = 8388613] = "VIDEO_INVALIDATE_FRAME", e[e.GROUP_TRACKING = 16777216] = "GROUP_TRACKING", e[e.TRACKING_STREAM_BEGIN = 16777217] = "TRACKING_STREAM_BEGIN", e[e.TRACKING_STREAM_END = 16777218] = "TRACKING_STREAM_END", e[e.TRACKING_FRAME = 16777219] = "TRACKING_FRAME", e[e.GROUP_SCENE = 33554432] = "GROUP_SCENE", e[e.SCENE_MESH = 33554433] = "SCENE_MESH", e[e.SCENE_ARRAY = 33554434] = "SCENE_ARRAY", e[e.GROUP_ALL = 67043328] = "GROUP_ALL", e[e.GROUP_APP_LOCAL = 1073741824] = "GROUP_APP_LOCAL", e[e.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", e))(b || {});
542
- const ut = 161083277, ht = 265814330, Tt = 1368629611, At = 2431514951, St = 2514959030, Nt = 2745379226, dt = 3282782683, Ct = 3284746250, Rt = 4101844078;
543
- function we(e) {
544
- const r = {};
545
- return De(r), r;
546
- }
547
- function De(e) {
548
- return e.StreamId = "", e.Description = "", e.SourceType = "", e.Codec = ce.Unknown, e.CodecDetails = "", e.SampleRate = 0, e.Channels = 0, e.ShapeSets = void 0, e.CorrelationId = void 0, e;
549
- }
550
- function wt(e, r) {
551
- const t = r ?? we();
552
- return De(t), Dt(e, t), t;
553
- }
554
- function Dt(e, r) {
555
- let t;
556
- for (; (t = e.next()) !== null; )
557
- switch (t.fieldId) {
558
- case ut: {
559
- if (t.isNull) throw new Error();
560
- r.StreamId = t.asString();
561
- break;
562
- }
563
- case ht: {
564
- if (t.isNull) {
565
- r.ShapeSets = void 0;
566
- break;
567
- }
568
- r.ShapeSets = yt(t.asArray());
569
- break;
570
- }
571
- case Tt: {
572
- if (t.isNull) throw new Error();
573
- r.Description = t.asString();
574
- break;
575
- }
576
- case At: {
577
- if (t.isNull) throw new Error();
578
- r.Channels = t.asInt32();
579
- break;
580
- }
581
- case St: {
582
- if (t.isNull) {
583
- r.CorrelationId = void 0;
584
- break;
585
- }
586
- r.CorrelationId = t.asString();
587
- break;
588
- }
589
- case Nt: {
590
- if (t.isNull) throw new Error();
591
- r.CodecDetails = t.asString();
592
- break;
593
- }
594
- case dt: {
595
- if (t.isNull) throw new Error();
596
- r.SourceType = t.asString();
597
- break;
598
- }
599
- case Ct: {
600
- if (t.isNull) throw new Error();
601
- r.Codec = t.asInt32();
602
- break;
603
- }
604
- case Rt: {
605
- if (t.isNull) throw new Error();
606
- r.SampleRate = t.asInt32();
607
- break;
608
- }
609
- }
610
- }
611
- function yt(e) {
612
- const r = [];
613
- let t;
614
- for (; (t = e.next()) !== null; )
615
- r.push(gt(t.asObject()));
616
- return r;
617
- }
618
- const Lt = 1107713536, Ut = 1154362099, Ot = 1185721362;
619
- function mt(e) {
620
- const r = {};
621
- return ye(r), r;
622
- }
623
- function ye(e) {
624
- return e.SetId = 0, e.Name = "", e.ShapeNames = [], e;
625
- }
626
- function gt(e, r) {
627
- const t = r ?? mt();
628
- return ye(t), Pt(e, t), t;
629
- }
630
- function Pt(e, r) {
631
- let t;
632
- for (; (t = e.next()) !== null; )
633
- switch (t.fieldId) {
634
- case Lt: {
635
- if (t.isNull) throw new Error();
636
- r.Name = t.asString();
637
- break;
638
- }
639
- case Ut: {
640
- if (t.isNull) throw new Error();
641
- r.SetId = t.asUInt32();
642
- break;
643
- }
644
- case Ot: {
645
- if (t.isNull) throw new Error();
646
- r.ShapeNames = Ft(t.asArray());
647
- break;
648
- }
649
- }
650
- }
651
- function Ft(e) {
652
- const r = [];
653
- let t;
654
- for (; (t = e.next()) !== null; )
655
- r.push(t.asString());
656
- return r;
657
- }
658
- const bt = 76337612, Mt = 185396121, vt = 250031587, kt = 388632637, pt = 417197284, Vt = 425972532, Gt = 469070965, Bt = 470595159, xt = 594855258, Ht = 617065367, Yt = 661691032, $t = 781727218, Kt = 834078886, jt = 1043273762, Xt = 1236999138, Wt = 1286979607, zt = 1368629611, Jt = 1437068682, Qt = 1668375353, qt = 1715899485, Zt = 1942830531, er = 1999510636, tr = 2033288346, rr = 2079864626, sr = 2142346422, nr = 2228539873, or = 2232517119, ir = 2598291686, ar = 2719718823, lr = 2810953526, Er = 2840065720, Ir = 2885165957, _r = 3542818975, cr = 3586157513, fr = 3717933110;
659
- function ur(e) {
660
- const r = {};
661
- return Le(r), r;
662
- }
663
- function Le(e) {
664
- return e.ContextType = ue.Unknown, e.UserType = Se.Unknown, e.PayloadType = he.Unknown, e.Description = "", e.UserId = "", e.DeviceId = "", e.ProductId = "", e.VersionId = "", e.InstallId = "", e.Locale = "", e.SessionId = -1, e.IsInternal = !1, e.IsSnapshot = !1, e.IsReady = !1, e.HasInput = !1, e.ChannelLocale = "", e.AuthSessionId = "", e.ReceiveAllMessages = !1, e.PreciseJoinedAt = 0n, e.UserAgent = "", e.ClientType = fe.Unknown, e.UniqueSessionId = "", e.Parameters = /* @__PURE__ */ Object.create(null), e.SdkType = de.Unknown, e.SdkCapability = 0, e.ViewportWidth = 0, e.ViewportHeight = 0, e.Theme = "", e.Timezone = "", e.IsTouchDevice = !1, e.InitialPath = "", e.StyleFormat = Ae.Css, e.SupportsCompression = !0, e.IsSoftDisconnected = !1, e.SoftDisconnectAt = 0n, e;
665
- }
666
- function hr(e, r) {
667
- const t = r ?? ur();
668
- return Le(t), Tr(e, t), t;
669
- }
670
- function Tr(e, r) {
671
- let t;
672
- for (; (t = e.next()) !== null; )
673
- switch (t.fieldId) {
674
- case bt: {
675
- if (t.isNull) throw new Error();
676
- r.DeviceId = t.asString();
677
- break;
678
- }
679
- case Mt: {
680
- if (t.isNull) throw new Error();
681
- r.InstallId = t.asString();
682
- break;
683
- }
684
- case vt: {
685
- if (t.isNull) throw new Error();
686
- r.Theme = t.asString();
687
- break;
688
- }
689
- case kt: {
690
- if (t.isNull) throw new Error();
691
- r.UserAgent = t.asString();
692
- break;
693
- }
694
- case pt: {
695
- if (t.isNull) throw new Error();
696
- r.ContextType = t.asInt32();
697
- break;
698
- }
699
- case Vt: {
700
- if (t.isNull) throw new Error();
701
- r.SoftDisconnectAt = t.asUInt64();
702
- break;
703
- }
704
- case Gt: {
705
- if (t.isNull) throw new Error();
706
- r.HasInput = t.asBool();
707
- break;
708
- }
709
- case Bt: {
710
- if (t.isNull) throw new Error();
711
- r.UserType = t.asInt32();
712
- break;
713
- }
714
- case xt: {
715
- if (t.isNull) throw new Error();
716
- r.InitialPath = t.asString();
717
- break;
718
- }
719
- case Ht: {
720
- if (t.isNull) throw new Error();
721
- r.IsSoftDisconnected = t.asBool();
722
- break;
723
- }
724
- case Yt: {
725
- if (t.isNull) throw new Error();
726
- r.SupportsCompression = t.asBool();
727
- break;
728
- }
729
- case $t: {
730
- if (t.isNull) throw new Error();
731
- r.UserId = t.asString();
732
- break;
733
- }
734
- case Kt: {
735
- if (t.isNull) throw new Error();
736
- r.ProductId = t.asString();
737
- break;
738
- }
739
- case jt: {
740
- if (t.isNull) throw new Error();
741
- r.AuthSessionId = t.asString();
742
- break;
743
- }
744
- case Xt: {
745
- if (t.isNull) throw new Error();
746
- r.ReceiveAllMessages = t.asBool();
747
- break;
748
- }
749
- case Wt: {
750
- if (t.isNull) throw new Error();
751
- r.ViewportHeight = t.asInt32();
752
- break;
753
- }
754
- case zt: {
755
- if (t.isNull) throw new Error();
756
- r.Description = t.asString();
757
- break;
758
- }
759
- case Jt: {
760
- if (t.isNull) throw new Error();
761
- r.SdkCapability = t.asInt32();
762
- break;
763
- }
764
- case Qt: {
765
- if (t.isNull) throw new Error();
766
- r.IsSnapshot = t.asBool();
767
- break;
768
- }
769
- case qt: {
770
- if (t.isNull) throw new Error();
771
- r.Locale = t.asString();
772
- break;
773
- }
774
- case Zt: {
775
- if (t.isNull) throw new Error();
776
- r.SdkType = t.asInt32();
777
- break;
778
- }
779
- case er: {
780
- if (t.isNull) throw new Error();
781
- r.SessionId = t.asInt32();
782
- break;
783
- }
784
- case tr: {
785
- if (t.isNull) throw new Error();
786
- r.ViewportWidth = t.asInt32();
787
- break;
788
- }
789
- case rr: {
790
- if (t.isNull) throw new Error();
791
- r.PreciseJoinedAt = t.asUInt64();
792
- break;
793
- }
794
- case sr: {
795
- if (t.isNull) throw new Error();
796
- r.PayloadType = t.asInt32();
797
- break;
798
- }
799
- case nr: {
800
- if (t.isNull) throw new Error();
801
- r.StyleFormat = t.asInt32();
802
- break;
803
- }
804
- case or: {
805
- if (t.isNull) throw new Error();
806
- r.IsTouchDevice = t.asBool();
807
- break;
808
- }
809
- case ir: {
810
- if (t.isNull) throw new Error();
811
- r.VersionId = t.asString();
812
- break;
813
- }
814
- case ar: {
815
- if (t.isNull) throw new Error();
816
- r.UniqueSessionId = t.asString();
817
- break;
818
- }
819
- case lr: {
820
- if (t.isNull) throw new Error();
821
- r.ClientType = t.asInt32();
822
- break;
823
- }
824
- case Er: {
825
- if (t.isNull) throw new Error();
826
- r.IsReady = t.asBool();
827
- break;
828
- }
829
- case Ir: {
830
- if (t.isNull) throw new Error();
831
- r.Parameters = Ar(t.asDictionary());
832
- break;
833
- }
834
- case _r: {
835
- if (t.isNull) throw new Error();
836
- r.Timezone = t.asString();
837
- break;
838
- }
839
- case cr: {
840
- if (t.isNull) throw new Error();
841
- r.IsInternal = t.asBool();
842
- break;
843
- }
844
- case fr: {
845
- if (t.isNull) throw new Error();
846
- r.ChannelLocale = t.asString();
847
- break;
848
- }
849
- }
850
- }
851
- function Ar(e) {
852
- const r = /* @__PURE__ */ Object.create(null);
853
- let t;
854
- for (; (t = e.next()) !== null; ) {
855
- const s = t.key.asString();
856
- r[s] = t.value.asString();
857
- }
858
- return r;
859
- }
860
- const Sr = 703025676, Nr = 814454131, dr = 972460562, Cr = 976255570, Rr = 1368629611, wr = 1479280922, Dr = 1533537016, yr = 1909301063, Lr = 2274386296, Ur = 2603556958, Or = 2885165957, mr = 3568439632;
861
- function gr(e) {
862
- const r = {};
863
- return Ue(r), r;
864
- }
865
- function Ue(e) {
866
- return e.FunctionId = T.fromBytes(new Uint8Array(16)), e.FunctionName = "", e.Parameters = [], e.ResultTypeName = "", e.IsEnumerable = !1, e.EnumerableItemTypeName = "", e.IsCancellable = !1, e.Description = "", e.LlmInlineResult = !1, e.LlmCallOnlyOnce = !1, e.RequiresInstance = !1, e.Versions = [], e;
867
- }
868
- function Pr(e, r) {
869
- const t = r ?? gr();
870
- return Ue(t), Fr(e, t), t;
871
- }
872
- function Fr(e, r) {
873
- let t;
874
- for (; (t = e.next()) !== null; )
875
- switch (t.fieldId) {
876
- case Sr: {
877
- if (t.isNull) throw new Error();
878
- r.ResultTypeName = t.asString();
879
- break;
880
- }
881
- case Nr: {
882
- if (t.isNull) throw new Error();
883
- r.FunctionName = t.asString();
884
- break;
885
- }
886
- case dr: {
887
- if (t.isNull) throw new Error();
888
- r.EnumerableItemTypeName = t.asString();
889
- break;
890
- }
891
- case Cr: {
892
- if (t.isNull) throw new Error();
893
- r.FunctionId = t.asGuid();
894
- break;
895
- }
896
- case Rr: {
897
- if (t.isNull) throw new Error();
898
- r.Description = t.asString();
899
- break;
900
- }
901
- case wr: {
902
- if (t.isNull) throw new Error();
903
- r.IsCancellable = t.asBool();
904
- break;
905
- }
906
- case Dr: {
907
- if (t.isNull) throw new Error();
908
- r.RequiresInstance = t.asBool();
909
- break;
910
- }
911
- case yr: {
912
- if (t.isNull) throw new Error();
913
- r.Versions = br(t.asArray());
914
- break;
915
- }
916
- case Lr: {
917
- if (t.isNull) throw new Error();
918
- r.LlmInlineResult = t.asBool();
919
- break;
920
- }
921
- case Ur: {
922
- if (t.isNull) throw new Error();
923
- r.IsEnumerable = t.asBool();
924
- break;
925
- }
926
- case Or: {
927
- if (t.isNull) throw new Error();
928
- r.Parameters = Mr(t.asArray());
929
- break;
930
- }
931
- case mr: {
932
- if (t.isNull) throw new Error();
933
- r.LlmCallOnlyOnce = t.asBool();
934
- break;
935
- }
936
- }
937
- }
938
- function br(e) {
939
- const r = [];
940
- let t;
941
- for (; (t = e.next()) !== null; )
942
- r.push(t.asString());
943
- return r;
944
- }
945
- function Mr(e) {
946
- const r = [];
947
- let t;
948
- for (; (t = e.next()) !== null; )
949
- r.push(Kr(t.asObject()));
950
- return r;
951
- }
952
- const vr = 607861992, kr = 894485888, pr = 972460562, Vr = 1368629611, Gr = 1883521406, Br = 2603556958, xr = 3609695522, Hr = 4075263697, Yr = 4257460908;
953
- function $r(e) {
954
- const r = {};
955
- return Oe(r), r;
956
- }
957
- function Oe(e) {
958
- return e.ParameterIndex = 0, e.ParameterName = "", e.TypeName = "", e.HasDefaultValue = !1, e.DefaultValueJson = "", e.DefaultValueData = new Uint8Array(0), e.IsEnumerable = !1, e.EnumerableItemTypeName = "", e.Description = "", e;
959
- }
960
- function Kr(e, r) {
961
- const t = r ?? $r();
962
- return Oe(t), jr(e, t), t;
963
- }
964
- function jr(e, r) {
965
- let t;
966
- for (; (t = e.next()) !== null; )
967
- switch (t.fieldId) {
968
- case vr: {
969
- if (t.isNull) throw new Error();
970
- r.HasDefaultValue = t.asBool();
971
- break;
972
- }
973
- case kr: {
974
- if (t.isNull) throw new Error();
975
- r.DefaultValueJson = t.asString();
976
- break;
977
- }
978
- case pr: {
979
- if (t.isNull) throw new Error();
980
- r.EnumerableItemTypeName = t.asString();
981
- break;
982
- }
983
- case Vr: {
984
- if (t.isNull) throw new Error();
985
- r.Description = t.asString();
986
- break;
987
- }
988
- case Gr: {
989
- if (t.isNull) throw new Error();
990
- r.DefaultValueData = t.asBinary();
991
- break;
992
- }
993
- case Br: {
994
- if (t.isNull) throw new Error();
995
- r.IsEnumerable = t.asBool();
996
- break;
997
- }
998
- case xr: {
999
- if (t.isNull) throw new Error();
1000
- r.TypeName = t.asString();
1001
- break;
1002
- }
1003
- case Hr: {
1004
- if (t.isNull) throw new Error();
1005
- r.ParameterName = t.asString();
1006
- break;
1007
- }
1008
- case Yr: {
1009
- if (t.isNull) throw new Error();
1010
- r.ParameterIndex = t.asInt32();
1011
- break;
1012
- }
1013
- }
1014
- }
1015
- const Xr = 3167053791, Wr = 3342364356, zr = 3612929027;
1016
- function me(e) {
1017
- const r = {};
1018
- return ge(r), r;
1019
- }
1020
- function ge(e) {
1021
- return e.Category = "", e.Type = Te.Face, e.FaceBlendshapes = [], e;
1022
- }
1023
- function Jr(e, r) {
1024
- const t = r ?? me();
1025
- return ge(t), Qr(e, t), t;
1026
- }
1027
- function Qr(e, r) {
1028
- let t;
1029
- for (; (t = e.next()) !== null; )
1030
- switch (t.fieldId) {
1031
- case Xr: {
1032
- if (t.isNull) throw new Error();
1033
- r.Type = t.asInt32();
1034
- break;
1035
- }
1036
- case Wr: {
1037
- if (t.isNull) throw new Error();
1038
- r.FaceBlendshapes = qr(t.asArray());
1039
- break;
1040
- }
1041
- case zr: {
1042
- if (t.isNull) throw new Error();
1043
- r.Category = t.asString();
1044
- break;
1045
- }
1046
- }
1047
- }
1048
- function qr(e) {
1049
- const r = [];
1050
- let t;
1051
- for (; (t = e.next()) !== null; )
1052
- r.push(t.asString());
1053
- return r;
1054
- }
1055
- const Zr = 1405462580, es = 2968276160;
1056
- function ts(e) {
1057
- const r = {};
1058
- return Pe(r), r;
1059
- }
1060
- function Pe(e) {
1061
- return e.MimeType = "", e.Value = new Uint8Array(0), e;
1062
- }
1063
- function rs(e, r) {
1064
- const t = r ?? ts();
1065
- return Pe(t), ss(e, t), t;
1066
- }
1067
- function ss(e, r) {
1068
- let t;
1069
- for (; (t = e.next()) !== null; )
1070
- switch (t.fieldId) {
1071
- case Zr: {
1072
- if (t.isNull) throw new Error();
1073
- r.Value = t.asBinary();
1074
- break;
1075
- }
1076
- case es: {
1077
- if (t.isNull) throw new Error();
1078
- r.MimeType = t.asString();
1079
- break;
1080
- }
1081
- }
1082
- }
1083
- const ns = 3612929027;
1084
- function Fe(e) {
1085
- const r = {};
1086
- return be(r), r;
1087
- }
1088
- function be(e) {
1089
- return e.Category = "", e;
1090
- }
1091
- function os(e, r) {
1092
- const t = r ?? Fe();
1093
- return be(t), is(e, t), t;
1094
- }
1095
- function is(e, r) {
1096
- let t;
1097
- for (; (t = e.next()) !== null; )
1098
- switch (t.fieldId) {
1099
- case ns: {
1100
- if (t.isNull) throw new Error();
1101
- r.Category = t.asString();
1102
- break;
1103
- }
1104
- }
1105
- }
1106
- const as = 2097188, ls = 979822885, Es = 2374537704;
1107
- function Is(e) {
1108
- const r = {};
1109
- return Me(r), r;
1110
- }
1111
- function Me(e) {
1112
- return e.StyleId = "", e.Style = /* @__PURE__ */ Object.create(null), e;
1113
- }
1114
- function _s(e, r) {
1115
- const t = g.create(e);
1116
- return cs(t, r);
1117
- }
1118
- function cs(e, r) {
1119
- const t = r ?? Is();
1120
- return Me(t), fs(e, t), t;
1121
- }
1122
- function fs(e, r) {
1123
- let t;
1124
- for (; (t = e.next()) !== null; )
1125
- switch (t.fieldId) {
1126
- case ls: {
1127
- if (t.isNull) throw new Error();
1128
- r.StyleId = t.asString();
1129
- break;
1130
- }
1131
- case Es: {
1132
- if (t.isNull) throw new Error();
1133
- r.Style = hs(t.asDictionary());
1134
- break;
1135
- }
1136
- }
1137
- }
1138
- async function us(e, r) {
1139
- const t = await j(e, as);
1140
- return _s(t, r);
1141
- }
1142
- function hs(e) {
1143
- const r = /* @__PURE__ */ Object.create(null);
1144
- let t;
1145
- for (; (t = e.next()) !== null; ) {
1146
- const s = t.key.asString();
1147
- r[s] = t.value.asString();
1148
- }
1149
- return r;
1150
- }
1151
- const Ts = 2097192, As = 2136687806;
1152
- function Ss(e) {
1153
- const r = {};
1154
- return ve(r), r;
1155
- }
1156
- function ve(e) {
1157
- return e.Styles = [], e;
1158
- }
1159
- function Ns(e, r) {
1160
- const t = g.create(e);
1161
- return ds(t, r);
1162
- }
1163
- function ds(e, r) {
1164
- const t = r ?? Ss();
1165
- return ve(t), Cs(e, t), t;
1166
- }
1167
- function Cs(e, r) {
1168
- let t;
1169
- for (; (t = e.next()) !== null; )
1170
- switch (t.fieldId) {
1171
- case As: {
1172
- if (t.isNull) throw new Error();
1173
- r.Styles = ws(t.asArray());
1174
- break;
1175
- }
1176
- }
1177
- }
1178
- async function Rs(e, r) {
1179
- const t = await j(e, Ts);
1180
- return Ns(t, r);
1181
- }
1182
- function ws(e) {
1183
- const r = [];
1184
- let t;
1185
- for (; (t = e.next()) !== null; )
1186
- r.push(Us(t.asObject()));
1187
- return r;
1188
- }
1189
- const Ds = 979822885, ys = 2374537704;
1190
- function Ls(e) {
1191
- const r = {};
1192
- return ke(r), r;
1193
- }
1194
- function ke(e) {
1195
- return e.StyleId = "", e.Style = /* @__PURE__ */ Object.create(null), e;
1196
- }
1197
- function Us(e, r) {
1198
- const t = r ?? Ls();
1199
- return ke(t), Os(e, t), t;
1200
- }
1201
- function Os(e, r) {
1202
- let t;
1203
- for (; (t = e.next()) !== null; )
1204
- switch (t.fieldId) {
1205
- case Ds: {
1206
- if (t.isNull) throw new Error();
1207
- r.StyleId = t.asString();
1208
- break;
1209
- }
1210
- case ys: {
1211
- if (t.isNull) throw new Error();
1212
- r.Style = ms(t.asDictionary());
1213
- break;
1214
- }
1215
- }
1216
- }
1217
- function ms(e) {
1218
- const r = /* @__PURE__ */ Object.create(null);
1219
- let t;
1220
- for (; (t = e.next()) !== null; ) {
1221
- const s = t.key.asString();
1222
- r[s] = t.value.asString();
1223
- }
1224
- return r;
1225
- }
1226
- const gs = 2097193, Ps = 1415642792;
1227
- function Fs(e) {
1228
- const r = {};
1229
- return pe(r), r;
1230
- }
1231
- function pe(e) {
1232
- return e.StyleIds = [], e;
1233
- }
1234
- function bs(e, r) {
1235
- const t = g.create(e);
1236
- return Ms(t, r);
1237
- }
1238
- function Ms(e, r) {
1239
- const t = r ?? Fs();
1240
- return pe(t), vs(e, t), t;
1241
- }
1242
- function vs(e, r) {
1243
- let t;
1244
- for (; (t = e.next()) !== null; )
1245
- switch (t.fieldId) {
1246
- case Ps: {
1247
- if (t.isNull) throw new Error();
1248
- r.StyleIds = ps(t.asArray());
1249
- break;
1250
- }
1251
- }
1252
- }
1253
- async function ks(e, r) {
1254
- const t = await j(e, gs);
1255
- return bs(t, r);
1256
- }
1257
- function ps(e) {
1258
- const r = [];
1259
- let t;
1260
- for (; (t = e.next()) !== null; )
1261
- r.push(t.asString());
1262
- return r;
1263
- }
1264
- const Vs = 2097190, Gs = 425183262, Bs = 653781469;
1265
- function xs(e) {
1266
- const r = {};
1267
- return Ve(r), r;
1268
- }
1269
- function Ve(e) {
1270
- return e.Json = "", e.Payloads = /* @__PURE__ */ Object.create(null), e;
1271
- }
1272
- function Hs(e, r) {
1273
- const t = g.create(e);
1274
- return Ys(t, r);
1275
- }
1276
- function Ys(e, r) {
1277
- const t = r ?? xs();
1278
- return Ve(t), $s(e, t), t;
1279
- }
1280
- function $s(e, r) {
1281
- let t;
1282
- for (; (t = e.next()) !== null; )
1283
- switch (t.fieldId) {
1284
- case Gs: {
1285
- if (t.isNull) throw new Error();
1286
- r.Json = t.asString();
1287
- break;
1288
- }
1289
- case Bs: {
1290
- if (t.isNull) throw new Error();
1291
- r.Payloads = js(t.asDictionary());
1292
- break;
1293
- }
1294
- }
1295
- }
1296
- async function Ks(e, r) {
1297
- const t = await j(e, Vs);
1298
- return Hs(t, r);
1299
- }
1300
- function js(e) {
1301
- const r = /* @__PURE__ */ Object.create(null);
1302
- let t;
1303
- for (; (t = e.next()) !== null; ) {
1304
- const s = t.key.asString();
1305
- r[s] = rs(t.value.asObject());
1306
- }
1307
- return r;
1308
- }
1309
- const Xs = 161083277, Ws = 164808083, zs = 1368629611, Js = 2514959030, Qs = 2745379226, qs = 2950031986, Zs = 3282782683, en = 3284746250, tn = 4065070594;
1310
- function Ge(e) {
1311
- const r = {};
1312
- return Be(r), r;
1313
- }
1314
- function Be(e) {
1315
- return e.StreamId = "", e.Description = "", e.SourceType = "", e.Codec = Ne.H264, e.CodecDetails = "", e.Width = 0, e.Height = 0, e.Framerate = 30, e.CorrelationId = void 0, e;
1316
- }
1317
- function rn(e, r) {
1318
- const t = r ?? Ge();
1319
- return Be(t), sn(e, t), t;
1320
- }
1321
- function sn(e, r) {
1322
- let t;
1323
- for (; (t = e.next()) !== null; )
1324
- switch (t.fieldId) {
1325
- case Xs: {
1326
- if (t.isNull) throw new Error();
1327
- r.StreamId = t.asString();
1328
- break;
1329
- }
1330
- case Ws: {
1331
- if (t.isNull) throw new Error();
1332
- r.Framerate = t.asFloat64();
1333
- break;
1334
- }
1335
- case zs: {
1336
- if (t.isNull) throw new Error();
1337
- r.Description = t.asString();
1338
- break;
1339
- }
1340
- case Js: {
1341
- if (t.isNull) {
1342
- r.CorrelationId = void 0;
1343
- break;
1344
- }
1345
- r.CorrelationId = t.asString();
1346
- break;
1347
- }
1348
- case Qs: {
1349
- if (t.isNull) throw new Error();
1350
- r.CodecDetails = t.asString();
1351
- break;
1352
- }
1353
- case qs: {
1354
- if (t.isNull) throw new Error();
1355
- r.Height = t.asInt32();
1356
- break;
1357
- }
1358
- case Zs: {
1359
- if (t.isNull) throw new Error();
1360
- r.SourceType = t.asString();
1361
- break;
1362
- }
1363
- case en: {
1364
- if (t.isNull) throw new Error();
1365
- r.Codec = t.asInt32();
1366
- break;
1367
- }
1368
- case tn: {
1369
- if (t.isNull) throw new Error();
1370
- r.Width = t.asInt32();
1371
- break;
1372
- }
1373
- }
1374
- }
1375
- const nn = 65539, on = 693643444, an = 976837618, ln = 1144553441, En = 1497620243, In = 1559330978, _n = 1976546434, cn = 2271236852, fn = 2277643855, un = 2469008121, hn = 3042922213, Tn = 3064612128, An = 3219210453, Sn = 3504054055, Nn = 3678477544, dn = 3696445035, Cn = 3707543140, Rn = 3712281496, wn = 3895362455, Dn = 3897397815, yn = 3914217035, Ln = 4225107827;
1376
- function Un(e) {
1377
- const r = {};
1378
- return xe(r), r;
1379
- }
1380
- function xe(e) {
1381
- return e.Clients = /* @__PURE__ */ Object.create(null), e.Functions = /* @__PURE__ */ Object.create(null), e.UIStreams = /* @__PURE__ */ Object.create(null), e.AudioStreams = /* @__PURE__ */ Object.create(null), e.VideoStreams = /* @__PURE__ */ Object.create(null), e.TrackingStreams = /* @__PURE__ */ Object.create(null), e.SpaceId = "", e.ChannelId = "", e.ServerSessionId = "", e.SessionHash = "", e.ChannelUrl = "", e.SessionChannelUrl = "", e.FirstUserId = "", e.PrimaryUserId = "", e.OrganisationName = "", e.SpaceName = "", e.ChannelName = "", e.ServerRunType = Ce.Local, e.AppSourceType = Re.Bundle, e.PublicAccess = !1, e.DebugMode = !1, e;
1382
- }
1383
- function On(e, r) {
1384
- const t = g.create(e);
1385
- return mn(t, r);
1386
- }
1387
- function mn(e, r) {
1388
- const t = r ?? Un();
1389
- return xe(t), gn(e, t), t;
1390
- }
1391
- function gn(e, r) {
1392
- let t;
1393
- for (; (t = e.next()) !== null; )
1394
- switch (t.fieldId) {
1395
- case on: {
1396
- if (t.isNull) throw new Error();
1397
- r.FirstUserId = t.asString();
1398
- break;
1399
- }
1400
- case an: {
1401
- if (t.isNull) throw new Error();
1402
- r.SessionHash = t.asString();
1403
- break;
1404
- }
1405
- case ln: {
1406
- if (t.isNull) throw new Error();
1407
- r.Clients = Fn(t.asDictionary());
1408
- break;
1409
- }
1410
- case En: {
1411
- if (t.isNull) throw new Error();
1412
- r.TrackingStreams = bn(t.asDictionary());
1413
- break;
1414
- }
1415
- case In: {
1416
- if (t.isNull) throw new Error();
1417
- r.ChannelId = t.asString();
1418
- break;
1419
- }
1420
- case _n: {
1421
- if (t.isNull) throw new Error();
1422
- r.AppSourceType = t.asInt32();
1423
- break;
1424
- }
1425
- case cn: {
1426
- if (t.isNull) throw new Error();
1427
- r.SessionChannelUrl = t.asString();
1428
- break;
1429
- }
1430
- case fn: {
1431
- if (t.isNull) throw new Error();
1432
- r.ChannelUrl = t.asString();
1433
- break;
1434
- }
1435
- case un: {
1436
- if (t.isNull) throw new Error();
1437
- r.ChannelName = t.asString();
1438
- break;
1439
- }
1440
- case hn: {
1441
- if (t.isNull) throw new Error();
1442
- r.PublicAccess = t.asBool();
1443
- break;
1444
- }
1445
- case Tn: {
1446
- if (t.isNull) throw new Error();
1447
- r.ServerRunType = t.asInt32();
1448
- break;
1449
- }
1450
- case An: {
1451
- if (t.isNull) throw new Error();
1452
- r.OrganisationName = t.asString();
1453
- break;
1454
- }
1455
- case Sn: {
1456
- if (t.isNull) throw new Error();
1457
- r.DebugMode = t.asBool();
1458
- break;
1459
- }
1460
- case Nn: {
1461
- if (t.isNull) throw new Error();
1462
- r.Functions = Mn(t.asDictionary());
1463
- break;
1464
- }
1465
- case dn: {
1466
- if (t.isNull) throw new Error();
1467
- r.UIStreams = vn(t.asDictionary());
1468
- break;
1469
- }
1470
- case Cn: {
1471
- if (t.isNull) throw new Error();
1472
- r.SpaceId = t.asString();
1473
- break;
1474
- }
1475
- case Rn: {
1476
- if (t.isNull) throw new Error();
1477
- r.PrimaryUserId = t.asString();
1478
- break;
1479
- }
1480
- case wn: {
1481
- if (t.isNull) throw new Error();
1482
- r.AudioStreams = kn(t.asDictionary());
1483
- break;
1484
- }
1485
- case Dn: {
1486
- if (t.isNull) throw new Error();
1487
- r.VideoStreams = pn(t.asDictionary());
1488
- break;
1489
- }
1490
- case yn: {
1491
- if (t.isNull) throw new Error();
1492
- r.ServerSessionId = t.asString();
1493
- break;
1494
- }
1495
- case Ln: {
1496
- if (t.isNull) throw new Error();
1497
- r.SpaceName = t.asString();
1498
- break;
1499
- }
1500
- }
1501
- }
1502
- async function Pn(e, r) {
1503
- const t = await j(e, nn);
1504
- return On(t, r);
1505
- }
1506
- function Fn(e) {
1507
- const r = /* @__PURE__ */ Object.create(null);
1508
- let t;
1509
- for (; (t = e.next()) !== null; ) {
1510
- const s = t.key.asInt32();
1511
- r[s] = hr(t.value.asObject());
1512
- }
1513
- return r;
1514
- }
1515
- function bn(e) {
1516
- const r = /* @__PURE__ */ Object.create(null);
1517
- let t;
1518
- for (; (t = e.next()) !== null; ) {
1519
- const s = t.key.asString();
1520
- r[s] = _o(t.value.asObject());
1521
- }
1522
- return r;
1523
- }
1524
- function Mn(e) {
1525
- const r = /* @__PURE__ */ Object.create(null);
1526
- let t;
1527
- for (; (t = e.next()) !== null; ) {
1528
- const s = t.key.asInt32();
1529
- r[s] = Vn(t.value.asArray());
1530
- }
1531
- return r;
1532
- }
1533
- function vn(e) {
1534
- const r = /* @__PURE__ */ Object.create(null);
1535
- let t;
1536
- for (; (t = e.next()) !== null; ) {
1537
- const s = t.key.asString();
1538
- r[s] = $n(t.value.asObject());
1539
- }
1540
- return r;
1541
- }
1542
- function kn(e) {
1543
- const r = /* @__PURE__ */ Object.create(null);
1544
- let t;
1545
- for (; (t = e.next()) !== null; ) {
1546
- const s = t.key.asString();
1547
- r[s] = Qn(t.value.asObject());
1548
- }
1549
- return r;
1550
- }
1551
- function pn(e) {
1552
- const r = /* @__PURE__ */ Object.create(null);
1553
- let t;
1554
- for (; (t = e.next()) !== null; ) {
1555
- const s = t.key.asString();
1556
- r[s] = no(t.value.asObject());
1557
- }
1558
- return r;
1559
- }
1560
- function Vn(e) {
1561
- const r = [];
1562
- let t;
1563
- for (; (t = e.next()) !== null; )
1564
- r.push(Pr(t.asObject()));
1565
- return r;
1566
- }
1567
- const Gn = 161083277, Bn = 325678206, xn = 3469892363, Hn = 3645544153;
1568
- function Yn(e) {
1569
- const r = {};
1570
- return He(r), r;
1571
- }
1572
- function He(e) {
1573
- return e.StreamId = "", e.ClientSessionId = 0, e.TrackId = 0, e.Info = Fe(), e;
1574
- }
1575
- function $n(e, r) {
1576
- const t = r ?? Yn();
1577
- return He(t), Kn(e, t), t;
1578
- }
1579
- function Kn(e, r) {
1580
- let t;
1581
- for (; (t = e.next()) !== null; )
1582
- switch (t.fieldId) {
1583
- case Gn: {
1584
- if (t.isNull) throw new Error();
1585
- r.StreamId = t.asString();
1586
- break;
1587
- }
1588
- case Bn: {
1589
- if (t.isNull) throw new Error();
1590
- r.ClientSessionId = t.asInt32();
1591
- break;
1592
- }
1593
- case xn: {
1594
- if (t.isNull) throw new Error();
1595
- r.TrackId = t.asInt32();
1596
- break;
1597
- }
1598
- case Hn: {
1599
- if (t.isNull) throw new Error();
1600
- r.Info = os(t.asObject());
1601
- break;
1602
- }
1603
- }
1604
- }
1605
- const jn = 161083277, Xn = 325678206, Wn = 3469892363, zn = 3645544153;
1606
- function Jn(e) {
1607
- const r = {};
1608
- return Ye(r), r;
1609
- }
1610
- function Ye(e) {
1611
- return e.StreamId = "", e.ClientSessionId = 0, e.TrackId = 0, e.Info = we(), e;
1612
- }
1613
- function Qn(e, r) {
1614
- const t = r ?? Jn();
1615
- return Ye(t), qn(e, t), t;
1616
- }
1617
- function qn(e, r) {
1618
- let t;
1619
- for (; (t = e.next()) !== null; )
1620
- switch (t.fieldId) {
1621
- case jn: {
1622
- if (t.isNull) throw new Error();
1623
- r.StreamId = t.asString();
1624
- break;
1625
- }
1626
- case Xn: {
1627
- if (t.isNull) throw new Error();
1628
- r.ClientSessionId = t.asInt32();
1629
- break;
1630
- }
1631
- case Wn: {
1632
- if (t.isNull) throw new Error();
1633
- r.TrackId = t.asInt32();
1634
- break;
1635
- }
1636
- case zn: {
1637
- if (t.isNull) throw new Error();
1638
- r.Info = wt(t.asObject());
1639
- break;
1640
- }
1641
- }
1642
- }
1643
- const Zn = 161083277, eo = 325678206, to = 3469892363, ro = 3645544153;
1644
- function so(e) {
1645
- const r = {};
1646
- return $e(r), r;
1647
- }
1648
- function $e(e) {
1649
- return e.StreamId = "", e.ClientSessionId = 0, e.TrackId = 0, e.Info = Ge(), e;
1650
- }
1651
- function no(e, r) {
1652
- const t = r ?? so();
1653
- return $e(t), oo(e, t), t;
1654
- }
1655
- function oo(e, r) {
1656
- let t;
1657
- for (; (t = e.next()) !== null; )
1658
- switch (t.fieldId) {
1659
- case Zn: {
1660
- if (t.isNull) throw new Error();
1661
- r.StreamId = t.asString();
1662
- break;
1663
- }
1664
- case eo: {
1665
- if (t.isNull) throw new Error();
1666
- r.ClientSessionId = t.asInt32();
1667
- break;
1668
- }
1669
- case to: {
1670
- if (t.isNull) throw new Error();
1671
- r.TrackId = t.asInt32();
1672
- break;
1673
- }
1674
- case ro: {
1675
- if (t.isNull) throw new Error();
1676
- r.Info = rn(t.asObject());
1677
- break;
1678
- }
1679
- }
1680
- }
1681
- const io = 161083277, ao = 325678206, lo = 3469892363, Eo = 3645544153;
1682
- function Io(e) {
1683
- const r = {};
1684
- return Ke(r), r;
1685
- }
1686
- function Ke(e) {
1687
- return e.StreamId = "", e.ClientSessionId = 0, e.TrackId = 0, e.Info = me(), e;
1688
- }
1689
- function _o(e, r) {
1690
- const t = r ?? Io();
1691
- return Ke(t), co(e, t), t;
1692
- }
1693
- function co(e, r) {
1694
- let t;
1695
- for (; (t = e.next()) !== null; )
1696
- switch (t.fieldId) {
1697
- case io: {
1698
- if (t.isNull) throw new Error();
1699
- r.StreamId = t.asString();
1700
- break;
1701
- }
1702
- case ao: {
1703
- if (t.isNull) throw new Error();
1704
- r.ClientSessionId = t.asInt32();
1705
- break;
1706
- }
1707
- case lo: {
1708
- if (t.isNull) throw new Error();
1709
- r.TrackId = t.asInt32();
1710
- break;
1711
- }
1712
- case Eo: {
1713
- if (t.isNull) throw new Error();
1714
- r.Info = Jr(t.asObject());
1715
- break;
1716
- }
1717
- }
1718
- }
1719
- function C(e) {
1720
- return typeof e == "object" && e !== null && !Array.isArray(e);
1721
- }
1722
- function je(e) {
1723
- const r = {}, t = Object.keys(e);
1724
- for (let s = 0; s < t.length; s++) {
1725
- const n = t[s];
1726
- r[n] = e[n];
1727
- }
1728
- return r;
1729
- }
1730
- function Xe(e, r, t, s) {
1731
- if (!(e === void 0 && s)) {
1732
- if (Array.isArray(e)) {
1733
- const n = [];
1734
- for (let o = 0; o < e.length; o++) {
1735
- const i = e[o];
1736
- if (typeof i != "string")
1737
- throw new Error(`Invalid styleIds entry at ${r}.styleIds[${o}] for element ${t}`);
1738
- const a = i.trim();
1739
- a.length !== 0 && n.push(a);
1740
- }
1741
- return n;
1742
- }
1743
- if (e != null)
1744
- throw new Error(`Invalid styleIds for element ${t}`);
1745
- return [];
1746
- }
1747
- }
1748
- function ie(e, r) {
1749
- if (!e || typeof e != "object")
1750
- throw new Error(`Invalid UI node at ${r}`);
1751
- const t = e.Id, s = e.Type, n = e.Props, o = e.Children, i = e.StyleIds;
1752
- if (typeof t != "string")
1753
- throw new Error(`Invalid or missing node id at ${r}`);
1754
- if (typeof s != "string")
1755
- throw new Error(`Invalid or missing node type for ${t}`);
1756
- let a = {};
1757
- if (n != null) {
1758
- if (!C(n))
1759
- throw new Error(`Invalid props for node ${t}`);
1760
- a = je(n);
1761
- }
1762
- let E = [];
1763
- Array.isArray(o) && (E = o.map(
1764
- (_, c) => ie(_ ?? {}, `${r}.children[${c}]`)
1765
- ));
1766
- const I = Xe(i, r, t, !1), l = typeof e.SourceMarker == "string" ? e.SourceMarker : void 0;
1767
- return {
1768
- id: t,
1769
- type: s,
1770
- props: a,
1771
- children: E,
1772
- styleIds: I ?? [],
1773
- ...l ? { sourceMarker: l } : {}
1774
- };
1775
- }
1776
- function fo(e, r) {
1777
- if (!C(e))
1778
- throw new Error(`Invalid text delta at ${r}`);
1779
- const t = e.NodeId, s = e.PropertyName, n = e.Start, o = e.End, i = e.InsertedText;
1780
- if (typeof t != "string" || t.length === 0)
1781
- throw new Error(`Invalid text delta node id at ${r}`);
1782
- if (typeof s != "string" || s.length === 0)
1783
- throw new Error(`Invalid text delta property name at ${r}`);
1784
- if (typeof n != "number" || !Number.isFinite(n))
1785
- throw new Error(`Invalid text delta start at ${r}`);
1786
- if (typeof i != "string")
1787
- throw new Error(`Invalid text delta inserted text at ${r}`);
1788
- let a;
1789
- if (typeof o == "number") {
1790
- if (!Number.isFinite(o))
1791
- throw new Error(`Invalid text delta end at ${r}`);
1792
- a = o;
1793
- } else if (o != null)
1794
- throw new Error(`Invalid text delta end at ${r}`);
1795
- return {
1796
- nodeId: t,
1797
- propertyName: s,
1798
- start: n,
1799
- end: a,
1800
- insertedText: i
1801
- };
1802
- }
1803
- function uo(e, r) {
1804
- if (!C(e))
1805
- throw new Error(`Invalid child insert at ${r}`);
1806
- const t = e.Index, s = e.Node;
1807
- if (typeof t != "number" || !Number.isFinite(t))
1808
- throw new Error(`Invalid child insert index at ${r}`);
1809
- if (!C(s))
1810
- throw new Error(`Invalid child insert node at ${r}`);
1811
- return {
1812
- index: t,
1813
- node: ie(s, `${r}.node`)
1814
- };
1815
- }
1816
- function ho(e, r) {
1817
- if (!C(e))
1818
- throw new Error(`Invalid child move at ${r}`);
1819
- const t = e.NodeId, s = e.FromIndex, n = e.ToIndex;
1820
- if (typeof t != "string" || t.length === 0)
1821
- throw new Error(`Invalid child move nodeId at ${r}`);
1822
- if (typeof s != "number" || !Number.isFinite(s))
1823
- throw new Error(`Invalid child move fromIndex at ${r}`);
1824
- if (typeof n != "number" || !Number.isFinite(n))
1825
- throw new Error(`Invalid child move toIndex at ${r}`);
1826
- return {
1827
- nodeId: t,
1828
- fromIndex: s,
1829
- toIndex: n
1830
- };
1831
- }
1832
- function To(e, r) {
1833
- if (!C(e))
1834
- throw new Error(`Invalid child remove at ${r}`);
1835
- const t = e.NodeId, s = e.Index;
1836
- if (typeof t != "string" || t.length === 0)
1837
- throw new Error(`Invalid child remove nodeId at ${r}`);
1838
- if (typeof s != "number" || !Number.isFinite(s))
1839
- throw new Error(`Invalid child remove index at ${r}`);
1840
- return {
1841
- nodeId: t,
1842
- index: s
1843
- };
1844
- }
1845
- function Ao(e, r) {
1846
- if (!C(e))
1847
- throw new Error(`Invalid node change at ${r}`);
1848
- const t = e.nodeId;
1849
- if (typeof t != "string" || t.length === 0)
1850
- throw new Error(`Invalid node change nodeId at ${r}`);
1851
- const s = Array.isArray(e.inserts) ? e.inserts.map(
1852
- (l, _) => uo(l ?? {}, `${r}.inserts[${_}]`)
1853
- ) : void 0, n = Array.isArray(e.moves) ? e.moves.map(
1854
- (l, _) => ho(l ?? {}, `${r}.moves[${_}]`)
1855
- ) : void 0, o = Array.isArray(e.removals) ? e.removals.map(
1856
- (l, _) => To(l ?? {}, `${r}.removals[${_}]`)
1857
- ) : void 0;
1858
- let i;
1859
- if (C(e.changedProps)) {
1860
- i = /* @__PURE__ */ new Map();
1861
- for (const [l, _] of Object.entries(e.changedProps)) {
1862
- if (!C(_))
1863
- continue;
1864
- const c = _.New;
1865
- c == null ? i.set(l, void 0) : C(c) ? i.set(l, je(c)) : i.set(l, c);
1866
- }
1867
- }
1868
- const a = Array.isArray(e.textUpdates) ? e.textUpdates.map(
1869
- (l, _) => fo(l ?? {}, `${r}.textUpdates[${_}]`)
1870
- ) : void 0, E = e.styleIds, I = E !== void 0 ? Xe(E, r, t, !0) : void 0;
1871
- return {
1872
- nodeId: t,
1873
- ...s && s.length > 0 ? { inserts: s } : {},
1874
- ...n && n.length > 0 ? { moves: n } : {},
1875
- ...o && o.length > 0 ? { removals: o } : {},
1876
- ...i && i.size > 0 ? { changedProps: i } : {},
1877
- ...a && a.length > 0 ? { textUpdates: a } : {},
1878
- ...I !== void 0 ? { styleIds: I } : {}
1879
- };
1880
- }
1881
- function So(e) {
1882
- const r = /* @__PURE__ */ new Map();
1883
- for (const [t, s] of Object.entries(e))
1884
- r.set(t, s);
1885
- return r;
1886
- }
1887
- function No(e, r, t) {
1888
- if (!e || typeof e != "object")
1889
- throw new w("UI update graph is missing");
1890
- const s = ie(e, "graph");
1891
- if (s.type !== "root")
1892
- throw new w('UI update root element must have type "root"');
1893
- const n = Ro(s.props, r);
1894
- return {
1895
- type: "full",
1896
- version: t,
1897
- root: s,
1898
- metadata: n
1899
- };
1900
- }
1901
- function Co(e, r, t) {
1902
- if (!Array.isArray(e))
1903
- throw new w("UI diff changes must be an array");
1904
- if (!C(r))
1905
- throw new w("UI diff metadata must be an object");
1906
- const s = r.viewId;
1907
- if (typeof s != "string" || s.length === 0)
1908
- throw new w("UI diff metadata is missing viewId");
1909
- const n = e.map(
1910
- (a, E) => Ao(a ?? {}, `changes[${E}]`)
1911
- ), o = typeof r.isUpdate == "boolean" ? r.isUpdate : void 0, i = {
1912
- viewId: s,
1913
- ...o !== void 0 ? { isUpdate: o } : {}
1914
- };
1915
- return {
1916
- type: "diff",
1917
- version: t,
1918
- changes: n,
1919
- metadata: i
1920
- };
1921
- }
1922
- function Ro(e, r) {
1923
- const t = e.viewId;
1924
- if (typeof t != "string" || t.length === 0)
1925
- throw new w("UI update root is missing viewId");
1926
- let s = t, n = typeof e.isUpdate == "boolean" ? e.isUpdate : void 0;
1927
- return C(r) && (typeof r.viewId == "string" && r.viewId.length > 0 && (s = r.viewId), typeof r.isUpdate == "boolean" && (n = r.isUpdate)), {
1928
- viewId: s,
1929
- ...n !== void 0 ? { isUpdate: n } : {}
1930
- };
1931
- }
1932
- class w extends Error {
1933
- constructor(r, t) {
1934
- super(r), this.causeError = t, this.name = "UiUpdateParseError", t instanceof Error && (this.stack = t.stack);
1935
- }
1936
- }
1937
- function We(e) {
1938
- let r;
1939
- try {
1940
- r = JSON.parse(e.Json);
1941
- } catch (i) {
1942
- throw new w("Failed to parse UIUpdate.Json payload", i);
1943
- }
1944
- if (!r || typeof r != "object")
1945
- throw new w("UI update snapshot must be an object");
1946
- const { type: t, version: s } = r;
1947
- if (t !== "full" && t !== "diff")
1948
- throw new w(`Unknown UI update type: ${String(t)}`);
1949
- if (typeof s != "number")
1950
- throw new w("UI update version must be a number");
1951
- const n = t === "full" ? No(r.graph, r.metadata, s) : Co(r.changes, r.metadata, s), o = e.Payloads ? So(e.Payloads) : /* @__PURE__ */ new Map();
1952
- return {
1953
- snapshot: n,
1954
- payloads: o
1955
- };
1956
- }
1957
- let wo = 1;
1958
- const Do = /* @__PURE__ */ new Map(), yo = {
1959
- 0: "DEBUG",
1960
- 1: "INFO",
1961
- 2: "WARN",
1962
- 3: "ERROR",
1963
- 4: "NONE"
1964
- };
1965
- function Lo(e, r) {
1966
- return `[${e}] ${r}`;
1967
- }
1968
- function W(e, r, t, s) {
1969
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = yo[e], i = {
1970
- timestamp: n,
1971
- level: e,
1972
- levelName: o,
1973
- component: r,
1974
- message: t,
1975
- args: s
1976
- };
1977
- for (const [a, E] of Do) {
1978
- const I = E?.minLevel ?? 2;
1979
- if (e >= I)
1980
- try {
1981
- a(i);
1982
- } catch {
1983
- }
1984
- }
1985
- if (wo <= e) {
1986
- const a = Lo(r, t);
1987
- switch (e) {
1988
- case 0:
1989
- console.debug(a, ...s);
1990
- break;
1991
- case 1:
1992
- console.info(a, ...s);
1993
- break;
1994
- case 2:
1995
- console.warn(a, ...s);
1996
- break;
1997
- case 3:
1998
- console.error(a, ...s);
1999
- break;
2000
- }
2001
- }
2002
- }
2003
- function Uo(e) {
2004
- return {
2005
- debug(r, ...t) {
2006
- W(0, e, r, t);
2007
- },
2008
- info(r, ...t) {
2009
- W(1, e, r, t);
2010
- },
2011
- warn(r, ...t) {
2012
- W(2, e, r, t);
2013
- },
2014
- error(r, ...t) {
2015
- W(3, e, r, t);
2016
- }
2017
- };
2018
- }
2019
- class Oo {
2020
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2021
- cache = /* @__PURE__ */ new Map();
2022
- /**
2023
- * Get a cached void handler (no payload) for a node/action combination.
2024
- * Creates and caches the handler if it doesn't exist.
2025
- */
2026
- getHandler(r, t, s) {
2027
- const n = `${r}:${t}`;
2028
- let o = this.cache.get(n);
2029
- return o || (o = () => s(t), this.cache.set(n, o)), o;
2030
- }
2031
- /**
2032
- * Get a cached handler that accepts a payload.
2033
- * Creates and caches the handler if it doesn't exist.
2034
- */
2035
- getHandlerWithPayload(r, t, s) {
2036
- const n = `${r}:${t}:payload`;
2037
- let o = this.cache.get(n);
2038
- return o || (o = (i) => s(t, i), this.cache.set(n, o)), o;
2039
- }
2040
- /**
2041
- * Get a cached handler for boolean payloads.
2042
- */
2043
- getBooleanHandler(r, t, s) {
2044
- return this.getHandlerWithPayload(r, t, s);
2045
- }
2046
- /**
2047
- * Get a cached handler for string payloads.
2048
- */
2049
- getStringHandler(r, t, s) {
2050
- return this.getHandlerWithPayload(r, t, s);
2051
- }
2052
- /**
2053
- * Get a cached handler for number payloads.
2054
- */
2055
- getNumberHandler(r, t, s) {
2056
- return this.getHandlerWithPayload(r, t, s);
2057
- }
2058
- /**
2059
- * Get a cached handler for number array payloads.
2060
- */
2061
- getNumberArrayHandler(r, t, s) {
2062
- return this.getHandlerWithPayload(r, t, s);
2063
- }
2064
- /**
2065
- * Get a cached handler for nullable boolean payloads.
2066
- */
2067
- getNullableBooleanHandler(r, t, s) {
2068
- const n = `${r}:${t}:nullable-bool`;
2069
- let o = this.cache.get(n);
2070
- return o || (o = (i) => s(t, i ?? null), this.cache.set(n, o)), o;
2071
- }
2072
- /**
2073
- * Invalidate all cached handlers for a specific node.
2074
- * Call this when a node is removed from the tree.
2075
- */
2076
- invalidateNode(r) {
2077
- const t = `${r}:`;
2078
- for (const s of this.cache.keys())
2079
- s.startsWith(t) && this.cache.delete(s);
2080
- }
2081
- /**
2082
- * Invalidate a specific handler.
2083
- */
2084
- invalidateHandler(r, t) {
2085
- this.cache.delete(`${r}:${t}`), this.cache.delete(`${r}:${t}:payload`), this.cache.delete(`${r}:${t}:nullable-bool`);
2086
- }
2087
- /**
2088
- * Clear all cached handlers.
2089
- */
2090
- clear() {
2091
- this.cache.clear();
2092
- }
2093
- /**
2094
- * Get the number of cached handlers (for debugging/testing).
2095
- */
2096
- get size() {
2097
- return this.cache.size;
2098
- }
2099
- }
2100
- const mo = Uo("UiStreamStore");
2101
- class go {
2102
- views = /* @__PURE__ */ new Map();
2103
- listeners = /* @__PURE__ */ new Set();
2104
- payloads = /* @__PURE__ */ new Map();
2105
- snapshotMode = !1;
2106
- snapshot = {
2107
- views: /* @__PURE__ */ new Map(),
2108
- payloads: /* @__PURE__ */ new Map(),
2109
- version: -1
2110
- };
2111
- rootViewId;
2112
- // Per-node subscriptions for granular updates
2113
- nodeListeners = /* @__PURE__ */ new Map();
2114
- changedNodeIds = /* @__PURE__ */ new Set();
2115
- nodeVersions = /* @__PURE__ */ new Map();
2116
- structureChanged = !1;
2117
- // Set when a diff is dropped because it can no longer be reconciled against the local tree:
2118
- // its version regressed, it jumped ahead of the local version (a missing intermediate diff),
2119
- // or there is no base tree to apply it to. Consumed by the transport layer, which then asks the
2120
- // server to resync this stream with a full snapshot.
2121
- resyncNeeded = !1;
2122
- // Dirty flags for lazy snapshot rebuilding - start true to ensure first snapshot builds correctly
2123
- viewsDirty = !0;
2124
- payloadsDirty = !0;
2125
- // Handler cache for stable event handlers
2126
- handlerCache = new Oo();
2127
- // id -> node lookup index for O(1) getNode. Rebuilt lazily from the committed snapshot's view
2128
- // trees. Node trees are immutable (a change replaces every node on the changed path with a new
2129
- // object and yields a new views Map), so the index is valid exactly while it points at the same
2130
- // views Map instance: comparing that reference is a correct, allocation-free dirty check that
2131
- // covers every mutation path (apply, replaceSnapshot, patchFromOp, clear) without touching them.
2132
- nodeIndex = /* @__PURE__ */ new Map();
2133
- indexedViews;
2134
- apply(r) {
2135
- if (this.snapshotMode) {
2136
- if (r.snapshot.type !== "full")
2137
- return !1;
2138
- this.snapshotMode = !1, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.viewsDirty = !0, this.payloadsDirty = !0, this.snapshot = {
2139
- views: /* @__PURE__ */ new Map(),
2140
- payloads: /* @__PURE__ */ new Map(),
2141
- version: -1
2142
- };
2143
- }
2144
- const { snapshot: t, payloads: s } = r, { metadata: n } = t, { viewId: o } = n;
2145
- let i = this.views.get(o);
2146
- i || (i = {
2147
- version: 0
2148
- }, this.views.set(o, i));
2149
- const a = t.type === "diff" && n.isUpdate === !0;
2150
- if (t.version < i.version)
2151
- return this.resyncNeeded = !0, !1;
2152
- if (t.type === "diff" && t.version > i.version + 1)
2153
- return this.resyncNeeded = !0, !1;
2154
- if (t.version === i.version && !a)
2155
- return !1;
2156
- let E = !1;
2157
- this.rootViewId || (this.rootViewId = o, E = !0, this.structureChanged = !0);
2158
- const I = i.root;
2159
- if (t.type === "full")
2160
- i.root = t.root, i.version = t.version, E = !0, this.viewsDirty = !0, this.structureChanged = !0, t.root && B(t.root, this.changedNodeIds);
2161
- else {
2162
- if (!I)
2163
- return this.resyncNeeded = !0, !1;
2164
- const l = Fo(I, t.changes);
2165
- l !== I ? (i.root = l, E = !0, this.viewsDirty = !0, q(I, l, this.changedNodeIds)) : i.root = l, i.version = t.version;
2166
- }
2167
- for (const [l, _] of s)
2168
- this.payloads.get(l) !== _ && (this.payloads.set(l, _), E = !0, this.payloadsDirty = !0);
2169
- return E ? (this.commitSnapshot(), this.notify(), !0) : (i.version = t.version, !1);
2170
- }
2171
- // Ignore further diffs (keeping the current tree visible) until the next full snapshot arrives,
2172
- // which then replaces the tree wholesale. Used on soft reconnect: the cached tree may be missing
2173
- // diffs lost while the transport was down, so incoming diffs can no longer be trusted — but the
2174
- // tree stays on screen (no blank) until the server's resync full snapshot lands.
2175
- enterSnapshotMode() {
2176
- this.snapshotMode = !0;
2177
- }
2178
- // Returns whether a diff was dropped as unrecoverable since the last call, clearing the flag.
2179
- consumeResyncNeeded() {
2180
- const r = this.resyncNeeded;
2181
- return this.resyncNeeded = !1, r;
2182
- }
2183
- replaceFromWire(r) {
2184
- const t = {
2185
- rootViewId: r.rootViewId,
2186
- views: new Map(r.views),
2187
- payloads: new Map(r.payloads),
2188
- version: r.version
2189
- };
2190
- return this.replaceSnapshot(t);
2191
- }
2192
- patchFromOp(r) {
2193
- this.snapshotMode = !0;
2194
- const t = r.expectedBaseVersion;
2195
- if (t !== void 0 && this.snapshot.version !== t)
2196
- return !1;
2197
- let s = !1, n = null, o = null;
2198
- const i = () => (n || (n = new Map(this.snapshot.views)), n), a = () => (o || (o = new Map(this.snapshot.payloads)), o);
2199
- if (r.deleteViews && r.deleteViews.length > 0)
2200
- for (const l of r.deleteViews)
2201
- i().delete(l) && (s = !0, this.structureChanged = !0);
2202
- if (r.upsertViews && r.upsertViews.length > 0)
2203
- for (const [l, _] of r.upsertViews) {
2204
- const c = i(), L = c.get(l);
2205
- L !== _ && (c.set(l, _), s = !0, L ? q(L, _, this.changedNodeIds) : (B(_, this.changedNodeIds), this.structureChanged = !0));
2206
- }
2207
- if (r.deletePayloads && r.deletePayloads.length > 0)
2208
- for (const l of r.deletePayloads)
2209
- a().delete(l) && (s = !0);
2210
- if (r.upsertPayloads && r.upsertPayloads.length > 0)
2211
- for (const [l, _] of r.upsertPayloads) {
2212
- const c = a();
2213
- c.get(l) !== _ && (c.set(l, _), s = !0);
2214
- }
2215
- const E = r.rootViewId ?? this.snapshot.rootViewId;
2216
- E !== this.snapshot.rootViewId && (s = !0, this.structureChanged = !0);
2217
- const I = r.nextVersion;
2218
- if (I !== this.snapshot.version && (s = !0), !s)
2219
- return this.snapshot = { ...this.snapshot, version: I }, !1;
2220
- for (const l of this.changedNodeIds)
2221
- this.nodeVersions.set(l, (this.nodeVersions.get(l) ?? 0) + 1);
2222
- return this.snapshot = {
2223
- rootViewId: E,
2224
- views: n ?? new Map(this.snapshot.views),
2225
- payloads: o ?? new Map(this.snapshot.payloads),
2226
- version: I
2227
- }, this.notify(), !0;
2228
- }
2229
- replaceSnapshot(r) {
2230
- this.snapshotMode = !0;
2231
- const t = this.snapshot, s = t.version !== r.version || t.rootViewId !== r.rootViewId || t.views.size !== r.views.size || t.payloads.size !== r.payloads.size;
2232
- (t.rootViewId !== r.rootViewId || t.views.size !== r.views.size) && (this.structureChanged = !0);
2233
- for (const [n, o] of r.views) {
2234
- const i = t.views.get(n);
2235
- i ? q(i, o, this.changedNodeIds) : (B(o, this.changedNodeIds), this.structureChanged = !0);
2236
- }
2237
- for (const n of this.changedNodeIds)
2238
- this.nodeVersions.set(n, (this.nodeVersions.get(n) ?? 0) + 1);
2239
- return this.snapshot = r, s && this.notify(), s;
2240
- }
2241
- clear() {
2242
- (this.snapshot.rootViewId === void 0 || this.snapshot.rootViewId.length === 0) && this.snapshot.views.size === 0 && this.snapshot.payloads.size === 0 || (this.snapshotMode = !0, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.viewsDirty = !0, this.payloadsDirty = !0, this.snapshot = {
2243
- views: /* @__PURE__ */ new Map(),
2244
- payloads: /* @__PURE__ */ new Map(),
2245
- version: -1
2246
- }, this.structureChanged = !0, this.notify());
2247
- }
2248
- getSnapshot() {
2249
- return this.snapshot;
2250
- }
2251
- subscribe(r) {
2252
- return this.listeners.add(r), () => {
2253
- this.listeners.delete(r);
2254
- };
2255
- }
2256
- subscribeNode(r, t) {
2257
- let s = this.nodeListeners.get(r);
2258
- return s || (s = /* @__PURE__ */ new Set(), this.nodeListeners.set(r, s)), s.add(t), () => {
2259
- s && (s.delete(t), s.size === 0 && this.nodeListeners.delete(r));
2260
- };
2261
- }
2262
- getNode(r) {
2263
- const t = this.snapshot.views;
2264
- return this.indexedViews !== t && this.rebuildNodeIndex(t), this.nodeIndex.get(r);
2265
- }
2266
- rebuildNodeIndex(r) {
2267
- this.nodeIndex.clear();
2268
- for (const t of r.values())
2269
- Je(t, this.nodeIndex);
2270
- for (const [t, s] of r)
2271
- this.nodeIndex.set(t, s);
2272
- this.indexedViews = r;
2273
- }
2274
- getNodeVersion(r) {
2275
- return this.nodeVersions.get(r) ?? 0;
2276
- }
2277
- notifyNodes() {
2278
- if (this.changedNodeIds.size === 0 || this.nodeListeners.size === 0) {
2279
- this.changedNodeIds.clear();
2280
- return;
2281
- }
2282
- for (const r of this.changedNodeIds) {
2283
- const t = this.nodeListeners.get(r);
2284
- if (t)
2285
- for (const s of t)
2286
- s();
2287
- }
2288
- this.changedNodeIds.clear();
2289
- }
2290
- commitSnapshot() {
2291
- let r, t;
2292
- if (this.viewsDirty) {
2293
- const n = /* @__PURE__ */ new Map();
2294
- for (const [o, i] of this.views)
2295
- i.root && n.set(o, i.root);
2296
- r = n, this.viewsDirty = !1;
2297
- } else
2298
- r = this.snapshot.views;
2299
- this.payloadsDirty ? (t = new Map(this.payloads), this.payloadsDirty = !1) : t = this.snapshot.payloads;
2300
- let s = this.rootViewId && this.views.has(this.rootViewId) ? this.views.get(this.rootViewId)?.version : void 0;
2301
- if (s === void 0)
2302
- for (const n of this.views.values())
2303
- s = s === void 0 ? n.version : Math.max(s, n.version);
2304
- this.snapshot = {
2305
- rootViewId: this.rootViewId,
2306
- views: r,
2307
- payloads: t,
2308
- version: s
2309
- };
2310
- for (const n of this.changedNodeIds)
2311
- this.nodeVersions.set(n, (this.nodeVersions.get(n) ?? 0) + 1);
2312
- }
2313
- notify() {
2314
- if (this.notifyNodes(), this.structureChanged) {
2315
- this.structureChanged = !1;
2316
- for (const r of this.listeners)
2317
- r();
2318
- }
2319
- }
2320
- }
2321
- class Po {
2322
- streams = /* @__PURE__ */ new Map();
2323
- listeners = /* @__PURE__ */ new Set();
2324
- apply(r, t) {
2325
- const n = this.getOrCreateStreamEntry(r).store.apply(t);
2326
- return n && this.notify(r), n;
2327
- }
2328
- // Whether the given stream dropped an unrecoverable diff since the last check (clears the flag).
2329
- needsResync(r) {
2330
- const t = this.streams.get(r);
2331
- return t ? t.store.consumeResyncNeeded() : !1;
2332
- }
2333
- applyStoreOp(r) {
2334
- if (r.type === "ReplaceStreamSnapshot") {
2335
- const t = this.getOrCreateStreamEntry(r.snapshot.streamId), s = t.category !== r.snapshot.category;
2336
- return t.category = r.snapshot.category, t.store.replaceFromWire(r.snapshot) || s ? (this.notify(r.snapshot.streamId), !0) : !1;
2337
- }
2338
- if (r.type === "PatchStreamSnapshot") {
2339
- const t = this.getOrCreateStreamEntry(r.streamId), s = r.category !== void 0 && t.category !== r.category;
2340
- return r.category !== void 0 && (t.category = r.category), t.store.patchFromOp(r) || s ? (this.notify(r.streamId), !0) : !1;
2341
- }
2342
- if (r.type === "ClearStream") {
2343
- const t = this.streams.get(r.streamId);
2344
- return t ? (t.store.clear(), this.notify(r.streamId), !0) : !1;
2345
- }
2346
- return r.type === "RemoveStream" ? this.streams.delete(r.streamId) ? (this.notify(r.streamId), !0) : !1 : r.type === "SetStreamCategory" ? (this.setCategory(r.streamId, r.category), !0) : !1;
2347
- }
2348
- applyStoreOps(r) {
2349
- for (const t of r)
2350
- this.applyStoreOp(t);
2351
- }
2352
- clear(r) {
2353
- const t = this.streams.get(r);
2354
- t && (t.store.clear(), this.notify(r));
2355
- }
2356
- remove(r) {
2357
- this.streams.delete(r) && this.notify(r);
2358
- }
2359
- // Puts every existing stream into snapshot mode (see UiStreamStore.enterSnapshotMode) so each one
2360
- // keeps its current tree visible and ignores diffs until the server's next full snapshot resyncs it.
2361
- enterSnapshotModeAll() {
2362
- for (const r of this.streams.values())
2363
- r.store.enterSnapshotMode();
2364
- }
2365
- setCategory(r, t) {
2366
- const s = this.getOrCreateStreamEntry(r);
2367
- s.category !== t && (s.category = t, this.notify(r));
2368
- }
2369
- getSnapshot(r) {
2370
- const t = this.streams.get(r);
2371
- return t ? {
2372
- ...t.store.getSnapshot(),
2373
- streamId: r,
2374
- category: t.category
2375
- } : void 0;
2376
- }
2377
- getSnapshots() {
2378
- const r = [];
2379
- for (const [t, s] of this.streams) {
2380
- const n = s.store.getSnapshot();
2381
- r.push({
2382
- ...n,
2383
- streamId: t,
2384
- category: s.category
2385
- });
2386
- }
2387
- return r;
2388
- }
2389
- subscribe(r) {
2390
- return this.listeners.add(r), () => {
2391
- this.listeners.delete(r);
2392
- };
2393
- }
2394
- getOrCreateStreamEntry(r) {
2395
- let t = this.streams.get(r);
2396
- return t || (t = { store: new go() }, this.streams.set(r, t)), t;
2397
- }
2398
- notify(r) {
2399
- for (const t of this.listeners)
2400
- t(r);
2401
- }
2402
- }
2403
- function Fo(e, r, t) {
2404
- if (r.length === 0)
2405
- return e;
2406
- const s = /* @__PURE__ */ new Map();
2407
- for (const n of r)
2408
- s.set(n.nodeId, n);
2409
- return ze(e, s, t);
2410
- }
2411
- function ze(e, r, t) {
2412
- const s = r.get(e.id);
2413
- let n = e, o = !1;
2414
- if (s?.textUpdates && s.textUpdates.length > 0) {
2415
- const f = ko(e, s.textUpdates);
2416
- n = f.node, o = f.changed;
2417
- }
2418
- let i = !1, a = n.props;
2419
- if (s?.changedProps && s.changedProps.size > 0)
2420
- for (const [f, d] of s.changedProps.entries()) {
2421
- const R = a[f];
2422
- if (d === void 0)
2423
- (R !== void 0 || f in a) && (i || (a = G(a), i = !0), delete a[f]);
2424
- else if (ee(d)) {
2425
- const u = G(d);
2426
- p(u, R) || (i || (a = G(a), i = !0), a[f] = u);
2427
- } else
2428
- p(d, R) || (i || (a = G(a), i = !0), a[f] = d);
2429
- }
2430
- let E = !1, I = n.styleIds;
2431
- s?.styleIds !== void 0 && (qe(n.styleIds, s.styleIds) || (I = s.styleIds, E = !0));
2432
- const l = n.children ?? [];
2433
- let _ = l, c = !1;
2434
- if (s?.removals && s.removals.length > 0 || s?.moves && s.moves.length > 0 || s?.inserts && s.inserts.length > 0) {
2435
- const f = _.slice();
2436
- if (s?.removals && s.removals.length > 0) {
2437
- const u = [...s.removals].sort((h, F) => F.index - h.index);
2438
- for (const h of u)
2439
- if (h.index >= 0 && h.index < f.length && f[h.index].id === h.nodeId)
2440
- f.splice(h.index, 1);
2441
- else {
2442
- const F = f.findIndex((st) => st.id === h.nodeId);
2443
- F >= 0 && f.splice(F, 1);
2444
- }
2445
- c = !0;
2446
- }
2447
- const d = /* @__PURE__ */ new Map();
2448
- if (s?.moves && s.moves.length > 0) {
2449
- for (const u of s.moves) {
2450
- const h = f.findIndex((F) => F.id === u.nodeId);
2451
- h >= 0 && (d.set(u.nodeId, f[h]), f.splice(h, 1));
2452
- }
2453
- c = !0;
2454
- }
2455
- const R = [];
2456
- if (s?.moves)
2457
- for (const u of s.moves) {
2458
- const h = d.get(u.nodeId);
2459
- h && R.push({ index: u.toIndex, node: h, isInsert: !1 });
2460
- }
2461
- if (s?.inserts) {
2462
- for (const u of s.inserts)
2463
- (f.some((h) => h.id === u.node.id) || d.has(u.node.id)) && mo.warn(`Duplicate node id '${u.node.id}' (type '${u.node.type}') inserted next to an existing sibling — UI tree diverged from the server`), R.push({ index: u.index, node: u.node, isInsert: !0 });
2464
- c = !0;
2465
- }
2466
- R.sort((u, h) => u.index - h.index);
2467
- for (const u of R) {
2468
- const h = Math.min(u.index, f.length);
2469
- f.splice(h, 0, u.node), u.isInsert;
2470
- }
2471
- _ = f;
2472
- }
2473
- let D;
2474
- for (let f = 0; f < _.length; f++) {
2475
- const d = _[f], R = ze(d, r, t);
2476
- R !== d && (D || (D = _.slice()), D[f] = R);
2477
- }
2478
- return D && (_ = D, c = !0), o || i || E || c ? !i && !c && !E ? n : {
2479
- id: e.id,
2480
- type: e.type,
2481
- props: i ? a : n.props,
2482
- children: c ? _ : l,
2483
- styleIds: E ? I : n.styleIds,
2484
- ...e.sourceMarker ? { sourceMarker: e.sourceMarker } : {}
2485
- } : e;
2486
- }
2487
- function B(e, r) {
2488
- if (r.add(e.id), e.children)
2489
- for (const t of e.children)
2490
- B(t, r);
2491
- }
2492
- function Je(e, r) {
2493
- if (r.set(e.id, e), e.children)
2494
- for (const t of e.children)
2495
- Je(t, r);
2496
- }
2497
- const z = [];
2498
- function bo(e) {
2499
- for (; z.length <= e; )
2500
- z.push(/* @__PURE__ */ new Map());
2501
- return z[e].clear(), z[e];
2502
- }
2503
- function q(e, r, t) {
2504
- Qe(e, r, t, 0);
2505
- }
2506
- function Qe(e, r, t, s) {
2507
- if (e === r)
2508
- return;
2509
- (e.type !== r.type || !Mo(e.props, r.props) || !qe(e.styleIds, r.styleIds)) && t.add(r.id);
2510
- const o = e.children ?? [], i = r.children ?? [];
2511
- if (o !== i) {
2512
- const a = bo(s);
2513
- for (const I of o)
2514
- a.set(I.id, I);
2515
- let E = !1;
2516
- for (let I = 0; I < i.length; I++) {
2517
- const l = i[I], _ = a.get(l.id);
2518
- _ ? (Qe(_, l, t, s + 1), !E && I < o.length && o[I].id !== l.id && (E = !0)) : (B(l, t), E = !0);
2519
- }
2520
- (o.length !== i.length || E) && t.add(r.id);
2521
- }
2522
- }
2523
- function Mo(e, r) {
2524
- return p(e, r);
2525
- }
2526
- function qe(e, r) {
2527
- return p(e, r);
2528
- }
2529
- function vo(e, r) {
2530
- if (r.length === 0)
2531
- return e;
2532
- const t = [...r].sort((o, i) => o.start - i.start);
2533
- let s = e, n = 0;
2534
- for (const o of t) {
2535
- const i = le(o.start + n, 0, s.length);
2536
- if (o.end == null) {
2537
- const l = s.slice(i), _ = po(l, o.insertedText);
2538
- s = s.slice(0, i) + o.insertedText + l.slice(_), n += o.insertedText.length - _;
2539
- continue;
2540
- }
2541
- const a = o.end + n, E = le(a, i, s.length), I = E - i;
2542
- s = s.slice(0, i) + o.insertedText + s.slice(E), n += o.insertedText.length - I;
2543
- }
2544
- return s;
2545
- }
2546
- function ko(e, r, t) {
2547
- if (r.length === 0)
2548
- return { node: e, changed: !1 };
2549
- const s = /* @__PURE__ */ new Map();
2550
- for (const n of r) {
2551
- const o = s.get(n.nodeId);
2552
- o ? o.push(n) : s.set(n.nodeId, [n]);
2553
- }
2554
- return Ze(e, s);
2555
- }
2556
- function Ze(e, r, t) {
2557
- const s = r.get(e.id) ?? [];
2558
- let n = !1, o = e.props;
2559
- if (s.length > 0) {
2560
- const I = /* @__PURE__ */ new Map();
2561
- for (const l of s) {
2562
- const _ = I.get(l.propertyName);
2563
- _ ? _.push(l) : I.set(l.propertyName, [l]);
2564
- }
2565
- for (const [l, _] of I.entries()) {
2566
- const c = o[l], D = vo(typeof c == "string" ? c : "", _);
2567
- n || (o = G(o), n = !0), o[l] = D;
2568
- }
2569
- }
2570
- let i = !1;
2571
- const a = e.children ?? [];
2572
- let E = a;
2573
- if (a.length > 0) {
2574
- let I;
2575
- for (let l = 0; l < a.length; l++) {
2576
- const _ = a[l], c = Ze(_, r);
2577
- c.changed && (I || (I = [...a]), I[l] = c.node);
2578
- }
2579
- I && (E = I, i = !0);
2580
- }
2581
- return !n && !i ? { node: e, changed: !1 } : {
2582
- node: {
2583
- id: e.id,
2584
- type: e.type,
2585
- props: n ? o : e.props,
2586
- children: i ? E : a,
2587
- styleIds: e.styleIds,
2588
- ...e.sourceMarker ? { sourceMarker: e.sourceMarker } : {}
2589
- },
2590
- changed: !0
2591
- };
2592
- }
2593
- function le(e, r, t) {
2594
- return Math.max(r, Math.min(t, e));
2595
- }
2596
- function po(e, r) {
2597
- const t = Math.min(e.length, r.length);
2598
- let s = 0;
2599
- for (; s < t && e.charCodeAt(s) === r.charCodeAt(s); )
2600
- s++;
2601
- return s;
2602
- }
2603
- function G(e) {
2604
- const r = {}, t = Object.keys(e);
2605
- for (let s = 0; s < t.length; s++) {
2606
- const n = t[s];
2607
- r[n] = e[n];
2608
- }
2609
- return r;
2610
- }
2611
- function ee(e) {
2612
- return typeof e == "object" && e !== null && !Array.isArray(e);
2613
- }
2614
- function p(e, r) {
2615
- if (Object.is(e, r))
2616
- return !0;
2617
- if (Array.isArray(e) && Array.isArray(r)) {
2618
- if (e.length !== r.length)
2619
- return !1;
2620
- for (let t = 0; t < e.length; t++)
2621
- if (!p(e[t], r[t]))
2622
- return !1;
2623
- return !0;
2624
- }
2625
- if (ee(e) && ee(r)) {
2626
- const t = Object.keys(e), s = Object.keys(r);
2627
- if (t.length !== s.length)
2628
- return !1;
2629
- for (const n of t)
2630
- if (!p(e[n], r[n]))
2631
- return !1;
2632
- return !0;
2633
- }
2634
- return !1;
2635
- }
2636
- const Vo = 16, Go = 50, A = new Po(), m = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
2637
- let et = Vo, tt = Go, H = [], Y = null, $ = null, O = 0, J = 0;
2638
- const M = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map();
2639
- function Bo() {
2640
- return typeof performance < "u" ? performance.now() : Date.now();
2641
- }
2642
- function xo() {
2643
- try {
2644
- return crypto.randomUUID();
2645
- } catch {
2646
- return `${Date.now()}_${Math.random().toString(16).slice(2)}`;
2647
- }
2648
- }
2649
- function rt(e) {
2650
- const r = [];
2651
- for (const s of e.views)
2652
- r.push(s);
2653
- const t = [];
2654
- for (const s of e.payloads)
2655
- t.push(s);
2656
- return {
2657
- streamId: e.streamId,
2658
- category: e.category,
2659
- version: e.version ?? -1,
2660
- rootViewId: e.rootViewId,
2661
- views: r,
2662
- payloads: t
2663
- };
2664
- }
2665
- function Ho(e, r, t) {
2666
- if (!t || t.version === -1)
2667
- return { type: "ReplaceStreamSnapshot", snapshot: rt(r) };
2668
- let s, n;
2669
- for (const [a, E] of r.views)
2670
- t.views.get(a) !== E && (s ??= []).push([a, E]);
2671
- for (const a of t.views.keys())
2672
- r.views.has(a) || (n ??= []).push(a);
2673
- let o, i;
2674
- for (const [a, E] of r.payloads)
2675
- t.payloads.get(a) !== E && (o ??= []).push([a, E]);
2676
- for (const a of t.payloads.keys())
2677
- r.payloads.has(a) || (i ??= []).push(a);
2678
- return {
2679
- type: "PatchStreamSnapshot",
2680
- streamId: e,
2681
- category: r.category,
2682
- nextVersion: r.version ?? -1,
2683
- expectedBaseVersion: t.version ?? -1,
2684
- rootViewId: r.rootViewId,
2685
- upsertViews: s,
2686
- deleteViews: n,
2687
- upsertPayloads: o,
2688
- deletePayloads: i
2689
- };
2690
- }
2691
- function te() {
2692
- Y || (Y = setTimeout(Ee, et)), $ || ($ = setTimeout(Ee, tt));
2693
- }
2694
- function y(e) {
2695
- H.push(e), te();
2696
- }
2697
- function Ee() {
2698
- if (Y && (clearTimeout(Y), Y = null), $ && (clearTimeout($), $ = null), H.length === 0 && M.size === 0 && K.size === 0) {
2699
- O = 0, J = 0;
2700
- return;
2701
- }
2702
- const e = [];
2703
- for (const [s, n] of M)
2704
- e.push({ trackId: s, version: n.version, senderId: n.senderId });
2705
- const r = [];
2706
- for (const [s, n] of K)
2707
- r.push({ trackId: s, senderId: n });
2708
- const t = {
2709
- batchId: xo(),
2710
- createdAtMs: Bo(),
2711
- ops: H,
2712
- ...e.length > 0 ? { acks: e } : {},
2713
- ...r.length > 0 ? { resyncs: r } : {},
2714
- stats: { uiMessagesConsumed: O, bytesConsumed: J }
2715
- };
2716
- H = [], O = 0, J = 0, M.clear(), K.clear(), self.postMessage(t);
2717
- }
2718
- function Yo(e) {
2719
- return `${e.senderId}_${e.trackId}`;
2720
- }
2721
- async function $o(e) {
2722
- const r = await Pn(e), t = /* @__PURE__ */ new Set();
2723
- for (const s of Object.values(r.UIStreams ?? {})) {
2724
- const n = s.StreamId;
2725
- t.add(n);
2726
- const o = s.Info?.Category;
2727
- A.getSnapshot(n)?.category !== o && (A.setCategory(n, o), y({ type: "SetStreamCategory", streamId: n, category: o }));
2728
- }
2729
- for (const s of A.getSnapshots())
2730
- x.has(s.streamId) || t.has(s.streamId) || (A.remove(s.streamId), P.delete(s.streamId), y({ type: "RemoveStream", streamId: s.streamId }));
2731
- }
2732
- function Ko(e) {
2733
- if (x.size !== 0) {
2734
- for (const r of x)
2735
- r !== e && (A.remove(r), P.delete(r), y({ type: "RemoveStream", streamId: r }));
2736
- x.clear();
2737
- }
2738
- }
2739
- async function jo(e) {
2740
- const r = Ie(e), t = Yo(r), s = await Ks(e), n = We(s), o = M.get(r.trackId);
2741
- (o === void 0 || n.snapshot.version > o.version) && (M.set(r.trackId, { version: n.snapshot.version, senderId: r.senderId }), te());
2742
- const i = A.apply(t, n);
2743
- if (A.needsResync(t) && (K.set(r.trackId, r.senderId), te()), !i)
2744
- return;
2745
- const a = A.getSnapshot(t);
2746
- if (!a)
2747
- return;
2748
- const E = P.get(t);
2749
- P.set(t, a), y(Ho(t, a, E)), Ko(t);
2750
- }
2751
- async function Xo(e) {
2752
- const r = await us(e);
2753
- if (!r.StyleId)
2754
- return;
2755
- const t = {
2756
- styleId: r.StyleId,
2757
- css: r.Style?.css,
2758
- common: r.Style?.common
2759
- }, s = m.get(t.styleId);
2760
- s && s.css === t.css && s.common === t.common || (m.set(t.styleId, t), y({ type: "UpsertUiStyle", style: t }));
2761
- }
2762
- async function Wo(e) {
2763
- const r = await Rs(e);
2764
- if (r.Styles)
2765
- for (const t of r.Styles) {
2766
- if (!t.StyleId)
2767
- continue;
2768
- const s = {
2769
- styleId: t.StyleId,
2770
- css: t.Style?.css,
2771
- common: t.Style?.common
2772
- }, n = m.get(s.styleId);
2773
- n && n.css === s.css && n.common === s.common || (m.set(s.styleId, s), y({ type: "UpsertUiStyle", style: s }));
2774
- }
2775
- }
2776
- async function zo(e) {
2777
- const r = await ks(e);
2778
- if (!(!r.StyleIds || r.StyleIds.length === 0))
2779
- for (const t of r.StyleIds)
2780
- m.delete(t) && y({ type: "RemoveUiStyle", styleId: t });
2781
- }
2782
- function Jo(e) {
2783
- if (!A.getSnapshots().some((r) => r.rootViewId)) {
2784
- for (const r of e.styles) {
2785
- const t = m.get(r.styleId);
2786
- t && t.css === r.css && t.common === r.common || (m.set(r.styleId, r), y({ type: "UpsertUiStyle", style: r }));
2787
- }
2788
- if (e.bootJson && e.bootStreamId) {
2789
- const r = We({ Json: e.bootJson });
2790
- if (A.apply(e.bootStreamId, r)) {
2791
- const t = A.getSnapshot(e.bootStreamId);
2792
- t && (P.set(e.bootStreamId, t), x.add(e.bootStreamId), y({ type: "ReplaceStreamSnapshot", snapshot: rt(t), fromSeed: !0 }));
2793
- }
2794
- }
2795
- for (const r of e.liveStreams ?? [])
2796
- if (A.applyStoreOp({ type: "ReplaceStreamSnapshot", snapshot: r })) {
2797
- const t = A.getSnapshot(r.streamId);
2798
- t && P.set(r.streamId, t), y({ type: "ReplaceStreamSnapshot", snapshot: r, fromSeed: !0 });
2799
- }
2800
- A.enterSnapshotModeAll();
2801
- }
2802
- }
2803
- async function Qo(e) {
2804
- const r = new Uint8Array(e);
2805
- J += r.byteLength;
2806
- const t = r;
2807
- switch (ot(t)) {
2808
- case b.CORE_GLOBAL_STATE:
2809
- await $o(t), O++;
2810
- return;
2811
- case b.UI_UPDATE:
2812
- try {
2813
- await jo(t);
2814
- } catch (n) {
2815
- return n instanceof w, void 0;
2816
- } finally {
2817
- O++;
2818
- }
2819
- return;
2820
- case b.UI_STYLES:
2821
- await Xo(t), O++;
2822
- return;
2823
- case b.UI_STYLES_BATCH:
2824
- await Wo(t), O++;
2825
- return;
2826
- case b.UI_STYLES_DELETE:
2827
- await zo(t), O++;
2828
- return;
2829
- default:
2830
- return;
2831
- }
2832
- }
2833
- self.addEventListener("message", (e) => {
2834
- const r = e.data;
2835
- if (r.type === "configure") {
2836
- typeof r.flushIntervalMs == "number" && Number.isFinite(r.flushIntervalMs) && r.flushIntervalMs >= 0 && (et = r.flushIntervalMs), typeof r.maxLatencyMs == "number" && Number.isFinite(r.maxLatencyMs) && r.maxLatencyMs >= 0 && (tt = r.maxLatencyMs);
2837
- return;
2838
- }
2839
- if (r.type === "clear") {
2840
- H = [], P.clear(), M.clear(), K.clear(), m.clear();
2841
- for (const t of A.getSnapshots())
2842
- A.remove(t.streamId);
2843
- return;
2844
- }
2845
- if (r.type === "snapshotMode") {
2846
- A.enterSnapshotModeAll();
2847
- return;
2848
- }
2849
- if (r.type === "seed") {
2850
- Jo(r);
2851
- return;
2852
- }
2853
- r.type === "protocol" && Qo(r.message).catch(() => {
2854
- });
2855
- });