@genome-spy/app 0.75.0 → 0.77.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.
Files changed (71) hide show
  1. package/dist/AbortablePromiseCache-beUIcZcW.js +96 -0
  2. package/dist/agentApi-ClsLtELB.js +26994 -0
  3. package/dist/agentApi.es.js +11145 -0
  4. package/dist/agentShared.es.js +4742 -0
  5. package/dist/{blosc-oa0DlI6G.js → blosc-BX4BJ8sR.js} +1 -1
  6. package/dist/blosc-DL1kZHdE.js +692 -0
  7. package/dist/chunk-INHXZS53-Dx2aFznx.js +13 -0
  8. package/dist/componentStyles-CIXoKEp0.js +2182 -0
  9. package/dist/dialog.es.js +377 -0
  10. package/dist/esm-CHVYSGF2.js +1084 -0
  11. package/dist/esm-CZvS2Ldm.js +155 -0
  12. package/dist/esm-C_XrKaCY.js +137 -0
  13. package/dist/{esm-DCCYNvaz.js → esm-CqrZuhTF.js} +50 -50
  14. package/dist/{esm-D-WfYOx7.js → esm-Cz4iCfzF.js} +25 -25
  15. package/dist/esm-D-y0Ce1M.js +573 -0
  16. package/dist/esm-D2-C5ZzN.js +1084 -0
  17. package/dist/esm-DPS6pYKF.js +1248 -0
  18. package/dist/esm-Dfo2M18m.js +461 -0
  19. package/dist/esm-DjF6pKy5.js +369 -0
  20. package/dist/{esm-n0auOe11.js → esm-Q6nrd9vJ.js} +1 -1
  21. package/dist/esm-aOLxLL7A.js +121 -0
  22. package/dist/esm-id9DWBZW.js +137 -0
  23. package/dist/esm-kXhrPIYy.js +1426 -0
  24. package/dist/esm-s_SlArJ8.js +298 -0
  25. package/dist/index.es.js +15272 -37563
  26. package/dist/index.js +1202 -741
  27. package/dist/lit-ymUSmGBw.js +510 -0
  28. package/dist/{lz4-jZ0zyLBa.js → lz4-BSYl80V8.js} +1 -1
  29. package/dist/lz4-Csz5aoFA.js +626 -0
  30. package/dist/parquetRead-m8-8_SpH.js +1609 -0
  31. package/dist/schema.json +489 -85
  32. package/dist/style.css +1 -1
  33. package/dist/viewUtils-3_xHIxmy.js +14292 -0
  34. package/dist/{zstd-C6ksIG9r.js → zstd-BAfRM3IH.js} +1 -1
  35. package/dist/zstd-dJuUp1fl.js +583 -0
  36. package/package.json +30 -5
  37. package/src/agentApi/index.d.ts +147 -0
  38. package/src/agentShared/index.d.ts +97 -0
  39. package/src/agentShared/types.d.ts +8 -0
  40. package/src/appTypes.d.ts +75 -0
  41. package/src/bookmark/databaseSchema.d.ts +33 -0
  42. package/src/charts/boxplotTypes.d.ts +15 -0
  43. package/src/charts/sampleAttributePlotTypes.d.ts +149 -0
  44. package/src/coreSpecAugmentation.d.ts +29 -0
  45. package/src/dialog/index.d.ts +5 -0
  46. package/src/embedTypes.d.ts +9 -0
  47. package/src/index.d.ts +16 -0
  48. package/src/sampleView/sampleViewTypes.d.ts +176 -0
  49. package/src/sampleView/state/payloadTypes.d.ts +484 -0
  50. package/src/sampleView/state/sampleState.d.ts +76 -0
  51. package/src/sampleView/types.d.ts +128 -0
  52. package/src/spec/appSpec.d.ts +54 -0
  53. package/src/spec/sampleView.d.ts +545 -0
  54. package/src/spec/view.d.ts +124 -0
  55. package/src/state/paramProvenanceTypes.d.ts +215 -0
  56. package/src/state/selectionExpansionTypes.d.ts +77 -0
  57. package/src/state.d.ts +97 -0
  58. package/src/types/lz-string.d.ts +24 -0
  59. package/src/types/vega-loader.d.ts +1 -0
  60. package/src/utils/colorScaleSummary.d.ts +15 -0
  61. package/src/utils/statistics/fieldSummary.d.ts +49 -0
  62. package/src/vite-env.d.ts +6 -0
  63. package/dist/browser-Dvlo92rx.js +0 -126
  64. package/dist/esm-Cmo4qEPr.js +0 -1015
  65. /package/dist/{AbortablePromiseCache-3gHJdF3E.js → AbortablePromiseCache-BDH1cqFl.js} +0 -0
  66. /package/dist/{chunk-INHXZS53-fPMmEwMt.js → chunk-INHXZS53-DwEV9sMh.js} +0 -0
  67. /package/dist/{esm-BygJiwh0.js → esm-BL9SNSnj.js} +0 -0
  68. /package/dist/{esm-B8-vSu-c.js → esm-BwW--bVV.js} +0 -0
  69. /package/dist/{esm-CGX-qz1d.js → esm-Bz_92nH0.js} +0 -0
  70. /package/dist/{esm-CuMSzCHy.js → esm-D2_c7lXY.js} +0 -0
  71. /package/dist/{parquetRead-CJe1UPsz.js → parquetRead-C33mgLEo.js} +0 -0
@@ -0,0 +1,461 @@
1
+ import { n as e, r as t } from "./esm-DPS6pYKF.js";
2
+ import { t as n } from "./esm-Bz_92nH0.js";
3
+ import { n as r, r as i } from "./esm-C_XrKaCY.js";
4
+ import { t as a } from "./AbortablePromiseCache-BDH1cqFl.js";
5
+ //#region ../../node_modules/@gmod/tabix/esm/chunk.js
6
+ var o = class {
7
+ constructor(e, t, n, r) {
8
+ this.minv = e, this.maxv = t, this.bin = n, this._fetchedSize = r;
9
+ }
10
+ toUniqueString() {
11
+ return `${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
12
+ }
13
+ toString() {
14
+ return this.toUniqueString();
15
+ }
16
+ compareTo(e) {
17
+ return this.minv.compareTo(e.minv) || this.maxv.compareTo(e.maxv) || this.bin - e.bin;
18
+ }
19
+ fetchedSize() {
20
+ return this._fetchedSize === void 0 ? this.maxv.blockPosition + 65536 - this.minv.blockPosition : this._fetchedSize;
21
+ }
22
+ }, s = class {
23
+ constructor({ filehandle: e, renameRefSeqs: t = (e) => e }) {
24
+ this.filehandle = e, this.renameRefSeq = t;
25
+ }
26
+ async getMetadata(e = {}) {
27
+ let { indices: t, ...n } = await this.parse(e);
28
+ return n;
29
+ }
30
+ _findFirstData(e, t) {
31
+ return e ? e.compareTo(t) > 0 ? t : e : t;
32
+ }
33
+ async parse(e = {}) {
34
+ return this.parseP ||= this._parse(e).catch((e) => {
35
+ throw this.parseP = void 0, e;
36
+ }), this.parseP;
37
+ }
38
+ async hasRefSeq(e, t = {}) {
39
+ return !!(await this.parse(t)).indices[e]?.binIndex;
40
+ }
41
+ _parseNameBytes(e) {
42
+ let t = 0, n = 0, r = [], i = {}, a = new TextDecoder("utf8");
43
+ for (let o = 0; o < e.length; o += 1) if (!e[o]) {
44
+ if (n < o) {
45
+ let s = this.renameRefSeq(a.decode(e.subarray(n, o)));
46
+ r[t] = s, i[s] = t;
47
+ }
48
+ n = o + 1, t += 1;
49
+ }
50
+ return {
51
+ refNameToId: i,
52
+ refIdToName: r
53
+ };
54
+ }
55
+ }, c = 65536, l = c * c;
56
+ function u(e, t = 0) {
57
+ let n = e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24;
58
+ return ((e[t + 4] | e[t + 5] << 8 | e[t + 6] << 16 | e[t + 7] << 24) >>> 0) * l + (n >>> 0);
59
+ }
60
+ //#endregion
61
+ //#region ../../node_modules/@gmod/tabix/esm/util.js
62
+ function d(e, t) {
63
+ return t.minv.blockPosition - e.maxv.blockPosition < 65e3 && t.maxv.blockPosition - e.minv.blockPosition < 5e6;
64
+ }
65
+ function f(e, t) {
66
+ let n = [], r;
67
+ if (e.length === 0) return e;
68
+ e.sort(function(e, t) {
69
+ let n = e.minv.blockPosition - t.minv.blockPosition;
70
+ return n === 0 ? e.minv.dataPosition - t.minv.dataPosition : n;
71
+ });
72
+ for (let i of e) (!t || i.maxv.compareTo(t) > 0) && (r === void 0 ? (n.push(i), r = i) : d(r, i) ? i.maxv.compareTo(r.maxv) > 0 && (r.maxv = i.maxv) : (n.push(i), r = i));
73
+ return n;
74
+ }
75
+ //#endregion
76
+ //#region ../../node_modules/@gmod/tabix/esm/virtualOffset.js
77
+ var p = class {
78
+ constructor(e, t) {
79
+ this.blockPosition = e, this.dataPosition = t;
80
+ }
81
+ toString() {
82
+ return `${this.blockPosition}:${this.dataPosition}`;
83
+ }
84
+ compareTo(e) {
85
+ return this.blockPosition - e.blockPosition || this.dataPosition - e.dataPosition;
86
+ }
87
+ };
88
+ function m(e, t = 0) {
89
+ return new p(e[t + 7] * 1099511627776 + e[t + 6] * 4294967296 + e[t + 5] * 16777216 + e[t + 4] * 65536 + e[t + 3] * 256 + e[t + 2], e[t + 1] << 8 | e[t]);
90
+ }
91
+ //#endregion
92
+ //#region ../../node_modules/@gmod/tabix/esm/csi.js
93
+ var h = 21582659, g = 38359875, _ = {
94
+ 0: "generic",
95
+ 1: "SAM",
96
+ 2: "VCF"
97
+ };
98
+ function v(e, t) {
99
+ return e * 2 ** t;
100
+ }
101
+ function y(e, t) {
102
+ return Math.floor(e / 2 ** t);
103
+ }
104
+ var b = class extends s {
105
+ constructor(e) {
106
+ super(e), this.maxBinNumber = 0, this.depth = 0, this.minShift = 0;
107
+ }
108
+ async lineCount(e, t = {}) {
109
+ let n = await this.parse(t), r = n.refNameToId[e];
110
+ if (r === void 0 || !n.indices[r]) return -1;
111
+ let { stats: i } = n.indices[r];
112
+ return i ? i.lineCount : -1;
113
+ }
114
+ indexCov() {
115
+ throw Error("CSI indexes do not support indexcov");
116
+ }
117
+ parseAuxData(e, t) {
118
+ let n = new DataView(e.buffer), r = n.getInt32(t, !0), i = r & 65536 ? "zero-based-half-open" : "1-based-closed", a = _[r & 15];
119
+ if (!a) throw Error(`invalid Tabix preset format flags ${r}`);
120
+ let o = {
121
+ ref: n.getInt32(t + 4, !0),
122
+ start: n.getInt32(t + 8, !0),
123
+ end: n.getInt32(t + 12, !0)
124
+ }, s = n.getInt32(t + 16, !0), c = s ? String.fromCharCode(s) : void 0, l = n.getInt32(t + 20, !0), u = n.getInt32(t + 24, !0), { refIdToName: d, refNameToId: f } = this._parseNameBytes(e.subarray(t + 28, t + 28 + u));
125
+ return {
126
+ refIdToName: d,
127
+ refNameToId: f,
128
+ skipLines: l,
129
+ metaChar: c,
130
+ columnNumbers: o,
131
+ format: a,
132
+ coordinateType: i
133
+ };
134
+ }
135
+ async _parse(t = {}) {
136
+ let n = await e(await this.filehandle.readFile(t)), r = new DataView(n.buffer), i;
137
+ if (r.getUint32(0, !0) === h) i = 1;
138
+ else if (r.getUint32(0, !0) === g) i = 2;
139
+ else throw Error("Not a CSI file");
140
+ this.minShift = r.getInt32(4, !0), this.depth = r.getInt32(8, !0), this.maxBinNumber = ((1 << (this.depth + 1) * 3) - 1) / 7;
141
+ let a = 2 ** (this.minShift + this.depth * 3), s = r.getInt32(12, !0), c = s && s >= 30 ? this.parseAuxData(n, 16) : {
142
+ refIdToName: [],
143
+ refNameToId: {},
144
+ metaChar: void 0,
145
+ columnNumbers: {
146
+ ref: 0,
147
+ start: 1,
148
+ end: 2
149
+ },
150
+ coordinateType: "zero-based-half-open",
151
+ format: "generic"
152
+ }, l = r.getInt32(16 + s, !0), u, d = 16 + s + 4, f = Array(l).fill(0).map(() => {
153
+ let e = r.getInt32(d, !0);
154
+ d += 4;
155
+ let t = {}, i;
156
+ for (let a = 0; a < e; a += 1) {
157
+ let e = r.getUint32(d, !0);
158
+ if (e > this.maxBinNumber) i = this.parsePseudoBin(n, d + 4), d += 48;
159
+ else {
160
+ let i = m(n, d + 4);
161
+ u = this._findFirstData(u, i);
162
+ let a = r.getInt32(d + 12, !0);
163
+ d += 16;
164
+ let s = Array(a);
165
+ for (let t = 0; t < a; t += 1) {
166
+ let r = m(n, d), i = m(n, d + 8);
167
+ d += 16, s[t] = new o(r, i, e);
168
+ }
169
+ t[e] = s;
170
+ }
171
+ }
172
+ return {
173
+ binIndex: t,
174
+ stats: i
175
+ };
176
+ });
177
+ return {
178
+ ...c,
179
+ csi: !0,
180
+ refCount: l,
181
+ maxBlockSize: 65536,
182
+ firstDataLine: u,
183
+ csiVersion: i,
184
+ indices: f,
185
+ depth: this.depth,
186
+ maxBinNumber: this.maxBinNumber,
187
+ maxRefLength: a
188
+ };
189
+ }
190
+ parsePseudoBin(e, t) {
191
+ return { lineCount: u(e, t + 28) };
192
+ }
193
+ async blocksForRange(e, t, n, r = {}) {
194
+ t < 0 && (t = 0);
195
+ let i = await this.parse(r), a = i.refNameToId[e];
196
+ if (a === void 0) return [];
197
+ let s = i.indices[a];
198
+ if (!s) return [];
199
+ let c = this.reg2bins(t, n), l = [];
200
+ for (let [e, t] of c) for (let n = e; n <= t; n++) if (s.binIndex[n]) for (let e of s.binIndex[n]) l.push(new o(e.minv, e.maxv, n));
201
+ return f(l, new p(0, 0));
202
+ }
203
+ reg2bins(e, t) {
204
+ --e, e < 1 && (e = 1), t > 2 ** 50 && (t = 2 ** 34), --t;
205
+ let n = 0, r = 0, i = this.minShift + this.depth * 3, a = [];
206
+ for (; n <= this.depth; i -= 3, r += v(1, n * 3), n += 1) {
207
+ let n = r + y(e, i), o = r + y(t, i);
208
+ if (o - n + a.length > this.maxBinNumber) throw Error(`query ${e}-${t} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);
209
+ a.push([n, o]);
210
+ }
211
+ return a;
212
+ }
213
+ }, x = 21578324, S = 14;
214
+ function C(e, t) {
215
+ return e += 1, --t, [
216
+ [0, 0],
217
+ [1 + (e >> 26), 1 + (t >> 26)],
218
+ [9 + (e >> 23), 9 + (t >> 23)],
219
+ [73 + (e >> 20), 73 + (t >> 20)],
220
+ [585 + (e >> 17), 585 + (t >> 17)],
221
+ [4681 + (e >> 14), 4681 + (t >> 14)]
222
+ ];
223
+ }
224
+ var w = class extends s {
225
+ async lineCount(e, t = {}) {
226
+ let n = await this.parse(t), r = n.refNameToId[e];
227
+ return r === void 0 || !n.indices[r] ? -1 : n.indices[r].stats?.lineCount ?? -1;
228
+ }
229
+ async _parse(t = {}) {
230
+ let n = await e(await this.filehandle.readFile(t)), r = new DataView(n.buffer);
231
+ if (r.getUint32(0, !0) !== x) throw Error("Not a TBI file");
232
+ let i = r.getUint32(4, !0), a = r.getUint32(8, !0), s = a & 65536 ? "zero-based-half-open" : "1-based-closed", c = {
233
+ 0: "generic",
234
+ 1: "SAM",
235
+ 2: "VCF"
236
+ }[a & 15];
237
+ if (!c) throw Error(`invalid Tabix preset format flags ${a}`);
238
+ let l = {
239
+ ref: r.getInt32(12, !0),
240
+ start: r.getInt32(16, !0),
241
+ end: r.getInt32(20, !0)
242
+ }, u = r.getInt32(24, !0), d = ((1 << 18) - 1) / 7, f = 2 ** 29, p = u ? String.fromCharCode(u) : void 0, h = r.getInt32(28, !0), g = r.getInt32(32, !0), { refNameToId: _, refIdToName: v } = this._parseNameBytes(n.slice(36, 36 + g)), y = 36 + g, b;
243
+ return {
244
+ indices: Array(i).fill(0).map(() => {
245
+ let e = r.getInt32(y, !0);
246
+ y += 4;
247
+ let t = {}, i;
248
+ for (let a = 0; a < e; a += 1) {
249
+ let e = r.getUint32(y, !0);
250
+ if (y += 4, e > d + 1) throw Error("tabix index contains too many bins, please use a CSI index");
251
+ if (e === d + 1) {
252
+ let e = r.getInt32(y, !0);
253
+ y += 4, e === 2 && (i = this.parsePseudoBin(n, y)), y += 16 * e;
254
+ } else {
255
+ let i = r.getInt32(y, !0);
256
+ y += 4;
257
+ let a = Array(i);
258
+ for (let t = 0; t < i; t += 1) {
259
+ let r = m(n, y), i = m(n, y + 8);
260
+ y += 16, b = this._findFirstData(b, r), a[t] = new o(r, i, e);
261
+ }
262
+ t[e] = a;
263
+ }
264
+ }
265
+ let a = r.getInt32(y, !0);
266
+ y += 4;
267
+ let s = Array(a);
268
+ for (let e = 0; e < a; e += 1) s[e] = m(n, y), y += 8, b = this._findFirstData(b, s[e]);
269
+ return {
270
+ binIndex: t,
271
+ linearIndex: s,
272
+ stats: i
273
+ };
274
+ }),
275
+ metaChar: p,
276
+ maxBinNumber: d,
277
+ maxRefLength: f,
278
+ skipLines: h,
279
+ firstDataLine: b,
280
+ columnNumbers: l,
281
+ coordinateType: s,
282
+ format: c,
283
+ refIdToName: v,
284
+ refNameToId: _,
285
+ maxBlockSize: 65536
286
+ };
287
+ }
288
+ parsePseudoBin(e, t) {
289
+ return { lineCount: u(e, t + 16) };
290
+ }
291
+ async blocksForRange(e, t, n, r = {}) {
292
+ t < 0 && (t = 0);
293
+ let i = await this.parse(r), a = i.refNameToId[e];
294
+ if (a === void 0) return [];
295
+ let s = i.indices[a];
296
+ if (!s) return [];
297
+ (s.linearIndex.length > 0 ? s.linearIndex[t >> S >= s.linearIndex.length ? s.linearIndex.length - 1 : t >> S] : new p(0, 0)) || console.warn("querying outside of possible tabix range");
298
+ let c = C(t, n), l = [];
299
+ for (let [e, t] of c) for (let n = e; n <= t; n++) if (s.binIndex[n]) for (let e of s.binIndex[n]) l.push(new o(e.minv, e.maxv, n));
300
+ let u = s.linearIndex.length, d, m = Math.min(t >> 14, u - 1), h = Math.min(n >> 14, u - 1);
301
+ for (let e = m; e <= h; ++e) {
302
+ let t = s.linearIndex[e];
303
+ t && (!d || t.compareTo(d) < 0) && (d = t);
304
+ }
305
+ return f(l, d);
306
+ }
307
+ }, T = class {
308
+ constructor({ path: e, filehandle: t, url: o, tbiPath: s, tbiUrl: c, tbiFilehandle: l, csiPath: u, csiUrl: d, csiFilehandle: f, renameRefSeqs: p, chunkCacheSize: m = 5 * 2 ** 20 }) {
309
+ this.cache = new n({ maxSize: 1e3 });
310
+ let h = p ?? ((e) => e);
311
+ if (t) this.filehandle = t;
312
+ else if (e) this.filehandle = new r(e);
313
+ else if (o) this.filehandle = new i(o);
314
+ else throw TypeError("must provide either filehandle or path");
315
+ if (l) this.index = new w({
316
+ filehandle: l,
317
+ renameRefSeqs: h
318
+ });
319
+ else if (f) this.index = new b({
320
+ filehandle: f,
321
+ renameRefSeqs: h
322
+ });
323
+ else if (s) this.index = new w({
324
+ filehandle: new r(s),
325
+ renameRefSeqs: h
326
+ });
327
+ else if (u) this.index = new b({
328
+ filehandle: new r(u),
329
+ renameRefSeqs: h
330
+ });
331
+ else if (e) this.index = new w({
332
+ filehandle: new r(`${e}.tbi`),
333
+ renameRefSeqs: h
334
+ });
335
+ else if (d) this.index = new b({ filehandle: new i(d) });
336
+ else if (c) this.index = new w({ filehandle: new i(c) });
337
+ else if (o) this.index = new w({ filehandle: new i(`${o}.tbi`) });
338
+ else throw TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl");
339
+ this.renameRefSeq = h, this.hasCustomRenameRefSeq = p !== void 0, this.chunkCache = new a({
340
+ cache: new n({ maxSize: Math.floor(m / 65536) }),
341
+ fill: (e, t) => this.readChunk(e, { signal: t })
342
+ });
343
+ }
344
+ calculateFileOffset(e, t, n, r, i) {
345
+ return e[n] * 256 + (r - t[n]) + i + 1;
346
+ }
347
+ async getLines(e, t, n, r) {
348
+ let i, a = {}, o;
349
+ typeof r == "function" ? o = r : (a = r, o = r.lineCallback, i = r.signal);
350
+ let s = await this.index.getMetadata(a), c = t ?? 0, l = n ?? s.maxRefLength;
351
+ if (!(c <= l)) throw TypeError("invalid start and end coordinates. start must be less than or equal to end");
352
+ if (c === l) return;
353
+ let u = await this.index.blocksForRange(e, c, l, a), d = new TextDecoder("utf8"), f = s.format === "VCF", p = {
354
+ ref: s.columnNumbers.ref || 0,
355
+ start: s.columnNumbers.start || 0,
356
+ end: f ? 8 : s.columnNumbers.end || 0
357
+ }, m = Math.max(p.ref, p.start, p.end), h = s.metaChar?.charCodeAt(0), g = s.coordinateType === "1-based-closed" ? -1 : 0, _ = !this.hasCustomRenameRefSeq;
358
+ for (let t of u) {
359
+ let { buffer: n, cpositions: r, dpositions: a } = await this.chunkCache.get(t.toString(), t, i), s = 0, u = 0, v = d.decode(n);
360
+ if (n.length == v.length) for (; s < v.length;) {
361
+ let n = v.indexOf("\n", s);
362
+ if (n === -1) break;
363
+ let i = v.slice(s, n);
364
+ if (a) {
365
+ let e = s + t.minv.dataPosition;
366
+ for (; u < a.length && e >= a[u];) u++;
367
+ }
368
+ let d = this.checkLine(e, c, l, i, p.ref, p.start, p.end, m, h, g, f, _);
369
+ if (d === null) return;
370
+ d !== void 0 && o(i, this.calculateFileOffset(r, a, u, s, t.minv.dataPosition), d.start, d.end), s = n + 1;
371
+ }
372
+ else for (; s < n.length;) {
373
+ let i = n.indexOf(10, s);
374
+ if (i === -1) break;
375
+ let v = n.slice(s, i), y = d.decode(v);
376
+ if (a) {
377
+ let e = s + t.minv.dataPosition;
378
+ for (; u < a.length && e >= a[u];) u++;
379
+ }
380
+ let b = this.checkLine(e, c, l, y, p.ref, p.start, p.end, m, h, g, f, _);
381
+ if (b === null) return;
382
+ b !== void 0 && o(y, this.calculateFileOffset(r, a, u, s, t.minv.dataPosition), b.start, b.end), s = i + 1;
383
+ }
384
+ }
385
+ }
386
+ async getMetadata(e = {}) {
387
+ return this.index.getMetadata(e);
388
+ }
389
+ async getHeaderBuffer(t = {}) {
390
+ let { firstDataLine: n, metaChar: r, maxBlockSize: i } = await this.getMetadata(t), a = (n?.blockPosition || 0) + i, o = await e(await this.filehandle.read(a, 0, t));
391
+ if (r) {
392
+ let e = -1, t = r.charCodeAt(0);
393
+ for (let n = 0, r = o.length; n < r; n++) {
394
+ let r = o[n];
395
+ if (n === e + 1 && r !== t) break;
396
+ r === 10 && (e = n);
397
+ }
398
+ return o.subarray(0, e + 1);
399
+ }
400
+ return o;
401
+ }
402
+ async getHeader(e = {}) {
403
+ let t = new TextDecoder("utf8"), n = await this.getHeaderBuffer(e);
404
+ return t.decode(n);
405
+ }
406
+ async getReferenceSequenceNames(e = {}) {
407
+ return (await this.getMetadata(e)).refIdToName;
408
+ }
409
+ checkLine(e, t, n, r, i, a, o, s, c, l, u, d) {
410
+ if (c !== void 0 && r.charCodeAt(0) === c) return;
411
+ if (r.length < 500) {
412
+ let s = r.split(" "), c = s[i - 1];
413
+ if (!(d ? c === e : this.renameRefSeq(c) === e)) return;
414
+ let f = +s[a - 1] + l;
415
+ if (f >= n) return null;
416
+ let p;
417
+ return p = o === 0 || o === a ? f + 1 : u ? this._getVcfEnd(f, s[3], s[o - 1]) : +s[o - 1], p <= t ? void 0 : {
418
+ start: f,
419
+ end: p
420
+ };
421
+ }
422
+ let f = -1, p = [-1];
423
+ for (let e = 0; e < s; e++) {
424
+ let e = r.indexOf(" ", f + 1);
425
+ if (e === -1) {
426
+ p.push(r.length);
427
+ break;
428
+ }
429
+ p.push(e), f = e;
430
+ }
431
+ let m = r.slice(p[i - 1] + 1, p[i]);
432
+ if (!(d ? m === e : this.renameRefSeq(m) === e)) return;
433
+ let h = +r.slice(p[a - 1] + 1, p[a]) + l;
434
+ if (h >= n) return null;
435
+ let g;
436
+ if (g = o === 0 || o === a ? h + 1 : u ? this._getVcfEnd(h, r.slice(p[3] + 1, p[4]), r.slice(p[o - 1] + 1, p[o])) : +r.slice(p[o - 1] + 1, p[o]), !(g <= t)) return {
437
+ start: h,
438
+ end: g
439
+ };
440
+ }
441
+ _getVcfEnd(e, t, n) {
442
+ let r = e + t.length;
443
+ if (n.includes("SVTYPE=TRA")) return e + 1;
444
+ if (n[0] !== ".") {
445
+ let e = n.indexOf("END=");
446
+ if (e !== -1 && (e === 0 || n[e - 1] === ";")) {
447
+ let t = e + 4, i = n.indexOf(";", t);
448
+ i === -1 && (i = n.length), r = Number.parseInt(n.slice(t, i), 10);
449
+ }
450
+ }
451
+ return r;
452
+ }
453
+ async lineCount(e, t = {}) {
454
+ return this.index.lineCount(e, t);
455
+ }
456
+ async readChunk(e, n = {}) {
457
+ return t(await this.filehandle.read(e.fetchedSize(), e.minv.blockPosition, n), e, this.cache);
458
+ }
459
+ };
460
+ //#endregion
461
+ export { b as CSI, w as TBI, T as TabixIndexedFile };