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