@seayoo-web/app-info 0.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.js ADDED
@@ -0,0 +1,2725 @@
1
+ import { loadAsync as J } from "jszip";
2
+ function Q(g) {
3
+ return typeof g == "string" ? g : `${g}`;
4
+ }
5
+ function at(g) {
6
+ return typeof g == "number" ? g : typeof g == "string" ? /^\d+(?:\.\d+)/.test(g) ? +g : Number(g) : NaN;
7
+ }
8
+ function B(g) {
9
+ return g instanceof Error ? g : new Error(String(g));
10
+ }
11
+ function rt(g) {
12
+ return `data:image/png;base64,${g}`;
13
+ }
14
+ async function Mt(g, i) {
15
+ const n = await J(g).catch(B);
16
+ if (n instanceof Error)
17
+ return new Error(`load file error: ${n.message}`);
18
+ const a = await ot(n);
19
+ if (a instanceof Error)
20
+ return new Error(`read pack.info error: ${a.message}`);
21
+ const c = {
22
+ package: a.summary.app.bundleName,
23
+ versionCode: a.summary.app.version.code,
24
+ versionName: a.summary.app.version.name,
25
+ summary: a.summary,
26
+ packages: a.packages
27
+ };
28
+ if (i?.ignoreIcon)
29
+ return c;
30
+ const E = a.packages.find((m) => m.moduleType === "entry");
31
+ if (!E)
32
+ return c;
33
+ const w = n.file(`${E.name}.hap`);
34
+ if (!w)
35
+ return c;
36
+ const y = await w.async("arraybuffer").catch(B);
37
+ if (y instanceof Error)
38
+ return c;
39
+ const I = await J(y).catch(B);
40
+ if (I instanceof Error)
41
+ return c;
42
+ const N = await ht(I);
43
+ if (N instanceof Error)
44
+ return c;
45
+ const T = await ut(I, N.app.icon);
46
+ return T instanceof Error || (c.icon = rt(T)), c;
47
+ }
48
+ async function ot(g) {
49
+ const i = g.file("pack.info");
50
+ if (!i)
51
+ return new Error("not found pack.info file");
52
+ const n = await i.async("text").catch(B);
53
+ if (n instanceof Error)
54
+ return new Error(`read pack.info file error: ${n.message}`);
55
+ if (!n)
56
+ return new Error("pack.info file is empty");
57
+ try {
58
+ return JSON.parse(n);
59
+ } catch (a) {
60
+ const c = B(a);
61
+ return new Error(`parse pack.info file error: ${c.message}`);
62
+ }
63
+ }
64
+ async function ht(g) {
65
+ const i = g.file("module.json") || g.file("module.json5");
66
+ if (!i)
67
+ return new Error("not found module.json file");
68
+ const n = await i.async("text").catch(B);
69
+ if (n instanceof Error)
70
+ return new Error(`read module.json file error: ${n.message}`);
71
+ if (!n)
72
+ return new Error("module.json file is empty");
73
+ try {
74
+ return JSON.parse(n);
75
+ } catch (a) {
76
+ const c = B(a);
77
+ return new Error(`parse module.json file error: ${c.message}`);
78
+ }
79
+ }
80
+ async function ut(g, i) {
81
+ const a = `resources/base/media/${(i || "app_icon").replace(/(?:^\$media:|\.[a-z]+$)/gi, "")}.png`, c = g.file(a);
82
+ if (!c)
83
+ return new Error(`not found icon file at ${a}`);
84
+ const E = await c.async("base64").catch(B);
85
+ return E instanceof Error ? new Error(`read icon file error: ${E.message}`) : E;
86
+ }
87
+ function lt(g) {
88
+ return g && g.__esModule && Object.prototype.hasOwnProperty.call(g, "default") ? g.default : g;
89
+ }
90
+ function st(g) {
91
+ throw new Error('Could not dynamically require "' + g + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
92
+ }
93
+ var W = { exports: {} }, K = { exports: {} }, ct = K.exports, it;
94
+ function ft() {
95
+ return it || (it = 1, function(g) {
96
+ /**
97
+ * @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
98
+ * Released under the Apache License, Version 2.0
99
+ * see: https://github.com/dcodeIO/long.js for details
100
+ */
101
+ (function(i, n) {
102
+ typeof st == "function" && g && g.exports ? g.exports = n() : (i.dcodeIO = i.dcodeIO || {}).Long = n();
103
+ })(ct, function() {
104
+ function i(f, h, b) {
105
+ this.low = f | 0, this.high = h | 0, this.unsigned = !!b;
106
+ }
107
+ i.prototype.__isLong__, Object.defineProperty(i.prototype, "__isLong__", {
108
+ value: !0,
109
+ enumerable: !1,
110
+ configurable: !1
111
+ });
112
+ function n(f) {
113
+ return (f && f.__isLong__) === !0;
114
+ }
115
+ i.isLong = n;
116
+ var a = {}, c = {};
117
+ function E(f, h) {
118
+ var b, v, x;
119
+ return h ? (f >>>= 0, (x = 0 <= f && f < 256) && (v = c[f], v) ? v : (b = y(f, (f | 0) < 0 ? -1 : 0, !0), x && (c[f] = b), b)) : (f |= 0, (x = -128 <= f && f < 128) && (v = a[f], v) ? v : (b = y(f, f < 0 ? -1 : 0, !1), x && (a[f] = b), b));
120
+ }
121
+ i.fromInt = E;
122
+ function w(f, h) {
123
+ if (isNaN(f) || !isFinite(f))
124
+ return h ? l : u;
125
+ if (h) {
126
+ if (f < 0)
127
+ return l;
128
+ if (f >= r)
129
+ return L;
130
+ } else {
131
+ if (f <= -s)
132
+ return _;
133
+ if (f + 1 >= s)
134
+ return A;
135
+ }
136
+ return f < 0 ? w(-f, h).neg() : y(f % e | 0, f / e | 0, h);
137
+ }
138
+ i.fromNumber = w;
139
+ function y(f, h, b) {
140
+ return new i(f, h, b);
141
+ }
142
+ i.fromBits = y;
143
+ var I = Math.pow;
144
+ function N(f, h, b) {
145
+ if (f.length === 0)
146
+ throw Error("empty string");
147
+ if (f === "NaN" || f === "Infinity" || f === "+Infinity" || f === "-Infinity")
148
+ return u;
149
+ if (typeof h == "number" ? (b = h, h = !1) : h = !!h, b = b || 10, b < 2 || 36 < b)
150
+ throw RangeError("radix");
151
+ var v;
152
+ if ((v = f.indexOf("-")) > 0)
153
+ throw Error("interior hyphen");
154
+ if (v === 0)
155
+ return N(f.substring(1), h, b).neg();
156
+ for (var x = w(I(b, 8)), U = u, k = 0; k < f.length; k += 8) {
157
+ var O = Math.min(8, f.length - k), R = parseInt(f.substring(k, k + O), b);
158
+ if (O < 8) {
159
+ var D = w(I(b, O));
160
+ U = U.mul(D).add(w(R));
161
+ } else
162
+ U = U.mul(x), U = U.add(w(R));
163
+ }
164
+ return U.unsigned = h, U;
165
+ }
166
+ i.fromString = N;
167
+ function T(f) {
168
+ return f instanceof i ? f : typeof f == "number" ? w(f) : typeof f == "string" ? N(f) : y(f.low, f.high, f.unsigned);
169
+ }
170
+ i.fromValue = T;
171
+ var m = 65536, t = 1 << 24, e = m * m, r = e * e, s = r / 2, o = E(t), u = E(0);
172
+ i.ZERO = u;
173
+ var l = E(0, !0);
174
+ i.UZERO = l;
175
+ var p = E(1);
176
+ i.ONE = p;
177
+ var F = E(1, !0);
178
+ i.UONE = F;
179
+ var S = E(-1);
180
+ i.NEG_ONE = S;
181
+ var A = y(-1, 2147483647, !1);
182
+ i.MAX_VALUE = A;
183
+ var L = y(-1, -1, !0);
184
+ i.MAX_UNSIGNED_VALUE = L;
185
+ var _ = y(0, -2147483648, !1);
186
+ i.MIN_VALUE = _;
187
+ var d = i.prototype;
188
+ return d.toInt = function() {
189
+ return this.unsigned ? this.low >>> 0 : this.low;
190
+ }, d.toNumber = function() {
191
+ return this.unsigned ? (this.high >>> 0) * e + (this.low >>> 0) : this.high * e + (this.low >>> 0);
192
+ }, d.toString = function(h) {
193
+ if (h = h || 10, h < 2 || 36 < h)
194
+ throw RangeError("radix");
195
+ if (this.isZero())
196
+ return "0";
197
+ if (this.isNegative())
198
+ if (this.eq(_)) {
199
+ var b = w(h), v = this.div(b), x = v.mul(b).sub(this);
200
+ return v.toString(h) + x.toInt().toString(h);
201
+ } else
202
+ return "-" + this.neg().toString(h);
203
+ for (var U = w(I(h, 6), this.unsigned), k = this, O = ""; ; ) {
204
+ var R = k.div(U), D = k.sub(R.mul(U)).toInt() >>> 0, M = D.toString(h);
205
+ if (k = R, k.isZero())
206
+ return M + O;
207
+ for (; M.length < 6; )
208
+ M = "0" + M;
209
+ O = "" + M + O;
210
+ }
211
+ }, d.getHighBits = function() {
212
+ return this.high;
213
+ }, d.getHighBitsUnsigned = function() {
214
+ return this.high >>> 0;
215
+ }, d.getLowBits = function() {
216
+ return this.low;
217
+ }, d.getLowBitsUnsigned = function() {
218
+ return this.low >>> 0;
219
+ }, d.getNumBitsAbs = function() {
220
+ if (this.isNegative())
221
+ return this.eq(_) ? 64 : this.neg().getNumBitsAbs();
222
+ for (var h = this.high != 0 ? this.high : this.low, b = 31; b > 0 && (h & 1 << b) == 0; b--)
223
+ ;
224
+ return this.high != 0 ? b + 33 : b + 1;
225
+ }, d.isZero = function() {
226
+ return this.high === 0 && this.low === 0;
227
+ }, d.isNegative = function() {
228
+ return !this.unsigned && this.high < 0;
229
+ }, d.isPositive = function() {
230
+ return this.unsigned || this.high >= 0;
231
+ }, d.isOdd = function() {
232
+ return (this.low & 1) === 1;
233
+ }, d.isEven = function() {
234
+ return (this.low & 1) === 0;
235
+ }, d.equals = function(h) {
236
+ return n(h) || (h = T(h)), this.unsigned !== h.unsigned && this.high >>> 31 === 1 && h.high >>> 31 === 1 ? !1 : this.high === h.high && this.low === h.low;
237
+ }, d.eq = d.equals, d.notEquals = function(h) {
238
+ return !this.eq(
239
+ /* validates */
240
+ h
241
+ );
242
+ }, d.neq = d.notEquals, d.lessThan = function(h) {
243
+ return this.comp(
244
+ /* validates */
245
+ h
246
+ ) < 0;
247
+ }, d.lt = d.lessThan, d.lessThanOrEqual = function(h) {
248
+ return this.comp(
249
+ /* validates */
250
+ h
251
+ ) <= 0;
252
+ }, d.lte = d.lessThanOrEqual, d.greaterThan = function(h) {
253
+ return this.comp(
254
+ /* validates */
255
+ h
256
+ ) > 0;
257
+ }, d.gt = d.greaterThan, d.greaterThanOrEqual = function(h) {
258
+ return this.comp(
259
+ /* validates */
260
+ h
261
+ ) >= 0;
262
+ }, d.gte = d.greaterThanOrEqual, d.compare = function(h) {
263
+ if (n(h) || (h = T(h)), this.eq(h))
264
+ return 0;
265
+ var b = this.isNegative(), v = h.isNegative();
266
+ return b && !v ? -1 : !b && v ? 1 : this.unsigned ? h.high >>> 0 > this.high >>> 0 || h.high === this.high && h.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(h).isNegative() ? -1 : 1;
267
+ }, d.comp = d.compare, d.negate = function() {
268
+ return !this.unsigned && this.eq(_) ? _ : this.not().add(p);
269
+ }, d.neg = d.negate, d.add = function(h) {
270
+ n(h) || (h = T(h));
271
+ var b = this.high >>> 16, v = this.high & 65535, x = this.low >>> 16, U = this.low & 65535, k = h.high >>> 16, O = h.high & 65535, R = h.low >>> 16, D = h.low & 65535, M = 0, P = 0, X = 0, j = 0;
272
+ return j += U + D, X += j >>> 16, j &= 65535, X += x + R, P += X >>> 16, X &= 65535, P += v + O, M += P >>> 16, P &= 65535, M += b + k, M &= 65535, y(X << 16 | j, M << 16 | P, this.unsigned);
273
+ }, d.subtract = function(h) {
274
+ return n(h) || (h = T(h)), this.add(h.neg());
275
+ }, d.sub = d.subtract, d.multiply = function(h) {
276
+ if (this.isZero() || (n(h) || (h = T(h)), h.isZero()))
277
+ return u;
278
+ if (this.eq(_))
279
+ return h.isOdd() ? _ : u;
280
+ if (h.eq(_))
281
+ return this.isOdd() ? _ : u;
282
+ if (this.isNegative())
283
+ return h.isNegative() ? this.neg().mul(h.neg()) : this.neg().mul(h).neg();
284
+ if (h.isNegative())
285
+ return this.mul(h.neg()).neg();
286
+ if (this.lt(o) && h.lt(o))
287
+ return w(this.toNumber() * h.toNumber(), this.unsigned);
288
+ var b = this.high >>> 16, v = this.high & 65535, x = this.low >>> 16, U = this.low & 65535, k = h.high >>> 16, O = h.high & 65535, R = h.low >>> 16, D = h.low & 65535, M = 0, P = 0, X = 0, j = 0;
289
+ return j += U * D, X += j >>> 16, j &= 65535, X += x * D, P += X >>> 16, X &= 65535, X += U * R, P += X >>> 16, X &= 65535, P += v * D, M += P >>> 16, P &= 65535, P += x * R, M += P >>> 16, P &= 65535, P += U * O, M += P >>> 16, P &= 65535, M += b * D + v * R + x * O + U * k, M &= 65535, y(X << 16 | j, M << 16 | P, this.unsigned);
290
+ }, d.mul = d.multiply, d.divide = function(h) {
291
+ if (n(h) || (h = T(h)), h.isZero())
292
+ throw Error("division by zero");
293
+ if (this.isZero())
294
+ return this.unsigned ? l : u;
295
+ var b, v, x;
296
+ if (this.unsigned) {
297
+ if (h.unsigned || (h = h.toUnsigned()), h.gt(this))
298
+ return l;
299
+ if (h.gt(this.shru(1)))
300
+ return F;
301
+ x = l;
302
+ } else {
303
+ if (this.eq(_)) {
304
+ if (h.eq(p) || h.eq(S))
305
+ return _;
306
+ if (h.eq(_))
307
+ return p;
308
+ var U = this.shr(1);
309
+ return b = U.div(h).shl(1), b.eq(u) ? h.isNegative() ? p : S : (v = this.sub(h.mul(b)), x = b.add(v.div(h)), x);
310
+ } else if (h.eq(_))
311
+ return this.unsigned ? l : u;
312
+ if (this.isNegative())
313
+ return h.isNegative() ? this.neg().div(h.neg()) : this.neg().div(h).neg();
314
+ if (h.isNegative())
315
+ return this.div(h.neg()).neg();
316
+ x = u;
317
+ }
318
+ for (v = this; v.gte(h); ) {
319
+ b = Math.max(1, Math.floor(v.toNumber() / h.toNumber()));
320
+ for (var k = Math.ceil(Math.log(b) / Math.LN2), O = k <= 48 ? 1 : I(2, k - 48), R = w(b), D = R.mul(h); D.isNegative() || D.gt(v); )
321
+ b -= O, R = w(b, this.unsigned), D = R.mul(h);
322
+ R.isZero() && (R = p), x = x.add(R), v = v.sub(D);
323
+ }
324
+ return x;
325
+ }, d.div = d.divide, d.modulo = function(h) {
326
+ return n(h) || (h = T(h)), this.sub(this.div(h).mul(h));
327
+ }, d.mod = d.modulo, d.not = function() {
328
+ return y(~this.low, ~this.high, this.unsigned);
329
+ }, d.and = function(h) {
330
+ return n(h) || (h = T(h)), y(this.low & h.low, this.high & h.high, this.unsigned);
331
+ }, d.or = function(h) {
332
+ return n(h) || (h = T(h)), y(this.low | h.low, this.high | h.high, this.unsigned);
333
+ }, d.xor = function(h) {
334
+ return n(h) || (h = T(h)), y(this.low ^ h.low, this.high ^ h.high, this.unsigned);
335
+ }, d.shiftLeft = function(h) {
336
+ return n(h) && (h = h.toInt()), (h &= 63) === 0 ? this : h < 32 ? y(this.low << h, this.high << h | this.low >>> 32 - h, this.unsigned) : y(0, this.low << h - 32, this.unsigned);
337
+ }, d.shl = d.shiftLeft, d.shiftRight = function(h) {
338
+ return n(h) && (h = h.toInt()), (h &= 63) === 0 ? this : h < 32 ? y(this.low >>> h | this.high << 32 - h, this.high >> h, this.unsigned) : y(this.high >> h - 32, this.high >= 0 ? 0 : -1, this.unsigned);
339
+ }, d.shr = d.shiftRight, d.shiftRightUnsigned = function(h) {
340
+ if (n(h) && (h = h.toInt()), h &= 63, h === 0)
341
+ return this;
342
+ var b = this.high;
343
+ if (h < 32) {
344
+ var v = this.low;
345
+ return y(v >>> h | b << 32 - h, b >>> h, this.unsigned);
346
+ } else return h === 32 ? y(b, 0, this.unsigned) : y(b >>> h - 32, 0, this.unsigned);
347
+ }, d.shru = d.shiftRightUnsigned, d.toSigned = function() {
348
+ return this.unsigned ? y(this.low, this.high, !1) : this;
349
+ }, d.toUnsigned = function() {
350
+ return this.unsigned ? this : y(this.low, this.high, !0);
351
+ }, d.toBytes = function(f) {
352
+ return f ? this.toBytesLE() : this.toBytesBE();
353
+ }, d.toBytesLE = function() {
354
+ var f = this.high, h = this.low;
355
+ return [
356
+ h & 255,
357
+ h >>> 8 & 255,
358
+ h >>> 16 & 255,
359
+ h >>> 24 & 255,
360
+ f & 255,
361
+ f >>> 8 & 255,
362
+ f >>> 16 & 255,
363
+ f >>> 24 & 255
364
+ ];
365
+ }, d.toBytesBE = function() {
366
+ var f = this.high, h = this.low;
367
+ return [
368
+ f >>> 24 & 255,
369
+ f >>> 16 & 255,
370
+ f >>> 8 & 255,
371
+ f & 255,
372
+ h >>> 24 & 255,
373
+ h >>> 16 & 255,
374
+ h >>> 8 & 255,
375
+ h & 255
376
+ ];
377
+ }, i;
378
+ });
379
+ }(K)), K.exports;
380
+ }
381
+ var gt = W.exports, nt;
382
+ function pt() {
383
+ return nt || (nt = 1, function(g) {
384
+ /**
385
+ * @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
386
+ * Backing buffer: ArrayBuffer, Accessor: Uint8Array
387
+ * Released under the Apache License, Version 2.0
388
+ * see: https://github.com/dcodeIO/bytebuffer.js for details
389
+ */
390
+ (function(i, n) {
391
+ typeof st == "function" && g && g.exports ? g.exports = function() {
392
+ var a;
393
+ try {
394
+ a = ft();
395
+ } catch {
396
+ }
397
+ return n(a);
398
+ }() : (i.dcodeIO = i.dcodeIO || {}).ByteBuffer = n(i.dcodeIO.Long);
399
+ })(gt, function(i) {
400
+ var n = function(t, e, r) {
401
+ if (typeof t > "u" && (t = n.DEFAULT_CAPACITY), typeof e > "u" && (e = n.DEFAULT_ENDIAN), typeof r > "u" && (r = n.DEFAULT_NOASSERT), !r) {
402
+ if (t = t | 0, t < 0)
403
+ throw RangeError("Illegal capacity");
404
+ e = !!e, r = !!r;
405
+ }
406
+ this.buffer = t === 0 ? c : new ArrayBuffer(t), this.view = t === 0 ? null : new Uint8Array(this.buffer), this.offset = 0, this.markedOffset = -1, this.limit = t, this.littleEndian = e, this.noAssert = r;
407
+ };
408
+ n.VERSION = "5.0.1", n.LITTLE_ENDIAN = !0, n.BIG_ENDIAN = !1, n.DEFAULT_CAPACITY = 16, n.DEFAULT_ENDIAN = n.BIG_ENDIAN, n.DEFAULT_NOASSERT = !1, n.Long = i || null;
409
+ var a = n.prototype;
410
+ a.__isByteBuffer__, Object.defineProperty(a, "__isByteBuffer__", {
411
+ value: !0,
412
+ enumerable: !1,
413
+ configurable: !1
414
+ });
415
+ var c = new ArrayBuffer(0), E = String.fromCharCode;
416
+ function w(t) {
417
+ var e = 0;
418
+ return function() {
419
+ return e < t.length ? t.charCodeAt(e++) : null;
420
+ };
421
+ }
422
+ function y() {
423
+ var t = [], e = [];
424
+ return function() {
425
+ if (arguments.length === 0)
426
+ return e.join("") + E.apply(String, t);
427
+ t.length + arguments.length > 1024 && (e.push(E.apply(String, t)), t.length = 0), Array.prototype.push.apply(t, arguments);
428
+ };
429
+ }
430
+ n.accessor = function() {
431
+ return Uint8Array;
432
+ }, n.allocate = function(t, e, r) {
433
+ return new n(t, e, r);
434
+ }, n.concat = function(t, e, r, s) {
435
+ (typeof e == "boolean" || typeof e != "string") && (s = r, r = e, e = void 0);
436
+ for (var o = 0, u = 0, l = t.length, p; u < l; ++u)
437
+ n.isByteBuffer(t[u]) || (t[u] = n.wrap(t[u], e)), p = t[u].limit - t[u].offset, p > 0 && (o += p);
438
+ if (o === 0)
439
+ return new n(0, r, s);
440
+ var F = new n(o, r, s), S;
441
+ for (u = 0; u < l; )
442
+ S = t[u++], p = S.limit - S.offset, !(p <= 0) && (F.view.set(S.view.subarray(S.offset, S.limit), F.offset), F.offset += p);
443
+ return F.limit = F.offset, F.offset = 0, F;
444
+ }, n.isByteBuffer = function(t) {
445
+ return (t && t.__isByteBuffer__) === !0;
446
+ }, n.type = function() {
447
+ return ArrayBuffer;
448
+ }, n.wrap = function(t, e, r, s) {
449
+ if (typeof e != "string" && (s = r, r = e, e = void 0), typeof t == "string")
450
+ switch (typeof e > "u" && (e = "utf8"), e) {
451
+ case "base64":
452
+ return n.fromBase64(t, r);
453
+ case "hex":
454
+ return n.fromHex(t, r);
455
+ case "binary":
456
+ return n.fromBinary(t, r);
457
+ case "utf8":
458
+ return n.fromUTF8(t, r);
459
+ case "debug":
460
+ return n.fromDebug(t, r);
461
+ default:
462
+ throw Error("Unsupported encoding: " + e);
463
+ }
464
+ if (t === null || typeof t != "object")
465
+ throw TypeError("Illegal buffer");
466
+ var o;
467
+ if (n.isByteBuffer(t))
468
+ return o = a.clone.call(t), o.markedOffset = -1, o;
469
+ if (t instanceof Uint8Array)
470
+ o = new n(0, r, s), t.length > 0 && (o.buffer = t.buffer, o.offset = t.byteOffset, o.limit = t.byteOffset + t.byteLength, o.view = new Uint8Array(t.buffer));
471
+ else if (t instanceof ArrayBuffer)
472
+ o = new n(0, r, s), t.byteLength > 0 && (o.buffer = t, o.offset = 0, o.limit = t.byteLength, o.view = t.byteLength > 0 ? new Uint8Array(t) : null);
473
+ else if (Object.prototype.toString.call(t) === "[object Array]") {
474
+ o = new n(t.length, r, s), o.limit = t.length;
475
+ for (var u = 0; u < t.length; ++u)
476
+ o.view[u] = t[u];
477
+ } else
478
+ throw TypeError("Illegal buffer");
479
+ return o;
480
+ }, a.writeBitSet = function(t, e) {
481
+ var r = typeof e > "u";
482
+ if (r && (e = this.offset), !this.noAssert) {
483
+ if (!(t instanceof Array))
484
+ throw TypeError("Illegal BitSet: Not an array");
485
+ if (typeof e != "number" || e % 1 !== 0)
486
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
487
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
488
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
489
+ }
490
+ var s = e, o = t.length, u = o >> 3, l = 0, p;
491
+ for (e += this.writeVarint32(o, e); u--; )
492
+ p = !!t[l++] & 1 | (!!t[l++] & 1) << 1 | (!!t[l++] & 1) << 2 | (!!t[l++] & 1) << 3 | (!!t[l++] & 1) << 4 | (!!t[l++] & 1) << 5 | (!!t[l++] & 1) << 6 | (!!t[l++] & 1) << 7, this.writeByte(p, e++);
493
+ if (l < o) {
494
+ var F = 0;
495
+ for (p = 0; l < o; ) p = p | (!!t[l++] & 1) << F++;
496
+ this.writeByte(p, e++);
497
+ }
498
+ return r ? (this.offset = e, this) : e - s;
499
+ }, a.readBitSet = function(t) {
500
+ var e = typeof t > "u";
501
+ e && (t = this.offset);
502
+ var r = this.readVarint32(t), s = r.value, o = s >> 3, u = 0, l = [], p;
503
+ for (t += r.length; o--; )
504
+ p = this.readByte(t++), l[u++] = !!(p & 1), l[u++] = !!(p & 2), l[u++] = !!(p & 4), l[u++] = !!(p & 8), l[u++] = !!(p & 16), l[u++] = !!(p & 32), l[u++] = !!(p & 64), l[u++] = !!(p & 128);
505
+ if (u < s) {
506
+ var F = 0;
507
+ for (p = this.readByte(t++); u < s; ) l[u++] = !!(p >> F++ & 1);
508
+ }
509
+ return e && (this.offset = t), l;
510
+ }, a.readBytes = function(t, e) {
511
+ var r = typeof e > "u";
512
+ if (r && (e = this.offset), !this.noAssert) {
513
+ if (typeof e != "number" || e % 1 !== 0)
514
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
515
+ if (e >>>= 0, e < 0 || e + t > this.buffer.byteLength)
516
+ throw RangeError("Illegal offset: 0 <= " + e + " (+" + t + ") <= " + this.buffer.byteLength);
517
+ }
518
+ var s = this.slice(e, e + t);
519
+ return r && (this.offset += t), s;
520
+ }, a.writeBytes = a.append, a.writeInt8 = function(t, e) {
521
+ var r = typeof e > "u";
522
+ if (r && (e = this.offset), !this.noAssert) {
523
+ if (typeof t != "number" || t % 1 !== 0)
524
+ throw TypeError("Illegal value: " + t + " (not an integer)");
525
+ if (t |= 0, typeof e != "number" || e % 1 !== 0)
526
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
527
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
528
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
529
+ }
530
+ e += 1;
531
+ var s = this.buffer.byteLength;
532
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 1, this.view[e] = t, r && (this.offset += 1), this;
533
+ }, a.writeByte = a.writeInt8, a.readInt8 = function(t) {
534
+ var e = typeof t > "u";
535
+ if (e && (t = this.offset), !this.noAssert) {
536
+ if (typeof t != "number" || t % 1 !== 0)
537
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
538
+ if (t >>>= 0, t < 0 || t + 1 > this.buffer.byteLength)
539
+ throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength);
540
+ }
541
+ var r = this.view[t];
542
+ return (r & 128) === 128 && (r = -(255 - r + 1)), e && (this.offset += 1), r;
543
+ }, a.readByte = a.readInt8, a.writeUint8 = function(t, e) {
544
+ var r = typeof e > "u";
545
+ if (r && (e = this.offset), !this.noAssert) {
546
+ if (typeof t != "number" || t % 1 !== 0)
547
+ throw TypeError("Illegal value: " + t + " (not an integer)");
548
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
549
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
550
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
551
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
552
+ }
553
+ e += 1;
554
+ var s = this.buffer.byteLength;
555
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 1, this.view[e] = t, r && (this.offset += 1), this;
556
+ }, a.writeUInt8 = a.writeUint8, a.readUint8 = function(t) {
557
+ var e = typeof t > "u";
558
+ if (e && (t = this.offset), !this.noAssert) {
559
+ if (typeof t != "number" || t % 1 !== 0)
560
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
561
+ if (t >>>= 0, t < 0 || t + 1 > this.buffer.byteLength)
562
+ throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength);
563
+ }
564
+ var r = this.view[t];
565
+ return e && (this.offset += 1), r;
566
+ }, a.readUInt8 = a.readUint8, a.writeInt16 = function(t, e) {
567
+ var r = typeof e > "u";
568
+ if (r && (e = this.offset), !this.noAssert) {
569
+ if (typeof t != "number" || t % 1 !== 0)
570
+ throw TypeError("Illegal value: " + t + " (not an integer)");
571
+ if (t |= 0, typeof e != "number" || e % 1 !== 0)
572
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
573
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
574
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
575
+ }
576
+ e += 2;
577
+ var s = this.buffer.byteLength;
578
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 2, this.littleEndian ? (this.view[e + 1] = (t & 65280) >>> 8, this.view[e] = t & 255) : (this.view[e] = (t & 65280) >>> 8, this.view[e + 1] = t & 255), r && (this.offset += 2), this;
579
+ }, a.writeShort = a.writeInt16, a.readInt16 = function(t) {
580
+ var e = typeof t > "u";
581
+ if (e && (t = this.offset), !this.noAssert) {
582
+ if (typeof t != "number" || t % 1 !== 0)
583
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
584
+ if (t >>>= 0, t < 0 || t + 2 > this.buffer.byteLength)
585
+ throw RangeError("Illegal offset: 0 <= " + t + " (+2) <= " + this.buffer.byteLength);
586
+ }
587
+ var r = 0;
588
+ return this.littleEndian ? (r = this.view[t], r |= this.view[t + 1] << 8) : (r = this.view[t] << 8, r |= this.view[t + 1]), (r & 32768) === 32768 && (r = -(65535 - r + 1)), e && (this.offset += 2), r;
589
+ }, a.readShort = a.readInt16, a.writeUint16 = function(t, e) {
590
+ var r = typeof e > "u";
591
+ if (r && (e = this.offset), !this.noAssert) {
592
+ if (typeof t != "number" || t % 1 !== 0)
593
+ throw TypeError("Illegal value: " + t + " (not an integer)");
594
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
595
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
596
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
597
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
598
+ }
599
+ e += 2;
600
+ var s = this.buffer.byteLength;
601
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 2, this.littleEndian ? (this.view[e + 1] = (t & 65280) >>> 8, this.view[e] = t & 255) : (this.view[e] = (t & 65280) >>> 8, this.view[e + 1] = t & 255), r && (this.offset += 2), this;
602
+ }, a.writeUInt16 = a.writeUint16, a.readUint16 = function(t) {
603
+ var e = typeof t > "u";
604
+ if (e && (t = this.offset), !this.noAssert) {
605
+ if (typeof t != "number" || t % 1 !== 0)
606
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
607
+ if (t >>>= 0, t < 0 || t + 2 > this.buffer.byteLength)
608
+ throw RangeError("Illegal offset: 0 <= " + t + " (+2) <= " + this.buffer.byteLength);
609
+ }
610
+ var r = 0;
611
+ return this.littleEndian ? (r = this.view[t], r |= this.view[t + 1] << 8) : (r = this.view[t] << 8, r |= this.view[t + 1]), e && (this.offset += 2), r;
612
+ }, a.readUInt16 = a.readUint16, a.writeInt32 = function(t, e) {
613
+ var r = typeof e > "u";
614
+ if (r && (e = this.offset), !this.noAssert) {
615
+ if (typeof t != "number" || t % 1 !== 0)
616
+ throw TypeError("Illegal value: " + t + " (not an integer)");
617
+ if (t |= 0, typeof e != "number" || e % 1 !== 0)
618
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
619
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
620
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
621
+ }
622
+ e += 4;
623
+ var s = this.buffer.byteLength;
624
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 4, this.littleEndian ? (this.view[e + 3] = t >>> 24 & 255, this.view[e + 2] = t >>> 16 & 255, this.view[e + 1] = t >>> 8 & 255, this.view[e] = t & 255) : (this.view[e] = t >>> 24 & 255, this.view[e + 1] = t >>> 16 & 255, this.view[e + 2] = t >>> 8 & 255, this.view[e + 3] = t & 255), r && (this.offset += 4), this;
625
+ }, a.writeInt = a.writeInt32, a.readInt32 = function(t) {
626
+ var e = typeof t > "u";
627
+ if (e && (t = this.offset), !this.noAssert) {
628
+ if (typeof t != "number" || t % 1 !== 0)
629
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
630
+ if (t >>>= 0, t < 0 || t + 4 > this.buffer.byteLength)
631
+ throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength);
632
+ }
633
+ var r = 0;
634
+ return this.littleEndian ? (r = this.view[t + 2] << 16, r |= this.view[t + 1] << 8, r |= this.view[t], r += this.view[t + 3] << 24 >>> 0) : (r = this.view[t + 1] << 16, r |= this.view[t + 2] << 8, r |= this.view[t + 3], r += this.view[t] << 24 >>> 0), r |= 0, e && (this.offset += 4), r;
635
+ }, a.readInt = a.readInt32, a.writeUint32 = function(t, e) {
636
+ var r = typeof e > "u";
637
+ if (r && (e = this.offset), !this.noAssert) {
638
+ if (typeof t != "number" || t % 1 !== 0)
639
+ throw TypeError("Illegal value: " + t + " (not an integer)");
640
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
641
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
642
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
643
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
644
+ }
645
+ e += 4;
646
+ var s = this.buffer.byteLength;
647
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 4, this.littleEndian ? (this.view[e + 3] = t >>> 24 & 255, this.view[e + 2] = t >>> 16 & 255, this.view[e + 1] = t >>> 8 & 255, this.view[e] = t & 255) : (this.view[e] = t >>> 24 & 255, this.view[e + 1] = t >>> 16 & 255, this.view[e + 2] = t >>> 8 & 255, this.view[e + 3] = t & 255), r && (this.offset += 4), this;
648
+ }, a.writeUInt32 = a.writeUint32, a.readUint32 = function(t) {
649
+ var e = typeof t > "u";
650
+ if (e && (t = this.offset), !this.noAssert) {
651
+ if (typeof t != "number" || t % 1 !== 0)
652
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
653
+ if (t >>>= 0, t < 0 || t + 4 > this.buffer.byteLength)
654
+ throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength);
655
+ }
656
+ var r = 0;
657
+ return this.littleEndian ? (r = this.view[t + 2] << 16, r |= this.view[t + 1] << 8, r |= this.view[t], r += this.view[t + 3] << 24 >>> 0) : (r = this.view[t + 1] << 16, r |= this.view[t + 2] << 8, r |= this.view[t + 3], r += this.view[t] << 24 >>> 0), e && (this.offset += 4), r;
658
+ }, a.readUInt32 = a.readUint32, i && (a.writeInt64 = function(t, e) {
659
+ var r = typeof e > "u";
660
+ if (r && (e = this.offset), !this.noAssert) {
661
+ if (typeof t == "number")
662
+ t = i.fromNumber(t);
663
+ else if (typeof t == "string")
664
+ t = i.fromString(t);
665
+ else if (!(t && t instanceof i))
666
+ throw TypeError("Illegal value: " + t + " (not an integer or Long)");
667
+ if (typeof e != "number" || e % 1 !== 0)
668
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
669
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
670
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
671
+ }
672
+ typeof t == "number" ? t = i.fromNumber(t) : typeof t == "string" && (t = i.fromString(t)), e += 8;
673
+ var s = this.buffer.byteLength;
674
+ e > s && this.resize((s *= 2) > e ? s : e), e -= 8;
675
+ var o = t.low, u = t.high;
676
+ return this.littleEndian ? (this.view[e + 3] = o >>> 24 & 255, this.view[e + 2] = o >>> 16 & 255, this.view[e + 1] = o >>> 8 & 255, this.view[e] = o & 255, e += 4, this.view[e + 3] = u >>> 24 & 255, this.view[e + 2] = u >>> 16 & 255, this.view[e + 1] = u >>> 8 & 255, this.view[e] = u & 255) : (this.view[e] = u >>> 24 & 255, this.view[e + 1] = u >>> 16 & 255, this.view[e + 2] = u >>> 8 & 255, this.view[e + 3] = u & 255, e += 4, this.view[e] = o >>> 24 & 255, this.view[e + 1] = o >>> 16 & 255, this.view[e + 2] = o >>> 8 & 255, this.view[e + 3] = o & 255), r && (this.offset += 8), this;
677
+ }, a.writeLong = a.writeInt64, a.readInt64 = function(t) {
678
+ var e = typeof t > "u";
679
+ if (e && (t = this.offset), !this.noAssert) {
680
+ if (typeof t != "number" || t % 1 !== 0)
681
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
682
+ if (t >>>= 0, t < 0 || t + 8 > this.buffer.byteLength)
683
+ throw RangeError("Illegal offset: 0 <= " + t + " (+8) <= " + this.buffer.byteLength);
684
+ }
685
+ var r = 0, s = 0;
686
+ this.littleEndian ? (r = this.view[t + 2] << 16, r |= this.view[t + 1] << 8, r |= this.view[t], r += this.view[t + 3] << 24 >>> 0, t += 4, s = this.view[t + 2] << 16, s |= this.view[t + 1] << 8, s |= this.view[t], s += this.view[t + 3] << 24 >>> 0) : (s = this.view[t + 1] << 16, s |= this.view[t + 2] << 8, s |= this.view[t + 3], s += this.view[t] << 24 >>> 0, t += 4, r = this.view[t + 1] << 16, r |= this.view[t + 2] << 8, r |= this.view[t + 3], r += this.view[t] << 24 >>> 0);
687
+ var o = new i(r, s, !1);
688
+ return e && (this.offset += 8), o;
689
+ }, a.readLong = a.readInt64, a.writeUint64 = function(t, e) {
690
+ var r = typeof e > "u";
691
+ if (r && (e = this.offset), !this.noAssert) {
692
+ if (typeof t == "number")
693
+ t = i.fromNumber(t);
694
+ else if (typeof t == "string")
695
+ t = i.fromString(t);
696
+ else if (!(t && t instanceof i))
697
+ throw TypeError("Illegal value: " + t + " (not an integer or Long)");
698
+ if (typeof e != "number" || e % 1 !== 0)
699
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
700
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
701
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
702
+ }
703
+ typeof t == "number" ? t = i.fromNumber(t) : typeof t == "string" && (t = i.fromString(t)), e += 8;
704
+ var s = this.buffer.byteLength;
705
+ e > s && this.resize((s *= 2) > e ? s : e), e -= 8;
706
+ var o = t.low, u = t.high;
707
+ return this.littleEndian ? (this.view[e + 3] = o >>> 24 & 255, this.view[e + 2] = o >>> 16 & 255, this.view[e + 1] = o >>> 8 & 255, this.view[e] = o & 255, e += 4, this.view[e + 3] = u >>> 24 & 255, this.view[e + 2] = u >>> 16 & 255, this.view[e + 1] = u >>> 8 & 255, this.view[e] = u & 255) : (this.view[e] = u >>> 24 & 255, this.view[e + 1] = u >>> 16 & 255, this.view[e + 2] = u >>> 8 & 255, this.view[e + 3] = u & 255, e += 4, this.view[e] = o >>> 24 & 255, this.view[e + 1] = o >>> 16 & 255, this.view[e + 2] = o >>> 8 & 255, this.view[e + 3] = o & 255), r && (this.offset += 8), this;
708
+ }, a.writeUInt64 = a.writeUint64, a.readUint64 = function(t) {
709
+ var e = typeof t > "u";
710
+ if (e && (t = this.offset), !this.noAssert) {
711
+ if (typeof t != "number" || t % 1 !== 0)
712
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
713
+ if (t >>>= 0, t < 0 || t + 8 > this.buffer.byteLength)
714
+ throw RangeError("Illegal offset: 0 <= " + t + " (+8) <= " + this.buffer.byteLength);
715
+ }
716
+ var r = 0, s = 0;
717
+ this.littleEndian ? (r = this.view[t + 2] << 16, r |= this.view[t + 1] << 8, r |= this.view[t], r += this.view[t + 3] << 24 >>> 0, t += 4, s = this.view[t + 2] << 16, s |= this.view[t + 1] << 8, s |= this.view[t], s += this.view[t + 3] << 24 >>> 0) : (s = this.view[t + 1] << 16, s |= this.view[t + 2] << 8, s |= this.view[t + 3], s += this.view[t] << 24 >>> 0, t += 4, r = this.view[t + 1] << 16, r |= this.view[t + 2] << 8, r |= this.view[t + 3], r += this.view[t] << 24 >>> 0);
718
+ var o = new i(r, s, !0);
719
+ return e && (this.offset += 8), o;
720
+ }, a.readUInt64 = a.readUint64);
721
+ function I(t, e, r, s, o) {
722
+ var u, l, p = o * 8 - s - 1, F = (1 << p) - 1, S = F >> 1, A = -7, L = r ? o - 1 : 0, _ = r ? -1 : 1, d = t[e + L];
723
+ for (L += _, u = d & (1 << -A) - 1, d >>= -A, A += p; A > 0; u = u * 256 + t[e + L], L += _, A -= 8)
724
+ ;
725
+ for (l = u & (1 << -A) - 1, u >>= -A, A += s; A > 0; l = l * 256 + t[e + L], L += _, A -= 8)
726
+ ;
727
+ if (u === 0)
728
+ u = 1 - S;
729
+ else {
730
+ if (u === F)
731
+ return l ? NaN : (d ? -1 : 1) * (1 / 0);
732
+ l = l + Math.pow(2, s), u = u - S;
733
+ }
734
+ return (d ? -1 : 1) * l * Math.pow(2, u - s);
735
+ }
736
+ function N(t, e, r, s, o, u) {
737
+ var l, p, F, S = u * 8 - o - 1, A = (1 << S) - 1, L = A >> 1, _ = o === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, d = s ? 0 : u - 1, f = s ? 1 : -1, h = e < 0 || e === 0 && 1 / e < 0 ? 1 : 0;
738
+ for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (p = isNaN(e) ? 1 : 0, l = A) : (l = Math.floor(Math.log(e) / Math.LN2), e * (F = Math.pow(2, -l)) < 1 && (l--, F *= 2), l + L >= 1 ? e += _ / F : e += _ * Math.pow(2, 1 - L), e * F >= 2 && (l++, F /= 2), l + L >= A ? (p = 0, l = A) : l + L >= 1 ? (p = (e * F - 1) * Math.pow(2, o), l = l + L) : (p = e * Math.pow(2, L - 1) * Math.pow(2, o), l = 0)); o >= 8; t[r + d] = p & 255, d += f, p /= 256, o -= 8)
739
+ ;
740
+ for (l = l << o | p, S += o; S > 0; t[r + d] = l & 255, d += f, l /= 256, S -= 8)
741
+ ;
742
+ t[r + d - f] |= h * 128;
743
+ }
744
+ a.writeFloat32 = function(t, e) {
745
+ var r = typeof e > "u";
746
+ if (r && (e = this.offset), !this.noAssert) {
747
+ if (typeof t != "number")
748
+ throw TypeError("Illegal value: " + t + " (not a number)");
749
+ if (typeof e != "number" || e % 1 !== 0)
750
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
751
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
752
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
753
+ }
754
+ e += 4;
755
+ var s = this.buffer.byteLength;
756
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 4, N(this.view, t, e, this.littleEndian, 23, 4), r && (this.offset += 4), this;
757
+ }, a.writeFloat = a.writeFloat32, a.readFloat32 = function(t) {
758
+ var e = typeof t > "u";
759
+ if (e && (t = this.offset), !this.noAssert) {
760
+ if (typeof t != "number" || t % 1 !== 0)
761
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
762
+ if (t >>>= 0, t < 0 || t + 4 > this.buffer.byteLength)
763
+ throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength);
764
+ }
765
+ var r = I(this.view, t, this.littleEndian, 23, 4);
766
+ return e && (this.offset += 4), r;
767
+ }, a.readFloat = a.readFloat32, a.writeFloat64 = function(t, e) {
768
+ var r = typeof e > "u";
769
+ if (r && (e = this.offset), !this.noAssert) {
770
+ if (typeof t != "number")
771
+ throw TypeError("Illegal value: " + t + " (not a number)");
772
+ if (typeof e != "number" || e % 1 !== 0)
773
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
774
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
775
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
776
+ }
777
+ e += 8;
778
+ var s = this.buffer.byteLength;
779
+ return e > s && this.resize((s *= 2) > e ? s : e), e -= 8, N(this.view, t, e, this.littleEndian, 52, 8), r && (this.offset += 8), this;
780
+ }, a.writeDouble = a.writeFloat64, a.readFloat64 = function(t) {
781
+ var e = typeof t > "u";
782
+ if (e && (t = this.offset), !this.noAssert) {
783
+ if (typeof t != "number" || t % 1 !== 0)
784
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
785
+ if (t >>>= 0, t < 0 || t + 8 > this.buffer.byteLength)
786
+ throw RangeError("Illegal offset: 0 <= " + t + " (+8) <= " + this.buffer.byteLength);
787
+ }
788
+ var r = I(this.view, t, this.littleEndian, 52, 8);
789
+ return e && (this.offset += 8), r;
790
+ }, a.readDouble = a.readFloat64, n.MAX_VARINT32_BYTES = 5, n.calculateVarint32 = function(t) {
791
+ return t = t >>> 0, t < 128 ? 1 : t < 16384 ? 2 : t < 1 << 21 ? 3 : t < 1 << 28 ? 4 : 5;
792
+ }, n.zigZagEncode32 = function(t) {
793
+ return ((t |= 0) << 1 ^ t >> 31) >>> 0;
794
+ }, n.zigZagDecode32 = function(t) {
795
+ return t >>> 1 ^ -(t & 1) | 0;
796
+ }, a.writeVarint32 = function(t, e) {
797
+ var r = typeof e > "u";
798
+ if (r && (e = this.offset), !this.noAssert) {
799
+ if (typeof t != "number" || t % 1 !== 0)
800
+ throw TypeError("Illegal value: " + t + " (not an integer)");
801
+ if (t |= 0, typeof e != "number" || e % 1 !== 0)
802
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
803
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
804
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
805
+ }
806
+ var s = n.calculateVarint32(t), o;
807
+ e += s;
808
+ var u = this.buffer.byteLength;
809
+ for (e > u && this.resize((u *= 2) > e ? u : e), e -= s, t >>>= 0; t >= 128; )
810
+ o = t & 127 | 128, this.view[e++] = o, t >>>= 7;
811
+ return this.view[e++] = t, r ? (this.offset = e, this) : s;
812
+ }, a.writeVarint32ZigZag = function(t, e) {
813
+ return this.writeVarint32(n.zigZagEncode32(t), e);
814
+ }, a.readVarint32 = function(t) {
815
+ var e = typeof t > "u";
816
+ if (e && (t = this.offset), !this.noAssert) {
817
+ if (typeof t != "number" || t % 1 !== 0)
818
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
819
+ if (t >>>= 0, t < 0 || t + 1 > this.buffer.byteLength)
820
+ throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength);
821
+ }
822
+ var r = 0, s = 0, o;
823
+ do {
824
+ if (!this.noAssert && t > this.limit) {
825
+ var u = Error("Truncated");
826
+ throw u.truncated = !0, u;
827
+ }
828
+ o = this.view[t++], r < 5 && (s |= (o & 127) << 7 * r), ++r;
829
+ } while ((o & 128) !== 0);
830
+ return s |= 0, e ? (this.offset = t, s) : {
831
+ value: s,
832
+ length: r
833
+ };
834
+ }, a.readVarint32ZigZag = function(t) {
835
+ var e = this.readVarint32(t);
836
+ return typeof e == "object" ? e.value = n.zigZagDecode32(e.value) : e = n.zigZagDecode32(e), e;
837
+ }, i && (n.MAX_VARINT64_BYTES = 10, n.calculateVarint64 = function(t) {
838
+ typeof t == "number" ? t = i.fromNumber(t) : typeof t == "string" && (t = i.fromString(t));
839
+ var e = t.toInt() >>> 0, r = t.shiftRightUnsigned(28).toInt() >>> 0, s = t.shiftRightUnsigned(56).toInt() >>> 0;
840
+ return s == 0 ? r == 0 ? e < 16384 ? e < 128 ? 1 : 2 : e < 1 << 21 ? 3 : 4 : r < 16384 ? r < 128 ? 5 : 6 : r < 1 << 21 ? 7 : 8 : s < 128 ? 9 : 10;
841
+ }, n.zigZagEncode64 = function(t) {
842
+ return typeof t == "number" ? t = i.fromNumber(t, !1) : typeof t == "string" ? t = i.fromString(t, !1) : t.unsigned !== !1 && (t = t.toSigned()), t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned();
843
+ }, n.zigZagDecode64 = function(t) {
844
+ return typeof t == "number" ? t = i.fromNumber(t, !1) : typeof t == "string" ? t = i.fromString(t, !1) : t.unsigned !== !1 && (t = t.toSigned()), t.shiftRightUnsigned(1).xor(t.and(i.ONE).toSigned().negate()).toSigned();
845
+ }, a.writeVarint64 = function(t, e) {
846
+ var r = typeof e > "u";
847
+ if (r && (e = this.offset), !this.noAssert) {
848
+ if (typeof t == "number")
849
+ t = i.fromNumber(t);
850
+ else if (typeof t == "string")
851
+ t = i.fromString(t);
852
+ else if (!(t && t instanceof i))
853
+ throw TypeError("Illegal value: " + t + " (not an integer or Long)");
854
+ if (typeof e != "number" || e % 1 !== 0)
855
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
856
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
857
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
858
+ }
859
+ typeof t == "number" ? t = i.fromNumber(t, !1) : typeof t == "string" ? t = i.fromString(t, !1) : t.unsigned !== !1 && (t = t.toSigned());
860
+ var s = n.calculateVarint64(t), o = t.toInt() >>> 0, u = t.shiftRightUnsigned(28).toInt() >>> 0, l = t.shiftRightUnsigned(56).toInt() >>> 0;
861
+ e += s;
862
+ var p = this.buffer.byteLength;
863
+ switch (e > p && this.resize((p *= 2) > e ? p : e), e -= s, s) {
864
+ case 10:
865
+ this.view[e + 9] = l >>> 7 & 1;
866
+ case 9:
867
+ this.view[e + 8] = s !== 9 ? l | 128 : l & 127;
868
+ case 8:
869
+ this.view[e + 7] = s !== 8 ? u >>> 21 | 128 : u >>> 21 & 127;
870
+ case 7:
871
+ this.view[e + 6] = s !== 7 ? u >>> 14 | 128 : u >>> 14 & 127;
872
+ case 6:
873
+ this.view[e + 5] = s !== 6 ? u >>> 7 | 128 : u >>> 7 & 127;
874
+ case 5:
875
+ this.view[e + 4] = s !== 5 ? u | 128 : u & 127;
876
+ case 4:
877
+ this.view[e + 3] = s !== 4 ? o >>> 21 | 128 : o >>> 21 & 127;
878
+ case 3:
879
+ this.view[e + 2] = s !== 3 ? o >>> 14 | 128 : o >>> 14 & 127;
880
+ case 2:
881
+ this.view[e + 1] = s !== 2 ? o >>> 7 | 128 : o >>> 7 & 127;
882
+ case 1:
883
+ this.view[e] = s !== 1 ? o | 128 : o & 127;
884
+ }
885
+ return r ? (this.offset += s, this) : s;
886
+ }, a.writeVarint64ZigZag = function(t, e) {
887
+ return this.writeVarint64(n.zigZagEncode64(t), e);
888
+ }, a.readVarint64 = function(t) {
889
+ var e = typeof t > "u";
890
+ if (e && (t = this.offset), !this.noAssert) {
891
+ if (typeof t != "number" || t % 1 !== 0)
892
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
893
+ if (t >>>= 0, t < 0 || t + 1 > this.buffer.byteLength)
894
+ throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength);
895
+ }
896
+ var r = t, s = 0, o = 0, u = 0, l = 0;
897
+ if (l = this.view[t++], s = l & 127, l & 128 && (l = this.view[t++], s |= (l & 127) << 7, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], s |= (l & 127) << 14, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], s |= (l & 127) << 21, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], o = l & 127, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], o |= (l & 127) << 7, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], o |= (l & 127) << 14, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], o |= (l & 127) << 21, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], u = l & 127, (l & 128 || this.noAssert && typeof l > "u") && (l = this.view[t++], u |= (l & 127) << 7, l & 128 || this.noAssert && typeof l > "u"))))))))))
898
+ throw Error("Buffer overrun");
899
+ var p = i.fromBits(s | o << 28, o >>> 4 | u << 24, !1);
900
+ return e ? (this.offset = t, p) : {
901
+ value: p,
902
+ length: t - r
903
+ };
904
+ }, a.readVarint64ZigZag = function(t) {
905
+ var e = this.readVarint64(t);
906
+ return e && e.value instanceof i ? e.value = n.zigZagDecode64(e.value) : e = n.zigZagDecode64(e), e;
907
+ }), a.writeCString = function(t, e) {
908
+ var r = typeof e > "u";
909
+ r && (e = this.offset);
910
+ var s, o = t.length;
911
+ if (!this.noAssert) {
912
+ if (typeof t != "string")
913
+ throw TypeError("Illegal str: Not a string");
914
+ for (s = 0; s < o; ++s)
915
+ if (t.charCodeAt(s) === 0)
916
+ throw RangeError("Illegal str: Contains NULL-characters");
917
+ if (typeof e != "number" || e % 1 !== 0)
918
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
919
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
920
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
921
+ }
922
+ o = m.calculateUTF16asUTF8(w(t))[1], e += o + 1;
923
+ var u = this.buffer.byteLength;
924
+ return e > u && this.resize((u *= 2) > e ? u : e), e -= o + 1, m.encodeUTF16toUTF8(w(t), (function(l) {
925
+ this.view[e++] = l;
926
+ }).bind(this)), this.view[e++] = 0, r ? (this.offset = e, this) : o;
927
+ }, a.readCString = function(t) {
928
+ var e = typeof t > "u";
929
+ if (e && (t = this.offset), !this.noAssert) {
930
+ if (typeof t != "number" || t % 1 !== 0)
931
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
932
+ if (t >>>= 0, t < 0 || t + 1 > this.buffer.byteLength)
933
+ throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength);
934
+ }
935
+ var r = t, s, o = -1;
936
+ return m.decodeUTF8toUTF16((function() {
937
+ if (o === 0) return null;
938
+ if (t >= this.limit)
939
+ throw RangeError("Illegal range: Truncated data, " + t + " < " + this.limit);
940
+ return o = this.view[t++], o === 0 ? null : o;
941
+ }).bind(this), s = y(), !0), e ? (this.offset = t, s()) : {
942
+ string: s(),
943
+ length: t - r
944
+ };
945
+ }, a.writeIString = function(t, e) {
946
+ var r = typeof e > "u";
947
+ if (r && (e = this.offset), !this.noAssert) {
948
+ if (typeof t != "string")
949
+ throw TypeError("Illegal str: Not a string");
950
+ if (typeof e != "number" || e % 1 !== 0)
951
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
952
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
953
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
954
+ }
955
+ var s = e, o;
956
+ o = m.calculateUTF16asUTF8(w(t), this.noAssert)[1], e += 4 + o;
957
+ var u = this.buffer.byteLength;
958
+ if (e > u && this.resize((u *= 2) > e ? u : e), e -= 4 + o, this.littleEndian ? (this.view[e + 3] = o >>> 24 & 255, this.view[e + 2] = o >>> 16 & 255, this.view[e + 1] = o >>> 8 & 255, this.view[e] = o & 255) : (this.view[e] = o >>> 24 & 255, this.view[e + 1] = o >>> 16 & 255, this.view[e + 2] = o >>> 8 & 255, this.view[e + 3] = o & 255), e += 4, m.encodeUTF16toUTF8(w(t), (function(l) {
959
+ this.view[e++] = l;
960
+ }).bind(this)), e !== s + 4 + o)
961
+ throw RangeError("Illegal range: Truncated data, " + e + " == " + (e + 4 + o));
962
+ return r ? (this.offset = e, this) : e - s;
963
+ }, a.readIString = function(t) {
964
+ var e = typeof t > "u";
965
+ if (e && (t = this.offset), !this.noAssert) {
966
+ if (typeof t != "number" || t % 1 !== 0)
967
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
968
+ if (t >>>= 0, t < 0 || t + 4 > this.buffer.byteLength)
969
+ throw RangeError("Illegal offset: 0 <= " + t + " (+4) <= " + this.buffer.byteLength);
970
+ }
971
+ var r = t, s = this.readUint32(t), o = this.readUTF8String(s, n.METRICS_BYTES, t += 4);
972
+ return t += o.length, e ? (this.offset = t, o.string) : {
973
+ string: o.string,
974
+ length: t - r
975
+ };
976
+ }, n.METRICS_CHARS = "c", n.METRICS_BYTES = "b", a.writeUTF8String = function(t, e) {
977
+ var r = typeof e > "u";
978
+ if (r && (e = this.offset), !this.noAssert) {
979
+ if (typeof e != "number" || e % 1 !== 0)
980
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
981
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
982
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
983
+ }
984
+ var s, o = e;
985
+ s = m.calculateUTF16asUTF8(w(t))[1], e += s;
986
+ var u = this.buffer.byteLength;
987
+ return e > u && this.resize((u *= 2) > e ? u : e), e -= s, m.encodeUTF16toUTF8(w(t), (function(l) {
988
+ this.view[e++] = l;
989
+ }).bind(this)), r ? (this.offset = e, this) : e - o;
990
+ }, a.writeString = a.writeUTF8String, n.calculateUTF8Chars = function(t) {
991
+ return m.calculateUTF16asUTF8(w(t))[0];
992
+ }, n.calculateUTF8Bytes = function(t) {
993
+ return m.calculateUTF16asUTF8(w(t))[1];
994
+ }, n.calculateString = n.calculateUTF8Bytes, a.readUTF8String = function(t, e, r) {
995
+ typeof e == "number" && (r = e, e = void 0);
996
+ var s = typeof r > "u";
997
+ if (s && (r = this.offset), typeof e > "u" && (e = n.METRICS_CHARS), !this.noAssert) {
998
+ if (typeof t != "number" || t % 1 !== 0)
999
+ throw TypeError("Illegal length: " + t + " (not an integer)");
1000
+ if (t |= 0, typeof r != "number" || r % 1 !== 0)
1001
+ throw TypeError("Illegal offset: " + r + " (not an integer)");
1002
+ if (r >>>= 0, r < 0 || r + 0 > this.buffer.byteLength)
1003
+ throw RangeError("Illegal offset: 0 <= " + r + " (+0) <= " + this.buffer.byteLength);
1004
+ }
1005
+ var o = 0, u = r, l;
1006
+ if (e === n.METRICS_CHARS) {
1007
+ if (l = y(), m.decodeUTF8((function() {
1008
+ return o < t && r < this.limit ? this.view[r++] : null;
1009
+ }).bind(this), function(F) {
1010
+ ++o, m.UTF8toUTF16(F, l);
1011
+ }), o !== t)
1012
+ throw RangeError("Illegal range: Truncated data, " + o + " == " + t);
1013
+ return s ? (this.offset = r, l()) : {
1014
+ string: l(),
1015
+ length: r - u
1016
+ };
1017
+ } else if (e === n.METRICS_BYTES) {
1018
+ if (!this.noAssert) {
1019
+ if (typeof r != "number" || r % 1 !== 0)
1020
+ throw TypeError("Illegal offset: " + r + " (not an integer)");
1021
+ if (r >>>= 0, r < 0 || r + t > this.buffer.byteLength)
1022
+ throw RangeError("Illegal offset: 0 <= " + r + " (+" + t + ") <= " + this.buffer.byteLength);
1023
+ }
1024
+ var p = r + t;
1025
+ if (m.decodeUTF8toUTF16((function() {
1026
+ return r < p ? this.view[r++] : null;
1027
+ }).bind(this), l = y(), this.noAssert), r !== p)
1028
+ throw RangeError("Illegal range: Truncated data, " + r + " == " + p);
1029
+ return s ? (this.offset = r, l()) : {
1030
+ string: l(),
1031
+ length: r - u
1032
+ };
1033
+ } else
1034
+ throw TypeError("Unsupported metrics: " + e);
1035
+ }, a.readString = a.readUTF8String, a.writeVString = function(t, e) {
1036
+ var r = typeof e > "u";
1037
+ if (r && (e = this.offset), !this.noAssert) {
1038
+ if (typeof t != "string")
1039
+ throw TypeError("Illegal str: Not a string");
1040
+ if (typeof e != "number" || e % 1 !== 0)
1041
+ throw TypeError("Illegal offset: " + e + " (not an integer)");
1042
+ if (e >>>= 0, e < 0 || e + 0 > this.buffer.byteLength)
1043
+ throw RangeError("Illegal offset: 0 <= " + e + " (+0) <= " + this.buffer.byteLength);
1044
+ }
1045
+ var s = e, o, u;
1046
+ o = m.calculateUTF16asUTF8(w(t), this.noAssert)[1], u = n.calculateVarint32(o), e += u + o;
1047
+ var l = this.buffer.byteLength;
1048
+ if (e > l && this.resize((l *= 2) > e ? l : e), e -= u + o, e += this.writeVarint32(o, e), m.encodeUTF16toUTF8(w(t), (function(p) {
1049
+ this.view[e++] = p;
1050
+ }).bind(this)), e !== s + o + u)
1051
+ throw RangeError("Illegal range: Truncated data, " + e + " == " + (e + o + u));
1052
+ return r ? (this.offset = e, this) : e - s;
1053
+ }, a.readVString = function(t) {
1054
+ var e = typeof t > "u";
1055
+ if (e && (t = this.offset), !this.noAssert) {
1056
+ if (typeof t != "number" || t % 1 !== 0)
1057
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
1058
+ if (t >>>= 0, t < 0 || t + 1 > this.buffer.byteLength)
1059
+ throw RangeError("Illegal offset: 0 <= " + t + " (+1) <= " + this.buffer.byteLength);
1060
+ }
1061
+ var r = t, s = this.readVarint32(t), o = this.readUTF8String(s.value, n.METRICS_BYTES, t += s.length);
1062
+ return t += o.length, e ? (this.offset = t, o.string) : {
1063
+ string: o.string,
1064
+ length: t - r
1065
+ };
1066
+ }, a.append = function(t, e, r) {
1067
+ (typeof e == "number" || typeof e != "string") && (r = e, e = void 0);
1068
+ var s = typeof r > "u";
1069
+ if (s && (r = this.offset), !this.noAssert) {
1070
+ if (typeof r != "number" || r % 1 !== 0)
1071
+ throw TypeError("Illegal offset: " + r + " (not an integer)");
1072
+ if (r >>>= 0, r < 0 || r + 0 > this.buffer.byteLength)
1073
+ throw RangeError("Illegal offset: 0 <= " + r + " (+0) <= " + this.buffer.byteLength);
1074
+ }
1075
+ t instanceof n || (t = n.wrap(t, e));
1076
+ var o = t.limit - t.offset;
1077
+ if (o <= 0) return this;
1078
+ r += o;
1079
+ var u = this.buffer.byteLength;
1080
+ return r > u && this.resize((u *= 2) > r ? u : r), r -= o, this.view.set(t.view.subarray(t.offset, t.limit), r), t.offset += o, s && (this.offset += o), this;
1081
+ }, a.appendTo = function(t, e) {
1082
+ return t.append(this, e), this;
1083
+ }, a.assert = function(t) {
1084
+ return this.noAssert = !t, this;
1085
+ }, a.capacity = function() {
1086
+ return this.buffer.byteLength;
1087
+ }, a.clear = function() {
1088
+ return this.offset = 0, this.limit = this.buffer.byteLength, this.markedOffset = -1, this;
1089
+ }, a.clone = function(t) {
1090
+ var e = new n(0, this.littleEndian, this.noAssert);
1091
+ return t ? (e.buffer = new ArrayBuffer(this.buffer.byteLength), e.view = new Uint8Array(e.buffer)) : (e.buffer = this.buffer, e.view = this.view), e.offset = this.offset, e.markedOffset = this.markedOffset, e.limit = this.limit, e;
1092
+ }, a.compact = function(t, e) {
1093
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), !this.noAssert) {
1094
+ if (typeof t != "number" || t % 1 !== 0)
1095
+ throw TypeError("Illegal begin: Not an integer");
1096
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
1097
+ throw TypeError("Illegal end: Not an integer");
1098
+ if (e >>>= 0, t < 0 || t > e || e > this.buffer.byteLength)
1099
+ throw RangeError("Illegal range: 0 <= " + t + " <= " + e + " <= " + this.buffer.byteLength);
1100
+ }
1101
+ if (t === 0 && e === this.buffer.byteLength)
1102
+ return this;
1103
+ var r = e - t;
1104
+ if (r === 0)
1105
+ return this.buffer = c, this.view = null, this.markedOffset >= 0 && (this.markedOffset -= t), this.offset = 0, this.limit = 0, this;
1106
+ var s = new ArrayBuffer(r), o = new Uint8Array(s);
1107
+ return o.set(this.view.subarray(t, e)), this.buffer = s, this.view = o, this.markedOffset >= 0 && (this.markedOffset -= t), this.offset = 0, this.limit = r, this;
1108
+ }, a.copy = function(t, e) {
1109
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), !this.noAssert) {
1110
+ if (typeof t != "number" || t % 1 !== 0)
1111
+ throw TypeError("Illegal begin: Not an integer");
1112
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
1113
+ throw TypeError("Illegal end: Not an integer");
1114
+ if (e >>>= 0, t < 0 || t > e || e > this.buffer.byteLength)
1115
+ throw RangeError("Illegal range: 0 <= " + t + " <= " + e + " <= " + this.buffer.byteLength);
1116
+ }
1117
+ if (t === e)
1118
+ return new n(0, this.littleEndian, this.noAssert);
1119
+ var r = e - t, s = new n(r, this.littleEndian, this.noAssert);
1120
+ return s.offset = 0, s.limit = r, s.markedOffset >= 0 && (s.markedOffset -= t), this.copyTo(s, 0, t, e), s;
1121
+ }, a.copyTo = function(t, e, r, s) {
1122
+ var o, u;
1123
+ if (!this.noAssert && !n.isByteBuffer(t))
1124
+ throw TypeError("Illegal target: Not a ByteBuffer");
1125
+ if (e = (u = typeof e > "u") ? t.offset : e | 0, r = (o = typeof r > "u") ? this.offset : r | 0, s = typeof s > "u" ? this.limit : s | 0, e < 0 || e > t.buffer.byteLength)
1126
+ throw RangeError("Illegal target range: 0 <= " + e + " <= " + t.buffer.byteLength);
1127
+ if (r < 0 || s > this.buffer.byteLength)
1128
+ throw RangeError("Illegal source range: 0 <= " + r + " <= " + this.buffer.byteLength);
1129
+ var l = s - r;
1130
+ return l === 0 ? t : (t.ensureCapacity(e + l), t.view.set(this.view.subarray(r, s), e), o && (this.offset += l), u && (t.offset += l), this);
1131
+ }, a.ensureCapacity = function(t) {
1132
+ var e = this.buffer.byteLength;
1133
+ return e < t ? this.resize((e *= 2) > t ? e : t) : this;
1134
+ }, a.fill = function(t, e, r) {
1135
+ var s = typeof e > "u";
1136
+ if (s && (e = this.offset), typeof t == "string" && t.length > 0 && (t = t.charCodeAt(0)), typeof e > "u" && (e = this.offset), typeof r > "u" && (r = this.limit), !this.noAssert) {
1137
+ if (typeof t != "number" || t % 1 !== 0)
1138
+ throw TypeError("Illegal value: " + t + " (not an integer)");
1139
+ if (t |= 0, typeof e != "number" || e % 1 !== 0)
1140
+ throw TypeError("Illegal begin: Not an integer");
1141
+ if (e >>>= 0, typeof r != "number" || r % 1 !== 0)
1142
+ throw TypeError("Illegal end: Not an integer");
1143
+ if (r >>>= 0, e < 0 || e > r || r > this.buffer.byteLength)
1144
+ throw RangeError("Illegal range: 0 <= " + e + " <= " + r + " <= " + this.buffer.byteLength);
1145
+ }
1146
+ if (e >= r)
1147
+ return this;
1148
+ for (; e < r; ) this.view[e++] = t;
1149
+ return s && (this.offset = e), this;
1150
+ }, a.flip = function() {
1151
+ return this.limit = this.offset, this.offset = 0, this;
1152
+ }, a.mark = function(t) {
1153
+ if (t = typeof t > "u" ? this.offset : t, !this.noAssert) {
1154
+ if (typeof t != "number" || t % 1 !== 0)
1155
+ throw TypeError("Illegal offset: " + t + " (not an integer)");
1156
+ if (t >>>= 0, t < 0 || t + 0 > this.buffer.byteLength)
1157
+ throw RangeError("Illegal offset: 0 <= " + t + " (+0) <= " + this.buffer.byteLength);
1158
+ }
1159
+ return this.markedOffset = t, this;
1160
+ }, a.order = function(t) {
1161
+ if (!this.noAssert && typeof t != "boolean")
1162
+ throw TypeError("Illegal littleEndian: Not a boolean");
1163
+ return this.littleEndian = !!t, this;
1164
+ }, a.LE = function(t) {
1165
+ return this.littleEndian = typeof t < "u" ? !!t : !0, this;
1166
+ }, a.BE = function(t) {
1167
+ return this.littleEndian = typeof t < "u" ? !t : !1, this;
1168
+ }, a.prepend = function(t, e, r) {
1169
+ (typeof e == "number" || typeof e != "string") && (r = e, e = void 0);
1170
+ var s = typeof r > "u";
1171
+ if (s && (r = this.offset), !this.noAssert) {
1172
+ if (typeof r != "number" || r % 1 !== 0)
1173
+ throw TypeError("Illegal offset: " + r + " (not an integer)");
1174
+ if (r >>>= 0, r < 0 || r + 0 > this.buffer.byteLength)
1175
+ throw RangeError("Illegal offset: 0 <= " + r + " (+0) <= " + this.buffer.byteLength);
1176
+ }
1177
+ t instanceof n || (t = n.wrap(t, e));
1178
+ var o = t.limit - t.offset;
1179
+ if (o <= 0) return this;
1180
+ var u = o - r;
1181
+ if (u > 0) {
1182
+ var l = new ArrayBuffer(this.buffer.byteLength + u), p = new Uint8Array(l);
1183
+ p.set(this.view.subarray(r, this.buffer.byteLength), o), this.buffer = l, this.view = p, this.offset += u, this.markedOffset >= 0 && (this.markedOffset += u), this.limit += u, r += u;
1184
+ } else
1185
+ new Uint8Array(this.buffer);
1186
+ return this.view.set(t.view.subarray(t.offset, t.limit), r - o), t.offset = t.limit, s && (this.offset -= o), this;
1187
+ }, a.prependTo = function(t, e) {
1188
+ return t.prepend(this, e), this;
1189
+ }, a.printDebug = function(t) {
1190
+ typeof t != "function" && (t = console.log.bind(console)), t(
1191
+ this.toString() + `
1192
+ -------------------------------------------------------------------
1193
+ ` + this.toDebug(
1194
+ /* columns */
1195
+ !0
1196
+ )
1197
+ );
1198
+ }, a.remaining = function() {
1199
+ return this.limit - this.offset;
1200
+ }, a.reset = function() {
1201
+ return this.markedOffset >= 0 ? (this.offset = this.markedOffset, this.markedOffset = -1) : this.offset = 0, this;
1202
+ }, a.resize = function(t) {
1203
+ if (!this.noAssert) {
1204
+ if (typeof t != "number" || t % 1 !== 0)
1205
+ throw TypeError("Illegal capacity: " + t + " (not an integer)");
1206
+ if (t |= 0, t < 0)
1207
+ throw RangeError("Illegal capacity: 0 <= " + t);
1208
+ }
1209
+ if (this.buffer.byteLength < t) {
1210
+ var e = new ArrayBuffer(t), r = new Uint8Array(e);
1211
+ r.set(this.view), this.buffer = e, this.view = r;
1212
+ }
1213
+ return this;
1214
+ }, a.reverse = function(t, e) {
1215
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), !this.noAssert) {
1216
+ if (typeof t != "number" || t % 1 !== 0)
1217
+ throw TypeError("Illegal begin: Not an integer");
1218
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
1219
+ throw TypeError("Illegal end: Not an integer");
1220
+ if (e >>>= 0, t < 0 || t > e || e > this.buffer.byteLength)
1221
+ throw RangeError("Illegal range: 0 <= " + t + " <= " + e + " <= " + this.buffer.byteLength);
1222
+ }
1223
+ return t === e ? this : (Array.prototype.reverse.call(this.view.subarray(t, e)), this);
1224
+ }, a.skip = function(t) {
1225
+ if (!this.noAssert) {
1226
+ if (typeof t != "number" || t % 1 !== 0)
1227
+ throw TypeError("Illegal length: " + t + " (not an integer)");
1228
+ t |= 0;
1229
+ }
1230
+ var e = this.offset + t;
1231
+ if (!this.noAssert && (e < 0 || e > this.buffer.byteLength))
1232
+ throw RangeError("Illegal length: 0 <= " + this.offset + " + " + t + " <= " + this.buffer.byteLength);
1233
+ return this.offset = e, this;
1234
+ }, a.slice = function(t, e) {
1235
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), !this.noAssert) {
1236
+ if (typeof t != "number" || t % 1 !== 0)
1237
+ throw TypeError("Illegal begin: Not an integer");
1238
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
1239
+ throw TypeError("Illegal end: Not an integer");
1240
+ if (e >>>= 0, t < 0 || t > e || e > this.buffer.byteLength)
1241
+ throw RangeError("Illegal range: 0 <= " + t + " <= " + e + " <= " + this.buffer.byteLength);
1242
+ }
1243
+ var r = this.clone();
1244
+ return r.offset = t, r.limit = e, r;
1245
+ }, a.toBuffer = function(t) {
1246
+ var e = this.offset, r = this.limit;
1247
+ if (!this.noAssert) {
1248
+ if (typeof e != "number" || e % 1 !== 0)
1249
+ throw TypeError("Illegal offset: Not an integer");
1250
+ if (e >>>= 0, typeof r != "number" || r % 1 !== 0)
1251
+ throw TypeError("Illegal limit: Not an integer");
1252
+ if (r >>>= 0, e < 0 || e > r || r > this.buffer.byteLength)
1253
+ throw RangeError("Illegal range: 0 <= " + e + " <= " + r + " <= " + this.buffer.byteLength);
1254
+ }
1255
+ if (!t && e === 0 && r === this.buffer.byteLength)
1256
+ return this.buffer;
1257
+ if (e === r)
1258
+ return c;
1259
+ var s = new ArrayBuffer(r - e);
1260
+ return new Uint8Array(s).set(new Uint8Array(this.buffer).subarray(e, r), 0), s;
1261
+ }, a.toArrayBuffer = a.toBuffer, a.toString = function(t, e, r) {
1262
+ if (typeof t > "u")
1263
+ return "ByteBufferAB(offset=" + this.offset + ",markedOffset=" + this.markedOffset + ",limit=" + this.limit + ",capacity=" + this.capacity() + ")";
1264
+ switch (typeof t == "number" && (t = "utf8", e = t, r = e), t) {
1265
+ case "utf8":
1266
+ return this.toUTF8(e, r);
1267
+ case "base64":
1268
+ return this.toBase64(e, r);
1269
+ case "hex":
1270
+ return this.toHex(e, r);
1271
+ case "binary":
1272
+ return this.toBinary(e, r);
1273
+ case "debug":
1274
+ return this.toDebug();
1275
+ case "columns":
1276
+ return this.toColumns();
1277
+ default:
1278
+ throw Error("Unsupported encoding: " + t);
1279
+ }
1280
+ };
1281
+ var T = function() {
1282
+ for (var t = {}, e = [
1283
+ 65,
1284
+ 66,
1285
+ 67,
1286
+ 68,
1287
+ 69,
1288
+ 70,
1289
+ 71,
1290
+ 72,
1291
+ 73,
1292
+ 74,
1293
+ 75,
1294
+ 76,
1295
+ 77,
1296
+ 78,
1297
+ 79,
1298
+ 80,
1299
+ 81,
1300
+ 82,
1301
+ 83,
1302
+ 84,
1303
+ 85,
1304
+ 86,
1305
+ 87,
1306
+ 88,
1307
+ 89,
1308
+ 90,
1309
+ 97,
1310
+ 98,
1311
+ 99,
1312
+ 100,
1313
+ 101,
1314
+ 102,
1315
+ 103,
1316
+ 104,
1317
+ 105,
1318
+ 106,
1319
+ 107,
1320
+ 108,
1321
+ 109,
1322
+ 110,
1323
+ 111,
1324
+ 112,
1325
+ 113,
1326
+ 114,
1327
+ 115,
1328
+ 116,
1329
+ 117,
1330
+ 118,
1331
+ 119,
1332
+ 120,
1333
+ 121,
1334
+ 122,
1335
+ 48,
1336
+ 49,
1337
+ 50,
1338
+ 51,
1339
+ 52,
1340
+ 53,
1341
+ 54,
1342
+ 55,
1343
+ 56,
1344
+ 57,
1345
+ 43,
1346
+ 47
1347
+ ], r = [], s = 0, o = e.length; s < o; ++s)
1348
+ r[e[s]] = s;
1349
+ return t.encode = function(u, l) {
1350
+ for (var p, F; (p = u()) !== null; )
1351
+ l(e[p >> 2 & 63]), F = (p & 3) << 4, (p = u()) !== null ? (F |= p >> 4 & 15, l(e[(F | p >> 4 & 15) & 63]), F = (p & 15) << 2, (p = u()) !== null ? (l(e[(F | p >> 6 & 3) & 63]), l(e[p & 63])) : (l(e[F & 63]), l(61))) : (l(e[F & 63]), l(61), l(61));
1352
+ }, t.decode = function(u, l) {
1353
+ var p, F, S;
1354
+ function A(L) {
1355
+ throw Error("Illegal character code: " + L);
1356
+ }
1357
+ for (; (p = u()) !== null; )
1358
+ if (F = r[p], typeof F > "u" && A(p), (p = u()) !== null && (S = r[p], typeof S > "u" && A(p), l(F << 2 >>> 0 | (S & 48) >> 4), (p = u()) !== null)) {
1359
+ if (F = r[p], typeof F > "u") {
1360
+ if (p === 61) break;
1361
+ A(p);
1362
+ }
1363
+ if (l((S & 15) << 4 >>> 0 | (F & 60) >> 2), (p = u()) !== null) {
1364
+ if (S = r[p], typeof S > "u") {
1365
+ if (p === 61) break;
1366
+ A(p);
1367
+ }
1368
+ l((F & 3) << 6 >>> 0 | S);
1369
+ }
1370
+ }
1371
+ }, t.test = function(u) {
1372
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(u);
1373
+ }, t;
1374
+ }();
1375
+ a.toBase64 = function(t, e) {
1376
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), t = t | 0, e = e | 0, t < 0 || e > this.capacity || t > e)
1377
+ throw RangeError("begin, end");
1378
+ var r;
1379
+ return T.encode((function() {
1380
+ return t < e ? this.view[t++] : null;
1381
+ }).bind(this), r = y()), r();
1382
+ }, n.fromBase64 = function(t, e) {
1383
+ if (typeof t != "string")
1384
+ throw TypeError("str");
1385
+ var r = new n(t.length / 4 * 3, e), s = 0;
1386
+ return T.decode(w(t), function(o) {
1387
+ r.view[s++] = o;
1388
+ }), r.limit = s, r;
1389
+ }, n.btoa = function(t) {
1390
+ return n.fromBinary(t).toBase64();
1391
+ }, n.atob = function(t) {
1392
+ return n.fromBase64(t).toBinary();
1393
+ }, a.toBinary = function(t, e) {
1394
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), t |= 0, e |= 0, t < 0 || e > this.capacity() || t > e)
1395
+ throw RangeError("begin, end");
1396
+ if (t === e)
1397
+ return "";
1398
+ for (var r = [], s = []; t < e; )
1399
+ r.push(this.view[t++]), r.length >= 1024 && (s.push(String.fromCharCode.apply(String, r)), r = []);
1400
+ return s.join("") + String.fromCharCode.apply(String, r);
1401
+ }, n.fromBinary = function(t, e) {
1402
+ if (typeof t != "string")
1403
+ throw TypeError("str");
1404
+ for (var r = 0, s = t.length, o, u = new n(s, e); r < s; ) {
1405
+ if (o = t.charCodeAt(r), o > 255)
1406
+ throw RangeError("illegal char code: " + o);
1407
+ u.view[r++] = o;
1408
+ }
1409
+ return u.limit = s, u;
1410
+ }, a.toDebug = function(t) {
1411
+ for (var e = -1, r = this.buffer.byteLength, s, o = "", u = "", l = ""; e < r; ) {
1412
+ if (e !== -1 && (s = this.view[e], s < 16 ? o += "0" + s.toString(16).toUpperCase() : o += s.toString(16).toUpperCase(), t && (u += s > 32 && s < 127 ? String.fromCharCode(s) : ".")), ++e, t && e > 0 && e % 16 === 0 && e !== r) {
1413
+ for (; o.length < 3 * 16 + 3; ) o += " ";
1414
+ l += o + u + `
1415
+ `, o = u = "";
1416
+ }
1417
+ e === this.offset && e === this.limit ? o += e === this.markedOffset ? "!" : "|" : e === this.offset ? o += e === this.markedOffset ? "[" : "<" : e === this.limit ? o += e === this.markedOffset ? "]" : ">" : o += e === this.markedOffset ? "'" : t || e !== 0 && e !== r ? " " : "";
1418
+ }
1419
+ if (t && o !== " ") {
1420
+ for (; o.length < 3 * 16 + 3; )
1421
+ o += " ";
1422
+ l += o + u + `
1423
+ `;
1424
+ }
1425
+ return t ? l : o;
1426
+ }, n.fromDebug = function(t, e, r) {
1427
+ for (var s = t.length, o = new n((s + 1) / 3 | 0, e, r), u = 0, l = 0, p, F, S = !1, A = !1, L = !1, _ = !1, d = !1; u < s; ) {
1428
+ switch (p = t.charAt(u++)) {
1429
+ case "!":
1430
+ if (!r) {
1431
+ if (A || L || _) {
1432
+ d = !0;
1433
+ break;
1434
+ }
1435
+ A = L = _ = !0;
1436
+ }
1437
+ o.offset = o.markedOffset = o.limit = l, S = !1;
1438
+ break;
1439
+ case "|":
1440
+ if (!r) {
1441
+ if (A || _) {
1442
+ d = !0;
1443
+ break;
1444
+ }
1445
+ A = _ = !0;
1446
+ }
1447
+ o.offset = o.limit = l, S = !1;
1448
+ break;
1449
+ case "[":
1450
+ if (!r) {
1451
+ if (A || L) {
1452
+ d = !0;
1453
+ break;
1454
+ }
1455
+ A = L = !0;
1456
+ }
1457
+ o.offset = o.markedOffset = l, S = !1;
1458
+ break;
1459
+ case "<":
1460
+ if (!r) {
1461
+ if (A) {
1462
+ d = !0;
1463
+ break;
1464
+ }
1465
+ A = !0;
1466
+ }
1467
+ o.offset = l, S = !1;
1468
+ break;
1469
+ case "]":
1470
+ if (!r) {
1471
+ if (_ || L) {
1472
+ d = !0;
1473
+ break;
1474
+ }
1475
+ _ = L = !0;
1476
+ }
1477
+ o.limit = o.markedOffset = l, S = !1;
1478
+ break;
1479
+ case ">":
1480
+ if (!r) {
1481
+ if (_) {
1482
+ d = !0;
1483
+ break;
1484
+ }
1485
+ _ = !0;
1486
+ }
1487
+ o.limit = l, S = !1;
1488
+ break;
1489
+ case "'":
1490
+ if (!r) {
1491
+ if (L) {
1492
+ d = !0;
1493
+ break;
1494
+ }
1495
+ L = !0;
1496
+ }
1497
+ o.markedOffset = l, S = !1;
1498
+ break;
1499
+ case " ":
1500
+ S = !1;
1501
+ break;
1502
+ default:
1503
+ if (!r && S) {
1504
+ d = !0;
1505
+ break;
1506
+ }
1507
+ if (F = parseInt(p + t.charAt(u++), 16), !r && (isNaN(F) || F < 0 || F > 255))
1508
+ throw TypeError("Illegal str: Not a debug encoded string");
1509
+ o.view[l++] = F, S = !0;
1510
+ }
1511
+ if (d)
1512
+ throw TypeError("Illegal str: Invalid symbol at " + u);
1513
+ }
1514
+ if (!r) {
1515
+ if (!A || !_)
1516
+ throw TypeError("Illegal str: Missing offset or limit");
1517
+ if (l < o.buffer.byteLength)
1518
+ throw TypeError("Illegal str: Not a debug encoded string (is it hex?) " + l + " < " + s);
1519
+ }
1520
+ return o;
1521
+ }, a.toHex = function(t, e) {
1522
+ if (t = typeof t > "u" ? this.offset : t, e = typeof e > "u" ? this.limit : e, !this.noAssert) {
1523
+ if (typeof t != "number" || t % 1 !== 0)
1524
+ throw TypeError("Illegal begin: Not an integer");
1525
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
1526
+ throw TypeError("Illegal end: Not an integer");
1527
+ if (e >>>= 0, t < 0 || t > e || e > this.buffer.byteLength)
1528
+ throw RangeError("Illegal range: 0 <= " + t + " <= " + e + " <= " + this.buffer.byteLength);
1529
+ }
1530
+ for (var r = new Array(e - t), s; t < e; )
1531
+ s = this.view[t++], s < 16 ? r.push("0", s.toString(16)) : r.push(s.toString(16));
1532
+ return r.join("");
1533
+ }, n.fromHex = function(t, e, r) {
1534
+ if (!r) {
1535
+ if (typeof t != "string")
1536
+ throw TypeError("Illegal str: Not a string");
1537
+ if (t.length % 2 !== 0)
1538
+ throw TypeError("Illegal str: Length not a multiple of 2");
1539
+ }
1540
+ for (var s = t.length, o = new n(s / 2 | 0, e), u, l = 0, p = 0; l < s; l += 2) {
1541
+ if (u = parseInt(t.substring(l, l + 2), 16), !r && (!isFinite(u) || u < 0 || u > 255))
1542
+ throw TypeError("Illegal str: Contains non-hex characters");
1543
+ o.view[p++] = u;
1544
+ }
1545
+ return o.limit = p, o;
1546
+ };
1547
+ var m = function() {
1548
+ var t = {};
1549
+ return t.MAX_CODEPOINT = 1114111, t.encodeUTF8 = function(e, r) {
1550
+ var s = null;
1551
+ for (typeof e == "number" && (s = e, e = function() {
1552
+ return null;
1553
+ }); s !== null || (s = e()) !== null; )
1554
+ s < 128 ? r(s & 127) : s < 2048 ? (r(s >> 6 & 31 | 192), r(s & 63 | 128)) : s < 65536 ? (r(s >> 12 & 15 | 224), r(s >> 6 & 63 | 128), r(s & 63 | 128)) : (r(s >> 18 & 7 | 240), r(s >> 12 & 63 | 128), r(s >> 6 & 63 | 128), r(s & 63 | 128)), s = null;
1555
+ }, t.decodeUTF8 = function(e, r) {
1556
+ for (var s, o, u, l, p = function(F) {
1557
+ F = F.slice(0, F.indexOf(null));
1558
+ var S = Error(F.toString());
1559
+ throw S.name = "TruncatedError", S.bytes = F, S;
1560
+ }; (s = e()) !== null; )
1561
+ if ((s & 128) === 0)
1562
+ r(s);
1563
+ else if ((s & 224) === 192)
1564
+ (o = e()) === null && p([s, o]), r((s & 31) << 6 | o & 63);
1565
+ else if ((s & 240) === 224)
1566
+ ((o = e()) === null || (u = e()) === null) && p([s, o, u]), r((s & 15) << 12 | (o & 63) << 6 | u & 63);
1567
+ else if ((s & 248) === 240)
1568
+ ((o = e()) === null || (u = e()) === null || (l = e()) === null) && p([s, o, u, l]), r((s & 7) << 18 | (o & 63) << 12 | (u & 63) << 6 | l & 63);
1569
+ else throw RangeError("Illegal starting byte: " + s);
1570
+ }, t.UTF16toUTF8 = function(e, r) {
1571
+ for (var s, o = null; (s = o !== null ? o : e()) !== null; ) {
1572
+ if (s >= 55296 && s <= 57343 && (o = e()) !== null && o >= 56320 && o <= 57343) {
1573
+ r((s - 55296) * 1024 + o - 56320 + 65536), o = null;
1574
+ continue;
1575
+ }
1576
+ r(s);
1577
+ }
1578
+ o !== null && r(o);
1579
+ }, t.UTF8toUTF16 = function(e, r) {
1580
+ var s = null;
1581
+ for (typeof e == "number" && (s = e, e = function() {
1582
+ return null;
1583
+ }); s !== null || (s = e()) !== null; )
1584
+ s <= 65535 ? r(s) : (s -= 65536, r((s >> 10) + 55296), r(s % 1024 + 56320)), s = null;
1585
+ }, t.encodeUTF16toUTF8 = function(e, r) {
1586
+ t.UTF16toUTF8(e, function(s) {
1587
+ t.encodeUTF8(s, r);
1588
+ });
1589
+ }, t.decodeUTF8toUTF16 = function(e, r) {
1590
+ t.decodeUTF8(e, function(s) {
1591
+ t.UTF8toUTF16(s, r);
1592
+ });
1593
+ }, t.calculateCodePoint = function(e) {
1594
+ return e < 128 ? 1 : e < 2048 ? 2 : e < 65536 ? 3 : 4;
1595
+ }, t.calculateUTF8 = function(e) {
1596
+ for (var r, s = 0; (r = e()) !== null; )
1597
+ s += r < 128 ? 1 : r < 2048 ? 2 : r < 65536 ? 3 : 4;
1598
+ return s;
1599
+ }, t.calculateUTF16asUTF8 = function(e) {
1600
+ var r = 0, s = 0;
1601
+ return t.UTF16toUTF8(e, function(o) {
1602
+ ++r, s += o < 128 ? 1 : o < 2048 ? 2 : o < 65536 ? 3 : 4;
1603
+ }), [r, s];
1604
+ }, t;
1605
+ }();
1606
+ return a.toUTF8 = function(t, e) {
1607
+ if (typeof t > "u" && (t = this.offset), typeof e > "u" && (e = this.limit), !this.noAssert) {
1608
+ if (typeof t != "number" || t % 1 !== 0)
1609
+ throw TypeError("Illegal begin: Not an integer");
1610
+ if (t >>>= 0, typeof e != "number" || e % 1 !== 0)
1611
+ throw TypeError("Illegal end: Not an integer");
1612
+ if (e >>>= 0, t < 0 || t > e || e > this.buffer.byteLength)
1613
+ throw RangeError("Illegal range: 0 <= " + t + " <= " + e + " <= " + this.buffer.byteLength);
1614
+ }
1615
+ var r;
1616
+ try {
1617
+ m.decodeUTF8toUTF16((function() {
1618
+ return t < e ? this.view[t++] : null;
1619
+ }).bind(this), r = y());
1620
+ } catch {
1621
+ if (t !== e)
1622
+ throw RangeError("Illegal range: Truncated data, " + t + " != " + e);
1623
+ }
1624
+ return r();
1625
+ }, n.fromUTF8 = function(t, e, r) {
1626
+ if (!r && typeof t != "string")
1627
+ throw TypeError("Illegal str: Not a string");
1628
+ var s = new n(m.calculateUTF16asUTF8(w(t), !0)[1], e, r), o = 0;
1629
+ return m.encodeUTF16toUTF8(w(t), function(u) {
1630
+ s.view[o++] = u;
1631
+ }), s.limit = o, s;
1632
+ }, n;
1633
+ });
1634
+ }(W)), W.exports;
1635
+ }
1636
+ var dt = pt();
1637
+ const q = /* @__PURE__ */ lt(dt), yt = 1, wt = 2, bt = 512, Et = 513, Ft = 514, Tt = 1, vt = 3;
1638
+ class H {
1639
+ // 实例属性的类型标注
1640
+ valueStringPool;
1641
+ typeStringPool;
1642
+ keyStringPool;
1643
+ package_id;
1644
+ responseMap;
1645
+ entryMap;
1646
+ // 构造函数
1647
+ constructor() {
1648
+ this.valueStringPool = null, this.typeStringPool = null, this.keyStringPool = null, this.package_id = 0, this.responseMap = {}, this.entryMap = {};
1649
+ }
1650
+ /**
1651
+ * Same to C# BinaryReader.readBytes
1652
+ *
1653
+ * @param bb ByteBuffer
1654
+ * @param len length
1655
+ * @returns {ByteBuffer}
1656
+ */
1657
+ static readBytes(i, n) {
1658
+ const a = new Uint8Array(n);
1659
+ for (let c = 0; c < n; c++)
1660
+ a[c] = i.readUint8();
1661
+ return q.wrap(a, "binary", !0);
1662
+ }
1663
+ /**
1664
+ *
1665
+ * @param resourceBuffer {Buffer | ArrayBuffer}
1666
+ * @return {Record<string, string[]>}
1667
+ */
1668
+ processResourceTable(i) {
1669
+ const n = q.wrap(i, "binary", !0), a = n.readShort(), c = n.readShort(), E = n.readInt(), w = n.readInt();
1670
+ let y, I;
1671
+ if (a !== wt)
1672
+ throw new Error("No RES_TABLE_TYPE found!");
1673
+ if (E !== n.limit)
1674
+ throw new Error("The buffer size not matches to the resource table size.");
1675
+ n.offset = c;
1676
+ let N = 0, T = 0;
1677
+ for (; ; ) {
1678
+ let m, t, e;
1679
+ try {
1680
+ m = n.offset, t = n.readShort(), n.readShort(), e = n.readInt();
1681
+ } catch {
1682
+ break;
1683
+ }
1684
+ if (t === yt)
1685
+ N === 0 && (y = new q(e), n.offset = m, n.prependTo(y), I = q.wrap(y, "binary", !0), I.LE(), this.valueStringPool = this.processStringPool(I)), N++;
1686
+ else if (t === bt)
1687
+ y = new q(e), n.offset = m, n.prependTo(y), I = q.wrap(y, "binary", !0), I.LE(), this.processPackage(I), T++;
1688
+ else
1689
+ throw new Error("Unsupported type");
1690
+ if (n.offset = m + e, !n.remaining())
1691
+ break;
1692
+ }
1693
+ if (N !== 1)
1694
+ throw new Error("More than 1 string pool found!");
1695
+ if (T !== w)
1696
+ throw new Error("Real package count not equals the declared count.");
1697
+ return this.responseMap;
1698
+ }
1699
+ /**
1700
+ *
1701
+ * @param {ByteBuffer} bb
1702
+ */
1703
+ processPackage(i) {
1704
+ i.readShort();
1705
+ const n = i.readShort();
1706
+ i.readInt();
1707
+ const a = i.readInt();
1708
+ this.package_id = a;
1709
+ for (let m = 0; m < 256; ++m)
1710
+ i.readUint8();
1711
+ const c = i.readInt();
1712
+ i.readInt();
1713
+ const E = i.readInt();
1714
+ if (i.readInt(), c !== n)
1715
+ throw new Error("TypeStrings must immediately following the package structure header.");
1716
+ let w = i.offset;
1717
+ i.offset = c;
1718
+ const y = H.readBytes(i, i.limit - i.offset);
1719
+ i.offset = w, this.typeStringPool = this.processStringPool(y), i.offset = E, i.readShort(), i.readShort();
1720
+ const I = i.readInt();
1721
+ w = i.offset, i.offset = E;
1722
+ const N = H.readBytes(i, i.limit - i.offset);
1723
+ i.offset = w, this.keyStringPool = this.processStringPool(N), i.offset = E + I;
1724
+ let T;
1725
+ for (; ; ) {
1726
+ const m = i.offset;
1727
+ let t, e;
1728
+ try {
1729
+ t = i.readShort(), i.readShort(), e = i.readInt();
1730
+ } catch {
1731
+ break;
1732
+ }
1733
+ if (t === Ft ? (i.offset = m, T = H.readBytes(i, e), this.processTypeSpec(T)) : t === Et && (i.offset = m, T = H.readBytes(i, e), this.processType(T)), e === 0 || (i.offset = m + e, !i.remaining()))
1734
+ break;
1735
+ }
1736
+ }
1737
+ /**
1738
+ *
1739
+ * @param {ByteBuffer} bb
1740
+ */
1741
+ processType(i) {
1742
+ i.readShort();
1743
+ const n = i.readShort();
1744
+ i.readInt();
1745
+ const a = i.readByte();
1746
+ i.readByte(), i.readShort();
1747
+ const c = i.readInt(), E = i.readInt(), w = {};
1748
+ if (i.readInt(), i.offset = n, n + c * 4 !== E)
1749
+ throw new Error("HeaderSize, entryCount and entriesStart are not valid.");
1750
+ const y = new Array(c);
1751
+ for (let I = 0; I < c; ++I)
1752
+ y[I] = i.readInt();
1753
+ for (let I = 0; I < c; ++I) {
1754
+ if (y[I] === -1) continue;
1755
+ const N = this.package_id << 24 | a << 16 | I, T = i.offset;
1756
+ let m, t, e, r;
1757
+ try {
1758
+ i.readShort(), m = i.readShort(), t = i.readInt();
1759
+ } catch {
1760
+ break;
1761
+ }
1762
+ if ((m & 1) === 0) {
1763
+ i.readShort(), i.readByte(), e = i.readByte(), r = i.readInt();
1764
+ const o = Number(N).toString(16), u = this.keyStringPool[t];
1765
+ let l = null;
1766
+ const p = parseInt(o, 16);
1767
+ let F = this.entryMap[p];
1768
+ F == null && (F = []), F.push(u), this.entryMap[p] = F, e === vt ? l = this.valueStringPool[r] : e === Tt ? w[o] = r : l = "" + r, this.putIntoMap("@" + o, l), i.offset = T + 8 + 8;
1769
+ } else {
1770
+ i.readInt();
1771
+ const o = i.readInt();
1772
+ for (let u = 0; u < o; ++u)
1773
+ i.readInt(), i.readShort(), i.readByte(), e = i.readByte(), r = i.readInt();
1774
+ }
1775
+ }
1776
+ for (const I in w) {
1777
+ const N = this.responseMap["@" + Number(w[I]).toString(16).toUpperCase()];
1778
+ if (N != null && Object.keys(N).length < 1e3)
1779
+ for (const T of N)
1780
+ this.putIntoMap("@" + I, T);
1781
+ }
1782
+ }
1783
+ /**
1784
+ *
1785
+ * @param {ByteBuffer} bb
1786
+ * @return {string[]}
1787
+ */
1788
+ processStringPool(i) {
1789
+ i.readShort(), i.readShort(), i.readInt();
1790
+ const n = i.readInt();
1791
+ i.readInt();
1792
+ const a = i.readInt(), c = i.readInt();
1793
+ i.readInt();
1794
+ let E, w;
1795
+ const y = (a & 256) !== 0, I = new Array(n);
1796
+ for (let T = 0; T < n; ++T)
1797
+ I[T] = i.readInt();
1798
+ const N = new Array(n);
1799
+ for (let T = 0; T < n; ++T) {
1800
+ const m = c + I[T];
1801
+ if (i.offset = m, N[T] = "", y) {
1802
+ E = i.readUint8(), (E & 128) !== 0 && (E = ((E & 127) << 8) + i.readUint8());
1803
+ let t = i.readUint8();
1804
+ if ((t & 128) !== 0 && (t = ((t & 127) << 8) + i.readUint8()), t > 0) {
1805
+ w = H.readBytes(i, t);
1806
+ try {
1807
+ N[T] = q.wrap(w, "utf8", !0).toString("utf8");
1808
+ } catch {
1809
+ }
1810
+ } else
1811
+ N[T] = "";
1812
+ } else if (E = i.readUint16(), (E & 32768) !== 0 && (E = ((E & 32767) << 16) + i.readUint16()), E > 0) {
1813
+ const t = E * 2;
1814
+ w = H.readBytes(i, t);
1815
+ try {
1816
+ N[T] = q.wrap(w, "utf8", !0).toString("utf8");
1817
+ } catch {
1818
+ }
1819
+ }
1820
+ }
1821
+ return N;
1822
+ }
1823
+ /**
1824
+ *
1825
+ * @param {ByteBuffer} bb
1826
+ */
1827
+ processTypeSpec(i) {
1828
+ i.readShort(), i.readShort(), i.readInt(), i.readByte(), i.readByte(), i.readShort();
1829
+ const n = i.readInt(), a = new Array(n);
1830
+ for (let c = 0; c < n; ++c)
1831
+ a[c] = i.readInt();
1832
+ }
1833
+ /**
1834
+ *
1835
+ * @param {string} resId - 格式如 '@10101010'
1836
+ * @param {string | null} value - 资源值,可能是 null
1837
+ */
1838
+ putIntoMap(i, n) {
1839
+ const a = i.toUpperCase();
1840
+ this.responseMap[a] == null && (this.responseMap[a] = []), n && this.responseMap[a].push(n);
1841
+ }
1842
+ }
1843
+ const z = {
1844
+ ELEMENT_NODE: 1,
1845
+ ATTRIBUTE_NODE: 2,
1846
+ CDATA_SECTION_NODE: 4
1847
+ }, Y = {
1848
+ NULL: 0,
1849
+ STRING_POOL: 1,
1850
+ XML: 3,
1851
+ XML_START_NAMESPACE: 256,
1852
+ XML_END_NAMESPACE: 257,
1853
+ XML_START_ELEMENT: 258,
1854
+ XML_END_ELEMENT: 259,
1855
+ XML_CDATA: 260,
1856
+ XML_RESOURCE_MAP: 384
1857
+ }, Z = {
1858
+ SORTED: 1,
1859
+ UTF8: 256
1860
+ }, C = {
1861
+ COMPLEX_UNIT_DIP: 1,
1862
+ COMPLEX_UNIT_FRACTION: 0,
1863
+ COMPLEX_UNIT_FRACTION_PARENT: 1,
1864
+ COMPLEX_UNIT_IN: 4,
1865
+ COMPLEX_UNIT_MM: 5,
1866
+ COMPLEX_UNIT_PT: 3,
1867
+ COMPLEX_UNIT_PX: 0,
1868
+ COMPLEX_UNIT_SP: 2,
1869
+ TYPE_DIMENSION: 5,
1870
+ TYPE_FRACTION: 6,
1871
+ TYPE_INT_BOOLEAN: 18,
1872
+ TYPE_INT_COLOR_ARGB4: 30,
1873
+ TYPE_INT_COLOR_ARGB8: 28,
1874
+ TYPE_INT_COLOR_RGB4: 31,
1875
+ TYPE_INT_COLOR_RGB8: 29,
1876
+ TYPE_INT_DEC: 16,
1877
+ TYPE_INT_HEX: 17,
1878
+ TYPE_NULL: 0,
1879
+ TYPE_REFERENCE: 1,
1880
+ TYPE_STRING: 3
1881
+ };
1882
+ class It {
1883
+ view;
1884
+ // Use DataView for reading little-endian data
1885
+ cursor;
1886
+ strings;
1887
+ resources;
1888
+ document;
1889
+ parent;
1890
+ stack;
1891
+ debug;
1892
+ /**
1893
+ * Initializes the parser.
1894
+ * @param buffer The ArrayBuffer containing the binary XML data.
1895
+ * @param options Configuration options for the parser.
1896
+ */
1897
+ constructor(i, n = {}) {
1898
+ this.view = new DataView(i), this.cursor = 0, this.strings = [], this.resources = [], this.document = null, this.parent = null, this.stack = [], this.debug = n.debug || !1;
1899
+ }
1900
+ // --- Reading Primitives (DataView Implementation) ---
1901
+ readU8() {
1902
+ this.debug && (console.group("readU8"), console.debug("cursor:", this.cursor));
1903
+ const i = this.view.getUint8(this.cursor);
1904
+ return this.debug && console.debug("value:", i), this.cursor += 1, this.debug && console.groupEnd(), i;
1905
+ }
1906
+ readU16() {
1907
+ this.debug && (console.group("readU16"), console.debug("cursor:", this.cursor));
1908
+ const i = this.view.getUint16(this.cursor, !0);
1909
+ return this.debug && console.debug("value:", i), this.cursor += 2, this.debug && console.groupEnd(), i;
1910
+ }
1911
+ readS32() {
1912
+ this.debug && (console.group("readS32"), console.debug("cursor:", this.cursor));
1913
+ const i = this.view.getInt32(this.cursor, !0);
1914
+ return this.debug && console.debug("value:", i), this.cursor += 4, this.debug && console.groupEnd(), i;
1915
+ }
1916
+ readU32() {
1917
+ this.debug && (console.group("readU32"), console.debug("cursor:", this.cursor));
1918
+ const i = this.view.getUint32(this.cursor, !0);
1919
+ return this.debug && console.debug("value:", i), this.cursor += 4, this.debug && console.groupEnd(), i;
1920
+ }
1921
+ // --- Utility Methods ---
1922
+ readLength8() {
1923
+ this.debug && console.group("readLength8");
1924
+ let i = this.readU8();
1925
+ return i & 128 && (i = (i & 127) << 8, i += this.readU8()), this.debug && (console.debug("length:", i), console.groupEnd()), i;
1926
+ }
1927
+ readLength16() {
1928
+ this.debug && console.group("readLength16");
1929
+ let i = this.readU16();
1930
+ return i & 32768 && (i = (i & 32767) << 16, i += this.readU16()), this.debug && (console.debug("length:", i), console.groupEnd()), i;
1931
+ }
1932
+ readDimension() {
1933
+ this.debug && console.group("readDimension");
1934
+ const i = {
1935
+ value: 0,
1936
+ // Will be overwritten
1937
+ unit: null,
1938
+ rawUnit: 0
1939
+ // Will be overwritten
1940
+ }, n = this.readU32(), a = n & 255;
1941
+ switch (i.value = n >> 8, i.rawUnit = a, a) {
1942
+ case C.COMPLEX_UNIT_MM:
1943
+ i.unit = "mm";
1944
+ break;
1945
+ case C.COMPLEX_UNIT_PX:
1946
+ i.unit = "px";
1947
+ break;
1948
+ case C.COMPLEX_UNIT_DIP:
1949
+ i.unit = "dp";
1950
+ break;
1951
+ case C.COMPLEX_UNIT_SP:
1952
+ i.unit = "sp";
1953
+ break;
1954
+ case C.COMPLEX_UNIT_PT:
1955
+ i.unit = "pt";
1956
+ break;
1957
+ case C.COMPLEX_UNIT_IN:
1958
+ i.unit = "in";
1959
+ break;
1960
+ }
1961
+ return this.debug && console.groupEnd(), i;
1962
+ }
1963
+ readFraction() {
1964
+ this.debug && console.group("readFraction");
1965
+ const i = {
1966
+ value: 0,
1967
+ // Will be overwritten
1968
+ type: null,
1969
+ rawType: 0
1970
+ // Will be overwritten
1971
+ }, n = this.readU32(), a = n & 15;
1972
+ switch (i.value = this.convertIntToFloat(n >> 4), i.rawType = a, a) {
1973
+ case C.COMPLEX_UNIT_FRACTION:
1974
+ i.type = "%";
1975
+ break;
1976
+ case C.COMPLEX_UNIT_FRACTION_PARENT:
1977
+ i.type = "%p";
1978
+ break;
1979
+ }
1980
+ return this.debug && console.groupEnd(), i;
1981
+ }
1982
+ readHex24() {
1983
+ this.debug && console.group("readHex24");
1984
+ const i = (this.readU32() & 16777215).toString(16).padStart(6, "0");
1985
+ return this.debug && console.groupEnd(), i;
1986
+ }
1987
+ readHex32() {
1988
+ this.debug && console.group("readHex32");
1989
+ const i = this.readU32().toString(16).padStart(8, "0");
1990
+ return this.debug && console.groupEnd(), i;
1991
+ }
1992
+ readTypedValue() {
1993
+ this.debug && console.group("readTypedValue");
1994
+ const i = {
1995
+ value: null,
1996
+ type: null,
1997
+ rawType: 0
1998
+ // Will be overwritten
1999
+ }, n = this.cursor;
2000
+ let a = this.readU16();
2001
+ this.readU8();
2002
+ const c = this.readU8();
2003
+ switch (a === 0 && (a = 8), i.rawType = c, c) {
2004
+ case C.TYPE_INT_DEC:
2005
+ i.value = this.readS32(), i.type = "int_dec";
2006
+ break;
2007
+ case C.TYPE_INT_HEX:
2008
+ i.value = this.readS32(), i.type = "int_hex";
2009
+ break;
2010
+ case C.TYPE_STRING:
2011
+ const w = this.readS32();
2012
+ i.value = w >= 0 ? this.strings[w] : "", i.type = "string";
2013
+ break;
2014
+ case C.TYPE_REFERENCE:
2015
+ const y = this.readU32();
2016
+ i.value = `resourceId:0x${y.toString(16)}`, i.type = "reference";
2017
+ break;
2018
+ case C.TYPE_INT_BOOLEAN:
2019
+ i.value = this.readS32() !== 0, i.type = "boolean";
2020
+ break;
2021
+ case C.TYPE_NULL:
2022
+ this.readU32(), i.value = null, i.type = "null";
2023
+ break;
2024
+ case C.TYPE_INT_COLOR_RGB8:
2025
+ i.value = this.readHex24(), i.type = "rgb8";
2026
+ break;
2027
+ case C.TYPE_INT_COLOR_RGB4:
2028
+ i.value = this.readHex24(), i.type = "rgb4";
2029
+ break;
2030
+ case C.TYPE_INT_COLOR_ARGB8:
2031
+ i.value = this.readHex32(), i.type = "argb8";
2032
+ break;
2033
+ case C.TYPE_INT_COLOR_ARGB4:
2034
+ i.value = this.readHex32(), i.type = "argb4";
2035
+ break;
2036
+ case C.TYPE_DIMENSION:
2037
+ i.value = this.readDimension(), i.type = "dimension";
2038
+ break;
2039
+ case C.TYPE_FRACTION:
2040
+ i.value = this.readFraction(), i.type = "fraction";
2041
+ break;
2042
+ default: {
2043
+ const I = c.toString(16);
2044
+ console.debug(`Not sure what to do with typed value of type 0x${I}, falling back to reading an uint32.`), i.value = this.readU32(), i.type = "unknown";
2045
+ }
2046
+ }
2047
+ const E = n + a;
2048
+ if (this.cursor !== E) {
2049
+ const w = c.toString(16), y = E - this.cursor;
2050
+ console.debug(`Cursor is off by ${y} bytes at ${this.cursor} at supposed end of typed value of type 0x${w}. The typed value started at offset ${n} and is supposed to end at offset ${E}. Ignoring the rest of the value.`), this.cursor = E;
2051
+ }
2052
+ return this.debug && console.groupEnd(), i;
2053
+ }
2054
+ // https://twitter.com/kawasima/status/427730289201139712
2055
+ convertIntToFloat(i) {
2056
+ const n = new ArrayBuffer(4);
2057
+ return new DataView(n).setInt32(0, i, !0), new DataView(n).getFloat32(0, !0);
2058
+ }
2059
+ // Use TextDecoder for browser compatibility
2060
+ readString(i) {
2061
+ this.debug && console.group("readString", i);
2062
+ let n, a;
2063
+ switch (i) {
2064
+ case "utf-8":
2065
+ a = this.readLength8(), this.debug && console.debug("stringLength:", a), n = this.readLength8(), this.debug && console.debug("byteLength:", n);
2066
+ break;
2067
+ // Continue below to decode using TextDecoder
2068
+ case "ucs2":
2069
+ a = this.readLength16(), this.debug && console.debug("stringLength:", a), n = a * 2, this.debug && console.debug("byteLength:", n);
2070
+ break;
2071
+ // Continue below to decode using TextDecoder
2072
+ default:
2073
+ throw new Error(`Unsupported encoding '${i}'`);
2074
+ }
2075
+ const c = new TextDecoder(i === "ucs2" ? "utf-16le" : i), E = new Uint8Array(this.view.buffer, this.cursor, n), w = c.decode(E);
2076
+ return this.cursor += n, this.debug && (console.debug("value:", w), console.groupEnd()), w;
2077
+ }
2078
+ readChunkHeader() {
2079
+ this.debug && console.group("readChunkHeader");
2080
+ const i = {
2081
+ startOffset: this.cursor,
2082
+ chunkType: this.readU16(),
2083
+ headerSize: this.readU16(),
2084
+ chunkSize: this.readU32()
2085
+ };
2086
+ return this.debug && (console.debug("startOffset:", i.startOffset), console.debug("chunkType:", i.chunkType), console.debug("headerSize:", i.headerSize), console.debug("chunkSize:", i.chunkSize), console.groupEnd()), i;
2087
+ }
2088
+ readStringPool(i) {
2089
+ if (this.debug && console.group("readStringPool"), i.stringCount = this.readU32(), this.debug && console.debug("stringCount:", i.stringCount), i.styleCount = this.readU32(), this.debug && console.debug("styleCount:", i.styleCount), i.flags = this.readU32(), this.debug && console.debug("flags:", i.flags), i.stringsStart = this.readU32(), this.debug && console.debug("stringsStart:", i.stringsStart), i.stylesStart = this.readU32(), this.debug && console.debug("stylesStart:", i.stylesStart), i.chunkType !== Y.STRING_POOL)
2090
+ throw new Error("Invalid string pool header");
2091
+ const n = [];
2092
+ for (let w = 0, y = i.stringCount; w < y; ++w)
2093
+ this.debug && console.debug("offset:", w), n.push(this.readU32());
2094
+ const a = (i.flags & Z.SORTED) === Z.SORTED;
2095
+ this.debug && console.debug("sorted:", a);
2096
+ const c = (i.flags & Z.UTF8) === Z.UTF8 ? "utf-8" : "ucs2";
2097
+ this.debug && console.debug("encoding:", c);
2098
+ const E = i.startOffset + (i.stringsStart || 0);
2099
+ for (let w = 0, y = i.stringCount; w < y; ++w)
2100
+ this.debug && (console.debug("string:", w), console.debug("offset:", n[w])), this.cursor = E + n[w], this.strings.push(this.readString(c));
2101
+ return this.cursor = i.startOffset + i.chunkSize, this.debug && console.groupEnd(), null;
2102
+ }
2103
+ readResourceMap(i) {
2104
+ this.debug && console.group("readResourceMap");
2105
+ const n = Math.floor((i.chunkSize - i.headerSize) / 4);
2106
+ for (let a = 0; a < n; ++a)
2107
+ this.resources.push(this.readU32());
2108
+ return this.debug && console.groupEnd(), null;
2109
+ }
2110
+ readXmlNamespaceStart(i) {
2111
+ return this.debug && console.group("readXmlNamespaceStart", i), this.readU32(), this.readU32(), this.readS32(), this.readS32(), this.debug && console.groupEnd(), null;
2112
+ }
2113
+ readXmlNamespaceEnd(i) {
2114
+ return this.debug && console.group("readXmlNamespaceEnd", i), this.readU32(), this.readU32(), this.readS32(), this.readS32(), this.debug && console.groupEnd(), null;
2115
+ }
2116
+ readXmlElementStart(i) {
2117
+ this.debug && console.group("readXmlElementStart", i);
2118
+ const n = {
2119
+ namespaceURI: null,
2120
+ nodeType: z.ELEMENT_NODE,
2121
+ nodeName: null,
2122
+ attributes: [],
2123
+ childNodes: []
2124
+ };
2125
+ this.readU32(), this.readU32();
2126
+ const a = this.readS32(), c = this.readS32();
2127
+ a >= 0 && (n.namespaceURI = this.strings[a]), c >= 0 && (n.nodeName = this.strings[c]), this.readU16(), this.readU16();
2128
+ const E = this.readU16();
2129
+ this.readU16(), this.readU16(), this.readU16();
2130
+ for (let w = 0; w < E; ++w)
2131
+ n.attributes.push(this.readXmlAttribute());
2132
+ return this.document ? (this.parent && this.parent.nodeType === z.ELEMENT_NODE && this.parent.childNodes.push(n), this.parent = n) : this.document = this.parent = n, this.stack.push(n), this.debug && console.groupEnd(), n;
2133
+ }
2134
+ readXmlAttribute() {
2135
+ this.debug && console.group("readXmlAttribute");
2136
+ const i = {
2137
+ namespaceURI: null,
2138
+ nodeType: z.ATTRIBUTE_NODE,
2139
+ nodeName: null,
2140
+ name: null,
2141
+ value: null,
2142
+ typedValue: {}
2143
+ // Will be overwritten
2144
+ }, n = this.readS32(), a = this.readS32(), c = this.readS32();
2145
+ return n >= 0 && (i.namespaceURI = this.strings[n]), a >= 0 && (i.nodeName = i.name = this.strings[a]), c >= 0 && (i.name === "versionName" && this.strings[c] && (this.strings[c] = this.strings[c].replace(/[^\d\w-.]/g, "")), i.value = this.strings[c]), i.typedValue = this.readTypedValue(), this.debug && console.groupEnd(), i;
2146
+ }
2147
+ readXmlElementEnd(i) {
2148
+ return this.debug && console.group("readXmlCData", i), this.readU32(), this.readU32(), this.readS32(), this.readS32(), this.stack.pop(), this.parent = this.stack[this.stack.length - 1] || null, this.debug && console.groupEnd(), null;
2149
+ }
2150
+ readXmlCData(i) {
2151
+ this.debug && console.group("readXmlCData", i);
2152
+ const n = {
2153
+ namespaceURI: null,
2154
+ nodeType: z.CDATA_SECTION_NODE,
2155
+ nodeName: "#cdata",
2156
+ data: null,
2157
+ typedValue: {}
2158
+ // Will be overwritten
2159
+ };
2160
+ this.readU32(), this.readU32();
2161
+ const a = this.readS32();
2162
+ return a >= 0 && (n.data = this.strings[a]), n.typedValue = this.readTypedValue(), this.parent && this.parent.nodeType === z.ELEMENT_NODE && this.parent.childNodes.push(n), this.debug && console.groupEnd(), n;
2163
+ }
2164
+ readNull(i) {
2165
+ return this.debug && console.group("readNull"), this.cursor += i.chunkSize - i.headerSize, this.debug && console.groupEnd(), null;
2166
+ }
2167
+ /**
2168
+ * Parses the binary XML buffer.
2169
+ * @returns The root XML element of the parsed document.
2170
+ */
2171
+ parse() {
2172
+ if (this.debug && console.group("BinaryXmlParser.parse"), this.readChunkHeader().chunkType !== Y.XML)
2173
+ throw new Error("Invalid XML header");
2174
+ for (; this.cursor < this.view.byteLength; ) {
2175
+ this.debug && console.group("chunk");
2176
+ const n = this.cursor, a = this.readChunkHeader();
2177
+ switch (a.chunkType) {
2178
+ case Y.STRING_POOL:
2179
+ this.readStringPool(a);
2180
+ break;
2181
+ case Y.XML_RESOURCE_MAP:
2182
+ this.readResourceMap(a);
2183
+ break;
2184
+ case Y.XML_START_NAMESPACE:
2185
+ this.readXmlNamespaceStart(a);
2186
+ break;
2187
+ case Y.XML_END_NAMESPACE:
2188
+ this.readXmlNamespaceEnd(a);
2189
+ break;
2190
+ case Y.XML_START_ELEMENT:
2191
+ this.readXmlElementStart(a);
2192
+ break;
2193
+ case Y.XML_END_ELEMENT:
2194
+ this.readXmlElementEnd(a);
2195
+ break;
2196
+ case Y.XML_CDATA:
2197
+ this.readXmlCData(a);
2198
+ break;
2199
+ case Y.NULL:
2200
+ this.readNull(a);
2201
+ break;
2202
+ default:
2203
+ throw new Error(`Unsupported chunk type '0x${a.chunkType.toString(16)}'`);
2204
+ }
2205
+ const c = n + a.chunkSize;
2206
+ if (this.cursor !== c) {
2207
+ const E = c - this.cursor, w = a.chunkType.toString(16);
2208
+ console.debug(`Cursor is off by ${E} bytes at ${this.cursor} at supposed end of chunk of type 0x${w}. The chunk started at offset ${n} and is supposed to end at offset ${c}. Ignoring the rest of the chunk.`), this.cursor = c;
2209
+ }
2210
+ this.debug && console.groupEnd();
2211
+ }
2212
+ return this.debug && console.groupEnd(), this.document;
2213
+ }
2214
+ }
2215
+ const mt = "android.intent.action.MAIN", xt = "android.intent.category.LAUNCHER";
2216
+ class St {
2217
+ buffer;
2218
+ xmlParser;
2219
+ /**
2220
+ * @param buffer The ArrayBuffer containing the binary XML data.
2221
+ * @param options Configuration options for the underlying BinaryXmlParser.
2222
+ */
2223
+ constructor(i, n = {}) {
2224
+ this.buffer = i, this.xmlParser = new It(this.buffer, n);
2225
+ }
2226
+ /**
2227
+ * Flattens the attributes of an XML element into a simple key/value object.
2228
+ * **(保留了 Array.from 的原始逻辑)**
2229
+ * @param element The XML element node.
2230
+ * @returns An object containing the collapsed attributes.
2231
+ */
2232
+ collapseAttributes(i) {
2233
+ const n = /* @__PURE__ */ Object.create(null);
2234
+ if (i.nodeType === z.ELEMENT_NODE)
2235
+ for (const a of Array.from(i.attributes))
2236
+ n[a.name] = a.typedValue.value;
2237
+ return n;
2238
+ }
2239
+ /**
2240
+ * Parses child nodes of a component into intent filters and meta data.
2241
+ */
2242
+ parseIntents(i, n) {
2243
+ n.intentFilters = [], n.metaData = [], i.childNodes.forEach((a) => {
2244
+ if (a.nodeType === z.ELEMENT_NODE)
2245
+ switch (a.nodeName) {
2246
+ case "intent-filter": {
2247
+ const c = this.collapseAttributes(a);
2248
+ c.actions = [], c.categories = [], c.data = [], a.childNodes.forEach((E) => {
2249
+ if (E.nodeType === z.ELEMENT_NODE)
2250
+ switch (E.nodeName) {
2251
+ case "action":
2252
+ c.actions.push(this.collapseAttributes(E));
2253
+ break;
2254
+ case "category":
2255
+ c.categories.push(this.collapseAttributes(E));
2256
+ break;
2257
+ case "data":
2258
+ c.data.push(this.collapseAttributes(E));
2259
+ break;
2260
+ }
2261
+ }), n.intentFilters.push(c);
2262
+ break;
2263
+ }
2264
+ case "meta-data":
2265
+ n.metaData.push(this.collapseAttributes(a));
2266
+ break;
2267
+ }
2268
+ });
2269
+ }
2270
+ /**
2271
+ * Parses the <application> element and its children.
2272
+ * @param element The <application> XML element.
2273
+ * @returns The parsed Application object.
2274
+ */
2275
+ parseApplication(i) {
2276
+ const n = this.collapseAttributes(i);
2277
+ return n.activities = [], n.activityAliases = [], n.launcherActivities = [], n.services = [], n.receivers = [], n.providers = [], n.usesLibraries = [], n.metaData = [], i.childNodes.forEach((a) => {
2278
+ if (a.nodeType === z.ELEMENT_NODE)
2279
+ switch (a.nodeName) {
2280
+ case "activity": {
2281
+ const c = this.collapseAttributes(a);
2282
+ this.parseIntents(a, c), n.activities.push(c), this.isLauncherActivity(c) && n.launcherActivities.push(c);
2283
+ break;
2284
+ }
2285
+ case "activity-alias": {
2286
+ const c = this.collapseAttributes(a);
2287
+ this.parseIntents(a, c), n.activityAliases.push(c), this.isLauncherActivity(c) && n.launcherActivities.push(c);
2288
+ break;
2289
+ }
2290
+ case "service": {
2291
+ const c = this.collapseAttributes(a);
2292
+ this.parseIntents(a, c), n.services.push(c);
2293
+ break;
2294
+ }
2295
+ case "receiver": {
2296
+ const c = this.collapseAttributes(a);
2297
+ this.parseIntents(a, c), n.receivers.push(c);
2298
+ break;
2299
+ }
2300
+ case "provider": {
2301
+ const c = this.collapseAttributes(a);
2302
+ c.grantUriPermissions = [], c.metaData = [], c.pathPermissions = [], a.childNodes.forEach((E) => {
2303
+ if (E.nodeType === z.ELEMENT_NODE)
2304
+ switch (E.nodeName) {
2305
+ case "grant-uri-permission":
2306
+ c.grantUriPermissions.push(this.collapseAttributes(E));
2307
+ break;
2308
+ case "meta-data":
2309
+ c.metaData.push(this.collapseAttributes(E));
2310
+ break;
2311
+ case "path-permission":
2312
+ c.pathPermissions.push(this.collapseAttributes(E));
2313
+ break;
2314
+ }
2315
+ }), n.providers.push(c);
2316
+ break;
2317
+ }
2318
+ case "uses-library":
2319
+ n.usesLibraries.push(this.collapseAttributes(a));
2320
+ break;
2321
+ case "meta-data":
2322
+ n.metaData.push(this.collapseAttributes(a));
2323
+ break;
2324
+ }
2325
+ }), n;
2326
+ }
2327
+ /**
2328
+ * Checks if an Activity or Activity Alias is configured as a launcher component.
2329
+ * @param component The Activity or Activity Alias object.
2330
+ * @returns True if it is a launcher component.
2331
+ */
2332
+ isLauncherActivity(i) {
2333
+ return i.intentFilters.some(function(n) {
2334
+ return n.actions.some((c) => c.name === mt) ? n.categories.some((c) => c.name === xt) : !1;
2335
+ });
2336
+ }
2337
+ /**
2338
+ * Parses the entire binary manifest buffer.
2339
+ * @returns The final parsed manifest object.
2340
+ */
2341
+ parse() {
2342
+ const i = this.xmlParser.parse(), n = this.collapseAttributes(i);
2343
+ return n.usesPermissions = [], n.usesPermissionsSDK23 = [], n.permissions = [], n.permissionTrees = [], n.permissionGroups = [], n.instrumentation = null, n.usesSdk = null, n.usesConfiguration = null, n.usesFeatures = [], n.supportsScreens = null, n.compatibleScreens = [], n.supportsGlTextures = [], i.childNodes.forEach((a) => {
2344
+ if (a.nodeType === z.ELEMENT_NODE)
2345
+ switch (a.nodeName) {
2346
+ case "uses-permission":
2347
+ n.usesPermissions.push(this.collapseAttributes(a));
2348
+ break;
2349
+ case "uses-permission-sdk-23":
2350
+ n.usesPermissionsSDK23.push(this.collapseAttributes(a));
2351
+ break;
2352
+ case "permission":
2353
+ n.permissions.push(this.collapseAttributes(a));
2354
+ break;
2355
+ case "permission-tree":
2356
+ n.permissionTrees.push(this.collapseAttributes(a));
2357
+ break;
2358
+ case "permission-group":
2359
+ n.permissionGroups.push(this.collapseAttributes(a));
2360
+ break;
2361
+ case "instrumentation":
2362
+ n.instrumentation = this.collapseAttributes(a);
2363
+ break;
2364
+ case "uses-sdk":
2365
+ n.usesSdk = this.collapseAttributes(a);
2366
+ break;
2367
+ case "uses-configuration":
2368
+ n.usesConfiguration = this.collapseAttributes(a);
2369
+ break;
2370
+ case "uses-feature":
2371
+ n.usesFeatures.push(this.collapseAttributes(a));
2372
+ break;
2373
+ case "supports-screens":
2374
+ n.supportsScreens = this.collapseAttributes(a);
2375
+ break;
2376
+ case "compatible-screens":
2377
+ a.childNodes.forEach((c) => {
2378
+ if (c.nodeType === z.ELEMENT_NODE)
2379
+ return n.compatibleScreens.push(this.collapseAttributes(c));
2380
+ });
2381
+ break;
2382
+ case "supports-gl-texture":
2383
+ n.supportsGlTextures.push(this.collapseAttributes(a));
2384
+ break;
2385
+ case "application":
2386
+ n.application = this.parseApplication(a);
2387
+ break;
2388
+ }
2389
+ }), n;
2390
+ }
2391
+ }
2392
+ async function Dt(g, i) {
2393
+ const n = await J(g).catch(B);
2394
+ if (n instanceof Error)
2395
+ return new Error(`load APK error: ${n.message}`);
2396
+ const a = n.file("AndroidManifest.xml"), c = i?.ignoreIcon ? null : n.file("resources.arsc"), [E, w] = await Promise.all([
2397
+ a?.async("arraybuffer").catch(B),
2398
+ c?.async("arraybuffer").catch(B)
2399
+ ]);
2400
+ if (!E || E instanceof Error)
2401
+ return new Error("not found AndroidManifest.xml");
2402
+ const y = Nt(E);
2403
+ if (y instanceof Error)
2404
+ return new Error(`parse AndroidManifest.xml error: ${y.message}`);
2405
+ const I = {
2406
+ package: y.package,
2407
+ versionCode: y.versionCode,
2408
+ versionName: y.versionName,
2409
+ manifest: y,
2410
+ application: y.application,
2411
+ metaData: y.application?.metaData
2412
+ }, N = y.application?.icon;
2413
+ if (!w || w instanceof Error || !N || typeof N != "string")
2414
+ return I;
2415
+ const T = Ut(w, N);
2416
+ if (!T)
2417
+ return I;
2418
+ const m = n.file(T);
2419
+ if (!m)
2420
+ return I;
2421
+ const t = await m.async("base64").catch(B);
2422
+ return t instanceof Error || (I.icon = rt(t)), I;
2423
+ }
2424
+ function Nt(g) {
2425
+ const i = new St(g, {
2426
+ ignore: [
2427
+ "application.activity",
2428
+ "application.service",
2429
+ "application.receiver",
2430
+ "application.provider",
2431
+ "permission-group"
2432
+ ]
2433
+ });
2434
+ try {
2435
+ return i.parse();
2436
+ } catch (n) {
2437
+ return B(n);
2438
+ }
2439
+ }
2440
+ function Ut(g, i) {
2441
+ try {
2442
+ const n = new H().processResourceTable(g), a = i.replace(/^resourceId:0x/, "@").toUpperCase();
2443
+ return n[a]?.[0] || "";
2444
+ } catch {
2445
+ return "";
2446
+ }
2447
+ }
2448
+ typeof globalThis < "u" || typeof self < "u" || typeof window < "u" || Function("return this")();
2449
+ function G(g, ...i) {
2450
+ if (!g || typeof g != "object") return !1;
2451
+ const n = Object.getPrototypeOf(g);
2452
+ return n !== Object.prototype && n !== null ? !1 : i.every((a) => a in g);
2453
+ }
2454
+ class At {
2455
+ constructor(i) {
2456
+ this.UID = i;
2457
+ }
2458
+ }
2459
+ const _t = 9783072e5, V = 100 * 1e3 * 1e3, Lt = 32768;
2460
+ function et(g, i, n) {
2461
+ return new DataView(g, i, n);
2462
+ }
2463
+ function $(g, i = 0) {
2464
+ let n = 0;
2465
+ for (let a = i; a < g.length; a++)
2466
+ n <<= 8, n |= g[a] & 255;
2467
+ return n;
2468
+ }
2469
+ function tt(g, i) {
2470
+ return et(g, i, 8).getUint32(4, !1);
2471
+ }
2472
+ function kt(g) {
2473
+ const i = g.length;
2474
+ for (let n = 0; n < i; n += 2) {
2475
+ const a = g[n];
2476
+ g[n] = g[n + 1], g[n + 1] = a;
2477
+ }
2478
+ return g;
2479
+ }
2480
+ function Rt(g) {
2481
+ let i = "", n;
2482
+ for (n = 0; n < g.length && g[n] === 0; n++)
2483
+ ;
2484
+ for (; n < g.length; n++) {
2485
+ const a = "00" + g[n].toString(16);
2486
+ i += a.substring(a.length - 2);
2487
+ }
2488
+ return i;
2489
+ }
2490
+ function Ct(g) {
2491
+ try {
2492
+ return Ot(g);
2493
+ } catch (i) {
2494
+ return B(i);
2495
+ }
2496
+ }
2497
+ function Ot(g) {
2498
+ const i = new Uint8Array(g), n = i.slice(0, 6);
2499
+ if (new TextDecoder("utf8").decode(n) !== "bplist")
2500
+ throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
2501
+ const c = g.byteLength - 32, E = new DataView(g, c, 32), w = E.getUint8(6), y = E.getUint8(7), I = tt(g, c + 8), N = tt(g, c + 16), T = tt(g, c + 24);
2502
+ if (I > Lt)
2503
+ throw new Error("maxObjectCount exceeded");
2504
+ const m = [];
2505
+ for (let e = 0; e < I; e++) {
2506
+ const r = i.slice(T + e * w, T + (e + 1) * w);
2507
+ m[e] = $(r, 0);
2508
+ }
2509
+ function t(e) {
2510
+ const r = m[e], s = i[r], o = (s & 240) >> 4, u = s & 15;
2511
+ switch (o) {
2512
+ case 0:
2513
+ return l();
2514
+ case 1:
2515
+ return p();
2516
+ case 8:
2517
+ return F();
2518
+ case 2:
2519
+ return S();
2520
+ case 3:
2521
+ return A();
2522
+ case 4:
2523
+ return L();
2524
+ case 5:
2525
+ return _(!1);
2526
+ case 6:
2527
+ return _(!0);
2528
+ case 10:
2529
+ return d();
2530
+ case 13:
2531
+ return f();
2532
+ default:
2533
+ throw new Error("Unhandled type 0x" + o.toString(16));
2534
+ }
2535
+ function l() {
2536
+ switch (u) {
2537
+ case 0:
2538
+ return null;
2539
+ case 8:
2540
+ return !1;
2541
+ case 9:
2542
+ return !0;
2543
+ case 15:
2544
+ return null;
2545
+ default:
2546
+ throw new Error("Unhandled simple type 0x" + o.toString(16) + u.toString(16));
2547
+ }
2548
+ }
2549
+ function p() {
2550
+ const h = Math.pow(2, u);
2551
+ if (h < V) {
2552
+ const b = i.slice(r + 1, r + 1 + h);
2553
+ if (h === 16) {
2554
+ const v = Rt(b);
2555
+ return BigInt("0x" + v);
2556
+ }
2557
+ return b.reduce((v, x) => (v <<= 8, v |= x & 255, v), 0);
2558
+ }
2559
+ throw new Error(
2560
+ "Too little heap space available! Wanted to read " + h + " bytes, but only " + V + " are available."
2561
+ );
2562
+ }
2563
+ function F() {
2564
+ const h = u + 1;
2565
+ if (h < V)
2566
+ return new At($(i.slice(r + 1, r + 1 + h)));
2567
+ throw new Error(
2568
+ "Too little heap space available! Wanted to read " + h + " bytes, but only " + V + " are available."
2569
+ );
2570
+ }
2571
+ function S() {
2572
+ const h = Math.pow(2, u);
2573
+ if (h < V) {
2574
+ const b = et(g, r + 1, h);
2575
+ if (h === 4)
2576
+ return b.getFloat32(0, !1);
2577
+ if (h === 8)
2578
+ return b.getFloat64(0, !1);
2579
+ } else
2580
+ throw new Error(
2581
+ "Too little heap space available! Wanted to read " + h + " bytes, but only " + V + " are available."
2582
+ );
2583
+ return 0;
2584
+ }
2585
+ function A() {
2586
+ const b = et(g, r + 1, 8).getFloat64(0, !1);
2587
+ return new Date(_t + 1e3 * b);
2588
+ }
2589
+ function L() {
2590
+ let h = 1, b = u;
2591
+ if (u === 15) {
2592
+ const x = i[r + 1] & 15, U = Math.pow(2, x);
2593
+ h = 2 + U, b = $(i.slice(r + 2, r + 2 + U));
2594
+ }
2595
+ if (b < V)
2596
+ return i.slice(r + h, r + h + b);
2597
+ throw new Error(
2598
+ "Too little heap space available! Wanted to read " + b + " bytes, but only " + V + " are available."
2599
+ );
2600
+ }
2601
+ function _(h) {
2602
+ let b = "utf8", v = u, x = 1;
2603
+ if (u === 15) {
2604
+ const k = i[r + 1] & 15, O = Math.pow(2, k);
2605
+ x = 2 + O, v = $(i.slice(r + 2, r + 2 + O));
2606
+ }
2607
+ if (v *= h ? 2 : 1, v < V) {
2608
+ let U = i.slice(r + x, r + x + v);
2609
+ if (h) {
2610
+ const k = new Uint8Array(U);
2611
+ U = kt(k), b = "utf-16le";
2612
+ } else
2613
+ b = "utf8";
2614
+ return new TextDecoder(b).decode(U);
2615
+ }
2616
+ throw new Error(
2617
+ "Too little heap space available! Wanted to read " + v + " bytes, but only " + V + " are available."
2618
+ );
2619
+ }
2620
+ function d() {
2621
+ let h = u, b = 1;
2622
+ if (u === 15) {
2623
+ const U = i[r + 1] & 15, k = Math.pow(2, U);
2624
+ b = 2 + k, h = $(i.slice(r + 2, r + 2 + k));
2625
+ }
2626
+ if (h * y > V)
2627
+ throw new Error("Too little heap space available!");
2628
+ const v = [];
2629
+ for (let x = 0; x < h; x++) {
2630
+ const U = $(
2631
+ i.slice(r + b + x * y, r + b + (x + 1) * y)
2632
+ );
2633
+ v[x] = t(U);
2634
+ }
2635
+ return v;
2636
+ }
2637
+ function f() {
2638
+ let h = u, b = 1;
2639
+ if (u === 15) {
2640
+ const U = i[r + 1] & 15, k = Math.pow(2, U);
2641
+ b = 2 + k, h = $(i.slice(r + 2, r + 2 + k));
2642
+ }
2643
+ if (h * 2 * y > V)
2644
+ throw new Error("Too little heap space available!");
2645
+ const v = {};
2646
+ for (let x = 0; x < h; x++) {
2647
+ const U = $(
2648
+ i.slice(r + b + x * y, r + b + (x + 1) * y)
2649
+ ), k = $(
2650
+ i.slice(
2651
+ r + b + h * y + x * y,
2652
+ r + b + h * y + (x + 1) * y
2653
+ )
2654
+ ), O = t(U), R = t(k);
2655
+ v[String(O)] = R;
2656
+ }
2657
+ return v;
2658
+ }
2659
+ }
2660
+ return t(N);
2661
+ }
2662
+ async function Xt(g, i) {
2663
+ const n = await J(g).catch(B);
2664
+ if (n instanceof Error)
2665
+ return new Error(`load IPA error: ${n.message}`);
2666
+ const a = {
2667
+ ...(i?.frameworks || []).reduce(
2668
+ function(e, r) {
2669
+ const s = r.replace(/\.framework/i, "");
2670
+ return e[s] = new RegExp(`/frameworks\\/${s}\\.framework\\/[^/]+?\\.plist$`, "i"), e;
2671
+ },
2672
+ {}
2673
+ ),
2674
+ main: /payload\/[^/]+?.app\/info.plist$/i
2675
+ }, c = {};
2676
+ if (n.forEach((e, r) => {
2677
+ for (const s in a)
2678
+ if (!c[s] && a[s].test(e)) {
2679
+ c[s] = r;
2680
+ break;
2681
+ }
2682
+ }), !c.main)
2683
+ return new Error("not found Info.plist file in IPA");
2684
+ const E = {}, w = {};
2685
+ if (await Promise.all([
2686
+ ...Object.keys(c).map((e) => c[e]?.async("arraybuffer").then((r) => {
2687
+ w[e] = Ct(r);
2688
+ }).catch((r) => {
2689
+ w[e] = B(r);
2690
+ })),
2691
+ ...(i?.files || []).map((e) => n.file(e)?.async("arraybuffer").then((r) => {
2692
+ E[e] = r;
2693
+ }).catch((r) => {
2694
+ E[e] = B(r);
2695
+ }))
2696
+ ]), !w.main || w.main instanceof Error)
2697
+ return new Error(`parse Info.plist error: ${w.main?.message || "unknown error"}`);
2698
+ const { main: y, ...I } = w, N = {
2699
+ package: "CFBundleIdentifier" in y ? Q(y.CFBundleIdentifier) : "",
2700
+ versionCode: "CFBundleVersion" in y ? at(y.CFBundleVersion) : 0,
2701
+ versionName: "CFBundleShortVersionString" in y ? Q(y.CFBundleShortVersionString) : "",
2702
+ plist: y,
2703
+ frameworks: I,
2704
+ files: E
2705
+ };
2706
+ if (i?.ignoreIcon)
2707
+ return N;
2708
+ const T = Pt(y), m = n.filter(
2709
+ T ? (e) => e.includes(T) : (e) => /\/icon[^.]*?\.png/i.test(e)
2710
+ )[0];
2711
+ if (!m)
2712
+ return N;
2713
+ const t = await m.async("base64").catch(B);
2714
+ return t instanceof Error || (N.icon = rt(t)), N;
2715
+ }
2716
+ function Pt(g) {
2717
+ return G(g, "CFBundleIcons") && G(g.CFBundleIcons, "CFBundlePrimaryIcon") && G(g.CFBundleIcons.CFBundlePrimaryIcon, "CFBundleIconFiles") && Array.isArray(g.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles) && g.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length ? Q(
2718
+ g.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles[g.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length - 1]
2719
+ ) : G(g, "CFBundleIconFiles") && Array.isArray(g.CFBundleIconFiles) && g.CFBundleIconFiles.length ? Q(g.CFBundleIconFiles[g.CFBundleIconFiles.length - 1]) : "";
2720
+ }
2721
+ export {
2722
+ Dt as parseApk,
2723
+ Mt as parseHosApp,
2724
+ Xt as parseIpa
2725
+ };