jbrowse-plugin-graphgenomeviewer 7.2.0 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/chunks/GbzBaseSyntenyAdapter-FXMGIM7Z.js +2 -0
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-NB6WBBZH.js.map → GbzBaseSyntenyAdapter-FXMGIM7Z.js.map} +3 -3
  3. package/dist/chunks/{GraphGenomeView-4O5F5I37.js → GraphGenomeView-WJ3FIDY2.js} +2 -2
  4. package/dist/chunks/{GraphTrackSettingsDialog-WZEJAF7F.js → GraphTrackSettingsDialog-ZW7ALMDV.js} +2 -2
  5. package/dist/chunks/{HighlightColorDialog-SRT2FPXP.js → HighlightColorDialog-VBZRUKD5.js} +2 -2
  6. package/dist/chunks/{LinearGraphDisplay-Z33PVCJL.js → LinearGraphDisplay-SPOPTJEN.js} +2 -2
  7. package/dist/chunks/MinigraphBubbleAdapter-QCOMFPLL.js +2 -0
  8. package/dist/chunks/{MinigraphBubbleAdapter-HDLUZ6YF.js.map → MinigraphBubbleAdapter-QCOMFPLL.js.map} +1 -1
  9. package/dist/chunks/RgfaTabixAdapter-O3NMNRZ2.js +2 -0
  10. package/dist/chunks/RgfaTabixAdapter-O3NMNRZ2.js.map +7 -0
  11. package/dist/chunks/WalkTabixSyntenyAdapter-7VDCNSFD.js +2 -0
  12. package/dist/chunks/WalkTabixSyntenyAdapter-7VDCNSFD.js.map +7 -0
  13. package/dist/chunks/chunk-2M4XYSLG.js +2 -0
  14. package/dist/chunks/chunk-2M4XYSLG.js.map +7 -0
  15. package/dist/chunks/{chunk-JLGPQO5L.js → chunk-2O3YVA2I.js} +2 -2
  16. package/dist/chunks/{chunk-CWNJR5XB.js → chunk-44CJ2N3N.js} +1 -1
  17. package/dist/chunks/{chunk-CWNJR5XB.js.map → chunk-44CJ2N3N.js.map} +1 -1
  18. package/dist/chunks/chunk-6KUHGRHU.js +2 -0
  19. package/dist/chunks/chunk-6KUHGRHU.js.map +7 -0
  20. package/dist/chunks/chunk-6MUBJVBG.js +2 -0
  21. package/dist/chunks/chunk-6MUBJVBG.js.map +7 -0
  22. package/dist/chunks/{chunk-GUXZESDR.js → chunk-7HWHWPRW.js} +1 -1
  23. package/dist/chunks/{chunk-GUXZESDR.js.map → chunk-7HWHWPRW.js.map} +1 -1
  24. package/dist/chunks/chunk-B2EP6FOQ.js +3 -0
  25. package/dist/chunks/chunk-B2EP6FOQ.js.map +7 -0
  26. package/dist/chunks/{chunk-44HZPYGC.js → chunk-BXRTG7FU.js} +2 -2
  27. package/dist/chunks/{chunk-44HZPYGC.js.map → chunk-BXRTG7FU.js.map} +1 -1
  28. package/dist/chunks/{chunk-HLKZCTQ3.js → chunk-DBPEUVUC.js} +1 -1
  29. package/dist/chunks/{chunk-HLKZCTQ3.js.map → chunk-DBPEUVUC.js.map} +1 -1
  30. package/dist/chunks/{chunk-FME624X3.js → chunk-DUR437TH.js} +2 -2
  31. package/dist/chunks/{chunk-FME624X3.js.map → chunk-DUR437TH.js.map} +1 -1
  32. package/dist/chunks/{chunk-6WA6WF6A.js → chunk-FIRQAKMX.js} +1 -1
  33. package/dist/chunks/{chunk-6WA6WF6A.js.map → chunk-FIRQAKMX.js.map} +1 -1
  34. package/dist/chunks/chunk-JCAZTNYG.js +2 -0
  35. package/dist/chunks/chunk-JCAZTNYG.js.map +7 -0
  36. package/dist/chunks/chunk-N74HGPAW.js +3 -0
  37. package/dist/chunks/chunk-N74HGPAW.js.map +7 -0
  38. package/dist/chunks/chunk-PEDWEPNK.js +2 -0
  39. package/dist/chunks/chunk-PEDWEPNK.js.map +7 -0
  40. package/dist/chunks/chunk-PYQG3JHP.js +3 -0
  41. package/dist/chunks/chunk-PYQG3JHP.js.map +7 -0
  42. package/dist/chunks/chunk-RFDSEB2X.js +4 -0
  43. package/dist/chunks/chunk-RFDSEB2X.js.map +7 -0
  44. package/dist/chunks/{chunk-O7Y7LYN6.js → chunk-RW775LQN.js} +2 -2
  45. package/dist/chunks/{chunk-O7Y7LYN6.js.map → chunk-RW775LQN.js.map} +1 -1
  46. package/dist/chunks/{chunk-N4WBX2OS.js → chunk-VQ77X5QU.js} +2 -2
  47. package/dist/chunks/{chunk-N4WBX2OS.js.map → chunk-VQ77X5QU.js.map} +1 -1
  48. package/dist/chunks/{chunk-LXCMWL7B.js → chunk-WUSKVEA6.js} +2 -2
  49. package/dist/chunks/{chunk-LXCMWL7B.js.map → chunk-WUSKVEA6.js.map} +1 -1
  50. package/dist/chunks/{chunk-ZNT7TQLN.js → chunk-YKSUKPYY.js} +2 -2
  51. package/dist/chunks/chunk-YKSUKPYY.js.map +7 -0
  52. package/dist/chunks/{renderSvg-RRWCAEGF.js → renderSvg-WD6YDV2I.js} +2 -2
  53. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  54. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  55. package/package.json +3 -3
  56. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +2 -2
  57. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +1 -1
  58. package/src/GetSubgraph.ts +1 -1
  59. package/src/GraphGenomeView/genes/genes.test.ts +20 -2
  60. package/src/GraphGenomeView/legendSections.test.ts +1 -1
  61. package/src/GraphGenomeView/legendSections.ts +1 -7
  62. package/src/GraphGenomeView/model.test.ts +1 -2
  63. package/src/GraphGenomeView/pane/graphViews.ts +24 -35
  64. package/src/GraphGenomeView/pane/loadActions.ts +4 -3
  65. package/src/GraphGenomeView/pane/paneBase.ts +1 -1
  66. package/src/GraphGenomeView/subgraphLoad.test.ts +41 -1
  67. package/src/GraphGenomeView/walkRowsCut.ts +10 -44
  68. package/src/RgfaTabixAdapter/RgfaTabixAdapter.test.ts +23 -4
  69. package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +2 -3
  70. package/src/RgfaTabixAdapter/bubbleTier.test.ts +1 -1
  71. package/src/RgfaTabixAdapter/test_data/walks3_inversion.GRCh38.walks.bed.gz +0 -0
  72. package/src/RgfaTabixAdapter/test_data/walks3_inversion.GRCh38.walks.bed.gz.tbi +0 -0
  73. package/src/RgfaTabixAdapter/walkCut.ts +20 -0
  74. package/src/RgfaTabixAdapter/walkFiles.test.ts +2 -2
  75. package/src/RgfaTabixAdapter/walkReader.ts +1 -1
  76. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.test.ts +77 -1
  77. package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +2 -2
  78. package/src/WalkTabixSyntenyAdapter/walkLanes.ts +55 -18
  79. package/src/version.ts +1 -1
  80. package/dist/chunks/GbzBaseSyntenyAdapter-NB6WBBZH.js +0 -2
  81. package/dist/chunks/MinigraphBubbleAdapter-HDLUZ6YF.js +0 -2
  82. package/dist/chunks/RgfaTabixAdapter-XZRTWQMZ.js +0 -3
  83. package/dist/chunks/RgfaTabixAdapter-XZRTWQMZ.js.map +0 -7
  84. package/dist/chunks/WalkTabixSyntenyAdapter-WBHOZLAN.js +0 -2
  85. package/dist/chunks/WalkTabixSyntenyAdapter-WBHOZLAN.js.map +0 -7
  86. package/dist/chunks/chunk-BWP3XYKD.js +0 -2
  87. package/dist/chunks/chunk-BWP3XYKD.js.map +0 -7
  88. package/dist/chunks/chunk-EDSIYH4H.js +0 -2
  89. package/dist/chunks/chunk-EDSIYH4H.js.map +0 -7
  90. package/dist/chunks/chunk-III4GT4G.js +0 -2
  91. package/dist/chunks/chunk-III4GT4G.js.map +0 -7
  92. package/dist/chunks/chunk-N5GYTUIL.js +0 -3
  93. package/dist/chunks/chunk-N5GYTUIL.js.map +0 -7
  94. package/dist/chunks/chunk-PA4HKAUJ.js +0 -2
  95. package/dist/chunks/chunk-PA4HKAUJ.js.map +0 -7
  96. package/dist/chunks/chunk-PFAHNHMM.js +0 -2
  97. package/dist/chunks/chunk-PFAHNHMM.js.map +0 -7
  98. package/dist/chunks/chunk-UFQTIWSN.js +0 -4
  99. package/dist/chunks/chunk-UFQTIWSN.js.map +0 -7
  100. package/dist/chunks/chunk-VDHDEEMF.js +0 -2
  101. package/dist/chunks/chunk-VDHDEEMF.js.map +0 -7
  102. package/dist/chunks/chunk-WGVATZLM.js +0 -3
  103. package/dist/chunks/chunk-WGVATZLM.js.map +0 -7
  104. package/dist/chunks/chunk-ZNT7TQLN.js.map +0 -7
  105. package/src/RgfaTabixAdapter/rgfaBed.test.ts +0 -254
  106. package/src/RgfaTabixAdapter/rgfaBed.ts +0 -314
  107. package/src/RgfaTabixAdapter/rgfaCut.ts +0 -139
  108. package/src/RgfaTabixAdapter/walkRowRuns.test.ts +0 -192
  109. package/src/RgfaTabixAdapter/walkRowRuns.ts +0 -520
  110. /package/dist/chunks/{GraphGenomeView-4O5F5I37.js.map → GraphGenomeView-WJ3FIDY2.js.map} +0 -0
  111. /package/dist/chunks/{GraphTrackSettingsDialog-WZEJAF7F.js.map → GraphTrackSettingsDialog-ZW7ALMDV.js.map} +0 -0
  112. /package/dist/chunks/{HighlightColorDialog-SRT2FPXP.js.map → HighlightColorDialog-VBZRUKD5.js.map} +0 -0
  113. /package/dist/chunks/{LinearGraphDisplay-Z33PVCJL.js.map → LinearGraphDisplay-SPOPTJEN.js.map} +0 -0
  114. /package/dist/chunks/{chunk-JLGPQO5L.js.map → chunk-2O3YVA2I.js.map} +0 -0
  115. /package/dist/chunks/{renderSvg-RRWCAEGF.js.map → renderSvg-WD6YDV2I.js.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/GraphGenomeView/components/PaneLayer.tsx", "../../src/GraphGenomeView/components/BubbleHalos.tsx", "../../src/GraphGenomeView/legendSections.ts", "../../src/GraphGenomeView/components/ElTree.tsx", "../../src/GraphGenomeView/components/LegendSwatch.tsx", "../../src/GraphGenomeView/components/GenePins.tsx", "../../src/GraphGenomeView/components/LabelChip.tsx", "../../src/GraphGenomeView/components/LabelLayer.tsx", "../../src/GraphGenomeView/components/ReferenceStripOverlay.tsx", "../../src/GraphGenomeView/components/TubeMapOverlay.tsx", "host:@jbrowse/render-core/marks", "../../src/GraphGenomeView/walkRowSpans.ts", "../../src/GraphGenomeView/components/WalkRowsOverlay.tsx"],
4
- "sourcesContent": ["import { useEffect, useRef } from 'react'\nimport type { ReactNode } from 'react'\n\nimport { syncCanvasSize } from '@jbrowse/bandage-core/renderer/canvas'\nimport { autorun } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport { dependOn } from '../pane/paneBase'\nimport { trackedDpr } from '../trackedDpr'\n\nimport type { GraphPaneModel } from '../model'\n\n// marks an overlay whose labels move with the drawing, so a press on one pans\nexport const PANS_WITH_DRAWING = 'data-pans-with-drawing'\n\n// A layer over the pane's canvas that leaves the pointer to it\nexport function paneLayerStyle(\n zIndex: number,\n overflow?: 'hidden' | 'visible',\n) {\n return {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow,\n zIndex,\n }\n}\n\n// An SVG the pane's size, over the canvas or inside PaneSvg's export\nexport const PaneSvgLayer = observer(function PaneSvgLayer({\n model,\n zIndex,\n overflow = 'hidden',\n testId,\n pansWithDrawing,\n children,\n}: {\n model: GraphPaneModel\n zIndex: number\n overflow?: 'hidden' | 'visible'\n testId?: string\n pansWithDrawing?: boolean\n children: ReactNode\n}) {\n return (\n <svg\n style={{\n ...paneLayerStyle(zIndex, overflow),\n userSelect: pansWithDrawing ? 'none' : undefined,\n }}\n width={model.paneWidth}\n height={model.canvasHeight}\n data-testid={testId}\n {...(pansWithDrawing ? { [PANS_WITH_DRAWING]: '' } : {})}\n >\n {children}\n </svg>\n )\n})\n\n// Layout units onto the screen. Its own observer, so a pan frame re-renders\n// this group's transform and not the children a parent built.\nexport const PaneTransformGroup = observer(function PaneTransformGroup({\n model,\n children,\n}: {\n model: GraphPaneModel\n children: ReactNode\n}) {\n const { scaleX, scaleY, translateX, translateY } = model\n return (\n <g\n transform={`translate(${translateX} ${translateY}) scale(${scaleX} ${scaleY})`}\n >\n {children}\n </g>\n )\n})\n\n// A canvas the pane's size that an autorun repaints, so a pan moves its ink in\n// the same frame as the drawing. `paint` draws in css px.\nexport function PaneOverlayCanvas({\n model,\n zIndex,\n shown = true,\n testId,\n paint,\n}: {\n model: GraphPaneModel\n zIndex: number\n shown?: boolean\n testId: string\n paint: (ctx: CanvasRenderingContext2D, dpr: number) => void\n}) {\n const ref = useRef<HTMLCanvasElement>(null)\n useEffect(() => {\n if (!shown) {\n return undefined\n }\n return autorun(() => {\n const canvas = ref.current\n const ctx = canvas?.getContext('2d')\n if (canvas && ctx) {\n const width = model.paneWidth\n const height = model.canvasHeight\n dependOn(trackedDpr())\n const dpr = syncCanvasSize(canvas, width, height)\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n ctx.clearRect(0, 0, width, height)\n paint(ctx, dpr)\n }\n })\n }, [model, shown, paint])\n return (\n <canvas\n ref={ref}\n data-testid={shown ? testId : undefined}\n style={{ ...paneLayerStyle(zIndex), display: shown ? 'block' : 'none' }}\n />\n )\n}\n", "import { bubbleKey, sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport { BUBBLE_KIND_COLORS } from '@jbrowse/bandage-core/bubbles/classifyBubble'\nimport { HALO_FACTOR } from '@jbrowse/bandage-core/labelLayout'\nimport { observer } from 'mobx-react'\n\nimport { PaneSvgLayer, PaneTransformGroup } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\n\n// The bubbles over a node drawing: each a translucent halo along its nodes,\n// drawn once in layout units and moved with the canvas by one transform. The\n// halo takes no pointer events, so the nodes under it still hover and drag;\n// its name and its routes' chips are LabelLayer's. A small variant is\n// LabelLayer's tick, and shows its halo only while hovered.\n\nconst BubbleHalos = observer(function BubbleHalos({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbleHalos, hoveredBubble } = model\n if (bubbleHalos.length === 0) {\n return null\n }\n const halo = model.contigThickness * HALO_FACTOR\n return (\n <PaneSvgLayer model={model} zIndex={2} testId=\"graph-bubble-halos\">\n <PaneTransformGroup model={model}>\n {bubbleHalos\n .filter(\n h =>\n !h.whole &&\n (!h.tick ||\n (hoveredBubble && sameBubble(h.bubble, hoveredBubble))),\n )\n .map(h => (\n <path\n key={bubbleKey(h.bubble)}\n d={h.path}\n fill=\"none\"\n stroke={BUBBLE_KIND_COLORS[h.kind]}\n strokeOpacity={\n hoveredBubble && sameBubble(h.bubble, hoveredBubble)\n ? 0.45\n : model.bubbleFaded(h)\n ? 0.06\n : 0.22\n }\n strokeWidth={halo}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ))}\n </PaneTransformGroup>\n </PaneSvgLayer>\n )\n})\n\nexport default BubbleHalos\n", "import { sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport {\n BUBBLE_KIND_COLORS,\n BUBBLE_KIND_NAMES,\n} from '@jbrowse/bandage-core/bubbles/classifyBubble'\nimport { EXON_COLOR } from '@jbrowse/bandage-core/genes/exonOutline'\nimport { formatBp } from '@jbrowse/bandage-core/graphLabels'\nimport {\n BAR_PX as WALK_ROW_BAR_PX,\n CALL_TICK,\n DISAGREES,\n GENE_INK,\n UNBACKED_TICK,\n walkRowsKey,\n} from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport { RAMP_GRADIENT_STOPS } from '@jbrowse/bandage-core/referenceRampCss'\nimport {\n LIFT_BACKDROP_CSS,\n REFERENCE_RAMP_ALT_CSS,\n} from '@jbrowse/bandage-core/renderer/GeometryBuilder'\nimport { deviationInk } from '@jbrowse/bandage-core/tubeMap/deviations'\nimport {\n FORWARD_READ_COLORS,\n REVERSE_READ_COLORS,\n} from '@jbrowse/bandage-core/tubeMap/reads'\nimport { encodingStops } from '@jbrowse/bandage-core/walkEncoding'\nimport { walkKey } from '@jbrowse/bandage-core/walkKey'\n\nimport { CALL_TOLERANCE } from './repeats/walkCalls'\nimport { PANEL_REFERENCE_TUBE } from './tubeMapPanels'\n\nimport type { GraphPaneModel } from './model'\nimport type { KeySwatch } from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport type { LiftedWalk } from '@jbrowse/bandage-core/walkHighlight'\n\n// The legend as data, so the screen's panel and the exported figure's key\n// draw the same rows from one place\n\nexport const SWATCH_PX = 18\nconst BAR_PX = 48\n\n// getNodeColor's grey for a node the ramp cannot place\nconst UNPLACED_SWATCH = 'rgb(160, 160, 160)'\n// LIFT_BACKDROP_CSS reads paler alone than faded strokes do where they\n// overlap, so the key samples it darker\nconst FADED_SWATCH = 'rgba(160, 160, 160, 0.45)'\n\nconst STRIP_SAMPLES = 6\nconst TUBE_SWATCH_PX = 7\nconst FOLD_TICK_BACKING = '#b8b8c0'\nconst WALK_ROW_SWATCH_PX = WALK_ROW_BAR_PX - 4\n\nexport interface Stop {\n offset: number\n color: string\n}\n\nexport type LegendSwatch =\n | {\n kind: 'fill'\n stops: Stop[]\n width?: number\n height?: number\n square?: boolean\n }\n // the reference strip, a band per lifted walk\n | { kind: 'bands'; bands: Stop[][] }\n | { kind: 'line'; color: string }\n | { kind: 'halo'; color: string }\n | {\n kind: 'outline'\n color: string\n stroke: number\n radius: number\n height: number\n }\n | { kind: 'overhang' }\n | { kind: 'glyph'; char: string }\n | { kind: 'tick'; color: string; height: number; backing?: string }\n | { kind: 'bracket' }\n | { kind: 'blank' }\n\n// A row with no swatch is a note on the drawing\nexport interface LegendRow {\n key: string\n label: string\n swatch?: LegendSwatch\n strong?: string\n under?: string\n title?: string\n walk?: LiftedWalk\n closesBubble?: true\n}\n\ninterface LegendSection {\n testid: string\n rows: LegendRow[]\n}\n\nexport function swatchWidth(swatch: LegendSwatch) {\n return swatch.kind === 'fill' ? (swatch.width ?? SWATCH_PX) : SWATCH_PX\n}\n\nconst flat = (color: string): Stop[] => [{ offset: 0, color }]\n\nfunction fillRow(\n key: string,\n color: string,\n label: string,\n width = SWATCH_PX,\n): LegendRow {\n return { key, label, swatch: { kind: 'fill', stops: flat(color), width } }\n}\n\n// hard-edged bands, a read taking one shade of its strand's palette\nfunction bandStops(colors: readonly string[]) {\n return colors.flatMap((color, i) => [\n { offset: i / colors.length, color },\n { offset: (i + 1) / colors.length, color },\n ])\n}\n\nfunction openBubbleRows(model: GraphPaneModel): LegendRow[] {\n const open = model.openBubble\n if (!open) {\n return []\n }\n const halo = model.bubbleHalos.find(h => sameBubble(h.bubble, open))\n return [\n {\n key: 'open',\n label: `open: ${halo?.label ?? 'bubble'}`,\n swatch: halo\n ? { kind: 'halo', color: BUBBLE_KIND_COLORS[halo.kind] }\n : { kind: 'blank' },\n closesBubble: true,\n },\n ]\n}\n\n// Under lifted walks each lane states its own scale, and the rest is grey\nfunction rampRows(model: GraphPaneModel): LegendRow[] {\n const domain = model.walkLift ? undefined : model.referenceRampDomain\n if (!domain) {\n return []\n }\n // a measured domain runs between node midpoints, which can fall on a half bp\n const start = Math.round(domain.start)\n const end = Math.round(domain.end)\n const { offReference, unplaced } = model.referenceRampOffKeys\n return [\n {\n key: 'ramp',\n label: `${start.toLocaleString('en-US')}-${end.toLocaleString('en-US')} (${formatBp(end - start)})`,\n swatch: { kind: 'fill', stops: RAMP_GRADIENT_STOPS, width: BAR_PX },\n },\n ...(offReference\n ? [fillRow('off', REFERENCE_RAMP_ALT_CSS, 'off the reference', BAR_PX)]\n : []),\n ...(unplaced\n ? [fillRow('unplaced', UNPLACED_SWATCH, 'no reference position', BAR_PX)]\n : []),\n ]\n}\n\n// The strip's own colours: a band per lifted walk in its lane's, else the\n// node scheme's, a few of its blocks in bp order rather than a rainbow it\n// does not draw\nfunction stripBands(model: GraphPaneModel): Stop[][] {\n const lift = model.walkLift\n if (lift) {\n return lift.walks.map(w => encodingStops(w.encoding))\n }\n if (model.effectiveColorScheme === 'reference-position') {\n return [RAMP_GRADIENT_STOPS]\n }\n const colors = model.referenceStripBlocks\n .map(b => b.colors[0]!)\n .filter((c, i, all) => c !== all[i - 1])\n const n = Math.min(STRIP_SAMPLES, colors.length)\n return [\n n === 0\n ? flat(LIFT_BACKDROP_CSS)\n : Array.from({ length: n }, (_, i) => ({\n offset: n > 1 ? i / (n - 1) : 0,\n color:\n colors[\n n > 1 ? Math.round((i * (colors.length - 1)) / (n - 1)) : 0\n ]!,\n })),\n ]\n}\n\nfunction stripRows(model: GraphPaneModel): LegendRow[] {\n if (!model.referenceStripShown) {\n return []\n }\n const rowPerWalk = (model.walkLift?.walks.length ?? 0) > 1\n return [\n {\n key: 'strip',\n label: `top strip: reference${rowPerWalk ? ', a row per walk' : ''}`,\n swatch: { kind: 'bands', bands: stripBands(model) },\n },\n ...(model.referenceStripFaded\n ? [\n fillRow(\n 'strip-faded',\n LIFT_BACKDROP_CSS,\n model.walkLift\n ? `reference not on ${rowPerWalk ? \"that row's walk\" : model.liftedWalksLabel}`\n : 'reference outside the open bubble',\n ),\n ]\n : []),\n ...(model.referenceStripOverhangs\n ? [\n {\n key: 'overhang',\n label: 'graph runs past this edge',\n swatch: { kind: 'overhang' } as const,\n },\n ]\n : []),\n ]\n}\n\n// One row per halo colour drawn, naming the kinds it stands for\nfunction haloRows(model: GraphPaneModel): LegendRow[] {\n const kindsByColor = new Map<string, Set<string>>()\n for (const h of model.bubbleHalos) {\n if (!h.whole) {\n const color = BUBBLE_KIND_COLORS[h.kind]\n const kinds = kindsByColor.get(color) ?? new Set<string>()\n kinds.add(BUBBLE_KIND_NAMES[h.kind])\n kindsByColor.set(color, kinds)\n }\n }\n return [...kindsByColor].map(([color, kinds]) => {\n const names = [...kinds].join(' or ')\n return {\n key: `halo-${color}`,\n label:\n names === BUBBLE_KIND_NAMES.superbubble ? names : `${names} bubble`,\n swatch: { kind: 'halo', color },\n }\n })\n}\n\nfunction geneRows(model: GraphPaneModel): LegendRow[] {\n return model.genePins.some(pin => pin.exonsByNode.length > 0)\n ? [\n {\n key: 'exon',\n label: 'exon',\n swatch: {\n kind: 'outline',\n color: EXON_COLOR,\n stroke: 2,\n radius: 5,\n height: 8,\n },\n },\n ]\n : []\n}\n\nfunction foldRows(model: GraphPaneModel): LegendRow[] {\n const note = model.foldNote\n return note ? [{ key: 'fold', label: note }] : []\n}\n\nfunction pathRows(model: GraphPaneModel): LegendRow[] {\n return model.pathLegend.map(({ name, label, color }) => ({\n key: `path-${name}`,\n label,\n swatch: { kind: 'line', color },\n }))\n}\n\nfunction tubeRow(key: string, stops: Stop[], label: string): LegendRow {\n return {\n key,\n label,\n swatch: { kind: 'fill', stops, height: TUBE_SWATCH_PX, square: true },\n }\n}\n\n// What a tube map draws that nothing else on screen explains, each listed\n// only while it applies\nexport function tubeMapRows(model: GraphPaneModel): LegendRow[] {\n const {\n roles,\n haplotypeTube,\n bundled,\n values,\n logWidths,\n foldBp,\n forwardReads,\n reverseReads,\n substitution,\n insertion,\n deletion,\n } = model.tubeMapKeys\n const reads = model.readsShown\n const rows: LegendRow[] = []\n if (values) {\n rows.push(\n tubeRow('value-reference', flat(PANEL_REFERENCE_TUBE), 'reference'),\n ...values.map(({ value, color }) =>\n tubeRow(`value-${value}`, flat(color), value),\n ),\n )\n }\n if (roles) {\n rows.push(\n tubeRow('ref', flat(PANEL_REFERENCE_TUBE), 'reference'),\n tubeRow(\n 'hap',\n flat(haplotypeTube),\n bundled ? 'shared route, \u00D7n haplotypes' : 'haplotype',\n ),\n )\n }\n if (forwardReads) {\n rows.push(\n tubeRow(\n 'fwd',\n bandStops(FORWARD_READ_COLORS),\n 'read on the forward strand',\n ),\n )\n }\n if (reverseReads) {\n rows.push(\n tubeRow(\n 'rev',\n bandStops(REVERSE_READ_COLORS),\n 'read on the reverse strand',\n ),\n )\n }\n if (reads && reads.shown < reads.total) {\n rows.push({\n key: 'sampled',\n label: `${reads.shown.toLocaleString('en-US')} of ${reads.total.toLocaleString('en-US')} reads shown`,\n swatch: { kind: 'blank' },\n })\n }\n if (substitution) {\n rows.push({\n key: 'sub',\n label: 'read mismatch',\n swatch: { kind: 'glyph', char: 'A' },\n })\n }\n if (insertion) {\n rows.push({\n key: 'ins',\n label: 'read insertion',\n swatch: { kind: 'glyph', char: '*' },\n })\n }\n if (deletion) {\n rows.push(tubeRow('del', flat('grey'), 'read deletion'))\n }\n if (foldBp !== undefined) {\n rows.push({\n key: 'tube-fold',\n label: `haplotype variant < ${formatBp(foldBp)}`,\n swatch: {\n kind: 'tick',\n color: deviationInk(),\n height: TUBE_SWATCH_PX,\n backing: FOLD_TICK_BACKING,\n },\n })\n }\n if (logWidths) {\n rows.push({\n key: 'log',\n label: 'width grows with log of length',\n swatch: { kind: 'bracket' },\n })\n }\n return rows\n}\n\nexport function walkRowSwatch(swatch: KeySwatch): LegendSwatch {\n return swatch.kind === 'gene'\n ? {\n kind: 'outline',\n color: GENE_INK,\n stroke: 1.5,\n radius: 0,\n height: WALK_ROW_SWATCH_PX,\n }\n : {\n kind: 'fill',\n stops:\n swatch.kind === 'bar' && swatch.ramp\n ? RAMP_GRADIENT_STOPS\n : flat(swatch.fill),\n height: swatch.kind === 'gap' ? swatch.px : WALK_ROW_SWATCH_PX,\n }\n}\n\n// The walk rows' bar colours, genes and ticks; each tick row appears once\n// the rows hold one, so a catalogue with no genotypes keeps the plain key\nfunction walkRowsRows(model: GraphPaneModel): LegendRow[] {\n const bars = model.walkRowBars\n if (!bars) {\n return []\n }\n const calls = [bars.reference, ...bars.rows].flatMap(row => row.call ?? [])\n const tick = (key: string, color: string, label: string): LegendRow => ({\n key,\n label,\n swatch: { kind: 'tick', color, height: WALK_ROW_SWATCH_PX },\n })\n return [\n ...walkRowsKey(bars, {\n ramp: model.referenceRampDomain,\n genes: model.walkRowGeneKey,\n }).map(entry => ({\n key: `rows-${entry.label}`,\n label: entry.label,\n swatch: entry.note ? undefined : walkRowSwatch(entry.swatch),\n })),\n ...(calls.some(call => call.spanningReads !== 0)\n ? [tick('call', CALL_TICK, 'allele length called for this walk')]\n : []),\n ...(calls.some(call => call.spanningReads === 0)\n ? [tick('unbacked', UNBACKED_TICK, 'called with no read spanning it')]\n : []),\n ...(calls.some(call => call.agrees === false)\n ? [\n tick(\n 'disagrees',\n DISAGREES,\n `walk and call over ${Math.round(CALL_TOLERANCE * 100)}% apart`,\n ),\n ]\n : []),\n ]\n}\n\n// One lifted walk's key: a swatch, or a short bar of the scale its lane\n// shades by, then its name, with the scale's stretch under it\nexport function walkKeyRow(model: GraphPaneModel, walk: LiftedWalk): LegendRow {\n const key = walkKey(walk, model.walkReference)\n return {\n key: `walk-${walk.name}`,\n strong: model.walkLabel(walk.name),\n label: key.delta + key.gaps + key.reversed,\n swatch: {\n kind: 'fill',\n stops: encodingStops(walk.encoding),\n width: key.shades ? BAR_PX : SWATCH_PX,\n },\n under: key.scale,\n title: key.hover,\n walk,\n }\n}\n\n// The off-reference colour, where the lift paints it, and the faded rest.\n// rampRows draws no key while walks are lifted, so these rows name both.\nfunction fadedRows(\n model: GraphPaneModel,\n faded: string,\n width = SWATCH_PX,\n): LegendRow[] {\n return [\n ...(model.liftPaintsOffReference\n ? [\n fillRow(\n 'lift-off',\n REFERENCE_RAMP_ALT_CSS,\n 'off the reference',\n width,\n ),\n ]\n : []),\n fillRow('faded', FADED_SWATCH, faded, width),\n ]\n}\n\n// Each lifted walk's key, then what the faded rest is; the colours under a\n// shaded walk's bar are bars of its width\nfunction walkReadoutRows(model: GraphPaneModel): LegendRow[] {\n const lift = model.walkLift\n if (!lift || model.facetPanels) {\n return []\n }\n const rows = lift.walks.map(w => walkKeyRow(model, w))\n const width = rows.some(r => swatchWidth(r.swatch!) === BAR_PX)\n ? BAR_PX\n : SWATCH_PX\n return [\n ...rows,\n ...fadedRows(model, `not on ${model.liftedWalksLabel}`, width),\n ]\n}\n\n// The faceted pane's one key line under its panels: each panel's title keys\n// its walk, so this keys only what every panel greys\nexport function facetKeyRows(model: GraphPaneModel): LegendRow[] {\n return model.facetPanels ? fadedRows(model, \"not on the panel's walk\") : []\n}\n\n// The keys in the order the panel stacks them, top first\nexport function legendSections(model: GraphPaneModel): LegendSection[] {\n return [\n { testid: 'graph-open-bubble-legend', rows: openBubbleRows(model) },\n { testid: 'graph-ramp-legend', rows: rampRows(model) },\n { testid: 'graph-reference-strip-legend', rows: stripRows(model) },\n { testid: 'graph-halo-legend', rows: haloRows(model) },\n { testid: 'graph-gene-legend', rows: geneRows(model) },\n { testid: 'graph-fold-legend', rows: foldRows(model) },\n { testid: 'graph-path-legend', rows: pathRows(model) },\n { testid: 'graph-tube-map-legend', rows: tubeMapRows(model) },\n { testid: 'graph-walk-rows-legend', rows: walkRowsRows(model) },\n { testid: 'graph-walk-readout', rows: walkReadoutRows(model) },\n ].filter(section => section.rows.length > 0)\n}\n", "import { createElement, useId } from 'react'\nimport type { ReactNode } from 'react'\n\nimport type { El } from '@jbrowse/bandage-core/el'\n\n// SVG's attribute names as React's props: `class` is className, `data-` and\n// `aria-` keep their dashes, the rest are camel-cased (`stroke-width` is\n// strokeWidth)\nfunction propName(name: string) {\n return name === 'class'\n ? 'className'\n : /^(data|aria)-/.test(name)\n ? name\n : name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase())\n}\n\nfunction toReact(node: El | string, key: number): ReactNode {\n if (typeof node === 'string') {\n return node\n }\n const props: Record<string, unknown> = { key }\n for (const [name, value] of Object.entries(node.attrs)) {\n if (value !== undefined) {\n props[propName(name)] = value\n }\n }\n return createElement(node.tag, props, ...node.children.map(toReact))\n}\n\n// A useId fit for an SVG id and for url(#\u2026)\nexport function useSvgId() {\n return useId().replaceAll(/[^\\w-]/g, '')\n}\n\n// A core element tree as React elements\nexport default function ElTree({ el }: { el: El }) {\n return toReact(el, 0)\n}\n", "import { rulerInk } from '@jbrowse/bandage-core/tubeMap/axis'\n\nimport { useSvgId } from './ElTree'\nimport { SWATCH_PX, swatchWidth } from '../legendSections'\n\nimport type { LegendSwatch, Stop } from '../legendSections'\n\nfunction Gradient({\n id,\n x,\n y,\n stops,\n width,\n height,\n square,\n}: {\n id: string\n x: number\n y: number\n stops: readonly Stop[]\n width: number\n height: number\n square?: boolean\n}) {\n const rect = (fill: string) => (\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n rx={square ? 0 : 2}\n fill={fill}\n />\n )\n return stops.length > 1 ? (\n <>\n <defs>\n <linearGradient id={id}>\n {stops.map((s, i) => (\n <stop key={i} offset={s.offset} stopColor={s.color} />\n ))}\n </linearGradient>\n </defs>\n {rect(`url(#${id})`)}\n </>\n ) : (\n rect(stops[0]!.color)\n )\n}\n\nconst bandPx = (bands: readonly unknown[]) => (bands.length > 1 ? 3 : 4)\n\nfunction swatchHeight(swatch: LegendSwatch) {\n switch (swatch.kind) {\n case 'fill':\n return swatch.height ?? 8\n case 'bands':\n return bandPx(swatch.bands) * swatch.bands.length\n case 'line':\n return 3\n case 'halo':\n case 'overhang':\n return 10\n case 'outline':\n case 'tick':\n return swatch.height\n case 'glyph':\n return 15\n case 'bracket':\n return 7\n case 'blank':\n return 0\n }\n}\n\n// A row's swatch with its left edge at x, centred on the row's text 5 px\n// above the baseline\nexport function SvgSwatch({\n swatch,\n x,\n id,\n}: {\n swatch: LegendSwatch\n x: number\n id: string\n}) {\n const mid = -5\n switch (swatch.kind) {\n case 'fill': {\n const height = swatchHeight(swatch)\n return (\n <Gradient\n id={id}\n x={x}\n y={mid - height / 2}\n stops={swatch.stops}\n width={swatchWidth(swatch)}\n height={height}\n square={swatch.square}\n />\n )\n }\n case 'bands': {\n const band = bandPx(swatch.bands)\n const top = mid - swatchHeight(swatch) / 2\n return (\n <>\n {swatch.bands.map((stops, i) => (\n <Gradient\n key={i}\n id={`${id}-${i}`}\n x={x}\n y={top + i * band}\n stops={stops}\n width={SWATCH_PX}\n height={band}\n square\n />\n ))}\n </>\n )\n }\n case 'line':\n return (\n <rect\n x={x}\n y={mid - 1.5}\n width={SWATCH_PX}\n height={3}\n rx={2}\n fill={swatch.color}\n />\n )\n case 'halo':\n return (\n <line\n x1={x + 5}\n x2={x + 13}\n y1={mid}\n y2={mid}\n stroke={swatch.color}\n strokeOpacity={0.35}\n strokeWidth={8}\n strokeLinecap=\"round\"\n />\n )\n case 'outline': {\n const inset = swatch.stroke / 2\n return (\n <rect\n x={x + inset}\n y={mid - swatch.height / 2 + inset}\n width={SWATCH_PX - swatch.stroke}\n height={swatch.height - swatch.stroke}\n rx={Math.max(0, swatch.radius - inset)}\n fill=\"none\"\n stroke={swatch.color}\n strokeWidth={swatch.stroke}\n />\n )\n }\n case 'overhang':\n return (\n <path\n transform={`translate(${x} ${mid - 5})`}\n d=\"M0,5 L8,0 L8,10 Z M18,5 L10,0 L10,10 Z\"\n fill=\"#18181c\"\n />\n )\n case 'glyph':\n return (\n <text\n x={x + SWATCH_PX / 2}\n y={mid + 4}\n textAnchor=\"middle\"\n fontFamily=\"monospace\"\n fontSize={12}\n fill=\"currentColor\"\n >\n {swatch.char}\n </text>\n )\n case 'tick': {\n const y = mid - swatch.height / 2\n return (\n <>\n {swatch.backing ? (\n <rect\n x={x}\n y={y}\n width={SWATCH_PX}\n height={swatch.height}\n fill={swatch.backing}\n />\n ) : null}\n <rect\n x={x + SWATCH_PX / 2 - 1}\n y={y}\n width={2}\n height={swatch.height}\n fill={swatch.color}\n />\n </>\n )\n }\n case 'bracket':\n return (\n <path\n transform={`translate(${x} ${mid - 3.5})`}\n d={`M0.5,6 V1.5 H5.5 V6 M8.5,6 V1.5 H${SWATCH_PX - 0.5} V6`}\n fill=\"none\"\n stroke={rulerInk()}\n />\n )\n case 'blank':\n return null\n }\n}\n\n// The same swatch on screen, in a box as tall as the swatch so the row\n// centres it on its words\nexport function LegendSwatchView({ swatch }: { swatch: LegendSwatch }) {\n const id = useSvgId()\n const height = swatchHeight(swatch)\n return (\n <svg\n width={swatchWidth(swatch)}\n height={height}\n overflow=\"visible\"\n style={{ flex: 'none' }}\n >\n <g transform={`translate(0 ${height / 2 + 5})`}>\n <SvgSwatch swatch={swatch} x={0} id={id} />\n </g>\n </svg>\n )\n}\n", "import { useMemo } from 'react'\n\nimport {\n exonOutlineTree,\n exonStretches,\n} from '@jbrowse/bandage-core/genes/exonOutline'\nimport { computed } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport ElTree, { useSvgId } from './ElTree'\nimport { PaneSvgLayer } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\n\n// The session's genes drawn onto the graph: each exon outlined round its\n// stretch of node, as core's exonOutlineTree draws it for every host, moved by\n// the same transform the halos use. Their names are LabelLayer's.\n\nconst GenePins = observer(function GenePins({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const id = `exon-outline-${useSvgId()}`\n // in layout units, so a pan frame reuses them and only moves the transform\n const stretches = useMemo(\n () =>\n computed(() => {\n const { genePins, walkLift } = model\n // an open bubble rings only its own exons\n const focus = walkLift ? undefined : model.openBubbleFocus\n const pins = focus\n ? genePins.map(pin => ({\n ...pin,\n exonsByNode: pin.exonsByNode.filter(e =>\n focus.nodeIds.has(e.nodeId),\n ),\n }))\n : genePins\n return exonStretches(pins, model.nodeInk.halfWidthPx, walkLift)\n }),\n [model],\n )\n const { scaleX, scaleY, translateX, translateY, paneWidth, canvasHeight } =\n model\n const tree = exonOutlineTree(stretches.get(), {\n id,\n width: paneWidth,\n height: canvasHeight,\n transform: `translate(${translateX} ${translateY}) scale(${scaleX} ${scaleY})`,\n })\n return tree ? (\n <PaneSvgLayer model={model} zIndex={2} testId=\"graph-gene-pins\">\n <ElTree el={tree} />\n </PaneSvgLayer>\n ) : null\n})\n\nexport default GenePins\n", "import { LABEL_PAD, LABEL_PX } from '@jbrowse/bandage-core/overlayLabels'\n\n// A chip's box, its text's baseline at y and centred on x\nfunction chipBox(x: number, y: number, w: number) {\n return {\n x: x - w / 2,\n y: y - LABEL_PX - LABEL_PAD + 2,\n width: w,\n height: LABEL_PX + LABEL_PAD * 2 - 2,\n }\n}\n\nexport function inChip(\n chip: { x: number; y: number; w: number },\n px: number,\n py: number,\n) {\n const box = chipBox(chip.x, chip.y, chip.w)\n return (\n px >= box.x &&\n px <= box.x + box.width &&\n py >= box.y &&\n py <= box.y + box.height\n )\n}\n\n// One label on an overlay: a white chip with a coloured edge and text. A note\n// follows the text in plain type. A chip takes the pointer only with a\n// handler, so its title shows only then.\nexport default function LabelChip({\n x,\n y,\n w,\n text,\n note,\n color,\n edge = color,\n italic,\n dimmed,\n title,\n testId,\n onClick,\n onHover,\n}: {\n x: number\n y: number\n w: number\n text: string\n note?: string\n color: string\n edge?: string\n italic?: boolean\n dimmed?: boolean\n title?: string\n testId?: string\n onClick?: () => void\n onHover?: (hovered: boolean) => void\n}) {\n return (\n <g\n style={{\n pointerEvents: onClick || onHover ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : undefined,\n opacity: dimmed ? 0.35 : 1,\n }}\n data-testid={testId}\n onClick={onClick}\n onMouseEnter={() => {\n onHover?.(true)\n }}\n onMouseLeave={() => {\n onHover?.(false)\n }}\n // a clickable chip is a button to the keyboard too\n {...(onClick && {\n role: 'button',\n tabIndex: 0,\n 'aria-label': (title ?? text).replaceAll('\\n', ', '),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClick()\n }\n },\n onFocus: () => {\n onHover?.(true)\n },\n onBlur: () => {\n onHover?.(false)\n },\n })}\n >\n {title ? <title>{title}</title> : null}\n <rect\n {...chipBox(x, y, w)}\n rx={3}\n fill=\"rgba(255,255,255,0.85)\"\n stroke={edge}\n strokeWidth={1}\n />\n <text\n x={x}\n y={y}\n fontSize={LABEL_PX}\n fontFamily=\"sans-serif\"\n fontStyle={italic ? 'italic' : undefined}\n fontWeight={italic ? 600 : undefined}\n fill={color}\n textAnchor=\"middle\"\n >\n {text}\n {note ? (\n <tspan fontStyle=\"normal\" fontWeight=\"normal\">\n {note}\n </tspan>\n ) : null}\n </text>\n </g>\n )\n}\n", "import { bubbleKey, sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'\nimport { BUBBLE_KIND_COLORS } from '@jbrowse/bandage-core/bubbles/classifyBubble'\nimport { EXON_COLOR } from '@jbrowse/bandage-core/genes/exonOutline'\nimport { geneCoverageNote } from '@jbrowse/bandage-core/labelLayout'\nimport { LABEL_PX, labelWidth } from '@jbrowse/bandage-core/overlayLabels'\nimport { isAlive } from '@jbrowse/mobx-state-tree'\nimport { observer } from 'mobx-react'\n\nimport LabelChip, { inChip } from './LabelChip'\nimport { PaneSvgLayer } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\nimport type { BubbleHalo } from '@jbrowse/bandage-core/bubbles/bubbleHalos'\nimport type { LabelLayout } from '@jbrowse/bandage-core/labelLayout'\n\n// Every chip drawn over the graph, above all of its ink: bubble names and gene\n// names on their pins. `overlayLabels` has placed\n// them against each other and against the row labels already.\n\nconst GENE_INK = '#1c1c22'\nconst TICK_PX = 9\nconst TICK_WIDTH = 3\n\n// What the gene chip under a point reads out, for the hover tooltip: those\n// chips leave the pointer to the canvas, so a drag can start on one\nexport function chipReadoutAt(\n { genes }: Pick<LabelLayout, 'genes'>,\n px: number,\n py: number,\n) {\n const pin = genes.find(chip => inChip(chip, px, py))?.item\n if (!pin) {\n return undefined\n }\n const { gene } = pin\n const note = geneCoverageNote(pin)\n return {\n label: gene.name,\n readout: `${gene.refName}:${gene.start.toLocaleString()}-${gene.end.toLocaleString()}${note ? `, ${note} in the cut` : ''}`,\n }\n}\n\nconst LabelLayer = observer(function LabelLayer({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbles, genes, ticks } = model.overlayLabels\n if (bubbles.length + genes.length + ticks.length === 0) {\n return null\n }\n const { scaleY, translateY, contigThickness, hoveredBubble } = model\n const hoveredTick = hoveredBubble\n ? ticks.find(t => sameBubble(t.item.bubble, hoveredBubble))\n : undefined\n const tickAt = (target: EventTarget) =>\n ticks[Number((target as Element).getAttribute('data-tick'))]\n const dimmedBubble = (h: BubbleHalo) => model.bubbleFaded(h)\n const isOpen = (h: BubbleHalo) => model.bubbleIsOpen(h.bubble)\n\n return (\n <PaneSvgLayer\n model={model}\n zIndex={3}\n testId=\"graph-label-layer\"\n pansWithDrawing\n >\n <g\n data-testid=\"graph-bubble-ticks\"\n onClick={e => {\n const tick = tickAt(e.target)\n if (tick) {\n model.toggleBubble(tick.item.bubble)\n }\n }}\n onMouseOver={e => {\n const tick = tickAt(e.target)\n if (tick) {\n model.setHoveredBubble(tick.item.bubble)\n }\n }}\n // a leave also fires as the view closing it unmounts the tick\n onMouseOut={() => {\n if (isAlive(model)) {\n model.setHoveredBubble(null)\n }\n }}\n onFocus={e => {\n const tick = tickAt(e.target)\n if (tick) {\n model.setHoveredBubble(tick.item.bubble)\n }\n }}\n onBlur={() => {\n if (isAlive(model)) {\n model.setHoveredBubble(null)\n }\n }}\n onKeyDown={e => {\n const tick = tickAt(e.target)\n if (tick && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault()\n model.toggleBubble(tick.item.bubble)\n }\n }}\n >\n {ticks.map(({ item: h, x, y }, i) => (\n <rect\n key={bubbleKey(h.bubble)}\n data-tick={i}\n role=\"button\"\n tabIndex={0}\n aria-label={`${h.label}, ${isOpen(h) ? 'close' : 'open'} bubble`}\n x={x - TICK_WIDTH / 2}\n y={y - TICK_PX}\n width={TICK_WIDTH}\n height={TICK_PX}\n rx={TICK_WIDTH / 2}\n fill={BUBBLE_KIND_COLORS[h.kind]}\n opacity={dimmedBubble(h) ? 0.35 : 1}\n style={{ pointerEvents: 'all', cursor: 'pointer' }}\n />\n ))}\n </g>\n {genes.map(({ item: pin, x, y, w, text }) => {\n const { gene } = pin\n return (\n <g key={`${gene.name}-${gene.start}`}>\n <line\n x1={x}\n x2={x}\n y1={y - LABEL_PX - 2}\n y2={pin.at.y * scaleY + translateY + contigThickness / 2}\n stroke={GENE_INK}\n strokeWidth={0.8}\n strokeOpacity={0.6}\n />\n <LabelChip\n x={x}\n y={y}\n w={w}\n text={gene.name}\n note={text.slice(gene.name.length) || undefined}\n color={GENE_INK}\n edge={EXON_COLOR}\n italic\n testId=\"graph-gene-pin-label\"\n />\n </g>\n )\n })}\n {bubbles.map(({ item: h, x, y, w, text }) => (\n <LabelChip\n key={bubbleKey(h.bubble)}\n x={x}\n y={y}\n w={w}\n text={text}\n color={BUBBLE_KIND_COLORS[h.kind]}\n dimmed={dimmedBubble(h)}\n title={`${h.label}\\n${h.bubble.segmentCount} segments${h.bubble.covering ? '' : isOpen(h) ? ' \u00B7 click to close' : ' \u00B7 click to open'}`}\n testId=\"graph-bubble-halo-label\"\n // the bubble the drawing is would open into this same drawing\n onClick={\n h.bubble.covering\n ? undefined\n : () => {\n model.toggleBubble(h.bubble)\n }\n }\n // a leave also fires as the view closing it unmounts the chip\n onHover={hovered => {\n if (isAlive(model)) {\n model.setHoveredBubble(hovered ? h.bubble : null)\n }\n }}\n />\n ))}\n {hoveredTick ? (\n <LabelChip\n x={hoveredTick.x}\n y={hoveredTick.y - TICK_PX - 4}\n w={labelWidth(hoveredTick.item.label)}\n text={hoveredTick.item.label}\n color={BUBBLE_KIND_COLORS[hoveredTick.item.kind]}\n testId=\"graph-bubble-tick-label\"\n />\n ) : null}\n </PaneSvgLayer>\n )\n})\n\nexport default LabelLayer\n", "import { useCallback } from 'react'\n\nimport { drawReferenceStrip } from '@jbrowse/bandage-core/referenceStrip'\nimport { observer } from 'mobx-react'\n\nimport { PaneOverlayCanvas } from './PaneLayer'\n\nimport type { GraphPaneModel } from '../model'\n\n// Each reference segment at its bp in the linear view, onto the pane's\n// canvas or the linear view's SVG export\nexport function paintReferenceStrip(\n ctx: CanvasRenderingContext2D,\n model: GraphPaneModel,\n {\n lit,\n dpr,\n }: { lit: GraphPaneModel['referenceStripLit'] | undefined; dpr: number },\n) {\n const frame = model.hostBpFrame\n if (frame) {\n drawReferenceStrip(ctx, model.referenceStripBlocks, frame, {\n width: model.paneWidth,\n lit,\n dpr,\n })\n }\n}\n\n// Each reference segment at its bp in the linear view, over a drawing that\n// has no bp axis of its own. Repainted by an autorun, so a pan in the linear\n// view moves the strip in the same frame as its other tracks.\nconst ReferenceStripOverlay = observer(function ReferenceStripOverlay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const paint = useCallback(\n (ctx: CanvasRenderingContext2D, dpr: number) => {\n paintReferenceStrip(ctx, model, { lit: model.referenceStripLit, dpr })\n },\n [model],\n )\n return (\n <PaneOverlayCanvas\n model={model}\n zIndex={5}\n shown={model.referenceStripShown}\n testId=\"graph-reference-strip\"\n paint={paint}\n />\n )\n})\n\nexport default ReferenceStripOverlay\n", "import { useCallback } from 'react'\n\nimport { drawTubeMapRuler } from '@jbrowse/bandage-core/tubeMap/axis'\nimport { drawTubeMapConnectors } from '@jbrowse/bandage-core/tubeMap/connectors'\nimport { drawDeviationMarks } from '@jbrowse/bandage-core/tubeMap/deviations'\nimport { drawTubeMap } from '@jbrowse/bandage-core/tubeMap/draw'\nimport { drawTubeMapGenes } from '@jbrowse/bandage-core/tubeMap/genes'\nimport { observer } from 'mobx-react'\n\nimport { PaneOverlayCanvas } from './PaneLayer'\nimport {\n PANEL_TITLE_FONT,\n drawBundleCounts,\n drawSqueezedLengths,\n} from '../tubeMapPanels'\n\n// variants folded into a box mark texture under a panel's routes\nconst PANEL_TICK_ALPHA = 0.45\n\nimport type { GraphPaneModel } from '../model'\n\n// The tubes, their connectors, genes and ruler, onto a canvas sized to the\n// pane or onto the linear view's SVG export\nexport function paintTubeMap(\n ctx: CanvasRenderingContext2D,\n model: GraphPaneModel,\n { highlightNode }: { highlightNode: string | null },\n) {\n const picture = model.tubeMapPicture\n const frame = model.tubeMapFrame\n if (!picture || !frame) {\n return\n }\n const width = model.paneWidth\n const panels = model.tubeMapPanelViews\n if (panels) {\n paintPanels(ctx, model, panels, highlightNode)\n return\n }\n const tubeFrame = {\n ...frame,\n width,\n highlightNode,\n tubeColors: model.tubeMapTubeColors,\n nodeColors: model.tubeMapNodeColors,\n }\n drawTubeMap(ctx, picture, tubeFrame)\n const drawn = model.layoutResult?.tubeMap\n if (drawn) {\n drawBundleCounts(ctx, picture, drawn.graph, tubeFrame)\n drawSqueezedLengths(ctx, drawn, tubeFrame)\n }\n drawDeviationMarks(ctx, model.tubeMapDeviations, tubeFrame)\n drawTubeMapConnectors(\n ctx,\n model.tubeMapConnectors,\n model.connectorZoneBottom,\n tubeFrame,\n )\n const { bounds } = picture\n drawTubeMapGenes(ctx, model.tubeMapGenes, tubeFrame, frame.y(bounds.minY) - 2)\n const boxes = model.tubeMapRulerBoxes\n if (boxes) {\n drawTubeMapRuler(\n ctx,\n boxes,\n tubeFrame,\n frame.y(bounds.maxY) + 4,\n model.layoutResult?.referenceAxis,\n )\n }\n}\n\n// Each panel of a split tube map under a rule and its title, which the canvas\n// draws so a figure's SVG carries them\nfunction paintPanels(\n ctx: CanvasRenderingContext2D,\n model: GraphPaneModel,\n panels: NonNullable<GraphPaneModel['tubeMapPanelViews']>,\n highlightNode: string | null,\n) {\n const width = model.paneWidth\n for (const p of panels) {\n if (p.bottom < 0 || p.titleTop > model.canvasHeight) {\n continue\n }\n const tubeFrame = {\n ...p.frame,\n width,\n highlightNode,\n tubeColors: p.tubeColors,\n nodeColors: p.nodeColors,\n }\n drawTubeMap(ctx, p.picture, tubeFrame)\n drawBundleCounts(ctx, p.picture, p.panel.result.tubeMap.graph, tubeFrame)\n drawSqueezedLengths(ctx, p.panel.result.tubeMap, tubeFrame)\n ctx.globalAlpha = PANEL_TICK_ALPHA\n drawDeviationMarks(ctx, p.deviations, tubeFrame)\n ctx.globalAlpha = 1\n ctx.strokeStyle = 'rgba(0,0,0,0.15)'\n ctx.lineWidth = 1\n ctx.beginPath()\n ctx.moveTo(0, Math.round(p.titleTop) + 0.5)\n ctx.lineTo(width, Math.round(p.titleTop) + 0.5)\n ctx.stroke()\n ctx.font = PANEL_TITLE_FONT\n ctx.textAlign = 'left'\n ctx.textBaseline = 'top'\n ctx.fillStyle = 'rgba(0,0,0,0.85)'\n ctx.fillText(p.label, 6, p.titleTop + 4)\n }\n const last = panels.at(-1)\n const boxes = model.tubeMapPanelRulerBoxes\n if (last && boxes) {\n drawTubeMapRuler(\n ctx,\n boxes,\n { ...last.frame, width },\n last.bottom + 4,\n true,\n )\n }\n}\n\n// The tube map's ink, over the canvas, which draws nothing under a tube map\n// layout. Above the tubes go the session's genes in a view of its own, or in\n// a linear view the bands tying each reference box to its bp there; under\n// them a reference ruler, unless the linear view's is already the axis.\n// Repainted by an autorun on every change of transform, so a pan in the linear\n// view above moves the tubes in the same frame as its other tracks.\nconst TubeMapOverlay = observer(function TubeMapOverlay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const paint = useCallback(\n (ctx: CanvasRenderingContext2D) => {\n paintTubeMap(ctx, model, { highlightNode: model.selectedNode })\n },\n [model],\n )\n return (\n <PaneOverlayCanvas\n model={model}\n zIndex={1}\n shown={!!model.tubeMapPicture}\n testId=\"graph-tube-map\"\n paint={paint}\n />\n )\n})\n\nexport default TubeMapOverlay\n", "const host = JBrowseExports[\"@jbrowse/render-core/marks\"]\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/render-core/marks\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const HIDDEN_ROW = /* @__PURE__ */ read(\"HIDDEN_ROW\")\nexport const LINK_ELSEWHERE = /* @__PURE__ */ read(\"LINK_ELSEWHERE\")\nexport const LINK_NO_REGION = /* @__PURE__ */ read(\"LINK_NO_REGION\")\nexport const NO_ROW_COLOR = /* @__PURE__ */ read(\"NO_ROW_COLOR\")\nexport const RAMP_NOT_A_NUMBER_COLOR = /* @__PURE__ */ read(\"RAMP_NOT_A_NUMBER_COLOR\")\nexport const RAMP_NO_VALUE_BITS = /* @__PURE__ */ read(\"RAMP_NO_VALUE_BITS\")\nexport const RAMP_NO_VALUE_COLOR = /* @__PURE__ */ read(\"RAMP_NO_VALUE_COLOR\")\nexport const RowKeys = /* @__PURE__ */ read(\"RowKeys\")\nexport const abgrToCssRgba = /* @__PURE__ */ read(\"abgrToCssRgba\")\nexport const appendGlyph = /* @__PURE__ */ read(\"appendGlyph\")\nexport const backToFront = /* @__PURE__ */ read(\"backToFront\")\nexport const barMark = /* @__PURE__ */ read(\"barMark\")\nexport const buildRowTable = /* @__PURE__ */ read(\"buildRowTable\")\nexport const defineMark = /* @__PURE__ */ read(\"defineMark\")\nexport const ellipseDistance = /* @__PURE__ */ read(\"ellipseDistance\")\nexport const ellipseNearest = /* @__PURE__ */ read(\"ellipseNearest\")\nexport const inkOfInstances = /* @__PURE__ */ read(\"inkOfInstances\")\nexport const instanceColor = /* @__PURE__ */ read(\"instanceColor\")\nexport const isThreshold = /* @__PURE__ */ read(\"isThreshold\")\nexport const keepRampValues = /* @__PURE__ */ read(\"keepRampValues\")\nexport const keySlot = /* @__PURE__ */ read(\"keySlot\")\nexport const lineCenterMark = /* @__PURE__ */ read(\"lineCenterMark\")\nexport const lineMarkOf = /* @__PURE__ */ read(\"lineMarkOf\")\nexport const lineStepMark = /* @__PURE__ */ read(\"lineStepMark\")\nexport const linkFeet = /* @__PURE__ */ read(\"linkFeet\")\nexport const linkMark = /* @__PURE__ */ read(\"linkMark\")\nexport const makeAbgrFill = /* @__PURE__ */ read(\"makeAbgrFill\")\nexport const nearestMarkHit = /* @__PURE__ */ read(\"nearestMarkHit\")\nexport const paintColors = /* @__PURE__ */ read(\"paintColors\")\nexport const paintMarkBlocks = /* @__PURE__ */ read(\"paintMarkBlocks\")\nexport const planMarks = /* @__PURE__ */ read(\"planMarks\")\nexport const pointInsetPx = /* @__PURE__ */ read(\"pointInsetPx\")\nexport const pointMark = /* @__PURE__ */ read(\"pointMark\")\nexport const rampUniforms = /* @__PURE__ */ read(\"rampUniforms\")\nexport const rampValueBits = /* @__PURE__ */ read(\"rampValueBits\")\nexport const recordPath = /* @__PURE__ */ read(\"recordPath\")\nexport const rowColor = /* @__PURE__ */ read(\"rowColor\")\nexport const rowSlot = /* @__PURE__ */ read(\"rowSlot\")\nexport const rowSpanIndex = /* @__PURE__ */ read(\"rowSpanIndex\")\nexport const ruleMark = /* @__PURE__ */ read(\"ruleMark\")\nexport const shiftInk = /* @__PURE__ */ read(\"shiftInk\")\nexport const spanMark = /* @__PURE__ */ read(\"spanMark\")\nexport const spansInRow = /* @__PURE__ */ read(\"spansInRow\")\nexport const thresholdBandOf = /* @__PURE__ */ read(\"thresholdBandOf\")\nexport const valueWindow = /* @__PURE__ */ read(\"valueWindow\")\nexport const withPassId = /* @__PURE__ */ read(\"withPassId\")\nexport default host && host.__esModule ? host.default : host", "import {\n GAP_PX,\n MISSING_PX,\n coalesceRuns,\n gapStyle,\n runPaint,\n} from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport { hslToRgb } from '@jbrowse/bandage-core/renderer/GeometryBuilder'\nimport { packAbgr } from '@jbrowse/bandage-core/renderer/colorBits'\nimport { spanMark } from '@jbrowse/render-core/marks'\n\nimport type { WalkRow, WalkRun } from '@jbrowse/bandage-core/layout/walkRows'\nimport type { MarkContext2D, SpanChannels } from '@jbrowse/render-core/marks'\n\ntype Rgb = [number, number, number]\n\n// The colours runPaint writes: `#rrggbb`, `rgb(r, g, b)` and\n// `hsl(h, s%, l%)`\nexport function cssRgb(css: string): Rgb {\n if (css.startsWith('#')) {\n const v = Number.parseInt(css.slice(1), 16)\n return [(v >> 16) & 0xff, (v >> 8) & 0xff, v & 0xff]\n }\n const [a = 0, b = 0, c = 0] = css.match(/[\\d.]+/g)!.map(Number)\n return css.startsWith('hsl')\n ? (hslToRgb(a, b / 100, c / 100).map(v => v * 255) as Rgb)\n : [a, b, c]\n}\n\nconst abgr = ([r, g, b]: Rgb) =>\n packAbgr(Math.round(r), Math.round(g), Math.round(b), 255)\n\nconst cssAbgr = new Map<string, number>()\nfunction packCss(css: string) {\n let v = cssAbgr.get(css)\n if (v === undefined) {\n v = abgr(cssRgb(css))\n cssAbgr.set(css, v)\n }\n return v\n}\n\n/**\n * A run as the pieces it paints in, each `[start, end, abgr]` in bp along\n * the row: one for a solid fill, and for a gradient one per pixel or per\n * degree of hue, whichever is fewer, coloured as the SVG gradient through\n * the same stops colours its middle\n */\nexport function runPieces(\n run: WalkRun,\n ramp: { start: number; end: number } | undefined,\n pxPerBp: number,\n): [number, number, number][] {\n const end = run.start + run.bp\n const paint = runPaint(run, ramp)\n if ('fill' in paint) {\n return [[run.start, end, packCss(paint.fill)]]\n }\n const stops = paint.stops.map(cssRgb)\n const hues = paint.stops.map(css => Number(/[\\d.]+/.exec(css)![0]))\n const hueSpan = Math.abs(hues.at(-1)! - hues[0]!)\n const n = Math.max(\n 1,\n Math.min(Math.ceil(run.bp * pxPerBp), Math.ceil(hueSpan), run.bp),\n )\n const pieces: [number, number, number][] = []\n for (let k = 0; k < n; k++) {\n const t = ((k + 0.5) / n) * (stops.length - 1)\n const i = Math.min(Math.floor(t), stops.length - 2)\n const a = stops[i]!\n const b = stops[i + 1]!\n const f = t - i\n pieces.push([\n Math.round(run.start + (run.bp * k) / n),\n Math.round(run.start + (run.bp * (k + 1)) / n),\n abgr([0, 1, 2].map(j => a[j]! + (b[j]! - a[j]!) * f) as Rgb),\n ])\n }\n return pieces\n}\n\nexport interface WalkRowSpans {\n bars: SpanChannels & { color: Uint32Array }\n gaps: SpanChannels & { color: Uint32Array }\n // gaps of bases the graph lacks, which draw as a hairline\n hairlines: SpanChannels & { color: Uint32Array }\n // where each drawn row's spans start in `bars`, `gaps` and `hairlines`\n barRows: Uint32Array\n gapRows: Uint32Array\n hairlineRows: Uint32Array\n // the furthest any span reaches along its row, in bp, and at least 1\n longest: number\n}\n\nfunction channels(capacity: number) {\n return {\n x: new Uint32Array(capacity),\n x2: new Uint32Array(capacity),\n row: new Uint32Array(capacity),\n color: new Uint32Array(capacity),\n count: 0,\n }\n}\n\nfunction slice<T extends SpanChannels & { color: Uint32Array }>(\n c: T,\n a: number,\n b: number,\n) {\n return {\n x: c.x.subarray(a, b),\n x2: c.x2.subarray(a, b),\n row: c.row.subarray(a, b),\n color: c.color.subarray(a, b),\n count: b - a,\n }\n}\n\n/**\n * Each row's runs as `walkRowsTree` coalesces and colours them at\n * `pxPerBp`, as span channels: `x`/`x2` in bp along the row, `row` its index\n * among `rows`. Gaps go apart, since they draw thinner, and gaps of bases the\n * graph lacks apart again, as a hairline.\n */\nexport function walkRowSpans(\n rows: WalkRow[],\n pxPerBp: number,\n ramp?: { start: number; end: number },\n): WalkRowSpans {\n const pieces = rows.map(r =>\n coalesceRuns(r.runs, pxPerBp).map(run => ({\n gap: run.gap,\n hairline: run.gap && gapStyle(run.cause).px === MISSING_PX,\n pieces: runPieces(run, ramp, pxPerBp),\n })),\n )\n let total = 0\n for (const runs of pieces) {\n for (const run of runs) {\n total += run.pieces.length\n }\n }\n const bars = channels(total)\n const gaps = channels(total)\n const hairlines = channels(total)\n const barRows = new Uint32Array(rows.length + 1)\n const gapRows = new Uint32Array(rows.length + 1)\n const hairlineRows = new Uint32Array(rows.length + 1)\n let longest = 1\n pieces.forEach((runs, row) => {\n for (const run of runs) {\n const c = run.hairline ? hairlines : run.gap ? gaps : bars\n for (const [x, x2, color] of run.pieces) {\n const i = c.count++\n c.x[i] = x\n c.x2[i] = x2\n c.row[i] = row\n c.color[i] = color\n longest = Math.max(longest, c.x2[i])\n }\n }\n barRows[row + 1] = bars.count\n gapRows[row + 1] = gaps.count\n hairlineRows[row + 1] = hairlines.count\n })\n return {\n bars: slice(bars, 0, bars.count),\n gaps: slice(gaps, 0, gaps.count),\n hairlines: slice(hairlines, 0, hairlines.count),\n barRows,\n gapRows,\n hairlineRows,\n longest,\n }\n}\n\nexport interface WalkRowSpanFrame {\n scaleX: number\n scaleY: number\n translateX: number\n translateY: number\n width: number\n height: number\n rowPx: number\n barPx: number\n origin: number\n // runs of rows whose y is `rowY(first)` plus a row pitch each, as the\n // reference row and each grouped section are\n blocks: { first: number; count: number; rowY: number }[]\n}\n\n/**\n * Paints the spans through render-core's span mark, a block of rows at a\n * time: row i's bar centred where `walkRowsTree` centres it, `barPx` tall,\n * its x at `origin + bp` through the pane's transform.\n */\nexport function paintWalkRowSpans(\n ctx: MarkContext2D,\n spans: WalkRowSpans,\n f: WalkRowSpanFrame,\n) {\n const { longest } = spans\n const block = {\n start: 0,\n end: longest,\n screenStartPx: f.origin * f.scaleX + f.translateX,\n screenEndPx: (f.origin + longest) * f.scaleX + f.translateX,\n reversed: false,\n displayedRegionIndex: 0,\n }\n const frame = { canvasWidth: f.width, canvasHeight: f.height }\n const rowHeight = f.rowPx * f.scaleY\n for (const { first, count, rowY } of f.blocks) {\n // slot `row` centres at (rowY + (row - first) * rowPx) * scaleY + translateY\n const scrollTop =\n rowHeight / 2 - f.translateY - (rowY - first * f.rowPx) * f.scaleY\n const top = (rowY - f.rowPx / 2) * f.scaleY + f.translateY\n if (top > f.height || top + count * rowHeight < 0) {\n continue\n }\n for (const [c, starts, barPx] of [\n [spans.bars, spans.barRows, f.barPx],\n [spans.gaps, spans.gapRows, Math.min(GAP_PX, f.barPx)],\n [spans.hairlines, spans.hairlineRows, Math.min(MISSING_PX, f.barPx)],\n ] as const) {\n spanMark.paintBlock(\n ctx,\n slice(c, starts[first]!, starts[first + count]!),\n block,\n frame,\n {\n rowHeight,\n rowProportion: barPx / rowHeight,\n minWidthPx: 1,\n seamPx: 0,\n scrollTop,\n },\n )\n }\n }\n}\n", "import { useCallback, useMemo } from 'react'\n\nimport { computed } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport ElTree, { useSvgId } from './ElTree'\nimport { PaneOverlayCanvas, PaneSvgLayer } from './PaneLayer'\nimport { SECTION_HEADER_PX, walkRowTrees } from '../walkRowGroups'\nimport { paintWalkRowSpans, walkRowSpans } from '../walkRowSpans'\n\nimport type { GraphPaneModel } from '../model'\n\n// The walk-rows layout's bars: one per haplotype walk under the reference\n// row, each on its own bp axis from the window's left edge. The runs paint as\n// spans on a canvas, coloured by whether they are on the reference walk's\n// path, and core's walkRowsTree draws the rest: unit separators, each row's\n// genes from its own assembly's annotation, the allele a repeat genotype\n// called and a readout. Under the\n// reference-position ramp an aligned run takes the hue of the reference it is\n// threaded through. In a tandem array that is the aligner's pick among\n// near-identical copies, so the hue says which reference copy the graph used,\n// not which one a copy resembles.\n//\n// The walk rows pair a repeat record's allele with each walk \u2014 see\n// repeats/walkCalls.ts, which also holds the threshold a red readout is read\n// off. Colouring each copy by its unit is jbrowse-plugin-tandem-repeat's.\n\n// The spans are recut only when the rows, the zoom or the ramp change\nfunction WalkRowSpansCanvas({ model }: { model: GraphPaneModel }) {\n const spans = useMemo(\n () =>\n computed(() => {\n const bars = model.walkRowBars\n return bars\n ? walkRowSpans(\n [bars.reference, ...bars.rows],\n model.scaleX,\n model.referenceRampDomain,\n )\n : undefined\n }),\n [model],\n )\n const paint = useCallback(\n (ctx: CanvasRenderingContext2D) => {\n const bars = model.walkRowBars\n const place = model.walkRowPlacement\n const pitch = model.walkRowPitch\n const painted = spans.get()\n if (!bars || !place || !pitch || !painted) {\n return\n }\n const sections = model.walkRowGroups?.sections\n const blocks = sections?.length\n ? [\n { first: 0, count: 1, rowY: place.rowY(0) },\n ...sections.map(s => ({\n first: s.first,\n count: s.count,\n rowY: place.rowY(s.first),\n })),\n ]\n : [{ first: 0, count: bars.rows.length + 1, rowY: place.rowY(0) }]\n paintWalkRowSpans(ctx, painted, {\n ...model.screenTransform,\n width: model.paneWidth,\n height: model.canvasHeight,\n rowPx: pitch.rowPx,\n barPx: pitch.barPx,\n origin: bars.origin,\n blocks,\n })\n },\n [model, spans],\n )\n return (\n <PaneOverlayCanvas\n model={model}\n zIndex={3}\n testId=\"graph-walk-rows-spans\"\n paint={paint}\n />\n )\n}\n\n// Its own observer, so moving between rows redraws this rect and not every row\nconst HoveredWalkRow = observer(function HoveredWalkRow({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const bars = model.walkRowBars\n const place = model.walkRowPlacement\n const pitch = model.walkRowPitch\n if (!bars || !place || !pitch || !model.hoveredWalkRowText) {\n return null\n }\n const rows = [bars.reference, ...bars.rows]\n const index = rows.findIndex(r => r.name === model.hoveredWalkRow)\n const row = rows[index]\n if (!row) {\n return null\n }\n const start = model.toScreen({ x: bars.origin, y: place.rowY(index) })\n return (\n <rect\n data-testid=\"graph-walk-row-hovered\"\n x={start.x - 2}\n y={start.y - pitch.rowPx / 2 - 1}\n width={row.bp * model.scaleX + 4}\n height={pitch.rowPx + 2}\n fill=\"none\"\n stroke=\"#111\"\n strokeWidth={1}\n />\n )\n})\n\n// `vector` for an SVG export, which draws the bars as walkRowsTree's rects\nconst WalkRowsOverlay = observer(function WalkRowsOverlay({\n model,\n vector = false,\n}: {\n model: GraphPaneModel\n vector?: boolean\n}) {\n const idPrefix = useSvgId()\n const bars = model.walkRowBars\n const place = model.walkRowPlacement\n const pitch = model.walkRowPitch\n if (!bars || !place || !pitch) {\n return null\n }\n const { paneWidth: width, canvasHeight } = model\n // the canvas paints the bars, except in a vector export\n const frame = {\n ...model.screenTransform,\n width,\n height: canvasHeight,\n ...pitch,\n bars: vector,\n }\n return (\n <>\n {vector ? null : <WalkRowSpansCanvas model={model} />}\n <PaneSvgLayer\n model={model}\n zIndex={3}\n overflow=\"visible\"\n testId=\"graph-walk-rows\"\n >\n {walkRowTrees(\n bars,\n model.walkRowGroups?.sections ?? [],\n place.rowY,\n frame,\n {\n ramp: model.referenceRampDomain,\n rowGenes: model.walkRowGenes,\n idPrefix,\n },\n ).map((tree, i) => (\n <ElTree key={i} el={tree} />\n ))}\n {place.headers.map(header => (\n <text\n key={header.key}\n x={10}\n y={\n model.toScreen({ x: 0, y: header.top }).y + SECTION_HEADER_PX - 4\n }\n fontFamily=\"sans-serif\"\n fontSize={11}\n fontWeight=\"bold\"\n fill=\"#333\"\n data-testid=\"graph-walk-section\"\n >\n {header.title}\n </text>\n ))}\n <HoveredWalkRow model={model} />\n </PaneSvgLayer>\n </>\n )\n})\n\nexport default WalkRowsOverlay\n"],
5
- "mappings": "muBAaO,IAAMA,GAAoB,yBAG1B,SAASC,GACdC,EACAC,EACA,CACA,MAAO,CACL,SAAU,WACV,KAAM,EACN,IAAK,EACL,cAAe,OAC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CAC3B,EACA5B,EAAM,QAAQ,IAAI8B,GACjBvB,EAAC,QAEC,EAAG,GACH,EACEhB,EAAM,SAAS,CAAE,EAAG,EAAG,EAAGuC,EAAO,GAAI,CAAC,EAAE,EAAIC,GAAoB,EAElE,WAAW,aACX,SAAU,GACV,WAAW,OACX,KAAK,OACL,cAAY,qBAEX,SAAAD,EAAO,OAXHA,EAAO,GAYd,CACD,EACDvB,EAACE,GAAA,CAAe,MAAOlB,EAAO,GAChC,GACF,CAEJ,CAAC,EAEMyC,GAAQhB",
6
- "names": ["PANS_WITH_DRAWING", "paneLayerStyle", "zIndex", "overflow", "PaneSvgLayer", "observer", "model", "testId", "pansWithDrawing", "children", "jsx", "PaneTransformGroup", "scaleX", "scaleY", "translateX", "translateY", "PaneOverlayCanvas", "shown", "paint", "ref", "useRef", "useEffect", "autorun", "canvas", "ctx", "width", "height", "dependOn", "trackedDpr", "dpr", "syncCanvasSize", "BubbleHalos", "observer", "model", "bubbleHalos", "hoveredBubble", "halo", "HALO_FACTOR", "jsx", "PaneSvgLayer", "PaneTransformGroup", "h", "sameBubble", "BUBBLE_KIND_COLORS", "bubbleKey", "BubbleHalos_default", "SWATCH_PX", "BAR_PX", "UNPLACED_SWATCH", "FADED_SWATCH", "STRIP_SAMPLES", "TUBE_SWATCH_PX", "FOLD_TICK_BACKING", "WALK_ROW_SWATCH_PX", "swatchWidth", "swatch", "flat", "color", "fillRow", "key", "label", "width", "bandStops", "colors", "i", "openBubbleRows", "model", "open", "halo", "h", "sameBubble", "BUBBLE_KIND_COLORS", "rampRows", "domain", "start", "end", "offReference", "unplaced", "formatBp", "RAMP_GRADIENT_STOPS", "REFERENCE_RAMP_ALT_CSS", "stripBands", "lift", "w", "encodingStops", "b", "c", "all", "n", "LIFT_BACKDROP_CSS", "_", "stripRows", "rowPerWalk", "haloRows", "kindsByColor", "kinds", "BUBBLE_KIND_NAMES", "names", "geneRows", "pin", "EXON_COLOR", "foldRows", "note", "pathRows", "name", "tubeRow", "stops", "tubeMapRows", "roles", "haplotypeTube", "bundled", "values", "logWidths", "foldBp", "forwardReads", "reverseReads", "substitution", "insertion", "deletion", "reads", "rows", "PANEL_REFERENCE_TUBE", "value", "FORWARD_READ_COLORS", "REVERSE_READ_COLORS", "deviationInk", "walkRowSwatch", "GENE_INK", "walkRowsRows", "bars", "calls", "row", "tick", "walkRowsKey", "entry", "call", "CALL_TICK", "UNBACKED_TICK", "DISAGREES", "walkKeyRow", "walk", "walkKey", "fadedRows", "faded", "walkReadoutRows", "facetKeyRows", "legendSections", "section", "propName", "name", "_", "c", "toReact", "node", "key", "props", "value", "createElement", "useSvgId", "useId", "ElTree", "el", "Gradient", "id", "x", "y", "stops", "width", "height", "square", "rect", "fill", "jsx", "jsxs", "Fragment", "s", "i", "bandPx", "bands", "swatchHeight", "swatch", "SvgSwatch", "swatchWidth", "band", "top", "SWATCH_PX", "inset", "rulerInk", "LegendSwatchView", "useSvgId", "GenePins", "observer", "model", "id", "useSvgId", "stretches", "useMemo", "computed", "genePins", "walkLift", "focus", "pins", "pin", "e", "exonStretches", "scaleX", "scaleY", "translateX", "translateY", "paneWidth", "canvasHeight", "tree", "exonOutlineTree", "jsx", "PaneSvgLayer", "ElTree", "GenePins_default", "chipBox", "x", "y", "w", "LABEL_PX", "LABEL_PAD", "inChip", "chip", "px", "py", "box", "LabelChip", "text", "note", "color", "edge", "italic", "dimmed", "title", "testId", "onClick", "onHover", "jsxs", "e", "jsx", "GENE_INK", "TICK_PX", "TICK_WIDTH", "chipReadoutAt", "genes", "px", "py", "pin", "chip", "inChip", "gene", "note", "geneCoverageNote", "LabelLayer", "observer", "model", "bubbles", "ticks", "scaleY", "translateY", "contigThickness", "hoveredBubble", "hoveredTick", "t", "sameBubble", "tickAt", "target", "dimmedBubble", "h", "isOpen", "jsxs", "PaneSvgLayer", "jsx", "e", "tick", "isAlive", "x", "y", "i", "BUBBLE_KIND_COLORS", "bubbleKey", "w", "text", "LABEL_PX", "LabelChip", "EXON_COLOR", "hovered", "labelWidth", "LabelLayer_default", "paintReferenceStrip", "ctx", "model", "lit", "dpr", "frame", "drawReferenceStrip", "ReferenceStripOverlay", "observer", "paint", "useCallback", "jsx", "PaneOverlayCanvas", "ReferenceStripOverlay_default", "PANEL_TICK_ALPHA", "paintTubeMap", "ctx", "model", "highlightNode", "picture", "frame", "width", "panels", "paintPanels", "tubeFrame", "drawTubeMap", "drawn", "drawBundleCounts", "drawSqueezedLengths", "drawDeviationMarks", "drawTubeMapConnectors", "bounds", "drawTubeMapGenes", "boxes", "drawTubeMapRuler", "p", "PANEL_TITLE_FONT", "last", "TubeMapOverlay", "observer", "paint", "useCallback", "jsx", "PaneOverlayCanvas", "TubeMapOverlay_default", "host", "read", "name", "spanMark", "read", "marks_default", "host", "cssRgb", "css", "v", "a", "b", "c", "hslToRgb", "abgr", "r", "g", "packAbgr", "cssAbgr", "packCss", "runPieces", "run", "ramp", "pxPerBp", "end", "paint", "runPaint", "stops", "hues", "hueSpan", "n", "pieces", "k", "t", "i", "f", "j", "channels", "capacity", "slice", "walkRowSpans", "rows", "coalesceRuns", "gapStyle", "MISSING_PX", "total", "runs", "bars", "gaps", "hairlines", "barRows", "gapRows", "hairlineRows", "longest", "row", "x", "x2", "color", "paintWalkRowSpans", "ctx", "spans", "block", "frame", "rowHeight", "first", "count", "rowY", "scrollTop", "top", "starts", "barPx", "GAP_PX", "spanMark", "WalkRowSpansCanvas", "model", "spans", "useMemo", "computed", "bars", "walkRowSpans", "paint", "useCallback", "ctx", "place", "pitch", "painted", "sections", "blocks", "s", "paintWalkRowSpans", "jsx", "PaneOverlayCanvas", "HoveredWalkRow", "observer", "rows", "index", "r", "row", "start", "WalkRowsOverlay", "vector", "idPrefix", "useSvgId", "width", "canvasHeight", "frame", "jsxs", "Fragment", "PaneSvgLayer", "walkRowTrees", "tree", "i", "ElTree", "header", "SECTION_HEADER_PX", "WalkRowsOverlay_default"]
7
- }
@@ -1,2 +0,0 @@
1
- var d="ws",k="we",f=["elsewhere","break","end"],N={missing:"not in the graph",elsewhere:"on nodes filed elsewhere",unknown:"gap, cause unknown"},b="outside the extracted subgraph";function v(e,t,s){if(!t&&!s)return[{bp:e}];let n=Math.min(t?.trimmed??0,e),r=Math.min(s?.trimmed??0,e-n),h=e-n-r,i=t?.kind==="break"?Math.min(t.bp,h):0;h-=i;let u=s?.kind==="break"?Math.min(s.bp,h):0;h-=u;let c=[t,s].find(a=>a?.kind==="elsewhere");return[{bp:n},{bp:i,cause:"missing"},c?.kind==="elsewhere"?{bp:h,cause:"elsewhere",chunk:c.chunk}:{bp:h,cause:"unknown"},{bp:u,cause:"missing"},{bp:r}].filter(a=>a.bp>0)}function S(e,t){let s=e.bp[t],n=e.chunkRefs[t];return m(e.kindNames[e.kinds[t]],Number.isNaN(s)?void 0:s,e.trimmed[t],n<0?void 0:{refName:e.chunkRefNames[n],start:e.chunkStarts[t]})}function m(e,t,s,n){let r=s>0?{trimmed:s}:{};return e==="elsewhere"&&n?{kind:e,chunk:n,...t===void 0?{}:{bp:t},...r}:e==="break"&&t!==void 0?{kind:e,bp:t,...n?{chunk:n}:{},...r}:e==="end"?{kind:e,...r}:void 0}function o(e){let[t,...s]=e.split(","),n,r=0,h;for(let i of s)if(i.startsWith("bp="))n=+i.slice(3);else if(i.startsWith("trimmed="))r=+i.slice(8);else if(i.startsWith("chunk=")){let u=i.lastIndexOf(":");h={refName:i.slice(6,u),start:+i.slice(u+1)}}return m(t,n,r,h)}function p(e,t){return{...e?{before:e}:{},...t?{after:t}:{}}}function g(e){let t=e[d],s=e[k];return p(typeof t=="string"?o(t):void 0,typeof s=="string"?o(s):void 0)}var w=class{constructor(){this.kinds=[],this.bp=[],this.trimmed=[],this.chunkRefs=[],this.chunkStarts=[],this.chunkRefNames=[],this.refIndex=new Map}push(e){this.kinds.push(f.indexOf(e.kind)),this.bp.push("bp"in e&&e.bp!==void 0?e.bp:NaN),this.trimmed.push(e.trimmed??0);let t="chunk"in e?e.chunk:void 0;if(t){let s=this.refIndex.get(t.refName);s===void 0&&(s=this.chunkRefNames.length,this.refIndex.set(t.refName,s),this.chunkRefNames.push(t.refName)),this.chunkRefs.push(s),this.chunkStarts.push(t.start)}else this.chunkRefs.push(-1),this.chunkStarts.push(NaN)}table(){return{kinds:Uint8Array.from(this.kinds),kindNames:[...f],bp:Float64Array.from(this.bp),trimmed:Float64Array.from(this.trimmed),chunkRefs:Int32Array.from(this.chunkRefs),chunkStarts:Float64Array.from(this.chunkStarts),chunkRefNames:this.chunkRefNames}}};export{d as a,k as b,N as c,b as d,v as e,S as f,o as g,p as h,g as i,w as j};
2
- //# sourceMappingURL=chunk-VDHDEEMF.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@11.0.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-EIY2SKD3.js"],
4
- "sourcesContent": ["// src/gfa/walkStops.ts\nvar START_STOP_TAG = \"ws\";\nvar END_STOP_TAG = \"we\";\nvar STOP_KINDS = [\"elsewhere\", \"break\", \"end\"];\nvar GAP_CAUSE_TEXT = {\n missing: \"not in the graph\",\n elsewhere: \"on nodes filed elsewhere\",\n unknown: \"gap, cause unknown\"\n};\nvar OUTSIDE_TEXT = \"outside the extracted subgraph\";\nfunction gapParts(bp, after, before) {\n if (!after && !before) {\n return [{ bp }];\n }\n const left = Math.min(after?.trimmed ?? 0, bp);\n const right = Math.min(before?.trimmed ?? 0, bp - left);\n let rest = bp - left - right;\n const lead = after?.kind === \"break\" ? Math.min(after.bp, rest) : 0;\n rest -= lead;\n const trail = before?.kind === \"break\" ? Math.min(before.bp, rest) : 0;\n rest -= trail;\n const elsewhere = [after, before].find((s) => s?.kind === \"elsewhere\");\n const parts = [\n { bp: left },\n { bp: lead, cause: \"missing\" },\n elsewhere?.kind === \"elsewhere\" ? { bp: rest, cause: \"elsewhere\", chunk: elsewhere.chunk } : { bp: rest, cause: \"unknown\" },\n { bp: trail, cause: \"missing\" },\n { bp: right }\n ];\n return parts.filter((part) => part.bp > 0);\n}\nfunction stopAt(table, i) {\n const bp = table.bp[i];\n const ref = table.chunkRefs[i];\n return stopOf(\n table.kindNames[table.kinds[i]],\n Number.isNaN(bp) ? void 0 : bp,\n table.trimmed[i],\n ref < 0 ? void 0 : { refName: table.chunkRefNames[ref], start: table.chunkStarts[i] }\n );\n}\nfunction stopOf(kind, bp, trimmed, chunk) {\n const cut = trimmed > 0 ? { trimmed } : {};\n if (kind === \"elsewhere\" && chunk) {\n return { kind, chunk, ...bp === void 0 ? {} : { bp }, ...cut };\n }\n if (kind === \"break\" && bp !== void 0) {\n return { kind, bp, ...chunk ? { chunk } : {}, ...cut };\n }\n return kind === \"end\" ? { kind, ...cut } : void 0;\n}\nfunction stopTag(stop) {\n const parts = [stop.kind];\n if (\"bp\" in stop && stop.bp !== void 0) {\n parts.push(`bp=${stop.bp}`);\n }\n if (stop.trimmed) {\n parts.push(`trimmed=${stop.trimmed}`);\n }\n if (\"chunk\" in stop && stop.chunk) {\n parts.push(`chunk=${stop.chunk.refName}:${stop.chunk.start}`);\n }\n return parts.join(\",\");\n}\nfunction parseStopTag(value) {\n const [kind, ...fields] = value.split(\",\");\n let bp;\n let trimmed = 0;\n let chunk;\n for (const field of fields) {\n if (field.startsWith(\"bp=\")) {\n bp = +field.slice(3);\n } else if (field.startsWith(\"trimmed=\")) {\n trimmed = +field.slice(8);\n } else if (field.startsWith(\"chunk=\")) {\n const at = field.lastIndexOf(\":\");\n chunk = { refName: field.slice(6, at), start: +field.slice(at + 1) };\n }\n }\n return stopOf(kind, bp, trimmed, chunk);\n}\nfunction stopFields(before, after) {\n return {\n ...before ? { before } : {},\n ...after ? { after } : {}\n };\n}\nfunction walkStopFields(tags) {\n const before = tags[START_STOP_TAG];\n const after = tags[END_STOP_TAG];\n return stopFields(\n typeof before === \"string\" ? parseStopTag(before) : void 0,\n typeof after === \"string\" ? parseStopTag(after) : void 0\n );\n}\nfunction walkStopTags(walks, p) {\n const tags = [];\n for (const [tag, table] of [\n [START_STOP_TAG, walks.before],\n [END_STOP_TAG, walks.after]\n ]) {\n const stop = table && stopAt(table, p);\n if (stop) {\n tags.push(`\t${tag}:Z:${stopTag(stop)}`);\n }\n }\n return tags.join(\"\");\n}\nvar StopColumns = class {\n constructor() {\n this.kinds = [];\n this.bp = [];\n this.trimmed = [];\n this.chunkRefs = [];\n this.chunkStarts = [];\n this.chunkRefNames = [];\n this.refIndex = /* @__PURE__ */ new Map();\n }\n push(stop) {\n this.kinds.push(STOP_KINDS.indexOf(stop.kind));\n this.bp.push(\"bp\" in stop && stop.bp !== void 0 ? stop.bp : NaN);\n this.trimmed.push(stop.trimmed ?? 0);\n const chunk = \"chunk\" in stop ? stop.chunk : void 0;\n if (chunk) {\n let ref = this.refIndex.get(chunk.refName);\n if (ref === void 0) {\n ref = this.chunkRefNames.length;\n this.refIndex.set(chunk.refName, ref);\n this.chunkRefNames.push(chunk.refName);\n }\n this.chunkRefs.push(ref);\n this.chunkStarts.push(chunk.start);\n } else {\n this.chunkRefs.push(-1);\n this.chunkStarts.push(NaN);\n }\n }\n table() {\n return {\n kinds: Uint8Array.from(this.kinds),\n kindNames: [...STOP_KINDS],\n bp: Float64Array.from(this.bp),\n trimmed: Float64Array.from(this.trimmed),\n chunkRefs: Int32Array.from(this.chunkRefs),\n chunkStarts: Float64Array.from(this.chunkStarts),\n chunkRefNames: this.chunkRefNames\n };\n }\n};\n\nexport {\n START_STOP_TAG,\n END_STOP_TAG,\n GAP_CAUSE_TEXT,\n OUTSIDE_TEXT,\n gapParts,\n stopAt,\n stopTag,\n parseStopTag,\n stopFields,\n walkStopFields,\n walkStopTags,\n StopColumns\n};\n"],
5
- "mappings": "AACA,IAAIA,EAAiB,KACjBC,EAAe,KACfC,EAAa,CAAC,YAAa,QAAS,KAAK,EACzCC,EAAiB,CACnB,QAAS,mBACT,UAAW,2BACX,QAAS,oBACX,EACIC,EAAe,iCACnB,SAASC,EAASC,EAAIC,EAAOC,EAAQ,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Q,CAAC,EACd,KAAK,GAAK,CAAC,EACX,KAAK,QAAU,CAAC,EAChB,KAAK,UAAY,CAAC,EAClB,KAAK,YAAc,CAAC,EACpB,KAAK,cAAgB,CAAC,EACtB,KAAK,SAA2B,IAAI,GACtC,CACA,KAAKC,EAAM,CACT,KAAK,MAAM,KAAKC,EAAW,QAAQD,EAAK,IAAI,CAAC,EAC7C,KAAK,GAAG,KAAK,OAAQA,GAAQA,EAAK,KAAO,OAASA,EAAK,GAAK,GAAG,EAC/D,KAAK,QAAQ,KAAKA,EAAK,SAAW,CAAC,EACnC,IAAME,EAAQ,UAAWF,EAAOA,EAAK,MAAQ,OAC7C,GAAIE,EAAO,CACT,IAAIC,EAAM,KAAK,SAAS,IAAID,EAAM,OAAO,EACrCC,IAAQ,SACVA,EAAM,KAAK,cAAc,OACzB,KAAK,SAAS,IAAID,EAAM,QAASC,CAAG,EACpC,KAAK,cAAc,KAAKD,EAAM,OAAO,GAEvC,KAAK,UAAU,KAAKC,CAAG,EACvB,KAAK,YAAY,KAAKD,EAAM,KAAK,CACnC,MACE,KAAK,UAAU,KAAK,EAAE,EACtB,KAAK,YAAY,KAAK,GAAG,CAE7B,CACA,OAAQ,CACN,MAAO,CACL,MAAO,WAAW,KAAK,KAAK,KAAK,EACjC,UAAW,CAAC,GAAGD,CAAU,EACzB,GAAI,aAAa,KAAK,KAAK,EAAE,EAC7B,QAAS,aAAa,KAAK,KAAK,OAAO,EACvC,UAAW,WAAW,KAAK,KAAK,SAAS,EACzC,YAAa,aAAa,KAAK,KAAK,WAAW,EAC/C,cAAe,KAAK,aACtB,CACF,CACF",
6
- "names": ["START_STOP_TAG", "END_STOP_TAG", "STOP_KINDS", "GAP_CAUSE_TEXT", "OUTSIDE_TEXT", "gapParts", "bp", "after", "before", "left", "right", "rest", "lead", "trail", "elsewhere", "s", "part", "stopAt", "table", "i", "ref", "stopOf", "kind", "trimmed", "chunk", "cut", "parseStopTag", "value", "kind", "fields", "bp", "trimmed", "chunk", "field", "at", "stopOf", "stopFields", "before", "after", "walkStopFields", "tags", "START_STOP_TAG", "END_STOP_TAG", "StopColumns", "stop", "STOP_KINDS", "chunk", "ref"]
7
- }
@@ -1,3 +0,0 @@
1
- import{a as Ve,d as ae,e as Et,g as ie,h as kt,i as Un,j as jn,k as Vn,l as Kn,m as Ke,o as ze,q as Rt,r as Tt}from"./chunk-III4GT4G.js";import{a as Pn,c as $n,e as Ze,f as At,g as zn,i as Zn,j as Jn}from"./chunk-CWNJR5XB.js";import{B as Gn,C as Wn,D as vt,E as ve,F as B,G as St,N as Yn,O as Hn,a as L,b as gt,e as bt,g as xt,h as In,i as Oe,j as Cn,l as Ln,m as yt,n as Ue,p as Bn,r as Xn,s as wt,t as Fn,u as Mt,v as je,x as Dn,y as qn}from"./chunk-PA4HKAUJ.js";import{e as Qn}from"./chunk-6WA6WF6A.js";import{a as On,d as Nn}from"./chunk-N4WBX2OS.js";import{a as we,c as qe,d as fe,e as pt,f as En,g as C,o as An,q as _n}from"./chunk-BWP3XYKD.js";import{c as se,d as Me,e as kn,f as ht,h as Rn,i as Tn}from"./chunk-VDHDEEMF.js";import{a as Ge,d as We,e as Ye,f as _e}from"./chunk-GUXZESDR.js";import{a as mt}from"./chunk-IKJZPPOA.js";import{g as k}from"./chunk-NDRLCGPC.js";import{b as He}from"./chunk-YU7T5WOQ.js";var Je=8,_t=34,Qe=12,bs=60;function xs({count:e,bounds:t,pixelRows:n,width:o,room:r,columns:s}){function a(c){let l=Math.ceil(e/c),d=Math.floor((o-(c-1)*Je)/c),u=(r-l*_t-(l-1)*Je)/l,f=(d-2*Qe)/t.w,p=t.h>0?(u-2*Qe)/t.h:1/0,h=n?f:Math.min(f,p),m=n?t.h:t.h*h,b=Math.floor(Math.max(bs,Math.min(m+2*Qe,u)));return{columns:c,width:d,height:b,scale:h,total:l*(b+_t)+(l-1)*Je}}if(s!==void 0)return a(Math.max(1,Math.min(e,Math.round(s))));let i=a(1);for(let c=2;c<=e;c++){let l=a(c);l.scale>i.scale&&(i=l)}return i}var ys=[{value:"",label:"None",description:"Every lifted walk in one drawing"},{value:"walk",label:"A panel per walk",description:"One panel per lifted walk, side by side"},{value:"sample",label:"A row per sample",description:"A row per sample, a column per haplotype"}];function ws(e){let t=typeof e=="string"?{field:e}:e??{};return{field:t.field==="walk"||t.field==="sample"?t.field:"",domain:[...t.domain??[]],...t.columns===void 0?{}:{columns:t.columns}}}function eo(e,t){let n=new Map(t.map((r,s)=>[r,s])),o=r=>n.get(r)??t.length;return e.map((r,s)=>({name:r,i:s})).sort((r,s)=>o(r.name)-o(s.name)||r.i-s.i).map(({name:r})=>r)}function Ms(e,t,n=[]){let o=eo(e,n),r={columns:void 0,count:e.length,cells:e.map(l=>o.indexOf(l))};if(t==="walk")return r;let s=e.map(l=>{let d=Ye(l);return d&&Number.isInteger(d.haplotype)&&d.haplotype>=0?{sample:d.sample,column:Math.max(0,d.haplotype-1)}:void 0}),a=eo([...new Set(s.flatMap(l=>l?[l.sample]:[]))],n),i=Math.max(1,...s.map(l=>l?l.column+1:1)),c=s.map(l=>l?a.indexOf(l.sample)*i+l.column:-1);return c.includes(-1)||new Set(c).size<c.length?r:{columns:i,count:a.length*i,cells:c}}function to(e,t){let n=e.nodes.filter(b=>C(b)&&(t[b.id]?.length??0)>0);if(n.length<2)return t;let o=n.map(b=>{let g=t[b.id],y=g[Math.floor(g.length/2)];return{x:y.x,y:y.y,r:b.stable.start+b.length/2,w:b.length}}),r=o.reduce((b,g)=>b+g.w,0);if(r===0)return t;let s=o.reduce((b,g)=>b+g.x*g.w,0)/r,a=o.reduce((b,g)=>b+g.y*g.w,0)/r,i=o.reduce((b,g)=>b+g.r*g.w,0)/r,c=0,l=0;for(let b of o)c+=b.w*(b.x-s)*(b.r-i),l+=b.w*(b.y-a)*(b.r-i);let d=-Math.atan2(l,c),u=Math.cos(d),f=Math.sin(d),p={};for(let[b,g]of Object.entries(t))p[b]=g.map(y=>{let M=y.x-s,x=y.y-a;return{x:s+u*M-f*x,y:a+f*M+u*x}});let h=0,m=0;for(let b of e.nodes)if(!C(b))for(let g of p[b.id]??[])g.y>a?h++:m++;if(m>h)for(let b of Object.values(p))for(let g of b)g.y=2*a-g.y;return p}var no=30;function vs(e,t){let{opts:n}=t,o=new Map(t.nodes.map(f=>[f.id,Ze(n,f.length)])),r=f=>o.get(f)??n.minimumNodeLength,s=e.nodes.filter(C).sort((f,p)=>f.stable.start-p.stable.start),a=new Map,i=0;for(let f of s)a.set(f.id,{x:i,y:0}),i+=r(f.id)+n.edgeLength;let c=Ve(e),l=new Map(s.map(f=>[f.id,0])),d=s.map(f=>f.id);for(let f of d){let p=a.get(f),h=l.get(f)+1;for(let m of c.get(f)??[])l.has(m)||(l.set(m,h),a.set(m,{x:p.x+r(f)/2,y:no*h}),d.push(m))}let u=0;for(let f of e.nodes)a.has(f.id)||a.set(f.id,{x:u++*i/e.nodes.length,y:no*3});return a}function oo(e,t){let n=vs(e,t);return t.nodes.map(o=>({...o,...n.get(o.id)}))}var Ss=Math.PI/24;function ro(e,t){let n=e[t-1],o=e[t],r=e[t+1];if(!n||!r)return 0;let s=Math.abs(Math.atan2(r.y-o.y,r.x-o.x)-Math.atan2(o.y-n.y,o.x-n.x));return s>Math.PI?2*Math.PI-s:s}function Es(e,t,n,o,r){let s=(h,m)=>Math.max(Math.hypot(m.x-h.x,m.y-h.y)**.5,1e-9),a=s(e,t),i=a+s(t,n),c=i+s(n,o),l=a+r*(i-a),d=(h,m,b,g)=>{let y=(l-b)/(g-b);return{x:h.x+(m.x-h.x)*y,y:h.y+(m.y-h.y)*y}},u=d(e,t,0,a),f=d(t,n,a,i),p=d(n,o,i,c);return d(d(u,f,0,i),d(f,p,a,c),a,i)}var so=(e,t)=>({x:2*t.x-e.x,y:2*t.y-e.y});function ao(e){if(e.length<3)return e;let t=[e[0]];for(let n=0;n+1<e.length;n++){let o=e[n],r=e[n+1],s=Math.ceil(Math.max(ro(e,n),ro(e,n+1))/Ss),a=e[n-1]??so(r,o),i=e[n+2]??so(o,r);for(let c=1;c<s;c++)t.push(Es(a,o,r,i,c/s));t.push(r)}return t}var ks=.5;function io(e,t,n=new Set){let o=new Map(t.map(s=>[s.edgeIndex,`${Pn}${s.edgeIndex}`])),r=[];return e.edges.forEach((s,a)=>{let i=o.get(a);if(!n.has(a))if(i===void 0)r.push(s);else{let{fromStrand:c,toStrand:l}=s;r.push({from:s.from,to:i,...c?{fromStrand:c}:{}},{from:i,to:s.to,...l?{toStrand:l}:{}})}}),{graph:{...e,nodes:[...e.nodes,...[...o.values()].map(s=>({id:s,name:s,length:0,depth:0}))],edges:r},routes:o,ids:new Set(o.values())}}function co(e,t,n,o,r){let s=new Map(e.nodes.map(a=>[a.id,a.length]));return t.map(a=>{let i=a.bypassed.reduce((d,u)=>d+(s.get(u)??0),0),c=Math.max(r.minimumNodeLength,o(i)*ks),l=n.get(a.edgeIndex);return{id:l,name:l,length:Math.round(c*1e6/r.nodeLengthPerMegabase),depth:0}})}function lo(e,t){let n={...e},o={};for(let[r,s]of t){let a=n[s];delete n[s],a?.length&&(o[r]=a)}return{nodePositions:n,deletionRoutes:o}}function Rs(e,t){let n=e.indexOf(":"),o=e.indexOf(":",n+1);if(n!==-1&&o!==-1){let r=e.slice(0,n),s=e.slice(n+1,o),a=e.slice(o+1);s==="i"||s==="f"?t[r]=+a:s==="Z"&&(t[r]=a)}}function Ne(e){let t={};for(let n of e)Rs(n,t);return t}function uo(e){let{SN:t,SO:n,SR:o}=e.tags;return typeof t=="string"&&typeof n=="number"&&typeof o=="number"?{refName:t,start:n,rank:o}:void 0}var fo=62,Ts=60;function As(e){let t=[],n="+",o=0;function r(s){s>o&&t.push({id:e.slice(o,s),strand:n})}for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);(a===fo||a===Ts)&&(r(s),n=a===fo?"+":"-",o=s+1)}return r(e.length),t}function po(e){let t={nodes:[],links:[],paths:[],walks:[],header:[],id:""};for(let n of e.split(`
2
- `)){let o=n.endsWith("\r")?n.slice(0,-1):n,r=o.split(" ",1)[0];if(r==="H"){let[,...s]=o.split(" ");t.header.push(Ne(s))}else if(r==="S"){let[,s,...a]=o.split(" "),i,c,l,d=!1,u=a[0]??"*";/^\d+$/.test(u)?(i=+u,c=a[1]??"*",l=a.slice(2)):(d=!0,c=u,i=c==="*"?0:c.length,l=a.slice(1));let f=Ne(l);d&&"LN"in f&&(i=+f.LN),t.nodes.push({id:s,length:i,sequence:c,tags:f})}else if(r==="E"){let[,,s,a,,,,,i,...c]=o.split(" ");s&&a&&t.links.push({source:s.slice(0,-1),target:a.slice(0,-1),strand1:s.at(-1),strand2:a.at(-1),cigar:i??"*",tags:Ne(c)})}else if(r==="L"){let[,s,a,i,c,l,...d]=o.split(" ");s&&i&&c&&t.links.push({source:s,target:i,strand1:a,strand2:c,cigar:l??"*",tags:Ne(d)})}else if(r==="W"){let[,s,a,i,c,l,d,...u]=o.split(" ");s&&a&&i&&c&&l&&d&&t.walks.push({sample:s,haplotype:+a,contig:i,start:c==="*"?-1:+c,end:l==="*"?-1:+l,segments:As(d),tags:Ne(u)})}else if(r==="P"){let[,s,a,...i]=o.split(" ");s&&a&&t.paths.push({name:s,path:a,rest:i})}}return t}function _s(e,t){let n=new Map,o=new Map;function r(a,i){n.has(a)||n.set(a,i)}function s(a,i){let c=o.get(a);c===void 0&&r(a,i),o.set(a,(c??0)+1)}for(let a of e.links)r(a.source,a.strand1==="-"?"-":"+"),r(a.target,a.strand2==="-"?"-":"+");for(let{steps:a}of t)for(let i of a)s(i.id,i.strand);for(let a of e.walks)for(let i of a.segments)s(i.id,i.strand);return{canonical:n,traversals:o}}var ho=e=>e.start===-1?0:e.start;function Os(e){return{...L(e.name),steps:e.path.split(",").map(t=>({id:t.slice(0,-1),strand:t.endsWith("-")?"-":"+"}))}}function Ns(e,t){return[...t,...e.walks.map(n=>({name:`${n.sample}#${n.haplotype}#${n.contig}`,start:ho(n),steps:n.segments}))]}function Ps(e){let t=e.tags.SM;if(typeof t!="string")return;let n=t.split(",").map(o=>o.trim()).filter(Boolean);return n.length>0?n:void 0}var Pe=e=>typeof e=="number"&&e>0?e:void 0;function $s({tags:e,length:t}){let n=Pe(e.RC)??Pe(e.FC)??Pe(e.KC);return Pe(e.dp)??Pe(e.DP)??(n!==void 0&&t>0?n/t:void 0)}function Is(e,t,n){return{id:`${e.id}${t}`,name:e.id,length:e.length,depth:n,stable:uo(e),samples:Ps(e)}}function mo(e,t="Imported GFA"){let n=[],o=[],r=e.paths.map(Os),{canonical:s,traversals:a}=_s(e,r),i=new Map,c=g=>{let y=i.get(g);return y===void 0&&(y=`${g}${s.get(g)??"+"}`,i.set(g,y)),y},l=new Map;for(let g of e.nodes){if(l.has(g.id))continue;l.set(g.id,g.length);let y=$s(g)??Math.max(a.get(g.id)??1,1);n.push(Is(g,s.get(g.id)??"+",y))}for(let g of e.links)o.push({from:c(g.source),to:c(g.target),fromStrand:g.strand1==="-"?"-":"+",toStrand:g.strand2==="-"?"-":"+"});let d=[],u=new Map,f=(g,y)=>u.get(g)?.get(y);function p(g,y,M){let x=u.get(g);x||(x=new Map,u.set(g,x)),x.set(y,M)}let h=o.map(g=>{let y=f(g.from,g.to);return y||(y=new Set,p(g.from,g.to,y),p(g.to,g.from,y)),y});function m(g,y){for(let M=0;M<g.length-1;M++)f(g[M],g[M+1])?.add(y)}e.paths.forEach(({name:g},y)=>{let{start:M,steps:x}=r[y],w=x.map(v=>c(v.id));d.push({name:g,nodeIds:w,start:M}),m(w,g)});for(let g of e.walks){let y=g.segments.map(x=>c(x.id)),M=`${g.sample}#${g.haplotype}#${g.contig}`;d.push({name:M,nodeIds:y,start:ho(g),sample:g.sample,haplotype:g.haplotype,contig:g.contig,...Tn(g.tags)}),m(y,M)}o.forEach((g,y)=>{let M=h[y];M.size>0&&(g.pathIds=[...M])});let b=e.paths.length>0||e.walks.length>0?gt(Ns(e,r),g=>l.get(g)??0):void 0;return{name:t,nodes:n,edges:o,paths:d.length>0?d:void 0,anchorPaths:b?.anchorPaths,pathVisits:b?.pathVisits,anchoredBy:n.some(g=>g.stable)?"tags":void 0}}function Cs(e,t,n){return t===0?e:`${e}:${t}-${n}`}function Ls(e,t,n,o){let r=new Int32Array(n+1);for(let c of e)r[c+1]++;for(let c=0;c<n;c++)r[c+1]+=r[c];let s=r.slice(0,n),a=new Int32Array(e.length);e.forEach((c,l)=>{a[s[c]++]=t[l]});let i=new Int32Array(o.length).fill(-1);return Array.from({length:n},(c,l)=>{let d=[];for(let u=r[l];u<r[l+1];u++){let f=a[u];i[f]!==l&&(i[f]=l,d.push(o[f]))}return d})}function Ot({nodes:e,links:t,walks:n},o="Imported GFA"){let r=e.names.length,s=e.lengths.length,a=new Uint8Array(r),i=(S,_)=>{a[S]===0&&(a[S]=_?2:1)};for(let S=0;S<t.from.length;S++)i(t.from[S],t.strands[S]&1),i(t.to[S],t.strands[S]&2);let c=[];for(let S=0;S<n.names.length;S++)n.offsets[S+1]>n.offsets[S]&&c.push(S);let l=new Int32Array(r);for(let S of c)for(let _=n.offsets[S];_<n.offsets[S+1];_++){let T=n.steps[_];l[T]===0&&i(T,n.reversed[_]),l[T]++}let d=e.names.map((S,_)=>`${S}${a[_]===2?"-":"+"}`),u=[];for(let S=0;S<s;S++){let _=e.refs[S];u.push({id:d[S],name:e.names[S],length:e.lengths[S],depth:Math.max(l[S],1),stable:_<0?void 0:{refName:e.refNames[_],start:e.starts[S],rank:e.ranks[S]},samples:void 0})}let f=[],p=new Array(r),h=(S,_)=>{let T=p[S];if(T){for(let N=0;N<T.length;N+=2)if(T[N]===_)return T[N+1]}},m=(S,_,T)=>{let N=p[S];N?N.push(_,T):p[S]=[_,T]},b=[],g=0;for(let S=0;S<t.from.length;S++){let _=t.from[S],T=t.to[S];f.push({from:d[_],to:d[T],fromStrand:t.strands[S]&1?"-":"+",toStrand:t.strands[S]&2?"-":"+"});let N=h(_,T);N===void 0&&(N=g++,m(_,T,N),m(T,_,N)),b.push(N)}let y=new Int32Array(r+1);for(let S=0;S<r;S++)y[S+1]=y[S]+(p[S]?.length??0)/2;let M=new Int32Array(y[r]),x=new Int32Array(y[r]);p.forEach((S,_)=>{for(let T=0;T<S.length;T+=2)M[y[_]+T/2]=S[T],x[y[_]+T/2]=S[T+1]});let w=(S,_)=>{for(let T=y[S];T<y[S+1];T++)if(M[T]===_)return x[T];return-1},v=new Map,E=[],O=new Int32Array(n.offsets[n.names.length]??0),A=new Int32Array(O.length),X=0,j=new Int32Array(g).fill(-1),U=[],z=[],Q=n.offsets[n.names.length]??0,R=new Int32Array(Q),$=new Float64Array(Q),I=new Uint8Array(Q),Y=new Int32Array(r).fill(-1),ee=[],H=[0],V=[],ge=new Map,F=[];for(let S of c){let _=n.names[S],T=Ye(_),N=n.starts[S],q=T?`${T.sample}#${T.haplotype}#${T.contig}`:_,Z=T?q:Cs(_,N,n.ends[S]),te=v.get(q);te===void 0&&(te=E.length,v.set(q,te),E.push(q),V.push(Ge(q)));let re=ge.get(Z);re===void 0&&(re=F.length,ge.set(Z,re),F.push(Z));let ft=V[te],xe=n.offsets[S],ye=new Array(n.offsets[S+1]-xe),Te=N,dt=-1;for(let Ae=xe;Ae<n.offsets[S+1];Ae++){let J=n.steps[Ae];ye[Ae-xe]=d[J],Y[J]===-1&&(Y[J]=H.at(-1),H.push(Y[J]+l[J]),ee.push(J));let ut=Y[J]++;if(R[ut]=te,$[ut]=Te,I[ut]=n.reversed[Ae],Te+=J<s?e.lengths[J]:0,dt>=0){let De=w(dt,J);De>=0&&j[De]!==S&&(j[De]=S,O[X]=De,A[X++]=re)}dt=J}U.push({name:Z,nodeIds:ye,start:N,...T,...T?Rn(n.before&&ht(n.before,S),n.after&&ht(n.after,S)):{}}),z.push({name:q,sample:ft,start:N,length:Te-N})}let le=Ls(O.subarray(0,X),A,g,F);f.forEach((S,_)=>{let T=le[b[_]];T.length>0&&(S.pathIds=T)});let be=c.length>0;return{name:o,nodes:u,edges:f,paths:be?U:void 0,anchorPaths:be?z:void 0,pathVisits:be?new An({segments:ee.map(S=>e.names[S]),offsets:Int32Array.from(H),path:R.subarray(0,H.at(-1)),start:$.subarray(0,H.at(-1)),reversed:I.subarray(0,H.at(-1)),paths:E,samples:V}):void 0,anchoredBy:u.some(S=>S.stable)?"tags":void 0}}function Bs(e,t){if(typeof e!="string")return Ot(e,t);let n=On(e);return n?Ot(n,t):mo(po(e),t)}function Ef(e,t,n={}){let o=bt(Bs(e,t),n.referencePath);if(o.nodes.length===0)throw new Error(`No graph segments in ${t}`);if(n.maxNodes!==void 0&&o.nodes.length>n.maxNodes)throw new Error(`Graph too large to draw: ${o.nodes.length.toLocaleString()} nodes (limit ${n.maxNodes.toLocaleString()}). Zoom in to a smaller region, or raise maxGraphNodes on this view.`);return o}var de={engine:"fmmm",quality:2,linearLayout:!1,bubbleSpread:"auto",spacing:1,componentSeparation:1,showDeletionEdges:!0};function go(e={}){return{engine:e.engine??de.engine,quality:e.quality??de.quality,linearLayout:e.linearLayout??de.linearLayout,bubbleSpread:e.bubbleSpread??de.bubbleSpread,spacing:e.spacing??de.spacing,componentSeparation:e.componentSeparation??de.componentSeparation,showDeletionEdges:e.showDeletionEdges??de.showDeletionEdges}}var Xs=15;function Fs(e,t,n){let o=e.nodes.some(C),r=go(n),s={...t,opts:{...t.opts,edgeLength:t.opts.edgeLength*r.spacing}};return{graph:{nodes:o?oo(e,s):s.nodes,edges:e.edges},options:{quality:r.quality,linearLayout:r.linearLayout,...s.opts,componentSeparation:Xs*r.componentSeparation,...o?{rotateComponents:!1}:{},engine:r.engine}}}function Nt(e,t){let n=e.nodes.some(C);return[...Object.values(go(t)),n,e.referencePath??""].join("|")}async function bo(e,t,n){let o=Jn(t.bubbleSpread),{shown:r,hidden:s}=Wn(e,Gn(e),t.showDeletionEdges!==!1),a=io(e,r,s),i=Dn(a.graph,a.ids),c={...i.graph,nodes:i.graph.nodes.filter(y=>!a.ids.has(y.id))},l=At(c,o),{result:d,duration:u}=await n(Fs(i.graph,{...l,nodes:[...l.nodes,...co(e,r,a.routes,zn(c,o),l.opts)]},t)),f=At(e,o),p=new Map(f.nodes.map(y=>[y.id,Ze(f.opts,y.length)])),h=Object.fromEntries(Object.entries(d.nodePositions).map(([y,M])=>[y,ao(M)])),m=qn(h,i.runs,y=>p.get(y)??0),{nodePositions:b,deletionRoutes:g}=lo(e.nodes.some(C)?to(e,m):m,a.routes);return{result:{...d,nodePositions:b,stranded:!0,...r.length?{deletionRoutes:g,extent:xo(g)}:{}},duration:u}}function xo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0;for(let s of Object.values(e))for(let a of s)t=Math.min(t,a.x),n=Math.min(n,a.y),o=Math.max(o,a.x),r=Math.max(r,a.y);return{minX:t,minY:n,maxX:o,maxY:r}}var $e=40,Ds=1e-6,qs=100;function Pt(e){return Math.max(Ds,Math.min(qs,e))}function Gs(e,t,n,o=$e){let r=t-e.h*n;return o-e.minY*n+Math.max(0,r)/2}function kf(e,t,n,o,{minScale:r=0,padLeft:s=$e,padTop:a=$e,padRight:i=$e,padBottom:c=$e}={}){let l=t-s-i,d=n-a-c;if(l<=0||d<=0||!(e.w>0||!o&&e.h>0))return;let u=e.w>0?l/e.w:1/0,f=e.h>0?d/e.h:1/0,p=Pt(Math.max(r,o?u:Math.min(u,f))),h=l-e.w*p;return{scale:p,translateX:s-e.minX*p+Math.max(0,h)/2,translateY:Gs(e,d,o?1:p,a)}}function Rf(e,t={}){let{minX:n,minY:o,maxX:r,maxY:s}=xo(e.nodePositions),{region:a}=t;e.referenceAxis&&a&&a.end>a.start&&(n=a.start,r=a.end);let i=t.extent??e.extent;return i&&(n=Math.min(n,i.minX??n),o=Math.min(o,i.minY??o),r=Math.max(r,i.maxX??r),s=Math.max(s,i.maxY??s)),{minX:n,minY:o,w:r-n,h:s-o}}var Ws=4;function $t(e=Ws){let t=new WeakMap,n=o=>{let r=t.get(o);return r||(r=new Map,t.set(o,r)),r};return{layout(o,r,s){let a=n(o),i=Nt(o,r),c=a.get(i);if(c)return c.run;a.size>=e&&a.delete(a.keys().next().value);let l=performance.now(),d={run:bo(o,r,s).then(u=>(d.done=u.result,{...u,duration:u.duration||performance.now()-l}))};return d.run.catch(()=>{a.get(i)===d&&a.delete(i)}),a.set(i,d),d.run},ready(o,r){return t.get(o)?.get(Nt(o,r))?.done},inherit(o,r){let s=t.get(o);s&&o!==r&&t.set(r,s)}}}function Ys(e,t){return{scaleX:e,scaleY:t?1:e,pixelRows:t}}function It(e,t,n,o){return{minX:-e.translateX/t.scaleX,minY:-e.translateY/t.scaleY,maxX:(n-e.translateX)/t.scaleX,maxY:(o-e.translateY)/t.scaleY}}function Hs(e,t){let n=(e.maxX-e.minX)*t,o=(e.maxY-e.minY)*t;return{minX:e.minX-n,minY:e.minY-o,maxX:e.maxX+n,maxY:e.maxY+o}}function Us(e,t){return t.minX>=e.minX&&t.maxX<=e.maxX&&t.minY>=e.minY&&t.maxY<=e.maxY}function js(e,t,n,o,r){let s=Pt(e.scale*t),a=s/e.scale;return{scale:s,translateX:n-(n-e.translateX)*a,translateY:r?e.translateY:o-(o-e.translateY)*a}}function Vs(e,t,n,o){return{x:(e-n.translateX)/o.scaleX,y:(t-n.translateY)/o.scaleY}}var ue=JBrowseExports["@jbrowse/render-core/RenderLifecycleMixin"],Ks=e=>ue!=null&&e in Object(ue)?ue[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/render-core/RenderLifecycleMixin' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),yo=Ks("RenderLifecycleMixin"),Ad=ue&&ue.__esModule?ue.default:ue;function wo(e){return t=>e.includes(t)?t:void 0}function Nd(e){return k.snapshotProcessor(k.maybe(k.enumeration(e)),{preProcessor:wo(e)})}function et(e,t){return k.snapshotProcessor(k.optional(k.enumeration(e),t),{preProcessor:wo(e)})}var Gd=600,Wd=160,Yd=[1,1,1,1],Hd="rgb(255, 255, 255)",Ud=5,jd=new Set(["tubemap","tubemapref"]),Vd=He(()=>import("./ChooseSamplesDialog-JRN4YLBY.js")),Kd=He(()=>import("./ChooseWalksDialog-SM326TOX.js")),zd=He(()=>import("./HighlightColorDialog-SRT2FPXP.js")),Zd=12,Jd=[{bp:0,label:"None"},{bp:3,label:"Under 3 bp"},{bp:10,label:"Under 10 bp"},{bp:50,label:"Under 50 bp, leaving structural variants"},{bp:1e3,label:"Under 1 kb"}];function Qd(e){if(typeof e.uri=="string")return e.uri;let n=e.segmentsLocation?.uri;return typeof n=="string"&&n.endsWith(mt)?n.slice(0,-mt.length):void 0}var eu=1.15,tu=1.6,nu=150,ou=1,ru=40,su=[{value:"each",label:"A tube per haplotype"},{value:"grouped",label:"A tube per haplotype, grouped by route"},{value:"bundled",label:"A tube per route"}],zs={nodeStrokes:[],nodeStrokeRuns:new Map,arrows:[],arrowRuns:new Map,edgeCurves:[],edgeCurveRuns:new Map};function au(...e){}var Zs=5e6;function iu(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:`${Math.round(e/1e3)} kb`}var Js=2e4;function cu(e){return("uri"in e?e.uri.split(/[?#]/)[0]:"localPath"in e?e.localPath:"name"in e?e.name:"").split(/[\\/]/).at(-1)??""}function lu(e){return e&&"uri"in e&&e.uri?new URL(e.uri,e.baseUri??window.location.href).href:void 0}function fu(e){return e.builtViewport!==void 0&&e.paintedViewport===e.builtViewport&&e.builtViewport.viewportDirty===e.viewportDirty&&!e.viewportRebuildPending}function du(e){let{width:t,height:n}=e.viewBox;return It(e,e.axisScale,t,n)}var uu=$t(),pu=k.compose("GraphPane",yo(),k.model({layoutQuality:k.optional(k.number,2),layoutEngine:et($n,"fmmm"),linearLayout:k.optional(k.boolean,!1),bubbleSpread:et(Zn,"auto"),tubeMapFold:k.optional(k.number,0),tubeMapRoutes:et(["each","grouped","bundled"],"each"),tubeMapColorBy:k.optional(k.string,""),geneTrackId:k.optional(k.string,""),repeatTrackId:k.optional(k.string,""),repeatKey:k.optional(k.string,""),walkLayers:k.optional(k.frozen(),[]),referencePath:k.optional(k.string,""),showPerf:k.optional(k.boolean,!1),connectorThickness:k.optional(k.number,2),scale:k.optional(k.number,1),translateX:k.optional(k.number,0),translateY:k.optional(k.number,0),paneHeight:k.maybe(k.number),maxGraphNodes:k.optional(k.number,Js),connectedViewId:k.maybe(k.string),maxRegionBp:k.optional(k.number,Zs),subgraphContext:k.optional(k.number,1),subgraphHaplotypes:k.maybe(k.frozen())})).volatile(()=>({graph:void 0,walkCut:void 0,graphRegion:void 0,loadedReferencePath:void 0,layoutResult:void 0,drawnLayoutMode:void 0,legendSize:{width:0,height:0},indexBubbles:void 0,foldedBelowBp:void 0,geneTrackFeatures:void 0,walkGeneFeatures:void 0,walkRowSampleTable:void 0,repeatArrays:void 0,handledLayoutMode:void 0,openBubbles:[],error:void 0,isLoading:!1,loadCanceled:!1,statusMessage:"",hoveredNode:null,hoveredAt:null,hoveredTube:null,hoveredPanel:null,hoveredRowWalks:[],hoveredBubble:null,pointerInPane:!1,stripHover:null,hoveredWalkRow:null,hoveredEdge:null,selectedNode:null,viewportDirty:0,positionsVersion:0,morphEntering:void 0,drawnBatch:zs,builtViewport:void 0,paintedViewport:void 0,draggingNode:null,isPanning:!1,viewportOwner:"fit",viewportDirtyTimer:void 0,positionsDirtyFrame:0,lastFetchMs:void 0,readsShown:void 0,lastLayoutMs:void 0,lastGeometryMs:void 0,lastGeometryStrokeCount:void 0,viewportRebuildPending:!1}));var D=e=>+e.toFixed(1),Qs=e=>+e.toFixed(3);function ea(e){let t=/^rgba?\(([^,]+),([^,]+),([^,)]+)(?:,([^)]+))?\)$/.exec(e.replaceAll(" ",""));if(!t)return{color:e,opacity:1};let n=t[4]===void 0?1:Number(t[4]);return{color:`rgb(${t[1]},${t[2]},${t[3]})`,opacity:n}}function Ct(e,t){let{color:n,opacity:o}=ea(t);return`${e}="${n}"${o<1?` ${e}-opacity="${Qs(o)}"`:""}`}var Mo=.5,vo=.25;function mu(e,t){let n=[],o=[],r=(l,d)=>{let u={d:`M${D(l)} ${D(d)}`,segments:0,x0:l,x1:l,y0:d,y1:d};return o.push(u),u},s=l=>{let d=o.at(-1)??r(l[0],l[1]);for(let u=0;u<l.length;u+=2)d.x0=Math.min(d.x0,l[u]),d.x1=Math.max(d.x1,l[u]),d.y0=Math.min(d.y0,l[u+1]),d.y1=Math.max(d.y1,l[u+1]);return d.segments++,d},a=l=>{let d=new Set;return o.map(u=>{if(!l||u.x1-u.x0>=Mo||u.y1-u.y0>=Mo)return u.d;let f=(u.x0+u.x1)/2,p=(u.y0+u.y1)/2,h=`${Math.round(f/vo)} ${Math.round(p/vo)}`;return u.segments===0||d.has(h)?"":(d.add(h),`M${D(f)} ${D(p)}h0`)}).join("")},i={canvas:void 0,fillStyle:"#000",strokeStyle:"#000",lineWidth:1,lineCap:"butt",lineJoin:"miter",beginPath(){o=[]},moveTo(l,d){r(l,d)},lineTo(l,d){s([l,d]).d+=`L${D(l)} ${D(d)}`},bezierCurveTo(l,d,u,f,p,h){s([l,d,u,f,p,h]).d+=`C${D(l)} ${D(d)} ${D(u)} ${D(f)} ${D(p)} ${D(h)}`},closePath(){let l=o.at(-1);l&&(l.d+="Z")},stroke(){let l=a(i.lineCap!=="butt");l&&n.push(`<path d="${l}" fill="none" ${Ct("stroke",i.strokeStyle)} stroke-width="${D(i.lineWidth)}" stroke-linecap="${i.lineCap}" stroke-linejoin="${i.lineJoin}"/>`)},fill(){let l=a(!1);l&&n.push(`<path d="${l}" ${Ct("fill",i.fillStyle)}/>`)},clearRect(){n.length=0},fillRect(l,d,u,f){n.push(`<rect x="${D(l)}" y="${D(d)}" width="${D(u)}" height="${D(f)}" ${Ct("fill",i.fillStyle)}/>`)}},c={width:e,height:t,style:{},getContext:()=>i};return i.canvas=c,{canvas:c,markup:()=>n.join("")}}var So=2,Eo=8192;function Se(e=0,t=0){let n=typeof devicePixelRatio>"u"?1:Math.min(devicePixelRatio,So);return Math.min(n,Eo/Math.max(e,t,1))}function Lt(e,t,n){let o=Se(t,n),r=Math.round(t*o),s=Math.round(n*o);(e.width!==r||e.height!==s)&&(e.width=r,e.height=s);let a=`${t}px`,i=`${n}px`;return e.style.width!==a&&(e.style.width=a),e.style.height!==i&&(e.style.height=i),o}var wu=class{constructor(e){this.transform=null,this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.highlightFactor=1,this.fit=1;let t=e.getContext("2d");if(!t)throw new Error("Canvas 2D context not available");this.canvas=e,this.ctx=t}setErrorHandler(e){}releaseOffscreenTargets(){}resize(e,t){this.fit=Lt(this.canvas,e,t)/Se()}uploadGeometry(e){this.batch=e,this.highlightedEdge=null}setNodeHighlights(e){this.nodeHighlights=e}setEdgeHighlight(e,t){this.highlightedEdge=e,this.highlightFactor=t}updateTransform(e){this.transform=e}fitted(){let e=this.transform,t=this.fit;return!e||t===1?e:{...e,scaleX:e.scaleX*t,scaleY:e.scaleY*t,translateX:e.translateX*t,translateY:e.translateY*t,dpr:e.dpr*t}}render(e){let t=this.fitted();if(!t)return;let n=this.ctx,{width:o,height:r}=n.canvas;e[3]<1&&n.clearRect(0,0,o,r),n.fillStyle=Et([e[0],e[1],e[2]],e[3]),n.fillRect(0,0,o,r);let s=this.batch;if(!s)return;n.lineCap="round",n.lineJoin="round";let a=this.highlightFactor,i=this.edgeRun(s.edgeCurveRuns);for(let{color:d,items:u}of Ee(s.edgeCurves,(f,p)=>({color:tt(i,p)?ie(f.color,a):f.color,weight:f.thickness,last:tt(i,p)})))this.strokeCurves(u,d,t);let c=this.liftedStrokes(s);for(let{color:d,items:u}of Ee(s.nodeStrokes,(f,p)=>{let h=c.get(p);return{color:h===void 0?f.color:ie(f.color,h),weight:f.thickness,last:h!==void 0}}))this.strokeNodes(u,d,t);let l=this.edgeRun(s.arrowRuns);for(let{color:d,items:u}of Ee(s.arrows,(f,p)=>({color:tt(l,p)?ie(f.color,a):f.color,weight:0,last:tt(l,p)})))this.fillArrows(u,d,t)}renderHighlights(){let e=this.ctx;e.clearRect(0,0,e.canvas.width,e.canvas.height);let t=this.batch,n=this.fitted();if(!n||!t)return;e.lineCap="round",e.lineJoin="round";let o=this.highlightFactor,r=ko(t.edgeCurves,this.edgeRun(t.edgeCurveRuns));for(let{color:i,items:c}of Ee(r,l=>({color:ie(l.color,o),weight:l.thickness,last:!1})))this.strokeCurves(c,i,n);let s=[...this.liftedStrokes(t)];for(let{color:i,items:c}of Ee(s,([l,d])=>({color:ie(t.nodeStrokes[l].color,d),weight:t.nodeStrokes[l].thickness,last:!1})))this.strokeNodes(c.map(([l])=>t.nodeStrokes[l]),i,n);let a=ko(t.arrows,this.edgeRun(t.arrowRuns));for(let{color:i,items:c}of Ee(a,l=>({color:ie(l.color,o),weight:0,last:!1})))this.fillArrows(c,i,n)}edgeRun(e){return this.highlightedEdge===null?void 0:e.get(this.highlightedEdge)}liftedStrokes(e){let t=new Map;for(let[n,o]of this.nodeHighlights){let r=e.nodeStrokeRuns.get(n);if(r)for(let s=r.start;s<r.start+r.count;s++)t.set(s,o)}return t}strokeCurves(e,t,n){let o=this.ctx;o.strokeStyle=ae(t),o.lineWidth=e[0].thickness*2*n.dpr,o.beginPath();for(let r of e){let s=r.curves[0];o.moveTo(s.x0*n.scaleX+n.translateX,s.y0*n.scaleY+n.translateY);for(let a of r.curves)o.bezierCurveTo(a.cx0*n.scaleX+n.translateX,a.cy0*n.scaleY+n.translateY,a.cx1*n.scaleX+n.translateX,a.cy1*n.scaleY+n.translateY,a.x1*n.scaleX+n.translateX,a.y1*n.scaleY+n.translateY)}o.stroke()}strokeNodes(e,t,n){let o=this.ctx;o.strokeStyle=ae(t),o.lineWidth=e[0].thickness*2*n.dpr,o.beginPath();for(let r of e){let s=r.points[0];o.moveTo(s.x*n.scaleX+n.translateX,s.y*n.scaleY+n.translateY);for(let a=1,i=r.points.length;a<i;a++){let c=r.points[a];o.lineTo(c.x*n.scaleX+n.translateX,c.y*n.scaleY+n.translateY)}}o.stroke()}fillArrows(e,t,n){let o=this.ctx;o.fillStyle=ae(t),o.beginPath();for(let r of e){let[s,a,i,c]=na(r,n);o.moveTo(s.x,s.y),o.lineTo(a.x,a.y),o.lineTo(i.x,i.y),o.lineTo(c.x,c.y),o.closePath()}o.fill()}dispose(){this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null}},ta=.25;function na(e,t){let n=Math.cos(e.angle),o=Math.sin(e.angle),r=e.x*t.scaleX+t.translateX,s=e.y*t.scaleY+t.translateY,a=e.length*t.dpr,i=e.halfWidth*t.dpr,c=r-n*a,l=s-o*a,d=a*(1-ta);return[{x:r,y:s},{x:c-o*i,y:l+n*i},{x:r-n*d,y:s-o*d},{x:c+o*i,y:l-n*i}]}function ko(e,t){return t?e.slice(t.start,t.start+t.count):[]}function tt(e,t){return e!==void 0&&t>=e.start&&t<e.start+e.count}function Ee(e,t){let n=new Map,o=new Map;for(let r=0,s=e.length;r<s;r++){let a=e[r],{color:i,weight:c,last:l}=t(a,r),d=l?o:n,u=`${i}:${c}`,f=d.get(u);f?f.items.push(a):d.set(u,{color:i,items:[a]})}return[...n.values(),...o.values()]}var oa=50;function Ro(e,t){return t>0?Math.max(1,e/t):oa}function ra(e){let t=new Set,n=1/0,o=-1/0;for(let r of e)t.add(r.minY),n=Math.min(n,r.minY),o=Math.max(o,r.minY);return t.size>1?(o-n)/(t.size-1):void 0}function To(e,t,n){let o=Ro(t,e.length);return{x:o,y:n>0?Ro(n,e.length):ra(e)??o}}function sa(e,t,n,o){return e===void 0?To(t,n,o):typeof e=="number"?{x:e,y:e}:e}function aa(e,t,n){let o=e.get(t);o||(o=new Map,e.set(t,o));let r=o.get(n);return r||(r=[],o.set(n,r)),r}function Ao(e,t,n,o,r,s,a){let i=Math.floor(n/t.x),c=Math.floor(r/t.x),l=Math.floor(o/t.y),d=Math.floor(s/t.y);for(let u=i;u<=c;u++)for(let f=l;f<=d;f++)aa(e,u,f).push(a)}function _o(e,t,n,o,r,s){let a=Math.floor((n-r)/t.x),i=Math.floor((n+r)/t.x),c=Math.floor((o-s)/t.y),l=Math.floor((o+s)/t.y),d=[],u=new Set;for(let f=a;f<=i;f++){let p=e.get(f);if(p)for(let h=c;h<=l;h++){let m=p.get(h);if(m)for(let b of m)u.has(b)||(u.add(b),d.push(b))}}return d}var Oo=class{constructor(e,t){this.cells=new Map;let n=[],o=0,r=0;for(let[s,a]of Object.entries(e))for(let i=0;i<a.length-1;i++){let c=a[i],l=a[i+1],d=Math.min(c.x,l.x),u=Math.min(c.y,l.y),f=Math.max(c.x,l.x),p=Math.max(c.y,l.y);o+=f-d,r+=p-u,n.push({entry:{nodeId:s,segmentIdx:i},minX:d,minY:u,maxX:f,maxY:p})}this.cellSize=sa(t,n,o,r);for(let s of n)Ao(this.cells,this.cellSize,s.minX,s.minY,s.maxX,s.maxY,s.entry)}query(e,t,n,o=n){return _o(this.cells,this.cellSize,e,t,n,o)}},No=class{constructor(e,t,n,o,r,s=0,a,i=!1){this.cells=new Map,this.edgeCurves=Kn(e,t,o,r,s,a,i);let c=[],l=0,d=0;for(let u=0;u<t.edges.length;u++){let f=t.edges[u],p=e[f.from],h=e[f.to],m=this.edgeCurves.get(u);if(p?.length&&h?.length&&m){let{minX:b,minY:g,maxX:y,maxY:M}=Bn(m),x=f.pathIds?.length??0;if(n&&x>0){let w=0,v=0;for(let E of je(p,h,x,o))w=Math.max(w,Math.abs(E.x)),v=Math.max(v,Math.abs(E.y));b-=w,g-=v,y+=w,M+=v}l+=y-b,d+=M-g,c.push({ei:u,minX:b,minY:g,maxX:y,maxY:M})}}this.cellSize=To(c,l,d);for(let u of c)Ao(this.cells,this.cellSize,u.minX,u.minY,u.maxX,u.maxY,u.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,t,n,o=n){return _o(this.cells,this.cellSize,e,t,n,o)}};function $o(e,t,n,o,r,s){let a=r-n,i=s-o,c=a*a+i*i;if(c===0)return Math.hypot(e-n,t-o);let l=Math.max(0,Math.min(1,((e-n)*a+(t-o)*i)/c));return Math.hypot(e-(n+l*a),t-(o+l*i))}function ia(e,t,n){let o=1/0,r=20,s=n.x0,a=n.y0;for(let i=1;i<=r;i++){let c=i/r,l=1-c,d=l*l*l*n.x0+3*l*l*c*n.cx0+3*l*c*c*n.cx1+c*c*c*n.x1,u=l*l*l*n.y0+3*l*l*c*n.cy0+3*l*c*c*n.cy1+c*c*c*n.y1;o=Math.min(o,$o(e,t,s,a,d,u)),s=d,a=u}return o}function Po(e,t,n,o=1){let r=1/0;for(let s of n){let a=ia(e,t,o===1?s:{x0:s.x0,y0:s.y0*o,cx0:s.cx0,cy0:s.cy0*o,cx1:s.cx1,cy1:s.cy1*o,x1:s.x1,y1:s.y1*o});a<r&&(r=a)}return r}var ca=xt();function Io(e,t){return ca(e,[t],()=>new Oo(e))}var la=xt();function fa(e,t,n,o,r,s,a,i=!1){return la(e,[t,n,o.scaleX,o.scaleY,r,s,a,i],()=>new No(e,t,n,o,s,r,a,i))}var da=5;function Nu(e,t,n,o,r=0,s){let a=Mt(o),i=Io(e,r),c=p=>Math.max(da,p)/o.scaleX,l=c(s?.maxHalfWidthPx??0),d=i.query(t,n,l,l/a),u=null,f=1/0;for(let{nodeId:p,segmentIdx:h}of d){let m=e[p],b=$o(t,n*a,m[h].x,m[h].y*a,m[h+1].x,m[h+1].y*a);b<f&&b<c(s?.halfWidthPx(p)??0)&&(f=b,u=p)}return u}function ua(e,t,n){let o=t.x-e.x,r=t.y-e.y,s=0,a=1;for(let[i,c]of[[-o,e.x-n.x0],[o,n.x1-e.x],[-r,e.y-n.y0],[r,n.y1-e.y]])if(i===0){if(c<0)return!1}else i<0?s=Math.max(s,c/i):a=Math.min(a,c/i);return s<=a}function Co(e,t,n=0){let o=Io(e,n),r=s=>({x:s.x*t.scaleX+t.translateX,y:s.y*t.scaleY+t.translateY});return s=>{let a=new Set,i=o.query(((s.x0+s.x1)/2-t.translateX)/t.scaleX,((s.y0+s.y1)/2-t.translateY)/t.scaleY,Math.abs((s.x1-s.x0)/2/t.scaleX),Math.abs((s.y1-s.y0)/2/t.scaleY));for(let{nodeId:c,segmentIdx:l}of i){let d=e[c];!a.has(c)&&ua(r(d[l]),r(d[l+1]),s)&&a.add(c)}return a}}function Pu(e,t,n,o,r,s,a=0,i,c,l,d=!1){let u=Mt(r),f=10/r.scaleX,p=fa(e,t,s,r,a,i,l,d),h=p.query(n,o,f,f/u),m=null,b=f;for(let g of h){let y=t.edges[g],M=e[y.from],x=e[y.to];if(!M?.length||!x?.length||c?.has(g))continue;let w=y.pathIds?.length??0,v=p.getCurves(g);if(!v)continue;let E;if(!s||w===0)E=Po(n,o*u,v,u);else{let O=1/0;for(let A of je(M,x,w,r)){let X=A.x===0&&A.y===0?v:Xn(v,A.x,A.y),j=Po(n,o*u,X,u);j<O&&(O=j)}E=O}E<b&&(b=E,m=g)}return m}var Lo=3.4,Bt=6,pa=18,ha=2,ma=3,ga=In+Cn;function Bo(e){let t=e.gene.end-e.gene.start;if(e.covered>=.98)return;let[n,o]=t>=1e6?[1e6,"Mb"]:t>=1e3?[1e3,"kb"]:[1,"bp"],r=s=>+(s/n).toFixed(n===1?0:1);return`${r(e.covered*t)} of ${r(t)} ${o}`}function Xo(e,t,n,o){let r=n/2;return Fo(e,s=>s.gene.end-s.gene.start).map(s=>{let{x:a,y:i}=t(s.at),c=Bo(s);return{item:s,x:a,y:i+n+pa,text:c?`${s.gene.name} \xB7 ${c}`:s.gene.name,fallback:c?`${s.gene.name} \u2026`:void 0,stack:ha,fits:l=>[...o({x0:l.x0-r,x1:l.x1+r,y0:l.y0-r,y1:l.y1+r})].every(d=>s.nodeIds.has(d))}})}function Fo(e,t){return[...e].sort((n,o)=>t(o)-t(n))}function ba(e){let{paneWidth:t,canvasHeight:n,translateX:o,translateY:r}=e,{scaleX:s,scaleY:a}=e.axisScale,i={width:t,height:n},c=w=>({x:w.x*s+o,y:w.y*a+r}),l=e.drawnRowLabels.map(({label:w,y:v})=>vt(w,v*a+r)),d=e.referenceStripZonePx??0;d>0&&l.push({x0:0,x1:t,y0:0,y1:d}),e.legendSize.width>0&&l.push({x0:t-Bt-e.legendSize.width,x1:t,y0:0,y1:d+Bt+e.legendSize.height}),e.poppedFrom&&l.push({x0:0,x1:60+e.poppedFrom.label.length*Oe*1.2,y0:0,y1:44});let u=Ln(i,l),f=e.drawnRowLabels.length>0,p=f?Math.min(...e.drawnRowLabels.map(w=>w.y)):1/0,h=e.contigThickness*Lo,m=(w,v)=>{let{x:E,y:O}=c({x:w.labelAt.x,y:Math.min(w.labelAt.y,p)}),A=O-h/2-v;return{x:E,y:f?Math.max(A,ga):A}},b=Fo(e.bubbleHalos.filter(w=>!w.tick),w=>w.whole?-1:w.members),g=yt(b.map(w=>({item:w,...m(w,6),text:w.label,fallback:w.label.includes(",")?w.label.split(",")[0]:void 0,stack:ma})),i,u),y=e.bubbleHalos.filter(w=>w.tick&&!w.whole).map(w=>({item:w,...m(w,2)})).filter(w=>w.x>=0&&w.x<=t&&w.y>=0&&w.y<=n),M=yt(Xo(e.genePins,c,e.contigThickness,Co(e.nodePositions??{},{scaleX:s,scaleY:a,translateX:o,translateY:r},e.positionsVersion)),i,u),x=e.nodePositions&&e.labelsNodeSizes?St({nodePositions:e.nodePositions,nodeLengths:e.nodeLengths,deletions:e.deletions,deletionRoutes:e.deletionRoutes,stranded:e.stranded,alleleDeletions:e.alleleDeletions,axis:e.axisScale,translateX:o,translateY:r,width:t,height:n,version:e.positionsVersion,take:u}):[];return{bubbles:g,ticks:y,genes:M,sizes:x}}var pe=JBrowseExports.mobx,ke=e=>pe!=null&&e in Object(pe)?pe[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from 'mobx' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var Qu=ke("autorun");var ep=ke("computed");var Do=ke("observable");var tp=ke("reaction");var qo=ke("runInAction");var np=ke("untracked");var op=pe&&pe.__esModule?pe.default:pe;function Xt(e){return e.id.endsWith("-")?"-":"+"}function Ft(e,t){return t===Xt(e)?e.id:`-${e.id}`}function xa(e,t){let n=e.map(()=>{}),o=0,r=0;for(;r<e.length&&e[r]!==void 0;r++)n[r]=o,o+=e[r];let s=t;for(let a=e.length-1;a>r&&e[a]!==void 0;a--)s-=e[a],n[a]=s;return n}function ya(e,t){let n=e.path.map(()=>[]);if(e.cs===void 0)return n;let o=xa(t,e.pathLength),r=o.flatMap((f,p)=>f===void 0?[]:[p]),s=f=>o[r[f]],a=f=>s(f)+t[r[f]],i=0,c=f=>{for(;i<r.length&&a(i)<f;)i++;for(let p=i;p<r.length&&s(p)<=f;p++){let h=a(p);if(f<h)return{s:r[p],local:f-s(p),room:h-f}}},l=f=>{for(let p=i;p<r.length;p++)if(s(p)>f)return s(p)-f;return 1/0},d=(f,p)=>{let h=n[f],m=h.at(-1);p.type==="substitution"&&m?.type==="substitution"&&m.pos+m.seq.length===p.pos?m.seq+=p.seq:h.push(p)},u=e.pathStart;for(let f of Nn(e.cs))if(f.op==="match")u+=f.length;else if(f.op==="substitution"){let p=c(u);p&&d(p.s,{type:"substitution",pos:p.local,seq:f.seq}),u+=1}else if(f.op==="insertion"){let p=u>e.pathStart&&u<e.pathEnd?c(u):void 0;p&&d(p.s,{type:"insertion",pos:p.local,seq:f.seq})}else{let p=f.length;for(;p>0;){let h=c(u),m=Math.min(p,h?h.room:l(u));h&&d(h.s,{type:"deletion",pos:h.local,length:m}),u+=m,p-=m}}return n}function Go(e,t,n){let o=new Map(e.nodes.map(s=>[s.name,s])),r=[];for(let s of t){let a=s.path.map(d=>o.get(d.name)),i=a.flatMap((d,u)=>d?[u]:[]),c=i[0],l=i.at(-1);if(c!==void 0&&l!==void 0){let d=ya(s,a.map(p=>p?.length)),u=i.map(p=>Ft(a[p],s.path[p].strand)),f=a[l].length;r.push({id:n+r.length,name:s.name,type:"read",sourceTrackID:1,sequence:u,sequenceNew:i.map((p,h)=>({nodeName:u[h],mismatches:d[p]})),firstNodeOffset:c===0?s.pathStart:0,finalNodeCoverLength:l===s.path.length-1?f-(s.pathLength-s.pathEnd):f,mapping_quality:s.mappingQuality===255?void 0:s.mappingQuality,is_secondary:s.secondary,is_reverse:s.strand==="-"})}}return r}var wa=["#6baed6","#4292c6","#2171b5","#08519c"],Ma=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function Wo(e){let t=e.is_reverse?Ma:wa;return t[e.id%t.length]}function P(e,t={},...n){return{tag:e,attrs:t,children:n.filter(o=>!!o||o==="")}}function Yo(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function va(e){return Yo(e).replaceAll('"',"&quot;")}function Sa(e){if(typeof e=="string")return Yo(e);let t=Object.entries(e.attrs).filter(([,n])=>n!==void 0).map(([n,o])=>` ${n}="${va(String(o))}"`).join("");return`<${e.tag}${t}>${e.children.map(Sa).join("")}</${e.tag}>`}var Ht="#2f8fd6",Ut="#8e3fbf",Ho="#bdbdbd",Uo="#8a8a8a",jo="#e2e2e2",Ie="#1c1c22",jt=12,Gt=4,Vo=1,Wt=12,Ea=6,ka=3;function ce(e){return`${(e/1e3).toFixed(e<1e4?1:0)} kb`}function Ra(e){let t=Math.abs(e);return`${e>0?"+":"\u2212"}${t<1e3?`${t} bp`:ce(t)}`}function Dt(e,t){return t?` \u2248 ${Math.round(e/t)} units`:""}var Ta=({refName:e,start:t})=>`${We(e)}:${t<1e6?`${Math.round(t/1e3)} kb`:`${(t/1e6).toFixed(1)} Mb`}`;function Aa(e,t){let n=(t??[]).filter(a=>a.gap);if(e<=0)return"";if(!n.some(a=>a.cause))return` \xB7 ${ce(e)} ${Me}`;let o=a=>n.filter(i=>i.cause===a).reduce((i,c)=>i+c.bp,0),r=[...new Set(n.flatMap(a=>a.chunk?[Ta(a.chunk)]:[]))];return[[o("missing"),se.missing],[o("elsewhere"),`on nodes filed near ${r[0]}${r.length>1?` and ${r.length-1} more place${r.length>2?"s":""}`:""}`],[o("unknown"),se.unknown],[o(void 0),Me]].filter(([a])=>a>0).map(([a,i])=>` \xB7 ${ce(a)} ${i}`).join("")}function Ko(e,t,n,o){let{bp:r,gapBp:s,complete:a,stop:i}=e;if(!t)return`${ce(r)}${Dt(r,n)}`;let c=Aa(s,e.runs),l=o?` \xB7 called ${ce(o.bp)}${o.spanningReads===0?" \xB7 no spanning read":""}`:"";if(a){let f=r-t.bp,p=f===0?"":` (${Ra(f)})`;return`${ce(r)}${Dt(r,n)}${p}${c}${l}`}let d=n?"repeat":"window";if(i?.contigEnds&&r===0)return`contig ends ${i.shortBp>0?`${ce(i.shortBp)} before`:"at"} the ${d}${l}`;let u=i?i.contigEnds?`contig ends inside the ${d}`:"does not rejoin the reference within the extracted subgraph":"partial walk";return`\u2265 ${ce(r)}${Dt(r,n)} \xB7 ${u}${c}${l}`}function zo(e,t,n){let o=t+6;return o+e.length*Oe<n?{x:o,anchor:"start",halo:!1}:{x:t-6,anchor:"end",halo:!0}}function Zo(e,t,n){if(t*n<ka)return[];let o=[];for(let r=t;r<e;r+=t)o.push(r);return o}function Ce(e){return e==="missing"?{fill:Uo,px:Vo,label:se.missing}:e==="unknown"?{fill:jo,px:Gt,label:se.unknown}:{fill:Ho,px:Gt,label:Me}}function Jo(e,t){if(e.gap)return{fill:Ce(e.cause).fill};if(!t)return{fill:e.onReference?Ht:Ut};if(e.referenceStart===void 0)return{fill:ze};let n=Un({...e,start:e.referenceStart},t);return n.length===1?{fill:kt(n[0])}:{stops:n.map(kt)}}function Yt(e,t,n){return e.reversed?{start:e.start-n,end:e.start-t}:{start:t-e.start,end:n-e.start}}function _a(e,t){return e.reversed?{start:e.start-t,end:e.start}:{start:e.start,end:e.start+t}}function Oa(e,t){let n=new Map;for(let o of e){let r=t.get(o.name);if(!o.axis||!r)continue;let s=o.axis,a=({start:i,end:c})=>({start:Math.max(0,i),end:Math.min(o.bp,c)});n.set(o.name,r.map(i=>({name:i.name,...a(Yt(s,i.start,i.end)),exons:i.exons.map(c=>a(Yt(s,c.start,c.end))).filter(c=>c.end>c.start)})).filter(i=>i.end>i.start).sort((i,c)=>i.start-c.start))}return n}var Na=9,Pa=5.2,$a=8,Qo=(e,t)=>Math.min(2,(e-t)/2-1);function er(e,t){return Qo(e,t)>=1}function tr(e,t,n,{rowPx:o=Ue,barPx:r=jt}={}){if(!er(o,r))return[];let s=Qo(o,r),a=e.map(l=>{let d=t(l.start);return{g:l,x:d,w:Math.max(2,t(l.end)-d)}}),i=[],c=new Set((r>=$a?[...a]:[]).sort((l,d)=>l.w-d.w).filter(({g:l,x:d,w:u})=>{let f=l.name.length*Pa/2,p=[d+u/2-f,d+u/2+f];return 2*f>u+6||i.some(([h,m])=>p[0]<m+2&&p[1]>h-2)?!1:(i.push(p),!0)}));return a.map(l=>({name:l.g.name,x:l.x,y:n-r/2-s,w:l.w,h:r+2*s,exons:l.g.exons.map(d=>({x:t(d.start),w:Math.max(1,t(d.end)-t(d.start))})),label:c.has(l)?{x:l.x+l.w/2,y:n+3,size:Na}:void 0}))}var qt=e=>`${e} row${e===1?"":"s"}`;function Ia(e,t={}){let n=[{swatch:t.ramp?{kind:"bar",fill:t.rampCss??Vn,ramp:!0}:{kind:"bar",fill:Ht},label:`on ${e.reference.label}'s path`},{swatch:{kind:"bar",fill:t.ramp?ze:Ut},label:`off ${e.reference.label}'s path`}],o=[e.reference,...e.rows].flatMap(s=>s.runs.filter(a=>a.gap)),r=new Set(o.map(s=>Ce(s.cause).label));for(let s of[void 0,"missing","unknown"]){let{fill:a,px:i,label:c}=Ce(s);r.has(c)&&n.push({swatch:{kind:"gap",fill:a,px:i},label:c})}return t.genes?.crowded?n.push({swatch:{kind:"gene"},label:"genes left out: too many rows to box them in",note:!0}):t.genes&&(n.push({swatch:{kind:"gene"},label:"gene"}),t.genes.untracked&&n.push({swatch:{kind:"gene"},label:`no gene track for ${qt(t.genes.untracked)}`,note:!0}),t.genes.unplaced&&n.push({swatch:{kind:"gene"},label:`no contig coordinates for ${qt(t.genes.unplaced)}`,note:!0}),t.genes.unread&&n.push({swatch:{kind:"gene"},label:`genes not read for the last ${qt(t.genes.unread)}`,note:!0})),n}var nr="#111",or="#9e9e9e",Vt="#c62828";function rr(e){return e.agrees===!1?Vt:e.spanningReads===0?or:nr}function Ca(e,t,n,o="walk-key"){let r=0,s=e.flatMap((a,i)=>{let c=`${o}-ramp-${i}`,l=!a.note&&a.swatch.kind==="bar"&&a.swatch.ramp?P("linearGradient",{id:c},...jn.map(f=>P("stop",{offset:f.offset,"stop-color":f.color}))):void 0,d=a.note?void 0:a.swatch.kind==="gene"?P("rect",{x:r,y:5,width:18,height:8,fill:"none",stroke:Ie,"stroke-width":1.5}):P("rect",{x:r,y:a.swatch.kind==="gap"?9-a.swatch.px/2:5,width:18,height:a.swatch.kind==="gap"?a.swatch.px:8,rx:2,fill:l?`url(#${c})`:a.swatch.fill}),u=P("text",{x:a.note?r:r+23,y:13,"font-style":a.note?"italic":void 0,fill:a.note?"#666":void 0},a.label);return r+=(a.note?0:23)+a.label.length*Oe+16,[l,d,u].filter(f=>f!==void 0)});return{width:r,tree:P("g",{transform:`translate(${t} ${n})`,"font-family":"Helvetica, Arial, sans-serif","font-size":11},...s)}}function La(e,t,n=0){let o=t/Math.max(1,e),r=Math.max(n,Math.min(Ue,o>=1?Math.floor(o):o));return{rowPx:r,barPx:r<=3?r:Math.max(3,Math.round(r*.6)),labelled:r>=Wt,readouts:r>=Wt}}function sr(e,t){let n=1/t,o=[],r=[],s=()=>{if(r.length!==0){if(r.length===1)o.push(r[0]);else{let i=0,c=0;for(let u of r)u.onReference?i+=u.bp:c+=u.bp;let l=i>=c,d=r.find(u=>u.onReference===l);o.push({start:r[0].start,bp:i+c,onReference:l,referenceStart:l?d.referenceStart:void 0,...d.reversed?{reversed:!0}:{}})}r=[]}},a=0;for(let i of e){if(i.gap||i.bp>=n){s(),a=0,o.push(i);continue}r.push(i),a+=i.bp,a>=n&&(s(),a=0)}return s(),o}function Ba(e,t,n){return P("g",{class:"row-gene","data-testid":"graph-walk-gene"},P("title",{},e.name),...e.exons.map(o=>P("rect",{x:o.x,y:t-n/2,width:o.w,height:n,fill:Ie,opacity:.35})),P("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:Ie,"stroke-width":1.5}),e.label&&P("text",{x:e.label.x,y:e.label.y,"font-family":"sans-serif","font-size":e.label.size,"font-weight":600,"text-anchor":"middle",fill:Ie,stroke:"white","stroke-width":2.5,"paint-order":"stroke"},e.name))}function Le(e,t,n={}){let o=m=>m*t.scaleX+t.translateX,r=t.rowPx??Ue,s=t.barPx??jt,a=Math.min(3,Math.max(0,(r-s)/2)),i=m=>m*r*t.scaleY+t.translateY,{origin:c,unit:l,reference:d,rows:u}=e,f=m=>o(c+m),p=n.idPrefix??"walkrow",h=(m,b)=>{let g=i(b);if(g<-s||g>t.height+s)return;let y=t.bars===!1?[]:m.runs,M=sr(y,t.scaleX).flatMap(A=>{let X=Jo(A,n.ramp),j=A.gap?Math.min(Ce(A.cause).px,s):s,U=`${p}-${b}-${A.start}`,z=P("rect",{x:f(A.start),y:g-j/2,width:Math.max(1,A.bp*t.scaleX),height:j,fill:"stops"in X?`url(#${U})`:X.fill});return"stops"in X?[P("linearGradient",{id:U},...X.stops.map((Q,R)=>P("stop",{offset:R/(X.stops.length-1),"stop-color":Q}))),z]:[z]}),x=l&&s>=Ea?Zo(m.bp,l,t.scaleX).map(A=>P("line",{x1:f(A),x2:f(A),y1:g-s/2,y2:g+s/2,stroke:"white","stroke-width":1})):[],{call:w}=m,v=Ko(m,b===0?void 0:d,l,w),E=zo(v,f(m.bp),t.width),O=t.readouts??!0;return P("g",{"data-testid":b===0?"graph-walk-reference":"graph-walk-row"},...M,...x,...tr(n.rowGenes?.get(m.name)??[],f,g,{rowPx:r,barPx:s}).map(A=>Ba(A,g,s)),w&&P("rect",{"data-testid":"graph-walk-call",x:f(w.bp)-1,y:g-s/2-a,width:2,height:s+2*a,fill:rr(w)}),O&&P("text",{x:E.x,y:g+4,"font-family":"sans-serif","font-size":11,fill:w?.agrees===!1?Vt:"#333",stroke:E.halo?"white":void 0,"stroke-width":E.halo?3:void 0,"paint-order":"stroke","text-anchor":E.anchor},v))};return P("g",{},...[d,...u].map(h))}var Xa=10;function Fa(e,t){let n=e.end-e.start,o=e.longestAlleleLength-e.shortestAlleleLength;return t.find(r=>o<=Xa*(r.end-r.start)&&(n===0?r.start<=e.start&&e.start<=r.end:Math.min(e.end,r.end)-Math.max(e.start,r.start)>=n/2))}var Da=40;function qa(e,t){let n=B(e),o=B(t),r=o.slice(o.indexOf(" "));return n.endsWith(r)?`${n.slice(0,-r.length)}\u2013${o}`:`${n}\u2013${o}`}function Kt(e){return e>=Qn?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function Ga(e,t=[]){let n=Wa(e,t);return e.partial?{...n,label:`${n.label}, partial`}:n}function Wa(e,t){let n=e.end-e.start,{shortestAlleleLength:o,longestAlleleLength:r,pathCount:s,segmentCount:a,inversion:i}=e,c=qa(o,r);if(a>=Da)return{kind:"superbubble",label:`${c} superbubble, ${a} segments, ${Kt(s)}${i?", inv":""}`};if(i)return{kind:"inversion",label:`${B(r)} inv`};if(e.offReference)return o===r?ar(o):{kind:"complex",label:`${c}, ${Kt(s)}`};let l=r!==o?Fa(e,t):void 0;if(l){let u=l.name?` (${l.name})`:"";return{kind:"repeat",label:`${c} repeat array${u}, ${Kt(s)}`}}let d=s>2?`, ${s} alleles`:"";return o===r&&o===n?ar(n):n===0||o===n?{kind:"insertion",label:`\u2264${B(r-n)} ins${d}`}:r===n?{kind:"deletion",label:`${B(n-o)} del${d}`}:{kind:"complex",label:`${B(n)} ref \u2192 ${c}, ${s} alleles`}}function ar(e){return e<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${B(e)} sub`}}var Ya={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},Ha={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function Ua(e){return e.segments.split(",").filter(Boolean)}function zt({graph:e,layout:t}){let n=new Map(e.nodes.map(r=>[r.id,r])),o=new Map;t.nodes.forEach((r,s)=>{let a=n.get(r.name);if(r.order>=0&&a&&C(a)){let{refName:i,start:c}=a.stable;we(o,i,{name:r.name,index:s,bp0:c,bp1:c+a.length,x0:r.x,x1:r.x+r.pixelWidth})}});for(let r of o.values())r.sort((s,a)=>s.bp0-a.bp0);return o}function nt(e,t,n=!1){let o=fe(e.length-1,r=>n?e[r].bp1<t:e[r].bp1<=t);return Be(e[o],t)}function Be(e,t){let n=e.bp1-e.bp0;return t<=e.bp0||n<=0?e.x0:e.x0+(Math.min(t,e.bp1)-e.bp0)/n*(e.x1-e.x0)}function ot(e,t,n){let o=nt(e,t),r=nt(e,n,!0);return{x0:Math.min(o,r),x1:Math.max(o,r)}}function ja(e){let t;for(let n of e.values())(!t||n.length>t.length)&&(t=n);return t}var ir=5,Va=10,Ka=110,za=3;function cr(e){return e?"#b0b0b8":"#55555c"}function Za(e){let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function lr(e){let t=[];for(let n of e)t.every(o=>Math.abs(n.at-o.at)>=(n.width+o.width)/2+Va)&&t.push(n);return t.map(({text:n,at:o})=>({text:n,at:o}))}function Ja(e,t,n,o){let r=e[0],s=e.at(-1);if(!r||!s)return;let a=t(r.x0),i=t(s.x1),c=s.bp1-r.bp0;if(i<=a||c<=0)return;let l=Za(c/(i-a)*Ka),d=[],u=[];for(let f=Math.ceil(r.bp0/l)*l;f<=s.bp1;f+=l){let p=Math.round(t(nt(e,f)))+.5;if(p>=0&&p<=n){d.push(p);let h=f.toLocaleString("en-US");u.push({text:h,at:p,width:o(h)})}}return{spans:[{x0:a,x1:i}],ticks:d,labels:lr(u)}}function Qa(e,t,n,o){let r=e.map(h=>({box:h,s0:t(h.x0),s1:t(h.x1)})).filter(({s0:h,s1:m})=>m>=0&&h<=n),s=r[0],a=r.at(-1);if(!s||!a)return;let i=(h,m)=>({text:h,at:m,width:o(h)}),c=(h,m)=>i(h.toLocaleString("en-US"),m),l=[],d=[],u=[],f=[];for(let{box:h,s0:m,s1:b}of r){l.push({x0:m,x1:b}),d.push(Math.round(m)+.5),b-m>=za&&d.push(Math.round(b)+.5);let g=i(B(h.bp1-h.bp0),(m+b)/2);g.width<=b-m&&u.push(g),h!==s.box&&f.push(c(h.bp0,m))}let p=[c(s.box.bp0,s.s0),c(a.box.bp1,a.s1)];return{spans:l,ticks:d,labels:lr([...p,...u,...f])}}function fr(e,t,n,o,r=!1){return(r?Ja:Qa)(e,t,n,o)}function ei(e,t,n,o,r=!1){let{x:s,width:a,darkMode:i}=n;e.font="10px sans-serif";let c=fr(t,s,a,u=>e.measureText(u).width,r);if(!c)return;let l=cr(i),d=o+.5;e.strokeStyle=l,e.fillStyle=l,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath();for(let{x0:u,x1:f}of c.spans)e.moveTo(Math.max(0,u),d),e.lineTo(Math.min(a,f),d);for(let u of c.ticks)e.moveTo(u,o),e.lineTo(u,o+ir);e.stroke();for(let{text:u,at:f}of c.labels)e.fillText(u,f,o+ir+2)}function ti(e,t,n,o){let r=[];for(let s of e){let a=n(s.x0),i=n(s.x1);i>=0&&a<=o&&r.push({node:s.name,top0:t(s.bp0),top1:t(s.bp1),bottom0:a,bottom1:i})}return r}var ni=3;function oi(e,t,n,o){if(t<=0||o<0||o>t)return;let r=o/t,s,a=ni;for(let i of e){let c=i.top0+(i.bottom0-i.top0)*r,l=i.top1+(i.bottom1-i.top1)*r,d=Math.max(0,Math.min(c,l)-n,n-Math.max(c,l));d<a&&(a=d,s=i.node)}return s}function dr(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.top1,0),e.lineTo(t.bottom1,n),e.lineTo(t.bottom0,n),e.closePath()}function ur(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.bottom0,n),e.moveTo(t.top1,0),e.lineTo(t.bottom1,n)}function ri(e,t,n,{highlightNode:o,darkMode:r}){if(n<=0||t.length===0)return;let s=r?"255,255,255":"0,0,0";e.beginPath();for(let a of t)dr(e,a,n);e.fillStyle=`rgba(${s},0.07)`,e.fill(),e.beginPath();for(let a of t)ur(e,a,n);e.strokeStyle=`rgba(${s},0.35)`,e.lineWidth=.5,e.stroke(),pr(e,t,n,o)}function pr(e,t,n,o){let r=n>0&&o?t.find(s=>s.node===o):void 0;r&&(e.beginPath(),dr(e,r,n),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),ur(e,r,n),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function hr(e){return e.sample??Ge(e.name)}function si(e){return e.haplotype!==void 0&&e.sample!==void 0?`${e.sample}#${e.haplotype}`:hr(e)}var ai=class{constructor(e){this.index=new Map,this.lengths=[],this.onReference=new Uint8Array(0),this.referenceStart=new Float64Array(0),this.referenceEnd=new Float64Array(0);for(let t of e.nodes)this.lengths[this.indexOf(t.id)]=t.length}indexOf(e){let t=this.index.get(e);return t===void 0&&(t=this.lengths.length,this.index.set(e,t),this.lengths.push(0)),t}nodesOf(e){let t=new Int32Array(e.nodeIds.length);return e.nodeIds.forEach((n,o)=>{t[o]=this.indexOf(n)}),t}spanAt(e,t){let n=t>=0&&t<e.length?e[t]:-1;return n>=0&&this.onReference[n]?{start:this.referenceStart[n],end:this.referenceEnd[n]}:void 0}};function ii(e,t){let n=[],o=[],r,s;for(let a of e){r!==void 0&&a.start!==void 0&&a.start>r&&(o.push(kn(a.start-r,s?.after,a.before)),n.push(-o.length));let i=0;for(let c of a.nodes)n.push(c),i+=t.lengths[c];r=a.start===void 0?void 0:a.start+i,s=a}return{steps:Float64Array.from(n),gaps:o}}function ci(e,t,n){let o,r=0,s;for(let a of e){if(a.start===void 0||o!==void 0&&a.start<o)return;o!==void 0&&a.start>o&&r++===n&&(s={start:o,end:a.start});let i=a.start;for(let c of a.nodes){let l=t.lengths[c];r++===n&&(s={start:i,end:i+l}),i+=l}o=i}return s}function li(e,t,n,o=!0){if(!n||!o)return{ids:e,complete:!0,from:-1,to:-1};let{onReference:r,referenceStart:s,referenceEnd:a}=t,i=-1,c=-1,l=-1/0,d=1/0;for(let x=0;x<e.length;x++){let w=e[x];if(w>=0&&r[w]){let v=a[w],E=s[w];v<=n.start&&v>l&&(l=v,i=x),E>=n.end&&E<d&&(d=E,c=x)}}if(i>=0&&c>=0){let x=e.slice(Math.min(i,c)+1,Math.max(i,c));return{ids:i<c?x:x.reverse(),complete:!0,from:i,to:c}}let u=x=>t.spanAt(e,x),f=i>=0?i:c,p=-1;for(let x=1;f>=0&&p<0&&x<e.length;x++)p=[f-x,f+x].find(w=>u(w)!==void 0)??-1;if(p<0)return{ids:e,complete:!1,from:-1,to:-1};let m=p>f==u(p).start>u(f).start===(f===i),b=m?e.slice(f+1):e.slice(0,f).reverse(),g=b.length>0?b.length-1:-1,y=g<0?u(f):u(m?f+1+g:0),M={contigEnds:y!==void 0,shortBp:y?Math.max(0,n.start-y.end,y.start-n.end):0};return{ids:b,complete:!1,from:f,to:m?e.length:-1,stop:M}}function gh(e,t){return t?e.filter(n=>t.includes(n.sample)).sort((n,o)=>t.indexOf(n.sample)-t.indexOf(o.sample)||n.label.localeCompare(o.label)):e}function Xe(e){let t=(e.paths??[]).map(o=>L(o.name).name);if(e.referencePath!==void 0&&t.includes(e.referencePath))return e.referencePath;let n=new Set(e.nodes.flatMap(o=>o.stable?.rank===0?[o.stable.refName]:[]));return t.find(o=>n.has(o))??t[0]}function bh(e,t,n){let o=e.paths??[],r=x=>L(x.name).name,s=Xe(e),a=o.filter(x=>r(x)===s).sort((x,w)=>(x.start??0)-(w.start??0)),i=a[0],c=o.filter(x=>!a.includes(x));if(!i||c.length===0)return;let l=qe(c,r),d=new ai(e),u=i.start??0,f=t&&t.end>t.start?t:void 0,p=a.map(x=>d.nodesOf(x)),h=d.lengths.length;d.onReference=new Uint8Array(h),d.referenceStart=new Float64Array(h),d.referenceEnd=new Float64Array(h);let m=!1,b=!1;for(let[x,w]of a.entries()){let v=w.start??0;for(let E of p[x]){let O=d.lengths[E];d.onReference[E]||(d.onReference[E]=1,d.referenceStart[E]=v,d.referenceEnd[E]=v+O,m||=f!==void 0&&v+O<=f.start,b||=f!==void 0&&v>=f.end),v+=O}}let g=f===void 0||m&&b,y=(x,w)=>{let v=x[0],E=x.map((N,q)=>({start:N.start,nodes:w?.[q]??d.nodesOf(N),before:N.before,after:N.after})).sort((N,q)=>(N.start??0)-(q.start??0)),{steps:O,gaps:A}=ii(E,d),{ids:X,complete:j,from:U,to:z,stop:Q}=li(O,d,f,g),R=v.contig??We(L(v.name).name),$=ci(E,d,U<0?0:U),I=$?U<0?{contig:R,start:$.start,reversed:!1}:U<z?{contig:R,start:$.end,reversed:!1}:{contig:R,start:$.start,reversed:!0}:void 0,{lengths:Y,onReference:ee,referenceStart:H,referenceEnd:V}=d,ge=[],F,le=0,be=0,S=0,_=0,T=U>=0&&U>z;for(let N of X){if(N<0){let xe=A[-N-1];for(let{bp:ye,...Te}of T?[...xe].reverse():xe)F={start:le,bp:ye,onReference:!1,gap:!0,...Te},ge.push(F),le+=ye,S+=ye;_=0;continue}let q=Y[N],Z=ee[N]===1,te=F?.referenceStart,re=Z&&te!==void 0&&_>=0&&te+F.bp===H[N],ft=Z&&te!==void 0&&_<=0&&V[N]===te;!Z&&F&&!F.onReference&&!F.gap?F.bp+=q:re||ft?(F.bp+=q,re||(F.referenceStart=H[N],F.reversed=!0),_=re?1:-1):(F={start:le,bp:q,onReference:Z,referenceStart:Z?H[N]:void 0},ge.push(F),_=0),le+=q,Z||(be+=q)}return{name:v.name,label:si(v),sample:hr(v),haplotype:v.haplotype,bp:le,offReferenceBp:be,gapBp:S,complete:j,stop:Q,runs:ge,axis:I}};return{origin:f?f.start:u,unit:n,reference:y(a,p),rows:[...l.values()].map(x=>y(x)).sort((x,w)=>Number(w.complete)-Number(x.complete)||w.bp-x.bp||x.label.localeCompare(w.label))}}function mr(e,t){let n=new Map;for(let o of e){let r=t(o),s=n.get(r);s===void 0?n.set(r,[o]):s.push(o)}return n}var fi=new Set(["_gbwt_ref","unknown"]);function gr(e){let[t,n,o]=e?.split("#")??[];if(!(t===void 0||t===""||fi.has(t)||n===void 0||!/^\d+$/.test(n)||o===void 0||o===""))return{sample:t,haplotype:Number(n),contig:o}}var di=["read_group","sample_name"],Sh=[...di,"haplotype_sample"],rt=8.401;function ui({layers:e,coarsenedReadView:t=!1,showReads:n=!0},o){if(e!==void 0)return e;let r=t&&n,s=a=>a?{stat:"coarsen"}:{};return[{data:"haplotypes",...s(r&&!o)},{data:"reads",...s(r&&o)}]}function br(e,t){return e.find(n=>n.data===t)?.stat}function pi(e,t){return{mergeNodes:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,layers:ui(e,t),ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??rt,trackWidth:e.trackWidth??15,freqWidth:e.freqWidth??"log"}}function hi(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[]}}function Or(e){return{config:e,nodes:[],tracks:[],reads:[],nodeMap:new Map,nodesPerOrder:[],nodeOrders:[],assignments:[],extraLeft:[],extraRight:[],maxOrder:-1,shapes:hi(),trackForRuler:void 0,coarsenedEdgeMeta:new Map}}function Nr(e,t,n=[],o={}){let r=mi(e,t,n,o);return r&&gi(r,o)}var Pr=new WeakMap;function mi(e,t,n=[],o={}){let r=xi(e,t,n,o);if(r===void 0)return;let s=$r(r,r.tracks,r.reads,"measure");return s.nodes.forEach((a,i)=>{a.order>=0&&(r.nodes[i].x=a.x)}),Pr.set(r,s),r}function gi(e,t={}){return bi(e,vi(e,t.facet),yi(e,t))}function bi(e,t,n,o){let r=Pr.get(e);return r!==void 0&&t.length===e.tracks.length&&n.length===e.reads.length?r:$r(e,t,n,"topology",o)}function xi(e,t,n,o){let r=Or(pi(o,n.length>0));if(!(e.length===0||t.length===0)){structuredClone(e).forEach((s,a)=>{s.seq??="",s.sequenceLength??=s.seq.length,r.nodes[a+1]=s}),r.tracks=structuredClone(t),r.reads=r.config.showReads?structuredClone(n.filter(s=>s.is_secondary!==!0)):[];for(let s=r.tracks.length-1;s>=0;s-=1){let a=r.tracks[s];if(a.type??="haplotype",a.hidden===!0){r.tracks.splice(s,1);continue}a.indexOfFirstBase!==void 0&&(r.trackForRuler=a.name)}if(r.tracks.length!==0)return Ei(r,0),r.nodeMap=Mr(r),Re(r,r.tracks),Re(r,r.reads),Ar(r),r.config.mergeNodes&&(vr(r),Jt(r),en(r),pc(r),r.nodeMap=Mr(r),Ar(r),Re(r,r.tracks),Re(r,r.reads)),vr(r),Hi(r),Jt(r),Ui(r),Jt(r),en(r),Re(r,r.reads),{options:r.config,nodes:r.nodes,tracks:r.tracks,reads:r.reads,nodeMap:r.nodeMap,maxOrder:Wi(r),trackForRuler:r.trackForRuler}}}function yi(e,{mappingQualityCutoff:t=0,focusReadNames:n=null,facet:o}){let r=n?new Set(n):null;return e.reads.filter(s=>(s.mapping_quality??0)>=t&&(r===null||s.name!==void 0&&r.has(s.name))&&(o===void 0||wi(o,s)))}function wi(e,t){return e.by==="haplotype_sample"?"reads"in e:(t[e.by]??null)===e.key}function Mi(e){return new Set(e.tracks.filter((t,n)=>n===0||t.name===e.trackForRuler))}function vi(e,t){if(t?.by!=="haplotype_sample")return e.tracks;let n=Mi(e);return e.tracks.filter(o=>n.has(o)||!("reads"in t)&&Si(o)===t.key)}function Si(e){return gr(e.name)?.sample??null}function $r(e,t,n,o,r={}){let s=Or(e.options);e.nodes.forEach((f,p)=>{s.nodes[p]={...f}}),s.tracks=t.map(f=>({...f})),s.reads=n.map(f=>({...f})),s.nodeMap=e.nodeMap,s.maxOrder=e.maxOrder,s.trackForRuler=e.trackForRuler;let{layers:a,ignoreStrand:i}=s.config,c=r.haplotypes??ac,l=br(a,"haplotypes")==="coarsen"?ic(s,c):void 0;l!==void 0&&(s.tracks=[l.ref]),rc(s),Zi(s),ki(s);let d=br(a,"reads")==="coarsen"&&s.reads.length>0?Xr(s,s.reads,"read",r.reads??c+(l?.bands.length??0)):void 0;d!==void 0&&(s.reads=d.bands);let u={};for(let[f,p,h]of[["haplotypes","haplotype",l],["reads","read",d]])h!==void 0&&(en(s,h.bands),Re(s,h.bands),u[f]={unit:p,total:h.total,reverse:!i&&h.bands.some(m=>m.is_reverse)});return l!==void 0&&(s.reads=l.bands.concat(s.reads)),Ti(s),s.tracks=s.tracks.concat(s.reads),o==="measure"&&Vi(s),sc(s),{nodes:s.nodes,tracks:s.tracks,reads:s.reads,nodeMap:s.nodeMap,shapes:s.shapes,bounds:Bi(s),maxOrder:s.maxOrder,trackForRuler:s.trackForRuler,coarsenedEdgeMeta:s.coarsenedEdgeMeta,coarsened:u}}function G(e){return e.startsWith("-")}function W(e){return G(e)?e.substring(1):e}function Ir(e){return G(e)?e:`-${e}`}function tn(e){return G(e)?W(e):Ir(e)}function xr(e){return e>0}function Ei(e,t){let n=new Set,o=new Set;for(let r of e.tracks[t].sequence)G(r)?o.has(W(r))||n.add(W(r)):o.add(r);if(n.size!==0){for(let{sequence:r}of[...e.tracks,...e.reads])for(let s=0;s<r.length;s+=1)n.has(W(r[s]))&&(r[s]=tn(r[s]));e.nodes.forEach(r=>{n.has(r.name)&&(r.seq=rn(r.seq))})}}function ki(e){e.nodesPerOrder=Array.from({length:e.maxOrder+1},()=>[]);let t=new Map;e.nodes.forEach(n=>{n.y!==void 0&&yr(t,n.order,n.y+n.contentHeight)}),e.tracks.forEach(n=>{n.type==="haplotype"&&n.path.forEach(o=>{yr(t,o.order,(o.y??0)+n.width)})}),e.nodes.forEach((n,o)=>{n.order>=0&&n.y===void 0&&(n.y=(t.get(n.order)??0)+25,n.contentHeight=0,e.nodesPerOrder[n.order].push(o))})}function yr(e,t,n){let o=e.get(t);o===void 0?e.set(t,n):e.set(t,Math.max(o,n))}var nn=7;function Ri(e){e.nodes.forEach(t=>{t.incomingReads=[],t.outgoingReads=[],t.internalReads=[]}),e.reads.forEach((t,n)=>{(t.width===void 0||t.width===0)&&(t.width=nn),t.path.forEach((o,r)=>{if(o.node===null)return;let s=e.nodes[o.node];t.path.length===1?s.internalReads.push(n):r===0?s.outgoingReads.push([n,r]):s.incomingReads.push([n,r])})})}function Ti(e){e.reads.forEach(i=>{i.path=Cr(e,i)}),Ri(e);let t=e.nodes.filter(i=>i.order>=0);t.sort(an);let n=new Map;for(let i=0;i<e.reads.length;i++){let c=e.reads[i],l=c.haplotypeShare===void 0?1:0,d=c.sourceTrackID,u=`${l}:${d}`,f=n.get(u);f===void 0?n.set(u,{layer:l,source:d,reads:new Set([i])}):f.reads.add(i)}let o=[...n.values()].sort((i,c)=>i.layer-c.layer||i.source-c.source),r=o.length>1?nn:0;t.forEach(i=>{for(let{reads:c}of o)Ai(e,c,i,r)});let s=Ii(e),a=[];e.reads.forEach((i,c)=>{let l=[],d=[],u;i.path.forEach((f,p)=>{l[p]=u,f.node!==null&&(u=f)}),u=void 0;for(let f=i.path.length-1;f>=0;f-=1)d[f]=u,i.path[f].node!==null&&(u=i.path[f]);i.path.forEach((f,p)=>{if(f.y===void 0){let h=l[p],m=d[p],b=!!(m&&h&&(h.order>m.order||m.order===h.order&&m.isForward===h.isForward));f.betweenCycleReverseTraversal=b,a.push({readIndex:c,pathIndex:p,previousY:h?.y,previousNode:h?.node})}})}),a.sort((i,c)=>Oi(e,i,c)),a.forEach(i=>{let c=e.reads[i.readIndex],l=c.path[i.pathIndex];l.y=s[l.order],s[l.order]+=c.width})}function Ai(e,t,n,o){let r=n.incomingReads.filter(([h])=>t.has(h)),s=n.outgoingReads.filter(([h])=>t.has(h)),a=n.internalReads.filter(h=>t.has(h));r.length===0&&s.length===0&&a.length===0&&(o=0);let i=n.y+n.contentHeight+o*2,c=r.map(h=>{let[m,b]=h,g=e.reads[m].path,y=b+1,M;for(let x=1;x<=b;x++){let w=g[b-x]?.y;if(w!==void 0){y=x,M=w;break}}return{entry:h,decisionStep:y,y:M}});c.sort(_i),r=c.map(h=>h.entry);let l=i,d=new Map;r.forEach(h=>{let m=e.reads[h[0]];m.path[h[1]].y=l,wr(d,m,h[1],l,n),l+=m.width});let u=l;s.sort((h,m)=>Ni(e,h,m));let f=new Map;l=i,s.forEach(h=>{let m=e.reads[h[0]],b=m.firstNodeOffset??0;m.path[h[1]].y=l,f.set(l,b);let g=d.get(l);g===void 0||g+1<=b?(l+=m.width,u=Math.max(u,l)):(d.set(l,0),r.forEach(y=>{let M=e.reads[y[0]],x=M.path[y[1]];x.y!==void 0&&x.y>=l&&(x.y+=m.width,wr(d,M,y[1],x.y,n))}),l+=m.width,u+=m.width)}),a.sort((h,m)=>$i(e,h,m)),a.forEach(h=>{let m=e.reads[h],b=m.firstNodeOffset??0,g=m.finalNodeCoverLength??0;for(l=i;b<(d.get(l)??-1/0)+2||g>(f.get(l)??1/0)-3;)l+=m.width;m.path[0].y=l,d.set(l,g),u=Math.max(u,l)});let p=u-n.y-n.contentHeight;n.contentHeight+=p,nc(e,n,p)}function _i(e,t){return e.decisionStep!==t.decisionStep?e.decisionStep-t.decisionStep:e.y===void 0||t.y===void 0?(e.y===void 0?0:1)-(t.y===void 0?0:1):e.y-t.y}function wr(e,t,n,o,r){e.set(o,n===t.path.length-1?t.finalNodeCoverLength??0:r.sequenceLength)}function Oi(e,t,n){let o=e.reads[t.readIndex],r=e.reads[n.readIndex],s=o.path[t.pathIndex],a=r.path[n.pathIndex];if(s.order!==a.order)return s.order-a.order;if(o.sourceTrackID!==r.sourceTrackID)return o.sourceTrackID-r.sourceTrackID;if(t.previousNode&&n.previousNode){let u=e.nodes[t.previousNode],f=e.nodes[n.previousNode];if(u&&f&&u.order!==f.order)return u.order-f.order}let i=t.previousY??0,c=n.previousY??0,l=s.betweenCycleReverseTraversal===!0,d=a.betweenCycleReverseTraversal===!0;return l!==d?l?1:-1:l?c-i:i-c}function Ni(e,[t,n],[o,r]){let s=e.reads[t],a=e.reads[o],i=s.path.findLast(p=>p.y!==void 0)?.y,c=a.path.findLast(p=>p.y!==void 0)?.y;if(i!==void 0&&c!==void 0)return i-c;let l=(p,h)=>{let m=p.path[h]?.node;return m==null?null:e.nodes[m]??null},d=(p,h)=>{let m=h+1;for(;p.path[m]?.node===null;)m+=1;return m},u=l(s,n),f=l(a,r);for(;u!==null&&u===f;)n=d(s,n),r=d(a,r),u=l(s,n),f=l(a,r);return u!==null&&f!==null?an(u,f):u!==null||f!==null?u===null?-1:1:(s.firstNodeOffset??0)-(a.firstNodeOffset??0)||(s.finalNodeCoverLength??0)-(a.finalNodeCoverLength??0)}function Pi(e,t){let n=e.path,o=t.path,r=0,s=0;for(;r<n.length&&s<o.length;){let a=n[r],i=o[s],c=a.order,l=i.order;if(c===l&&a.node&&i.node)return(i.y??0)-(a.y??0);c<l?r+=1:(c>l||(r+=1),s+=1)}return 0}function $i(e,t,n){let o=e.reads[t],r=e.reads[n];return(o.firstNodeOffset??0)-(r.firstNodeOffset??0)||(o.finalNodeCoverLength??0)-(r.finalNodeCoverLength??0)}function Ii(e){let t=new Array(e.maxOrder+1).fill(0);return e.nodes.forEach(n=>{n.y!==void 0&&(t[n.order]=Math.max(t[n.order],n.y+n.contentHeight+20))}),e.tracks.forEach(n=>{n.path.forEach(o=>{t[o.order]=Math.max(t[o.order],(o.y??0)+n.width)})}),t}function Cr(e,t){let n=[],o=(c,l)=>{n.push({order:c,isForward:l,node:null})},r=(c,l,d)=>{n.push({order:c,isForward:l,node:d})},s=Math.abs(t.indexSequence[0]),a=xr(t.indexSequence[0]),i=e.nodes[s];r(i.order,a,s);for(let c=1;c<t.sequence.length;c+=1){let l=i,d=a;s=Math.abs(t.indexSequence[c]),a=xr(t.indexSequence[c]),i=e.nodes[s];let{order:u}=i;if(u>l.order){d||o(l.order,!0);for(let f=l.order+1;f<u;f+=1)o(f,!0);a||o(u,!0)}else if(u<l.order){d&&o(l.order,!1);for(let f=l.order-1;f>u;f-=1)o(f,!1);a&&o(u,!1)}else a===d&&o(u,!a);r(u,a,s)}return n}function en(e,t=e.reads){t.forEach(n=>{if(!n.sequence.every(G))return;n.is_reverse=n.is_reverse!==!0,n.sequence=n.sequence.toReversed().map(W),n.sequenceNew!==void 0&&(n.sequenceNew=n.sequenceNew.toReversed());for(let a of n.sequenceNew??[]){a.nodeName=W(a.nodeName);let{sequenceLength:i}=Zt(e,a.nodeName);a.mismatches=a.mismatches.map(c=>on(c,i))}let o=n.firstNodeOffset??0,r=Zt(e,n.sequence[0]).sequenceLength,s=Zt(e,n.sequence.at(-1)).sequenceLength;n.firstNodeOffset=r-(n.finalNodeCoverLength??0),n.finalNodeCoverLength=s-o})}function on(e,t){let n=e.type==="insertion"?0:e.type==="deletion"?e.length??0:e.seq?.length??0;return{...e,pos:t-e.pos-n,...e.seq!==void 0&&{seq:rn(e.seq)}}}var Ci={A:"T",T:"A",C:"G",G:"C"};function rn(e){let t="";for(let n=e.length-1;n>=0;n-=1)t+=Ci[e.charAt(n)]??"N";return t}function Re(e,t){let n=new Map;t.forEach(o=>{o.indexSequence=o.sequence.map(r=>{let s=n.get(r);if(s===void 0){let a=e.nodeMap.get(W(r));if(a===void 0)throw new Error(`Track ${o.name??o.id} visits unknown node ${r}`);s=G(r)?-a:a,n.set(r,s)}return s})})}var Li=20;function Bi(e){let t={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},{rectangles:n,verticalRectangles:o,curves:r}=e.shapes;for(let s of[n,o,r])for(let{xStart:a,xEnd:i}of s)t.minX=Math.min(t.minX,a,i),t.maxX=Math.max(t.maxX,a,i);return e.nodes.forEach(s=>{s.x!==void 0&&(t.minX=Math.min(t.minX,s.x-9),t.maxX=Math.max(t.maxX,s.x+Li+s.pixelWidth)),s.y!==void 0&&(t.minY=Math.min(t.minY,s.y-10),t.maxY=Math.max(t.maxY,s.y+s.contentHeight+10))}),e.tracks.forEach(s=>{s.path.forEach(a=>{let i=a.y??0;t.maxY=Math.max(t.maxY,i+s.width),t.minY=Math.min(t.minY,i)})}),t}function Zt(e,t){let n=e.nodeMap.get(W(t)),o=n===void 0?void 0:e.nodes[n];if(o===void 0)throw new Error(`Unknown node ${t}`);return o}function Mr(e){let t=new Map;return e.nodes.forEach((n,o)=>{t.set(n.name,o)}),t}function vr(e){let t=e.nodes.map(()=>new Set),n=e.nodes.map(()=>new Set),o=r=>{for(let s=0;s<r.indexSequence.length-1;s+=1){let a=Math.abs(r.indexSequence[s]),i=Math.abs(r.indexSequence[s+1]);t[a].add(i),n[i].add(a)}};e.tracks.forEach(o),e.reads.forEach(o),e.nodes.forEach((r,s)=>{r.successors=Array.from(t[s]),r.predecessors=Array.from(n[s])})}function Sr(e,t){let n=0,o=0,r=0;t.forEach(s=>{let a=Math.abs(s);if(s<0){let i=e.nodeOrders[a]??=o;i<r&&(r=i),n=i,o=i-1}else{let i=e.nodeOrders[a]??=n;n=i+1,o=i}}),r<0&&sn(e,-r)}function Xi(e,t){let n=0,o=0;for(;n<t.length&&e.nodeOrders[Math.abs(t[n])]===void 0;)n+=1;if(n>=t.length)return null;let r=t[n],s,a;r>=0?(s=e.nodeOrders[r]-1,a=-1):(s=e.nodeOrders[-r]+1,a=1);for(let i=n-1;i>=0;i-=1){let c=Math.abs(t[i]);e.nodeOrders[c]===void 0&&(e.nodeOrders[c]=s,o=Math.min(o,s),s+=a)}return o<0&&sn(e,-o),n}var Fi=-1;function Di(e){return Array.from(e,t=>t??Fi)}function qi(e){let t=[...new Set(e.filter(o=>o>=0))].sort((o,r)=>o-r),n=new Map(t.map((o,r)=>[o,r]));return e.map(o=>n.get(o)??o)}function Jt(e){let t,n,o,r,s=0,a=e.tracks.concat(e.reads),i={stamp:new Int32Array(e.nodes.length),generation:0};e.nodeOrders=new Array(e.nodes.length).fill(void 0),e.nodes.forEach(c=>{c.order=void 0}),Sr(e,e.tracks[0].indexSequence);for(let c=1;c<a.length;c+=1){if(o=Xi(e,a[c].indexSequence),o===null){c<e.tracks.length?Sr(e,a[c].indexSequence):(a.splice(c,1),e.reads.splice(c-e.tracks.length,1),c-=1);continue}for(t=Yi(a[c].indexSequence);o<t.length;){for(r=o,o+=1;o<t.length&&e.nodeOrders[t[o]]===void 0;)o+=1;if(o<t.length){n=e.nodeOrders[t[r]]+1;for(let l=r+1;l<o;l+=1)e.nodeOrders[t[l]]=n,n+=1;if(e.nodeOrders[t[o]]>e.nodeOrders[t[r]])e.nodeOrders[t[o]]<n&&Er(e,t[o],t[o-1],n);else if(a[c].indexSequence[o]>=0&&!Gi(e,t[o],t[r],i))Er(e,t[o],t[o-1],n);else if(a[c].indexSequence[r]<0||e.nodes[t[r+1]].degree<2&&e.nodeOrders[t[o]]<e.nodeOrders[t[r]]){n=e.nodeOrders[t[r]]-1;for(let l=r+1;l<o;l+=1)e.nodeOrders[t[l]]=n,s=Math.min(s,n),n-=1}}else if(a[c].indexSequence[r]>=0){n=e.nodeOrders[t[r]]+1;for(let l=r+1;l<t.length;l+=1){let d=t[l];e.nodeOrders[d]===void 0&&(e.nodeOrders[d]=n,n+=1)}}else{n=e.nodeOrders[t[r]]-1;for(let l=r+1;l<t.length;l+=1){let d=t[l];e.nodeOrders[d]===void 0&&(e.nodeOrders[d]=n,s=Math.min(s,n),n-=1)}}}}s<0&&sn(e,-s),e.nodeOrders=qi(Di(e.nodeOrders)),e.nodes.forEach((c,l)=>{c.order=e.nodeOrders[l]})}function Gi(e,t,n,o){o.generation+=1;let{stamp:r,generation:s}=o,a=[t];for(r[t]=s;a.length>0;){let i=a.pop();if(i===n)return!0;for(let c of e.nodes[i].successors)r[c]!==s&&(r[c]=s,a.push(c))}return!1}function Wi(e){let t=-1;return e.nodeOrders.forEach(n=>{n!==void 0&&n>t&&(t=n)}),t}function Yi(e){return e.map(t=>Math.abs(t))}function sn(e,t){e.nodeOrders.forEach((n,o)=>{n!==void 0&&(e.nodeOrders[o]=n+t)})}function Er(e,t,n,o){let r=new Map,s=[[t,o]],a=0;for(;a<s.length;){let[i,c]=s[a];a+=1;let l=e.nodeOrders[i];l!==void 0&&l<c&&(r.get(i)??-1/0)<c&&(r.set(i,c),e.nodes[i].successors.forEach(d=>{e.nodeOrders[d]>l&&d!==n&&s.push([d,c+1])}),i!==t&&e.nodes[i].predecessors.forEach(d=>{e.nodeOrders[d]>l&&d!==n&&s.push([d,c+1])}))}r.forEach((i,c)=>{e.nodeOrders[c]=i})}function Hi(e){e.nodes.forEach(t=>{t.tracks=[]}),e.tracks.forEach(t=>{t.indexSequence.forEach(n=>{e.nodes[Math.abs(n)].tracks.push(t.id)})}),e.nodes.forEach(t=>{t.degree=t.tracks.length})}function Ui(e){ji(e,[...e.tracks.slice(1),...e.reads],e.tracks[0])}function ji(e,t,n){let o=new Int32Array(e.nodes.length),r=new Uint8Array(e.nodes.length);for(let s of n.sequence){let a=G(s)?void 0:e.nodeMap.get(s);a!==void 0&&(r[a]=1)}for(let s of t){let{sequence:a,indexSequence:i}=s,c=i.length-1;for(let l=0;l<=c;l+=1){let d=Math.abs(i[l]);if(r[d]===1)continue;let u=e.nodes[d].order,f=l>0?e.nodes[Math.abs(i[l-1])].order:void 0,p=l<c?e.nodes[Math.abs(i[l+1])].order:void 0,h=G(a[l])?1:-1;(f===void 0||f<u)&&(p===void 0||u<p)&&(o[d]+=h),(f===void 0||f>u)&&(p===void 0||u>p)&&(o[d]-=h)}}for(let s of t){let{sequence:a,indexSequence:i}=s;for(let c=0;c<i.length;c+=1)o[Math.abs(i[c])]>0&&(a[c]=tn(a[c]),i[c]=-i[c])}e.nodes.forEach((s,a)=>{o[a]>0&&(s.seq=rn(s.seq),s.switched=!0)})}function Vi(e){let t=0,n=20,o=-1,r=e.nodes.slice();r.sort(an);let s=zi(e);r.forEach(a=>{a.order>=0&&(a.order>o&&(o=a.order,t=n+10*s[a.order]),a.x=t,n=Math.max(n,t+40+a.pixelWidth))})}var Qt=35;function Ki(e){return e<=Qt?e/17.5:Qt/17.5*Math.sqrt(e/Qt)}function zi(e){let t=e.maxOrder+1,n=new Array(t).fill(0),o=new Array(t).fill(0),r=new Array(t).fill(0),s=[];e.tracks.forEach(a=>{for(let i=1;i<a.path.length;i+=1){let c=a.path[i],l=a.path[i-1];c.order===l.order?c.isForward?n[c.order]+=1:o[c.order]+=1:r[c.order]=Math.max(Ki(Math.abs((c.y??0)-(l.y??0))),r[c.order])}}),s.push(Math.max(0,n[0]-1));for(let a=1;a<=e.maxOrder;a+=1)s.push(Math.max(Math.max(0,n[a]-1)+Math.max(0,o[a-1]-1),r[a]));return s}function Zi(e){e.assignments=Array.from({length:e.maxOrder+1},()=>[]);let t=new Map;e.tracks.forEach((n,o)=>{n.path=Cr(e,n),n.path.forEach(({order:r,node:s},a)=>{let i={trackID:o,segmentID:a},c=s===null?void 0:t.get(s);if(c===void 0){let l={node:s,tracks:[i]};e.assignments[r].push(l),s!==null&&t.set(s,l)}else c.tracks.push(i)})});for(let n=0;n<=e.maxOrder;n+=1)ec(e,e.assignments[n],n)}function Ji(e,t,n){t.forEach(o=>{let r=0;o.tracks.forEach(s=>{let a=Qi(e.tracks[s.trackID].path,s.segmentID,n-1);s.idealLane=a===void 0?s.trackID:a.lane,s.idealY=a===void 0?null:a.y,r+=s.idealLane}),o.idealLane=r/o.tracks.length})}function Qi(e,t,n){if(t!==0)return e[t-1].order===n?e[t-1]:e[t+1]?.order===n?e[t+1]:e.slice(0,t).findLast(o=>o.order===n)}function ec(e,t,n){let o=0,r=new Set,s=20,a=!1,i=-1;Ji(e,t,n),t.sort(kr),t.forEach(c=>{let l=c.node===null?void 0:e.nodes[c.node];l!==void 0?(a&&(s-=10),l.y=s,l.contentHeight=0,a=!1):(a?s-=25:s>20&&(s-=10),a=!0),c.tracks.sort(kr),c.tracks.forEach(d=>{let{path:u,width:f}=e.tracks[d.trackID];d.trackID===i&&l===void 0&&a&&(s+=10),u[d.segmentID].lane=o,u[d.segmentID].y=s,typeof d.idealY=="number"&&r.add(d.idealY-s),o+=1,s+=f,l!==void 0&&(l.contentHeight+=f),i=d.trackID}),s+=25}),tc(e,t,r)}function tc(e,t,n){let o=0,r=Number.MAX_SAFE_INTEGER;n.forEach(s=>{let a=oc(e,t,s);a<r&&(r=a,o=s)}),t.forEach(s=>{s.node!==null&&(e.nodes[s.node].y+=o),s.tracks.forEach(a=>{let i=e.tracks[a.trackID].path[a.segmentID];i.y=i.y+o})})}function nc(e,t,n){t.order<0||e.assignments[t.order]===void 0||(e.assignments[t.order].forEach(o=>{if(o.node!==null){let r=e.nodes[o.node];r!==t&&r.y>t.y&&(r.y+=n,o.tracks.forEach(s=>{let a=e.tracks[s.trackID].path[s.segmentID];a.y=a.y+n}))}else o.tracks.forEach(r=>{let s=e.tracks[r.trackID].path[r.segmentID];s.y>=t.y&&(s.y=s.y+n)})}),e.nodesPerOrder[t.order].forEach(o=>{let r=e.nodes[o];r!==t&&r.y>t.y&&(r.y+=n)}))}function oc(e,t,n){let o=0;return t.forEach(r=>{r.tracks.forEach(s=>{let{type:a,path:i,width:c}=e.tracks[s.trackID];typeof s.idealY=="number"&&a!=="read"&&(o+=Math.abs(s.idealY-n-i[s.segmentID].y)*c)})}),o}function kr(e,t){return e.idealLane===void 0||t.idealLane===void 0?+(e.idealLane===void 0)-+(t.idealLane===void 0):e.idealLane-t.idealLane}function an(e,t){return e.order!==t.order?e.order-t.order:e.y!==void 0&&t.y!==void 0?e.y-t.y:0}function rc(e){let n=e.config.trackWidth;if(e.config.freqWidth==="linear"){for(let o of e.tracks)o.width=o.type==="read"?4:Math.max(1,Math.round(o.freq??1))*n;return}for(let o of e.tracks)o.width=o.freq!==void 0?Math.round((Math.log(Math.max(o.freq,1))+1)*4):o.type==="read"?4:n;e.tracks.every(o=>o.width===4)&&e.tracks.forEach(o=>{o.freq!==void 0&&(o.width=n)})}function Rr(e,t,n){let o=e.nodes[t.node];return Br(o,t.isForward?n:o.sequenceLength-n)}function Lr(e,t){return t>e.sequenceLength?null:Br(e,t)}function Br(e,t){let[n,o]=uc(e);if(e.sequenceLength===0)return n;let r=Math.min(Math.max(t,0),e.sequenceLength);return n+r/e.sequenceLength*(o-n)}function sc(e){e.extraLeft=new Array(e.maxOrder+1).fill(0),e.extraRight=new Array(e.maxOrder+1).fill(0);let t=[],n=[];e.nodes.forEach(r=>{r.x!==void 0&&(t[r.order]=r.x,n[r.order]=Math.max(n[r.order]??-1/0,r.x+r.pixelWidth))});let o=e.tracks[0];e.tracks.sort(Pi),e.tracks.forEach(r=>{let{id:s,name:a,type:i,width:c,path:l}=r,d=(g,y,M)=>{e.shapes.rectangles.push({xStart:Math.min(g,y),yStart:M,xEnd:Math.max(g,y),yEnd:M+c-1,id:s,name:a,type:i})},u=g=>g.isForward?n[g.order]:t[g.order],f=l[0],p=f.y,h=i==="read"?Rr(e,f,r.firstNodeOffset??0):f.isForward?t[f.order]-20:n[f.order]+20;for(let g=1;g<l.length;g+=1){let y=l[g-1],M=l[g];if(M.y===p)continue;let x=u(y);x!==h&&d(h,x,p);let w=M.y,v=M.order-y.order;if(v===1||v===-1){let E=v===1?t[M.order]:n[M.order];e.shapes.curves.push({xStart:v===1?x:x+1,yStart:p,xEnd:v===1?E+1:E,yEnd:w,width:c,id:s,name:a,type:i,nodeStart:y.node,nodeEnd:M.node,orderStart:y.order,orderEnd:M.order,...r===o?{reference:!0}:{}}),h=E}else dc(e,r,y.isForward?1:-1,x,p,w,M.order),h=x;p=w}let m=l[l.length-1],b=i==="read"?Rr(e,m,r.finalNodeCoverLength??0):u(m)+(m.isForward?20:-20);d(h,b,p)})}var ac=1e9;function Xr(e,t,n,o){let r=new Map,s=0,a=e.nodes.length,i=(m,b)=>(m+a)*(2*a+1)+b+a,c=e.config.ignoreStrand;for(let[m,b]of t.entries()){let g=Math.max(b.freq??1,1);s+=g;let y=b.indexSequence;if(!(y.length<2))for(let M=0;M<y.length-1;M+=1){let x=y[M],w=y[M+1],v=e.nodes[Math.abs(x)],E=e.nodes[Math.abs(w)],O=c?Math.min(i(x,w),i(-w,-x)):i(x,w),A=r.get(O);A===void 0?r.set(O,{sSigned:x,dSigned:w,sName:x<0?`-${v.name}`:v.name,dName:w<0?`-${E.name}`:E.name,count:g,crossings:g,sourceTrackID:b.sourceTrackID,lastSource:m}):(A.crossings+=g,A.lastSource!==m&&(A.count+=g,A.lastSource=m))}}let l=0;for(let m of r.values())m.crossings>l&&(l=m.crossings);let d=nn,u=60,f=m=>l<=1?d:d+(u-d)*Math.sqrt(m/l),p=[],h=0;for(let m of r.values()){let b=o+h,g=n==="haplotype"?{count:m.count,total:s}:void 0,y=g===void 0?"":` (${fc(g)})`,M=m.crossings===m.count?"":`, ${m.crossings.toLocaleString()} crossings`,x=`${m.count.toLocaleString()} ${n}${m.count===1?"":"s"}${y}${M}: Node ${m.sName} \u2192 Node ${m.dName}`;e.coarsenedEdgeMeta.set(b,{count:m.count,label:x});let w=e.nodes[Math.abs(m.sSigned)].sequenceLength;p.push({id:b,sourceTrackID:m.sourceTrackID,type:"read",name:x,sequence:[m.sName,m.dName],indexSequence:[],path:[],width:f(m.crossings),firstNodeOffset:w,finalNodeCoverLength:0,sequenceNew:[{nodeName:m.sName,mismatches:[]},{nodeName:m.dName,mismatches:[]}],mapping_quality:0,is_secondary:!1,sample_name:null,read_group:null,score:m.count,haplotypeShare:g}),h+=1}return{bands:p,total:s}}function ic(e,t){let n=e.trackForRuler===void 0?-1:e.tracks.findIndex(d=>d.name===e.trackForRuler),o=n===-1?0:n,r=e.tracks[o],s=(r.freq??1)-1,a=lc(e,r),i=e.tracks.filter((d,u)=>u!==o).map(d=>cc(a,d));if(s>0&&i.push({...r,freq:s}),i.length===0)return;let{bands:c,total:l}=Xr(e,i,"haplotype",t);return c.length>0?{ref:r,bands:c,total:l}:void 0}function cc(e,t){let n=0;for(let o of t.indexSequence){let r=e[Math.abs(o)];r!==void 0&&r!==0&&(n+=r===Math.sign(o)?1:-1)}return n>=0?t:{...t,sequence:t.sequence.map(tn).reverse(),indexSequence:t.indexSequence.map(o=>-o).reverse()}}function lc(e,t){let n=new Int8Array(e.nodes.length);for(let o of t.indexSequence){let r=Math.abs(o);n[r]===0&&(n[r]=Math.sign(o))}return n}function fc({count:e,total:t}){let n=e/t;return n<.01?"<1%":n>.99&&e<t?">99%":`${Math.round(n*100)}%`}var Tr=7;function dc(e,{width:t,id:n,name:o,type:r},s,a,i,c,l){let d=s===1?e.extraRight:e.extraLeft,u=10*d[l],f=a+s*(u+5),p=Tr,h=Math.min(Tr,t),m=Math.min(i,c),b=Math.max(i,c),g=s===1?a:f-1,y=s===1?f:a,M=E=>{e.shapes.verticalRectangles.push({xStart:g,yStart:E,xEnd:y,yEnd:E+t-1,id:n,name:o,type:r})};M(i),e.shapes.verticalRectangles.push({xStart:s===1?f+p:f-p-h,yStart:m+t+p-1,xEnd:s===1?f+p+h-1:f-p-1,yEnd:b-p+1,id:n,name:o,type:r}),M(c);let x=f+s*p,w=f+s*(p+h),v=`M ${f} ${b}`;v+=` Q ${x} ${b} ${x} ${b-p}`,v+=` H ${w}`,v+=` Q ${w} ${b+t} ${f} ${b+t}`,v+=" Z ",e.shapes.corners.push({path:v,id:n,name:o,type:r}),v=`M ${f} ${m}`,v+=` Q ${w} ${m} ${w} ${m+t+p}`,v+=` H ${x}`,v+=` Q ${x} ${m+t} ${f} ${m+t}`,v+=" Z ",e.shapes.corners.push({path:v,id:n,name:o,type:r}),d[l]+=1}function uc(e){let t=e.x-4,n=e.x+e.pixelWidth+4;return[t,n]}function Ar(e){switch(e.config.nodeWidthOption){case"compressed":e.nodes.forEach(t=>{t.width=1+Math.log2(Math.max(t.sequenceLength,1)),t.pixelWidth=Math.round((t.width-1)*rt)});break;case"small":e.nodes.forEach(t=>{t.width=t.sequenceLength/100,t.pixelWidth=Math.max(Math.round((t.width-1)*rt),0)});break;case"fixed":e.nodes.forEach(t=>{t.width=10,t.pixelWidth=Math.round(t.width*rt)});break;case"normal":{let t=e.config.charWidth;e.nodes.forEach(n=>{n.width=n.sequenceLength,n.pixelWidth=Math.round(t*Math.max(n.sequenceLength-1,0))});break}default:throw new Error(`${e.config.nodeWidthOption} not implemented`)}}var he=0;function _r(e){return{first:new Int32Array(e),count:new Uint8Array(e)}}function K(e,t,n){let o=e.count[t];o===0?(e.first[t]=n,e.count[t]=1):o===1&&e.first[t]!==n&&(e.count[t]=2)}function Fe(e,t){return e.count[t]===1?Math.abs(e.first[t]):0}function pc(e){let t=_r(e.nodes.length),n=_r(e.nodes.length),o=new Map,r=u=>{let f=o.get(u);if(f===void 0){let p=e.nodeMap.get(W(u));f=G(u)?-p:p,o.set(u,f)}return f};e.tracks.concat(e.reads).forEach(u=>{let{sequence:f}=u,p=u.type==="haplotype",h=f.length-1,m=he,b=h>=0?r(f[0]):he;for(let g=0;g<=h;g+=1){let y=g<h?r(f[g+1]):he;if(b>0)g>0?(K(t,b,m),m<0&&K(t,b,-m)):p&&K(t,b,he),g<h?(K(n,b,y),y<0&&K(n,b,-y)):p&&K(n,b,he);else{let M=-b;g>0?(K(n,M,-m),m>0&&K(n,M,m)):p&&K(n,M,he),g<h?(K(t,M,-y),y>0&&K(t,M,y)):p&&K(t,M,he)}m=b,b=y}});let a=new Uint8Array(e.nodes.length);e.nodes.forEach((u,f)=>{hc(f,t,n)&&(a[f]=1)});let i=new Int32Array(e.nodes.length),c=new Float64Array(e.nodes.length),l=new Float64Array(e.nodes.length);e.nodes.forEach((u,f)=>{if(a[f]!==1){i[f]=f,l[f]=u.sequenceLength;for(let p=f;mc(p,t,n);)p=Fe(n,p),i[p]=f,c[p]=u.sequenceLength,u.sequenceLength+=e.nodes[p].sequenceLength,u.seq+=e.nodes[p].seq,l[p]=u.sequenceLength}}),e.reads.forEach(u=>{let{sequence:f}=u,p=u.sequenceNew??f.map(M=>({nodeName:M,mismatches:[]})),h=M=>{let x=Math.abs(r(M));return G(M)?e.nodes[i[x]].sequenceLength-l[x]:c[x]},m=f.length-1;u.firstNodeOffset=(u.firstNodeOffset??0)+h(f[0]),u.finalNodeCoverLength=(u.finalNodeCoverLength??0)+h(f[m]);let b=[],g=[],y=[];f.forEach((M,x)=>{let w=Math.abs(r(M)),{mismatches:v}=p[x],E=h(M);if(v.forEach(O=>{O.pos+=E}),a[w]===1&&!G(M)&&x>0)g.at(-1).mismatches.push(...v);else if(a[w]===1&&G(M)&&x<m)y.push(...v);else{let O=e.nodes[i[w]].name,A=G(M)?Ir(O):O;b.push(A),g.push({nodeName:A,mismatches:y.concat(v)}),y=[]}}),u.sequence=b,u.sequenceNew!==void 0&&(u.sequenceNew=g)}),e.tracks.forEach(u=>{let{sequence:f}=u,p=0;for(let h of f)a[Math.abs(r(h))]===0&&(f[p]=h,p+=1);f.length=p});let d=1;for(let u=1;u<e.nodes.length;u+=1)a[u]===0&&(e.nodes[d]=e.nodes[u],d+=1);e.nodes.length=d}function hc(e,t,n){let o=Fe(t,e);return o!==0&&Fe(n,o)!==0}function mc(e,t,n){let o=Fe(n,e);return o!==0&&Fe(t,o)!==0}function gc(e,t){return t.xStart-e.xStart||e.yStart-t.yStart}function cn(e){return[e.nodeStart??-1,e.nodeEnd??-1,e.nodeStart===null?e.orderStart:-1,e.nodeEnd===null?e.orderEnd:-1]}function bc(e,t){for(let n=0;n<e.length;n+=1){let o=e[n]-t[n];if(o!==0)return o}return 0}var Fr=.75,st=.8;function xc(e,t){let n=e[0],o=Math.min(Math.abs(n.xEnd-n.xStart),t);if(o===0)return e.map(()=>0);let r=e.length>5?.4/e.length:0,s=e.map(f=>{let p=Math.abs(f.yEnd-f.yStart),h=p/Math.hypot(p,o)*Math.min(f.width,st*Fr*o);return Math.max(r,h/(Fr*o))}),a=f=>s.reduce((p,h,m)=>p+(f(e[m])?h:0),0),i=a(f=>f.reference===!0),c=a(f=>f.reference!==!0),l=i>st?st/i:1,d=st-i*l,u=c>d?d/c:1;return s.map((f,p)=>f*(e[p].reference?l:u))}function Dr(e,t,{gapWidth:n=1/0}={}){let o=mr(e.filter(r=>r.type===t),r=>cn(r).join(","));return o.forEach(r=>{r.sort(gc);let s=xc(r,n),a=.5-s.reduce((i,c)=>i+c,0)/2;r.forEach((i,c)=>{let l=p=>i.xStart+(i.xEnd-i.xStart)*(i.yStart<i.yEnd?1-p:p),d=l(a);a+=s[c];let u=l(a),f=`M ${i.xStart} ${i.yStart}`;f+=` C ${d} ${i.yStart} ${d} ${i.yEnd} ${i.xEnd} ${i.yEnd}`,f+=` V ${i.yEnd+i.width}`,f+=` C ${u} ${i.yEnd+i.width} ${u} ${i.yStart+i.width} ${i.xStart} ${i.yStart+i.width}`,f+=" Z",i.path=f})}),[...o.values()].sort((r,s)=>bc(cn(r[0]),cn(s[0]))).flat()}function qr(e,t=16){let n=e.match(/[A-Za-z]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=[],r=0,s=0,a=0,i=()=>Number(n[a++]);for(;a<n.length;){let c=n[a++];if(c==="M"||c==="L")r=i(),s=i(),o.push([r,s]);else if(c==="H")r=i(),o.push([r,s]);else if(c==="V")s=i(),o.push([r,s]);else if(c==="C"){let[l,d,u,f,p,h]=[i(),i(),i(),i(),i(),i()];for(let m=1;m<=t;m+=1){let b=m/t,g=1-b,y=g*g*g,M=3*g*g*b,x=3*g*b*b,w=b*b*b;o.push([y*r+M*l+x*u+w*p,y*s+M*d+x*f+w*h])}r=p,s=h}else if(c==="Q"){let[l,d,u,f]=[i(),i(),i(),i()];for(let p=1;p<=t;p+=1){let h=p/t,m=1-h;o.push([m*m*r+2*m*h*l+h*h*u,m*m*s+2*m*h*d+h*h*f])}r=u,s=f}else if(c!=="Z")throw new Error(`flattenPath: unsupported path command ${c}`)}return o}function Gr(e){let t=`M ${e.x-9} ${e.y} Q ${e.x-9} ${e.y-9} ${e.x} ${e.y-9}`,n=e.x,o=e.y-9;return e.width>1&&(n+=e.pixelWidth,t+=` L ${n} ${o}`),t+=` Q ${n+9} ${o} ${n+9} ${o+9}`,n+=9,o+=9,e.contentHeight>0&&(o+=e.contentHeight,t+=` L ${n} ${o}`),t+=` Q ${n} ${o+9} ${n-9} ${o+9}`,n-=9,o+=9,e.width>1&&(n-=e.pixelWidth,t+=` L ${n} ${o}`),t+=` Q ${n-9} ${o} ${n-9} ${o-9}`,n-=9,o-=9,e.contentHeight>0&&(o-=e.contentHeight,t+=` L ${n} ${o}`),t}function ln(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=e.pathVisits,o=n?.replay();return(e.paths??[]).map(r=>{let s=n?.pathIndex(L(r.name).name)??-1;return r.nodeIds.flatMap(a=>{let i=t.get(a);if(!i)return[];let c=n&&o?o(n.slot(i.name),s):-1;return[{node:i,strand:c>=0?n.strand(c):Xt(i)}]})})}function yc(e){let t=ln(e),n=(e.paths??[]).flatMap((s,a)=>{let i=t[a].map(c=>Ft(c.node,c.strand));return i.length>0?[{id:a,name:s.name,sequence:i,sourceTrackID:0,type:"haplotype",...s.members?{freq:s.members.length}:{}}]:[]}),o=Xe(e),r=n.findIndex(s=>L(s.name).name===o);return r>0&&n.unshift(...n.splice(r,1)),n}function wc(e){return e.nodes.map(t=>({name:t.id,seq:"",sequenceLength:Math.max(1,t.length)}))}function Yr(e){return(e.paths?.length??0)>0}var Mc=600,vc=3,Sc=15;function Ec(e){return Math.max(vc,Math.min(Sc,Math.floor(Mc/Math.max(1,e))))}function kc(e){let t=new Set,n=new Set;for(let o of e?.sequence??[])G(o)?n.has(W(o))||t.add(W(o)):n.add(o);return t}function Rc(e,t,n){let o=kc(n[0]),r=new Map;for(let{sequence:c,is_secondary:l}of n)l||c.forEach((d,u)=>{let f=W(d),h=G(d)!==o.has(f)?c[u+1]:c[u-1];!t.nodeMap.has(f)&&h!==void 0&&r.set(f,W(h))});let s=new Map(e.nodes.map(c=>[c.id,Math.max(1,c.length)])),a=new Map([...r].map(([c,l])=>[l,c])),i=new Map;for(let c of a.keys()){let l=t.nodeMap.get(c);if(l!==void 0){let d=[c];for(let f=a.get(c);f!==void 0;f=a.get(f))d.push(f);d.reduce((f,p)=>f+(s.get(p)??0),0)===t.nodes[l].sequenceLength&&i.set(c,d)}}return{members:i,flipped:o}}var Tc={start:"end",end:"start"},Wr={"+":"-","-":"+"};function Ac(e,{members:t,flipped:n}){if(t.size===0)return e;let o=new Map(e.nodes.map(f=>[f.id,f])),r=new Map,s=new Set,a=(f,p)=>n.has(f)?Tc[p]:p;for(let[f,p]of t)p.forEach((h,m)=>{r.set(h,f);let b=p[m+1];b!==void 0&&s.add(`${h}:${a(h,"end")} ${b}:${a(b,"start")}`)});let i=new Set([...r].filter(([f,p])=>f!==p).map(([f])=>f)),c=e.nodes.flatMap(f=>{let p=t.get(f.id);if(!p)return i.has(f.id)?[]:[f];let h=p.map(b=>o.get(b)),m=h.flatMap(b=>b.stable?[b.stable.start]:[]);return[{...f,length:h.reduce((b,g)=>b+g.length,0),stable:f.stable&&{...f.stable,start:Math.min(...m)}}]}),l=(f,p,h)=>a(p,a(f,h))==="end"?wt(p):Wr[wt(p)],d=e.edges.flatMap(f=>{let p=Fn(f),h=`${f.from}:${p.from}`,m=`${f.to}:${p.to}`;if(s.has(`${h} ${m}`)||s.has(`${m} ${h}`))return[];let b=r.get(f.from),g=r.get(f.to);return[{...f,...b===void 0?{}:{from:b,fromStrand:l(f.from,b,p.from)},...g===void 0?{}:{to:g,toStrand:Wr[l(f.to,g,p.to)]}}]}),u=new Set([...i].map(f=>o.get(f)?.name??f));return{...e,nodes:c,edges:d,paths:e.paths?.map(f=>({...f,nodeIds:f.nodeIds.filter(p=>!i.has(p))})),pathVisits:e.pathVisits?.filter(()=>!0,f=>!u.has(f))}}function Hr(e){let t=e.paths??[],n=yc(e),o=e.reads?Go(e,e.reads,t.length):[],r=o.length>0?Hn:Yn,s=t.map((d,u)=>r(u,t.length)),a=t.some(d=>d.members),i=t.reduce((d,u)=>d+(u.members?.length??1),0),c=Nr(wc(e),n,o,{nodeWidthOption:"compressed",trackWidth:Ec(a?i:n.length),...a?{freqWidth:"linear"}:{}});if(!c)return;let l=Rc(e,c,[...n,...o]);return{layout:c,pathColors:s,members:l.members,graph:Ac(e,l)}}function fn(e){let t=[];return e.nodes.forEach(n=>{n.order>=0&&t.push(n)}),t}function Ur(e,t,n,o){let r=e.y+e.contentHeight/2-t;return[{x:n,y:r},{x:o,y:r}]}function jr(e,t){return{minY:e.bounds.minY-t,maxY:e.bounds.maxY-t}}function Ch(e){let t=Yr(e)?Hr(e):void 0;if(!t)return;let{layout:n,...o}=t,r=n.bounds.minY,s={};for(let c of fn(n))s[c.name]=Ur(c,r,c.x,c.x+c.pixelWidth);let{minY:a,maxY:i}=jr(n,r);return{nodePositions:s,tubeMap:{layout:n,yOffset:r,...o},extent:{minX:n.bounds.minX,maxX:n.bounds.maxX,minY:a,maxY:i}}}function _c(e,t){let n=new Map(e.nodes.map(i=>[i.id,i])),o=qe(fn(t),i=>i.order),r=[],s=-1/0;for(let i of[...o.keys()].sort((c,l)=>c-l)){let c=o.get(i),l=1/0,d=-1/0;for(let u of c){let f=n.get(u.name);f&&C(f)&&(l=Math.min(l,f.stable.start),d=Math.max(d,f.stable.start+f.length))}l===1/0&&(l=d=s),l<s&&(l=s,d=Math.max(s,d)),s=Math.max(s,d),r.push({order:i,x0:Math.min(...c.map(u=>u.x)),x1:Math.max(...c.map(u=>u.x+u.pixelWidth)),bp0:l,bp1:d})}let a=r.find(i=>i.bp0!==-1/0);for(let i of r)i.bp0===-1/0&&(i.bp0=i.bp1=a?.bp0??0);return r}function Oc(e){return Yr(e)&&e.nodes.some(C)}function Lh(e){let t=Oc(e)?Hr(e):void 0;if(!t)return;let{layout:n,...o}=t,r=_c(o.graph,n),s=new Map(r.map(c=>[c.order,c])),a=n.bounds.minY,i={};for(let c of fn(n)){let l=s.get(c.order);i[c.name]=Ur(c,a,l.bp0,l.bp1)}return{nodePositions:i,tubeMap:{layout:n,yOffset:a,columns:r,...o},referenceAxis:!0,pixelRows:!0,extent:jr(n,a)}}function Nc(e,t){let n=[],o=()=>({a:-1/0,b:1/0,detour:[],bp:0}),r=[o()];for(let{node:s,strand:a}of t){let i=r.at(-1),c=n.at(-1);if(C(s)){let l=s.stable.start,d=l+s.length,u=a!==(s.stable.strand??"+"),f=c!==void 0&&i.detour.length===0;f&&!c.inverted&&!u&&c.end===l?c.end=d:f&&c.inverted&&u&&c.start===d?c.start=l:(n.push({start:l,end:d,inverted:u}),r.push(o()))}else i.detour.push({node:s,strand:a}),i.bp+=s.length}return n.forEach((s,a)=>{r[a].b=s.start,r[a+1].a=s.end}),{path:e,runs:n,gaps:r}}function dn(e,t){return Number.isFinite(e.a)&&Number.isFinite(e.b)&&e.b>=e.a&&Math.max(e.b-e.a,e.bp)<t}function Vr(e,t,n){let o=fe(e.length,r=>e[r]<=t);return o<e.length&&e[o]<n}function Pc(e){let t=new Map;for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n],s=o.stable.start+o.length;s!==r.stable.start&&(t.set(s,"reference-gap"),t.set(r.stable.start,"reference-gap"))}return t}function $c(e,t,n){let o=(s,a)=>{Number.isFinite(s)&&!n.has(s)&&n.set(s,a)};for(let{runs:s,gaps:a}of e){let i=s[0],c=s.at(-1);i&&c&&(o(i.start,"walk-end"),o(c.end,"walk-end"));for(let l of s)l.inverted&&l.end-l.start>=t&&(o(l.start,"inversion"),o(l.end,"inversion"));for(let l of a)l.b<l.a?(o(l.a,"backward"),o(l.b,"backward")):dn(l,t)||(o(l.a,"variant"),o(l.b,"variant"))}let r=e.flatMap(({runs:s,gaps:a})=>[...a.filter(i=>dn(i,t)).map(i=>[i.a,i.b]),...s.filter(i=>i.inverted&&i.end-i.start<t).map(i=>[i.start,i.end])]);for(let s=!0;s;){s=!1;let a=[...n.keys()].sort((i,c)=>i-c);for(let[i,c]of r)Vr(a,i,c)&&(s||=!n.has(i)||!n.has(c),o(i,"overlap"),o(c,"overlap"))}return n}function Ic(e,t){let n=[],o=[],r=()=>{let s=o[0],a=o.at(-1);if(s&&a){let i=s.stable.start,c=a.stable.start+a.length,l=`${i}-${c}`;n.push({node:{id:`${l}+`,name:l,length:c-i,depth:0,stable:{refName:s.stable.refName,start:i,rank:0,strand:"+"}},members:o})}o=[]};for(let s of e)t.has(s.stable.start)&&r(),o.push(s);return r(),n}function un(e,t,n){return Math.max(0,fe(e.length,o=>t(e[o])<=n)-1)}function Wh(e,t){let n=e.nodes.filter(C).sort((x,w)=>x.stable.start-w.stable.start),o=e.paths??[];if(n.length===0||o.length===0)return;let r=ln(e),s=o.map((x,w)=>Nc(x,r[w])),a=$c(s,t,Pc(n)),i=[...a.keys()].sort((x,w)=>x-w),c=Ic(n,a),l=x=>un(c,w=>w.node.stable.start,x),d=new Map,u=new Map;for(let x of c){d.set(x.node.id,x.members.map(w=>w.id));for(let w of x.members)u.set(w.id,x.node.id)}let f=new Map,p=x=>{let w=`${x.a} ${x.b} ${x.detour.map(E=>E.node.id+E.strand).join(",")}`,v=f.get(w);if(!v){let E=`r${f.size}`;v={id:`${E}+`,name:E,length:x.bp,depth:0,stable:{refName:n[0].stable.refName,start:Number.isFinite(x.a)?x.a:x.b,rank:1,strand:"+"}},f.set(w,v),d.set(v.id,x.detour.map(O=>O.node.id));for(let O of x.detour)u.has(O.node.id)||u.set(O.node.id,v.id)}return v},h=new Map,m=[],b=new _n,g=new Map,y=new Map;for(let{path:x,runs:w,gaps:v}of s){let E=[],O=[],A=!1,X=(R,$)=>{let I=E.at(-1);A&&I?.node===R&&I.strand===$||E.push({node:R,strand:$}),A=!0},j=R=>{A=!1,R.detour.length>0&&(X(p(R),"+"),A=!1)},U=R=>{(R.bp>0||R.b>R.a)&&O.push({start:R.a,end:R.b,bp:R.bp});let $=c[l(R.b>R.a?R.a:R.a-1)];for(let I of R.detour)u.has(I.node.id)||(u.set(I.node.id,$.node.id),d.get($.node.id).push(I.node.id))};w.forEach((R,$)=>{let I=v[$];dn(I,t)&&!Vr(i,I.a,I.b)?U(I):j(I);let Y=l(R.start),ee=l(R.end-1),H=R.end-R.start<t;if(R.inverted&&!H){A=!1;for(let V=ee;V>=Y;V--)X(c[V].node,"-");A=!1}else{R.inverted&&O.push({start:R.start,end:R.end,bp:R.end-R.start,inverted:!0});for(let V=Y;V<=ee;V++)X(c[V].node,"+")}}),j(v.at(-1));let z=L(x.name).name,Q=0;E.forEach(({node:R,strand:$},I)=>{y.set(R.id,(y.get(R.id)??0)+1),b.add(R.name,z,x.sample??z,Q,$==="-"),Q+=R.length;let Y=E[I+1];if(Y){let ee=`${R.id}${$} ${Y.node.id}${Y.strand}`,H=g.get(ee);H?H.pathIds.push(x.name):g.set(ee,{from:R.id,to:Y.node.id,fromStrand:$,toStrand:Y.strand,pathIds:[x.name]})}}),m.push({...x,nodeIds:E.map(R=>R.node.id)}),h.set(x.name,O)}let M=[...c.map(x=>x.node),...f.values()].filter(x=>y.has(x.id)).map(x=>({...x,depth:y.get(x.id)}));return{graph:{...e,nodes:M,edges:[...g.values()],paths:m,pathVisits:b.build(),reads:void 0},members:d,coarseOf:u,deviations:h,cuts:a}}function Cc(e,t,n){let o=un(e,r=>r.bp0,t);return[e[o],e[o-1]].find(r=>r&&n.has(r.index)&&r.bp0<=t&&t<=r.bp1)}function Lc(e,t){let n=new Map;for(let[r,s]of t)for(let a of s)we(n,L(r).name,a);let o=new Map;for(let r of e.paths??[])if(r.members){let s=new Map;for(let a of r.members.flatMap(i=>n.get(i)??[]))s.set(`${a.start}-${a.end}`,a);o.set(r.name,[...s.values()])}else o.set(r.name,t.get(r.name)??[]);return o}function um(e,t){let{graph:n,layout:o}=e,r=[...zt(e).values()].flat().sort((i,c)=>i.bp0-c.bp0),s=Lc(n,t),a=[];for(let i of o.tracks){let c=i.name?s.get(i.name):void 0;if(c?.length){let l=new Map;for(let d of i.path)d.node!==null&&d.y!==void 0&&!l.has(d.node)&&l.set(d.node,d.y);for(let d of c){let u=Cc(r,d.start,l);u&&a.push({x0:Be(u,d.start),x1:Be(u,d.end),y:l.get(u.index),height:i.width})}}}return a}function Bc(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function pm(e,t,{x:n,y:o,width:r,darkMode:s}){if(t.length!==0){e.fillStyle=Bc(s),e.beginPath();for(let a of t){let i=n(a.x0),c=Math.max(n(a.x1),i+1);if(c>=0&&i<=r){let l=o(a.y);e.rect(i,l,c-i,o(a.y+a.height)-l)}}e.fill()}}var pn=24,Xc=.5,Fc=e=>e.bp1>e.bp0;function gm(e,t){let n=e.filter(Fc);if(n.length===0){let l=e[0];return l?[{tx:l.x0,sx:t(l.bp0)}]:[]}let o=[],r=[],s=[];n.forEach((l,d)=>{o.push(l.x0,l.x1),r.push(t(l.bp0),t(l.bp1)),s.push(d===0?0:Math.min(l.x0-n[d-1].x1,pn),0)});let a=r.at(-1)-r[0],i=s.reduce((l,d)=>l+d,0),c=i>0?Math.min(1,Xc*a/i):1;return Dc(r,s,c).map((l,d)=>({tx:o[d],sx:l}))}function Dc(e,t,n){let o=[],r=0;for(let a of t)r+=a*n,o.push(r);let s=[];return e.forEach((a,i)=>{let c={mean:a-o[i],n:1},l=s.at(-1);for(;l&&l.mean>=c.mean;){s.pop();let d=l.n+c.n;c={mean:(l.mean*l.n+c.mean*c.n)/d,n:d},l=s.at(-1)}s.push(c)}),s.flatMap(a=>Array(a.n).fill(a.mean)).map((a,i)=>a+o[i])}function bm(e,t){let n=e.length;if(n===0)return t;let o=e[0],r=e[n-1];if(t<=o.tx)return o.sx+(t-o.tx);if(t>=r.tx)return r.sx+(t-r.tx);let s=1+fe(n-2,l=>e[l+1].tx<=t),a=e[s-1],i=e[s],c=i.tx-a.tx;return c>0?a.sx+(t-a.tx)/c*(i.sx-a.sx):a.sx}function qc(e,t){let n=[],o=e.sequenceNew??[],r=e.path.filter(s=>s.node!==null);return o.forEach((s,a)=>{let i=t.nodeMap.get(W(s.nodeName)),c=i===void 0?void 0:t.nodes[i],l=r[a];if(c&&l?.y!==void 0){let d={readId:e.id,y:l.y,height:e.width},u=f=>Lr(c,f);for(let f of s.mismatches){let p=l.isForward?f:on(f,c.sequenceLength),h=u(p.pos);if(h!==null){if(p.type==="insertion")n.push({...d,kind:"insertion",x:h,seq:p.seq});else if(p.type==="deletion"&&p.length!==void 0){let m=u(p.pos+p.length);m!==null&&n.push({...d,kind:"deletion",x0:h,x1:m,length:p.length})}else if(p.type==="substitution"&&p.seq!==void 0){let m=u(p.pos+p.seq.length);m!==null&&n.push({...d,kind:"substitution",x0:h,x1:m,seq:p.seq})}}}}}),n}function Kr(e){return e.reads.flatMap(t=>qc(t,e))}function gn(e){let t=e.trim().split(/[\s,]+/),n=[],o=0,r=()=>Number(t[o++]);for(;o<t.length;){let s=t[o++];s==="M"||s==="L"?n.push({op:s,x:r(),y:r()}):s==="H"?n.push({op:s,x:r()}):s==="V"?n.push({op:s,y:r()}):s==="Q"?n.push({op:s,x1:r(),y1:r(),x:r(),y:r()}):s==="C"?n.push({op:s,x1:r(),y1:r(),x2:r(),y2:r(),x:r(),y:r()}):s==="Z"&&n.push({op:s})}return n}function Qr(e){let t=1/0,n=-1/0;for(let o of e)"x"in o&&(t=Math.min(t,o.x),n=Math.max(n,o.x)),"x1"in o&&(t=Math.min(t,o.x1),n=Math.max(n,o.x1));return{x0:t,x1:n}}function zr(e,t,n,o,r){let s=gn(e);return{commands:s,outline:qr(e,12),color:t,id:n,haplotype:o,reference:r,...Qr(s)}}function es(e,t){return new Map(e.tracks.map(n=>[n.id,n.type==="read"?Wo(n):t[n.id]]))}function Zr(e,t,n,o,r){let{shapes:s}=e,a=t==="haplotype",i=f=>n.get(f.id),c=f=>a&&o.has(f.id),l=[...s.rectangles,...s.verticalRectangles].filter(f=>f.type===t).map(f=>({color:i(f),id:f.id,haplotype:a,reference:c(f),x0:f.xStart,x1:f.xEnd+1,y0:f.yStart,y1:f.yEnd+1})),d=Dr(s.curves,t,{gapWidth:r}).map(f=>zr(f.path,i(f),f.id,a,c(f))),u=s.corners.filter(f=>f.type===t).map(f=>zr(f.path,i(f),f.id,a,c(f)));return{rects:l,shapes:[...d,...u]}}function Gc(e){let t=new Set,n=e&&Xe(e);return e?.paths?.forEach((o,r)=>{L(o.name).name===n&&t.add(r)}),t}function Wc({layout:e,pathColors:t,graph:n,columns:o}){let r=es(e,t),s=Gc(n),a=o?pn:void 0,i=[];return e.nodes.forEach(c=>{if(c.order>=0){let l=gn(Gr(c));i.push({name:c.name,commands:l,...Qr(l)})}}),{bounds:e.bounds,layers:[Zr(e,"haplotype",r,s,a),Zr(e,"read",r,s,a)],nodes:i,mismatches:Kr(e)}}function hn(e,t,n,o){let r=0,s=0;for(let a of t)switch(a.op){case"M":r=a.x,s=a.y,e.moveTo(n(r),o(s));break;case"L":r=a.x,s=a.y,e.lineTo(n(r),o(s));break;case"H":r=a.x,e.lineTo(n(r),o(s));break;case"V":s=a.y,e.lineTo(n(r),o(s));break;case"Q":r=a.x,s=a.y,e.quadraticCurveTo(n(a.x1),o(a.y1),n(r),o(s));break;case"C":r=a.x,s=a.y,e.bezierCurveTo(n(a.x1),o(a.y1),n(a.x2),o(a.y2),n(r),o(s));break;case"Z":e.closePath();break}}function Jr(e,t,n,o,r){let s=new Map;for(let a of t)n(a)&&we(s,o(a),a);for(let a of s.values()){e.fillStyle=o(a[0]),e.beginPath();for(let i of a)r(i);e.fill()}}var Yc=12,Hc=.15;function Uc(e){return Math.max(Hc,Math.min(1,e/Yc))}var jc=.55;function Vc(e,t,n){let{x:o,y:r,width:s}=n,a=d=>o(d.x1)>=0&&o(d.x0)<=s,i=d=>d.haplotype&&n.tubeColors?.[d.id]||d.color;e.globalAlpha=1;for(let d of t.layers)for(let u of[!1,!0]){let f=p=>p.reference===u;Jr(e,d.rects,p=>f(p)&&a(p),i,p=>{let h=o(p.x0),m=r(p.y0);e.rect(h,m,o(p.x1)-h,r(p.y1)-m)}),Jr(e,d.shapes,p=>f(p)&&a(p),i,p=>{hn(e,p.commands,o,r)})}let c=n.darkMode?"#d0d0d0":"#000000",l=n.darkMode?"rgba(40,40,40,0.4)":"rgba(255,255,255,0.4)";e.lineWidth=ts(n);for(let d of t.nodes)if(a(d)&&d.name!==n.highlightNode){e.beginPath(),hn(e,d.commands,o,r);let u=n.nodeColors?.get(d.name);e.fillStyle=u??l,e.strokeStyle=c,e.globalAlpha=u?jc:1,e.fill(),e.globalAlpha=Uc(o(d.x1)-o(d.x0)),e.stroke(),e.globalAlpha=1}at(e,t,n),zc(e,t.mismatches,n)}function ts(e){return 2*Math.max(.25,Math.min(1,e.yScale))}function at(e,t,n){let o=n.highlightNode?t.nodes.find(r=>r.name===n.highlightNode):void 0;o&&(e.beginPath(),hn(e,o.commands,n.x,n.y),e.globalAlpha=1,e.lineWidth=ts(n),e.fillStyle="rgba(255,192,203,0.5)",e.strokeStyle="#ff0000",e.fill(),e.stroke())}var ns=12,Kc=6;function bn(e){return ns*e>=Kc}function mn(e,{x:t,width:n}){let[o,r]=e.kind==="insertion"?[e.x,e.x]:[e.x0,e.x1];return t(r)>=0&&t(o)<=n}function zc(e,t,n){let{x:o,y:r,yScale:s,darkMode:a}=n;if(!bn(s)||t.length===0)return;let i=ns*s;e.fillStyle="grey",e.beginPath();for(let c of t)if(c.kind==="deletion"&&mn(c,n)){let l=o(c.x0),d=r(c.y);e.rect(l,d,o(c.x1)-l,r(c.y+c.height)-d)}e.fill(),e.font=`${i}px monospace`,e.textAlign="left",e.textBaseline="alphabetic",e.fillStyle=a?"#ffffff":"#000000";for(let c of t)mn(c,n)&&(c.kind==="substitution"?e.fillText(c.seq,o(c.x0)+1,r(c.y+c.height)):c.kind==="insertion"&&e.fillText("*",o(c.x)-3,r(c.y+c.height)))}function Zc(e,t,n){let o=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){let[a,i]=e[r],[c,l]=e[s];i>n!=l>n&&t<(c-a)*(n-i)/(l-i)+a&&(o=!o)}return o}function Jc(e,{x:t,y:n},o,r){for(let s=e.layers.length-1;s>=0;s--){let{rects:a,shapes:i}=e.layers[s];for(let c of[!0,!1]){for(let l of a)if(l.reference===c&&t(l.x0)<=o&&o<=t(l.x1)&&n(l.y0)<=r&&r<=n(l.y1))return l.id;for(let l of i)if(l.reference===c&&t(l.x0)<=o&&o<=t(l.x1)&&Zc(l.outline.map(([d,u])=>[t(d),n(u)]),o,r))return l.id}}}var Qc=4;function el(e,t,n,o){let{x:r,y:s,yScale:a}=t;return bn(a)?e.mismatches.find(i=>s(i.y)<=o&&o<=s(i.y+i.height)&&(i.kind==="insertion"?Math.abs(r(i.x)-n)<=Qc:r(i.x0)<=n&&n<=r(i.x1))):void 0}var me=JBrowseExports["@jbrowse/core/util/groupKeys"],tl=e=>me!=null&&e in Object(me)?me[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/core/util/groupKeys' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var it=tl("groupKeyComparator");var hg=me&&me.__esModule?me.default:me;var ct=16;function xg(e){let[t="",...n]=e.split(/\r\n|\r|\n/),o=t.split(" ").slice(1),r=new Map;for(let s of n){if(!s)continue;let[a="",...i]=s.split(" ");a&&!r.has(a)&&r.set(a,{...Object.fromEntries(o.map((c,l)=>[c,i[l]??""])),name:a})}return[...r.values()]}function yg(e){let t=new Set;for(let n of e??[])for(let o of Object.keys(n))o!=="name"&&t.add(o);return[...t]}function wg(e){if(typeof e=="string")return e?{field:e}:void 0;let{field:t,domain:n}=e??{};if(!(typeof t!="string"||!t))return Array.isArray(n)?{field:t,domain:n.filter(o=>typeof o=="string")}:{field:t}}function xn(e,t){return`${e} ${t}${e===1?"":"s"}`}function yn(e,t){let n=new Map(t.map(o=>[o.name,o[e]??""]));return(o,r)=>n.get(o)||n.get(r)||""}function wn(e,t,{field:n,domain:o},r,s){let a=new Map;for(let i of e){let c=t(i),l=a.get(c);l?l.push(i):a.set(c,[i])}return[...a.keys()].sort(it(o)).map(i=>{let c=a.get(i),l=new Set(c.map(s)).size;return{key:i,members:c,title:`${i||`${n}: none`} \xB7 ${xn(l,r)}`}})}function Mg(e,t,n){let o=yn(n.field,t),r=wn(e,i=>o(i.label,i.sample),n,"haplotype",i=>i.label),s=1,a=r.map(({key:i,members:c,title:l})=>{let d={key:i,title:l,first:s,count:c.length};return s+=c.length,d});return{rows:r.flatMap(i=>i.members),sections:a}}function vg(e,t){let n=r=>{let s=-1;for(;s+1<e.length&&e[s+1].first<=r;)s++;return s},o=r=>r*t+(n(r)+1)*ct;return{rowY:o,headers:e.map((r,s)=>({...r,top:(r.first-.5)*t+s*ct})),headersPx:e.length*ct,rowAt(r,s){let a=0;for(let i=-1;i<e.length;i++){let c=i<0?0:e[i].first,l=i<0?Math.min(s,e[0]?.first??s):c+e[i].count,d=(i+1)*ct,u=Math.min(l-1,Math.max(c,Math.round((r-d)/t)));Math.abs(o(u)-r)<Math.abs(o(a)-r)&&(a=u)}return a}}}function Sg(e,t,n,o,r){return t.length===0?[Le(e,o,r)]:[Le({...e,rows:[]},o,r),...t.flatMap((s,a)=>Le({...e,rows:e.rows.slice(s.first-1,s.first-1+s.count)},{...o,translateY:o.translateY+(n(s.first)-o.rowPx)*o.scaleY},{...r,idPrefix:`${r.idPrefix}-s${a}`}).children.filter(c=>typeof c!="string"&&c.attrs["data-testid"]!=="graph-walk-reference"))]}function nl(e,t,n,o){let r=[],s=[],a=[e];for(o.add(e);a.length>0;){let i=a.pop(),c=t.get(i);if(c){r.push(c);for(let l of n.get(i)??[]){let d=t.get(l);d&&(d.stable.rank===pt?s.push(d):o.has(l)||(o.add(l),a.push(l)))}}}return{members:r,anchors:s}}function ol(e){if(new Set(e.map(i=>i.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((i,c)=>i.stable.start-c.stable.start),o=n[0],r=n.at(-1),s=o.stable.start+o.length,a=r.stable.start;return a>=s?{start:s,end:a,entry:o}:void 0}function rl(e,t,n){let o=new Map(e.map(a=>[a.id,a])),r=new Map,s=[];for(let a of n.get(t.id)??[])o.has(a)&&(r.set(a,0),s.push(a));if(s.length===0)for(let a of e)r.set(a.id,0),s.push(a.id);for(let a of s){let i=r.get(a)+o.get(a).length;for(let c of n.get(a)??[])if(o.has(c)){let l=r.get(c);(l===void 0||i<l)&&(r.set(c,i),s.push(c))}}return r}function sl(e,t,n){let o=rl(e,t,n),r=[...e].sort((c,l)=>o.get(c.id)-o.get(l.id)),s=new Map(r.map((c,l)=>[c.id,l])),a=new Map(e.map(c=>[c.id,c])),i=new Map;for(let[c,l]of r.entries()){let d=0;for(let u of n.get(l.id)??[]){let f=a.get(u);f&&s.get(u)<c&&(d=Math.max(d,i.get(u)+f.length))}i.set(l.id,d)}return{offsets:i,ordered:r}}function al(e){let t=new Map(e.nodes.filter(En).map(s=>[s.id,s])),n=Ve(e),o=new Set,r=[];for(let s of t.values())if(s.stable.rank!==pt&&!o.has(s.id)){let{members:a,anchors:i}=nl(s.id,t,n,o),c=ol(i);if(c){let{offsets:l,ordered:d}=sl(a,c.entry,n);r.push({start:c.start,refSpan:c.end-c.start,nodeIds:d.map(u=>u.id),nodeOffsets:d.map(u=>l.get(u.id)),pathLength:d.reduce((u,f)=>Math.max(u,l.get(f.id)+f.length),0)})}}return r.sort((s,a)=>s.start-a.start)}var il=28,os="#4d4d4d",cl="#5b8cc4",ll=[cl,"#82abd9"],Zg=["#8c8c8c","#adadad"],fl="12px sans-serif",Jg=[{field:"",label:"None"},{field:"sample",label:"A panel per sample"},{field:"walk",label:"A panel per haplotype"}],ne=e=>L(e).name;function Qg(e,t,n=ll){let o=0;return e.map(r=>ne(r.name)===t?os:n[o++%n.length])}var dl=["#4e79a7","#f28e2b","#59a14f","#e15759","#b07aa1","#76b7b2","#edc948","#9c755f","#ff9da7","#bab0ac"],rs="#c8c8c8";function e0(e){let t=[...new Set(e)].filter(n=>n!=="").sort(it());return new Map(t.map((n,o)=>[n,dl[o]??rs]))}function t0(e,t,n,o){return e.map(r=>{let s=ne(r.name);return s===t?os:o.get(n(r.members?.[0]??s))??rs})}function ul(e,t){let n=yn(e,t);return o=>{let{sample:r,haplotype:s}=_e(o);return n(`${r}#${s}`,r)}}function n0(e,t){let n=(e.paths??[]).map(c=>c.name).filter(c=>ne(c)!==e.referencePath);if(t.by==="column"){let c=ul(t.field,t.table);return wn(n,l=>c(ne(l)),t,"sample",l=>_e(ne(l)).sample).map(({key:l,members:d,title:u})=>({key:l,paths:d,label:u}))}let o=t.by==="sample"?c=>_e(c).sample:c=>c,r=new Map;for(let c of n){let l=o(ne(c)),d=r.get(l);d?d.push(c):r.set(l,[c])}let s=t.domain??[],a=new Map(s.map((c,l)=>[c,l])),i=c=>a.get(c)??s.length;return[...r].map(([c,l],d)=>({key:c,paths:l,i:d})).sort((c,l)=>i(c.key)-i(l.key)||c.i-l.i).map(({key:c,paths:l})=>({key:c,paths:l}))}function o0(e,t){if(e.graph.nodes.some(n=>n.id===t))return t;for(let[n,o]of e.members)if(o.includes(t))return n}function r0(e,t,n,o,r){let s=e.flatMap(u=>{let f=t(u);return f?[{id:u,...f}]:[]});if(s.length===0)return;let a=Math.min(...s.map(u=>u.start)),i=Math.max(...s.map(u=>u.end)),c=o>n?(r-n)/(o-n):0,l=a+Math.min(1,Math.max(0,c))*(i-a),d=u=>l<u.start?u.start-l:l>=u.end?l-u.end+1:0;return s.reduce((u,f)=>d(f)<d(u)?f:u).id}function s0(e,t){let n=new Set,o=new Set;for(let r of e.paths??[]){let s=ne(r.name);if(s!==e.referencePath)for(let a of r.members??[s])n.add(a),r.nodeIds.includes(t)&&o.add(a)}return{here:o.size,of:n.size}}var pl="bold 11px sans-serif",hl=80,ml=9;function a0(e,t,n,{x:o,y:r,width:s}){let a=n.paths??[];if(!a.some(c=>c.members))return;let i=new Map;a.forEach((c,l)=>{ne(c.name)!==n.referencePath&&i.set(l,c.members?.length??1)}),e.font=pl,e.textAlign="left",e.textBaseline="middle",e.fillStyle="#0b1f3a";for(let c of t.layers[0]?.rects??[]){let l=i.get(c.id),d=Math.max(0,o(c.x0)),u=Math.min(s,o(c.x1)),f=r(c.y0),p=r(c.y1);l!==void 0&&u-d>=hl&&p-f>=ml&&e.fillText(`\xD7${l}`,d+4,(f+p)/2)}}var gl="10px sans-serif",bl=1e3;function i0(e,t,{x:n,y:o,width:r}){if(!t.columns)return;let s=new Map(t.graph.nodes.map(c=>[c.id,c.length]));e.font=gl;let a=new Map;t.layout.nodes.forEach(c=>{let l=s.get(c.name)??0,d=n(c.x),u=n(c.x+c.pixelWidth),f=B(l);if(c.order>=0&&l>=bl&&u-d<e.measureText(f).width){let p=(o(c.y)+o(c.y+c.contentHeight))/2,h=`${Math.round(u)}:${f}`,m=a.get(h);m?(m.count++,m.mid=Math.max(m.mid,p)):a.set(h,{text:f,right:u,mid:p,count:1})}}),e.textAlign="left",e.textBaseline="middle",e.lineJoin="round",e.lineWidth=3,e.strokeStyle="rgba(255,255,255,0.9)",e.fillStyle="rgba(0,0,0,0.75)";let i=[];for(let{text:c,right:l,mid:d,count:u}of a.values()){let f=u>1?`${c} each`:c,p={x0:l+3,x1:l+3+e.measureText(f).width,y0:d-6,y1:d+6};p.x1<=r&&!i.some(h=>h.x0<p.x1&&p.x0<h.x1&&h.y0<p.y1&&p.y0<h.y1)&&(i.push(p),e.strokeText(f,p.x0,d),e.fillText(f,p.x0,d))}}function c0(e,t,n,{width:o,lit:r}){t.forEach((s,a)=>{let i=n?.[a];i&&(r&&at(e,s.picture,{...s.frame,width:o,highlightNode:i.box}),e.font=fl,e.textAlign="left",e.textBaseline="top",e.fillStyle="#c00000",e.fillText(` \xB7 ${i.here} of ${xn(i.of,"haplotype")} here`,6+e.measureText(s.label).width,s.titleTop+4))})}function l0(e,t){let n=new Set(t),o=(e.paths??[]).filter(l=>n.has(l.name)||ne(l.name)===e.referencePath),r=new Set(o.map(l=>ne(l.name))),s=new Set(o.flatMap(l=>l.nodeIds)),a=e.nodes.filter(l=>s.has(l.id)),i=new Set(a.map(l=>l.name)),c=e.pathVisits?.filter(l=>r.has(l),l=>i.has(l));return{...e,nodes:a,edges:e.edges.filter(l=>s.has(l.from)&&s.has(l.to)),paths:o,anchorPaths:e.anchorPaths?.filter(l=>r.has(l.name)),pathVisits:c,reads:void 0}}function f0(e,t){let n=[],o={},r=0,s=1/0,a=-1/0;for(let{key:i,paths:c,label:l,result:d}of t){let u=d?.tubeMap,f=d?.extent;if(u&&f){let p=r+il,h=(f.maxY??0)-(f.minY??0);n.push({key:i,paths:c,label:l,result:{...d,tubeMap:u},top:p,height:h});let m=p-(f.minY??0);for(let[b,g]of Object.entries(d.nodePositions))o[b]=g.map(y=>({x:y.x,y:y.y+m}));r=p+h,s=Math.min(s,f.minX??s),a=Math.max(a,f.maxX??a)}}return n.length>1?{...e,nodePositions:o,extent:{...s<=a?{minX:s,maxX:a}:{},minY:0,maxY:r},tubeMapPanels:n}:e}var xl="#daa520",yl=1,wl=2,Ml=4;function p0(e,t,n,o=r=>r){let r=s=>{let a=t(s)*2;return n?.nodeIds.has(s)?Math.max(a,n.walks.length*Ml):a};return e.flatMap(s=>s.exonsByNode.map(({nodeId:a,d:i})=>({key:`${s.gene.name}-${s.gene.start}-${a}`,d:o(i),inner:r(a)+2*yl})))}function h0(e,t){if(e.length===0)return;let n=(o,r,s)=>P("path",{d:o.d,fill:"none",stroke:r,"stroke-width":s,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":t.transform?"non-scaling-stroke":void 0});return P("g",{},P("mask",{id:t.id,maskUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height},P("g",{transform:t.transform},...e.map(o=>n(o,"#fff",o.inner+2*wl)),...e.map(o=>n(o,"#000",o.inner)))),P("rect",{width:t.width,height:t.height,fill:xl,mask:`url(#${t.id})`}))}function Mn(e,t,n){let o=Math.round(t),r=Math.round(n);return`${e?`${e}:`:""}${ve(o)}-${ve(r)} (${B(r-o)})`}function vl(e,t){let{field:n}=e.encoding,o=e.range?Mn(e.range.contig,e.range.start,e.range.end):void 0,r=n==="progress"?o:n==="reference"&&t?Mn(t.name,t.start,t.end):void 0,s=e.range?e.range.end-e.range.start:e.bp,a=s-e.bp-e.missingBp-e.unknownBp,i=[[e.missingBp,se.missing],[e.unknownBp,se.unknown],[a,Me]];return{delta:e.referenceBp===void 0||s===e.referenceBp?"":` ${s>e.referenceBp?"+":"\u2212"}${B(Math.abs(s-e.referenceBp))}`,gaps:i.filter(([c])=>c>0).map(([c,l])=>`, ${B(c)} ${l}`).join(""),reversed:e.reversedBp>0?`, ${B(e.reversedBp)} reversed`:"",shades:n!=="walk",scale:r,hover:r===o?void 0:o}}function Sl(e,t,n){let o=e.progress.get(t),r=e.range;if(o===void 0||!r)return;let s=Math.round(r.start+o*(r.end-r.start)-n/2);return`${r.contig}:${ve(s)}-${ve(s+n)}`}function El(e,t){let n=[];for(let o of t){let r=e.get(o.refName),s=r?.[0],a=r?.at(-1);if(!r||!s||!a)continue;let i=Math.max(o.start,s.bp0),c=Math.min(o.end,a.bp1);c<=i||n.push({gene:o,...ot(r,i,c),exons:o.exons.filter(l=>l.end>i&&l.start<c).map(l=>ot(r,Math.max(l.start,i),Math.min(l.end,c)))})}return n}var vn=22,kl=4,lt=8,Rl="11px sans-serif",Tl=8;function Al(e){let t=e.flatMap(r=>[{x:r.x0,step:1},{x:r.x1,step:-1}]).sort((r,s)=>r.x-s.x||r.step-s.step),n=0,o=0;for(let{step:r}of t)n+=r,o=Math.max(o,n);return Math.min(kl,o)}function _l(e,t,n,o,r=0){let{x:s,width:a,darkMode:i}=n,c=Math.max(1,Math.floor((o-r)/vn)),l=[],d=i?"#e0e0e6":"#1c1c22";e.font=Rl,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=d,e.strokeStyle=d,e.lineWidth=1;let u=t.map(f=>({g:f,s0:s(f.x0),s1:s(f.x1)})).filter(({s0:f,s1:p})=>p>=0&&f<=a).sort((f,p)=>f.s0-p.s0);for(let{g:f,s0:p,s1:h}of u){let m=f.gene.strand>0?" \u2192":f.gene.strand<0?"\u2190 ":"",b=f.gene.strand<0?`${m}${f.gene.name}`:`${f.gene.name}${m}`,g=(Math.max(p,0)+Math.min(h,a))/2,y=e.measureText(b).width/2,M=Math.min(p,g-y),x=Math.max(h,g+y),w=l.findIndex(E=>E+Tl<=M);w===-1&&(w=Math.min(l.length,c-1)),l[w]=Math.max(l[w]??-1/0,x);let v=o-w*vn-lt/2;e.beginPath(),e.moveTo(p,v+.5),e.lineTo(h,v+.5),e.stroke();for(let E of f.exons){let O=s(E.x0);e.fillRect(O,v-lt/2,Math.max(1,s(E.x1)-O),lt)}e.fillText(b,g,v-lt/2-2)}}var oe=12,ls=oe+8,fs=8,ss=fs+3,Ol=12;function Nl(e,{colorScheme:t,referenceRamp:n,walks:o}){let r=Rt(e,n),s=[];return e.nodes.forEach((a,i)=>{if(C(a)){let c=o?o.map(l=>{let d=l.colors.get(a.id);return d===void 0?Ke:ae(d)}):[ae(Tt(a,i,t,r))];s.push({node:a.id,bp0:a.stable.start,bp1:a.stable.start+a.length,colors:c,faded:c.includes(Ke)})}}),s.sort((a,i)=>a.bp0-i.bp0)}function Sn(e,t,n){let o=t*e.scale+e.translateX,r=n*e.scale+e.translateX;return o<r?[o,r]:[r,o]}var as=2;function ds(e,t,n){let o=-t.translateX/t.scale,r=(n-t.translateX)/t.scale,s=Math.min(o,r),a=Math.max(o,r),i=0,c=0;for(let l of e)i+=Math.max(0,Math.min(l.bp1,s)-l.bp0),c+=Math.max(0,l.bp1-Math.max(l.bp0,a));return t.scale>=0?{left:Math.round(i),right:Math.round(c)}:{left:Math.round(c),right:Math.round(i)}}function Pl(e,t,n,o){if(o<0||o>oe+as)return;let r,s=as;for(let a of e){let[i,c]=Sn(t,a.bp0,a.bp1),l=Math.max(0,i-n,n-c);l<=s&&(s=l,r=a.node)}return r}function $l(e,t){let n=e?.[Math.floor(e.length/2)];return n?t(n):void 0}function us(e,t,n,o){let r=e.map(l=>{let[d,u]=Sn(t,l.bp0,l.bp1),f=Math.round(d*o);return{colors:l.colors,x0:d,px0:f,px1:Math.max(Math.round(u*o),f+1)}}).filter(l=>l.px1>0&&l.px0<n*o).sort((l,d)=>l.x0-d.x0),s=[],a=-1/0,i=[-1/0,-1/0];for(let{colors:l,px0:d,px1:u}of r){let f=Math.max(d,a);if(u>f){let p=i[0]<f?0:1;i[p]=u,s.push({colors:l,x0:f/o,x1:u/o,tier:p}),a=u}}return(s.length>0?s.at(-1).x1-s[0].x0:0)>=s.length*Ol?s:s.map(({tier:l,...d})=>d)}function is(e,t,n,o){let r=n>0?t:t-ss;e.clearRect(r,0,ss,oe);let s=t+n,a=s+n*fs;e.beginPath(),e.moveTo(s,oe/2),e.lineTo(a,0),e.lineTo(a,oe),e.closePath(),e.fillStyle=o,e.fill()}function cs(e,t,n){return Math.round(e*oe*n/t)/n}function Il(e,t,n,{width:o,lit:r,darkMode:s,dpr:a=1}){let i=s?"#ffffff":"#18181c";e.clearRect(0,0,o,ls);for(let l of us(t,n,o,a)){let{tier:d}=l,u=d!==void 0&&l.colors.length===1,f=u?2:l.colors.length;l.colors.forEach((p,h)=>{let m=u?d:h,b=cs(m,f,a);e.fillStyle=p,e.fillRect(l.x0,b,l.x1-l.x0,cs(m+1,f,a)-b)})}let c=ds(t,n,o);if(c.left>0&&is(e,0,1,i),c.right>0&&is(e,o,-1,i),r){let[l,d]=Sn(n,r.start,r.end),u=Math.max(d-l,3),f=(l+d)/2-u/2;e.strokeStyle=i,e.lineWidth=1.5,e.strokeRect(f,.75,u,oe-1.5),r.anchor&&(e.beginPath(),e.moveTo(f+u/2,oe),e.lineTo(r.anchor.x,r.anchor.y),e.lineWidth=1,e.stroke())}}function Cl(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function Ll(e,t){let n=e.length,o=t.length,r=Array.from({length:n+1},()=>new Array(o+1).fill(0)),s=Array.from({length:n+1},()=>new Array(o+1).fill(!1));for(let i=n-1;i>=0;i--)for(let c=o-1;c>=0;c--){let l=Math.abs(e[i]-t[c])+r[i+1][c+1],d=n-i>o-c?r[i+1][c]:1/0,u=o-c>n-i?r[i][c+1]:1/0;r[i][c]=Math.min(l,d,u),s[i][c]=r[i][c]===l}let a=new Array(n).fill(void 0);for(let i=0,c=0;i<n&&c<o;)s[i][c]?a[i++]=c++:n-i>o-c?i++:c++;return a}function ps(e,t){return e.map((n,o)=>({item:n,i:o})).sort((n,o)=>t(n.item)-t(o.item))}var hs=e=>e.spanningReads!==0;function Bl(e,t){return{...t,agrees:e.complete&&hs(t)?Cl(e.bp,t.bp):void 0}}function Xl(e,t){let n=new Map,o=new Set,r=ps(e,a=>a.bp),s=(a,i)=>{let c=[[a.filter(l=>l.item.complete),i.filter(hs)],[a,i]];for(let[l,d]of c){let u=l.filter(p=>!n.has(p.i)),f=ps(d.filter(p=>!o.has(p)),p=>p.bp);Ll(u.map(p=>p.item.bp),f.map(p=>p.item.bp)).forEach((p,h)=>{if(p!==void 0){let m=u[h],b=f[p].item;o.add(b),n.set(m.i,Bl(m.item,b))}})}};for(let a of new Set(t.flatMap(i=>i.haplotype??[])))s(r.filter(i=>i.item.haplotype===a),t.filter(i=>i.haplotype===a));return s(r,t.filter(a=>a.haplotype===void 0)),n}function Vb(e,t){if(!t)return e;let n=new Map,o=new Map;for(let r of e){let s=o.get(r.sample);s?s.push(r):o.set(r.sample,[r])}for(let[r,s]of o){let a=t[r];if(a)for(let[i,c]of Xl(s,a))n.set(s[i],c)}return e.map(r=>({...r,call:n.get(r)}))}var ms=Do.box(typeof devicePixelRatio>"u"?1:devicePixelRatio);function gs(){matchMedia(`(resolution: ${devicePixelRatio}dppx)`).addEventListener("change",()=>{qo(()=>{ms.set(devicePixelRatio)}),gs()},{once:!0})}typeof matchMedia=="function"&&gs();function ex(e=0,t=0){return ms.get(),Se(e,t)}export{Qu as a,ep as b,tp as c,np as d,wa as e,Ma as f,gh as g,bh as h,ln as i,Yr as j,Ch as k,Oc as l,Lh as m,al as n,Nd as o,et as p,P as q,va as r,Sa as s,Ie as t,jt as u,Gt as v,Vo as w,Ko as x,Ce as y,Jo as z,Yt as A,_a as B,Oa as C,er as D,Ia as E,nr as F,or as G,Vt as H,Ca as I,La as J,sr as K,Le as L,Je as M,_t as N,Qe as O,xs as P,ys as Q,ws as R,Ms as S,Ef as T,de as U,go as V,$e as W,Pt as X,Gs as Y,kf as Z,Rf as _,Ys as $,Hs as aa,Us as ba,js as ca,Vs as da,Gd as ea,Wd as fa,Yd as ga,Hd as ha,Ud as ia,jd as ja,Vd as ka,Kd as la,zd as ma,Zd as na,Jd as oa,Qd as pa,eu as qa,tu as ra,nu as sa,ou as ta,ru as ua,su as va,zs as wa,au as xa,iu as ya,cu as za,lu as Aa,fu as Ba,du as Ca,uu as Da,pu as Ea,Ga as Fa,Ya as Ga,Ha,Ua as Ia,Wh as Ja,zt as Ka,ja as La,cr as Ma,ei as Na,ti as Oa,oi as Pa,ri as Qa,pr as Ra,um as Sa,Bc as Ta,pm as Ua,gm as Va,bm as Wa,Wc as Xa,Vc as Ya,at as Za,bn as _a,mn as $a,Jc as ab,el as bb,ct as cb,xg as db,yg as eb,wg as fb,Mg as gb,vg as hb,Sg as ib,il as jb,os as kb,cl as lb,Zg as mb,fl as nb,Jg as ob,Qg as pb,rs as qb,e0 as rb,t0 as sb,ul as tb,n0 as ub,o0 as vb,r0 as wb,s0 as xb,a0 as yb,i0 as zb,c0 as Ab,l0 as Bb,f0 as Cb,mu as Db,Lt as Eb,wu as Fb,xl as Gb,p0 as Hb,h0 as Ib,Nu as Jb,Co as Kb,Pu as Lb,Lo as Mb,Bt as Nb,Bo as Ob,Xo as Pb,ba as Qb,Mn as Rb,vl as Sb,Sl as Tb,El as Ub,vn as Vb,Al as Wb,_l as Xb,ls as Yb,Nl as Zb,ds as _b,Pl as $b,$l as ac,Il as bc,Vb as cc,ex as dc};
3
- //# sourceMappingURL=chunk-WGVATZLM.js.map