@genome-spy/app 0.57.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3998 +0,0 @@
1
- import { b as J } from "./index-DluFz_0j.js";
2
- import { A as Gn, L as Yn } from "./index-C159nEYc.js";
3
- import { L as nr } from "./__vite-browser-external-C--ziKoh.js";
4
- import { R as ir } from "./remoteFile-DwSeXAZ0.js";
5
- const st = BigInt(32);
6
- function rr(e, n, t) {
7
- const i = +!!t, a = +!t;
8
- return BigInt(e.getInt32(n, t) * a + e.getInt32(n + 4, t) * i) << st | BigInt(e.getUint32(n, t) * i + e.getUint32(n + 4, t) * a);
9
- }
10
- function ar(e, n, t) {
11
- const i = e.getUint32(n, t), a = e.getUint32(n + 4, t), r = +!!t, o = +!t;
12
- return BigInt(i * o + a * r) << st | BigInt(i * r + a * o);
13
- }
14
- function or(e, n, t, i) {
15
- const a = Number(t >> st), r = Number(t & BigInt(4294967295));
16
- i ? (e.setInt32(n + 4, a, i), e.setUint32(n, r, i)) : (e.setInt32(n, a, i), e.setUint32(n + 4, r, i));
17
- }
18
- function sr(e, n, t, i) {
19
- const a = Number(t >> st), r = Number(t & BigInt(4294967295));
20
- i ? (e.setUint32(n + 4, a, i), e.setUint32(n, r, i)) : (e.setUint32(n, a, i), e.setUint32(n + 4, r, i));
21
- }
22
- "getBigInt64" in DataView || (DataView.prototype.getBigInt64 = function(e, n) {
23
- return rr(this, e, n);
24
- });
25
- "getBigUint64" in DataView || (DataView.prototype.getBigUint64 = function(e, n) {
26
- return ar(this, e, n);
27
- });
28
- "setBigInt64" in DataView || (DataView.prototype.setBigInt64 = function(e, n, t) {
29
- or(this, e, n, t);
30
- });
31
- "setBigUint64" in DataView || (DataView.prototype.setBigUint64 = function(e, n, t) {
32
- sr(this, e, n, t);
33
- });
34
- class lr {
35
- constructor(n, t) {
36
- this.code = "", this.scopes = [["vars"]], this.bitFields = [], this.tmpVariableCount = 0, this.references = /* @__PURE__ */ new Map(), this.imports = [], this.reverseImports = /* @__PURE__ */ new Map(), this.useContextVariables = !1, this.importPath = n, this.useContextVariables = t;
37
- }
38
- generateVariable(n) {
39
- const t = [...this.scopes[this.scopes.length - 1]];
40
- return n && t.push(n), t.join(".");
41
- }
42
- generateOption(n) {
43
- switch (typeof n) {
44
- case "number":
45
- return n.toString();
46
- case "string":
47
- return this.generateVariable(n);
48
- case "function":
49
- return `${this.addImport(n)}.call(${this.generateVariable()}, vars)`;
50
- }
51
- }
52
- generateError(n) {
53
- this.pushCode(`throw new Error(${n});`);
54
- }
55
- generateTmpVariable() {
56
- return "$tmp" + this.tmpVariableCount++;
57
- }
58
- pushCode(n) {
59
- this.code += n + `
60
- `;
61
- }
62
- pushPath(n) {
63
- n && this.scopes[this.scopes.length - 1].push(n);
64
- }
65
- popPath(n) {
66
- n && this.scopes[this.scopes.length - 1].pop();
67
- }
68
- pushScope(n) {
69
- this.scopes.push([n]);
70
- }
71
- popScope() {
72
- this.scopes.pop();
73
- }
74
- addImport(n) {
75
- if (!this.importPath)
76
- return `(${n})`;
77
- let t = this.reverseImports.get(n);
78
- return t || (t = this.imports.push(n) - 1, this.reverseImports.set(n, t)), `${this.importPath}[${t}]`;
79
- }
80
- addReference(n) {
81
- this.references.has(n) || this.references.set(n, { resolved: !1, requested: !1 });
82
- }
83
- markResolved(n) {
84
- const t = this.references.get(n);
85
- t && (t.resolved = !0);
86
- }
87
- markRequested(n) {
88
- n.forEach((t) => {
89
- const i = this.references.get(t);
90
- i && (i.requested = !0);
91
- });
92
- }
93
- getUnresolvedReferences() {
94
- return Array.from(this.references).filter(([n, t]) => !t.resolved && !t.requested).map(([n, t]) => n);
95
- }
96
- }
97
- const x = /* @__PURE__ */ new Map(), re = "___parser_", M = {
98
- uint8: 1,
99
- uint16le: 2,
100
- uint16be: 2,
101
- uint32le: 4,
102
- uint32be: 4,
103
- int8: 1,
104
- int16le: 2,
105
- int16be: 2,
106
- int32le: 4,
107
- int32be: 4,
108
- int64be: 8,
109
- int64le: 8,
110
- uint64be: 8,
111
- uint64le: 8,
112
- floatle: 4,
113
- floatbe: 4,
114
- doublele: 8,
115
- doublebe: 8
116
- }, Ye = {
117
- uint8: "Uint8",
118
- uint16le: "Uint16",
119
- uint16be: "Uint16",
120
- uint32le: "Uint32",
121
- uint32be: "Uint32",
122
- int8: "Int8",
123
- int16le: "Int16",
124
- int16be: "Int16",
125
- int32le: "Int32",
126
- int32be: "Int32",
127
- int64be: "BigInt64",
128
- int64le: "BigInt64",
129
- uint64be: "BigUint64",
130
- uint64le: "BigUint64",
131
- floatle: "Float32",
132
- floatbe: "Float32",
133
- doublele: "Float64",
134
- doublebe: "Float64"
135
- }, Ke = {
136
- uint8: !1,
137
- uint16le: !0,
138
- uint16be: !1,
139
- uint32le: !0,
140
- uint32be: !1,
141
- int8: !1,
142
- int16le: !0,
143
- int16be: !1,
144
- int32le: !0,
145
- int32be: !1,
146
- int64be: !1,
147
- int64le: !0,
148
- uint64be: !1,
149
- uint64le: !0,
150
- floatle: !0,
151
- floatbe: !1,
152
- doublele: !0,
153
- doublebe: !1
154
- };
155
- class S {
156
- constructor() {
157
- this.varName = "", this.type = "", this.options = {}, this.endian = "be", this.useContextVariables = !1;
158
- }
159
- static start() {
160
- return new S();
161
- }
162
- primitiveGenerateN(n, t) {
163
- const i = Ye[n], a = Ke[n];
164
- t.pushCode(`${t.generateVariable(this.varName)} = dataView.get${i}(offset, ${a});`), t.pushCode(`offset += ${M[n]};`);
165
- }
166
- primitiveN(n, t, i) {
167
- return this.setNextParser(n, t, i);
168
- }
169
- useThisEndian(n) {
170
- return n + this.endian.toLowerCase();
171
- }
172
- uint8(n, t = {}) {
173
- return this.primitiveN("uint8", n, t);
174
- }
175
- uint16(n, t = {}) {
176
- return this.primitiveN(this.useThisEndian("uint16"), n, t);
177
- }
178
- uint16le(n, t = {}) {
179
- return this.primitiveN("uint16le", n, t);
180
- }
181
- uint16be(n, t = {}) {
182
- return this.primitiveN("uint16be", n, t);
183
- }
184
- uint32(n, t = {}) {
185
- return this.primitiveN(this.useThisEndian("uint32"), n, t);
186
- }
187
- uint32le(n, t = {}) {
188
- return this.primitiveN("uint32le", n, t);
189
- }
190
- uint32be(n, t = {}) {
191
- return this.primitiveN("uint32be", n, t);
192
- }
193
- int8(n, t = {}) {
194
- return this.primitiveN("int8", n, t);
195
- }
196
- int16(n, t = {}) {
197
- return this.primitiveN(this.useThisEndian("int16"), n, t);
198
- }
199
- int16le(n, t = {}) {
200
- return this.primitiveN("int16le", n, t);
201
- }
202
- int16be(n, t = {}) {
203
- return this.primitiveN("int16be", n, t);
204
- }
205
- int32(n, t = {}) {
206
- return this.primitiveN(this.useThisEndian("int32"), n, t);
207
- }
208
- int32le(n, t = {}) {
209
- return this.primitiveN("int32le", n, t);
210
- }
211
- int32be(n, t = {}) {
212
- return this.primitiveN("int32be", n, t);
213
- }
214
- bigIntVersionCheck() {
215
- if (!DataView.prototype.getBigInt64)
216
- throw new Error("BigInt64 is unsupported on this runtime");
217
- }
218
- int64(n, t = {}) {
219
- return this.bigIntVersionCheck(), this.primitiveN(this.useThisEndian("int64"), n, t);
220
- }
221
- int64be(n, t = {}) {
222
- return this.bigIntVersionCheck(), this.primitiveN("int64be", n, t);
223
- }
224
- int64le(n, t = {}) {
225
- return this.bigIntVersionCheck(), this.primitiveN("int64le", n, t);
226
- }
227
- uint64(n, t = {}) {
228
- return this.bigIntVersionCheck(), this.primitiveN(this.useThisEndian("uint64"), n, t);
229
- }
230
- uint64be(n, t = {}) {
231
- return this.bigIntVersionCheck(), this.primitiveN("uint64be", n, t);
232
- }
233
- uint64le(n, t = {}) {
234
- return this.bigIntVersionCheck(), this.primitiveN("uint64le", n, t);
235
- }
236
- floatle(n, t = {}) {
237
- return this.primitiveN("floatle", n, t);
238
- }
239
- floatbe(n, t = {}) {
240
- return this.primitiveN("floatbe", n, t);
241
- }
242
- doublele(n, t = {}) {
243
- return this.primitiveN("doublele", n, t);
244
- }
245
- doublebe(n, t = {}) {
246
- return this.primitiveN("doublebe", n, t);
247
- }
248
- bitN(n, t, i) {
249
- return i.length = n, this.setNextParser("bit", t, i);
250
- }
251
- bit1(n, t = {}) {
252
- return this.bitN(1, n, t);
253
- }
254
- bit2(n, t = {}) {
255
- return this.bitN(2, n, t);
256
- }
257
- bit3(n, t = {}) {
258
- return this.bitN(3, n, t);
259
- }
260
- bit4(n, t = {}) {
261
- return this.bitN(4, n, t);
262
- }
263
- bit5(n, t = {}) {
264
- return this.bitN(5, n, t);
265
- }
266
- bit6(n, t = {}) {
267
- return this.bitN(6, n, t);
268
- }
269
- bit7(n, t = {}) {
270
- return this.bitN(7, n, t);
271
- }
272
- bit8(n, t = {}) {
273
- return this.bitN(8, n, t);
274
- }
275
- bit9(n, t = {}) {
276
- return this.bitN(9, n, t);
277
- }
278
- bit10(n, t = {}) {
279
- return this.bitN(10, n, t);
280
- }
281
- bit11(n, t = {}) {
282
- return this.bitN(11, n, t);
283
- }
284
- bit12(n, t = {}) {
285
- return this.bitN(12, n, t);
286
- }
287
- bit13(n, t = {}) {
288
- return this.bitN(13, n, t);
289
- }
290
- bit14(n, t = {}) {
291
- return this.bitN(14, n, t);
292
- }
293
- bit15(n, t = {}) {
294
- return this.bitN(15, n, t);
295
- }
296
- bit16(n, t = {}) {
297
- return this.bitN(16, n, t);
298
- }
299
- bit17(n, t = {}) {
300
- return this.bitN(17, n, t);
301
- }
302
- bit18(n, t = {}) {
303
- return this.bitN(18, n, t);
304
- }
305
- bit19(n, t = {}) {
306
- return this.bitN(19, n, t);
307
- }
308
- bit20(n, t = {}) {
309
- return this.bitN(20, n, t);
310
- }
311
- bit21(n, t = {}) {
312
- return this.bitN(21, n, t);
313
- }
314
- bit22(n, t = {}) {
315
- return this.bitN(22, n, t);
316
- }
317
- bit23(n, t = {}) {
318
- return this.bitN(23, n, t);
319
- }
320
- bit24(n, t = {}) {
321
- return this.bitN(24, n, t);
322
- }
323
- bit25(n, t = {}) {
324
- return this.bitN(25, n, t);
325
- }
326
- bit26(n, t = {}) {
327
- return this.bitN(26, n, t);
328
- }
329
- bit27(n, t = {}) {
330
- return this.bitN(27, n, t);
331
- }
332
- bit28(n, t = {}) {
333
- return this.bitN(28, n, t);
334
- }
335
- bit29(n, t = {}) {
336
- return this.bitN(29, n, t);
337
- }
338
- bit30(n, t = {}) {
339
- return this.bitN(30, n, t);
340
- }
341
- bit31(n, t = {}) {
342
- return this.bitN(31, n, t);
343
- }
344
- bit32(n, t = {}) {
345
- return this.bitN(32, n, t);
346
- }
347
- namely(n) {
348
- return x.set(n, this), this.alias = n, this;
349
- }
350
- skip(n, t = {}) {
351
- return this.seek(n, t);
352
- }
353
- seek(n, t = {}) {
354
- if (t.assert)
355
- throw new Error("assert option on seek is not allowed.");
356
- return this.setNextParser("seek", "", { length: n });
357
- }
358
- string(n, t) {
359
- if (!t.zeroTerminated && !t.length && !t.greedy)
360
- throw new Error("One of length, zeroTerminated, or greedy must be defined for string.");
361
- if ((t.zeroTerminated || t.length) && t.greedy)
362
- throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");
363
- if (t.stripNull && !(t.length || t.greedy))
364
- throw new Error("length or greedy must be defined if stripNull is enabled.");
365
- return t.encoding = t.encoding || "utf8", this.setNextParser("string", n, t);
366
- }
367
- buffer(n, t) {
368
- if (!t.length && !t.readUntil)
369
- throw new Error("length or readUntil must be defined for buffer.");
370
- return this.setNextParser("buffer", n, t);
371
- }
372
- wrapped(n, t) {
373
- if (typeof t != "object" && typeof n == "object" && (t = n, n = ""), !t || !t.wrapper || !t.type)
374
- throw new Error("Both wrapper and type must be defined for wrapped.");
375
- if (!t.length && !t.readUntil)
376
- throw new Error("length or readUntil must be defined for wrapped.");
377
- return this.setNextParser("wrapper", n, t);
378
- }
379
- array(n, t) {
380
- if (!t.readUntil && !t.length && !t.lengthInBytes)
381
- throw new Error("One of readUntil, length and lengthInBytes must be defined for array.");
382
- if (!t.type)
383
- throw new Error("type is required for array.");
384
- if (typeof t.type == "string" && !x.has(t.type) && !(t.type in M))
385
- throw new Error(`Array element type "${t.type}" is unkown.`);
386
- return this.setNextParser("array", n, t);
387
- }
388
- choice(n, t) {
389
- if (typeof t != "object" && typeof n == "object" && (t = n, n = ""), !t)
390
- throw new Error("tag and choices are are required for choice.");
391
- if (!t.tag)
392
- throw new Error("tag is requird for choice.");
393
- if (!t.choices)
394
- throw new Error("choices is required for choice.");
395
- for (const i in t.choices) {
396
- const a = parseInt(i, 10), r = t.choices[a];
397
- if (isNaN(a))
398
- throw new Error(`Choice key "${i}" is not a number.`);
399
- if (typeof r == "string" && !x.has(r) && !(r in M))
400
- throw new Error(`Choice type "${r}" is unkown.`);
401
- }
402
- return this.setNextParser("choice", n, t);
403
- }
404
- nest(n, t) {
405
- if (typeof t != "object" && typeof n == "object" && (t = n, n = ""), !t || !t.type)
406
- throw new Error("type is required for nest.");
407
- if (!(t.type instanceof S) && !x.has(t.type))
408
- throw new Error("type must be a known parser name or a Parser object.");
409
- if (!(t.type instanceof S) && !n)
410
- throw new Error("type must be a Parser object if the variable name is omitted.");
411
- return this.setNextParser("nest", n, t);
412
- }
413
- pointer(n, t) {
414
- if (!t.offset)
415
- throw new Error("offset is required for pointer.");
416
- if (!t.type)
417
- throw new Error("type is required for pointer.");
418
- if (typeof t.type == "string" && !(t.type in M) && !x.has(t.type))
419
- throw new Error(`Pointer type "${t.type}" is unkown.`);
420
- return this.setNextParser("pointer", n, t);
421
- }
422
- saveOffset(n, t = {}) {
423
- return this.setNextParser("saveOffset", n, t);
424
- }
425
- endianness(n) {
426
- switch (n.toLowerCase()) {
427
- case "little":
428
- this.endian = "le";
429
- break;
430
- case "big":
431
- this.endian = "be";
432
- break;
433
- default:
434
- throw new Error('endianness must be one of "little" or "big"');
435
- }
436
- return this;
437
- }
438
- endianess(n) {
439
- return this.endianness(n);
440
- }
441
- useContextVars(n = !0) {
442
- return this.useContextVariables = n, this;
443
- }
444
- create(n) {
445
- if (!(n instanceof Function))
446
- throw new Error("Constructor must be a Function object.");
447
- return this.constructorFn = n, this;
448
- }
449
- getContext(n) {
450
- const t = new lr(n, this.useContextVariables);
451
- return t.pushCode("var dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"), this.alias ? (this.addAliasedCode(t), t.pushCode(`return ${re + this.alias}(0).result;`)) : this.addRawCode(t), t;
452
- }
453
- getCode() {
454
- return this.getContext("imports").code;
455
- }
456
- addRawCode(n) {
457
- n.pushCode("var offset = 0;"), n.pushCode(`var vars = ${this.constructorFn ? "new constructorFn()" : "{}"};`), n.pushCode("vars.$parent = null;"), n.pushCode("vars.$root = vars;"), this.generate(n), this.resolveReferences(n), n.pushCode("delete vars.$parent;"), n.pushCode("delete vars.$root;"), n.pushCode("return vars;");
458
- }
459
- addAliasedCode(n) {
460
- return n.pushCode(`function ${re + this.alias}(offset, context) {`), n.pushCode(`var vars = ${this.constructorFn ? "new constructorFn()" : "{}"};`), n.pushCode("var ctx = Object.assign({$parent: null, $root: vars}, context || {});"), n.pushCode("vars = Object.assign(vars, ctx);"), this.generate(n), n.markResolved(this.alias), this.resolveReferences(n), n.pushCode("Object.keys(ctx).forEach(function (item) { delete vars[item]; });"), n.pushCode("return { offset: offset, result: vars };"), n.pushCode("}"), n;
461
- }
462
- resolveReferences(n) {
463
- const t = n.getUnresolvedReferences();
464
- n.markRequested(t), t.forEach((i) => {
465
- var a;
466
- (a = x.get(i)) === null || a === void 0 || a.addAliasedCode(n);
467
- });
468
- }
469
- compile() {
470
- const n = "imports", t = this.getContext(n);
471
- this.compiled = new Function(n, "TextDecoder", `return function (buffer, constructorFn) { ${t.code} };`)(t.imports, TextDecoder);
472
- }
473
- sizeOf() {
474
- let n = NaN;
475
- if (Object.keys(M).indexOf(this.type) >= 0)
476
- n = M[this.type];
477
- else if (this.type === "string" && typeof this.options.length == "number")
478
- n = this.options.length;
479
- else if (this.type === "buffer" && typeof this.options.length == "number")
480
- n = this.options.length;
481
- else if (this.type === "array" && typeof this.options.length == "number") {
482
- let t = NaN;
483
- typeof this.options.type == "string" ? t = M[this.options.type] : this.options.type instanceof S && (t = this.options.type.sizeOf()), n = this.options.length * t;
484
- } else this.type === "seek" ? n = this.options.length : this.type === "nest" ? n = this.options.type.sizeOf() : this.type || (n = 0);
485
- return this.next && (n += this.next.sizeOf()), n;
486
- }
487
- // Follow the parser chain till the root and start parsing from there
488
- parse(n) {
489
- return this.compiled || this.compile(), this.compiled(n, this.constructorFn);
490
- }
491
- setNextParser(n, t, i) {
492
- const a = new S();
493
- return a.type = n, a.varName = t, a.options = i, a.endian = this.endian, this.head ? this.head.next = a : this.next = a, this.head = a, this;
494
- }
495
- // Call code generator for this parser
496
- generate(n) {
497
- if (this.type) {
498
- switch (this.type) {
499
- case "uint8":
500
- case "uint16le":
501
- case "uint16be":
502
- case "uint32le":
503
- case "uint32be":
504
- case "int8":
505
- case "int16le":
506
- case "int16be":
507
- case "int32le":
508
- case "int32be":
509
- case "int64be":
510
- case "int64le":
511
- case "uint64be":
512
- case "uint64le":
513
- case "floatle":
514
- case "floatbe":
515
- case "doublele":
516
- case "doublebe":
517
- this.primitiveGenerateN(this.type, n);
518
- break;
519
- case "bit":
520
- this.generateBit(n);
521
- break;
522
- case "string":
523
- this.generateString(n);
524
- break;
525
- case "buffer":
526
- this.generateBuffer(n);
527
- break;
528
- case "seek":
529
- this.generateSeek(n);
530
- break;
531
- case "nest":
532
- this.generateNest(n);
533
- break;
534
- case "array":
535
- this.generateArray(n);
536
- break;
537
- case "choice":
538
- this.generateChoice(n);
539
- break;
540
- case "pointer":
541
- this.generatePointer(n);
542
- break;
543
- case "saveOffset":
544
- this.generateSaveOffset(n);
545
- break;
546
- case "wrapper":
547
- this.generateWrapper(n);
548
- break;
549
- }
550
- this.type !== "bit" && this.generateAssert(n);
551
- }
552
- const t = n.generateVariable(this.varName);
553
- return this.options.formatter && this.type !== "bit" && this.generateFormatter(n, t, this.options.formatter), this.generateNext(n);
554
- }
555
- generateAssert(n) {
556
- if (!this.options.assert)
557
- return;
558
- const t = n.generateVariable(this.varName);
559
- switch (typeof this.options.assert) {
560
- case "function":
561
- {
562
- const i = n.addImport(this.options.assert);
563
- n.pushCode(`if (!${i}.call(vars, ${t})) {`);
564
- }
565
- break;
566
- case "number":
567
- n.pushCode(`if (${this.options.assert} !== ${t}) {`);
568
- break;
569
- case "string":
570
- n.pushCode(`if (${JSON.stringify(this.options.assert)} !== ${t}) {`);
571
- break;
572
- default:
573
- throw new Error("assert option must be a string, number or a function.");
574
- }
575
- n.generateError(`"Assertion error: ${t} is " + ${JSON.stringify(this.options.assert.toString())}`), n.pushCode("}");
576
- }
577
- // Recursively call code generators and append results
578
- generateNext(n) {
579
- return this.next && (n = this.next.generate(n)), n;
580
- }
581
- generateBit(n) {
582
- const t = JSON.parse(JSON.stringify(this));
583
- if (t.options = this.options, t.generateAssert = this.generateAssert.bind(this), t.generateFormatter = this.generateFormatter.bind(this), t.varName = n.generateVariable(t.varName), n.bitFields.push(t), !this.next || this.next && ["bit", "nest"].indexOf(this.next.type) < 0) {
584
- const i = n.generateTmpVariable();
585
- n.pushCode(`var ${i} = 0;`);
586
- const a = (f = 0) => {
587
- let _ = 0;
588
- for (let c = f; c < n.bitFields.length; c++) {
589
- const h = n.bitFields[c].options.length;
590
- if (_ + h > 32)
591
- break;
592
- _ += h;
593
- }
594
- return _;
595
- }, r = (f) => (f <= 8 ? (n.pushCode(`${i} = dataView.getUint8(offset);`), f = 8) : f <= 16 ? (n.pushCode(`${i} = dataView.getUint16(offset);`), f = 16) : f <= 24 ? (n.pushCode(`${i} = (dataView.getUint16(offset) << 8) | dataView.getUint8(offset + 2);`), f = 24) : (n.pushCode(`${i} = dataView.getUint32(offset);`), f = 32), n.pushCode(`offset += ${f / 8};`), f);
596
- let o = 0;
597
- const l = this.endian === "be";
598
- let u = 0, s = 0;
599
- n.bitFields.forEach((f, _) => {
600
- let c = f.options.length;
601
- if (c > s) {
602
- if (s) {
603
- const g = -1 >>> 32 - s;
604
- n.pushCode(`${f.varName} = (${i} & 0x${g.toString(16)}) << ${c - s};`), c -= s;
605
- }
606
- o = 0, s = u = r(a(_) - s);
607
- }
608
- const h = l ? u - o - c : o, d = -1 >>> 32 - c;
609
- n.pushCode(`${f.varName} ${c < f.options.length ? "|=" : "="} ${i} >> ${h} & 0x${d.toString(16)};`), f.options.length === 32 && n.pushCode(`${f.varName} >>>= 0`), f.options.assert && f.generateAssert(n), f.options.formatter && f.generateFormatter(n, f.varName, f.options.formatter), o += c, s -= c;
610
- }), n.bitFields = [];
611
- }
612
- }
613
- generateSeek(n) {
614
- const t = n.generateOption(this.options.length);
615
- n.pushCode(`offset += ${t};`);
616
- }
617
- generateString(n) {
618
- const t = n.generateVariable(this.varName), i = n.generateTmpVariable(), a = this.options.encoding, r = a.toLowerCase() === "hex", o = 'b => b.toString(16).padStart(2, "0")';
619
- if (this.options.length && this.options.zeroTerminated) {
620
- const l = this.options.length;
621
- n.pushCode(`var ${i} = offset;`), n.pushCode(`while(dataView.getUint8(offset++) !== 0 && offset - ${i} < ${l});`);
622
- const u = `offset - ${i} < ${l} ? offset - 1 : offset`;
623
- n.pushCode(r ? `${t} = Array.from(buffer.subarray(${i}, ${u}), ${o}).join('');` : `${t} = new TextDecoder('${a}').decode(buffer.subarray(${i}, ${u}));`);
624
- } else if (this.options.length) {
625
- const l = n.generateOption(this.options.length);
626
- n.pushCode(r ? `${t} = Array.from(buffer.subarray(offset, offset + ${l}), ${o}).join('');` : `${t} = new TextDecoder('${a}').decode(buffer.subarray(offset, offset + ${l}));`), n.pushCode(`offset += ${l};`);
627
- } else this.options.zeroTerminated ? (n.pushCode(`var ${i} = offset;`), n.pushCode("while(dataView.getUint8(offset++) !== 0);"), n.pushCode(r ? `${t} = Array.from(buffer.subarray(${i}, offset - 1), ${o}).join('');` : `${t} = new TextDecoder('${a}').decode(buffer.subarray(${i}, offset - 1));`)) : this.options.greedy && (n.pushCode(`var ${i} = offset;`), n.pushCode("while(buffer.length > offset++);"), n.pushCode(r ? `${t} = Array.from(buffer.subarray(${i}, offset), ${o}).join('');` : `${t} = new TextDecoder('${a}').decode(buffer.subarray(${i}, offset));`));
628
- this.options.stripNull && n.pushCode(`${t} = ${t}.replace(/\\x00+$/g, '')`);
629
- }
630
- generateBuffer(n) {
631
- const t = n.generateVariable(this.varName);
632
- if (typeof this.options.readUntil == "function") {
633
- const i = this.options.readUntil, a = n.generateTmpVariable(), r = n.generateTmpVariable();
634
- n.pushCode(`var ${a} = offset;`), n.pushCode(`var ${r} = 0;`), n.pushCode("while (offset < buffer.length) {"), n.pushCode(`${r} = dataView.getUint8(offset);`);
635
- const o = n.addImport(i);
636
- n.pushCode(`if (${o}.call(${n.generateVariable()}, ${r}, buffer.subarray(offset))) break;`), n.pushCode("offset += 1;"), n.pushCode("}"), n.pushCode(`${t} = buffer.subarray(${a}, offset);`);
637
- } else if (this.options.readUntil === "eof")
638
- n.pushCode(`${t} = buffer.subarray(offset);`);
639
- else {
640
- const i = n.generateOption(this.options.length);
641
- n.pushCode(`${t} = buffer.subarray(offset, offset + ${i});`), n.pushCode(`offset += ${i};`);
642
- }
643
- this.options.clone && n.pushCode(`${t} = buffer.constructor.from(${t});`);
644
- }
645
- generateArray(n) {
646
- const t = n.generateOption(this.options.length), i = n.generateOption(this.options.lengthInBytes), a = this.options.type, r = n.generateTmpVariable(), o = n.generateVariable(this.varName), l = n.generateTmpVariable(), u = this.options.key, s = typeof u == "string";
647
- if (s ? n.pushCode(`${o} = {};`) : n.pushCode(`${o} = [];`), typeof this.options.readUntil == "function" ? n.pushCode("do {") : this.options.readUntil === "eof" ? n.pushCode(`for (var ${r} = 0; offset < buffer.length; ${r}++) {`) : i !== void 0 ? n.pushCode(`for (var ${r} = offset + ${i}; offset < ${r}; ) {`) : n.pushCode(`for (var ${r} = ${t}; ${r} > 0; ${r}--) {`), typeof a == "string")
648
- if (x.get(a)) {
649
- const f = n.generateTmpVariable();
650
- if (n.pushCode(`var ${f} = ${re + a}(offset, {`), n.useContextVariables) {
651
- const _ = n.generateVariable();
652
- n.pushCode(`$parent: ${_},`), n.pushCode(`$root: ${_}.$root,`), !this.options.readUntil && i === void 0 && n.pushCode(`$index: ${t} - ${r},`);
653
- }
654
- n.pushCode("});"), n.pushCode(`var ${l} = ${f}.result; offset = ${f}.offset;`), a !== this.alias && n.addReference(a);
655
- } else {
656
- const f = Ye[a], _ = Ke[a];
657
- n.pushCode(`var ${l} = dataView.get${f}(offset, ${_});`), n.pushCode(`offset += ${M[a]};`);
658
- }
659
- else if (a instanceof S) {
660
- n.pushCode(`var ${l} = {};`);
661
- const f = n.generateVariable();
662
- n.pushScope(l), n.useContextVariables && (n.pushCode(`${l}.$parent = ${f};`), n.pushCode(`${l}.$root = ${f}.$root;`), !this.options.readUntil && i === void 0 && n.pushCode(`${l}.$index = ${t} - ${r};`)), a.generate(n), n.useContextVariables && (n.pushCode(`delete ${l}.$parent;`), n.pushCode(`delete ${l}.$root;`), n.pushCode(`delete ${l}.$index;`)), n.popScope();
663
- }
664
- if (s ? n.pushCode(`${o}[${l}.${u}] = ${l};`) : n.pushCode(`${o}.push(${l});`), n.pushCode("}"), typeof this.options.readUntil == "function") {
665
- const f = this.options.readUntil, _ = n.addImport(f);
666
- n.pushCode(`while (!${_}.call(${n.generateVariable()}, ${l}, buffer.subarray(offset)));`);
667
- }
668
- }
669
- generateChoiceCase(n, t, i) {
670
- if (typeof i == "string") {
671
- const a = n.generateVariable(this.varName);
672
- if (x.has(i)) {
673
- const r = n.generateTmpVariable();
674
- n.pushCode(`var ${r} = ${re + i}(offset, {`), n.useContextVariables && (n.pushCode(`$parent: ${a}.$parent,`), n.pushCode(`$root: ${a}.$root,`)), n.pushCode("});"), n.pushCode(`${a} = ${r}.result; offset = ${r}.offset;`), i !== this.alias && n.addReference(i);
675
- } else {
676
- const r = Ye[i], o = Ke[i];
677
- n.pushCode(`${a} = dataView.get${r}(offset, ${o});`), n.pushCode(`offset += ${M[i]}`);
678
- }
679
- } else i instanceof S && (n.pushPath(t), i.generate(n), n.popPath(t));
680
- }
681
- generateChoice(n) {
682
- const t = n.generateOption(this.options.tag), i = n.generateVariable(this.varName);
683
- if (this.varName && (n.pushCode(`${i} = {};`), n.useContextVariables)) {
684
- const a = n.generateVariable();
685
- n.pushCode(`${i}.$parent = ${a};`), n.pushCode(`${i}.$root = ${a}.$root;`);
686
- }
687
- n.pushCode(`switch(${t}) {`);
688
- for (const a in this.options.choices) {
689
- const r = parseInt(a, 10), o = this.options.choices[r];
690
- n.pushCode(`case ${r}:`), this.generateChoiceCase(n, this.varName, o), n.pushCode("break;");
691
- }
692
- n.pushCode("default:"), this.options.defaultChoice ? this.generateChoiceCase(n, this.varName, this.options.defaultChoice) : n.generateError(`"Met undefined tag value " + ${t} + " at choice"`), n.pushCode("}"), this.varName && n.useContextVariables && (n.pushCode(`delete ${i}.$parent;`), n.pushCode(`delete ${i}.$root;`));
693
- }
694
- generateNest(n) {
695
- const t = n.generateVariable(this.varName);
696
- if (this.options.type instanceof S) {
697
- if (this.varName && (n.pushCode(`${t} = {};`), n.useContextVariables)) {
698
- const i = n.generateVariable();
699
- n.pushCode(`${t}.$parent = ${i};`), n.pushCode(`${t}.$root = ${i}.$root;`);
700
- }
701
- n.pushPath(this.varName), this.options.type.generate(n), n.popPath(this.varName), this.varName && n.useContextVariables && n.useContextVariables && (n.pushCode(`delete ${t}.$parent;`), n.pushCode(`delete ${t}.$root;`));
702
- } else if (x.has(this.options.type)) {
703
- const i = n.generateTmpVariable();
704
- if (n.pushCode(`var ${i} = ${re + this.options.type}(offset, {`), n.useContextVariables) {
705
- const a = n.generateVariable();
706
- n.pushCode(`$parent: ${a},`), n.pushCode(`$root: ${a}.$root,`);
707
- }
708
- n.pushCode("});"), n.pushCode(`${t} = ${i}.result; offset = ${i}.offset;`), this.options.type !== this.alias && n.addReference(this.options.type);
709
- }
710
- }
711
- generateWrapper(n) {
712
- const t = n.generateVariable(this.varName), i = n.generateTmpVariable();
713
- if (typeof this.options.readUntil == "function") {
714
- const u = this.options.readUntil, s = n.generateTmpVariable(), f = n.generateTmpVariable();
715
- n.pushCode(`var ${s} = offset;`), n.pushCode(`var ${f} = 0;`), n.pushCode("while (offset < buffer.length) {"), n.pushCode(`${f} = dataView.getUint8(offset);`);
716
- const _ = n.addImport(u);
717
- n.pushCode(`if (${_}.call(${n.generateVariable()}, ${f}, buffer.subarray(offset))) break;`), n.pushCode("offset += 1;"), n.pushCode("}"), n.pushCode(`${i} = buffer.subarray(${s}, offset);`);
718
- } else if (this.options.readUntil === "eof")
719
- n.pushCode(`${i} = buffer.subarray(offset);`);
720
- else {
721
- const u = n.generateOption(this.options.length);
722
- n.pushCode(`${i} = buffer.subarray(offset, offset + ${u});`), n.pushCode(`offset += ${u};`);
723
- }
724
- this.options.clone && n.pushCode(`${i} = buffer.constructor.from(${i});`);
725
- const a = n.generateTmpVariable(), r = n.generateTmpVariable(), o = n.generateTmpVariable(), l = n.addImport(this.options.wrapper);
726
- if (n.pushCode(`${i} = ${l}.call(this, ${i}).subarray(0);`), n.pushCode(`var ${a} = buffer;`), n.pushCode(`var ${r} = offset;`), n.pushCode(`var ${o} = dataView;`), n.pushCode(`buffer = ${i};`), n.pushCode("offset = 0;"), n.pushCode("dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"), this.options.type instanceof S)
727
- this.varName && n.pushCode(`${t} = {};`), n.pushPath(this.varName), this.options.type.generate(n), n.popPath(this.varName);
728
- else if (x.has(this.options.type)) {
729
- const u = n.generateTmpVariable();
730
- n.pushCode(`var ${u} = ${re + this.options.type}(0);`), n.pushCode(`${t} = ${u}.result;`), this.options.type !== this.alias && n.addReference(this.options.type);
731
- }
732
- n.pushCode(`buffer = ${a};`), n.pushCode(`dataView = ${o};`), n.pushCode(`offset = ${r};`);
733
- }
734
- generateFormatter(n, t, i) {
735
- if (typeof i == "function") {
736
- const a = n.addImport(i);
737
- n.pushCode(`${t} = ${a}.call(${n.generateVariable()}, ${t});`);
738
- }
739
- }
740
- generatePointer(n) {
741
- const t = this.options.type, i = n.generateOption(this.options.offset), a = n.generateTmpVariable(), r = n.generateVariable(this.varName);
742
- if (n.pushCode(`var ${a} = offset;`), n.pushCode(`offset = ${i};`), this.options.type instanceof S) {
743
- if (n.pushCode(`${r} = {};`), n.useContextVariables) {
744
- const o = n.generateVariable();
745
- n.pushCode(`${r}.$parent = ${o};`), n.pushCode(`${r}.$root = ${o}.$root;`);
746
- }
747
- n.pushPath(this.varName), this.options.type.generate(n), n.popPath(this.varName), n.useContextVariables && (n.pushCode(`delete ${r}.$parent;`), n.pushCode(`delete ${r}.$root;`));
748
- } else if (x.has(this.options.type)) {
749
- const o = n.generateTmpVariable();
750
- if (n.pushCode(`var ${o} = ${re + this.options.type}(offset, {`), n.useContextVariables) {
751
- const l = n.generateVariable();
752
- n.pushCode(`$parent: ${l},`), n.pushCode(`$root: ${l}.$root,`);
753
- }
754
- n.pushCode("});"), n.pushCode(`${r} = ${o}.result; offset = ${o}.offset;`), this.options.type !== this.alias && n.addReference(this.options.type);
755
- } else if (Object.keys(M).indexOf(this.options.type) >= 0) {
756
- const o = Ye[t], l = Ke[t];
757
- n.pushCode(`${r} = dataView.get${o}(offset, ${l});`), n.pushCode(`offset += ${M[t]};`);
758
- }
759
- n.pushCode(`offset = ${a};`);
760
- }
761
- generateSaveOffset(n) {
762
- const t = n.generateVariable(this.varName);
763
- n.pushCode(`${t} = offset`);
764
- }
765
- }
766
- class pe {
767
- constructor(n) {
768
- this.ranges = n;
769
- }
770
- get min() {
771
- return this.ranges[0].min;
772
- }
773
- get max() {
774
- return this.ranges[this.ranges.length - 1].max;
775
- }
776
- contains(n) {
777
- for (const t of this.ranges)
778
- if (t.min <= n && t.max >= n)
779
- return !0;
780
- return !1;
781
- }
782
- isContiguous() {
783
- return this.ranges.length > 1;
784
- }
785
- getRanges() {
786
- return this.ranges.map((n) => new pe([{ min: n.min, max: n.max }]));
787
- }
788
- toString() {
789
- return this.ranges.map((n) => `[${n.min}-${n.max}]`).join(",");
790
- }
791
- union(n) {
792
- const t = [...this.getRanges(), ...n.getRanges()].sort((r, o) => r.min < o.min ? -1 : r.min > o.min ? 1 : r.max < o.max ? -1 : o.max > r.max ? 1 : 0), i = [];
793
- let a = t[0];
794
- for (const r of t)
795
- r.min > a.max + 1 ? (i.push(a), a = r) : r.max > a.max && (a = new pe([{ min: a.min, max: r.max }]));
796
- return i.push(a), i.length === 1 ? i[0] : new pe(i);
797
- }
798
- }
799
- /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
800
- const fr = 4, Qt = 0, en = 1, ur = 2;
801
- function ye(e) {
802
- let n = e.length;
803
- for (; --n >= 0; )
804
- e[n] = 0;
805
- }
806
- const hr = 0, Kn = 1, cr = 2, dr = 3, pr = 258, Zt = 29, Ze = 256, Oe = Ze + 1 + Zt, _e = 30, xt = 19, Wn = 2 * Oe + 1, ae = 15, ht = 16, _r = 7, Mt = 256, Xn = 16, qn = 17, Jn = 18, Tt = (
807
- /* extra bits for each length code */
808
- new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])
809
- ), nt = (
810
- /* extra bits for each distance code */
811
- new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])
812
- ), br = (
813
- /* extra bits for each bit length code */
814
- new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])
815
- ), Qn = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), gr = 512, W = new Array((Oe + 2) * 2);
816
- ye(W);
817
- const Ie = new Array(_e * 2);
818
- ye(Ie);
819
- const ze = new Array(gr);
820
- ye(ze);
821
- const Re = new Array(pr - dr + 1);
822
- ye(Re);
823
- const Ht = new Array(Zt);
824
- ye(Ht);
825
- const it = new Array(_e);
826
- ye(it);
827
- function ct(e, n, t, i, a) {
828
- this.static_tree = e, this.extra_bits = n, this.extra_base = t, this.elems = i, this.max_length = a, this.has_stree = e && e.length;
829
- }
830
- let ei, ti, ni;
831
- function dt(e, n) {
832
- this.dyn_tree = e, this.max_code = 0, this.stat_desc = n;
833
- }
834
- const ii = (e) => e < 256 ? ze[e] : ze[256 + (e >>> 7)], Be = (e, n) => {
835
- e.pending_buf[e.pending++] = n & 255, e.pending_buf[e.pending++] = n >>> 8 & 255;
836
- }, D = (e, n, t) => {
837
- e.bi_valid > ht - t ? (e.bi_buf |= n << e.bi_valid & 65535, Be(e, e.bi_buf), e.bi_buf = n >> ht - e.bi_valid, e.bi_valid += t - ht) : (e.bi_buf |= n << e.bi_valid & 65535, e.bi_valid += t);
838
- }, j = (e, n, t) => {
839
- D(
840
- e,
841
- t[n * 2],
842
- t[n * 2 + 1]
843
- /*.Len*/
844
- );
845
- }, ri = (e, n) => {
846
- let t = 0;
847
- do
848
- t |= e & 1, e >>>= 1, t <<= 1;
849
- while (--n > 0);
850
- return t >>> 1;
851
- }, wr = (e) => {
852
- e.bi_valid === 16 ? (Be(e, e.bi_buf), e.bi_buf = 0, e.bi_valid = 0) : e.bi_valid >= 8 && (e.pending_buf[e.pending++] = e.bi_buf & 255, e.bi_buf >>= 8, e.bi_valid -= 8);
853
- }, mr = (e, n) => {
854
- const t = n.dyn_tree, i = n.max_code, a = n.stat_desc.static_tree, r = n.stat_desc.has_stree, o = n.stat_desc.extra_bits, l = n.stat_desc.extra_base, u = n.stat_desc.max_length;
855
- let s, f, _, c, h, d, g = 0;
856
- for (c = 0; c <= ae; c++)
857
- e.bl_count[c] = 0;
858
- for (t[e.heap[e.heap_max] * 2 + 1] = 0, s = e.heap_max + 1; s < Wn; s++)
859
- f = e.heap[s], c = t[t[f * 2 + 1] * 2 + 1] + 1, c > u && (c = u, g++), t[f * 2 + 1] = c, !(f > i) && (e.bl_count[c]++, h = 0, f >= l && (h = o[f - l]), d = t[f * 2], e.opt_len += d * (c + h), r && (e.static_len += d * (a[f * 2 + 1] + h)));
860
- if (g !== 0) {
861
- do {
862
- for (c = u - 1; e.bl_count[c] === 0; )
863
- c--;
864
- e.bl_count[c]--, e.bl_count[c + 1] += 2, e.bl_count[u]--, g -= 2;
865
- } while (g > 0);
866
- for (c = u; c !== 0; c--)
867
- for (f = e.bl_count[c]; f !== 0; )
868
- _ = e.heap[--s], !(_ > i) && (t[_ * 2 + 1] !== c && (e.opt_len += (c - t[_ * 2 + 1]) * t[_ * 2], t[_ * 2 + 1] = c), f--);
869
- }
870
- }, ai = (e, n, t) => {
871
- const i = new Array(ae + 1);
872
- let a = 0, r, o;
873
- for (r = 1; r <= ae; r++)
874
- a = a + t[r - 1] << 1, i[r] = a;
875
- for (o = 0; o <= n; o++) {
876
- let l = e[o * 2 + 1];
877
- l !== 0 && (e[o * 2] = ri(i[l]++, l));
878
- }
879
- }, yr = () => {
880
- let e, n, t, i, a;
881
- const r = new Array(ae + 1);
882
- for (t = 0, i = 0; i < Zt - 1; i++)
883
- for (Ht[i] = t, e = 0; e < 1 << Tt[i]; e++)
884
- Re[t++] = i;
885
- for (Re[t - 1] = i, a = 0, i = 0; i < 16; i++)
886
- for (it[i] = a, e = 0; e < 1 << nt[i]; e++)
887
- ze[a++] = i;
888
- for (a >>= 7; i < _e; i++)
889
- for (it[i] = a << 7, e = 0; e < 1 << nt[i] - 7; e++)
890
- ze[256 + a++] = i;
891
- for (n = 0; n <= ae; n++)
892
- r[n] = 0;
893
- for (e = 0; e <= 143; )
894
- W[e * 2 + 1] = 8, e++, r[8]++;
895
- for (; e <= 255; )
896
- W[e * 2 + 1] = 9, e++, r[9]++;
897
- for (; e <= 279; )
898
- W[e * 2 + 1] = 7, e++, r[7]++;
899
- for (; e <= 287; )
900
- W[e * 2 + 1] = 8, e++, r[8]++;
901
- for (ai(W, Oe + 1, r), e = 0; e < _e; e++)
902
- Ie[e * 2 + 1] = 5, Ie[e * 2] = ri(e, 5);
903
- ei = new ct(W, Tt, Ze + 1, Oe, ae), ti = new ct(Ie, nt, 0, _e, ae), ni = new ct(new Array(0), br, 0, xt, _r);
904
- }, oi = (e) => {
905
- let n;
906
- for (n = 0; n < Oe; n++)
907
- e.dyn_ltree[n * 2] = 0;
908
- for (n = 0; n < _e; n++)
909
- e.dyn_dtree[n * 2] = 0;
910
- for (n = 0; n < xt; n++)
911
- e.bl_tree[n * 2] = 0;
912
- e.dyn_ltree[Mt * 2] = 1, e.opt_len = e.static_len = 0, e.sym_next = e.matches = 0;
913
- }, si = (e) => {
914
- e.bi_valid > 8 ? Be(e, e.bi_buf) : e.bi_valid > 0 && (e.pending_buf[e.pending++] = e.bi_buf), e.bi_buf = 0, e.bi_valid = 0;
915
- }, tn = (e, n, t, i) => {
916
- const a = n * 2, r = t * 2;
917
- return e[a] < e[r] || e[a] === e[r] && i[n] <= i[t];
918
- }, pt = (e, n, t) => {
919
- const i = e.heap[t];
920
- let a = t << 1;
921
- for (; a <= e.heap_len && (a < e.heap_len && tn(n, e.heap[a + 1], e.heap[a], e.depth) && a++, !tn(n, i, e.heap[a], e.depth)); )
922
- e.heap[t] = e.heap[a], t = a, a <<= 1;
923
- e.heap[t] = i;
924
- }, nn = (e, n, t) => {
925
- let i, a, r = 0, o, l;
926
- if (e.sym_next !== 0)
927
- do
928
- i = e.pending_buf[e.sym_buf + r++] & 255, i += (e.pending_buf[e.sym_buf + r++] & 255) << 8, a = e.pending_buf[e.sym_buf + r++], i === 0 ? j(e, a, n) : (o = Re[a], j(e, o + Ze + 1, n), l = Tt[o], l !== 0 && (a -= Ht[o], D(e, a, l)), i--, o = ii(i), j(e, o, t), l = nt[o], l !== 0 && (i -= it[o], D(e, i, l)));
929
- while (r < e.sym_next);
930
- j(e, Mt, n);
931
- }, At = (e, n) => {
932
- const t = n.dyn_tree, i = n.stat_desc.static_tree, a = n.stat_desc.has_stree, r = n.stat_desc.elems;
933
- let o, l, u = -1, s;
934
- for (e.heap_len = 0, e.heap_max = Wn, o = 0; o < r; o++)
935
- t[o * 2] !== 0 ? (e.heap[++e.heap_len] = u = o, e.depth[o] = 0) : t[o * 2 + 1] = 0;
936
- for (; e.heap_len < 2; )
937
- s = e.heap[++e.heap_len] = u < 2 ? ++u : 0, t[s * 2] = 1, e.depth[s] = 0, e.opt_len--, a && (e.static_len -= i[s * 2 + 1]);
938
- for (n.max_code = u, o = e.heap_len >> 1; o >= 1; o--)
939
- pt(e, t, o);
940
- s = r;
941
- do
942
- o = e.heap[
943
- 1
944
- /*SMALLEST*/
945
- ], e.heap[
946
- 1
947
- /*SMALLEST*/
948
- ] = e.heap[e.heap_len--], pt(
949
- e,
950
- t,
951
- 1
952
- /*SMALLEST*/
953
- ), l = e.heap[
954
- 1
955
- /*SMALLEST*/
956
- ], e.heap[--e.heap_max] = o, e.heap[--e.heap_max] = l, t[s * 2] = t[o * 2] + t[l * 2], e.depth[s] = (e.depth[o] >= e.depth[l] ? e.depth[o] : e.depth[l]) + 1, t[o * 2 + 1] = t[l * 2 + 1] = s, e.heap[
957
- 1
958
- /*SMALLEST*/
959
- ] = s++, pt(
960
- e,
961
- t,
962
- 1
963
- /*SMALLEST*/
964
- );
965
- while (e.heap_len >= 2);
966
- e.heap[--e.heap_max] = e.heap[
967
- 1
968
- /*SMALLEST*/
969
- ], mr(e, n), ai(t, u, e.bl_count);
970
- }, rn = (e, n, t) => {
971
- let i, a = -1, r, o = n[0 * 2 + 1], l = 0, u = 7, s = 4;
972
- for (o === 0 && (u = 138, s = 3), n[(t + 1) * 2 + 1] = 65535, i = 0; i <= t; i++)
973
- r = o, o = n[(i + 1) * 2 + 1], !(++l < u && r === o) && (l < s ? e.bl_tree[r * 2] += l : r !== 0 ? (r !== a && e.bl_tree[r * 2]++, e.bl_tree[Xn * 2]++) : l <= 10 ? e.bl_tree[qn * 2]++ : e.bl_tree[Jn * 2]++, l = 0, a = r, o === 0 ? (u = 138, s = 3) : r === o ? (u = 6, s = 3) : (u = 7, s = 4));
974
- }, an = (e, n, t) => {
975
- let i, a = -1, r, o = n[0 * 2 + 1], l = 0, u = 7, s = 4;
976
- for (o === 0 && (u = 138, s = 3), i = 0; i <= t; i++)
977
- if (r = o, o = n[(i + 1) * 2 + 1], !(++l < u && r === o)) {
978
- if (l < s)
979
- do
980
- j(e, r, e.bl_tree);
981
- while (--l !== 0);
982
- else r !== 0 ? (r !== a && (j(e, r, e.bl_tree), l--), j(e, Xn, e.bl_tree), D(e, l - 3, 2)) : l <= 10 ? (j(e, qn, e.bl_tree), D(e, l - 3, 3)) : (j(e, Jn, e.bl_tree), D(e, l - 11, 7));
983
- l = 0, a = r, o === 0 ? (u = 138, s = 3) : r === o ? (u = 6, s = 3) : (u = 7, s = 4);
984
- }
985
- }, vr = (e) => {
986
- let n;
987
- for (rn(e, e.dyn_ltree, e.l_desc.max_code), rn(e, e.dyn_dtree, e.d_desc.max_code), At(e, e.bl_desc), n = xt - 1; n >= 3 && e.bl_tree[Qn[n] * 2 + 1] === 0; n--)
988
- ;
989
- return e.opt_len += 3 * (n + 1) + 5 + 5 + 4, n;
990
- }, kr = (e, n, t, i) => {
991
- let a;
992
- for (D(e, n - 257, 5), D(e, t - 1, 5), D(e, i - 4, 4), a = 0; a < i; a++)
993
- D(e, e.bl_tree[Qn[a] * 2 + 1], 3);
994
- an(e, e.dyn_ltree, n - 1), an(e, e.dyn_dtree, t - 1);
995
- }, $r = (e) => {
996
- let n = 4093624447, t;
997
- for (t = 0; t <= 31; t++, n >>>= 1)
998
- if (n & 1 && e.dyn_ltree[t * 2] !== 0)
999
- return Qt;
1000
- if (e.dyn_ltree[9 * 2] !== 0 || e.dyn_ltree[10 * 2] !== 0 || e.dyn_ltree[13 * 2] !== 0)
1001
- return en;
1002
- for (t = 32; t < Ze; t++)
1003
- if (e.dyn_ltree[t * 2] !== 0)
1004
- return en;
1005
- return Qt;
1006
- };
1007
- let on = !1;
1008
- const Er = (e) => {
1009
- on || (yr(), on = !0), e.l_desc = new dt(e.dyn_ltree, ei), e.d_desc = new dt(e.dyn_dtree, ti), e.bl_desc = new dt(e.bl_tree, ni), e.bi_buf = 0, e.bi_valid = 0, oi(e);
1010
- }, li = (e, n, t, i) => {
1011
- D(e, (hr << 1) + (i ? 1 : 0), 3), si(e), Be(e, t), Be(e, ~t), t && e.pending_buf.set(e.window.subarray(n, n + t), e.pending), e.pending += t;
1012
- }, Cr = (e) => {
1013
- D(e, Kn << 1, 3), j(e, Mt, W), wr(e);
1014
- }, Sr = (e, n, t, i) => {
1015
- let a, r, o = 0;
1016
- e.level > 0 ? (e.strm.data_type === ur && (e.strm.data_type = $r(e)), At(e, e.l_desc), At(e, e.d_desc), o = vr(e), a = e.opt_len + 3 + 7 >>> 3, r = e.static_len + 3 + 7 >>> 3, r <= a && (a = r)) : a = r = t + 5, t + 4 <= a && n !== -1 ? li(e, n, t, i) : e.strategy === fr || r === a ? (D(e, (Kn << 1) + (i ? 1 : 0), 3), nn(e, W, Ie)) : (D(e, (cr << 1) + (i ? 1 : 0), 3), kr(e, e.l_desc.max_code + 1, e.d_desc.max_code + 1, o + 1), nn(e, e.dyn_ltree, e.dyn_dtree)), oi(e), i && si(e);
1017
- }, Nr = (e, n, t) => (e.pending_buf[e.sym_buf + e.sym_next++] = n, e.pending_buf[e.sym_buf + e.sym_next++] = n >> 8, e.pending_buf[e.sym_buf + e.sym_next++] = t, n === 0 ? e.dyn_ltree[t * 2]++ : (e.matches++, n--, e.dyn_ltree[(Re[t] + Ze + 1) * 2]++, e.dyn_dtree[ii(n) * 2]++), e.sym_next === e.sym_end);
1018
- var Ir = Er, Tr = li, Ar = Sr, Or = Nr, zr = Cr, Rr = {
1019
- _tr_init: Ir,
1020
- _tr_stored_block: Tr,
1021
- _tr_flush_block: Ar,
1022
- _tr_tally: Or,
1023
- _tr_align: zr
1024
- };
1025
- const Br = (e, n, t, i) => {
1026
- let a = e & 65535 | 0, r = e >>> 16 & 65535 | 0, o = 0;
1027
- for (; t !== 0; ) {
1028
- o = t > 2e3 ? 2e3 : t, t -= o;
1029
- do
1030
- a = a + n[i++] | 0, r = r + a | 0;
1031
- while (--o);
1032
- a %= 65521, r %= 65521;
1033
- }
1034
- return a | r << 16 | 0;
1035
- };
1036
- var Ue = Br;
1037
- const Ur = () => {
1038
- let e, n = [];
1039
- for (var t = 0; t < 256; t++) {
1040
- e = t;
1041
- for (var i = 0; i < 8; i++)
1042
- e = e & 1 ? 3988292384 ^ e >>> 1 : e >>> 1;
1043
- n[t] = e;
1044
- }
1045
- return n;
1046
- }, Dr = new Uint32Array(Ur()), Vr = (e, n, t, i) => {
1047
- const a = Dr, r = i + t;
1048
- e ^= -1;
1049
- for (let o = i; o < r; o++)
1050
- e = e >>> 8 ^ a[(e ^ n[o]) & 255];
1051
- return e ^ -1;
1052
- };
1053
- var R = Vr, ge = {
1054
- 2: "need dictionary",
1055
- /* Z_NEED_DICT 2 */
1056
- 1: "stream end",
1057
- /* Z_STREAM_END 1 */
1058
- 0: "",
1059
- /* Z_OK 0 */
1060
- "-1": "file error",
1061
- /* Z_ERRNO (-1) */
1062
- "-2": "stream error",
1063
- /* Z_STREAM_ERROR (-2) */
1064
- "-3": "data error",
1065
- /* Z_DATA_ERROR (-3) */
1066
- "-4": "insufficient memory",
1067
- /* Z_MEM_ERROR (-4) */
1068
- "-5": "buffer error",
1069
- /* Z_BUF_ERROR (-5) */
1070
- "-6": "incompatible version"
1071
- /* Z_VERSION_ERROR (-6) */
1072
- }, xe = {
1073
- /* Allowed flush values; see deflate() and inflate() below for details */
1074
- Z_NO_FLUSH: 0,
1075
- Z_PARTIAL_FLUSH: 1,
1076
- Z_SYNC_FLUSH: 2,
1077
- Z_FULL_FLUSH: 3,
1078
- Z_FINISH: 4,
1079
- Z_BLOCK: 5,
1080
- Z_TREES: 6,
1081
- /* Return codes for the compression/decompression functions. Negative values
1082
- * are errors, positive values are used for special but normal events.
1083
- */
1084
- Z_OK: 0,
1085
- Z_STREAM_END: 1,
1086
- Z_NEED_DICT: 2,
1087
- Z_ERRNO: -1,
1088
- Z_STREAM_ERROR: -2,
1089
- Z_DATA_ERROR: -3,
1090
- Z_MEM_ERROR: -4,
1091
- Z_BUF_ERROR: -5,
1092
- //Z_VERSION_ERROR: -6,
1093
- /* compression levels */
1094
- Z_NO_COMPRESSION: 0,
1095
- Z_BEST_SPEED: 1,
1096
- Z_BEST_COMPRESSION: 9,
1097
- Z_DEFAULT_COMPRESSION: -1,
1098
- Z_FILTERED: 1,
1099
- Z_HUFFMAN_ONLY: 2,
1100
- Z_RLE: 3,
1101
- Z_FIXED: 4,
1102
- Z_DEFAULT_STRATEGY: 0,
1103
- /* Possible values of the data_type field (though see inflate()) */
1104
- Z_BINARY: 0,
1105
- Z_TEXT: 1,
1106
- //Z_ASCII: 1, // = Z_TEXT (deprecated)
1107
- Z_UNKNOWN: 2,
1108
- /* The deflate compression method */
1109
- Z_DEFLATED: 8
1110
- //Z_NULL: null // Use -1 or null inline, depending on var type
1111
- };
1112
- const { _tr_init: Fr, _tr_stored_block: Ot, _tr_flush_block: Lr, _tr_tally: ee, _tr_align: Pr } = Rr, {
1113
- Z_NO_FLUSH: te,
1114
- Z_PARTIAL_FLUSH: Zr,
1115
- Z_FULL_FLUSH: xr,
1116
- Z_FINISH: L,
1117
- Z_BLOCK: sn,
1118
- Z_OK: B,
1119
- Z_STREAM_END: ln,
1120
- Z_STREAM_ERROR: G,
1121
- Z_DATA_ERROR: Mr,
1122
- Z_BUF_ERROR: _t,
1123
- Z_DEFAULT_COMPRESSION: Hr,
1124
- Z_FILTERED: jr,
1125
- Z_HUFFMAN_ONLY: We,
1126
- Z_RLE: Gr,
1127
- Z_FIXED: Yr,
1128
- Z_DEFAULT_STRATEGY: Kr,
1129
- Z_UNKNOWN: Wr,
1130
- Z_DEFLATED: lt
1131
- } = xe, Xr = 9, qr = 15, Jr = 8, Qr = 29, ea = 256, zt = ea + 1 + Qr, ta = 30, na = 19, ia = 2 * zt + 1, ra = 15, T = 3, Q = 258, Y = Q + T + 1, aa = 32, we = 42, jt = 57, Rt = 69, Bt = 73, Ut = 91, Dt = 103, oe = 113, Se = 666, U = 1, ve = 2, fe = 3, ke = 4, oa = 3, se = (e, n) => (e.msg = ge[n], n), fn = (e) => e * 2 - (e > 4 ? 9 : 0), q = (e) => {
1132
- let n = e.length;
1133
- for (; --n >= 0; )
1134
- e[n] = 0;
1135
- }, sa = (e) => {
1136
- let n, t, i, a = e.w_size;
1137
- n = e.hash_size, i = n;
1138
- do
1139
- t = e.head[--i], e.head[i] = t >= a ? t - a : 0;
1140
- while (--n);
1141
- n = a, i = n;
1142
- do
1143
- t = e.prev[--i], e.prev[i] = t >= a ? t - a : 0;
1144
- while (--n);
1145
- };
1146
- let la = (e, n, t) => (n << e.hash_shift ^ t) & e.hash_mask, ne = la;
1147
- const V = (e) => {
1148
- const n = e.state;
1149
- let t = n.pending;
1150
- t > e.avail_out && (t = e.avail_out), t !== 0 && (e.output.set(n.pending_buf.subarray(n.pending_out, n.pending_out + t), e.next_out), e.next_out += t, n.pending_out += t, e.total_out += t, e.avail_out -= t, n.pending -= t, n.pending === 0 && (n.pending_out = 0));
1151
- }, F = (e, n) => {
1152
- Lr(e, e.block_start >= 0 ? e.block_start : -1, e.strstart - e.block_start, n), e.block_start = e.strstart, V(e.strm);
1153
- }, A = (e, n) => {
1154
- e.pending_buf[e.pending++] = n;
1155
- }, Ce = (e, n) => {
1156
- e.pending_buf[e.pending++] = n >>> 8 & 255, e.pending_buf[e.pending++] = n & 255;
1157
- }, Vt = (e, n, t, i) => {
1158
- let a = e.avail_in;
1159
- return a > i && (a = i), a === 0 ? 0 : (e.avail_in -= a, n.set(e.input.subarray(e.next_in, e.next_in + a), t), e.state.wrap === 1 ? e.adler = Ue(e.adler, n, a, t) : e.state.wrap === 2 && (e.adler = R(e.adler, n, a, t)), e.next_in += a, e.total_in += a, a);
1160
- }, fi = (e, n) => {
1161
- let t = e.max_chain_length, i = e.strstart, a, r, o = e.prev_length, l = e.nice_match;
1162
- const u = e.strstart > e.w_size - Y ? e.strstart - (e.w_size - Y) : 0, s = e.window, f = e.w_mask, _ = e.prev, c = e.strstart + Q;
1163
- let h = s[i + o - 1], d = s[i + o];
1164
- e.prev_length >= e.good_match && (t >>= 2), l > e.lookahead && (l = e.lookahead);
1165
- do
1166
- if (a = n, !(s[a + o] !== d || s[a + o - 1] !== h || s[a] !== s[i] || s[++a] !== s[i + 1])) {
1167
- i += 2, a++;
1168
- do
1169
- ;
1170
- while (s[++i] === s[++a] && s[++i] === s[++a] && s[++i] === s[++a] && s[++i] === s[++a] && s[++i] === s[++a] && s[++i] === s[++a] && s[++i] === s[++a] && s[++i] === s[++a] && i < c);
1171
- if (r = Q - (c - i), i = c - Q, r > o) {
1172
- if (e.match_start = n, o = r, r >= l)
1173
- break;
1174
- h = s[i + o - 1], d = s[i + o];
1175
- }
1176
- }
1177
- while ((n = _[n & f]) > u && --t !== 0);
1178
- return o <= e.lookahead ? o : e.lookahead;
1179
- }, me = (e) => {
1180
- const n = e.w_size;
1181
- let t, i, a;
1182
- do {
1183
- if (i = e.window_size - e.lookahead - e.strstart, e.strstart >= n + (n - Y) && (e.window.set(e.window.subarray(n, n + n - i), 0), e.match_start -= n, e.strstart -= n, e.block_start -= n, e.insert > e.strstart && (e.insert = e.strstart), sa(e), i += n), e.strm.avail_in === 0)
1184
- break;
1185
- if (t = Vt(e.strm, e.window, e.strstart + e.lookahead, i), e.lookahead += t, e.lookahead + e.insert >= T)
1186
- for (a = e.strstart - e.insert, e.ins_h = e.window[a], e.ins_h = ne(e, e.ins_h, e.window[a + 1]); e.insert && (e.ins_h = ne(e, e.ins_h, e.window[a + T - 1]), e.prev[a & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = a, a++, e.insert--, !(e.lookahead + e.insert < T)); )
1187
- ;
1188
- } while (e.lookahead < Y && e.strm.avail_in !== 0);
1189
- }, ui = (e, n) => {
1190
- let t = e.pending_buf_size - 5 > e.w_size ? e.w_size : e.pending_buf_size - 5, i, a, r, o = 0, l = e.strm.avail_in;
1191
- do {
1192
- if (i = 65535, r = e.bi_valid + 42 >> 3, e.strm.avail_out < r || (r = e.strm.avail_out - r, a = e.strstart - e.block_start, i > a + e.strm.avail_in && (i = a + e.strm.avail_in), i > r && (i = r), i < t && (i === 0 && n !== L || n === te || i !== a + e.strm.avail_in)))
1193
- break;
1194
- o = n === L && i === a + e.strm.avail_in ? 1 : 0, Ot(e, 0, 0, o), e.pending_buf[e.pending - 4] = i, e.pending_buf[e.pending - 3] = i >> 8, e.pending_buf[e.pending - 2] = ~i, e.pending_buf[e.pending - 1] = ~i >> 8, V(e.strm), a && (a > i && (a = i), e.strm.output.set(e.window.subarray(e.block_start, e.block_start + a), e.strm.next_out), e.strm.next_out += a, e.strm.avail_out -= a, e.strm.total_out += a, e.block_start += a, i -= a), i && (Vt(e.strm, e.strm.output, e.strm.next_out, i), e.strm.next_out += i, e.strm.avail_out -= i, e.strm.total_out += i);
1195
- } while (o === 0);
1196
- return l -= e.strm.avail_in, l && (l >= e.w_size ? (e.matches = 2, e.window.set(e.strm.input.subarray(e.strm.next_in - e.w_size, e.strm.next_in), 0), e.strstart = e.w_size, e.insert = e.strstart) : (e.window_size - e.strstart <= l && (e.strstart -= e.w_size, e.window.set(e.window.subarray(e.w_size, e.w_size + e.strstart), 0), e.matches < 2 && e.matches++, e.insert > e.strstart && (e.insert = e.strstart)), e.window.set(e.strm.input.subarray(e.strm.next_in - l, e.strm.next_in), e.strstart), e.strstart += l, e.insert += l > e.w_size - e.insert ? e.w_size - e.insert : l), e.block_start = e.strstart), e.high_water < e.strstart && (e.high_water = e.strstart), o ? ke : n !== te && n !== L && e.strm.avail_in === 0 && e.strstart === e.block_start ? ve : (r = e.window_size - e.strstart, e.strm.avail_in > r && e.block_start >= e.w_size && (e.block_start -= e.w_size, e.strstart -= e.w_size, e.window.set(e.window.subarray(e.w_size, e.w_size + e.strstart), 0), e.matches < 2 && e.matches++, r += e.w_size, e.insert > e.strstart && (e.insert = e.strstart)), r > e.strm.avail_in && (r = e.strm.avail_in), r && (Vt(e.strm, e.window, e.strstart, r), e.strstart += r, e.insert += r > e.w_size - e.insert ? e.w_size - e.insert : r), e.high_water < e.strstart && (e.high_water = e.strstart), r = e.bi_valid + 42 >> 3, r = e.pending_buf_size - r > 65535 ? 65535 : e.pending_buf_size - r, t = r > e.w_size ? e.w_size : r, a = e.strstart - e.block_start, (a >= t || (a || n === L) && n !== te && e.strm.avail_in === 0 && a <= r) && (i = a > r ? r : a, o = n === L && e.strm.avail_in === 0 && i === a ? 1 : 0, Ot(e, e.block_start, i, o), e.block_start += i, V(e.strm)), o ? fe : U);
1197
- }, bt = (e, n) => {
1198
- let t, i;
1199
- for (; ; ) {
1200
- if (e.lookahead < Y) {
1201
- if (me(e), e.lookahead < Y && n === te)
1202
- return U;
1203
- if (e.lookahead === 0)
1204
- break;
1205
- }
1206
- if (t = 0, e.lookahead >= T && (e.ins_h = ne(e, e.ins_h, e.window[e.strstart + T - 1]), t = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart), t !== 0 && e.strstart - t <= e.w_size - Y && (e.match_length = fi(e, t)), e.match_length >= T)
1207
- if (i = ee(e, e.strstart - e.match_start, e.match_length - T), e.lookahead -= e.match_length, e.match_length <= e.max_lazy_match && e.lookahead >= T) {
1208
- e.match_length--;
1209
- do
1210
- e.strstart++, e.ins_h = ne(e, e.ins_h, e.window[e.strstart + T - 1]), t = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart;
1211
- while (--e.match_length !== 0);
1212
- e.strstart++;
1213
- } else
1214
- e.strstart += e.match_length, e.match_length = 0, e.ins_h = e.window[e.strstart], e.ins_h = ne(e, e.ins_h, e.window[e.strstart + 1]);
1215
- else
1216
- i = ee(e, 0, e.window[e.strstart]), e.lookahead--, e.strstart++;
1217
- if (i && (F(e, !1), e.strm.avail_out === 0))
1218
- return U;
1219
- }
1220
- return e.insert = e.strstart < T - 1 ? e.strstart : T - 1, n === L ? (F(e, !0), e.strm.avail_out === 0 ? fe : ke) : e.sym_next && (F(e, !1), e.strm.avail_out === 0) ? U : ve;
1221
- }, ce = (e, n) => {
1222
- let t, i, a;
1223
- for (; ; ) {
1224
- if (e.lookahead < Y) {
1225
- if (me(e), e.lookahead < Y && n === te)
1226
- return U;
1227
- if (e.lookahead === 0)
1228
- break;
1229
- }
1230
- if (t = 0, e.lookahead >= T && (e.ins_h = ne(e, e.ins_h, e.window[e.strstart + T - 1]), t = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart), e.prev_length = e.match_length, e.prev_match = e.match_start, e.match_length = T - 1, t !== 0 && e.prev_length < e.max_lazy_match && e.strstart - t <= e.w_size - Y && (e.match_length = fi(e, t), e.match_length <= 5 && (e.strategy === jr || e.match_length === T && e.strstart - e.match_start > 4096) && (e.match_length = T - 1)), e.prev_length >= T && e.match_length <= e.prev_length) {
1231
- a = e.strstart + e.lookahead - T, i = ee(e, e.strstart - 1 - e.prev_match, e.prev_length - T), e.lookahead -= e.prev_length - 1, e.prev_length -= 2;
1232
- do
1233
- ++e.strstart <= a && (e.ins_h = ne(e, e.ins_h, e.window[e.strstart + T - 1]), t = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart);
1234
- while (--e.prev_length !== 0);
1235
- if (e.match_available = 0, e.match_length = T - 1, e.strstart++, i && (F(e, !1), e.strm.avail_out === 0))
1236
- return U;
1237
- } else if (e.match_available) {
1238
- if (i = ee(e, 0, e.window[e.strstart - 1]), i && F(e, !1), e.strstart++, e.lookahead--, e.strm.avail_out === 0)
1239
- return U;
1240
- } else
1241
- e.match_available = 1, e.strstart++, e.lookahead--;
1242
- }
1243
- return e.match_available && (i = ee(e, 0, e.window[e.strstart - 1]), e.match_available = 0), e.insert = e.strstart < T - 1 ? e.strstart : T - 1, n === L ? (F(e, !0), e.strm.avail_out === 0 ? fe : ke) : e.sym_next && (F(e, !1), e.strm.avail_out === 0) ? U : ve;
1244
- }, fa = (e, n) => {
1245
- let t, i, a, r;
1246
- const o = e.window;
1247
- for (; ; ) {
1248
- if (e.lookahead <= Q) {
1249
- if (me(e), e.lookahead <= Q && n === te)
1250
- return U;
1251
- if (e.lookahead === 0)
1252
- break;
1253
- }
1254
- if (e.match_length = 0, e.lookahead >= T && e.strstart > 0 && (a = e.strstart - 1, i = o[a], i === o[++a] && i === o[++a] && i === o[++a])) {
1255
- r = e.strstart + Q;
1256
- do
1257
- ;
1258
- while (i === o[++a] && i === o[++a] && i === o[++a] && i === o[++a] && i === o[++a] && i === o[++a] && i === o[++a] && i === o[++a] && a < r);
1259
- e.match_length = Q - (r - a), e.match_length > e.lookahead && (e.match_length = e.lookahead);
1260
- }
1261
- if (e.match_length >= T ? (t = ee(e, 1, e.match_length - T), e.lookahead -= e.match_length, e.strstart += e.match_length, e.match_length = 0) : (t = ee(e, 0, e.window[e.strstart]), e.lookahead--, e.strstart++), t && (F(e, !1), e.strm.avail_out === 0))
1262
- return U;
1263
- }
1264
- return e.insert = 0, n === L ? (F(e, !0), e.strm.avail_out === 0 ? fe : ke) : e.sym_next && (F(e, !1), e.strm.avail_out === 0) ? U : ve;
1265
- }, ua = (e, n) => {
1266
- let t;
1267
- for (; ; ) {
1268
- if (e.lookahead === 0 && (me(e), e.lookahead === 0)) {
1269
- if (n === te)
1270
- return U;
1271
- break;
1272
- }
1273
- if (e.match_length = 0, t = ee(e, 0, e.window[e.strstart]), e.lookahead--, e.strstart++, t && (F(e, !1), e.strm.avail_out === 0))
1274
- return U;
1275
- }
1276
- return e.insert = 0, n === L ? (F(e, !0), e.strm.avail_out === 0 ? fe : ke) : e.sym_next && (F(e, !1), e.strm.avail_out === 0) ? U : ve;
1277
- };
1278
- function H(e, n, t, i, a) {
1279
- this.good_length = e, this.max_lazy = n, this.nice_length = t, this.max_chain = i, this.func = a;
1280
- }
1281
- const Ne = [
1282
- /* good lazy nice chain */
1283
- new H(0, 0, 0, 0, ui),
1284
- /* 0 store only */
1285
- new H(4, 4, 8, 4, bt),
1286
- /* 1 max speed, no lazy matches */
1287
- new H(4, 5, 16, 8, bt),
1288
- /* 2 */
1289
- new H(4, 6, 32, 32, bt),
1290
- /* 3 */
1291
- new H(4, 4, 16, 16, ce),
1292
- /* 4 lazy matches */
1293
- new H(8, 16, 32, 32, ce),
1294
- /* 5 */
1295
- new H(8, 16, 128, 128, ce),
1296
- /* 6 */
1297
- new H(8, 32, 128, 256, ce),
1298
- /* 7 */
1299
- new H(32, 128, 258, 1024, ce),
1300
- /* 8 */
1301
- new H(32, 258, 258, 4096, ce)
1302
- /* 9 max compression */
1303
- ], ha = (e) => {
1304
- e.window_size = 2 * e.w_size, q(e.head), e.max_lazy_match = Ne[e.level].max_lazy, e.good_match = Ne[e.level].good_length, e.nice_match = Ne[e.level].nice_length, e.max_chain_length = Ne[e.level].max_chain, e.strstart = 0, e.block_start = 0, e.lookahead = 0, e.insert = 0, e.match_length = e.prev_length = T - 1, e.match_available = 0, e.ins_h = 0;
1305
- };
1306
- function ca() {
1307
- this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = lt, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(ia * 2), this.dyn_dtree = new Uint16Array((2 * ta + 1) * 2), this.bl_tree = new Uint16Array((2 * na + 1) * 2), q(this.dyn_ltree), q(this.dyn_dtree), q(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(ra + 1), this.heap = new Uint16Array(2 * zt + 1), q(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(2 * zt + 1), q(this.depth), this.sym_buf = 0, this.lit_bufsize = 0, this.sym_next = 0, this.sym_end = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0;
1308
- }
1309
- const Me = (e) => {
1310
- if (!e)
1311
- return 1;
1312
- const n = e.state;
1313
- return !n || n.strm !== e || n.status !== we && //#ifdef GZIP
1314
- n.status !== jt && //#endif
1315
- n.status !== Rt && n.status !== Bt && n.status !== Ut && n.status !== Dt && n.status !== oe && n.status !== Se ? 1 : 0;
1316
- }, hi = (e) => {
1317
- if (Me(e))
1318
- return se(e, G);
1319
- e.total_in = e.total_out = 0, e.data_type = Wr;
1320
- const n = e.state;
1321
- return n.pending = 0, n.pending_out = 0, n.wrap < 0 && (n.wrap = -n.wrap), n.status = //#ifdef GZIP
1322
- n.wrap === 2 ? jt : (
1323
- //#endif
1324
- n.wrap ? we : oe
1325
- ), e.adler = n.wrap === 2 ? 0 : 1, n.last_flush = -2, Fr(n), B;
1326
- }, ci = (e) => {
1327
- const n = hi(e);
1328
- return n === B && ha(e.state), n;
1329
- }, da = (e, n) => Me(e) || e.state.wrap !== 2 ? G : (e.state.gzhead = n, B), di = (e, n, t, i, a, r) => {
1330
- if (!e)
1331
- return G;
1332
- let o = 1;
1333
- if (n === Hr && (n = 6), i < 0 ? (o = 0, i = -i) : i > 15 && (o = 2, i -= 16), a < 1 || a > Xr || t !== lt || i < 8 || i > 15 || n < 0 || n > 9 || r < 0 || r > Yr || i === 8 && o !== 1)
1334
- return se(e, G);
1335
- i === 8 && (i = 9);
1336
- const l = new ca();
1337
- return e.state = l, l.strm = e, l.status = we, l.wrap = o, l.gzhead = null, l.w_bits = i, l.w_size = 1 << l.w_bits, l.w_mask = l.w_size - 1, l.hash_bits = a + 7, l.hash_size = 1 << l.hash_bits, l.hash_mask = l.hash_size - 1, l.hash_shift = ~~((l.hash_bits + T - 1) / T), l.window = new Uint8Array(l.w_size * 2), l.head = new Uint16Array(l.hash_size), l.prev = new Uint16Array(l.w_size), l.lit_bufsize = 1 << a + 6, l.pending_buf_size = l.lit_bufsize * 4, l.pending_buf = new Uint8Array(l.pending_buf_size), l.sym_buf = l.lit_bufsize, l.sym_end = (l.lit_bufsize - 1) * 3, l.level = n, l.strategy = r, l.method = t, ci(e);
1338
- }, pa = (e, n) => di(e, n, lt, qr, Jr, Kr), _a = (e, n) => {
1339
- if (Me(e) || n > sn || n < 0)
1340
- return e ? se(e, G) : G;
1341
- const t = e.state;
1342
- if (!e.output || e.avail_in !== 0 && !e.input || t.status === Se && n !== L)
1343
- return se(e, e.avail_out === 0 ? _t : G);
1344
- const i = t.last_flush;
1345
- if (t.last_flush = n, t.pending !== 0) {
1346
- if (V(e), e.avail_out === 0)
1347
- return t.last_flush = -1, B;
1348
- } else if (e.avail_in === 0 && fn(n) <= fn(i) && n !== L)
1349
- return se(e, _t);
1350
- if (t.status === Se && e.avail_in !== 0)
1351
- return se(e, _t);
1352
- if (t.status === we && t.wrap === 0 && (t.status = oe), t.status === we) {
1353
- let a = lt + (t.w_bits - 8 << 4) << 8, r = -1;
1354
- if (t.strategy >= We || t.level < 2 ? r = 0 : t.level < 6 ? r = 1 : t.level === 6 ? r = 2 : r = 3, a |= r << 6, t.strstart !== 0 && (a |= aa), a += 31 - a % 31, Ce(t, a), t.strstart !== 0 && (Ce(t, e.adler >>> 16), Ce(t, e.adler & 65535)), e.adler = 1, t.status = oe, V(e), t.pending !== 0)
1355
- return t.last_flush = -1, B;
1356
- }
1357
- if (t.status === jt) {
1358
- if (e.adler = 0, A(t, 31), A(t, 139), A(t, 8), t.gzhead)
1359
- A(
1360
- t,
1361
- (t.gzhead.text ? 1 : 0) + (t.gzhead.hcrc ? 2 : 0) + (t.gzhead.extra ? 4 : 0) + (t.gzhead.name ? 8 : 0) + (t.gzhead.comment ? 16 : 0)
1362
- ), A(t, t.gzhead.time & 255), A(t, t.gzhead.time >> 8 & 255), A(t, t.gzhead.time >> 16 & 255), A(t, t.gzhead.time >> 24 & 255), A(t, t.level === 9 ? 2 : t.strategy >= We || t.level < 2 ? 4 : 0), A(t, t.gzhead.os & 255), t.gzhead.extra && t.gzhead.extra.length && (A(t, t.gzhead.extra.length & 255), A(t, t.gzhead.extra.length >> 8 & 255)), t.gzhead.hcrc && (e.adler = R(e.adler, t.pending_buf, t.pending, 0)), t.gzindex = 0, t.status = Rt;
1363
- else if (A(t, 0), A(t, 0), A(t, 0), A(t, 0), A(t, 0), A(t, t.level === 9 ? 2 : t.strategy >= We || t.level < 2 ? 4 : 0), A(t, oa), t.status = oe, V(e), t.pending !== 0)
1364
- return t.last_flush = -1, B;
1365
- }
1366
- if (t.status === Rt) {
1367
- if (t.gzhead.extra) {
1368
- let a = t.pending, r = (t.gzhead.extra.length & 65535) - t.gzindex;
1369
- for (; t.pending + r > t.pending_buf_size; ) {
1370
- let l = t.pending_buf_size - t.pending;
1371
- if (t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex, t.gzindex + l), t.pending), t.pending = t.pending_buf_size, t.gzhead.hcrc && t.pending > a && (e.adler = R(e.adler, t.pending_buf, t.pending - a, a)), t.gzindex += l, V(e), t.pending !== 0)
1372
- return t.last_flush = -1, B;
1373
- a = 0, r -= l;
1374
- }
1375
- let o = new Uint8Array(t.gzhead.extra);
1376
- t.pending_buf.set(o.subarray(t.gzindex, t.gzindex + r), t.pending), t.pending += r, t.gzhead.hcrc && t.pending > a && (e.adler = R(e.adler, t.pending_buf, t.pending - a, a)), t.gzindex = 0;
1377
- }
1378
- t.status = Bt;
1379
- }
1380
- if (t.status === Bt) {
1381
- if (t.gzhead.name) {
1382
- let a = t.pending, r;
1383
- do {
1384
- if (t.pending === t.pending_buf_size) {
1385
- if (t.gzhead.hcrc && t.pending > a && (e.adler = R(e.adler, t.pending_buf, t.pending - a, a)), V(e), t.pending !== 0)
1386
- return t.last_flush = -1, B;
1387
- a = 0;
1388
- }
1389
- t.gzindex < t.gzhead.name.length ? r = t.gzhead.name.charCodeAt(t.gzindex++) & 255 : r = 0, A(t, r);
1390
- } while (r !== 0);
1391
- t.gzhead.hcrc && t.pending > a && (e.adler = R(e.adler, t.pending_buf, t.pending - a, a)), t.gzindex = 0;
1392
- }
1393
- t.status = Ut;
1394
- }
1395
- if (t.status === Ut) {
1396
- if (t.gzhead.comment) {
1397
- let a = t.pending, r;
1398
- do {
1399
- if (t.pending === t.pending_buf_size) {
1400
- if (t.gzhead.hcrc && t.pending > a && (e.adler = R(e.adler, t.pending_buf, t.pending - a, a)), V(e), t.pending !== 0)
1401
- return t.last_flush = -1, B;
1402
- a = 0;
1403
- }
1404
- t.gzindex < t.gzhead.comment.length ? r = t.gzhead.comment.charCodeAt(t.gzindex++) & 255 : r = 0, A(t, r);
1405
- } while (r !== 0);
1406
- t.gzhead.hcrc && t.pending > a && (e.adler = R(e.adler, t.pending_buf, t.pending - a, a));
1407
- }
1408
- t.status = Dt;
1409
- }
1410
- if (t.status === Dt) {
1411
- if (t.gzhead.hcrc) {
1412
- if (t.pending + 2 > t.pending_buf_size && (V(e), t.pending !== 0))
1413
- return t.last_flush = -1, B;
1414
- A(t, e.adler & 255), A(t, e.adler >> 8 & 255), e.adler = 0;
1415
- }
1416
- if (t.status = oe, V(e), t.pending !== 0)
1417
- return t.last_flush = -1, B;
1418
- }
1419
- if (e.avail_in !== 0 || t.lookahead !== 0 || n !== te && t.status !== Se) {
1420
- let a = t.level === 0 ? ui(t, n) : t.strategy === We ? ua(t, n) : t.strategy === Gr ? fa(t, n) : Ne[t.level].func(t, n);
1421
- if ((a === fe || a === ke) && (t.status = Se), a === U || a === fe)
1422
- return e.avail_out === 0 && (t.last_flush = -1), B;
1423
- if (a === ve && (n === Zr ? Pr(t) : n !== sn && (Ot(t, 0, 0, !1), n === xr && (q(t.head), t.lookahead === 0 && (t.strstart = 0, t.block_start = 0, t.insert = 0))), V(e), e.avail_out === 0))
1424
- return t.last_flush = -1, B;
1425
- }
1426
- return n !== L ? B : t.wrap <= 0 ? ln : (t.wrap === 2 ? (A(t, e.adler & 255), A(t, e.adler >> 8 & 255), A(t, e.adler >> 16 & 255), A(t, e.adler >> 24 & 255), A(t, e.total_in & 255), A(t, e.total_in >> 8 & 255), A(t, e.total_in >> 16 & 255), A(t, e.total_in >> 24 & 255)) : (Ce(t, e.adler >>> 16), Ce(t, e.adler & 65535)), V(e), t.wrap > 0 && (t.wrap = -t.wrap), t.pending !== 0 ? B : ln);
1427
- }, ba = (e) => {
1428
- if (Me(e))
1429
- return G;
1430
- const n = e.state.status;
1431
- return e.state = null, n === oe ? se(e, Mr) : B;
1432
- }, ga = (e, n) => {
1433
- let t = n.length;
1434
- if (Me(e))
1435
- return G;
1436
- const i = e.state, a = i.wrap;
1437
- if (a === 2 || a === 1 && i.status !== we || i.lookahead)
1438
- return G;
1439
- if (a === 1 && (e.adler = Ue(e.adler, n, t, 0)), i.wrap = 0, t >= i.w_size) {
1440
- a === 0 && (q(i.head), i.strstart = 0, i.block_start = 0, i.insert = 0);
1441
- let u = new Uint8Array(i.w_size);
1442
- u.set(n.subarray(t - i.w_size, t), 0), n = u, t = i.w_size;
1443
- }
1444
- const r = e.avail_in, o = e.next_in, l = e.input;
1445
- for (e.avail_in = t, e.next_in = 0, e.input = n, me(i); i.lookahead >= T; ) {
1446
- let u = i.strstart, s = i.lookahead - (T - 1);
1447
- do
1448
- i.ins_h = ne(i, i.ins_h, i.window[u + T - 1]), i.prev[u & i.w_mask] = i.head[i.ins_h], i.head[i.ins_h] = u, u++;
1449
- while (--s);
1450
- i.strstart = u, i.lookahead = T - 1, me(i);
1451
- }
1452
- return i.strstart += i.lookahead, i.block_start = i.strstart, i.insert = i.lookahead, i.lookahead = 0, i.match_length = i.prev_length = T - 1, i.match_available = 0, e.next_in = o, e.input = l, e.avail_in = r, i.wrap = a, B;
1453
- };
1454
- var wa = pa, ma = di, ya = ci, va = hi, ka = da, $a = _a, Ea = ba, Ca = ga, Sa = "pako deflate (from Nodeca project)", Te = {
1455
- deflateInit: wa,
1456
- deflateInit2: ma,
1457
- deflateReset: ya,
1458
- deflateResetKeep: va,
1459
- deflateSetHeader: ka,
1460
- deflate: $a,
1461
- deflateEnd: Ea,
1462
- deflateSetDictionary: Ca,
1463
- deflateInfo: Sa
1464
- };
1465
- const Na = (e, n) => Object.prototype.hasOwnProperty.call(e, n);
1466
- var Ia = function(e) {
1467
- const n = Array.prototype.slice.call(arguments, 1);
1468
- for (; n.length; ) {
1469
- const t = n.shift();
1470
- if (t) {
1471
- if (typeof t != "object")
1472
- throw new TypeError(t + "must be non-object");
1473
- for (const i in t)
1474
- Na(t, i) && (e[i] = t[i]);
1475
- }
1476
- }
1477
- return e;
1478
- }, Ta = (e) => {
1479
- let n = 0;
1480
- for (let i = 0, a = e.length; i < a; i++)
1481
- n += e[i].length;
1482
- const t = new Uint8Array(n);
1483
- for (let i = 0, a = 0, r = e.length; i < r; i++) {
1484
- let o = e[i];
1485
- t.set(o, a), a += o.length;
1486
- }
1487
- return t;
1488
- }, ft = {
1489
- assign: Ia,
1490
- flattenChunks: Ta
1491
- };
1492
- let pi = !0;
1493
- try {
1494
- String.fromCharCode.apply(null, new Uint8Array(1));
1495
- } catch {
1496
- pi = !1;
1497
- }
1498
- const De = new Uint8Array(256);
1499
- for (let e = 0; e < 256; e++)
1500
- De[e] = e >= 252 ? 6 : e >= 248 ? 5 : e >= 240 ? 4 : e >= 224 ? 3 : e >= 192 ? 2 : 1;
1501
- De[254] = De[254] = 1;
1502
- var Aa = (e) => {
1503
- if (typeof TextEncoder == "function" && TextEncoder.prototype.encode)
1504
- return new TextEncoder().encode(e);
1505
- let n, t, i, a, r, o = e.length, l = 0;
1506
- for (a = 0; a < o; a++)
1507
- t = e.charCodeAt(a), (t & 64512) === 55296 && a + 1 < o && (i = e.charCodeAt(a + 1), (i & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (i - 56320), a++)), l += t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4;
1508
- for (n = new Uint8Array(l), r = 0, a = 0; r < l; a++)
1509
- t = e.charCodeAt(a), (t & 64512) === 55296 && a + 1 < o && (i = e.charCodeAt(a + 1), (i & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (i - 56320), a++)), t < 128 ? n[r++] = t : t < 2048 ? (n[r++] = 192 | t >>> 6, n[r++] = 128 | t & 63) : t < 65536 ? (n[r++] = 224 | t >>> 12, n[r++] = 128 | t >>> 6 & 63, n[r++] = 128 | t & 63) : (n[r++] = 240 | t >>> 18, n[r++] = 128 | t >>> 12 & 63, n[r++] = 128 | t >>> 6 & 63, n[r++] = 128 | t & 63);
1510
- return n;
1511
- };
1512
- const Oa = (e, n) => {
1513
- if (n < 65534 && e.subarray && pi)
1514
- return String.fromCharCode.apply(null, e.length === n ? e : e.subarray(0, n));
1515
- let t = "";
1516
- for (let i = 0; i < n; i++)
1517
- t += String.fromCharCode(e[i]);
1518
- return t;
1519
- };
1520
- var za = (e, n) => {
1521
- const t = n || e.length;
1522
- if (typeof TextDecoder == "function" && TextDecoder.prototype.decode)
1523
- return new TextDecoder().decode(e.subarray(0, n));
1524
- let i, a;
1525
- const r = new Array(t * 2);
1526
- for (a = 0, i = 0; i < t; ) {
1527
- let o = e[i++];
1528
- if (o < 128) {
1529
- r[a++] = o;
1530
- continue;
1531
- }
1532
- let l = De[o];
1533
- if (l > 4) {
1534
- r[a++] = 65533, i += l - 1;
1535
- continue;
1536
- }
1537
- for (o &= l === 2 ? 31 : l === 3 ? 15 : 7; l > 1 && i < t; )
1538
- o = o << 6 | e[i++] & 63, l--;
1539
- if (l > 1) {
1540
- r[a++] = 65533;
1541
- continue;
1542
- }
1543
- o < 65536 ? r[a++] = o : (o -= 65536, r[a++] = 55296 | o >> 10 & 1023, r[a++] = 56320 | o & 1023);
1544
- }
1545
- return Oa(r, a);
1546
- }, Ra = (e, n) => {
1547
- n = n || e.length, n > e.length && (n = e.length);
1548
- let t = n - 1;
1549
- for (; t >= 0 && (e[t] & 192) === 128; )
1550
- t--;
1551
- return t < 0 || t === 0 ? n : t + De[e[t]] > n ? t : n;
1552
- }, Ve = {
1553
- string2buf: Aa,
1554
- buf2string: za,
1555
- utf8border: Ra
1556
- };
1557
- function Ba() {
1558
- this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0;
1559
- }
1560
- var _i = Ba;
1561
- const bi = Object.prototype.toString, {
1562
- Z_NO_FLUSH: Ua,
1563
- Z_SYNC_FLUSH: Da,
1564
- Z_FULL_FLUSH: Va,
1565
- Z_FINISH: Fa,
1566
- Z_OK: rt,
1567
- Z_STREAM_END: La,
1568
- Z_DEFAULT_COMPRESSION: Pa,
1569
- Z_DEFAULT_STRATEGY: Za,
1570
- Z_DEFLATED: xa
1571
- } = xe;
1572
- function Gt(e) {
1573
- this.options = ft.assign({
1574
- level: Pa,
1575
- method: xa,
1576
- chunkSize: 16384,
1577
- windowBits: 15,
1578
- memLevel: 8,
1579
- strategy: Za
1580
- }, e || {});
1581
- let n = this.options;
1582
- n.raw && n.windowBits > 0 ? n.windowBits = -n.windowBits : n.gzip && n.windowBits > 0 && n.windowBits < 16 && (n.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new _i(), this.strm.avail_out = 0;
1583
- let t = Te.deflateInit2(
1584
- this.strm,
1585
- n.level,
1586
- n.method,
1587
- n.windowBits,
1588
- n.memLevel,
1589
- n.strategy
1590
- );
1591
- if (t !== rt)
1592
- throw new Error(ge[t]);
1593
- if (n.header && Te.deflateSetHeader(this.strm, n.header), n.dictionary) {
1594
- let i;
1595
- if (typeof n.dictionary == "string" ? i = Ve.string2buf(n.dictionary) : bi.call(n.dictionary) === "[object ArrayBuffer]" ? i = new Uint8Array(n.dictionary) : i = n.dictionary, t = Te.deflateSetDictionary(this.strm, i), t !== rt)
1596
- throw new Error(ge[t]);
1597
- this._dict_set = !0;
1598
- }
1599
- }
1600
- Gt.prototype.push = function(e, n) {
1601
- const t = this.strm, i = this.options.chunkSize;
1602
- let a, r;
1603
- if (this.ended)
1604
- return !1;
1605
- for (n === ~~n ? r = n : r = n === !0 ? Fa : Ua, typeof e == "string" ? t.input = Ve.string2buf(e) : bi.call(e) === "[object ArrayBuffer]" ? t.input = new Uint8Array(e) : t.input = e, t.next_in = 0, t.avail_in = t.input.length; ; ) {
1606
- if (t.avail_out === 0 && (t.output = new Uint8Array(i), t.next_out = 0, t.avail_out = i), (r === Da || r === Va) && t.avail_out <= 6) {
1607
- this.onData(t.output.subarray(0, t.next_out)), t.avail_out = 0;
1608
- continue;
1609
- }
1610
- if (a = Te.deflate(t, r), a === La)
1611
- return t.next_out > 0 && this.onData(t.output.subarray(0, t.next_out)), a = Te.deflateEnd(this.strm), this.onEnd(a), this.ended = !0, a === rt;
1612
- if (t.avail_out === 0) {
1613
- this.onData(t.output);
1614
- continue;
1615
- }
1616
- if (r > 0 && t.next_out > 0) {
1617
- this.onData(t.output.subarray(0, t.next_out)), t.avail_out = 0;
1618
- continue;
1619
- }
1620
- if (t.avail_in === 0) break;
1621
- }
1622
- return !0;
1623
- };
1624
- Gt.prototype.onData = function(e) {
1625
- this.chunks.push(e);
1626
- };
1627
- Gt.prototype.onEnd = function(e) {
1628
- e === rt && (this.result = ft.flattenChunks(this.chunks)), this.chunks = [], this.err = e, this.msg = this.strm.msg;
1629
- };
1630
- const Xe = 16209, Ma = 16191;
1631
- var Ha = function(n, t) {
1632
- let i, a, r, o, l, u, s, f, _, c, h, d, g, k, y, E, C, p, $, N, b, m, w, v;
1633
- const I = n.state;
1634
- i = n.next_in, w = n.input, a = i + (n.avail_in - 5), r = n.next_out, v = n.output, o = r - (t - n.avail_out), l = r + (n.avail_out - 257), u = I.dmax, s = I.wsize, f = I.whave, _ = I.wnext, c = I.window, h = I.hold, d = I.bits, g = I.lencode, k = I.distcode, y = (1 << I.lenbits) - 1, E = (1 << I.distbits) - 1;
1635
- e:
1636
- do {
1637
- d < 15 && (h += w[i++] << d, d += 8, h += w[i++] << d, d += 8), C = g[h & y];
1638
- t:
1639
- for (; ; ) {
1640
- if (p = C >>> 24, h >>>= p, d -= p, p = C >>> 16 & 255, p === 0)
1641
- v[r++] = C & 65535;
1642
- else if (p & 16) {
1643
- $ = C & 65535, p &= 15, p && (d < p && (h += w[i++] << d, d += 8), $ += h & (1 << p) - 1, h >>>= p, d -= p), d < 15 && (h += w[i++] << d, d += 8, h += w[i++] << d, d += 8), C = k[h & E];
1644
- n:
1645
- for (; ; ) {
1646
- if (p = C >>> 24, h >>>= p, d -= p, p = C >>> 16 & 255, p & 16) {
1647
- if (N = C & 65535, p &= 15, d < p && (h += w[i++] << d, d += 8, d < p && (h += w[i++] << d, d += 8)), N += h & (1 << p) - 1, N > u) {
1648
- n.msg = "invalid distance too far back", I.mode = Xe;
1649
- break e;
1650
- }
1651
- if (h >>>= p, d -= p, p = r - o, N > p) {
1652
- if (p = N - p, p > f && I.sane) {
1653
- n.msg = "invalid distance too far back", I.mode = Xe;
1654
- break e;
1655
- }
1656
- if (b = 0, m = c, _ === 0) {
1657
- if (b += s - p, p < $) {
1658
- $ -= p;
1659
- do
1660
- v[r++] = c[b++];
1661
- while (--p);
1662
- b = r - N, m = v;
1663
- }
1664
- } else if (_ < p) {
1665
- if (b += s + _ - p, p -= _, p < $) {
1666
- $ -= p;
1667
- do
1668
- v[r++] = c[b++];
1669
- while (--p);
1670
- if (b = 0, _ < $) {
1671
- p = _, $ -= p;
1672
- do
1673
- v[r++] = c[b++];
1674
- while (--p);
1675
- b = r - N, m = v;
1676
- }
1677
- }
1678
- } else if (b += _ - p, p < $) {
1679
- $ -= p;
1680
- do
1681
- v[r++] = c[b++];
1682
- while (--p);
1683
- b = r - N, m = v;
1684
- }
1685
- for (; $ > 2; )
1686
- v[r++] = m[b++], v[r++] = m[b++], v[r++] = m[b++], $ -= 3;
1687
- $ && (v[r++] = m[b++], $ > 1 && (v[r++] = m[b++]));
1688
- } else {
1689
- b = r - N;
1690
- do
1691
- v[r++] = v[b++], v[r++] = v[b++], v[r++] = v[b++], $ -= 3;
1692
- while ($ > 2);
1693
- $ && (v[r++] = v[b++], $ > 1 && (v[r++] = v[b++]));
1694
- }
1695
- } else if (p & 64) {
1696
- n.msg = "invalid distance code", I.mode = Xe;
1697
- break e;
1698
- } else {
1699
- C = k[(C & 65535) + (h & (1 << p) - 1)];
1700
- continue n;
1701
- }
1702
- break;
1703
- }
1704
- } else if (p & 64)
1705
- if (p & 32) {
1706
- I.mode = Ma;
1707
- break e;
1708
- } else {
1709
- n.msg = "invalid literal/length code", I.mode = Xe;
1710
- break e;
1711
- }
1712
- else {
1713
- C = g[(C & 65535) + (h & (1 << p) - 1)];
1714
- continue t;
1715
- }
1716
- break;
1717
- }
1718
- } while (i < a && r < l);
1719
- $ = d >> 3, i -= $, d -= $ << 3, h &= (1 << d) - 1, n.next_in = i, n.next_out = r, n.avail_in = i < a ? 5 + (a - i) : 5 - (i - a), n.avail_out = r < l ? 257 + (l - r) : 257 - (r - l), I.hold = h, I.bits = d;
1720
- };
1721
- const de = 15, un = 852, hn = 592, cn = 0, gt = 1, dn = 2, ja = new Uint16Array([
1722
- /* Length codes 257..285 base */
1723
- 3,
1724
- 4,
1725
- 5,
1726
- 6,
1727
- 7,
1728
- 8,
1729
- 9,
1730
- 10,
1731
- 11,
1732
- 13,
1733
- 15,
1734
- 17,
1735
- 19,
1736
- 23,
1737
- 27,
1738
- 31,
1739
- 35,
1740
- 43,
1741
- 51,
1742
- 59,
1743
- 67,
1744
- 83,
1745
- 99,
1746
- 115,
1747
- 131,
1748
- 163,
1749
- 195,
1750
- 227,
1751
- 258,
1752
- 0,
1753
- 0
1754
- ]), Ga = new Uint8Array([
1755
- /* Length codes 257..285 extra */
1756
- 16,
1757
- 16,
1758
- 16,
1759
- 16,
1760
- 16,
1761
- 16,
1762
- 16,
1763
- 16,
1764
- 17,
1765
- 17,
1766
- 17,
1767
- 17,
1768
- 18,
1769
- 18,
1770
- 18,
1771
- 18,
1772
- 19,
1773
- 19,
1774
- 19,
1775
- 19,
1776
- 20,
1777
- 20,
1778
- 20,
1779
- 20,
1780
- 21,
1781
- 21,
1782
- 21,
1783
- 21,
1784
- 16,
1785
- 72,
1786
- 78
1787
- ]), Ya = new Uint16Array([
1788
- /* Distance codes 0..29 base */
1789
- 1,
1790
- 2,
1791
- 3,
1792
- 4,
1793
- 5,
1794
- 7,
1795
- 9,
1796
- 13,
1797
- 17,
1798
- 25,
1799
- 33,
1800
- 49,
1801
- 65,
1802
- 97,
1803
- 129,
1804
- 193,
1805
- 257,
1806
- 385,
1807
- 513,
1808
- 769,
1809
- 1025,
1810
- 1537,
1811
- 2049,
1812
- 3073,
1813
- 4097,
1814
- 6145,
1815
- 8193,
1816
- 12289,
1817
- 16385,
1818
- 24577,
1819
- 0,
1820
- 0
1821
- ]), Ka = new Uint8Array([
1822
- /* Distance codes 0..29 extra */
1823
- 16,
1824
- 16,
1825
- 16,
1826
- 16,
1827
- 17,
1828
- 17,
1829
- 18,
1830
- 18,
1831
- 19,
1832
- 19,
1833
- 20,
1834
- 20,
1835
- 21,
1836
- 21,
1837
- 22,
1838
- 22,
1839
- 23,
1840
- 23,
1841
- 24,
1842
- 24,
1843
- 25,
1844
- 25,
1845
- 26,
1846
- 26,
1847
- 27,
1848
- 27,
1849
- 28,
1850
- 28,
1851
- 29,
1852
- 29,
1853
- 64,
1854
- 64
1855
- ]), Wa = (e, n, t, i, a, r, o, l) => {
1856
- const u = l.bits;
1857
- let s = 0, f = 0, _ = 0, c = 0, h = 0, d = 0, g = 0, k = 0, y = 0, E = 0, C, p, $, N, b, m = null, w;
1858
- const v = new Uint16Array(de + 1), I = new Uint16Array(de + 1);
1859
- let ie = null, Jt, je, Ge;
1860
- for (s = 0; s <= de; s++)
1861
- v[s] = 0;
1862
- for (f = 0; f < i; f++)
1863
- v[n[t + f]]++;
1864
- for (h = u, c = de; c >= 1 && v[c] === 0; c--)
1865
- ;
1866
- if (h > c && (h = c), c === 0)
1867
- return a[r++] = 1 << 24 | 64 << 16 | 0, a[r++] = 1 << 24 | 64 << 16 | 0, l.bits = 1, 0;
1868
- for (_ = 1; _ < c && v[_] === 0; _++)
1869
- ;
1870
- for (h < _ && (h = _), k = 1, s = 1; s <= de; s++)
1871
- if (k <<= 1, k -= v[s], k < 0)
1872
- return -1;
1873
- if (k > 0 && (e === cn || c !== 1))
1874
- return -1;
1875
- for (I[1] = 0, s = 1; s < de; s++)
1876
- I[s + 1] = I[s] + v[s];
1877
- for (f = 0; f < i; f++)
1878
- n[t + f] !== 0 && (o[I[n[t + f]]++] = f);
1879
- if (e === cn ? (m = ie = o, w = 20) : e === gt ? (m = ja, ie = Ga, w = 257) : (m = Ya, ie = Ka, w = 0), E = 0, f = 0, s = _, b = r, d = h, g = 0, $ = -1, y = 1 << h, N = y - 1, e === gt && y > un || e === dn && y > hn)
1880
- return 1;
1881
- for (; ; ) {
1882
- Jt = s - g, o[f] + 1 < w ? (je = 0, Ge = o[f]) : o[f] >= w ? (je = ie[o[f] - w], Ge = m[o[f] - w]) : (je = 96, Ge = 0), C = 1 << s - g, p = 1 << d, _ = p;
1883
- do
1884
- p -= C, a[b + (E >> g) + p] = Jt << 24 | je << 16 | Ge | 0;
1885
- while (p !== 0);
1886
- for (C = 1 << s - 1; E & C; )
1887
- C >>= 1;
1888
- if (C !== 0 ? (E &= C - 1, E += C) : E = 0, f++, --v[s] === 0) {
1889
- if (s === c)
1890
- break;
1891
- s = n[t + o[f]];
1892
- }
1893
- if (s > h && (E & N) !== $) {
1894
- for (g === 0 && (g = h), b += _, d = s - g, k = 1 << d; d + g < c && (k -= v[d + g], !(k <= 0)); )
1895
- d++, k <<= 1;
1896
- if (y += 1 << d, e === gt && y > un || e === dn && y > hn)
1897
- return 1;
1898
- $ = E & N, a[$] = h << 24 | d << 16 | b - r | 0;
1899
- }
1900
- }
1901
- return E !== 0 && (a[b + E] = s - g << 24 | 64 << 16 | 0), l.bits = h, 0;
1902
- };
1903
- var Ae = Wa;
1904
- const Xa = 0, gi = 1, wi = 2, {
1905
- Z_FINISH: pn,
1906
- Z_BLOCK: qa,
1907
- Z_TREES: qe,
1908
- Z_OK: ue,
1909
- Z_STREAM_END: Ja,
1910
- Z_NEED_DICT: Qa,
1911
- Z_STREAM_ERROR: P,
1912
- Z_DATA_ERROR: mi,
1913
- Z_MEM_ERROR: yi,
1914
- Z_BUF_ERROR: eo,
1915
- Z_DEFLATED: _n
1916
- } = xe, ut = 16180, bn = 16181, gn = 16182, wn = 16183, mn = 16184, yn = 16185, vn = 16186, kn = 16187, $n = 16188, En = 16189, at = 16190, K = 16191, wt = 16192, Cn = 16193, mt = 16194, Sn = 16195, Nn = 16196, In = 16197, Tn = 16198, Je = 16199, Qe = 16200, An = 16201, On = 16202, zn = 16203, Rn = 16204, Bn = 16205, yt = 16206, Un = 16207, Dn = 16208, O = 16209, vi = 16210, ki = 16211, to = 852, no = 592, io = 15, ro = io, Vn = (e) => (e >>> 24 & 255) + (e >>> 8 & 65280) + ((e & 65280) << 8) + ((e & 255) << 24);
1917
- function ao() {
1918
- this.strm = null, this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
1919
- }
1920
- const he = (e) => {
1921
- if (!e)
1922
- return 1;
1923
- const n = e.state;
1924
- return !n || n.strm !== e || n.mode < ut || n.mode > ki ? 1 : 0;
1925
- }, $i = (e) => {
1926
- if (he(e))
1927
- return P;
1928
- const n = e.state;
1929
- return e.total_in = e.total_out = n.total = 0, e.msg = "", n.wrap && (e.adler = n.wrap & 1), n.mode = ut, n.last = 0, n.havedict = 0, n.flags = -1, n.dmax = 32768, n.head = null, n.hold = 0, n.bits = 0, n.lencode = n.lendyn = new Int32Array(to), n.distcode = n.distdyn = new Int32Array(no), n.sane = 1, n.back = -1, ue;
1930
- }, Ei = (e) => {
1931
- if (he(e))
1932
- return P;
1933
- const n = e.state;
1934
- return n.wsize = 0, n.whave = 0, n.wnext = 0, $i(e);
1935
- }, Ci = (e, n) => {
1936
- let t;
1937
- if (he(e))
1938
- return P;
1939
- const i = e.state;
1940
- return n < 0 ? (t = 0, n = -n) : (t = (n >> 4) + 5, n < 48 && (n &= 15)), n && (n < 8 || n > 15) ? P : (i.window !== null && i.wbits !== n && (i.window = null), i.wrap = t, i.wbits = n, Ei(e));
1941
- }, Si = (e, n) => {
1942
- if (!e)
1943
- return P;
1944
- const t = new ao();
1945
- e.state = t, t.strm = e, t.window = null, t.mode = ut;
1946
- const i = Ci(e, n);
1947
- return i !== ue && (e.state = null), i;
1948
- }, oo = (e) => Si(e, ro);
1949
- let Fn = !0, vt, kt;
1950
- const so = (e) => {
1951
- if (Fn) {
1952
- vt = new Int32Array(512), kt = new Int32Array(32);
1953
- let n = 0;
1954
- for (; n < 144; )
1955
- e.lens[n++] = 8;
1956
- for (; n < 256; )
1957
- e.lens[n++] = 9;
1958
- for (; n < 280; )
1959
- e.lens[n++] = 7;
1960
- for (; n < 288; )
1961
- e.lens[n++] = 8;
1962
- for (Ae(gi, e.lens, 0, 288, vt, 0, e.work, { bits: 9 }), n = 0; n < 32; )
1963
- e.lens[n++] = 5;
1964
- Ae(wi, e.lens, 0, 32, kt, 0, e.work, { bits: 5 }), Fn = !1;
1965
- }
1966
- e.lencode = vt, e.lenbits = 9, e.distcode = kt, e.distbits = 5;
1967
- }, Ni = (e, n, t, i) => {
1968
- let a;
1969
- const r = e.state;
1970
- return r.window === null && (r.wsize = 1 << r.wbits, r.wnext = 0, r.whave = 0, r.window = new Uint8Array(r.wsize)), i >= r.wsize ? (r.window.set(n.subarray(t - r.wsize, t), 0), r.wnext = 0, r.whave = r.wsize) : (a = r.wsize - r.wnext, a > i && (a = i), r.window.set(n.subarray(t - i, t - i + a), r.wnext), i -= a, i ? (r.window.set(n.subarray(t - i, t), 0), r.wnext = i, r.whave = r.wsize) : (r.wnext += a, r.wnext === r.wsize && (r.wnext = 0), r.whave < r.wsize && (r.whave += a))), 0;
1971
- }, lo = (e, n) => {
1972
- let t, i, a, r, o, l, u, s, f, _, c, h, d, g, k = 0, y, E, C, p, $, N, b, m;
1973
- const w = new Uint8Array(4);
1974
- let v, I;
1975
- const ie = (
1976
- /* permutation of code lengths */
1977
- new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
1978
- );
1979
- if (he(e) || !e.output || !e.input && e.avail_in !== 0)
1980
- return P;
1981
- t = e.state, t.mode === K && (t.mode = wt), o = e.next_out, a = e.output, u = e.avail_out, r = e.next_in, i = e.input, l = e.avail_in, s = t.hold, f = t.bits, _ = l, c = u, m = ue;
1982
- e:
1983
- for (; ; )
1984
- switch (t.mode) {
1985
- case ut:
1986
- if (t.wrap === 0) {
1987
- t.mode = wt;
1988
- break;
1989
- }
1990
- for (; f < 16; ) {
1991
- if (l === 0)
1992
- break e;
1993
- l--, s += i[r++] << f, f += 8;
1994
- }
1995
- if (t.wrap & 2 && s === 35615) {
1996
- t.wbits === 0 && (t.wbits = 15), t.check = 0, w[0] = s & 255, w[1] = s >>> 8 & 255, t.check = R(t.check, w, 2, 0), s = 0, f = 0, t.mode = bn;
1997
- break;
1998
- }
1999
- if (t.head && (t.head.done = !1), !(t.wrap & 1) || /* check if zlib header allowed */
2000
- (((s & 255) << 8) + (s >> 8)) % 31) {
2001
- e.msg = "incorrect header check", t.mode = O;
2002
- break;
2003
- }
2004
- if ((s & 15) !== _n) {
2005
- e.msg = "unknown compression method", t.mode = O;
2006
- break;
2007
- }
2008
- if (s >>>= 4, f -= 4, b = (s & 15) + 8, t.wbits === 0 && (t.wbits = b), b > 15 || b > t.wbits) {
2009
- e.msg = "invalid window size", t.mode = O;
2010
- break;
2011
- }
2012
- t.dmax = 1 << t.wbits, t.flags = 0, e.adler = t.check = 1, t.mode = s & 512 ? En : K, s = 0, f = 0;
2013
- break;
2014
- case bn:
2015
- for (; f < 16; ) {
2016
- if (l === 0)
2017
- break e;
2018
- l--, s += i[r++] << f, f += 8;
2019
- }
2020
- if (t.flags = s, (t.flags & 255) !== _n) {
2021
- e.msg = "unknown compression method", t.mode = O;
2022
- break;
2023
- }
2024
- if (t.flags & 57344) {
2025
- e.msg = "unknown header flags set", t.mode = O;
2026
- break;
2027
- }
2028
- t.head && (t.head.text = s >> 8 & 1), t.flags & 512 && t.wrap & 4 && (w[0] = s & 255, w[1] = s >>> 8 & 255, t.check = R(t.check, w, 2, 0)), s = 0, f = 0, t.mode = gn;
2029
- case gn:
2030
- for (; f < 32; ) {
2031
- if (l === 0)
2032
- break e;
2033
- l--, s += i[r++] << f, f += 8;
2034
- }
2035
- t.head && (t.head.time = s), t.flags & 512 && t.wrap & 4 && (w[0] = s & 255, w[1] = s >>> 8 & 255, w[2] = s >>> 16 & 255, w[3] = s >>> 24 & 255, t.check = R(t.check, w, 4, 0)), s = 0, f = 0, t.mode = wn;
2036
- case wn:
2037
- for (; f < 16; ) {
2038
- if (l === 0)
2039
- break e;
2040
- l--, s += i[r++] << f, f += 8;
2041
- }
2042
- t.head && (t.head.xflags = s & 255, t.head.os = s >> 8), t.flags & 512 && t.wrap & 4 && (w[0] = s & 255, w[1] = s >>> 8 & 255, t.check = R(t.check, w, 2, 0)), s = 0, f = 0, t.mode = mn;
2043
- case mn:
2044
- if (t.flags & 1024) {
2045
- for (; f < 16; ) {
2046
- if (l === 0)
2047
- break e;
2048
- l--, s += i[r++] << f, f += 8;
2049
- }
2050
- t.length = s, t.head && (t.head.extra_len = s), t.flags & 512 && t.wrap & 4 && (w[0] = s & 255, w[1] = s >>> 8 & 255, t.check = R(t.check, w, 2, 0)), s = 0, f = 0;
2051
- } else t.head && (t.head.extra = null);
2052
- t.mode = yn;
2053
- case yn:
2054
- if (t.flags & 1024 && (h = t.length, h > l && (h = l), h && (t.head && (b = t.head.extra_len - t.length, t.head.extra || (t.head.extra = new Uint8Array(t.head.extra_len)), t.head.extra.set(
2055
- i.subarray(
2056
- r,
2057
- // extra field is limited to 65536 bytes
2058
- // - no need for additional size check
2059
- r + h
2060
- ),
2061
- /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
2062
- b
2063
- )), t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, i, h, r)), l -= h, r += h, t.length -= h), t.length))
2064
- break e;
2065
- t.length = 0, t.mode = vn;
2066
- case vn:
2067
- if (t.flags & 2048) {
2068
- if (l === 0)
2069
- break e;
2070
- h = 0;
2071
- do
2072
- b = i[r + h++], t.head && b && t.length < 65536 && (t.head.name += String.fromCharCode(b));
2073
- while (b && h < l);
2074
- if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, i, h, r)), l -= h, r += h, b)
2075
- break e;
2076
- } else t.head && (t.head.name = null);
2077
- t.length = 0, t.mode = kn;
2078
- case kn:
2079
- if (t.flags & 4096) {
2080
- if (l === 0)
2081
- break e;
2082
- h = 0;
2083
- do
2084
- b = i[r + h++], t.head && b && t.length < 65536 && (t.head.comment += String.fromCharCode(b));
2085
- while (b && h < l);
2086
- if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, i, h, r)), l -= h, r += h, b)
2087
- break e;
2088
- } else t.head && (t.head.comment = null);
2089
- t.mode = $n;
2090
- case $n:
2091
- if (t.flags & 512) {
2092
- for (; f < 16; ) {
2093
- if (l === 0)
2094
- break e;
2095
- l--, s += i[r++] << f, f += 8;
2096
- }
2097
- if (t.wrap & 4 && s !== (t.check & 65535)) {
2098
- e.msg = "header crc mismatch", t.mode = O;
2099
- break;
2100
- }
2101
- s = 0, f = 0;
2102
- }
2103
- t.head && (t.head.hcrc = t.flags >> 9 & 1, t.head.done = !0), e.adler = t.check = 0, t.mode = K;
2104
- break;
2105
- case En:
2106
- for (; f < 32; ) {
2107
- if (l === 0)
2108
- break e;
2109
- l--, s += i[r++] << f, f += 8;
2110
- }
2111
- e.adler = t.check = Vn(s), s = 0, f = 0, t.mode = at;
2112
- case at:
2113
- if (t.havedict === 0)
2114
- return e.next_out = o, e.avail_out = u, e.next_in = r, e.avail_in = l, t.hold = s, t.bits = f, Qa;
2115
- e.adler = t.check = 1, t.mode = K;
2116
- case K:
2117
- if (n === qa || n === qe)
2118
- break e;
2119
- case wt:
2120
- if (t.last) {
2121
- s >>>= f & 7, f -= f & 7, t.mode = yt;
2122
- break;
2123
- }
2124
- for (; f < 3; ) {
2125
- if (l === 0)
2126
- break e;
2127
- l--, s += i[r++] << f, f += 8;
2128
- }
2129
- switch (t.last = s & 1, s >>>= 1, f -= 1, s & 3) {
2130
- case 0:
2131
- t.mode = Cn;
2132
- break;
2133
- case 1:
2134
- if (so(t), t.mode = Je, n === qe) {
2135
- s >>>= 2, f -= 2;
2136
- break e;
2137
- }
2138
- break;
2139
- case 2:
2140
- t.mode = Nn;
2141
- break;
2142
- case 3:
2143
- e.msg = "invalid block type", t.mode = O;
2144
- }
2145
- s >>>= 2, f -= 2;
2146
- break;
2147
- case Cn:
2148
- for (s >>>= f & 7, f -= f & 7; f < 32; ) {
2149
- if (l === 0)
2150
- break e;
2151
- l--, s += i[r++] << f, f += 8;
2152
- }
2153
- if ((s & 65535) !== (s >>> 16 ^ 65535)) {
2154
- e.msg = "invalid stored block lengths", t.mode = O;
2155
- break;
2156
- }
2157
- if (t.length = s & 65535, s = 0, f = 0, t.mode = mt, n === qe)
2158
- break e;
2159
- case mt:
2160
- t.mode = Sn;
2161
- case Sn:
2162
- if (h = t.length, h) {
2163
- if (h > l && (h = l), h > u && (h = u), h === 0)
2164
- break e;
2165
- a.set(i.subarray(r, r + h), o), l -= h, r += h, u -= h, o += h, t.length -= h;
2166
- break;
2167
- }
2168
- t.mode = K;
2169
- break;
2170
- case Nn:
2171
- for (; f < 14; ) {
2172
- if (l === 0)
2173
- break e;
2174
- l--, s += i[r++] << f, f += 8;
2175
- }
2176
- if (t.nlen = (s & 31) + 257, s >>>= 5, f -= 5, t.ndist = (s & 31) + 1, s >>>= 5, f -= 5, t.ncode = (s & 15) + 4, s >>>= 4, f -= 4, t.nlen > 286 || t.ndist > 30) {
2177
- e.msg = "too many length or distance symbols", t.mode = O;
2178
- break;
2179
- }
2180
- t.have = 0, t.mode = In;
2181
- case In:
2182
- for (; t.have < t.ncode; ) {
2183
- for (; f < 3; ) {
2184
- if (l === 0)
2185
- break e;
2186
- l--, s += i[r++] << f, f += 8;
2187
- }
2188
- t.lens[ie[t.have++]] = s & 7, s >>>= 3, f -= 3;
2189
- }
2190
- for (; t.have < 19; )
2191
- t.lens[ie[t.have++]] = 0;
2192
- if (t.lencode = t.lendyn, t.lenbits = 7, v = { bits: t.lenbits }, m = Ae(Xa, t.lens, 0, 19, t.lencode, 0, t.work, v), t.lenbits = v.bits, m) {
2193
- e.msg = "invalid code lengths set", t.mode = O;
2194
- break;
2195
- }
2196
- t.have = 0, t.mode = Tn;
2197
- case Tn:
2198
- for (; t.have < t.nlen + t.ndist; ) {
2199
- for (; k = t.lencode[s & (1 << t.lenbits) - 1], y = k >>> 24, E = k >>> 16 & 255, C = k & 65535, !(y <= f); ) {
2200
- if (l === 0)
2201
- break e;
2202
- l--, s += i[r++] << f, f += 8;
2203
- }
2204
- if (C < 16)
2205
- s >>>= y, f -= y, t.lens[t.have++] = C;
2206
- else {
2207
- if (C === 16) {
2208
- for (I = y + 2; f < I; ) {
2209
- if (l === 0)
2210
- break e;
2211
- l--, s += i[r++] << f, f += 8;
2212
- }
2213
- if (s >>>= y, f -= y, t.have === 0) {
2214
- e.msg = "invalid bit length repeat", t.mode = O;
2215
- break;
2216
- }
2217
- b = t.lens[t.have - 1], h = 3 + (s & 3), s >>>= 2, f -= 2;
2218
- } else if (C === 17) {
2219
- for (I = y + 3; f < I; ) {
2220
- if (l === 0)
2221
- break e;
2222
- l--, s += i[r++] << f, f += 8;
2223
- }
2224
- s >>>= y, f -= y, b = 0, h = 3 + (s & 7), s >>>= 3, f -= 3;
2225
- } else {
2226
- for (I = y + 7; f < I; ) {
2227
- if (l === 0)
2228
- break e;
2229
- l--, s += i[r++] << f, f += 8;
2230
- }
2231
- s >>>= y, f -= y, b = 0, h = 11 + (s & 127), s >>>= 7, f -= 7;
2232
- }
2233
- if (t.have + h > t.nlen + t.ndist) {
2234
- e.msg = "invalid bit length repeat", t.mode = O;
2235
- break;
2236
- }
2237
- for (; h--; )
2238
- t.lens[t.have++] = b;
2239
- }
2240
- }
2241
- if (t.mode === O)
2242
- break;
2243
- if (t.lens[256] === 0) {
2244
- e.msg = "invalid code -- missing end-of-block", t.mode = O;
2245
- break;
2246
- }
2247
- if (t.lenbits = 9, v = { bits: t.lenbits }, m = Ae(gi, t.lens, 0, t.nlen, t.lencode, 0, t.work, v), t.lenbits = v.bits, m) {
2248
- e.msg = "invalid literal/lengths set", t.mode = O;
2249
- break;
2250
- }
2251
- if (t.distbits = 6, t.distcode = t.distdyn, v = { bits: t.distbits }, m = Ae(wi, t.lens, t.nlen, t.ndist, t.distcode, 0, t.work, v), t.distbits = v.bits, m) {
2252
- e.msg = "invalid distances set", t.mode = O;
2253
- break;
2254
- }
2255
- if (t.mode = Je, n === qe)
2256
- break e;
2257
- case Je:
2258
- t.mode = Qe;
2259
- case Qe:
2260
- if (l >= 6 && u >= 258) {
2261
- e.next_out = o, e.avail_out = u, e.next_in = r, e.avail_in = l, t.hold = s, t.bits = f, Ha(e, c), o = e.next_out, a = e.output, u = e.avail_out, r = e.next_in, i = e.input, l = e.avail_in, s = t.hold, f = t.bits, t.mode === K && (t.back = -1);
2262
- break;
2263
- }
2264
- for (t.back = 0; k = t.lencode[s & (1 << t.lenbits) - 1], y = k >>> 24, E = k >>> 16 & 255, C = k & 65535, !(y <= f); ) {
2265
- if (l === 0)
2266
- break e;
2267
- l--, s += i[r++] << f, f += 8;
2268
- }
2269
- if (E && !(E & 240)) {
2270
- for (p = y, $ = E, N = C; k = t.lencode[N + ((s & (1 << p + $) - 1) >> p)], y = k >>> 24, E = k >>> 16 & 255, C = k & 65535, !(p + y <= f); ) {
2271
- if (l === 0)
2272
- break e;
2273
- l--, s += i[r++] << f, f += 8;
2274
- }
2275
- s >>>= p, f -= p, t.back += p;
2276
- }
2277
- if (s >>>= y, f -= y, t.back += y, t.length = C, E === 0) {
2278
- t.mode = Bn;
2279
- break;
2280
- }
2281
- if (E & 32) {
2282
- t.back = -1, t.mode = K;
2283
- break;
2284
- }
2285
- if (E & 64) {
2286
- e.msg = "invalid literal/length code", t.mode = O;
2287
- break;
2288
- }
2289
- t.extra = E & 15, t.mode = An;
2290
- case An:
2291
- if (t.extra) {
2292
- for (I = t.extra; f < I; ) {
2293
- if (l === 0)
2294
- break e;
2295
- l--, s += i[r++] << f, f += 8;
2296
- }
2297
- t.length += s & (1 << t.extra) - 1, s >>>= t.extra, f -= t.extra, t.back += t.extra;
2298
- }
2299
- t.was = t.length, t.mode = On;
2300
- case On:
2301
- for (; k = t.distcode[s & (1 << t.distbits) - 1], y = k >>> 24, E = k >>> 16 & 255, C = k & 65535, !(y <= f); ) {
2302
- if (l === 0)
2303
- break e;
2304
- l--, s += i[r++] << f, f += 8;
2305
- }
2306
- if (!(E & 240)) {
2307
- for (p = y, $ = E, N = C; k = t.distcode[N + ((s & (1 << p + $) - 1) >> p)], y = k >>> 24, E = k >>> 16 & 255, C = k & 65535, !(p + y <= f); ) {
2308
- if (l === 0)
2309
- break e;
2310
- l--, s += i[r++] << f, f += 8;
2311
- }
2312
- s >>>= p, f -= p, t.back += p;
2313
- }
2314
- if (s >>>= y, f -= y, t.back += y, E & 64) {
2315
- e.msg = "invalid distance code", t.mode = O;
2316
- break;
2317
- }
2318
- t.offset = C, t.extra = E & 15, t.mode = zn;
2319
- case zn:
2320
- if (t.extra) {
2321
- for (I = t.extra; f < I; ) {
2322
- if (l === 0)
2323
- break e;
2324
- l--, s += i[r++] << f, f += 8;
2325
- }
2326
- t.offset += s & (1 << t.extra) - 1, s >>>= t.extra, f -= t.extra, t.back += t.extra;
2327
- }
2328
- if (t.offset > t.dmax) {
2329
- e.msg = "invalid distance too far back", t.mode = O;
2330
- break;
2331
- }
2332
- t.mode = Rn;
2333
- case Rn:
2334
- if (u === 0)
2335
- break e;
2336
- if (h = c - u, t.offset > h) {
2337
- if (h = t.offset - h, h > t.whave && t.sane) {
2338
- e.msg = "invalid distance too far back", t.mode = O;
2339
- break;
2340
- }
2341
- h > t.wnext ? (h -= t.wnext, d = t.wsize - h) : d = t.wnext - h, h > t.length && (h = t.length), g = t.window;
2342
- } else
2343
- g = a, d = o - t.offset, h = t.length;
2344
- h > u && (h = u), u -= h, t.length -= h;
2345
- do
2346
- a[o++] = g[d++];
2347
- while (--h);
2348
- t.length === 0 && (t.mode = Qe);
2349
- break;
2350
- case Bn:
2351
- if (u === 0)
2352
- break e;
2353
- a[o++] = t.length, u--, t.mode = Qe;
2354
- break;
2355
- case yt:
2356
- if (t.wrap) {
2357
- for (; f < 32; ) {
2358
- if (l === 0)
2359
- break e;
2360
- l--, s |= i[r++] << f, f += 8;
2361
- }
2362
- if (c -= u, e.total_out += c, t.total += c, t.wrap & 4 && c && (e.adler = t.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/
2363
- t.flags ? R(t.check, a, c, o - c) : Ue(t.check, a, c, o - c)), c = u, t.wrap & 4 && (t.flags ? s : Vn(s)) !== t.check) {
2364
- e.msg = "incorrect data check", t.mode = O;
2365
- break;
2366
- }
2367
- s = 0, f = 0;
2368
- }
2369
- t.mode = Un;
2370
- case Un:
2371
- if (t.wrap && t.flags) {
2372
- for (; f < 32; ) {
2373
- if (l === 0)
2374
- break e;
2375
- l--, s += i[r++] << f, f += 8;
2376
- }
2377
- if (t.wrap & 4 && s !== (t.total & 4294967295)) {
2378
- e.msg = "incorrect length check", t.mode = O;
2379
- break;
2380
- }
2381
- s = 0, f = 0;
2382
- }
2383
- t.mode = Dn;
2384
- case Dn:
2385
- m = Ja;
2386
- break e;
2387
- case O:
2388
- m = mi;
2389
- break e;
2390
- case vi:
2391
- return yi;
2392
- case ki:
2393
- default:
2394
- return P;
2395
- }
2396
- return e.next_out = o, e.avail_out = u, e.next_in = r, e.avail_in = l, t.hold = s, t.bits = f, (t.wsize || c !== e.avail_out && t.mode < O && (t.mode < yt || n !== pn)) && Ni(e, e.output, e.next_out, c - e.avail_out), _ -= e.avail_in, c -= e.avail_out, e.total_in += _, e.total_out += c, t.total += c, t.wrap & 4 && c && (e.adler = t.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
2397
- t.flags ? R(t.check, a, c, e.next_out - c) : Ue(t.check, a, c, e.next_out - c)), e.data_type = t.bits + (t.last ? 64 : 0) + (t.mode === K ? 128 : 0) + (t.mode === Je || t.mode === mt ? 256 : 0), (_ === 0 && c === 0 || n === pn) && m === ue && (m = eo), m;
2398
- }, fo = (e) => {
2399
- if (he(e))
2400
- return P;
2401
- let n = e.state;
2402
- return n.window && (n.window = null), e.state = null, ue;
2403
- }, uo = (e, n) => {
2404
- if (he(e))
2405
- return P;
2406
- const t = e.state;
2407
- return t.wrap & 2 ? (t.head = n, n.done = !1, ue) : P;
2408
- }, ho = (e, n) => {
2409
- const t = n.length;
2410
- let i, a, r;
2411
- return he(e) || (i = e.state, i.wrap !== 0 && i.mode !== at) ? P : i.mode === at && (a = 1, a = Ue(a, n, t, 0), a !== i.check) ? mi : (r = Ni(e, n, t, t), r ? (i.mode = vi, yi) : (i.havedict = 1, ue));
2412
- };
2413
- var co = Ei, po = Ci, _o = $i, bo = oo, go = Si, wo = lo, mo = fo, yo = uo, vo = ho, ko = "pako inflate (from Nodeca project)", X = {
2414
- inflateReset: co,
2415
- inflateReset2: po,
2416
- inflateResetKeep: _o,
2417
- inflateInit: bo,
2418
- inflateInit2: go,
2419
- inflate: wo,
2420
- inflateEnd: mo,
2421
- inflateGetHeader: yo,
2422
- inflateSetDictionary: vo,
2423
- inflateInfo: ko
2424
- };
2425
- function $o() {
2426
- this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1;
2427
- }
2428
- var Eo = $o;
2429
- const Ii = Object.prototype.toString, {
2430
- Z_NO_FLUSH: Co,
2431
- Z_FINISH: So,
2432
- Z_OK: Fe,
2433
- Z_STREAM_END: $t,
2434
- Z_NEED_DICT: Et,
2435
- Z_STREAM_ERROR: No,
2436
- Z_DATA_ERROR: Ln,
2437
- Z_MEM_ERROR: Io
2438
- } = xe;
2439
- function He(e) {
2440
- this.options = ft.assign({
2441
- chunkSize: 1024 * 64,
2442
- windowBits: 15,
2443
- to: ""
2444
- }, e || {});
2445
- const n = this.options;
2446
- n.raw && n.windowBits >= 0 && n.windowBits < 16 && (n.windowBits = -n.windowBits, n.windowBits === 0 && (n.windowBits = -15)), n.windowBits >= 0 && n.windowBits < 16 && !(e && e.windowBits) && (n.windowBits += 32), n.windowBits > 15 && n.windowBits < 48 && (n.windowBits & 15 || (n.windowBits |= 15)), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new _i(), this.strm.avail_out = 0;
2447
- let t = X.inflateInit2(
2448
- this.strm,
2449
- n.windowBits
2450
- );
2451
- if (t !== Fe)
2452
- throw new Error(ge[t]);
2453
- if (this.header = new Eo(), X.inflateGetHeader(this.strm, this.header), n.dictionary && (typeof n.dictionary == "string" ? n.dictionary = Ve.string2buf(n.dictionary) : Ii.call(n.dictionary) === "[object ArrayBuffer]" && (n.dictionary = new Uint8Array(n.dictionary)), n.raw && (t = X.inflateSetDictionary(this.strm, n.dictionary), t !== Fe)))
2454
- throw new Error(ge[t]);
2455
- }
2456
- He.prototype.push = function(e, n) {
2457
- const t = this.strm, i = this.options.chunkSize, a = this.options.dictionary;
2458
- let r, o, l;
2459
- if (this.ended) return !1;
2460
- for (n === ~~n ? o = n : o = n === !0 ? So : Co, Ii.call(e) === "[object ArrayBuffer]" ? t.input = new Uint8Array(e) : t.input = e, t.next_in = 0, t.avail_in = t.input.length; ; ) {
2461
- for (t.avail_out === 0 && (t.output = new Uint8Array(i), t.next_out = 0, t.avail_out = i), r = X.inflate(t, o), r === Et && a && (r = X.inflateSetDictionary(t, a), r === Fe ? r = X.inflate(t, o) : r === Ln && (r = Et)); t.avail_in > 0 && r === $t && t.state.wrap > 0 && e[t.next_in] !== 0; )
2462
- X.inflateReset(t), r = X.inflate(t, o);
2463
- switch (r) {
2464
- case No:
2465
- case Ln:
2466
- case Et:
2467
- case Io:
2468
- return this.onEnd(r), this.ended = !0, !1;
2469
- }
2470
- if (l = t.avail_out, t.next_out && (t.avail_out === 0 || r === $t))
2471
- if (this.options.to === "string") {
2472
- let u = Ve.utf8border(t.output, t.next_out), s = t.next_out - u, f = Ve.buf2string(t.output, u);
2473
- t.next_out = s, t.avail_out = i - s, s && t.output.set(t.output.subarray(u, u + s), 0), this.onData(f);
2474
- } else
2475
- this.onData(t.output.length === t.next_out ? t.output : t.output.subarray(0, t.next_out));
2476
- if (!(r === Fe && l === 0)) {
2477
- if (r === $t)
2478
- return r = X.inflateEnd(this.strm), this.onEnd(r), this.ended = !0, !0;
2479
- if (t.avail_in === 0) break;
2480
- }
2481
- }
2482
- return !0;
2483
- };
2484
- He.prototype.onData = function(e) {
2485
- this.chunks.push(e);
2486
- };
2487
- He.prototype.onEnd = function(e) {
2488
- e === Fe && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = ft.flattenChunks(this.chunks)), this.chunks = [], this.err = e, this.msg = this.strm.msg;
2489
- };
2490
- function Yt(e, n) {
2491
- const t = new He(n);
2492
- if (t.push(e), t.err) throw t.msg || ge[t.err];
2493
- return t.result;
2494
- }
2495
- function To(e, n) {
2496
- return n = n || {}, n.raw = !0, Yt(e, n);
2497
- }
2498
- var Ao = He, Oo = Yt, zo = To, Ro = Yt, Bo = xe, Uo = {
2499
- Inflate: Ao,
2500
- inflate: Oo,
2501
- inflateRaw: zo,
2502
- ungzip: Ro,
2503
- constants: Bo
2504
- };
2505
- const { Inflate: Us, inflate: Ds, inflateRaw: Do, ungzip: Vs } = Uo;
2506
- var Vo = Do;
2507
- function Fo(e) {
2508
- return Vo(e.subarray(2));
2509
- }
2510
- class Lo extends Error {
2511
- constructor(n) {
2512
- super(n), this.code = "ERR_ABORTED";
2513
- }
2514
- }
2515
- function Po(e) {
2516
- e.sort((a, r) => Number(a.offset) - Number(r.offset));
2517
- const n = [];
2518
- let t, i;
2519
- for (const a of e)
2520
- t && i && Number(a.offset) - i <= 2e3 ? (t.length = BigInt(Number(t.length) + Number(a.length) - i + Number(a.offset)), t.blocks.push(a)) : n.push(t = {
2521
- blocks: [a],
2522
- length: a.length,
2523
- offset: a.offset
2524
- }), i = Number(t.offset) + Number(t.length);
2525
- return n;
2526
- }
2527
- function et(e) {
2528
- if (e && e.aborted)
2529
- if (typeof DOMException > "u") {
2530
- const n = new Lo("aborted");
2531
- throw n.code = "ERR_ABORTED", n;
2532
- } else
2533
- throw new DOMException("aborted", "AbortError");
2534
- }
2535
- const Zo = 1, xo = 2, Mo = 3;
2536
- function Ct(e, n, t, i) {
2537
- return e < i && n >= t;
2538
- }
2539
- function Ho(e) {
2540
- const n = e ? "big" : "little", t = new S().endianess(n).uint32("chromId").uint32("start").uint32("end").uint32("validCnt").floatle("minScore").floatle("maxScore").floatle("sumData").floatle("sumSqData").saveOffset("offset"), i = new S().endianess(n).uint8("isLeaf").skip(1).uint16("cnt").choice({
2541
- tag: "isLeaf",
2542
- choices: {
2543
- 1: new S().endianess(n).array("blocksToFetch", {
2544
- length: "cnt",
2545
- type: new S().endianess(n).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").uint64("blockSize").saveOffset("offset")
2546
- }),
2547
- 0: new S().array("recurOffsets", {
2548
- length: "cnt",
2549
- type: new S().endianess(n).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").saveOffset("offset")
2550
- })
2551
- }
2552
- }), a = new S().endianess(n).uint32("chromId").int32("start").int32("end").string("rest", {
2553
- zeroTerminated: !0
2554
- }).saveOffset("offset");
2555
- return {
2556
- bigWigParser: new S().endianess(n).skip(4).int32("blockStart").skip(4).uint32("itemStep").uint32("itemSpan").uint8("blockType").skip(1).uint16("itemCount").choice({
2557
- tag: "blockType",
2558
- choices: {
2559
- [Mo]: new S().array("items", {
2560
- length: "itemCount",
2561
- type: new S().floatle("score")
2562
- }),
2563
- [xo]: new S().array("items", {
2564
- length: "itemCount",
2565
- type: new S().endianess(n).int32("start").floatle("score")
2566
- }),
2567
- [Zo]: new S().array("items", {
2568
- length: "itemCount",
2569
- type: new S().endianess(n).int32("start").int32("end").floatle("score")
2570
- })
2571
- }
2572
- }),
2573
- bigBedParser: a,
2574
- summaryParser: t,
2575
- leafParser: i
2576
- };
2577
- }
2578
- class Ti {
2579
- constructor(n, t, i, a, r, o) {
2580
- if (this.bbi = n, this.refsByName = t, this.cirTreeOffset = i, this.isBigEndian = a, this.isCompressed = r, this.blockType = o, this.featureCache = new Gn({
2581
- cache: new Yn({ maxSize: 1e3 }),
2582
- fill: async (u, s) => {
2583
- const f = Number(u.length), _ = Number(u.offset), { buffer: c } = await this.bbi.read(J.Buffer.alloc(f), 0, f, _, {
2584
- signal: s
2585
- });
2586
- return c;
2587
- }
2588
- }), !(i >= 0))
2589
- throw new Error("invalid cirTreeOffset!");
2590
- const l = Ho(a);
2591
- this.leafParser = l.leafParser, this.bigBedParser = l.bigBedParser;
2592
- }
2593
- async readWigData(n, t, i, a, r) {
2594
- try {
2595
- const { refsByName: o, bbi: l, cirTreeOffset: u, isBigEndian: s } = this, f = o[n];
2596
- f === void 0 && a.complete();
2597
- const _ = { chrId: f, start: t, end: i };
2598
- this.cirTreePromise || (this.cirTreePromise = l.read(J.Buffer.alloc(48), 0, 48, Number(u), r));
2599
- const { buffer: c } = await this.cirTreePromise, h = s ? c.readUInt32BE(4) : c.readUInt32LE(4);
2600
- let d = [], g = 0;
2601
- const k = (p, $, N) => {
2602
- try {
2603
- const b = p.subarray($), m = this.leafParser.parse(b);
2604
- if (m.blocksToFetch && (d = d.concat(m.blocksToFetch.filter((w) => y(w)).map((w) => ({
2605
- offset: w.blockOffset,
2606
- length: w.blockSize
2607
- })))), m.recurOffsets) {
2608
- const w = m.recurOffsets.filter((v) => y(v)).map((v) => Number(v.blockOffset));
2609
- w.length > 0 && C(w, N + 1);
2610
- }
2611
- } catch (b) {
2612
- a.error(b);
2613
- }
2614
- }, y = (p) => {
2615
- const { startChrom: $, startBase: N, endChrom: b, endBase: m } = p;
2616
- return ($ < f || $ === f && N <= i) && (b > f || b === f && m >= t);
2617
- }, E = async (p, $, N) => {
2618
- try {
2619
- const b = $.max - $.min, m = $.min, w = await this.featureCache.get(`${b}_${m}`, { length: b, offset: m }, r == null ? void 0 : r.signal);
2620
- for (const v of p)
2621
- $.contains(v) && (k(w, v - m, N), g -= 1, g === 0 && this.readFeatures(a, d, {
2622
- ...r,
2623
- request: _
2624
- }).catch((I) => a.error(I)));
2625
- } catch (b) {
2626
- a.error(b);
2627
- }
2628
- }, C = (p, $) => {
2629
- try {
2630
- g += p.length;
2631
- const N = 4 + Number(h) * 32;
2632
- let b = new pe([
2633
- { min: p[0], max: p[0] + N }
2634
- ]);
2635
- for (let m = 1; m < p.length; m += 1) {
2636
- const w = new pe([
2637
- { min: p[m], max: p[m] + N }
2638
- ]);
2639
- b = b.union(w);
2640
- }
2641
- b.getRanges().map((m) => E(p, m, $));
2642
- } catch (N) {
2643
- a.error(N);
2644
- }
2645
- };
2646
- return C([Number(u) + 48], 1);
2647
- } catch (o) {
2648
- a.error(o);
2649
- }
2650
- }
2651
- parseSummaryBlock(n, t, i) {
2652
- const a = [];
2653
- let r = t;
2654
- const o = new DataView(n.buffer, n.byteOffset, n.length);
2655
- for (; r < n.byteLength; ) {
2656
- const l = o.getUint32(r, !0);
2657
- r += 4;
2658
- const u = o.getUint32(r, !0);
2659
- r += 4;
2660
- const s = o.getUint32(r, !0);
2661
- r += 4;
2662
- const f = o.getUint32(r, !0);
2663
- r += 4;
2664
- const _ = o.getFloat32(r, !0);
2665
- r += 4;
2666
- const c = o.getFloat32(r, !0);
2667
- r += 4;
2668
- const h = o.getFloat32(r, !0);
2669
- r += 4, r += 4, (!i || l === i.chrId && Ct(u, s, i.start, i.end)) && a.push({
2670
- start: u,
2671
- end: s,
2672
- maxScore: c,
2673
- minScore: _,
2674
- summary: !0,
2675
- score: h / (f || 1)
2676
- });
2677
- }
2678
- return a;
2679
- }
2680
- parseBigBedBlock(n, t, i, a) {
2681
- const r = [];
2682
- let o = t;
2683
- for (; o < n.byteLength; ) {
2684
- const l = this.bigBedParser.parse(n.subarray(o));
2685
- l.uniqueId = `bb-${i + o}`, r.push(l), o += l.offset;
2686
- }
2687
- return a ? r.filter((l) => Ct(l.start, l.end, a.start, a.end)) : r;
2688
- }
2689
- parseBigWigBlock(n, t, i) {
2690
- const a = n.subarray(t), r = new DataView(a.buffer, a.byteOffset, a.length);
2691
- let o = 0;
2692
- o += 4;
2693
- const l = r.getInt32(o, !0);
2694
- o += 8;
2695
- const u = r.getUint32(o, !0);
2696
- o += 4;
2697
- const s = r.getUint32(o, !0);
2698
- o += 4;
2699
- const f = r.getUint8(o);
2700
- o += 2;
2701
- const _ = r.getUint16(o, !0);
2702
- o += 2;
2703
- const c = new Array(_);
2704
- switch (f) {
2705
- case 1: {
2706
- for (let h = 0; h < _; h++) {
2707
- const d = r.getInt32(o, !0);
2708
- o += 4;
2709
- const g = r.getInt32(o, !0);
2710
- o += 4;
2711
- const k = r.getFloat32(o, !0);
2712
- o += 4, c[h] = { start: d, end: g, score: k };
2713
- }
2714
- break;
2715
- }
2716
- case 2: {
2717
- for (let h = 0; h < _; h++) {
2718
- const d = r.getInt32(o, !0);
2719
- o += 4;
2720
- const g = r.getFloat32(o, !0);
2721
- o += 4, c[h] = { score: g, start: d, end: d + s };
2722
- }
2723
- break;
2724
- }
2725
- case 3: {
2726
- for (let h = 0; h < _; h++) {
2727
- const d = r.getFloat32(o, !0);
2728
- o += 4;
2729
- const g = l + h * u;
2730
- c[h] = { score: d, start: g, end: g + s };
2731
- }
2732
- break;
2733
- }
2734
- }
2735
- return i ? c.filter((h) => Ct(h.start, h.end, i.start, i.end)) : c;
2736
- }
2737
- async readFeatures(n, t, i = {}) {
2738
- try {
2739
- const { blockType: a, isCompressed: r } = this, { signal: o, request: l } = i, u = Po(t);
2740
- et(o), await Promise.all(u.map(async (s) => {
2741
- et(o);
2742
- const { length: f, offset: _ } = s, c = await this.featureCache.get(`${f}_${_}`, s, o);
2743
- for (const h of s.blocks) {
2744
- et(o);
2745
- let d = Number(h.offset) - Number(s.offset), g = c;
2746
- switch (r && (g = Fo(c.subarray(d)), d = 0), et(o), a) {
2747
- case "summary": {
2748
- n.next(this.parseSummaryBlock(g, d, l));
2749
- break;
2750
- }
2751
- case "bigwig": {
2752
- n.next(this.parseBigWigBlock(g, d, l));
2753
- break;
2754
- }
2755
- case "bigbed": {
2756
- n.next(this.parseBigBedBlock(g, d, Number(h.offset) * 256, l));
2757
- break;
2758
- }
2759
- default:
2760
- console.warn(`Don't know what to do with ${a}`);
2761
- }
2762
- }
2763
- })), n.complete();
2764
- } catch (a) {
2765
- n.error(a);
2766
- }
2767
- }
2768
- }
2769
- var Ft = function(e, n) {
2770
- return Ft = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
2771
- t.__proto__ = i;
2772
- } || function(t, i) {
2773
- for (var a in i) Object.prototype.hasOwnProperty.call(i, a) && (t[a] = i[a]);
2774
- }, Ft(e, n);
2775
- };
2776
- function Kt(e, n) {
2777
- if (typeof n != "function" && n !== null)
2778
- throw new TypeError("Class extends value " + String(n) + " is not a constructor or null");
2779
- Ft(e, n);
2780
- function t() {
2781
- this.constructor = e;
2782
- }
2783
- e.prototype = n === null ? Object.create(n) : (t.prototype = n.prototype, new t());
2784
- }
2785
- function jo(e, n, t, i) {
2786
- function a(r) {
2787
- return r instanceof t ? r : new t(function(o) {
2788
- o(r);
2789
- });
2790
- }
2791
- return new (t || (t = Promise))(function(r, o) {
2792
- function l(f) {
2793
- try {
2794
- s(i.next(f));
2795
- } catch (_) {
2796
- o(_);
2797
- }
2798
- }
2799
- function u(f) {
2800
- try {
2801
- s(i.throw(f));
2802
- } catch (_) {
2803
- o(_);
2804
- }
2805
- }
2806
- function s(f) {
2807
- f.done ? r(f.value) : a(f.value).then(l, u);
2808
- }
2809
- s((i = i.apply(e, n || [])).next());
2810
- });
2811
- }
2812
- function Ai(e, n) {
2813
- var t = { label: 0, sent: function() {
2814
- if (r[0] & 1) throw r[1];
2815
- return r[1];
2816
- }, trys: [], ops: [] }, i, a, r, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
2817
- return o.next = l(0), o.throw = l(1), o.return = l(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
2818
- return this;
2819
- }), o;
2820
- function l(s) {
2821
- return function(f) {
2822
- return u([s, f]);
2823
- };
2824
- }
2825
- function u(s) {
2826
- if (i) throw new TypeError("Generator is already executing.");
2827
- for (; o && (o = 0, s[0] && (t = 0)), t; ) try {
2828
- if (i = 1, a && (r = s[0] & 2 ? a.return : s[0] ? a.throw || ((r = a.return) && r.call(a), 0) : a.next) && !(r = r.call(a, s[1])).done) return r;
2829
- switch (a = 0, r && (s = [s[0] & 2, r.value]), s[0]) {
2830
- case 0:
2831
- case 1:
2832
- r = s;
2833
- break;
2834
- case 4:
2835
- return t.label++, { value: s[1], done: !1 };
2836
- case 5:
2837
- t.label++, a = s[1], s = [0];
2838
- continue;
2839
- case 7:
2840
- s = t.ops.pop(), t.trys.pop();
2841
- continue;
2842
- default:
2843
- if (r = t.trys, !(r = r.length > 0 && r[r.length - 1]) && (s[0] === 6 || s[0] === 2)) {
2844
- t = 0;
2845
- continue;
2846
- }
2847
- if (s[0] === 3 && (!r || s[1] > r[0] && s[1] < r[3])) {
2848
- t.label = s[1];
2849
- break;
2850
- }
2851
- if (s[0] === 6 && t.label < r[1]) {
2852
- t.label = r[1], r = s;
2853
- break;
2854
- }
2855
- if (r && t.label < r[2]) {
2856
- t.label = r[2], t.ops.push(s);
2857
- break;
2858
- }
2859
- r[2] && t.ops.pop(), t.trys.pop();
2860
- continue;
2861
- }
2862
- s = n.call(e, t);
2863
- } catch (f) {
2864
- s = [6, f], a = 0;
2865
- } finally {
2866
- i = r = 0;
2867
- }
2868
- if (s[0] & 5) throw s[1];
2869
- return { value: s[0] ? s[1] : void 0, done: !0 };
2870
- }
2871
- }
2872
- function Le(e) {
2873
- var n = typeof Symbol == "function" && Symbol.iterator, t = n && e[n], i = 0;
2874
- if (t) return t.call(e);
2875
- if (e && typeof e.length == "number") return {
2876
- next: function() {
2877
- return e && i >= e.length && (e = void 0), { value: e && e[i++], done: !e };
2878
- }
2879
- };
2880
- throw new TypeError(n ? "Object is not iterable." : "Symbol.iterator is not defined.");
2881
- }
2882
- function Lt(e, n) {
2883
- var t = typeof Symbol == "function" && e[Symbol.iterator];
2884
- if (!t) return e;
2885
- var i = t.call(e), a, r = [], o;
2886
- try {
2887
- for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; ) r.push(a.value);
2888
- } catch (l) {
2889
- o = { error: l };
2890
- } finally {
2891
- try {
2892
- a && !a.done && (t = i.return) && t.call(i);
2893
- } finally {
2894
- if (o) throw o.error;
2895
- }
2896
- }
2897
- return r;
2898
- }
2899
- function Pt(e, n, t) {
2900
- if (t || arguments.length === 2) for (var i = 0, a = n.length, r; i < a; i++)
2901
- (r || !(i in n)) && (r || (r = Array.prototype.slice.call(n, 0, i)), r[i] = n[i]);
2902
- return e.concat(r || Array.prototype.slice.call(n));
2903
- }
2904
- function be(e) {
2905
- return this instanceof be ? (this.v = e, this) : new be(e);
2906
- }
2907
- function Go(e, n, t) {
2908
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2909
- var i = t.apply(e, n || []), a, r = [];
2910
- return a = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), l("next"), l("throw"), l("return", o), a[Symbol.asyncIterator] = function() {
2911
- return this;
2912
- }, a;
2913
- function o(h) {
2914
- return function(d) {
2915
- return Promise.resolve(d).then(h, _);
2916
- };
2917
- }
2918
- function l(h, d) {
2919
- i[h] && (a[h] = function(g) {
2920
- return new Promise(function(k, y) {
2921
- r.push([h, g, k, y]) > 1 || u(h, g);
2922
- });
2923
- }, d && (a[h] = d(a[h])));
2924
- }
2925
- function u(h, d) {
2926
- try {
2927
- s(i[h](d));
2928
- } catch (g) {
2929
- c(r[0][3], g);
2930
- }
2931
- }
2932
- function s(h) {
2933
- h.value instanceof be ? Promise.resolve(h.value.v).then(f, _) : c(r[0][2], h);
2934
- }
2935
- function f(h) {
2936
- u("next", h);
2937
- }
2938
- function _(h) {
2939
- u("throw", h);
2940
- }
2941
- function c(h, d) {
2942
- h(d), r.shift(), r.length && u(r[0][0], r[0][1]);
2943
- }
2944
- }
2945
- function Yo(e) {
2946
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2947
- var n = e[Symbol.asyncIterator], t;
2948
- return n ? n.call(e) : (e = typeof Le == "function" ? Le(e) : e[Symbol.iterator](), t = {}, i("next"), i("throw"), i("return"), t[Symbol.asyncIterator] = function() {
2949
- return this;
2950
- }, t);
2951
- function i(r) {
2952
- t[r] = e[r] && function(o) {
2953
- return new Promise(function(l, u) {
2954
- o = e[r](o), a(l, u, o.done, o.value);
2955
- });
2956
- };
2957
- }
2958
- function a(r, o, l, u) {
2959
- Promise.resolve(u).then(function(s) {
2960
- r({ value: s, done: l });
2961
- }, o);
2962
- }
2963
- }
2964
- function z(e) {
2965
- return typeof e == "function";
2966
- }
2967
- function Oi(e) {
2968
- var n = function(i) {
2969
- Error.call(i), i.stack = new Error().stack;
2970
- }, t = e(n);
2971
- return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
2972
- }
2973
- var St = Oi(function(e) {
2974
- return function(t) {
2975
- e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
2976
- ` + t.map(function(i, a) {
2977
- return a + 1 + ") " + i.toString();
2978
- }).join(`
2979
- `) : "", this.name = "UnsubscriptionError", this.errors = t;
2980
- };
2981
- });
2982
- function Pn(e, n) {
2983
- if (e) {
2984
- var t = e.indexOf(n);
2985
- 0 <= t && e.splice(t, 1);
2986
- }
2987
- }
2988
- var Wt = function() {
2989
- function e(n) {
2990
- this.initialTeardown = n, this.closed = !1, this._parentage = null, this._finalizers = null;
2991
- }
2992
- return e.prototype.unsubscribe = function() {
2993
- var n, t, i, a, r;
2994
- if (!this.closed) {
2995
- this.closed = !0;
2996
- var o = this._parentage;
2997
- if (o)
2998
- if (this._parentage = null, Array.isArray(o))
2999
- try {
3000
- for (var l = Le(o), u = l.next(); !u.done; u = l.next()) {
3001
- var s = u.value;
3002
- s.remove(this);
3003
- }
3004
- } catch (g) {
3005
- n = { error: g };
3006
- } finally {
3007
- try {
3008
- u && !u.done && (t = l.return) && t.call(l);
3009
- } finally {
3010
- if (n) throw n.error;
3011
- }
3012
- }
3013
- else
3014
- o.remove(this);
3015
- var f = this.initialTeardown;
3016
- if (z(f))
3017
- try {
3018
- f();
3019
- } catch (g) {
3020
- r = g instanceof St ? g.errors : [g];
3021
- }
3022
- var _ = this._finalizers;
3023
- if (_) {
3024
- this._finalizers = null;
3025
- try {
3026
- for (var c = Le(_), h = c.next(); !h.done; h = c.next()) {
3027
- var d = h.value;
3028
- try {
3029
- Zn(d);
3030
- } catch (g) {
3031
- r = r ?? [], g instanceof St ? r = Pt(Pt([], Lt(r)), Lt(g.errors)) : r.push(g);
3032
- }
3033
- }
3034
- } catch (g) {
3035
- i = { error: g };
3036
- } finally {
3037
- try {
3038
- h && !h.done && (a = c.return) && a.call(c);
3039
- } finally {
3040
- if (i) throw i.error;
3041
- }
3042
- }
3043
- }
3044
- if (r)
3045
- throw new St(r);
3046
- }
3047
- }, e.prototype.add = function(n) {
3048
- var t;
3049
- if (n && n !== this)
3050
- if (this.closed)
3051
- Zn(n);
3052
- else {
3053
- if (n instanceof e) {
3054
- if (n.closed || n._hasParent(this))
3055
- return;
3056
- n._addParent(this);
3057
- }
3058
- (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(n);
3059
- }
3060
- }, e.prototype._hasParent = function(n) {
3061
- var t = this._parentage;
3062
- return t === n || Array.isArray(t) && t.includes(n);
3063
- }, e.prototype._addParent = function(n) {
3064
- var t = this._parentage;
3065
- this._parentage = Array.isArray(t) ? (t.push(n), t) : t ? [t, n] : n;
3066
- }, e.prototype._removeParent = function(n) {
3067
- var t = this._parentage;
3068
- t === n ? this._parentage = null : Array.isArray(t) && Pn(t, n);
3069
- }, e.prototype.remove = function(n) {
3070
- var t = this._finalizers;
3071
- t && Pn(t, n), n instanceof e && n._removeParent(this);
3072
- }, e.EMPTY = function() {
3073
- var n = new e();
3074
- return n.closed = !0, n;
3075
- }(), e;
3076
- }();
3077
- Wt.EMPTY;
3078
- function zi(e) {
3079
- return e instanceof Wt || e && "closed" in e && z(e.remove) && z(e.add) && z(e.unsubscribe);
3080
- }
3081
- function Zn(e) {
3082
- z(e) ? e() : e.unsubscribe();
3083
- }
3084
- var Ri = {
3085
- onUnhandledError: null,
3086
- onStoppedNotification: null,
3087
- Promise: void 0,
3088
- useDeprecatedSynchronousErrorHandling: !1,
3089
- useDeprecatedNextContext: !1
3090
- }, Bi = {
3091
- setTimeout: function(e, n) {
3092
- for (var t = [], i = 2; i < arguments.length; i++)
3093
- t[i - 2] = arguments[i];
3094
- return setTimeout.apply(void 0, Pt([e, n], Lt(t)));
3095
- },
3096
- clearTimeout: function(e) {
3097
- var n = Bi.delegate;
3098
- return ((n == null ? void 0 : n.clearTimeout) || clearTimeout)(e);
3099
- },
3100
- delegate: void 0
3101
- };
3102
- function Ui(e) {
3103
- Bi.setTimeout(function() {
3104
- throw e;
3105
- });
3106
- }
3107
- function xn() {
3108
- }
3109
- function Ko(e) {
3110
- e();
3111
- }
3112
- var Xt = function(e) {
3113
- Kt(n, e);
3114
- function n(t) {
3115
- var i = e.call(this) || this;
3116
- return i.isStopped = !1, t ? (i.destination = t, zi(t) && t.add(i)) : i.destination = Jo, i;
3117
- }
3118
- return n.create = function(t, i, a) {
3119
- return new ot(t, i, a);
3120
- }, n.prototype.next = function(t) {
3121
- this.isStopped || this._next(t);
3122
- }, n.prototype.error = function(t) {
3123
- this.isStopped || (this.isStopped = !0, this._error(t));
3124
- }, n.prototype.complete = function() {
3125
- this.isStopped || (this.isStopped = !0, this._complete());
3126
- }, n.prototype.unsubscribe = function() {
3127
- this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
3128
- }, n.prototype._next = function(t) {
3129
- this.destination.next(t);
3130
- }, n.prototype._error = function(t) {
3131
- try {
3132
- this.destination.error(t);
3133
- } finally {
3134
- this.unsubscribe();
3135
- }
3136
- }, n.prototype._complete = function() {
3137
- try {
3138
- this.destination.complete();
3139
- } finally {
3140
- this.unsubscribe();
3141
- }
3142
- }, n;
3143
- }(Wt), Wo = Function.prototype.bind;
3144
- function Nt(e, n) {
3145
- return Wo.call(e, n);
3146
- }
3147
- var Xo = function() {
3148
- function e(n) {
3149
- this.partialObserver = n;
3150
- }
3151
- return e.prototype.next = function(n) {
3152
- var t = this.partialObserver;
3153
- if (t.next)
3154
- try {
3155
- t.next(n);
3156
- } catch (i) {
3157
- tt(i);
3158
- }
3159
- }, e.prototype.error = function(n) {
3160
- var t = this.partialObserver;
3161
- if (t.error)
3162
- try {
3163
- t.error(n);
3164
- } catch (i) {
3165
- tt(i);
3166
- }
3167
- else
3168
- tt(n);
3169
- }, e.prototype.complete = function() {
3170
- var n = this.partialObserver;
3171
- if (n.complete)
3172
- try {
3173
- n.complete();
3174
- } catch (t) {
3175
- tt(t);
3176
- }
3177
- }, e;
3178
- }(), ot = function(e) {
3179
- Kt(n, e);
3180
- function n(t, i, a) {
3181
- var r = e.call(this) || this, o;
3182
- if (z(t) || !t)
3183
- o = {
3184
- next: t ?? void 0,
3185
- error: i ?? void 0,
3186
- complete: a ?? void 0
3187
- };
3188
- else {
3189
- var l;
3190
- r && Ri.useDeprecatedNextContext ? (l = Object.create(t), l.unsubscribe = function() {
3191
- return r.unsubscribe();
3192
- }, o = {
3193
- next: t.next && Nt(t.next, l),
3194
- error: t.error && Nt(t.error, l),
3195
- complete: t.complete && Nt(t.complete, l)
3196
- }) : o = t;
3197
- }
3198
- return r.destination = new Xo(o), r;
3199
- }
3200
- return n;
3201
- }(Xt);
3202
- function tt(e) {
3203
- Ui(e);
3204
- }
3205
- function qo(e) {
3206
- throw e;
3207
- }
3208
- var Jo = {
3209
- closed: !0,
3210
- next: xn,
3211
- error: qo,
3212
- complete: xn
3213
- }, qt = function() {
3214
- return typeof Symbol == "function" && Symbol.observable || "@@observable";
3215
- }();
3216
- function Di(e) {
3217
- return e;
3218
- }
3219
- function Qo(e) {
3220
- return e.length === 0 ? Di : e.length === 1 ? e[0] : function(t) {
3221
- return e.reduce(function(i, a) {
3222
- return a(i);
3223
- }, t);
3224
- };
3225
- }
3226
- var Z = function() {
3227
- function e(n) {
3228
- n && (this._subscribe = n);
3229
- }
3230
- return e.prototype.lift = function(n) {
3231
- var t = new e();
3232
- return t.source = this, t.operator = n, t;
3233
- }, e.prototype.subscribe = function(n, t, i) {
3234
- var a = this, r = ts(n) ? n : new ot(n, t, i);
3235
- return Ko(function() {
3236
- var o = a, l = o.operator, u = o.source;
3237
- r.add(l ? l.call(r, u) : u ? a._subscribe(r) : a._trySubscribe(r));
3238
- }), r;
3239
- }, e.prototype._trySubscribe = function(n) {
3240
- try {
3241
- return this._subscribe(n);
3242
- } catch (t) {
3243
- n.error(t);
3244
- }
3245
- }, e.prototype.forEach = function(n, t) {
3246
- var i = this;
3247
- return t = Mn(t), new t(function(a, r) {
3248
- var o = new ot({
3249
- next: function(l) {
3250
- try {
3251
- n(l);
3252
- } catch (u) {
3253
- r(u), o.unsubscribe();
3254
- }
3255
- },
3256
- error: r,
3257
- complete: a
3258
- });
3259
- i.subscribe(o);
3260
- });
3261
- }, e.prototype._subscribe = function(n) {
3262
- var t;
3263
- return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(n);
3264
- }, e.prototype[qt] = function() {
3265
- return this;
3266
- }, e.prototype.pipe = function() {
3267
- for (var n = [], t = 0; t < arguments.length; t++)
3268
- n[t] = arguments[t];
3269
- return Qo(n)(this);
3270
- }, e.prototype.toPromise = function(n) {
3271
- var t = this;
3272
- return n = Mn(n), new n(function(i, a) {
3273
- var r;
3274
- t.subscribe(function(o) {
3275
- return r = o;
3276
- }, function(o) {
3277
- return a(o);
3278
- }, function() {
3279
- return i(r);
3280
- });
3281
- });
3282
- }, e.create = function(n) {
3283
- return new e(n);
3284
- }, e;
3285
- }();
3286
- function Mn(e) {
3287
- var n;
3288
- return (n = e ?? Ri.Promise) !== null && n !== void 0 ? n : Promise;
3289
- }
3290
- function es(e) {
3291
- return e && z(e.next) && z(e.error) && z(e.complete);
3292
- }
3293
- function ts(e) {
3294
- return e && e instanceof Xt || es(e) && zi(e);
3295
- }
3296
- function ns(e) {
3297
- return z(e == null ? void 0 : e.lift);
3298
- }
3299
- function $e(e) {
3300
- return function(n) {
3301
- if (ns(n))
3302
- return n.lift(function(t) {
3303
- try {
3304
- return e(t, this);
3305
- } catch (i) {
3306
- this.error(i);
3307
- }
3308
- });
3309
- throw new TypeError("Unable to lift unknown Observable type");
3310
- };
3311
- }
3312
- function Pe(e, n, t, i, a) {
3313
- return new is(e, n, t, i, a);
3314
- }
3315
- var is = function(e) {
3316
- Kt(n, e);
3317
- function n(t, i, a, r, o, l) {
3318
- var u = e.call(this, t) || this;
3319
- return u.onFinalize = o, u.shouldUnsubscribe = l, u._next = i ? function(s) {
3320
- try {
3321
- i(s);
3322
- } catch (f) {
3323
- t.error(f);
3324
- }
3325
- } : e.prototype._next, u._error = r ? function(s) {
3326
- try {
3327
- r(s);
3328
- } catch (f) {
3329
- t.error(f);
3330
- } finally {
3331
- this.unsubscribe();
3332
- }
3333
- } : e.prototype._error, u._complete = a ? function() {
3334
- try {
3335
- a();
3336
- } catch (s) {
3337
- t.error(s);
3338
- } finally {
3339
- this.unsubscribe();
3340
- }
3341
- } : e.prototype._complete, u;
3342
- }
3343
- return n.prototype.unsubscribe = function() {
3344
- var t;
3345
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
3346
- var i = this.closed;
3347
- e.prototype.unsubscribe.call(this), !i && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
3348
- }
3349
- }, n;
3350
- }(Xt), rs = new Z(function(e) {
3351
- return e.complete();
3352
- });
3353
- function as(e) {
3354
- return e && z(e.schedule);
3355
- }
3356
- function Vi(e) {
3357
- return e[e.length - 1];
3358
- }
3359
- function os(e) {
3360
- return as(Vi(e)) ? e.pop() : void 0;
3361
- }
3362
- function ss(e, n) {
3363
- return typeof Vi(e) == "number" ? e.pop() : n;
3364
- }
3365
- var Fi = function(e) {
3366
- return e && typeof e.length == "number" && typeof e != "function";
3367
- };
3368
- function Li(e) {
3369
- return z(e == null ? void 0 : e.then);
3370
- }
3371
- function Pi(e) {
3372
- return z(e[qt]);
3373
- }
3374
- function Zi(e) {
3375
- return Symbol.asyncIterator && z(e == null ? void 0 : e[Symbol.asyncIterator]);
3376
- }
3377
- function xi(e) {
3378
- return new TypeError("You provided " + (e !== null && typeof e == "object" ? "an invalid object" : "'" + e + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
3379
- }
3380
- function ls() {
3381
- return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
3382
- }
3383
- var Mi = ls();
3384
- function Hi(e) {
3385
- return z(e == null ? void 0 : e[Mi]);
3386
- }
3387
- function ji(e) {
3388
- return Go(this, arguments, function() {
3389
- var t, i, a, r;
3390
- return Ai(this, function(o) {
3391
- switch (o.label) {
3392
- case 0:
3393
- t = e.getReader(), o.label = 1;
3394
- case 1:
3395
- o.trys.push([1, , 9, 10]), o.label = 2;
3396
- case 2:
3397
- return [4, be(t.read())];
3398
- case 3:
3399
- return i = o.sent(), a = i.value, r = i.done, r ? [4, be(void 0)] : [3, 5];
3400
- case 4:
3401
- return [2, o.sent()];
3402
- case 5:
3403
- return [4, be(a)];
3404
- case 6:
3405
- return [4, o.sent()];
3406
- case 7:
3407
- return o.sent(), [3, 2];
3408
- case 8:
3409
- return [3, 10];
3410
- case 9:
3411
- return t.releaseLock(), [7];
3412
- case 10:
3413
- return [2];
3414
- }
3415
- });
3416
- });
3417
- }
3418
- function Gi(e) {
3419
- return z(e == null ? void 0 : e.getReader);
3420
- }
3421
- function Ee(e) {
3422
- if (e instanceof Z)
3423
- return e;
3424
- if (e != null) {
3425
- if (Pi(e))
3426
- return fs(e);
3427
- if (Fi(e))
3428
- return us(e);
3429
- if (Li(e))
3430
- return hs(e);
3431
- if (Zi(e))
3432
- return Yi(e);
3433
- if (Hi(e))
3434
- return cs(e);
3435
- if (Gi(e))
3436
- return ds(e);
3437
- }
3438
- throw xi(e);
3439
- }
3440
- function fs(e) {
3441
- return new Z(function(n) {
3442
- var t = e[qt]();
3443
- if (z(t.subscribe))
3444
- return t.subscribe(n);
3445
- throw new TypeError("Provided object does not correctly implement Symbol.observable");
3446
- });
3447
- }
3448
- function us(e) {
3449
- return new Z(function(n) {
3450
- for (var t = 0; t < e.length && !n.closed; t++)
3451
- n.next(e[t]);
3452
- n.complete();
3453
- });
3454
- }
3455
- function hs(e) {
3456
- return new Z(function(n) {
3457
- e.then(function(t) {
3458
- n.closed || (n.next(t), n.complete());
3459
- }, function(t) {
3460
- return n.error(t);
3461
- }).then(null, Ui);
3462
- });
3463
- }
3464
- function cs(e) {
3465
- return new Z(function(n) {
3466
- var t, i;
3467
- try {
3468
- for (var a = Le(e), r = a.next(); !r.done; r = a.next()) {
3469
- var o = r.value;
3470
- if (n.next(o), n.closed)
3471
- return;
3472
- }
3473
- } catch (l) {
3474
- t = { error: l };
3475
- } finally {
3476
- try {
3477
- r && !r.done && (i = a.return) && i.call(a);
3478
- } finally {
3479
- if (t) throw t.error;
3480
- }
3481
- }
3482
- n.complete();
3483
- });
3484
- }
3485
- function Yi(e) {
3486
- return new Z(function(n) {
3487
- ps(e, n).catch(function(t) {
3488
- return n.error(t);
3489
- });
3490
- });
3491
- }
3492
- function ds(e) {
3493
- return Yi(ji(e));
3494
- }
3495
- function ps(e, n) {
3496
- var t, i, a, r;
3497
- return jo(this, void 0, void 0, function() {
3498
- var o, l;
3499
- return Ai(this, function(u) {
3500
- switch (u.label) {
3501
- case 0:
3502
- u.trys.push([0, 5, 6, 11]), t = Yo(e), u.label = 1;
3503
- case 1:
3504
- return [4, t.next()];
3505
- case 2:
3506
- if (i = u.sent(), !!i.done) return [3, 4];
3507
- if (o = i.value, n.next(o), n.closed)
3508
- return [2];
3509
- u.label = 3;
3510
- case 3:
3511
- return [3, 1];
3512
- case 4:
3513
- return [3, 11];
3514
- case 5:
3515
- return l = u.sent(), a = { error: l }, [3, 11];
3516
- case 6:
3517
- return u.trys.push([6, , 9, 10]), i && !i.done && (r = t.return) ? [4, r.call(t)] : [3, 8];
3518
- case 7:
3519
- u.sent(), u.label = 8;
3520
- case 8:
3521
- return [3, 10];
3522
- case 9:
3523
- if (a) throw a.error;
3524
- return [7];
3525
- case 10:
3526
- return [7];
3527
- case 11:
3528
- return n.complete(), [2];
3529
- }
3530
- });
3531
- });
3532
- }
3533
- function le(e, n, t, i, a) {
3534
- i === void 0 && (i = 0), a === void 0 && (a = !1);
3535
- var r = n.schedule(function() {
3536
- t(), a ? e.add(this.schedule(null, i)) : this.unsubscribe();
3537
- }, i);
3538
- if (e.add(r), !a)
3539
- return r;
3540
- }
3541
- function Ki(e, n) {
3542
- return n === void 0 && (n = 0), $e(function(t, i) {
3543
- t.subscribe(Pe(i, function(a) {
3544
- return le(i, e, function() {
3545
- return i.next(a);
3546
- }, n);
3547
- }, function() {
3548
- return le(i, e, function() {
3549
- return i.complete();
3550
- }, n);
3551
- }, function(a) {
3552
- return le(i, e, function() {
3553
- return i.error(a);
3554
- }, n);
3555
- }));
3556
- });
3557
- }
3558
- function Wi(e, n) {
3559
- return n === void 0 && (n = 0), $e(function(t, i) {
3560
- i.add(e.schedule(function() {
3561
- return t.subscribe(i);
3562
- }, n));
3563
- });
3564
- }
3565
- function _s(e, n) {
3566
- return Ee(e).pipe(Wi(n), Ki(n));
3567
- }
3568
- function bs(e, n) {
3569
- return Ee(e).pipe(Wi(n), Ki(n));
3570
- }
3571
- function gs(e, n) {
3572
- return new Z(function(t) {
3573
- var i = 0;
3574
- return n.schedule(function() {
3575
- i === e.length ? t.complete() : (t.next(e[i++]), t.closed || this.schedule());
3576
- });
3577
- });
3578
- }
3579
- function ws(e, n) {
3580
- return new Z(function(t) {
3581
- var i;
3582
- return le(t, n, function() {
3583
- i = e[Mi](), le(t, n, function() {
3584
- var a, r, o;
3585
- try {
3586
- a = i.next(), r = a.value, o = a.done;
3587
- } catch (l) {
3588
- t.error(l);
3589
- return;
3590
- }
3591
- o ? t.complete() : t.next(r);
3592
- }, 0, !0);
3593
- }), function() {
3594
- return z(i == null ? void 0 : i.return) && i.return();
3595
- };
3596
- });
3597
- }
3598
- function Xi(e, n) {
3599
- if (!e)
3600
- throw new Error("Iterable cannot be null");
3601
- return new Z(function(t) {
3602
- le(t, n, function() {
3603
- var i = e[Symbol.asyncIterator]();
3604
- le(t, n, function() {
3605
- i.next().then(function(a) {
3606
- a.done ? t.complete() : t.next(a.value);
3607
- });
3608
- }, 0, !0);
3609
- });
3610
- });
3611
- }
3612
- function ms(e, n) {
3613
- return Xi(ji(e), n);
3614
- }
3615
- function ys(e, n) {
3616
- if (e != null) {
3617
- if (Pi(e))
3618
- return _s(e, n);
3619
- if (Fi(e))
3620
- return gs(e, n);
3621
- if (Li(e))
3622
- return bs(e, n);
3623
- if (Zi(e))
3624
- return Xi(e, n);
3625
- if (Hi(e))
3626
- return ws(e, n);
3627
- if (Gi(e))
3628
- return ms(e, n);
3629
- }
3630
- throw xi(e);
3631
- }
3632
- function vs(e, n) {
3633
- return n ? ys(e, n) : Ee(e);
3634
- }
3635
- var ks = Oi(function(e) {
3636
- return function() {
3637
- e(this), this.name = "EmptyError", this.message = "no elements in sequence";
3638
- };
3639
- });
3640
- function qi(e, n) {
3641
- return new Promise(function(t, i) {
3642
- var a = new ot({
3643
- next: function(r) {
3644
- t(r), a.unsubscribe();
3645
- },
3646
- error: i,
3647
- complete: function() {
3648
- i(new ks());
3649
- }
3650
- });
3651
- e.subscribe(a);
3652
- });
3653
- }
3654
- function Ji(e, n) {
3655
- return $e(function(t, i) {
3656
- var a = 0;
3657
- t.subscribe(Pe(i, function(r) {
3658
- i.next(e.call(n, r, a++));
3659
- }));
3660
- });
3661
- }
3662
- function $s(e, n, t, i, a, r, o, l) {
3663
- var u = [], s = 0, f = 0, _ = !1, c = function() {
3664
- _ && !u.length && !s && n.complete();
3665
- }, h = function(g) {
3666
- return s < i ? d(g) : u.push(g);
3667
- }, d = function(g) {
3668
- s++;
3669
- var k = !1;
3670
- Ee(t(g, f++)).subscribe(Pe(n, function(y) {
3671
- n.next(y);
3672
- }, function() {
3673
- k = !0;
3674
- }, void 0, function() {
3675
- if (k)
3676
- try {
3677
- s--;
3678
- for (var y = function() {
3679
- var E = u.shift();
3680
- o || d(E);
3681
- }; u.length && s < i; )
3682
- y();
3683
- c();
3684
- } catch (E) {
3685
- n.error(E);
3686
- }
3687
- }));
3688
- };
3689
- return e.subscribe(Pe(n, h, function() {
3690
- _ = !0, c();
3691
- })), function() {
3692
- };
3693
- }
3694
- function Qi(e, n, t) {
3695
- return t === void 0 && (t = 1 / 0), z(n) ? Qi(function(i, a) {
3696
- return Ji(function(r, o) {
3697
- return n(i, r, a, o);
3698
- })(Ee(e(i, a)));
3699
- }, t) : (typeof n == "number" && (t = n), $e(function(i, a) {
3700
- return $s(i, a, e, t);
3701
- }));
3702
- }
3703
- function Es(e) {
3704
- return e === void 0 && (e = 1 / 0), Qi(Di, e);
3705
- }
3706
- function Cs() {
3707
- for (var e = [], n = 0; n < arguments.length; n++)
3708
- e[n] = arguments[n];
3709
- var t = os(e), i = ss(e, 1 / 0), a = e;
3710
- return a.length ? a.length === 1 ? Ee(a[0]) : Es(i)(vs(a, t)) : rs;
3711
- }
3712
- function Ss(e, n, t, i, a) {
3713
- return function(r, o) {
3714
- var l = t, u = n, s = 0;
3715
- r.subscribe(Pe(o, function(f) {
3716
- var _ = s++;
3717
- u = l ? e(u, f, _) : (l = !0, f);
3718
- }, function() {
3719
- l && o.next(u), o.complete();
3720
- }));
3721
- };
3722
- }
3723
- function er(e, n) {
3724
- return $e(Ss(e, n, arguments.length >= 2, !1, !0));
3725
- }
3726
- var Ns = function(e, n) {
3727
- return e.push(n), e;
3728
- };
3729
- function Is() {
3730
- return $e(function(e, n) {
3731
- er(Ns, [])(e).subscribe(n);
3732
- });
3733
- }
3734
- const Hn = -2003829722, It = -2021002517;
3735
- function Ts(e) {
3736
- return new TextDecoder().decode(e);
3737
- }
3738
- function jn(e) {
3739
- const n = e ? "big" : "little", t = new S().endianess(n).int32("magic").uint16("version").uint16("numZoomLevels").uint64("chromTreeOffset").uint64("unzoomedDataOffset").uint64("unzoomedIndexOffset").uint16("fieldCount").uint16("definedFieldCount").uint64("asOffset").uint64("totalSummaryOffset").uint32("uncompressBufSize").uint64("extHeaderOffset").array("zoomLevels", {
3740
- length: "numZoomLevels",
3741
- type: new S().endianess(n).uint32("reductionLevel").uint32("reserved").uint64("dataOffset").uint64("indexOffset")
3742
- }), i = new S().endianess(n).uint64("basesCovered").doublele("scoreMin").doublele("scoreMax").doublele("scoreSum").doublele("scoreSumSquares"), a = new S().endianess(n).uint32("magic").uint32("blockSize").uint32("keySize").uint32("valSize").uint64("itemCount"), r = new S().endianess(n).uint8("isLeafNode").skip(1).uint16("cnt").saveOffset("offset");
3743
- return {
3744
- chromTreeParser: a,
3745
- totalSummaryParser: i,
3746
- headerParser: t,
3747
- isLeafNode: r
3748
- };
3749
- }
3750
- class tr {
3751
- getHeader(n) {
3752
- return this.headerP || (this.headerP = this._getHeader(n).catch((t) => {
3753
- throw this.headerP = void 0, t;
3754
- })), this.headerP;
3755
- }
3756
- /*
3757
- * @param filehandle - a filehandle from generic-filehandle or implementing something similar to the node10 fs.promises API
3758
- *
3759
- * @param path - a Local file path as a string
3760
- *
3761
- * @param url - a URL string
3762
- *
3763
- * @param renameRefSeqs - an optional method to rename the internal reference
3764
- * sequences using a mapping function
3765
- */
3766
- constructor(n) {
3767
- const { filehandle: t, renameRefSeqs: i = (o) => o, path: a, url: r } = n;
3768
- if (this.renameRefSeqs = i, t)
3769
- this.bbi = t;
3770
- else if (r)
3771
- this.bbi = new ir(r);
3772
- else if (a)
3773
- this.bbi = new nr(a);
3774
- else
3775
- throw new Error("no file given");
3776
- }
3777
- async _getHeader(n) {
3778
- const t = await this._getMainHeader(n), i = await this._readChromTree(t, n);
3779
- return { ...t, ...i };
3780
- }
3781
- async _getMainHeader(n, t = 2e3) {
3782
- const { buffer: i } = await this.bbi.read(J.Buffer.alloc(t), 0, t, 0, n), a = this._isBigEndian(i), r = jn(a), o = r.headerParser.parse(i), { magic: l, asOffset: u, totalSummaryOffset: s } = o;
3783
- if (o.fileType = l === It ? "bigbed" : "bigwig", u > t || s > t)
3784
- return this._getMainHeader(n, t * 2);
3785
- if (u) {
3786
- const f = Number(o.asOffset);
3787
- o.autoSql = Ts(i.subarray(f, i.indexOf(0, f)));
3788
- }
3789
- if (o.totalSummaryOffset > t - 8 * 5)
3790
- return this._getMainHeader(n, t * 2);
3791
- if (o.totalSummaryOffset) {
3792
- const f = i.subarray(Number(o.totalSummaryOffset)), _ = r.totalSummaryParser.parse(f);
3793
- o.totalSummary = { ..._, basesCovered: Number(_.basesCovered) };
3794
- }
3795
- return { ...o, isBigEndian: a };
3796
- }
3797
- _isBigEndian(n) {
3798
- let t = n.readInt32LE(0);
3799
- if (t === Hn || t === It)
3800
- return !1;
3801
- if (t = n.readInt32BE(0), t === Hn || t === It)
3802
- return !0;
3803
- throw new Error("not a BigWig/BigBed file");
3804
- }
3805
- // todo: add progress if long running
3806
- async _readChromTree(n, t) {
3807
- const i = n.isBigEndian, a = i ? "big" : "little", r = [], o = {};
3808
- let l = Number(n.unzoomedDataOffset);
3809
- const u = Number(n.chromTreeOffset);
3810
- for (; l % 4 !== 0; )
3811
- l += 1;
3812
- const s = l - u, { buffer: f } = await this.bbi.read(J.Buffer.alloc(s), 0, s, Number(u), t), _ = jn(i), { keySize: c } = _.chromTreeParser.parse(f), h = new S().endianess(a).string("key", { stripNull: !0, length: c }).uint32("refId").uint32("refSize").saveOffset("offset"), d = new S().endianess(a).skip(c).uint64("childOffset").saveOffset("offset"), g = 32, k = async (y) => {
3813
- let E = y;
3814
- if (E >= f.length)
3815
- throw new Error("reading beyond end of buffer");
3816
- const C = _.isLeafNode.parse(f.subarray(E)), { isLeafNode: p, cnt: $ } = C;
3817
- if (E += C.offset, p)
3818
- for (let N = 0; N < $; N += 1) {
3819
- const b = h.parse(f.subarray(E));
3820
- E += b.offset;
3821
- const { key: m, refId: w, refSize: v } = b, I = { name: m, id: w, length: v };
3822
- o[this.renameRefSeqs(m)] = w, r[w] = I;
3823
- }
3824
- else {
3825
- const N = [];
3826
- for (let b = 0; b < $; b += 1) {
3827
- const m = d.parse(f.subarray(E)), { childOffset: w } = m;
3828
- E += m.offset, N.push(k(Number(w) - Number(u)));
3829
- }
3830
- await Promise.all(N);
3831
- }
3832
- };
3833
- return await k(g), {
3834
- refsByName: o,
3835
- refsByNumber: r
3836
- };
3837
- }
3838
- /*
3839
- * fetches the "unzoomed" view of the bigwig data. this is the default for bigbed
3840
- * @param abortSignal - a signal to optionally abort this operation
3841
- */
3842
- async getUnzoomedView(n) {
3843
- const { unzoomedIndexOffset: t, refsByName: i, uncompressBufSize: a, isBigEndian: r, fileType: o } = await this.getHeader(n);
3844
- return new Ti(this.bbi, i, t, r, a > 0, o);
3845
- }
3846
- /**
3847
- * Gets features from a BigWig file
3848
- *
3849
- * @param refName - The chromosome name
3850
- * @param start - The start of a region
3851
- * @param end - The end of a region
3852
- * @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use
3853
- */
3854
- async getFeatureStream(n, t, i, a) {
3855
- await this.getHeader(a);
3856
- const r = this.renameRefSeqs(n);
3857
- let o;
3858
- const { basesPerSpan: l, scale: u } = a || {};
3859
- return l ? o = await this.getView(1 / l, a) : u ? o = await this.getView(u, a) : o = await this.getView(1, a), new Z((s) => {
3860
- o.readWigData(r, t, i, s, a).catch((f) => s.error(f));
3861
- });
3862
- }
3863
- async getFeatures(n, t, i, a) {
3864
- const r = await this.getFeatureStream(n, t, i, a);
3865
- return (await qi(r.pipe(Is()))).flat();
3866
- }
3867
- }
3868
- class Fs extends tr {
3869
- /**
3870
- * Retrieves a BlockView of a specific zoomLevel
3871
- *
3872
- * @param scale - number
3873
- *
3874
- * @param opts - An object containing basesPerSpan (e.g. pixels per basepair)
3875
- * or scale used to infer the zoomLevel to use
3876
- */
3877
- async getView(n, t) {
3878
- const { zoomLevels: i, refsByName: a, fileSize: r, isBigEndian: o, uncompressBufSize: l } = await this.getHeader(t), u = 1 / n;
3879
- let s = i.length;
3880
- r || (s -= 1);
3881
- for (let f = s; f >= 0; f -= 1) {
3882
- const _ = i[f];
3883
- if (_ && _.reductionLevel <= 2 * u) {
3884
- const c = Number(_.indexOffset);
3885
- return new Ti(this.bbi, a, c, o, l > 0, "summary");
3886
- }
3887
- }
3888
- return this.getUnzoomedView(t);
3889
- }
3890
- }
3891
- function As(e) {
3892
- return e.filter((n) => !!n);
3893
- }
3894
- class Ls extends tr {
3895
- constructor() {
3896
- super(...arguments), this.readIndicesCache = new Gn({
3897
- cache: new Yn({ maxSize: 1 }),
3898
- fill: (n, t) => this._readIndices({ ...n, signal: t })
3899
- });
3900
- }
3901
- readIndices(n = {}) {
3902
- const { signal: t, ...i } = n;
3903
- return this.readIndicesCache.get(JSON.stringify(i), n, t);
3904
- }
3905
- /*
3906
- * retrieve unzoomed view for any scale
3907
- */
3908
- async getView(n, t) {
3909
- return this.getUnzoomedView(t);
3910
- }
3911
- /*
3912
- * parse the bigbed extraIndex fields
3913
- * @param abortSignal to abort operation
3914
- * @return a Promise for an array of Index data structure since there can be multiple extraIndexes in a bigbed, see bedToBigBed documentation
3915
- */
3916
- async _readIndices(n) {
3917
- const { extHeaderOffset: t, isBigEndian: i } = await this.getHeader(n), { buffer: a } = await this.bbi.read(J.Buffer.alloc(64), 0, 64, Number(t)), r = i ? "big" : "little", o = new S().endianess(r).uint16("size").uint16("count").uint64("offset").parse(a), { count: l, offset: u } = o;
3918
- if (l === 0)
3919
- return [];
3920
- const s = 20, f = s * l, { buffer: _ } = await this.bbi.read(J.Buffer.alloc(f), 0, f, Number(u)), c = new S().endianess(r).int16("type").int16("fieldcount").uint64("offset").skip(4).int16("field"), h = [];
3921
- for (let d = 0; d < l; d += 1)
3922
- h.push(c.parse(_.subarray(d * s)));
3923
- return h;
3924
- }
3925
- /*
3926
- * perform a search in the bigbed extraIndex to find which blocks in the bigbed data to look for the
3927
- * actual feature data
3928
- *
3929
- * @param name - the name to search for
3930
- * @param opts - a SearchOptions argument with optional signal
3931
- * @return a Promise for an array of bigbed block Loc entries
3932
- */
3933
- async searchExtraIndexBlocks(n, t = {}) {
3934
- const { isBigEndian: i } = await this.getHeader(t), a = await this.readIndices(t);
3935
- if (a.length === 0)
3936
- return [];
3937
- const r = a.map(async (o) => {
3938
- const { offset: l, field: u } = o, { buffer: s } = await this.bbi.read(J.Buffer.alloc(32), 0, 32, Number(l), t), f = i ? "big" : "little", _ = new S().endianess(f).int32("magic").int32("blockSize").int32("keySize").int32("valSize").uint64("itemCount"), { blockSize: c, keySize: h, valSize: d } = _.parse(s), g = new S().endianess(f).int8("nodeType").skip(1).int16("cnt").choice({
3939
- tag: "nodeType",
3940
- choices: {
3941
- 0: new S().array("leafkeys", {
3942
- length: "cnt",
3943
- type: new S().endianess(f).string("key", { length: h, stripNull: !0 }).uint64("offset")
3944
- }),
3945
- 1: new S().array("keys", {
3946
- length: "cnt",
3947
- type: new S().endianess(f).string("key", { length: h, stripNull: !0 }).uint64("offset").uint32("length").uint32("reserved")
3948
- })
3949
- }
3950
- }), k = async (E) => {
3951
- const C = Number(E), p = 4 + c * (h + d), { buffer: $ } = await this.bbi.read(J.Buffer.alloc(p), 0, p, C, t), N = g.parse($);
3952
- if (N.leafkeys) {
3953
- let b;
3954
- for (const { key: m, offset: w } of N.leafkeys) {
3955
- if (n.localeCompare(m) < 0 && b)
3956
- return k(b);
3957
- b = w;
3958
- }
3959
- return k(b);
3960
- }
3961
- for (const b of N.keys)
3962
- if (b.key === n)
3963
- return { ...b, field: u };
3964
- };
3965
- return k(Number(l) + 32);
3966
- });
3967
- return As(await Promise.all(r));
3968
- }
3969
- /*
3970
- * retrieve the features from the bigbed data that were found through the
3971
- * lookup of the extraIndex note that there can be multiple extraIndex, see
3972
- * the BigBed specification and the -extraIndex argument to bedToBigBed
3973
- *
3974
- * @param name - the name to search for
3975
- * @param opts - a SearchOptions argument with optional signal
3976
- * @return a Promise for an array of Feature
3977
- */
3978
- async searchExtraIndex(n, t = {}) {
3979
- const i = await this.searchExtraIndexBlocks(n, t);
3980
- if (i.length === 0)
3981
- return [];
3982
- const a = await this.getUnzoomedView(t), r = i.map((l) => new Z((u) => {
3983
- a.readFeatures(u, [l], t).catch((s) => u.error(s));
3984
- }).pipe(er((u, s) => u.concat(s)), Ji((u) => {
3985
- for (const s of u)
3986
- s.field = l.field;
3987
- return u;
3988
- })));
3989
- return (await qi(Cs(...r))).filter((l) => {
3990
- var u;
3991
- return ((u = l.rest) === null || u === void 0 ? void 0 : u.split(" ")[(l.field || 0) - 3]) === n;
3992
- });
3993
- }
3994
- }
3995
- export {
3996
- Ls as BigBed,
3997
- Fs as BigWig
3998
- };