jbrowse-plugin-graphgenomeviewer 6.3.1 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +2 -2
  2. package/dist/chunks/AddTrackWorkflow-ANWIWCO6.js +2 -0
  3. package/dist/chunks/{AddTrackWorkflow-F5YBOJ3E.js.map → AddTrackWorkflow-ANWIWCO6.js.map} +1 -1
  4. package/dist/chunks/ChooseSamplesDialog-OYAB355I.js +2 -0
  5. package/dist/chunks/{ChooseSamplesDialog-KVTDIA4A.js.map → ChooseSamplesDialog-OYAB355I.js.map} +1 -1
  6. package/dist/chunks/ChooseWalksDialog-HJE4CAKU.js +2 -0
  7. package/dist/chunks/{ChooseWalksDialog-L6QKOT7M.js.map → ChooseWalksDialog-HJE4CAKU.js.map} +1 -1
  8. package/dist/chunks/{GraphGenomeView-VIKLXNQD.js → GraphGenomeView-ULQ6U5MK.js} +2 -2
  9. package/dist/chunks/{GraphGenomeView-VIKLXNQD.js.map → GraphGenomeView-ULQ6U5MK.js.map} +1 -1
  10. package/dist/chunks/GraphTrackSettingsDialog-O6IYVHNJ.js +4 -0
  11. package/dist/chunks/{GraphTrackSettingsDialog-MRMSH2FO.js.map → GraphTrackSettingsDialog-O6IYVHNJ.js.map} +1 -1
  12. package/dist/chunks/HighlightColorDialog-LXT72W7R.js +2 -0
  13. package/dist/chunks/{HighlightColorDialog-SABW5OMB.js.map → HighlightColorDialog-LXT72W7R.js.map} +1 -1
  14. package/dist/chunks/LinearGraphDisplay-KM5SOSQQ.js +2 -0
  15. package/dist/chunks/{LinearGraphDisplay-AHCKWNFJ.js.map → LinearGraphDisplay-KM5SOSQQ.js.map} +1 -1
  16. package/dist/chunks/TrackWarningsDialog-YL2UP35Z.js +2 -0
  17. package/dist/chunks/{TrackWarningsDialog-HPHM5S7U.js.map → TrackWarningsDialog-YL2UP35Z.js.map} +1 -1
  18. package/dist/chunks/chunk-64LZZURD.js +2 -0
  19. package/dist/chunks/chunk-64LZZURD.js.map +7 -0
  20. package/dist/chunks/chunk-7KFSWOWX.js +3 -0
  21. package/dist/chunks/chunk-7KFSWOWX.js.map +7 -0
  22. package/dist/chunks/chunk-AMD4KXQV.js +2 -0
  23. package/dist/chunks/chunk-AMD4KXQV.js.map +7 -0
  24. package/dist/chunks/chunk-GB7CF6Z2.js +2 -0
  25. package/dist/chunks/chunk-GB7CF6Z2.js.map +7 -0
  26. package/dist/chunks/chunk-GXQ7NYB3.js +2 -0
  27. package/dist/chunks/chunk-GXQ7NYB3.js.map +7 -0
  28. package/dist/chunks/chunk-NXZT63HN.js +2 -0
  29. package/dist/chunks/chunk-NXZT63HN.js.map +7 -0
  30. package/dist/chunks/chunk-PLV6SE4Y.js +2 -0
  31. package/dist/chunks/chunk-PLV6SE4Y.js.map +7 -0
  32. package/dist/chunks/chunk-X4DGSMS6.js +2 -0
  33. package/dist/chunks/{chunk-A6GKF63C.js.map → chunk-X4DGSMS6.js.map} +1 -1
  34. package/dist/chunks/renderSvg-J7L374ND.js +2 -0
  35. package/dist/chunks/renderSvg-J7L374ND.js.map +7 -0
  36. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +6 -6
  37. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  38. package/package.json +1 -1
  39. package/src/GraphGenomeView/components/PaneSvg.tsx +828 -0
  40. package/src/GraphGenomeView/components/ReferenceStripOverlay.tsx +23 -5
  41. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +46 -35
  42. package/src/GraphGenomeView/model.test.ts +52 -0
  43. package/src/GraphGenomeView/pane/graphViews.ts +4 -0
  44. package/src/GraphGenomeView/pane/loadActions.ts +5 -2
  45. package/src/GraphGenomeView/pane/settingActions.ts +30 -12
  46. package/src/GraphGenomeView/viewModel.ts +16 -0
  47. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +17 -0
  48. package/src/LinearGraphDisplay/model.ts +24 -1
  49. package/src/LinearGraphDisplay/renderSvg.tsx +27 -0
  50. package/src/version.ts +1 -1
  51. package/dist/chunks/AddTrackWorkflow-F5YBOJ3E.js +0 -2
  52. package/dist/chunks/ChooseSamplesDialog-KVTDIA4A.js +0 -2
  53. package/dist/chunks/ChooseWalksDialog-L6QKOT7M.js +0 -2
  54. package/dist/chunks/GraphTrackSettingsDialog-MRMSH2FO.js +0 -4
  55. package/dist/chunks/HighlightColorDialog-SABW5OMB.js +0 -2
  56. package/dist/chunks/LinearGraphDisplay-AHCKWNFJ.js +0 -2
  57. package/dist/chunks/TrackWarningsDialog-HPHM5S7U.js +0 -2
  58. package/dist/chunks/chunk-2SL675KP.js +0 -3
  59. package/dist/chunks/chunk-2SL675KP.js.map +0 -7
  60. package/dist/chunks/chunk-A6GKF63C.js +0 -2
  61. package/dist/chunks/chunk-B7KMMGFB.js +0 -2
  62. package/dist/chunks/chunk-B7KMMGFB.js.map +0 -7
  63. package/dist/chunks/chunk-TYJTJGPO.js +0 -2
  64. package/dist/chunks/chunk-TYJTJGPO.js.map +0 -7
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["global-externals:@jbrowse/render-core/useRenderingBackend", "../../src/GraphGenomeView/components/GraphCanvas.tsx", "../../node_modules/.pnpm/@jbrowse+bandage-core@8.0.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-AZFVORTC.js", "../../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/FacetPanels.tsx", "../../src/GraphGenomeView/components/WalkKey.tsx", "../../src/GraphGenomeView/components/usePaneGestures.ts", "../../node_modules/.pnpm/@jbrowse+bandage-core@8.0.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-TDQLINVI.js", "../../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/UnpopButton.tsx", "../../src/GraphGenomeView/components/WalkRowContextMenu.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/FilterList.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/FilterListOff.mjs", "../../src/GraphGenomeView/components/WalkStrip.tsx", "../../src/GraphGenomeView/components/WalkStripLocator.tsx", "../../src/GraphGenomeView/renderer/GraphRenderer.ts"],
4
+ "sourcesContent": ["module.exports = JBrowseExports[\"@jbrowse/render-core/useRenderingBackend\"];", "import { useEffect, useRef } from 'react'\n\nimport { formatBp } from '@jbrowse/bandage-core/graphLabels'\nimport { edgeHoverText } from '@jbrowse/bandage-core/hoverText'\nimport { LEGEND_INSET_PX } from '@jbrowse/bandage-core/labelLayout'\nimport { RAMP_GRADIENT_CSS } from '@jbrowse/bandage-core/referenceRampCss'\nimport {\n LIFT_BACKDROP_CSS,\n REFERENCE_RAMP_ALT_CSS,\n} from '@jbrowse/bandage-core/renderer/GeometryBuilder'\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, { HaloLegend } from './BubbleHalos'\nimport FacetPanels from './FacetPanels'\nimport GenePins, { EXON_COLOR } from './GenePins'\nimport GraphToolbar from './GraphToolbar'\nimport LabelLayer from './LabelLayer'\nimport ReferenceStripOverlay, {\n ReferenceStripLegend,\n} from './ReferenceStripOverlay'\nimport TubeMapOverlay, { TubeMapLegend } from './TubeMapOverlay'\nimport UnpopButton from './UnpopButton'\nimport WalkKey, { walkSwatchStyle } from './WalkKey'\nimport { WalkRowContextMenu } from './WalkRowContextMenu'\nimport WalkRowsOverlay, { WalkRowsLegend } from './WalkRowsOverlay'\nimport WalkStrip from './WalkStrip'\nimport WalkStripLocator from './WalkStripLocator'\nimport { legendBoxStyle, legendRowStyle } from './legendStyles'\nimport { usePaneGestures, useWheelZoom } from './usePaneGestures'\nimport { locLabel, nodeOwnLocation } from '../../launchFromGraph/contributors'\nimport { nodeLaunchMenuItems } from '../../launchFromGraph/graphMenuItems'\nimport { createGraphRenderer } from '../renderer/GraphRenderer'\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 zIndex: 6,\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 = {\n position: 'relative' as const,\n lineHeight: 0,\n isolation: 'isolate' as const,\n}\n\n// Under a transparent canvas, from below the reference strip down, so the\n// linear view's gridlines show only behind the strip\nconst paperStyle = {\n position: 'absolute' as const,\n left: 0,\n right: 0,\n bottom: 0,\n zIndex: 0,\n}\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 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={legendRowStyle}>\n <div style={{ ...pathSwatchStyle, backgroundColor: color }} />\n <span>{label}</span>\n </div>\n ))}\n </div>\n ) : null\n})\n\n// Each lifted walk's key, then what the faded rest is\nconst WalkReadout = observer(function WalkReadout({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const lift = model.walkLift\n if (!lift) {\n return null\n }\n return (\n <div style={legendBoxStyle} data-testid=\"graph-walk-readout\">\n {lift.walks.map(w => (\n <WalkKey\n key={w.name}\n walk={w}\n label={model.walkLabel(w.name)}\n reference={model.walkReference}\n at={model.hoveredOn(w)}\n />\n ))}\n {/* the ramp's own key, which names this, is off while walks are lifted */}\n {model.liftPaintsOffReference ? <OffReferenceRow /> : null}\n <div style={legendRowStyle}>\n <div style={{ ...walkSwatchStyle, background: LIFT_BACKDROP_CSS }} />\n <span>not on {model.liftedWalksLabel}</span>\n </div>\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.\nconst rampStripStyle = {\n minWidth: 90,\n height: 8,\n borderRadius: 2,\n background: RAMP_GRADIENT_CSS,\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 // under lifted walks each lane states its own scale, and the rest is grey\n const domain = model.walkLift ? undefined : model.referenceRampDomain\n const { offReference, unplaced } = model.referenceRampOffKeys\n // a measured domain runs between node midpoints, which can fall on a half bp\n const start = Math.round(domain?.start ?? 0)\n const end = Math.round(domain?.end ?? 0)\n return domain ? (\n <div style={legendBoxStyle} data-testid=\"graph-ramp-legend\">\n <div style={rampStripStyle} />\n <div style={rampEndsStyle}>\n <span>{start.toLocaleString()}</span>\n <span>({formatBp(end - start)})</span>\n <span>{end.toLocaleString()}</span>\n </div>\n {offReference ? <OffReferenceRow /> : null}\n {unplaced ? (\n <div style={legendRowStyle}>\n <div style={{ ...walkSwatchStyle, background: UNPLACED_SWATCH }} />\n <span>no reference position</span>\n </div>\n ) : null}\n </div>\n ) : null\n})\n\n// getNodeColor's grey for a node the ramp cannot place\nconst UNPLACED_SWATCH = 'rgb(160, 160, 160)'\n\n// The charcoal both the ramp and a lane coloured by reference position give\n// sequence the reference does not carry\nfunction OffReferenceRow() {\n return (\n <div style={legendRowStyle}>\n <div style={{ ...walkSwatchStyle, background: REFERENCE_RAMP_ALT_CSS }} />\n <span>off the reference</span>\n </div>\n )\n}\n\nconst exonSwatchStyle = {\n ...walkSwatchStyle,\n border: `2px solid ${EXON_COLOR}`,\n borderRadius: 5,\n boxSizing: 'border-box' as const,\n}\n\nconst GeneLegend = observer(function GeneLegend({\n model,\n}: {\n model: GraphPaneModel\n}) {\n return model.genePins.some(pin => pin.exonsByNode.length > 0) ? (\n <div style={legendBoxStyle} data-testid=\"graph-gene-legend\">\n <div style={legendRowStyle}>\n <div style={exonSwatchStyle} />\n <span>exon</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.\n//\n// At rest only: the walk keys' hover readout would otherwise refit the view,\n// and the refit clears the hover that grew it\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) && model.hoveredNode === null) {\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\n ref={ref}\n style={{\n ...legendStackStyle,\n top: LEGEND_INSET_PX + model.referenceStripZonePx,\n }}\n >\n <ReferenceRampLegend model={model} />\n <ReferenceStripLegend model={model} />\n <HaloLegend model={model} />\n <GeneLegend model={model} />\n <PathLegend model={model} />\n <TubeMapLegend 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 hoveredEdgeText = hoveredEdgeData\n ? edgeHoverText(\n hoveredEdgeData,\n model.deletions.find(d => d.edgeIndex === model.hoveredEdge),\n id => model.nodeById?.get(id)?.name ?? id,\n )\n : undefined\n\n const walkRow = model.hoveredWalkRowText\n\n return (\n <>\n {walkRow && !hoveredNodeData ? (\n <div style={tooltipStyle} data-testid=\"graph-walk-row-tooltip\">\n <strong>{walkRow.label}</strong> \u2014 {walkRow.readout}\n </div>\n ) : null}\n {hoveredNodeData ? (\n <div style={tooltipStyle}>\n <strong>{hoveredNodeData.name}</strong> \u2014{' '}\n {hoveredNodeData.length.toLocaleString()} bp, 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 {hoveredEdgeText ? (\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 {hoveredEdgeText.deletion ? (\n <>\n <strong>Deletion</strong> {hoveredEdgeText.deletion.bp}\n <br />\n {hoveredEdgeText.deletion.where}\n </>\n ) : (\n <>Edge: {hoveredEdgeText.ends}</>\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 const { handlers, contextNode, contextRow, closeContextMenu } =\n usePaneGestures(model)\n useWheelZoom(canvas, model)\n const faceted = model.facetPanels !== undefined\n\n return (\n <div style={wrapperStyle}>\n {ownChrome ? <GraphToolbar model={model} /> : null}\n\n <div\n style={canvasAreaStyle}\n onMouseEnter={() => {\n model.setPointerInPane(true)\n }}\n onMouseLeave={() => {\n if (isAlive(model)) {\n model.setPointerInPane(false)\n }\n }}\n >\n {model.referenceStripShown ? (\n <div\n style={{\n ...paperStyle,\n top: model.referenceStripZonePx,\n background: model.paperCss,\n }}\n />\n ) : null}\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 position: 'relative',\n zIndex: 1,\n }}\n {...handlers}\n />\n\n {faceted ? (\n <FacetPanels model={model} handlers={handlers} />\n ) : (\n <>\n <TubeMapOverlay model={model} />\n <ReferenceStripOverlay model={model} />\n <RowLabels model={model} />\n <GraphSizeLabels model={model} />\n <BubbleHalos model={model} />\n <GenePins model={model} />\n <LabelLayer model={model} />\n <WalkRowsOverlay model={model} />\n <WalkStripLocator model={model} />\n <Legends model={model} />\n </>\n )}\n <UnpopButton 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 {model.walkStripShown ? <WalkStrip model={model} /> : null}\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={closeContextMenu}\n />\n ) : null}\n\n {contextRow ? (\n <WalkRowContextMenu\n model={model}\n row={contextRow.row}\n top={contextRow.top}\n left={contextRow.left}\n onClose={closeContextMenu}\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", "// src/hoverText.ts\nfunction regionLabel(loc) {\n return `${loc.refName}:${(loc.start + 1).toLocaleString()}-${loc.end.toLocaleString()}`;\n}\nfunction edgeHoverText(edge, deletion, nameOf = (id) => id) {\n return deletion ? {\n deletion: {\n bp: `${deletion.bp.toLocaleString()} bp`,\n where: regionLabel(deletion)\n }\n } : {\n ends: `${nameOf(edge.from)}${edge.fromStrand ?? \"\"} \\u2192 ${nameOf(edge.to)}${edge.toStrand ?? \"\"}`\n };\n}\n\nexport {\n regionLabel,\n edgeHoverText\n};\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 { useEffect, useState } from 'react'\n\nimport { FACET_GAP_PX, FACET_TITLE_PX } from '@jbrowse/bandage-core/facetGrid'\nimport { Canvas2DRenderer } from '@jbrowse/bandage-core/renderer/Canvas2DRenderer'\nimport { autorun, computed } from 'mobx'\nimport { observer } from 'mobx-react'\n\nimport WalkKey from './WalkKey'\nimport { useWheelZoom } from './usePaneGestures'\n\nimport type { PaneHandlers } from './usePaneGestures'\nimport type { GraphPaneModel } from '../model'\nimport type { WalkLift } from '@jbrowse/bandage-core/walkHighlight'\n\n// The pane faceted by walk: the same layout drawn once per lifted walk, each\n// panel with that walk alone shading along itself, so walks compare by where\n// they go rather than by which lane is which colour. The panels share the\n// pane's transform, so a pan, zoom or hover in one is in all of them.\n\nconst gridStyle = {\n position: 'absolute' as const,\n left: 0,\n top: 0,\n zIndex: 4,\n display: 'grid',\n gap: FACET_GAP_PX,\n lineHeight: 'normal',\n}\n\nconst titleStyle = {\n height: FACET_TITLE_PX,\n padding: '2px 6px',\n boxSizing: 'border-box' as const,\n fontFamily: 'inherit',\n fontSize: 11,\n color: 'inherit',\n cursor: 'pointer',\n border: 'none',\n background: 'none',\n textAlign: 'left' as const,\n display: 'block',\n}\n\nconst FacetPanel = observer(function FacetPanel({\n model,\n lift,\n width,\n height,\n cell,\n handlers,\n}: {\n model: GraphPaneModel\n lift: WalkLift\n width: number\n height: number\n cell: { gridRow: number; gridColumn: number }\n handlers: PaneHandlers\n}) {\n const [canvas, setCanvas] = useState<HTMLCanvasElement | null>(null)\n const walk = lift.walks[0]!\n useWheelZoom(canvas, model)\n\n useEffect(() => {\n if (!canvas) {\n return undefined\n }\n const renderer = new Canvas2DRenderer(canvas)\n renderer.resize(width, height)\n const drawing = computed(() => model.buildDrawing(lift, false))\n let uploaded: ReturnType<typeof model.buildDrawing>\n const dispose = autorun(() => {\n const built = drawing.get()\n if (!built) {\n return\n }\n if (built !== uploaded) {\n renderer.uploadGeometry(built.batch)\n uploaded = built\n }\n model.applyHighlights(renderer)\n model.paint(renderer)\n })\n return () => {\n dispose()\n renderer.dispose()\n }\n }, [canvas, model, lift, width, height])\n\n const label = model.walkLabel(walk.name)\n return (\n <div style={cell}>\n <button\n type=\"button\"\n style={titleStyle}\n data-testid=\"graph-facet-title\"\n onClick={() => {\n model.liftWalks([walk.name])\n model.setFacet('')\n }}\n >\n <WalkKey\n walk={walk}\n label={label}\n reference={model.walkReference}\n hint={`click to lift ${label} alone`}\n at={model.hoveredOn(walk)}\n />\n </button>\n <canvas\n ref={setCanvas}\n data-testid=\"graph-facet-canvas\"\n style={{\n width,\n height,\n display: 'block',\n cursor: model.isPanning || model.draggingNode ? 'grabbing' : 'grab',\n }}\n {...handlers}\n />\n </div>\n )\n})\n\nconst FacetPanels = observer(function FacetPanels({\n model,\n handlers,\n}: {\n model: GraphPaneModel\n handlers: PaneHandlers\n}) {\n const panels = model.facetPanels\n const grid = model.facetGrid\n const place = model.facetPlacement\n if (!panels || !grid || !place) {\n return null\n }\n const { columns, width, height } = grid\n return (\n <div\n data-testid=\"graph-facet-panels\"\n style={{\n ...gridStyle,\n width: model.paneWidth,\n minHeight: model.canvasHeight,\n gridTemplateColumns: `repeat(${columns}, ${width}px)`,\n background: model.darkMode ? '#1f1f1f' : 'white',\n }}\n >\n {panels.map((lift, i) => (\n <FacetPanel\n key={lift.walks[0]!.name}\n model={model}\n lift={lift}\n width={width}\n height={height}\n cell={{\n gridRow: Math.floor(place.cells[i]! / columns) + 1,\n gridColumn: (place.cells[i]! % columns) + 1,\n }}\n handlers={handlers}\n />\n ))}\n </div>\n )\n})\n\nexport default FacetPanels\n", "import { encodingSwatchCss } from '@jbrowse/bandage-core/walkEncoding'\nimport { walkKey } from '@jbrowse/bandage-core/walkKey'\n\nimport { legendRowStyle } from './legendStyles'\n\nimport type { LiftedWalk } from '@jbrowse/bandage-core/walkHighlight'\n\nexport const walkSwatchStyle = {\n width: 18,\n height: 8,\n borderRadius: 2,\n flex: 'none',\n}\nconst walkBlockStyle = { marginBottom: 2 }\nconst walkBarStyle = { ...walkSwatchStyle, width: 48 }\n\n// One walk's key: a swatch, or a short bar of the scale its lane shades by,\n// then its name; see walkKey for the words. `at`, where the hovered node sits\n// on the walk, stands in for the scale's stretch while there is one.\nexport default function WalkKey({\n walk,\n label,\n reference,\n hint,\n at,\n}: {\n walk: LiftedWalk\n label: string\n reference?: { name?: string; start: number; end: number }\n hint?: string\n at?: string\n}) {\n const key = walkKey(walk, reference)\n return (\n <div\n style={walkBlockStyle}\n title={[key.hover, hint].filter(Boolean).join(' \u00B7 ') || undefined}\n >\n <div style={legendRowStyle}>\n <div\n style={{\n ...(key.shades ? walkBarStyle : walkSwatchStyle),\n background: encodingSwatchCss(walk.encoding),\n }}\n />\n <span>\n <strong>{label}</strong>\n {key.delta}\n {key.outside}\n {key.reversed}\n </span>\n </div>\n {at ? (\n <div data-testid=\"graph-walk-at\">{at}</div>\n ) : key.scale ? (\n <div>{key.scale}</div>\n ) : null}\n </div>\n )\n}\n", "import { useEffect, useRef, useState } from 'react'\n\nimport {\n findHoveredEdge,\n findHoveredNode,\n} from '@jbrowse/bandage-core/util/hitDetection'\nimport { wheelZoomFactor } from '@jbrowse/bandage-core/util/wheelZoom'\nimport { isAlive } from '@jbrowse/mobx-state-tree'\n\nimport type { GraphPaneModel } from '../model'\n\n// wheel events need passive:false to call preventDefault \u2014 React registers\n// wheel listeners as passive, so we must add this imperatively\nexport function useWheelZoom(\n canvas: HTMLCanvasElement | null | undefined,\n model: GraphPaneModel,\n) {\n useEffect(() => {\n if (!canvas) {\n return undefined\n }\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 }, [canvas, model])\n}\n\n// The pointer on a canvas drawing the pane's transform: the pane's own, or any\n// facet panel, since the panels share it. Coordinates are read against the\n// canvas the event is on.\nexport function usePaneGestures(model: GraphPaneModel) {\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 const [contextRow, setContextRow] = useState<\n { row: number; top: number; left: number } | undefined\n >(undefined)\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 const sx = x * model.scaleX + model.translateX\n const sy = y * model.scaleY + model.translateY\n if (model.layoutResult?.tubeMap) {\n return model.tubeMapNodeAt(sx, sy)\n }\n const onStrip = model.referenceStripNodeAt(sx, sy)\n if (onStrip) {\n return onStrip\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 onMouseDown(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, and the strip's are bp, not\n // positions to drag\n const node =\n model.layoutResult?.tubeMap ||\n e.nativeEvent.offsetY < model.referenceStripZonePx\n ? null\n : 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 const bars = model.walkRowBars\n if (pending.hover && bars) {\n const i = model.walkRowAt(pending.hover.x, pending.hover.y)\n model.setHoveredWalkRow(\n i === undefined ? null : [bars.reference, ...bars.rows][i]!.name,\n )\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. Facet panels draw\n // none.\n model.effectiveDrawPaths && !model.facetPanels,\n model.positionsVersion,\n model.deletionEdgeIndexes,\n model.hiddenEdgeIndexes,\n model.deletionRoutes,\n model.layoutResult?.stranded,\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 onMouseMove(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 onMouseUp() {\n model.stopDragging()\n }\n\n // also fired by the canvas unmounting under a resting pointer, after the\n // view closing it has destroyed the model\n function onMouseLeave() {\n dropPending()\n if (!isAlive(model)) {\n return\n }\n model.stopDragging()\n model.setHoveredNode(null)\n model.setHoveredEdge(null)\n model.setHoveredWalkRow(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 onContextMenu(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 return\n }\n const row = model.walkRowAt(\n x * model.scaleX + model.translateX,\n y * model.scaleY + model.translateY,\n )\n if (row !== undefined) {\n e.preventDefault()\n setContextRow({ row, top: e.clientY, left: e.clientX })\n }\n }\n\n function onClick(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 handlers: {\n onMouseDown,\n onMouseMove,\n onMouseUp,\n onMouseLeave,\n onClick,\n onContextMenu,\n },\n contextNode,\n contextRow,\n closeContextMenu: () => {\n setContextNode(undefined)\n setContextRow(undefined)\n },\n }\n}\n\nexport type PaneHandlers = ReturnType<typeof usePaneGestures>['handlers']\n", "// src/util/wheelZoom.ts\nvar ZOOM_PER_NOTCH = 1.1;\nvar NOTCH_PX = 100;\nvar LINE_PX = 40;\nvar PAGE_PX = 800;\nvar PINCH_GAIN = 10;\nvar MAX_NOTCHES_PER_EVENT = 2;\nfunction wheelZoomFactor(e) {\n const px = 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 ZOOM_PER_NOTCH ** -Math.max(-MAX_NOTCHES_PER_EVENT, Math.min(MAX_NOTCHES_PER_EVENT, notches));\n}\n\nexport {\n wheelZoomFactor\n};\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.viewBox.width / 2, model.viewBox.height / 2)\n }}\n >\n <ZoomInIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title=\"Zoom out\">\n <IconButton\n size=\"small\"\n onClick={() => {\n model.zoom(\n 1 / 1.5,\n model.viewBox.width / 2,\n model.viewBox.height / 2,\n )\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 { COLOR_SCHEMES } from '@jbrowse/bandage-core/colorSchemes'\nimport { 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: 100,\n },\n})\n\nconst ColorSchemeSelect = observer(function ColorSchemeSelect({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { classes } = useStyles()\n const fixed = model.colorSchemeLock\n return (\n <FormControl\n size=\"small\"\n className={classes.formControl}\n disabled={fixed !== undefined}\n title={fixed?.why}\n >\n <InputLabel>Color</InputLabel>\n <Select\n value={model.chosenColorScheme}\n label=\"Color\"\n renderValue={fixed ? () => fixed.value : undefined}\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 { LAYOUT_MODES } from '@jbrowse/bandage-core/layoutModes'\nimport {\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 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 void model.toggleDeletionEdges()\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 {\n Checkbox,\n FormControl,\n InputLabel,\n ListItemText,\n MenuItem,\n Select,\n} 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: 260,\n },\n})\n\n// Which walks to lift out of the drawing: Bandage's path highlight, for as many\n// of the haplotypes a GBZ cut carries as the reader picks. Absent from a graph\n// with no walks, and from a tube map, whose tubes are the 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 || !model.liftsWalks) {\n return null\n }\n const names = new Set(walkChoices.map(c => c.name))\n const labels = new Map(walkChoices.map(c => [c.name, c.label]))\n const picked = model.walkLayers\n .map(layer => layer.walk)\n .filter(name => names.has(name))\n return (\n <FormControl size=\"small\" className={classes.formControl}>\n <InputLabel>Walks</InputLabel>\n <Select\n multiple\n value={picked}\n label=\"Walks\"\n data-testid=\"graph-walk-select\"\n renderValue={selected => selected.map(n => labels.get(n)).join(', ')}\n onChange={e => {\n const { value } = e.target\n model.liftWalks(typeof value === 'string' ? value.split(',') : value)\n }}\n >\n {walkChoices.map(({ name, label }) => (\n <MenuItem key={name} value={name} dense>\n <Checkbox size=\"small\" checked={picked.includes(name)} />\n <ListItemText primary={label} />\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n})\n\nexport default WalkSelect\n", "import { Button } from '@mui/material'\nimport { observer } from 'mobx-react'\n\nimport type { GraphPaneModel } from '../model'\n\nconst style = {\n position: 'absolute' as const,\n left: 8,\n zIndex: 5,\n background: 'rgba(255,255,255,0.9)',\n textTransform: 'none' as const,\n}\n\nconst UnpopButton = observer(function UnpopButton({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const { poppedFrom } = model\n return poppedFrom ? (\n <Button\n size=\"small\"\n variant=\"outlined\"\n style={{ ...style, ...(model.facetPanels ? { bottom: 8 } : { top: 8 }) }}\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})\n\nexport default UnpopButton\n", "import { Menu } from '@jbrowse/core/ui'\nimport FilterListIcon from '@mui/icons-material/FilterList'\nimport FilterListOffIcon from '@mui/icons-material/FilterListOff'\nimport LineStyleIcon from '@mui/icons-material/LineStyle'\nimport { observer } from 'mobx-react'\n\nimport { locLabel } from '../../launchFromGraph/contributors'\n\nimport type { GraphPaneModel } from '../model'\nimport type { WalkRows } from '@jbrowse/bandage-core/layout/walkRows'\n\n// A walk row's bar stands for a span of its haplotype's own contig, so the\n// question a right-click asks is answered by a linear view on that assembly,\n// with its genes\nexport const WalkRowContextMenu = observer(function WalkRowContextMenu({\n model,\n row,\n bars,\n top,\n left,\n onClose,\n}: {\n model: GraphPaneModel\n row: number\n // the rows `row` indexes, walk rows' own unless a strip's\n bars?: WalkRows\n top: number\n left: number\n onClose: () => void\n}) {\n const rows = bars ?? model.walkRowBars\n const target = model.walkRowLaunchTarget(row, rows)\n const assembly = target?.assembly\n const sample = row > 0 ? rows?.rows[row - 1]?.sample : undefined\n // the strip's rows are not walk rows', and take no sample filter\n const filters = !bars && model.walkRowBars\n const shown = model.walkRowSamples\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 target && assembly\n ? {\n label: `Linear genome view \u2014 ${assembly} ${locLabel(target.location)}`,\n icon: LineStyleIcon,\n onClick: () => {\n model.showInLinearView({ location: target.location, assembly })\n },\n }\n : {\n label: 'Linear genome view',\n icon: LineStyleIcon,\n disabled: true,\n disabledHelpText: target\n ? `No assembly in this session is ${target.location.haplotype ?? target.label}`\n : 'This walk states no contig coordinates',\n onClick: () => {},\n },\n ...(filters && sample && !(shown?.length === 1 && shown[0] === sample)\n ? [\n {\n label: `Show only ${sample}`,\n icon: FilterListIcon,\n onClick: () => {\n model.setWalkRowSamples([sample])\n },\n },\n ]\n : []),\n ...(filters && shown\n ? [\n {\n label: 'Show every sample',\n icon: FilterListOffIcon,\n onClick: () => {\n model.setWalkRowSamples(undefined)\n },\n },\n ]\n : []),\n ]}\n />\n )\n})\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: \"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z\"\n}), 'FilterList');", "\"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: \"M10.83 8H21V6H8.83zm5 5H18v-2h-4.17zM14 16.83V18h-4v-2h3.17l-3-3H6v-2h2.17l-3-3H3V6h.17L1.39 4.22 2.8 2.81l18.38 18.38-1.41 1.41z\"\n}), 'FilterListOff');", "import { useId, useMemo, useState } from 'react'\n\nimport {\n walkRowReadout,\n walkRowsKey,\n walkRowsTree,\n} from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport {\n stripGeneGaps,\n stripRowAt,\n walkMarksTree,\n walkStripLabelsTree,\n} from '@jbrowse/bandage-core/layout/walkStrip'\nimport { RAMP_GRADIENT_CSS } from '@jbrowse/bandage-core/referenceRampCss'\nimport { isAlive } from '@jbrowse/mobx-state-tree'\nimport { observer } from 'mobx-react'\n\nimport ElTree from './ElTree'\nimport { WalkRowContextMenu } from './WalkRowContextMenu'\nimport { Swatch } from './WalkRowsOverlay'\nimport { legendRowStyle } from './legendStyles'\n\nimport type { GraphPaneModel } from '../model'\nimport type { RowGene } from '@jbrowse/bandage-core/layout/walkRowDraw'\nimport type { WalkRows } from '@jbrowse/bandage-core/layout/walkRows'\nimport type { StripFrame } from '@jbrowse/bandage-core/layout/walkStrip'\n\n// Walk rows under a layout that draws nodes, each haplotype's walk on its own\n// bp, linked to the drawing above: the hovered node ticks every bar where its\n// walk passes it, and a point on a bar lights its node, ringed, above. The\n// bars share the drawing's colours, so under the reference-position ramp a hue\n// in the drawing is the same hue on each bar. Every row is shown; rows too\n// thin to letter say who they are on hover.\n\nconst keyStyle = {\n display: 'flex',\n flexWrap: 'wrap' as const,\n gap: '2px 14px',\n padding: '2px 8px 6px',\n fontSize: 11,\n color: '#333',\n}\n\nconst tipStyle = {\n position: 'absolute' as const,\n pointerEvents: 'none' as const,\n background: 'rgba(255,255,255,0.92)',\n border: '1px solid #ccc',\n borderRadius: 3,\n padding: '1px 6px',\n fontSize: 11,\n whiteSpace: 'nowrap' as const,\n zIndex: 4,\n}\n\n// The bars, built once per rows, frame, colouring and genes rather than per\n// hover\nconst StripBars = observer(function StripBars({\n bars,\n frame,\n ramp,\n rowGenes,\n}: {\n bars: WalkRows\n frame: StripFrame\n ramp: { start: number; end: number } | undefined\n rowGenes: Map<string, RowGene[]> | undefined\n}) {\n const idPrefix = useId().replace(/[^\\w-]/g, '')\n const tree = useMemo(\n () => walkRowsTree(bars, frame, { ramp, rowGenes, idPrefix }),\n [bars, frame, ramp, rowGenes, idPrefix],\n )\n return <ElTree el={tree} />\n})\n\nconst WalkStrip = observer(function WalkStrip({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const bars = model.walkStripRows\n const frame = model.walkStripFrame\n const [menu, setMenu] = useState<\n { row: number; top: number; left: number } | undefined\n >(undefined)\n const [tip, setTip] = useState<\n { text: string; x: number; y: number } | undefined\n >(undefined)\n if (!bars || !frame) {\n return null\n }\n const hit = (e: React.MouseEvent<SVGSVGElement>) => {\n const box = e.currentTarget.getBoundingClientRect()\n const x = e.clientX - box.left\n const y = e.clientY - box.top\n return { ...stripRowAt(bars, frame, x, y), x, y }\n }\n const key = walkRowsKey(bars, {\n ramp: model.referenceRampDomain,\n rampCss: RAMP_GRADIENT_CSS,\n genes: stripGeneGaps(frame, model.walkRowGenes, model.walkRowGeneGaps),\n })\n return (\n <div\n data-testid=\"graph-walk-strip\"\n style={{ position: 'relative', borderTop: '1px solid #ddd' }}\n onMouseEnter={() => {\n model.setPointerInPane(true)\n }}\n onMouseLeave={() => {\n if (isAlive(model)) {\n model.setPointerInPane(false)\n model.setStripHover(null)\n }\n setTip(undefined)\n }}\n >\n <svg\n width={frame.width}\n height={frame.height}\n style={{ display: 'block', cursor: 'pointer' }}\n onMouseMove={e => {\n const at = hit(e)\n if (at.row) {\n model.setStripHover({ row: at.row.name, offset: at.offset! })\n setTip(\n frame.labelled\n ? undefined\n : {\n text: `${at.row.label} \u00B7 ${walkRowReadout(\n at.row,\n at.index === 0 ? undefined : bars.reference,\n )}`,\n x: at.x,\n y: at.y,\n },\n )\n } else {\n model.setStripHover(null)\n setTip(undefined)\n }\n }}\n onClick={e => {\n const at = hit(e)\n if (at.row && at.index! > 0) {\n model.toggleWalk(at.row.name)\n }\n }}\n onContextMenu={e => {\n const at = hit(e)\n if (at.row) {\n e.preventDefault()\n setMenu({ row: at.index!, top: e.clientY, left: e.clientX })\n }\n }}\n >\n <StripBars\n bars={bars}\n frame={frame}\n ramp={model.referenceRampDomain}\n rowGenes={model.walkRowGenes}\n />\n <ElTree el={walkMarksTree(bars, frame, model.walkStripMarks)} />\n <ElTree\n el={walkStripLabelsTree(\n bars,\n frame,\n new Set(model.walkLayers.map(l => l.walk)),\n )}\n />\n </svg>\n {tip ? (\n <div style={{ ...tipStyle, left: tip.x + 12, top: tip.y - 18 }}>\n {tip.text}\n </div>\n ) : null}\n <div style={keyStyle} data-testid=\"graph-walk-strip-key\">\n {key.map(entry => (\n <div key={entry.label} style={legendRowStyle}>\n <Swatch swatch={entry.swatch} />\n <span>{entry.label}</span>\n </div>\n ))}\n <div style={legendRowStyle}>\n <span>\n \u25AE ticks: where each walk passes the node under the pointer \u00B7 click a\n bar to lift its walk\n </span>\n </div>\n </div>\n {menu ? (\n <WalkRowContextMenu\n model={model}\n row={menu.row}\n bars={bars}\n top={menu.top}\n left={menu.left}\n onClose={() => {\n setMenu(undefined)\n }}\n />\n ) : null}\n </div>\n )\n})\n\nexport default WalkStrip\n", "import { observer } from 'mobx-react'\n\nimport type { GraphPaneModel } from '../model'\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: 4,\n}\n\n// A ring round the node a point on the walk strip lights, so a one-bp node\n// can be found in a hairball\nconst WalkStripLocator = observer(function WalkStripLocator({\n model,\n}: {\n model: GraphPaneModel\n}) {\n const at = model.walkStripLocator\n return at ? (\n <svg\n style={svgStyle}\n width={model.paneWidth}\n height={model.canvasHeight}\n data-testid=\"graph-walk-strip-locator\"\n >\n <circle\n cx={at.x}\n cy={at.y}\n r={11}\n fill=\"none\"\n stroke=\"white\"\n strokeWidth={4}\n />\n <circle\n cx={at.x}\n cy={at.y}\n r={11}\n fill=\"none\"\n stroke=\"#111\"\n strokeWidth={1.75}\n />\n </svg>\n ) : null\n})\n\nexport default WalkStripLocator\n", "import { Canvas2DRenderer } from '@jbrowse/bandage-core/renderer/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/reference/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/waiting-on-a-number scopes it.\nexport function createGraphRenderer(canvas: HTMLCanvasElement) {\n return Promise.resolve(new Canvas2DRenderer(canvas))\n}\n"],
5
+ "mappings": "0yBAAA,IAAAA,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAO,QAAU,eAAe,0CAA0C,ICA1E,IAAAC,GAAkC,SCClC,SAASC,GAAYC,EAAK,CACxB,MAAO,GAAGA,EAAI,OAAO,KAAKA,EAAI,MAAQ,GAAG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KACC,OAACpB,GAAA,CACC,MAAOvE,EACP,OAAQ2F,EAAY,OACpB,IAAKA,EAAY,IACjB,KAAMA,EAAY,KAClB,QAASE,EACX,EACE,KAEHD,KACC,OAACgB,GAAA,CACC,MAAO5G,EACP,IAAK4F,EAAW,IAChB,IAAKA,EAAW,IAChB,KAAMA,EAAW,KACjB,QAASC,EACX,EACE,KAEHN,KACC,OAAC,eAAY,MAAOA,EAAa,QAASC,EAAa,EACrD,KAEHJ,GAAapF,EAAM,SAClB,OAAC,eACC,MAAOA,EAAM,MACb,QACEA,EAAM,aACF,IAAM,CACJA,EAAM,UAAU,CAClB,EACA,OAER,EACE,MACN,CAEJ,CAAC,EAEM6G,GAAQ1B",
6
+ "names": ["require_useRenderingBackend", "__commonJSMin", "exports", "module", "import_react", "regionLabel", "loc", "edgeHoverText", "edge", "deletion", "nameOf", "id", "import_ui", "import_mobx_state_tree", "import_useRenderingBackend", "import_jsx_runtime", "Info_default", "_jsx", "import_mobx_react", "import_react", "import_mobx", "import_mobx_react", "import_jsx_runtime", "walkSwatchStyle", "walkBlockStyle", "walkBarStyle", "WalkKey", "walk", "label", "reference", "hint", "at", "key", "walkKey", "legendRowStyle", "encodingSwatchCss", "import_react", "ZOOM_PER_NOTCH", "NOTCH_PX", "LINE_PX", "PAGE_PX", "PINCH_GAIN", "MAX_NOTCHES_PER_EVENT", "wheelZoomFactor", "e", "px", "notches", "import_mobx_state_tree", "useWheelZoom", "canvas", "model", "c", "handleWheel", "e", "rect", "wheelZoomFactor", "usePaneGestures", "lastMouseRef", "hasMovedRef", "pendingRef", "contextNode", "setContextNode", "contextRow", "setContextRow", "screenToGraph", "screenX", "screenY", "getMouseCoord", "nodeAt", "x", "y", "nodePositions", "sx", "sy", "onStrip", "findHoveredNode", "onMouseDown", "node", "applyPending", "pending", "bars", "i", "findHoveredEdge", "scheduleFrame", "dropPending", "onMouseMove", "dx", "dy", "onMouseUp", "onMouseLeave", "onContextMenu", "row", "onClick", "import_jsx_runtime", "gridStyle", "FACET_GAP_PX", "titleStyle", "FACET_TITLE_PX", "FacetPanel", "model", "lift", "width", "height", "cell", "handlers", "canvas", "setCanvas", "walk", "useWheelZoom", "renderer", "Canvas2DRenderer", "drawing", "uploaded", "dispose", "built", "label", "WalkKey", "FacetPanels", "panels", "grid", "place", "columns", "i", "FacetPanels_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", "fixed", "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", "labels", "picked", "layer", "name", "selected", "n", "e", "value", "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_material", "import_mobx_react", "import_jsx_runtime", "style", "UnpopButton", "model", "poppedFrom", "UnpopButton_default", "import_ui", "import_jsx_runtime", "FilterList_default", "_jsx", "import_jsx_runtime", "FilterListOff_default", "_jsx", "import_mobx_react", "import_jsx_runtime", "WalkRowContextMenu", "model", "row", "bars", "top", "left", "onClose", "rows", "target", "assembly", "sample", "filters", "shown", "callback", "locLabel", "LineStyle_default", "FilterList_default", "FilterListOff_default", "import_react", "import_mobx_state_tree", "import_mobx_react", "import_jsx_runtime", "keyStyle", "tipStyle", "StripBars", "bars", "frame", "ramp", "rowGenes", "idPrefix", "tree", "walkRowsTree", "ElTree", "WalkStrip", "model", "menu", "setMenu", "tip", "setTip", "hit", "e", "box", "x", "y", "stripRowAt", "key", "walkRowsKey", "RAMP_GRADIENT_CSS", "stripGeneGaps", "at", "walkRowReadout", "walkMarksTree", "walkStripLabelsTree", "l", "entry", "legendRowStyle", "Swatch", "WalkRowContextMenu", "WalkStrip_default", "import_mobx_react", "import_jsx_runtime", "svgStyle", "WalkStripLocator", "model", "at", "WalkStripLocator_default", "createGraphRenderer", "canvas", "Canvas2DRenderer", "import_jsx_runtime", "tooltipStyle", "wrapperStyle", "canvasAreaStyle", "paperStyle", "loadingLayerStyle", "rowLabelStyle", "RowLabels", "model", "rowLabels", "label", "y", "screenY", "legendStackStyle", "LEGEND_INSET_PX", "pathSwatchStyle", "PathLegend", "pathLegend", "legendBoxStyle", "name", "color", "legendRowStyle", "WalkReadout", "lift", "w", "WalkKey", "OffReferenceRow", "walkSwatchStyle", "LIFT_BACKDROP_CSS", "rampStripStyle", "RAMP_GRADIENT_CSS", "rampEndsStyle", "ReferenceRampLegend", "domain", "offReference", "unplaced", "start", "end", "formatBp", "UNPLACED_SWATCH", "REFERENCE_RAMP_ALT_CSS", "exonSwatchStyle", "EXON_COLOR", "GeneLegend", "pin", "nodeLabelStyle", "deletionLabelStyle", "leaderStyle", "Legends", "ref", "el", "observer", "ReferenceStripLegend", "HaloLegend", "TubeMapLegend", "WalkRowsLegend", "GraphSizeLabels", "labels", "leaders", "key", "leader", "arcX", "arcY", "labelX", "labelY", "text", "x", "kind", "HoverTooltips", "hoveredNodeData", "hoveredEdgeData", "ownLocation", "nodeOwnLocation", "hoveredEdgeText", "edgeHoverText", "d", "id", "walkRow", "locLabel", "NodeContextMenu", "nodeId", "top", "left", "onClose", "own", "reference", "highlight", "callback", "Info_default", "nodeLaunchMenuItems", "target", "GraphCanvas", "ownChrome", "canvasRef", "canvas", "renderError", "retryRender", "createGraphRenderer", "handlers", "contextNode", "contextRow", "closeContextMenu", "usePaneGestures", "useWheelZoom", "faceted", "GraphToolbar_default", "FacetPanels_default", "TubeMapOverlay_default", "ReferenceStripOverlay_default", "BubbleHalos_default", "GenePins_default", "LabelLayer_default", "WalkRowsOverlay_default", "WalkStripLocator_default", "UnpopButton_default", "WalkStrip_default", "WalkRowContextMenu", "GraphCanvas_default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{c as I,d as Ze,e as j,f as Je,g as V,h as Q,i as Z,k as he,l as pe}from"./chunk-WTOQRUK2.js";import{A as fe,B as ue,C as z,a as G,b as Ke,c as F,d as ze,e as je,f as U,h as Ve,j as Qe,l as le,m as K,x as de,y as P,z as k}from"./chunk-B7GF3TC3.js";import{d as et}from"./chunk-KRXALLQG.js";import{c as Ue}from"./chunk-EHV7EUMI.js";import{c as C}from"./chunk-MYJYGSOH.js";import{a as Ge,b as Hn}from"./chunk-FY3BTKY4.js";var ar=Ge((yc,Wt)=>{Wt.exports=JBrowseExports.mobx});var Gt=Ge((bc,Ht)=>{Ht.exports=JBrowseExports["@jbrowse/core/util/groupKeys"]});function Gn(e){return e.id.endsWith("-")?"-":"+"}function Un(e,t){return t===Gn(e)?e.id:`-${e.id}`}function Kn(e,t){let n=e.map(()=>{}),r=0,o=0;for(;o<e.length&&e[o]!==void 0;o++)n[o]=r,r+=e[o];let s=t;for(let a=e.length-1;a>o&&e[a]!==void 0;a--)s-=e[a],n[a]=s;return n}function zn(e,t){let n=e.path.map(()=>[]);if(e.cs===void 0)return n;let r=Kn(t,e.pathLength),o=(i,c=!1)=>{for(let l=0;l<r.length;l++){let d=r[l],f=t[l];if(d!==void 0&&f!==void 0&&d<=i&&(i<d+f||c&&i===d+f))return{s:l,local:i-d,room:d+f-i}}},s=(i,c)=>{let l=n[i],d=l.at(-1);c.type==="substitution"&&d?.type==="substitution"&&d.pos+d.seq.length===c.pos?d.seq+=c.seq:l.push(c)},a=e.pathStart;for(let i of Ue(e.cs))if(i.op==="match")a+=i.length;else if(i.op==="substitution"){let c=o(a);c&&s(c.s,{type:"substitution",pos:c.local,seq:i.seq}),a+=1}else if(i.op==="insertion"){let c=o(a,a===e.pathEnd);c&&s(c.s,{type:"insertion",pos:c.local,seq:i.seq})}else{let c=i.length;for(;c>0;){let l=o(a),d=l?Math.min(c,l.room):c;l&&s(l.s,{type:"deletion",pos:l.local,length:d}),a+=d,c-=d}}return n}function Us(e,t,n){let r=new Map(e.nodes.map(s=>[s.name,s])),o=[];for(let s of t){let a=s.path.map(d=>r.get(d.name)),i=a.flatMap((d,f)=>d?[f]:[]),c=i[0],l=i.at(-1);if(c!==void 0&&l!==void 0){let d=zn(s,a.map(m=>m?.length)),f=i.map(m=>Un(a[m],s.path[m].strand)),u=a[l].length;o.push({id:n+o.length,name:s.name,type:"read",sourceTrackID:1,sequence:f,sequenceNew:i.map((m,p)=>({nodeName:f[p],mismatches:d[m]})),firstNodeOffset:c===0?s.pathStart:0,finalNodeCoverLength:l===s.path.length-1?u-(s.pathLength-s.pathEnd):u,mapping_quality:s.mappingQuality===255?0:s.mappingQuality,is_secondary:s.secondary,is_reverse:s.strand==="-"})}}return o}var jn=["#6baed6","#4292c6","#2171b5","#08519c"],Vn=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function tt(e){let t=e.is_reverse?Vn:jn;return t[e.id%t.length]}var J=8,me=34,ee=12,Qn=60;function Zn({count:e,bounds:t,pixelRows:n,width:r,room:o,columns:s}){function a(c){let l=Math.ceil(e/c),d=Math.floor((r-(c-1)*J)/c),f=(o-l*me-(l-1)*J)/l,u=(d-2*ee)/t.w,m=t.h>0?(f-2*ee)/t.h:1/0,p=n?u:Math.min(u,m),h=n?t.h:t.h*p,g=Math.floor(Math.max(Qn,Math.min(h+2*ee,f)));return{columns:c,width:d,height:g,scale:p,total:l*(g+me)+(l-1)*J}}if(s!==void 0)return a(Math.max(1,Math.min(e,Math.round(s))));let i=a(1);for(let c=2;c<=e;c++){let l=a(c);l.scale>i.scale&&(i=l)}return i}var Jn=[{value:"",label:"None",description:"Every lifted walk in one drawing"},{value:"walk",label:"A panel per walk",description:"One panel per lifted walk, side by side"},{value:"sample",label:"A row per sample",description:"A row per sample, a column per haplotype"}];function eo(e){let t=typeof e=="string"?{field:e}:e??{};return{field:t.field==="walk"||t.field==="sample"?t.field:"",domain:[...t.domain??[]],...t.columns===void 0?{}:{columns:t.columns}}}function nt(e,t){let n=new Map(t.map((o,s)=>[o,s])),r=o=>n.get(o)??t.length;return e.map((o,s)=>({name:o,i:s})).sort((o,s)=>r(o.name)-r(s.name)||o.i-s.i).map(({name:o})=>o)}function to(e,t,n=[]){let r=nt(e,n),o={columns:void 0,count:e.length,cells:e.map(l=>r.indexOf(l))};if(t==="walk")return o;let s=e.map(l=>{let[d,f,u]=l.split("#"),m=Number(f);return u!==void 0&&Number.isInteger(m)&&m>=0?{sample:d,column:Math.max(0,m-1)}:void 0}),a=nt([...new Set(s.flatMap(l=>l?[l.sample]:[]))],n),i=Math.max(1,...s.map(l=>l?l.column+1:1)),c=s.map(l=>l?a.indexOf(l.sample)*i+l.column:-1);return c.includes(-1)||new Set(c).size<c.length?o:{columns:i,count:a.length*i,cells:c}}var no=10;function oo(e,t){let n=e.end-e.start,r=e.longestAlleleLength-e.shortestAlleleLength;return t.find(o=>r<=no*(o.end-o.start)&&(n===0?o.start<=e.start&&e.start<=o.end:Math.min(e.end,o.end)-Math.max(e.start,o.start)>=n/2))}var ro=40;function $(e){return e>=1e4?`${(e/1e3).toFixed(0)} kb`:e>=1e3?`${(e/1e3).toFixed(1)} kb`:`${e} bp`}function so(e,t){let n=$(e),r=$(t),o=r.slice(r.indexOf(" "));return n.endsWith(o)?`${n.slice(0,-o.length)}\u2013${r}`:`${n}\u2013${r}`}function ot(e){return e>=et?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function io(e,t=[]){let n=ao(e,t);return e.partial?{...n,label:`${n.label}, partial`}:n}function ao(e,t){let n=e.end-e.start,{shortestAlleleLength:r,longestAlleleLength:o,pathCount:s,segmentCount:a,inversion:i}=e,c=so(r,o);if(a>=ro)return{kind:"superbubble",label:`${c} superbubble, ${a} segments, ${ot(s)}${i?", inv":""}`};if(i)return{kind:"inversion",label:`${$(o)} inv`};let l=o!==r?oo(e,t):void 0;if(l){let f=l.name?` (${l.name})`:"";return{kind:"repeat",label:`${c} repeat array${f}, ${ot(s)}`}}let d=s>2?`, ${s} alleles`:"";return r===o&&r===n?n<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${$(n)} sub`}:n===0||r===n?{kind:"insertion",label:`\u2264${$(o-n)} ins${d}`}:o===n?{kind:"deletion",label:`${$(n-r)} del${d}`}:{kind:"complex",label:`${$(n)} ref \u2192 ${c}, ${s} alleles`}}var co={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},lo={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function fo(e){return e.segments.split(",").filter(Boolean)}function te(e){return`hsl(${e}, 70%, 50%)`}function ge(e,t){let n=(e-t.start)/(t.end-t.start);return Math.max(0,Math.min(1,n))*Q}var uo=30;function rt({start:e,bp:t,reversed:n},r){let o=ge(e,r),s=ge(e+t,r);if(s-o<1)return[(o+s)/2];let a=Math.ceil((s-o)/uo);return Array.from({length:a+1},(i,c)=>ge(e+t*(n?a-c:c)/a,r))}var xe=Array.from({length:7},(e,t)=>({offset:t/6,color:te(t/6*Q)})),st=`linear-gradient(to right, ${xe.map(e=>`${e.color} ${e.offset*100}%`).join(", ")})`;function R(e,t={},...n){return{tag:e,attrs:t,children:n.filter(r=>!!r||r==="")}}function it(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function ho(e){return it(e).replaceAll('"',"&quot;")}function po(e){if(typeof e=="string")return it(e);let t=Object.entries(e.attrs).filter(([,n])=>n!==void 0).map(([n,r])=>` ${n}="${ho(String(r))}"`).join("");return`<${e.tag}${t}>${e.children.map(po).join("")}</${e.tag}>`}var we="#2f8fd6",Ee="#8e3fbf",Se="#bdbdbd",Y="#1c1c22",ve=12,Re=4,be=12,mo=6,go=3;function X(e){return`${(e/1e3).toFixed(e<1e4?1:0)} kb`}function at(e,t){return t?` \u2248 ${Math.round(e/t)} units`:""}function ct(e,t,n,r){let{bp:o,gapBp:s,complete:a}=e;if(!t)return`${X(o)}${at(o,n)}`;let i=o-t.bp,c=i===0?"":` (${i>0?"+":"\u2212"}${X(Math.abs(i))})`,l=s>0?` \xB7 ${X(s)} outside the cut`:"",d=r?` \xB7 called ${X(r.bp)}${r.spanningReads===0?" \xB7 no spanning read":""}`:"";return`${X(o)}${at(o,n)}${c}${l}${a?"":" \xB7 partial walk"}${d}`}function lt(e,t,n){let r=t+6;return r+e.length*F<n?{x:r,anchor:"start",halo:!1}:{x:t-6,anchor:"end",halo:!0}}function dt(e,t,n){if(t*n<go)return[];let r=[];for(let o=t;o<e;o+=t)r.push(o);return r}function ft(e,t){if(e.gap)return{fill:Se};if(!t)return{fill:e.onReference?we:Ee};if(e.referenceStart===void 0)return{fill:Z};let n=rt({...e,start:e.referenceStart},t);return n.length===1?{fill:te(n[0])}:{stops:n.map(te)}}function Me(e,t,n){return e.reversed?{start:e.start-n,end:e.start-t}:{start:t-e.start,end:n-e.start}}function xo(e,t){return e.reversed?{start:e.start-t,end:e.start}:{start:e.start,end:e.start+t}}function yo(e,t){let n=new Map;for(let r of e){let o=t.get(r.name);if(!r.axis||!o)continue;let s=r.axis,a=({start:i,end:c})=>({start:Math.max(0,i),end:Math.min(r.bp,c)});n.set(r.name,o.map(i=>({name:i.name,...a(Me(s,i.start,i.end)),exons:i.exons.map(c=>a(Me(s,c.start,c.end))).filter(c=>c.end>c.start)})).filter(i=>i.end>i.start).sort((i,c)=>i.start-c.start))}return n}var bo=9,Mo=5.2,wo=8,ut=(e,t)=>Math.min(2,(e-t)/2-1);function ht(e,t){return ut(e,t)>=1}function pt(e,t,n,{rowPx:r=G,barPx:o=ve}={}){if(!ht(r,o))return[];let s=ut(r,o),a=e.map(l=>{let d=t(l.start);return{g:l,x:d,w:Math.max(2,t(l.end)-d)}}),i=[],c=new Set((o>=wo?[...a]:[]).sort((l,d)=>l.w-d.w).filter(({g:l,x:d,w:f})=>{let u=l.name.length*Mo/2,m=[d+f/2-u,d+f/2+u];return 2*u>f+6||i.some(([p,h])=>m[0]<h+2&&m[1]>p-2)?!1:(i.push(m),!0)}));return a.map(l=>({name:l.g.name,x:l.x,y:n-o/2-s,w:l.w,h:o+2*s,exons:l.g.exons.map(d=>({x:t(d.start),w:Math.max(1,t(d.end)-t(d.start))})),label:c.has(l)?{x:l.x+l.w/2,y:n+3,size:bo}:void 0}))}var ye=e=>`${e} row${e===1?"":"s"}`;function Eo(e,t={}){let n=[{swatch:t.ramp?{kind:"bar",fill:t.rampCss??st,ramp:!0}:{kind:"bar",fill:we},label:`on ${e.reference.label}'s path`},{swatch:{kind:"bar",fill:t.ramp?Z:Ee},label:`off ${e.reference.label}'s path`}];return[e.reference,...e.rows].some(r=>r.gapBp>0)&&n.push({swatch:{kind:"gap",fill:Se},label:"walked outside the cut"}),t.genes?.crowded?n.push({swatch:{kind:"gene"},label:"genes left out: too many rows to box them in",note:!0}):t.genes&&(n.push({swatch:{kind:"gene"},label:"genes, each row's own annotation"}),t.genes.untracked&&n.push({swatch:{kind:"gene"},label:`no gene track for ${ye(t.genes.untracked)}`,note:!0}),t.genes.unplaced&&n.push({swatch:{kind:"gene"},label:`no contig coordinates for ${ye(t.genes.unplaced)}`,note:!0}),t.genes.unread&&n.push({swatch:{kind:"gene"},label:`genes not read for the last ${ye(t.genes.unread)}`,note:!0})),n}var mt="#111",gt="#9e9e9e",_e="#c62828";function xt(e){return e.agrees===!1?_e:e.spanningReads===0?gt:mt}function So(e,t,n,r="walk-key"){let o=0,s=e.flatMap((a,i)=>{let c=`${r}-ramp-${i}`,l=!a.note&&a.swatch.kind==="bar"&&a.swatch.ramp?R("linearGradient",{id:c},...xe.map(u=>R("stop",{offset:u.offset,"stop-color":u.color}))):void 0,d=a.note?void 0:a.swatch.kind==="gene"?R("rect",{x:o,y:5,width:18,height:8,fill:"none",stroke:Y,"stroke-width":1.5}):R("rect",{x:o,y:a.swatch.kind==="gap"?7:5,width:18,height:a.swatch.kind==="gap"?Re:8,rx:2,fill:l?`url(#${c})`:a.swatch.fill}),f=R("text",{x:a.note?o:o+23,y:13,"font-style":a.note?"italic":void 0,fill:a.note?"#666":void 0},a.label);return o+=(a.note?0:23)+a.label.length*F+16,[l,d,f].filter(u=>u!==void 0)});return{width:o,tree:R("g",{transform:`translate(${t} ${n})`,"font-family":"Helvetica, Arial, sans-serif","font-size":11},...s)}}function vo(e,t,n=0){let r=t/Math.max(1,e),o=Math.max(n,Math.min(G,r>=1?Math.floor(r):r));return{rowPx:o,barPx:o<=3?o:Math.max(3,Math.round(o*.6)),labelled:o>=be,readouts:o>=be}}function yt(e,t){let n=1/t,r=[],o=[],s=()=>{if(o.length!==0){if(o.length===1)r.push(o[0]);else{let i=0,c=0;for(let f of o)f.onReference?i+=f.bp:c+=f.bp;let l=i>=c,d=o.find(f=>f.onReference===l);r.push({start:o[0].start,bp:i+c,onReference:l,referenceStart:l?d.referenceStart:void 0,...d.reversed?{reversed:!0}:{}})}o=[]}},a=0;for(let i of e){if(i.gap||i.bp>=n){s(),a=0,r.push(i);continue}o.push(i),a+=i.bp,a>=n&&(s(),a=0)}return s(),r}function Ro(e,t,n){return R("g",{class:"row-gene","data-testid":"graph-walk-gene"},R("title",{},e.name),...e.exons.map(r=>R("rect",{x:r.x,y:t-n/2,width:r.w,height:n,fill:Y,opacity:.35})),R("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:Y,"stroke-width":1.5}),e.label&&R("text",{x:e.label.x,y:e.label.y,"font-family":"sans-serif","font-size":e.label.size,"font-weight":600,"text-anchor":"middle",fill:Y,stroke:"white","stroke-width":2.5,"paint-order":"stroke"},e.name))}function _o(e,t,n={}){let r=h=>h*t.scaleX+t.translateX,o=t.rowPx??G,s=t.barPx??ve,a=Math.min(3,Math.max(0,(o-s)/2)),i=h=>h*o*t.scaleY+t.translateY,{origin:c,unit:l,reference:d,rows:f}=e,u=h=>r(c+h),m=n.idPrefix??"walkrow",p=(h,g)=>{let x=i(g);if(x<-s||x>t.height+s)return;let M=yt(h.runs,t.scaleX).flatMap(v=>{let _=ft(v,n.ramp),H=v.gap?Math.min(Re,s):s,D=`${m}-${g}-${v.start}`,He=R("rect",{x:u(v.start),y:x-H/2,width:Math.max(1,v.bp*t.scaleX),height:H,fill:"stops"in _?`url(#${D})`:_.fill});return"stops"in _?[R("linearGradient",{id:D},..._.stops.map((Yn,Wn)=>R("stop",{offset:Wn/(_.stops.length-1),"stop-color":Yn}))),He]:[He]}),w=l&&s>=mo?dt(h.bp,l,t.scaleX).map(v=>R("line",{x1:u(v),x2:u(v),y1:x-s/2,y2:x+s/2,stroke:"white","stroke-width":1})):[],{call:b}=h,E=ct(h,g===0?void 0:d,l,b),y=lt(E,u(h.bp),t.width),S=t.readouts??!0;return R("g",{"data-testid":g===0?"graph-walk-reference":"graph-walk-row"},...M,...w,...pt(n.rowGenes?.get(h.name)??[],u,x,{rowPx:o,barPx:s}).map(v=>Ro(v,x,s)),b&&R("rect",{"data-testid":"graph-walk-call",x:u(b.bp)-1,y:x-s/2-a,width:2,height:s+2*a,fill:xt(b)}),S&&R("text",{x:y.x,y:x+4,"font-family":"sans-serif","font-size":11,fill:b?.agrees===!1?_e:"#333",stroke:y.halo?"white":void 0,"stroke-width":y.halo?3:void 0,"paint-order":"stroke","text-anchor":y.anchor},E))};return R("g",{},...[d,...f].map(p))}var wt=2,ne=8192;function Et(){return typeof devicePixelRatio>"u"?1:Math.min(devicePixelRatio,wt)}var bt=!1;function Mt(e,t,n){let r=Math.round(e*t);return r>ne?(bt||(bt=!0,console.warn(`Canvas ${n} ${r}px exceeds the safe limit ${ne}px and was clamped`)),ne):r}function Ne(e,t,n){let r=Et(),o=Mt(t,r,"width"),s=Mt(n,r,"height");(e.width!==o||e.height!==s)&&(e.width=o,e.height=s);let a=`${t}px`,i=`${n}px`;e.style.width!==a&&(e.style.width=a),e.style.height!==i&&(e.style.height=i)}var pi=class{constructor(e){this.transform=null,this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.highlightFactor=1;let t=e.getContext("2d");if(!t)throw new Error("Canvas 2D context not available");this.canvas=e,this.ctx=t}setErrorHandler(e){}releaseOffscreenTargets(){}resize(e,t){Ne(this.canvas,e,t)}uploadGeometry(e){this.batch=e,this.highlightedEdge=null}setNodeHighlights(e){this.nodeHighlights=e}setEdgeHighlight(e,t){this.highlightedEdge=e,this.highlightFactor=t}updateTransform(e){this.transform=e}render(e){if(!this.transform)return;let n=this.ctx,{width:r,height:o}=n.canvas;e[3]<1&&n.clearRect(0,0,r,o),n.fillStyle=Ze([e[0],e[1],e[2]],e[3]),n.fillRect(0,0,r,o);let s=this.batch;s&&(n.lineCap="round",n.lineJoin="round",this.renderEdges(s),this.renderNodes(s),this.renderArrows(s))}renderEdges(e){let t=this.transform,n=this.ctx,r=this.highlightedEdge===null?void 0:e.edgeCurveRuns.get(this.highlightedEdge);for(let{color:o,items:s}of Oe(e.edgeCurves,(a,i)=>({color:oe(r,i)?j(a.color,this.highlightFactor):a.color,weight:a.thickness,last:oe(r,i)}))){n.strokeStyle=I(o),n.lineWidth=s[0].thickness*2*t.dpr,n.beginPath();for(let a of s){let i=a.curves[0];n.moveTo(i.x0*t.scaleX+t.translateX,i.y0*t.scaleY+t.translateY);for(let c of a.curves)n.bezierCurveTo(c.cx0*t.scaleX+t.translateX,c.cy0*t.scaleY+t.translateY,c.cx1*t.scaleX+t.translateX,c.cy1*t.scaleY+t.translateY,c.x1*t.scaleX+t.translateX,c.y1*t.scaleY+t.translateY)}n.stroke()}}renderNodes(e){let t=this.transform,n=this.ctx,r=new Map;for(let[o,s]of this.nodeHighlights){let a=e.nodeStrokeRuns.get(o);if(a)for(let i=a.start;i<a.start+a.count;i++)r.set(i,s)}for(let{color:o,items:s}of Oe(e.nodeStrokes,(a,i)=>{let c=r.get(i);return{color:c===void 0?a.color:j(a.color,c),weight:a.thickness,last:c!==void 0}})){n.strokeStyle=I(o),n.lineWidth=s[0].thickness*2*t.dpr,n.beginPath();for(let a of s){let i=a.points[0];n.moveTo(i.x*t.scaleX+t.translateX,i.y*t.scaleY+t.translateY);for(let c=1,l=a.points.length;c<l;c++){let d=a.points[c];n.lineTo(d.x*t.scaleX+t.translateX,d.y*t.scaleY+t.translateY)}}n.stroke()}}renderArrows(e){let t=this.transform,n=this.ctx,r=this.highlightedEdge===null?void 0:e.arrowRuns.get(this.highlightedEdge);for(let{color:o,items:s}of Oe(e.arrows,(a,i)=>({color:oe(r,i)?j(a.color,this.highlightFactor):a.color,weight:0,last:oe(r,i)}))){n.fillStyle=I(o),n.beginPath();for(let a of s){let[i,c,l,d]=Oo(a,t);n.moveTo(i.x,i.y),n.lineTo(c.x,c.y),n.lineTo(l.x,l.y),n.lineTo(d.x,d.y),n.closePath()}n.fill()}}dispose(){this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null}},No=.25;function Oo(e,t){let n=Math.cos(e.angle),r=Math.sin(e.angle),o=e.x*t.scaleX+t.translateX,s=e.y*t.scaleY+t.translateY,a=e.length*t.dpr,i=e.halfWidth*t.dpr,c=o-n*a,l=s-r*a,d=a*(1-No);return[{x:o,y:s},{x:c-r*i,y:l+n*i},{x:o-n*d,y:s-r*d},{x:c+r*i,y:l-n*i}]}function oe(e,t){return e!==void 0&&t>=e.start&&t<e.start+e.count}function Oe(e,t){let n=new Map,r=new Map;for(let o=0,s=e.length;o<s;o++){let a=e[o],{color:i,weight:c,last:l}=t(a,o),d=l?r:n,f=`${i}:${c}`,u=d.get(f);u?u.items.push(a):d.set(f,{color:i,items:[a]})}return[...n.values(),...r.values()]}var Ao="#daa520",To=1,Co=2,ko=4;function yi(e,t,n,r=o=>o){let o=s=>{let a=t(s)*2;return n?.nodeIds.has(s)?Math.max(a,n.walks.length*ko):a};return e.flatMap(s=>s.exonsByNode.map(({nodeId:a,d:i})=>({key:`${s.gene.name}-${s.gene.start}-${a}`,d:r(i),inner:o(a)+2*To})))}function bi(e,t){if(e.length===0)return;let n=(r,o,s)=>R("path",{d:r.d,fill:"none",stroke:o,"stroke-width":s,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":t.transform?"non-scaling-stroke":void 0});return R("g",{},R("mask",{id:t.id,maskUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height},R("g",{transform:t.transform},...e.map(r=>n(r,"#fff",r.inner+2*Co)),...e.map(r=>n(r,"#000",r.inner)))),R("rect",{width:t.width,height:t.height,fill:Ao,mask:`url(#${t.id})`}))}function Ae(e,t,n){let r=Math.round(t),o=Math.round(n);return`${e?`${e}:`:""}${P(r)}-${P(o)} (${k(o-r)})`}function $o(e,t){let{field:n}=e.encoding,r=e.range?Ae(e.range.contig,e.range.start,e.range.end):void 0,o=n==="progress"?r:n==="reference"&&t?Ae(t.name,t.start,t.end):void 0,s=e.range?e.range.end-e.range.start:e.bp,a=s-e.bp;return{delta:e.referenceBp===void 0||s===e.referenceBp?"":` ${s>e.referenceBp?"+":"\u2212"}${k(Math.abs(s-e.referenceBp))}`,outside:a>0?`, ${k(a)} outside the cut`:"",reversed:e.reversedBp>0?`, ${k(e.reversedBp)} reversed`:"",shades:n!=="walk",scale:o,hover:o===r?void 0:r}}function Io(e,t,n){let r=e.progress.get(t),o=e.range;if(r===void 0||!o)return;let s=Math.round(o.start+r*(o.end-o.start)-n/2);return`${o.contig}:${P(s)}-${P(s+n)}`}var Lo=50;function St(e,t){return t>0?Math.max(1,e/t):Lo}function Po(e){let t=new Set,n=1/0,r=-1/0;for(let o of e)t.add(o.minY),n=Math.min(n,o.minY),r=Math.max(r,o.minY);return t.size>1?(r-n)/(t.size-1):void 0}function Xo(e,t,n){let r=St(t,e.length);return{x:r,y:n>0?St(n,e.length):Po(e)??r}}function vt(e,t,n,r){return e===void 0?Xo(t,n,r):typeof e=="number"?{x:e,y:e}:e}function qo(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let o=r.get(n);return o||(o=[],r.set(n,o)),o}function Rt(e,t,n,r,o,s,a){let i=Math.floor(n/t.x),c=Math.floor(o/t.x),l=Math.floor(r/t.y),d=Math.floor(s/t.y);for(let f=i;f<=c;f++)for(let u=l;u<=d;u++)qo(e,f,u).push(a)}function _t(e,t,n,r,o,s){let a=Math.floor((n-o)/t.x),i=Math.floor((n+o)/t.x),c=Math.floor((r-s)/t.y),l=Math.floor((r+s)/t.y),d=[],f=new Set;for(let u=a;u<=i;u++){let m=e.get(u);if(m)for(let p=c;p<=l;p++){let h=m.get(p);if(h)for(let g of h)f.has(g)||(f.add(g),d.push(g))}}return d}var Nt=class{constructor(e,t){this.cells=new Map;let n=[],r=0,o=0;for(let[s,a]of Object.entries(e))for(let i=0;i<a.length-1;i++){let c=a[i],l=a[i+1],d=Math.min(c.x,l.x),f=Math.min(c.y,l.y),u=Math.max(c.x,l.x),m=Math.max(c.y,l.y);r+=u-d,o+=m-f,n.push({entry:{nodeId:s,segmentIdx:i},minX:d,minY:f,maxX:u,maxY:m})}this.cellSize=vt(t,n,r,o);for(let s of n)Rt(this.cells,this.cellSize,s.minX,s.minY,s.maxX,s.maxY,s.entry)}query(e,t,n,r=n){return _t(this.cells,this.cellSize,e,t,n,r)}},Ot=class{constructor(e,t,n,r,o,s,a=0,i,c=!1){this.cells=new Map,this.edgeCurves=Je(e,t,r,s,a,i,c);let l=[],d=0,f=0;for(let u=0;u<t.edges.length;u++){let m=t.edges[u],p=e[m.from],h=e[m.to],g=this.edgeCurves.get(u);if(p?.length&&h?.length&&g){let{minX:x,minY:M,maxX:w,maxY:b}=Ve(g),E=m.pathIds?.length??0;if(n&&E>0){let y=0,S=0;for(let v of K(p,h,E,r))y=Math.max(y,Math.abs(v.x)),S=Math.max(S,Math.abs(v.y));x-=y,M-=S,w+=y,b+=S}d+=w-x,f+=b-M,l.push({ei:u,minX:x,minY:M,maxX:w,maxY:b})}}this.cellSize=vt(o,l,d,f);for(let u of l)Rt(this.cells,this.cellSize,u.minX,u.minY,u.maxX,u.maxY,u.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,t,n,r=n){return _t(this.cells,this.cellSize,e,t,n,r)}};function kt(e,t,n,r,o,s){let a=o-n,i=s-r,c=a*a+i*i;if(c===0)return Math.hypot(e-n,t-r);let l=Math.max(0,Math.min(1,((e-n)*a+(t-r)*i)/c));return Math.hypot(e-(n+l*a),t-(r+l*i))}function Bo(e,t,n,r,o,s,a,i,c,l){let d=1/0,f=20,u=n,m=r;for(let p=1;p<=f;p++){let h=p/f,g=1-h,x=g*g*g*n+3*g*g*h*o+3*g*h*h*a+h*h*h*c,M=g*g*g*r+3*g*g*h*s+3*g*h*h*i+h*h*h*l;d=Math.min(d,kt(e,t,u,m,x,M)),u=x,m=M}return d}function Do(e,t,n){return Bo(e,t,n.x0,n.y0,n.cx0,n.cy0,n.cx1,n.cy1,n.x1,n.y1)}function At(e,t,n,r=1){let o=1/0;for(let s of n){let a=Do(e,t,r===1?s:{x0:s.x0,y0:s.y0*r,cx0:s.cx0,cy0:s.cy0*r,cx1:s.cx1,cy1:s.cy1*r,x1:s.x1,y1:s.y1*r});a<o&&(o=a)}return o}var Tt=new WeakMap;function $t(e,t){let n=Tt.get(e);if(n?.version===t)return n.index;let r=new Nt(e);return Tt.set(e,{version:t,index:r}),r}var Ct=new WeakMap;function Fo(e,t,n,r,o,s,a,i=!1){let c=Ct.get(e);if(c?.graph===t&&c.drawPaths===n&&c.scaleX===r.scaleX&&c.scaleY===r.scaleY&&c.version===o&&c.deletions===s&&c.routes===a&&c.stranded===i)return c.index;let l=new Ot(e,t,n,r,void 0,s,o,a,i);return Ct.set(e,{graph:t,drawPaths:n,scaleX:r.scaleX,scaleY:r.scaleY,version:o,index:l,deletions:s,routes:a,stranded:i}),l}var Yo=5;function Ti(e,t,n,r,o=0,s){let a=le(r),i=$t(e,o),c=m=>Math.max(Yo,m)/r.scaleX,l=c(s?.maxHalfWidthPx??0),d=i.query(t,n,l,l/a),f=null,u=1/0;for(let{nodeId:m,segmentIdx:p}of d){let h=e[m],g=kt(t,n*a,h[p].x,h[p].y*a,h[p+1].x,h[p+1].y*a);g<u&&g<c(s?.halfWidthPx(m)??0)&&(u=g,f=m)}return f}function Wo(e,t,n){let r=t.x-e.x,o=t.y-e.y,s=0,a=1;for(let[i,c]of[[-r,e.x-n.x0],[r,n.x1-e.x],[-o,e.y-n.y0],[o,n.y1-e.y]])if(i===0){if(c<0)return!1}else i<0?s=Math.max(s,c/i):a=Math.min(a,c/i);return s<=a}function It(e,t,n=0){let r=$t(e,n),o=s=>({x:s.x*t.scaleX+t.translateX,y:s.y*t.scaleY+t.translateY});return s=>{let a=new Set,i=r.query(((s.x0+s.x1)/2-t.translateX)/t.scaleX,((s.y0+s.y1)/2-t.translateY)/t.scaleY,Math.abs((s.x1-s.x0)/2/t.scaleX),Math.abs((s.y1-s.y0)/2/t.scaleY));for(let{nodeId:c,segmentIdx:l}of i){let d=e[c];!a.has(c)&&Wo(o(d[l]),o(d[l+1]),s)&&a.add(c)}return a}}function Ci(e,t,n,r,o,s,a=0,i,c,l,d=!1){let f=le(o),u=10/o.scaleX,m=Fo(e,t,s,o,a,i,l,d),p=m.query(n,r,u,u/f),h=null,g=u;for(let x of p){let M=t.edges[x],w=e[M.from],b=e[M.to];if(!w?.length||!b?.length||c?.has(x))continue;let E=M.pathIds?.length??0,y=m.getCurves(x);if(!y)continue;let S;if(!s||E===0)S=At(n,r*f,y,f);else{let v=1/0;for(let _ of K(w,b,E,o)){let H=_.x===0&&_.y===0?y:Qe(y,_.x,_.y),D=At(n,r*f,H,f);D<v&&(v=D)}S=v}S<g&&(g=S,h=x)}return h}var Lt=3.4,Te=6,Ho=8,Go=18,Uo=2,Ko=Ke+ze;function Pt(e){let t=e.gene.end-e.gene.start;if(e.covered>=.98)return;let[n,r]=t>=1e6?[1e6,"Mb"]:t>=1e3?[1e3,"kb"]:[1,"bp"],o=s=>+(s/n).toFixed(n===1?0:1);return`${o(e.covered*t)} of ${o(t)} ${r}`}function Xt(e,t,n,r){let o=n/2;return qt(e,s=>s.gene.end-s.gene.start).map(s=>{let{x:a,y:i}=t(s.at),c=Pt(s);return{item:s,x:a,y:i+n+Go,text:c?`${s.gene.name} \xB7 ${c}`:s.gene.name,fallback:c?`${s.gene.name} \u2026`:void 0,stack:Uo,fits:l=>[...r({x0:l.x0-o,x1:l.x1+o,y0:l.y0-o,y1:l.y1+o})].every(d=>s.nodeIds.has(d))}})}function qt(e,t){return[...e].sort((n,r)=>t(r)-t(n))}function zo(e){let{paneWidth:t,canvasHeight:n,translateX:r,translateY:o}=e,{scaleX:s,scaleY:a}=e.axisScale,i={width:t,height:n},c=y=>({x:y.x*s+r,y:y.y*a+o}),l=e.drawnRowLabels.map(({label:y,y:S})=>de(y,S*a+o)),d=e.referenceStripZonePx??0;d>0&&l.push({x0:0,x1:t,y0:0,y1:d}),e.legendSize.width>0&&l.push({x0:t-Te-e.legendSize.width,x1:t,y0:0,y1:d+Te+e.legendSize.height}),e.poppedFrom&&l.push({x0:0,x1:60+e.poppedFrom.label.length*F*1.2,y0:0,y1:44});let f=je(i,l),u=e.drawnRowLabels.length>0,m=u?Math.min(...e.drawnRowLabels.map(y=>y.y)):1/0,p=e.contigThickness*Lt,h=qt(e.bubbleHalos,y=>y.members),g=U(h.map(y=>{let{x:S,y:v}=c({x:y.labelAt.x,y:Math.min(y.labelAt.y,m)}),_=v-p/2-6;return{item:y,x:S,y:u?Math.max(_,Ko):_,text:y.label}}),i,f),x=U(Xt(e.genePins,c,e.contigThickness,It(e.nodePositions??{},{scaleX:s,scaleY:a,translateX:r,translateY:o},e.positionsVersion)),i,f),M=e.nodePositions&&e.labelsNodeSizes?fe({nodePositions:e.nodePositions,nodeLengths:e.nodeLengths,deletions:e.deletions,deletionRoutes:e.deletionRoutes,stranded:e.stranded,alleleDeletions:e.alleleDeletions,axis:e.axisScale,translateX:r,translateY:o,width:t,height:n,version:e.positionsVersion}):{deletions:[],nodes:[]},w=z(M.deletions,f),b=U(h.flatMap(y=>y.routes.map(S=>{let{x:v,y:_}=c(S.at);return{item:{halo:y,route:S},x:v,y:_+4,text:S.text,stack:Ho}})),i,f),E=z(M.nodes,f,ue(t,n));return{bubbles:g,genes:x,routes:b,sizes:[...w,...E]}}function jo(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),r=new Map;t.nodes.forEach(o=>{let s=n.get(o.name);if(o.order>=0&&s&&C(s)){let{refName:a,start:i}=s.stable;(r.get(a)??r.set(a,[]).get(a)).push({bp0:i,bp1:i+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}});for(let o of r.values())o.sort((s,a)=>s.bp0-a.bp0);return r}function re(e,t,n=!1){let r=0,o=e.length-1;for(;r<o;){let i=r+o>>1,c=e[i].bp1;(n?c<t:c<=t)?r=i+1:o=i}let s=e[r];if(t<=s.bp0)return s.x0;let a=s.bp1-s.bp0;return a>0?s.x0+(Math.min(t,s.bp1)-s.bp0)/a*(s.x1-s.x0):s.x0}function se(e,t,n){let r=re(e,t),o=re(e,n,!0);return{x0:Math.min(r,o),x1:Math.max(r,o)}}function Vo(e){let t;for(let n of e.values())(!t||n.length>t.length)&&(t=n);return t}var Bt=5,Qo=10,Zo=110,Jo=3;function Dt(e){return e?"#b0b0b8":"#55555c"}function er(e){let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function Ft(e){let t=[];for(let n of e)t.every(r=>Math.abs(n.at-r.at)>=(n.width+r.width)/2+Qo)&&t.push(n);return t.map(({text:n,at:r})=>({text:n,at:r}))}function tr(e,t,n,r){let o=e[0],s=e.at(-1);if(!o||!s)return;let a=t(o.x0),i=t(s.x1),c=s.bp1-o.bp0;if(i<=a||c<=0)return;let l=er(c/(i-a)*Zo),d=[],f=[];for(let u=Math.ceil(o.bp0/l)*l;u<=s.bp1;u+=l){let m=Math.round(t(re(e,u)))+.5;if(m>=0&&m<=n){d.push(m);let p=u.toLocaleString("en-US");f.push({text:p,at:m,width:r(p)})}}return{spans:[{x0:a,x1:i}],ticks:d,labels:Ft(f)}}function nr(e,t,n,r){let o=e.map(p=>({box:p,s0:t(p.x0),s1:t(p.x1)})).filter(({s0:p,s1:h})=>h>=0&&p<=n),s=o[0],a=o.at(-1);if(!s||!a)return;let i=(p,h)=>({text:p,at:h,width:r(p)}),c=(p,h)=>i(p.toLocaleString("en-US"),h),l=[],d=[],f=[],u=[];for(let{box:p,s0:h,s1:g}of o){l.push({x0:h,x1:g}),d.push(Math.round(h)+.5),g-h>=Jo&&d.push(Math.round(g)+.5);let x=i(k(p.bp1-p.bp0),(h+g)/2);x.width<=g-h&&f.push(x),p!==s.box&&u.push(c(p.bp0,h))}let m=[c(s.box.bp0,s.s0),c(a.box.bp1,a.s1)];return{spans:l,ticks:d,labels:Ft([...m,...f,...u])}}function Yt(e,t,n,r,o=!1){return(o?tr:nr)(e,t,n,r)}function or(e,t,n,r,o=!1){let{x:s,width:a,darkMode:i}=n;e.font="10px sans-serif";let c=Yt(t,s,a,f=>e.measureText(f).width,o);if(!c)return;let l=Dt(i),d=r+.5;e.strokeStyle=l,e.fillStyle=l,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath();for(let{x0:f,x1:u}of c.spans)e.moveTo(Math.max(0,f),d),e.lineTo(Math.min(a,u),d);for(let f of c.ticks)e.moveTo(f,r),e.lineTo(f,r+Bt);e.stroke();for(let{text:f,at:u}of c.labels)e.fillText(f,u,r+Bt+2)}function rr(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),r=[];return t.nodes.forEach((o,s)=>{let a=n.get(o.name);if(o.order>=0&&a&&C(a)){let i=a.stable.start;r.push({bp0:i,bp1:i+o.sequenceLength,index:s,node:o})}}),r.sort((o,s)=>o.bp0-s.bp0)}function sr(e,t,n){let r=0,o=e.length-1;for(;r<o;){let s=r+o+1>>1;e[s].bp0<=t?r=s:o=s-1}return[e[r],e[r-1]].find(s=>s&&n.has(s.index)&&s.bp0<=t&&t<=s.bp1)}function mc(e,t,n){let r=rr(e,t),o=[];for(let s of t.tracks){let a=s.name?n.get(s.name):void 0;if(a?.length){let i=new Map;for(let c of s.path)c.node!==null&&c.y!==void 0&&!i.has(c.node)&&i.set(c.node,c.y);for(let c of a){let l=sr(r,c.start,i);if(l){let{node:d,bp0:f,bp1:u}=l,m=p=>d.x+(Math.min(p,u)-f)/(u-f)*d.pixelWidth;o.push({x0:m(c.start),x1:m(c.end),y:i.get(l.index),height:s.width})}}}}return o}function ir(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function gc(e,t,{x:n,y:r,width:o,darkMode:s}){if(t.length!==0){e.fillStyle=ir(s),e.beginPath();for(let a of t){let i=n(a.x0),c=Math.max(n(a.x1),i+1);if(c>=0&&i<=o){let l=r(a.y);e.rect(i,l,c-i,r(a.y+a.height)-l)}}e.fill()}}var Ut=Hn(Gt(),1),ie=16;function Mc(e){let[t="",...n]=e.split(/\r\n|\r|\n/),r=t.split(" ").slice(1),o=new Map;for(let s of n){if(!s)continue;let[a="",...i]=s.split(" ");a&&!o.has(a)&&o.set(a,{...Object.fromEntries(r.map((c,l)=>[c,i[l]??""])),name:a})}return[...o.values()]}function wc(e){let t=new Set;for(let n of e??[])for(let r of Object.keys(n))r!=="name"&&t.add(r);return[...t]}function Ec(e){if(typeof e=="string")return e?{field:e}:void 0;let{field:t,domain:n}=e??{};if(!(typeof t!="string"||!t))return Array.isArray(n)?{field:t,domain:n.filter(r=>typeof r=="string")}:{field:t}}function cr(e){let t=new Set(e.map(n=>n.label)).size;return`${t} haplotype${t===1?"":"s"}`}function Sc(e,t,{field:n,domain:r}){let o=new Map(t.map(c=>[c.name,c[n]??""])),s=new Map;for(let c of e){let l=o.get(c.label)||o.get(c.sample)||"",d=s.get(l);d?d.push(c):s.set(l,[c])}let a=1,i=[...s.keys()].sort((0,Ut.groupKeyComparator)(r)).map(c=>{let l=s.get(c),d={key:c,title:`${c||`${n}: none`} \xB7 ${cr(l)}`,first:a,count:l.length};return a+=l.length,d});return{rows:i.flatMap(c=>s.get(c.key)),sections:i}}function vc(e,t){let n=o=>{let s=-1;for(;s+1<e.length&&e[s+1].first<=o;)s++;return s},r=o=>o*t+(n(o)+1)*ie;return{rowY:r,headers:e.map((o,s)=>({...o,top:(o.first-.5)*t+s*ie})),headersPx:e.length*ie,rowAt(o,s){let a=0;for(let i=-1;i<e.length;i++){let c=i<0?0:e[i].first,l=i<0?Math.min(s,e[0]?.first??s):c+e[i].count,d=(i+1)*ie,f=Math.min(l-1,Math.max(c,Math.round((o-d)/t)));Math.abs(r(f)-o)<Math.abs(r(a)-o)&&(a=f)}return a}}}function lr(e,t){let n=new Map(e.nodes.map(o=>[o.id,o])),r=[];return t.nodes.forEach(o=>{let s=n.get(o.name);o.order>=0&&s&&C(s)&&r.push({node:o.name,bp0:s.stable.start,bp1:s.stable.start+o.sequenceLength,x0:o.x,x1:o.x+o.pixelWidth})}),r}function dr(e,t,n,r){let o=[];for(let s of e){let a=n(s.x0),i=n(s.x1);i>=0&&a<=r&&o.push({node:s.node,top0:t(s.bp0),top1:t(s.bp1),bottom0:a,bottom1:i})}return o}var fr=3;function ur(e,t,n,r){if(t<=0||r<0||r>t)return;let o=r/t,s,a=fr;for(let i of e){let c=i.top0+(i.bottom0-i.top0)*o,l=i.top1+(i.bottom1-i.top1)*o,d=Math.max(0,Math.min(c,l)-n,n-Math.max(c,l));d<a&&(a=d,s=i.node)}return s}function Kt(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.top1,0),e.lineTo(t.bottom1,n),e.lineTo(t.bottom0,n),e.closePath()}function zt(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.bottom0,n),e.moveTo(t.top1,0),e.lineTo(t.bottom1,n)}function hr(e,t,n,{highlightNode:r,darkMode:o}){if(n<=0||t.length===0)return;let s=o?"255,255,255":"0,0,0";e.beginPath();for(let i of t)Kt(e,i,n);e.fillStyle=`rgba(${s},0.07)`,e.fill(),e.beginPath();for(let i of t)zt(e,i,n);e.strokeStyle=`rgba(${s},0.35)`,e.lineWidth=.5,e.stroke();let a=t.find(i=>i.node===r);a&&(e.beginPath(),Kt(e,a,n),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),zt(e,a,n),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function jt(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[]}}var pr=new Set(["_gbwt_ref","unknown"]);function Vt(e){let[t,n,r]=e?.split("#")??[];if(!(t===void 0||t===""||pr.has(t)||n===void 0||!/^\d+$/.test(n)||r===void 0||r===""))return{sample:t,haplotype:Number(n),contig:r}}var fn=!1;function B(...e){fn&&console.log(...e)}var mr=["read_group","sample_name"],Xc=[...mr,"haplotype_sample"];function gr({layers:e,coarsenedReadView:t=!1,showReads:n=!0},r){if(e!==void 0)return e;let o=t&&n,s=a=>a?{stat:"coarsen"}:{};return[{data:"haplotypes",...s(o&&!r)},{data:"reads",...s(o&&r)}]}function Qt(e,t){return e.find(n=>n.data===t)?.stat}function xr(e,t){return{mergeNodes:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,layers:gr(e,t),ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??8.401,trackWidth:e.trackWidth??15}}function un(e){return{config:e,nodes:[],tracks:[],reads:[],nodeMap:new Map,nodesPerOrder:[],nodeOrders:[],assignments:[],extraLeft:[],extraRight:[],maxOrder:-1,shapes:jt(),imageBounds:{minX:0,maxX:0,minY:0,maxY:0},trackForRuler:void 0,coarsenedEdgeMeta:new Map}}function qc(e,t,n=[],r={}){let o=yr(e,t,n,r);return o&&br(o,r)}var hn=new WeakMap;function yr(e,t,n=[],r={}){let o=wr(e,t,n,r);if(o===void 0)return;let s=pn(o,o.tracks,o.reads,"measure");return s.nodes.forEach((a,i)=>{a.order>=0&&(o.nodes[i].x=a.x)}),hn.set(o,s),o}function br(e,t={}){return Mr(e,Rr(e,t.facet),Er(e,t))}function Mr(e,t,n,r){let o=hn.get(e);return o!==void 0&&t.length===e.tracks.length&&n.length===e.reads.length?o:pn(e,t,n,"topology",r)}function wr(e,t,n,r){let o=un(xr(r,n.length>0));if(!(e.length===0||t.length===0)){structuredClone(e).forEach((s,a)=>{s.seq??="",s.sequenceLength??=s.seq.length,o.nodes[a+1]=s}),o.tracks=structuredClone(t),o.reads=o.config.showReads?structuredClone(n.filter(s=>s.is_secondary!==!0)):[];for(let s=o.tracks.length-1;s>=0;s-=1){let a=o.tracks[s];if(a.type??="haplotype",a.hidden===!0){o.tracks.splice(s,1);continue}a.indexOfFirstBase!==void 0&&(o.trackForRuler=a.name)}if(o.tracks.length!==0)return Nr(o,0),o.nodeMap=tn(o),q(o,o.tracks),q(o,o.reads),ln(o),o.config.mergeNodes&&(nn(o),ke(o),$e(o),gs(o),o.nodeMap=tn(o),ln(o),q(o,o.tracks),q(o,o.reads)),nn(o),jr(o),ke(o),Vr(o),ke(o),$e(o),q(o,o.reads),{options:o.config,nodes:o.nodes,tracks:o.tracks,reads:o.reads,nodeMap:o.nodeMap,maxOrder:Kr(o),trackForRuler:o.trackForRuler}}}function Er(e,{mappingQualityCutoff:t=0,focusReadNames:n=null,facet:r}){let o=n?new Set(n):null;return e.reads.filter(s=>(s.mapping_quality??0)>=t&&(o===null||s.name!==void 0&&o.has(s.name))&&(r===void 0||Sr(r,s)))}function Sr(e,t){return e.by==="haplotype_sample"?"reads"in e:(t[e.by]??null)===e.key}function vr(e){return new Set(e.tracks.filter((t,n)=>n===0||t.name===e.trackForRuler))}function Rr(e,t){if(t?.by!=="haplotype_sample")return e.tracks;let n=vr(e);return e.tracks.filter(r=>n.has(r)||!("reads"in t)&&_r(r)===t.key)}function _r(e){return Vt(e.name)?.sample??null}function pn(e,t,n,r,o={}){let s=un(e.options);e.nodes.forEach((u,m)=>{s.nodes[m]={...u}}),s.tracks=t.map(u=>({...u})),s.reads=n.map(u=>({...u})),s.nodeMap=e.nodeMap,s.maxOrder=e.maxOrder,s.trackForRuler=e.trackForRuler;let{layers:a,ignoreStrand:i}=s.config,c=o.haplotypes??yn,l=Qt(a,"haplotypes")==="coarsen"?fs(s,c):void 0;l!==void 0&&(s.tracks=[l.ref]),as(s),es(s),Or(s);let d=Qt(a,"reads")==="coarsen"&&s.reads.length>0?bn(s,s.reads,"read",o.reads??c+(l?.bands.length??0)):void 0;d!==void 0&&(s.reads=d.bands);let f={};for(let[u,m,p]of[["haplotypes","haplotype",l],["reads","read",d]])p!==void 0&&($e(s,p.bands),q(s,p.bands),f[u]={unit:m,total:p.total,reverse:!i&&p.bands.some(h=>h.is_reverse)});return l!==void 0&&(s.reads=l.bands.concat(s.reads)),s.reads.length>0?(Tr(s),s.tracks=s.tracks.concat(s.reads)):s.nodes.forEach(u=>{u.incomingReads=[],u.outgoingReads=[],u.internalReads=[]}),r==="measure"&&Zr(s),ds(s),B("Tracks:",s.tracks),B("Nodes:",s.nodes),B("Lane assignment:",s.assignments),Yr(s),{nodes:s.nodes,tracks:s.tracks,reads:s.reads,nodeMap:s.nodeMap,shapes:s.shapes,bounds:s.imageBounds,maxOrder:s.maxOrder,trackForRuler:s.trackForRuler,coarsenedEdgeMeta:s.coarsenedEdgeMeta,coarsened:f}}function O(e){return e.startsWith("-")}function A(e){return O(e)?e.substring(1):e}function mn(e){return O(e)?e:`-${e}`}function Ie(e){return O(e)?A(e):mn(e)}function Zt(e){return e>0}function Nr(e,t){let n=new Set,r=new Set;for(let o of e.tracks[t].sequence)O(o)?r.has(A(o))||n.add(A(o)):r.add(o);if(n.size!==0){for(let{sequence:o}of[...e.tracks,...e.reads])for(let s=0;s<o.length;s+=1)n.has(A(o[s]))&&(o[s]=Ie(o[s]));e.nodes.forEach(o=>{n.has(o.name)&&(o.seq=Le(o.seq))})}}function Or(e){e.nodesPerOrder=[];for(let n=0;n<=e.maxOrder;n+=1)e.nodesPerOrder[n]=[];let t=new Map;e.nodes.forEach(n=>{n.y!==void 0&&Jt(t,n.order,n.y+n.contentHeight)}),e.tracks.forEach(n=>{n.type==="haplotype"&&n.path.forEach(r=>{Jt(t,r.order,(r.y??0)+n.width)})}),e.nodes.forEach((n,r)=>{n.order>=0&&n.y===void 0&&(n.y=(t.get(n.order)??0)+25,n.contentHeight=0,e.nodesPerOrder[n.order].push(r))})}function Jt(e,t,n){let r=e.get(t);r===void 0?e.set(t,n):e.set(t,Math.max(r,n))}var ae=7;function Ar(e){e.nodes.forEach(t=>{t.incomingReads=[],t.outgoingReads=[],t.internalReads=[]}),e.reads.forEach((t,n)=>{if((t.width===void 0||t.width===0)&&(t.width=ae),t.path.length===1){let r=t.path[0].node;r!==null&&e.nodes[r].internalReads.push(n)}else t.path.forEach((r,o)=>{if(o===0){let s=t.path[0].node;s!==null&&e.nodes[s].outgoingReads.push([n,o])}else{let s=r.node;s!==null&&e.nodes[s].incomingReads.push([n,o])}})})}function Tr(e){e.reads.forEach(i=>{i.path=gn(e,i)}),Ar(e);let t=e.nodes.filter(i=>i.order>=0);t.sort(Xe);let n=new Map;for(let i=0;i<e.reads.length;i++){let c=e.reads[i],l=c.haplotypeShare===void 0?1:0,d=c.sourceTrackID,f=`${l}:${d}`,u=n.get(f);u===void 0?n.set(f,{layer:l,source:d,reads:new Set([i])}):u.reads.add(i)}let r=[...n.values()].sort((i,c)=>i.layer-c.layer||i.source-c.source),o=r.length>1?ae:0;t.forEach(i=>{for(let{reads:c}of r)Cr(e,c,i,o)});let s=Xr(e),a=[];e.reads.forEach((i,c)=>{let l=i.path.length,d=new Array(l),f;for(let p=0;p<l;p++){p===0?d[p]=void 0:d[p]=f??i.path[0];let h=i.path[p];h.node!==null&&h.node&&(f=h)}let u=new Array(l),m;for(let p=l-1;p>=0;p--){p===l-1?u[p]=void 0:u[p]=m??i.path[l-1];let h=i.path[p];h.node!==null&&h.node&&(m=h)}i.path.forEach((p,h)=>{if(p.y===void 0){let g=d[h],x=u[h],M=!!(x&&g&&(g.order>x.order||x.order===g.order&&x.isForward===g.isForward));p.betweenCycleReverseTraversal=M,a.push({readIndex:c,pathIndex:h,previousY:g?.y,previousNode:g?.node})}})}),a.sort((i,c)=>$r(e,i,c)),a.forEach(i=>{let c=e.reads[i.readIndex],l=c.path[i.pathIndex];l.y=s[l.order],s[l.order]+=c.width}),B("Reads:",e.reads)}function Cr(e,t,n,r){let o=n.incomingReads.filter(([p])=>t.has(p)),s=n.outgoingReads.filter(([p])=>t.has(p)),a=n.internalReads.filter(p=>t.has(p));o.length===0&&s.length===0&&a.length===0&&(r=0);let i=n.y+n.contentHeight+r*2,c=o.map(p=>{let[h,g]=p,x=e.reads[h].path,M=g+1,w;for(let b=1;b<=g;b++){let E=x[g-b]?.y;if(E!==void 0){M=b,w=E;break}}return{entry:p,decisionStep:M,y:w}});c.sort(kr),o=c.map(p=>p.entry);let l=i,d=new Map;o.forEach(p=>{let h=e.reads[p[0]];h.path[p[1]].y=l,en(d,h,p[1],l,n),l+=h.width});let f=l;s.sort((p,h)=>Ir(e,p,h));let u=new Map;l=i,s.forEach(p=>{let h=e.reads[p[0]],g=h.firstNodeOffset??0;h.path[p[1]].y=l,u.set(l,g);let x=d.get(l);x===void 0||x+1<=g?(l+=h.width,f=Math.max(f,l)):(d.set(l,0),o.forEach(M=>{let w=e.reads[M[0]],b=w.path[M[1]];b.y!==void 0&&b.y>=l&&(b.y+=h.width,en(d,w,M[1],b.y,n))}),l+=h.width,f+=h.width)}),a.sort((p,h)=>Pr(e,p,h)),a.forEach(p=>{let h=e.reads[p],g=h.firstNodeOffset??0,x=h.finalNodeCoverLength??0;for(l=i;g<(d.get(l)??-1/0)+2||x>(u.get(l)??1/0)-3;)l+=h.width||ae;h.path[0].y=l,d.set(l,x),f=Math.max(f,l)});let m=f-n.y-n.contentHeight;n.contentHeight+=m,ss(e,n,m)}function kr(e,t){return e.decisionStep!==t.decisionStep?e.decisionStep-t.decisionStep:e.y===void 0||t.y===void 0?(e.y===void 0?0:1)-(t.y===void 0?0:1):e.y-t.y}function en(e,t,n,r,o){n===t.path.length-1?e.set(r,t.finalNodeCoverLength??0):e.set(r,o.sequenceLength)}function $r(e,t,n){let r=e.reads[t.readIndex],o=e.reads[n.readIndex],s=r.path[t.pathIndex],a=o.path[n.pathIndex];if(s.order!==a.order)return s.order-a.order;if(r.sourceTrackID!==o.sourceTrackID)return r.sourceTrackID-o.sourceTrackID;if(t.previousNode&&n.previousNode){let f=e.nodes[t.previousNode],u=e.nodes[n.previousNode];if(f&&u&&f.order!==u.order)return f.order-u.order}let i=t.previousY??0,c=n.previousY??0,l=s.betweenCycleReverseTraversal===!0,d=a.betweenCycleReverseTraversal===!0;return l!==d?l?1:-1:l?c-i:i-c}function Ir(e,[t,n],[r,o]){let s=e.reads[t],a=e.reads[r],i,c,l=s.path.length-1,d=a.path.length-1;for(;!i&&l>=0;)i=s.path[l]?.y,l-=1;for(;!c&&d>=0;)c=a.path[d]?.y,d-=1;if(i&&c)return i-c;let f=s.path[n]?.node,u=a.path[o]?.node,m=typeof f=="number"?e.nodes[f]:null,p=typeof u=="number"?e.nodes[u]:null;for(;m&&p&&m===p;){if(n<s.path.length-1){for(n+=1;s.path[n]?.node===null;)n+=1;let g=s.path[n]?.node;m=typeof g=="number"?e.nodes[g]:null}else m=null;if(o<a.path.length-1){for(o+=1;a.path[o]?.node===null;)o+=1;let g=a.path[o]?.node;p=typeof g=="number"?e.nodes[g]:null}else p=null}if(m)return p?Xe(m,p):1;if(p)return-1;let h=(s.firstNodeOffset??0)-(a.firstNodeOffset??0);return h!==0?h:(s.finalNodeCoverLength??0)-(a.finalNodeCoverLength??0)}function Lr(e,t){let n=e.path,r=t.path,o=0,s=0;for(;o<n.length&&s<r.length;){let a=n[o],i=r[s],c=a.order,l=i.order;if(c===l&&a.node&&i.node)return(i.y??0)-(a.y??0);c<l?o+=1:(c>l||(o+=1),s+=1)}return 0}function Pr(e,t,n){let r=e.reads[t],o=e.reads[n],s=r.firstNodeOffset??0,a=o.firstNodeOffset??0;if(s<a)return-1;if(s>a)return 1;let i=r.finalNodeCoverLength??0,c=o.finalNodeCoverLength??0;return i<c?-1:i>c?1:0}function Xr(e){let t=[];for(let n=0;n<=e.maxOrder;n+=1)t.push(0);return e.nodes.forEach(n=>{n.y!==void 0&&(t[n.order]=Math.max(t[n.order],n.y+n.contentHeight+20))}),e.tracks.forEach(n=>{n.path.forEach(r=>{t[r.order]=Math.max(t[r.order],(r.y??0)+n.width)})}),t}function gn(e,t){let n=[],r=(c,l)=>{n.push({order:c,isForward:l,node:null})},o=(c,l,d)=>{n.push({order:c,isForward:l,node:d})},s=Math.abs(t.indexSequence[0]),a=Zt(t.indexSequence[0]),i=e.nodes[s];o(i.order,a,s);for(let c=1;c<t.sequence.length;c+=1){let l=i,d=a;s=Math.abs(t.indexSequence[c]),a=Zt(t.indexSequence[c]),i=e.nodes[s];let{order:f}=i;if(f>l.order){d||r(l.order,!0);for(let u=l.order+1;u<f;u+=1)r(u,!0);a||r(f,!0)}else if(f<l.order){d&&r(l.order,!1);for(let u=l.order-1;u>f;u-=1)r(u,!1);a&&r(f,!1)}else a===d&&r(f,!a);o(f,a,s)}return n}function $e(e,t=e.reads){t.forEach(n=>{let r=0;for(;r<n.sequence.length&&n.sequence[r].startsWith("-");)r+=1;if(r===n.sequence.length){n.is_reverse=!0,n.sequence=n.sequence.reverse();for(let c=0;c<n.sequence.length;c+=1)n.sequence[c]=A(n.sequence[c]);let o=n.sequenceNew??[];o.reverse(),n.sequenceNew=o;for(let c of o)c.nodeName=A(c.nodeName),qr(c.mismatches,Ce(e,c.nodeName).sequenceLength);let s=n.firstNodeOffset??0,a=Ce(e,n.sequence[0]).sequenceLength;n.firstNodeOffset=a-(n.finalNodeCoverLength??0);let i=Ce(e,n.sequence[n.sequence.length-1]).sequenceLength;n.finalNodeCoverLength=i-s}})}function qr(e,t){e.forEach(n=>{Object.assign(n,Br(n,t))})}function Br(e,t){let n=e.type==="insertion"?0:e.type==="deletion"?e.length??0:e.seq?.length??0;return{...e,pos:t-e.pos-n,...e.seq!==void 0&&{seq:Le(e.seq)}}}var Dr={A:"T",T:"A",C:"G",G:"C"};function Le(e){let t="";for(let n=e.length-1;n>=0;n-=1)t+=Dr[e.charAt(n)]??"N";return t}function q(e,t){let n=new Map;t.forEach(r=>{r.indexSequence=r.sequence.map(o=>{let s=n.get(o);if(s===void 0){let a=e.nodeMap.get(A(o));if(a===void 0)throw new Error(`Track ${r.name??r.id} visits unknown node ${o}`);s=O(o)?-a:a,n.set(o,s)}return s})})}var Fr=20;function Yr(e){let t={minX:99,maxX:-99,minY:99,maxY:-99};e.nodes.forEach(n=>{n.x!==void 0&&(t.minX=Math.min(t.minX,n.x),t.maxX=Math.max(t.maxX,n.x+Fr+n.pixelWidth)),n.y!==void 0&&(t.minY=Math.min(t.minY,n.y-10),t.maxY=Math.max(t.maxY,n.y+n.contentHeight+10))}),e.tracks.forEach(n=>{n.path.forEach(r=>{let o=r.y??0;t.maxY=Math.max(t.maxY,o+n.width),t.minY=Math.min(t.minY,o)})}),e.imageBounds=t}function Ce(e,t){let n=e.nodeMap.get(A(t)),r=n===void 0?void 0:e.nodes[n];if(r===void 0)throw new Error(`Unknown node ${t}`);return r}function tn(e){let t=new Map;return e.nodes.forEach((n,r)=>{t.set(n.name,r)}),t}function nn(e){let t=e.nodes.map(()=>new Set),n=e.nodes.map(()=>new Set),r=o=>{for(let s=0;s<o.indexSequence.length-1;s+=1){let a=Math.abs(o.indexSequence[s]),i=Math.abs(o.indexSequence[s+1]);t[a].add(i),n[i].add(a)}};e.tracks.forEach(r),e.reads.forEach(r),e.nodes.forEach((o,s)=>{o.successors=Array.from(t[s]),o.predecessors=Array.from(n[s])})}function on(e,t){let n=0,r=0,o=0;t.forEach(s=>{let a=Math.abs(s);if(s<0){let i=e.nodeOrders[a]??=r;i<o&&(o=i),n=i,r=i-1}else{let i=e.nodeOrders[a]??=n;n=i+1,r=i}}),o<0&&Pe(e,-o)}function Wr(e,t){let n=0,r=0;for(;n<t.length&&e.nodeOrders[Math.abs(t[n])]===void 0;)n+=1;if(n>=t.length)return null;let o=t[n],s,a;o>=0?(s=e.nodeOrders[o]-1,a=-1):(s=e.nodeOrders[-o]+1,a=1);for(let i=n-1;i>=0;i-=1){let c=Math.abs(t[i]);e.nodeOrders[c]===void 0&&(e.nodeOrders[c]=s,r=Math.min(r,s),s+=a)}return r<0&&Pe(e,-r),n}var Hr=-1;function Gr(e){let t=[];for(let n of e)t.push(n??Hr);return t}function ke(e){let t,n,r,o,s=0,a=e.tracks.concat(e.reads),i={stamp:new Int32Array(e.nodes.length),generation:0};e.nodeOrders=new Array(e.nodes.length).fill(void 0),e.nodes.forEach(l=>{l.order=void 0}),on(e,e.tracks[0].indexSequence);for(let l=1;l<a.length;l+=1){if(B(`generating order for track ${l+1}`),r=Wr(e,a[l].indexSequence),r===null){l<e.tracks.length?on(e,a[l].indexSequence):(a.splice(l,1),e.reads.splice(l-e.tracks.length,1),l-=1);continue}for(t=zr(a[l].indexSequence);r<t.length;){for(o=r,r+=1;r<t.length&&e.nodeOrders[t[r]]===void 0;)r+=1;if(r<t.length){n=e.nodeOrders[t[o]]+1;for(let d=o+1;d<r;d+=1)e.nodeOrders[t[d]]=n,n+=1;if(e.nodeOrders[t[r]]>e.nodeOrders[t[o]])e.nodeOrders[t[r]]<n&&rn(e,t[r],t[r-1],n);else if(a[l].indexSequence[r]>=0&&!Ur(e,t[r],t[o],i))rn(e,t[r],t[r-1],n);else if(a[l].indexSequence[o]<0||e.nodes[t[o+1]].degree<2&&e.nodeOrders[t[r]]<e.nodeOrders[t[o]]){n=e.nodeOrders[t[o]]-1;for(let d=o+1;d<r;d+=1)e.nodeOrders[t[d]]=n,s=Math.min(s,n),n-=1}}else if(a[l].indexSequence[o]>=0){n=e.nodeOrders[t[o]]+1;for(let d=o+1;d<t.length;d+=1){let f=t[d];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,n+=1)}}else{n=e.nodeOrders[t[o]]-1;for(let d=o+1;d<t.length;d+=1){let f=t[d];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,s=Math.min(s,n),n-=1)}}}}s<0&&Pe(e,-s);let c=Gr(e.nodeOrders);e.nodeOrders=c,c.forEach((l,d)=>{let f=e.nodes[d];f!==void 0&&(f.order=l)})}function Ur(e,t,n,r){r.generation+=1;let{stamp:o,generation:s}=r,a=[t];for(o[t]=s;a.length>0;){let i=a.pop();if(i===n)return!0;for(let c of e.nodes[i].successors)o[c]!==s&&(o[c]=s,a.push(c))}return!1}function Kr(e){let t=-1;return e.nodeOrders.forEach(n=>{n!==void 0&&n>t&&(t=n)}),t}function zr(e){return e.map(t=>Math.abs(t))}function Pe(e,t){e.nodeOrders.forEach((n,r)=>{n!==void 0&&(e.nodeOrders[r]=n+t)})}function rn(e,t,n,r){let o=new Map,s=[[t,r]],a=0;for(;a<s.length;){let[i,c]=s[a];a+=1;let l=e.nodeOrders[i];l!==void 0&&l<c&&(!o.has(i)||o.get(i)<c)&&(o.set(i,c),e.nodes[i].successors.forEach(d=>{e.nodeOrders[d]>l&&d!==n&&s.push([d,c+1])}),i!==t&&e.nodes[i].predecessors.forEach(d=>{e.nodeOrders[d]>l&&d!==n&&s.push([d,c+1])}))}o.forEach((i,c)=>{e.nodeOrders[c]=i})}function jr(e){e.nodes.forEach(t=>{t.tracks=[]}),e.tracks.forEach(t=>{t.indexSequence.forEach(n=>{e.nodes[Math.abs(n)].tracks.push(t.id)})}),e.nodes.forEach(t=>{t.degree=t.tracks.length})}function Vr(e){Qr(e,[...e.tracks.slice(1),...e.reads],e.tracks[0])}function Qr(e,t,n){let r=new Int32Array(e.nodes.length),o=new Uint8Array(e.nodes.length);for(let s of n.sequence){let a=O(s)?void 0:e.nodeMap.get(s);a!==void 0&&(o[a]=1)}for(let s of t){let{sequence:a,indexSequence:i}=s,c=i.length-1;for(let l=0;l<=c;l+=1){let d=Math.abs(i[l]);if(o[d]===1)continue;let f=e.nodes[d].order,u=l>0?e.nodes[Math.abs(i[l-1])].order:void 0,m=l<c?e.nodes[Math.abs(i[l+1])].order:void 0,p=O(a[l])?1:-1;(u===void 0||u<f)&&(m===void 0||f<m)&&(r[d]+=p),(u===void 0||u>f)&&(m===void 0||f>m)&&(r[d]-=p)}}for(let s of t){let{sequence:a,indexSequence:i}=s;for(let c=0;c<i.length;c+=1)r[Math.abs(i[c])]>0&&(a[c]=Ie(a[c]),i[c]=-i[c])}e.nodes.forEach((s,a)=>{r[a]>0&&(s.seq=Le(s.seq),s.switched=!0)})}function Zr(e){let t=0,n=20,r=-1,o=e.nodes.slice();o.sort(Xe);let s=Jr(e);o.forEach(a=>{a.order>=0&&(a.order>r&&(r=a.order,t=n+10*s[a.order]),a.x=t,n=Math.max(n,t+40+a.pixelWidth))})}function Jr(e){let t=[],n=[],r=[],o=[];for(let s=0;s<=e.maxOrder;s+=1)t.push(0),n.push(0),r.push(0);e.tracks.forEach(s=>{for(let a=1;a<s.path.length;a+=1){let i=s.path[a],c=s.path[a-1];if(i.order===c.order)i.isForward?t[i.order]=t[i.order]+1:n[i.order]=n[i.order]+1;else{let l=Math.abs((i.y??0)-(c.y??0));r[i.order]=Math.max(l/17.5,r[i.order])}}}),o.push(Math.max(0,t[0]-1));for(let s=1;s<=e.maxOrder;s+=1)o.push(Math.max(Math.max(0,t[s]-1)+Math.max(0,n[s-1]-1),r[s]));return o}function es(e){let t=[],n=[];for(let r=0;r<=e.maxOrder;r+=1)e.assignments[r]=[],n[r]=new Map,t[r]=[];e.tracks.forEach((r,o)=>{r.path=gn(e,r),r.path.forEach((s,a)=>{ts(e,s.order,s.node,o,a,t,n)})});for(let r=0;r<=e.maxOrder;r+=1)os(e,e.assignments[r],r)}function ts(e,t,n,r,o,s,a){let i={trackID:r,segmentID:o,compareToFromSame:s[t][r]??null},c=n===null?void 0:a[t].get(n);if(c===void 0){let l={type:"single",node:n,tracks:[i]};e.assignments[t].push(l),n!==null&&a[t].set(n,l)}else c.type="multiple",c.tracks.push(i);s[t][r]=i}function ns(e,t,n){let r;t.forEach(o=>{o.idealLane=0,o.tracks.forEach(s=>{if(s.segmentID===0)s.idealLane=s.trackID,s.idealY=null;else if(e.tracks[s.trackID].path[s.segmentID-1].order===n-1)s.idealLane=e.tracks[s.trackID].path[s.segmentID-1].lane??void 0,s.idealY=e.tracks[s.trackID].path[s.segmentID-1].y;else if(s.segmentID<e.tracks[s.trackID].path.length-1&&e.tracks[s.trackID].path[s.segmentID+1].order===n-1)s.idealLane=e.tracks[s.trackID].path[s.segmentID+1].lane??void 0,s.idealY=e.tracks[s.trackID].path[s.segmentID+1].y;else{for(r=s.segmentID-1;r>=0&&e.tracks[s.trackID].path[r].order!==n-1;)r-=1;r<0?(s.idealLane=s.trackID,s.idealY=null):(s.idealLane=e.tracks[s.trackID].path[r].lane,s.idealY=e.tracks[s.trackID].path[r].y)}o.idealLane+=s.idealLane}),o.idealLane/=o.tracks.length})}function os(e,t,n){let r=0,o=new Set,s=20,a=!1,i=-1;ns(e,t,n),t.sort(sn),t.forEach(c=>{c.node!==null?(e.nodes[c.node].topLane=r,a&&(s-=10),e.nodes[c.node].y=s,e.nodes[c.node].contentHeight=0,a=!1):(a?s-=25:s>20&&(s-=10),a=!0),c.tracks.sort(sn),c.tracks.forEach(l=>{l.lane=r,l.trackID===i&&c.node===null&&a&&(s+=10),e.tracks[l.trackID].path[l.segmentID].lane=r,e.tracks[l.trackID].path[l.segmentID].y=s,typeof l.idealY=="number"&&o.add(l.idealY-s),r+=1,s+=e.tracks[l.trackID].width,c.node!==null&&(e.nodes[c.node].contentHeight+=e.tracks[l.trackID].width),i=l.trackID}),s+=25}),rs(e,t,o)}function rs(e,t,n){let r=0,o=Number.MAX_SAFE_INTEGER;n.forEach(s=>{let a=is(e,t,s);a<o&&(o=a,r=s)}),t.forEach(s=>{s.node!==null&&(e.nodes[s.node].y+=r),s.tracks.forEach(a=>{let i=e.tracks[a.trackID].path[a.segmentID];i.y=i.y+r})})}function ss(e,t,n){t.order<0||e.assignments[t.order]===void 0||(e.assignments[t.order].forEach(r=>{if(r.node!==null){let o=e.nodes[r.node];o!==t&&o.y>t.y&&(o.y+=n,r.tracks.forEach(s=>{let a=e.tracks[s.trackID].path[s.segmentID];a.y=a.y+n}))}else r.tracks.forEach(o=>{let s=e.tracks[o.trackID].path[o.segmentID];s.y>=t.y&&(s.y=s.y+n)})}),e.nodesPerOrder[t.order].length>0&&e.nodesPerOrder[t.order].forEach(r=>{e.nodes[r]!==t&&e.nodes[r].y>t.y&&(e.nodes[r].y+=n)}))}function is(e,t,n){let r=0;return t.forEach(o=>{o.tracks.forEach(s=>{typeof s.idealY=="number"&&e.tracks[s.trackID].type!=="read"&&(r+=Math.abs(s.idealY-n-e.tracks[s.trackID].path[s.segmentID].y)*e.tracks[s.trackID].width)})}),r}function sn(e,t){return e.idealLane!==void 0?t.idealLane!==void 0?e.idealLane<t.idealLane?-1:e.idealLane>t.idealLane?1:0:-1:t.idealLane!==void 0?1:0}function Xe(e,t){return e.order!==t.order?e.order-t.order:e.y!==void 0&&t.y!==void 0?e.y-t.y:0}function as(e){let t=!0,n=4,r=e.config.trackWidth;for(let o of e.tracks)o.freq!==void 0?o.width=Math.round((Math.log(Math.max(o.freq,1))+1)*n):(o.width=r,o.type!==void 0&&o.type==="read"&&(o.width=n)),o.width!==n&&(t=!1);t&&e.tracks.forEach(o=>{o.freq!==void 0&&(o.width=r)})}function cs(e,t){let n=t.path[0],r=e.nodes[n.node],o=t.firstNodeOffset??0;return qe(r,n.isForward?o:r.sequenceLength-o)}function ls(e,t){let n=t.path[t.path.length-1],r=e.nodes[n.node],o=t.finalNodeCoverLength??0;return qe(r,n.isForward?o:r.sequenceLength-o)}function xn(e,t){return t>e.sequenceLength?null:qe(e,t)}function qe(e,t){let[n,r]=ms(e);if(e.sequenceLength===0)return n;let o=Math.min(Math.max(t,0),e.sequenceLength);return n+o/e.sequenceLength*(r-n)}function ds(e){let t,n,r,o;for(let i=0;i<=e.maxOrder;i+=1)e.extraLeft.push(0),e.extraRight.push(0);let s=[],a=[];e.nodes.forEach(i=>{i.x!==void 0&&(s[i.order]=i.x,a[i.order]===void 0?a[i.order]=i.x+i.pixelWidth:a[i.order]=Math.max(a[i.order],i.x+i.pixelWidth))}),e.tracks.sort(Lr),e.tracks.forEach(i=>{r=i.path[0].y,i.type!=="read"?i.sequence[0].startsWith("-")?t=a[i.path[0].order]+20:t=s[i.path[0].order]-20:t=cs(e,i);for(let c=0;c<i.path.length;c+=1)i.path[c].y!==r&&(i.path[c-1].isForward?n=a[i.path[c-1].order]:n=s[i.path[c-1].order],n!==t&&e.shapes.rectangles.push({xStart:Math.min(t,n),yStart:r,xEnd:Math.max(t,n),yEnd:r+i.width-1,id:i.id,name:i.name,type:i.type}),i.path[c].order-1===i.path[c-1].order?(t=n,n=s[i.path[c].order],o=i.path[c].y,e.shapes.curves.push({xStart:t,yStart:r,xEnd:n+1,yEnd:o,width:i.width,id:i.id,name:i.name,type:i.type,nodeStart:i.path[c-1].node,nodeEnd:i.path[c].node,orderStart:i.path[c-1].order,orderEnd:i.path[c].order}),t=n,r=o):i.path[c].order+1===i.path[c-1].order?(t=n,n=a[i.path[c].order],o=i.path[c].y,e.shapes.curves.push({xStart:t+1,yStart:r,xEnd:n,yEnd:o,width:i.width,id:i.id,name:i.name,type:i.type,nodeStart:i.path[c-1].node,nodeEnd:i.path[c].node,orderStart:i.path[c-1].order,orderEnd:i.path[c].order}),t=n,r=o):i.path[c-1].isForward?(o=i.path[c].y,cn(e,1,n,r,o,i.width,i.id,i.path[c].order,i.type,i.name),t=a[i.path[c].order],r=i.path[c].y):(o=i.path[c].y,cn(e,-1,n,r,o,i.width,i.id,i.path[c].order,i.type,i.name),t=s[i.path[c].order],r=i.path[c].y));i.type!=="read"?i.path[i.path.length-1].isForward?n=a[i.path[i.path.length-1].order]+20:n=s[i.path[i.path.length-1].order]-20:n=ls(e,i),e.shapes.rectangles.push({xStart:Math.min(t,n),yStart:r,xEnd:Math.max(t,n),yEnd:r+i.width-1,id:i.id,name:i.name,type:i.type})})}var yn=1e9;function bn(e,t,n,r=yn){let o=new Map,s=0,a=e.nodes.length,i=(h,g)=>(h+a)*(2*a+1)+g+a,c=e.config.ignoreStrand;for(let[h,g]of t.entries()){let x=Math.max(g.freq??1,1);s+=x;let M=g.indexSequence;if(!(M.length<2))for(let w=0;w<M.length-1;w+=1){let b=M[w],E=M[w+1],y=e.nodes[Math.abs(b)],S=e.nodes[Math.abs(E)],v=c?Math.min(i(b,E),i(-E,-b)):i(b,E),_=o.get(v);_===void 0?o.set(v,{sSigned:b,dSigned:E,sName:b<0?`-${y.name}`:y.name,dName:E<0?`-${S.name}`:S.name,count:x,crossings:x,sourceTrackID:g.sourceTrackID,lastSource:h}):(_.crossings+=x,_.lastSource!==h&&(_.count+=x,_.lastSource=h))}}let l=0;for(let h of o.values())h.crossings>l&&(l=h.crossings);let d=ae,f=60,u=h=>l<=1?d:d+(f-d)*Math.sqrt(h/l),m=[],p=0;for(let h of o.values()){let g=r+p,x=n==="haplotype"?{count:h.count,total:s}:void 0,M=x===void 0?"":` (${ps(x)})`,w=h.crossings===h.count?"":`, ${h.crossings.toLocaleString()} crossings`,b=`${h.count.toLocaleString()} ${n}${h.count===1?"":"s"}${M}${w}: Node ${h.sName} \u2192 Node ${h.dName}`;e.coarsenedEdgeMeta.set(g,{count:h.count,label:b});let E=e.nodes[Math.abs(h.sSigned)].sequenceLength;m.push({id:g,sourceTrackID:h.sourceTrackID,type:"read",name:b,sequence:[h.sName,h.dName],indexSequence:[],path:[],width:u(h.crossings),firstNodeOffset:E,finalNodeCoverLength:0,sequenceNew:[{nodeName:h.sName,mismatches:[]},{nodeName:h.dName,mismatches:[]}],mapping_quality:0,is_secondary:!1,sample_name:null,read_group:null,score:h.count,haplotypeShare:x}),p+=1}if(fn){let h="?",g=0;e.nodes.forEach(x=>{x.contentHeight>g&&(g=x.contentHeight,h=x.name)}),B(`[coarsened] ${n}s_in=${t.length} edges_out=${m.length} tallestNodeBeforePlace=${h}(${g.toFixed(1)})`)}return{bands:m,total:s}}function fs(e,t){let n=e.trackForRuler===void 0?-1:e.tracks.findIndex(d=>d.name===e.trackForRuler),r=n===-1?0:n,o=e.tracks[r],s=(o.freq??1)-1,a=hs(e,o),i=e.tracks.filter((d,f)=>f!==r).map(d=>us(a,d));if(s>0&&i.push({...o,freq:s}),i.length===0)return;let{bands:c,total:l}=bn(e,i,"haplotype",t);return c.length>0?{ref:o,bands:c,total:l}:void 0}function us(e,t){let n=0;for(let r of t.indexSequence){let o=e[Math.abs(r)];o!==void 0&&o!==0&&(n+=o===Math.sign(r)?1:-1)}return n>=0?t:{...t,sequence:t.sequence.map(Ie).reverse(),indexSequence:t.indexSequence.map(r=>-r).reverse()}}function hs(e,t){let n=new Int8Array(e.nodes.length);for(let r of t.indexSequence){let o=Math.abs(r);n[o]===0&&(n[o]=Math.sign(r))}return n}function ps({count:e,total:t}){let n=e/t;return n<.01?"<1%":n>.99&&e<t?">99%":`${Math.round(n*100)}%`}var an=7;function cn(e,t,n,r,o,s,a,i,c,l){let d=t===1?e.extraRight:e.extraLeft,f=10*d[i],u=n+t*(f+5),m=an,p=Math.min(an,s),h=Math.min(r,o),g=Math.max(r,o),x=t===1?n:u-1,M=t===1?u:n,w=S=>{e.shapes.verticalRectangles.push({xStart:x,yStart:S,xEnd:M,yEnd:S+s-1,id:a,name:l,type:c})};w(r),e.shapes.verticalRectangles.push({xStart:t===1?u+m:u-m-p,yStart:h+s+m-1,xEnd:t===1?u+m+p-1:u-m-1,yEnd:g-m+1,id:a,name:l,type:c}),w(o);let b=u+t*m,E=u+t*(m+p),y=`M ${u} ${g}`;y+=` Q ${b} ${g} ${b} ${g-m}`,y+=` H ${E}`,y+=` Q ${E} ${g+s} ${u} ${g+s}`,y+=" Z ",e.shapes.corners.push({path:y,id:a,type:c}),y=`M ${u} ${h}`,y+=` Q ${E} ${h} ${E} ${h+s+m}`,y+=` H ${b}`,y+=` Q ${b} ${h+s} ${u} ${h+s}`,y+=" Z ",e.shapes.corners.push({path:y,id:a,type:c}),d[i]+=1}function ms(e){let t=e.x-4,n=e.x+e.pixelWidth+4;return[t,n]}function ln(e){switch(e.config.nodeWidthOption){case"compressed":e.nodes.forEach(t=>{t.width=1+Math.log2(Math.max(t.sequenceLength,1)),t.pixelWidth=Math.round((t.width-1)*8.401)});break;case"small":e.nodes.forEach(t=>{t.width=t.sequenceLength/100,t.pixelWidth=Math.max(Math.round((t.width-1)*8.401),0)});break;case"fixed":e.nodes.forEach(t=>{t.width=10,t.pixelWidth=Math.round(t.width*8.401)});break;case"normal":{let t=e.config.charWidth;e.nodes.forEach(n=>{n.width=n.sequenceLength,n.pixelWidth=Math.round(t*Math.max(n.sequenceLength-1,0))});break}default:throw new Error(`${e.config.nodeWidthOption} not implemented`)}}var L=0;function dn(e){return{first:new Int32Array(e),count:new Uint8Array(e)}}function N(e,t,n){let r=e.count[t];r===0?(e.first[t]=n,e.count[t]=1):r===1&&e.first[t]!==n&&(e.count[t]=2)}function W(e,t){return e.count[t]===1?Math.abs(e.first[t]):0}function gs(e){let t=dn(e.nodes.length),n=dn(e.nodes.length),r=new Map,o=f=>{let u=r.get(f);if(u===void 0){let m=e.nodeMap.get(A(f));u=O(f)?-m:m,r.set(f,u)}return u};e.tracks.concat(e.reads).forEach(f=>{let{sequence:u}=f,m=f.type==="haplotype",p=u.length-1,h=L,g=p>=0?o(u[0]):L;for(let x=0;x<=p;x+=1){let M=x<p?o(u[x+1]):L;if(g>0)x>0?(N(t,g,h),h<0&&N(t,g,-h)):m&&N(t,g,L),x<p?(N(n,g,M),M<0&&N(n,g,-M)):m&&N(n,g,L);else{let w=-g;x>0?(N(n,w,-h),h>0&&N(n,w,h)):m&&N(n,w,L),x<p?(N(t,w,-M),M>0&&N(t,w,M)):m&&N(t,w,L)}h=g,g=M}});let a=new Uint8Array(e.nodes.length);e.nodes.forEach((f,u)=>{xs(u,t,n)!==0&&(a[u]=1)});let i=new Int32Array(e.nodes.length),c=new Float64Array(e.nodes.length),l=new Float64Array(e.nodes.length);e.nodes.forEach((f,u)=>{if(a[u]!==1){i[u]=u,l[u]=f.sequenceLength;for(let m=u;ys(m,t,n);)m=W(n,m),i[m]=u,c[m]=f.sequenceLength,f.sequenceLength+=e.nodes[m].sequenceLength,f.seq+=e.nodes[m].seq,l[m]=f.sequenceLength}}),e.reads.forEach(f=>{let{sequence:u}=f,m=f.sequenceNew??u.map(w=>({nodeName:w,mismatches:[]})),p=w=>{let b=Math.abs(o(w));return O(w)?e.nodes[i[b]].sequenceLength-l[b]:c[b]},h=u.length-1;f.firstNodeOffset=(f.firstNodeOffset??0)+p(u[0]),f.finalNodeCoverLength=(f.finalNodeCoverLength??0)+p(u[h]);let g=[],x=[],M=[];u.forEach((w,b)=>{let E=Math.abs(o(w)),{mismatches:y}=m[b],S=p(w);if(y.forEach(v=>{v.pos+=S}),a[E]===1&&!O(w)&&b>0)x.at(-1).mismatches.push(...y);else if(a[E]===1&&O(w)&&b<h)M.push(...y);else{let v=e.nodes[i[E]].name,_=O(w)?mn(v):v;g.push(_),x.push({nodeName:_,mismatches:M.concat(y)}),M=[]}}),f.sequence=g,f.sequenceNew!==void 0&&(f.sequenceNew=x)}),e.tracks.forEach(f=>{let{sequence:u}=f,m=0;for(let p of u)a[Math.abs(o(p))]===0&&(u[m]=p,m+=1);u.length=m});let d=1;for(let f=1;f<e.nodes.length;f+=1)a[f]===0&&(e.nodes[d]=e.nodes[f],d+=1);e.nodes.length=d}function xs(e,t,n){let r=W(t,e);return r!==0&&W(n,r)!==0?r:0}function ys(e,t,n){let r=W(n,e);return r!==0&&W(t,r)!==0}function bs(e,t){let n=new Map;for(let r of e){let o=t(r),s=n.get(o);s===void 0?n.set(o,[r]):s.push(r)}return n}function Ms(e,t){return e.xStart<t.xStart?1:e.xStart>t.xStart?-1:e.yStart>t.yStart?1:e.yStart<t.yStart?-1:0}function Be(e){return[e.nodeStart??-1,e.nodeEnd??-1,e.nodeStart===null?e.orderStart:-1,e.nodeEnd===null?e.orderEnd:-1]}function ws(e,t){for(let n=0;n<e.length;n+=1){let r=e[n]-t[n];if(r!==0)return r}return 0}function Mn(e,t){let n=bs(e.filter(r=>r.type===t),r=>Be(r).join(","));return n.forEach(r=>{let o=.3,s=.4/r.length;r.length<=5&&(o=.5,s=0),r.sort(Ms),r.forEach(a=>{let i,c;a.yStart<a.yEnd?(i=a.xStart+(a.xEnd-a.xStart)*(1-o),o+=s,c=a.xStart+(a.xEnd-a.xStart)*(1-o)):(i=a.xStart+(a.xEnd-a.xStart)*o,o+=s,c=a.xStart+(a.xEnd-a.xStart)*o);let l=`M ${a.xStart} ${a.yStart}`;l+=` C ${i} ${a.yStart} ${i} ${a.yEnd} ${a.xEnd} ${a.yEnd}`,l+=` V ${a.yEnd+a.width}`,l+=` C ${c} ${a.yEnd+a.width} ${c} ${a.yStart+a.width} ${a.xStart} ${a.yStart+a.width}`,l+=" Z",a.path=l})}),[...n.values()].sort((r,o)=>ws(Be(r[0]),Be(o[0]))).flat()}function wn(e){let t=`M ${e.x-9} ${e.y} Q ${e.x-9} ${e.y-9} ${e.x} ${e.y-9}`,n=e.x,r=e.y-9;return e.width>1&&(n+=e.pixelWidth,t+=` L ${n} ${r}`),t+=` Q ${n+9} ${r} ${n+9} ${r+9}`,n+=9,r+=9,e.contentHeight>0&&(r+=e.contentHeight,t+=` L ${n} ${r}`),t+=` Q ${n} ${r+9} ${n-9} ${r+9}`,n-=9,r+=9,e.width>1&&(n-=e.pixelWidth,t+=` L ${n} ${r}`),t+=` Q ${n-9} ${r} ${n-9} ${r-9}`,n-=9,r-=9,e.contentHeight>0&&(r-=e.contentHeight,t+=` L ${n} ${r}`),t}function Es(e,t){let n=[],r=e.sequenceNew??[];return r.forEach((o,s)=>{let a=t.nodeMap.get(A(o.nodeName)),i=a===void 0?void 0:t.nodes[a],c=s;for(;c<e.path.length&&e.path[c].node!==a;)c+=1;let l=e.path[c]?.y;if(i&&l!==void 0){let d={readId:e.id,y:l,height:e.width,nodeY:i.y},f=u=>xn(i,u);for(let u of o.mismatches){let m=f(u.pos);if(m!==null){if(u.type==="insertion"){let p=s===0&&u.pos===e.firstNodeOffset||s===r.length-1&&u.pos===e.finalNodeCoverLength;n.push({...d,kind:"insertion",x:m,seq:u.seq,softClip:p})}else if(u.type==="deletion"&&u.length!==void 0){let p=f(u.pos+u.length);p!==null&&n.push({...d,kind:"deletion",x0:m,x1:p})}else if(u.type==="substitution"&&u.seq!==void 0){let p=f(u.pos+u.seq.length);p!==null&&n.push({...d,kind:"substitution",x0:m,x1:p,seq:u.seq})}}}}}),n}function En(e){return e.reads.flatMap(t=>Es(t,e))}function Fe(e){let t=e.trim().split(/[\s,]+/),n=[],r=0,o=()=>Number(t[r++]);for(;r<t.length;){let s=t[r++];s==="M"||s==="L"?n.push({op:s,x:o(),y:o()}):s==="H"?n.push({op:s,x:o()}):s==="V"?n.push({op:s,y:o()}):s==="Q"?n.push({op:s,x1:o(),y1:o(),x:o(),y:o()}):s==="C"?n.push({op:s,x1:o(),y1:o(),x2:o(),y2:o(),x:o(),y:o()}):s==="Z"&&n.push({op:s})}return n}function Nn(e){let t=1/0,n=-1/0;for(let r of e)"x"in r&&(t=Math.min(t,r.x),n=Math.max(n,r.x)),"x1"in r&&(t=Math.min(t,r.x1),n=Math.max(n,r.x1));return{x0:t,x1:n}}function Sn(e,t,n){let r=Fe(e);return{commands:r,color:t,track:n,...Nn(r)}}function On(e,t){return new Map(e.tracks.map(n=>[n.id,n.type==="read"?tt(n):t[n.id]]))}function vn(e,t,n){let{shapes:r}=e,o=l=>n.get(l.id),s=l=>t==="haplotype"?l.id:void 0,a=[...r.rectangles,...r.verticalRectangles].filter(l=>l.type===t).map(l=>({color:o(l),track:s(l),x0:l.xStart,x1:l.xEnd+1,y0:l.yStart,y1:l.yEnd+1})),i=Mn(r.curves,t).map(l=>Sn(l.path,o(l),s(l))),c=r.corners.filter(l=>l.type===t).map(l=>Sn(l.path,o(l),s(l)));return{rects:a,shapes:[...i,...c]}}function Ss({layout:e,pathColors:t}){let n=On(e,t),r=[];return e.nodes.forEach(o=>{if(o.order>=0){let s=Fe(wn(o));r.push({name:o.name,commands:s,...Nn(s)})}}),{bounds:e.bounds,layers:[vn(e,"haplotype",n),vn(e,"read",n)],nodes:r,mismatches:En(e).filter(o=>o.kind!=="insertion"||!o.softClip)}}function Rn(e,t,n,r){let o=0,s=0;for(let a of t)switch(a.op){case"M":o=a.x,s=a.y,e.moveTo(n(o),r(s));break;case"L":o=a.x,s=a.y,e.lineTo(n(o),r(s));break;case"H":o=a.x,e.lineTo(n(o),r(s));break;case"V":s=a.y,e.lineTo(n(o),r(s));break;case"Q":o=a.x,s=a.y,e.quadraticCurveTo(n(a.x1),r(a.y1),n(o),r(s));break;case"C":o=a.x,s=a.y,e.bezierCurveTo(n(a.x1),r(a.y1),n(a.x2),r(a.y2),n(o),r(s));break;case"Z":e.closePath();break}}function _n(e,t,n,r,o){let s=new Map;for(let a of t)if(n(a)){let i=r(a),c=s.get(i);c?c.push(a):s.set(i,[a])}for(let a of s.values()){e.fillStyle=r(a[0]),e.beginPath();for(let i of a)o(i);e.fill()}}var vs=12,Rs=.15;function _s(e){return Math.max(Rs,Math.min(1,e/vs))}var Ns=.55;function Os(e,t,n){let{x:r,y:o,width:s}=n,a=d=>r(d.x1)>=0&&r(d.x0)<=s,i=d=>d.track!==void 0&&n.tubeColors?.[d.track]||d.color;e.globalAlpha=1;for(let d of t.layers)_n(e,d.rects,a,i,f=>{let u=r(f.x0),m=o(f.y0);e.rect(u,m,r(f.x1)-u,o(f.y1)-m)}),_n(e,d.shapes,a,i,f=>{Rn(e,f.commands,r,o)});let c=n.darkMode?"#d0d0d0":"#000000",l=n.darkMode?"rgba(40,40,40,0.4)":"rgba(255,255,255,0.4)";e.lineWidth=2*Math.max(.25,Math.min(1,n.yScale));for(let d of t.nodes)if(a(d)){let f=d.name===n.highlightNode;e.beginPath(),Rn(e,d.commands,r,o);let u=f?void 0:n.nodeColors?.get(d.name);e.fillStyle=f?"rgba(255,192,203,0.5)":u??l,e.strokeStyle=f?"#ff0000":c,e.globalAlpha=u?Ns:1,e.fill(),e.globalAlpha=f?1:_s(r(d.x1)-r(d.x0)),e.stroke(),e.globalAlpha=1}Ts(e,t.mismatches,n)}var An=12,As=6;function Tn(e){return An*e>=As}function De(e,{x:t,width:n}){let[r,o]=e.kind==="insertion"?[e.x,e.x]:[e.x0,e.x1];return t(o)>=0&&t(r)<=n}function Ts(e,t,n){let{x:r,y:o,yScale:s,darkMode:a}=n;if(!Tn(s)||t.length===0)return;let i=An*s;e.fillStyle="grey",e.beginPath();for(let c of t)if(c.kind==="deletion"&&De(c,n)){let l=r(c.x0),d=o(c.y);e.rect(l,d,r(c.x1)-l,o(c.y+c.height)-d)}e.fill(),e.font=`${i}px monospace`,e.textBaseline="alphabetic",e.fillStyle=a?"#ffffff":"#000000";for(let c of t)De(c,n)&&(c.kind==="substitution"?e.fillText(c.seq,r(c.x0)+1,o(c.y+c.height)):c.kind==="insertion"&&e.fillText("*",r(c.x)-3,o(c.y+c.height)))}function Cs(e,t){let n=[];for(let r of t){let o=e.get(r.refName),s=o?.[0],a=o?.at(-1);if(!o||!s||!a)continue;let i=Math.max(r.start,s.bp0),c=Math.min(r.end,a.bp1);c<=i||n.push({gene:r,...se(o,i,c),exons:r.exons.filter(l=>l.end>i&&l.start<c).map(l=>se(o,Math.max(l.start,i),Math.min(l.end,c)))})}return n}var Ye=22,ks=4,ce=8,$s="11px sans-serif",Is=8;function Ls(e){let t=e.flatMap(o=>[{x:o.x0,step:1},{x:o.x1,step:-1}]).sort((o,s)=>o.x-s.x||o.step-s.step),n=0,r=0;for(let{step:o}of t)n+=o,r=Math.max(r,n);return Math.min(ks,r)}function Ps(e,t,n,r,o=0){let{x:s,width:a,darkMode:i}=n,c=Math.max(1,Math.floor((r-o)/Ye)),l=[],d=i?"#e0e0e6":"#1c1c22";e.font=$s,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=d,e.strokeStyle=d,e.lineWidth=1;let f=t.map(u=>({g:u,s0:s(u.x0),s1:s(u.x1)})).filter(({s0:u,s1:m})=>m>=0&&u<=a).sort((u,m)=>u.s0-m.s0);for(let{g:u,s0:m,s1:p}of f){let h=u.gene.strand>0?" \u2192":u.gene.strand<0?"\u2190 ":"",g=u.gene.strand<0?`${h}${u.gene.name}`:`${u.gene.name}${h}`,x=(Math.max(m,0)+Math.min(p,a))/2,M=e.measureText(g).width/2,w=Math.min(m,x-M),b=Math.max(p,x+M),E=l.findIndex(S=>S+Is<=w);E===-1&&(E=Math.min(l.length,c-1)),l[E]=Math.max(l[E]??-1/0,b);let y=r-E*Ye-ce/2;e.beginPath(),e.moveTo(m,y+.5),e.lineTo(p,y+.5),e.stroke();for(let S of u.exons){let v=s(S.x0);e.fillRect(v,y-ce/2,Math.max(1,s(S.x1)-v),ce)}e.fillText(g,x,y-ce/2-2)}}var T=12,Ln=T+8,Pn=8,Cn=Pn+3,Xs=12;function qs(e,{colorScheme:t,referenceRamp:n,walks:r}){let o={...he(e),referenceRamp:n},s=[];return e.nodes.forEach((a,i)=>{if(C(a)){let c=r?r.map(l=>{let d=l.colors.get(a.id);return d===void 0?V:I(d)}):[I(pe(a,i,t,o))];s.push({node:a.id,bp0:a.stable.start,bp1:a.stable.start+a.length,colors:c,faded:c.includes(V)})}}),s.sort((a,i)=>a.bp0-i.bp0)}function We(e,t,n){let r=t*e.scale+e.translateX,o=n*e.scale+e.translateX;return r<o?[r,o]:[o,r]}var kn=2;function Xn(e,t,n){let r=-t.translateX/t.scale,o=(n-t.translateX)/t.scale,s=Math.min(r,o),a=Math.max(r,o),i=0,c=0;for(let l of e)i+=Math.max(0,Math.min(l.bp1,s)-l.bp0),c+=Math.max(0,l.bp1-Math.max(l.bp0,a));return t.scale>=0?{left:Math.round(i),right:Math.round(c)}:{left:Math.round(c),right:Math.round(i)}}function Bs(e,t,n,r){if(r<0||r>T+kn)return;let o,s=kn;for(let a of e){let[i,c]=We(t,a.bp0,a.bp1),l=Math.max(0,i-n,n-c);l<=s&&(s=l,o=a.node)}return o}function Ds(e,t){let n=e?.[Math.floor(e.length/2)];return n?t(n):void 0}function qn(e,t,n,r){let o=e.map(l=>{let[d,f]=We(t,l.bp0,l.bp1),u=Math.round(d*r);return{colors:l.colors,x0:d,px0:u,px1:Math.max(Math.round(f*r),u+1)}}).filter(l=>l.px1>0&&l.px0<n*r).sort((l,d)=>l.x0-d.x0),s=[],a=-1/0,i=[-1/0,-1/0];for(let{colors:l,px0:d,px1:f}of o){let u=Math.max(d,a);if(f>u){let m=i[0]<u?0:1;i[m]=f,s.push({colors:l,x0:u/r,x1:f/r,tier:m}),a=f}}return(s.length>0?s.at(-1).x1-s[0].x0:0)>=s.length*Xs?s:s.map(({tier:l,...d})=>d)}function $n(e,t,n,r){let o=n>0?t:t-Cn;e.clearRect(o,0,Cn,T);let s=t+n,a=s+n*Pn;e.beginPath(),e.moveTo(s,T/2),e.lineTo(a,0),e.lineTo(a,T),e.closePath(),e.fillStyle=r,e.fill()}function In(e,t,n){return Math.round(e*T*n/t)/n}function Fs(e,t,n,{width:r,lit:o,darkMode:s,dpr:a=1}){let i=s?"#ffffff":"#18181c";e.clearRect(0,0,r,Ln);for(let l of qn(t,n,r,a)){let{tier:d}=l,f=d!==void 0&&l.colors.length===1,u=f?2:l.colors.length;l.colors.forEach((m,p)=>{let h=f?d:p,g=In(h,u,a);e.fillStyle=m,e.fillRect(l.x0,g,l.x1-l.x0,In(h+1,u,a)-g)})}let c=Xn(t,n,r);if(c.left>0&&$n(e,0,1,i),c.right>0&&$n(e,r,-1,i),o){let[l,d]=We(n,o.start,o.end),f=Math.max(d-l,3),u=(l+d)/2-f/2;e.strokeStyle=i,e.lineWidth=1.5,e.strokeRect(u,.75,f,T-1.5),o.anchor&&(e.beginPath(),e.moveTo(u+f/2,T),e.lineTo(o.anchor.x,o.anchor.y),e.lineWidth=1,e.stroke())}}function Ys(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function Ws(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0)),s=Array.from({length:n+1},()=>new Array(r+1).fill(!1));for(let i=n-1;i>=0;i--)for(let c=r-1;c>=0;c--){let l=Math.abs(e[i]-t[c])+o[i+1][c+1],d=n-i>r-c?o[i+1][c]:1/0,f=r-c>n-i?o[i][c+1]:1/0;o[i][c]=Math.min(l,d,f),s[i][c]=o[i][c]===l}let a=new Array(n).fill(void 0);for(let i=0,c=0;i<n&&c<r;)s[i][c]?a[i++]=c++:n-i>r-c?i++:c++;return a}function Bn(e,t){return e.map((n,r)=>({item:n,i:r})).sort((n,r)=>t(n.item)-t(r.item))}var Fn=e=>e.spanningReads!==0;function Dn(e,t){return{...t,agrees:e.complete&&Fn(t)?Ys(e.bp,t.bp):void 0}}function Hs(e,t){let n=new Map,r=new Set;e.forEach((i,c)=>{let l=t.find(d=>d.haplotype!==void 0&&d.haplotype===i.haplotype);l&&(r.add(l),n.set(c,Dn(i,l)))});let o=t.filter(i=>i.haplotype===void 0),s=Bn(e,i=>i.bp),a=[[s.filter(i=>i.item.complete),o.filter(Fn)],[s,o]];for(let[i,c]of a){let l=i.filter(f=>!n.has(f.i)),d=Bn(c.filter(f=>!r.has(f)),f=>f.bp);Ws(l.map(f=>f.item.bp),d.map(f=>f.item.bp)).forEach((f,u)=>{if(f!==void 0){let m=l[u],p=d[f].item;r.add(p),n.set(m.i,Dn(m.item,p))}})}return n}function Cl(e,t){if(!t)return e;let n=new Map,r=new Map;for(let o of e)r.set(o.sample,[...r.get(o.sample)??[],o]);for(let[o,s]of r){let a=t[o];if(a)for(let[i,c]of Hs(s,a))n.set(s[i],c)}return e.map(o=>({...o,call:n.get(o)}))}export{ar as a,Gn as b,Un as c,Us as d,jn as e,Vn as f,qc as g,J as h,me as i,ee as j,Zn as k,Jn as l,eo as m,to as n,ie as o,Mc as p,wc as q,Ec as r,Sc as s,vc as t,$ as u,io as v,co as w,lo as x,fo as y,st as z,R as A,po as B,Y as C,ve as D,Re as E,ct as F,Me as G,xo as H,yo as I,ht as J,Eo as K,mt as L,gt as M,_e as N,So as O,vo as P,_o as Q,Et as R,pi as S,Ao as T,yi as U,bi as V,Ae as W,$o as X,Io as Y,Ti as Z,It as _,Ci as $,Lt as aa,Te as ba,Pt as ca,Xt as da,zo as ea,jo as fa,Vo as ga,Dt as ha,or as ia,lr as ja,dr as ka,ur as la,hr as ma,Ss as na,Os as oa,Tn as pa,De as qa,Cs as ra,Ye as sa,Ls as ta,Ps as ua,Ln as va,qs as wa,Xn as xa,Bs as ya,Ds as za,Fs as Aa,mc as Ba,ir as Ca,gc as Da,Cl as Ea};
2
+ //# sourceMappingURL=chunk-GB7CF6Z2.js.map