@ikonai/sdk-ui 1.0.13 → 1.0.14

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