jbrowse-plugin-graphgenomeviewer 7.1.0 → 7.1.2

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 (233) hide show
  1. package/README.md +17 -8
  2. package/dist/chunks/AddTrackWorkflow-RPH4ZFSX.js +2 -0
  3. package/dist/chunks/{AddTrackWorkflow-Q6RY23LF.js.map → AddTrackWorkflow-RPH4ZFSX.js.map} +2 -2
  4. package/dist/chunks/{ChooseSamplesDialog-BNVYBGJQ.js → ChooseSamplesDialog-JRN4YLBY.js} +2 -2
  5. package/dist/chunks/{ChooseWalksDialog-EN3C6AQA.js → ChooseWalksDialog-UXLFZTZJ.js} +2 -2
  6. package/dist/chunks/GbzBaseSyntenyAdapter-LRECKL74.js +2 -0
  7. package/dist/chunks/GbzBaseSyntenyAdapter-LRECKL74.js.map +7 -0
  8. package/dist/chunks/{GraphGenomeView-Z2WZKEEO.js → GraphGenomeView-NJ5XCREB.js} +2 -2
  9. package/dist/chunks/GraphTrackSettingsDialog-47PQ6LM7.js +6 -0
  10. package/dist/chunks/GraphTrackSettingsDialog-47PQ6LM7.js.map +7 -0
  11. package/dist/chunks/{HighlightColorDialog-EYBKFSJU.js → HighlightColorDialog-UK5VDDV6.js} +2 -2
  12. package/dist/chunks/{LinearGraphDisplay-WIBVWRQE.js → LinearGraphDisplay-TXTKAACH.js} +2 -2
  13. package/dist/chunks/MinigraphBubbleAdapter-HW7XQMAI.js +2 -0
  14. package/dist/chunks/MinigraphBubbleAdapter-HW7XQMAI.js.map +7 -0
  15. package/dist/chunks/RgfaTabixAdapter-PSKYWD2X.js +3 -0
  16. package/dist/chunks/RgfaTabixAdapter-PSKYWD2X.js.map +7 -0
  17. package/dist/chunks/{TrackWarningsDialog-QT4YEXGD.js → TrackWarningsDialog-TRYBOIHX.js} +2 -2
  18. package/dist/chunks/WalkTabixSyntenyAdapter-U53JLYVU.js +2 -0
  19. package/dist/chunks/WalkTabixSyntenyAdapter-U53JLYVU.js.map +7 -0
  20. package/dist/chunks/chunk-2MCOY3YG.js +3 -0
  21. package/dist/chunks/chunk-2MCOY3YG.js.map +7 -0
  22. package/dist/chunks/{chunk-EWFJBQDV.js → chunk-5O6YRJHL.js} +2 -2
  23. package/dist/chunks/{chunk-EWFJBQDV.js.map → chunk-5O6YRJHL.js.map} +1 -1
  24. package/dist/chunks/chunk-BUY2PV7D.js +2 -0
  25. package/dist/chunks/chunk-BUY2PV7D.js.map +7 -0
  26. package/dist/chunks/chunk-DVCZ3BOC.js +2 -0
  27. package/dist/chunks/chunk-DVCZ3BOC.js.map +7 -0
  28. package/dist/chunks/{chunk-SAMJE6GH.js → chunk-EGDLEQ47.js} +3 -3
  29. package/dist/chunks/{chunk-SAMJE6GH.js.map → chunk-EGDLEQ47.js.map} +4 -4
  30. package/dist/chunks/chunk-FHZXW7IG.js +2 -0
  31. package/dist/chunks/chunk-FHZXW7IG.js.map +7 -0
  32. package/dist/chunks/{chunk-DZ4OUKQV.js → chunk-FITPB5X6.js} +2 -2
  33. package/dist/chunks/{chunk-DZ4OUKQV.js.map → chunk-FITPB5X6.js.map} +1 -1
  34. package/dist/chunks/chunk-FVK2THE4.js +2 -0
  35. package/dist/chunks/chunk-FVK2THE4.js.map +7 -0
  36. package/dist/chunks/{chunk-AHFQHYJI.js → chunk-IBWORBGY.js} +2 -2
  37. package/dist/chunks/chunk-MND7GAOG.js +2 -0
  38. package/dist/chunks/chunk-MND7GAOG.js.map +7 -0
  39. package/dist/chunks/chunk-MURN3JPK.js +2 -0
  40. package/dist/chunks/chunk-MURN3JPK.js.map +7 -0
  41. package/dist/chunks/{chunk-3Q4RBDCL.js → chunk-N6PQZSAX.js} +1 -1
  42. package/dist/chunks/{chunk-3Q4RBDCL.js.map → chunk-N6PQZSAX.js.map} +1 -1
  43. package/dist/chunks/chunk-NWJYLP6Z.js +4 -0
  44. package/dist/chunks/chunk-NWJYLP6Z.js.map +7 -0
  45. package/dist/chunks/{chunk-YJHYBDYF.js → chunk-S75W27NT.js} +2 -2
  46. package/dist/chunks/{chunk-YJHYBDYF.js.map → chunk-S75W27NT.js.map} +1 -1
  47. package/dist/chunks/{chunk-IXQK7JAW.js → chunk-T4HOC6O3.js} +1 -1
  48. package/dist/chunks/{chunk-IXQK7JAW.js.map → chunk-T4HOC6O3.js.map} +1 -1
  49. package/dist/chunks/{chunk-AU73K7LX.js → chunk-TUKJRVBS.js} +1 -1
  50. package/dist/chunks/{chunk-AU73K7LX.js.map → chunk-TUKJRVBS.js.map} +1 -1
  51. package/dist/chunks/chunk-UGCNPRKC.js +2 -0
  52. package/dist/chunks/{chunk-E3WYW7Z6.js.map → chunk-UGCNPRKC.js.map} +2 -2
  53. package/dist/chunks/{chunk-YSTMDXXX.js → chunk-VJ3SO4CH.js} +1 -1
  54. package/dist/chunks/{chunk-YSTMDXXX.js.map → chunk-VJ3SO4CH.js.map} +1 -1
  55. package/dist/chunks/{chunk-XT766CZ5.js → chunk-W6EQLQ6H.js} +1 -1
  56. package/dist/chunks/{chunk-XT766CZ5.js.map → chunk-W6EQLQ6H.js.map} +1 -1
  57. package/dist/chunks/chunk-WAMBI7OX.js +2 -0
  58. package/dist/chunks/chunk-WAMBI7OX.js.map +7 -0
  59. package/dist/chunks/chunk-WCGVUZWP.js +2 -0
  60. package/dist/chunks/chunk-WCGVUZWP.js.map +7 -0
  61. package/dist/chunks/chunk-WEGWTC52.js +2 -0
  62. package/dist/chunks/chunk-WEGWTC52.js.map +7 -0
  63. package/dist/chunks/chunk-YU7T5WOQ.js +2 -0
  64. package/dist/chunks/{chunk-6OPB7FOJ.js.map → chunk-YU7T5WOQ.js.map} +2 -2
  65. package/dist/chunks/{chunk-446RWIA3.js → chunk-ZMOMFU2B.js} +1 -1
  66. package/dist/chunks/{chunk-446RWIA3.js.map → chunk-ZMOMFU2B.js.map} +1 -1
  67. package/dist/chunks/renderSvg-KSQI5DH6.js +2 -0
  68. package/dist/chunks/renderSvg-KSQI5DH6.js.map +7 -0
  69. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  70. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  71. package/package.json +8 -9
  72. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +12 -10
  73. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +31 -39
  74. package/src/GbzBaseSyntenyAdapter/configSchema.ts +5 -29
  75. package/src/GetGraphHaplotypes.ts +6 -15
  76. package/src/GetGraphReads.ts +7 -14
  77. package/src/GetSubgraph.ts +11 -20
  78. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.test.tsx +73 -0
  79. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.tsx +1 -0
  80. package/src/GraphAddTrackWorkflow/buildTrackConfig.test.ts +3 -2
  81. package/src/GraphAddTrackWorkflow/buildTrackConfig.ts +2 -11
  82. package/src/GraphAddTrackWorkflow/graphManifest.ts +15 -3
  83. package/src/GraphGenomeView/components/BubbleHalos.tsx +5 -24
  84. package/src/GraphGenomeView/components/ElTree.tsx +6 -1
  85. package/src/GraphGenomeView/components/FacetPanels.test.tsx +65 -0
  86. package/src/GraphGenomeView/components/FacetPanels.tsx +17 -12
  87. package/src/GraphGenomeView/components/GenePins.tsx +5 -22
  88. package/src/GraphGenomeView/components/GraphCanvas.tsx +40 -234
  89. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +102 -108
  90. package/src/GraphGenomeView/components/GraphToolbar.tsx +5 -6
  91. package/src/GraphGenomeView/components/HoverLayer.tsx +3 -7
  92. package/src/GraphGenomeView/components/HoverTooltip.test.tsx +39 -0
  93. package/src/GraphGenomeView/components/HoverTooltip.tsx +122 -0
  94. package/src/GraphGenomeView/components/LabelChip.tsx +3 -5
  95. package/src/GraphGenomeView/components/LabelLayer.tsx +4 -17
  96. package/src/GraphGenomeView/components/LabelledSelect.tsx +1 -1
  97. package/src/GraphGenomeView/components/Legend.tsx +14 -23
  98. package/src/GraphGenomeView/components/PaneContextMenu.test.tsx +48 -0
  99. package/src/GraphGenomeView/components/PaneContextMenu.tsx +144 -0
  100. package/src/GraphGenomeView/components/PaneLayer.tsx +91 -0
  101. package/src/GraphGenomeView/components/PaneSvg.tsx +32 -50
  102. package/src/GraphGenomeView/components/ReferenceStripOverlay.test.tsx +48 -0
  103. package/src/GraphGenomeView/components/ReferenceStripOverlay.tsx +13 -42
  104. package/src/GraphGenomeView/components/SettingsMenu.test.tsx +29 -0
  105. package/src/GraphGenomeView/components/SettingsMenu.tsx +56 -65
  106. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +15 -46
  107. package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +58 -132
  108. package/src/GraphGenomeView/components/WalkStrip.tsx +17 -20
  109. package/src/GraphGenomeView/components/WalkStripLocator.tsx +8 -15
  110. package/src/GraphGenomeView/components/usePaneGestures.test.tsx +35 -0
  111. package/src/GraphGenomeView/components/usePaneGestures.ts +88 -91
  112. package/src/GraphGenomeView/genes/geneFeatures.ts +27 -45
  113. package/src/GraphGenomeView/graphLayers.ts +4 -4
  114. package/src/GraphGenomeView/host.ts +1 -1
  115. package/src/GraphGenomeView/legendSections.test.ts +23 -1
  116. package/src/GraphGenomeView/legendSections.ts +68 -74
  117. package/src/GraphGenomeView/model.test.ts +373 -39
  118. package/src/GraphGenomeView/model.ts +67 -11
  119. package/src/GraphGenomeView/pane/fitViews.ts +57 -514
  120. package/src/GraphGenomeView/pane/graphViews.ts +219 -160
  121. package/src/GraphGenomeView/pane/hostViews.ts +2 -10
  122. package/src/GraphGenomeView/pane/keepInView.ts +5 -4
  123. package/src/GraphGenomeView/pane/launchActions.ts +117 -139
  124. package/src/GraphGenomeView/pane/launchViews.ts +8 -27
  125. package/src/GraphGenomeView/pane/loadActions.ts +208 -187
  126. package/src/GraphGenomeView/pane/morph.ts +3 -9
  127. package/src/GraphGenomeView/pane/paneBase.ts +22 -11
  128. package/src/GraphGenomeView/pane/renderingActions.ts +65 -11
  129. package/src/GraphGenomeView/pane/settingActions.ts +17 -42
  130. package/src/GraphGenomeView/pane/tubeMapViews.ts +445 -0
  131. package/src/GraphGenomeView/pane/walkRowViews.ts +29 -37
  132. package/src/GraphGenomeView/renderPipeline.test.ts +1 -1
  133. package/src/GraphGenomeView/repeats/repeatFeatures.test.ts +23 -0
  134. package/src/GraphGenomeView/repeats/repeatFeatures.ts +16 -23
  135. package/src/GraphGenomeView/repeats/walkCalls.test.ts +18 -0
  136. package/src/GraphGenomeView/repeats/walkCalls.ts +46 -38
  137. package/src/GraphGenomeView/subgraphLoad.test.ts +67 -3
  138. package/src/GraphGenomeView/trackFeatures.ts +24 -0
  139. package/src/GraphGenomeView/tubeMapPanels.ts +28 -36
  140. package/src/GraphGenomeView/viewModel.ts +8 -56
  141. package/src/GraphGenomeView/walkRowGroups.ts +104 -30
  142. package/src/GraphGenomeView/walkRowSpans.test.ts +6 -0
  143. package/src/GraphGenomeView/walkRowSpans.ts +22 -31
  144. package/src/GraphGenomeView/walkRowsCut.ts +8 -17
  145. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +173 -26
  146. package/src/LinearGraphDisplay/components/SubgraphContextSelect.test.tsx +1 -1
  147. package/src/LinearGraphDisplay/components/SubgraphContextSelect.tsx +3 -3
  148. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.test.tsx +3 -3
  149. package/src/LinearGraphDisplay/components/SubgraphHaplotypesField.tsx +7 -10
  150. package/src/LinearGraphDisplay/configSchema.ts +0 -3
  151. package/src/LinearGraphDisplay/denseWindow.ts +8 -11
  152. package/src/LinearGraphDisplay/model.ts +89 -82
  153. package/src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.test.ts +21 -0
  154. package/src/MinigraphBubbleAdapter/MinigraphBubbleAdapter.ts +6 -14
  155. package/src/MinigraphBubbleAdapter/configSchema.ts +3 -9
  156. package/src/MinigraphBubbleAdapter/index.ts +1 -2
  157. package/src/RgfaTabixAdapter/RgfaTabixAdapter.test.ts +45 -1
  158. package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +111 -276
  159. package/src/RgfaTabixAdapter/configSchema.ts +15 -49
  160. package/src/RgfaTabixAdapter/index.ts +1 -2
  161. package/src/RgfaTabixAdapter/rgfaBed.ts +25 -15
  162. package/src/RgfaTabixAdapter/rgfaCut.ts +139 -0
  163. package/src/RgfaTabixAdapter/test_data/walks2_twopart.GRCh38.walks.bed.gz +0 -0
  164. package/src/RgfaTabixAdapter/test_data/walks2_twopart.GRCh38.walks.bed.gz.tbi +0 -0
  165. package/src/RgfaTabixAdapter/walkFiles.test.ts +33 -0
  166. package/src/RgfaTabixAdapter/walkReader.ts +103 -27
  167. package/src/RgfaTabixAdapter/walkRowRuns.test.ts +53 -0
  168. package/src/RgfaTabixAdapter/walkRowRuns.ts +42 -24
  169. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +37 -6
  170. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +23 -45
  171. package/src/WalkTabixSyntenyAdapter/configSchema.ts +11 -24
  172. package/src/WalkTabixSyntenyAdapter/index.ts +1 -2
  173. package/src/WalkTabixSyntenyAdapter/walkLanes.ts +35 -43
  174. package/src/adapterImplementing.ts +27 -0
  175. package/src/graphTrackDefaults/index.ts +14 -20
  176. package/src/hoverSync/lgvHover.ts +2 -4
  177. package/src/launchFromGraph/contributors.ts +1 -5
  178. package/src/launchFromGraph/graphMenuItems.ts +3 -4
  179. package/src/launchFromGraph/launchFromGraph.test.ts +0 -1
  180. package/src/launchFromGraph/launchFromGraph.ts +8 -13
  181. package/src/panSNTabix.test.ts +1 -26
  182. package/src/panSNTabix.ts +54 -51
  183. package/src/synteny/lanePairs.ts +8 -0
  184. package/src/synteny/matchFeature.ts +52 -0
  185. package/src/tabixRange.ts +13 -10
  186. package/src/version.ts +1 -1
  187. package/dist/chunks/AddTrackWorkflow-Q6RY23LF.js +0 -2
  188. package/dist/chunks/GbzBaseSyntenyAdapter-TIXR4Y3J.js +0 -2
  189. package/dist/chunks/GbzBaseSyntenyAdapter-TIXR4Y3J.js.map +0 -7
  190. package/dist/chunks/GraphTrackSettingsDialog-TAM6PMXD.js +0 -6
  191. package/dist/chunks/GraphTrackSettingsDialog-TAM6PMXD.js.map +0 -7
  192. package/dist/chunks/MinigraphBubbleAdapter-AGI2UYQR.js +0 -2
  193. package/dist/chunks/MinigraphBubbleAdapter-AGI2UYQR.js.map +0 -7
  194. package/dist/chunks/RgfaTabixAdapter-2OL5X3HF.js +0 -3
  195. package/dist/chunks/RgfaTabixAdapter-2OL5X3HF.js.map +0 -7
  196. package/dist/chunks/WalkTabixSyntenyAdapter-UKFHCFOF.js +0 -2
  197. package/dist/chunks/WalkTabixSyntenyAdapter-UKFHCFOF.js.map +0 -7
  198. package/dist/chunks/chunk-5SFGHDQA.js +0 -2
  199. package/dist/chunks/chunk-5SFGHDQA.js.map +0 -7
  200. package/dist/chunks/chunk-6OPB7FOJ.js +0 -2
  201. package/dist/chunks/chunk-AMFIBQVR.js +0 -2
  202. package/dist/chunks/chunk-AMFIBQVR.js.map +0 -7
  203. package/dist/chunks/chunk-BJMRBVG3.js +0 -2
  204. package/dist/chunks/chunk-BJMRBVG3.js.map +0 -7
  205. package/dist/chunks/chunk-E3WYW7Z6.js +0 -2
  206. package/dist/chunks/chunk-EHCF6AXH.js +0 -2
  207. package/dist/chunks/chunk-EHCF6AXH.js.map +0 -7
  208. package/dist/chunks/chunk-GOFS7BXK.js +0 -3
  209. package/dist/chunks/chunk-GOFS7BXK.js.map +0 -7
  210. package/dist/chunks/chunk-IJQTSJGT.js +0 -4
  211. package/dist/chunks/chunk-IJQTSJGT.js.map +0 -7
  212. package/dist/chunks/chunk-J6NZIAZF.js +0 -2
  213. package/dist/chunks/chunk-J6NZIAZF.js.map +0 -7
  214. package/dist/chunks/chunk-LUTMKRXY.js +0 -2
  215. package/dist/chunks/chunk-LUTMKRXY.js.map +0 -7
  216. package/dist/chunks/chunk-MHPJB22Z.js +0 -2
  217. package/dist/chunks/chunk-MHPJB22Z.js.map +0 -7
  218. package/dist/chunks/chunk-TXI43PEN.js +0 -2
  219. package/dist/chunks/chunk-TXI43PEN.js.map +0 -7
  220. package/dist/chunks/chunk-WRH2EJKX.js +0 -2
  221. package/dist/chunks/chunk-WRH2EJKX.js.map +0 -7
  222. package/dist/chunks/chunk-WX26KTZM.js +0 -2
  223. package/dist/chunks/chunk-WX26KTZM.js.map +0 -7
  224. package/dist/chunks/renderSvg-ST2GBBOC.js +0 -2
  225. package/dist/chunks/renderSvg-ST2GBBOC.js.map +0 -7
  226. package/src/GraphGenomeView/components/WalkRowContextMenu.tsx +0 -105
  227. /package/dist/chunks/{ChooseSamplesDialog-BNVYBGJQ.js.map → ChooseSamplesDialog-JRN4YLBY.js.map} +0 -0
  228. /package/dist/chunks/{ChooseWalksDialog-EN3C6AQA.js.map → ChooseWalksDialog-UXLFZTZJ.js.map} +0 -0
  229. /package/dist/chunks/{GraphGenomeView-Z2WZKEEO.js.map → GraphGenomeView-NJ5XCREB.js.map} +0 -0
  230. /package/dist/chunks/{HighlightColorDialog-EYBKFSJU.js.map → HighlightColorDialog-UK5VDDV6.js.map} +0 -0
  231. /package/dist/chunks/{LinearGraphDisplay-WIBVWRQE.js.map → LinearGraphDisplay-TXTKAACH.js.map} +0 -0
  232. /package/dist/chunks/{TrackWarningsDialog-QT4YEXGD.js.map → TrackWarningsDialog-TRYBOIHX.js.map} +0 -0
  233. /package/dist/chunks/{chunk-AHFQHYJI.js.map → chunk-IBWORBGY.js.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["host:@jbrowse/core/data_adapters/BaseAdapter", "../../node_modules/.pnpm/@jbrowse+graph-walks@1.1.0/node_modules/@jbrowse/graph-walks/esm/util.js", "../../node_modules/.pnpm/@jbrowse+graph-walks@1.1.0/node_modules/@jbrowse/graph-walks/esm/walkChunk.js", "../../node_modules/.pnpm/@jbrowse+graph-walks@1.1.0/node_modules/@jbrowse/graph-walks/esm/walkRows.js", "../../node_modules/.pnpm/@jbrowse+graph-walks@1.1.0/node_modules/@jbrowse/graph-walks/esm/refNames.js", "../../node_modules/.pnpm/@jbrowse+graph-walks@1.1.0/node_modules/@jbrowse/graph-walks/esm/walkReader.js", "../../src/tabixRange.ts", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/constants.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/utils/common.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/utils/strings.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/gzheader.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/adler32.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/crc32.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/inffast.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/inftrees.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/inflate.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/messages.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/zlib/zstream.js", "../../node_modules/.pnpm/pako-esm2@2.0.2/node_modules/pako-esm2/src/inflate.js", "../../node_modules/.pnpm/@gmod+bgzf-filehandle@6.7.0/node_modules/@gmod/bgzf-filehandle/src/bgzfBlockScan.ts", "../../node_modules/.pnpm/@gmod+bgzf-filehandle@6.7.0/node_modules/@gmod/bgzf-filehandle/src/util.ts", "../../node_modules/.pnpm/@gmod+bgzf-filehandle@6.7.0/node_modules/@gmod/bgzf-filehandle/src/wasm/bgzf-wasm-inlined.js", "../../node_modules/.pnpm/@gmod+bgzf-filehandle@6.7.0/node_modules/@gmod/bgzf-filehandle/src/unzip.ts", "../../node_modules/.pnpm/@gmod+shared-read-cache@2.0.1/node_modules/@gmod/shared-read-cache/src/throwIfAborted.ts", "../../node_modules/.pnpm/@gmod+shared-read-cache@2.0.1/node_modules/@gmod/shared-read-cache/src/SharedReadCache.ts", "../../node_modules/.pnpm/generic-filehandle2@2.5.1/node_modules/generic-filehandle2/src/util.ts", "../../node_modules/.pnpm/generic-filehandle2@2.5.1/node_modules/generic-filehandle2/src/remoteFile.ts", "../../node_modules/.pnpm/generic-filehandle2@2.5.1/node_modules/generic-filehandle2/src/browser.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/chunk.ts", "../../node_modules/.pnpm/@jbrowse+quick-lru@8.0.0/node_modules/@jbrowse/quick-lru/src/index.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/long.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/virtualOffset.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/util.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/indexFile.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/csi.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/tbi.ts", "../../node_modules/.pnpm/@gmod+tabix@3.10.2/node_modules/@gmod/tabix/src/tabixIndexedFile.ts", "../../src/panSNTabix.ts"],
4
+ "sourcesContent": ["const host = JBrowseExports[\"@jbrowse/core/data_adapters/BaseAdapter\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"@jbrowse/core/data_adapters/BaseAdapter\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const BaseAdapter = /* @__PURE__ */ read(\"BaseAdapter\")\nexport const BaseFeatureDataAdapter = /* @__PURE__ */ read(\"BaseFeatureDataAdapter\")\nexport const BaseSequenceAdapter = /* @__PURE__ */ read(\"BaseSequenceAdapter\")\nexport const cachedSetup = /* @__PURE__ */ read(\"cachedSetup\")\nexport const densityAdapterConfigSchemaFields = /* @__PURE__ */ read(\"densityAdapterConfigSchemaFields\")\nexport const isFeatureAdapter = /* @__PURE__ */ read(\"isFeatureAdapter\")\nexport const isRefNameAliasAdapter = /* @__PURE__ */ read(\"isRefNameAliasAdapter\")\nexport const isRegionsAdapter = /* @__PURE__ */ read(\"isRegionsAdapter\")\nexport const isSequenceAdapter = /* @__PURE__ */ read(\"isSequenceAdapter\")\nexport const isSubAdapterConfig = /* @__PURE__ */ read(\"isSubAdapterConfig\")\nexport const isTextSearchAdapter = /* @__PURE__ */ read(\"isTextSearchAdapter\")\nexport default host && host.__esModule ? host.default : host", "/**\n * A window too large to cut. `regionTooLarge` and the name are what JBrowse\n * and @jbrowse/bandage-core read a zoom-in notice by; `fitsBp` is about how\n * wide a window would fit.\n */\nexport class RegionTooLargeError extends Error {\n constructor(message, limit, windowBp, fitsBp) {\n super(message);\n this.regionTooLarge = true;\n this.name = 'NodeLimitError';\n this.limit = limit;\n this.windowBp = windowBp;\n this.fitsBp = fitsBp;\n }\n}\nconst SEP = '#';\n// `grape#1#chr1` -> `grape`\nexport function panSNSample(refName) {\n return refName.split(SEP)[0];\n}\n// `grape#1#chr1` and `grape#chr1` -> `chr1`\nexport function panSNContig(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3\n ? parts.slice(2).join(SEP)\n : parts.length === 2\n ? parts[1]\n : refName;\n}\nexport function panSNHaplotype(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? `${parts[0]}${SEP}${parts[1]}` : undefined;\n}\nexport function panSNMatchesPrefix(refName, prefix) {\n return (prefix !== undefined &&\n (refName === prefix || refName.startsWith(prefix + SEP)));\n}\nconst precise = (n) => Number.parseFloat(n.toPrecision(3));\n// `1.5Kbp`, `12Mbp`, `850bp`, as JBrowse writes a span\nexport function bpString(bp) {\n const mb = precise(bp / 1000000);\n return mb >= 1\n ? `${mb.toLocaleString('en-US')}Mbp`\n : bp >= 1000\n ? `${precise(bp / 1000).toLocaleString('en-US')}Kbp`\n : `${Math.floor(bp)}bp`;\n}\n", "// A chunk of gfa-to-tabix's walk format 2, one file per reference (that\n// repo's docs/walks-format.md). A chunk lists its `ref` rows, which joined in\n// hapOffset order are the chunk's reference path R; a `nodes` row with the\n// lengths of the nodes its routes visit; `route` rows, each a way off R; and a\n// `walk` row per piece of every other path, naming the routes it takes in\n// order. A handle is 2 * id + 1 when reversed.\nconst NONE = -1;\nconst idOf = (handle) => (handle - (handle & 1)) / 2;\n// the other strand's handle; arithmetic, which holds past 2^31\nconst otherStrand = (handle) => (handle & 1 ? handle - 1 : handle + 1);\n// The handles a column of delta tokens names, each 2 * (id - previous id) +\n// reverse, from `previous.id`, which ends on the last id read\nfunction tokens(field, previous, out) {\n if (field === '.') {\n return out;\n }\n let v = 0;\n let neg = false;\n for (let p = 0; p <= field.length; p++) {\n const ch = p < field.length ? field.charCodeAt(p) : 44;\n if (ch === 44) {\n const d = neg ? -v : v;\n const r = d & 1;\n previous.id += (d - r) / 2;\n out.push(previous.id * 2 + r);\n v = 0;\n neg = false;\n }\n else if (ch === 45) {\n neg = true;\n }\n else {\n v = v * 10 + (ch - 48);\n }\n }\n return out;\n}\nfunction numbers(field) {\n return field === '.' ? [] : field.split(',').map(Number);\n}\n// A link the way round the converter writes it, so a link and its reverse\n// are one: the smaller of a and the flipped b first\nexport function canonicalLink(a, b) {\n return a > otherStrand(b) ? [otherStrand(b), otherStrand(a)] : [a, b];\n}\nfunction tags(cols, from, anchor) {\n let prev;\n let next;\n for (let k = from; k < cols.length; k++) {\n const tag = cols[k];\n if (tag.startsWith('pv:') || tag.startsWith('nx:')) {\n const at = tag.lastIndexOf(':');\n const chunk = {\n refName: tag[3] === 'Z' ? tag.slice(5, at) : anchor,\n start: +tag.slice(at + 1),\n };\n if (tag.startsWith('pv:')) {\n prev = chunk;\n }\n else {\n next = chunk;\n }\n }\n }\n return { prev, next };\n}\n// The chunk's reference path R: its handles, the bp of its steps before each\n// position, and each node's occurrences in R\nexport class RefPath {\n constructor() {\n this.handles = [];\n this.before = [0];\n this.occurrences = new Map();\n }\n add(handles, lengths) {\n for (let k = 0; k < handles.length; k++) {\n const h = handles[k];\n const i = this.handles.length;\n this.handles.push(h);\n this.before.push(this.before[i] + lengths[k]);\n const id = idOf(h);\n const list = this.occurrences.get(id);\n if (list) {\n list.push(i);\n }\n else {\n this.occurrences.set(id, [i]);\n }\n }\n }\n // bp of R's steps before position i\n bp(i) {\n return this.before[i];\n }\n first(handle) {\n var _a;\n return (_a = this.occurrences.get(idOf(handle))) === null || _a === void 0 ? void 0 : _a[0];\n }\n nearest(handle, i) {\n var _a;\n let best;\n for (const j of (_a = this.occurrences.get(idOf(handle))) !== null && _a !== void 0 ? _a : []) {\n if (best === undefined || Math.abs(j - i) <= Math.abs(best - i)) {\n best = j;\n }\n }\n return best;\n }\n // The position a stretch along R from position i, reading R the way `h`\n // does there, first holds `target`, i itself included\n reach(i, h, target) {\n var _a;\n const forward = this.handles[i] === h;\n let found;\n for (const j of (_a = this.occurrences.get(idOf(target))) !== null && _a !== void 0 ? _a : []) {\n if (forward && j >= i && this.handles[j] === target) {\n if (found === undefined || j < found) {\n found = j;\n }\n }\n else if (!forward &&\n j <= i &&\n otherStrand(this.handles[j]) === target) {\n if (found === undefined || j > found) {\n found = j;\n }\n }\n }\n return found;\n }\n handleAt(i, forward) {\n return forward ? this.handles[i] : otherStrand(this.handles[i]);\n }\n}\nexport class WalkRowError extends Error {\n}\nconst orientedEntry = (route, flip) => flip ? (route.exit === NONE ? NONE : otherStrand(route.exit)) : route.entry;\nconst orientedExit = (route, flip) => flip ? (route.entry === NONE ? NONE : otherStrand(route.entry)) : route.exit;\n// A route's interior handle k, taken the way round `flip` says\nconst interiorAt = (route, flip, k) => flip\n ? otherStrand(route.interior[route.interior.length - 1 - k])\n : route.interior[k];\n// A walk row's choices, three numbers each: route index, flip and step count,\n// from `tok` or `tok:count` tokens\nfunction parseChoices(field) {\n const choices = [];\n if (field !== '.') {\n let previous = 0;\n let v = 0;\n let neg = false;\n let tok = 0;\n let colonSeen = false;\n for (let p = 0; p <= field.length; p++) {\n const ch = p < field.length ? field.charCodeAt(p) : 44;\n if (ch === 44) {\n const value = neg ? -v : v;\n const d = colonSeen ? tok : value;\n const r = d & 1;\n previous += (d - r) / 2;\n choices.push(previous, r, colonSeen ? value : 0);\n v = 0;\n neg = false;\n colonSeen = false;\n }\n else if (ch === 58) {\n tok = neg ? -v : v;\n v = 0;\n neg = false;\n colonSeen = true;\n }\n else if (ch === 45) {\n neg = true;\n }\n else {\n v = v * 10 + (ch - 48);\n }\n }\n }\n return choices;\n}\n// Follows a walk row as docs/walks-format.md decodes it\nfunction traverse(path, routes, start, endField, choices, visit) {\n const colon = endField.indexOf(':');\n const end = start + +(colon < 0 ? endField : endField.slice(0, colon));\n const counted = colon >= 0;\n const tail = counted ? +endField.slice(colon + 1) : 0;\n const routeOf = (index) => {\n const route = routes[index];\n if (!route) {\n throw new WalkRowError(`route ${index} is not in the chunk`);\n }\n return route;\n };\n let k = 0;\n if (choices.length > 0 &&\n orientedEntry(routeOf(choices[0]), choices[1] === 1) === NONE) {\n if (!visit.route(choices[0], choices[1] === 1)) {\n return;\n }\n k = 3;\n }\n let h = start;\n let i = path.first(h);\n if (i === undefined) {\n throw new WalkRowError('a walk row starts off its chunk');\n }\n visit.step(h);\n const follow = (target, count) => {\n const forward = path.handles[i] === h;\n const j = counted\n ? i + (forward ? count : -count)\n : path.reach(i, h, target);\n if (j === undefined || j < 0 || j >= path.handles.length) {\n throw new WalkRowError('a walk row runs off its chunk');\n }\n if (j !== i) {\n visit.stretch(i, j, forward);\n }\n i = j;\n h = path.handleAt(j, forward);\n };\n for (; k < choices.length; k += 3) {\n const index = choices[k];\n const flip = choices[k + 1] === 1;\n const route = routeOf(index);\n const entry = orientedEntry(route, flip);\n if (entry === NONE) {\n throw new WalkRowError('an open route after the first choice');\n }\n follow(entry, choices[k + 2]);\n if (!visit.route(index, flip)) {\n return;\n }\n const exit = orientedExit(route, flip);\n if (exit === NONE) {\n return;\n }\n h = exit;\n i = path.nearest(h, i);\n if (i === undefined) {\n throw new WalkRowError('a route lands off its chunk');\n }\n visit.step(h);\n }\n follow(end, tail);\n if (h !== end) {\n throw new WalkRowError('a walk row misses its last handle');\n }\n}\n// A walk row's steps as node ids and reverse flags\nfunction decodeWalk(path, routes, cols, choices, n) {\n const ids = new Int32Array(n);\n const rev = new Uint8Array(n);\n let at = 0;\n const push = (h) => {\n if (at >= n) {\n throw new WalkRowError('a walk row decodes to more steps than it states');\n }\n ids[at] = idOf(h);\n rev[at++] = h & 1;\n };\n traverse(path, routes, +cols[9], cols[10], choices, {\n step: push,\n stretch(from, to, forward) {\n if (forward) {\n for (let j = from + 1; j <= to; j++) {\n push(path.handles[j]);\n }\n }\n else {\n for (let j = from - 1; j >= to; j--) {\n push(otherStrand(path.handles[j]));\n }\n }\n },\n route(index, flip) {\n const route = routes[index];\n for (let k = 0; k < route.interior.length; k++) {\n push(interiorAt(route, flip, k));\n }\n return true;\n },\n });\n if (at !== n) {\n throw new WalkRowError(`a walk row decodes to ${at} steps, not ${n}`);\n }\n return { ids, rev };\n}\n// The bases an SQ:Z: tag at or after column `from` joins, one node's per\n// length, as `ids` names them\nfunction sliceBases(cols, from, ids, lengths, out) {\n const tag = cols.slice(from).find(c => c.startsWith('SQ:Z:'));\n if (tag === undefined) {\n return;\n }\n let at = 5;\n for (let k = 0; k < ids.length; k++) {\n const length = lengths[k];\n out.set(ids[k], tag.slice(at, at + length));\n at += length;\n }\n}\n/**\n * Decodes one chunk's rows, each split on tabs. `keep` names the walk rows\n * whose steps a cut wants, undefined for every one.\n */\nexport function decodeChunk(rows, keep, withSequences = false) {\n var _a, _b, _c;\n const path = new RefPath();\n const lengths = new Map();\n const routes = [];\n const out = {\n sequences: new Map(),\n rows: [],\n nodes: new Map(),\n ends: [],\n chunk: { path, routes, walks: [], lengths },\n };\n const previous = { id: 0 };\n const refs = rows.filter(c => c[3] === 'ref').sort((a, b) => +a[6] - +b[6]);\n for (const cols of refs) {\n const anchor = cols[0];\n const handles = tokens(cols[9], { id: 0 }, []);\n const nodeLengths = numbers(cols[10]);\n const hapOffset = +cols[6];\n path.add(handles, nodeLengths);\n if (withSequences) {\n sliceBases(cols, 11, handles.map(idOf), nodeLengths, out.sequences);\n }\n let start = hapOffset;\n for (let k = 0; k < handles.length; k++) {\n const id = idOf(handles[k]);\n const length = nodeLengths[k];\n lengths.set(id, length);\n if (!out.nodes.has(id)) {\n out.nodes.set(id, {\n refName: cols[4],\n start,\n end: start + length,\n rank: 0,\n });\n }\n start += length;\n }\n out.ends.push({\n name: cols[4],\n fragStart: +cols[5],\n piece: +cols[7],\n first: handles[0],\n last: handles.at(-1),\n });\n if (keep === undefined || keep(cols[4])) {\n out.rows.push({\n chunkStart: +cols[1],\n name: cols[4],\n fragStart: +cols[5],\n hapOffset,\n piece: +cols[7],\n n: handles.length,\n steps: {\n ids: Int32Array.from(handles, idOf),\n rev: Uint8Array.from(handles, h => h & 1),\n },\n ...tags(cols, 11, anchor),\n });\n }\n }\n for (const cols of rows) {\n if (cols[3] === 'nodes') {\n const ids = numbers(cols[4]);\n const nodeLengths = numbers(cols[5]);\n let id = 0;\n for (let k = 0; k < ids.length; k++) {\n id += ids[k];\n ids[k] = id;\n lengths.set(id, nodeLengths[k]);\n }\n if (withSequences) {\n sliceBases(cols, 6, ids, nodeLengths, out.sequences);\n }\n }\n else if (cols[3] === 'route') {\n const entry = tokens(cols[4], previous, []);\n const interior = tokens(cols[5], previous, []);\n const exit = tokens(cols[6], previous, []);\n routes.push({ entry: (_a = entry[0]) !== null && _a !== void 0 ? _a : NONE, interior, exit: (_b = exit[0]) !== null && _b !== void 0 ? _b : NONE });\n }\n }\n const routeOf = (index) => {\n const route = routes[index];\n if (!route) {\n throw new WalkRowError(`route ${index} is not in the chunk`);\n }\n return route;\n };\n for (const cols of rows) {\n if (cols[3] !== 'walk') {\n continue;\n }\n const choices = parseChoices(cols[11]);\n out.chunk.walks.push({ cols, choices });\n const name = cols[4];\n const start = +cols[9];\n const endField = cols[10];\n const colon = endField.indexOf(':');\n let first = start;\n let last = start + +(colon < 0 ? endField : endField.slice(0, colon));\n if (choices.length > 0) {\n const lead = routeOf(choices[0]);\n const leadFlip = choices[1] === 1;\n if (orientedEntry(lead, leadFlip) === NONE) {\n first = interiorAt(lead, leadFlip, 0);\n }\n const at = choices.length - 3;\n const tail = routeOf(choices[at]);\n const tailFlip = choices[at + 1] === 1;\n if (orientedExit(tail, tailFlip) === NONE) {\n last = interiorAt(tail, tailFlip, tail.interior.length - 1);\n }\n }\n out.ends.push({\n name,\n fragStart: +cols[5],\n piece: +cols[7],\n first,\n last,\n });\n if (keep === undefined || keep(name)) {\n const n = +cols[8];\n // the walk's nodes off R, by length; placeAndLink gives their position\n for (let k = 0; k < choices.length; k += 3) {\n for (const h of routeOf(choices[k]).interior) {\n const id = idOf(h);\n if (!out.nodes.has(id)) {\n const length = (_c = lengths.get(id)) !== null && _c !== void 0 ? _c : 0;\n out.nodes.set(id, { refName: name, start: 0, end: length, rank: 1 });\n }\n }\n }\n out.rows.push({\n chunkStart: +cols[1],\n name,\n fragStart: +cols[5],\n hapOffset: +cols[6],\n piece: +cols[7],\n n,\n steps: decodeWalk(path, routes, cols, choices, n),\n ...tags(cols, 12, cols[0]),\n });\n }\n }\n return out;\n}\n/**\n * The positions of the cut's nodes off R, and the links among the cut's\n * nodes, from the chunks a cut read: `kept` holds the node ids the cut draws.\n * A node off R takes its position from the path whose name sorts first among\n * those visiting it in the chunks read, at its earliest offset, as format 1's\n * node rows had it. Links are R's and the routes', both ends in the cut.\n */\nexport function placeAndLink(chunks, kept, place, link) {\n const best = new Map();\n for (const { path, routes, walks, lengths } of chunks) {\n const handles = path.handles;\n for (let k = 1; k < handles.length; k++) {\n if (kept.has(idOf(handles[k - 1])) && kept.has(idOf(handles[k]))) {\n link(...canonicalLink(handles[k - 1], handles[k]));\n }\n }\n // routes holding a node of the cut off R\n const wanted = new Uint8Array(routes.length);\n for (let index = 0; index < routes.length; index++) {\n const { entry, interior, exit } = routes[index];\n let any = false;\n let from = entry;\n for (const h of interior) {\n const inCut = kept.has(idOf(h));\n any || (any = inCut);\n if (inCut && from !== NONE && kept.has(idOf(from))) {\n link(...canonicalLink(from, h));\n }\n from = h;\n }\n if (from !== NONE &&\n exit !== NONE &&\n kept.has(idOf(from)) &&\n kept.has(idOf(exit))) {\n link(...canonicalLink(from, exit));\n }\n wanted[index] = any ? 1 : 0;\n }\n const lengthOf = (h) => { var _a; return (_a = lengths.get(idOf(h))) !== null && _a !== void 0 ? _a : 0; };\n const bp = new Float64Array(routes.length).fill(-1);\n const routeBp = (index) => {\n if (bp[index] < 0) {\n bp[index] = routes[index].interior.reduce((s, h) => s + lengthOf(h), 0);\n }\n return bp[index];\n };\n // Walk rows run in path-name order, so a route's first taker is the\n // first-named path to reach its nodes here; each row is followed only as\n // far as the last route it is first to take\n const taken = new Uint8Array(routes.length);\n for (const { cols, choices } of walks) {\n let remaining = 0;\n for (let k = 0; k < choices.length; k += 3) {\n const index = choices[k];\n if (wanted[index] && !taken[index]) {\n remaining++;\n }\n }\n if (remaining === 0) {\n continue;\n }\n const name = cols[4];\n let offset = +cols[6];\n traverse(path, routes, +cols[9], cols[10], choices, {\n step(h) {\n offset += lengthOf(h);\n },\n stretch(from, to, forward) {\n offset += forward\n ? path.bp(to + 1) - path.bp(from + 1)\n : path.bp(from) - path.bp(to);\n },\n route(index, flip) {\n if (!wanted[index] || taken[index]) {\n offset += routeBp(index);\n return true;\n }\n taken[index] = 1;\n const route = routes[index];\n for (let k = 0; k < route.interior.length; k++) {\n const h = interiorAt(route, flip, k);\n const id = idOf(h);\n const length = lengthOf(h);\n if (kept.has(id)) {\n const held = best.get(id);\n if (!held ||\n name < held.refName ||\n (name === held.refName && offset < held.start)) {\n best.set(id, {\n refName: name,\n start: offset,\n end: offset + length,\n rank: 1,\n });\n }\n }\n offset += length;\n }\n remaining--;\n return remaining > 0;\n },\n });\n }\n }\n for (const [id, node] of best) {\n place(id, node);\n }\n}\n// The reference's nodes in a chunk's ref rows, with their positions\nexport function referenceNodes(rows) {\n const nodes = [];\n for (const cols of rows) {\n if (cols[3] !== 'ref') {\n continue;\n }\n const handles = tokens(cols[9], { id: 0 }, []);\n const nodeLengths = numbers(cols[10]);\n let start = +cols[6];\n for (let k = 0; k < handles.length; k++) {\n const length = nodeLengths[k];\n nodes.push({\n id: idOf(handles[k]),\n refName: cols[4],\n start,\n end: start + length,\n rank: 0,\n });\n start += length;\n }\n }\n return nodes;\n}\n// Links between consecutive pieces of a path, each piece's last step to the\n// next one's first, among the pieces read\nexport function pieceLinks(ends) {\n const byPath = new Map();\n for (const e of ends) {\n const key = `${e.name}\\t${e.fragStart}`;\n let pieces = byPath.get(key);\n if (!pieces) {\n pieces = new Map();\n byPath.set(key, pieces);\n }\n pieces.set(e.piece, e);\n }\n const links = [];\n for (const pieces of byPath.values()) {\n for (const [piece, e] of pieces) {\n const next = pieces.get(piece + 1);\n if (next) {\n links.push(canonicalLink(e.last, next.first));\n }\n }\n }\n return links;\n}\n", "import { RegionTooLargeError, bpString, panSNHaplotype, panSNMatchesPrefix, } from \"./util.js\";\nimport { placeAndLink } from \"./walkChunk.js\";\nfunction integerTag(line, tag) {\n const match = new RegExp(`(?:^|\\\\t)${tag}:i:(\\\\d+)`).exec(line);\n return match ? +match[1] : undefined;\n}\n/**\n * What a walk file's header states: a `#walks` line with the format, the\n * chunk size and the longest node in bp, `format:i:2\\tchunk:i:65536\\tmaxnode:i:1024`,\n * a `#reference\\tGRCh38` line naming the reference sample and a\n * `#haplotype\\tHG002#1` line per other haplotype with rows\n */\nexport function walkHeader(lines) {\n var _a, _b, _c;\n const header = { references: [], haplotypes: [] };\n for (const line of lines) {\n const [key, value = ''] = line.split('\\t');\n if (key === '#reference') {\n header.references.push(value);\n }\n else if (key === '#haplotype') {\n header.haplotypes.push(value);\n }\n else {\n (_a = header.format) !== null && _a !== void 0 ? _a : (header.format = integerTag(line, 'format'));\n (_b = header.chunk) !== null && _b !== void 0 ? _b : (header.chunk = integerTag(line, 'chunk'));\n (_c = header.maxNode) !== null && _c !== void 0 ? _c : (header.maxNode = integerTag(line, 'maxnode'));\n }\n }\n return header;\n}\n/**\n * How many chunks before the window's own a cut reads. A node is filed under\n * the chunk holding its start, so a node `maxNode` bp long reaching into the\n * window starts at most ceil(maxNode / chunk) chunks back. At least one, since\n * the chunk before carries the detour a haplotype takes into the window's\n * first reference node; one when the header gives no `maxnode:i:`, which holds\n * for vg's graphs, chopped to nodes of at most 1,024 bp.\n */\nexport function lookbackChunks(maxNode, chunk) {\n return maxNode === undefined ? 1 : Math.max(1, Math.ceil(maxNode / chunk));\n}\n// The first base a cut queries: the start of the chunk `lookback` chunks\n// before the one holding the window's start\nexport function chunkQueryStart(start, chunk, lookback = 1) {\n return Math.max(0, (Math.floor(start / chunk) - lookback) * chunk);\n}\n// Which walks a cut decodes: the reference's, and those `wanted` names by\n// PanSN prefix at sample or haplotype depth; undefined decodes every one\nexport function walkNameFilter(wanted, referenceHaplotype) {\n return wanted === undefined || wanted.length === 0\n ? undefined\n : (name) => panSNMatchesPrefix(name, referenceHaplotype) ||\n wanted.some(prefix => panSNMatchesPrefix(name, prefix));\n}\n/**\n * The walks a cut on `refName` decodes: its own and those `wanted` names. A\n * pggb P-line names a reference with no haplotype field (`chm13#chr1`), so the\n * filter matches the reference by its whole name.\n */\nexport function walksKept(wanted, refName) {\n var _a;\n return walkNameFilter(wanted, (_a = panSNHaplotype(refName)) !== null && _a !== void 0 ? _a : refName);\n}\nexport function joinPieces(rows) {\n const byPath = new Map();\n for (const row of rows) {\n const key = `${row.name}\\t${row.fragStart}`;\n const list = byPath.get(key);\n if (list) {\n list.push(row);\n }\n else {\n byPath.set(key, [row]);\n }\n }\n const runs = [];\n for (const pieces of byPath.values()) {\n pieces.sort((a, b) => a.piece - b.piece);\n let from = 0;\n for (let i = 1; i <= pieces.length; i++) {\n if (i === pieces.length ||\n pieces[i].piece !== pieces[i - 1].piece + 1) {\n runs.push(decodeRun(pieces.slice(from, i)));\n from = i;\n }\n }\n }\n return runs;\n}\nfunction decodeRun(pieces) {\n const n = pieces.reduce((sum, p) => sum + p.n, 0);\n const ids = new Int32Array(n);\n const rev = new Uint8Array(n);\n let at = 0;\n for (const p of pieces) {\n ids.set(p.steps.ids, at);\n rev.set(p.steps.rev, at);\n at += p.n;\n }\n const first = pieces[0];\n return {\n name: first.name,\n hapOffset: first.hapOffset,\n ids,\n rev,\n prev: first.prev,\n next: pieces.at(-1).next,\n };\n}\n/**\n * The cut a window draws from its walks: the reference inside the window plus\n * its context, and each run from its first to its last step on that stretch.\n * A run that leaves the reference there, through steps off it or across a\n * deletion, is followed to the reference step where it rejoins, when the read\n * holds it, and otherwise through the steps off the reference it holds: at\n * the ABCA7 VNTR four haplotypes leave inside the repeat and rejoin 1.8 kb\n * past the window, and cut at the context they measured as partial walks. The reference is cut out as far as those rejoins reach, and\n * a run then runs on outward while the next step's node is already in the\n * cut. Without the run-on a haplotype whose alternate allele straddles the\n * edge stopped short of a node other walks had brought into the cut, and that\n * node drew without it. The run-on adds no node, so one pass is enough, but\n * it reaches through nodes other walks brought in, so with a window edge inside\n * a collapsed array a row's length depends on which haplotypes are cut.\n */\nexport function walkCut(runs, nodes, refName) {\n const onWindow = (id) => { var _a; return ((_a = nodes.get(id)) === null || _a === void 0 ? void 0 : _a.onWindow) === true; };\n const reference = (id) => {\n const node = nodes.get(id);\n return (node === null || node === void 0 ? void 0 : node.rank) === 0 ? node : undefined;\n };\n // the chunks walks cut off at the end of a run go on in\n const open = new Map();\n const goesOn = (chunk) => {\n if (chunk) {\n open.set(`${chunk.refName}:${chunk.start}`, chunk);\n }\n };\n // Where a walk stops being followed from step `at`, going by `dir`: the\n // reference step it rejoins at past any steps off the reference, or across\n // a deletion; else its last step off the reference before the run ends,\n // noting the chunk the path goes on in, or reaches another reference\n // sequence\n const rejoin = (run, at, dir) => {\n const { ids } = run;\n let i = at + dir;\n while (i >= 0 && i < ids.length && reference(ids[i]) === undefined) {\n i += dir;\n }\n if (i < 0 || i >= ids.length) {\n goesOn(dir < 0 ? run.prev : run.next);\n return i - dir;\n }\n const from = reference(ids[at]);\n const to = reference(ids[i]);\n if (to.refName !== refName) {\n return i - dir;\n }\n const adjacent = i === at + dir && (to.start === from.end || to.end === from.start);\n return adjacent ? at : i;\n };\n let reachStart = Infinity;\n let reachEnd = -Infinity;\n const spans = [];\n for (const run of runs) {\n const { ids } = run;\n let first = -1;\n let last = -1;\n for (let i = 0; i < ids.length; i++) {\n if (onWindow(ids[i])) {\n if (first < 0) {\n first = i;\n }\n last = i;\n }\n }\n if (first >= 0) {\n if (run.name !== refName) {\n first = rejoin(run, first, -1);\n last = rejoin(run, last, 1);\n for (const i of [first, last]) {\n const node = reference(ids[i]);\n if (node) {\n reachStart = Math.min(reachStart, node.start);\n reachEnd = Math.max(reachEnd, node.end);\n }\n }\n }\n spans.push({ run, first, last });\n }\n }\n const inReach = (id) => {\n const node = reference(id);\n return (onWindow(id) ||\n ((node === null || node === void 0 ? void 0 : node.refName) === refName &&\n node.end > reachStart &&\n node.start < reachEnd));\n };\n const kept = new Set();\n for (const [id, node] of nodes) {\n if (node.onWindow) {\n kept.add(id);\n }\n }\n for (const span of spans) {\n const { ids } = span.run;\n if (span.run.name === refName) {\n while (span.first > 0 && inReach(ids[span.first - 1])) {\n span.first--;\n }\n while (span.last < ids.length - 1 && inReach(ids[span.last + 1])) {\n span.last++;\n }\n }\n for (let i = span.first; i <= span.last; i++) {\n kept.add(ids[i]);\n }\n }\n const length = (id) => {\n const node = nodes.get(id);\n return node === undefined ? 0 : node.end - node.start;\n };\n const fragments = [];\n for (const { run, first: f, last: l } of spans) {\n const { ids, rev } = run;\n let first = f;\n let last = l;\n while (first > 0 && kept.has(ids[first - 1])) {\n first--;\n }\n while (last < ids.length - 1 && kept.has(ids[last + 1])) {\n last++;\n }\n let hapStart = run.hapOffset;\n for (let i = 0; i < first; i++) {\n hapStart += length(ids[i]);\n }\n let hapEnd = hapStart;\n for (let i = first; i <= last; i++) {\n hapEnd += length(ids[i]);\n }\n fragments.push({\n name: run.name,\n hapStart,\n hapEnd,\n ids: ids.subarray(first, last + 1),\n rev: rev.subarray(first, last + 1),\n });\n }\n return { kept, fragments, open: [...open.values()] };\n}\n/**\n * The nodes and links of the chunks a cut reads, and the tables of the cut\n * they make with its walks. A node in two chunks is placed once.\n */\nexport class WalkGraph {\n constructor(window) {\n this.nodes = new Map();\n this.sequences = new Map();\n this.links = [];\n // the chunks read, whose nodes off R and links tables() fills in\n this.chunks = [];\n this.window = window;\n }\n // A node with its position, unless the cut already holds it\n placeNode(id, node) {\n if (this.nodes.has(id)) {\n return;\n }\n const { window } = this;\n this.nodes.set(id, {\n ...node,\n onWindow: node.rank === 0 &&\n node.refName === window.refName &&\n node.end > window.start - window.context &&\n node.start < window.end + window.context,\n });\n }\n // A link between two endpoints, each id * 2 + 1 when reversed\n addLinkEnds(source, target) {\n this.links.push(source, target);\n }\n addChunk(chunk) {\n this.chunks.push(chunk);\n }\n // Bases of nodes a chunk's rows give, for a window that asks for them\n addSequences(sequences) {\n if (this.window.sequences) {\n for (const [id, bases] of sequences) {\n this.sequences.set(id, bases);\n }\n }\n }\n /**\n * The cut as typed arrays, which the worker transfers rather than copies:\n * nodes by reference position, each link once in the order its L line\n * sorts, then a walk per fragment, the reference's first and the rest by\n * name. graphTablesGFA writes them as the GFA they stand for, the same bytes\n * for the same rows.\n */\n tables(kept, fragments) {\n if (this.chunks.length > 0) {\n placeAndLink(this.chunks, kept, (id, node) => {\n const held = this.nodes.get(id);\n if (held) {\n this.nodes.set(id, { ...held, ...node });\n }\n }, (a, b) => {\n this.links.push(a, b);\n });\n }\n const held = [];\n for (const id of kept) {\n const node = this.nodes.get(id);\n if (node) {\n held.push({ ...node, id });\n }\n }\n held.sort((x, y) => x.refName < y.refName\n ? -1\n : x.refName > y.refName\n ? 1\n : x.start - y.start || x.id - y.id);\n const index = new Map();\n const names = [];\n const refNames = [];\n const refIndex = new Map();\n const lengths = new Int32Array(held.length);\n const refs = new Int32Array(held.length);\n const starts = new Float64Array(held.length);\n const ranks = new Int32Array(held.length);\n held.forEach(({ id, refName, start, end, rank }, i) => {\n index.set(id, i);\n names.push(String(id));\n let ref = refIndex.get(refName);\n if (ref === undefined) {\n ref = refNames.length;\n refIndex.set(refName, ref);\n refNames.push(refName);\n }\n lengths[i] = end - start;\n refs[i] = ref;\n starts[i] = start;\n ranks[i] = rank;\n });\n // a kept node with no row of its own is named, and not drawn\n const nodeIndex = (id) => {\n let i = index.get(id);\n if (i === undefined) {\n i = names.length;\n index.set(id, i);\n names.push(String(id));\n }\n return i;\n };\n const byLine = new Map();\n for (let i = 0; i < this.links.length; i += 2) {\n const a = this.links[i];\n const b = this.links[i + 1];\n const source = Math.floor(a / 2);\n const target = Math.floor(b / 2);\n if (kept.has(source) && kept.has(target)) {\n byLine.set(`${source}\\t${a % 2 ? '-' : '+'}\\t${target}\\t${b % 2 ? '-' : '+'}`, i);\n }\n }\n const lines = [...byLine.keys()].sort();\n const from = new Int32Array(lines.length);\n const to = new Int32Array(lines.length);\n const strands = new Uint8Array(lines.length);\n lines.forEach((line, k) => {\n const i = byLine.get(line);\n const a = this.links[i];\n const b = this.links[i + 1];\n from[k] = nodeIndex(Math.floor(a / 2));\n to[k] = nodeIndex(Math.floor(b / 2));\n strands[k] = (a % 2) | ((b % 2) << 1);\n });\n const walks = this.referenceFirst(fragments);\n const offsets = new Int32Array(walks.length + 1);\n walks.forEach(({ ids }, p) => {\n offsets[p + 1] = offsets[p] + ids.length;\n });\n const steps = new Int32Array(offsets[walks.length]);\n const reversed = new Uint8Array(steps.length);\n walks.forEach(({ ids, rev }, p) => {\n const at = offsets[p];\n for (let j = 0; j < ids.length; j++) {\n steps[at + j] = nodeIndex(ids[j]);\n }\n reversed.set(rev, at);\n });\n return {\n nodes: { names, lengths, refs, starts, ranks, refNames },\n links: { from, to, strands },\n walks: {\n names: walks.map(f => f.name),\n starts: Float64Array.from(walks, f => f.hapStart),\n ends: Float64Array.from(walks, f => f.hapEnd),\n offsets,\n steps,\n reversed,\n },\n };\n }\n // The view anchors on the first walk when no walk names the assembly, as\n // gbz-base's cut has it; in file order that was whichever haplotype the\n // chunk listed first, CHM13 on a GRCh38 window\n referenceFirst(fragments) {\n const { refName } = this.window;\n return [...fragments].sort((a, b) => Number(b.name === refName) - Number(a.name === refName) ||\n (a.name < b.name ? -1 : a.name > b.name ? 1 : a.hapStart - b.hapStart));\n }\n}\nexport const BUDGET_NAMES = {\n steps: 'the step budget',\n bytes: 'a byte budget of',\n};\nexport function stepBudgetError(rows, stepBudget, readPerKept, window, chunk, filtered, names = BUDGET_NAMES) {\n var _a;\n let total = 0;\n const perChunk = new Map();\n const walks = new Set();\n for (const row of rows) {\n total += row.n;\n perChunk.set(row.chunkStart, ((_a = perChunk.get(row.chunkStart)) !== null && _a !== void 0 ? _a : 0) + row.n);\n walks.add(row.name);\n }\n const budget = stepBudget * readPerKept;\n if (total <= budget) {\n return undefined;\n }\n const windowBp = window.end - window.start;\n let read = 0;\n let fitsBp = 0;\n for (const cs of [...perChunk.keys()].sort((a, b) => a - b)) {\n read += perChunk.get(cs);\n if (read > budget) {\n break;\n }\n fitsBp = Math.max(fitsBp, cs + chunk - window.start);\n }\n const fewerFit = !filtered && walks.size > 2 && (2 * total) / walks.size <= budget;\n return new RegionTooLargeError(fitsBp > 0\n ? `Zoom in to about ${bpString(fitsBp)}${fewerFit ? ', or choose fewer haplotypes,' : ''} to see the graph`\n : `Too many haplotype steps here to draw ${filtered ? 'these haplotypes' : 'every haplotype'} (${read.toLocaleString()} steps read, over ${readPerKept} \u00D7 ${names.steps} of ${stepBudget.toLocaleString()}); choose fewer haplotypes`, budget, windowBp, Math.max(fitsBp, 1));\n}\n/**\n * The zoom-in notice for a cut that keeps more steps than `budget`, or\n * undefined when it fits. The span that fits is the window scaled by how far\n * over the cut is.\n */\nexport function keptStepsError(fragments, budget, window, filtered) {\n const total = fragments.reduce((sum, f) => sum + f.ids.length, 0);\n if (total <= budget) {\n return undefined;\n }\n const windowBp = window.end - window.start;\n const fitsBp = Math.max(1, Math.floor((windowBp * budget) / total));\n return new RegionTooLargeError(`Zoom in to about ${bpString(fitsBp)}${filtered ? '' : ', or choose fewer haplotypes,'} to see the graph`, budget, windowBp, fitsBp);\n}\n/**\n * The zoom-in notice for a cut whose three files would fetch more than\n * `budget` compressed bytes, or undefined when they fit. `bytesTo(end)` is the\n * indexes' estimate for a read from the window's first query base to `end`;\n * the span that fits grows a chunk at a time from the chunk holding the\n * window's start, and when that chunk and those before it are over on their\n * own, no zoom fits.\n */\nexport async function byteBudgetError(bytesTo, budget, window, chunk, names = BUDGET_NAMES) {\n const bytes = await bytesTo(window.end);\n if (bytes <= budget) {\n return undefined;\n }\n let fitsBp = 0;\n let least;\n for (let cs = Math.floor(window.start / chunk) * chunk; cs < window.end; cs += chunk) {\n const read = await bytesTo(cs + 1);\n least !== null && least !== void 0 ? least : (least = read);\n if (read > budget) {\n break;\n }\n fitsBp = cs + chunk - window.start;\n }\n const windowBp = window.end - window.start;\n return new RegionTooLargeError(fitsBp > 0\n ? `Zoom in to about ${bpString(fitsBp)} to see the graph`\n : `Too much graph here to fetch (${megabytes(least !== null && least !== void 0 ? least : bytes)} against ${names.bytes} ${megabytes(budget)})`, budget, windowBp, Math.max(fitsBp, 1));\n}\nconst megabytes = (bytes) => `${(bytes / 1e6).toFixed(1)} MB`;\n", "import { panSNContig, panSNHaplotype, panSNSample } from \"./util.js\";\n// A tab can occur in neither half: both come out of BED columns\nfunction qualifiedKey(assemblyName, refName) {\n return `${assemblyName}\\t${refName}`;\n}\n/**\n * A file's sequence names under each spelling a caller may ask by: the file's\n * own (`GRCh38#0#chr6`), and a PanSN name's contig under its sample (`chr6`\n * on `GRCh38`) and under its haplotype (`chr6` on `GRCh38#0`). A pggb name\n * with no haplotype field, `chm13#chr1`, is `chr1` on `chm13`.\n */\nexport function refNameLookup(names) {\n const lookup = new Map();\n for (const name of names) {\n lookup.set(name, name);\n const sample = panSNSample(name);\n if (sample !== name) {\n const contig = panSNContig(name);\n lookup.set(qualifiedKey(sample, contig), name);\n const haplotype = panSNHaplotype(name);\n if (haplotype !== undefined) {\n lookup.set(qualifiedKey(haplotype, contig), name);\n }\n }\n }\n return lookup;\n}\n/**\n * The file's name for `refName` on `assemblyName`, a sample or a haplotype,\n * else for `refName` as the file spells it; undefined when it holds neither\n */\nexport function resolveRefName(lookup, assemblyName, refName) {\n var _a;\n return (_a = lookup.get(qualifiedKey(assemblyName, refName))) !== null && _a !== void 0 ? _a : lookup.get(refName);\n}\n", "import { refNameLookup, resolveRefName } from \"./refNames.js\";\nimport { decodeChunk, pieceLinks } from \"./walkChunk.js\";\nimport { WalkGraph, byteBudgetError, chunkQueryStart, joinPieces, keptStepsError, lookbackChunks, stepBudgetError, walkCut, walkHeader, } from \"./walkRows.js\";\n// A window reads whole chunks and keeps the steps on it, so a narrow window\n// reads several times what it keeps: 464 haplotypes across the 1.5 kb ABCA7\n// repeat read 5.0 M steps and keep 1.16 M, and the cut takes 0.4 s from warm\n// files. The step budget bounds what the cut keeps, and rows are read to this\n// multiple of it.\nconst READ_STEPS_PER_KEPT = 8;\n// A walk the read cuts off goes on in the chunk its row names, out to which a\n// cut reads on, in at most this many rounds and this many chunks from the read\nconst FOLLOW_ROUNDS = 3;\nconst FOLLOW_CHUNKS = 4;\n// bp of reference a cut keeps past each end of the window\nconst WALK_CONTEXT = 1000;\n// The budgets the JBrowse graph plugin and BandageJS cut a browser's window by\nexport const WALK_BUDGETS = { stepBudget: 4000000, byteBudget: 8000000 };\n// A walk file gfa-to-tabix 0.12 or earlier wrote, which the reader refuses\nexport class WalkFormatError extends Error {\n constructor() {\n super(...arguments);\n this.name = 'WalkFormatError';\n }\n}\n// @gmod/tabix loops forever on a NaN end and reads nothing for a NaN start\n// (GMOD/tabix-js#157), so every query refuses a range that is not finite first\nexport function checkRange(refName, start, end) {\n if (!Number.isFinite(start) || !Number.isFinite(end)) {\n throw new Error(`${refName}:${start}-${end} is not a finite range to query the graph's index for`);\n }\n}\n// Settles like `promise` unless `signal` aborts first\nfunction raceAbort(promise, signal) {\n if (!signal) {\n return promise;\n }\n signal.throwIfAborted();\n return new Promise((resolve, reject) => {\n const onAbort = () => {\n reject(signal.reason instanceof Error\n ? signal.reason\n : new Error(String(signal.reason)));\n };\n signal.addEventListener('abort', onAbort, { once: true });\n promise.then(resolve, reject).finally(() => {\n signal.removeEventListener('abort', onAbort);\n });\n });\n}\n/**\n * A `gfa-to-tabix --walks` file, `<prefix>.<sample>.walks.bed.gz`, read a\n * window at a time: one read over whole chunks, from the lookback chunks\n * before the window to its end, each chunk decoded once. The index first\n * estimates the bytes the read fetches, and a window past the byte budget\n * reads no row. Only the walks `keep` accepts are decoded. The step budget\n * bounds the steps the cut keeps, and rows holding READ_STEPS_PER_KEPT times\n * as many stop the read.\n */\nexport class WalkReader {\n constructor(walks) {\n this.walks = walks;\n }\n // The header, read once for every caller: one caller giving up stops only\n // its own wait, and a read that fails is tried again by the next caller\n header(opts = {}) {\n if (!this.headerRead) {\n const read = this.walks.getHeaderLines().then(lines => {\n var _a;\n const header = walkHeader(lines);\n if (header.format !== 2) {\n throw new WalkFormatError('This walk file is format 1, from gfa-to-tabix 0.12 or earlier; rebuild it with gfa-to-tabix 1.0 or later');\n }\n const chunk = (_a = header.chunk) !== null && _a !== void 0 ? _a : 65536;\n return {\n ...header,\n chunk,\n lookback: lookbackChunks(header.maxNode, chunk),\n };\n });\n read.catch(() => {\n if (this.headerRead === read) {\n this.headerRead = undefined;\n }\n });\n this.headerRead = read;\n }\n return raceAbort(this.headerRead, opts.signal);\n }\n // The reference sequences the walk file holds windows on\n referenceSequences(opts = {}) {\n return this.walks.getReferenceSequenceNames(opts);\n }\n /**\n * The walk file's sequence for `refName` on `sample`, or for `refName` as\n * the file spells it: `chr6` on `GRCh38` is `GRCh38#0#chr6`. Undefined when\n * the file holds neither.\n */\n async sequenceFor(sample, refName, opts = {}) {\n if (!this.lookupRead) {\n const read = this.walks.getReferenceSequenceNames().then(refNameLookup);\n read.catch(() => {\n if (this.lookupRead === read) {\n this.lookupRead = undefined;\n }\n });\n this.lookupRead = read;\n }\n const lookup = await raceAbort(this.lookupRead, opts.signal);\n return resolveRefName(lookup, sample, refName);\n }\n async queryStart(start, opts = {}) {\n const { chunk, lookback } = await this.header(opts);\n return chunkQueryStart(start, chunk, lookback);\n }\n async cut(refName, region, opts = {}) {\n var _a;\n const { signal, keep, context = WALK_CONTEXT, stepBudget = Infinity, byteBudget = Infinity, links = true, } = opts;\n const { chunk, lookback } = await this.header({ signal });\n const from = chunkQueryStart(region.start, chunk, lookback);\n const bytesForRegions = (_a = this.walks.bytesForRegions) === null || _a === void 0 ? void 0 : _a.bind(this.walks);\n const budgeted = Number.isFinite(byteBudget) && bytesForRegions !== undefined;\n const bytesFor = async (spans) => budgeted\n ? bytesForRegions(spans.map(span => ({ refName, ...span })), { signal })\n : 0;\n const tooLarge = budgeted\n ? await byteBudgetError(async (end) => {\n checkRange(refName, from, end);\n return bytesFor([{ start: from, end }]);\n }, byteBudget, region, chunk, opts.budgetNames)\n : undefined;\n if (tooLarge) {\n throw tooLarge;\n }\n const reads = new AbortController();\n const stop = () => {\n reads.abort(signal === null || signal === void 0 ? void 0 : signal.reason);\n };\n signal === null || signal === void 0 ? void 0 : signal.throwIfAborted();\n signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', stop, { once: true });\n const rows = [];\n let cut;\n const graph = new WalkGraph({\n refName,\n start: region.start,\n end: region.end,\n context,\n sequences: opts.sequences,\n });\n const decoded = new Set();\n const ends = [];\n // each chunk read is decoded once, into its rows, nodes and the links\n // between pieces\n const readChunks = async (start, end) => {\n checkRange(refName, start, end);\n const byChunk = new Map();\n await this.walks.getLines(refName, start, end, {\n signal: reads.signal,\n lineCallback: line => {\n const cols = line.split('\\t');\n const cs = +cols[1];\n const held = byChunk.get(cs);\n if (held) {\n held.push(cols);\n }\n else {\n byChunk.set(cs, [cols]);\n }\n },\n });\n for (const [cs, chunkRows] of byChunk) {\n if (decoded.has(cs)) {\n continue;\n }\n decoded.add(cs);\n const chunkCut = decodeChunk(chunkRows, keep, opts.sequences);\n rows.push(...chunkCut.rows);\n for (const [id, node] of chunkCut.nodes) {\n graph.placeNode(id, node);\n }\n graph.addSequences(chunkCut.sequences);\n graph.addChunk(chunkCut.chunk);\n ends.push(...chunkCut.ends);\n }\n if (links) {\n for (const [a, b] of pieceLinks(ends)) {\n graph.addLinkEnds(a, b);\n }\n }\n };\n try {\n await readChunks(from, region.end);\n const tooManyRead = stepBudgetError(rows, stepBudget, READ_STEPS_PER_KEPT, region, chunk, keep !== undefined, opts.budgetNames);\n if (tooManyRead) {\n throw tooManyRead;\n }\n // the chunks read, first to last, which a follow widens to the\n // farthest chunk a cut-off walk goes on in, so the reference between\n // is read too\n let first = from;\n let last = Math.floor((region.end - 1) / chunk) * chunk;\n const reach = FOLLOW_CHUNKS * chunk;\n const [lo, hi] = [first - reach, last + reach];\n cut = walkCut(joinPieces(rows), graph.nodes, refName);\n let spent = await bytesFor([{ start: from, end: region.end }]);\n for (let round = 0; round < FOLLOW_ROUNDS; round++) {\n const starts = cut.open\n .filter(c => c.refName === refName && c.start >= lo && c.start <= hi)\n .map(c => c.start);\n const spans = [\n { start: Math.min(first, ...starts), end: first },\n { start: last + chunk, end: Math.max(last, ...starts) + 1 },\n ].filter(span => span.end > span.start);\n if (spans.length === 0) {\n break;\n }\n spent += await bytesFor(spans);\n if (spent > byteBudget) {\n break;\n }\n first = Math.min(first, ...starts);\n last = Math.max(last, ...starts);\n await Promise.all(spans.map(({ start, end }) => readChunks(start, end)));\n cut = walkCut(joinPieces(rows), graph.nodes, refName);\n }\n }\n catch (error) {\n reads.abort();\n throw error;\n }\n finally {\n signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', stop);\n }\n const tooMany = keptStepsError(cut.fragments, stepBudget, region, keep !== undefined);\n if (tooMany) {\n throw tooMany;\n }\n return { graph, ...cut };\n }\n}\n", "import { checkRange } from '@jbrowse/graph-walks'\n\nimport type { TabixIndexedFile } from '@gmod/tabix'\n\nexport async function getLines(\n file: TabixIndexedFile,\n refName: string,\n start: number,\n end: number,\n opts: {\n signal?: AbortSignal\n lineCallback: (line: string, fileOffset: number) => void\n },\n) {\n checkRange(refName, start, end)\n return file.getLines(refName, start, end, opts)\n}\n\nexport async function bytesForRegions(\n file: TabixIndexedFile,\n regions: { refName: string; start: number; end: number }[],\n opts: { signal?: AbortSignal },\n) {\n for (const { refName, start, end } of regions) {\n checkRange(refName, start, end)\n }\n return file.bytesForRegions(regions, opts)\n}\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nexport var Z_NO_FLUSH = 0\nexport var Z_PARTIAL_FLUSH = 1\nexport var Z_SYNC_FLUSH = 2\nexport var Z_FULL_FLUSH = 3\nexport var Z_FINISH = 4\nexport var Z_BLOCK = 5\nexport var Z_TREES = 6\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nexport var Z_OK = 0\nexport var Z_STREAM_END = 1\nexport var Z_NEED_DICT = 2\nexport var Z_ERRNO = -1\nexport var Z_STREAM_ERROR = -2\nexport var Z_DATA_ERROR = -3\n//export var Z_MEM_ERROR = -4;\nexport var Z_BUF_ERROR = -5\n//export var Z_VERSION_ERROR = -6;\n\n/* compression levels */\nexport var Z_NO_COMPRESSION = 0\nexport var Z_BEST_SPEED = 1\nexport var Z_BEST_COMPRESSION = 9\nexport var Z_DEFAULT_COMPRESSION = -1\n\nexport var Z_FILTERED = 1\nexport var Z_HUFFMAN_ONLY = 2\nexport var Z_RLE = 3\nexport var Z_FIXED = 4\nexport var Z_DEFAULT_STRATEGY = 0\n\n/* Possible values of the data_type field (though see inflate()) */\nexport var Z_BINARY = 0\nexport var Z_TEXT = 1\n//export var Z_ASCII = 1; // = Z_TEXT (deprecated)\nexport var Z_UNKNOWN = 2\n\n/* The deflate compression method */\nexport var Z_DEFLATED = 8\n//export var Z_NULL = null // Use -1 or null inline; depending on var type\n", "function _has(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key)\n}\n\nexport function assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1)\n while (sources.length) {\n var source = sources.shift()\n if (!source) {\n continue\n }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object')\n }\n\n for (var p in source) {\n if (_has(source, p)) {\n obj[p] = source[p]\n }\n }\n }\n\n return obj\n}\n\n// reduce buffer size, avoiding mem copy\nexport function shrinkBuf(buf, size) {\n if (buf.length === size) {\n return buf\n }\n if (buf.subarray) {\n return buf.subarray(0, size)\n }\n buf.length = size\n return buf\n}\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs)\n return\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i]\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result\n\n // calculate data length\n len = 0\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length\n }\n\n // join chunks\n result = new Uint8Array(len)\n pos = 0\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i]\n result.set(chunk, pos)\n pos += chunk.length\n }\n\n return result\n },\n Buf8: function (size) {\n return new Uint8Array(size)\n },\n Buf16: function (size) {\n return new Uint16Array(size)\n },\n Buf32: function (size) {\n return new Int32Array(size)\n },\n}\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i]\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks)\n },\n Buf8: function (size) {\n return new Array(size)\n },\n Buf16: function (size) {\n return new Array(size)\n },\n Buf32: function (size) {\n return new Array(size)\n },\n}\n\nlet typedOK = () => {\n const supported =\n typeof Uint8Array !== 'undefined' &&\n typeof Uint16Array !== 'undefined' &&\n typeof Int32Array !== 'undefined'\n\n typedOK = () => supported\n return supported\n}\n\nexport let arraySet = (dest, src, src_offs, len, dest_offs) => {\n arraySet = typedOK() ? fnTyped.arraySet : fnUntyped.arraySet\n\n return arraySet(dest, src, src_offs, len, dest_offs)\n}\n\nexport let flattenChunks = chunks => {\n flattenChunks = typedOK() ? fnTyped.flattenChunks : fnUntyped.flattenChunks\n\n return flattenChunks(chunks)\n}\n\nexport let Buf8 = size => {\n Buf8 = typedOK() ? fnTyped.Buf8 : fnUntyped.Buf8\n return Buf8(size)\n}\n\nexport let Buf16 = size => {\n Buf16 = typedOK() ? fnTyped.Buf16 : fnUntyped.Buf16\n return Buf16(size)\n}\n\nexport let Buf32 = size => {\n Buf32 = typedOK() ? fnTyped.Buf32 : fnUntyped.Buf32\n return Buf32(size)\n}\n\nexport function setTyped(on) {\n arraySet = on ? fnTyped.arraySet : fnUntyped.arraySet\n flattenChunks = on ? fnTyped.flattenChunks : fnUntyped.flattenChunks\n Buf8 = on ? fnTyped.Buf8 : fnUntyped.Buf8\n Buf16 = on ? fnTyped.Buf16 : fnUntyped.Buf16\n Buf32 = on ? fnTyped.Buf32 : fnUntyped.Buf32\n}\n", "// String encode/decode helpers\n\nimport { Buf8, shrinkBuf } from './common.js'\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\nlet strApplyOK = function () {\n let result = true\n try {\n String.fromCharCode.apply(null, [0])\n } catch (_) {\n result = false\n }\n\n strApplyOK = () => result\n return result\n}\n\nlet strApplyUintOK = function () {\n let result = true\n try {\n String.fromCharCode.apply(null, new Uint8Array(1))\n } catch (_) {\n result = false\n }\n\n strApplyUintOK = () => result\n return result\n}\n\nlet utf8len = function (c) {\n // Table with utf8 lengths (calculated by first byte of sequence)\n // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n // because max possible codepoint is 0x10ffff\n var table = Buf8(256)\n for (var q = 0; q < 256; q++) {\n table[q] =\n q >= 252\n ? 6\n : q >= 248\n ? 5\n : q >= 240\n ? 4\n : q >= 224\n ? 3\n : q >= 192\n ? 2\n : 1\n }\n table[254] = table[254] = 1 // Invalid sequence start\n\n utf8len = arg => table[arg]\n return table[c]\n}\n\n// convert string to array (typed, when possible)\nexport function string2buf(str) {\n var buf,\n c,\n c2,\n m_pos,\n i,\n str_len = str.length,\n buf_len = 0\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos)\n if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1)\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00)\n m_pos++\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len)\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos)\n if ((c & 0xfc00) === 0xd800 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1)\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00)\n m_pos++\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xc0 | (c >>> 6)\n buf[i++] = 0x80 | (c & 0x3f)\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xe0 | (c >>> 12)\n buf[i++] = 0x80 | ((c >>> 6) & 0x3f)\n buf[i++] = 0x80 | (c & 0x3f)\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18)\n buf[i++] = 0x80 | ((c >>> 12) & 0x3f)\n buf[i++] = 0x80 | ((c >>> 6) & 0x3f)\n buf[i++] = 0x80 | (c & 0x3f)\n }\n }\n\n return buf\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if ((buf.subarray && strApplyUintOK()) || (!buf.subarray && strApplyOK())) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len))\n }\n }\n\n var result = ''\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i])\n }\n return result\n}\n\n// Convert byte array to binary string\nexport function buf2binstring(buf) {\n return _buf2binstring(buf, buf.length)\n}\n\n// Convert binary string (typed, when possible)\nexport function binstring2buf(str) {\n var buf = new Uint8Array(str.length)\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i)\n }\n return buf\n}\n\n// convert array to string\nexport function buf2string(buf, max) {\n var i, out, c, c_len\n var len = max || buf.length\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2)\n\n for (out = 0, i = 0; i < len; ) {\n c = buf[i++]\n // quick process ascii\n if (c < 0x80) {\n utf16buf[out++] = c\n continue\n }\n\n c_len = utf8len(c)\n // skip 5 & 6 byte codes\n if (c_len > 4) {\n utf16buf[out++] = 0xfffd\n i += c_len - 1\n continue\n }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f)\n c_len--\n }\n\n // terminated by end of string?\n if (c_len > 1) {\n utf16buf[out++] = 0xfffd\n continue\n }\n\n if (c < 0x10000) {\n utf16buf[out++] = c\n } else {\n c -= 0x10000\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff)\n utf16buf[out++] = 0xdc00 | (c & 0x3ff)\n }\n }\n\n return _buf2binstring(utf16buf, out)\n}\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexport function utf8border(buf, max) {\n var pos\n\n max = max || buf.length\n if (max > buf.length) {\n max = buf.length\n }\n\n // go back from last position, until start of sequence found\n pos = max - 1\n while (pos >= 0 && (buf[pos] & 0xc0) === 0x80) {\n pos--\n }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) {\n return max\n }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) {\n return max\n }\n\n return pos + utf8len(buf[pos]) > max ? pos : max\n}\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nexport default function GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0\n /* modification time */\n this.time = 0\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0\n /* operating system */\n this.os = 0\n /* pointer to extra field or Z_NULL if none */\n this.extra = null\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0 // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = ''\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = ''\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false\n}\n", "// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nexport default function adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) | 0,\n s2 = ((adler >>> 16) & 0xffff) | 0,\n n = 0\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len\n len -= n\n\n do {\n s1 = (s1 + buf[pos++]) | 0\n s2 = (s2 + s1) | 0\n } while (--n)\n\n s1 %= 65521\n s2 %= 65521\n }\n\n return s1 | (s2 << 16) | 0\n}\n", "// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c,\n table = []\n\n for (var n = 0; n < 256; n++) {\n c = n\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1\n }\n table[n] = c\n }\n\n return table\n}\n\nlet crcTable = function () {\n const table = makeTable()\n crcTable = () => table\n return table\n}\n\nexport default function crc32(crc, buf, len, pos) {\n var t = crcTable(),\n end = pos + len\n\n crc ^= -1\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xff]\n }\n\n return crc ^ -1 // >>> 0;\n}\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30 /* got a data error -- remain here until reset */\nvar TYPE = 12 /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nexport default function inflate_fast(strm, start) {\n var state\n var _in /* local strm.input */\n var last /* have enough input while in < last */\n var _out /* local strm.output */\n var beg /* inflate()'s initial strm.output */\n var end /* while out < end, enough space available */\n //#ifdef INFLATE_STRICT\n var dmax /* maximum distance from zlib header */\n //#endif\n var wsize /* window size or zero if not using window */\n var whave /* valid bytes in the window */\n var wnext /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window /* allocated sliding window, if wsize != 0 */\n var hold /* local strm.hold */\n var bits /* local strm.bits */\n var lcode /* local strm.lencode */\n var dcode /* local strm.distcode */\n var lmask /* mask for first level of length codes */\n var dmask /* mask for first level of distance codes */\n var here /* retrieved table entry */\n var op /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len /* match length, unused bytes */\n var dist /* match distance */\n var from /* where to copy match from */\n var from_source\n\n var input, output // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state\n //here = state.here;\n _in = strm.next_in\n input = strm.input\n last = _in + (strm.avail_in - 5)\n _out = strm.next_out\n output = strm.output\n beg = _out - (start - strm.avail_out)\n end = _out + (strm.avail_out - 257)\n //#ifdef INFLATE_STRICT\n dmax = state.dmax\n //#endif\n wsize = state.wsize\n whave = state.whave\n wnext = state.wnext\n s_window = state.window\n hold = state.hold\n bits = state.bits\n lcode = state.lencode\n dcode = state.distcode\n lmask = (1 << state.lenbits) - 1\n dmask = (1 << state.distbits) - 1\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top: do {\n if (bits < 15) {\n hold += input[_in++] << bits\n bits += 8\n hold += input[_in++] << bits\n bits += 8\n }\n\n here = lcode[hold & lmask]\n\n dolen: for (;;) {\n // Goto emulation\n op = here >>> 24 /*here.bits*/\n hold >>>= op\n bits -= op\n op = (here >>> 16) & 0xff /*here.op*/\n if (op === 0) {\n /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff /*here.val*/\n } else if (op & 16) {\n /* length base */\n len = here & 0xffff /*here.val*/\n op &= 15 /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits\n bits += 8\n }\n len += hold & ((1 << op) - 1)\n hold >>>= op\n bits -= op\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits\n bits += 8\n hold += input[_in++] << bits\n bits += 8\n }\n here = dcode[hold & dmask]\n\n dodist: for (;;) {\n // goto emulation\n op = here >>> 24 /*here.bits*/\n hold >>>= op\n bits -= op\n op = (here >>> 16) & 0xff /*here.op*/\n\n if (op & 16) {\n /* distance base */\n dist = here & 0xffff /*here.val*/\n op &= 15 /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits\n bits += 8\n if (bits < op) {\n hold += input[_in++] << bits\n bits += 8\n }\n }\n dist += hold & ((1 << op) - 1)\n //#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back'\n state.mode = BAD\n break top\n }\n //#endif\n hold >>>= op\n bits -= op\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg /* max distance in output */\n if (dist > op) {\n /* see if copy from window */\n op = dist - op /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back'\n state.mode = BAD\n break top\n }\n\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // if (len <= op - whave) {\n // do {\n // output[_out++] = 0;\n // } while (--len);\n // continue top;\n // }\n // len -= op - whave;\n // do {\n // output[_out++] = 0;\n // } while (--op > whave);\n // if (op === 0) {\n // from = _out - dist;\n // do {\n // output[_out++] = output[from++];\n // } while (--len);\n // continue top;\n // }\n //#endif\n }\n from = 0 // window index\n from_source = s_window\n if (wnext === 0) {\n /* very common case */\n from += wsize - op\n if (op < len) {\n /* some from window */\n len -= op\n do {\n output[_out++] = s_window[from++]\n } while (--op)\n from = _out - dist /* rest from output */\n from_source = output\n }\n } else if (wnext < op) {\n /* wrap around window */\n from += wsize + wnext - op\n op -= wnext\n if (op < len) {\n /* some from end of window */\n len -= op\n do {\n output[_out++] = s_window[from++]\n } while (--op)\n from = 0\n if (wnext < len) {\n /* some from start of window */\n op = wnext\n len -= op\n do {\n output[_out++] = s_window[from++]\n } while (--op)\n from = _out - dist /* rest from output */\n from_source = output\n }\n }\n } else {\n /* contiguous in window */\n from += wnext - op\n if (op < len) {\n /* some from window */\n len -= op\n do {\n output[_out++] = s_window[from++]\n } while (--op)\n from = _out - dist /* rest from output */\n from_source = output\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++]\n output[_out++] = from_source[from++]\n output[_out++] = from_source[from++]\n len -= 3\n }\n if (len) {\n output[_out++] = from_source[from++]\n if (len > 1) {\n output[_out++] = from_source[from++]\n }\n }\n } else {\n from = _out - dist /* copy direct from output */\n do {\n /* minimum length is three */\n output[_out++] = output[from++]\n output[_out++] = output[from++]\n output[_out++] = output[from++]\n len -= 3\n } while (len > 2)\n if (len) {\n output[_out++] = output[from++]\n if (len > 1) {\n output[_out++] = output[from++]\n }\n }\n }\n } else if ((op & 64) === 0) {\n /* 2nd level distance code */\n here =\n dcode[(here & 0xffff) /*here.val*/ + (hold & ((1 << op) - 1))]\n continue dodist\n } else {\n strm.msg = 'invalid distance code'\n state.mode = BAD\n break top\n }\n\n break // need to emulate goto via \"continue\"\n }\n } else if ((op & 64) === 0) {\n /* 2nd level length code */\n here = lcode[(here & 0xffff) /*here.val*/ + (hold & ((1 << op) - 1))]\n continue dolen\n } else if (op & 32) {\n /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE\n break top\n } else {\n strm.msg = 'invalid literal/length code'\n state.mode = BAD\n break top\n }\n\n break // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end)\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3\n _in -= len\n bits -= len << 3\n hold &= (1 << bits) - 1\n\n /* update state and return */\n strm.next_in = _in\n strm.next_out = _out\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last)\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end)\n state.hold = hold\n state.bits = bits\n return\n}\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nimport { Buf16 } from '../utils/common.js'\n\nvar MAXBITS = 15\nvar ENOUGH_LENS = 852\nvar ENOUGH_DISTS = 592\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0\nvar LENS = 1\nvar DISTS = 2\n\nvar lbase = [\n /* Length codes 257..285 base */ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19,\n 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0,\n]\n\nvar lext = [\n /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17,\n 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72,\n 78,\n]\n\nvar dbase = [\n /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65,\n 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193,\n 12289, 16385, 24577, 0, 0,\n]\n\nvar dext = [\n /* Distance codes 0..29 extra */ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20,\n 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29,\n 64, 64,\n]\n\nexport default function inflate_table(\n type,\n lens,\n lens_index,\n codes,\n table,\n table_index,\n work,\n opts,\n) {\n var bits = opts.bits\n //here = opts.here; /* table entry for duplication */\n\n var len = 0 /* a code's length in bits */\n var sym = 0 /* index of code symbols */\n var min = 0,\n max = 0 /* minimum and maximum code lengths */\n var root = 0 /* number of index bits for root table */\n var curr = 0 /* number of index bits for current table */\n var drop = 0 /* code bits to drop for sub-table */\n var left = 0 /* number of prefix codes available */\n var used = 0 /* code entries in table used */\n var huff = 0 /* Huffman code */\n var incr /* for incrementing code, index */\n var fill /* index for replicating entries */\n var low /* low bits for current root entry */\n var mask /* mask for low root bits */\n var next /* next available space in table */\n var base = null /* base value table to use */\n var base_index = 0\n // var shoextra; /* extra bits table to use */\n var end /* use base and extra for symbol > end */\n var count = Buf16(MAXBITS + 1) //[MAXBITS+1]; /* number of codes of each length */\n var offs = Buf16(MAXBITS + 1) //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null\n var extra_index = 0\n\n var here_bits, here_op, here_val\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break\n }\n }\n if (root > max) {\n root = max\n }\n if (max === 0) {\n /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0\n\n opts.bits = 1\n return 0 /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break\n }\n }\n if (root < min) {\n root = min\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1\n left -= count[len]\n if (left < 0) {\n return -1\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1 /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len]\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work /* dummy value--not used */\n end = 19\n } else if (type === LENS) {\n base = lbase\n base_index -= 257\n extra = lext\n extra_index -= 257\n end = 256\n } else {\n /* DISTS */\n base = dbase\n extra = dext\n end = -1\n }\n\n /* initialize opts for loop */\n huff = 0 /* starting code */\n sym = 0 /* starting code symbol */\n len = min /* starting code length */\n next = table_index /* current table to fill in */\n curr = root /* current table index bits */\n drop = 0 /* current bits to drop from code for index */\n low = -1 /* trigger new sub-table when len > root */\n used = 1 << root /* use root table entries */\n mask = used - 1 /* mask for comparing low */\n\n /* check available table space */\n if (\n (type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)\n ) {\n return 1\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop\n if (work[sym] < end) {\n here_op = 0\n here_val = work[sym]\n } else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]]\n here_val = base[base_index + work[sym]]\n } else {\n here_op = 32 + 64 /* end of block */\n here_val = 0\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop)\n fill = 1 << curr\n min = fill /* save offset to next table */\n do {\n fill -= incr\n table[next + (huff >> drop) + fill] =\n (here_bits << 24) | (here_op << 16) | here_val | 0\n } while (fill !== 0)\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1)\n while (huff & incr) {\n incr >>= 1\n }\n if (incr !== 0) {\n huff &= incr - 1\n huff += incr\n } else {\n huff = 0\n }\n\n /* go to next symbol, update count, len */\n sym++\n if (--count[len] === 0) {\n if (len === max) {\n break\n }\n len = lens[lens_index + work[sym]]\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root\n }\n\n /* increment past last table */\n next += min /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop\n left = 1 << curr\n while (curr + drop < max) {\n left -= count[curr + drop]\n if (left <= 0) {\n break\n }\n curr++\n left <<= 1\n }\n\n /* check for enough space */\n used += 1 << curr\n if (\n (type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)\n ) {\n return 1\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) | 0\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) | 0\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root\n return 0\n}\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nimport adler32 from './adler32.js'\nimport crc32 from './crc32.js'\nimport inflate_fast from './inffast.js'\nimport inflate_table from './inftrees.js'\nimport { Buf16, Buf32, Buf8, arraySet } from '../utils/common.js'\n\nvar CODES = 0\nvar LENS = 1\nvar DISTS = 2\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4\nvar Z_BLOCK = 5\nvar Z_TREES = 6\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0\nvar Z_STREAM_END = 1\nvar Z_NEED_DICT = 2\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2\nvar Z_DATA_ERROR = -3\nvar Z_MEM_ERROR = -4\nvar Z_BUF_ERROR = -5\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\nvar HEAD = 1 /* i: waiting for magic header */\nvar FLAGS = 2 /* i: waiting for method and flags (gzip) */\nvar TIME = 3 /* i: waiting for modification time (gzip) */\nvar OS = 4 /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5 /* i: waiting for extra length (gzip) */\nvar EXTRA = 6 /* i: waiting for extra bytes (gzip) */\nvar NAME = 7 /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8 /* i: waiting for end of comment (gzip) */\nvar HCRC = 9 /* i: waiting for header crc (gzip) */\nvar DICTID = 10 /* i: waiting for dictionary check value */\nvar DICT = 11 /* waiting for inflateSetDictionary() call */\nvar TYPE = 12 /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13 /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14 /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15 /* i/o: same as COPY below, but only first time in */\nvar COPY = 16 /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17 /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18 /* i: waiting for code length code lengths */\nvar CODELENS = 19 /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20 /* i: same as LEN below, but only first time in */\nvar LEN = 21 /* i: waiting for length/lit/eob code */\nvar LENEXT = 22 /* i: waiting for length extra bits */\nvar DIST = 23 /* i: waiting for distance code */\nvar DISTEXT = 24 /* i: waiting for distance extra bits */\nvar MATCH = 25 /* o: waiting for output space to copy string */\nvar LIT = 26 /* o: waiting for output space to write literal */\nvar CHECK = 27 /* i: waiting for 32-bit check value */\nvar LENGTH = 28 /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29 /* finished check, done -- remain here until reset */\nvar BAD = 30 /* got a data error -- remain here until reset */\nvar MEM = 31 /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32 /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\nvar ENOUGH_LENS = 852\nvar ENOUGH_DISTS = 592\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS\n\nfunction zswap32(q) {\n return (\n ((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24)\n )\n}\n\nfunction InflateState() {\n this.mode = 0 /* current inflate mode */\n this.last = false /* true if processing last block */\n this.wrap = 0 /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false /* true if dictionary provided */\n this.flags = 0 /* gzip header method and flags (0 if zlib) */\n this.dmax = 0 /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0 /* protected copy of check value */\n this.total = 0 /* protected copy of output count */\n // TODO: may be {}\n this.head = null /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0 /* log base 2 of requested window size */\n this.wsize = 0 /* window size or zero if not using window */\n this.whave = 0 /* valid bytes in the window */\n this.wnext = 0 /* window write index */\n this.window = null /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0 /* input bit accumulator */\n this.bits = 0 /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0 /* literal or length of data to copy */\n this.offset = 0 /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0 /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null /* starting table for length/literal codes */\n this.distcode = null /* starting table for distance codes */\n this.lenbits = 0 /* index bits for lencode */\n this.distbits = 0 /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0 /* number of code length code lengths */\n this.nlen = 0 /* number of length code lengths */\n this.ndist = 0 /* number of distance code lengths */\n this.have = 0 /* number of code lengths in lens[] */\n this.next = null /* next available space in codes[] */\n\n this.lens = Buf16(320) /* temporary storage for code lengths */\n this.work = Buf16(288) /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null /* dynamic table for distance codes (JS specific) */\n this.sane = 0 /* if false, allow invalid distance too far */\n this.back = 0 /* bits back of last unprocessed length/lit */\n this.was = 0 /* initial length of match */\n}\n\nexport function inflateResetKeep(strm) {\n var state\n\n if (!strm || !strm.state) {\n return Z_STREAM_ERROR\n }\n state = strm.state\n strm.total_in = strm.total_out = state.total = 0\n strm.msg = '' /*Z_NULL*/\n if (state.wrap) {\n /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1\n }\n state.mode = HEAD\n state.last = 0\n state.havedict = 0\n state.dmax = 32768\n state.head = null /*Z_NULL*/\n state.hold = 0\n state.bits = 0\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = Buf32(ENOUGH_LENS)\n state.distcode = state.distdyn = Buf32(ENOUGH_DISTS)\n\n state.sane = 1\n state.back = -1\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK\n}\n\nexport function inflateReset(strm) {\n var state\n\n if (!strm || !strm.state) {\n return Z_STREAM_ERROR\n }\n state = strm.state\n state.wsize = 0\n state.whave = 0\n state.wnext = 0\n return inflateResetKeep(strm)\n}\n\nexport function inflateReset2(strm, windowBits) {\n var wrap\n var state\n\n /* get the state */\n if (!strm || !strm.state) {\n return Z_STREAM_ERROR\n }\n state = strm.state\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0\n windowBits = -windowBits\n } else {\n wrap = (windowBits >> 4) + 1\n if (windowBits < 48) {\n windowBits &= 15\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap\n state.wbits = windowBits\n return inflateReset(strm)\n}\n\nexport function inflateInit2(strm, windowBits) {\n var ret\n var state\n\n if (!strm) {\n return Z_STREAM_ERROR\n }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState()\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state\n state.window = null /*Z_NULL*/\n ret = inflateReset2(strm, windowBits)\n if (ret !== Z_OK) {\n strm.state = null /*Z_NULL*/\n }\n return ret\n}\n\nexport function inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS)\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true\n\nvar lenfix, distfix // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym\n\n lenfix = Buf32(512)\n distfix = Buf32(32)\n\n /* literal/length table */\n sym = 0\n while (sym < 144) {\n state.lens[sym++] = 8\n }\n while (sym < 256) {\n state.lens[sym++] = 9\n }\n while (sym < 280) {\n state.lens[sym++] = 7\n }\n while (sym < 288) {\n state.lens[sym++] = 8\n }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 })\n\n /* distance table */\n sym = 0\n while (sym < 32) {\n state.lens[sym++] = 5\n }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, {\n bits: 5,\n })\n\n /* do this just once */\n virgin = false\n }\n\n state.lencode = lenfix\n state.lenbits = 9\n state.distcode = distfix\n state.distbits = 5\n}\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist\n var state = strm.state\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits\n state.wnext = 0\n state.whave = 0\n\n state.window = Buf8(state.wsize)\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0)\n state.wnext = 0\n state.whave = state.wsize\n } else {\n dist = state.wsize - state.wnext\n if (dist > copy) {\n dist = copy\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext)\n copy -= dist\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0)\n state.wnext = copy\n state.whave = state.wsize\n } else {\n state.wnext += dist\n if (state.wnext === state.wsize) {\n state.wnext = 0\n }\n if (state.whave < state.wsize) {\n state.whave += dist\n }\n }\n }\n return 0\n}\n\nexport function inflate(strm, flush) {\n var state\n var input, output // input/output buffers\n var next /* next input INDEX */\n var put /* next output INDEX */\n var have, left /* available input and output */\n var hold /* bit buffer */\n var bits /* bits in bit buffer */\n var _in, _out /* save starting available input and output */\n var copy /* number of stored or match bytes to copy */\n var from /* where to copy match bytes from */\n var from_source\n var here = 0 /* current decoding table entry */\n var here_bits, here_op, here_val // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val // paked \"last\" denormalized (JS specific)\n var len /* length to copy for repeats, bits to drop */\n var ret /* return code */\n var hbuf = Buf8(4) /* buffer for gzip header crc calculation */\n var opts\n\n var n // temporary var for NEED_BITS\n\n var order =\n /* permutation of code lengths */\n [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]\n\n if (\n !strm ||\n !strm.state ||\n !strm.output ||\n (!strm.input && strm.avail_in !== 0)\n ) {\n return Z_STREAM_ERROR\n }\n\n state = strm.state\n if (state.mode === TYPE) {\n state.mode = TYPEDO\n } /* skip check */\n\n //--- LOAD() ---\n put = strm.next_out\n output = strm.output\n left = strm.avail_out\n next = strm.next_in\n input = strm.input\n have = strm.avail_in\n hold = state.hold\n bits = state.bits\n //---\n\n _in = have\n _out = left\n ret = Z_OK\n\n // goto emulation\n inf_leave: for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO\n break\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n if (state.wrap & 2 && hold === 0x8b1f) {\n /* gzip header */\n state.check = 0 /*crc32(0L, Z_NULL, 0)*/\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff\n hbuf[1] = (hold >>> 8) & 0xff\n state.check = crc32(state.check, hbuf, 2, 0)\n //===//\n\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n state.mode = FLAGS\n break\n }\n state.flags = 0 /* expect zlib header */\n if (state.head) {\n state.head.done = false\n }\n if (\n !(state.wrap & 1) /* check if zlib header allowed */ ||\n (((hold & 0xff) /*BITS(8)*/ << 8) + (hold >> 8)) % 31\n ) {\n strm.msg = 'incorrect header check'\n state.mode = BAD\n break\n }\n if ((hold & 0x0f) /*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method'\n state.mode = BAD\n break\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4\n bits -= 4\n //---//\n len = (hold & 0x0f) /*BITS(4)*/ + 8\n if (state.wbits === 0) {\n state.wbits = len\n } else if (len > state.wbits) {\n strm.msg = 'invalid window size'\n state.mode = BAD\n break\n }\n state.dmax = 1 << len\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1 /*adler32(0L, Z_NULL, 0)*/\n state.mode = hold & 0x200 ? DICTID : TYPE\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n break\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.flags = hold\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method'\n state.mode = BAD\n break\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set'\n state.mode = BAD\n break\n }\n if (state.head) {\n state.head.text = (hold >> 8) & 1\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff\n hbuf[1] = (hold >>> 8) & 0xff\n state.check = crc32(state.check, hbuf, 2, 0)\n //===//\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n state.mode = TIME\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n if (state.head) {\n state.head.time = hold\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff\n hbuf[1] = (hold >>> 8) & 0xff\n hbuf[2] = (hold >>> 16) & 0xff\n hbuf[3] = (hold >>> 24) & 0xff\n state.check = crc32(state.check, hbuf, 4, 0)\n //===\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n state.mode = OS\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n if (state.head) {\n state.head.xflags = hold & 0xff\n state.head.os = hold >> 8\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff\n hbuf[1] = (hold >>> 8) & 0xff\n state.check = crc32(state.check, hbuf, 2, 0)\n //===//\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n state.mode = EXLEN\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.length = hold\n if (state.head) {\n state.head.extra_len = hold\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff\n hbuf[1] = (hold >>> 8) & 0xff\n state.check = crc32(state.check, hbuf, 2, 0)\n //===//\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n } else if (state.head) {\n state.head.extra = null /*Z_NULL*/\n }\n state.mode = EXTRA\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length\n if (copy > have) {\n copy = have\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len)\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len,\n )\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next)\n }\n have -= copy\n next += copy\n state.length -= copy\n }\n if (state.length) {\n break inf_leave\n }\n }\n state.length = 0\n state.mode = NAME\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) {\n break inf_leave\n }\n copy = 0\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++]\n /* use constant limit because in js we should not preallocate memory */\n if (\n state.head &&\n len &&\n state.length < 65536 /*state.head.name_max*/\n ) {\n state.head.name += String.fromCharCode(len)\n }\n } while (len && copy < have)\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next)\n }\n have -= copy\n next += copy\n if (len) {\n break inf_leave\n }\n } else if (state.head) {\n state.head.name = null\n }\n state.length = 0\n state.mode = COMMENT\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) {\n break inf_leave\n }\n copy = 0\n do {\n len = input[next + copy++]\n /* use constant limit because in js we should not preallocate memory */\n if (\n state.head &&\n len &&\n state.length < 65536 /*state.head.comm_max*/\n ) {\n state.head.comment += String.fromCharCode(len)\n }\n } while (len && copy < have)\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next)\n }\n have -= copy\n next += copy\n if (len) {\n break inf_leave\n }\n } else if (state.head) {\n state.head.comment = null\n }\n state.mode = HCRC\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch'\n state.mode = BAD\n break\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n }\n if (state.head) {\n state.head.hcrc = (state.flags >> 9) & 1\n state.head.done = true\n }\n strm.adler = state.check = 0\n state.mode = TYPE\n break\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n strm.adler = state.check = zswap32(hold)\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n state.mode = DICT\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put\n strm.avail_out = left\n strm.next_in = next\n strm.avail_in = have\n state.hold = hold\n state.bits = bits\n //---\n return Z_NEED_DICT\n }\n strm.adler = state.check = 1 /*adler32(0L, Z_NULL, 0)*/\n state.mode = TYPE\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7\n bits -= bits & 7\n //---//\n state.mode = CHECK\n break\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.last = hold & 0x01 /*BITS(1)*/\n //--- DROPBITS(1) ---//\n hold >>>= 1\n bits -= 1\n //---//\n\n switch (hold & 0x03 /*BITS(2)*/) {\n case 0 /* stored block */:\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED\n break\n case 1 /* fixed block */:\n fixedtables(state)\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_ /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2\n bits -= 2\n //---//\n break inf_leave\n }\n break\n case 2 /* dynamic block */:\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE\n break\n case 3:\n strm.msg = 'invalid block type'\n state.mode = BAD\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2\n bits -= 2\n //---//\n break\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7\n bits -= bits & 7\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths'\n state.mode = BAD\n break\n }\n state.length = hold & 0xffff\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n state.mode = COPY_\n if (flush === Z_TREES) {\n break inf_leave\n }\n /* falls through */\n case COPY_:\n state.mode = COPY\n /* falls through */\n case COPY:\n copy = state.length\n if (copy) {\n if (copy > have) {\n copy = have\n }\n if (copy > left) {\n copy = left\n }\n if (copy === 0) {\n break inf_leave\n }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put)\n //---//\n have -= copy\n next += copy\n left -= copy\n put += copy\n state.length -= copy\n break\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE\n break\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.nlen = (hold & 0x1f) /*BITS(5)*/ + 257\n //--- DROPBITS(5) ---//\n hold >>>= 5\n bits -= 5\n //---//\n state.ndist = (hold & 0x1f) /*BITS(5)*/ + 1\n //--- DROPBITS(5) ---//\n hold >>>= 5\n bits -= 5\n //---//\n state.ncode = (hold & 0x0f) /*BITS(4)*/ + 4\n //--- DROPBITS(4) ---//\n hold >>>= 4\n bits -= 4\n //---//\n //#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols'\n state.mode = BAD\n break\n }\n //#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0\n state.mode = LENLENS\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.lens[order[state.have++]] = hold & 0x07 //BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3\n bits -= 3\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn\n state.lenbits = 7\n\n opts = { bits: state.lenbits }\n ret = inflate_table(\n CODES,\n state.lens,\n 0,\n 19,\n state.lencode,\n 0,\n state.work,\n opts,\n )\n state.lenbits = opts.bits\n\n if (ret) {\n strm.msg = 'invalid code lengths set'\n state.mode = BAD\n break\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0\n state.mode = CODELENS\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here =\n state.lencode[\n hold & ((1 << state.lenbits) - 1)\n ] /*BITS(state.lenbits)*/\n here_bits = here >>> 24\n here_op = (here >>> 16) & 0xff\n here_val = here & 0xffff\n\n if (here_bits <= bits) {\n break\n }\n //--- PULLBYTE() ---//\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits\n bits -= here_bits\n //---//\n state.lens[state.have++] = here_val\n } else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2\n while (bits < n) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits\n bits -= here_bits\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat'\n state.mode = BAD\n break\n }\n len = state.lens[state.have - 1]\n copy = 3 + (hold & 0x03) //BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2\n bits -= 2\n //---//\n } else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3\n while (bits < n) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits\n bits -= here_bits\n //---//\n len = 0\n copy = 3 + (hold & 0x07) //BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3\n bits -= 3\n //---//\n } else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7\n while (bits < n) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits\n bits -= here_bits\n //---//\n len = 0\n copy = 11 + (hold & 0x7f) //BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7\n bits -= 7\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat'\n state.mode = BAD\n break\n }\n while (copy--) {\n state.lens[state.have++] = len\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) {\n break\n }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block'\n state.mode = BAD\n break\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9\n\n opts = { bits: state.lenbits }\n ret = inflate_table(\n LENS,\n state.lens,\n 0,\n state.nlen,\n state.lencode,\n 0,\n state.work,\n opts,\n )\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set'\n state.mode = BAD\n break\n }\n\n state.distbits = 6\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn\n opts = { bits: state.distbits }\n ret = inflate_table(\n DISTS,\n state.lens,\n state.nlen,\n state.ndist,\n state.distcode,\n 0,\n state.work,\n opts,\n )\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set'\n state.mode = BAD\n break\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_\n if (flush === Z_TREES) {\n break inf_leave\n }\n /* falls through */\n case LEN_:\n state.mode = LEN\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put\n strm.avail_out = left\n strm.next_in = next\n strm.avail_in = have\n state.hold = hold\n state.bits = bits\n //---\n inflate_fast(strm, _out)\n //--- LOAD() ---\n put = strm.next_out\n output = strm.output\n left = strm.avail_out\n next = strm.next_in\n input = strm.input\n have = strm.avail_in\n hold = state.hold\n bits = state.bits\n //---\n\n if (state.mode === TYPE) {\n state.back = -1\n }\n break\n }\n state.back = 0\n for (;;) {\n here =\n state.lencode[\n hold & ((1 << state.lenbits) - 1)\n ] /*BITS(state.lenbits)*/\n here_bits = here >>> 24\n here_op = (here >>> 16) & 0xff\n here_val = here & 0xffff\n\n if (here_bits <= bits) {\n break\n }\n //--- PULLBYTE() ---//\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits\n last_op = here_op\n last_val = here_val\n for (;;) {\n here =\n state.lencode[\n last_val +\n ((hold &\n ((1 << (last_bits + last_op)) -\n 1)) /*BITS(last.bits + last.op)*/ >>\n last_bits)\n ]\n here_bits = here >>> 24\n here_op = (here >>> 16) & 0xff\n here_val = here & 0xffff\n\n if (last_bits + here_bits <= bits) {\n break\n }\n //--- PULLBYTE() ---//\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits\n bits -= last_bits\n //---//\n state.back += last_bits\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits\n bits -= here_bits\n //---//\n state.back += here_bits\n state.length = here_val\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT\n break\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1\n state.mode = TYPE\n break\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code'\n state.mode = BAD\n break\n }\n state.extra = here_op & 15\n state.mode = LENEXT\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra\n while (bits < n) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1) /*BITS(state.extra)*/\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra\n bits -= state.extra\n //---//\n state.back += state.extra\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length\n state.mode = DIST\n /* falls through */\n case DIST:\n for (;;) {\n here =\n state.distcode[\n hold & ((1 << state.distbits) - 1)\n ] /*BITS(state.distbits)*/\n here_bits = here >>> 24\n here_op = (here >>> 16) & 0xff\n here_val = here & 0xffff\n\n if (here_bits <= bits) {\n break\n }\n //--- PULLBYTE() ---//\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits\n last_op = here_op\n last_val = here_val\n for (;;) {\n here =\n state.distcode[\n last_val +\n ((hold &\n ((1 << (last_bits + last_op)) -\n 1)) /*BITS(last.bits + last.op)*/ >>\n last_bits)\n ]\n here_bits = here >>> 24\n here_op = (here >>> 16) & 0xff\n here_val = here & 0xffff\n\n if (last_bits + here_bits <= bits) {\n break\n }\n //--- PULLBYTE() ---//\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits\n bits -= last_bits\n //---//\n state.back += last_bits\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits\n bits -= here_bits\n //---//\n state.back += here_bits\n if (here_op & 64) {\n strm.msg = 'invalid distance code'\n state.mode = BAD\n break\n }\n state.offset = here_val\n state.extra = here_op & 15\n state.mode = DISTEXT\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra\n while (bits < n) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1) /*BITS(state.extra)*/\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra\n bits -= state.extra\n //---//\n state.back += state.extra\n }\n //#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back'\n state.mode = BAD\n break\n }\n //#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave\n }\n copy = _out - left\n if (state.offset > copy) {\n /* copy from window */\n copy = state.offset - copy\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back'\n state.mode = BAD\n break\n }\n // (!) This block is disabled in zlib defaults,\n // don't enable it for binary compatibility\n //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n // Trace((stderr, \"inflate.c too far\\n\"));\n // copy -= state.whave;\n // if (copy > state.length) { copy = state.length; }\n // if (copy > left) { copy = left; }\n // left -= copy;\n // state.length -= copy;\n // do {\n // output[put++] = 0;\n // } while (--copy);\n // if (state.length === 0) { state.mode = LEN; }\n // break;\n //#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext\n from = state.wsize - copy\n } else {\n from = state.wnext - copy\n }\n if (copy > state.length) {\n copy = state.length\n }\n from_source = state.window\n } else {\n /* copy from output */\n from_source = output\n from = put - state.offset\n copy = state.length\n }\n if (copy > left) {\n copy = left\n }\n left -= copy\n state.length -= copy\n do {\n output[put++] = from_source[from++]\n } while (--copy)\n if (state.length === 0) {\n state.mode = LEN\n }\n break\n case LIT:\n if (left === 0) {\n break inf_leave\n }\n output[put++] = state.length\n left--\n state.mode = LEN\n break\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) {\n break inf_leave\n }\n have--\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits\n bits += 8\n }\n //===//\n _out -= left\n strm.total_out += _out\n state.total += _out\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n state.flags\n ? crc32(state.check, output, _out, put - _out)\n : adler32(state.check, output, _out, put - _out)\n }\n _out = left\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check'\n state.mode = BAD\n break\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) {\n break inf_leave\n }\n have--\n hold += input[next++] << bits\n bits += 8\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check'\n state.mode = BAD\n break\n }\n //=== INITBITS();\n hold = 0\n bits = 0\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE\n /* falls through */\n case DONE:\n ret = Z_STREAM_END\n break inf_leave\n case BAD:\n ret = Z_DATA_ERROR\n break inf_leave\n case MEM:\n return Z_MEM_ERROR\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put\n strm.avail_out = left\n strm.next_in = next\n strm.avail_in = have\n state.hold = hold\n state.bits = bits\n //---\n\n if (\n state.wsize ||\n (_out !== strm.avail_out &&\n state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))\n ) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM\n return Z_MEM_ERROR\n }\n }\n _in -= strm.avail_in\n _out -= strm.avail_out\n strm.total_in += _in\n strm.total_out += _out\n state.total += _out\n if (state.wrap && _out) {\n strm.adler = state.check =\n /*UPDATE(state.check, strm.next_out - _out, _out);*/\n state.flags\n ? crc32(state.check, output, _out, strm.next_out - _out)\n : adler32(state.check, output, _out, strm.next_out - _out)\n }\n strm.data_type =\n state.bits +\n (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0)\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR\n }\n return ret\n}\n\nexport function inflateEnd(strm) {\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR\n }\n\n var state = strm.state\n if (state.window) {\n state.window = null\n }\n strm.state = null\n return Z_OK\n}\n\nexport function inflateGetHeader(strm, head) {\n var state\n\n /* check state */\n if (!strm || !strm.state) {\n return Z_STREAM_ERROR\n }\n state = strm.state\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR\n }\n\n /* save header structure */\n state.head = head\n head.done = false\n return Z_OK\n}\n\nexport function inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length\n\n var state\n var dictid\n var ret\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) {\n return Z_STREAM_ERROR\n }\n state = strm.state\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1 /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0)\n if (dictid !== state.check) {\n return Z_DATA_ERROR\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength)\n if (ret) {\n state.mode = MEM\n return Z_MEM_ERROR\n }\n state.havedict = 1\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK\n}\n\nexport var inflateInfo = 'pako inflate (from Nodeca project)'\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nexport default {\n 2: 'need dictionary' /* Z_NEED_DICT 2 */,\n 1: 'stream end' /* Z_STREAM_END 1 */,\n 0: '' /* Z_OK 0 */,\n '-1': 'file error' /* Z_ERRNO (-1) */,\n '-2': 'stream error' /* Z_STREAM_ERROR (-2) */,\n '-3': 'data error' /* Z_DATA_ERROR (-3) */,\n '-4': 'insufficient memory' /* Z_MEM_ERROR (-4) */,\n '-5': 'buffer error' /* Z_BUF_ERROR (-5) */,\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */,\n}\n", "// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nexport default function ZStream() {\n /* next input byte */\n this.input = null // JS specific, because we have no pointers\n this.next_in = 0\n /* number of bytes available at input */\n this.avail_in = 0\n /* total number of input bytes read so far */\n this.total_in = 0\n /* next output byte should be put there */\n this.output = null // JS specific, because we have no pointers\n this.next_out = 0\n /* remaining free space at output */\n this.avail_out = 0\n /* total number of bytes output so far */\n this.total_out = 0\n /* last error message, NULL if no error */\n this.msg = '' /*Z_NULL*/\n /* not visible by applications */\n this.state = null\n /* best guess about the data type: binary or text */\n this.data_type = 2 /*Z_UNKNOWN*/\n /* adler32 value of the uncompressed data */\n this.adler = 0\n}\n", "import {\n Buf8,\n arraySet,\n assign,\n flattenChunks,\n shrinkBuf,\n} from './utils/common.js'\nimport {\n binstring2buf,\n buf2string,\n string2buf,\n utf8border,\n} from './utils/strings.js'\nimport {\n Z_BUF_ERROR,\n Z_FINISH,\n Z_NEED_DICT,\n Z_NO_FLUSH,\n Z_OK,\n Z_STREAM_END,\n Z_SYNC_FLUSH,\n} from './zlib/constants.js'\nimport GZheader from './zlib/gzheader.js'\nimport {\n inflate as zlibInflate,\n inflateEnd,\n inflateGetHeader,\n inflateInit2,\n inflateSetDictionary,\n} from './zlib/inflate.js'\nimport msg from './zlib/messages.js'\nimport ZStream from './zlib/zstream.js'\n\nvar toString = Object.prototype.toString\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nexport class Inflate {\n constructor(options) {\n if (!(this instanceof Inflate)) return new Inflate(options)\n\n this.options = assign(\n {\n chunkSize: 16384,\n windowBits: 0,\n to: '',\n },\n options || {},\n )\n\n var opt = this.options\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits\n if (opt.windowBits === 0) {\n opt.windowBits = -15\n }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if (\n opt.windowBits >= 0 &&\n opt.windowBits < 16 &&\n !(options && options.windowBits)\n ) {\n opt.windowBits += 32\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15\n }\n }\n\n this.err = 0 // error code, if happens (0 = Z_OK)\n this.msg = '' // error message\n this.ended = false // used to avoid multiple onEnd() calls\n this.chunks = [] // chunks of compressed data\n\n this.strm = new ZStream()\n this.strm.avail_out = 0\n\n var status = inflateInit2(this.strm, opt.windowBits)\n\n if (status !== Z_OK) {\n throw new Error(msg[status])\n }\n\n this.header = new GZheader()\n\n inflateGetHeader(this.strm, this.header)\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = string2buf(opt.dictionary)\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary)\n }\n if (opt.raw) {\n //In raw mode we need to set the dictionary early\n status = inflateSetDictionary(this.strm, opt.dictionary)\n if (status !== Z_OK) {\n throw new Error(msg[status])\n }\n }\n }\n }\n\n /**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\n push(data, mode) {\n var strm = this.strm\n var chunkSize = this.options.chunkSize\n var dictionary = this.options.dictionary\n var status, _mode\n var next_out_utf8, tail, utf8str\n var dict\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false\n\n if (this.ended) {\n return false\n }\n _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data)\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data)\n } else {\n strm.input = data\n }\n\n strm.next_in = 0\n strm.avail_in = strm.input.length\n\n do {\n if (strm.avail_out === 0) {\n strm.output = Buf8(chunkSize)\n strm.next_out = 0\n strm.avail_out = chunkSize\n }\n\n status = zlibInflate(strm, Z_NO_FLUSH) /* no bad return value */\n\n if (status === Z_NEED_DICT && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary)\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary)\n } else {\n dict = dictionary\n }\n\n status = inflateSetDictionary(this.strm, dict)\n }\n\n if (status === Z_BUF_ERROR && allowBufError === true) {\n status = Z_OK\n allowBufError = false\n }\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status)\n this.ended = true\n return false\n }\n\n if (strm.next_out) {\n if (\n strm.avail_out === 0 ||\n status === Z_STREAM_END ||\n (strm.avail_in === 0 &&\n (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))\n ) {\n if (this.options.to === 'string') {\n next_out_utf8 = utf8border(strm.output, strm.next_out)\n\n tail = strm.next_out - next_out_utf8\n utf8str = buf2string(strm.output, next_out_utf8)\n\n // move tail\n strm.next_out = tail\n strm.avail_out = chunkSize - tail\n if (tail) {\n arraySet(strm.output, strm.output, next_out_utf8, tail, 0)\n }\n\n this.onData(utf8str)\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out))\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true\n }\n } while (\n (strm.avail_in > 0 || strm.avail_out === 0) &&\n status !== Z_STREAM_END\n )\n\n if (status === Z_STREAM_END) {\n _mode = Z_FINISH\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = inflateEnd(this.strm)\n this.onEnd(status)\n this.ended = true\n return status === Z_OK\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK)\n strm.avail_out = 0\n return true\n }\n\n return true\n }\n\n /**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\n onData(chunk) {\n this.chunks.push(chunk)\n }\n\n /**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\n onEnd(status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('')\n } else {\n this.result = flattenChunks(this.chunks)\n }\n }\n this.chunks = []\n this.err = status\n this.msg = this.strm.msg\n }\n}\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nexport function inflate(input, options) {\n var inflator = new Inflate(options)\n\n inflator.push(input, true)\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) {\n throw inflator.msg || msg[inflator.err]\n }\n\n return inflator.result\n}\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nexport function inflateRaw(input, options) {\n options = options || {}\n options.raw = true\n return inflate(input, options)\n}\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\nexport var ungzip = inflate\n", "/** Where one BGZF block sits, and how big it is on both sides of the inflate. */\nexport interface BgzfBlockInfo {\n /** Offset of the block's first byte within the scanned buffer. */\n inputOffset: number\n /** Length of the block as it appears in the file, header and trailer included. */\n compressedSize: number\n /** Length of the block once inflated, read from its `ISIZE` trailer. */\n decompressedSize: number\n /** Offset of the block's first byte within the file \u2014 a virtual offset's `blockPosition`. */\n filePosition: number\n}\n\nconst BGZF_HEADER_SIZE = 18\nconst BGZF_TRAILER_SIZE = 8\nconst BGZF_MIN_BLOCK_SIZE = BGZF_HEADER_SIZE + BGZF_TRAILER_SIZE\n\n/**\n * Walk a buffer's BGZF block boundaries without decompressing anything, reading\n * each block's `BSIZE` header field and `ISIZE` trailer field.\n *\n * @param input - compressed bytes whose FIRST byte is the block at\n * `minBlockPosition`. Scanning is relative to the buffer, so passing a whole\n * file while claiming it starts mid-file mislabels every `filePosition`.\n * @param minBlockPosition - the file offset `input` starts at, i.e. a chunk's\n * `minv.blockPosition`.\n * @param maxBlockPosition - the last block wanted, i.e. `maxv.blockPosition`.\n * That block is included; scanning also stops early at the end of `input` or\n * at the first bytes that are not a valid BGZF header.\n */\nexport function scanBgzfBlocks(\n input: Uint8Array,\n minBlockPosition: number,\n maxBlockPosition: number,\n) {\n const blocks: BgzfBlockInfo[] = []\n let offset = 0\n let filePosition = minBlockPosition\n\n while (offset + BGZF_MIN_BLOCK_SIZE <= input.length) {\n if (\n input[offset] !== 0x1f ||\n input[offset + 1] !== 0x8b ||\n input[offset + 2] !== 8 ||\n input[offset + 3] !== 4\n ) {\n break\n }\n\n if (\n input[offset + 10] !== 6 ||\n input[offset + 12] !== 0x42 ||\n input[offset + 13] !== 0x43\n ) {\n break\n }\n\n const bsize = (input[offset + 16]! | (input[offset + 17]! << 8)) + 1\n\n if (bsize < BGZF_MIN_BLOCK_SIZE || offset + bsize > input.length) {\n break\n }\n\n const trailerPos = offset + bsize - BGZF_TRAILER_SIZE\n const isize =\n (input[trailerPos + 4]! |\n (input[trailerPos + 5]! << 8) |\n (input[trailerPos + 6]! << 16) |\n (input[trailerPos + 7]! << 24)) >>>\n 0\n\n blocks.push({\n inputOffset: offset,\n compressedSize: bsize,\n decompressedSize: isize,\n filePosition,\n })\n\n if (filePosition >= maxBlockPosition) {\n break\n }\n\n offset += bsize\n filePosition += bsize\n }\n\n return blocks\n}\n", "export function concatUint8Array(args: Uint8Array[]) {\n let total = 0\n for (const entry of args) {\n total += entry.length\n }\n const mergedArray = new Uint8Array(total)\n let offset = 0\n for (const entry of args) {\n mergedArray.set(entry, offset)\n offset += entry.length\n }\n return mergedArray\n}\n", "/******/ // The require scope\n/******/ const __webpack_require__ = {};\n/******/ \n/************************************************************************/\n/******/ /* webpack/runtime/define property getters */\n/******/ (() => {\n/******/ \t// define getter/value functions for harmony exports\n/******/ \t__webpack_require__.d = (exports, definition) => {\n/******/ \t\tif(Array.isArray(definition)) {\n/******/ \t\t\tvar i = 0;\n/******/ \t\t\twhile(i < definition.length) {\n/******/ \t\t\t\tvar key = definition[i++];\n/******/ \t\t\t\tvar binding = definition[i++];\n/******/ \t\t\t\tif(!__webpack_require__.o(exports, key)) {\n/******/ \t\t\t\t\tif(binding === 0) {\n/******/ \t\t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, value: definition[i++] });\n/******/ \t\t\t\t\t} else {\n/******/ \t\t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: binding });\n/******/ \t\t\t\t\t}\n/******/ \t\t\t\t} else if(binding === 0) { i++; }\n/******/ \t\t\t}\n/******/ \t\t} else {\n/******/ \t\t\tfor(var key in definition) {\n/******/ \t\t\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n/******/ \t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n/******/ \t\t\t\t}\n/******/ \t\t\t}\n/******/ \t\t}\n/******/ \t};\n/******/ })();\n/******/ \n/******/ /* webpack/runtime/hasOwnProperty shorthand */\n/******/ (() => {\n/******/ \t__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))\n/******/ })();\n/******/ \n/******/ /* webpack/runtime/make namespace object */\n/******/ (() => {\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = (exports) => {\n/******/ \t\tif(Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/ })();\n/******/ \n/************************************************************************/\n\n// NAMESPACE OBJECT (decoupled): ../src/wasm/bgzf_wasm_bg.js\nvar bgzf_wasm_bg_namespaceObject = {};\n__webpack_require__.r(bgzf_wasm_bg_namespaceObject);\n__webpack_require__.d(bgzf_wasm_bg_namespaceObject, {\n ChunkSliceResult: () => (ChunkSliceResult),\n __wbg_Error_92b29b0548f8b746: () => (__wbg_Error_92b29b0548f8b746),\n __wbg___wbindgen_throw_344f42d3211c4765: () => (__wbg___wbindgen_throw_344f42d3211c4765),\n __wbg_set_wasm: () => (__wbg_set_wasm),\n decompress_all: () => (decompress_all),\n decompress_chunk_slice: () => (decompress_chunk_slice)\n});\n\n;// ../src/wasm/bgzf_wasm_bg.wasm\nconst wasm_bgzf_wasm_bg_namespaceObject = \"data:application/wasm;base64,AGFzbQEAAAABfRFgAABgAAF/YAF/AGABfwF/YAJ/fwBgAn9/AX9gA39/fwBgA39/fwF/YAR/f39/AGAEf39/fwF/YAV/f39/fwBgBX9/f39/AX9gBn9/f39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gCH9/f39/f39/AX9gB39/f3x8fHwAAm4CES4vYmd6Zl93YXNtX2JnLmpzJ19fd2JnX19fd2JpbmRnZW5fdGhyb3dfMzQ0ZjQyZDMyMTFjNDc2NQAEES4vYmd6Zl93YXNtX2JnLmpzHF9fd2JnX0Vycm9yXzkyYjI5YjA1NDhmOGI3NDYABQNsawMODxAFCQINBwYJBAUEBAgFBQQKEAYEBwUEBAcEDAwGCgYEAgICDAIGBwQDBQMEBgYFBQsEAgYCAgQEBQMCAgEEAgUCBAYGDQIEBAcJAgQFBQYEBwADBQUEAAAEBAQFBAUCAgICBAQFAAAABAUBcAEaGgUDAQARBhkDfwFBgIDAAAt/AEGkmsAAC38AQdSawAALB6wCDAZtZW1vcnkCABtfX3diZ19jaHVua3NsaWNlcmVzdWx0X2ZyZWUAFBxjaHVua3NsaWNlcmVzdWx0X3Rha2VfYnVmZmVyAB4gY2h1bmtzbGljZXJlc3VsdF90YWtlX2Nwb3NpdGlvbnMAGyBjaHVua3NsaWNlcmVzdWx0X3Rha2VfZHBvc2l0aW9ucwAcDmRlY29tcHJlc3NfYWxsABcWZGVjb21wcmVzc19ja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oiADYCrJ5AQQAgAEEAKAKwnkAiAiAAIAJLGzYCsJ5AAkACQAJAQQAoAqieQCICRQ0AQfybwAAhAANAIAYgACgCACIIIAAoAgQiB2pGDQIgACgCCCIADQAMAwsLAkACQEEAKAK4nkAiAEUNACAGIABPDQELQQAgBjYCuJ5AC0EAQf8fNgK8nkBBACAFNgKInEBBACAJNgKAnEBBACAGNgL8m0BBAEGMnMAANgKYnEBBAEGUnMAANgKgnEBBAEGMnMAANgKUnEBBAEGcnMAANgKonEBBAEGUnMAANgKcnEBBAEGknMAANgKwnEBBAEGcnMAANgKknEBBAEGsnMAANgK4nEBBAEGknMAANgKsnEBBAEG0nMAANgLAnEBBAEGsnMAANgK0nEBBAEG8nMAANgLInEBBAEG0nMAANgK8nEBBAEHEnMAANgLQnEBBAEG8nMAANgLEnEBBAEHMnMAANgLYnEBBAEHEnMAANgLMnEBBAEHMnMAANgLUnEBBAEHUnMAANgLgnEBBAEHUnMAANgLcnEBBAEHcnMAANgLonEBBAEHcnMAANgLknEBBAEHknMAANgLwnEBBAEHknMAANgLsnEBBAEHsnMAANgL4nEBBAEHsnMAANgL0nEBBAEH0nMAANgKAnUBBAEH0nMAANgL8nEBBAEH8nMAANgKInUBBAEH8nMAANgKEnUBBAEGEncAANgKQnUBBAEGEncAANgKMnUBBAEGMncAANgKYnUBBAEGUncAANgKgnUBBAEGMncAANgKUnUBBAEGcncAANgKonUBBAEGUncAANgKcnUBBAEGkncAANgKwnUBBAEGcncAANgKknUBBAEGsncAANgK4nUBBAEGkncAANgKsnUBBAEG0ncAANgLAnUBBAEGsncAANgK0nUBBAEG8ncAANgLInUBBAEG0ncAANgK8nUBBAEHEncAANgLQnUBBAEG8ncAANgLEnUBBAEHMncAANgLYnUBBAEHEncAANgLMnUBBAEHUncAANgLgnUBBAEHMncAANgLUnUBBAEHcncAANgLonUBBAEHUncAANgLcnUBBAEHkncAANgLwnUBBAEHcncAANgLknUBBAEHsncAANgL4nUBBAEHkncAANgLsnUBBAEH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gASgCAEUNACAAQbiXwAA2AgQgACABNgIADwsACx4BAX8CQCAAKAIAIgJFDQAgASACIAAoAgQQTQ8LAAsbAQF/EGogAEEEakEEEFgiASAANgIAIAFBBGoLHgEBfwJAIAAoAgAiAUEBSA0AIAAoAgQgAUEBEFMLCx4AIAAoAgAgACgCBEEAKALomkAiAEEEIAAbEQQAAAsjAQF/AkBBhIrAABAtIgANAEG4icAAQTpB9InAABA4AAsgAAsXAAJAIABBf2pBfk8NACABIABBARBTCwscAQF/AkAgACgCACIBRQ0AIAAoAgQgAUEBEFMLCxcAAkAgAUEJSQ0AIAEgABAODwsgABACCxUAIABBfGoiACAAKAIAQQRqQQQQUwsUAAJAIABFDQAgACABEF8ACxBWAAsRACAAIAFBAXRBAXIgAhAxAAsSAAJAIAFFDQAgACABIAIQUwsLEgAgACABIAIgAyAEQQAgBRADCxUAAkAgAEUNACAAIAAoAqhaEQIACwsaACAAQQApAoSWQDcCCCAAQQApAvyVQDcCAAsaACAAQQApAvSVQDcCCCAAQQApAuyVQDcCAAsWACAAKAIAIAEgAiAAKAIEKAIMEQcACw0AIAAgASACIAMQBw8LFABBACAANgK8mkBBAEEBNgK4mkALEwAgAEG4l8AANgIEIAAgATYCAAsQACABIAAoAgAgACgCBBBNCxAAIAEgACgCACAAKAIEEAoLCwAgACABIAIQKg8LCgAgACABEGkaAAsPACAAQZyVwAAgASACEAwLEQBBkJjAAEEjQaSYwAAQMQALCwAgACMAaiQAIwALCQAgACABEEQPCwkAIAAgARAuDwsJACAAIAEQYQALDABBr4fAAEEbEFoACw0AQcqHwABBzwAQWgALCQAgASAAEDsACwwAIAAgASkCADcDAAsJACABIAAQXQALDQAgAUH8mcAAQRgQCgsIACAAIAEQAAsIACAAIAEQAQsJACAAKAIAEEoLBwAgABA5AAsHACAAEEAACwcAIAAQJgALCwBBAEEBOgDAnkALCQAgAEEANgIACwUAEGsACwMADwsDAAALAgALC74aAgBBgIDAAAuUGkF0dGVtcHRlZCB0byBpbml0aWFsa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E3MjczNzQ3NTc2Nzc3ODc5ODA4MTgyODM4NDg1ODY4Nzg4ODk5MDkxOTI5Mzk0OTU5Njk3OTg5OVJlZkNlbGwgYWxyZWFkeSBib3Jyb3dlZABBlJrAAAsYAAAAAAAAAAABAAAAAAAAAAEAAAAEAAAAACkEbmFtZQEiAVcfX193YmluZGdlbl9hZGRfdG9fc3RhY2tfcG9pbnRlcgBICXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AgZ3YWxydXMGMC4yNi40DHdhc20tYmluZGdlbhMwLjIuMTI2ICgyMWFjODA0YTkp\";\n;// ../src/wasm/bgzf_wasm_bg.js\nclass ChunkSliceResult {\n static __wrap(ptr) {\n const obj = Object.create(ChunkSliceResult.prototype);\n obj.__wbg_ptr = ptr;\n ChunkSliceResultFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n ChunkSliceResultFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_chunksliceresult_free(ptr, 0);\n }\n /**\n * @returns {Uint8Array}\n */\n take_buffer() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.chunksliceresult_take_buffer(retptr, this.__wbg_ptr);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var v1 = getArrayU8FromWasm0(r0, r1).slice();\n wasm.__wbindgen_export(r0, r1 * 1, 1);\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Float64Array}\n */\n take_cpositions() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.chunksliceresult_take_cpositions(retptr, this.__wbg_ptr);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var v1 = getArrayF64FromWasm0(r0, r1).slice();\n wasm.__wbindgen_export(r0, r1 * 8, 8);\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n /**\n * @returns {Float64Array}\n */\n take_dpositions() {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n wasm.chunksliceresult_take_dpositions(retptr, this.__wbg_ptr);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var v1 = getArrayF64FromWasm0(r0, r1).slice();\n wasm.__wbindgen_export(r0, r1 * 8, 8);\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n }\n}\nif (Symbol.dispose) ChunkSliceResult.prototype[Symbol.dispose] = ChunkSliceResult.prototype.free;\n\n/**\n * @param {Uint8Array} input\n * @returns {Uint8Array}\n */\nfunction decompress_all(input) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export2);\n const len0 = WASM_VECTOR_LEN;\n wasm.decompress_all(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n if (r3) {\n throw takeObject(r2);\n }\n var v2 = getArrayU8FromWasm0(r0, r1).slice();\n wasm.__wbindgen_export(r0, r1 * 1, 1);\n return v2;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\n/**\n * Decompress a slice of BGZF data between two virtual offsets.\n * Position parameters use f64 to map to JS number, supporting files >4GB.\n * The input buffer should be a slice starting at min_block_position in the original file.\n * Positions are tracked as f64 to preserve precision for large files.\n * @param {Uint8Array} input\n * @param {number} min_block_position\n * @param {number} min_data_position\n * @param {number} max_block_position\n * @param {number} max_data_position\n * @returns {ChunkSliceResult}\n */\nfunction decompress_chunk_slice(input, min_block_position, min_data_position, max_block_position, max_data_position) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export2);\n const len0 = WASM_VECTOR_LEN;\n wasm.decompress_chunk_slice(retptr, ptr0, len0, min_block_position, min_data_position, max_block_position, max_data_position);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n if (r2) {\n throw takeObject(r1);\n }\n return ChunkSliceResult.__wrap(r0);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\nfunction __wbg_Error_92b29b0548f8b746(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n}\nfunction __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n}\nconst ChunkSliceResultFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_chunksliceresult_free(ptr, 1));\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nfunction dropObject(idx) {\n if (idx < 1028) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction getArrayF64FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nlet cachedFloat64ArrayMemory0 = null;\nfunction getFloat64ArrayMemory0() {\n if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {\n cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);\n }\n return cachedFloat64ArrayMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return decodeText(ptr >>> 0, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction getObject(idx) { return heap[idx]; }\n\nlet heap = new Array(1024).fill(undefined);\nheap.push(undefined, null, true, false);\n\nlet heap_next = heap.length;\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len).slice());\n}\n\nlet WASM_VECTOR_LEN = 0;\n\n\nlet wasm;\nfunction __wbg_set_wasm(val) {\n wasm = val;\n}\n\n;// ./src/wrapper.js\n// Import the WASM binary as base64 data URL\n\n\n\nlet wrapper_wasm = null\nlet initPromise = null\n\nasync function init() {\n if (wrapper_wasm) return wrapper_wasm\n\n if (!initPromise) {\n initPromise = (async () => {\n // wasmData is a data URL from asset/inline\n const response = await fetch(wasm_bgzf_wasm_bg_namespaceObject)\n const bytes = await response.arrayBuffer()\n const { instance } = await WebAssembly.instantiate(bytes, {\n './bgzf_wasm_bg.js': bgzf_wasm_bg_namespaceObject,\n })\n wrapper_wasm = instance.exports\n __wbg_set_wasm(wrapper_wasm)\n return wrapper_wasm\n })()\n }\n\n return initPromise\n}\n\nasync function decompressAll(input) {\n if (!wrapper_wasm) {\n await init()\n }\n return decompress_all(input)\n}\n\nasync function decompressChunkSlice(\n input,\n minBlockPosition,\n minDataPosition,\n maxBlockPosition,\n maxDataPosition,\n) {\n if (!wrapper_wasm) {\n await init()\n }\n const result = decompress_chunk_slice(\n input,\n minBlockPosition,\n minDataPosition,\n maxBlockPosition,\n maxDataPosition,\n )\n // The take_* accessors already copy out of the wasm heap \u2014 wasm-bindgen\n // emits `getArrayF64FromWasm0(...).slice()` \u2014 so the returned typed arrays\n // own their bytes and stay valid after free() and after the heap grows.\n // Spreading them into plain arrays was therefore a second copy of every\n // block offset, for consumers (tabix-js, bam-js) that only index them.\n const buffer = result.take_buffer()\n const cpositions = result.take_cpositions()\n const dpositions = result.take_dpositions()\n result.free()\n return { buffer, cpositions, dpositions }\n}\n\n\n\n\nexport { decompressAll, decompressChunkSlice };\n", "import { ungzip } from 'pako-esm2'\n\nimport { scanBgzfBlocks } from './bgzfBlockScan.ts'\nimport { concatUint8Array } from './util.ts'\nimport {\n decompressAll,\n decompressChunkSlice,\n} from './wasm/bgzf-wasm-inlined.js'\n\nimport type { BgzfBlockInfo } from './bgzfBlockScan.ts'\nimport type { BgzfWorkerPool } from './workerPool.ts'\n\n/**\n * A position in the uncompressed data: which BGZF block (by its compressed\n * offset in the file), and how far into that block's decompressed bytes.\n */\nexport interface VirtualOffset {\n blockPosition: number\n dataPosition: number\n}\n\n/**\n * A range between two virtual offsets \u2014 what a BAI or TBI resolves a query to.\n * It covers a run of consecutive BGZF blocks and usually starts and ends\n * partway through the first and last of them.\n */\nexport interface Chunk {\n minv: VirtualOffset\n maxv: VirtualOffset\n}\n\nconst BGZF_MIN_BLOCK_SIZE = 26\n\nfunction hasGzipHeader(data: Uint8Array) {\n return data[0] === 0x1f && data[1] === 0x8b\n}\n\n// Mirrors the header check in the wasm `parse_block`: gzip magic, deflate\n// method, FEXTRA flag, XLEN=6 and the 'BC' extra-subfield id. Checked here so\n// non-bgzf input never reaches wasm \u2014 see the comment in unzip().\nfunction hasBgzfHeader(data: Uint8Array) {\n return (\n data.length >= BGZF_MIN_BLOCK_SIZE &&\n hasGzipHeader(data) &&\n data[2] === 8 &&\n data[3] === 4 &&\n data[10] === 6 &&\n data[12] === 0x42 &&\n data[13] === 0x43\n )\n}\n\nfunction errorMessage(error: unknown) {\n return error instanceof Error ? error.message : `${error}`\n}\n\nasync function decompressGzip(inputData: Uint8Array) {\n if (typeof DecompressionStream !== 'undefined') {\n const stream = new Blob([inputData as Uint8Array<ArrayBuffer>])\n .stream()\n .pipeThrough(new DecompressionStream('gzip'))\n return new Uint8Array(await new Response(stream).arrayBuffer())\n } else {\n return ungzip(inputData, undefined)\n }\n}\n\nfunction wrapGzipHeaderError(error: unknown) {\n if (errorMessage(error).includes('invalid gzip header')) {\n return new Error(\n 'problem decompressing block: incorrect gzip header check',\n { cause: error },\n )\n }\n return error\n}\n\n// The return type is annotated rather than inferred. `decompressAll` comes from\n// the inlined wasm bundle, which is untyped JS, so inference makes this\n// `Promise<any>` \u2014 and that `any` is published in the .d.ts and flows straight\n// into consumers (@gmod/bam's csi.ts reads .buffer/.byteOffset/.subarray off it\n// completely unchecked). The Rust returns `Vec<u8>`, i.e. a Uint8Array.\nexport async function unzip(inputData: Uint8Array): Promise<Uint8Array> {\n // Reading past EOF yields an empty buffer; decompressing nothing is nothing\n // rather than an error.\n if (inputData.length === 0) {\n return new Uint8Array(0)\n }\n // Sniff the header in JS before handing off to wasm. Calling into wasm\n // copies the whole input into the wasm heap, and that heap can only grow \u2014\n // so routing a plain (non-bgzf) gzip file through wasm just to have it\n // rejected would permanently reserve the file's full size.\n if (!hasBgzfHeader(inputData)) {\n if (hasGzipHeader(inputData)) {\n return decompressGzip(inputData)\n }\n throw new Error(\n 'problem decompressing block: not a valid bgzf or gzip block',\n )\n }\n try {\n return await decompressAll(inputData)\n } catch (error) {\n // A valid-looking header that wasm still rejects means the first block is\n // truncated; the generic gzip path gives a better error for that.\n if (errorMessage(error).includes('invalid bgzf header')) {\n return decompressGzip(inputData)\n }\n throw wrapGzipHeaderError(error)\n }\n}\n\n/**\n * A decompressed BGZF chunk plus, per block it spans, that block's compressed\n * offset in the file (`cpositions`) and its uncompressed offset within the\n * chunk (`dpositions`). Together they let a caller turn a byte offset in\n * `buffer` back into a virtual file offset \u2014 see @gmod/tabix and @gmod/bam.\n *\n * Annotated rather than inferred, for the same reason as {@link unzip}: it is\n * derived from the untyped inlined-wasm bundle, and whatever tsc makes of that\n * is what gets published in the .d.ts.\n */\nexport interface ChunkSlice {\n buffer: Uint8Array\n cpositions: Float64Array\n dpositions: Float64Array\n}\n\n/**\n * Reassemble a chunk slice from independently decompressed blocks.\n *\n * Mirrors what `decompress_chunk_slice` does in wasm: trim the first block to\n * `minv.dataPosition` and the last to `maxv.dataPosition`, and record each\n * block's compressed offset and its uncompressed offset within the result.\n */\nfunction assembleChunkSliceResult(\n blocks: Uint8Array[],\n infos: BgzfBlockInfo[],\n minv: VirtualOffset,\n maxv: VirtualOffset,\n): ChunkSlice {\n const cpositions: number[] = []\n const dpositions: number[] = []\n const slices: Uint8Array[] = []\n let dpos = minv.dataPosition\n\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i]!\n const info = infos[i]!\n const isLast = info.filePosition >= maxv.blockPosition\n\n cpositions.push(info.filePosition)\n dpositions.push(dpos)\n\n const start = i === 0 ? minv.dataPosition : 0\n const end = isLast\n ? Math.min(maxv.dataPosition + 1, block.length)\n : block.length\n if (start < end) {\n slices.push(block.subarray(start, end))\n }\n dpos += block.length - start\n\n if (isLast) {\n cpositions.push(info.filePosition + info.compressedSize)\n dpositions.push(dpos)\n break\n }\n }\n\n return {\n buffer: concatUint8Array(slices),\n // Float64Array to match the wasm path's shape exactly \u2014 a caller must not\n // be able to tell which one produced its result\n cpositions: Float64Array.from(cpositions),\n dpositions: Float64Array.from(dpositions),\n }\n}\n\n/**\n * The smallest chunk, in inflated bytes, that `unzipChunkSlice` hands to a\n * pool. Below it the round trip and the input copy cost more than the\n * parallelism returns: in the chunk-size table in docs/worker-pool.md every BAM\n * fixture turned positive by eight blocks, 0.4-0.5MB out, and at two to four\n * blocks most lost. A reader that only ever asks for smaller chunks never boots\n * a shared pool's workers at all.\n */\nexport const POOL_MIN_DECOMPRESSED_BYTES = 400_000\n\nfunction decompressedBytes(blocks: BgzfBlockInfo[]) {\n let total = 0\n for (const block of blocks) {\n total += block.decompressedSize\n }\n return total\n}\n\nexport async function unzipChunkSlice(\n inputData: Uint8Array,\n chunk: Chunk,\n workerPool?: BgzfWorkerPool,\n): Promise<ChunkSlice> {\n const { minv, maxv } = chunk\n\n if (workerPool) {\n const blocks = scanBgzfBlocks(\n inputData,\n minv.blockPosition,\n maxv.blockPosition,\n )\n if (decompressedBytes(blocks) >= POOL_MIN_DECOMPRESSED_BYTES) {\n const result = await workerPool.decompressBlocks(inputData, blocks)\n return assembleChunkSliceResult(result.blocks, blocks, minv, maxv)\n }\n }\n\n try {\n const result = await decompressChunkSlice(\n inputData,\n minv.blockPosition,\n minv.dataPosition,\n maxv.blockPosition,\n maxv.dataPosition,\n )\n return {\n buffer: result.buffer,\n cpositions: result.cpositions,\n dpositions: result.dpositions,\n }\n } catch (error) {\n throw wrapGzipHeaderError(error)\n }\n}\n", "/**\n * Throws if `signal` has been aborted, matching the semantics of\n * `signal.throwIfAborted()` without requiring either that method or `reason`.\n *\n * Two reasons not to call the built-in directly. It assumes a *real*\n * `AbortSignal`, and callers pass duck-typed ones \u2014 `@gmod/bam`'s\n * `test/csi.test.ts` casts a bare `{ aborted }` through `as AbortSignal`, which\n * is a fair model of what consumers do. Calling a missing method there is a\n * `TypeError` rather than the cancellation the caller asked for, which is a\n * strictly worse failure.\n *\n * And it sets a browser floor. `AbortSignal.prototype.throwIfAborted` and\n * `AbortSignal.reason` are Safari 15.4 / Chrome 100 / Firefox 97 (March 2022),\n * higher than the consumers of this package otherwise need \u2014 they touch only\n * `.aborted`, and `generic-filehandle2` only forwards a signal to `fetch`. A\n * few lines here keep that floor where it was.\n */\nexport function throwIfAborted(signal?: AbortSignal) {\n if (signal?.aborted) {\n throw abortReason(signal)\n }\n}\n\n/**\n * What an aborted `signal` should be reported as.\n *\n * Spec-faithful: `throwIfAborted` throws `reason` verbatim, and `reason` is\n * whatever the caller passed to abort() \u2014 `controller.abort('too slow')` makes\n * it a string. Coercing it to an Error here would hide that from a consumer who\n * set it deliberately.\n *\n * Separate from the throw so a caller that has to *reject* with it rather than\n * throw it reports cancellation identically; see `SharedReadCache.settleFor`.\n *\n * Annotated `unknown` rather than inferred, because the inference narrows to\n * something only-throw-error rejects and this value is thrown.\n */\nexport function abortReason(signal: AbortSignal): unknown {\n const reason: unknown = signal.reason\n return reason === undefined\n ? new DOMException('This operation was aborted', 'AbortError')\n : reason\n}\n", "import { abortReason, throwIfAborted } from './throwIfAborted.ts'\n\nimport type { Budget, BudgetMember, BudgetMembership } from './SharedBudget.ts'\n\n/** What exists only to cancel a read, so only while it is in flight. */\ninterface PendingRead {\n /**\n * The callers still waiting on this read, each with the listener the read put\n * on its signal. The read is cancelled only once every one of them has given\n * up \u2014 see {@link SharedReadCache.join}.\n */\n signals: Map<AbortSignal, () => void>\n /** true once a caller that cannot give up has joined, which pins the read */\n pinned: boolean\n /** aborts when every caller has given up; what the read actually runs under */\n controller: AbortController\n}\n\ninterface Entry<V> {\n promise: Promise<V>\n /**\n * Dropped when the read settles, so `undefined` is what \"settled\" means and a\n * cached value carries none of the machinery that was there to cancel it.\n */\n pending?: PendingRead\n /** 0 until the read settles and the value can be weighed */\n size: number\n /**\n * `Date.now()` at the last {@link SharedReadCache.get} or\n * {@link SharedReadCache.getIfCached} that resolved to this entry, or at its\n * read settling if that is later. What the idle sweep measures from.\n */\n lastTouched: number\n /**\n * The budget's stamp at the last touch, for the cross-cache LRU order it\n * evicts by; 0 when there is no budget. See {@link Budget.nextSeq}.\n */\n seq: number\n}\n\nexport interface SharedReadCacheOptions<K, V> {\n /**\n * Performs the read. It is handed the *shared* signal, which fires only once\n * every caller waiting on this key has aborted \u2014 never one caller's own.\n *\n * Optional, because a caller whose read differs per key \u2014 a closure over the\n * thing being read, rather than a function of the key \u2014 can pass it to\n * {@link SharedReadCache.get} instead. One of the two must be present.\n */\n fill?: (key: K, signal: AbortSignal) => Promise<V>\n\n /**\n * Budget, in whatever unit {@link sizeOf} returns. Defaults to `Infinity`:\n * this package does not prescribe a limit, because what a sensible one is\n * depends entirely on what is being cached.\n *\n * Note what a budget does and does not do. It bounds *retained* memory, not\n * request size: a value larger than the whole budget is still kept, reads in\n * flight are never evicted, and eviction only ever discards a value already\n * returned once. So nothing is refused for being too large, and the worst a\n * budget can cost is a re-read.\n *\n * Unbounded is therefore the permissive default, not the safe one. A cache\n * with no budget grows for the life of the object \u2014 @gmod/tabix measured 2GB\n * RSS panning a dense VCF before it bounded this. Pass one if the values are\n * large or the object is long-lived.\n *\n * Settable later: lowering it evicts immediately rather than waiting for the\n * next read, which is what a consumer shedding memory under pressure needs.\n */\n maxSize?: number\n\n /**\n * Weighs a settled value against `maxSize`. Defaults to 1, making the budget\n * an entry count.\n *\n * This is the parameter the whole package exists for. Every hand-rolled copy\n * of this cache across the gmod repos was identical except here: @gmod/bam\n * and @gmod/tabix weigh decompressed bytes, @gmod/bbi weighs entries, and\n * @gmod/cram weighed decoded records before it moved to bytes. An entry\n * cannot be weighed until its read settles, so a cache that does this has to\n * own its entries \u2014 which is exactly why those four could not share a\n * plain-LRU-backed package and each wrote their own.\n */\n sizeOf?: (value: V) => number\n\n /** Maps a key to its cache key. Defaults to `String(key)`. */\n cacheKey?: (key: K) => string\n\n /**\n * A budget shared with other caches, evicted globally least-recently-used\n * across all of them. Defaults to none.\n *\n * Composes with {@link maxSize} rather than replacing it: the per-cache\n * ceiling still applies, and a cache that passes only a budget is unbounded\n * on its own and bounded in aggregate \u2014 usually what you want, since the\n * point of sharing is to let one busy member use most of the total.\n *\n * Reach for it when the number of caches is a property of the workload\n * rather than of the code. A per-cache ceiling sized so that one cache never\n * thrashes is, by construction, not a bound on N of them; see\n * {@link SharedBudget} for what that measured.\n */\n budget?: Budget\n /**\n * Drop an entry once nothing has asked for it for this many milliseconds.\n * Defaults to no idle eviction.\n *\n * This is the only reclamation that happens while a consumer sits still.\n * {@link maxSize} is enforced when a read settles, so an idle cache stays at\n * whatever it reached and never gives it back \u2014 fine for a short-lived\n * object, expensive for one that lives as long as its UI does. A genome\n * browser parked on a region holds its whole last view indefinitely, times\n * every open track.\n *\n * The two compose and answer different questions. `maxSize` is the ceiling\n * under load, and wants to be generous: set below one request's working set\n * it does not cache less, it caches *nothing*, evicting each value before the\n * next request can reuse it while still retaining the ones in flight.\n * `idleTimeoutMs` is what makes a generous ceiling affordable, by making it a\n * peak rather than a resting level.\n *\n * Measured from the last **read** of an entry, or from its fill settling if\n * nothing has read it since: something fetched once and used every second is\n * not idle, and an absolute expiry would throw it away mid-use for no reason.\n * The clock never starts before the value exists, so however long a read\n * takes it still gets the full timeout to be reused in.\n *\n * Reads still in flight are never swept, on the same grounds as eviction \u2014\n * they have no weight to reclaim and dropping one would lose the\n * de-duplication every caller joined to it is relying on.\n */\n idleTimeoutMs?: number\n}\n\n/**\n * One read per key, shared by every caller that asks for it while it is in\n * flight, with a bounded cache of the results.\n *\n * ## Why not a memoized promise\n *\n * Memoizing a bare promise built from the *first* caller's signal makes that\n * caller's abort reject everyone else awaiting it. In a genome browser, panning\n * away from one block then fails its still-wanted siblings. Here the read runs\n * under a controller of its own, and a caller's abort is reported to that\n * caller alone.\n *\n * ## The cancellation rule\n *\n * A read is cancelled only once **every** caller waiting on it has given up. A\n * caller with no signal cannot give up, so it pins the read \u2014 the honest\n * reading of a caller that never asked to be cancellable, and the reason one\n * signal-free consumer makes a read uncancellable for everyone joined to it. A\n * duck-typed signal with no `addEventListener` pins it for the same reason \u2014\n * nothing here can learn when such a caller gives up \u2014 and is still told about\n * its own cancellation once the read settles.\n *\n * A rejection is dropped rather than cached, so one transient failure does not\n * poison the key for the life of the cache.\n *\n * ## On \"LRU\"\n *\n * With no {@link SharedReadCacheOptions.maxSize} nothing is ever evicted, so\n * this is a shared-read memo and not an LRU at all \u2014 least-recently-used is an\n * *eviction order*, and there is no eviction to order. Recency is still tracked\n * while unbounded, cheaply, so that imposing a budget later evicts the right\n * entries rather than the oldest-inserted ones.\n */\nexport class SharedReadCache<K, V> implements BudgetMember {\n private entries = new Map<string, Entry<V>>()\n private total = 0\n /**\n * How many of {@link entries} have settled. Maintained rather than counted,\n * because {@link evict} needs it on every settle and a cache sitting at its\n * ceiling is over the limit on every settle \u2014 so the O(entries) count it\n * replaces was the steady-state cost of having a budget at all. That count\n * measured 8.6us per read over 100 entries and 134us over 20,000; maintaining\n * it instead holds 7.4us and 14us across the same range.\n */\n private settledCount = 0\n private limit: number\n /** the budget this cache joined, and the handle it reports its weight by */\n private shared?: { budget: Budget; membership: BudgetMembership }\n private fill?: (key: K, signal: AbortSignal) => Promise<V>\n private sizeOf: (value: V) => number\n private toCacheKey: (key: K) => string\n private idleTimeoutMs?: number\n private sweepTimer?: ReturnType<typeof setInterval>\n\n constructor({\n fill,\n maxSize = Infinity,\n sizeOf = () => 1,\n cacheKey = (key: K) => String(key),\n idleTimeoutMs = 0,\n budget,\n // Defaulted, because a cache with no options at all is a real shape and a\n // common one: the memo, whose fill is a closure passed per get() call. Five\n // of these exist across @gmod/bam, @gmod/tabix and indexedfasta-js, and\n // every one of them was written `new SharedReadCache({})`.\n }: SharedReadCacheOptions<K, V> = {}) {\n this.fill = fill\n this.limit = maxSize\n this.shared = budget && { budget, membership: budget.register(this) }\n this.sizeOf = sizeOf\n this.toCacheKey = cacheKey\n // 0, a negative and Infinity all mean \"no idle eviction\", so the rest of\n // the class has one thing to check\n this.idleTimeoutMs =\n idleTimeoutMs > 0 && Number.isFinite(idleTimeoutMs)\n ? idleTimeoutMs\n : undefined\n }\n\n /** Number of entries held, including reads still in flight. */\n get size() {\n return this.entries.size\n }\n\n /** Sum of {@link SharedReadCacheOptions.sizeOf} over the settled entries. */\n get totalSize() {\n return this.total\n }\n\n get maxSize() {\n return this.limit\n }\n\n /**\n * Accessor rather than a plain field so lowering the budget frees memory now.\n * As a field it did nothing until the next read happened to run the eviction\n * loop, which on an idle consumer is never.\n */\n set maxSize(maxSize: number) {\n this.limit = maxSize\n this.evict()\n }\n\n /**\n * How many caller signals the entry under `key` is still holding. Exposed for\n * tests: an entry that has leaked a thousand stale signals answers every read\n * exactly like one that has not, so nothing else would notice.\n */\n waiterCount(key: K) {\n return this.entries.get(this.toCacheKey(key))?.pending?.signals.size ?? 0\n }\n\n async get(\n key: K,\n signal?: AbortSignal,\n fill?: (signal: AbortSignal) => Promise<V>,\n ) {\n // Before the cache hit too: a caller that has already given up must not\n // start a read, nor be registered as a waiter on someone else's.\n throwIfAborted(signal)\n\n const cacheKey = this.toCacheKey(key)\n let entry = this.entries.get(cacheKey)\n // A read every caller has abandoned is replaced rather than joined, since\n // joining it means inheriting a cancellation that is not this caller's.\n if (entry && this.isDoomed(entry)) {\n this.deleteKey(cacheKey)\n entry = undefined\n }\n if (entry) {\n this.touch(cacheKey, entry)\n } else {\n entry = this.start(cacheKey, key, fill)\n }\n if (entry.pending) {\n this.join(entry.pending, signal)\n }\n\n try {\n return await this.settleFor(entry, signal)\n } finally {\n // This caller's own cancellation wins over whatever the shared read\n // reported, a value included: it gave up while waiting.\n throwIfAborted(signal)\n }\n }\n\n /**\n * The shared read, but a caller that gives up while it is still running is\n * released now rather than whenever that read lands. The read is shared, so\n * one caller aborting does not stop it, and awaiting `entry.promise` alone\n * left that caller pending until every other waiter was done \u2014 or forever,\n * against a fill that ignores its signal.\n *\n * Only for a read in flight and a signal that can be subscribed to. The rest\n * fall back to the {@link throwIfAborted} in {@link get}.\n */\n private settleFor(entry: Entry<V>, signal?: AbortSignal) {\n if (\n !entry.pending ||\n signal === undefined ||\n typeof signal.addEventListener !== 'function'\n ) {\n return entry.promise\n }\n let reject: (reason: unknown) => void\n const aborted = new Promise<never>((_resolve, rejectAborted) => {\n reject = rejectAborted\n })\n const onAbort = () => {\n // the caller's own reason, verbatim, as throwIfAborted would throw it\n reject(abortReason(signal))\n }\n // Removed by reference rather than through a `{ signal }` option. Node holds\n // that option's removal hook weakly, one per target, so a second listener\n // registered that way on the same signal orphans the first after a GC \u2014 and\n // an orphaned listener pins the entry and its value for the signal's life.\n signal.addEventListener('abort', onAbort, { once: true })\n // Losing this race leaves `entry.promise` unobserved here, which is safe\n // only because start() attaches its own handlers to it.\n return Promise.race([entry.promise, aborted]).finally(() => {\n signal.removeEventListener('abort', onAbort)\n })\n }\n\n /**\n * The promise cached under `key`, or `undefined` if there is none.\n *\n * Marks the entry most-recently-used, exactly as {@link get} does: this is a\n * lookup that happens not to start a read, not an inspection. Use\n * {@link has} if you need to ask without touching the LRU order.\n *\n * The promise is the shared one, so awaiting it does not register the caller\n * as a waiter and its rejection is not re-reported per caller. Callers that\n * want either should use {@link get}.\n *\n * `undefined` too for a read every caller has already abandoned, which is not\n * a cached value but a rejection that has not landed yet.\n */\n getIfCached(key: K) {\n const cacheKey = this.toCacheKey(key)\n const entry = this.entries.get(cacheKey)\n if (!entry) {\n return undefined\n }\n if (this.isDoomed(entry)) {\n this.deleteKey(cacheKey)\n return undefined\n }\n this.touch(cacheKey, entry)\n return entry.promise\n }\n\n /**\n * Whether {@link get} would be answered from the cache, by a settled value or\n * a read in flight. False for a read every caller has abandoned, as it is for\n * {@link get} and {@link getIfCached}. The one lookup that changes nothing.\n */\n has(key: K) {\n const entry = this.entries.get(this.toCacheKey(key))\n return entry !== undefined && !this.isDoomed(entry)\n }\n\n delete(key: K) {\n this.deleteKey(this.toCacheKey(key))\n }\n\n clear() {\n this.entries.clear()\n this.shared?.budget.charge(this.shared.membership, -this.total)\n this.total = 0\n this.settledCount = 0\n this.stopSweep()\n }\n\n /**\n * Mark an entry most-recently-used, in both orders that word has here: its\n * position in {@link entries}, which {@link evict} and {@link lruSpare} walk,\n * and its {@link Entry.seq}, which a budget compares across caches.\n *\n * {@link lruSpare} takes an entry from map order and reports its seq, so the\n * two orders have to move together. This and {@link start} are the only\n * places either moves.\n */\n private touch(cacheKey: string, entry: Entry<V>) {\n this.entries.delete(cacheKey)\n this.entries.set(cacheKey, entry)\n entry.lastTouched = Date.now()\n entry.seq = this.stamp()\n }\n\n /** Only a budget compares these, so a cache without one has no order to keep. */\n private stamp() {\n return this.shared?.budget.nextSeq() ?? 0\n }\n\n /** In flight, but every caller waiting on it has already given up. */\n private isDoomed(entry: Entry<V>) {\n return entry.pending?.controller.signal.aborted === true\n }\n\n /**\n * Evict entries nothing has read for {@link SharedReadCacheOptions.idleTimeoutMs}.\n *\n * Exposed so a consumer can reclaim on its own schedule \u2014 a browser tab going\n * hidden, say \u2014 rather than only on the interval. A no-op when no idle\n * timeout is configured.\n */\n sweepIdle() {\n const timeout = this.idleTimeoutMs\n if (timeout === undefined) {\n return\n }\n const cutoff = Date.now() - timeout\n for (const [cacheKey, entry] of this.entries) {\n if (!entry.pending && entry.lastTouched <= cutoff) {\n this.deleteKey(cacheKey)\n }\n }\n // Nothing settled left, rather than an empty map: a read that never settles\n // is never swept, and must not keep the timer ticking. If it does settle,\n // start() arms the timer again.\n if (this.settledCount === 0) {\n this.stopSweep()\n }\n }\n\n // The sweep runs on an interval because it is the one form of reclamation\n // that has to happen when nothing is calling in. It runs exactly when there\n // is something it could reclaim: armed by the first read to SETTLE, stopped\n // by the first sweep that finds no settled entry left.\n //\n // The timer holds the cache weakly, which is what makes a dispose() method\n // unnecessary: a pending timer is a GC root, so held strongly it kept a\n // dropped cache, and everything its fill closes over, alive until a sweep\n // emptied it \u2014 a whole idle timeout after the consumer let go.\n private startSweep() {\n const timeout = this.idleTimeoutMs\n if (timeout === undefined || this.sweepTimer !== undefined) {\n return\n }\n // A quarter of the timeout, so an idle entry is reclaimed within ~1.25x of\n // it, but no more often than once a second. Capped at what a timer can\n // hold: past 2^31-1 ms Node and browsers fire immediately instead.\n const interval = Math.min(\n 2 ** 31 - 1,\n Math.max(1000, Math.floor(timeout / 4)),\n )\n const ref = new WeakRef(this)\n const timer = setInterval(() => {\n const cache = ref.deref()\n if (cache) {\n cache.sweepIdle()\n } else {\n clearInterval(timer)\n }\n }, interval)\n this.sweepTimer = timer\n // Node holds the process open for a pending interval, and a library's\n // housekeeping must never be why a script fails to exit. Browsers return a\n // number, which has no unref.\n ;(timer as { unref?: () => void }).unref?.()\n }\n\n private stopSweep() {\n if (this.sweepTimer !== undefined) {\n clearInterval(this.sweepTimer)\n this.sweepTimer = undefined\n }\n }\n\n // The read runs under its own controller rather than any one caller's signal,\n // because it is shared: it must survive until every caller waiting on it has\n // given up. join() is what registers them.\n private start(\n cacheKey: string,\n key: K,\n fill?: (signal: AbortSignal) => Promise<V>,\n ) {\n const run = fill ?? (this.fill && ((s: AbortSignal) => this.fill!(key, s)))\n if (!run) {\n throw new Error(\n 'SharedReadCache needs a fill, either on the cache or on the get() call',\n )\n }\n const pending: PendingRead = {\n signals: new Map(),\n pinned: false,\n controller: new AbortController(),\n }\n const entry: Entry<V> = {\n // Promise.resolve hands a native promise back untouched, so getIfCached\n // still returns the fill's own. What it adds is that an untyped fill\n // returning a bare value is a read like any other, where calling `.then`\n // on it threw after the entry was already in the map.\n promise: Promise.resolve(run(pending.controller.signal)),\n pending,\n size: 0,\n lastTouched: Date.now(),\n seq: this.stamp(),\n }\n this.entries.set(cacheKey, entry)\n const isCurrent = () => this.entries.get(cacheKey) === entry\n const settle = () => {\n for (const [signal, onAbort] of pending.signals) {\n signal.removeEventListener('abort', onAbort)\n }\n entry.pending = undefined\n }\n // `.then(f, g)` rather than `.finally(f)` so the handler's own promise never\n // carries an unhandled rejection.\n void entry.promise.then(\n value => {\n // Weighed while the entry still reads as in flight, because sizeOf is\n // consumer code: if it deletes or clears from in here, the entry leaves\n // as the uncounted read it still is.\n const size = isCurrent() ? this.weigh(value) : undefined\n // false too if a later read replaced this key while this one ran\n const current = isCurrent()\n settle()\n if (current) {\n if (size === undefined) {\n // not deleteKey, which credits back a settled entry: this one was\n // never counted as one\n this.entries.delete(cacheKey)\n } else {\n // The idle clock starts when the value exists, so a slow read\n // still gets its whole timeout. Not a touch(): eviction order\n // stays the order reads were asked for in, since ordering by when\n // they landed keeps whatever was slowest to arrive.\n entry.lastTouched = Date.now()\n entry.size = size\n this.settledCount++\n this.total += size\n this.shared?.budget.charge(this.shared.membership, size)\n this.startSweep()\n }\n }\n this.evict()\n // after the local pass, so a cache that can get under its own ceiling\n // does that first and only then competes for the shared one\n this.shared?.budget.evict()\n },\n () => {\n // A failed read caches nothing, so the next caller starts over. Dropped\n // before settle(), so deleteKey sees the uncounted read it still is.\n if (isCurrent()) {\n this.deleteKey(cacheKey)\n }\n settle()\n },\n )\n return entry\n }\n\n /**\n * {@link SharedReadCacheOptions.sizeOf}, checked \u2014 `undefined` when it does\n * not answer with a weight, which drops the entry rather than keeping one the\n * budget cannot see.\n *\n * Checked because it is consumer code over consumer values: `v =>\n * v.byteLength` returns `undefined` on a value without the field, arithmetic\n * turns that into `NaN`, and `NaN` in `total` is permanent \u2014 `total <= limit`\n * is false forever after, so every settle evicts down to the last entry.\n *\n * Swallowed rather than rethrown. Thrown from here it would reject a promise\n * nothing holds, and carried into the entry's own promise it would fail a\n * read that succeeded and whose caller already has its value.\n */\n private weigh(value: V) {\n try {\n const size = this.sizeOf(value)\n return Number.isFinite(size) && size >= 0 ? size : undefined\n } catch {\n return undefined\n }\n }\n\n // Register a caller's interest, so the read survives until that caller has\n // given up too.\n private join(pending: PendingRead, signal?: AbortSignal) {\n if (signal === undefined || typeof signal.addEventListener !== 'function') {\n // Nothing here can learn that this caller gave up \u2014 it has no signal, or\n // a duck-typed `{ aborted }` that cannot be subscribed to \u2014 so the read\n // must not be cancelled out from under it.\n pending.pinned = true\n } else if (!signal.aborted && !pending.signals.has(signal)) {\n // `!signal.aborted` is unreachable through get(), which rejects such a\n // caller first. It stays because an abort listener never fires on a\n // signal that aborted before it was added: counted as a waiter, that\n // caller would make the read uncancellable for everyone, silently.\n const onAbort = () => {\n pending.signals.delete(signal)\n if (!pending.pinned && pending.signals.size === 0) {\n pending.controller.abort(signal.reason)\n }\n }\n pending.signals.set(signal, onAbort)\n signal.addEventListener('abort', onAbort, { once: true })\n }\n }\n\n private deleteKey(cacheKey: string) {\n const entry = this.entries.get(cacheKey)\n if (entry) {\n this.entries.delete(cacheKey)\n if (!entry.pending) {\n this.settledCount--\n }\n this.total -= entry.size\n this.shared?.budget.charge(this.shared.membership, -entry.size)\n }\n }\n\n /**\n * @internal \u2014 a budget asks; nothing else should.\n *\n * The least-recently-used settled entry, or `undefined` if this cache holds\n * at most one.\n */\n lruSpare() {\n if (this.settledCount <= 1) {\n return undefined\n }\n for (const [cacheKey, entry] of this.entries) {\n if (!entry.pending) {\n return { cacheKey, seq: entry.seq }\n }\n }\n return undefined\n }\n\n /** @internal \u2014 a budget evicting on this cache's behalf. */\n release(cacheKey: string) {\n this.deleteKey(cacheKey)\n }\n\n /**\n * Evict from the least-recently-used end.\n *\n * Reads still in flight are skipped: they have no weight to reclaim, and\n * dropping one would lose the de-duplication every caller joined to it is\n * relying on.\n *\n * The last settled entry is kept whatever the budget. A single value larger\n * than the whole budget is still worth holding \u2014 the caller needs it for the\n * request in flight, so dropping it only buys an immediate re-read.\n */\n private evict() {\n // also what keeps an unbounded cache, or one comfortably under its budget,\n // from building an iterator on every settle\n if (this.total <= this.limit) {\n return\n }\n for (const [cacheKey, entry] of this.entries) {\n if (this.total <= this.limit || this.settledCount <= 1) {\n break\n }\n if (!entry.pending) {\n this.deleteKey(cacheKey)\n }\n }\n }\n}\n", "import type {\n BufferEncoding,\n FilehandleOptions,\n ProgressCallback,\n} from './filehandle.ts'\n\n// Response.bytes() / Blob.bytes() is widely available but not yet in all\n// lib.dom.d.ts versions, so the optional-chain check is load-bearing for older\n// runtimes despite TS thinking it's always defined.\nexport async function toBytes(\n src: Response | Blob,\n): Promise<Uint8Array<ArrayBuffer>> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return src.bytes ? src.bytes() : new Uint8Array(await src.arrayBuffer())\n}\n\n/**\n * The body of a `readFile()`, decoded per the caller's encoding.\n *\n * Shared by RemoteFile and BlobFile because the branch is the same in both:\n * text for utf8, bytes for no encoding, an error for an encoding neither can\n * decode. Both spellings of utf8 count \u2014 node's `readFile` accepts `utf-8`, so\n * LocalFile does too, and rejecting it only here would make the encoding a\n * property of which filehandle you happened to hold.\n */\nexport async function readBody(\n src: Response | Blob,\n encoding: BufferEncoding | undefined,\n onProgress?: ProgressCallback,\n): Promise<Uint8Array<ArrayBuffer> | string> {\n if (encoding === 'utf8' || encoding === 'utf-8') {\n return src.text()\n } else if (encoding) {\n throw new Error(`unsupported encoding: ${encoding}`)\n }\n // duck-typed rather than `instanceof Response`, because a custom `fetch` may\n // hand back a Response from another realm or another implementation\n // altogether, and taking the no-progress path there leaves a progress bar at\n // zero for the whole download. Only Response has `body`.\n return onProgress && 'body' in src\n ? toBytesWithProgress(src, onProgress)\n : toBytes(src)\n}\n\n/**\n * `readFile()` takes either a bare encoding string or an options object, in\n * every implementation. Split whichever was passed into the two things callers\n * actually branch on.\n */\nexport function splitReadFileOptions(\n options: FilehandleOptions | BufferEncoding | undefined,\n): { encoding?: BufferEncoding; opts: FilehandleOptions } {\n return typeof options === 'string'\n ? { encoding: options, opts: {} }\n : { encoding: options?.encoding, opts: options ?? {} }\n}\n\n/**\n * Total file size from a `Content-Range: bytes 0-9/1234` header, or undefined\n * if the header is absent or gives the size as `*`.\n */\nexport function parseContentRangeSize(\n contentRange: string | null,\n): number | undefined {\n const size = /\\/(\\d+)$/.exec(contentRange ?? '')?.[1]\n return size === undefined ? undefined : parseInt(size, 10)\n}\n\n/**\n * Content-Length as a usable byte count. A malformed header yields undefined\n * rather than NaN, which would otherwise survive an `=== undefined` check and\n * poison every arithmetic use downstream.\n */\nexport function parseContentLength(res: Response): number | undefined {\n const header = res.headers.get('content-length')\n const parsed = header === null ? Number.NaN : Number(header)\n return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : undefined\n}\n\n// throttle intermediate progress ticks; a large body can yield thousands of\n// chunks and the final exact count is always emitted regardless\nconst PROGRESS_THROTTLE_MS = 50\n\n/**\n * Read a Response body to bytes while reporting download progress.\n *\n * When Content-Length is known the body is streamed directly into one pre-sized\n * buffer (no per-chunk array, no second copy), ticking `onProgress` as chunks\n * arrive. Without a known length there is no fraction to show, so it falls back\n * to a single one-shot read and one completion tick rather than buffering\n * chunks. Only used when a caller opts in via `onProgress`; the plain {@link\n * toBytes} fast path is unaffected.\n */\nexport async function toBytesWithProgress(\n res: Response,\n onProgress: ProgressCallback,\n): Promise<Uint8Array<ArrayBuffer>> {\n const total = parseContentLength(res)\n const body = res.body\n if (!body || total === undefined) {\n const bytes = await toBytes(res)\n onProgress(bytes.byteLength, total ?? bytes.byteLength)\n return bytes\n }\n\n const reader = body.getReader()\n let out = new Uint8Array(total)\n let received = 0\n let lastTick = Date.now()\n onProgress(0, total)\n for (\n let chunk = await reader.read();\n !chunk.done;\n chunk = await reader.read()\n ) {\n // a decoded body can exceed Content-Length (e.g. gzip transfer-encoding);\n // grow the buffer rather than throwing on out.set() overflow\n if (received + chunk.value.byteLength > out.length) {\n const grown = new Uint8Array(\n Math.max(received + chunk.value.byteLength, out.length * 2),\n )\n grown.set(out.subarray(0, received))\n out = grown\n }\n out.set(chunk.value, received)\n received += chunk.value.byteLength\n const now = Date.now()\n if (now - lastTick >= PROGRESS_THROTTLE_MS) {\n lastTick = now\n onProgress(received, total)\n }\n }\n\n onProgress(received, total)\n // copy rather than return a view: a body shorter than its Content-Length\n // would otherwise pin the whole over-allocated buffer, and hand the caller\n // bytes whose `.buffer` is longer than the view over it\n return received === out.length ? out : out.slice(0, received)\n}\n", "import {\n parseContentRangeSize,\n readBody,\n splitReadFileOptions,\n toBytes,\n toBytesWithProgress,\n} from './util.ts'\n\nimport type {\n BufferEncoding,\n Fetcher,\n FilehandleOptions,\n GenericFilehandle,\n ProgressCallback,\n ReadFileOptions,\n ReadFileTextOptions,\n Stats,\n} from './filehandle.ts'\n\n// header names are case-insensitive but object keys are not, so a caller's\n// `Range` and the `range` a ranged GET adds are two keys \u2014 and fetch folds them\n// into one comma-joined multi-range request, whose multipart/byteranges body we\n// would hand back as file bytes. The same folding joins a constructor's\n// `Authorization` to a per-call `authorization`. A later source wins, however\n// either one spelled the name.\nfunction mergeHeaders(...sources: (Record<string, string> | undefined)[]) {\n const merged = new Map<string, [string, string]>()\n for (const source of sources) {\n for (const [name, value] of Object.entries(source ?? {})) {\n merged.set(name.toLowerCase(), [name, value])\n }\n }\n return Object.fromEntries(merged.values())\n}\n\n// under node, a body nobody reads holds its connection until it is collected.\n// A custom fetch may return a Response-like whose body has no cancel().\nfunction discardBody(res: Response) {\n const body = res.body as Partial<ReadableStream> | null\n if (typeof body?.cancel === 'function') {\n body.cancel().catch(() => undefined)\n }\n}\n\nfunction isByteOffset(n: number) {\n return Number.isSafeInteger(n) && n >= 0\n}\n\n// fetch reports a request that got no response as a bare TypeError naming no\n// URL. Matched by name, since a custom fetch can throw one from another realm.\nfunction isNetworkFailure(e: unknown) {\n return (\n typeof e === 'object' && e !== null && 'name' in e && e.name === 'TypeError'\n )\n}\n\nfunction getMessage(e: unknown) {\n const r =\n typeof e === 'object' &&\n e !== null &&\n 'message' in e &&\n typeof e.message === 'string'\n ? e.message\n : `${e}`\n // strip trailing period so the wrapped form `${msg} fetching ${url}` reads cleanly\n return r.replace(/\\.$/, '')\n}\n\nexport default class RemoteFile implements GenericFilehandle {\n protected url: string\n\n /** the URL this handle fetches \u2014 see {@link GenericFilehandle.source} */\n public get source() {\n return this.url\n }\n\n private _stat?: Stats\n private statProbe?: Promise<unknown>\n private fetchImplementation: Fetcher\n private baseHeaders: Record<string, string>\n private baseOverrides: Omit<RequestInit, 'headers'>\n private baseSignal?: AbortSignal\n\n public constructor(source: string, opts: FilehandleOptions = {}) {\n this.url = source\n this.baseHeaders = opts.headers ?? {}\n this.baseOverrides = opts.overrides ?? {}\n this.baseSignal = opts.signal\n this.fetchImplementation = opts.fetch ?? globalThis.fetch.bind(globalThis)\n }\n\n protected buildRequest(\n opts: FilehandleOptions,\n extraHeaders?: Record<string, string>,\n ): RequestInit {\n // a per-call signal beats the constructor's, which beats one supplied via\n // overrides; omit the key entirely when there is none, so we don't write\n // `signal: undefined` over an overrides-supplied signal\n const signal = opts.signal ?? this.baseSignal\n return {\n // defaults first: `overrides` is documented as extra fetch params, so a\n // caller passing e.g. mode/redirect/method has to be able to win\n method: 'GET',\n redirect: 'follow',\n mode: 'cors',\n ...this.baseOverrides,\n ...opts.overrides,\n headers: mergeHeaders(this.baseHeaders, opts.headers, extraHeaders),\n ...(signal ? { signal } : {}),\n }\n }\n\n public async fetch(\n input: RequestInfo,\n init?: RequestInit,\n ): Promise<Response> {\n const wrapError = (e: unknown) =>\n isNetworkFailure(e) && !init?.signal?.aborted\n ? new Error(`${getMessage(e)} fetching ${input}`, { cause: e })\n : e\n\n let response: Response\n try {\n response = await this.fetchImplementation(input, init)\n } catch (e) {\n if (`${e}`.includes('Failed to fetch')) {\n // refetch to help work around a chrome bug (discussed in\n // generic-filehandle issue #72) in which the chrome cache returns a\n // CORS error for content in its cache. see also\n // https://github.com/GMOD/jbrowse-components/pull/1511\n console.warn(\n `generic-filehandle: refetching ${input} to attempt to work around chrome CORS header caching bug`,\n )\n try {\n response = await this.fetchImplementation(input, {\n ...init,\n cache: 'reload',\n })\n } catch (e) {\n throw wrapError(e)\n }\n } else {\n throw wrapError(e)\n }\n }\n return response\n }\n\n public async read(\n length: number,\n position: number,\n opts: FilehandleOptions = {},\n ): Promise<Uint8Array<ArrayBuffer>> {\n // NaN is the one that motivated this \u2014 a corrupt index yields it from\n // ordinary arithmetic \u2014 but a fractional or negative byte offset is just as\n // unsendable, and reaches the server as a range header it can only reject\n if (!isByteOffset(length) || !isByteOffset(position)) {\n throw new TypeError(\n `read() called with an invalid length or position (length=${length}, position=${position}). The index file may be corrupt.`,\n )\n }\n return length === 0\n ? new Uint8Array(0)\n : this.fetchBytes(length, position, opts)\n }\n\n /**\n * The bytes for one byte range \u2014 the seam a subclass that can serve those\n * bytes some other way overrides.\n *\n * The alternative is overriding {@link fetch}, and for a subclass holding a\n * byte cache that is the wrong altitude: it has bytes, so it has to wrap them\n * in a `Response` that `read` immediately unwraps again. Both halves copy.\n * Measured against JBrowse's `RemoteFileWithRangeCache` on a fully warm cache\n * with no network at all, that round trip was **69-77% of the entire read** \u2014\n * 6.15ms vs 1.90ms for 16MB, and the same ratio down to 256KB.\n *\n * So: override this to serve bytes, override {@link fetch} to change how\n * requests are made. Overriding neither leaves the ranged GET below, and the\n * default implementation still goes through `this.fetch`, so a subclass that\n * only wraps `fetch` keeps working untouched.\n */\n protected async fetchBytes(\n length: number,\n position: number,\n opts: FilehandleOptions,\n ): Promise<Uint8Array<ArrayBuffer>> {\n const res = await this.fetch(\n this.url,\n this.buildRequest(opts, {\n range: `bytes=${position}-${position + length - 1}`,\n }),\n )\n\n // HTTP 416 Range Not Satisfiable: the requested range starts past EOF.\n // Translate to an empty read so callers can detect EOF via short/empty\n // returns instead of needing a separate size oracle (stat) to stay clear of\n // the end of the file.\n if (res.status === 416) {\n discardBody(res)\n return new Uint8Array(0)\n }\n\n this.checkOk(res)\n\n if ((res.status === 200 && position === 0) || res.status === 206) {\n // try to parse out the size of the remote file\n const size = parseContentRangeSize(res.headers.get('content-range'))\n if (size !== undefined) {\n this._stat = { size }\n }\n\n const resData = opts.onProgress\n ? await toBytesWithProgress(res, opts.onProgress)\n : await toBytes(res)\n // server didn't honor the range request and returned the full file \u2014\n // the body length is the actual file size\n if (!this._stat && res.status === 200) {\n this._stat = { size: resData.byteLength }\n }\n // the server over-delivered (it ignored our range header and sent the\n // whole file). copy out the requested slice rather than returning a\n // subarray view, which would pin the entire body in memory for as long\n // as the caller holds those few bytes.\n return resData.byteLength <= length ? resData : resData.slice(0, length)\n }\n\n discardBody(res)\n throw new Error(\n res.status === 200\n ? `${this.url} fetch returned status 200, expected 206`\n : `HTTP ${res.status} fetching ${this.url}`,\n )\n }\n\n private checkOk(res: Response) {\n if (!res.ok) {\n discardBody(res)\n throw new Error(`HTTP ${res.status} fetching ${this.url}`)\n }\n }\n\n public async readFile(\n options?: ReadFileOptions,\n ): Promise<Uint8Array<ArrayBuffer>>\n public async readFile(options: ReadFileTextOptions): Promise<string>\n public async readFile(\n options?: FilehandleOptions | BufferEncoding,\n ): Promise<Uint8Array<ArrayBuffer> | string> {\n const { encoding, opts } = splitReadFileOptions(options)\n const res = await this.fetch(this.url, this.buildRequest(opts))\n this.checkOk(res)\n const body = await this.readFileBody(res, encoding, opts.onProgress)\n // a 200 means we hold the entire file, so its length is the file size \u2014\n // record it so a subsequent stat() doesn't need another request. a 206\n // (caller supplied their own range header) tells us nothing.\n if (res.status === 200 && typeof body !== 'string') {\n this._stat = { size: body.byteLength }\n }\n return body\n }\n\n /**\n * Reads the body of a whole-file response. A subclass overrides it to learn\n * when that body starts and ends, which `fetch` cannot tell it: `fetch`\n * returns at the headers.\n */\n protected readFileBody(\n res: Response,\n encoding: BufferEncoding | undefined,\n onProgress?: ProgressCallback,\n ) {\n return readBody(res, encoding, onProgress)\n }\n\n public async stat(): Promise<Stats> {\n if (!this._stat) {\n // share one probe between concurrent stat() callers instead of each\n // firing its own request; cleared afterwards so a failed probe retries\n this.statProbe ??= this.read(10, 0).finally(() => {\n this.statProbe = undefined\n })\n await this.statProbe\n }\n // Content-Range may not be exposed due to CORS \u2014 return size 0 rather\n // than crashing so callers can degrade gracefully.\n return this._stat ?? { size: 0 }\n }\n\n public close(): Promise<void> {\n return Promise.resolve()\n }\n}\n", "// Browser-specific exports that exclude Node.js-only modules\nimport type {\n FilehandleOptions,\n GenericFilehandle,\n ReadFileOptions,\n ReadFileTextOptions,\n} from './filehandle.ts'\nimport type { LocalFileOptions } from './localFile.ts'\n\nexport * from './filehandle.ts'\nexport type { LocalFileOptions } from './localFile.ts'\n\nexport { default as BlobFile } from './blobFile.ts'\nexport { default as RemoteFile } from './remoteFile.ts'\n\n/**\n * Stub standing in for the Node.js LocalFile in browser builds. Every member\n * carries the same signature as the real one \u2014 otherwise code written against\n * the node class fails to compile in any bundle that resolves the `browser`\n * export condition, which is the one thing this stub exists to prevent.\n * `implements GenericFilehandle` keeps drift from the interface a compile\n * error rather than a runtime one.\n *\n * The parameters go unread: every call rejects. They are here to be typed, so\n * a bundle only discovers that a local file is unavailable in the browser at\n * the point it actually tries to read one.\n */\nexport class LocalFile implements GenericFilehandle {\n /** the path this stub was handed \u2014 see {@link GenericFilehandle.source} */\n public readonly source: string\n\n // takes the options argument too, for the same reason it takes `source`: a\n // bundle resolving the `browser` condition must still typecheck a call\n // written against the node class, options and all\n public constructor(source: string, _opts: LocalFileOptions = {}) {\n this.source = source\n }\n\n private unimplemented(): Promise<never> {\n return Promise.reject(\n new Error(`LocalFile is unimplemented in the browser (${this.source})`),\n )\n }\n\n readFile(options?: ReadFileOptions): Promise<Uint8Array<ArrayBuffer>>\n readFile(options: ReadFileTextOptions): Promise<string>\n readFile(_options?: unknown): Promise<never> {\n return this.unimplemented()\n }\n read(\n _length: number,\n _position?: number,\n _opts?: FilehandleOptions,\n ): Promise<never> {\n return this.unimplemented()\n }\n stat(): Promise<never> {\n return this.unimplemented()\n }\n close(): Promise<never> {\n return this.unimplemented()\n }\n}\n", "import type VirtualOffset from './virtualOffset.ts'\n\n// little class representing a chunk in the index\nexport default class Chunk {\n public minv: VirtualOffset\n public maxv: VirtualOffset\n public bin: number\n // Absolute byte offset where the fetch for this chunk ends. The compressed\n // size of the final BGZF block (the one at maxv.blockPosition) is unknown\n // from the index, so this defaults to a full max-size block past maxv. It can\n // be tightened to the next known block boundary via clampChunkEnds.\n public endPosition: number\n\n constructor(\n minv: VirtualOffset,\n maxv: VirtualOffset,\n bin: number,\n endPosition = maxv.blockPosition + (1 << 16),\n ) {\n this.minv = minv\n this.maxv = maxv\n this.bin = bin\n this.endPosition = endPosition\n }\n\n toString() {\n return `${this.minv.toString()}..${this.maxv.toString()} (bin ${\n this.bin\n }, fetchedSize ${this.fetchedSize()})`\n }\n\n fetchedSize() {\n return this.endPosition - this.minv.blockPosition\n }\n}\n", "export interface Options<KeyType, ValueType> {\n /**\n * The target maximum number of items before evicting the least recently used items.\n *\n * __Note:__ The cache keeps two generations of items to avoid expensive deletes, so it can hold up to `2 \u00D7 maxSize` items, though `size` never reports more than `maxSize`.\n */\n readonly maxSize: number\n\n /**\n * The maximum number of milliseconds an item should remain in the cache. Items expire lazily, on the next read or write that touches them.\n *\n * Individual items can override it with `set(key, value, {maxAge})`.\n *\n * @default Infinity\n */\n readonly maxAge?: number\n\n /**\n * Called when an item leaves the cache due to LRU pressure, TTL expiration, `resize()` or `evict()`. Useful for cleaning up items like object URLs (`revokeObjectURL`).\n *\n * It is not called for `delete()`, `clear()`, or when `set()` overwrites an existing key.\n */\n onEviction?: (key: KeyType, value: ValueType) => void\n}\n\ninterface Item<ValueType> {\n value: ValueType\n expiry?: number\n}\n\nfunction assertPositive(name: string, value: number) {\n if (!(value > 0)) {\n throw new TypeError(`\\`${name}\\` must be a number greater than 0`)\n }\n}\n\n/**\n * Simple [\"Least Recently Used\" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29).\n *\n * The instance is an iterable of `[key, value]` pairs, oldest first.\n *\n * @example\n * ```\n * import QuickLRU from '@jbrowse/quick-lru'\n *\n * const lru = new QuickLRU({maxSize: 1000})\n *\n * lru.set('\uD83E\uDD84', '\uD83C\uDF08')\n *\n * lru.has('\uD83E\uDD84')\n * //=> true\n *\n * lru.get('\uD83E\uDD84')\n * //=> '\uD83C\uDF08'\n * ```\n */\nexport default class QuickLRU<KeyType, ValueType> implements Iterable<\n [KeyType, ValueType]\n> {\n #cache = new Map<KeyType, Item<ValueType>>()\n #oldCache = new Map<KeyType, Item<ValueType>>()\n #maxSize: number\n #maxAge: number\n #onEviction?: (key: KeyType, value: ValueType) => void\n\n constructor(options: Options<KeyType, ValueType>) {\n const maxAge = options.maxAge ?? Number.POSITIVE_INFINITY\n assertPositive('maxSize', options.maxSize)\n assertPositive('maxAge', maxAge)\n this.#maxSize = options.maxSize\n this.#maxAge = maxAge\n this.#onEviction = options.onEviction\n }\n\n #emitEvictions(items: Iterable<[KeyType, Item<ValueType>]>) {\n const onEviction = this.#onEviction\n if (onEviction) {\n for (const [key, item] of items) {\n onEviction(key, item.value)\n }\n }\n }\n\n #deleteIfExpired(key: KeyType, item: Item<ValueType>) {\n if (item.expiry !== undefined && item.expiry <= Date.now()) {\n this.#onEviction?.(key, item.value)\n this.delete(key)\n return true\n }\n return false\n }\n\n #valueIfFresh(key: KeyType, item: Item<ValueType>) {\n return this.#deleteIfExpired(key, item) ? undefined : item.value\n }\n\n #moveToRecent(key: KeyType, item: Item<ValueType>) {\n this.#oldCache.delete(key)\n this.#cache.set(key, item)\n\n if (this.#cache.size >= this.#maxSize) {\n const evicted = this.#oldCache\n this.#oldCache = this.#cache\n this.#cache = new Map()\n this.#emitEvictions(evicted)\n }\n }\n\n #replaceWith(items: [KeyType, Item<ValueType>][]) {\n this.#oldCache = new Map(items)\n this.#cache = new Map()\n }\n\n *#liveItemsAscending(): Generator<[KeyType, Item<ValueType>]> {\n for (const cache of [this.#oldCache, this.#cache]) {\n for (const entry of cache) {\n if (!this.#deleteIfExpired(...entry)) {\n yield entry\n }\n }\n }\n }\n\n /**\n * Get an item, marking it as recently used.\n *\n * @returns The stored item or `undefined`.\n */\n get(key: KeyType): ValueType | undefined {\n const item = this.#cache.get(key)\n if (item) {\n return this.#valueIfFresh(key, item)\n }\n\n const oldItem = this.#oldCache.get(key)\n if (oldItem && !this.#deleteIfExpired(key, oldItem)) {\n this.#moveToRecent(key, oldItem)\n return oldItem.value\n }\n return undefined\n }\n\n /**\n * Set an item, marking it as recently used.\n *\n * The `maxAge` option overrides the cache-wide `maxAge` for this item.\n *\n * @returns The cache instance.\n */\n set(\n key: KeyType,\n value: ValueType,\n { maxAge = this.#maxAge }: { maxAge?: number } = {},\n ): this {\n const item = {\n value,\n expiry:\n maxAge === Number.POSITIVE_INFINITY ? undefined : Date.now() + maxAge,\n }\n\n if (this.#cache.has(key)) {\n this.#cache.set(key, item)\n } else {\n this.#moveToRecent(key, item)\n }\n return this\n }\n\n /** Check if an item exists, without marking it as recently used. */\n has(key: KeyType): boolean {\n const item = this.#cache.get(key) ?? this.#oldCache.get(key)\n return item !== undefined && !this.#deleteIfExpired(key, item)\n }\n\n /**\n * Get an item without marking it as recently used.\n *\n * @returns The stored item or `undefined`.\n */\n peek(key: KeyType): ValueType | undefined {\n const item = this.#cache.get(key) ?? this.#oldCache.get(key)\n return item ? this.#valueIfFresh(key, item) : undefined\n }\n\n /**\n * Get the remaining time to live of an item, in milliseconds. Neither marks the item as recently used nor removes it if expired, so the result may be negative.\n *\n * @returns The remaining milliseconds, `Infinity` if the item never expires, or `undefined` if it is not in the cache.\n */\n expiresIn(key: KeyType): number | undefined {\n const item = this.#cache.get(key) ?? this.#oldCache.get(key)\n if (item) {\n return item.expiry === undefined\n ? Number.POSITIVE_INFINITY\n : item.expiry - Date.now()\n }\n return undefined\n }\n\n /**\n * Delete an item.\n *\n * @returns `true` if the item was removed, `false` if it did not exist.\n */\n delete(key: KeyType): boolean {\n return this.#cache.delete(key) || this.#oldCache.delete(key)\n }\n\n /** Delete all items. */\n clear(): void {\n this.#cache.clear()\n this.#oldCache.clear()\n }\n\n /** Update `maxSize` in place, evicting the least recently used items if the cache no longer fits. */\n resize(maxSize: number): void {\n assertPositive('maxSize', maxSize)\n\n const items = [...this.#liveItemsAscending()]\n const removeCount = items.length - maxSize\n if (removeCount < 0) {\n this.#cache = new Map(items)\n this.#oldCache = new Map()\n } else {\n this.#emitEvictions(items.slice(0, removeCount))\n this.#replaceWith(items.slice(removeCount))\n }\n this.#maxSize = maxSize\n }\n\n /**\n * Evict the least recently used items. Always keeps at least one item.\n *\n * @param count - The number of items to evict.\n */\n evict(count = 1): void {\n if (!(count > 0)) {\n return\n }\n\n const items = [...this.#liveItemsAscending()]\n const evictCount = Math.trunc(Math.min(count, items.length - 1))\n if (evictCount > 0) {\n this.#emitEvictions(items.slice(0, evictCount))\n this.#replaceWith(items.slice(evictCount))\n }\n }\n\n /** The stored item count, capped at `maxSize`. */\n get size(): number {\n return Math.min(this.#cache.size + this.#oldCache.size, this.#maxSize)\n }\n\n get maxSize(): number {\n return this.#maxSize\n }\n\n get maxAge(): number {\n return this.#maxAge\n }\n\n /** Iterate over all entries, oldest first. */\n *entriesAscending(): IterableIterator<[KeyType, ValueType]> {\n for (const [key, item] of this.#liveItemsAscending()) {\n yield [key, item.value]\n }\n }\n\n /** Iterate over all entries, newest first. */\n *entriesDescending(): IterableIterator<[KeyType, ValueType]> {\n for (const cache of [this.#cache, this.#oldCache]) {\n for (const [key, item] of [...cache].reverse()) {\n if (!this.#deleteIfExpired(key, item)) {\n yield [key, item.value]\n }\n }\n }\n }\n\n /** Iterate over all entries, oldest first. Alias for `entriesAscending()`. */\n entries(): IterableIterator<[KeyType, ValueType]> {\n return this.entriesAscending()\n }\n\n [Symbol.iterator](): IterableIterator<[KeyType, ValueType]> {\n return this.entriesAscending()\n }\n\n *keys(): IterableIterator<KeyType> {\n for (const [key] of this) {\n yield key\n }\n }\n\n *values(): IterableIterator<ValueType> {\n for (const [, value] of this) {\n yield value\n }\n }\n\n forEach(\n callbackFunction: (\n value: ValueType,\n key: KeyType,\n map: QuickLRU<KeyType, ValueType>,\n ) => void,\n thisArgument: unknown = this,\n ): void {\n for (const [key, value] of this) {\n callbackFunction.call(thisArgument, value, key, this)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/class-literal-property-style\n get [Symbol.toStringTag](): string {\n return 'QuickLRU'\n }\n\n toString(): string {\n return `QuickLRU(${this.size}/${this.maxSize})`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n", "const TWO_PWR_32_DBL = 2 ** 32\n\nexport function longFromBytesToUnsigned(source: Uint8Array, i = 0) {\n const low =\n source[i]! |\n (source[i + 1]! << 8) |\n (source[i + 2]! << 16) |\n (source[i + 3]! << 24)\n const high =\n source[i + 4]! |\n (source[i + 5]! << 8) |\n (source[i + 6]! << 16) |\n (source[i + 7]! << 24)\n return (high >>> 0) * TWO_PWR_32_DBL + (low >>> 0)\n}\n", "export default class VirtualOffset {\n public blockPosition: number\n public dataPosition: number\n constructor(blockPosition: number, dataPosition: number) {\n this.blockPosition = blockPosition // < offset of the compressed data block\n this.dataPosition = dataPosition // < offset into the uncompressed data\n }\n\n toString() {\n return `${this.blockPosition}:${this.dataPosition}`\n }\n\n compareTo(b: VirtualOffset) {\n return (\n this.blockPosition - b.blockPosition || this.dataPosition - b.dataPosition\n )\n }\n}\nexport function fromBytes(bytes: Uint8Array, offset = 0) {\n return new VirtualOffset(\n bytes[offset + 7]! * 0x1_00_00_00_00_00 +\n bytes[offset + 6]! * 0x1_00_00_00_00 +\n bytes[offset + 5]! * 0x1_00_00_00 +\n bytes[offset + 4]! * 0x1_00_00 +\n bytes[offset + 3]! * 0x1_00 +\n bytes[offset + 2]!,\n (bytes[offset + 1]! << 8) | bytes[offset]!,\n )\n}\n", "import LRU from '@jbrowse/quick-lru'\n\nimport Chunk from './chunk.ts'\nimport { longFromBytesToUnsigned } from './long.ts'\nimport VirtualOffset from './virtualOffset.ts'\n\n// SYNC: ~/src/gmod/bam-js/src/util.ts optimizeChunks\n// Re-exported so the internal import path stays './util.ts'. The\n// implementation moved to @gmod/shared-read-cache, which needs it anyway --\n// every consumer of that package was carrying an identical copy.\nexport { throwIfAborted } from '@gmod/shared-read-cache'\n\nexport function optimizeChunks(chunks: Chunk[], lowest?: VirtualOffset) {\n const n = chunks.length\n if (n === 0) {\n return chunks\n }\n\n // Pre-filter before sorting: discard chunks whose maxv is at or before\n // `lowest` (the linear-index floor). Avoids sorting chunks that will be\n // dropped anyway \u2014 significant win when the linear index prunes most bins.\n let filtered: Chunk[]\n if (lowest) {\n const lowestBlock = lowest.blockPosition\n const lowestData = lowest.dataPosition\n filtered = []\n for (let i = 0; i < n; i++) {\n const chunk = chunks[i]!\n const cmp =\n chunk.maxv.blockPosition - lowestBlock ||\n chunk.maxv.dataPosition - lowestData\n if (cmp > 0) {\n filtered.push(chunk)\n }\n }\n if (filtered.length === 0) {\n return filtered\n }\n } else {\n filtered = chunks\n }\n\n filtered.sort((c0, c1) => {\n const dif = c0.minv.blockPosition - c1.minv.blockPosition\n return dif === 0 ? c0.minv.dataPosition - c1.minv.dataPosition : dif\n })\n\n // Merge adjacent/overlapping chunks. Track min/max blockPositions in locals\n // to avoid repeated property-chain reads in the hot loop.\n // Chunks are never mutated \u2014 merging produces a new Chunk instance.\n const mergedChunks: Chunk[] = [filtered[0]!]\n let lastMinBlock = filtered[0]!.minv.blockPosition\n let lastMaxBlock = filtered[0]!.maxv.blockPosition\n\n for (let i = 1; i < filtered.length; i++) {\n const chunk = filtered[i]!\n const chunkMinBlock = chunk.minv.blockPosition\n const chunkMaxBlock = chunk.maxv.blockPosition\n if (\n chunkMinBlock - lastMaxBlock < 65_000 &&\n chunkMaxBlock - lastMinBlock < 5_000_000\n ) {\n const lastChunk = mergedChunks.at(-1)!\n const cmp =\n chunkMaxBlock - lastMaxBlock ||\n chunk.maxv.dataPosition - lastChunk.maxv.dataPosition\n if (cmp > 0) {\n mergedChunks[mergedChunks.length - 1] = new Chunk(\n lastChunk.minv,\n chunk.maxv,\n lastChunk.bin,\n chunk.endPosition,\n )\n lastMaxBlock = chunkMaxBlock\n }\n } else {\n mergedChunks.push(chunk)\n lastMinBlock = chunkMinBlock\n lastMaxBlock = chunkMaxBlock\n }\n }\n\n return makeDisjoint(mergedChunks)\n}\n\n// SYNC: ~/src/gmod/bam-js/src/util.ts makeDisjoint\n/**\n * Trim any chunk that starts before its predecessor ends, so the spans a query\n * reads never overlap.\n *\n * Merging alone does not guarantee this. Two chunks from different bins can\n * overlap inside a single BGZF block while the merge above still declines to\n * join them, because the combined span would exceed its 5MB cap. The shared\n * bytes are then fetched, decompressed and decoded by both chunks, and every\n * line in the overlap is returned TWICE from getLines \u2014 a duplicated VCF\n * record or GFF feature, with a duplicated fileOffset.\n *\n * Safe because a chunk's `maxv` is the virtual offset just past its last\n * record \u2014 a record boundary \u2014 so no record begins inside the trimmed span and\n * the union of the chunks is unchanged.\n *\n * No fixture here reproduces it (@gmod/bam found it on an 18MB BAM, where\n * out.bam returned 5 of its 6551 records twice); this keeps the two copies of\n * optimizeChunks in step and pins the invariant.\n */\nfunction makeDisjoint(chunks: Chunk[]) {\n const out: Chunk[] = [chunks[0]!]\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i]!\n const prevMax = out.at(-1)!.maxv\n const cmp =\n chunk.minv.blockPosition - prevMax.blockPosition ||\n chunk.minv.dataPosition - prevMax.dataPosition\n if (cmp >= 0) {\n out.push(chunk)\n continue\n }\n const stillHasData =\n chunk.maxv.blockPosition - prevMax.blockPosition ||\n chunk.maxv.dataPosition - prevMax.dataPosition\n if (stillHasData > 0) {\n out.push(new Chunk(prevMax, chunk.maxv, chunk.bin, chunk.endPosition))\n }\n }\n return out\n}\n\n// Tighten each chunk's endPosition (default: a full max-size BGZF block past\n// maxv) down to the next known block boundary. Every chunk min/maxv blockPosition\n// and every extraBoundary (e.g. linear-index entries) is a real BGZF block start;\n// since blocks don't overlap, the first boundary strictly greater than a chunk's\n// maxv.blockPosition is an upper bound on where that final block ends \u2014 always at\n// least the true block end, so the clamped fetch still contains the whole block.\n// Shrinks both the byte estimate and the actual fetch with no extra I/O.\nexport function clampChunkEnds(\n chunks: Chunk[],\n extraBoundaries: number[] = [],\n) {\n // Array#sort with a comparator beats a Float64Array numeric sort here:\n // extraBoundaries (the linear index) arrives already sorted and TimSort\n // exploits the existing run, which introsort cannot.\n const boundaries = [...extraBoundaries]\n for (const c of chunks) {\n boundaries.push(c.minv.blockPosition, c.maxv.blockPosition)\n }\n boundaries.sort((a, b) => a - b)\n\n for (const c of chunks) {\n const max = c.maxv.blockPosition\n // first boundary strictly greater than max\n let lo = 0\n let hi = boundaries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (boundaries[mid]! > max) {\n hi = mid\n } else {\n lo = mid + 1\n }\n }\n if (lo < boundaries.length) {\n c.endPosition = Math.min(c.endPosition, boundaries[lo]!)\n }\n }\n}\n\n/**\n * The smallest of `current` and the `count` packed virtual offsets starting at\n * `offset`, allocating at most one VirtualOffset rather than one per entry.\n *\n * The index first pass exists only to find this minimum, and it visits every\n * linear-index entry in the file to do it \u2014 301k of them on\n * test/data/failing_tabix.vcf.gz.tbi against 19k bin chunks. Building a\n * VirtualOffset per entry to compare and discard it is the bulk of that pass.\n */\nexport function minVirtualOffset(\n bytes: Uint8Array,\n offset: number,\n count: number,\n current: VirtualOffset | undefined,\n) {\n let minBlock = current ? current.blockPosition : Infinity\n let minData = current ? current.dataPosition : 0\n let found = false\n for (let i = 0; i < count; i++) {\n const p = offset + i * 8\n const block =\n bytes[p + 7]! * 0x1_00_00_00_00_00 +\n bytes[p + 6]! * 0x1_00_00_00_00 +\n bytes[p + 5]! * 0x1_00_00_00 +\n bytes[p + 4]! * 0x1_00_00 +\n bytes[p + 3]! * 0x1_00 +\n bytes[p + 2]!\n const data = (bytes[p + 1]! << 8) | bytes[p]!\n if (block < minBlock || (block === minBlock && data < minData)) {\n minBlock = block\n minData = data\n found = true\n }\n }\n return found ? new VirtualOffset(minBlock, minData) : current\n}\n\nexport function parseNameBytes(namesBytes: Uint8Array) {\n const decoder = new TextDecoder('utf-8')\n const refIdToName: string[] = []\n const refNameToId: Record<string, number> = {}\n let currRefId = 0\n let pos = 0\n while (pos < namesBytes.length) {\n const end = namesBytes.indexOf(0, pos)\n if (end === -1) {\n break\n }\n if (end > pos) {\n const refName = decoder.decode(namesBytes.subarray(pos, end))\n refIdToName[currRefId] = refName\n refNameToId[refName] = currRefId\n }\n pos = end + 1\n currRefId++\n }\n return { refNameToId, refIdToName }\n}\n\nconst tabixFormats: Record<number, string> = {\n 0: 'generic',\n 1: 'SAM',\n 2: 'VCF',\n 3: 'GAF',\n}\n\nexport function parseAuxData(bytes: Uint8Array, offset: number) {\n const dataView = new DataView(\n bytes.buffer,\n bytes.byteOffset,\n bytes.byteLength,\n )\n const formatFlags = dataView.getInt32(offset, true)\n const coordinateType =\n formatFlags & 0x1_00_00 ? 'zero-based-half-open' : '1-based-closed'\n const format = tabixFormats[formatFlags & 0xf]\n if (!format) {\n throw new Error(`invalid Tabix preset format flags ${formatFlags}`)\n }\n const columnNumbers = {\n ref: dataView.getInt32(offset + 4, true),\n start: dataView.getInt32(offset + 8, true),\n end: dataView.getInt32(offset + 12, true),\n }\n const metaValue = dataView.getInt32(offset + 16, true)\n const metaChar = metaValue ? String.fromCharCode(metaValue) : undefined\n const skipLines = dataView.getInt32(offset + 20, true)\n const nameSectionLength = dataView.getInt32(offset + 24, true)\n const { refIdToName, refNameToId } = parseNameBytes(\n bytes.subarray(offset + 28, offset + 28 + nameSectionLength),\n )\n return {\n refIdToName,\n refNameToId,\n skipLines,\n metaChar,\n columnNumbers,\n format,\n coordinateType,\n }\n}\n\nexport function parsePseudoBin(bytes: Uint8Array, offset: number) {\n return { lineCount: longFromBytesToUnsigned(bytes, offset) }\n}\n\n// SYNC: ~/src/gmod/bam-js/src/indexFile.ts memoizeByRefId\nexport function memoizeByRefId<T>(\n getIndices: (refId: number) => T | undefined,\n maxSize = 5,\n): (refId: number) => T | undefined {\n const lru = new LRU<number, T>({ maxSize })\n return (refId: number) => {\n const cached = lru.get(refId)\n if (cached !== undefined) {\n return cached\n }\n const result = getIndices(refId)\n if (result !== undefined) {\n lru.set(refId, result)\n }\n return result\n }\n}\n", "import { unzip } from '@gmod/bgzf-filehandle'\nimport { SharedReadCache } from '@gmod/shared-read-cache'\n\nimport { optimizeChunks } from './util.ts'\n\nimport type Chunk from './chunk.ts'\nimport type VirtualOffset from './virtualOffset.ts'\nimport type { GenericFilehandle } from 'generic-filehandle2'\n\n/**\n * The virtual offset past which a coordinate-sorted file holds nothing\n * overlapping `[.., end)`, from the binning index alone: htslib's `max_off`\n * (`hts_itr_query` in hts.c).\n *\n * Walk right from the finest bin after the one holding `end - 1`, stepping up\n * to the parent at every first child, so each bin visited begins at or past\n * `end` and never overlaps the query. Every record in such a bin starts at or\n * past `end`, so the first chunk of the first bin that exists is a record past\n * the query, and in a sorted file so is every record after it.\n *\n * SYNC: ~/src/gmod/bam-js/src/indexFile.ts maxOffset, and see bam-js ADR 0023\n * for why the caller drops whole merged chunks with it rather than trimming.\n */\nexport function maxOffset(\n binIndex: Record<number, Chunk[]>,\n end: number,\n minShift: number,\n depth: number,\n) {\n if (end > 2 ** (minShift + depth * 3)) {\n return undefined\n }\n const binCount = (8 ** (depth + 1) - 1) / 7\n let bin = (8 ** depth - 1) / 7 + Math.floor((end - 1) / 2 ** minShift) + 1\n if (bin >= binCount) {\n bin = 0\n }\n for (;;) {\n while (bin % 8 === 1) {\n bin = (bin - 1) / 8\n }\n if (bin === 0) {\n return undefined\n }\n const chunks = binIndex[bin]\n if (chunks?.length) {\n let lowest = chunks[0]!.minv\n for (let i = 1; i < chunks.length; i++) {\n const minv = chunks[i]!.minv\n if (minv.compareTo(lowest) < 0) {\n lowest = minv\n }\n }\n return lowest\n }\n bin++\n }\n}\n\nexport interface Options {\n signal?: AbortSignal\n /**\n * Called as the index (.tbi/.csi) is downloaded, with cumulative downloaded\n * bytes and the total. The index is a whole-file read, so this streams real\n * byte progress. Lets callers show a determinate \"downloading index\" bar.\n */\n onProgress?: (bytesDownloaded: number, totalBytes?: number) => void\n}\n\nexport interface RefIndex {\n binIndex: Record<number, Chunk[]>\n stats?: { lineCount: number }\n linearIndex?: VirtualOffset[]\n /** CSI only: per-bin loffset, the linear index's equivalent for pruning */\n loffsets?: Record<number, VirtualOffset>\n}\n\nexport interface IndexData {\n refNameToId: Record<string, number>\n refIdToName: string[]\n metaChar: string | undefined\n columnNumbers: { ref: number; start: number; end: number }\n coordinateType: string\n format: string\n indices: (refId: number) => RefIndex | undefined\n maxRefLength: number\n skipLines?: number\n maxBlockSize: number\n firstDataLine?: VirtualOffset\n refCount?: number\n csi?: boolean\n csiVersion?: number\n /**\n * The binning scheme. TBI reports these too, though its own are fixed by the\n * format (minShift 14, depth 5) rather than read from the file: they are the\n * same scheme, and CSI exists to let a file choose other values for them.\n */\n minShift: number\n depth: number\n maxBinNumber: number\n}\n\n// htslib files every GAF record under ref 0 and ignores a query's name\nfunction refIdFor(indexData: IndexData, refName: string) {\n return indexData.format === 'GAF' ? 0 : indexData.refNameToId[refName]\n}\n\nexport default abstract class IndexFile {\n public filehandle: GenericFilehandle\n /**\n * The parsed index, as a shared read \u2014 see {@link parse}. One entry, never\n * evicted, which is what a memo is.\n */\n private parseCache = new SharedReadCache<string, IndexData>({})\n\n constructor({ filehandle }: { filehandle: GenericFilehandle }) {\n this.filehandle = filehandle\n }\n\n protected abstract _parse(opts: Options): Promise<IndexData>\n\n /**\n * The bins that may overlap [beg, end), as one inclusive [first, last] range\n * per level of the binning scheme.\n */\n protected abstract reg2bins(\n beg: number,\n end: number,\n indexData: IndexData,\n ): (readonly [number, number])[]\n\n /**\n * The earliest virtual offset any record overlapping `beg` can have, so that\n * chunks ending at or before it can be dropped. TBI reads it off the linear\n * index; CSI, which has none, off the bins' loffsets.\n */\n protected abstract lowestOffset(\n ref: RefIndex,\n beg: number,\n indexData: IndexData,\n ): VirtualOffset | undefined\n\n /**\n * The whole index file, decompressed, with a DataView over it. Both .tbi and\n * .csi are bgzf-compressed and read whole, so both parsers start here.\n */\n protected async readIndexBytes(opts: Options) {\n const buf = await this.filehandle.readFile({\n signal: opts.signal,\n onProgress: opts.onProgress,\n })\n const bytes = await unzip(buf)\n return {\n bytes,\n dataView: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength),\n }\n }\n\n /** @internal */\n public async lineCount(refName: string, opts: Options = {}) {\n const indexData = await this.parse(opts)\n const refId = refIdFor(indexData, refName)\n if (refId === undefined) {\n return -1\n }\n return indexData.indices(refId)?.stats?.lineCount ?? -1\n }\n\n /** @internal */\n public async getMetadata(opts: Options = {}) {\n const { indices: _indices, ...rest } = await this.parse(opts)\n return rest\n }\n\n /**\n * The chunks of the data file that may hold records overlapping the region.\n * The two index formats differ only in their binning scheme and in where\n * they keep the pruning floor, which is what the two hooks above supply.\n * The ceiling, `maxOffset`, needs only the bins, so it serves both.\n *\n * @internal\n */\n public async blocksForRange(\n refName: string,\n min: number,\n max: number,\n opts: Options = {},\n ) {\n const indexData = await this.parse(opts)\n const refId = refIdFor(indexData, refName)\n if (refId === undefined) {\n return []\n }\n const ba = indexData.indices(refId)\n if (!ba) {\n return []\n }\n // htslib indexes a GAF read as [minNode, maxNode), one short of the\n // [minNode, maxNode] that getLines matches, so look one node lower, as\n // `tabix` does for a region's 1-based start\n if (indexData.format === 'GAF') {\n min = Math.max(min - 1, 0)\n }\n\n // Find chunks in overlapping bins. Leaf bins are not pruned.\n const chunks: Chunk[] = []\n for (const [start, end] of this.reg2bins(min, max, indexData)) {\n for (let bin = start; bin <= end; bin++) {\n const binChunks = ba.binIndex[bin]\n if (binChunks) {\n for (const c of binChunks) {\n chunks.push(c)\n }\n }\n }\n }\n\n const merged = optimizeChunks(chunks, this.lowestOffset(ba, min, indexData))\n const past = maxOffset(\n ba.binIndex,\n max,\n indexData.minShift,\n indexData.depth,\n )\n if (past) {\n let n = merged.length\n while (n > 0 && merged[n - 1]!.minv.compareTo(past) >= 0) {\n n--\n }\n merged.length = n\n }\n return merged\n }\n\n // SYNC: ~/src/gmod/bam-js/src/indexFile.ts parse \u2014 same shape and the same\n // reasoning below.\n /**\n * Parse the index, or join the parse already running.\n *\n * The index is downloaded and parsed once for the life of this object, so it\n * is the one read here that is shared between queries \u2014 and therefore the one\n * place a cancellation can leak from the query that asked for it to a query\n * that did not. `_parse` hands `opts` straight to `readIndexBytes`, so a bare\n * memoized promise makes the first query to arrive the owner of a read every\n * other query depends on: when it pans away, every concurrent query fails\n * with its abort.\n *\n * The same cache `ChunkCache` uses, for the same reason and with the same\n * rule: the parse runs under a signal of its own and is cancelled only once\n * every caller waiting on it has given up, so one query's abort is reported\n * to that query alone and a bystander gets the parse already in flight rather\n * than having to re-read the index. A rejection is dropped rather than\n * cached, so a transient failure does not poison the index for the life of\n * the file.\n *\n * The fill is per call rather than on the cache so that the caller who starts\n * the parse has its `onProgress` reach `readIndexBytes` \u2014 the index is a\n * whole-file read, and a determinate \"downloading index\" bar is what that\n * callback exists for.\n *\n * @internal\n */\n parse(opts: Options = {}): Promise<IndexData> {\n return this.parseCache.get('index', opts.signal, signal =>\n this._parse({ ...opts, signal }),\n )\n }\n\n /** @internal */\n async hasRefSeq(seqId: number, opts: Options = {}) {\n const idx = await this.parse(opts)\n return !!idx.indices(seqId)?.binIndex\n }\n}\n", "import Chunk from './chunk.ts'\nimport IndexFile from './indexFile.ts'\nimport {\n clampChunkEnds,\n memoizeByRefId,\n minVirtualOffset,\n parseAuxData,\n parsePseudoBin,\n} from './util.ts'\nimport { fromBytes } from './virtualOffset.ts'\n\nimport type { IndexData, Options, RefIndex } from './indexFile.ts'\nimport type VirtualOffset from './virtualOffset.ts'\n\nconst CSI1_MAGIC = 21_582_659 // CSI\\1\nconst CSI2_MAGIC = 38_359_875 // CSI\\2\n\n// CSI coordinates can exceed 2^31, so bitwise << / >> (which truncate to int32)\n// are unsafe here; use multiplication/division instead.\nfunction lshift(num: number, bits: number) {\n return num * 2 ** bits\n}\nfunction rshift(num: number, bits: number) {\n return Math.floor(num / 2 ** bits)\n}\n\nexport default class CSI extends IndexFile {\n /** @internal */\n async _parse(opts: Options = {}) {\n const { bytes, dataView } = await this.readIndexBytes(opts)\n\n const magic = dataView.getUint32(0, true)\n let csiVersion\n if (magic === CSI1_MAGIC) {\n csiVersion = 1\n } else if (magic === CSI2_MAGIC) {\n csiVersion = 2\n } else {\n throw new Error(`Not a CSI file (magic=${magic})`)\n }\n\n const minShift = dataView.getInt32(4, true)\n const depth = dataView.getInt32(8, true)\n const maxBinNumber = (8 ** (depth + 1) - 1) / 7\n const maxRefLength = 2 ** (minShift + depth * 3)\n const auxLength = dataView.getInt32(12, true)\n // htslib names no references in a GAF index, so its aux is the bare\n // 28-byte header block\n const isGaf = auxLength >= 28 && (dataView.getInt32(16, true) & 0xf) === 3\n if (auxLength < 30 && !isGaf) {\n throw new Error(\n 'CSI index has no tabix header, so it names no references; it may be a BAM or BCF index',\n )\n }\n const aux = parseAuxData(bytes, 16)\n const refCount = dataView.getInt32(16 + auxLength, true)\n\n // SYNC: ~/src/gmod/bam-js/src/csi.ts _parse \u2014 two-pass structure\n // First pass: record per-refId byte offsets and find firstDataLine via loffsets\n let curr = 16 + auxLength + 4\n let firstDataLine: VirtualOffset | undefined\n const offsets: number[] = []\n\n for (let i = 0; i < refCount; i++) {\n offsets.push(curr)\n const binCount = dataView.getInt32(curr, true)\n curr += 4\n for (let j = 0; j < binCount; j++) {\n const bin = dataView.getUint32(curr, true)\n curr += 4\n if (bin > maxBinNumber) {\n curr += 28 + 16 // skip pseudo-bin (loffset + nchunk + 2 chunks)\n } else {\n firstDataLine = minVirtualOffset(bytes, curr, 1, firstDataLine)\n curr += 8 // loffset\n const chunkCount = dataView.getInt32(curr, true)\n curr += 4 + 16 * chunkCount\n }\n }\n }\n\n function getIndices(refId: number): RefIndex | undefined {\n const start = offsets[refId]\n if (start === undefined) {\n return undefined\n }\n let pos = start\n const binCount = dataView.getInt32(pos, true)\n pos += 4\n const binIndex: Record<number, Chunk[]> = {}\n const loffsets: Record<number, VirtualOffset> = {}\n let stats\n for (let j = 0; j < binCount; j++) {\n const bin = dataView.getUint32(pos, true)\n pos += 4\n if (bin > maxBinNumber) {\n stats = parsePseudoBin(bytes, pos + 28)\n pos += 28 + 16\n } else {\n loffsets[bin] = fromBytes(bytes, pos)\n pos += 8\n const chunkCount = dataView.getInt32(pos, true)\n pos += 4\n const chunks = Array.from<Chunk>({ length: chunkCount })\n for (let k = 0; k < chunkCount; k++) {\n chunks[k] = new Chunk(\n fromBytes(bytes, pos),\n fromBytes(bytes, pos + 8),\n bin,\n )\n pos += 16\n }\n binIndex[bin] = chunks\n }\n }\n clampChunkEnds(Object.values(binIndex).flat())\n return { binIndex, loffsets, stats }\n }\n\n return {\n ...aux,\n csi: true,\n refCount,\n maxBlockSize: 1 << 16,\n firstDataLine,\n csiVersion,\n indices: memoizeByRefId(getIndices),\n minShift,\n depth,\n maxBinNumber,\n maxRefLength,\n }\n }\n\n /**\n * CSI's equivalent of the BAI/TBI linear index: the loffset of the deepest\n * indexed bin covering `beg` is the earliest virtual offset any record\n * overlapping `beg` can have, so chunks ending at or before it are dead.\n * Walks leaf -> previous sibling -> parent until an indexed bin is found.\n * SYNC: htslib hts_itr_query min_off computation\n */\n protected lowestOffset(\n ref: RefIndex,\n beg: number,\n { minShift, depth }: IndexData,\n ) {\n const { loffsets } = ref\n let found: VirtualOffset | undefined\n if (loffsets) {\n // first bin of the deepest level, i.e. (8**depth - 1) / 7\n let bin =\n (lshift(1, 3 * depth) - 1) / 7 + rshift(Math.max(beg, 0), minShift)\n while (found === undefined && bin > 0) {\n found = loffsets[bin]\n if (found === undefined) {\n const parent = Math.floor((bin - 1) / 8)\n const firstChild = parent * 8 + 1\n bin = bin > firstChild ? bin - 1 : parent\n }\n }\n found ??= loffsets[0]\n }\n return found\n }\n\n protected reg2bins(\n beg: number,\n end: number,\n { minShift, depth, maxBinNumber }: IndexData,\n ) {\n beg = Math.max(beg, 0)\n const maxPos = 2 ** (minShift + depth * 3)\n if (end > maxPos) {\n end = maxPos\n }\n end -= 1\n let l = 0\n let t = 0\n let s = minShift + depth * 3\n const bins: (readonly [number, number])[] = []\n for (; l <= depth; s -= 3, t += lshift(1, l * 3), l += 1) {\n const b = t + rshift(beg, s)\n const e = t + rshift(end, s)\n if (e - b + bins.length > maxBinNumber) {\n throw new Error(\n `query ${beg}-${end} is too large for current binning scheme (shift ${minShift}, depth ${depth}), try a smaller query or a coarser index binning scheme`,\n )\n }\n bins.push([b, e] as const)\n }\n return bins\n }\n}\n", "import Chunk from './chunk.ts'\nimport IndexFile from './indexFile.ts'\nimport {\n clampChunkEnds,\n memoizeByRefId,\n minVirtualOffset,\n parseAuxData,\n parsePseudoBin,\n} from './util.ts'\nimport { fromBytes } from './virtualOffset.ts'\n\nimport type { Options, RefIndex } from './indexFile.ts'\nimport type VirtualOffset from './virtualOffset.ts'\n\nconst TBI_MAGIC = 21_578_324 // TBI\\1\n\n// TBI is always the fixed depth-5, 14-bit-leaf binning scheme\nconst TBI_DEPTH = 5\nconst TBI_MIN_SHIFT = 14\nconst TBI_MAX_REF_LENGTH = 2 ** (TBI_MIN_SHIFT + TBI_DEPTH * 3)\n\n// Clamp a query coordinate into the binning scheme's range. Past 2**31 the\n// int32 shifts below truncate and go negative, which would silently yield no\n// bins.\nfunction clampToRefLength(pos: number) {\n return Math.min(Math.max(pos, 0), TBI_MAX_REF_LENGTH)\n}\n\nexport default class TabixIndex extends IndexFile {\n /**\n * The bins that may overlap [beg, end) (zero-based half-open). TBI's scheme\n * is CSI's with minShift/depth fixed, so this is CSI's reg2bins with the\n * levels unrolled and its float shifts replaced by int32 ones.\n */\n protected reg2bins(beg: number, end: number) {\n if (beg > TBI_MAX_REF_LENGTH) {\n console.warn('querying outside of possible tabix range')\n }\n const b = clampToRefLength(beg)\n const e = Math.min(end, TBI_MAX_REF_LENGTH) - 1\n const bins: (readonly [number, number])[] = []\n if (b <= e) {\n bins.push(\n [0, 0],\n [1 + (b >> 26), 1 + (e >> 26)],\n [9 + (b >> 23), 9 + (e >> 23)],\n [73 + (b >> 20), 73 + (e >> 20)],\n [585 + (b >> 17), 585 + (e >> 17)],\n [4681 + (b >> 14), 4681 + (e >> 14)],\n )\n }\n return bins\n }\n\n /**\n * The linear index is monotonically non-decreasing, so the minimum virtual\n * offset for chunks that could overlap [beg, ...) is its entry for beg.\n * SYNC: ~/src/gmod/bam-js/src/bai.ts getLowestChunk\n */\n protected lowestOffset(ref: RefIndex, beg: number) {\n const linearIndex = ref.linearIndex\n return linearIndex?.[\n Math.min(clampToRefLength(beg) >> TBI_MIN_SHIFT, linearIndex.length - 1)\n ]\n }\n\n /** @internal */\n async _parse(opts: Options = {}) {\n const { bytes, dataView } = await this.readIndexBytes(opts)\n\n if (dataView.getUint32(0, true) !== TBI_MAGIC) {\n throw new Error('Not a TBI file')\n }\n\n const refCount = dataView.getUint32(4, true)\n const maxBinNumber = ((1 << ((TBI_DEPTH + 1) * 3)) - 1) / 7\n\n // TBI header layout matches CSI aux data; parseAuxData handles both\n const {\n refNameToId,\n refIdToName,\n coordinateType,\n format,\n columnNumbers,\n metaChar,\n skipLines,\n } = parseAuxData(bytes, 8)\n // nameSectionLength is at TBI offset 32; re-read to find where bin data starts\n const nameSectionLength = dataView.getInt32(32, true)\n\n // SYNC: ~/src/gmod/bam-js/src/bai.ts _parse \u2014 two-pass structure\n // First pass: record per-refId byte offsets and find firstDataLine.\n //\n // Only the linear index is consulted. Its entry for a window is the\n // smallest virtual offset of any record overlapping that window, so the\n // minimum over the linear index is already the minimum over the bin chunks\n // \u2014 walking the chunks too only re-derives it. Checked against every .tbi\n // in test/data: same answer on all 23, and no ref has bins without a\n // linear index.\n let curr = 36 + nameSectionLength\n let firstDataLine: VirtualOffset | undefined\n const offsets: number[] = []\n\n for (let i = 0; i < refCount; i++) {\n offsets.push(curr)\n const binCount = dataView.getInt32(curr, true)\n curr += 4\n for (let j = 0; j < binCount; j++) {\n const bin = dataView.getUint32(curr, true)\n curr += 4\n const chunkCount = dataView.getInt32(curr, true)\n curr += 4\n if (bin > maxBinNumber + 1) {\n throw new Error(\n 'tabix index contains too many bins, please use a CSI index',\n )\n }\n curr += 16 * chunkCount\n }\n const linearCount = dataView.getInt32(curr, true)\n curr += 4\n firstDataLine = minVirtualOffset(bytes, curr, linearCount, firstDataLine)\n curr += 8 * linearCount\n }\n\n function getIndices(refId: number): RefIndex | undefined {\n const start = offsets[refId]\n if (start === undefined) {\n return undefined\n }\n let pos = start\n const binCount = dataView.getInt32(pos, true)\n pos += 4\n const binIndex: Record<number, Chunk[]> = {}\n let stats\n for (let j = 0; j < binCount; j++) {\n const bin = dataView.getUint32(pos, true)\n pos += 4\n if (bin > maxBinNumber + 1) {\n throw new Error(\n 'tabix index contains too many bins, please use a CSI index',\n )\n } else if (bin === maxBinNumber + 1) {\n const chunkCount = dataView.getInt32(pos, true)\n pos += 4\n if (chunkCount === 2) {\n stats = parsePseudoBin(bytes, pos + 16)\n }\n pos += 16 * chunkCount\n } else {\n const chunkCount = dataView.getInt32(pos, true)\n pos += 4\n const chunks = Array.from<Chunk>({ length: chunkCount })\n for (let k = 0; k < chunkCount; k++) {\n chunks[k] = new Chunk(\n fromBytes(bytes, pos),\n fromBytes(bytes, pos + 8),\n bin,\n )\n pos += 16\n }\n binIndex[bin] = chunks\n }\n }\n const linearCount = dataView.getInt32(pos, true)\n pos += 4\n const linearIndex = Array.from<VirtualOffset>({ length: linearCount })\n for (let k = 0; k < linearCount; k++) {\n linearIndex[k] = fromBytes(bytes, pos)\n pos += 8\n }\n clampChunkEnds(\n Object.values(binIndex).flat(),\n linearIndex.map(v => v.blockPosition),\n )\n return { binIndex, linearIndex, stats }\n }\n\n return {\n indices: memoizeByRefId(getIndices),\n metaChar,\n minShift: TBI_MIN_SHIFT,\n depth: TBI_DEPTH,\n maxBinNumber,\n maxRefLength: TBI_MAX_REF_LENGTH,\n skipLines,\n firstDataLine,\n columnNumbers,\n coordinateType,\n format,\n refIdToName,\n refNameToId,\n maxBlockSize: 1 << 16,\n }\n }\n}\n", "import { unzip, unzipChunkSlice } from '@gmod/bgzf-filehandle'\nimport { SharedReadCache } from '@gmod/shared-read-cache'\nimport { LocalFile, RemoteFile } from 'generic-filehandle2'\n\nimport CSI from './csi.ts'\nimport TBI from './tbi.ts'\nimport { optimizeChunks } from './util.ts'\n\nimport type Chunk from './chunk.ts'\nimport type IndexFile from './indexFile.ts'\nimport type { Options } from './indexFile.ts'\nimport type { BgzfWorkerPool, ChunkSlice } from '@gmod/bgzf-filehandle'\nimport type { Budget } from '@gmod/shared-read-cache'\nimport type { GenericFilehandle } from 'generic-filehandle2'\n\nconst TAB = 9\nconst NEWLINE = 10\nconst CARRIAGE_RETURN = 13\nconst SEMICOLON = 59\nconst LESS_THAN = 60\nconst GREATER_THAN = 62\n\n// Ceiling on how many chunk reads getLines keeps in flight ahead of the one it\n// is parsing. Six is the HTTP/1.1 per-host connection cap browsers enforce, so\n// going much above it buys nothing on the transport that matters.\nconst MAX_READ_AHEAD_CHUNKS = 6\n\n// SYNC: ~/src/gmod/bam-js/src/bamFile.ts DEFAULT_MAX_CACHE_BYTES\n//\n// We fetch compressed and cache decompressed, and an entry is a whole chunk, so\n// entry count says nothing about memory. How little is easy to underestimate:\n// a dense VCF (test/data/1kg.chr1.subset.vcf.gz \u2014 213MB over 600kb of chr1)\n// has single index bins of 17MB compressed, 120MB decompressed. Panning it\n// under the old 80-entry cache peaked at 2GB RSS.\n//\n// That 120MB figure is also why this is no longer 100MB. A budget below one\n// query's working set does not cache less, it caches NOTHING: each entry is\n// evicted before the next pan can reuse it, so the hit rate is zero and the\n// decompress is paid again every time. On that same fixture, a six-window 50kb\n// pan measured 17 refills out of 17 \u2014 a total miss \u2014 at 100MB, against 0 at\n// 800MB, and 2596ms against 600ms. The working set plateaus at 497MB held, so\n// 1GB clears it with headroom and nothing above 800MB buys anything.\n//\n// Affordable as a ceiling only because of the idle timeout below: it is a peak\n// under panning, not a level a parked consumer holds. A small file is\n// unaffected either way, this being a ceiling and not an allocation.\nconst DEFAULT_CHUNK_CACHE_BYTES = 1024 * 2 ** 20\n\n// SYNC: ~/src/gmod/bam-js/src/bamFile.ts DEFAULT_CACHE_IDLE_TIMEOUT_MS\n//\n// Drop a chunk nothing has looked at for three minutes. The budget above is\n// only applied when a read settles, so it does nothing at all for a consumer\n// sitting still \u2014 and a genome browser holds one of these per track for as long\n// as the track is open. Timed from the last read, not the fetch, so panning\n// back and forth over one region never expires it.\nconst DEFAULT_CHUNK_CACHE_IDLE_TIMEOUT_MS = 3 * 60 * 1000\n\ntype GetLinesCallback = (\n line: string,\n fileOffset: number,\n start: number,\n end: number,\n) => void\n\ninterface GetLinesOpts {\n signal?: AbortSignal\n lineCallback: GetLinesCallback\n /**\n * Called as the chunks covering the query are fetched, with cumulative\n * downloaded bytes and the total bytes to fetch. One tick per chunk \u2014 the run\n * of BGZF blocks the index resolves a query to \u2014 including instant ticks for\n * chunks already cached. That is the natural unit here, since chunk byte\n * sizes are known up front from the index, which is what lets a caller render\n * a determinate progress bar rather than a spinner.\n */\n onProgress?: (bytesDownloaded: number, totalBytes?: number) => void\n}\n\n// The decompressed chunk plus its block offsets, as @gmod/bgzf-filehandle\n// returns them: cpositions/dpositions are Float64Arrays, which is what the\n// wasm decompressor produces, and only indexed reads and `.length` are used\n// here. Taken from the package rather than restated so the two can't drift.\ntype ReadChunk = ChunkSlice\n\nfunction resolveFilehandle(\n filehandle?: GenericFilehandle,\n path?: string,\n url?: string,\n) {\n if (filehandle) {\n return filehandle\n }\n if (path) {\n return new LocalFile(path)\n }\n if (url) {\n return new RemoteFile(url)\n }\n throw new TypeError('must provide either filehandle, path, or url')\n}\n\n// An explicitly supplied index always wins over the `<path>.tbi` /\n// `<url>.tbi` names derived from the data file, whichever kind it is.\nfunction resolveIndex({\n tbiFilehandle,\n csiFilehandle,\n tbiPath,\n csiPath,\n tbiUrl,\n csiUrl,\n path,\n url,\n}: {\n tbiFilehandle?: GenericFilehandle\n csiFilehandle?: GenericFilehandle\n tbiPath?: string\n csiPath?: string\n tbiUrl?: string\n csiUrl?: string\n path?: string\n url?: string\n}) {\n if (tbiFilehandle) {\n return new TBI({ filehandle: tbiFilehandle })\n }\n if (csiFilehandle) {\n return new CSI({ filehandle: csiFilehandle })\n }\n if (tbiPath) {\n return new TBI({ filehandle: new LocalFile(tbiPath) })\n }\n if (csiPath) {\n return new CSI({ filehandle: new LocalFile(csiPath) })\n }\n if (csiUrl) {\n return new CSI({ filehandle: new RemoteFile(csiUrl) })\n }\n if (tbiUrl) {\n return new TBI({ filehandle: new RemoteFile(tbiUrl) })\n }\n if (path) {\n return new TBI({ filehandle: new LocalFile(`${path}.tbi`) })\n }\n if (url) {\n return new TBI({ filehandle: new RemoteFile(`${url}.tbi`) })\n }\n throw new TypeError(\n 'must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl',\n )\n}\n\nfunction calculateFileOffset(\n cpositions: ArrayLike<number>,\n dpositions: ArrayLike<number>,\n pos: number,\n blockStart: number,\n minvDataPosition: number,\n) {\n return (\n cpositions[pos]! * (1 << 8) +\n (blockStart - dpositions[pos]!) +\n minvDataPosition +\n 1\n )\n}\n\nfunction getVcfEnd(\n buffer: Uint8Array,\n startCoordinate: number,\n refStart: number,\n refEnd: number,\n infoStart: number,\n infoEnd: number,\n altEnd: number,\n) {\n const refLen = refEnd - refStart\n let endCoordinate = startCoordinate + refLen\n let svlen = 0\n\n // INFO is '.', no fields to check\n if (buffer[infoStart] === 46) {\n return endCoordinate\n }\n\n // Single pass over semicolon-delimited fields checking prefixes.\n // Avoids repeated indexOf scans for common bytes like 'S' and 'E'\n // that produce many false positives in typical INFO fields.\n let fieldStart = infoStart\n for (let i = infoStart; i <= infoEnd; i++) {\n if (i === infoEnd || buffer[i] === SEMICOLON) {\n const fieldLen = i - fieldStart\n if (\n fieldLen >= 10 &&\n buffer[fieldStart] === 83 && // S\n buffer[fieldStart + 1] === 86 && // V\n buffer[fieldStart + 2] === 84 && // T\n buffer[fieldStart + 3] === 89 && // Y\n buffer[fieldStart + 4] === 80 && // P\n buffer[fieldStart + 5] === 69 && // E\n buffer[fieldStart + 6] === 61 && // =\n buffer[fieldStart + 7] === 84 && // T\n buffer[fieldStart + 8] === 82 && // R\n buffer[fieldStart + 9] === 65 // A\n ) {\n return startCoordinate + 1\n }\n if (\n fieldLen >= 4 &&\n buffer[fieldStart] === 69 && // E\n buffer[fieldStart + 1] === 78 && // N\n buffer[fieldStart + 2] === 68 && // D\n buffer[fieldStart + 3] === 61 // =\n ) {\n // an END at or before POS describes no span; htslib ignores it too\n const end = parseIntFromBytes(buffer, fieldStart + 4, i)\n if (end > startCoordinate) {\n endCoordinate = end\n }\n } else if (\n fieldLen >= 6 &&\n buffer[fieldStart] === 83 && // S\n buffer[fieldStart + 1] === 86 && // V\n buffer[fieldStart + 2] === 76 && // L\n buffer[fieldStart + 3] === 69 && // E\n buffer[fieldStart + 4] === 78 && // N\n buffer[fieldStart + 5] === 61 // =\n ) {\n svlen = maxSvlenOnRef(buffer, fieldStart + 6, i, refEnd + 1, altEnd)\n }\n fieldStart = i + 1\n }\n }\n return Math.max(endCoordinate, startCoordinate + svlen)\n}\n\nconst COMMA = 44\n\n/**\n * htslib's `svlen_on_ref_for_vcf_alt`: whether an ALT's SVLEN is a length on\n * the reference, which it is for <CNV>, <DEL>, <DUP>, <INV> and their subtypes.\n */\nfunction svlenSpansRef(buffer: Uint8Array, start: number, end: number) {\n if (end - start < 5 || buffer[start] !== 60 || buffer[end - 1] !== 62) {\n return false\n }\n const after = buffer[start + 4]\n if (after !== 62 && after !== 58) {\n return false\n }\n const a = buffer[start + 1]\n const b = buffer[start + 2]\n const c = buffer[start + 3]\n return (\n (a === 67 && b === 78 && c === 86) || // CNV\n (a === 68 && b === 69 && c === 76) || // DEL\n (a === 68 && b === 85 && c === 80) || // DUP\n (a === 73 && b === 78 && c === 86) // INV\n )\n}\n\n/**\n * The longest reference length the SVLEN values state, each read against the\n * ALT it pairs with, as htslib's tbx_parse1 does.\n */\nfunction maxSvlenOnRef(\n buffer: Uint8Array,\n valuesStart: number,\n valuesEnd: number,\n altStart: number,\n altEnd: number,\n) {\n let max = 0\n let value = valuesStart\n let alt = altStart\n while (value < valuesEnd && alt < altEnd) {\n let valueEnd = buffer.indexOf(COMMA, value)\n if (valueEnd === -1 || valueEnd > valuesEnd) {\n valueEnd = valuesEnd\n }\n let alleleEnd = buffer.indexOf(COMMA, alt)\n if (alleleEnd === -1 || alleleEnd > altEnd) {\n alleleEnd = altEnd\n }\n if (svlenSpansRef(buffer, alt, alleleEnd)) {\n const len = parseIntFromBytes(\n buffer,\n buffer[value] === 45 ? value + 1 : value,\n valueEnd,\n )\n if (len > max) {\n max = len\n }\n }\n value = valueEnd + 1\n alt = alleleEnd + 1\n }\n return max\n}\n\nconst textDecoder = new TextDecoder()\n\n/**\n * The leading run of meta-character lines \u2014 what `tabix -H` prints. Everything\n * from the first line that doesn't begin with the meta character is dropped.\n */\nfunction trimToMetaLines(bytes: Uint8Array, metaChar: string) {\n let lastNewline = -1\n const metaByte = metaChar.charCodeAt(0)\n\n for (let i = 0, l = bytes.length; i < l; i++) {\n const byte = bytes[i]\n if (i === lastNewline + 1 && byte !== metaByte) {\n break\n }\n if (byte === NEWLINE) {\n lastNewline = i\n }\n }\n return bytes.subarray(0, lastNewline + 1)\n}\n\n/**\n * The first `count` lines. Scans for the count-th newline and decodes only that\n * far, rather than decoding and splitting the whole buffer to keep its first\n * few lines \u2014 the buffer runs to the first data line, which for a file with a\n * long commented preamble above its counted rows can be megabytes.\n */\nfunction firstLines(bytes: Uint8Array, count: number) {\n let end = 0\n for (let i = 0; i < count; i++) {\n const n = bytes.indexOf(NEWLINE, end)\n if (n === -1) {\n end = bytes.length\n break\n }\n end = n + 1\n }\n return textDecoder\n .decode(bytes.subarray(0, end))\n .split(/\\r?\\n/)\n .slice(0, count)\n}\n\nfunction parseIntFromBytes(buffer: Uint8Array, start: number, end: number) {\n let val = 0\n for (let i = start; i < end; i++) {\n const c = buffer[i]!\n if (c >= 48 && c <= 57) {\n val = val * 10 + (c - 48)\n } else {\n break\n }\n }\n return val\n}\n\ninterface GafQuery {\n start: number\n end: number\n pathCol: number\n metaCharCode: number | undefined\n decoder: TextDecoder\n callback: GetLinesCallback\n}\n\n/**\n * The GAF scan of one chunk. A read spans the lowest to the highest node id on\n * its path, which htslib's tbx_parse1 reads the same way. Returns true once a\n * read starts at or past `end`: records are sorted by their lowest node.\n */\nfunction scanGafChunk(\n buffer: Uint8Array,\n cpositions: ArrayLike<number>,\n dpositions: ArrayLike<number>,\n minvDataPosition: number,\n { start, end, pathCol, metaCharCode, decoder, callback }: GafQuery,\n) {\n let blockStart = 0\n let pos = 0\n while (blockStart < buffer.length) {\n const n = buffer.indexOf(NEWLINE, blockStart)\n if (n === -1) {\n break\n }\n const lineStart = blockStart\n blockStart = n + 1\n\n const target = lineStart + minvDataPosition\n while (pos < dpositions.length && target >= dpositions[pos]!) {\n pos++\n }\n if (buffer[lineStart] === metaCharCode) {\n continue\n }\n\n let pathStart = lineStart\n for (let i = 1; i < pathCol; i++) {\n const t = buffer.indexOf(TAB, pathStart)\n if (t === -1 || t >= n) {\n pathStart = n\n break\n }\n pathStart = t + 1\n }\n // A path without a leading step is a stable sequence name (or `*`), which\n // carries no node ids. htslib parses one anyway and indexes garbage\n // (`GRCh38#0#chr1` as nodes 0..38), so skip it rather than match that.\n const first = buffer[pathStart]\n if (first !== GREATER_THAN && first !== LESS_THAN) {\n continue\n }\n let pathEnd = buffer.indexOf(TAB, pathStart)\n if (pathEnd === -1 || pathEnd > n) {\n pathEnd = n\n }\n\n // like htslib, skip one byte (the orientation) before each node id\n let min = Infinity\n let max = -1\n let i = pathStart\n while (i < pathEnd) {\n let id = 0\n let j = i + 1\n for (; j < pathEnd; j++) {\n const digit = buffer[j]! - 48\n if (digit < 0 || digit > 9) {\n break\n }\n id = id * 10 + digit\n }\n if (id < min) {\n min = id\n }\n if (id > max) {\n max = id\n }\n i = j\n }\n\n if (min >= end) {\n return true\n }\n if (max >= start) {\n const lineEnd = buffer[n - 1] === CARRIAGE_RETURN ? n - 1 : n\n callback(\n decoder.decode(buffer.subarray(lineStart, lineEnd)),\n calculateFileOffset(\n cpositions,\n dpositions,\n pos,\n lineStart,\n minvDataPosition,\n ),\n min,\n max + 1,\n )\n }\n }\n return false\n}\n\n/**\n * Reads Tabix-indexed files (bgzipped), supporting both .tbi and .csi index formats.\n */\nexport default class TabixIndexedFile {\n private filehandle: GenericFilehandle\n private index: IndexFile\n public chunkCache: SharedReadCache<Chunk, ReadChunk>\n /**\n * The parsed header, as a shared read \u2014 see {@link getParsedHeader}. One\n * entry, never evicted, which is what a memo is.\n */\n private headerCache = new SharedReadCache<\n string,\n { header: string; skippedLines: string[] }\n >({})\n\n /** see the constructor option of the same name */\n private bgzfWorkerPool?:\n BgzfWorkerPool | Promise<BgzfWorkerPool | undefined> | undefined\n\n constructor({\n path,\n filehandle,\n url,\n tbiPath,\n tbiUrl,\n tbiFilehandle,\n csiPath,\n csiUrl,\n csiFilehandle,\n chunkCacheSize = DEFAULT_CHUNK_CACHE_BYTES,\n chunkCacheIdleTimeoutMs = DEFAULT_CHUNK_CACHE_IDLE_TIMEOUT_MS,\n chunkCacheBudget,\n bgzfWorkerPool,\n }: {\n path?: string\n filehandle?: GenericFilehandle\n url?: string\n tbiPath?: string\n tbiUrl?: string\n tbiFilehandle?: GenericFilehandle\n csiPath?: string\n csiUrl?: string\n csiFilehandle?: GenericFilehandle\n /**\n * Budget for the decompressed chunk cache, in bytes. Default 1GB.\n *\n * **The unit changed in v3.5.2** (ADR 0001). Before that this was divided\n * by 64KB to get an entry count, so a caller passing `50 * 2**20` was\n * asking for 800 whole decompressed chunks \u2014 unbounded in practice. It now\n * means 50MB, twenty times under the default, and the name did not change\n * so nothing warns. If you pinned a value here before v3.5.2, it does not\n * mean what it did.\n *\n * What that costs is worth keeping, because it is the reason to check a\n * pinned value rather than assume it is harmless: jbrowse passed exactly\n * `50 * 2**20` in nine adapters, and measured on\n * `test/data/1kg.chr1.subset.vcf.gz` that was a **total miss** \u2014 47 refills\n * out of 47 on the warm pass against 0 at the default, holding 82.7MB in a\n * single entry, over the budget it was given because the last settled entry\n * is kept whatever the budget. Those nine adapters now pass\n * `chunkCacheBudget` and no `chunkCacheSize` at all, so that particular\n * instance is gone; the trap it demonstrates is not.\n *\n * A retention bound, not a bound on peak memory: reads in flight are never\n * evicted and the last settled entry is kept whatever the budget. Size it\n * to hold several queries \u2014 below one query's working set the hit rate\n * drops to zero while the memory is retained anyway, so a number between\n * the two is the worst available choice.\n */\n chunkCacheSize?: number\n /**\n * Drop a cached chunk once nothing has read it for this many milliseconds.\n * Default 3 minutes; `0` keeps chunks until `chunkCacheSize` evicts them.\n *\n * The only thing that lowers the cache while nothing is happening, and what\n * makes the budget above a peak rather than a resting level.\n */\n chunkCacheIdleTimeoutMs?: number\n /**\n * A budget shared with other files, so that the ceiling applies to their\n * sum rather than to each of them. Any `@gmod/shared-read-cache` consumer\n * that weighs in the same unit can join it: `@gmod/bam` also weighs\n * decompressed bytes, while `@gmod/cram` weighs decoded records and\n * `@gmod/bbi` weighs entries, and a budget mixing those adds bytes to\n * records and bounds neither.\n *\n * {@link chunkCacheSize} is per file, which is not a bound on a consumer\n * that opens one file per track. @gmod/bam measured the shape: six tracks\n * browsing six windows retained 1442 MB with every cache still under its\n * own ceiling, so the ceiling was not holding the line and nothing else\n * was. The idle timeout cannot help there \u2014 it does nothing while the\n * reader is browsing, which is the whole case.\n *\n * Dividing {@link chunkCacheSize} by the track count instead reintroduces\n * the cliff it exists to avoid. A shared budget does not, because a member\n * yields only what is globally least-recently-used: files nobody is\n * reading hand their space to the one being panned.\n */\n chunkCacheBudget?: Budget\n /**\n * A `@gmod/bgzf-filehandle` worker pool to inflate this file's chunks on,\n * instead of inflating them on the calling thread.\n *\n * BGZF decompression dominates a cold query and BGZF blocks are\n * independently inflatable, so this is the one remaining lever of that\n * size. @gmod/bam measured 1.95x end to end wiring the same pool into a\n * genome browser's read path.\n *\n * Accepts the promise `getSharedWorkerPool()` returns as well as a pool,\n * so a caller whose own construction is synchronous can hand the pending\n * pool straight over \u2014 it is awaited at the point of use, by which time it\n * has long since resolved. `undefined` (which is what that helper gives\n * back under node, or anywhere Workers cannot be created) keeps the\n * in-process path, so this is safe to pass unconditionally.\n */\n bgzfWorkerPool?:\n BgzfWorkerPool | Promise<BgzfWorkerPool | undefined> | undefined\n }) {\n this.bgzfWorkerPool = bgzfWorkerPool\n this.filehandle = resolveFilehandle(filehandle, path, url)\n this.index = resolveIndex({\n tbiFilehandle,\n csiFilehandle,\n tbiPath,\n csiPath,\n tbiUrl,\n csiUrl,\n path,\n url,\n })\n\n this.chunkCache = new SharedReadCache<Chunk, ReadChunk>({\n maxSize: chunkCacheSize,\n // decompressed bytes, not entry count: we fetch compressed and cache\n // decompressed, and an entry is a whole chunk\n sizeOf: read => read.buffer.byteLength,\n cacheKey: chunk => chunk.toString(),\n idleTimeoutMs: chunkCacheIdleTimeoutMs,\n budget: chunkCacheBudget,\n fill: (chunk, signal) => this.readChunk(chunk, { signal }),\n })\n }\n\n /**\n * Drops every decompressed chunk held by the cache, and stops the idle sweep\n * until something is cached again.\n *\n * `chunkCacheIdleTimeoutMs` reclaims a view the user has wandered away from;\n * this is for a consumer that knows it is finished \u2014 a closed track, a\n * changed assembly \u2014 and should not have to wait it out.\n */\n clearChunkCache() {\n this.chunkCache.clear()\n }\n\n /**\n * Estimates the compressed byte size of the index chunks covering the given\n * regions. Useful for byte budgeting before issuing a `getLines` call to\n * decide whether a region is too large to fetch.\n */\n async bytesForRegions(\n regions: { refName: string; start: number; end: number }[],\n opts: Options = {},\n ) {\n const all: Chunk[] = []\n for (const { refName, start, end } of regions) {\n const chunks = await this.index.blocksForRange(refName, start, end, opts)\n for (const chunk of chunks) {\n all.push(chunk)\n }\n }\n let bytes = 0\n for (const chunk of optimizeChunks(all)) {\n bytes += chunk.fetchedSize()\n }\n return bytes\n }\n\n /**\n * @param refName name of the reference sequence\n * @param s start of the region (0-based half-open)\n * @param e end of the region (0-based half-open)\n * @param opts callback invoked for each line, or an options object with `lineCallback` and optional `signal`\n */\n async getLines(\n refName: string,\n s: number | undefined,\n e: number | undefined,\n opts: GetLinesOpts | GetLinesCallback,\n ) {\n let signal: AbortSignal | undefined\n let options: Options = {}\n let callback: GetLinesCallback\n let onProgress: GetLinesOpts['onProgress']\n\n if (typeof opts === 'function') {\n callback = opts\n } else {\n options = opts\n callback = opts.lineCallback\n signal = opts.signal\n onProgress = opts.onProgress\n }\n\n const metadata = await this.index.getMetadata(options)\n const start = s ?? 0\n const end = e ?? metadata.maxRefLength\n if (start > end) {\n throw new TypeError(\n 'invalid start and end coordinates. start must be less than or equal to end',\n )\n }\n if (start === end) {\n return\n }\n\n const chunks = await this.index.blocksForRange(refName, start, end, options)\n\n const isVCF = metadata.format === 'VCF'\n const refCol = metadata.columnNumbers.ref || 0\n const startCol = metadata.columnNumbers.start || 0\n const endCol = isVCF ? 8 : metadata.columnNumbers.end || 0\n const maxColumn = Math.max(refCol, startCol, endCol)\n const metaCharCode = metadata.metaChar?.charCodeAt(0)\n const coordinateOffset =\n metadata.coordinateType === '1-based-closed' ? -1 : 0\n\n const encoder = new TextEncoder()\n const decoder = new TextDecoder()\n const regionRefNameBytes = encoder.encode(refName)\n // tabs[N] holds the byte offset of the N-th tab on the current line; with\n // the sentinel tabs[0] = blockStart - 1, column N spans tabs[N-1]+1..tabs[N]\n const tabs = new Int32Array(maxColumn + 1)\n const gaf: GafQuery | undefined =\n metadata.format === 'GAF'\n ? { start, end, pathCol: startCol, metaCharCode, decoder, callback }\n : undefined\n\n let totalBytes = 0\n for (const c of chunks) {\n totalBytes += c.fetchedSize()\n }\n let downloadedBytes = 0\n onProgress?.(0, totalBytes)\n\n // Read ahead, but only as far as the scan has earned. Every chunk is its\n // own range request, so a query spanning many of them pays a network round\n // trip apiece, serially \u2014 for a remote file that dominates, well ahead of\n // decompression (1kg.chr1 over a 1Mb window reads 22 chunks in a row).\n //\n // A fixed window would be wrong, though: blocksForRange offers a chunk per\n // overlapping bin across every level, and on a sparse file the early return\n // below can stop the scan inside the first one, leaving the rest untouched.\n // max_off drops only the chunks it can prove lie past the query, so the\n // scan can still end before the last one it is offered. Prefetching those\n // would multiply the bytes such a query fetches for no gain.\n //\n // Finishing a chunk without hitting the early return proves the next chunk\n // has to be examined, so the window starts at one and doubles per chunk\n // consumed. A query that stops in its first chunk issues exactly the reads\n // a sequential scan did; a long scan reaches full concurrency after three.\n let readAhead = 1\n const reads: Promise<ReadChunk>[] = []\n const ensureReadsStarted = (count: number) => {\n while (reads.length < Math.min(count, chunks.length)) {\n const c = chunks[reads.length]!\n const read = this.chunkCache.get(c, signal)\n void read.catch(() => {\n // a prefetch the early return skips is never awaited, so swallow its\n // rejection here rather than let it surface unhandled\n })\n reads.push(read)\n }\n }\n ensureReadsStarted(1)\n\n for (let ci = 0, cl = chunks.length; ci < cl; ci++) {\n const c = chunks[ci]!\n const { buffer, cpositions, dpositions } = await reads[ci]!\n downloadedBytes += c.fetchedSize()\n onProgress?.(downloadedBytes, totalBytes)\n const minvDataPosition = c.minv.dataPosition\n\n if (gaf) {\n if (\n scanGafChunk(buffer, cpositions, dpositions, minvDataPosition, gaf)\n ) {\n return\n }\n } else {\n let blockStart = 0\n let pos = 0\n\n while (blockStart < buffer.length) {\n const n = buffer.indexOf(NEWLINE, blockStart)\n if (n === -1) {\n break\n }\n\n const target = blockStart + minvDataPosition\n while (pos < dpositions.length && target >= dpositions[pos]!) {\n pos++\n }\n\n // skip meta lines\n if (\n metaCharCode !== undefined &&\n buffer[blockStart] === metaCharCode\n ) {\n blockStart = n + 1\n continue\n }\n\n // find tab positions. Columns past the end of the line all get `n`\n // rather than breaking out, which would leave stale offsets from the\n // previous line in the tail of the array.\n tabs[0] = blockStart - 1\n for (let i = 0; i < maxColumn; i++) {\n const prev = tabs[i]!\n const tabPos = prev < n ? buffer.indexOf(TAB, prev + 1) : -1\n tabs[i + 1] = tabPos === -1 || tabPos >= n ? n : tabPos\n }\n\n // compare ref name bytes directly\n const refStart = tabs[refCol - 1]! + 1\n const refEnd = tabs[refCol]!\n const refLen = refEnd - refStart\n if (refLen !== regionRefNameBytes.length) {\n blockStart = n + 1\n continue\n }\n let isRefMatch = true\n for (let i = 0; i < refLen; i++) {\n if (buffer[refStart + i] !== regionRefNameBytes[i]) {\n isRefMatch = false\n break\n }\n }\n if (!isRefMatch) {\n blockStart = n + 1\n continue\n }\n\n // parse start coordinate\n const startCoordinate =\n parseIntFromBytes(\n buffer,\n tabs[startCol - 1]! + 1,\n tabs[startCol]!,\n ) + coordinateOffset\n\n if (startCoordinate >= end) {\n return\n }\n\n // parse end coordinate\n let endCoordinate: number\n if (endCol === 0 || endCol === startCol) {\n endCoordinate = startCoordinate + 1\n } else if (isVCF) {\n endCoordinate = getVcfEnd(\n buffer,\n startCoordinate,\n tabs[3]! + 1,\n tabs[4]!,\n tabs[endCol - 1]! + 1,\n tabs[endCol]!,\n tabs[5]!,\n )\n } else {\n endCoordinate = parseIntFromBytes(\n buffer,\n tabs[endCol - 1]! + 1,\n tabs[endCol]!,\n )\n }\n\n if (endCoordinate > start) {\n // trim a CRLF terminator, matching htslib's line reader\n const lineEnd = buffer[n - 1] === CARRIAGE_RETURN ? n - 1 : n\n const line = decoder.decode(buffer.subarray(blockStart, lineEnd))\n callback(\n line,\n calculateFileOffset(\n cpositions,\n dpositions,\n pos,\n blockStart,\n minvDataPosition,\n ),\n startCoordinate,\n endCoordinate,\n )\n }\n blockStart = n + 1\n }\n }\n\n // every line in this chunk was still inside the query, so the next chunk\n // has to be examined too - widen the window and start the reads for it\n readAhead = Math.min(readAhead * 2, MAX_READ_AHEAD_CHUNKS)\n ensureReadsStarted(ci + 1 + readAhead)\n }\n }\n\n async getMetadata(opts: Options = {}) {\n return this.index.getMetadata(opts)\n }\n\n /**\n * The file's leading blocks, decompressed: everything from the start through\n * the end of the block holding the first data line.\n */\n private async readHeaderBytes(opts: Options) {\n const { firstDataLine, maxBlockSize } = await this.getMetadata(opts)\n\n const maxFetch = (firstDataLine?.blockPosition ?? 0) + maxBlockSize\n // TODO: what if we don't have a firstDataLine, and the header actually\n // takes up more than one block? this case is not covered here\n\n const buf = await this.filehandle.read(maxFetch, 0, opts)\n return unzip(buf)\n }\n\n /**\n * Both header forms, from one read of the same bytes: the commented block\n * `tabix -H` prints, and the rows `tabix -S N` counted.\n *\n * Memoized, because asking for one and then the other is the normal way to\n * find a header whichever way the file keeps it (see `getHeaderLines`), and\n * that used to fetch and decompress the file's leading blocks twice. Only\n * the parsed results are retained \u2014 the decompressed bytes are dropped,\n * which matters for a VCF header that can run to megabytes.\n */\n private async parseHeader(opts: Options) {\n const { metaChar, skipLines = 0 } = await this.getMetadata(opts)\n const bytes = await this.readHeaderBytes(opts)\n return {\n header: textDecoder.decode(\n metaChar ? trimToMetaLines(bytes, metaChar) : bytes,\n ),\n skippedLines: skipLines > 0 ? firstLines(bytes, skipLines) : [],\n }\n }\n\n /**\n * Parse the header, or join the parse already running.\n *\n * `parseHeader` threads `opts` into both `getMetadata` and the header read,\n * so memoizing it on the first caller's opts put that caller's signal in\n * charge of a read every later caller joins: when it aborted, they failed\n * with its cancellation, their own signals untouched.\n *\n * The same cache the chunk reads use, and the same rule: the parse runs under\n * a signal of its own and is cancelled only once every caller waiting on it\n * has given up, so one caller's abort is reported to that caller alone and a\n * bystander gets the parse already in flight. There is no retry here because\n * there is nothing to retry \u2014 the parse a bystander joined is not cancelled by\n * someone else's abort. A rejection is dropped rather than cached, so a\n * transient failure does not poison the header for the life of the file.\n *\n * The fill is per call rather than on the cache, so the caller that starts the\n * parse has its `onProgress` reach the index download inside `getMetadata`.\n *\n * SYNC: ~/src/gmod/bam-js/src/bamFile.ts getHeader \u2014 same shape for the same\n * reason, on the header rather than the index.\n */\n private getParsedHeader(opts: Options = {}) {\n return this.headerCache.get('header', opts.signal, signal =>\n this.parseHeader({ ...opts, signal }),\n )\n }\n\n /**\n * The bytes of the commented header. Deliberately not memoized, unlike the\n * string form: this hands back the buffer, and holding one for the lifetime\n * of the file is the caller's decision to make.\n */\n async getHeaderBuffer(opts: Options = {}) {\n const { metaChar } = await this.getMetadata(opts)\n const bytes = await this.readHeaderBytes(opts)\n return metaChar ? trimToMetaLines(bytes, metaChar) : bytes\n }\n\n /**\n * The leading lines the index says to skip \u2014 `tabix -S N` \u2014 which is where a\n * file whose header row is not commented keeps it. Empty when the index\n * records no skipped lines.\n *\n * Deliberately not part of `getHeader`. htslib draws the same distinction:\n * its indexer treats a line as non-data when `lineno <= line_skip` OR it\n * begins with the meta character (tbx.c), while `tabix -H` prints only the\n * leading meta-character lines and never consults line_skip (tabix.c).\n * `getHeader` mirrors `-H`, so a bare header row is absent from it, and\n * callers that need one were left re-reading the file themselves \u2014 guessing\n * at a read size, and unable to tell a headerless file from an uncommented\n * one. PLINK `.ld`, bedGraph and BED deflines are all routinely written this\n * way.\n */\n async getSkippedLines(opts: Options = {}) {\n const { skipLines = 0 } = await this.getMetadata(opts)\n // the index already answers this without reading the file at all\n if (skipLines <= 0) {\n return []\n }\n return (await this.getParsedHeader(opts)).skippedLines\n }\n\n async getHeader(opts: Options = {}) {\n return (await this.getParsedHeader(opts)).header\n }\n\n /**\n * The file's header lines, however that file keeps them: the meta-character\n * block when there is one, and otherwise the rows the index counted. Empty\n * lines are dropped.\n *\n * The two halves answer different questions (see `getSkippedLines`), but\n * \"what are this file's header lines\" is nearly always the question a caller\n * actually has, and answering it from `getHeader` alone is wrong in a way\n * that doesn't announce itself: a bare header row comes back as the empty\n * string, indistinguishable from a file that has no header, so callers fall\n * back to an assumed column layout and quietly mis-name columns. Deciding it\n * here also means one read of the leading blocks instead of two.\n */\n async getHeaderLines(opts: Options = {}) {\n const { header, skippedLines } = await this.getParsedHeader(opts)\n return (header ? header.split(/\\r?\\n/) : skippedLines).filter(Boolean)\n }\n\n async getReferenceSequenceNames(opts: Options = {}) {\n const metadata = await this.getMetadata(opts)\n return metadata.refIdToName\n }\n\n /** @param refName reference sequence name */\n async lineCount(refName: string, opts: Options = {}) {\n return this.index.lineCount(refName, opts)\n }\n\n /** @internal */\n async readChunk(c: Chunk, opts: Options = {}) {\n const ret = await this.filehandle.read(\n c.fetchedSize(),\n c.minv.blockPosition,\n opts,\n )\n // Awaited rather than stored resolved: the pool is commonly handed over as\n // the pending promise from getSharedWorkerPool(), and awaiting an\n // already-settled promise costs a microtask.\n const pool = await this.bgzfWorkerPool\n return unzipChunkSlice(ret, c, pool)\n }\n}\n", "import { TabixIndexedFile } from '@gmod/tabix'\nimport {\n panSNContig,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { ConfigurationSchema } from '@jbrowse/core/configuration'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { openLocation, openTabixIndexFilehandle } from '@jbrowse/core/util/io'\nimport { refNameLookup, resolveRefName } from '@jbrowse/graph-walks'\nimport { types } from '@jbrowse/mobx-state-tree'\n\nimport { bytesForRegions } from './tabixRange.ts'\n\nimport type {\n BaseFeatureDataAdapter,\n BaseOptions,\n} from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Region } from '@jbrowse/core/util/types'\n\n// What a tabix-indexed graph track answers about its own reference names, for\n// the two adapters that read one: `RgfaTabixAdapter` over segments and links,\n// and `MinigraphBubbleAdapter` over bubbles. @jbrowse/graph-walks builds the\n// name lookup.\n//\n// A class rather than a base class, for the reason ComparativeAdapterBase.ts\n// records: a base generic over the config cannot prove a slot name to\n// `getConf`, so the adapter\n// keeps the two lines that read its own slots and hands over the file. Reading\n// `assemblyNameToPanSN` IS hoistable, because every schema here declares it and\n// `resolvePanSNPrefix` is already generic over the base adapter type.\n\n// Tabix's own cache, per file. Large because a graph query is a scattered read\n// over a small index: the segment and link files for a 5 Mb window are tens of\n// kB of compressed blocks, and re-fetching them per pan is the cost this avoids.\nconst CHUNK_CACHE_SIZE = 50 * 2 ** 20\n\n// A file slot whose default is a url, '' for none\nexport const fileLocationSlot = (uri: string) => ({\n type: 'fileLocation' as const,\n defaultValue: { uri, locationType: 'UriLocation' },\n})\n\n/**\n * The index slot `openTabixSlot` reads: its own `location` and `indexType`\n */\nexport const tabixIndexSchema = (name: string, defaultUri = '') =>\n ConfigurationSchema(name, {\n /**\n * #slot\n */\n indexType: {\n model: types.enumeration('IndexType', ['TBI', 'CSI']),\n type: 'stringEnum',\n defaultValue: 'TBI',\n },\n /**\n * #slot\n */\n location: fileLocationSlot(defaultUri),\n })\n\n// The index slot's snapshot for a file whose `.tbi`, or `.csi`, sits beside it\nexport function tbiBeside(uri: string, baseUri: unknown, csi: unknown) {\n return {\n indexType: csi ? 'CSI' : 'TBI',\n location: { uri: `${uri}.${csi ? 'csi' : 'tbi'}`, baseUri },\n }\n}\n\n// The `walksUri` shorthand: `<walksUri>.walks.bed.gz` and its index\nexport function walksLocations(snap: Record<string, unknown>) {\n const { walksUri, baseUri, csi } = snap\n if (typeof walksUri !== 'string') {\n return snap\n }\n const walks = `${walksUri}.walks.bed.gz`\n return {\n ...snap,\n walksLocation: { uri: walks, baseUri },\n walksIndex: tbiBeside(walks, baseUri, csi),\n }\n}\n\n// One indexed file from the pair of slots that names it: the data location, and\n// an index slot holding its own `location` and `indexType`. Paths, so the pair\n// can sit in a sub-schema.\nexport function openTabixSlot(\n adapter: BaseFeatureDataAdapter,\n location: string[],\n index: string[],\n) {\n const pm = adapter.pluginManager\n return new TabixIndexedFile({\n filehandle: openLocation(adapter.getConf(location), pm),\n ...openTabixIndexFilehandle(\n adapter.getConf([...index, 'location']),\n adapter.getConf([...index, 'indexType']),\n pm,\n ),\n chunkCacheSize: CHUNK_CACHE_SIZE,\n })\n}\n\n/**\n * The reference-name half of a tabix graph track, against one indexed file.\n *\n * Constructed with the file the adapter's own slots opened, so this never reads\n * a slot whose name it cannot prove.\n */\nexport class PanSNRefNames {\n // Read once and shared by every query, so it takes on no caller's signal: a\n // track fetch the user panned away from once aborted the read a graph cut\n // was waiting on. cachedSetup rejects only the caller that aborts, keeps the\n // read going for the rest, and retries a failed read.\n private lookup = cachedSetup({\n setup: async opts =>\n refNameLookup(await this.file.getReferenceSequenceNames(opts)),\n })\n\n constructor(\n private file: TabixIndexedFile,\n private adapter: BaseFeatureDataAdapter,\n ) {}\n\n /**\n * The names the ASSEMBLY uses, not the graph's own.\n *\n * A minigraph graph's stable names are already bare (`chr6`) and pass\n * straight through; a Minigraph-Cactus graph's are PanSN, and returning\n * `GRCh38#0#chr6` here makes JBrowse decide the track has no data for `chr6`\n * and never query it \u2014 the graph view still worked, because it resolves per\n * region rather than through this list, which is exactly how the empty tracks\n * were spotted.\n */\n async assemblyRefNames(opts: BaseOptions = {}) {\n const names = await this.file.getReferenceSequenceNames(opts)\n const prefix = resolvePanSNPrefix(this.adapter, opts.assemblyName)\n const contigs = names\n .filter(n => panSNMatchesPrefix(n, prefix))\n .map(n => panSNContig(n))\n return contigs.length > 0 ? [...new Set(contigs)] : names\n }\n\n /**\n * The file's own stable name for a region, or undefined when it holds no\n * sequence answering to it.\n *\n * The graph's stable names may be PanSN (`GRCh38#0#chr1`), in which case the\n * assembly name is not the sample prefix; `assemblyNameToPanSN` maps the two,\n * the same slot and helper the all-vs-all PAF adapters use.\n */\n async resolve(region: Region, opts?: BaseOptions) {\n const lookup = await this.lookup(opts)\n return resolveRefName(\n lookup,\n resolvePanSNPrefix(this.adapter, region.assemblyName),\n region.refName,\n )\n }\n\n /**\n * The compressed bytes a read of `regions` fetches from the file, as its\n * index estimates them, for the display's byte gate. `queryStart` moves a\n * region's start to where the read begins.\n */\n async regionBytes(\n regions: Region[],\n opts: BaseOptions = {},\n queryStart = async (start: number) => start,\n ) {\n const spans = []\n for (const region of regions) {\n const refName = await this.resolve(region, opts)\n if (refName !== undefined) {\n spans.push({\n refName,\n start: await queryStart(region.start),\n end: region.end,\n })\n }\n }\n return bytesForRegions(this.file, spans, opts)\n }\n}\n"],
5
+ "mappings": "4LAAA,IAAMA,GAAO,eAAe,yCAAyC,EAC/DC,GAAOC,GACXF,IAAQ,MAAQE,KAAQ,OAAOF,EAAI,EAC/BA,GAAKE,CAAI,EACT,OAAO,OACL,UAAY,CACV,MAAM,IAAI,MACR,kCAAoCA,EAAO,yJAC7C,CACF,EACA,CAAE,mBAAoBA,CAAK,CAC7B,EAEC,IAAMC,GAAyCC,GAAK,wBAAwB,EAE5E,IAAMC,GAA8BC,GAAK,aAAa,EAQ7D,IAAOC,GAAQC,IAAQA,GAAK,WAAaA,GAAK,QAAUA,GClBjD,IAAMC,GAAN,cAAkC,KAAM,CAC3C,YAAYC,EAASC,EAAOC,EAAUC,EAAQ,CAC1C,MAAMH,CAAO,EACb,KAAK,eAAiB,GACtB,KAAK,KAAO,iBACZ,KAAK,MAAQC,EACb,KAAK,SAAWC,EAChB,KAAK,OAASC,CAClB,CACJ,EACMC,GAAM,IAEL,SAASC,GAAYC,EAAS,CACjC,OAAOA,EAAQ,MAAMF,EAAG,EAAE,CAAC,CAC/B,CAEO,SAASG,GAAYD,EAAS,CACjC,IAAME,EAAQF,EAAQ,MAAMF,EAAG,EAC/B,OAAOI,EAAM,QAAU,EACjBA,EAAM,MAAM,CAAC,EAAE,KAAKJ,EAAG,EACvBI,EAAM,SAAW,EACbA,EAAM,CAAC,EACPF,CACd,CACO,SAASG,GAAeH,EAAS,CACpC,IAAME,EAAQF,EAAQ,MAAMF,EAAG,EAC/B,OAAOI,EAAM,QAAU,EAAI,GAAGA,EAAM,CAAC,CAAC,GAAGJ,EAAG,GAAGI,EAAM,CAAC,CAAC,GAAK,MAChE,CACO,SAASE,GAAmBJ,EAASK,EAAQ,CAChD,OAAQA,IAAW,SACdL,IAAYK,GAAUL,EAAQ,WAAWK,EAASP,EAAG,EAC9D,CACA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AK,0BAA0BD,CAAI,CAAC,CACjE,CAAC,CAKE,CAYH,MAAM,iBAAiBA,EAAoB,CAAC,EAAG,CAC7C,IAAME,EAAQ,MAAM,KAAK,KAAK,0BAA0BF,CAAI,EACtDG,EAASC,GAAmB,KAAK,QAASJ,EAAK,YAAY,EAC3DK,EAAUH,EACb,OAAOI,GAAKC,GAAmBD,EAAGH,CAAM,CAAC,EACzC,IAAIG,GAAKE,GAAYF,CAAC,CAAC,EAC1B,OAAOD,EAAQ,OAAS,EAAI,CAAC,GAAG,IAAI,IAAIA,CAAO,CAAC,EAAIH,CACtD,CAUA,MAAM,QAAQO,EAAgBT,EAAoB,CAChD,IAAMU,EAAS,MAAM,KAAK,OAAOV,CAAI,EACrC,OAAOW,GACLD,EACAN,GAAmB,KAAK,QAASK,EAAO,YAAY,EACpDA,EAAO,OACT,CACF,CAOA,MAAM,YACJG,EACAZ,EAAoB,CAAC,EACrBa,EAAa,MAAOC,GAAkBA,EACtC,CACA,IAAMC,EAAQ,CAAC,EACf,QAAWN,KAAUG,EAAS,CAC5B,IAAMI,EAAU,MAAM,KAAK,QAAQP,EAAQT,CAAI,EAC3CgB,IAAY,QACdD,EAAM,KAAK,CACT,QAAAC,EACA,MAAO,MAAMH,EAAWJ,EAAO,KAAK,EACpC,IAAKA,EAAO,GACd,CAAC,CAEL,CACA,OAAOQ,GAAgB,KAAK,KAAMF,EAAOf,CAAI,CAC/C,CACF",
6
+ "names": ["host", "read", "name", "BaseFeatureDataAdapter", "read", "cachedSetup", "read", "BaseAdapter_default", "host", "RegionTooLargeError", "message", "limit", "windowBp", "fitsBp", "SEP", "panSNSample", "refName", "panSNContig", "parts", "panSNHaplotype", "panSNMatchesPrefix", "prefix", "precise", "n", "bpString", "bp", "mb", "idOf", "handle", "otherStrand", "tokens", "field", "previous", "out", "v", "neg", "p", "ch", "d", "r", "numbers", "canonicalLink", "a", "b", "tags", "cols", "from", "anchor", "prev", "next", "k", "tag", "at", "chunk", "RefPath", "handles", "lengths", "h", "id", "list", "i", "_a", "best", "j", "target", "forward", "found", "WalkRowError", "orientedEntry", "route", "flip", "orientedExit", "interiorAt", "parseChoices", "choices", "tok", "colonSeen", "value", "traverse", "path", "routes", "start", "endField", "visit", "colon", "end", "counted", "tail", "routeOf", "index", "follow", "count", "entry", "exit", "decodeWalk", "n", "ids", "rev", "push", "to", "sliceBases", "c", "length", "decodeChunk", "rows", "keep", "withSequences", "_b", "_c", "refs", "nodeLengths", "hapOffset", "interior", "name", "first", "last", "lead", "leadFlip", "tailFlip", "placeAndLink", "chunks", "kept", "place", "link", "walks", "wanted", "any", "inCut", "lengthOf", "bp", "routeBp", "s", "taken", "remaining", "offset", "held", "node", "referenceNodes", "nodes", "pieceLinks", "ends", "byPath", "e", "key", "pieces", "links", "piece", "integerTag", "line", "tag", "match", "walkHeader", "lines", "_a", "_b", "_c", "header", "key", "value", "lookbackChunks", "maxNode", "chunk", "chunkQueryStart", "start", "lookback", "walkNameFilter", "wanted", "referenceHaplotype", "name", "panSNMatchesPrefix", "prefix", "walksKept", "refName", "panSNHaplotype", "joinPieces", "rows", "byPath", "row", "list", "runs", "pieces", "a", "b", "from", "decodeRun", "n", "sum", "p", "ids", "rev", "at", "first", "walkCut", "nodes", "onWindow", "id", "reference", "node", "open", "goesOn", "rejoin", "run", "dir", "i", "to", "reachStart", "reachEnd", "spans", "last", "inReach", "kept", "span", "length", "fragments", "f", "l", "hapStart", "hapEnd", "WalkGraph", "window", "source", "target", "sequences", "bases", "placeAndLink", "held", "x", "y", "index", "names", "refNames", "refIndex", "lengths", "refs", "starts", "ranks", "end", "rank", "ref", "nodeIndex", "byLine", "strands", "k", "walks", "offsets", "steps", "reversed", "j", "BUDGET_NAMES", "stepBudgetError", "stepBudget", "readPerKept", "filtered", "total", "perChunk", "budget", "windowBp", "read", "fitsBp", "cs", "fewerFit", "RegionTooLargeError", "bpString", "keptStepsError", "byteBudgetError", "bytesTo", "bytes", "least", "megabytes", "qualifiedKey", "assemblyName", "refName", "refNameLookup", "names", "lookup", "name", "sample", "panSNSample", "contig", "panSNContig", "haplotype", "panSNHaplotype", "resolveRefName", "_a", "READ_STEPS_PER_KEPT", "FOLLOW_ROUNDS", "FOLLOW_CHUNKS", "WALK_CONTEXT", "WALK_BUDGETS", "WalkFormatError", "checkRange", "refName", "start", "end", "raceAbort", "promise", "signal", "resolve", "reject", "onAbort", "WalkReader", "walks", "opts", "read", "lines", "_a", "header", "walkHeader", "chunk", "lookbackChunks", "sample", "refNameLookup", "lookup", "resolveRefName", "lookback", "chunkQueryStart", "region", "keep", "context", "stepBudget", "byteBudget", "links", "from", "bytesForRegions", "budgeted", "bytesFor", "spans", "span", "tooLarge", "byteBudgetError", "reads", "stop", "rows", "cut", "graph", "WalkGraph", "decoded", "ends", "readChunks", "byChunk", "line", "cols", "cs", "held", "chunkRows", "chunkCut", "decodeChunk", "id", "node", "a", "b", "pieceLinks", "tooManyRead", "stepBudgetError", "first", "last", "reach", "lo", "hi", "walkCut", "joinPieces", "spent", "round", "starts", "c", "error", "tooMany", "keptStepsError", "getLines", "file", "refName", "start", "end", "opts", "checkRange", "bytesForRegions", "regions", "Z_NO_FLUSH", "Z_SYNC_FLUSH", "Z_FINISH", "Z_OK", "Z_STREAM_END", "Z_NEED_DICT", "Z_BUF_ERROR", "_has", "obj", "key", "assign", "sources", "source", "p", "shrinkBuf", "buf", "size", "fnTyped", "dest", "src", "src_offs", "len", "dest_offs", "chunks", "i", "l", "pos", "chunk", "result", "fnUntyped", "typedOK", "supported", "arraySet", "flattenChunks", "Buf8", "Buf16", "Buf32", "strApplyOK", "result", "strApplyUintOK", "utf8len", "c", "table", "Buf8", "q", "arg", "string2buf", "str", "buf", "c2", "m_pos", "str_len", "buf_len", "_buf2binstring", "len", "shrinkBuf", "i", "binstring2buf", "str", "buf", "i", "len", "buf2string", "max", "out", "c", "c_len", "utf16buf", "utf8len", "_buf2binstring", "utf8border", "pos", "GZheader", "adler32", "adler", "buf", "len", "pos", "s1", "s2", "n", "makeTable", "c", "table", "n", "k", "crcTable", "crc32", "crc", "buf", "len", "pos", "t", "end", "i", "BAD", "TYPE", "inflate_fast", "strm", "start", "state", "_in", "last", "_out", "beg", "end", "dmax", "wsize", "whave", "wnext", "s_window", "hold", "bits", "lcode", "dcode", "lmask", "dmask", "here", "op", "len", "dist", "from", "from_source", "input", "output", "top", "dolen", "dodist", "MAXBITS", "ENOUGH_LENS", "ENOUGH_DISTS", "CODES", "LENS", "DISTS", "lbase", "lext", "dbase", "dext", "inflate_table", "type", "lens", "lens_index", "codes", "table", "table_index", "work", "opts", "bits", "len", "sym", "min", "max", "root", "curr", "drop", "left", "used", "huff", "incr", "fill", "low", "mask", "next", "base", "base_index", "end", "count", "Buf16", "offs", "extra", "extra_index", "here_bits", "here_op", "here_val", "CODES", "LENS", "DISTS", "Z_FINISH", "Z_BLOCK", "Z_TREES", "Z_OK", "Z_STREAM_END", "Z_NEED_DICT", "Z_STREAM_ERROR", "Z_DATA_ERROR", "Z_MEM_ERROR", "Z_BUF_ERROR", "Z_DEFLATED", "HEAD", "FLAGS", "TIME", "OS", "EXLEN", "EXTRA", "NAME", "COMMENT", "HCRC", "DICTID", "DICT", "TYPE", "TYPEDO", "STORED", "COPY_", "COPY", "TABLE", "LENLENS", "CODELENS", "LEN_", "LEN", "LENEXT", "DIST", "DISTEXT", "MATCH", "LIT", "CHECK", "LENGTH", "DONE", "BAD", "MEM", "SYNC", "ENOUGH_LENS", "ENOUGH_DISTS", "zswap32", "q", "InflateState", "Buf16", "inflateResetKeep", "strm", "state", "Z_STREAM_ERROR", "HEAD", "Buf32", "ENOUGH_LENS", "ENOUGH_DISTS", "Z_OK", "inflateReset", "inflateReset2", "windowBits", "wrap", "inflateInit2", "ret", "virgin", "lenfix", "distfix", "fixedtables", "state", "sym", "Buf32", "inflate_table", "LENS", "DISTS", "updatewindow", "strm", "src", "end", "copy", "dist", "Buf8", "arraySet", "inflate", "flush", "input", "output", "next", "put", "have", "left", "hold", "bits", "_in", "_out", "from", "from_source", "here", "here_bits", "here_op", "here_val", "last_bits", "last_op", "last_val", "len", "ret", "hbuf", "opts", "n", "order", "Z_STREAM_ERROR", "TYPE", "TYPEDO", "Z_OK", "inf_leave", "HEAD", "crc32", "FLAGS", "BAD", "Z_DEFLATED", "DICTID", "TIME", "OS", "EXLEN", "EXTRA", "NAME", "COMMENT", "HCRC", "zswap32", "DICT", "Z_NEED_DICT", "Z_BLOCK", "Z_TREES", "CHECK", "STORED", "LEN_", "TABLE", "COPY_", "COPY", "LENLENS", "CODES", "CODELENS", "LEN", "inflate_fast", "LIT", "LENEXT", "DIST", "DISTEXT", "MATCH", "adler32", "LENGTH", "DONE", "Z_STREAM_END", "Z_DATA_ERROR", "MEM", "Z_MEM_ERROR", "SYNC", "Z_FINISH", "Z_BUF_ERROR", "inflateEnd", "inflateGetHeader", "head", "inflateSetDictionary", "dictionary", "dictLength", "dictid", "messages_default", "ZStream", "toString", "Inflate", "_Inflate", "options", "assign", "opt", "ZStream", "status", "inflateInit2", "Z_OK", "messages_default", "GZheader", "inflateGetHeader", "string2buf", "inflateSetDictionary", "data", "mode", "strm", "chunkSize", "dictionary", "_mode", "next_out_utf8", "tail", "utf8str", "dict", "allowBufError", "Z_FINISH", "Z_NO_FLUSH", "binstring2buf", "Buf8", "inflate", "Z_NEED_DICT", "Z_BUF_ERROR", "Z_STREAM_END", "Z_SYNC_FLUSH", "utf8border", "buf2string", "arraySet", "shrinkBuf", "inflateEnd", "chunk", "flattenChunks", "input", "inflator", "ungzip", "inflate", "scanBgzfBlocks", "input", "minBlockPosition", "maxBlockPosition", "blocks", "offset", "filePosition", "bsize", "trailerPos", "isize", "concatUint8Array", "args", "total", "entry", "mergedArray", "offset", "__webpack_require__", "exports", "definition", "i", "key", "binding", "obj", "prop", "bgzf_wasm_bg_namespaceObject", "ChunkSliceResult", "__wbg_Error_92b29b0548f8b746", "__wbg___wbindgen_throw_344f42d3211c4765", "__wbg_set_wasm", "decompress_all", "decompress_chunk_slice", "wasm_bgzf_wasm_bg_namespaceObject", "_ChunkSliceResult", "ptr", "ChunkSliceResultFinalization", "wasm", "retptr", "r0", "getDataViewMemory0", "r1", "v1", "getArrayU8FromWasm0", "getArrayF64FromWasm0", "input", "ptr0", "passArray8ToWasm0", "len0", "WASM_VECTOR_LEN", "r2", "r3", "takeObject", "v2", "min_block_position", "min_data_position", "max_block_position", "max_data_position", "arg0", "arg1", "ret", "getStringFromWasm0", "addHeapObject", "heap_next", "heap", "idx", "dropObject", "len", "getFloat64ArrayMemory0", "getUint8ArrayMemory0", "cachedDataViewMemory0", "cachedFloat64ArrayMemory0", "decodeText", "cachedUint8ArrayMemory0", "getObject", "arg", "malloc", "cachedTextDecoder", "MAX_SAFARI_DECODE_BYTES", "numBytesDecoded", "val", "wrapper_wasm", "initPromise", "init", "bytes", "instance", "decompressAll", "decompressChunkSlice", "minBlockPosition", "minDataPosition", "maxBlockPosition", "maxDataPosition", "result", "buffer", "cpositions", "dpositions", "BGZF_MIN_BLOCK_SIZE", "hasGzipHeader", "data", "hasBgzfHeader", "errorMessage", "error", "decompressGzip", "inputData", "stream", "ungzip", "wrapGzipHeaderError", "unzip", "decompressAll", "assembleChunkSliceResult", "blocks", "infos", "minv", "maxv", "cpositions", "dpositions", "slices", "dpos", "i", "block", "info", "isLast", "start", "end", "concatUint8Array", "POOL_MIN_DECOMPRESSED_BYTES", "decompressedBytes", "total", "unzipChunkSlice", "chunk", "workerPool", "scanBgzfBlocks", "result", "decompressChunkSlice", "throwIfAborted", "signal", "abortReason", "reason", "SharedReadCache", "fill", "maxSize", "sizeOf", "cacheKey", "key", "idleTimeoutMs", "budget", "signal", "throwIfAborted", "entry", "reject", "aborted", "_resolve", "rejectAborted", "onAbort", "abortReason", "timeout", "cutoff", "interval", "ref", "timer", "cache", "run", "pending", "isCurrent", "settle", "value", "size", "current", "toBytes", "src", "readBody", "encoding", "onProgress", "toBytesWithProgress", "splitReadFileOptions", "options", "parseContentRangeSize", "contentRange", "size", "parseContentLength", "res", "header", "parsed", "PROGRESS_THROTTLE_MS", "total", "body", "bytes", "reader", "out", "received", "lastTick", "chunk", "grown", "now", "mergeHeaders", "sources", "merged", "source", "name", "value", "discardBody", "res", "body", "isByteOffset", "n", "isNetworkFailure", "e", "getMessage", "RemoteFile", "opts", "extraHeaders", "signal", "input", "init", "wrapError", "response", "length", "position", "size", "parseContentRangeSize", "resData", "toBytesWithProgress", "toBytes", "options", "encoding", "splitReadFileOptions", "onProgress", "readBody", "LocalFile", "source", "_opts", "_options", "_length", "_position", "Chunk", "minv", "maxv", "bin", "endPosition", "assertPositive", "name", "value", "QuickLRU", "#cache", "#oldCache", "#maxSize", "#maxAge", "#onEviction", "options", "maxAge", "#emitEvictions", "items", "onEviction", "key", "item", "#deleteIfExpired", "#valueIfFresh", "#moveToRecent", "evicted", "#replaceWith", "#liveItemsAscending", "cache", "entry", "oldItem", "maxSize", "removeCount", "count", "evictCount", "callbackFunction", "thisArgument", "longFromBytesToUnsigned", "source", "i", "low", "VirtualOffset", "blockPosition", "dataPosition", "b", "fromBytes", "bytes", "offset", "optimizeChunks", "chunks", "lowest", "n", "filtered", "lowestBlock", "lowestData", "i", "chunk", "c0", "c1", "dif", "mergedChunks", "lastMinBlock", "lastMaxBlock", "chunkMinBlock", "chunkMaxBlock", "lastChunk", "Chunk", "makeDisjoint", "out", "prevMax", "clampChunkEnds", "extraBoundaries", "boundaries", "c", "a", "b", "max", "lo", "hi", "mid", "minVirtualOffset", "bytes", "offset", "count", "current", "minBlock", "minData", "found", "p", "block", "data", "VirtualOffset", "parseNameBytes", "namesBytes", "decoder", "refIdToName", "refNameToId", "currRefId", "pos", "end", "refName", "tabixFormats", "parseAuxData", "dataView", "formatFlags", "coordinateType", "format", "columnNumbers", "metaValue", "metaChar", "skipLines", "nameSectionLength", "parsePseudoBin", "longFromBytesToUnsigned", "memoizeByRefId", "getIndices", "maxSize", "lru", "QuickLRU", "refId", "cached", "result", "maxOffset", "binIndex", "end", "minShift", "depth", "binCount", "bin", "chunks", "lowest", "i", "minv", "refIdFor", "indexData", "refName", "IndexFile", "SharedReadCache", "filehandle", "opts", "buf", "bytes", "unzip", "refId", "_indices", "rest", "min", "max", "ba", "start", "binChunks", "c", "merged", "optimizeChunks", "past", "n", "signal", "seqId", "CSI1_MAGIC", "CSI2_MAGIC", "lshift", "num", "bits", "rshift", "CSI", "IndexFile", "opts", "bytes", "dataView", "magic", "csiVersion", "minShift", "depth", "maxBinNumber", "maxRefLength", "auxLength", "isGaf", "aux", "parseAuxData", "refCount", "curr", "firstDataLine", "offsets", "i", "binCount", "j", "bin", "minVirtualOffset", "chunkCount", "getIndices", "refId", "start", "pos", "binIndex", "loffsets", "stats", "parsePseudoBin", "fromBytes", "chunks", "k", "Chunk", "clampChunkEnds", "memoizeByRefId", "ref", "beg", "found", "parent", "firstChild", "end", "maxPos", "l", "t", "bins", "b", "e", "TBI_MAGIC", "TBI_DEPTH", "TBI_MIN_SHIFT", "TBI_MAX_REF_LENGTH", "clampToRefLength", "pos", "TabixIndex", "IndexFile", "beg", "end", "b", "e", "bins", "ref", "linearIndex", "opts", "bytes", "dataView", "refCount", "maxBinNumber", "refNameToId", "refIdToName", "coordinateType", "format", "columnNumbers", "metaChar", "skipLines", "parseAuxData", "curr", "firstDataLine", "offsets", "i", "binCount", "j", "bin", "chunkCount", "linearCount", "minVirtualOffset", "getIndices", "refId", "start", "binIndex", "stats", "parsePseudoBin", "chunks", "k", "Chunk", "fromBytes", "clampChunkEnds", "v", "memoizeByRefId", "TAB", "NEWLINE", "CARRIAGE_RETURN", "SEMICOLON", "LESS_THAN", "GREATER_THAN", "MAX_READ_AHEAD_CHUNKS", "DEFAULT_CHUNK_CACHE_BYTES", "DEFAULT_CHUNK_CACHE_IDLE_TIMEOUT_MS", "resolveFilehandle", "filehandle", "path", "url", "LocalFile", "RemoteFile", "resolveIndex", "tbiFilehandle", "csiFilehandle", "tbiPath", "csiPath", "tbiUrl", "csiUrl", "TabixIndex", "CSI", "calculateFileOffset", "cpositions", "dpositions", "pos", "blockStart", "minvDataPosition", "getVcfEnd", "buffer", "startCoordinate", "refStart", "refEnd", "infoStart", "infoEnd", "altEnd", "refLen", "endCoordinate", "svlen", "fieldStart", "i", "fieldLen", "end", "parseIntFromBytes", "maxSvlenOnRef", "COMMA", "svlenSpansRef", "start", "after", "a", "b", "c", "valuesStart", "valuesEnd", "altStart", "max", "value", "alt", "valueEnd", "alleleEnd", "len", "textDecoder", "trimToMetaLines", "bytes", "metaChar", "lastNewline", "metaByte", "l", "byte", "firstLines", "count", "n", "val", "scanGafChunk", "pathCol", "metaCharCode", "decoder", "callback", "lineStart", "target", "pathStart", "t", "first", "pathEnd", "min", "id", "j", "digit", "lineEnd", "TabixIndexedFile", "SharedReadCache", "chunkCacheSize", "chunkCacheIdleTimeoutMs", "chunkCacheBudget", "bgzfWorkerPool", "read", "chunk", "signal", "regions", "opts", "all", "refName", "chunks", "optimizeChunks", "s", "e", "options", "onProgress", "metadata", "isVCF", "refCol", "startCol", "endCol", "maxColumn", "coordinateOffset", "encoder", "regionRefNameBytes", "tabs", "gaf", "totalBytes", "downloadedBytes", "readAhead", "reads", "ensureReadsStarted", "ci", "cl", "prev", "tabPos", "isRefMatch", "line", "firstDataLine", "maxBlockSize", "maxFetch", "buf", "unzip", "skipLines", "header", "skippedLines", "ret", "pool", "unzipChunkSlice", "CHUNK_CACHE_SIZE", "fileLocationSlot", "uri", "tabixIndexSchema", "name", "defaultUri", "ConfigurationSchema", "types", "tbiBeside", "baseUri", "csi", "walksLocations", "snap", "walksUri", "walks", "openTabixSlot", "adapter", "location", "index", "pm", "TabixIndexedFile", "openLocation", "openTabixIndexFilehandle", "PanSNRefNames", "file", "cachedSetup", "opts", "refNameLookup", "names", "prefix", "resolvePanSNPrefix", "contigs", "n", "panSNMatchesPrefix", "panSNContig", "region", "lookup", "resolveRefName", "regions", "queryStart", "start", "spans", "refName", "bytesForRegions"]
7
+ }