jbrowse-plugin-graphgenomeviewer 4.0.7 → 4.0.8

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 (73) hide show
  1. package/README.md +26 -43
  2. package/dist/chunks/AddTrackWorkflow-LRRSAVSX.js +2 -0
  3. package/dist/chunks/{AddTrackWorkflow-J44PELJE.js.map → AddTrackWorkflow-LRRSAVSX.js.map} +1 -1
  4. package/dist/chunks/{GbzBaseSyntenyAdapter-BLSUE5LT.js → GbzBaseSyntenyAdapter-WI3VYEF2.js} +5 -5
  5. package/dist/chunks/{GbzBaseSyntenyAdapter-BLSUE5LT.js.map → GbzBaseSyntenyAdapter-WI3VYEF2.js.map} +4 -4
  6. package/dist/chunks/{GraphGenomeView-U4XVAEO3.js → GraphGenomeView-K5PZO33Q.js} +2 -2
  7. package/dist/chunks/{GraphGenomeView-U4XVAEO3.js.map → GraphGenomeView-K5PZO33Q.js.map} +1 -1
  8. package/dist/chunks/{GraphTrackSettingsDialog-6KKN5F3W.js → GraphTrackSettingsDialog-6STIFKVD.js} +2 -2
  9. package/dist/chunks/LinearGraphDisplay-3WQBA6ZX.js +2 -0
  10. package/dist/chunks/{LinearGraphDisplay-IBECRYKJ.js.map → LinearGraphDisplay-3WQBA6ZX.js.map} +2 -2
  11. package/dist/chunks/{chunk-N7EFSGPU.js → chunk-254OZVVL.js} +2 -2
  12. package/dist/chunks/chunk-5TBIQWPH.js +4 -0
  13. package/dist/chunks/chunk-5TBIQWPH.js.map +7 -0
  14. package/dist/chunks/chunk-FCWXYIFC.js +2 -0
  15. package/dist/chunks/chunk-FCWXYIFC.js.map +7 -0
  16. package/dist/chunks/chunk-JVMMNMQG.js +2 -0
  17. package/dist/chunks/chunk-JVMMNMQG.js.map +7 -0
  18. package/dist/chunks/chunk-NBDRTXH2.js +2 -0
  19. package/dist/chunks/chunk-NBDRTXH2.js.map +7 -0
  20. package/dist/chunks/chunk-VXUVWSY5.js +2 -0
  21. package/dist/chunks/chunk-VXUVWSY5.js.map +7 -0
  22. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
  23. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  24. package/package.json +3 -1
  25. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +45 -1
  26. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +26 -114
  27. package/src/GbzBaseSyntenyAdapter/configSchema.ts +1 -1
  28. package/src/GbzBaseSyntenyAdapter/gbzWindow.ts +166 -0
  29. package/src/GraphAddTrackWorkflow/buildTrackConfig.test.ts +1 -1
  30. package/src/GraphAddTrackWorkflow/buildTrackConfig.ts +1 -1
  31. package/src/GraphGenomeView/components/GraphCanvas.tsx +16 -3
  32. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +70 -0
  33. package/src/GraphGenomeView/labelLayout.test.ts +1 -0
  34. package/src/GraphGenomeView/labelLayout.ts +18 -14
  35. package/src/GraphGenomeView/layout/tubeMapLayout.test.ts +95 -0
  36. package/src/GraphGenomeView/layout/tubeMapLayout.ts +276 -0
  37. package/src/GraphGenomeView/layoutModes.ts +27 -0
  38. package/src/GraphGenomeView/model.test.ts +3 -1
  39. package/src/GraphGenomeView/model.ts +114 -68
  40. package/src/GraphGenomeView/pipeline.ts +14 -5
  41. package/src/GraphGenomeView/renderPasses.bench.ts +1 -0
  42. package/src/GraphGenomeView/tubeMap/draw.ts +264 -0
  43. package/src/GraphGenomeView/tubeMap/frame.test.ts +59 -0
  44. package/src/GraphGenomeView/tubeMap/frame.ts +78 -0
  45. package/src/GraphGenomeView/tubeMap/warp.test.ts +58 -0
  46. package/src/GraphGenomeView/tubeMap/warp.ts +99 -0
  47. package/src/GraphGenomeView/types.ts +8 -4
  48. package/src/GraphGenomeView/viewport.ts +91 -0
  49. package/src/GraphTrack/index.ts +53 -0
  50. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +25 -37
  51. package/src/LinearGraphDisplay/components/LinearGraphDisplay.tsx +1 -1
  52. package/src/LinearGraphDisplay/index.ts +12 -9
  53. package/src/LinearGraphDisplay/model.ts +5 -1
  54. package/src/RgfaTabixAdapter/configSchema.ts +1 -1
  55. package/src/core.test.ts +86 -6
  56. package/src/core.ts +38 -0
  57. package/src/graphTrackDefaults/graphTrackDefaults.test.ts +58 -36
  58. package/src/graphTrackDefaults/index.ts +66 -29
  59. package/src/index.ts +2 -0
  60. package/src/launchFromGraph/launchTracks.ts +1 -2
  61. package/src/version.ts +1 -1
  62. package/dist/chunks/AddTrackWorkflow-J44PELJE.js +0 -2
  63. package/dist/chunks/LinearGraphDisplay-IBECRYKJ.js +0 -2
  64. package/dist/chunks/chunk-C6PIPNZS.js +0 -2
  65. package/dist/chunks/chunk-C6PIPNZS.js.map +0 -7
  66. package/dist/chunks/chunk-IVUTPSHP.js +0 -2
  67. package/dist/chunks/chunk-IVUTPSHP.js.map +0 -7
  68. package/dist/chunks/chunk-J2UKZSOC.js +0 -2
  69. package/dist/chunks/chunk-J2UKZSOC.js.map +0 -7
  70. package/dist/chunks/chunk-MT25CI4U.js +0 -4
  71. package/dist/chunks/chunk-MT25CI4U.js.map +0 -7
  72. /package/dist/chunks/{GraphTrackSettingsDialog-6KKN5F3W.js.map → GraphTrackSettingsDialog-6STIFKVD.js.map} +0 -0
  73. /package/dist/chunks/{chunk-N7EFSGPU.js.map → chunk-254OZVVL.js.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["global-externals:@jbrowse/render-core/useRenderingBackend", "global-externals:@jbrowse/render-core/renderingBackendBase", "../../src/GraphGenomeView/components/GraphCanvas.tsx", "../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.3._3766ec55733e6b150ee672ad270cc236/node_modules/@mui/icons-material/Info.mjs", "../../src/GraphGenomeView/components/BubbleHalos.tsx", "../../src/GraphGenomeView/components/BubbleOverlay.tsx", "../../src/GraphGenomeView/components/GenePins.tsx", "../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.3._3766ec55733e6b150ee672ad270cc236/node_modules/@mui/icons-material/CropFree.mjs", "../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.3._3766ec55733e6b150ee672ad270cc236/node_modules/@mui/icons-material/ZoomIn.mjs", "../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.3._3766ec55733e6b150ee672ad270cc236/node_modules/@mui/icons-material/ZoomOut.mjs", "../../src/GraphGenomeView/components/GraphToolbar.tsx", "../../src/GraphGenomeView/components/ColorSchemeSelect.tsx", "../../src/GraphGenomeView/components/GraphStats.tsx", "../../src/GraphGenomeView/components/LayoutSelect.tsx", "../../src/GraphGenomeView/components/RepeatSelect.tsx", "../../src/GraphGenomeView/components/SettingsMenu.tsx", "../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.3._3766ec55733e6b150ee672ad270cc236/node_modules/@mui/icons-material/Delete.mjs", "../../node_modules/.pnpm/@mui+icons-material@9.4.0_@mui+material@9.4.0_@emotion+react@11.14.0_@types+react@19.3._3766ec55733e6b150ee672ad270cc236/node_modules/@mui/icons-material/MoreVert.mjs", "../../src/GraphGenomeView/components/WalkSelect.tsx", "../../src/GraphGenomeView/components/LabelLayer.tsx", "../../src/GraphGenomeView/components/LabelChip.tsx", "../../src/GraphGenomeView/components/TubeMapOverlay.tsx", "../../src/GraphGenomeView/components/WalkRowsOverlay.tsx", "../../src/GraphGenomeView/renderer/Canvas2DRenderer.ts", "../../src/GraphGenomeView/renderer/GraphRenderer.ts", "../../src/GraphGenomeView/util/SpatialIndex.ts", "../../src/GraphGenomeView/util/hitDetection.ts", "../../src/GraphGenomeView/util/wheelZoom.ts"],
4
+ "sourcesContent": ["module.exports = JBrowseExports[\"@jbrowse/render-core/useRenderingBackend\"];", "module.exports = JBrowseExports[\"@jbrowse/render-core/renderingBackendBase\"];", "import { useEffect, useRef, useState } from 'react'\n\nimport { ErrorBanner, LoadingOverlay, Menu } from '@jbrowse/core/ui'\nimport { isAlive } from '@jbrowse/mobx-state-tree'\nimport { useRenderingBackend } from '@jbrowse/render-core/useRenderingBackend'\nimport InfoIcon from '@mui/icons-material/Info'\nimport { observer } from 'mobx-react'\n\nimport BubbleHalos from './BubbleHalos'\nimport BubbleOverlay from './BubbleOverlay'\nimport GenePins from './GenePins'\nimport GraphToolbar from './GraphToolbar'\nimport LabelLayer from './LabelLayer'\nimport TubeMapOverlay from './TubeMapOverlay'\nimport WalkRowsOverlay, { WalkRowsLegend } from './WalkRowsOverlay'\nimport { locLabel, nodeOwnLocation } from '../../launchFromGraph/contributors'\nimport { nodeLaunchMenuItems } from '../../launchFromGraph/graphMenuItems'\nimport { formatBp } from '../graphLabels'\nimport { LEGEND_INSET_PX } from '../labelLayout'\nimport { REFERENCE_RAMP_MAX_HUE } from '../renderer/GeometryBuilder'\nimport { createGraphRenderer } from '../renderer/GraphRenderer'\nimport { findHoveredEdge, findHoveredNode } from '../util/hitDetection'\nimport { wheelZoomFactor } from '../util/wheelZoom'\n\nimport type { GraphPaneModel } from '../model'\n\n// Bottom RIGHT, not bottom left: the row labels of a row-structured layout are\n// pinned to the left edge, so a bottom-left tooltip lands on top of them and\n// covers the one thing that says which haplotype a row is. Nothing is drawn\n// against the right edge.\nconst tooltipStyle = {\n position: 'absolute' as const,\n bottom: 8,\n right: 8,\n background: 'rgba(0,0,0,0.75)',\n color: 'white',\n padding: '4px 8px',\n borderRadius: 4,\n fontSize: 12,\n pointerEvents: 'none' as const,\n}\n\nconst wrapperStyle = { position: 'relative' as const }\n\n// The overlay origin has to be the canvas, not the wrapper: the wrapper also\n// holds the toolbar, so anything positioned against it is offset by the\n// toolbar's height, and a row label lands a whole row off the row it names.\nconst canvasAreaStyle = { position: 'relative' as const, lineHeight: 0 }\n\n// Above the labels, pins and legends drawn over the canvas, and with the line\n// height the canvas area zeroes, which would collapse the overlay's label\nconst loadingLayerStyle = {\n position: 'absolute' as const,\n inset: 0,\n zIndex: 10,\n lineHeight: 'normal',\n pointerEvents: 'none' as const,\n}\n\nconst rowLabelStyle = {\n position: 'absolute' as const,\n left: 6,\n transform: 'translateY(-50%)',\n background: 'rgba(255,255,255,0.82)',\n padding: '0 4px',\n borderRadius: 3,\n fontSize: 11,\n // explicit, because the canvas container zeroes line-height to kill the\n // inline-block gap under the canvas. Inherited, that collapses the label to a\n // zero-height box: it still paints, but it has no layout, so anything asking\n // whether it is visible (a screenshot spec's waitForVisible, a11y tooling)\n // is told no.\n lineHeight: '16px',\n whiteSpace: 'nowrap' as const,\n pointerEvents: 'none' as const,\n zIndex: 4,\n}\n\n// Names the rows of a row-structured layout (anchored, sample rows). Without\n// them the layout draws real structure that cannot be read: a stack of bars\n// where every row means something and nothing says what.\n//\n// Positioned from the layout's own `rowLabels` through the same transform the\n// canvas draws with, so a label tracks its row across pan and zoom instead of\n// sitting at a measured pixel. It therefore has to be mounted in the canvas's\n// own positioning context (canvasAreaStyle) \u2014 against the wrapper it picks up\n// the toolbar's height and names the wrong row. Pinned to the left edge rather\n// than to the row's own x, because a row's leftmost node is wherever its first\n// allele happens to branch. Rows scrolled out of the canvas are dropped rather\n// than clamped to the edge, so a label never points at a row that is not\n// there.\nconst RowLabels = observer(function RowLabels({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const rowLabels = model.drawnRowLabels\n return (\n <>\n {rowLabels.map(({ label, y }) => {\n const screenY = y * model.scaleY + model.translateY\n return screenY >= 0 && screenY <= model.canvasHeight ? (\n // Keyed on the row, not on the label: two rows can carry the same\n // words. The sample-row layout names row 0 for the assembly the\n // backbone comes from and the rows below it for the samples\n // contributing alleles, and a diploid reference is in both lists \u2014\n // one haplotype is the reference path, the other walks alleles of its\n // own, and `parsePanSN` reduces both to one sample name.\n <div\n key={y}\n data-testid=\"graph-row-label\"\n style={{ ...rowLabelStyle, top: screenY }}\n >\n {label}\n </div>\n ) : null\n })}\n </>\n )\n})\n\n// Top RIGHT: the row labels own the left edge and the hover tooltip owns the\n// bottom right, so this is the one corner nothing else claims. A row-structured\n// layout draws its band across the middle, which is what the keys are for. The\n// two keys stack rather than each claiming the corner, since a path-coloured\n// graph can also be reference-position coloured.\nconst legendStackStyle = {\n position: 'absolute' as const,\n top: LEGEND_INSET_PX,\n right: LEGEND_INSET_PX,\n display: 'flex',\n flexDirection: 'column' as const,\n alignItems: 'flex-end',\n gap: 4,\n pointerEvents: 'none' as const,\n zIndex: 4,\n}\n\nconst legendBoxStyle = {\n background: 'rgba(255,255,255,0.82)',\n padding: '4px 6px',\n borderRadius: 3,\n fontSize: 11,\n lineHeight: '15px',\n whiteSpace: 'nowrap' as const,\n}\n\nconst pathLegendRowStyle = { display: 'flex', alignItems: 'center', gap: 5 }\n\nconst pathSwatchStyle = { width: 18, height: 3, borderRadius: 2 }\n\n// Which haplotype each ribbon colour is. The ribbons are one stroke per path\n// fanned across every edge the path crosses, so without this the drawing states\n// that the alleles are taken by *different* samples and never which.\nconst PathLegend = observer(function PathLegend({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { pathLegend } = model\n return pathLegend.length > 0 ? (\n <div style={legendBoxStyle} data-testid=\"graph-path-legend\">\n {pathLegend.map(({ name, label, color }) => (\n <div key={name} style={pathLegendRowStyle}>\n <div style={{ ...pathSwatchStyle, backgroundColor: color }} />\n <span>{label}</span>\n </div>\n ))}\n </div>\n ) : null\n})\n\n// What the lifted walk carries through the window, against the reference walk\n// where the graph has one: the number the array's loops are drawn for.\nconst WalkReadout = observer(function WalkReadout({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const h = model.walkHighlight\n if (!h) {\n return null\n }\n const label = model.walkChoices.find(c => c.name === h.name)?.label ?? h.name\n const delta =\n h.referenceBp === undefined\n ? ''\n : h.bp === h.referenceBp\n ? ', the reference length'\n : `, ${h.bp > h.referenceBp ? '+' : '\u2212'}${Math.abs(h.bp - h.referenceBp).toLocaleString()} bp against the reference`\n return (\n <div style={legendBoxStyle} data-testid=\"graph-walk-readout\">\n <strong>{label}</strong>: {h.steps.toLocaleString()} steps,{' '}\n {h.bp.toLocaleString()} bp{delta}\n </div>\n )\n})\n\n// The reference-position ramp, as a strip labelled with the interval it runs\n// over. Nothing on screen used to say that red-to-magenta means left-to-right of\n// the cut window, so two tutorials carried that sentence in prose and a reader\n// arriving at a figure had no way to know it at all.\n//\n// The gradient is built from the same three numbers `getNodeColor` paints with\n// (hue 0 to REFERENCE_RAMP_MAX_HUE at 70%/50%), rather than from a picked pair\n// of hex stops, so it cannot come to describe a ramp the drawing stopped using.\nconst rampStripStyle = {\n minWidth: 90,\n height: 8,\n borderRadius: 2,\n background: `linear-gradient(to right, ${Array.from(\n { length: 7 },\n (_, i) =>\n `hsl(${(i / 6) * REFERENCE_RAMP_MAX_HUE}, 70%, 50%) ${(i / 6) * 100}%`,\n ).join(', ')})`,\n}\n\nconst rampEndsStyle = {\n display: 'flex',\n justifyContent: 'space-between',\n gap: 8,\n}\n\nconst ReferenceRampLegend = observer(function ReferenceRampLegend({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const domain = model.referenceRampDomain\n return domain ? (\n <div style={legendBoxStyle} data-testid=\"graph-ramp-legend\">\n <div style={rampStripStyle} />\n <div style={rampEndsStyle}>\n <span>{domain.start.toLocaleString()}</span>\n <span>({formatBp(domain.end - domain.start)})</span>\n <span>{domain.end.toLocaleString()}</span>\n </div>\n </div>\n ) : null\n})\n\nconst nodeLabelStyle = {\n position: 'absolute' as const,\n transform: 'translate(-50%, -50%)',\n background: 'rgba(255,255,255,0.78)',\n padding: '0 3px',\n borderRadius: 3,\n fontSize: 10,\n lineHeight: '13px',\n whiteSpace: 'nowrap' as const,\n pointerEvents: 'none' as const,\n zIndex: 3,\n}\n\n// Matches EDGE_DELETION_COLOR, so the words and the arc they name are one thing.\nconst deletionLabelStyle = {\n ...nodeLabelStyle,\n color: '#18181c',\n fontWeight: 600,\n}\n\n// Under the labels (z 3) and over the canvas, so a leader runs beneath the text\n// it points from rather than across it. `overflow: visible` because a label\n// displaced past the canvas edge is culled by the placement, not clipped here.\nconst leaderStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow: 'visible' as const,\n zIndex: 2,\n}\n\n// Measures itself for the model, so no label is placed under a legend and\n// none gives way to one that is not drawn.\nconst Legends = observer(function Legends({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const ref = useRef<HTMLDivElement>(null)\n useEffect(() => {\n const el = ref.current\n if (!el) {\n return\n }\n // the last callback can land after the track is closed\n const observer = new ResizeObserver(() => {\n if (isAlive(model)) {\n model.setLegendSize({ width: el.offsetWidth, height: el.offsetHeight })\n }\n })\n observer.observe(el)\n return () => {\n observer.disconnect()\n }\n }, [model])\n return (\n <div ref={ref} style={legendStackStyle}>\n <ReferenceRampLegend model={model} />\n <PathLegend model={model} />\n <WalkRowsLegend model={model} />\n <WalkReadout model={model} />\n </div>\n )\n})\n\n// Writes each drawn thing's size onto it, which is what Bandage's Length label\n// does and what the tooltip alone could not: a graph you have to hover to read\n// is a graph nobody reads. graphLabels applies the same transform the canvas\n// draws with \u2014 so a label tracks its node across pan and zoom \u2014 and decides\n// which labels fit; this only paints them, mounted in the canvas's own\n// positioning context for the reason RowLabels is.\nconst GraphSizeLabels = observer(function GraphSizeLabels({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const labels = model.overlayLabels.sizes\n // A label too wide for the arc it names is placed clear of it and tethered\n // back; nothing else in the drawing carries one.\n const leaders = labels.flatMap(({ key, leader }) =>\n leader ? [{ key, ...leader }] : [],\n )\n return (\n <>\n {leaders.length > 0 ? (\n <svg\n style={leaderStyle}\n width={model.paneWidth}\n height={model.canvasHeight}\n >\n {leaders.map(({ key, arcX, arcY, labelX, labelY }) => (\n <line\n key={key}\n data-testid=\"graph-label-leader\"\n x1={arcX}\n y1={arcY}\n x2={labelX}\n y2={labelY}\n stroke=\"#18181c\"\n strokeWidth={1}\n />\n ))}\n </svg>\n ) : null}\n {labels.map(({ key, text, x, y, kind }) => (\n <div\n key={key}\n data-testid=\"graph-size-label\"\n style={{\n ...(kind === 'deletion' ? deletionLabelStyle : nodeLabelStyle),\n left: x,\n top: y,\n }}\n >\n {text}\n </div>\n ))}\n </>\n )\n})\n\nconst HoverTooltips = observer(function HoverTooltips({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const hoveredNodeData = model.hoveredNode\n ? model.nodeById?.get(model.hoveredNode)\n : null\n\n const hoveredEdgeData =\n model.hoveredEdge !== null && model.graph\n ? model.graph.edges[model.hoveredEdge]\n : null\n\n const ownLocation = hoveredNodeData\n ? nodeOwnLocation(hoveredNodeData)\n : undefined\n\n const hoveredDeletion =\n model.hoveredEdge === null\n ? undefined\n : model.deletions.find(d => d.edgeIndex === model.hoveredEdge)\n\n return (\n <>\n {hoveredNodeData ? (\n <div style={tooltipStyle}>\n <strong>{hoveredNodeData.name}</strong> \u2014 length:{' '}\n {hoveredNodeData.length.toLocaleString()}, depth:{' '}\n {hoveredNodeData.depth.toFixed(1)}\n {/* Which assembly contributed this segment, and where it sits on it.\n rGFA states both, and until now neither reached the screen: the\n node was a bare id in a picture. */}\n {ownLocation ? (\n <>\n <br />\n {ownLocation.sample} {locLabel(ownLocation)} (rank{' '}\n {hoveredNodeData.stable?.rank})\n </>\n ) : null}\n </div>\n ) : null}\n {hoveredEdgeData ? (\n <div style={tooltipStyle}>\n {/* A deletion edge is the one link that means something on its own \u2014\n the backbone it skips is sequence some haplotype does not carry \u2014\n so it says how much rather than just naming its endpoints. */}\n {hoveredDeletion ? (\n <>\n <strong>Deletion</strong> {hoveredDeletion.bp.toLocaleString()} bp\n <br />\n {hoveredDeletion.refName}:{hoveredDeletion.start.toLocaleString()}\n -{hoveredDeletion.end.toLocaleString()}\n </>\n ) : (\n <>\n Edge: {hoveredEdgeData.from} \u2192 {hoveredEdgeData.to}\n </>\n )}\n </div>\n ) : null}\n </>\n )\n})\n\n// Flat rather than under a \"Launch view\" submenu: this menu is two or three\n// items long and every one of them is contextual to the node just clicked. The\n// submenu grouping earns its keep in the long view and track menus.\nconst NodeContextMenu = observer(function NodeContextMenu({\n model,\n nodeId,\n top,\n left,\n onClose,\n}: {\n model: GraphPaneModel\n nodeId: string\n top: number\n left: number\n onClose: () => void\n}) {\n const { own, reference, highlight } = model.nodeLaunchTargets(nodeId)\n return (\n <Menu\n open\n anchorReference=\"anchorPosition\"\n anchorPosition={{ top, left }}\n onClose={() => {\n onClose()\n }}\n onMenuItemClick={callback => {\n callback()\n }}\n menuItems={[\n {\n label: 'Node details',\n icon: InfoIcon,\n onClick: () => {\n model.showNodeDetails(nodeId)\n },\n },\n ...nodeLaunchMenuItems({\n own,\n reference,\n highlight,\n onShowLinear: target => {\n model.showInLinearView(target)\n },\n onHighlight: model.canHighlightInLinearView\n ? target => {\n model.highlightInLinearView(target)\n }\n : undefined,\n }),\n ]}\n />\n )\n})\n\n// `ownChrome` false for a pane inside a track, whose controls, loading state\n// and errors are the track's. A hosted pane whose x the host places takes no pan or wheel of its\n// own: those are the linear view's, as on any other track. One drawing its\n// own coordinates inside a track keeps them, and keeps them from the view.\nconst GraphCanvas = observer(function GraphCanvas({\n model,\n ownChrome = true,\n}: {\n model: GraphPaneModel\n ownChrome?: boolean\n}) {\n const {\n canvasRef,\n canvas,\n error: renderError,\n retry: retryRender,\n } = useRenderingBackend(createGraphRenderer, model)\n // Where the pointer was last, and whether it has travelled since mousedown \u2014\n // per-gesture scratch that nothing renders from, which is what a ref is for.\n // Whether a drag is in progress is model state (`isPanning`/`draggingNode`),\n // because the cursor renders from it.\n const lastMouseRef = useRef({ x: 0, y: 0 })\n const hasMovedRef = useRef(false)\n // A pan and a hover are applied once per frame, not once per mousemove:\n // mousemove fires in bursts well above the frame rate, and each pan step\n // repainted the canvas and re-placed every overlay label, while each hover\n // step ran both hit indexes. The pending pan is the summed delta; the pending\n // hover is the last pointer position, since only the last one can be right.\n const pendingRef = useRef<{\n frame: number\n pan: { dx: number; dy: number } | null\n hover: { x: number; y: number } | null\n }>({ frame: 0, pan: null, hover: null })\n useEffect(\n () => () => {\n cancelAnimationFrame(pendingRef.current.frame)\n },\n [],\n )\n const [contextNode, setContextNode] = useState<\n { nodeId: string; top: number; left: number } | undefined\n >(undefined)\n\n // wheel events need passive:false to call preventDefault \u2014 React registers\n // wheel listeners as passive, so we must add this imperatively\n useEffect(() => {\n if (canvas) {\n const c = canvas\n function handleWheel(e: WheelEvent) {\n if (model.hostPlacesX) {\n return\n }\n if (model.host) {\n e.stopPropagation()\n }\n e.preventDefault()\n const rect = c.getBoundingClientRect()\n model.zoom(\n wheelZoomFactor(e),\n e.clientX - rect.left,\n e.clientY - rect.top,\n )\n }\n c.addEventListener('wheel', handleWheel, { passive: false })\n return () => {\n c.removeEventListener('wheel', handleWheel)\n }\n }\n return undefined\n }, [canvas, model])\n\n function screenToGraph(screenX: number, screenY: number) {\n return {\n x: (screenX - model.translateX) / model.scaleX,\n y: (screenY - model.translateY) / model.scaleY,\n }\n }\n\n function getMouseCoord(e: React.MouseEvent) {\n const rect = (e.currentTarget as HTMLCanvasElement).getBoundingClientRect()\n return screenToGraph(e.clientX - rect.left, e.clientY - rect.top)\n }\n\n // The node at a graph coordinate, which mousedown, mousemove and click all\n // need. Takes the coordinate rather than the event so a caller that already\n // has one does not pay for a second getBoundingClientRect.\n function nodeAt(x: number, y: number) {\n const { nodePositions } = model\n if (model.layoutResult?.tubeMap) {\n return model.tubeMapNodeAt(\n x * model.scaleX + model.translateX,\n y * model.scaleY + model.translateY,\n )\n }\n return nodePositions\n ? findHoveredNode(\n nodePositions,\n x,\n y,\n model.axisScale,\n model.positionsVersion,\n model.nodeInk,\n )\n : null\n }\n\n function handleMouseDown(e: React.MouseEvent) {\n if (e.button === 0) {\n hasMovedRef.current = false\n if (model.hostPlacesX) {\n return\n }\n if (model.host) {\n e.stopPropagation()\n }\n const { x, y } = getMouseCoord(e)\n // a tube map's boxes are the layout's, not positions to drag\n const node = model.layoutResult?.tubeMap ? null : nodeAt(x, y)\n if (node) {\n model.setDraggingNode(node)\n } else {\n model.setPanning(true)\n }\n lastMouseRef.current = { x: e.clientX, y: e.clientY }\n }\n }\n\n function applyPending() {\n const pending = pendingRef.current\n pending.frame = 0\n if (pending.pan) {\n model.setTransform(\n model.scale,\n model.translateX + pending.pan.dx,\n model.translateY + pending.pan.dy,\n )\n pending.pan = null\n }\n if (pending.hover && model.nodePositions && model.graph) {\n const { x, y } = screenToGraph(pending.hover.x, pending.hover.y)\n pending.hover = null\n const node = nodeAt(x, y)\n model.setHoveredNode(node)\n model.setHoveredEdge(\n node || model.layoutResult?.tubeMap\n ? null\n : findHoveredEdge(\n model.nodePositions,\n model.graph,\n x,\n y,\n model.axisScale,\n // resolved, so the hit index bounds the ribbons that are\n // actually drawn \u2014 see effectiveDrawPaths\n model.effectiveDrawPaths,\n model.positionsVersion,\n model.deletionEdgeIndexes,\n model.hiddenEdgeIndexes,\n ),\n )\n }\n }\n\n function scheduleFrame() {\n if (!pendingRef.current.frame) {\n pendingRef.current.frame = requestAnimationFrame(applyPending)\n }\n }\n\n function dropPending() {\n const pending = pendingRef.current\n cancelAnimationFrame(pending.frame)\n pending.frame = 0\n pending.pan = null\n pending.hover = null\n }\n\n function handleMouseMove(e: React.MouseEvent) {\n const dx = e.clientX - lastMouseRef.current.x\n const dy = e.clientY - lastMouseRef.current.y\n lastMouseRef.current = { x: e.clientX, y: e.clientY }\n\n if (Math.abs(dx) > 1 || Math.abs(dy) > 1) {\n hasMovedRef.current = true\n }\n\n const pending = pendingRef.current\n if (model.draggingNode) {\n model.moveNode(model.draggingNode, dx / model.scaleX, dy / model.scaleY)\n } else if (model.isPanning) {\n pending.pan = {\n dx: (pending.pan?.dx ?? 0) + dx,\n dy: (pending.pan?.dy ?? 0) + dy,\n }\n scheduleFrame()\n } else {\n const rect = (\n e.currentTarget as HTMLCanvasElement\n ).getBoundingClientRect()\n pending.hover = { x: e.clientX - rect.left, y: e.clientY - rect.top }\n scheduleFrame()\n }\n }\n\n function handleMouseUp() {\n model.stopDragging()\n }\n\n function handleMouseLeave() {\n dropPending()\n model.stopDragging()\n model.setHoveredNode(null)\n model.setHoveredEdge(null)\n }\n\n // Right-clicking a node is the gesture that asks \"where is this?\", and until\n // now the graph had no answer: a node named an assembly and an offset in its\n // tags that nothing surfaced. The items come from the model's launch targets,\n // so what is offered is what can actually be opened.\n function handleContextMenu(e: React.MouseEvent) {\n const { x, y } = getMouseCoord(e)\n const node = nodeAt(x, y)\n if (node) {\n e.preventDefault()\n setContextNode({ nodeId: node, top: e.clientY, left: e.clientX })\n }\n }\n\n function handleClick(e: React.MouseEvent) {\n // a click that ended a drag selects nothing\n if (!hasMovedRef.current) {\n const { x, y } = getMouseCoord(e)\n const node = nodeAt(x, y)\n model.setSelectedNode(node)\n if (node) {\n model.showNodeDetails(node)\n }\n }\n }\n\n return (\n <div style={wrapperStyle}>\n {ownChrome ? <GraphToolbar model={model} /> : null}\n\n <div style={canvasAreaStyle}>\n <canvas\n ref={canvasRef}\n data-testid=\"graph-genome-canvas\"\n style={{\n width: model.paneWidth,\n height: model.canvasHeight,\n cursor: model.isPanning || model.draggingNode ? 'grabbing' : 'grab',\n display: 'block',\n }}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseLeave}\n onClick={handleClick}\n onContextMenu={handleContextMenu}\n />\n\n <TubeMapOverlay model={model} />\n <RowLabels model={model} />\n <GraphSizeLabels model={model} />\n <BubbleHalos model={model} />\n <GenePins model={model} />\n <LabelLayer model={model} />\n <BubbleOverlay model={model} />\n <WalkRowsOverlay model={model} />\n <Legends model={model} />\n\n {ownChrome ? (\n <div style={loadingLayerStyle}>\n <LoadingOverlay\n isVisible={model.isLoading}\n immediate={!model.layoutResult}\n statusMessage={model.statusMessage}\n onCancel={\n model.canCancelLoad\n ? () => {\n model.cancelLoad()\n }\n : undefined\n }\n />\n </div>\n ) : null}\n </div>\n\n <HoverTooltips model={model} />\n\n {contextNode ? (\n <NodeContextMenu\n model={model}\n nodeId={contextNode.nodeId}\n top={contextNode.top}\n left={contextNode.left}\n onClose={() => {\n setContextNode(undefined)\n }}\n />\n ) : null}\n\n {renderError ? (\n <ErrorBanner error={renderError} onReset={retryRender} />\n ) : null}\n\n {ownChrome && model.error ? (\n <ErrorBanner\n error={model.error}\n onReset={\n model.canRetryLoad\n ? () => {\n model.retryLoad()\n }\n : undefined\n }\n />\n ) : null}\n </div>\n )\n})\n\nexport default GraphCanvas\n", "\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon(/*#__PURE__*/_jsx(\"path\", {\n d: \"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z\"\n}), 'Info');", "import { observer } from 'mobx-react'\n\nimport { BUBBLE_KIND_COLORS } from '../bubbles/classifyBubble'\nimport { HALO_FACTOR } from '../labelLayout'\n\nimport type { BubbleHalo } from '../bubbles/bubbleHalos'\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.\n\nconst svgStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow: 'hidden' as const,\n zIndex: 2,\n}\n\nconst BubbleHalos = observer(function BubbleHalos({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbleHalos, walkHighlight } = model\n if (bubbleHalos.length === 0) {\n return null\n }\n const {\n scaleX,\n scaleY,\n translateX,\n translateY,\n paneWidth: width,\n canvasHeight,\n } = model\n const halo = model.contigThickness * HALO_FACTOR\n // a lifted walk dims the bubbles it never enters\n const dimmedBubble = (h: BubbleHalo) =>\n walkHighlight !== undefined &&\n !h.nodeIds.some(id => walkHighlight.nodeIds.has(id))\n\n return (\n <svg\n style={svgStyle}\n width={width}\n height={canvasHeight}\n data-testid=\"graph-bubble-halos\"\n >\n <g\n transform={`translate(${translateX} ${translateY}) scale(${scaleX} ${scaleY})`}\n >\n {bubbleHalos\n .filter(h => !h.whole)\n .map(h => (\n <path\n key={`${h.bubble.start}-${h.bubble.end}`}\n d={h.path}\n fill=\"none\"\n stroke={BUBBLE_KIND_COLORS[h.kind]}\n strokeOpacity={dimmedBubble(h) ? 0.06 : 0.22}\n strokeWidth={halo}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ))}\n </g>\n </svg>\n )\n})\n\nexport default BubbleHalos\n", "import { Button } from '@mui/material'\nimport { observer } from 'mobx-react'\n\nimport { BUBBLE_KIND_COLORS } from '../bubbles/classifyBubble'\nimport { LABEL_PAD } from '../overlayLabels'\n\nimport type { GraphPaneModel } from '../model'\n\n// The variant map's glyphs: one lens per bubble on the reference line the\n// canvas draws, sized by the longest route through it, coloured and labelled\n// by what kind of variation it is. SVG over the canvas rather than geometry in\n// it, because a glyph is text plus a shape that reads at one screen size\n// whatever the zoom, which is what the row labels are too.\n//\n// Height is in screen px and adapts to the room above the line, so a pane of\n// any height shows every glyph; a bubble shorter than the reference it\n// replaces also gets a dashed chord under the line, the deletion's side.\n\nconst svgStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow: 'visible' as const,\n zIndex: 3,\n}\n\nconst backButtonStyle = {\n position: 'absolute' as const,\n left: 8,\n top: 8,\n zIndex: 5,\n background: 'rgba(255,255,255,0.9)',\n textTransform: 'none' as const,\n}\n\nconst MIN_GLYPH_PX = 10\n\nfunction glyphHeight(bp: number, room: number) {\n const raw = 12 + 26 * Math.log10(1 + bp)\n return Math.min(raw, room)\n}\n\nconst BubbleOverlay = observer(function BubbleOverlay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbleGlyphs, poppedFrom } = model\n const back = poppedFrom ? (\n <Button\n size=\"small\"\n variant=\"outlined\"\n style={backButtonStyle}\n data-testid=\"graph-unpop-bubble\"\n onClick={() => {\n void model.unpopBubble()\n }}\n >\n \u25C0 Back to {poppedFrom.label}\n </Button>\n ) : null\n if (bubbleGlyphs.length === 0) {\n return back\n }\n const {\n scaleX,\n translateX,\n translateY,\n paneWidth: width,\n canvasHeight,\n } = model\n const lineY = translateY\n const X = (bp: number) => bp * scaleX + translateX\n const labels = model.overlayLabels.glyphs\n // glyphs take whatever the names leave above the line\n const labelsBottom = Math.max(0, ...labels.map(l => l.y + LABEL_PAD))\n const room = Math.max(24, lineY - labelsBottom - 14)\n const glyphs = [...bubbleGlyphs].sort(\n (a, b) => b.bubble.end - b.bubble.start - (a.bubble.end - a.bubble.start),\n )\n\n return (\n <>\n {back}\n <svg\n style={svgStyle}\n width={width}\n height={canvasHeight}\n data-testid=\"graph-bubble-overlay\"\n >\n {glyphs.map(({ bubble, kind, label }) => {\n const x0 = X(bubble.start)\n const x1 = X(bubble.end)\n const w = Math.max(x1 - x0, MIN_GLYPH_PX)\n const cx = (x0 + x1) / 2\n const h = glyphHeight(bubble.longestAlleleLength, room)\n const color = BUBBLE_KIND_COLORS[kind]\n const refSpan = bubble.end - bubble.start\n const skipped = refSpan - bubble.shortestAlleleLength\n const dip = skipped > 0 ? 6 + 10 * Math.log10(1 + skipped) : 0\n const key = `${bubble.start}-${bubble.end}`\n return (\n <g key={key}>\n <path\n d={`M${cx - w / 2},${lineY} C${cx - w / 2},${lineY - h} ${cx + w / 2},${lineY - h} ${cx + w / 2},${lineY} Z`}\n fill={color}\n fillOpacity={0.18}\n stroke={color}\n strokeWidth={2}\n style={{ pointerEvents: 'auto', cursor: 'pointer' }}\n onClick={() => {\n void model.popBubble(bubble)\n }}\n >\n <title>{`${label}\\n${bubble.segmentCount} segments \u00B7 click to open`}</title>\n </path>\n {dip > 0 ? (\n <path\n d={`M${cx - w / 2},${lineY} C${cx - w / 2},${lineY + dip} ${cx + w / 2},${lineY + dip} ${cx + w / 2},${lineY}`}\n fill=\"none\"\n stroke={color}\n strokeWidth={2}\n strokeDasharray=\"4 3\"\n />\n ) : null}\n </g>\n )\n })}\n {labels.map(({ item: { glyph: g, glyphX }, x, y }) => {\n const color = BUBBLE_KIND_COLORS[g.kind]\n const top = lineY - glyphHeight(g.bubble.longestAlleleLength, room)\n return (\n <g key={`${g.bubble.start}-${g.bubble.end}-label`}>\n <line\n x1={glyphX}\n x2={glyphX}\n y1={y + 4}\n y2={top - 2}\n stroke={color}\n strokeWidth={0.7}\n strokeOpacity={0.5}\n />\n <text\n x={x}\n y={y}\n fontSize={11}\n fontFamily=\"sans-serif\"\n fill={color}\n textAnchor=\"middle\"\n >\n {g.label}\n </text>\n </g>\n )\n })}\n </svg>\n </>\n )\n})\n\nexport default BubbleOverlay\n", "import { observer } from 'mobx-react'\n\nimport type { GraphPaneModel } from '../model'\n\n// The session's genes drawn onto the graph: exons as dark stretches along the\n// backbone nodes that carry them, in layout units, moved by the same transform\n// the halos use. Their names are LabelLayer's.\n\nconst svgStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow: 'hidden' as const,\n zIndex: 2,\n}\n\nexport const EXON_COLOR = '#1c1c22'\n\nconst GenePins = observer(function GenePins({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { genePins } = model\n if (genePins.length === 0) {\n return null\n }\n const {\n scaleX,\n scaleY,\n translateX,\n translateY,\n paneWidth: width,\n canvasHeight,\n contigThickness,\n } = model\n return (\n <svg\n style={svgStyle}\n width={width}\n height={canvasHeight}\n data-testid=\"graph-gene-pins\"\n >\n <g\n transform={`translate(${translateX} ${translateY}) scale(${scaleX} ${scaleY})`}\n >\n {genePins.map(pin =>\n pin.exons ? (\n <path\n key={`${pin.gene.name}-${pin.gene.start}`}\n d={pin.exons}\n fill=\"none\"\n stroke={EXON_COLOR}\n strokeOpacity={0.9}\n strokeWidth={contigThickness * 0.55}\n strokeLinecap=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ) : null,\n )}\n </g>\n </svg>\n )\n})\n\nexport default GenePins\n", "\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon(/*#__PURE__*/_jsx(\"path\", {\n d: \"M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2m2 10H3v4c0 1.1.9 2 2 2h4v-2H5zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2\"\n}), 'CropFree');", "\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon([/*#__PURE__*/_jsx(\"path\", {\n d: \"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14\"\n}, \"0\"), /*#__PURE__*/_jsx(\"path\", {\n d: \"M12 10h-2v2H9v-2H7V9h2V7h1v2h2z\"\n}, \"1\")], 'ZoomIn');", "\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon(/*#__PURE__*/_jsx(\"path\", {\n d: \"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14M7 9h5v1H7z\"\n}), 'ZoomOut');", "import CropFreeIcon from '@mui/icons-material/CropFree'\nimport ZoomInIcon from '@mui/icons-material/ZoomIn'\nimport ZoomOutIcon from '@mui/icons-material/ZoomOut'\nimport { IconButton, Tooltip, Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport ColorSchemeSelect from './ColorSchemeSelect'\nimport GraphStats from './GraphStats'\nimport LayoutSelect from './LayoutSelect'\nimport RepeatSelect from './RepeatSelect'\nimport SettingsMenu from './SettingsMenu'\nimport WalkSelect from './WalkSelect'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n toolbar: {\n display: 'flex',\n alignItems: 'center',\n gap: 4,\n padding: '2px 4px',\n borderBottom: '1px solid #ddd',\n },\n})\n\nconst ZoomDisplay = observer(function ZoomDisplay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n return <Typography variant=\"body2\">{model.zoomPercent}</Typography>\n})\n\nconst GraphToolbar = observer(function GraphToolbar({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.toolbar}>\n <LayoutSelect model={model} />\n <ColorSchemeSelect model={model} />\n <WalkSelect model={model} />\n <RepeatSelect model={model} />\n <Tooltip title=\"Zoom in\">\n <IconButton\n size=\"small\"\n onClick={() => {\n model.zoom(1.5, model.paneWidth / 2, model.canvasHeight / 2)\n }}\n >\n <ZoomInIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title=\"Zoom out\">\n <IconButton\n size=\"small\"\n onClick={() => {\n model.zoom(1 / 1.5, model.paneWidth / 2, model.canvasHeight / 2)\n }}\n >\n <ZoomOutIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title=\"Zoom to fit\">\n <IconButton\n size=\"small\"\n onClick={() => {\n model.zoomToFit()\n }}\n >\n <CropFreeIcon />\n </IconButton>\n </Tooltip>\n <ZoomDisplay model={model} />\n <GraphStats model={model} />\n <SettingsMenu model={model} />\n </div>\n )\n})\n\nexport default GraphToolbar\n", "import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport { COLOR_SCHEMES } from '../colorSchemes'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n formControl: {\n minWidth: 100,\n },\n})\n\nconst ColorSchemeSelect = observer(function ColorSchemeSelect({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n return (\n <FormControl size=\"small\" className={classes.formControl}>\n <InputLabel>Color</InputLabel>\n <Select\n value={model.chosenColorScheme}\n label=\"Color\"\n onChange={e => {\n model.setColorScheme(e.target.value)\n }}\n >\n {COLOR_SCHEMES.map(({ value, label }) => (\n <MenuItem key={value} value={value}>\n {label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n})\n\nexport default ColorSchemeSelect\n", "import { Typography } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n stats: {\n marginLeft: 'auto',\n },\n perf: {\n color: '#888',\n fontVariantNumeric: 'tabular-nums',\n },\n})\n\nfunction fmtMs(ms: number | undefined) {\n return ms === undefined ? '\u2013' : `${Math.round(ms)}ms`\n}\n\n// The perf READOUT, off by default: it sat in the toolbar of every published\n// graph figure, where one machine's fetch time is a number a reader has to work\n// out is not about them. `showPerf` is in the settings menu.\n//\n// The numbers themselves are not conditional \u2014 they ride the stats element's\n// data-* attributes either way (see GraphStats), so a browser test asserting a\n// timing budget never depends on a display setting, and turning the text off\n// costs no coverage. They live there rather than on this element so that\n// switching the text off leaves no empty node behind to carry them.\nconst GraphPerf = observer(function GraphPerf({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n const { lastFetchMs, lastLayoutMs, lastGeometryMs } = model\n const hasMetrics =\n lastFetchMs !== undefined ||\n lastLayoutMs !== undefined ||\n lastGeometryMs !== undefined\n return model.showPerf && hasMetrics ? (\n <Typography\n variant=\"caption\"\n className={classes.perf}\n data-testid=\"graph-perf-stats\"\n >\n fetch {fmtMs(lastFetchMs)} \u00B7 layout {fmtMs(lastLayoutMs)} \u00B7 geom{' '}\n {fmtMs(lastGeometryMs)}\n </Typography>\n ) : null\n})\n\nconst GraphStats = observer(function GraphStats({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n return (\n <div\n className={classes.stats}\n data-testid=\"graph-stats\"\n data-node-count={model.nodeCount}\n data-edge-count={model.edgeCount}\n data-path-count={model.pathCount}\n // unconditional, whatever `showPerf` is doing to the text beside them \u2014\n // see GraphPerf\n data-fetch-ms={model.lastFetchMs ?? ''}\n data-layout-ms={model.lastLayoutMs ?? ''}\n data-geometry-ms={model.lastGeometryMs ?? ''}\n data-geometry-strokes={model.lastGeometryStrokeCount ?? ''}\n >\n <Typography variant=\"body2\" component=\"span\">\n {model.nodeCount} nodes, {model.edgeCount} edges\n {model.pathCount > 0 ? `, ${model.pathCount} paths` : ''}\n </Typography>{' '}\n <GraphPerf model={model} />\n </div>\n )\n})\n\nexport default GraphStats\n", "import {\n FormControl,\n InputLabel,\n MenuItem,\n Select,\n Tooltip,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport { LAYOUT_MODES } from '../layoutModes'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n formControl: {\n minWidth: 150,\n },\n})\n\nconst LayoutSelect = observer(function LayoutSelect({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n const { graph } = model\n return (\n <FormControl size=\"small\" className={classes.formControl}>\n <InputLabel>Layout</InputLabel>\n <Select\n value={model.chosenLayoutMode}\n label=\"Layout\"\n data-testid=\"graph-layout-select\"\n onChange={e => {\n void model.switchLayout(e.target.value)\n }}\n >\n {LAYOUT_MODES.map(({ value, label, description, available }) => (\n <MenuItem\n key={value}\n value={value}\n disabled={graph ? !available(graph) : false}\n >\n <Tooltip title={description} placement=\"right\">\n <span>{label}</span>\n </Tooltip>\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n})\n\nexport default LayoutSelect\n", "import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n formControl: {\n minWidth: 130,\n maxWidth: 240,\n },\n})\n\n// Which tandem repeat array the walk rows measure between and tile by, from\n// the session's repeat annotation over the window. Only the walk rows read it.\nconst RepeatSelect = observer(function RepeatSelect({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n const { repeatChoices } = model\n if (model.chosenLayoutMode !== 'walkrows' || repeatChoices.length === 0) {\n return null\n }\n const keys = new Set(repeatChoices.map(r => r.key))\n return (\n <FormControl size=\"small\" className={classes.formControl}>\n <InputLabel>Repeat</InputLabel>\n <Select\n value={keys.has(model.repeatKey) ? model.repeatKey : ''}\n label=\"Repeat\"\n data-testid=\"graph-repeat-select\"\n onChange={e => {\n model.setRepeatKey(e.target.value)\n }}\n >\n <MenuItem value=\"\">\n <em>Whole window</em>\n </MenuItem>\n {repeatChoices.map(({ key, name, unit }) => (\n <MenuItem key={key} value={key}>\n {name} \u00B7 {unit.toLocaleString()} bp unit\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n})\n\nexport default RepeatSelect\n", "import { useState } from 'react'\n\nimport { CascadingMenuButton } from '@jbrowse/core/ui'\nimport DeleteIcon from '@mui/icons-material/Delete'\nimport MoreVertIcon from '@mui/icons-material/MoreVert'\nimport SettingsIcon from '@mui/icons-material/Settings'\nimport { observer } from 'mobx-react'\n\nimport GraphSettingsDialog from './GraphSettingsDialog'\n\nimport type { GraphPaneModel } from '../model'\n\nconst SettingsMenu = observer(function SettingsMenu({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const [settingsOpen, setSettingsOpen] = useState(false)\n\n return (\n <>\n <CascadingMenuButton\n size=\"small\"\n menuItems={[\n {\n type: 'checkbox' as const,\n label: 'Linear layout',\n checked: model.linearLayout,\n onClick: () => {\n model.setLinearLayout(!model.linearLayout)\n void model.recomputeLayout()\n },\n },\n {\n type: 'checkbox' as const,\n label: 'Show deletion edges',\n checked: model.showDeletionEdges,\n onClick: () => {\n model.setShowDeletionEdges(!model.showDeletionEdges)\n },\n },\n {\n type: 'checkbox' as const,\n label: 'Show timings',\n checked: model.showPerf,\n onClick: () => {\n model.setShowPerf(!model.showPerf)\n },\n },\n { type: 'divider' as const },\n {\n label: 'Settings',\n icon: SettingsIcon,\n onClick: () => {\n setSettingsOpen(true)\n },\n },\n { type: 'divider' as const },\n {\n label: 'Return to import form',\n icon: DeleteIcon,\n onClick: () => {\n model.clearGraph()\n },\n },\n ]}\n >\n <MoreVertIcon />\n </CascadingMenuButton>\n\n <GraphSettingsDialog\n model={model}\n open={settingsOpen}\n onClose={() => {\n setSettingsOpen(false)\n }}\n />\n </>\n )\n})\n\nexport default SettingsMenu\n", "\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon(/*#__PURE__*/_jsx(\"path\", {\n d: \"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z\"\n}), 'Delete');", "\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.mjs\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon(/*#__PURE__*/_jsx(\"path\", {\n d: \"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2\"\n}), 'MoreVert');", "import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n formControl: {\n minWidth: 130,\n maxWidth: 220,\n },\n})\n\n// Which walk to lift out of the drawing: Bandage's path highlight, with the\n// haplotypes a GBZ cut carries. Absent from a graph with no walks.\nconst WalkSelect = observer(function WalkSelect({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n const { walkChoices } = model\n if (walkChoices.length === 0) {\n return null\n }\n const names = new Set(walkChoices.map(c => c.name))\n return (\n <FormControl size=\"small\" className={classes.formControl}>\n <InputLabel>Walk</InputLabel>\n <Select\n value={names.has(model.highlightedPath) ? model.highlightedPath : ''}\n label=\"Walk\"\n data-testid=\"graph-walk-select\"\n onChange={e => {\n model.setHighlightedPath(e.target.value)\n }}\n >\n <MenuItem value=\"\">\n <em>None</em>\n </MenuItem>\n {walkChoices.map(({ name, label }) => (\n <MenuItem key={name} value={name}>\n {label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n})\n\nexport default WalkSelect\n", "import { observer } from 'mobx-react'\n\nimport { EXON_COLOR } from './GenePins'\nimport LabelChip from './LabelChip'\nimport { BUBBLE_KIND_COLORS } from '../bubbles/classifyBubble'\nimport { LABEL_PX } from '../overlayLabels'\n\nimport type { BubbleHalo, RouteLabel } from '../bubbles/bubbleHalos'\nimport type { GraphPaneModel } from '../model'\n\n// Every chip drawn over the graph, above all of its ink: bubble names, gene\n// names on their pins, and the routes' walkers. `overlayLabels` has placed\n// them against each other and against the row labels already.\n\nconst svgStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow: 'hidden' as const,\n zIndex: 3,\n}\n\nconst LabelLayer = observer(function LabelLayer({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { bubbles, genes, routes } = model.overlayLabels\n if (bubbles.length + genes.length + routes.length === 0) {\n return null\n }\n const { walkHighlight, scaleY, translateY, contigThickness } = model\n // a lifted walk dims the bubbles it never enters and the routes it does not\n // take\n const dimmedBubble = (h: BubbleHalo) =>\n walkHighlight !== undefined &&\n !h.nodeIds.some(id => walkHighlight.nodeIds.has(id))\n const dimmedRoute = (r: RouteLabel) =>\n walkHighlight !== undefined && !r.route.walks.includes(walkHighlight.name)\n\n return (\n <svg\n style={svgStyle}\n width={model.paneWidth}\n height={model.canvasHeight}\n data-testid=\"graph-label-layer\"\n >\n {genes.map(({ item: pin, x, y, w, text }) => (\n <g key={`${pin.gene.name}-${pin.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={EXON_COLOR}\n strokeWidth={0.8}\n strokeOpacity={0.6}\n />\n <LabelChip\n x={x}\n y={y}\n w={w}\n text={text}\n color={EXON_COLOR}\n italic\n title={`${pin.gene.name} ${pin.gene.refName}:${pin.gene.start.toLocaleString()}-${pin.gene.end.toLocaleString()}${pin.covered < 0.98 ? ', runs past the cut' : ''}`}\n testId=\"graph-gene-pin-label\"\n />\n </g>\n ))}\n {routes.map(({ item: { halo: h, route }, x, y, w, text }) => (\n <LabelChip\n key={`${h.bubble.start}-${h.bubble.end}-${route.route.steps.join(',')}`}\n x={x}\n y={y}\n w={w}\n text={text}\n color={BUBBLE_KIND_COLORS[h.kind]}\n small\n dimmed={dimmedRoute(route)}\n title={`${route.route.walks.length} walk(s): ${route.route.walks.join(', ')}`}\n testId=\"graph-route-label\"\n />\n ))}\n {bubbles.map(({ item: h, x, y, w, text }) => (\n <LabelChip\n key={`${h.bubble.start}-${h.bubble.end}`}\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 \u00B7 click to open`}\n testId=\"graph-bubble-halo-label\"\n onClick={() => {\n void model.popBubble(h.bubble)\n }}\n />\n ))}\n </svg>\n )\n})\n\nexport default LabelLayer\n", "import { LABEL_PAD, LABEL_PX } from '../overlayLabels'\n\n// One label on an overlay: a white chip with a coloured edge and text, its\n// baseline at y and centred on x.\nexport default function LabelChip({\n x,\n y,\n w,\n text,\n color,\n italic,\n small,\n dimmed,\n title,\n testId,\n onClick,\n}: {\n x: number\n y: number\n w: number\n text: string\n color: string\n italic?: boolean\n small?: boolean\n dimmed?: boolean\n title?: string\n testId?: string\n onClick?: () => void\n}) {\n return (\n <g\n style={{\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : undefined,\n opacity: dimmed ? 0.35 : 1,\n }}\n data-testid={testId}\n onClick={onClick}\n >\n {title ? <title>{title}</title> : null}\n <rect\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 rx={3}\n fill=\"rgba(255,255,255,0.85)\"\n stroke={color}\n strokeWidth={small ? 0.6 : 1}\n />\n <text\n x={x}\n y={y}\n fontSize={small ? LABEL_PX - 1 : 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 </text>\n </g>\n )\n}\n", "import { useEffect, useRef } from 'react'\n\nimport { getDpr } from '@jbrowse/render-core/canvas2dUtils'\nimport { autorun } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport { drawTubeMap } from '../tubeMap/draw'\n\nimport type { GraphPaneModel } from '../model'\n\nconst canvasStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n zIndex: 1,\n}\n\n// The tube map's ink, over the canvas, which draws nothing under a tube map\n// layout. Repainted by an autorun on every change of transform, so a pan in\n// the linear 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 ref = useRef<HTMLCanvasElement>(null)\n const { tubeMapPicture, paneWidth, canvasHeight } = model\n useEffect(\n () =>\n autorun(() => {\n const canvas = ref.current\n const picture = model.tubeMapPicture\n const frame = model.tubeMapFrame\n const ctx = canvas?.getContext('2d')\n if (canvas && ctx && picture && frame) {\n const dpr = getDpr()\n const width = model.paneWidth\n const height = model.canvasHeight\n canvas.width = Math.round(width * dpr)\n canvas.height = Math.round(height * dpr)\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n ctx.clearRect(0, 0, width, height)\n drawTubeMap(ctx, picture, {\n ...frame,\n width,\n highlightNode: model.hoveredNode ?? model.selectedNode,\n darkMode: model.darkMode,\n })\n }\n }),\n [model],\n )\n // Mounted whether or not there is a tube map, so the autorun above has its\n // canvas the moment a layout brings one.\n return (\n <canvas\n ref={ref}\n data-testid={tubeMapPicture ? 'graph-tube-map' : undefined}\n style={{\n ...canvasStyle,\n width: paneWidth,\n height: canvasHeight,\n display: tubeMapPicture ? 'block' : 'none',\n }}\n />\n )\n})\n\nexport default TubeMapOverlay\n", "import { observer } from 'mobx-react'\n\nimport { ROW_HEIGHT_PX } from '../layout/rowSpacing'\nimport { LABEL_CHAR_PX } from '../overlayLabels'\nimport { CALL_TOLERANCE } from '../repeats/walkCalls'\n\nimport type { GraphPaneModel } from '../model'\n\n// The walk-rows layout's bars: one per haplotype walk under the reference line\n// the canvas draws, each on its own bp axis from the window's left edge. Blue\n// is sequence the reference walk also carries, purple is sequence it does not,\n// and the readout at the end of a bar is what it carries against the\n// reference, which for a repeat array is the expansion.\n//\n// A tick is the genotyped allele length paired with THAT walk, and the walk\n// rows pair them \u2014 see repeats/walkCalls.ts, which also holds the threshold\n// this reads a red readout off.\n\nconst svgStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n pointerEvents: 'none' as const,\n overflow: 'visible' as const,\n zIndex: 3,\n}\n\nconst ON_REFERENCE = '#2f8fd6'\nconst CALL_TICK = '#111'\nconst UNBACKED_TICK = '#9e9e9e'\nconst DISAGREES = '#c62828'\nconst OFF_REFERENCE = '#8e3fbf'\nconst BAR_PX = 12\n\nconst legendBoxStyle = {\n background: 'rgba(255,255,255,0.82)',\n padding: '4px 6px',\n borderRadius: 3,\n fontSize: 11,\n lineHeight: '15px',\n whiteSpace: 'nowrap' as const,\n}\nconst legendRowStyle = { display: 'flex', alignItems: 'center', gap: 5 }\nconst swatchStyle = { width: 18, height: BAR_PX - 4, borderRadius: 2 }\nconst tickSwatchStyle = {\n ...swatchStyle,\n display: 'flex',\n justifyContent: 'center',\n}\n\nfunction TickSwatch({ color }: { color: string }) {\n return (\n <div style={tickSwatchStyle}>\n <div style={{ width: 2, backgroundColor: color }} />\n </div>\n )\n}\n\n// What the bar colours and the ticks mean, in the legend stack with the other\n// keys. The reference row is named, so \"the reference\" here reads as that row.\n// Each tick row appears once the rows hold one, so a catalogue with no\n// genotypes keeps the two-colour key it had.\nexport const WalkRowsLegend = observer(function WalkRowsLegend({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const bars = model.walkRowBars\n if (!bars) {\n return null\n }\n const calls = bars.rows.flatMap(row => row.call ?? [])\n return (\n <div style={legendBoxStyle} data-testid=\"graph-walk-rows-legend\">\n <div style={legendRowStyle}>\n <div style={{ ...swatchStyle, backgroundColor: ON_REFERENCE }} />\n <span>sequence {bars.reference.label} also carries</span>\n </div>\n <div style={legendRowStyle}>\n <div style={{ ...swatchStyle, backgroundColor: OFF_REFERENCE }} />\n <span>sequence it does not</span>\n </div>\n {calls.some(call => call.spanningReads !== 0) ? (\n <div style={legendRowStyle}>\n <TickSwatch color={CALL_TICK} />\n <span>allele length called for this walk</span>\n </div>\n ) : null}\n {calls.some(call => call.spanningReads === 0) ? (\n <div style={legendRowStyle}>\n <TickSwatch color={UNBACKED_TICK} />\n <span>called with no read spanning it</span>\n </div>\n ) : null}\n {calls.some(call => call.agrees === false) ? (\n <div style={legendRowStyle}>\n <div style={swatchStyle} />\n <span style={{ color: DISAGREES }}>\n walk and call over {Math.round(CALL_TOLERANCE * 100)}% apart\n </span>\n </div>\n ) : null}\n </div>\n )\n})\n\nfunction kb(bp: number) {\n return `${(bp / 1000).toFixed(bp < 10_000 ? 1 : 0)} kb`\n}\n\nfunction units(bp: number, unit: number | undefined) {\n return unit ? ` \u2248 ${Math.round(bp / unit)} units` : ''\n}\n\nfunction readout(\n bp: number,\n referenceBp: number,\n complete: boolean,\n unit: number | undefined,\n) {\n const delta = bp - referenceBp\n const against =\n delta === 0 ? '' : ` (${delta > 0 ? '+' : '\u2212'}${kb(Math.abs(delta))})`\n return `${kb(bp)}${units(bp, unit)}${against}${complete ? '' : ' \u00B7 partial walk'}`\n}\n\nfunction calledReadout(call: { bp: number; spanningReads?: number }) {\n const unbacked = call.spanningReads === 0 ? ' \u00B7 no spanning read' : ''\n return ` \u00B7 called ${kb(call.bp)}${unbacked}`\n}\n\n// One separator per unit along a bar, so copies are countable, dropped when a\n// unit is under a few px. The reference bar is the canvas's, so it gets none.\nconst MIN_TILE_PX = 3\n\nfunction tileSeparators(bp: number, unit: number, X: (bp: number) => number) {\n if (X(unit) - X(0) < MIN_TILE_PX) {\n return []\n }\n const xs: number[] = []\n for (let k = unit; k < bp; k += unit) {\n xs.push(k)\n }\n return xs\n}\n\nconst WalkRowsOverlay = observer(function WalkRowsOverlay({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { walkRowBars } = model\n if (!walkRowBars) {\n return null\n }\n const {\n scaleX,\n scaleY,\n translateX,\n translateY,\n paneWidth: width,\n canvasHeight,\n } = model\n const X = (bp: number) => bp * scaleX + translateX\n const Y = (row: number) => row * ROW_HEIGHT_PX * scaleY + translateY\n const { origin, unit, reference, rows } = walkRowBars\n // The backbone the canvas draws spans the cut window, which reaches past a\n // selected array on both sides, so the reference readout sits after it.\n const backboneEnd = Math.max(\n origin + reference.bp,\n model.graphRegion?.end ?? 0,\n )\n // A readout that would leave the pane is written inside the end of its bar.\n const label = (text: string, endBp: number, y: number, fill = '#333') => {\n const x = X(endBp) + 6\n const fits = x + text.length * LABEL_CHAR_PX < width\n return (\n <text\n x={fits ? x : X(endBp) - 6}\n y={y + 4}\n fontSize={11}\n fontFamily=\"sans-serif\"\n fill={fill}\n stroke={fits ? undefined : 'white'}\n strokeWidth={fits ? undefined : 3}\n paintOrder=\"stroke\"\n textAnchor={fits ? 'start' : 'end'}\n >\n {text}\n </text>\n )\n }\n return (\n <svg\n style={svgStyle}\n width={width}\n height={canvasHeight}\n data-testid=\"graph-walk-rows\"\n >\n {label(\n `${kb(reference.bp)}${units(reference.bp, unit)}`,\n backboneEnd,\n Y(0),\n )}\n {rows.map((row, i) => {\n const y = Y(i + 1)\n if (y < -BAR_PX || y > canvasHeight + BAR_PX) {\n return null\n }\n const { call } = row\n return (\n <g key={row.name} data-testid=\"graph-walk-row\">\n {row.runs.map(run => (\n <rect\n key={run.start}\n x={X(origin + run.start)}\n y={y - BAR_PX / 2}\n width={Math.max(1, run.bp * scaleX)}\n height={BAR_PX}\n fill={run.onReference ? ON_REFERENCE : OFF_REFERENCE}\n />\n ))}\n {unit\n ? tileSeparators(row.bp, unit, bp => bp * scaleX).map(k => (\n <line\n key={k}\n x1={X(origin + k)}\n x2={X(origin + k)}\n y1={y - BAR_PX / 2}\n y2={y + BAR_PX / 2}\n stroke=\"white\"\n strokeWidth={1}\n />\n ))\n : null}\n {call ? (\n <rect\n data-testid=\"graph-walk-call\"\n x={X(origin + call.bp) - 1}\n y={y - BAR_PX / 2 - 3}\n width={2}\n height={BAR_PX + 6}\n fill={call.spanningReads === 0 ? UNBACKED_TICK : CALL_TICK}\n />\n ) : null}\n {label(\n `${readout(row.bp, reference.bp, row.complete, unit)}${call ? calledReadout(call) : ''}`,\n origin + row.bp,\n y,\n call?.agrees === false ? DISAGREES : undefined,\n )}\n </g>\n )\n })}\n </svg>\n )\n})\n\nexport default WalkRowsOverlay\n", "import {\n abgrToCssRgba,\n normalizedRgbToCssRgba,\n} from '@jbrowse/core/util/colorBits'\nimport { syncCanvasSize } from '@jbrowse/render-core/canvas2dUtils'\nimport { Canvas2DRenderingBackendBase } from '@jbrowse/render-core/renderingBackendBase'\n\nimport { brightenAbgr } from './colorBits'\n\nimport type { RenderBatch, Renderer, TransformUniform } from './types'\n\n// Everything is drawn as a handful of paths, one per distinct (colour, weight),\n// rather than one path per thing. A drawing is mostly runs of one colour, and\n// Canvas2D's cost is per path verb and per fill or stroke, not per pixel: the\n// same 15k-node graph took 414 ms a frame as one fill per mesh triangle and 11\n// ms as batched strokes (agent-docs/GRAPH_SCALE_AND_LOD.md). Highlighted things\n// are drawn last, in their own paths, so they sit on top of what they brighten.\n//\n// Extends the shared Canvas2D base rather than standing alone, which is how\n// `setErrorHandler` arrives \u2014 `useRenderingBackend` requires it. The base's\n// no-op implementation is the correct one here: Canvas2D allocates no GPU\n// resources, so there is no OOM channel to forward.\nexport class Canvas2DRenderer\n extends Canvas2DRenderingBackendBase\n implements Renderer\n{\n private transform: TransformUniform | null = null\n private batch: RenderBatch | null = null\n private nodeHighlights: ReadonlyMap<string, number> = new Map()\n private highlightedEdge: number | null = null\n private highlightFactor = 1\n\n // render-core's, not a local `width * devicePixelRatio`: it clamps the\n // backing store at MAX_CANVAS_DIM_PX, reads the ratio through `getDpr()` so\n // this agrees with the transform the model builds, and writes the css size\n // independently of the backing size.\n resize(width: number, height: number) {\n syncCanvasSize(this.ctx.canvas, width, height)\n }\n\n uploadGeometry(batch: RenderBatch) {\n this.batch = batch\n // A rebuild renumbers the strokes, so the old edge no longer addresses the\n // same run; the model re-applies the current hover against the new batch.\n this.highlightedEdge = null\n }\n\n setNodeHighlights(factors: ReadonlyMap<string, number>) {\n this.nodeHighlights = factors\n }\n\n setEdgeHighlight(edgeIndex: number | null, factor: number) {\n this.highlightedEdge = edgeIndex\n this.highlightFactor = factor\n }\n\n updateTransform(transform: TransformUniform) {\n this.transform = transform\n }\n\n render(clearColor: [number, number, number, number]) {\n const t = this.transform\n if (!t) {\n return\n }\n const ctx = this.ctx\n const { width, height } = ctx.canvas\n\n ctx.fillStyle = normalizedRgbToCssRgba(\n [clearColor[0], clearColor[1], clearColor[2]],\n clearColor[3],\n )\n ctx.fillRect(0, 0, width, height)\n\n const batch = this.batch\n if (!batch) {\n return\n }\n ctx.lineCap = 'round'\n ctx.lineJoin = 'round'\n this.renderEdges(batch)\n this.renderNodes(batch)\n this.renderArrows(batch)\n }\n\n private renderEdges(batch: RenderBatch) {\n const t = this.transform!\n const ctx = this.ctx\n const hl =\n this.highlightedEdge === null\n ? undefined\n : batch.edgeCurveRuns.get(this.highlightedEdge)\n for (const { color, items } of groupByPaint(batch.edgeCurves, (e, i) => ({\n color: inRun(hl, i)\n ? brightenAbgr(e.color, this.highlightFactor)\n : e.color,\n weight: e.thickness,\n last: inRun(hl, i),\n }))) {\n ctx.strokeStyle = abgrToCssRgba(color)\n // thickness is the half-width in css px, so the stroke is twice it at\n // the device ratio the transform already carries\n ctx.lineWidth = items[0]!.thickness * 2 * t.dpr\n ctx.beginPath()\n for (const e of items) {\n const first = e.curves[0]!\n ctx.moveTo(\n first.x0 * t.scaleX + t.translateX,\n first.y0 * t.scaleY + t.translateY,\n )\n for (const c of e.curves) {\n ctx.bezierCurveTo(\n c.cx0 * t.scaleX + t.translateX,\n c.cy0 * t.scaleY + t.translateY,\n c.cx1 * t.scaleX + t.translateX,\n c.cy1 * t.scaleY + t.translateY,\n c.x1 * t.scaleX + t.translateX,\n c.y1 * t.scaleY + t.translateY,\n )\n }\n }\n ctx.stroke()\n }\n }\n\n private renderNodes(batch: RenderBatch) {\n const t = this.transform!\n const ctx = this.ctx\n // stroke index -> brighten factor, for the nodes the model lifted\n const lifted = new Map<number, number>()\n for (const [nodeId, factor] of this.nodeHighlights) {\n const run = batch.nodeStrokeRuns.get(nodeId)\n if (run) {\n for (let i = run.start; i < run.start + run.count; i++) {\n lifted.set(i, factor)\n }\n }\n }\n for (const { color, items } of groupByPaint(batch.nodeStrokes, (s, i) => {\n const factor = lifted.get(i)\n return {\n color: factor === undefined ? s.color : brightenAbgr(s.color, factor),\n weight: s.thickness,\n last: factor !== undefined,\n }\n })) {\n ctx.strokeStyle = abgrToCssRgba(color)\n ctx.lineWidth = items[0]!.thickness * 2 * t.dpr\n ctx.beginPath()\n for (const s of items) {\n const p0 = s.points[0]!\n ctx.moveTo(\n p0.x * t.scaleX + t.translateX,\n p0.y * t.scaleY + t.translateY,\n )\n for (let i = 1, l = s.points.length; i < l; i++) {\n const p = s.points[i]!\n ctx.lineTo(\n p.x * t.scaleX + t.translateX,\n p.y * t.scaleY + t.translateY,\n )\n }\n }\n ctx.stroke()\n }\n }\n\n private renderArrows(batch: RenderBatch) {\n const t = this.transform!\n const ctx = this.ctx\n const hl =\n this.highlightedEdge === null\n ? undefined\n : batch.arrowRuns.get(this.highlightedEdge)\n for (const { color, items } of groupByPaint(batch.arrows, (a, i) => ({\n color: inRun(hl, i)\n ? brightenAbgr(a.color, this.highlightFactor)\n : a.color,\n weight: 0,\n last: inRun(hl, i),\n }))) {\n ctx.fillStyle = abgrToCssRgba(color)\n ctx.beginPath()\n for (const a of items) {\n // The tip sits on the edge's end; the two barbs are `size` css px back\n // along either side of the tangent, expanded after the transform so\n // the head is the same size at every zoom.\n const tipX = a.x * t.scaleX + t.translateX\n const tipY = a.y * t.scaleY + t.translateY\n const reach = a.size * t.dpr\n ctx.moveTo(tipX, tipY)\n ctx.lineTo(\n tipX - Math.cos(a.angle - 0.5) * reach,\n tipY - Math.sin(a.angle - 0.5) * reach,\n )\n ctx.lineTo(\n tipX - Math.cos(a.angle + 0.5) * reach,\n tipY - Math.sin(a.angle + 0.5) * reach,\n )\n ctx.closePath()\n }\n ctx.fill()\n }\n }\n\n override dispose() {\n super.dispose()\n this.batch = null\n this.nodeHighlights = new Map()\n this.highlightedEdge = null\n }\n}\n\nfunction inRun(run: { start: number; count: number } | undefined, i: number) {\n return run !== undefined && i >= run.start && i < run.start + run.count\n}\n\ninterface Paint {\n color: number\n weight: number\n // drawn after everything else, so a highlight lands on top of its neighbours\n last: boolean\n}\n\n// Items bucketed by what they are painted with, in first-seen order, with the\n// `last` ones after the rest.\nfunction groupByPaint<T>(\n items: T[],\n paintOf: (item: T, index: number) => Paint,\n) {\n const groups = new Map<string, { color: number; items: T[] }>()\n const deferred = new Map<string, { color: number; items: T[] }>()\n for (let i = 0, l = items.length; i < l; i++) {\n const item = items[i]!\n const { color, weight, last } = paintOf(item, i)\n const into = last ? deferred : groups\n const key = `${color}:${weight}`\n const group = into.get(key)\n if (group) {\n group.items.push(item)\n } else {\n into.set(key, { color, items: [item] })\n }\n }\n return [...groups.values(), ...deferred.values()]\n}\n", "import { Canvas2DRenderer } from './Canvas2DRenderer'\n\n// Canvas2D only, and deliberately not through render-core's GPU ladder. The\n// batch is strokes and arrowheads in layout units, and stroking them batched by\n// colour is inside a frame budget at the node counts this view caps itself at\n// (agent-docs/GRAPH_SCALE_AND_LOD.md), so a GPU backend would buy a few\n// milliseconds for ~30 KB of bundled HAL and a shader toolchain. If one is ever\n// wanted, it should take the same `Renderer` interface and draw the batch as\n// instances \u2014 a capsule per node segment, a bezier ribbon per edge stroke \u2014\n// rather than reviving a triangle mesh; agent-docs/IDEAS.md scopes it.\nexport function createGraphRenderer(canvas: HTMLCanvasElement) {\n return Promise.resolve(new Canvas2DRenderer(canvas))\n}\n", "import { baseEdgeCurves } from './edgeCurves'\nimport { curveBounds, pathRibbonOffsets } from './geometry'\n\nimport type { EdgeCurves } from './edgeCurves'\nimport type { Graph, NodeSegment } from '../types'\nimport type { AxisScale } from './geometry'\n\ninterface CellEntry {\n nodeId: string\n segmentIdx: number\n}\n\n// A uniform grid only performs when its cells are about the size of the things\n// in them: too large and every query scans a crowd, too small and every item is\n// stamped into hundreds of cells. World units here are whatever the layout uses,\n// and the two differ by orders of magnitude \u2014 the force layout's are screen-ish\n// (nodes ~8 units long), while the reference-anchored layouts put x in bp, so a\n// 100 kb window is 100,000 units wide. A fixed 50 was tuned for the first and\n// left the second stamping each edge into hundreds of cells: measured 7.2 ms to\n// index 800 bp-scale edges, against 2.8 ms for 8,000 screen-scale ones.\n//\n// So the size is derived from the mean extent of the items being indexed \u2014\n// **per axis**, for the reason the query radius below is already per axis: on a\n// row layout x is bp and y is screen px, and one size taken from the two summed\n// is the x size. Applied to y it swallowed every row into one cell, so the grid\n// degenerated to a 1-D index on x and each query handed the distance loop every\n// row in the band. On HPRC's rGFA, whose mean segment is ~7 kb against a 20 px\n// row pitch, that is all of them.\nconst FALLBACK_CELL_SIZE = 50\n\nexport interface CellSize {\n x: number\n y: number\n}\n\nfunction meanExtentCellSize(extentTotal: number, count: number) {\n return count > 0 ? Math.max(1, extentTotal / count) : FALLBACK_CELL_SIZE\n}\n\n// The y size for the layouts whose items have no y extent of their own. Every\n// row there is a horizontal line, so the mean per-item extent is exactly zero\n// and says nothing about how the rows are spaced. What separates them is the\n// ROW PITCH, which is their spread over the number of rows they occupy.\nfunction rowPitchOf(boxes: { minY: number }[]) {\n const distinct = new Set<number>()\n let min = Infinity\n let max = -Infinity\n for (const box of boxes) {\n distinct.add(box.minY)\n min = Math.min(min, box.minY)\n max = Math.max(max, box.minY)\n }\n return distinct.size > 1 ? (max - min) / (distinct.size - 1) : undefined\n}\n\n// A row layout with one row has nothing to separate on y, so it takes the x\n// size and lands in one cell rather than being stamped across thousands.\nfunction cellSizeFrom(\n boxes: { minY: number }[],\n extentX: number,\n extentY: number,\n): CellSize {\n const x = meanExtentCellSize(extentX, boxes.length)\n return {\n x,\n y:\n extentY > 0\n ? meanExtentCellSize(extentY, boxes.length)\n : (rowPitchOf(boxes) ?? x),\n }\n}\n\nfunction resolveCellSize(\n given: number | CellSize | undefined,\n boxes: { minY: number }[],\n extentX: number,\n extentY: number,\n): CellSize {\n return given === undefined\n ? cellSizeFrom(boxes, extentX, extentY)\n : typeof given === 'number'\n ? { x: given, y: given }\n : given\n}\n\nfunction getOrCreateCell<T>(\n cells: Map<number, Map<number, T[]>>,\n cx: number,\n cy: number,\n) {\n let row = cells.get(cx)\n if (!row) {\n row = new Map()\n cells.set(cx, row)\n }\n let cell = row.get(cy)\n if (!cell) {\n cell = []\n row.set(cy, cell)\n }\n return cell\n}\n\nfunction addToGrid<T>(\n cells: Map<number, Map<number, T[]>>,\n cellSize: CellSize,\n minX: number,\n minY: number,\n maxX: number,\n maxY: number,\n entry: T,\n) {\n const cx0 = Math.floor(minX / cellSize.x)\n const cx1 = Math.floor(maxX / cellSize.x)\n const cy0 = Math.floor(minY / cellSize.y)\n const cy1 = Math.floor(maxY / cellSize.y)\n for (let cx = cx0; cx <= cx1; cx++) {\n for (let cy = cy0; cy <= cy1; cy++) {\n getOrCreateCell(cells, cx, cy).push(entry)\n }\n }\n}\n\n// The radius is per axis because the two axes need not be in the same units: a\n// row layout's x is bp and its y is screen px, so the same 5 px of slack is\n// hundreds of bp one way and 5 the other. Passing the x radius on both axes\n// would sweep every row in the band into the candidate set.\nfunction queryGrid<T>(\n cells: Map<number, Map<number, T[]>>,\n cellSize: CellSize,\n x: number,\n y: number,\n radiusX: number,\n radiusY: number,\n): T[] {\n const cx0 = Math.floor((x - radiusX) / cellSize.x)\n const cx1 = Math.floor((x + radiusX) / cellSize.x)\n const cy0 = Math.floor((y - radiusY) / cellSize.y)\n const cy1 = Math.floor((y + radiusY) / cellSize.y)\n const results: T[] = []\n const seen = new Set<T>()\n for (let cx = cx0; cx <= cx1; cx++) {\n const row = cells.get(cx)\n if (row) {\n for (let cy = cy0; cy <= cy1; cy++) {\n const cell = row.get(cy)\n if (cell) {\n for (const entry of cell) {\n if (!seen.has(entry)) {\n seen.add(entry)\n results.push(entry)\n }\n }\n }\n }\n }\n }\n return results\n}\n\nexport class SpatialIndex {\n private cellSize: CellSize\n private cells = new Map<number, Map<number, CellEntry[]>>()\n\n constructor(\n nodePositions: Record<string, NodeSegment[]>,\n // one number sets both axes, which is what a test that only cares about\n // bucketing wants\n cellSize?: number | CellSize,\n ) {\n // Segment boxes are collected first so the cell size can come from their\n // mean extent; the grid itself needs the size up front.\n const boxes: {\n entry: CellEntry\n minX: number\n minY: number\n maxX: number\n maxY: number\n }[] = []\n let extentX = 0\n let extentY = 0\n for (const [nodeId, segments] of Object.entries(nodePositions)) {\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i]!\n const next = segments[i + 1]!\n const minX = Math.min(seg.x, next.x)\n const minY = Math.min(seg.y, next.y)\n const maxX = Math.max(seg.x, next.x)\n const maxY = Math.max(seg.y, next.y)\n extentX += maxX - minX\n extentY += maxY - minY\n boxes.push({ entry: { nodeId, segmentIdx: i }, minX, minY, maxX, maxY })\n }\n }\n\n this.cellSize = resolveCellSize(cellSize, boxes, extentX, extentY)\n for (const b of boxes) {\n addToGrid(\n this.cells,\n this.cellSize,\n b.minX,\n b.minY,\n b.maxX,\n b.maxY,\n b.entry,\n )\n }\n }\n\n query(x: number, y: number, radiusX: number, radiusY = radiusX) {\n return queryGrid(this.cells, this.cellSize, x, y, radiusX, radiusY)\n }\n}\n\nexport class EdgeSpatialIndex {\n private cellSize: CellSize\n private cells = new Map<number, Map<number, number[]>>()\n // Base curves (offset 0) by edge index \u2014 the shared derivation, which the\n // geometry builder draws the same edges from. findHoveredEdge reuses them on\n // every mousemove; path-offset variants translate them (pure translation).\n private edgeCurves: EdgeCurves\n\n constructor(\n nodePositions: Record<string, NodeSegment[]>,\n graph: Graph,\n drawPaths: boolean,\n // The transform the curves indexed here were drawn under, so hit detection\n // tests the shape on screen. See AxisScale.\n axis: AxisScale,\n cellSize?: number | CellSize,\n // Bypassed backbone ids per deletion edge, i.e. what GeometryBuilder is\n // given. Without it a deletion is indexed and hit-tested on the STRAIGHT\n // chord between its endpoints while it is drawn as an arc bowed off that\n // chord, so the shape on screen is not hoverable and the empty space where\n // the chord runs is \u2014 and the tutorial tells the reader to hover it for the\n // interval and the bp. Bowing is part of the drawn geometry, so it has to be\n // part of the geometry hit detection uses.\n deletions?: Map<number, string[]>,\n // Bumped when a drag moves the positions in place; see baseEdgeCurves.\n version = 0,\n ) {\n this.edgeCurves = baseEdgeCurves(\n nodePositions,\n graph,\n axis,\n deletions,\n version,\n )\n const boxes: {\n ei: number\n minX: number\n minY: number\n maxX: number\n maxY: number\n }[] = []\n let extentX = 0\n let extentY = 0\n for (let ei = 0; ei < graph.edges.length; ei++) {\n const edge = graph.edges[ei]!\n const fromSegments = nodePositions[edge.from]\n const toSegments = nodePositions[edge.to]\n const curves = this.edgeCurves.get(ei)\n if (fromSegments?.length && toSegments?.length && curves) {\n // The control polygon's box, which contains the curve \u2014 the same\n // measure the geometry builder culls by, from the one function that\n // takes it.\n let { minX, minY, maxX, maxY } = curveBounds(curves)\n\n // Ribbons sit off the edge itself, so the box has to hold them too. Per\n // axis and off the offsets actually used, rather than one number on\n // both: the fan is perpendicular to the edge, so an edge running along\n // x spends all of it on y and none on x, and on a row layout the two\n // axes are not even in the same units.\n const numPaths = edge.pathIds?.length ?? 0\n if (drawPaths && numPaths > 0) {\n let padX = 0\n let padY = 0\n for (const o of pathRibbonOffsets(\n fromSegments,\n toSegments,\n numPaths,\n axis,\n )) {\n padX = Math.max(padX, Math.abs(o.x))\n padY = Math.max(padY, Math.abs(o.y))\n }\n minX -= padX\n minY -= padY\n maxX += padX\n maxY += padY\n }\n\n extentX += maxX - minX\n extentY += maxY - minY\n boxes.push({ ei, minX, minY, maxX, maxY })\n }\n }\n\n this.cellSize = resolveCellSize(cellSize, boxes, extentX, extentY)\n for (const b of boxes) {\n addToGrid(this.cells, this.cellSize, b.minX, b.minY, b.maxX, b.maxY, b.ei)\n }\n }\n\n getCurves(ei: number) {\n return this.edgeCurves.get(ei)\n }\n\n query(x: number, y: number, radiusX: number, radiusY = radiusX) {\n return queryGrid(this.cells, this.cellSize, x, y, radiusX, radiusY)\n }\n}\n", "import { EdgeSpatialIndex, SpatialIndex } from './SpatialIndex'\nimport { pathRibbonOffsets, translateCurves, yToXOf } from './geometry'\n\nimport type { Graph, NodeSegment } from '../types'\nimport type { AxisScale, BezierCurve } from './geometry'\n\nexport function distanceToSegment(\n px: number,\n py: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n) {\n const dx = x2 - x1\n const dy = y2 - y1\n const lenSq = dx * dx + dy * dy\n if (lenSq === 0) {\n return Math.hypot(px - x1, py - y1)\n }\n const t = Math.max(0, Math.min(1, ((px - x1) * dx + (py - y1) * dy) / lenSq))\n return Math.hypot(px - (x1 + t * dx), py - (y1 + t * dy))\n}\n\nexport function distanceToCubicBezier(\n px: number,\n py: number,\n x1: number,\n y1: number,\n cx1: number,\n cy1: number,\n cx2: number,\n cy2: number,\n x2: number,\n y2: number,\n) {\n // To the chords between samples, not to the samples: on a long curve they\n // are tens of px apart, and a cursor on the curve between two of them\n // measured as far off it as half that gap.\n let minDist = Infinity\n const samples = 20\n let lastX = x1\n let lastY = y1\n for (let i = 1; i <= samples; i++) {\n const t = i / samples\n const u = 1 - t\n const bx =\n u * u * u * x1 +\n 3 * u * u * t * cx1 +\n 3 * u * t * t * cx2 +\n t * t * t * x2\n const by =\n u * u * u * y1 +\n 3 * u * u * t * cy1 +\n 3 * u * t * t * cy2 +\n t * t * t * y2\n minDist = Math.min(minDist, distanceToSegment(px, py, lastX, lastY, bx, by))\n lastX = bx\n lastY = by\n }\n return minDist\n}\n\nfunction distanceToBezierCurve(px: number, py: number, c: BezierCurve) {\n return distanceToCubicBezier(\n px,\n py,\n c.x0,\n c.y0,\n c.cx0,\n c.cy0,\n c.cx1,\n c.cy1,\n c.x1,\n c.y1,\n )\n}\n\nfunction distanceToEdgeCurves(\n px: number,\n py: number,\n curves: BezierCurve[],\n yToX = 1,\n) {\n let minDist = Infinity\n for (const c of curves) {\n const d = distanceToBezierCurve(\n px,\n py,\n yToX === 1\n ? c\n : {\n x0: c.x0,\n y0: c.y0 * yToX,\n cx0: c.cx0,\n cy0: c.cy0 * yToX,\n cx1: c.cx1,\n cy1: c.cy1 * yToX,\n x1: c.x1,\n y1: c.y1 * yToX,\n },\n )\n if (d < minDist) {\n minDist = d\n }\n }\n return minDist\n}\n\n// Indexes are cached against the layout they were built from, in a WeakMap\n// rather than a module-level slot. A single slot meant two graph views in one\n// session evicted each other's index on alternating mousemoves, and held the last\n// graph's positions alive for as long as the tab lived. Keyed this way each view\n// keeps its own, and an entry becomes collectable when its layout is replaced.\n//\n// `version` still has to be compared: a node drag mutates the position objects in\n// place, so the identity of `nodePositions` cannot report that it changed.\nconst nodeCache = new WeakMap<\n Record<string, NodeSegment[]>,\n { version: number; index: SpatialIndex }\n>()\n\nfunction getSpatialIndex(\n nodePositions: Record<string, NodeSegment[]>,\n version: number,\n) {\n const cached = nodeCache.get(nodePositions)\n if (cached?.version === version) {\n return cached.index\n }\n const index = new SpatialIndex(nodePositions)\n nodeCache.set(nodePositions, { version, index })\n return index\n}\n\nconst edgeCache = new WeakMap<\n Record<string, NodeSegment[]>,\n {\n graph: Graph\n drawPaths: boolean\n // compared by VALUE, not by the AxisScale's identity: the model rebuilds\n // that object whenever either scale changes, so identity would miss a cache\n // hit on every mousemove\n scaleX: number\n scaleY: number\n version: number\n index: EdgeSpatialIndex\n deletions?: Map<number, string[]>\n }\n>()\n\nfunction getEdgeSpatialIndex(\n nodePositions: Record<string, NodeSegment[]>,\n graph: Graph,\n drawPaths: boolean,\n axis: AxisScale,\n version: number,\n deletions?: Map<number, string[]>,\n) {\n const cached = edgeCache.get(nodePositions)\n if (\n cached?.graph === graph &&\n cached.drawPaths === drawPaths &&\n cached.scaleX === axis.scaleX &&\n cached.scaleY === axis.scaleY &&\n cached.version === version &&\n cached.deletions === deletions\n ) {\n return cached.index\n }\n const index = new EdgeSpatialIndex(\n nodePositions,\n graph,\n drawPaths,\n axis,\n undefined,\n deletions,\n version,\n )\n edgeCache.set(nodePositions, {\n graph,\n drawPaths,\n scaleX: axis.scaleX,\n scaleY: axis.scaleY,\n version,\n index,\n deletions,\n })\n return index\n}\n\n// Every distance below is measured with y converted into x units by `yToX` (the\n// model's scaleY / scaleX), because on a row layout the two axes are bp and\n// screen px and a raw hypot over them is not a distance at all \u2014 5 bp of x and\n// 5 px of y are nothing alike. The thresholds stay screen px over the x scale,\n// which is what they always were; on an isotropic layout yToX is 1 and this is\n// the arithmetic it has always done.\n//\n// `ink` is how far from its centreline each node is drawn, in screen px, and\n// the most any node is. A node drawn thick by its depth is 18 px across at the\n// defaults, and a fixed tolerance missed the pointer on its outer ink, where\n// the link beside it took the hover instead. MIN_NODE_REACH_PX keeps a thin\n// node catchable.\nconst MIN_NODE_REACH_PX = 5\n\nexport interface NodeInk {\n halfWidthPx: (nodeId: string) => number\n maxHalfWidthPx: number\n}\n\nexport function findHoveredNode(\n nodePositions: Record<string, NodeSegment[]>,\n graphX: number,\n graphY: number,\n axis: AxisScale,\n version = 0,\n ink?: NodeInk,\n) {\n const yToX = yToXOf(axis)\n const index = getSpatialIndex(nodePositions, version)\n const reach = (px: number) => Math.max(MIN_NODE_REACH_PX, px) / axis.scaleX\n // the query has to cover the thickest node there could be\n const queryReach = reach(ink?.maxHalfWidthPx ?? 0)\n const candidates = index.query(graphX, graphY, queryReach, queryReach / yToX)\n\n // The nearest candidate, not the first one inside its reach. The reach is in\n // world units, so when zoomed out it covers several nodes at once and \"first\"\n // meant whichever the grid happened to visit first \u2014 the cursor could sit on\n // one node and highlight its neighbour.\n let hovered: string | null = null\n let best = Infinity\n for (const { nodeId, segmentIdx } of candidates) {\n const segments = nodePositions[nodeId]!\n const dist = distanceToSegment(\n graphX,\n graphY * yToX,\n segments[segmentIdx]!.x,\n segments[segmentIdx]!.y * yToX,\n segments[segmentIdx + 1]!.x,\n segments[segmentIdx + 1]!.y * yToX,\n )\n if (dist < best && dist < reach(ink?.halfWidthPx(nodeId) ?? 0)) {\n best = dist\n hovered = nodeId\n }\n }\n return hovered\n}\n\nexport function findHoveredEdge(\n nodePositions: Record<string, NodeSegment[]>,\n graph: Graph,\n graphX: number,\n graphY: number,\n axis: AxisScale,\n drawPaths: boolean,\n version = 0,\n deletions?: Map<number, string[]>,\n hiddenEdges?: ReadonlySet<number>,\n) {\n const yToX = yToXOf(axis)\n const edgeThreshold = 10 / axis.scaleX\n const edgeIndex = getEdgeSpatialIndex(\n nodePositions,\n graph,\n drawPaths,\n axis,\n version,\n deletions,\n )\n const candidates = edgeIndex.query(\n graphX,\n graphY,\n edgeThreshold,\n edgeThreshold / yToX,\n )\n\n // Nearest, not first \u2014 same reason as findHoveredNode.\n let hovered: number | null = null\n let best = edgeThreshold\n for (const edgeIdx of candidates) {\n const edge = graph.edges[edgeIdx]!\n const fromSegments = nodePositions[edge.from]\n const toSegments = nodePositions[edge.to]\n if (\n !fromSegments?.length ||\n !toSegments?.length ||\n hiddenEdges?.has(edgeIdx)\n ) {\n continue\n }\n\n const numPaths = edge.pathIds?.length ?? 0\n const baseCurves = edgeIndex.getCurves(edgeIdx)\n if (!baseCurves) {\n continue\n }\n let dist: number\n\n if (!drawPaths || numPaths === 0) {\n dist = distanceToEdgeCurves(graphX, graphY * yToX, baseCurves, yToX)\n } else {\n // The same offsets GeometryBuilder drew the ribbons at, from the one\n // function that decides them, so a ribbon is hoverable where it is drawn.\n let minDist = Infinity\n for (const offset of pathRibbonOffsets(\n fromSegments,\n toSegments,\n numPaths,\n axis,\n )) {\n const curves =\n offset.x === 0 && offset.y === 0\n ? baseCurves\n : translateCurves(baseCurves, offset.x, offset.y)\n const d = distanceToEdgeCurves(graphX, graphY * yToX, curves, yToX)\n if (d < minDist) {\n minDist = d\n }\n }\n dist = minDist\n }\n\n if (dist < best) {\n best = dist\n hovered = edgeIdx\n }\n }\n return hovered\n}\n", "const ZOOM_PER_NOTCH = 1.1\nconst NOTCH_PX = 100\nconst LINE_PX = 40\nconst PAGE_PX = 800\nconst PINCH_GAIN = 10\nconst MAX_NOTCHES_PER_EVENT = 2\n\n// Zoom by how far the wheel moved rather than by one step per event. A mouse\n// sends one event of about NOTCH_PX per notch and still zooms ZOOM_PER_NOTCH;\n// a trackpad sends sixty small ones a second, which at a step each compounded\n// to hundreds of times per second. A pinch arrives as ctrl+wheel with deltas a\n// tenth the size. The delta is normalized here rather than with core's\n// normalizeWheelDelta, which a released host may not export.\nexport function wheelZoomFactor(e: {\n deltaY: number\n deltaMode: number\n ctrlKey: boolean\n}) {\n const px =\n e.deltaY * (e.deltaMode === 1 ? LINE_PX : e.deltaMode === 2 ? PAGE_PX : 1)\n const notches = ((e.ctrlKey ? PINCH_GAIN : 1) * px) / NOTCH_PX\n return (\n ZOOM_PER_NOTCH **\n -Math.max(-MAX_NOTCHES_PER_EVENT, Math.min(MAX_NOTCHES_PER_EVENT, notches))\n )\n}\n"],
5
+ "mappings": "+bAAA,IAAAA,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAO,QAAU,eAAe,0CAA0C,ICA1E,IAAAC,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAO,QAAU,eAAe,2CAA2C,ICA3E,IAAAC,EAA4C,UAE5CC,EAAkD,UAClDC,GAAwB,UACxBC,GAAoC,UCDpC,IAAAC,GAA4B,SACrBC,MAAQ,oBAA2B,GAAAC,KAAK,OAAQ,CACrD,EAAG,6FACL,CAAC,EAAG,MAAM,EDAV,IAAAC,EAAyB,SENzB,IAAAC,GAAyB,SA0Db,IAAAC,GAAA,SA7CNC,GAAW,CACf,SAAU,WACV,KAAM,EACN,IAAK,EACL,cAAe,OACf,SAAU,SACV,OAAQ,CACV,EAEMC,MAAc,aAAS,SAAqB,CAChD,MAAAC,CACF,EAEG,CACD,GAAM,CAAE,YAAAC,EAAa,cAAAC,CAAc,EAAIF,EACvC,GAAIC,EAAY,SAAW,EACzB,OAAO,KAET,GAAM,CACJ,OAAAE,EACA,OAAAC,EACA,WAAAC,EACA,WAAAC,EACA,UAAWC,EACX,aAAAC,CACF,EAAIR,EACES,EAAOT,EAAM,gBAAkBU,GAE/BC,EAAgBC,GACpBV,IAAkB,QAClB,CAACU,EAAE,QAAQ,KAAKC,GAAMX,EAAc,QAAQ,IAAIW,C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AAA,CAAe,MAAOvG,EAAO,KAC9B,OAACD,GAAA,CAAU,MAAOC,EAAO,KACzB,OAACkC,GAAA,CAAgB,MAAOlC,EAAO,KAC/B,OAACwG,GAAA,CAAY,MAAOxG,EAAO,KAC3B,OAACyG,GAAA,CAAS,MAAOzG,EAAO,KACxB,OAAC0G,GAAA,CAAW,MAAO1G,EAAO,KAC1B,OAAC2G,GAAA,CAAc,MAAO3G,EAAO,KAC7B,OAAC4G,GAAA,CAAgB,MAAO5G,EAAO,KAC/B,OAAC6B,GAAA,CAAQ,MAAO7B,EAAO,EAEtBmE,KACC,OAAC,OAAI,MAAOtE,GACV,mBAAC,kBACC,UAAWG,EAAM,UACjB,UAAW,CAACA,EAAM,aAClB,cAAeA,EAAM,cACrB,SACEA,EAAM,cACF,IAAM,CACJA,EAAM,WAAW,CACnB,EACA,OAER,EACF,EACE,MACN,KAEA,OAAC8C,GAAA,CAAc,MAAO9C,EAAO,EAE5B4E,KACC,OAACtB,GAAA,CACC,MAAOtD,EACP,OAAQ4E,EAAY,OACpB,IAAKA,EAAY,IACjB,KAAMA,EAAY,KAClB,QAAS,IAAM,CACbC,EAAe,MAAS,CAC1B,EACF,EACE,KAEHP,KACC,OAAC,eAAY,MAAOA,EAAa,QAASC,EAAa,EACrD,KAEHJ,GAAanE,EAAM,SAClB,OAAC,eACC,MAAOA,EAAM,MACb,QACEA,EAAM,aACF,IAAM,CACJA,EAAM,UAAU,CAClB,EACA,OAER,EACE,MACN,CAEJ,CAAC,EAEM6G,GAAQ3C",
6
+ "names": ["require_useRenderingBackend", "__commonJSMin", "exports", "module", "require_renderingBackendBase", "__commonJSMin", "exports", "module", "import_react", "import_ui", "import_mobx_state_tree", "import_useRenderingBackend", "import_jsx_runtime", "Info_default", "_jsx", "import_mobx_react", "import_mobx_react", "import_jsx_runtime", "svgStyle", "BubbleHalos", "model", "bubbleHalos", "walkHighlight", "scaleX", "scaleY", "translateX", "translateY", "width", "canvasHeight", "halo", "HALO_FACTOR", "dimmedBubble", "h", "id", "BUBBLE_KIND_COLORS", "BubbleHalos_default", "import_material", "import_mobx_react", "import_jsx_runtime", "svgStyle", "backButtonStyle", "MIN_GLYPH_PX", "glyphHeight", "bp", "room", "raw", "BubbleOverlay", "model", "bubbleGlyphs", "poppedFrom", "back", "scaleX", "translateX", "translateY", "width", "canvasHeight", "lineY", "X", "labels", "labelsBottom", "l", "glyphs", "a", "b", "bubble", "kind", "label", "x0", "x1", "w", "cx", "h", "color", "BUBBLE_KIND_COLORS", "skipped", "dip", "key", "g", "glyphX", "x", "y", "top", "BubbleOverlay_default", "import_mobx_react", "import_jsx_runtime", "svgStyle", "EXON_COLOR", "GenePins", "model", "genePins", "scaleX", "scaleY", "translateX", "translateY", "width", "canvasHeight", "contigThickness", "pin", "GenePins_default", "import_jsx_runtime", "CropFree_default", "_jsx", "import_jsx_runtime", "ZoomIn_default", "_jsx", "import_jsx_runtime", "ZoomOut_default", "_jsx", "import_material", "import_mobx_react", "import_mui", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "ColorSchemeSelect", "model", "classes", "e", "COLOR_SCHEMES", "value", "label", "ColorSchemeSelect_default", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "fmtMs", "ms", "GraphPerf", "model", "classes", "lastFetchMs", "lastLayoutMs", "lastGeometryMs", "hasMetrics", "GraphStats", "GraphStats_default", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "LayoutSelect", "model", "classes", "graph", "e", "LAYOUT_MODES", "value", "label", "description", "available", "LayoutSelect_default", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "RepeatSelect", "model", "classes", "repeatChoices", "keys", "r", "e", "key", "name", "unit", "RepeatSelect_default", "import_react", "import_ui", "import_jsx_runtime", "Delete_default", "_jsx", "import_jsx_runtime", "MoreVert_default", "_jsx", "import_mobx_react", "import_jsx_runtime", "SettingsMenu", "model", "settingsOpen", "setSettingsOpen", "Settings_default", "Delete_default", "MoreVert_default", "GraphSettingsDialog_default", "SettingsMenu_default", "import_material", "import_mobx_react", "import_mui", "import_jsx_runtime", "useStyles", "WalkSelect", "model", "classes", "walkChoices", "names", "c", "e", "name", "label", "WalkSelect_default", "import_jsx_runtime", "useStyles", "ZoomDisplay", "model", "GraphToolbar", "classes", "LayoutSelect_default", "ColorSchemeSelect_default", "WalkSelect_default", "RepeatSelect_default", "ZoomIn_default", "ZoomOut_default", "CropFree_default", "GraphStats_default", "SettingsMenu_default", "GraphToolbar_default", "import_mobx_react", "import_jsx_runtime", "LabelChip", "x", "y", "w", "text", "color", "italic", "small", "dimmed", "title", "testId", "onClick", "import_jsx_runtime", "svgStyle", "LabelLayer", "model", "bubbles", "genes", "routes", "walkHighlight", "scaleY", "translateY", "contigThickness", "dimmedBubble", "h", "id", "dimmedRoute", "r", "pin", "x", "w", "text", "EXON_COLOR", "LabelChip", "route", "y", "BUBBLE_KIND_COLORS", "LabelLayer_default", "import_react", "import_canvas2dUtils", "import_mobx", "import_mobx_react", "import_jsx_runtime", "canvasStyle", "TubeMapOverlay", "model", "ref", "tubeMapPicture", "paneWidth", "canvasHeight", "canvas", "picture", "frame", "ctx", "dpr", "width", "height", "drawTubeMap", "TubeMapOverlay_default", "import_mobx_react", "import_jsx_runtime", "svgStyle", "ON_REFERENCE", "CALL_TICK", "UNBACKED_TICK", "DISAGREES", "OFF_REFERENCE", "BAR_PX", "legendBoxStyle", "legendRowStyle", "swatchStyle", "tickSwatchStyle", "TickSwatch", "color", "WalkRowsLegend", "model", "bars", "calls", "row", "call", "kb", "bp", "units", "unit", "readout", "referenceBp", "complete", "delta", "against", "calledReadout", "unbacked", "MIN_TILE_PX", "tileSeparators", "X", "xs", "k", "WalkRowsOverlay", "walkRowBars", "scaleX", "scaleY", "translateX", "translateY", "width", "canvasHeight", "Y", "origin", "reference", "rows", "backboneEnd", "label", "text", "endBp", "y", "fill", "fits", "i", "run", "WalkRowsOverlay_default", "import_colorBits", "import_canvas2dUtils", "import_renderingBackendBase", "Canvas2DRenderer", "width", "height", "batch", "factors", "edgeIndex", "factor", "transform", "clearColor", "ctx", "t", "hl", "color", "items", "groupByPaint", "e", "inRun", "brightenAbgr", "first", "c", "lifted", "nodeId", "run", "s", "p0", "i", "p", "a", "tipX", "tipY", "reach", "paintOf", "groups", "deferred", "l", "item", "weight", "last", "into", "key", "group", "createGraphRenderer", "canvas", "Canvas2DRenderer", "FALLBACK_CELL_SIZE", "meanExtentCellSize", "extentTotal", "count", "rowPitchOf", "boxes", "distinct", "min", "max", "box", "cellSizeFrom", "extentX", "extentY", "x", "resolveCellSize", "given", "getOrCreateCell", "cells", "cx", "cy", "row", "cell", "addToGrid", "cellSize", "minX", "minY", "maxX", "maxY", "entry", "cx0", "cx1", "cy0", "cy1", "queryGrid", "y", "radiusX", "radiusY", "results", "seen", "SpatialIndex", "nodePositions", "nodeId", "segments", "i", "seg", "next", "b", "EdgeSpatialIndex", "graph", "drawPaths", "axis", "deletions", "version", "baseEdgeCurves", "ei", "edge", "fromSegments", "toSegments", "curves", "curveBounds", "numPaths", "padX", "padY", "o", "pathRibbonOffsets", "distanceToSegment", "px", "py", "x1", "y1", "x2", "y2", "dx", "dy", "lenSq", "t", "distanceToCubicBezier", "cx1", "cy1", "cx2", "cy2", "minDist", "samples", "lastX", "lastY", "i", "u", "bx", "by", "distanceToBezierCurve", "c", "distanceToEdgeCurves", "curves", "yToX", "d", "nodeCache", "getSpatialIndex", "nodePositions", "version", "cached", "index", "SpatialIndex", "edgeCache", "getEdgeSpatialIndex", "graph", "drawPaths", "axis", "deletions", "EdgeSpatialIndex", "MIN_NODE_REACH_PX", "findHoveredNode", "graphX", "graphY", "ink", "yToXOf", "reach", "queryReach", "candidates", "hovered", "best", "nodeId", "segmentIdx", "segments", "dist", "findHoveredEdge", "hiddenEdges", "edgeThreshold", "edgeIndex", "edgeIdx", "edge", "fromSegments", "toSegments", "numPaths", "baseCurves", "offset", "pathRibbonOffsets", "translateCurves", "wheelZoomFactor", "e", "px", "notches", "import_jsx_runtime", "tooltipStyle", "wrapperStyle", "canvasAreaStyle", "loadingLayerStyle", "rowLabelStyle", "RowLabels", "model", "rowLabels", "label", "y", "screenY", "legendStackStyle", "LEGEND_INSET_PX", "legendBoxStyle", "pathLegendRowStyle", "pathSwatchStyle", "PathLegend", "pathLegend", "name", "color", "WalkReadout", "h", "c", "delta", "rampStripStyle", "_", "i", "REFERENCE_RAMP_MAX_HUE", "rampEndsStyle", "ReferenceRampLegend", "domain", "formatBp", "nodeLabelStyle", "deletionLabelStyle", "leaderStyle", "Legends", "ref", "el", "observer", "WalkRowsLegend", "GraphSizeLabels", "labels", "leaders", "key", "leader", "arcX", "arcY", "labelX", "labelY", "text", "x", "kind", "HoverTooltips", "hoveredNodeData", "hoveredEdgeData", "ownLocation", "nodeOwnLocation", "hoveredDeletion", "d", "locLabel", "NodeContextMenu", "nodeId", "top", "left", "onClose", "own", "reference", "highlight", "callback", "Info_default", "nodeLaunchMenuItems", "target", "GraphCanvas", "ownChrome", "canvasRef", "canvas", "renderError", "retryRender", "createGraphRenderer", "lastMouseRef", "hasMovedRef", "pendingRef", "contextNode", "setContextNode", "handleWheel", "e", "rect", "wheelZoomFactor", "screenToGraph", "screenX", "getMouseCoord", "nodeAt", "nodePositions", "findHoveredNode", "handleMouseDown", "node", "applyPending", "pending", "findHoveredEdge", "scheduleFrame", "dropPending", "handleMouseMove", "dx", "dy", "handleMouseUp", "handleMouseLeave", "handleContextMenu", "handleClick", "GraphToolbar_default", "TubeMapOverlay_default", "BubbleHalos_default", "GenePins_default", "LabelLayer_default", "BubbleOverlay_default", "WalkRowsOverlay_default", "GraphCanvas_default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as t}from"./chunk-FY3BTKY4.js";var o=t((r,e)=>{e.exports=JBrowseExports["mobx-state-tree"]});export{o as a};
2
+ //# sourceMappingURL=chunk-FCWXYIFC.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["global-externals:@jbrowse/mobx-state-tree"],
4
+ "sourcesContent": ["module.exports = JBrowseExports[\"mobx-state-tree\"];"],
5
+ "mappings": "wCAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAA,EAAO,QAAU,eAAe,iBAAiB",
6
+ "names": ["require_mobx_state_tree", "__commonJSMin", "exports", "module"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as p}from"./chunk-D7XFR2IV.js";import{b as l}from"./chunk-FY3BTKY4.js";var t=l(p(),1),m={RgfaTabixAdapter:"rGFA segments (tabix BED pair)",MinigraphBubbleAdapter:"Minigraph bubbles (tabix BED)"},x={RgfaTabixAdapter:"Path to segments BED (.segs.bed.gz from build_rgfa_tabix.sh; the .links.bed.gz and both .tbi are assumed beside it)",MinigraphBubbleAdapter:"Path to bubbles BED (.bed.gz from gfatools bubble; the .tbi is assumed beside it)"},s=".segs.bed.gz";function r(e){return"uri"in e?e.uri:"localPath"in e?e.localPath:""}function u(e){return r(e).endsWith(s)}function g(e){let i=r(e);if(!u(e))throw new Error(`Expected a segments BED ending in ${s}, got ${i||"a blob"}`);let n=`${i.slice(0,-s.length)}.links.bed.gz`;return"uri"in e?{...e,uri:n}:"localPath"in e?{...e,localPath:n}:e}function c(e,i){return i?{location:i,indexType:(0,t.makeIndexType)(r(i),"CSI","TBI")}:{location:(0,t.makeIndex)(e,".tbi"),indexType:"TBI"}}function h(e,i){return i!==void 0&&r(i).endsWith(".csi")?{location:(0,t.makeIndex)(e,".csi"),indexType:"CSI"}:{location:(0,t.makeIndex)(e,".tbi"),indexType:"TBI"}}function d(e,i){let n=i.trim();return n?{assemblyNameToPanSN:{[e]:n}}:{}}function f({choice:e,loc:i,indexLoc:n,assembly:a,sample:o}){if(e==="MinigraphBubbleAdapter")return{type:"MinigraphBubbleAdapter",bubblesLocation:i,index:c(i,n),...d(a,o)};let b=g(i);return{type:"RgfaTabixAdapter",segmentsLocation:i,segmentsIndex:c(i,n),linksLocation:b,linksIndex:h(b,n),...d(a,o)}}function F(e){let{choice:i,assembly:n,trackId:a,name:o}=e;return{type:i==="RgfaTabixAdapter"?"GraphTrack":"FeatureTrack",trackId:a,name:o,assemblyNames:[n],adapter:f(e),...i==="RgfaTabixAdapter"?{displayDefaults:{showLabels:"none"}}:{}}}export{m as a,x as b,u as c,f as d,F as e};
2
+ //# sourceMappingURL=chunk-JVMMNMQG.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/GraphAddTrackWorkflow/buildTrackConfig.ts"],
4
+ "sourcesContent": ["import { makeIndex, makeIndexType } from '@jbrowse/core/util/tracks'\n\nimport type { FileLocation } from '@jbrowse/core/util'\n\nexport type GraphFileChoice = 'RgfaTabixAdapter' | 'MinigraphBubbleAdapter'\n\nexport const GRAPH_FILE_LABELS: Record<GraphFileChoice, string> = {\n RgfaTabixAdapter: 'rGFA segments (tabix BED pair)',\n MinigraphBubbleAdapter: 'Minigraph bubbles (tabix BED)',\n}\n\nexport const GRAPH_FILE_FIELDS: Record<GraphFileChoice, string> = {\n RgfaTabixAdapter:\n 'Path to segments BED (.segs.bed.gz from build_rgfa_tabix.sh; the .links.bed.gz and both .tbi are assumed beside it)',\n MinigraphBubbleAdapter:\n 'Path to bubbles BED (.bed.gz from gfatools bubble; the .tbi is assumed beside it)',\n}\n\nconst SEGMENTS_SUFFIX = '.segs.bed.gz'\n\nfunction locationName(loc: FileLocation) {\n return 'uri' in loc ? loc.uri : 'localPath' in loc ? loc.localPath : ''\n}\n\nexport function isSegmentsLocation(loc: FileLocation) {\n return locationName(loc).endsWith(SEGMENTS_SUFFIX)\n}\n\nfunction linksLocation(loc: FileLocation) {\n const name = locationName(loc)\n if (!isSegmentsLocation(loc)) {\n throw new Error(\n `Expected a segments BED ending in ${SEGMENTS_SUFFIX}, got ${name || 'a blob'}`,\n )\n }\n const links = `${name.slice(0, -SEGMENTS_SUFFIX.length)}.links.bed.gz`\n return 'uri' in loc\n ? { ...loc, uri: links }\n : 'localPath' in loc\n ? { ...loc, localPath: links }\n : loc\n}\n\nfunction tabixIndex(loc: FileLocation, indexLoc: FileLocation | undefined) {\n return indexLoc\n ? {\n location: indexLoc,\n indexType: makeIndexType(locationName(indexLoc), 'CSI', 'TBI'),\n }\n : { location: makeIndex(loc, '.tbi'), indexType: 'TBI' }\n}\n\n// The links file's index is assumed beside it, of the kind the segments' is.\nfunction siblingIndex(loc: FileLocation, indexLoc: FileLocation | undefined) {\n const csi = indexLoc !== undefined && locationName(indexLoc).endsWith('.csi')\n return csi\n ? { location: makeIndex(loc, '.csi'), indexType: 'CSI' }\n : { location: makeIndex(loc, '.tbi'), indexType: 'TBI' }\n}\n\nfunction panSN(assembly: string, sample: string) {\n const name = sample.trim()\n return name ? { assemblyNameToPanSN: { [assembly]: name } } : {}\n}\n\nexport function buildAdapterConfig({\n choice,\n loc,\n indexLoc,\n assembly,\n sample,\n}: {\n choice: GraphFileChoice\n loc: FileLocation\n indexLoc: FileLocation | undefined\n assembly: string\n sample: string\n}) {\n if (choice === 'MinigraphBubbleAdapter') {\n return {\n type: 'MinigraphBubbleAdapter',\n bubblesLocation: loc,\n index: tabixIndex(loc, indexLoc),\n ...panSN(assembly, sample),\n }\n }\n const links = linksLocation(loc)\n return {\n type: 'RgfaTabixAdapter',\n segmentsLocation: loc,\n segmentsIndex: tabixIndex(loc, indexLoc),\n linksLocation: links,\n linksIndex: siblingIndex(links, indexLoc),\n ...panSN(assembly, sample),\n }\n}\n\nexport function buildTrackConfig(args: {\n choice: GraphFileChoice\n loc: FileLocation\n indexLoc: FileLocation | undefined\n assembly: string\n sample: string\n trackId: string\n name: string\n}) {\n const { choice, assembly, trackId, name } = args\n return {\n type: choice === 'RgfaTabixAdapter' ? 'GraphTrack' : 'FeatureTrack',\n trackId,\n name,\n assemblyNames: [assembly],\n adapter: buildAdapterConfig(args),\n ...(choice === 'RgfaTabixAdapter'\n ? { displayDefaults: { showLabels: 'none' } }\n : {}),\n }\n}\n"],
5
+ "mapp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,SAASQ,EAAmB,CACjC,OAAAC,EACA,IAAAZ,EACA,SAAAM,EACA,SAAAG,EACA,OAAAC,CACF,EAMG,CACD,GAAIE,IAAW,yBACb,MAAO,CACL,KAAM,yBACN,gBAAiBZ,EACjB,MAAOK,EAAWL,EAAKM,CAAQ,EAC/B,GAAGE,EAAMC,EAAUC,CAAM,CAC3B,EAEF,IAAMN,EAAQF,EAAcF,CAAG,EAC/B,MAAO,CACL,KAAM,mBACN,iBAAkBA,EAClB,cAAeK,EAAWL,EAAKM,CAAQ,EACvC,cAAeF,EACf,WAAYG,EAAaH,EAAOE,CAAQ,EACxC,GAAGE,EAAMC,EAAUC,CAAM,CAC3B,CACF,CAEO,SAASG,EAAiBC,EAQ9B,CACD,GAAM,CAAE,OAAAF,EAAQ,SAAAH,EAAU,QAAAM,EAAS,KAAAZ,CAAK,EAAIW,EAC5C,MAAO,CACL,KAAMF,IAAW,mBAAqB,aAAe,eACrD,QAAAG,EACA,KAAAZ,EACA,cAAe,CAACM,CAAQ,EACxB,QAASE,EAAmBG,CAAI,EAChC,GAAIF,IAAW,mBACX,CAAE,gBAAiB,CAAE,WAAY,MAAO,CAAE,EAC1C,CAAC,CACP,CACF",
6
+ "names": ["import_tracks", "GRAPH_FILE_LABELS", "GRAPH_FILE_FIELDS", "SEGMENTS_SUFFIX", "locationName", "loc", "isSegmentsLocation", "linksLocation", "name", "links", "tabixIndex", "indexLoc", "siblingIndex", "panSN", "assembly", "sample", "buildAdapterConfig", "choice", "buildTrackConfig", "args", "trackId"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as l}from"./chunk-F4C3BEPV.js";import{a as g}from"./chunk-FY3BTKY4.js";var X=g((Ae,N)=>{N.exports=JBrowseExports["tss-react/mui"]});function j(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function b(e,t=5){let r=e.nodes.reduce((a,s)=>a+s.length,0)/1e6,o=Math.max(e.nodes.length*40,500);return{nodeLengthPerMegabase:r>0?o/r:1e4,minimumNodeLength:Math.max(5,t),edgeLength:5,nodeSegmentLength:20}}var d={power:1,effect:1};function E(e){return e.power===1&&e.effect===1}function x(e,t){let n=e.nodes.length,r=e.nodes.reduce((s,i)=>s+i.length,0),o=n>0?r/n:0,a=n>0?Math.max(n*40,500)/n:40;return s=>{if(o<=0)return a;let i=(s/o)**t.power;return Math.max(a*((i-1)*t.effect+1),5)}}var u=1e3,L={law:d,minNodeLength:0};function q(e,t=L){let{law:n,minNodeLength:r}=t,o=b(e,r);if(E(n))return{nodes:e.nodes,opts:o};let a=x(e,n);return{nodes:e.nodes.map(s=>({...s,length:Math.round(a(s.length)*u)})),opts:{...o,nodeLengthPerMegabase:1e6/u,minimumNodeLength:5}}}var m=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:d,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:d,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:d,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],Y=m.map(e=>e.value);function Q(e){let t=m.find(n=>n.value===e);return{law:t?.law??d,minNodeLength:(t?.minNodeFactor??0)*40}}var A=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node Length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],ee=A.map(e=>e.value);function te(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}function re(e){return e.stable!==void 0}function G(e){return e.stable?.rank===0}function oe(e){return e.stable!==void 0&&e.stable.rank>0}function ae(e){return e.nodes.filter(G)}function se(e){let t={};for(let n of e)t[n.id]=[{x:n.stable.start,y:0},{x:n.stable.start+n.length,y:0}];return t}function ie(e,t){let n=0,r=e.length;for(;n<r;){let o=n+r>>1;e[o].stable.start<t?n=o+1:r=o}return n}function S(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.stable.start),n=Math.max(n,r.stable.start+r.length);return n-t}function de(e,t){return t&&t.end>t.start?t.end-t.start:S(e)}var M=/:(\d+)-\d+$/;function p(e){let t=M.exec(e);return t?{name:e.slice(0,t.index),start:+t[1]}:{name:e,start:0}}function le(e,t){let n=[],r=new Map;for(let o of e){let a=l(o.name),s=o.start;for(let i of o.steps){let c={path:o.name,sample:a,start:s,strand:i.strand},h=r.get(i.id);h?h.push(c):r.set(i.id,[c]),s+=t(i.id)}n.push({name:o.name,sample:a,start:o.start,length:s-o.start})}return{anchorPaths:n,pathVisits:r}}function w(e,t){return e.find(r=>r.sample===t||r.name===t)??e[0]}var y=1;function P(e,t,n){let r=e;if(t&&t.length>0){let o=t.find(a=>a.path===n)??t[0];r={...e,stable:{refName:o.path,start:o.start,rank:o.path===n?0:y,strand:o.strand},samples:[...new Set(t.map(a=>a.sample))].sort()}}return r}function R(e,t){let{anchorPaths:n,pathVisits:r}=e,o=n&&r?w(n,t):void 0;return o&&r?{...e,nodes:e.nodes.map(a=>P(a,r.get(a.name),o.name)),anchoredBy:"paths",referencePath:o.name}:e}function ue(e,t){return e.anchoredBy==="tags"?e:R(e,t)}function Ne(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Math.abs(t%360)}function T(e,t){return e*360/t}var D=.7,H=.5,I=16;function ge(e){return e>0&&e<=I}function B(e,t){return`hsl(${T(e,t)}, ${D*100}%, ${H*100}%)`}function v(e){let t=p(e).name.split("#");return[t[0],t.slice(0,2).join("#"),t.join("#")]}function C(e){return String(e).replace(/\B(?=(\d{3})+$)/g,",")}function F(e,t){let{start:n}=p(e);return t.map(r=>`${r} @${C(n)}`)}function be(e){let t=e.map(a=>v(a.name)),n=[0,1,2].flatMap(a=>[e.map((s,i)=>t[i][a]),e.map((s,i)=>F(s.name,t[i])[a])]),o=n.find(a=>new Set(a).size===e.length)??n.at(-1);return e.map((a,s)=>({name:a.name,label:o[s],color:B(s,e.length)}))}var U=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],xe=U.map(e=>e.value),k=.3,f=3;function W(e){let t=0,n=0;for(let r of e.nodes)t+=r.depth*r.length,n+=r.length;return n>0?t/n:0}function V(e,t){return!(t>0)||!(e.depth>0)?1:Math.min(f,Math.max(k,Math.sqrt(e.depth/t)))}function $(e,t,n,r){return t*(n==="depth"?V(e,r):1)}function K(e,t){return e*(t==="depth"?f:1)}function Le(e,t,n,r){let o=e?W(e):0;return{maxHalfWidthPx:K(n,r)/2,halfWidthPx:a=>{let s=t?.get(a);return s?$(s,n,r,o)/2:n/2}}}export{re as a,G as b,oe as c,ae as d,se as e,ie as f,S as g,de as h,j as i,q as j,m as k,Y as l,Q as m,A as n,ee as o,te as p,p as q,le as r,R as s,ue as t,Ne as u,T as v,D as w,H as x,I as y,ge as z,B as A,be as B,U as C,xe as D,W as E,$ as F,Le as G,X as H};
2
+ //# sourceMappingURL=chunk-NBDRTXH2.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["global-externals:tss-react/mui", "../../src/GraphGenomeView/layout/drawnScale.ts", "../../src/GraphGenomeView/bubbleSpreads.ts", "../../src/GraphGenomeView/colorSchemes.ts", "../../src/GraphGenomeView/anchoredNodes.ts", "../../src/GraphGenomeView/pathAnchoring.ts", "../../src/GraphGenomeView/pathColors.ts", "../../src/GraphGenomeView/nodeWidths.ts"],
4
+ "sourcesContent": ["module.exports = JBrowseExports[\"tss-react/mui\"];", "import type { Graph, GraphNode } from '../types'\n\nexport interface BandageScaleOpts {\n nodeLengthPerMegabase: number\n minimumNodeLength: number\n nodeSegmentLength: number\n edgeLength: number\n}\n\n// Node drawn length, in FMMM units, as a function of bp. Used both by the layouts\n// that run here and by the options handed to the WASM engine, so a graph is drawn\n// at the same scale whichever one draws it. Bandage's own auto rule\n// (`AssemblyGraph::determineGraphInfo`):\n// pick units-per-megabase so the *mean* drawn node length lands on 40, with a\n// floor on total drawn length so a small graph doesn't collapse to a speck.\n//\n// This has to be derived per graph, not fixed. The scale that suits a bacterial\n// assembly's 10-100 kb contigs is wrong by orders of magnitude for a minigraph\n// pangenome window, whose nodes run 300 bp to a few kb: a fixed 1000 units/Mbp\n// makes every node shorter than the edges between them and the graph reads as\n// beads on a string, while 1 unit/bp makes each node a long sweeping curve and\n// the graph sprawls. For the 53-node E. coli window this lands near 35,000.\n//\n// It matters most at the small end. The WASM wrapper's own default of 1000\n// units/Mbp puts *every* node in a 400 bp pggb window below minimumNodeLength,\n// so all 31 clamp to the floor and a 1 bp SNP allele draws the same size as the\n// 164 bp backbone segment beside it \u2014 which is what made that figure read as a\n// chain of same-sized two-node bubbles. Bandage draws the same file with a 75:1\n// length ratio, the SNP alleles as specks.\n//\n// The remaining three are upstream Bandage's shipped defaults\n// (`program/settings.cpp`), which the WASM wrapper's own header does not match \u2014\n// it defaults all of them to 1.0, so they have to be passed explicitly.\nconst MEAN_NODE_LENGTH = 40\nconst MIN_TOTAL_GRAPH_LENGTH = 500\n\n// Bandage's own floor on a node's drawn length. Right for an assembly graph,\n// whose nodes are kb to Mb, and the reason a variation graph draws as a rope:\n// see BUBBLE_SPREADS, which is how a view asks for more.\nconst BANDAGE_MINIMUM_NODE_LENGTH = 5\n\n// The engine's own rule (`settings.h`, `getDrawnNodeLength`), so a seed computed\n// here spans exactly the chain the engine builds from the same numbers.\nexport function drawnNodeLength(opts: BandageScaleOpts, length: number) {\n return Math.max(\n (opts.nodeLengthPerMegabase * length) / 1_000_000,\n opts.minimumNodeLength,\n )\n}\n\nexport function bandageAutoScale(\n graph: Graph,\n // Floor on a node's drawn length, in the same FMMM units as the scale below.\n // Anything at or under Bandage's own floor leaves the drawing exactly as it\n // was, which is what keeps `'auto'` byte-identical to the shipped behaviour.\n minNodeLength = BANDAGE_MINIMUM_NODE_LENGTH,\n): BandageScaleOpts {\n const totalLength = graph.nodes.reduce((sum, n) => sum + n.length, 0)\n const megabases = totalLength / 1_000_000\n const target = Math.max(\n graph.nodes.length * MEAN_NODE_LENGTH,\n MIN_TOTAL_GRAPH_LENGTH,\n )\n return {\n nodeLengthPerMegabase: megabases > 0 ? target / megabases : 10_000,\n minimumNodeLength: Math.max(BANDAGE_MINIMUM_NODE_LENGTH, minNodeLength),\n edgeLength: 5,\n nodeSegmentLength: 20,\n }\n}\n\n// How a node's bp becomes its drawn length, as a power law against the graph's\n// own mean. The idiom is Bandage's, moved onto the axis a pangenome needs it on:\n// upstream derives a node's *width* from its depth exactly this way\n// (`graph/graphicsitemnode.cpp`, `getNodeWidth`), at a `depthPower` of 0.5 and a\n// `depthEffectOnWidth` of 0.5, because depth in an assembly graph spans orders\n// of magnitude and drawing it linearly is unreadable.\n//\n// drawn = meanDrawn * (((bp / meanBp) ^ power - 1) * effect + 1)\n//\n// Length in a *variation* graph spans those same orders of magnitude \u2014 a 1 bp\n// allele beside a 16 kb backbone segment \u2014 and upstream still maps it linearly,\n// because its own nodes are assembled contigs where that range does not arise.\n// That linear map is what draws a pggb window as one rope: past the small end\n// every allele falls under `minimumNodeLength` and clamps, so both arms of a\n// bubble land inside one node thickness of each other.\n//\n// power 1 with effect 1 is exactly proportional, so Bandage's shipped behaviour\n// is a point in this family rather than a mechanism sitting beside it. See\n// BUBBLE_SPREADS for the points a view can ask for.\nexport interface DrawnLengthLaw {\n // exponent applied to a node's length relative to the graph's mean\n power: number\n // how much of that relative length survives. 0 draws every node at the mean,\n // 1 applies the power law undamped.\n effect: number\n}\n\nexport const PROPORTIONAL_LENGTH: DrawnLengthLaw = { power: 1, effect: 1 }\n\nexport function isProportional(law: DrawnLengthLaw) {\n return law.power === 1 && law.effect === 1\n}\n\n// Drawn length in FMMM units for one node of `graph`, under `law`.\nexport function drawnLengthFor(graph: Graph, law: DrawnLengthLaw) {\n const count = graph.nodes.length\n const totalLength = graph.nodes.reduce((sum, n) => sum + n.length, 0)\n const meanBp = count > 0 ? totalLength / count : 0\n // The mean drawn length `bandageAutoScale` already targets, small-graph floor\n // included, so a compressed drawing comes out the same overall size as the\n // proportional one it replaces. That is the property a per-node floor does\n // not have, and the reason raising one is unusable at scale: it lifts the\n // hundreds of non-branching chain nodes along with the alleles, which on a\n // 521-node cut inflates the drawing past what zoom-to-fit can frame.\n const meanDrawn =\n count > 0\n ? Math.max(count * MEAN_NODE_LENGTH, MIN_TOTAL_GRAPH_LENGTH) / count\n : MEAN_NODE_LENGTH\n return (bp: number) => {\n if (meanBp <= 0) {\n return meanDrawn\n }\n const relative = (bp / meanBp) ** law.power\n return Math.max(\n meanDrawn * ((relative - 1) * law.effect + 1),\n BANDAGE_MINIMUM_NODE_LENGTH,\n )\n }\n}\n\n// The engine's own length rule is linear with a floor and takes two numbers\n// (`settings.h`, `getDrawnNodeLength`), so a non-linear law cannot be expressed\n// through them. It can be expressed in the lengths themselves: node length\n// crosses the RPC boundary only to become a drawn length \u2014 `getLength()` has\n// exactly two call sites upstream, both inside that rule \u2014 so handing the engine\n// pre-transformed lengths and a 1:1 scale draws the law without touching the\n// WASM build. Scaled by this factor first because the binding reads a node's\n// length as an `unsigned`, and rounding drawn units straight to integers would\n// quantise the small end where the whole point is legibility.\nconst LAYOUT_LENGTH_PRECISION = 1000\n\n// How a view asks for its node lengths: a law, plus Bandage's own per-node\n// floor. Orthogonal on purpose \u2014 see BUBBLE_SPREADS for which does what.\nexport interface NodeLengthSpread {\n law: DrawnLengthLaw\n // in the same FMMM units as the drawn lengths. At or under Bandage's own\n // floor this leaves the drawing exactly as it was.\n minNodeLength: number\n}\n\nexport const PROPORTIONAL_SPREAD: NodeLengthSpread = {\n law: PROPORTIONAL_LENGTH,\n minNodeLength: 0,\n}\n\nexport interface LayoutScaling {\n // the nodes to hand the engine. Under any law but the proportional one their\n // `length` is a scaled drawn length rather than a bp count, which is why this\n // is a separate array and never the graph's own nodes.\n nodes: GraphNode[]\n opts: BandageScaleOpts\n}\n\nexport function layoutScaling(\n graph: Graph,\n spread: NodeLengthSpread = PROPORTIONAL_SPREAD,\n): LayoutScaling {\n const { law, minNodeLength } = spread\n const opts = bandageAutoScale(graph, minNodeLength)\n // The proportional law is what every committed force figure was drawn\n // against, and it is already exactly what `bandageAutoScale` expresses, so it\n // keeps the untransformed path rather than round-tripping through a rounding\n // step FMMM would be free to amplify. Every floor-based spread comes through\n // here too, unchanged.\n if (isProportional(law)) {\n return { nodes: graph.nodes, opts }\n }\n const drawn = drawnLengthFor(graph, law)\n return {\n nodes: graph.nodes.map(node => ({\n ...node,\n length: Math.round(drawn(node.length) * LAYOUT_LENGTH_PRECISION),\n })),\n opts: {\n ...opts,\n nodeLengthPerMegabase: 1_000_000 / LAYOUT_LENGTH_PRECISION,\n // Bandage's own floor only. A law and a raised floor are alternatives\n // rather than a stack: the law has already lifted the small end, and a\n // floor on top of it would flatten exactly what it just spread.\n minimumNodeLength: BANDAGE_MINIMUM_NODE_LENGTH,\n },\n }\n}\n\n// The mean drawn node length `bandageAutoScale` targets, exported so\n// BUBBLE_SPREADS can state its laws against it rather than against unanchored\n// constants.\nexport { MEAN_NODE_LENGTH }\n", "import { MEAN_NODE_LENGTH, PROPORTIONAL_LENGTH } from './layout/drawnScale'\n\nimport type { NodeLengthSpread } from './layout/drawnScale'\n\n// How far apart the force layout draws the two arms of a bubble, as the law\n// turning a node's bp into its drawn length. One table drives the persisted\n// enum, the dropdown and the value handed to the engine, the same way\n// LAYOUT_MODES and COLOR_SCHEMES do.\n//\n// Why this needs to be a control rather than a better default: the drawn-length\n// law is the one thing standing between a variation graph and a legible force\n// layout, and compressing it costs the property that node length is proportional\n// to bp. Bandage maps length linearly, which suits an assembly graph whose nodes\n// are kb to Mb. In a pangenome an allele is 1-50 bp against a backbone segment\n// of several kb, so on that map every alt clamps to the engine's 5-unit floor,\n// both arms of a bubble land inside one node thickness of each other, and FMMM\n// has nothing to spread \u2014 zoom-to-fit then delivers a single rope with the\n// variation invisible inside it. Compressing the law opens the bubbles and\n// flattens the length ratio, and which of those a reader wants depends on the\n// figure, so the view asks rather than assumes.\n//\n// The compression is Bandage's own, taken off the axis upstream uses it on: it\n// draws node *width* from depth as a power law against the mean, at power 0.5\n// and effect 0.5, for the same reason. 'open' is those two numbers. See\n// DrawnLengthLaw.\n//\n// Measured on an odgi extract of GRCh38#0#chrM:8,200-8,400 from HPRC release 2's\n// chrM pggb graph (61 nodes, 84 edges, 234 haplotype paths), fitted to a 900x560\n// pane: proportional is one squiggle with a single knot in it, and the bubbles\n// come apart into legible lenses once the law compresses.\n//\n// The floor and the law are different instruments and both are kept, because\n// neither does the other's job:\n//\n// - a FLOOR lifts the small end and leaves everything above it proportional. It\n// is what a figure wants when one long node has to stay long \u2014 the ribbons in\n// `pangenome/pggb_haplotype_paths` separate along a 1.2 kb deletion arc, and\n// shortening that arc towards the mean piles them up. Its cost is that it is a\n// per-node minimum, so it lifts a graph's non-branching chain nodes along with\n// its alleles and the drawing inflates with node count: on the 521-node pggb\n// cut in `pangenome/graph_resolution` it reached ~52,000 units and a 1.4% fit,\n// which is why that figure could once afford a spread on its 7-node half only.\n// - the LAW compresses both ends towards the mean, so the drawing stays the size\n// it already was whatever the node count, and a cut spanning 6 bp to 16 kb\n// fits one pane. Its cost is the top end: a node that has to read as long no\n// longer does.\n//\n// So a figure about bubble shape at scale takes 'compress', and a figure about\n// what is drawn along one long edge takes 'open'.\n//\n// 'auto' is the proportional map, unchanged, so every existing figure and the\n// `bandageAutoScale` length-proportionality test are untouched by this existing.\nexport const BUBBLE_SPREADS = [\n {\n value: 'auto',\n label: 'Proportional',\n description:\n \"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.\",\n law: PROPORTIONAL_LENGTH,\n minNodeFactor: 0,\n },\n {\n value: 'open',\n label: 'Open bubbles',\n description:\n 'Give every allele a drawn length, so a bubble reads as two arms rather than a knot.',\n law: PROPORTIONAL_LENGTH,\n minNodeFactor: 2.5,\n },\n {\n value: 'wide',\n label: 'Wide bubbles',\n description:\n 'As open, spread further. Best on a window of a dozen bubbles.',\n law: PROPORTIONAL_LENGTH,\n minNodeFactor: 10,\n },\n {\n value: 'compress',\n label: 'Compress lengths',\n description:\n 'Pull the longest and shortest nodes towards the graph\\u2019s mean, so a cut spanning kb and bp fits one pane.',\n law: { power: 0.5, effect: 0.5 },\n minNodeFactor: 0,\n },\n] as const\n\nexport type BubbleSpread = (typeof BUBBLE_SPREADS)[number]['value']\n\nexport const BUBBLE_SPREAD_VALUES = BUBBLE_SPREADS.map(s => s.value)\n\n// The law and floor behind a spread, resolved so the model has one place that\n// knows how a spread becomes numbers. An unknown value draws proportionally\n// rather than throwing, which is what a session persisted by a newer build\n// degrades to.\nexport function spreadFor(spread: string): NodeLengthSpread {\n const entry = BUBBLE_SPREADS.find(s => s.value === spread)\n return {\n law: entry?.law ?? PROPORTIONAL_LENGTH,\n minNodeLength: (entry?.minNodeFactor ?? 0) * MEAN_NODE_LENGTH,\n }\n}\n", "import type { Graph } from './types'\n\n// One table drives the persisted enum and both colour dropdowns, the same way\n// LAYOUT_MODES drives the layout enum and its menu. The values and their labels\n// used to live in two lists in two directories, so adding a scheme meant editing\n// both and a mismatch showed up as a dropdown entry that selected nothing.\n//\n// Kept out of the components directory because the model needs it too.\nexport const COLOR_SCHEMES = [\n // Mirrors `layoutModes`' 'auto': a value the model resolves rather than a\n // colour of its own. It exists because 'uniform' was the default, so a\n // launched graph opened flat grey and both tutorials spent a step saying \"now\n // pick a colour\" \u2014 one figure literally drives that click. A graph with\n // reference coordinates resolves to 'reference-position', which is the one\n // ramp a linear track beside it can be painted with too; a graph with none\n // keeps 'uniform', because there the ramp would be a hue nothing earned.\n //\n // Resolve through `effectiveColorScheme`; the dropdown reads the raw prop, so\n // \"Auto\" stays selectable and visible as what it is.\n { value: 'auto', label: 'Auto' },\n { value: 'uniform', label: 'Uniform' },\n { value: 'random', label: 'Random' },\n { value: 'rainbow', label: 'Rainbow' },\n { value: 'depth', label: 'Depth' },\n { value: 'node-length', label: 'Node Length' },\n { value: 'stable-rank', label: 'Stable rank' },\n { value: 'reference-position', label: 'Reference position' },\n { value: 'grey', label: 'Grey' },\n] as const\n\nexport type ColorScheme = (typeof COLOR_SCHEMES)[number]['value']\n\n// What the renderer can actually paint with: every scheme except the one that\n// stands for \"work it out\". Stated as its own type so `getNodeColor`'s switch\n// has no 'auto' arm to forget.\nexport type ResolvedColorScheme = Exclude<ColorScheme, 'auto'>\n\nexport const COLOR_SCHEME_VALUES = COLOR_SCHEMES.map(s => s.value)\n\n// 'auto' asks the GRAPH, not the layout: a hue along the reference means\n// something whenever the segments have reference coordinates, force-directed\n// drawings included.\nexport function resolveColorScheme(\n scheme: ColorScheme,\n graph: Graph | undefined,\n): ResolvedColorScheme {\n return scheme !== 'auto'\n ? scheme\n : graph?.anchoredBy\n ? 'reference-position'\n : 'uniform'\n}\n", "import type { Graph, GraphNode, NodeSegment } from './types'\nimport type { StableCoordinate } from '../gfa-core/index'\n\n// A node whose stable coordinate is known to be present. rGFA states SN/SO/SR\n// on every segment and a path walk derives the same for every segment a path\n// visits (pathAnchoring.ts), so the anchored layouts and the allele projection\n// all work with nodes whose `stable` is a fact rather than an optional \u2014\n// narrowing once here keeps them from asserting it at every use.\nexport type AnchoredNode = GraphNode & { stable: StableCoordinate }\n\n// Stable rank: 0 is the reference backbone, higher ranks are the sequence that\n// diverges from it. rGFA counts those up in build order; a path-derived graph\n// has only the one distinction its paths support, on the reference or off it.\nexport const REFERENCE_RANK = 0\n\nexport function isAnchored(node: GraphNode): node is AnchoredNode {\n return node.stable !== undefined\n}\n\n// Narrows to AnchoredNode so `filter` yields nodes whose coordinate is a fact.\n// Only use it on nodes that may be unanchored: negating a type predicate on an\n// AnchoredNode narrows the other branch to `never`, which is not what \"off the\n// backbone\" means. Where a node is already anchored, compare the rank directly.\nexport function isBackbone(node: GraphNode): node is AnchoredNode {\n return node.stable?.rank === REFERENCE_RANK\n}\n\n// Anchored and above rank 0: sequence that diverges from the reference. Not\n// simply `!isBackbone`, which would also admit nodes carrying no coordinate.\nexport function isOffReference(node: GraphNode): node is AnchoredNode {\n return node.stable !== undefined && node.stable.rank > REFERENCE_RANK\n}\n\nexport function backboneNodes(graph: Graph) {\n return graph.nodes.filter(isBackbone)\n}\n\n// The backbone on row 0 at its declared offsets: the x axis of every layout\n// whose x is reference bp.\nexport function backbonePositions(backbone: AnchoredNode[]) {\n const positions: Record<string, NodeSegment[]> = {}\n for (const node of backbone) {\n positions[node.id] = [\n { x: node.stable.start, y: 0 },\n { x: node.stable.start + node.length, y: 0 },\n ]\n }\n return positions\n}\n\n// Index of the first node starting at or after `bp`, in a list sorted by start.\nexport function firstNodeAtOrAfter(nodes: AnchoredNode[], bp: number) {\n let lo = 0\n let hi = nodes.length\n while (lo < hi) {\n const mid = (lo + hi) >> 1\n if (nodes[mid]!.stable.start < bp) {\n lo = mid + 1\n } else {\n hi = mid\n }\n }\n return lo\n}\n\n// bp the backbone covers in this subgraph. Both anchored layouts scale their row\n// spacing and their minimum drawn allele length off it.\n//\n// A fold rather than Math.max(...starts): the subgraph path is capped at 100 kb\n// but a whole-file GFA import is not, and spreading a backbone of more than\n// ~130k segments into an argument list throws RangeError.\nexport function backboneSpan(backbone: AnchoredNode[]) {\n let min = Infinity\n let max = -Infinity\n for (const node of backbone) {\n min = Math.min(min, node.stable.start)\n max = Math.max(max, node.stable.start + node.length)\n }\n return max - min\n}\n\n// The reference interval the drawing is scaled against: the region the cut was\n// made for, when there is one.\n//\n// Not the same as the backbone's own extent, and the difference is not small. A\n// hop reaches the far anchor of a long-range allele, and that anchor is a rank-0\n// segment: in the E. coli pggb graph a 75 bp CFT073 segment bridges K12:997,574\n// and K12:1,004,667, so a 484 bp window's backbone measured 7,395 bp. Everything\n// scaled off that span went with it \u2014 rows 15x too far apart, and an off-\n// reference floor of 111 bp inside a 484 bp window.\n//\n// A whole-file import has no region, and there the measured extent is the only\n// answer available.\nexport function referenceSpan(\n backbone: AnchoredNode[],\n region?: { start: number; end: number },\n) {\n return region && region.end > region.start\n ? region.end - region.start\n : backboneSpan(backbone)\n}\n", "import { REFERENCE_RANK } from './anchoredNodes'\nimport { panSNSample } from '../pansn'\n\nimport type { Graph, GraphNode, PathOrigin, PathVisit } from './types'\n\n// Reference coordinates for a GFA that tags none of its segments with one.\n//\n// rGFA writes the fact per segment (SN/SO/SR). A pggb / odgi / Minigraph-Cactus\n// graph writes the same fact once per path and leaves the arithmetic to the\n// reader: walking a path's steps in order, accumulating segment lengths,\n// assigns every segment that path visits an interval on the path's own\n// sequence. Same information, different encoding \u2014 so a general GFA is not a\n// degraded rGFA, and the anchored layouts work on it once the walk is done.\n//\n// It carries one thing rGFA cannot: a segment's *carriage*, the set of\n// assemblies that actually traverse it. rGFA's SR is build order, so there the\n// most a segment can say is which assembly first contributed it.\n\n// `odgi extract` names an extracted path for the interval it covers on its own\n// sequence: `K12#1#chr:1004500-1004961`. That suffix is the only place a cut\n// subgraph states where in the genome it sits, so it is split off here rather\n// than carried around as part of the name \u2014 no assembly has a sequence called\n// `K12#1#chr:1004500-1004961`, and PanSN parsing of it yields a contig no\n// linear view can open.\n//\n// Anchored on the digits rather than on a trailing colon, because a stable name\n// may legitimately contain one (the same hazard gfaParser's tag splitting has).\nconst RANGE_SUFFIX = /:(\\d+)-\\d+$/\n\nexport function pathOrigin(pathName: string) {\n const match = RANGE_SUFFIX.exec(pathName)\n return match\n ? { name: pathName.slice(0, match.index), start: +match[1]! }\n : { name: pathName, start: 0 }\n}\n\nexport interface PathSteps {\n name: string\n start: number\n steps: { id: string; strand: '+' | '-' }[]\n}\n\n// The single walk. Every segment visit lands in `pathVisits` at the bp its own\n// path reaches it at; `anchorPaths` is what the walk learned about the paths\n// themselves, which is what a reference-path picker lists.\nexport function surveyPaths(\n paths: PathSteps[],\n lengthOf: (segmentId: string) => number,\n) {\n const anchorPaths: PathOrigin[] = []\n const pathVisits = new Map<string, PathVisit[]>()\n for (const path of paths) {\n const sample = panSNSample(path.name)\n let pos = path.start\n for (const step of path.steps) {\n const visit = {\n path: path.name,\n sample,\n start: pos,\n strand: step.strand,\n }\n const existing = pathVisits.get(step.id)\n if (existing) {\n existing.push(visit)\n } else {\n pathVisits.set(step.id, [visit])\n }\n pos += lengthOf(step.id)\n }\n anchorPaths.push({\n name: path.name,\n sample,\n start: path.start,\n length: pos - path.start,\n })\n }\n return { anchorPaths, pathVisits }\n}\n\n// Which path x is drawn on. This is a choice, not a fact: a general GFA's path\n// names are arbitrary and nothing in the file marks one of them as the\n// reference, so a preference is matched against a path's PanSN sample name (the\n// assembly a subgraph was cut against, which is how the launch path knows) and\n// then against its full name. With no preference the first path in the file\n// wins, which is where pggb and odgi leave the reference.\nexport function chooseReferencePath(\n anchorPaths: PathOrigin[],\n preferred: string | undefined,\n) {\n const named = anchorPaths.find(\n p => p.sample === preferred || p.name === preferred,\n )\n return named ?? anchorPaths[0]\n}\n\n// Rank on a path-derived graph is the one distinction the paths support: on the\n// reference path or off it. rGFA's higher ranks are minigraph's build order,\n// which a path GFA has no equivalent of, so drawing more rows than this would\n// be drawing structure the file does not state.\nconst OFF_REFERENCE_RANK = 1\n\n// A segment the reference path visits sits on the backbone at the offset that\n// visit reaches it. One it never visits is an alternate allele, placed on the\n// coordinates of the first path that does carry it \u2014 the same asymmetry rGFA\n// has, where a rank>0 segment's SO is an offset on the assembly that\n// contributed the sequence rather than on the reference.\n//\n// **First visit wins** when a path reaches the same segment more than once, and\n// collapsed repeats make that real rather than hypothetical: pggb folds the\n// E. coli rRNA operons into shared segments, so every strain's path walks them\n// twice (`odgi depth` reaches 10 over a five-strain graph at chr:4,167,000 and\n// chr:3,942,000). A node draws as one tube at one x, so the alternative to\n// picking a copy is one tube spanning both, claiming reference the segment does\n// not occupy. The repeat stays visible as depth: such a node's traversal count\n// is a multiple of the path count.\nfunction anchorNode(\n node: GraphNode,\n visits: PathVisit[] | undefined,\n reference: string,\n): GraphNode {\n let anchored = node\n if (visits && visits.length > 0) {\n const anchor = visits.find(v => v.path === reference) ?? visits[0]!\n anchored = {\n ...node,\n stable: {\n refName: anchor.path,\n start: anchor.start,\n rank: anchor.path === reference ? REFERENCE_RANK : OFF_REFERENCE_RANK,\n strand: anchor.strand,\n },\n samples: [...new Set(visits.map(v => v.sample))].sort(),\n }\n }\n return anchored\n}\n\n// Re-runnable against a different reference path at no parsing cost, which is\n// what the picker needs: the walk is already recorded in `pathVisits`, and only\n// which path counts as rank 0 changes.\nexport function anchorFromPaths(graph: Graph, preferred: string | undefined) {\n const { anchorPaths, pathVisits } = graph\n const reference =\n anchorPaths && pathVisits\n ? chooseReferencePath(anchorPaths, preferred)\n : undefined\n return reference && pathVisits\n ? ({\n ...graph,\n nodes: graph.nodes.map(node =>\n anchorNode(node, pathVisits.get(node.name), reference.name),\n ),\n anchoredBy: 'paths',\n referencePath: reference.name,\n } satisfies Graph)\n : graph\n}\n\n// rGFA states coordinates on every segment, so only a graph that states none\n// has to derive them. A GFA with neither tags nor paths comes back untouched\n// and falls through to the force layout, which is the honest answer for it.\nexport function anchorGraph(graph: Graph, preferred: string | undefined) {\n return graph.anchoredBy === 'tags' ? graph : anchorFromPaths(graph, preferred)\n}\n", "import { pathOrigin } from './pathAnchoring'\n\nimport type { GraphPath } from './types'\n\n// Deterministic colour from a string (djb2-style hash to an HSL hue). Fine for\n// the `random` node scheme, where a collision between two of thousands of nodes\n// means nothing. NOT what the path ribbons use: see pathHueAt.\nexport function nameHue(name: string) {\n let hash = 0\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash)\n }\n return Math.abs(hash % 360)\n}\n\n// Ribbon hues are spread evenly over the wheel by position in the path list,\n// not hashed from the path name. A hash draws from the wheel at random, and at\n// five paths two of them landing on the same hue is common rather than\n// unlucky: `Sakai#1#chr:1983339-1983535` and `NCTC86#1#chr:1709109-1710286`\n// hash 26 degrees apart, which is two purples and a legend that cannot be read\n// off the drawing. Evenly spaced, the worst case is the best available.\n//\n// The cost is that a path's colour depends on how many paths there are, so it\n// moves when the cut changes. That is what the legend is for, and it is the\n// same trade the Bandage demo this was ported from made.\nexport function pathHueAt(index: number, count: number) {\n return (index * 360) / count\n}\n\nexport const PATH_SATURATION = 0.7\nexport const PATH_LIGHTNESS = 0.5\n\n// Past this many paths a graph cannot be drawn per path at all, and the WHOLE\n// of `drawPaths` goes off with it: the node stripes, the edge ribbons and the\n// key naming them.\n//\n// One number for all three because they are one statement, and they used to\n// disagree. Only the stripes were capped. So a Minigraph-Cactus cut, which\n// writes one W record per haplotype and walks every backbone link with all of\n// them, drew: no stripes at all, a key hundreds of rows tall, and one bezier\n// stroke per path per edge \u2014 measured at 99,800 strokes and 64 ms of geometry\n// for 200 paths over 499 links, against 2,495 strokes for the five-path pggb\n// cut the figures use. Every one of those is its own `beginPath`/`stroke` on\n// the Canvas2D backend, every frame.\n//\n// 16 is where the drawing stops SAYING anything, not where it stops being fast.\n// `pathHueAt` spreads the wheel evenly, so 16 hues are 22 degrees apart and\n// still tellable and 200 are one degree; the ribbon fan is PATH_RIBBON_SPACING\n// per path, so 16 of them is a legible fan and 200 is a band wider than the\n// nodes; and a key past about 16 rows is taller than the drawing beside it.\n// Above the cap the honest picture is the plain one \u2014 which is exactly what a\n// graph carrying no paths at all already draws.\nexport const MAX_PATH_COLORS = 16\n\n// Whether this graph's paths can be drawn as colours. Resolve it once and hand\n// the answer down: the geometry, the hit index and the key each used to decide\n// for themselves, which is how they came to disagree.\nexport function pathColorsLegible(pathCount: number) {\n return pathCount > 0 && pathCount <= MAX_PATH_COLORS\n}\n\nexport function pathCssColor(index: number, count: number) {\n return `hsl(${pathHueAt(index, count)}, ${PATH_SATURATION * 100}%, ${\n PATH_LIGHTNESS * 100\n }%)`\n}\n\n// A path is named the way its file names it \u2014 `K12#1#chr:1004500-1004961` for a\n// P record `odgi extract` wrote, `HG00738#1` for a W record \u2014 and neither is a\n// legend entry. The label is the least of that name which still tells the paths\n// apart: the sample where samples are unique, the haplotype too where they are\n// not, the whole stable name where even that repeats. Widening it for every row\n// rather than only for the colliding ones, because a legend where one entry is\n// `HG00738#1` and its neighbour is `HG01071` reads as two kinds of thing.\nfunction labelTiers(name: string) {\n const parts = pathOrigin(name).name.split('#')\n return [parts[0]!, parts.slice(0, 2).join('#'), parts.join('#')]\n}\n\n// Locale-independent, unlike toLocaleString: a figure regenerated on a machine\n// with a different locale would otherwise differ from the committed one.\nfunction groupDigits(n: number) {\n return String(n).replace(/\\B(?=(\\d{3})+$)/g, ',')\n}\n\n// A collapsed repeat puts one sequence through the same segments more than\n// once, and `odgi extract` emits one path per visit \u2014 nine visits over five\n// E. coli chromosomes at the rRNA operons, where every name tier above collides\n// because the sequence really is the same one. What separates those is the\n// offset each name carried, which is the one thing pathOrigin strips off.\nfunction offsetTiers(name: string, tiers: string[]) {\n const { start } = pathOrigin(name)\n return tiers.map(t => `${t} @${groupDigits(start)}`)\n}\n\nexport interface PathLegendEntry {\n name: string\n label: string\n color: string\n}\n\nexport function pathLegend(paths: GraphPath[]): PathLegendEntry[] {\n const named = paths.map(p => labelTiers(p.name))\n // narrowest first, and the offset is tried before the next name tier: two\n // copies of one operon are told apart by where they are, not by widening a\n // name that is genuinely identical\n const candidates = [0, 1, 2].flatMap(t => [\n paths.map((_, i) => named[i]![t]!),\n paths.map((p, i) => offsetTiers(p.name, named[i]!)[t]!),\n ])\n const distinct = candidates.find(\n labels => new Set(labels).size === paths.length,\n )\n // Nothing separates two paths with the same name and the same offset, so the\n // widest labelling is as close as any can get.\n const labels = distinct ?? candidates.at(-1)!\n return paths.map((path, i) => ({\n name: path.name,\n label: labels[i]!,\n color: pathCssColor(i, paths.length),\n }))\n}\n", "import type { Graph, GraphNode } from './types'\nimport type { NodeInk } from './util/hitDetection'\n\n// How thick a node draws. Bandage widens a node by its depth, the square root\n// of its depth against the graph's mean, so a contig every read covers is fat\n// and a spurious one is a hair. In a pangenome cut depth is carriage, how many\n// walks go through the node, and the same rule makes the reference thick and a\n// private allele thin. One table drives the persisted enum and the dropdown,\n// the way BUBBLE_SPREADS does.\nexport const NODE_WIDTHS = [\n {\n value: 'depth',\n label: 'By depth',\n description:\n 'Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform.',\n },\n {\n value: 'uniform',\n label: 'Uniform',\n description: 'Every node the same thickness.',\n },\n] as const\n\nexport type NodeWidth = (typeof NODE_WIDTHS)[number]['value']\n\nexport const NODE_WIDTH_VALUES = NODE_WIDTHS.map(w => w.value)\n\nconst MIN_FACTOR = 0.3\nconst MAX_FACTOR = 3\n\n// Length-weighted, as Bandage's mean depth is, so a cut's long reference nodes\n// set the norm and the alleles read against it.\nexport function meanDepth(graph: Graph) {\n let weighted = 0\n let length = 0\n for (const node of graph.nodes) {\n weighted += node.depth * node.length\n length += node.length\n }\n return length > 0 ? weighted / length : 0\n}\n\nexport function depthWidthFactor(node: GraphNode, mean: number) {\n if (!(mean > 0) || !(node.depth > 0)) {\n return 1\n }\n return Math.min(\n MAX_FACTOR,\n Math.max(MIN_FACTOR, Math.sqrt(node.depth / mean)),\n )\n}\n\n// How wide a node is drawn, in screen px. One function for the geometry and\n// for the hit test, so the pointer finds a node exactly where its ink is.\nexport function nodeWidthPx(\n node: GraphNode,\n contigThickness: number,\n nodeWidth: NodeWidth,\n mean: number,\n) {\n return (\n contigThickness * (nodeWidth === 'depth' ? depthWidthFactor(node, mean) : 1)\n )\n}\n\nexport function maxNodeWidthPx(contigThickness: number, nodeWidth: NodeWidth) {\n return contigThickness * (nodeWidth === 'depth' ? MAX_FACTOR : 1)\n}\n\n// How far each node's ink reaches from its centreline, for the hit test: the\n// widths the geometry draws with, from the same function.\nexport function nodeInk(\n graph: Graph | undefined,\n nodeById: ReadonlyMap<string, GraphNode> | undefined,\n contigThickness: number,\n nodeWidth: NodeWidth,\n): NodeInk {\n const mean = graph ? meanDepth(graph) : 0\n return {\n maxHalfWidthPx: maxNodeWidthPx(contigThickness, nodeWidth) / 2,\n halfWidthPx: id => {\n const node = nodeById?.get(id)\n return node\n ? nodeWidthPx(node, contigThickness, nodeWidth, mean) / 2\n : contigThickness / 2\n },\n }\n}\n"],
5
+ "mappings": "gFAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,CAAAA,EAAO,QAAU,eAAe,eAAe,IC2CxC,SAASC,EAAgBC,EAAwBC,EAAgB,CACtE,OAAO,KAAK,IACTD,EAAK,sBAAwBC,EAAU,IACxCD,EAAK,iBACP,CACF,CAEO,SAASE,EACdC,EAIAC,EAAgB,EACE,CAElB,IAAMC,EADcF,EAAM,MAAM,OAAO,CAACG,EAAKC,IAAMD,EAAMC,EAAE,OAAQ,CAAC,EACpC,IAC1BC,EAAS,KAAK,IAClBL,EAAM,MAAM,OAAS,GACrB,GACF,EACA,MAAO,CACL,sBAAuBE,EAAY,EAAIG,EAASH,EAAY,IAC5D,kBAAmB,KAAK,IAAI,EAA6BD,CAAa,EACtE,WAAY,EACZ,kBAAmB,EACrB,CACF,CA6BO,IAAMK,EAAsC,CAAE,MAAO,EAAG,OAAQ,CAAE,EAElE,SAASC,EAAeC,EAAqB,CAClD,OAAOA,EAAI,QAAU,GAAKA,EAAI,SAAW,CAC3C,CAGO,SAASC,EAAeT,EAAcQ,EAAqB,CAChE,IAAME,EAAQV,EAAM,MAAM,OACpBW,EAAcX,EAAM,MAAM,OAAO,CAACG,EAAKC,IAAMD,EAAMC,EAAE,OAAQ,CAAC,EAC9DQ,EAASF,EAAQ,EAAIC,EAAcD,EAAQ,EAO3CG,EACJH,EAAQ,EACJ,KAAK,IAAIA,EAAQ,GAAkB,GAAsB,EAAIA,EAC7D,GACN,OAAQI,GAAe,CACrB,GAAIF,GAAU,EACZ,OAAOC,EAET,IAAME,GAAYD,EAAKF,IAAWJ,EAAI,MACtC,OAAO,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EAAc,CACzB,CACE,MAAO,QACP,MAAO,WACP,YACE,yIACJ,EACA,CACE,MAAO,UACP,MAAO,UACP,YAAa,gCACf,CACF,EAIaC,GAAoBD,EAAY,IAAIE,GAAKA,EAAE,KAAK,EAEvDC,EAAa,GACbC,EAAa,EAIZ,SAASC,EAAUC,EAAc,CACtC,IAAIC,EAAW,EACXC,EAAS,EACb,QAAWC,KAAQH,EAAM,MACvBC,GAAYE,EAAK,MAAQA,EAAK,OAC9BD,GAAUC,EAAK,OAEjB,OAAOD,EAAS,EAAID,EAAWC,EAAS,CAC1C,CAEO,SAASE,EAAiBD,EAAiBE,EAAc,CAC9D,MAAI,EAAEA,EAAO,IAAM,EAAEF,EAAK,MAAQ,GACzB,EAEF,KAAK,IACVL,EACA,KAAK,IAAID,EAAY,KAAK,KAAKM,EAAK,MAAQE,CAAI,CAAC,CACnD,CACF,CAIO,SAASC,EACdH,EACAI,EACAC,EACAH,EACA,CACA,OACEE,GAAmBC,IAAc,QAAUJ,EAAiBD,EAAME,CAAI,EAAI,EAE9E,CAEO,SAASI,EAAeF,EAAyBC,EAAsB,CAC5E,OAAOD,GAAmBC,IAAc,QAAUV,EAAa,EACjE,CAIO,SAASY,GACdV,EACAW,EACAJ,EACAC,EACS,CACT,IAAMH,EAAOL,EAAQD,EAAUC,CAAK,EAAI,EACxC,MAAO,CACL,eAAgBS,EAAeF,EAAiBC,CAAS,EAAI,EAC7D,YAAaI,GAAM,CACjB,IAAMT,EAAOQ,GAAU,IAAIC,CAAE,EAC7B,OAAOT,EACHG,EAAYH,EAAMI,EAAiBC,EAAWH,CAAI,EAAI,EACtDE,EAAkB,CACxB,CACF,CACF",
6
+ "names": ["require_mui", "__commonJSMin", "exports", "module", "drawnNodeLength", "opts", "length", "bandageAutoScale", "graph", "minNodeLength", "megabases", "sum", "n", "target", "PROPORTIONAL_LENGTH", "isProportional", "law", "drawnLengthFor", "count", "totalLength", "meanBp", "meanDrawn", "bp", "relative", "LAYOUT_LENGTH_PRECISION", "PROPORTIONAL_SPREAD", "layoutScaling", "spread", "drawn", "node", "BUBBLE_SPREADS", "PROPORTIONAL_LENGTH", "BUBBLE_SPREAD_VALUES", "s", "spreadFor", "spread", "entry", "COLOR_SCHEMES", "COLOR_SCHEME_VALUES", "s", "resolveColorScheme", "scheme", "graph", "isAnchored", "node", "isBackbone", "isOffReference", "backboneNodes", "graph", "backbonePositions", "backbone", "positions", "firstNodeAtOrAfter", "nodes", "bp", "lo", "hi", "mid", "backboneSpan", "min", "max", "referenceSpan", "region", "RANGE_SUFFIX", "pathOrigin", "pathName", "match", "surveyPaths", "paths", "lengthOf", "anchorPaths", "pathVisits", "path", "sample", "panSNSample", "pos", "step", "visit", "existing", "chooseReferencePath", "preferred", "p", "OFF_REFERENCE_RANK", "anchorNode", "node", "visits", "reference", "anchored", "anchor", "v", "anchorFromPaths", "graph", "anchorGraph", "nameHue", "name", "hash", "i", "pathHueAt", "index", "count", "PATH_SATURATION", "PATH_LIGHTNESS", "MAX_PATH_COLORS", "pathColorsLegible", "pathCount", "pathCssColor", "labelTiers", "parts", "pathOrigin", "groupDigits", "n", "offsetTiers", "tiers", "start", "t", "pathLegend", "paths", "named", "p", "candidates", "_", "labels", "path", "NODE_WIDTHS", "NODE_WIDTH_VALUES", "w", "MIN_FACTOR", "MAX_FACTOR", "meanDepth", "graph", "weighted", "length", "node", "depthWidthFactor", "mean", "nodeWidthPx", "contigThickness", "nodeWidth", "maxNodeWidthPx", "nodeInk", "nodeById", "id"]
7
+ }