@csfloat/cs2-inspect-serializer 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2570 +1,5 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // node_modules/crc-32/crc32.js
28
- var require_crc32 = __commonJS({
29
- "node_modules/crc-32/crc32.js"(exports) {
30
- "use strict";
31
- var CRC322;
32
- (function(factory) {
33
- if (typeof DO_NOT_EXPORT_CRC === "undefined") {
34
- if ("object" === typeof exports) {
35
- factory(exports);
36
- } else if ("function" === typeof define && define.amd) {
37
- define(function() {
38
- var module2 = {};
39
- factory(module2);
40
- return module2;
41
- });
42
- } else {
43
- factory(CRC322 = {});
44
- }
45
- } else {
46
- factory(CRC322 = {});
47
- }
48
- })(function(CRC323) {
49
- CRC323.version = "1.2.2";
50
- function signed_crc_table() {
51
- var c = 0, table = new Array(256);
52
- for (var n = 0; n != 256; ++n) {
53
- c = n;
54
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
55
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
56
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
57
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
58
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
59
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
60
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
61
- c = c & 1 ? -306674912 ^ c >>> 1 : c >>> 1;
62
- table[n] = c;
63
- }
64
- return typeof Int32Array !== "undefined" ? new Int32Array(table) : table;
65
- }
66
- var T0 = signed_crc_table();
67
- function slice_by_16_tables(T) {
68
- var c = 0, v = 0, n = 0, table = typeof Int32Array !== "undefined" ? new Int32Array(4096) : new Array(4096);
69
- for (n = 0; n != 256; ++n) table[n] = T[n];
70
- for (n = 0; n != 256; ++n) {
71
- v = T[n];
72
- for (c = 256 + n; c < 4096; c += 256) v = table[c] = v >>> 8 ^ T[v & 255];
73
- }
74
- var out = [];
75
- for (n = 1; n != 16; ++n) out[n - 1] = typeof Int32Array !== "undefined" ? table.subarray(n * 256, n * 256 + 256) : table.slice(n * 256, n * 256 + 256);
76
- return out;
77
- }
78
- var TT = slice_by_16_tables(T0);
79
- var T1 = TT[0], T2 = TT[1], T3 = TT[2], T4 = TT[3], T5 = TT[4];
80
- var T6 = TT[5], T7 = TT[6], T8 = TT[7], T9 = TT[8], Ta = TT[9];
81
- var Tb = TT[10], Tc = TT[11], Td = TT[12], Te = TT[13], Tf = TT[14];
82
- function crc32_bstr(bstr, seed) {
83
- var C = seed ^ -1;
84
- for (var i = 0, L = bstr.length; i < L; ) C = C >>> 8 ^ T0[(C ^ bstr.charCodeAt(i++)) & 255];
85
- return ~C;
86
- }
87
- function crc32_buf(B, seed) {
88
- var C = seed ^ -1, L = B.length - 15, i = 0;
89
- for (; i < L; ) C = Tf[B[i++] ^ C & 255] ^ Te[B[i++] ^ C >> 8 & 255] ^ Td[B[i++] ^ C >> 16 & 255] ^ Tc[B[i++] ^ C >>> 24] ^ Tb[B[i++]] ^ Ta[B[i++]] ^ T9[B[i++]] ^ T8[B[i++]] ^ T7[B[i++]] ^ T6[B[i++]] ^ T5[B[i++]] ^ T4[B[i++]] ^ T3[B[i++]] ^ T2[B[i++]] ^ T1[B[i++]] ^ T0[B[i++]];
90
- L += 15;
91
- while (i < L) C = C >>> 8 ^ T0[(C ^ B[i++]) & 255];
92
- return ~C;
93
- }
94
- function crc32_str(str, seed) {
95
- var C = seed ^ -1;
96
- for (var i = 0, L = str.length, c = 0, d = 0; i < L; ) {
97
- c = str.charCodeAt(i++);
98
- if (c < 128) {
99
- C = C >>> 8 ^ T0[(C ^ c) & 255];
100
- } else if (c < 2048) {
101
- C = C >>> 8 ^ T0[(C ^ (192 | c >> 6 & 31)) & 255];
102
- C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 255];
103
- } else if (c >= 55296 && c < 57344) {
104
- c = (c & 1023) + 64;
105
- d = str.charCodeAt(i++) & 1023;
106
- C = C >>> 8 ^ T0[(C ^ (240 | c >> 8 & 7)) & 255];
107
- C = C >>> 8 ^ T0[(C ^ (128 | c >> 2 & 63)) & 255];
108
- C = C >>> 8 ^ T0[(C ^ (128 | d >> 6 & 15 | (c & 3) << 4)) & 255];
109
- C = C >>> 8 ^ T0[(C ^ (128 | d & 63)) & 255];
110
- } else {
111
- C = C >>> 8 ^ T0[(C ^ (224 | c >> 12 & 15)) & 255];
112
- C = C >>> 8 ^ T0[(C ^ (128 | c >> 6 & 63)) & 255];
113
- C = C >>> 8 ^ T0[(C ^ (128 | c & 63)) & 255];
114
- }
115
- }
116
- return ~C;
117
- }
118
- CRC323.table = T0;
119
- CRC323.bstr = crc32_bstr;
120
- CRC323.buf = crc32_buf;
121
- CRC323.str = crc32_str;
122
- });
123
- }
124
- });
125
-
126
- // node_modules/@protobuf-ts/runtime/build/es2015/json-typings.js
127
- function typeofJsonValue(value) {
128
- let t = typeof value;
129
- if (t == "object") {
130
- if (Array.isArray(value))
131
- return "array";
132
- if (value === null)
133
- return "null";
134
- }
135
- return t;
136
- }
137
- function isJsonObject(value) {
138
- return value !== null && typeof value == "object" && !Array.isArray(value);
139
- }
140
-
141
- // node_modules/@protobuf-ts/runtime/build/es2015/base64.js
142
- var encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
143
- var decTable = [];
144
- for (let i = 0; i < encTable.length; i++)
145
- decTable[encTable[i].charCodeAt(0)] = i;
146
- decTable["-".charCodeAt(0)] = encTable.indexOf("+");
147
- decTable["_".charCodeAt(0)] = encTable.indexOf("/");
148
- function base64decode(base64Str) {
149
- let es = base64Str.length * 3 / 4;
150
- if (base64Str[base64Str.length - 2] == "=")
151
- es -= 2;
152
- else if (base64Str[base64Str.length - 1] == "=")
153
- es -= 1;
154
- let bytes = new Uint8Array(es), bytePos = 0, groupPos = 0, b, p = 0;
155
- for (let i = 0; i < base64Str.length; i++) {
156
- b = decTable[base64Str.charCodeAt(i)];
157
- if (b === void 0) {
158
- switch (base64Str[i]) {
159
- case "=":
160
- groupPos = 0;
161
- // reset state when padding found
162
- case "\n":
163
- case "\r":
164
- case " ":
165
- case " ":
166
- continue;
167
- // skip white-space, and padding
168
- default:
169
- throw Error(`invalid base64 string.`);
170
- }
171
- }
172
- switch (groupPos) {
173
- case 0:
174
- p = b;
175
- groupPos = 1;
176
- break;
177
- case 1:
178
- bytes[bytePos++] = p << 2 | (b & 48) >> 4;
179
- p = b;
180
- groupPos = 2;
181
- break;
182
- case 2:
183
- bytes[bytePos++] = (p & 15) << 4 | (b & 60) >> 2;
184
- p = b;
185
- groupPos = 3;
186
- break;
187
- case 3:
188
- bytes[bytePos++] = (p & 3) << 6 | b;
189
- groupPos = 0;
190
- break;
191
- }
192
- }
193
- if (groupPos == 1)
194
- throw Error(`invalid base64 string.`);
195
- return bytes.subarray(0, bytePos);
196
- }
197
- function base64encode(bytes) {
198
- let base64 = "", groupPos = 0, b, p = 0;
199
- for (let i = 0; i < bytes.length; i++) {
200
- b = bytes[i];
201
- switch (groupPos) {
202
- case 0:
203
- base64 += encTable[b >> 2];
204
- p = (b & 3) << 4;
205
- groupPos = 1;
206
- break;
207
- case 1:
208
- base64 += encTable[p | b >> 4];
209
- p = (b & 15) << 2;
210
- groupPos = 2;
211
- break;
212
- case 2:
213
- base64 += encTable[p | b >> 6];
214
- base64 += encTable[b & 63];
215
- groupPos = 0;
216
- break;
217
- }
218
- }
219
- if (groupPos) {
220
- base64 += encTable[p];
221
- base64 += "=";
222
- if (groupPos == 1)
223
- base64 += "=";
224
- }
225
- return base64;
226
- }
227
-
228
- // node_modules/@protobuf-ts/runtime/build/es2015/binary-format-contract.js
229
- var UnknownFieldHandler;
230
- (function(UnknownFieldHandler2) {
231
- UnknownFieldHandler2.symbol = Symbol.for("protobuf-ts/unknown");
232
- UnknownFieldHandler2.onRead = (typeName, message, fieldNo, wireType, data) => {
233
- let container = is(message) ? message[UnknownFieldHandler2.symbol] : message[UnknownFieldHandler2.symbol] = [];
234
- container.push({ no: fieldNo, wireType, data });
235
- };
236
- UnknownFieldHandler2.onWrite = (typeName, message, writer) => {
237
- for (let { no, wireType, data } of UnknownFieldHandler2.list(message))
238
- writer.tag(no, wireType).raw(data);
239
- };
240
- UnknownFieldHandler2.list = (message, fieldNo) => {
241
- if (is(message)) {
242
- let all = message[UnknownFieldHandler2.symbol];
243
- return fieldNo ? all.filter((uf) => uf.no == fieldNo) : all;
244
- }
245
- return [];
246
- };
247
- UnknownFieldHandler2.last = (message, fieldNo) => UnknownFieldHandler2.list(message, fieldNo).slice(-1)[0];
248
- const is = (message) => message && Array.isArray(message[UnknownFieldHandler2.symbol]);
249
- })(UnknownFieldHandler || (UnknownFieldHandler = {}));
250
- var WireType;
251
- (function(WireType2) {
252
- WireType2[WireType2["Varint"] = 0] = "Varint";
253
- WireType2[WireType2["Bit64"] = 1] = "Bit64";
254
- WireType2[WireType2["LengthDelimited"] = 2] = "LengthDelimited";
255
- WireType2[WireType2["StartGroup"] = 3] = "StartGroup";
256
- WireType2[WireType2["EndGroup"] = 4] = "EndGroup";
257
- WireType2[WireType2["Bit32"] = 5] = "Bit32";
258
- })(WireType || (WireType = {}));
259
-
260
- // node_modules/@protobuf-ts/runtime/build/es2015/goog-varint.js
261
- function varint64read() {
262
- let lowBits = 0;
263
- let highBits = 0;
264
- for (let shift = 0; shift < 28; shift += 7) {
265
- let b = this.buf[this.pos++];
266
- lowBits |= (b & 127) << shift;
267
- if ((b & 128) == 0) {
268
- this.assertBounds();
269
- return [lowBits, highBits];
270
- }
271
- }
272
- let middleByte = this.buf[this.pos++];
273
- lowBits |= (middleByte & 15) << 28;
274
- highBits = (middleByte & 112) >> 4;
275
- if ((middleByte & 128) == 0) {
276
- this.assertBounds();
277
- return [lowBits, highBits];
278
- }
279
- for (let shift = 3; shift <= 31; shift += 7) {
280
- let b = this.buf[this.pos++];
281
- highBits |= (b & 127) << shift;
282
- if ((b & 128) == 0) {
283
- this.assertBounds();
284
- return [lowBits, highBits];
285
- }
286
- }
287
- throw new Error("invalid varint");
288
- }
289
- function varint64write(lo, hi, bytes) {
290
- for (let i = 0; i < 28; i = i + 7) {
291
- const shift = lo >>> i;
292
- const hasNext = !(shift >>> 7 == 0 && hi == 0);
293
- const byte = (hasNext ? shift | 128 : shift) & 255;
294
- bytes.push(byte);
295
- if (!hasNext) {
296
- return;
297
- }
298
- }
299
- const splitBits = lo >>> 28 & 15 | (hi & 7) << 4;
300
- const hasMoreBits = !(hi >> 3 == 0);
301
- bytes.push((hasMoreBits ? splitBits | 128 : splitBits) & 255);
302
- if (!hasMoreBits) {
303
- return;
304
- }
305
- for (let i = 3; i < 31; i = i + 7) {
306
- const shift = hi >>> i;
307
- const hasNext = !(shift >>> 7 == 0);
308
- const byte = (hasNext ? shift | 128 : shift) & 255;
309
- bytes.push(byte);
310
- if (!hasNext) {
311
- return;
312
- }
313
- }
314
- bytes.push(hi >>> 31 & 1);
315
- }
316
- var TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
317
- function int64fromString(dec) {
318
- let minus = dec[0] == "-";
319
- if (minus)
320
- dec = dec.slice(1);
321
- const base = 1e6;
322
- let lowBits = 0;
323
- let highBits = 0;
324
- function add1e6digit(begin, end) {
325
- const digit1e6 = Number(dec.slice(begin, end));
326
- highBits *= base;
327
- lowBits = lowBits * base + digit1e6;
328
- if (lowBits >= TWO_PWR_32_DBL) {
329
- highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0);
330
- lowBits = lowBits % TWO_PWR_32_DBL;
331
- }
332
- }
333
- add1e6digit(-24, -18);
334
- add1e6digit(-18, -12);
335
- add1e6digit(-12, -6);
336
- add1e6digit(-6);
337
- return [minus, lowBits, highBits];
338
- }
339
- function int64toString(bitsLow, bitsHigh) {
340
- if (bitsHigh >>> 0 <= 2097151) {
341
- return "" + (TWO_PWR_32_DBL * bitsHigh + (bitsLow >>> 0));
342
- }
343
- let low = bitsLow & 16777215;
344
- let mid = (bitsLow >>> 24 | bitsHigh << 8) >>> 0 & 16777215;
345
- let high = bitsHigh >> 16 & 65535;
346
- let digitA = low + mid * 6777216 + high * 6710656;
347
- let digitB = mid + high * 8147497;
348
- let digitC = high * 2;
349
- let base = 1e7;
350
- if (digitA >= base) {
351
- digitB += Math.floor(digitA / base);
352
- digitA %= base;
353
- }
354
- if (digitB >= base) {
355
- digitC += Math.floor(digitB / base);
356
- digitB %= base;
357
- }
358
- function decimalFrom1e7(digit1e7, needLeadingZeros) {
359
- let partial = digit1e7 ? String(digit1e7) : "";
360
- if (needLeadingZeros) {
361
- return "0000000".slice(partial.length) + partial;
362
- }
363
- return partial;
364
- }
365
- return decimalFrom1e7(
366
- digitC,
367
- /*needLeadingZeros=*/
368
- 0
369
- ) + decimalFrom1e7(
370
- digitB,
371
- /*needLeadingZeros=*/
372
- digitC
373
- ) + // If the final 1e7 digit didn't need leading zeros, we would have
374
- // returned via the trivial code path at the top.
375
- decimalFrom1e7(
376
- digitA,
377
- /*needLeadingZeros=*/
378
- 1
379
- );
380
- }
381
- function varint32write(value, bytes) {
382
- if (value >= 0) {
383
- while (value > 127) {
384
- bytes.push(value & 127 | 128);
385
- value = value >>> 7;
386
- }
387
- bytes.push(value);
388
- } else {
389
- for (let i = 0; i < 9; i++) {
390
- bytes.push(value & 127 | 128);
391
- value = value >> 7;
392
- }
393
- bytes.push(1);
394
- }
395
- }
396
- function varint32read() {
397
- let b = this.buf[this.pos++];
398
- let result = b & 127;
399
- if ((b & 128) == 0) {
400
- this.assertBounds();
401
- return result;
402
- }
403
- b = this.buf[this.pos++];
404
- result |= (b & 127) << 7;
405
- if ((b & 128) == 0) {
406
- this.assertBounds();
407
- return result;
408
- }
409
- b = this.buf[this.pos++];
410
- result |= (b & 127) << 14;
411
- if ((b & 128) == 0) {
412
- this.assertBounds();
413
- return result;
414
- }
415
- b = this.buf[this.pos++];
416
- result |= (b & 127) << 21;
417
- if ((b & 128) == 0) {
418
- this.assertBounds();
419
- return result;
420
- }
421
- b = this.buf[this.pos++];
422
- result |= (b & 15) << 28;
423
- for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++)
424
- b = this.buf[this.pos++];
425
- if ((b & 128) != 0)
426
- throw new Error("invalid varint");
427
- this.assertBounds();
428
- return result >>> 0;
429
- }
430
-
431
- // node_modules/@protobuf-ts/runtime/build/es2015/pb-long.js
432
- var BI;
433
- function detectBi() {
434
- const dv = new DataView(new ArrayBuffer(8));
435
- const ok = globalThis.BigInt !== void 0 && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function";
436
- BI = ok ? {
437
- MIN: BigInt("-9223372036854775808"),
438
- MAX: BigInt("9223372036854775807"),
439
- UMIN: BigInt("0"),
440
- UMAX: BigInt("18446744073709551615"),
441
- C: BigInt,
442
- V: dv
443
- } : void 0;
444
- }
445
- detectBi();
446
- function assertBi(bi) {
447
- if (!bi)
448
- throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support");
449
- }
450
- var RE_DECIMAL_STR = /^-?[0-9]+$/;
451
- var TWO_PWR_32_DBL2 = 4294967296;
452
- var HALF_2_PWR_32 = 2147483648;
453
- var SharedPbLong = class {
454
- /**
455
- * Create a new instance with the given bits.
456
- */
457
- constructor(lo, hi) {
458
- this.lo = lo | 0;
459
- this.hi = hi | 0;
460
- }
461
- /**
462
- * Is this instance equal to 0?
463
- */
464
- isZero() {
465
- return this.lo == 0 && this.hi == 0;
466
- }
467
- /**
468
- * Convert to a native number.
469
- */
470
- toNumber() {
471
- let result = this.hi * TWO_PWR_32_DBL2 + (this.lo >>> 0);
472
- if (!Number.isSafeInteger(result))
473
- throw new Error("cannot convert to safe number");
474
- return result;
475
- }
476
- };
477
- var PbULong = class _PbULong extends SharedPbLong {
478
- /**
479
- * Create instance from a `string`, `number` or `bigint`.
480
- */
481
- static from(value) {
482
- if (BI)
483
- switch (typeof value) {
484
- case "string":
485
- if (value == "0")
486
- return this.ZERO;
487
- if (value == "")
488
- throw new Error("string is no integer");
489
- value = BI.C(value);
490
- case "number":
491
- if (value === 0)
492
- return this.ZERO;
493
- value = BI.C(value);
494
- case "bigint":
495
- if (!value)
496
- return this.ZERO;
497
- if (value < BI.UMIN)
498
- throw new Error("signed value for ulong");
499
- if (value > BI.UMAX)
500
- throw new Error("ulong too large");
501
- BI.V.setBigUint64(0, value, true);
502
- return new _PbULong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));
503
- }
504
- else
505
- switch (typeof value) {
506
- case "string":
507
- if (value == "0")
508
- return this.ZERO;
509
- value = value.trim();
510
- if (!RE_DECIMAL_STR.test(value))
511
- throw new Error("string is no integer");
512
- let [minus, lo, hi] = int64fromString(value);
513
- if (minus)
514
- throw new Error("signed value for ulong");
515
- return new _PbULong(lo, hi);
516
- case "number":
517
- if (value == 0)
518
- return this.ZERO;
519
- if (!Number.isSafeInteger(value))
520
- throw new Error("number is no integer");
521
- if (value < 0)
522
- throw new Error("signed value for ulong");
523
- return new _PbULong(value, value / TWO_PWR_32_DBL2);
524
- }
525
- throw new Error("unknown value " + typeof value);
526
- }
527
- /**
528
- * Convert to decimal string.
529
- */
530
- toString() {
531
- return BI ? this.toBigInt().toString() : int64toString(this.lo, this.hi);
532
- }
533
- /**
534
- * Convert to native bigint.
535
- */
536
- toBigInt() {
537
- assertBi(BI);
538
- BI.V.setInt32(0, this.lo, true);
539
- BI.V.setInt32(4, this.hi, true);
540
- return BI.V.getBigUint64(0, true);
541
- }
542
- };
543
- PbULong.ZERO = new PbULong(0, 0);
544
- var PbLong = class _PbLong extends SharedPbLong {
545
- /**
546
- * Create instance from a `string`, `number` or `bigint`.
547
- */
548
- static from(value) {
549
- if (BI)
550
- switch (typeof value) {
551
- case "string":
552
- if (value == "0")
553
- return this.ZERO;
554
- if (value == "")
555
- throw new Error("string is no integer");
556
- value = BI.C(value);
557
- case "number":
558
- if (value === 0)
559
- return this.ZERO;
560
- value = BI.C(value);
561
- case "bigint":
562
- if (!value)
563
- return this.ZERO;
564
- if (value < BI.MIN)
565
- throw new Error("signed long too small");
566
- if (value > BI.MAX)
567
- throw new Error("signed long too large");
568
- BI.V.setBigInt64(0, value, true);
569
- return new _PbLong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));
570
- }
571
- else
572
- switch (typeof value) {
573
- case "string":
574
- if (value == "0")
575
- return this.ZERO;
576
- value = value.trim();
577
- if (!RE_DECIMAL_STR.test(value))
578
- throw new Error("string is no integer");
579
- let [minus, lo, hi] = int64fromString(value);
580
- if (minus) {
581
- if (hi > HALF_2_PWR_32 || hi == HALF_2_PWR_32 && lo != 0)
582
- throw new Error("signed long too small");
583
- } else if (hi >= HALF_2_PWR_32)
584
- throw new Error("signed long too large");
585
- let pbl = new _PbLong(lo, hi);
586
- return minus ? pbl.negate() : pbl;
587
- case "number":
588
- if (value == 0)
589
- return this.ZERO;
590
- if (!Number.isSafeInteger(value))
591
- throw new Error("number is no integer");
592
- return value > 0 ? new _PbLong(value, value / TWO_PWR_32_DBL2) : new _PbLong(-value, -value / TWO_PWR_32_DBL2).negate();
593
- }
594
- throw new Error("unknown value " + typeof value);
595
- }
596
- /**
597
- * Do we have a minus sign?
598
- */
599
- isNegative() {
600
- return (this.hi & HALF_2_PWR_32) !== 0;
601
- }
602
- /**
603
- * Negate two's complement.
604
- * Invert all the bits and add one to the result.
605
- */
606
- negate() {
607
- let hi = ~this.hi, lo = this.lo;
608
- if (lo)
609
- lo = ~lo + 1;
610
- else
611
- hi += 1;
612
- return new _PbLong(lo, hi);
613
- }
614
- /**
615
- * Convert to decimal string.
616
- */
617
- toString() {
618
- if (BI)
619
- return this.toBigInt().toString();
620
- if (this.isNegative()) {
621
- let n = this.negate();
622
- return "-" + int64toString(n.lo, n.hi);
623
- }
624
- return int64toString(this.lo, this.hi);
625
- }
626
- /**
627
- * Convert to native bigint.
628
- */
629
- toBigInt() {
630
- assertBi(BI);
631
- BI.V.setInt32(0, this.lo, true);
632
- BI.V.setInt32(4, this.hi, true);
633
- return BI.V.getBigInt64(0, true);
634
- }
635
- };
636
- PbLong.ZERO = new PbLong(0, 0);
637
-
638
- // node_modules/@protobuf-ts/runtime/build/es2015/binary-reader.js
639
- var defaultsRead = {
640
- readUnknownField: true,
641
- readerFactory: (bytes) => new BinaryReader(bytes)
642
- };
643
- function binaryReadOptions(options) {
644
- return options ? Object.assign(Object.assign({}, defaultsRead), options) : defaultsRead;
645
- }
646
- var BinaryReader = class {
647
- constructor(buf, textDecoder) {
648
- this.varint64 = varint64read;
649
- this.uint32 = varint32read;
650
- this.buf = buf;
651
- this.len = buf.length;
652
- this.pos = 0;
653
- this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
654
- this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder("utf-8", {
655
- fatal: true,
656
- ignoreBOM: true
657
- });
658
- }
659
- /**
660
- * Reads a tag - field number and wire type.
661
- */
662
- tag() {
663
- let tag = this.uint32(), fieldNo = tag >>> 3, wireType = tag & 7;
664
- if (fieldNo <= 0 || wireType < 0 || wireType > 5)
665
- throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
666
- return [fieldNo, wireType];
667
- }
668
- /**
669
- * Skip one element on the wire and return the skipped data.
670
- * Supports WireType.StartGroup since v2.0.0-alpha.23.
671
- */
672
- skip(wireType) {
673
- let start = this.pos;
674
- switch (wireType) {
675
- case WireType.Varint:
676
- while (this.buf[this.pos++] & 128) {
677
- }
678
- break;
679
- case WireType.Bit64:
680
- this.pos += 4;
681
- case WireType.Bit32:
682
- this.pos += 4;
683
- break;
684
- case WireType.LengthDelimited:
685
- let len = this.uint32();
686
- this.pos += len;
687
- break;
688
- case WireType.StartGroup:
689
- let t;
690
- while ((t = this.tag()[1]) !== WireType.EndGroup) {
691
- this.skip(t);
692
- }
693
- break;
694
- default:
695
- throw new Error("cant skip wire type " + wireType);
696
- }
697
- this.assertBounds();
698
- return this.buf.subarray(start, this.pos);
699
- }
700
- /**
701
- * Throws error if position in byte array is out of range.
702
- */
703
- assertBounds() {
704
- if (this.pos > this.len)
705
- throw new RangeError("premature EOF");
706
- }
707
- /**
708
- * Read a `int32` field, a signed 32 bit varint.
709
- */
710
- int32() {
711
- return this.uint32() | 0;
712
- }
713
- /**
714
- * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
715
- */
716
- sint32() {
717
- let zze = this.uint32();
718
- return zze >>> 1 ^ -(zze & 1);
719
- }
720
- /**
721
- * Read a `int64` field, a signed 64-bit varint.
722
- */
723
- int64() {
724
- return new PbLong(...this.varint64());
725
- }
726
- /**
727
- * Read a `uint64` field, an unsigned 64-bit varint.
728
- */
729
- uint64() {
730
- return new PbULong(...this.varint64());
731
- }
732
- /**
733
- * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
734
- */
735
- sint64() {
736
- let [lo, hi] = this.varint64();
737
- let s = -(lo & 1);
738
- lo = (lo >>> 1 | (hi & 1) << 31) ^ s;
739
- hi = hi >>> 1 ^ s;
740
- return new PbLong(lo, hi);
741
- }
742
- /**
743
- * Read a `bool` field, a variant.
744
- */
745
- bool() {
746
- let [lo, hi] = this.varint64();
747
- return lo !== 0 || hi !== 0;
748
- }
749
- /**
750
- * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
751
- */
752
- fixed32() {
753
- return this.view.getUint32((this.pos += 4) - 4, true);
754
- }
755
- /**
756
- * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
757
- */
758
- sfixed32() {
759
- return this.view.getInt32((this.pos += 4) - 4, true);
760
- }
761
- /**
762
- * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
763
- */
764
- fixed64() {
765
- return new PbULong(this.sfixed32(), this.sfixed32());
766
- }
767
- /**
768
- * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
769
- */
770
- sfixed64() {
771
- return new PbLong(this.sfixed32(), this.sfixed32());
772
- }
773
- /**
774
- * Read a `float` field, 32-bit floating point number.
775
- */
776
- float() {
777
- return this.view.getFloat32((this.pos += 4) - 4, true);
778
- }
779
- /**
780
- * Read a `double` field, a 64-bit floating point number.
781
- */
782
- double() {
783
- return this.view.getFloat64((this.pos += 8) - 8, true);
784
- }
785
- /**
786
- * Read a `bytes` field, length-delimited arbitrary data.
787
- */
788
- bytes() {
789
- let len = this.uint32();
790
- let start = this.pos;
791
- this.pos += len;
792
- this.assertBounds();
793
- return this.buf.subarray(start, start + len);
794
- }
795
- /**
796
- * Read a `string` field, length-delimited data converted to UTF-8 text.
797
- */
798
- string() {
799
- return this.textDecoder.decode(this.bytes());
800
- }
801
- };
802
-
803
- // node_modules/@protobuf-ts/runtime/build/es2015/assert.js
804
- function assert(condition, msg) {
805
- if (!condition) {
806
- throw new Error(msg);
807
- }
808
- }
809
- var FLOAT32_MAX = 34028234663852886e22;
810
- var FLOAT32_MIN = -34028234663852886e22;
811
- var UINT32_MAX = 4294967295;
812
- var INT32_MAX = 2147483647;
813
- var INT32_MIN = -2147483648;
814
- function assertInt32(arg) {
815
- if (typeof arg !== "number")
816
- throw new Error("invalid int 32: " + typeof arg);
817
- if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN)
818
- throw new Error("invalid int 32: " + arg);
819
- }
820
- function assertUInt32(arg) {
821
- if (typeof arg !== "number")
822
- throw new Error("invalid uint 32: " + typeof arg);
823
- if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0)
824
- throw new Error("invalid uint 32: " + arg);
825
- }
826
- function assertFloat32(arg) {
827
- if (typeof arg !== "number")
828
- throw new Error("invalid float 32: " + typeof arg);
829
- if (!Number.isFinite(arg))
830
- return;
831
- if (arg > FLOAT32_MAX || arg < FLOAT32_MIN)
832
- throw new Error("invalid float 32: " + arg);
833
- }
834
-
835
- // node_modules/@protobuf-ts/runtime/build/es2015/binary-writer.js
836
- var defaultsWrite = {
837
- writeUnknownFields: true,
838
- writerFactory: () => new BinaryWriter()
839
- };
840
- function binaryWriteOptions(options) {
841
- return options ? Object.assign(Object.assign({}, defaultsWrite), options) : defaultsWrite;
842
- }
843
- var BinaryWriter = class {
844
- constructor(textEncoder) {
845
- this.stack = [];
846
- this.textEncoder = textEncoder !== null && textEncoder !== void 0 ? textEncoder : new TextEncoder();
847
- this.chunks = [];
848
- this.buf = [];
849
- }
850
- /**
851
- * Return all bytes written and reset this writer.
852
- */
853
- finish() {
854
- this.chunks.push(new Uint8Array(this.buf));
855
- let len = 0;
856
- for (let i = 0; i < this.chunks.length; i++)
857
- len += this.chunks[i].length;
858
- let bytes = new Uint8Array(len);
859
- let offset = 0;
860
- for (let i = 0; i < this.chunks.length; i++) {
861
- bytes.set(this.chunks[i], offset);
862
- offset += this.chunks[i].length;
863
- }
864
- this.chunks = [];
865
- return bytes;
866
- }
867
- /**
868
- * Start a new fork for length-delimited data like a message
869
- * or a packed repeated field.
870
- *
871
- * Must be joined later with `join()`.
872
- */
873
- fork() {
874
- this.stack.push({ chunks: this.chunks, buf: this.buf });
875
- this.chunks = [];
876
- this.buf = [];
877
- return this;
878
- }
879
- /**
880
- * Join the last fork. Write its length and bytes, then
881
- * return to the previous state.
882
- */
883
- join() {
884
- let chunk = this.finish();
885
- let prev = this.stack.pop();
886
- if (!prev)
887
- throw new Error("invalid state, fork stack empty");
888
- this.chunks = prev.chunks;
889
- this.buf = prev.buf;
890
- this.uint32(chunk.byteLength);
891
- return this.raw(chunk);
892
- }
893
- /**
894
- * Writes a tag (field number and wire type).
895
- *
896
- * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
897
- *
898
- * Generated code should compute the tag ahead of time and call `uint32()`.
899
- */
900
- tag(fieldNo, type) {
901
- return this.uint32((fieldNo << 3 | type) >>> 0);
902
- }
903
- /**
904
- * Write a chunk of raw bytes.
905
- */
906
- raw(chunk) {
907
- if (this.buf.length) {
908
- this.chunks.push(new Uint8Array(this.buf));
909
- this.buf = [];
910
- }
911
- this.chunks.push(chunk);
912
- return this;
913
- }
914
- /**
915
- * Write a `uint32` value, an unsigned 32 bit varint.
916
- */
917
- uint32(value) {
918
- assertUInt32(value);
919
- while (value > 127) {
920
- this.buf.push(value & 127 | 128);
921
- value = value >>> 7;
922
- }
923
- this.buf.push(value);
924
- return this;
925
- }
926
- /**
927
- * Write a `int32` value, a signed 32 bit varint.
928
- */
929
- int32(value) {
930
- assertInt32(value);
931
- varint32write(value, this.buf);
932
- return this;
933
- }
934
- /**
935
- * Write a `bool` value, a variant.
936
- */
937
- bool(value) {
938
- this.buf.push(value ? 1 : 0);
939
- return this;
940
- }
941
- /**
942
- * Write a `bytes` value, length-delimited arbitrary data.
943
- */
944
- bytes(value) {
945
- this.uint32(value.byteLength);
946
- return this.raw(value);
947
- }
948
- /**
949
- * Write a `string` value, length-delimited data converted to UTF-8 text.
950
- */
951
- string(value) {
952
- let chunk = this.textEncoder.encode(value);
953
- this.uint32(chunk.byteLength);
954
- return this.raw(chunk);
955
- }
956
- /**
957
- * Write a `float` value, 32-bit floating point number.
958
- */
959
- float(value) {
960
- assertFloat32(value);
961
- let chunk = new Uint8Array(4);
962
- new DataView(chunk.buffer).setFloat32(0, value, true);
963
- return this.raw(chunk);
964
- }
965
- /**
966
- * Write a `double` value, a 64-bit floating point number.
967
- */
968
- double(value) {
969
- let chunk = new Uint8Array(8);
970
- new DataView(chunk.buffer).setFloat64(0, value, true);
971
- return this.raw(chunk);
972
- }
973
- /**
974
- * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
975
- */
976
- fixed32(value) {
977
- assertUInt32(value);
978
- let chunk = new Uint8Array(4);
979
- new DataView(chunk.buffer).setUint32(0, value, true);
980
- return this.raw(chunk);
981
- }
982
- /**
983
- * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
984
- */
985
- sfixed32(value) {
986
- assertInt32(value);
987
- let chunk = new Uint8Array(4);
988
- new DataView(chunk.buffer).setInt32(0, value, true);
989
- return this.raw(chunk);
990
- }
991
- /**
992
- * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
993
- */
994
- sint32(value) {
995
- assertInt32(value);
996
- value = (value << 1 ^ value >> 31) >>> 0;
997
- varint32write(value, this.buf);
998
- return this;
999
- }
1000
- /**
1001
- * Write a `fixed64` value, a signed, fixed-length 64-bit integer.
1002
- */
1003
- sfixed64(value) {
1004
- let chunk = new Uint8Array(8);
1005
- let view = new DataView(chunk.buffer);
1006
- let long = PbLong.from(value);
1007
- view.setInt32(0, long.lo, true);
1008
- view.setInt32(4, long.hi, true);
1009
- return this.raw(chunk);
1010
- }
1011
- /**
1012
- * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
1013
- */
1014
- fixed64(value) {
1015
- let chunk = new Uint8Array(8);
1016
- let view = new DataView(chunk.buffer);
1017
- let long = PbULong.from(value);
1018
- view.setInt32(0, long.lo, true);
1019
- view.setInt32(4, long.hi, true);
1020
- return this.raw(chunk);
1021
- }
1022
- /**
1023
- * Write a `int64` value, a signed 64-bit varint.
1024
- */
1025
- int64(value) {
1026
- let long = PbLong.from(value);
1027
- varint64write(long.lo, long.hi, this.buf);
1028
- return this;
1029
- }
1030
- /**
1031
- * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
1032
- */
1033
- sint64(value) {
1034
- let long = PbLong.from(value), sign = long.hi >> 31, lo = long.lo << 1 ^ sign, hi = (long.hi << 1 | long.lo >>> 31) ^ sign;
1035
- varint64write(lo, hi, this.buf);
1036
- return this;
1037
- }
1038
- /**
1039
- * Write a `uint64` value, an unsigned 64-bit varint.
1040
- */
1041
- uint64(value) {
1042
- let long = PbULong.from(value);
1043
- varint64write(long.lo, long.hi, this.buf);
1044
- return this;
1045
- }
1046
- };
1047
-
1048
- // node_modules/@protobuf-ts/runtime/build/es2015/json-format-contract.js
1049
- var defaultsWrite2 = {
1050
- emitDefaultValues: false,
1051
- enumAsInteger: false,
1052
- useProtoFieldName: false,
1053
- prettySpaces: 0
1054
- };
1055
- var defaultsRead2 = {
1056
- ignoreUnknownFields: false
1057
- };
1058
- function jsonReadOptions(options) {
1059
- return options ? Object.assign(Object.assign({}, defaultsRead2), options) : defaultsRead2;
1060
- }
1061
- function jsonWriteOptions(options) {
1062
- return options ? Object.assign(Object.assign({}, defaultsWrite2), options) : defaultsWrite2;
1063
- }
1064
-
1065
- // node_modules/@protobuf-ts/runtime/build/es2015/message-type-contract.js
1066
- var MESSAGE_TYPE = Symbol.for("protobuf-ts/message-type");
1067
-
1068
- // node_modules/@protobuf-ts/runtime/build/es2015/lower-camel-case.js
1069
- function lowerCamelCase(snakeCase) {
1070
- let capNext = false;
1071
- const sb = [];
1072
- for (let i = 0; i < snakeCase.length; i++) {
1073
- let next = snakeCase.charAt(i);
1074
- if (next == "_") {
1075
- capNext = true;
1076
- } else if (/\d/.test(next)) {
1077
- sb.push(next);
1078
- capNext = true;
1079
- } else if (capNext) {
1080
- sb.push(next.toUpperCase());
1081
- capNext = false;
1082
- } else if (i == 0) {
1083
- sb.push(next.toLowerCase());
1084
- } else {
1085
- sb.push(next);
1086
- }
1087
- }
1088
- return sb.join("");
1089
- }
1090
-
1091
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-info.js
1092
- var ScalarType;
1093
- (function(ScalarType2) {
1094
- ScalarType2[ScalarType2["DOUBLE"] = 1] = "DOUBLE";
1095
- ScalarType2[ScalarType2["FLOAT"] = 2] = "FLOAT";
1096
- ScalarType2[ScalarType2["INT64"] = 3] = "INT64";
1097
- ScalarType2[ScalarType2["UINT64"] = 4] = "UINT64";
1098
- ScalarType2[ScalarType2["INT32"] = 5] = "INT32";
1099
- ScalarType2[ScalarType2["FIXED64"] = 6] = "FIXED64";
1100
- ScalarType2[ScalarType2["FIXED32"] = 7] = "FIXED32";
1101
- ScalarType2[ScalarType2["BOOL"] = 8] = "BOOL";
1102
- ScalarType2[ScalarType2["STRING"] = 9] = "STRING";
1103
- ScalarType2[ScalarType2["BYTES"] = 12] = "BYTES";
1104
- ScalarType2[ScalarType2["UINT32"] = 13] = "UINT32";
1105
- ScalarType2[ScalarType2["SFIXED32"] = 15] = "SFIXED32";
1106
- ScalarType2[ScalarType2["SFIXED64"] = 16] = "SFIXED64";
1107
- ScalarType2[ScalarType2["SINT32"] = 17] = "SINT32";
1108
- ScalarType2[ScalarType2["SINT64"] = 18] = "SINT64";
1109
- })(ScalarType || (ScalarType = {}));
1110
- var LongType;
1111
- (function(LongType2) {
1112
- LongType2[LongType2["BIGINT"] = 0] = "BIGINT";
1113
- LongType2[LongType2["STRING"] = 1] = "STRING";
1114
- LongType2[LongType2["NUMBER"] = 2] = "NUMBER";
1115
- })(LongType || (LongType = {}));
1116
- var RepeatType;
1117
- (function(RepeatType2) {
1118
- RepeatType2[RepeatType2["NO"] = 0] = "NO";
1119
- RepeatType2[RepeatType2["PACKED"] = 1] = "PACKED";
1120
- RepeatType2[RepeatType2["UNPACKED"] = 2] = "UNPACKED";
1121
- })(RepeatType || (RepeatType = {}));
1122
- function normalizeFieldInfo(field) {
1123
- var _a, _b, _c, _d;
1124
- field.localName = (_a = field.localName) !== null && _a !== void 0 ? _a : lowerCamelCase(field.name);
1125
- field.jsonName = (_b = field.jsonName) !== null && _b !== void 0 ? _b : lowerCamelCase(field.name);
1126
- field.repeat = (_c = field.repeat) !== null && _c !== void 0 ? _c : RepeatType.NO;
1127
- field.opt = (_d = field.opt) !== null && _d !== void 0 ? _d : field.repeat ? false : field.oneof ? false : field.kind == "message";
1128
- return field;
1129
- }
1130
-
1131
- // node_modules/@protobuf-ts/runtime/build/es2015/oneof.js
1132
- function isOneofGroup(any) {
1133
- if (typeof any != "object" || any === null || !any.hasOwnProperty("oneofKind")) {
1134
- return false;
1135
- }
1136
- switch (typeof any.oneofKind) {
1137
- case "string":
1138
- if (any[any.oneofKind] === void 0)
1139
- return false;
1140
- return Object.keys(any).length == 2;
1141
- case "undefined":
1142
- return Object.keys(any).length == 1;
1143
- default:
1144
- return false;
1145
- }
1146
- }
1147
-
1148
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-type-check.js
1149
- var ReflectionTypeCheck = class {
1150
- constructor(info) {
1151
- var _a;
1152
- this.fields = (_a = info.fields) !== null && _a !== void 0 ? _a : [];
1153
- }
1154
- prepare() {
1155
- if (this.data)
1156
- return;
1157
- const req = [], known = [], oneofs = [];
1158
- for (let field of this.fields) {
1159
- if (field.oneof) {
1160
- if (!oneofs.includes(field.oneof)) {
1161
- oneofs.push(field.oneof);
1162
- req.push(field.oneof);
1163
- known.push(field.oneof);
1164
- }
1165
- } else {
1166
- known.push(field.localName);
1167
- switch (field.kind) {
1168
- case "scalar":
1169
- case "enum":
1170
- if (!field.opt || field.repeat)
1171
- req.push(field.localName);
1172
- break;
1173
- case "message":
1174
- if (field.repeat)
1175
- req.push(field.localName);
1176
- break;
1177
- case "map":
1178
- req.push(field.localName);
1179
- break;
1180
- }
1181
- }
1182
- }
1183
- this.data = { req, known, oneofs: Object.values(oneofs) };
1184
- }
1185
- /**
1186
- * Is the argument a valid message as specified by the
1187
- * reflection information?
1188
- *
1189
- * Checks all field types recursively. The `depth`
1190
- * specifies how deep into the structure the check will be.
1191
- *
1192
- * With a depth of 0, only the presence of fields
1193
- * is checked.
1194
- *
1195
- * With a depth of 1 or more, the field types are checked.
1196
- *
1197
- * With a depth of 2 or more, the members of map, repeated
1198
- * and message fields are checked.
1199
- *
1200
- * Message fields will be checked recursively with depth - 1.
1201
- *
1202
- * The number of map entries / repeated values being checked
1203
- * is < depth.
1204
- */
1205
- is(message, depth, allowExcessProperties = false) {
1206
- if (depth < 0)
1207
- return true;
1208
- if (message === null || message === void 0 || typeof message != "object")
1209
- return false;
1210
- this.prepare();
1211
- let keys = Object.keys(message), data = this.data;
1212
- if (keys.length < data.req.length || data.req.some((n) => !keys.includes(n)))
1213
- return false;
1214
- if (!allowExcessProperties) {
1215
- if (keys.some((k) => !data.known.includes(k)))
1216
- return false;
1217
- }
1218
- if (depth < 1) {
1219
- return true;
1220
- }
1221
- for (const name of data.oneofs) {
1222
- const group = message[name];
1223
- if (!isOneofGroup(group))
1224
- return false;
1225
- if (group.oneofKind === void 0)
1226
- continue;
1227
- const field = this.fields.find((f) => f.localName === group.oneofKind);
1228
- if (!field)
1229
- return false;
1230
- if (!this.field(group[group.oneofKind], field, allowExcessProperties, depth))
1231
- return false;
1232
- }
1233
- for (const field of this.fields) {
1234
- if (field.oneof !== void 0)
1235
- continue;
1236
- if (!this.field(message[field.localName], field, allowExcessProperties, depth))
1237
- return false;
1238
- }
1239
- return true;
1240
- }
1241
- field(arg, field, allowExcessProperties, depth) {
1242
- let repeated = field.repeat;
1243
- switch (field.kind) {
1244
- case "scalar":
1245
- if (arg === void 0)
1246
- return field.opt;
1247
- if (repeated)
1248
- return this.scalars(arg, field.T, depth, field.L);
1249
- return this.scalar(arg, field.T, field.L);
1250
- case "enum":
1251
- if (arg === void 0)
1252
- return field.opt;
1253
- if (repeated)
1254
- return this.scalars(arg, ScalarType.INT32, depth);
1255
- return this.scalar(arg, ScalarType.INT32);
1256
- case "message":
1257
- if (arg === void 0)
1258
- return true;
1259
- if (repeated)
1260
- return this.messages(arg, field.T(), allowExcessProperties, depth);
1261
- return this.message(arg, field.T(), allowExcessProperties, depth);
1262
- case "map":
1263
- if (typeof arg != "object" || arg === null)
1264
- return false;
1265
- if (depth < 2)
1266
- return true;
1267
- if (!this.mapKeys(arg, field.K, depth))
1268
- return false;
1269
- switch (field.V.kind) {
1270
- case "scalar":
1271
- return this.scalars(Object.values(arg), field.V.T, depth, field.V.L);
1272
- case "enum":
1273
- return this.scalars(Object.values(arg), ScalarType.INT32, depth);
1274
- case "message":
1275
- return this.messages(Object.values(arg), field.V.T(), allowExcessProperties, depth);
1276
- }
1277
- break;
1278
- }
1279
- return true;
1280
- }
1281
- message(arg, type, allowExcessProperties, depth) {
1282
- if (allowExcessProperties) {
1283
- return type.isAssignable(arg, depth);
1284
- }
1285
- return type.is(arg, depth);
1286
- }
1287
- messages(arg, type, allowExcessProperties, depth) {
1288
- if (!Array.isArray(arg))
1289
- return false;
1290
- if (depth < 2)
1291
- return true;
1292
- if (allowExcessProperties) {
1293
- for (let i = 0; i < arg.length && i < depth; i++)
1294
- if (!type.isAssignable(arg[i], depth - 1))
1295
- return false;
1296
- } else {
1297
- for (let i = 0; i < arg.length && i < depth; i++)
1298
- if (!type.is(arg[i], depth - 1))
1299
- return false;
1300
- }
1301
- return true;
1302
- }
1303
- scalar(arg, type, longType) {
1304
- let argType = typeof arg;
1305
- switch (type) {
1306
- case ScalarType.UINT64:
1307
- case ScalarType.FIXED64:
1308
- case ScalarType.INT64:
1309
- case ScalarType.SFIXED64:
1310
- case ScalarType.SINT64:
1311
- switch (longType) {
1312
- case LongType.BIGINT:
1313
- return argType == "bigint";
1314
- case LongType.NUMBER:
1315
- return argType == "number" && !isNaN(arg);
1316
- default:
1317
- return argType == "string";
1318
- }
1319
- case ScalarType.BOOL:
1320
- return argType == "boolean";
1321
- case ScalarType.STRING:
1322
- return argType == "string";
1323
- case ScalarType.BYTES:
1324
- return arg instanceof Uint8Array;
1325
- case ScalarType.DOUBLE:
1326
- case ScalarType.FLOAT:
1327
- return argType == "number" && !isNaN(arg);
1328
- default:
1329
- return argType == "number" && Number.isInteger(arg);
1330
- }
1331
- }
1332
- scalars(arg, type, depth, longType) {
1333
- if (!Array.isArray(arg))
1334
- return false;
1335
- if (depth < 2)
1336
- return true;
1337
- if (Array.isArray(arg)) {
1338
- for (let i = 0; i < arg.length && i < depth; i++)
1339
- if (!this.scalar(arg[i], type, longType))
1340
- return false;
1341
- }
1342
- return true;
1343
- }
1344
- mapKeys(map, type, depth) {
1345
- let keys = Object.keys(map);
1346
- switch (type) {
1347
- case ScalarType.INT32:
1348
- case ScalarType.FIXED32:
1349
- case ScalarType.SFIXED32:
1350
- case ScalarType.SINT32:
1351
- case ScalarType.UINT32:
1352
- return this.scalars(keys.slice(0, depth).map((k) => parseInt(k)), type, depth);
1353
- case ScalarType.BOOL:
1354
- return this.scalars(keys.slice(0, depth).map((k) => k == "true" ? true : k == "false" ? false : k), type, depth);
1355
- default:
1356
- return this.scalars(keys, type, depth, LongType.STRING);
1357
- }
1358
- }
1359
- };
1360
-
1361
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-long-convert.js
1362
- function reflectionLongConvert(long, type) {
1363
- switch (type) {
1364
- case LongType.BIGINT:
1365
- return long.toBigInt();
1366
- case LongType.NUMBER:
1367
- return long.toNumber();
1368
- default:
1369
- return long.toString();
1370
- }
1371
- }
1372
-
1373
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-json-reader.js
1374
- var ReflectionJsonReader = class {
1375
- constructor(info) {
1376
- this.info = info;
1377
- }
1378
- prepare() {
1379
- var _a;
1380
- if (this.fMap === void 0) {
1381
- this.fMap = {};
1382
- const fieldsInput = (_a = this.info.fields) !== null && _a !== void 0 ? _a : [];
1383
- for (const field of fieldsInput) {
1384
- this.fMap[field.name] = field;
1385
- this.fMap[field.jsonName] = field;
1386
- this.fMap[field.localName] = field;
1387
- }
1388
- }
1389
- }
1390
- // Cannot parse JSON <type of jsonValue> for <type name>#<fieldName>.
1391
- assert(condition, fieldName, jsonValue) {
1392
- if (!condition) {
1393
- let what = typeofJsonValue(jsonValue);
1394
- if (what == "number" || what == "boolean")
1395
- what = jsonValue.toString();
1396
- throw new Error(`Cannot parse JSON ${what} for ${this.info.typeName}#${fieldName}`);
1397
- }
1398
- }
1399
- /**
1400
- * Reads a message from canonical JSON format into the target message.
1401
- *
1402
- * Repeated fields are appended. Map entries are added, overwriting
1403
- * existing keys.
1404
- *
1405
- * If a message field is already present, it will be merged with the
1406
- * new data.
1407
- */
1408
- read(input, message, options) {
1409
- this.prepare();
1410
- const oneofsHandled = [];
1411
- for (const [jsonKey, jsonValue] of Object.entries(input)) {
1412
- const field = this.fMap[jsonKey];
1413
- if (!field) {
1414
- if (!options.ignoreUnknownFields)
1415
- throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${jsonKey}`);
1416
- continue;
1417
- }
1418
- const localName = field.localName;
1419
- let target;
1420
- if (field.oneof) {
1421
- if (jsonValue === null && (field.kind !== "enum" || field.T()[0] !== "google.protobuf.NullValue")) {
1422
- continue;
1423
- }
1424
- if (oneofsHandled.includes(field.oneof))
1425
- throw new Error(`Multiple members of the oneof group "${field.oneof}" of ${this.info.typeName} are present in JSON.`);
1426
- oneofsHandled.push(field.oneof);
1427
- target = message[field.oneof] = {
1428
- oneofKind: localName
1429
- };
1430
- } else {
1431
- target = message;
1432
- }
1433
- if (field.kind == "map") {
1434
- if (jsonValue === null) {
1435
- continue;
1436
- }
1437
- this.assert(isJsonObject(jsonValue), field.name, jsonValue);
1438
- const fieldObj = target[localName];
1439
- for (const [jsonObjKey, jsonObjValue] of Object.entries(jsonValue)) {
1440
- this.assert(jsonObjValue !== null, field.name + " map value", null);
1441
- let val;
1442
- switch (field.V.kind) {
1443
- case "message":
1444
- val = field.V.T().internalJsonRead(jsonObjValue, options);
1445
- break;
1446
- case "enum":
1447
- val = this.enum(field.V.T(), jsonObjValue, field.name, options.ignoreUnknownFields);
1448
- if (val === false)
1449
- continue;
1450
- break;
1451
- case "scalar":
1452
- val = this.scalar(jsonObjValue, field.V.T, field.V.L, field.name);
1453
- break;
1454
- }
1455
- this.assert(val !== void 0, field.name + " map value", jsonObjValue);
1456
- let key = jsonObjKey;
1457
- if (field.K == ScalarType.BOOL)
1458
- key = key == "true" ? true : key == "false" ? false : key;
1459
- key = this.scalar(key, field.K, LongType.STRING, field.name).toString();
1460
- fieldObj[key] = val;
1461
- }
1462
- } else if (field.repeat) {
1463
- if (jsonValue === null)
1464
- continue;
1465
- this.assert(Array.isArray(jsonValue), field.name, jsonValue);
1466
- const fieldArr = target[localName];
1467
- for (const jsonItem of jsonValue) {
1468
- this.assert(jsonItem !== null, field.name, null);
1469
- let val;
1470
- switch (field.kind) {
1471
- case "message":
1472
- val = field.T().internalJsonRead(jsonItem, options);
1473
- break;
1474
- case "enum":
1475
- val = this.enum(field.T(), jsonItem, field.name, options.ignoreUnknownFields);
1476
- if (val === false)
1477
- continue;
1478
- break;
1479
- case "scalar":
1480
- val = this.scalar(jsonItem, field.T, field.L, field.name);
1481
- break;
1482
- }
1483
- this.assert(val !== void 0, field.name, jsonValue);
1484
- fieldArr.push(val);
1485
- }
1486
- } else {
1487
- switch (field.kind) {
1488
- case "message":
1489
- if (jsonValue === null && field.T().typeName != "google.protobuf.Value") {
1490
- this.assert(field.oneof === void 0, field.name + " (oneof member)", null);
1491
- continue;
1492
- }
1493
- target[localName] = field.T().internalJsonRead(jsonValue, options, target[localName]);
1494
- break;
1495
- case "enum":
1496
- if (jsonValue === null)
1497
- continue;
1498
- let val = this.enum(field.T(), jsonValue, field.name, options.ignoreUnknownFields);
1499
- if (val === false)
1500
- continue;
1501
- target[localName] = val;
1502
- break;
1503
- case "scalar":
1504
- if (jsonValue === null)
1505
- continue;
1506
- target[localName] = this.scalar(jsonValue, field.T, field.L, field.name);
1507
- break;
1508
- }
1509
- }
1510
- }
1511
- }
1512
- /**
1513
- * Returns `false` for unrecognized string representations.
1514
- *
1515
- * google.protobuf.NullValue accepts only JSON `null` (or the old `"NULL_VALUE"`).
1516
- */
1517
- enum(type, json, fieldName, ignoreUnknownFields) {
1518
- if (type[0] == "google.protobuf.NullValue")
1519
- assert(json === null || json === "NULL_VALUE", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
1520
- if (json === null)
1521
- return 0;
1522
- switch (typeof json) {
1523
- case "number":
1524
- assert(Number.isInteger(json), `Unable to parse field ${this.info.typeName}#${fieldName}, enum can only be integral number, got ${json}.`);
1525
- return json;
1526
- case "string":
1527
- let localEnumName = json;
1528
- if (type[2] && json.substring(0, type[2].length) === type[2])
1529
- localEnumName = json.substring(type[2].length);
1530
- let enumNumber = type[1][localEnumName];
1531
- if (typeof enumNumber === "undefined" && ignoreUnknownFields) {
1532
- return false;
1533
- }
1534
- assert(typeof enumNumber == "number", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} has no value for "${json}".`);
1535
- return enumNumber;
1536
- }
1537
- assert(false, `Unable to parse field ${this.info.typeName}#${fieldName}, cannot parse enum value from ${typeof json}".`);
1538
- }
1539
- scalar(json, type, longType, fieldName) {
1540
- let e;
1541
- try {
1542
- switch (type) {
1543
- // float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
1544
- // Either numbers or strings are accepted. Exponent notation is also accepted.
1545
- case ScalarType.DOUBLE:
1546
- case ScalarType.FLOAT:
1547
- if (json === null)
1548
- return 0;
1549
- if (json === "NaN")
1550
- return Number.NaN;
1551
- if (json === "Infinity")
1552
- return Number.POSITIVE_INFINITY;
1553
- if (json === "-Infinity")
1554
- return Number.NEGATIVE_INFINITY;
1555
- if (json === "") {
1556
- e = "empty string";
1557
- break;
1558
- }
1559
- if (typeof json == "string" && json.trim().length !== json.length) {
1560
- e = "extra whitespace";
1561
- break;
1562
- }
1563
- if (typeof json != "string" && typeof json != "number") {
1564
- break;
1565
- }
1566
- let float = Number(json);
1567
- if (Number.isNaN(float)) {
1568
- e = "not a number";
1569
- break;
1570
- }
1571
- if (!Number.isFinite(float)) {
1572
- e = "too large or small";
1573
- break;
1574
- }
1575
- if (type == ScalarType.FLOAT)
1576
- assertFloat32(float);
1577
- return float;
1578
- // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
1579
- case ScalarType.INT32:
1580
- case ScalarType.FIXED32:
1581
- case ScalarType.SFIXED32:
1582
- case ScalarType.SINT32:
1583
- case ScalarType.UINT32:
1584
- if (json === null)
1585
- return 0;
1586
- let int32;
1587
- if (typeof json == "number")
1588
- int32 = json;
1589
- else if (json === "")
1590
- e = "empty string";
1591
- else if (typeof json == "string") {
1592
- if (json.trim().length !== json.length)
1593
- e = "extra whitespace";
1594
- else
1595
- int32 = Number(json);
1596
- }
1597
- if (int32 === void 0)
1598
- break;
1599
- if (type == ScalarType.UINT32)
1600
- assertUInt32(int32);
1601
- else
1602
- assertInt32(int32);
1603
- return int32;
1604
- // int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted.
1605
- case ScalarType.INT64:
1606
- case ScalarType.SFIXED64:
1607
- case ScalarType.SINT64:
1608
- if (json === null)
1609
- return reflectionLongConvert(PbLong.ZERO, longType);
1610
- if (typeof json != "number" && typeof json != "string")
1611
- break;
1612
- return reflectionLongConvert(PbLong.from(json), longType);
1613
- case ScalarType.FIXED64:
1614
- case ScalarType.UINT64:
1615
- if (json === null)
1616
- return reflectionLongConvert(PbULong.ZERO, longType);
1617
- if (typeof json != "number" && typeof json != "string")
1618
- break;
1619
- return reflectionLongConvert(PbULong.from(json), longType);
1620
- // bool:
1621
- case ScalarType.BOOL:
1622
- if (json === null)
1623
- return false;
1624
- if (typeof json !== "boolean")
1625
- break;
1626
- return json;
1627
- // string:
1628
- case ScalarType.STRING:
1629
- if (json === null)
1630
- return "";
1631
- if (typeof json !== "string") {
1632
- e = "extra whitespace";
1633
- break;
1634
- }
1635
- try {
1636
- encodeURIComponent(json);
1637
- } catch (e2) {
1638
- e2 = "invalid UTF8";
1639
- break;
1640
- }
1641
- return json;
1642
- // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
1643
- // Either standard or URL-safe base64 encoding with/without paddings are accepted.
1644
- case ScalarType.BYTES:
1645
- if (json === null || json === "")
1646
- return new Uint8Array(0);
1647
- if (typeof json !== "string")
1648
- break;
1649
- return base64decode(json);
1650
- }
1651
- } catch (error) {
1652
- e = error.message;
1653
- }
1654
- this.assert(false, fieldName + (e ? " - " + e : ""), json);
1655
- }
1656
- };
1657
-
1658
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-json-writer.js
1659
- var ReflectionJsonWriter = class {
1660
- constructor(info) {
1661
- var _a;
1662
- this.fields = (_a = info.fields) !== null && _a !== void 0 ? _a : [];
1663
- }
1664
- /**
1665
- * Converts the message to a JSON object, based on the field descriptors.
1666
- */
1667
- write(message, options) {
1668
- const json = {}, source = message;
1669
- for (const field of this.fields) {
1670
- if (!field.oneof) {
1671
- let jsonValue2 = this.field(field, source[field.localName], options);
1672
- if (jsonValue2 !== void 0)
1673
- json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue2;
1674
- continue;
1675
- }
1676
- const group = source[field.oneof];
1677
- if (group.oneofKind !== field.localName)
1678
- continue;
1679
- const opt = field.kind == "scalar" || field.kind == "enum" ? Object.assign(Object.assign({}, options), { emitDefaultValues: true }) : options;
1680
- let jsonValue = this.field(field, group[field.localName], opt);
1681
- assert(jsonValue !== void 0);
1682
- json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
1683
- }
1684
- return json;
1685
- }
1686
- field(field, value, options) {
1687
- let jsonValue = void 0;
1688
- if (field.kind == "map") {
1689
- assert(typeof value == "object" && value !== null);
1690
- const jsonObj = {};
1691
- switch (field.V.kind) {
1692
- case "scalar":
1693
- for (const [entryKey, entryValue] of Object.entries(value)) {
1694
- const val = this.scalar(field.V.T, entryValue, field.name, false, true);
1695
- assert(val !== void 0);
1696
- jsonObj[entryKey.toString()] = val;
1697
- }
1698
- break;
1699
- case "message":
1700
- const messageType = field.V.T();
1701
- for (const [entryKey, entryValue] of Object.entries(value)) {
1702
- const val = this.message(messageType, entryValue, field.name, options);
1703
- assert(val !== void 0);
1704
- jsonObj[entryKey.toString()] = val;
1705
- }
1706
- break;
1707
- case "enum":
1708
- const enumInfo = field.V.T();
1709
- for (const [entryKey, entryValue] of Object.entries(value)) {
1710
- assert(entryValue === void 0 || typeof entryValue == "number");
1711
- const val = this.enum(enumInfo, entryValue, field.name, false, true, options.enumAsInteger);
1712
- assert(val !== void 0);
1713
- jsonObj[entryKey.toString()] = val;
1714
- }
1715
- break;
1716
- }
1717
- if (options.emitDefaultValues || Object.keys(jsonObj).length > 0)
1718
- jsonValue = jsonObj;
1719
- } else if (field.repeat) {
1720
- assert(Array.isArray(value));
1721
- const jsonArr = [];
1722
- switch (field.kind) {
1723
- case "scalar":
1724
- for (let i = 0; i < value.length; i++) {
1725
- const val = this.scalar(field.T, value[i], field.name, field.opt, true);
1726
- assert(val !== void 0);
1727
- jsonArr.push(val);
1728
- }
1729
- break;
1730
- case "enum":
1731
- const enumInfo = field.T();
1732
- for (let i = 0; i < value.length; i++) {
1733
- assert(value[i] === void 0 || typeof value[i] == "number");
1734
- const val = this.enum(enumInfo, value[i], field.name, field.opt, true, options.enumAsInteger);
1735
- assert(val !== void 0);
1736
- jsonArr.push(val);
1737
- }
1738
- break;
1739
- case "message":
1740
- const messageType = field.T();
1741
- for (let i = 0; i < value.length; i++) {
1742
- const val = this.message(messageType, value[i], field.name, options);
1743
- assert(val !== void 0);
1744
- jsonArr.push(val);
1745
- }
1746
- break;
1747
- }
1748
- if (options.emitDefaultValues || jsonArr.length > 0 || options.emitDefaultValues)
1749
- jsonValue = jsonArr;
1750
- } else {
1751
- switch (field.kind) {
1752
- case "scalar":
1753
- jsonValue = this.scalar(field.T, value, field.name, field.opt, options.emitDefaultValues);
1754
- break;
1755
- case "enum":
1756
- jsonValue = this.enum(field.T(), value, field.name, field.opt, options.emitDefaultValues, options.enumAsInteger);
1757
- break;
1758
- case "message":
1759
- jsonValue = this.message(field.T(), value, field.name, options);
1760
- break;
1761
- }
1762
- }
1763
- return jsonValue;
1764
- }
1765
- /**
1766
- * Returns `null` as the default for google.protobuf.NullValue.
1767
- */
1768
- enum(type, value, fieldName, optional, emitDefaultValues, enumAsInteger) {
1769
- if (type[0] == "google.protobuf.NullValue")
1770
- return !emitDefaultValues && !optional ? void 0 : null;
1771
- if (value === void 0) {
1772
- assert(optional);
1773
- return void 0;
1774
- }
1775
- if (value === 0 && !emitDefaultValues && !optional)
1776
- return void 0;
1777
- assert(typeof value == "number");
1778
- assert(Number.isInteger(value));
1779
- if (enumAsInteger || !type[1].hasOwnProperty(value))
1780
- return value;
1781
- if (type[2])
1782
- return type[2] + type[1][value];
1783
- return type[1][value];
1784
- }
1785
- message(type, value, fieldName, options) {
1786
- if (value === void 0)
1787
- return options.emitDefaultValues ? null : void 0;
1788
- return type.internalJsonWrite(value, options);
1789
- }
1790
- scalar(type, value, fieldName, optional, emitDefaultValues) {
1791
- if (value === void 0) {
1792
- assert(optional);
1793
- return void 0;
1794
- }
1795
- const ed = emitDefaultValues || optional;
1796
- switch (type) {
1797
- // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.
1798
- case ScalarType.INT32:
1799
- case ScalarType.SFIXED32:
1800
- case ScalarType.SINT32:
1801
- if (value === 0)
1802
- return ed ? 0 : void 0;
1803
- assertInt32(value);
1804
- return value;
1805
- case ScalarType.FIXED32:
1806
- case ScalarType.UINT32:
1807
- if (value === 0)
1808
- return ed ? 0 : void 0;
1809
- assertUInt32(value);
1810
- return value;
1811
- // float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity".
1812
- // Either numbers or strings are accepted. Exponent notation is also accepted.
1813
- case ScalarType.FLOAT:
1814
- assertFloat32(value);
1815
- case ScalarType.DOUBLE:
1816
- if (value === 0)
1817
- return ed ? 0 : void 0;
1818
- assert(typeof value == "number");
1819
- if (Number.isNaN(value))
1820
- return "NaN";
1821
- if (value === Number.POSITIVE_INFINITY)
1822
- return "Infinity";
1823
- if (value === Number.NEGATIVE_INFINITY)
1824
- return "-Infinity";
1825
- return value;
1826
- // string:
1827
- case ScalarType.STRING:
1828
- if (value === "")
1829
- return ed ? "" : void 0;
1830
- assert(typeof value == "string");
1831
- return value;
1832
- // bool:
1833
- case ScalarType.BOOL:
1834
- if (value === false)
1835
- return ed ? false : void 0;
1836
- assert(typeof value == "boolean");
1837
- return value;
1838
- // JSON value will be a decimal string. Either numbers or strings are accepted.
1839
- case ScalarType.UINT64:
1840
- case ScalarType.FIXED64:
1841
- assert(typeof value == "number" || typeof value == "string" || typeof value == "bigint");
1842
- let ulong = PbULong.from(value);
1843
- if (ulong.isZero() && !ed)
1844
- return void 0;
1845
- return ulong.toString();
1846
- // JSON value will be a decimal string. Either numbers or strings are accepted.
1847
- case ScalarType.INT64:
1848
- case ScalarType.SFIXED64:
1849
- case ScalarType.SINT64:
1850
- assert(typeof value == "number" || typeof value == "string" || typeof value == "bigint");
1851
- let long = PbLong.from(value);
1852
- if (long.isZero() && !ed)
1853
- return void 0;
1854
- return long.toString();
1855
- // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
1856
- // Either standard or URL-safe base64 encoding with/without paddings are accepted.
1857
- case ScalarType.BYTES:
1858
- assert(value instanceof Uint8Array);
1859
- if (!value.byteLength)
1860
- return ed ? "" : void 0;
1861
- return base64encode(value);
1862
- }
1863
- }
1864
- };
1865
-
1866
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-scalar-default.js
1867
- function reflectionScalarDefault(type, longType = LongType.STRING) {
1868
- switch (type) {
1869
- case ScalarType.BOOL:
1870
- return false;
1871
- case ScalarType.UINT64:
1872
- case ScalarType.FIXED64:
1873
- return reflectionLongConvert(PbULong.ZERO, longType);
1874
- case ScalarType.INT64:
1875
- case ScalarType.SFIXED64:
1876
- case ScalarType.SINT64:
1877
- return reflectionLongConvert(PbLong.ZERO, longType);
1878
- case ScalarType.DOUBLE:
1879
- case ScalarType.FLOAT:
1880
- return 0;
1881
- case ScalarType.BYTES:
1882
- return new Uint8Array(0);
1883
- case ScalarType.STRING:
1884
- return "";
1885
- default:
1886
- return 0;
1887
- }
1888
- }
1889
-
1890
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-binary-reader.js
1891
- var ReflectionBinaryReader = class {
1892
- constructor(info) {
1893
- this.info = info;
1894
- }
1895
- prepare() {
1896
- var _a;
1897
- if (!this.fieldNoToField) {
1898
- const fieldsInput = (_a = this.info.fields) !== null && _a !== void 0 ? _a : [];
1899
- this.fieldNoToField = new Map(fieldsInput.map((field) => [field.no, field]));
1900
- }
1901
- }
1902
- /**
1903
- * Reads a message from binary format into the target message.
1904
- *
1905
- * Repeated fields are appended. Map entries are added, overwriting
1906
- * existing keys.
1907
- *
1908
- * If a message field is already present, it will be merged with the
1909
- * new data.
1910
- */
1911
- read(reader, message, options, length) {
1912
- this.prepare();
1913
- const end = length === void 0 ? reader.len : reader.pos + length;
1914
- while (reader.pos < end) {
1915
- const [fieldNo, wireType] = reader.tag(), field = this.fieldNoToField.get(fieldNo);
1916
- if (!field) {
1917
- let u = options.readUnknownField;
1918
- if (u == "throw")
1919
- throw new Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.info.typeName}`);
1920
- let d = reader.skip(wireType);
1921
- if (u !== false)
1922
- (u === true ? UnknownFieldHandler.onRead : u)(this.info.typeName, message, fieldNo, wireType, d);
1923
- continue;
1924
- }
1925
- let target = message, repeated = field.repeat, localName = field.localName;
1926
- if (field.oneof) {
1927
- target = target[field.oneof];
1928
- if (target.oneofKind !== localName)
1929
- target = message[field.oneof] = {
1930
- oneofKind: localName
1931
- };
1932
- }
1933
- switch (field.kind) {
1934
- case "scalar":
1935
- case "enum":
1936
- let T = field.kind == "enum" ? ScalarType.INT32 : field.T;
1937
- let L = field.kind == "scalar" ? field.L : void 0;
1938
- if (repeated) {
1939
- let arr = target[localName];
1940
- if (wireType == WireType.LengthDelimited && T != ScalarType.STRING && T != ScalarType.BYTES) {
1941
- let e = reader.uint32() + reader.pos;
1942
- while (reader.pos < e)
1943
- arr.push(this.scalar(reader, T, L));
1944
- } else
1945
- arr.push(this.scalar(reader, T, L));
1946
- } else
1947
- target[localName] = this.scalar(reader, T, L);
1948
- break;
1949
- case "message":
1950
- if (repeated) {
1951
- let arr = target[localName];
1952
- let msg = field.T().internalBinaryRead(reader, reader.uint32(), options);
1953
- arr.push(msg);
1954
- } else
1955
- target[localName] = field.T().internalBinaryRead(reader, reader.uint32(), options, target[localName]);
1956
- break;
1957
- case "map":
1958
- let [mapKey, mapVal] = this.mapEntry(field, reader, options);
1959
- target[localName][mapKey] = mapVal;
1960
- break;
1961
- }
1962
- }
1963
- }
1964
- /**
1965
- * Read a map field, expecting key field = 1, value field = 2
1966
- */
1967
- mapEntry(field, reader, options) {
1968
- let length = reader.uint32();
1969
- let end = reader.pos + length;
1970
- let key = void 0;
1971
- let val = void 0;
1972
- while (reader.pos < end) {
1973
- let [fieldNo, wireType] = reader.tag();
1974
- switch (fieldNo) {
1975
- case 1:
1976
- if (field.K == ScalarType.BOOL)
1977
- key = reader.bool().toString();
1978
- else
1979
- key = this.scalar(reader, field.K, LongType.STRING);
1980
- break;
1981
- case 2:
1982
- switch (field.V.kind) {
1983
- case "scalar":
1984
- val = this.scalar(reader, field.V.T, field.V.L);
1985
- break;
1986
- case "enum":
1987
- val = reader.int32();
1988
- break;
1989
- case "message":
1990
- val = field.V.T().internalBinaryRead(reader, reader.uint32(), options);
1991
- break;
1992
- }
1993
- break;
1994
- default:
1995
- throw new Error(`Unknown field ${fieldNo} (wire type ${wireType}) in map entry for ${this.info.typeName}#${field.name}`);
1996
- }
1997
- }
1998
- if (key === void 0) {
1999
- let keyRaw = reflectionScalarDefault(field.K);
2000
- key = field.K == ScalarType.BOOL ? keyRaw.toString() : keyRaw;
2001
- }
2002
- if (val === void 0)
2003
- switch (field.V.kind) {
2004
- case "scalar":
2005
- val = reflectionScalarDefault(field.V.T, field.V.L);
2006
- break;
2007
- case "enum":
2008
- val = 0;
2009
- break;
2010
- case "message":
2011
- val = field.V.T().create();
2012
- break;
2013
- }
2014
- return [key, val];
2015
- }
2016
- scalar(reader, type, longType) {
2017
- switch (type) {
2018
- case ScalarType.INT32:
2019
- return reader.int32();
2020
- case ScalarType.STRING:
2021
- return reader.string();
2022
- case ScalarType.BOOL:
2023
- return reader.bool();
2024
- case ScalarType.DOUBLE:
2025
- return reader.double();
2026
- case ScalarType.FLOAT:
2027
- return reader.float();
2028
- case ScalarType.INT64:
2029
- return reflectionLongConvert(reader.int64(), longType);
2030
- case ScalarType.UINT64:
2031
- return reflectionLongConvert(reader.uint64(), longType);
2032
- case ScalarType.FIXED64:
2033
- return reflectionLongConvert(reader.fixed64(), longType);
2034
- case ScalarType.FIXED32:
2035
- return reader.fixed32();
2036
- case ScalarType.BYTES:
2037
- return reader.bytes();
2038
- case ScalarType.UINT32:
2039
- return reader.uint32();
2040
- case ScalarType.SFIXED32:
2041
- return reader.sfixed32();
2042
- case ScalarType.SFIXED64:
2043
- return reflectionLongConvert(reader.sfixed64(), longType);
2044
- case ScalarType.SINT32:
2045
- return reader.sint32();
2046
- case ScalarType.SINT64:
2047
- return reflectionLongConvert(reader.sint64(), longType);
2048
- }
2049
- }
2050
- };
2051
-
2052
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-binary-writer.js
2053
- var ReflectionBinaryWriter = class {
2054
- constructor(info) {
2055
- this.info = info;
2056
- }
2057
- prepare() {
2058
- if (!this.fields) {
2059
- const fieldsInput = this.info.fields ? this.info.fields.concat() : [];
2060
- this.fields = fieldsInput.sort((a, b) => a.no - b.no);
2061
- }
2062
- }
2063
- /**
2064
- * Writes the message to binary format.
2065
- */
2066
- write(message, writer, options) {
2067
- this.prepare();
2068
- for (const field of this.fields) {
2069
- let value, emitDefault, repeated = field.repeat, localName = field.localName;
2070
- if (field.oneof) {
2071
- const group = message[field.oneof];
2072
- if (group.oneofKind !== localName)
2073
- continue;
2074
- value = group[localName];
2075
- emitDefault = true;
2076
- } else {
2077
- value = message[localName];
2078
- emitDefault = false;
2079
- }
2080
- switch (field.kind) {
2081
- case "scalar":
2082
- case "enum":
2083
- let T = field.kind == "enum" ? ScalarType.INT32 : field.T;
2084
- if (repeated) {
2085
- assert(Array.isArray(value));
2086
- if (repeated == RepeatType.PACKED)
2087
- this.packed(writer, T, field.no, value);
2088
- else
2089
- for (const item of value)
2090
- this.scalar(writer, T, field.no, item, true);
2091
- } else if (value === void 0)
2092
- assert(field.opt);
2093
- else
2094
- this.scalar(writer, T, field.no, value, emitDefault || field.opt);
2095
- break;
2096
- case "message":
2097
- if (repeated) {
2098
- assert(Array.isArray(value));
2099
- for (const item of value)
2100
- this.message(writer, options, field.T(), field.no, item);
2101
- } else {
2102
- this.message(writer, options, field.T(), field.no, value);
2103
- }
2104
- break;
2105
- case "map":
2106
- assert(typeof value == "object" && value !== null);
2107
- for (const [key, val] of Object.entries(value))
2108
- this.mapEntry(writer, options, field, key, val);
2109
- break;
2110
- }
2111
- }
2112
- let u = options.writeUnknownFields;
2113
- if (u !== false)
2114
- (u === true ? UnknownFieldHandler.onWrite : u)(this.info.typeName, message, writer);
2115
- }
2116
- mapEntry(writer, options, field, key, value) {
2117
- writer.tag(field.no, WireType.LengthDelimited);
2118
- writer.fork();
2119
- let keyValue = key;
2120
- switch (field.K) {
2121
- case ScalarType.INT32:
2122
- case ScalarType.FIXED32:
2123
- case ScalarType.UINT32:
2124
- case ScalarType.SFIXED32:
2125
- case ScalarType.SINT32:
2126
- keyValue = Number.parseInt(key);
2127
- break;
2128
- case ScalarType.BOOL:
2129
- assert(key == "true" || key == "false");
2130
- keyValue = key == "true";
2131
- break;
2132
- }
2133
- this.scalar(writer, field.K, 1, keyValue, true);
2134
- switch (field.V.kind) {
2135
- case "scalar":
2136
- this.scalar(writer, field.V.T, 2, value, true);
2137
- break;
2138
- case "enum":
2139
- this.scalar(writer, ScalarType.INT32, 2, value, true);
2140
- break;
2141
- case "message":
2142
- this.message(writer, options, field.V.T(), 2, value);
2143
- break;
2144
- }
2145
- writer.join();
2146
- }
2147
- message(writer, options, handler, fieldNo, value) {
2148
- if (value === void 0)
2149
- return;
2150
- handler.internalBinaryWrite(value, writer.tag(fieldNo, WireType.LengthDelimited).fork(), options);
2151
- writer.join();
2152
- }
2153
- /**
2154
- * Write a single scalar value.
2155
- */
2156
- scalar(writer, type, fieldNo, value, emitDefault) {
2157
- let [wireType, method, isDefault] = this.scalarInfo(type, value);
2158
- if (!isDefault || emitDefault) {
2159
- writer.tag(fieldNo, wireType);
2160
- writer[method](value);
2161
- }
2162
- }
2163
- /**
2164
- * Write an array of scalar values in packed format.
2165
- */
2166
- packed(writer, type, fieldNo, value) {
2167
- if (!value.length)
2168
- return;
2169
- assert(type !== ScalarType.BYTES && type !== ScalarType.STRING);
2170
- writer.tag(fieldNo, WireType.LengthDelimited);
2171
- writer.fork();
2172
- let [, method] = this.scalarInfo(type);
2173
- for (let i = 0; i < value.length; i++)
2174
- writer[method](value[i]);
2175
- writer.join();
2176
- }
2177
- /**
2178
- * Get information for writing a scalar value.
2179
- *
2180
- * Returns tuple:
2181
- * [0]: appropriate WireType
2182
- * [1]: name of the appropriate method of IBinaryWriter
2183
- * [2]: whether the given value is a default value
2184
- *
2185
- * If argument `value` is omitted, [2] is always false.
2186
- */
2187
- scalarInfo(type, value) {
2188
- let t = WireType.Varint;
2189
- let m;
2190
- let i = value === void 0;
2191
- let d = value === 0;
2192
- switch (type) {
2193
- case ScalarType.INT32:
2194
- m = "int32";
2195
- break;
2196
- case ScalarType.STRING:
2197
- d = i || !value.length;
2198
- t = WireType.LengthDelimited;
2199
- m = "string";
2200
- break;
2201
- case ScalarType.BOOL:
2202
- d = value === false;
2203
- m = "bool";
2204
- break;
2205
- case ScalarType.UINT32:
2206
- m = "uint32";
2207
- break;
2208
- case ScalarType.DOUBLE:
2209
- t = WireType.Bit64;
2210
- m = "double";
2211
- break;
2212
- case ScalarType.FLOAT:
2213
- t = WireType.Bit32;
2214
- m = "float";
2215
- break;
2216
- case ScalarType.INT64:
2217
- d = i || PbLong.from(value).isZero();
2218
- m = "int64";
2219
- break;
2220
- case ScalarType.UINT64:
2221
- d = i || PbULong.from(value).isZero();
2222
- m = "uint64";
2223
- break;
2224
- case ScalarType.FIXED64:
2225
- d = i || PbULong.from(value).isZero();
2226
- t = WireType.Bit64;
2227
- m = "fixed64";
2228
- break;
2229
- case ScalarType.BYTES:
2230
- d = i || !value.byteLength;
2231
- t = WireType.LengthDelimited;
2232
- m = "bytes";
2233
- break;
2234
- case ScalarType.FIXED32:
2235
- t = WireType.Bit32;
2236
- m = "fixed32";
2237
- break;
2238
- case ScalarType.SFIXED32:
2239
- t = WireType.Bit32;
2240
- m = "sfixed32";
2241
- break;
2242
- case ScalarType.SFIXED64:
2243
- d = i || PbLong.from(value).isZero();
2244
- t = WireType.Bit64;
2245
- m = "sfixed64";
2246
- break;
2247
- case ScalarType.SINT32:
2248
- m = "sint32";
2249
- break;
2250
- case ScalarType.SINT64:
2251
- d = i || PbLong.from(value).isZero();
2252
- m = "sint64";
2253
- break;
2254
- }
2255
- return [t, m, i || d];
2256
- }
2257
- };
2258
-
2259
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-create.js
2260
- function reflectionCreate(type) {
2261
- const msg = type.messagePrototype ? Object.create(type.messagePrototype) : Object.defineProperty({}, MESSAGE_TYPE, { value: type });
2262
- for (let field of type.fields) {
2263
- let name = field.localName;
2264
- if (field.opt)
2265
- continue;
2266
- if (field.oneof)
2267
- msg[field.oneof] = { oneofKind: void 0 };
2268
- else if (field.repeat)
2269
- msg[name] = [];
2270
- else
2271
- switch (field.kind) {
2272
- case "scalar":
2273
- msg[name] = reflectionScalarDefault(field.T, field.L);
2274
- break;
2275
- case "enum":
2276
- msg[name] = 0;
2277
- break;
2278
- case "map":
2279
- msg[name] = {};
2280
- break;
2281
- }
2282
- }
2283
- return msg;
2284
- }
2285
-
2286
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-merge-partial.js
2287
- function reflectionMergePartial(info, target, source) {
2288
- let fieldValue, input = source, output;
2289
- for (let field of info.fields) {
2290
- let name = field.localName;
2291
- if (field.oneof) {
2292
- const group = input[field.oneof];
2293
- if ((group === null || group === void 0 ? void 0 : group.oneofKind) == void 0) {
2294
- continue;
2295
- }
2296
- fieldValue = group[name];
2297
- output = target[field.oneof];
2298
- output.oneofKind = group.oneofKind;
2299
- if (fieldValue == void 0) {
2300
- delete output[name];
2301
- continue;
2302
- }
2303
- } else {
2304
- fieldValue = input[name];
2305
- output = target;
2306
- if (fieldValue == void 0) {
2307
- continue;
2308
- }
2309
- }
2310
- if (field.repeat)
2311
- output[name].length = fieldValue.length;
2312
- switch (field.kind) {
2313
- case "scalar":
2314
- case "enum":
2315
- if (field.repeat)
2316
- for (let i = 0; i < fieldValue.length; i++)
2317
- output[name][i] = fieldValue[i];
2318
- else
2319
- output[name] = fieldValue;
2320
- break;
2321
- case "message":
2322
- let T = field.T();
2323
- if (field.repeat)
2324
- for (let i = 0; i < fieldValue.length; i++)
2325
- output[name][i] = T.create(fieldValue[i]);
2326
- else if (output[name] === void 0)
2327
- output[name] = T.create(fieldValue);
2328
- else
2329
- T.mergePartial(output[name], fieldValue);
2330
- break;
2331
- case "map":
2332
- switch (field.V.kind) {
2333
- case "scalar":
2334
- case "enum":
2335
- Object.assign(output[name], fieldValue);
2336
- break;
2337
- case "message":
2338
- let T2 = field.V.T();
2339
- for (let k of Object.keys(fieldValue))
2340
- output[name][k] = T2.create(fieldValue[k]);
2341
- break;
2342
- }
2343
- break;
2344
- }
2345
- }
2346
- }
2347
-
2348
- // node_modules/@protobuf-ts/runtime/build/es2015/reflection-equals.js
2349
- function reflectionEquals(info, a, b) {
2350
- if (a === b)
2351
- return true;
2352
- if (!a || !b)
2353
- return false;
2354
- for (let field of info.fields) {
2355
- let localName = field.localName;
2356
- let val_a = field.oneof ? a[field.oneof][localName] : a[localName];
2357
- let val_b = field.oneof ? b[field.oneof][localName] : b[localName];
2358
- switch (field.kind) {
2359
- case "enum":
2360
- case "scalar":
2361
- let t = field.kind == "enum" ? ScalarType.INT32 : field.T;
2362
- if (!(field.repeat ? repeatedPrimitiveEq(t, val_a, val_b) : primitiveEq(t, val_a, val_b)))
2363
- return false;
2364
- break;
2365
- case "map":
2366
- if (!(field.V.kind == "message" ? repeatedMsgEq(field.V.T(), objectValues(val_a), objectValues(val_b)) : repeatedPrimitiveEq(field.V.kind == "enum" ? ScalarType.INT32 : field.V.T, objectValues(val_a), objectValues(val_b))))
2367
- return false;
2368
- break;
2369
- case "message":
2370
- let T = field.T();
2371
- if (!(field.repeat ? repeatedMsgEq(T, val_a, val_b) : T.equals(val_a, val_b)))
2372
- return false;
2373
- break;
2374
- }
2375
- }
2376
- return true;
2377
- }
2378
- var objectValues = Object.values;
2379
- function primitiveEq(type, a, b) {
2380
- if (a === b)
2381
- return true;
2382
- if (type !== ScalarType.BYTES)
2383
- return false;
2384
- let ba = a;
2385
- let bb = b;
2386
- if (ba.length !== bb.length)
2387
- return false;
2388
- for (let i = 0; i < ba.length; i++)
2389
- if (ba[i] != bb[i])
2390
- return false;
2391
- return true;
2392
- }
2393
- function repeatedPrimitiveEq(type, a, b) {
2394
- if (a.length !== b.length)
2395
- return false;
2396
- for (let i = 0; i < a.length; i++)
2397
- if (!primitiveEq(type, a[i], b[i]))
2398
- return false;
2399
- return true;
2400
- }
2401
- function repeatedMsgEq(type, a, b) {
2402
- if (a.length !== b.length)
2403
- return false;
2404
- for (let i = 0; i < a.length; i++)
2405
- if (!type.equals(a[i], b[i]))
2406
- return false;
2407
- return true;
2408
- }
2409
-
2410
- // node_modules/@protobuf-ts/runtime/build/es2015/message-type.js
2411
- var baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
2412
- var messageTypeDescriptor = baseDescriptors[MESSAGE_TYPE] = {};
2413
- var MessageType = class {
2414
- constructor(name, fields, options) {
2415
- this.defaultCheckDepth = 16;
2416
- this.typeName = name;
2417
- this.fields = fields.map(normalizeFieldInfo);
2418
- this.options = options !== null && options !== void 0 ? options : {};
2419
- messageTypeDescriptor.value = this;
2420
- this.messagePrototype = Object.create(null, baseDescriptors);
2421
- this.refTypeCheck = new ReflectionTypeCheck(this);
2422
- this.refJsonReader = new ReflectionJsonReader(this);
2423
- this.refJsonWriter = new ReflectionJsonWriter(this);
2424
- this.refBinReader = new ReflectionBinaryReader(this);
2425
- this.refBinWriter = new ReflectionBinaryWriter(this);
2426
- }
2427
- create(value) {
2428
- let message = reflectionCreate(this);
2429
- if (value !== void 0) {
2430
- reflectionMergePartial(this, message, value);
2431
- }
2432
- return message;
2433
- }
2434
- /**
2435
- * Clone the message.
2436
- *
2437
- * Unknown fields are discarded.
2438
- */
2439
- clone(message) {
2440
- let copy = this.create();
2441
- reflectionMergePartial(this, copy, message);
2442
- return copy;
2443
- }
2444
- /**
2445
- * Determines whether two message of the same type have the same field values.
2446
- * Checks for deep equality, traversing repeated fields, oneof groups, maps
2447
- * and messages recursively.
2448
- * Will also return true if both messages are `undefined`.
2449
- */
2450
- equals(a, b) {
2451
- return reflectionEquals(this, a, b);
2452
- }
2453
- /**
2454
- * Is the given value assignable to our message type
2455
- * and contains no [excess properties](https://www.typescriptlang.org/docs/handbook/interfaces.html#excess-property-checks)?
2456
- */
2457
- is(arg, depth = this.defaultCheckDepth) {
2458
- return this.refTypeCheck.is(arg, depth, false);
2459
- }
2460
- /**
2461
- * Is the given value assignable to our message type,
2462
- * regardless of [excess properties](https://www.typescriptlang.org/docs/handbook/interfaces.html#excess-property-checks)?
2463
- */
2464
- isAssignable(arg, depth = this.defaultCheckDepth) {
2465
- return this.refTypeCheck.is(arg, depth, true);
2466
- }
2467
- /**
2468
- * Copy partial data into the target message.
2469
- */
2470
- mergePartial(target, source) {
2471
- reflectionMergePartial(this, target, source);
2472
- }
2473
- /**
2474
- * Create a new message from binary format.
2475
- */
2476
- fromBinary(data, options) {
2477
- let opt = binaryReadOptions(options);
2478
- return this.internalBinaryRead(opt.readerFactory(data), data.byteLength, opt);
2479
- }
2480
- /**
2481
- * Read a new message from a JSON value.
2482
- */
2483
- fromJson(json, options) {
2484
- return this.internalJsonRead(json, jsonReadOptions(options));
2485
- }
2486
- /**
2487
- * Read a new message from a JSON string.
2488
- * This is equivalent to `T.fromJson(JSON.parse(json))`.
2489
- */
2490
- fromJsonString(json, options) {
2491
- let value = JSON.parse(json);
2492
- return this.fromJson(value, options);
2493
- }
2494
- /**
2495
- * Write the message to canonical JSON value.
2496
- */
2497
- toJson(message, options) {
2498
- return this.internalJsonWrite(message, jsonWriteOptions(options));
2499
- }
2500
- /**
2501
- * Convert the message to canonical JSON string.
2502
- * This is equivalent to `JSON.stringify(T.toJson(t))`
2503
- */
2504
- toJsonString(message, options) {
2505
- var _a;
2506
- let value = this.toJson(message, options);
2507
- return JSON.stringify(value, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0);
2508
- }
2509
- /**
2510
- * Write the message to binary format.
2511
- */
2512
- toBinary(message, options) {
2513
- let opt = binaryWriteOptions(options);
2514
- return this.internalBinaryWrite(message, opt.writerFactory(), opt).finish();
2515
- }
2516
- /**
2517
- * This is an internal method. If you just want to read a message from
2518
- * JSON, use `fromJson()` or `fromJsonString()`.
2519
- *
2520
- * Reads JSON value and merges the fields into the target
2521
- * according to protobuf rules. If the target is omitted,
2522
- * a new instance is created first.
2523
- */
2524
- internalJsonRead(json, options, target) {
2525
- if (json !== null && typeof json == "object" && !Array.isArray(json)) {
2526
- let message = target !== null && target !== void 0 ? target : this.create();
2527
- this.refJsonReader.read(json, message, options);
2528
- return message;
2529
- }
2530
- throw new Error(`Unable to parse message ${this.typeName} from JSON ${typeofJsonValue(json)}.`);
2531
- }
2532
- /**
2533
- * This is an internal method. If you just want to write a message
2534
- * to JSON, use `toJson()` or `toJsonString().
2535
- *
2536
- * Writes JSON value and returns it.
2537
- */
2538
- internalJsonWrite(message, options) {
2539
- return this.refJsonWriter.write(message, options);
2540
- }
2541
- /**
2542
- * This is an internal method. If you just want to write a message
2543
- * in binary format, use `toBinary()`.
2544
- *
2545
- * Serializes the message in binary format and appends it to the given
2546
- * writer. Returns passed writer.
2547
- */
2548
- internalBinaryWrite(message, writer, options) {
2549
- this.refBinWriter.write(message, writer, options);
2550
- return writer;
2551
- }
2552
- /**
2553
- * This is an internal method. If you just want to read a message from
2554
- * binary data, use `fromBinary()`.
2555
- *
2556
- * Reads data from binary format and merges the fields into
2557
- * the target according to protobuf rules. If the target is
2558
- * omitted, a new instance is created first.
2559
- */
2560
- internalBinaryRead(reader, length, options, target) {
2561
- let message = target !== null && target !== void 0 ? target : this.create();
2562
- this.refBinReader.read(reader, message, options, length);
2563
- return message;
2564
- }
2565
- };
2566
-
2567
1
  // src/econ.ts
2
+ import { MessageType } from "@protobuf-ts/runtime";
2568
3
  var CEconItemPreviewDataBlock$Type = class extends MessageType {
2569
4
  constructor() {
2570
5
  super("CEconItemPreviewDataBlock", [
@@ -2717,156 +152,6 @@ var CEconItemPreviewDataBlock$Type = class extends MessageType {
2717
152
  { no: 20, name: "keychains", kind: "message", repeat: 2, T: () => CEconItemPreviewDataBlock_Sticker }
2718
153
  ]);
2719
154
  }
2720
- create(value) {
2721
- const message = globalThis.Object.create(this.messagePrototype);
2722
- message.stickers = [];
2723
- message.keychains = [];
2724
- if (value !== void 0)
2725
- reflectionMergePartial(this, message, value);
2726
- return message;
2727
- }
2728
- internalBinaryRead(reader, length, options, target) {
2729
- let message = target ?? this.create(), end = reader.pos + length;
2730
- while (reader.pos < end) {
2731
- let [fieldNo, wireType] = reader.tag();
2732
- switch (fieldNo) {
2733
- case /* optional uint32 accountid */
2734
- 1:
2735
- message.accountid = reader.uint32();
2736
- break;
2737
- case /* optional uint64 itemid */
2738
- 2:
2739
- message.itemid = reader.uint64().toBigInt();
2740
- break;
2741
- case /* optional uint32 defindex */
2742
- 3:
2743
- message.defindex = reader.uint32();
2744
- break;
2745
- case /* optional uint32 paintindex */
2746
- 4:
2747
- message.paintindex = reader.uint32();
2748
- break;
2749
- case /* optional uint32 rarity */
2750
- 5:
2751
- message.rarity = reader.uint32();
2752
- break;
2753
- case /* optional uint32 quality */
2754
- 6:
2755
- message.quality = reader.uint32();
2756
- break;
2757
- case /* optional uint32 paintwear */
2758
- 7:
2759
- message.paintwear = reader.uint32();
2760
- break;
2761
- case /* optional uint32 paintseed */
2762
- 8:
2763
- message.paintseed = reader.uint32();
2764
- break;
2765
- case /* optional uint32 killeaterscoretype */
2766
- 9:
2767
- message.killeaterscoretype = reader.uint32();
2768
- break;
2769
- case /* optional uint32 killeatervalue */
2770
- 10:
2771
- message.killeatervalue = reader.uint32();
2772
- break;
2773
- case /* optional string customname */
2774
- 11:
2775
- message.customname = reader.string();
2776
- break;
2777
- case /* repeated CEconItemPreviewDataBlock.Sticker stickers */
2778
- 12:
2779
- message.stickers.push(CEconItemPreviewDataBlock_Sticker.internalBinaryRead(reader, reader.uint32(), options));
2780
- break;
2781
- case /* optional uint32 inventory */
2782
- 13:
2783
- message.inventory = reader.uint32();
2784
- break;
2785
- case /* optional uint32 origin */
2786
- 14:
2787
- message.origin = reader.uint32();
2788
- break;
2789
- case /* optional uint32 questid */
2790
- 15:
2791
- message.questid = reader.uint32();
2792
- break;
2793
- case /* optional uint32 dropreason */
2794
- 16:
2795
- message.dropreason = reader.uint32();
2796
- break;
2797
- case /* optional uint32 musicindex */
2798
- 17:
2799
- message.musicindex = reader.uint32();
2800
- break;
2801
- case /* optional int32 entindex */
2802
- 18:
2803
- message.entindex = reader.int32();
2804
- break;
2805
- case /* optional uint32 petindex */
2806
- 19:
2807
- message.petindex = reader.uint32();
2808
- break;
2809
- case /* repeated CEconItemPreviewDataBlock.Sticker keychains */
2810
- 20:
2811
- message.keychains.push(CEconItemPreviewDataBlock_Sticker.internalBinaryRead(reader, reader.uint32(), options));
2812
- break;
2813
- default:
2814
- let u = options.readUnknownField;
2815
- if (u === "throw")
2816
- throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
2817
- let d = reader.skip(wireType);
2818
- if (u !== false)
2819
- (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
2820
- }
2821
- }
2822
- return message;
2823
- }
2824
- internalBinaryWrite(message, writer, options) {
2825
- if (message.accountid !== void 0)
2826
- writer.tag(1, WireType.Varint).uint32(message.accountid);
2827
- if (message.itemid !== void 0)
2828
- writer.tag(2, WireType.Varint).uint64(message.itemid);
2829
- if (message.defindex !== void 0)
2830
- writer.tag(3, WireType.Varint).uint32(message.defindex);
2831
- if (message.paintindex !== void 0)
2832
- writer.tag(4, WireType.Varint).uint32(message.paintindex);
2833
- if (message.rarity !== void 0)
2834
- writer.tag(5, WireType.Varint).uint32(message.rarity);
2835
- if (message.quality !== void 0)
2836
- writer.tag(6, WireType.Varint).uint32(message.quality);
2837
- if (message.paintwear !== void 0)
2838
- writer.tag(7, WireType.Varint).uint32(message.paintwear);
2839
- if (message.paintseed !== void 0)
2840
- writer.tag(8, WireType.Varint).uint32(message.paintseed);
2841
- if (message.killeaterscoretype !== void 0)
2842
- writer.tag(9, WireType.Varint).uint32(message.killeaterscoretype);
2843
- if (message.killeatervalue !== void 0)
2844
- writer.tag(10, WireType.Varint).uint32(message.killeatervalue);
2845
- if (message.customname !== void 0)
2846
- writer.tag(11, WireType.LengthDelimited).string(message.customname);
2847
- for (let i = 0; i < message.stickers.length; i++)
2848
- CEconItemPreviewDataBlock_Sticker.internalBinaryWrite(message.stickers[i], writer.tag(12, WireType.LengthDelimited).fork(), options).join();
2849
- if (message.inventory !== void 0)
2850
- writer.tag(13, WireType.Varint).uint32(message.inventory);
2851
- if (message.origin !== void 0)
2852
- writer.tag(14, WireType.Varint).uint32(message.origin);
2853
- if (message.questid !== void 0)
2854
- writer.tag(15, WireType.Varint).uint32(message.questid);
2855
- if (message.dropreason !== void 0)
2856
- writer.tag(16, WireType.Varint).uint32(message.dropreason);
2857
- if (message.musicindex !== void 0)
2858
- writer.tag(17, WireType.Varint).uint32(message.musicindex);
2859
- if (message.entindex !== void 0)
2860
- writer.tag(18, WireType.Varint).int32(message.entindex);
2861
- if (message.petindex !== void 0)
2862
- writer.tag(19, WireType.Varint).uint32(message.petindex);
2863
- for (let i = 0; i < message.keychains.length; i++)
2864
- CEconItemPreviewDataBlock_Sticker.internalBinaryWrite(message.keychains[i], writer.tag(20, WireType.LengthDelimited).fork(), options).join();
2865
- let u = options.writeUnknownFields;
2866
- if (u !== false)
2867
- (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
2868
- return writer;
2869
- }
2870
155
  };
2871
156
  var CEconItemPreviewDataBlock = new CEconItemPreviewDataBlock$Type();
2872
157
  var CEconItemPreviewDataBlock_Sticker$Type = class extends MessageType {
@@ -2962,138 +247,139 @@ var CEconItemPreviewDataBlock_Sticker$Type = class extends MessageType {
2962
247
  }
2963
248
  ]);
2964
249
  }
2965
- create(value) {
2966
- const message = globalThis.Object.create(this.messagePrototype);
2967
- if (value !== void 0)
2968
- reflectionMergePartial(this, message, value);
2969
- return message;
2970
- }
2971
- internalBinaryRead(reader, length, options, target) {
2972
- let message = target ?? this.create(), end = reader.pos + length;
2973
- while (reader.pos < end) {
2974
- let [fieldNo, wireType] = reader.tag();
2975
- switch (fieldNo) {
2976
- case /* optional uint32 slot */
2977
- 1:
2978
- message.slot = reader.uint32();
2979
- break;
2980
- case /* optional uint32 sticker_id */
2981
- 2:
2982
- message.stickerId = reader.uint32();
2983
- break;
2984
- case /* optional float wear */
2985
- 3:
2986
- message.wear = reader.float();
2987
- break;
2988
- case /* optional float scale */
2989
- 4:
2990
- message.scale = reader.float();
2991
- break;
2992
- case /* optional float rotation */
2993
- 5:
2994
- message.rotation = reader.float();
2995
- break;
2996
- case /* optional uint32 tint_id */
2997
- 6:
2998
- message.tintId = reader.uint32();
2999
- break;
3000
- case /* optional float offset_x */
3001
- 7:
3002
- message.offsetX = reader.float();
3003
- break;
3004
- case /* optional float offset_y */
3005
- 8:
3006
- message.offsetY = reader.float();
3007
- break;
3008
- case /* optional float offset_z */
3009
- 9:
3010
- message.offsetZ = reader.float();
3011
- break;
3012
- case /* optional uint32 pattern */
3013
- 10:
3014
- message.pattern = reader.uint32();
3015
- break;
3016
- case /* optional uint32 highlight_reel */
3017
- 11:
3018
- message.highlightReel = reader.uint32();
3019
- break;
3020
- default:
3021
- let u = options.readUnknownField;
3022
- if (u === "throw")
3023
- throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
3024
- let d = reader.skip(wireType);
3025
- if (u !== false)
3026
- (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
3027
- }
3028
- }
3029
- return message;
3030
- }
3031
- internalBinaryWrite(message, writer, options) {
3032
- if (message.slot !== void 0)
3033
- writer.tag(1, WireType.Varint).uint32(message.slot);
3034
- if (message.stickerId !== void 0)
3035
- writer.tag(2, WireType.Varint).uint32(message.stickerId);
3036
- if (message.wear !== void 0)
3037
- writer.tag(3, WireType.Bit32).float(message.wear);
3038
- if (message.scale !== void 0)
3039
- writer.tag(4, WireType.Bit32).float(message.scale);
3040
- if (message.rotation !== void 0)
3041
- writer.tag(5, WireType.Bit32).float(message.rotation);
3042
- if (message.tintId !== void 0)
3043
- writer.tag(6, WireType.Varint).uint32(message.tintId);
3044
- if (message.offsetX !== void 0)
3045
- writer.tag(7, WireType.Bit32).float(message.offsetX);
3046
- if (message.offsetY !== void 0)
3047
- writer.tag(8, WireType.Bit32).float(message.offsetY);
3048
- if (message.offsetZ !== void 0)
3049
- writer.tag(9, WireType.Bit32).float(message.offsetZ);
3050
- if (message.pattern !== void 0)
3051
- writer.tag(10, WireType.Varint).uint32(message.pattern);
3052
- if (message.highlightReel !== void 0)
3053
- writer.tag(11, WireType.Varint).uint32(message.highlightReel);
3054
- let u = options.writeUnknownFields;
3055
- if (u !== false)
3056
- (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
3057
- return writer;
3058
- }
3059
250
  };
3060
251
  var CEconItemPreviewDataBlock_Sticker = new CEconItemPreviewDataBlock_Sticker$Type();
3061
252
 
3062
253
  // src/index.ts
3063
- var import_crc_32 = __toESM(require_crc32());
254
+ import { Buffer as Buffer3 } from "buffer";
255
+
256
+ // src/decode.ts
3064
257
  import { Buffer as Buffer2 } from "buffer";
3065
- var previewLink = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview";
258
+
259
+ // src/inspect-payload.ts
260
+ import CRC32 from "crc-32";
261
+ import { Buffer } from "buffer";
3066
262
  var floatToBytes = (floatValue) => {
3067
- const floatArray = new Float32Array(1);
3068
- floatArray[0] = floatValue;
3069
- const byteArray = new Uint32Array(floatArray.buffer);
3070
- return byteArray[0];
263
+ const buffer = new ArrayBuffer(4);
264
+ const view = new DataView(buffer);
265
+ view.setFloat32(0, floatValue, true);
266
+ return view.getUint32(0, true);
267
+ };
268
+ var bytesToFloat = (uintValue) => {
269
+ const buffer = new ArrayBuffer(4);
270
+ const view = new DataView(buffer);
271
+ view.setUint32(0, uintValue, true);
272
+ return view.getFloat32(0, true);
273
+ };
274
+ var getChecksum = (payload) => {
275
+ const bufferPayload = Buffer.concat([Uint8Array.from([0]), payload]);
276
+ const crc = CRC32.buf(bufferPayload);
277
+ const x_crc = crc & 65535 ^ payload.byteLength * crc;
278
+ return (x_crc & 4294967295) >>> 0;
279
+ };
280
+
281
+ // src/decode.ts
282
+ var normalizeDecodedEcon = (econ) => {
283
+ return {
284
+ ...econ,
285
+ paintwear: econ.paintwear === void 0 ? void 0 : bytesToFloat(econ.paintwear)
286
+ };
287
+ };
288
+ var hasDecodedInspectPayload = (econ) => {
289
+ return econ.itemid !== void 0 || econ.defindex !== void 0 || econ.paintindex !== void 0 || econ.paintseed !== void 0 || econ.stickers.length > 0 || econ.keychains.length > 0;
3071
290
  };
291
+ var assertValidHex = (hex) => {
292
+ if (!/^[0-9A-F]+$/i.test(hex) || hex.length % 2 !== 0) {
293
+ throw new Error("Invalid inspect hex payload");
294
+ }
295
+ };
296
+ var decodeURIComponentSafely = (value) => {
297
+ try {
298
+ return decodeURIComponent(value);
299
+ } catch {
300
+ return value;
301
+ }
302
+ };
303
+ var extractHexFromLink = (link) => {
304
+ const decodedLink = decodeURIComponentSafely(link.trim());
305
+ const linkMatch = decodedLink.match(
306
+ /^(?:steam:\/\/(?:run|rungame)\/730\/(?:76561202255233023\/)?\/?)?\+?csgo_econ_action_preview\s+([0-9A-F]+)$/i
307
+ );
308
+ if (linkMatch?.[1]) {
309
+ assertValidHex(linkMatch[1]);
310
+ return linkMatch[1];
311
+ }
312
+ throw new Error("Invalid inspect link");
313
+ };
314
+ var decodePayload = (payload, isValidPayload) => {
315
+ const econ = normalizeDecodedEcon(CEconItemPreviewDataBlock.fromBinary(payload));
316
+ if (!isValidPayload(econ)) {
317
+ throw new Error("Invalid inspect hex payload");
318
+ }
319
+ return econ;
320
+ };
321
+ var decodeWrappedBuffer = (buffer) => {
322
+ if (buffer.length < 5 || buffer[0] !== 0) {
323
+ throw new Error("Invalid inspect hex payload");
324
+ }
325
+ const payload = buffer.subarray(1, -4);
326
+ const expectedChecksum = buffer.readUInt32BE(buffer.length - 4);
327
+ const actualChecksum = getChecksum(payload);
328
+ if (expectedChecksum !== actualChecksum) {
329
+ throw new Error("Inspect hex checksum mismatch");
330
+ }
331
+ return decodePayload(payload, hasDecodedInspectPayload);
332
+ };
333
+ var isDecodedMaskedInspectPayload = (econ) => {
334
+ return econ.itemid !== void 0 && econ.defindex !== void 0 && econ.paintindex !== void 0 && econ.inventory !== void 0 && econ.origin !== void 0;
335
+ };
336
+ var decodeMaskedBuffer = (buffer) => {
337
+ if (buffer.length < 5) {
338
+ throw new Error("Invalid inspect hex payload");
339
+ }
340
+ const unmaskedBuffer = xorMaskBuffer(buffer, buffer[0]);
341
+ if (unmaskedBuffer[0] !== 0) {
342
+ throw new Error("Invalid inspect hex payload");
343
+ }
344
+ return decodePayload(unmaskedBuffer.subarray(1, -4), isDecodedMaskedInspectPayload);
345
+ };
346
+ var xorMaskBuffer = (buffer, key) => {
347
+ return Buffer2.from(buffer.map((byte) => byte ^ key));
348
+ };
349
+ var decodeHex = (hex) => {
350
+ const normalizedHex = hex.trim();
351
+ assertValidHex(normalizedHex);
352
+ const buffer = Buffer2.from(normalizedHex, "hex");
353
+ if (buffer[0] === 0) {
354
+ return decodeWrappedBuffer(buffer);
355
+ }
356
+ return decodeMaskedBuffer(buffer);
357
+ };
358
+ var decodeLink = (link) => {
359
+ return decodeHex(extractHexFromLink(link));
360
+ };
361
+
362
+ // src/index.ts
363
+ var previewLink = "steam://rungame/730/76561202255233023/+csgo_econ_action_preview";
3072
364
  var generateHex = ({ paintwear = 1e-3, ...props }) => {
3073
365
  const econ = {
3074
366
  ...props,
3075
367
  paintwear: floatToBytes(paintwear)
3076
368
  };
3077
- let payload = CEconItemPreviewDataBlock.toBinary(econ);
3078
- payload = Buffer2.concat([Uint8Array.from([0]), payload]);
3079
- let crc = import_crc_32.default.buf(payload);
3080
- const x_crc = crc & 65535 ^ CEconItemPreviewDataBlock.toBinary(econ).byteLength * crc;
3081
- const crcBuffer = Buffer2.alloc(4);
3082
- crcBuffer.writeUInt32BE((x_crc & 4294967295) >>> 0, 0);
3083
- const buffer = Buffer2.concat([payload, crcBuffer]);
3084
- return buffer.toString("hex").toUpperCase();
369
+ const payload = CEconItemPreviewDataBlock.toBinary(econ);
370
+ const crcBuffer = Buffer3.alloc(4);
371
+ crcBuffer.writeUInt32BE(getChecksum(payload), 0);
372
+ return Buffer3.concat([Uint8Array.from([0]), payload, crcBuffer]).toString("hex").toUpperCase();
3085
373
  };
3086
374
  var generateLink = (props) => {
3087
375
  const hex = generateHex(props);
3088
376
  return `${previewLink} ${hex}`;
3089
377
  };
3090
378
  export {
379
+ CEconItemPreviewDataBlock,
380
+ decodeHex,
381
+ decodeLink,
3091
382
  generateHex,
3092
383
  generateLink,
3093
384
  previewLink
3094
385
  };
3095
- /*! Bundled license information:
3096
-
3097
- crc-32/crc32.js:
3098
- (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
3099
- */