jbrowse-plugin-graphgenomeviewer 8.3.1 → 8.3.3

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 (85) hide show
  1. package/README.md +7 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-Y5VUDFZP.js → GbzBaseSyntenyAdapter-OLFYIFN4.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-Y5VUDFZP.js.map → GbzBaseSyntenyAdapter-OLFYIFN4.js.map} +1 -1
  4. package/dist/chunks/{GraphGenomeView-VW3PEHFP.js → GraphGenomeView-TC3UNRFN.js} +2 -2
  5. package/dist/chunks/{GraphTrackSettingsDialog-TT5TXM5I.js → GraphTrackSettingsDialog-JZBOLXZW.js} +2 -2
  6. package/dist/chunks/{HighlightColorDialog-R3EIOO2M.js → HighlightColorDialog-4VGVC7SN.js} +2 -2
  7. package/dist/chunks/{LinearGraphDisplay-OBD4R5G3.js → LinearGraphDisplay-6IO5ADGB.js} +2 -2
  8. package/dist/chunks/{MinigraphBubbleAdapter-QXISPSHM.js → MinigraphBubbleAdapter-X4VJ3AEX.js} +2 -2
  9. package/dist/chunks/{RgfaTabixAdapter-SVZ5SSEY.js → RgfaTabixAdapter-535GN32R.js} +2 -2
  10. package/dist/chunks/{WalkFormsAdapter-6LK2XCHQ.js → WalkFormsAdapter-DAGNKDXV.js} +2 -2
  11. package/dist/chunks/{WalkTabixSyntenyAdapter-LA22PX4I.js → WalkTabixSyntenyAdapter-M453NH3L.js} +2 -2
  12. package/dist/chunks/chunk-2EDOJEF3.js +4 -0
  13. package/dist/chunks/chunk-2EDOJEF3.js.map +7 -0
  14. package/dist/chunks/{chunk-IUBWMYUA.js → chunk-37XRCKBJ.js} +2 -2
  15. package/dist/chunks/{chunk-IUBWMYUA.js.map → chunk-37XRCKBJ.js.map} +1 -1
  16. package/dist/chunks/{chunk-TMFUYJFG.js → chunk-4CP5H6LQ.js} +2 -2
  17. package/dist/chunks/chunk-52L7CQAG.js +3 -0
  18. package/dist/chunks/chunk-52L7CQAG.js.map +7 -0
  19. package/dist/chunks/chunk-A4YJFEBE.js +2 -0
  20. package/dist/chunks/{chunk-DSKPOCCE.js → chunk-B6YUND32.js} +2 -2
  21. package/dist/chunks/{chunk-DSKPOCCE.js.map → chunk-B6YUND32.js.map} +1 -1
  22. package/dist/chunks/{chunk-NSBH4FIW.js → chunk-BI2RYKPA.js} +2 -2
  23. package/dist/chunks/chunk-BI2RYKPA.js.map +7 -0
  24. package/dist/chunks/{chunk-B2MJV7HN.js → chunk-CCPRHM4X.js} +1 -1
  25. package/dist/chunks/{chunk-B2MJV7HN.js.map → chunk-CCPRHM4X.js.map} +1 -1
  26. package/dist/chunks/{chunk-WA7FCDLQ.js → chunk-DXJSOZY2.js} +1 -1
  27. package/dist/chunks/{chunk-WA7FCDLQ.js.map → chunk-DXJSOZY2.js.map} +1 -1
  28. package/dist/chunks/{chunk-NAC3EXT4.js → chunk-ELO4G2TG.js} +2 -2
  29. package/dist/chunks/{chunk-NAC3EXT4.js.map → chunk-ELO4G2TG.js.map} +1 -1
  30. package/dist/chunks/{chunk-PEE2MP7K.js → chunk-JBQSIRNH.js} +1 -1
  31. package/dist/chunks/{chunk-PEE2MP7K.js.map → chunk-JBQSIRNH.js.map} +1 -1
  32. package/dist/chunks/{chunk-EKGY6PG2.js → chunk-MBGXXS3Z.js} +2 -2
  33. package/dist/chunks/{chunk-EKGY6PG2.js.map → chunk-MBGXXS3Z.js.map} +1 -1
  34. package/dist/chunks/chunk-NLMAQYCK.js +2 -0
  35. package/dist/chunks/chunk-NLMAQYCK.js.map +7 -0
  36. package/dist/chunks/{chunk-QATGAV57.js → chunk-QCEM5AXZ.js} +2 -2
  37. package/dist/chunks/{chunk-QATGAV57.js.map → chunk-QCEM5AXZ.js.map} +1 -1
  38. package/dist/chunks/chunk-QY2UJ4TX.js +4 -0
  39. package/dist/chunks/chunk-QY2UJ4TX.js.map +7 -0
  40. package/dist/chunks/{chunk-G3L2L62S.js → chunk-SZZZD7I3.js} +2 -2
  41. package/dist/chunks/{chunk-HAVM67SF.js → chunk-UMCYJHEB.js} +2 -2
  42. package/dist/chunks/chunk-UZYU3HDD.js +2 -0
  43. package/dist/chunks/chunk-UZYU3HDD.js.map +7 -0
  44. package/dist/chunks/{chunk-DL2S7QKE.js → chunk-YUA46UN2.js} +2 -2
  45. package/dist/chunks/{chunk-DL2S7QKE.js.map → chunk-YUA46UN2.js.map} +1 -1
  46. package/dist/chunks/{chunk-PMM6BEKY.js → chunk-YVRZM7FP.js} +1 -1
  47. package/dist/chunks/{chunk-PMM6BEKY.js.map → chunk-YVRZM7FP.js.map} +1 -1
  48. package/dist/chunks/{renderSvg-2DPRP5UX.js → renderSvg-MNRHFE4C.js} +2 -2
  49. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
  50. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +3 -3
  51. package/package.json +2 -2
  52. package/src/GetSubgraph.ts +2 -0
  53. package/src/GraphGenomeView/legendSections.ts +5 -2
  54. package/src/GraphGenomeView/model.ts +8 -1
  55. package/src/RgfaTabixAdapter/configSchema.ts +1 -1
  56. package/src/RgfaTabixAdapter/walkFiles.test.ts +14 -0
  57. package/src/RgfaTabixAdapter/walkReader.ts +22 -5
  58. package/src/WalkFormsAdapter/configSchema.ts +1 -1
  59. package/src/WalkTabixSyntenyAdapter/configSchema.ts +1 -1
  60. package/src/version.ts +1 -1
  61. package/dist/chunks/chunk-5ZGRAPN5.js +0 -4
  62. package/dist/chunks/chunk-5ZGRAPN5.js.map +0 -7
  63. package/dist/chunks/chunk-73B6AYVV.js +0 -2
  64. package/dist/chunks/chunk-73B6AYVV.js.map +0 -7
  65. package/dist/chunks/chunk-AUQISDXJ.js +0 -2
  66. package/dist/chunks/chunk-AUQISDXJ.js.map +0 -7
  67. package/dist/chunks/chunk-GIIUVBOH.js +0 -4
  68. package/dist/chunks/chunk-GIIUVBOH.js.map +0 -7
  69. package/dist/chunks/chunk-MHIKXNVU.js +0 -3
  70. package/dist/chunks/chunk-MHIKXNVU.js.map +0 -7
  71. package/dist/chunks/chunk-NSBH4FIW.js.map +0 -7
  72. package/dist/chunks/chunk-WO3MEQ25.js +0 -2
  73. /package/dist/chunks/{GraphGenomeView-VW3PEHFP.js.map → GraphGenomeView-TC3UNRFN.js.map} +0 -0
  74. /package/dist/chunks/{GraphTrackSettingsDialog-TT5TXM5I.js.map → GraphTrackSettingsDialog-JZBOLXZW.js.map} +0 -0
  75. /package/dist/chunks/{HighlightColorDialog-R3EIOO2M.js.map → HighlightColorDialog-4VGVC7SN.js.map} +0 -0
  76. /package/dist/chunks/{LinearGraphDisplay-OBD4R5G3.js.map → LinearGraphDisplay-6IO5ADGB.js.map} +0 -0
  77. /package/dist/chunks/{MinigraphBubbleAdapter-QXISPSHM.js.map → MinigraphBubbleAdapter-X4VJ3AEX.js.map} +0 -0
  78. /package/dist/chunks/{RgfaTabixAdapter-SVZ5SSEY.js.map → RgfaTabixAdapter-535GN32R.js.map} +0 -0
  79. /package/dist/chunks/{WalkFormsAdapter-6LK2XCHQ.js.map → WalkFormsAdapter-DAGNKDXV.js.map} +0 -0
  80. /package/dist/chunks/{WalkTabixSyntenyAdapter-LA22PX4I.js.map → WalkTabixSyntenyAdapter-M453NH3L.js.map} +0 -0
  81. /package/dist/chunks/{chunk-TMFUYJFG.js.map → chunk-4CP5H6LQ.js.map} +0 -0
  82. /package/dist/chunks/{chunk-WO3MEQ25.js.map → chunk-A4YJFEBE.js.map} +0 -0
  83. /package/dist/chunks/{chunk-G3L2L62S.js.map → chunk-SZZZD7I3.js.map} +0 -0
  84. /package/dist/chunks/{chunk-HAVM67SF.js.map → chunk-UMCYJHEB.js.map} +0 -0
  85. /package/dist/chunks/{renderSvg-2DPRP5UX.js.map → renderSvg-MNRHFE4C.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{i as M,l as W,p as F}from"./chunk-WA7FCDLQ.js";import{b as O,h as A}from"./chunk-PMM6BEKY.js";import{K as b,Q as _,X as B}from"./chunk-NSBH4FIW.js";import{f as R}from"./chunk-NIEZKWQV.js";import{D as E,E as P,H as m,d as v,o as T,q as I,r as L,s as w,t as N,w as D,y as G,z as x}from"./chunk-5Z4VIKXZ.js";import{b as t,c as r,d as C}from"./chunk-JMBDTNUR.js";var S=[{value:0,label:"Fastest"},{value:1,label:"Fast"},{value:2,label:"Default"},{value:3,label:"Fine"},{value:4,label:"Best"}];function f({label:o,value:n,options:e,testId:s,size:d,sx:p,disabled:a,title:h,shown:g,onChange:z}){let k=R();return r(w,{size:d,sx:p,disabled:a,title:h,children:[t(D,{id:k,shrink:!0,children:o}),t(E,{labelId:k,value:n,label:o,notched:!0,displayEmpty:!0,"data-testid":s,renderValue:i=>g??e.find(H=>H.value===i)?.label??i,onChange:i=>{z(i.target.value)},children:e.map(i=>t(x,{value:i.value,disabled:i.disabled,title:i.disabled?void 0:i.description,children:t(G,{primary:i.label,secondary:i.disabled?i.description:void 0})},i.value))})]})}var u=F()({section:{marginBottom:24},group:{marginBottom:16},heading:{marginBottom:8}});function l({warn:o=!1,children:n}){return t(m,{variant:"caption",component:"div",color:o?"warning.main":"text.secondary",children:n})}function y({title:o,children:n}){let{classes:e}=u();return r("section",{className:e.group,children:[t(m,{variant:"subtitle1",className:e.heading,children:o}),n]})}function U({label:o,checked:n,onChange:e,children:s}){let{classes:d}=u();return r("div",{className:d.section,children:[t(N,{control:t(P,{checked:n,onChange:p=>{e(p.target.checked)}}),label:o}),s]})}function c({children:o,...n}){let{classes:e}=u();return r("div",{className:e.section,children:[t(f,{sx:{minWidth:200},...n}),o]})}var Y=[5e3,2e4,5e4,1e5];function $(o){return[...new Set([...Y,o])].sort((n,e)=>n-e).map(n=>({value:String(n),label:n.toLocaleString()}))}function Q({label:o,choices:n,stored:e,auto:s,testId:d,onChange:p,children:a}){return n.length>0?t(c,{label:o,value:n.some(h=>h.trackId===e)?e:"",options:[{value:"",label:`Automatic (${s?.name??"none"})`},...n.map(({trackId:h,name:g})=>({value:h,label:g}))],testId:d,onChange:p,children:a}):null}var q=C(function(n){let{model:e,onClose:s,children:d}=n,{classes:p}=u();return r(v,{open:!0,onClose:s,title:"Graph settings",children:[r(L,{children:[r(y,{title:"Subgraph",children:[d,t(c,{label:"Node limit",value:String(e.maxGraphNodes),options:$(e.maxGraphNodes),testId:"graph-node-limit-select",onChange:a=>{e.setMaxGraphNodes(Number(a))},children:t(l,{children:"The most nodes a layout draws; past it the graph is declined. Walk rows take no limit."})})]}),r(y,{title:"Drawing",children:[e.anchorPaths.length>1?t(c,{label:"Reference path",value:e.activeReferencePath??"",options:e.anchorPaths.map(({name:a})=>({value:a,label:a})),testId:"graph-reference-path-select",onChange:a=>{e.setReferencePath(a),e.recomputeLayout()},children:t(l,{children:"The path the anchored layouts place x along"})}):null,t(c,{label:"Node width",value:e.nodeWidth,options:_,testId:"graph-node-width-select",onChange:a=>{e.setNodeWidth(a)},children:t(l,{children:"Depth as width. In a cut with walks, depth is how many haplotypes carry the node."})}),t(c,{label:"Link width",value:e.linkWidth,options:B,testId:"graph-link-width-select",onChange:a=>{e.setLinkWidth(a)},children:t(l,{children:"Walks as width, so a common route reads heavy and a private one thin."})}),r(U,{label:"Draw paths",checked:e.drawPaths,onChange:a=>{e.setLayer("paths",a)},children:[t(l,{children:"Color each node by the paths through it, one lane per path"}),e.drawPaths&&!e.effectiveDrawPaths?t(l,{warn:!0,children:e.pathCount>b?`Off: ${e.pathCount.toLocaleString()} paths is past the ${b} this can tell apart`:"Off: this graph states no paths"}):null]}),t(Q,{label:"Gene track",choices:e.geneTrackChoices,stored:e.geneTrackId,auto:W(e.geneTrackChoices,""),testId:"graph-gene-track-select",onChange:a=>{e.setGeneTrackId(a)},children:t(l,{children:"Where genes on the backbone come from"})}),t(Q,{label:"Repeat track",choices:e.repeatTrackChoices,stored:e.repeatTrackId,auto:M(e.repeatTrackChoices,""),testId:"graph-repeat-track-select",onChange:a=>{e.setRepeatTrackId(a)},children:t(l,{children:"The tandem repeat annotation walk rows measure and tile by"})})]}),r(y,{title:"Force-directed layout",children:[e.hasGraph&&!e.usesLayoutEngine?t("div",{className:p.section,children:t(l,{warn:!0,children:"No effect on the current layout until Layout is Force-directed"})}):null,t(c,{label:"Engine",value:e.layoutEngine,options:O,testId:"graph-layout-engine-select",onChange:a=>{e.setLayoutEngine(a)},children:t(l,{children:"Stress keeps the reference straight, so a zoom keeps the picture; FMMM lets the whole graph settle."})}),t(c,{label:"Layout quality",value:String(e.layoutQuality),options:S.map(a=>({value:String(a.value),label:a.label})),testId:"graph-layout-quality-select",onChange:a=>{e.setLayoutQuality(Number(a))},children:t(l,{children:"The engine's iteration budget; higher is slower"})}),t(c,{label:"Bubble spread",value:e.bubbleSpread,options:A,testId:"graph-bubble-spread-select",onChange:a=>{e.setBubbleSpread(a)},children:t(l,{children:"How far the layout opens a bubble"})}),e.layoutEngine==="stress"?null:t(U,{label:"Linear layout",checked:e.linearLayout,onChange:a=>{e.setLinearLayout(a)},children:t(l,{children:"Keeps a chain of nodes on one line where it can"})})]})]}),t(I,{children:t(T,{variant:"contained",color:"primary",onClick:s,children:"Close"})})]})}),ge=q;export{f as a,ge as b};
2
- //# sourceMappingURL=chunk-IUBWMYUA.js.map
1
+ import{i as M,l as W,p as F}from"./chunk-DXJSOZY2.js";import{b as O,h as A}from"./chunk-YVRZM7FP.js";import{K as b,Q as _,X as B}from"./chunk-BI2RYKPA.js";import{f as R}from"./chunk-NIEZKWQV.js";import{D as E,E as P,H as m,d as v,o as T,q as I,r as L,s as w,t as N,w as D,y as G,z as x}from"./chunk-5Z4VIKXZ.js";import{b as t,c as r,d as C}from"./chunk-JMBDTNUR.js";var S=[{value:0,label:"Fastest"},{value:1,label:"Fast"},{value:2,label:"Default"},{value:3,label:"Fine"},{value:4,label:"Best"}];function f({label:o,value:n,options:e,testId:s,size:d,sx:p,disabled:a,title:h,shown:g,onChange:z}){let k=R();return r(w,{size:d,sx:p,disabled:a,title:h,children:[t(D,{id:k,shrink:!0,children:o}),t(E,{labelId:k,value:n,label:o,notched:!0,displayEmpty:!0,"data-testid":s,renderValue:i=>g??e.find(H=>H.value===i)?.label??i,onChange:i=>{z(i.target.value)},children:e.map(i=>t(x,{value:i.value,disabled:i.disabled,title:i.disabled?void 0:i.description,children:t(G,{primary:i.label,secondary:i.disabled?i.description:void 0})},i.value))})]})}var u=F()({section:{marginBottom:24},group:{marginBottom:16},heading:{marginBottom:8}});function l({warn:o=!1,children:n}){return t(m,{variant:"caption",component:"div",color:o?"warning.main":"text.secondary",children:n})}function y({title:o,children:n}){let{classes:e}=u();return r("section",{className:e.group,children:[t(m,{variant:"subtitle1",className:e.heading,children:o}),n]})}function U({label:o,checked:n,onChange:e,children:s}){let{classes:d}=u();return r("div",{className:d.section,children:[t(N,{control:t(P,{checked:n,onChange:p=>{e(p.target.checked)}}),label:o}),s]})}function c({children:o,...n}){let{classes:e}=u();return r("div",{className:e.section,children:[t(f,{sx:{minWidth:200},...n}),o]})}var Y=[5e3,2e4,5e4,1e5];function $(o){return[...new Set([...Y,o])].sort((n,e)=>n-e).map(n=>({value:String(n),label:n.toLocaleString()}))}function Q({label:o,choices:n,stored:e,auto:s,testId:d,onChange:p,children:a}){return n.length>0?t(c,{label:o,value:n.some(h=>h.trackId===e)?e:"",options:[{value:"",label:`Automatic (${s?.name??"none"})`},...n.map(({trackId:h,name:g})=>({value:h,label:g}))],testId:d,onChange:p,children:a}):null}var q=C(function(n){let{model:e,onClose:s,children:d}=n,{classes:p}=u();return r(v,{open:!0,onClose:s,title:"Graph settings",children:[r(L,{children:[r(y,{title:"Subgraph",children:[d,t(c,{label:"Node limit",value:String(e.maxGraphNodes),options:$(e.maxGraphNodes),testId:"graph-node-limit-select",onChange:a=>{e.setMaxGraphNodes(Number(a))},children:t(l,{children:"The most nodes a layout draws; past it the graph is declined. Walk rows take no limit."})})]}),r(y,{title:"Drawing",children:[e.anchorPaths.length>1?t(c,{label:"Reference path",value:e.activeReferencePath??"",options:e.anchorPaths.map(({name:a})=>({value:a,label:a})),testId:"graph-reference-path-select",onChange:a=>{e.setReferencePath(a),e.recomputeLayout()},children:t(l,{children:"The path the anchored layouts place x along"})}):null,t(c,{label:"Node width",value:e.nodeWidth,options:_,testId:"graph-node-width-select",onChange:a=>{e.setNodeWidth(a)},children:t(l,{children:"Depth as width. In a cut with walks, depth is how many haplotypes carry the node."})}),t(c,{label:"Link width",value:e.linkWidth,options:B,testId:"graph-link-width-select",onChange:a=>{e.setLinkWidth(a)},children:t(l,{children:"Walks as width, so a common route reads heavy and a private one thin."})}),r(U,{label:"Draw paths",checked:e.drawPaths,onChange:a=>{e.setLayer("paths",a)},children:[t(l,{children:"Color each node by the paths through it, one lane per path"}),e.drawPaths&&!e.effectiveDrawPaths?t(l,{warn:!0,children:e.pathCount>b?`Off: ${e.pathCount.toLocaleString()} paths is past the ${b} this can tell apart`:"Off: this graph states no paths"}):null]}),t(Q,{label:"Gene track",choices:e.geneTrackChoices,stored:e.geneTrackId,auto:W(e.geneTrackChoices,""),testId:"graph-gene-track-select",onChange:a=>{e.setGeneTrackId(a)},children:t(l,{children:"Where genes on the backbone come from"})}),t(Q,{label:"Repeat track",choices:e.repeatTrackChoices,stored:e.repeatTrackId,auto:M(e.repeatTrackChoices,""),testId:"graph-repeat-track-select",onChange:a=>{e.setRepeatTrackId(a)},children:t(l,{children:"The tandem repeat annotation walk rows measure and tile by"})})]}),r(y,{title:"Force-directed layout",children:[e.hasGraph&&!e.usesLayoutEngine?t("div",{className:p.section,children:t(l,{warn:!0,children:"No effect on the current layout until Layout is Force-directed"})}):null,t(c,{label:"Engine",value:e.layoutEngine,options:O,testId:"graph-layout-engine-select",onChange:a=>{e.setLayoutEngine(a)},children:t(l,{children:"Stress keeps the reference straight, so a zoom keeps the picture; FMMM lets the whole graph settle."})}),t(c,{label:"Layout quality",value:String(e.layoutQuality),options:S.map(a=>({value:String(a.value),label:a.label})),testId:"graph-layout-quality-select",onChange:a=>{e.setLayoutQuality(Number(a))},children:t(l,{children:"The engine's iteration budget; higher is slower"})}),t(c,{label:"Bubble spread",value:e.bubbleSpread,options:A,testId:"graph-bubble-spread-select",onChange:a=>{e.setBubbleSpread(a)},children:t(l,{children:"How far the layout opens a bubble"})}),e.layoutEngine==="stress"?null:t(U,{label:"Linear layout",checked:e.linearLayout,onChange:a=>{e.setLinearLayout(a)},children:t(l,{children:"Keeps a chain of nodes on one line where it can"})})]})]}),t(I,{children:t(T,{variant:"contained",color:"primary",onClick:s,children:"Close"})})]})}),ge=q;export{f as a,ge as b};
2
+ //# sourceMappingURL=chunk-37XRCKBJ.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.1.2/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-K5SIJGAE.js", "../../src/GraphGenomeView/components/LabelledSelect.tsx", "../../src/GraphGenomeView/components/GraphSettingsDialog.tsx"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.2.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-K5SIJGAE.js", "../../src/GraphGenomeView/components/LabelledSelect.tsx", "../../src/GraphGenomeView/components/GraphSettingsDialog.tsx"],
4
4
  "sourcesContent": ["// src/layoutQualities.ts\nvar LAYOUT_QUALITIES = [\n { value: 0, label: \"Fastest\" },\n { value: 1, label: \"Fast\" },\n { value: 2, label: \"Default\" },\n { value: 3, label: \"Fine\" },\n { value: 4, label: \"Best\" }\n];\n\nexport {\n LAYOUT_QUALITIES\n};\n", "import { useId } from 'react'\n\nimport {\n FormControl,\n InputLabel,\n ListItemText,\n MenuItem,\n Select,\n} from '@mui/material'\n\nimport type { SxProps } from '@mui/material'\n\ninterface SelectOption<T extends string> {\n value: T\n label: string\n // an option's tooltip, and the reason under a disabled one, whose tooltip\n // cannot open\n description?: string\n disabled?: boolean\n}\n\n// One dropdown with its label tied to it, so a screen reader names the combobox\nexport default function LabelledSelect<T extends string>({\n label,\n value,\n options,\n testId,\n size,\n sx,\n disabled,\n title,\n shown,\n onChange,\n}: {\n label: string\n value: T\n options: readonly SelectOption<T>[]\n testId?: string\n size?: 'small' | 'medium'\n sx?: SxProps\n disabled?: boolean\n title?: string\n // what the closed select reads, when not the picked option's label\n shown?: string\n onChange: (value: T) => void\n}) {\n const labelId = useId()\n return (\n <FormControl size={size} sx={sx} disabled={disabled} title={title}>\n <InputLabel id={labelId} shrink>\n {label}\n </InputLabel>\n <Select\n labelId={labelId}\n value={value}\n label={label}\n notched\n displayEmpty\n data-testid={testId}\n renderValue={picked =>\n shown ?? options.find(o => o.value === picked)?.label ?? picked\n }\n onChange={e => {\n onChange(e.target.value as T)\n }}\n >\n {options.map(o => (\n <MenuItem\n key={o.value}\n value={o.value}\n disabled={o.disabled}\n title={o.disabled ? undefined : o.description}\n >\n <ListItemText\n primary={o.label}\n secondary={o.disabled ? o.description : undefined}\n />\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n}\n", "import type { ReactNode } from 'react'\n\nimport { BUBBLE_SPREADS } from '@jbrowse/bandage-core/bubbleSpreads'\nimport { EDGE_WIDTHS } from '@jbrowse/bandage-core/edgeWidths'\nimport { LAYOUT_ENGINES } from '@jbrowse/bandage-core/layoutEngines'\nimport { LAYOUT_QUALITIES } from '@jbrowse/bandage-core/layoutQualities'\nimport { NODE_WIDTHS } from '@jbrowse/bandage-core/nodeWidths'\nimport { MAX_PATH_COLORS } from '@jbrowse/bandage-core/pathColors'\nimport { Dialog } from '@jbrowse/core/ui'\nimport {\n Button,\n DialogActions,\n DialogContent,\n FormControlLabel,\n Switch,\n Typography,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport LabelledSelect from './LabelledSelect'\nimport { pickGeneTrack } from '../genes/geneFeatures'\nimport { pickRepeatTrack } from '../repeats/repeatFeatures'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n group: {\n marginBottom: 16,\n },\n heading: {\n marginBottom: 8,\n },\n})\n\nfunction Caption({\n warn = false,\n children,\n}: {\n warn?: boolean\n children: ReactNode\n}) {\n return (\n <Typography\n variant=\"caption\"\n component=\"div\"\n color={warn ? 'warning.main' : 'text.secondary'}\n >\n {children}\n </Typography>\n )\n}\n\nfunction Group({ title, children }: { title: string; children: ReactNode }) {\n const { classes } = useStyles()\n return (\n <section className={classes.group}>\n <Typography variant=\"subtitle1\" className={classes.heading}>\n {title}\n </Typography>\n {children}\n </section>\n )\n}\n\nfunction SettingSwitch({\n label,\n checked,\n onChange,\n children,\n}: {\n label: string\n checked: boolean\n onChange: (checked: boolean) => void\n children?: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <FormControlLabel\n control={\n <Switch\n checked={checked}\n onChange={e => {\n onChange(e.target.checked)\n }}\n />\n }\n label={label}\n />\n {children}\n </div>\n )\n}\n\n// one dropdown setting, at the dialog's width, and its caption\nfunction SettingSelect<T extends string>({\n children,\n ...props\n}: Omit<Parameters<typeof LabelledSelect<T>>[0], 'size' | 'sx'> & {\n children?: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <LabelledSelect sx={{ minWidth: 200 }} {...props} />\n {children}\n </div>\n )\n}\n\nconst NODE_LIMITS = [5000, 20_000, 50_000, 100_000]\n\n// the presets, with a limit a session states among them\nfunction nodeLimitOptions(current: number) {\n return [...new Set([...NODE_LIMITS, current])]\n .sort((a, b) => a - b)\n .map(limit => ({ value: String(limit), label: limit.toLocaleString() }))\n}\n\ninterface NamedTrack {\n trackId: string\n name: string\n}\n\n// '' leaves the pick to the heuristic, so a session can go back to it\nfunction TrackPickSetting({\n label,\n choices,\n stored,\n auto,\n testId,\n onChange,\n children,\n}: {\n label: string\n choices: NamedTrack[]\n stored: string\n auto: NamedTrack | undefined\n testId: string\n onChange: (trackId: string) => void\n children: ReactNode\n}) {\n return choices.length > 0 ? (\n <SettingSelect\n label={label}\n value={choices.some(t => t.trackId === stored) ? stored : ''}\n options={[\n { value: '', label: `Automatic (${auto?.name ?? 'none'})` },\n ...choices.map(({ trackId, name }) => ({\n value: trackId,\n label: name,\n })),\n ]}\n testId={testId}\n onChange={onChange}\n >\n {children}\n </SettingSelect>\n ) : null\n}\n\n// Toggles the menus already offer (halos, genes, color) stay out of here.\n// `children` is the host's own part of the subgraph group.\nconst GraphSettingsDialog = observer(function GraphSettingsDialog(props: {\n model: GraphPaneModel\n onClose: () => void\n children?: ReactNode\n}) {\n const { model, onClose, children } = props\n const { classes } = useStyles()\n\n return (\n <Dialog open onClose={onClose} title=\"Graph settings\">\n <DialogContent>\n <Group title=\"Subgraph\">\n {children}\n <SettingSelect\n label=\"Node limit\"\n value={String(model.maxGraphNodes)}\n options={nodeLimitOptions(model.maxGraphNodes)}\n testId=\"graph-node-limit-select\"\n onChange={limit => {\n model.setMaxGraphNodes(Number(limit))\n }}\n >\n <Caption>\n The most nodes a layout draws; past it the graph is declined. Walk\n rows take no limit.\n </Caption>\n </SettingSelect>\n </Group>\n\n <Group title=\"Drawing\">\n {model.anchorPaths.length > 1 ? (\n <SettingSelect\n label=\"Reference path\"\n value={model.activeReferencePath ?? ''}\n options={model.anchorPaths.map(({ name }) => ({\n value: name,\n label: name,\n }))}\n testId=\"graph-reference-path-select\"\n onChange={name => {\n model.setReferencePath(name)\n void model.recomputeLayout()\n }}\n >\n <Caption>The path the anchored layouts place x along</Caption>\n </SettingSelect>\n ) : null}\n\n <SettingSelect\n label=\"Node width\"\n value={model.nodeWidth}\n options={NODE_WIDTHS}\n testId=\"graph-node-width-select\"\n onChange={width => {\n model.setNodeWidth(width)\n }}\n >\n <Caption>\n Depth as width. In a cut with walks, depth is how many haplotypes\n carry the node.\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Link width\"\n value={model.linkWidth}\n options={EDGE_WIDTHS}\n testId=\"graph-link-width-select\"\n onChange={links => {\n model.setLinkWidth(links)\n }}\n >\n <Caption>\n Walks as width, so a common route reads heavy and a private one\n thin.\n </Caption>\n </SettingSelect>\n\n <SettingSwitch\n label=\"Draw paths\"\n checked={model.drawPaths}\n onChange={draw => {\n model.setLayer('paths', draw)\n }}\n >\n <Caption>\n Color each node by the paths through it, one lane per path\n </Caption>\n {model.drawPaths && !model.effectiveDrawPaths ? (\n <Caption warn>\n {model.pathCount > MAX_PATH_COLORS\n ? `Off: ${model.pathCount.toLocaleString()} paths is past the ${MAX_PATH_COLORS} this can tell apart`\n : 'Off: this graph states no paths'}\n </Caption>\n ) : null}\n </SettingSwitch>\n\n <TrackPickSetting\n label=\"Gene track\"\n choices={model.geneTrackChoices}\n stored={model.geneTrackId}\n auto={pickGeneTrack(model.geneTrackChoices, '')}\n testId=\"graph-gene-track-select\"\n onChange={trackId => {\n model.setGeneTrackId(trackId)\n }}\n >\n <Caption>Where genes on the backbone come from</Caption>\n </TrackPickSetting>\n\n <TrackPickSetting\n label=\"Repeat track\"\n choices={model.repeatTrackChoices}\n stored={model.repeatTrackId}\n auto={pickRepeatTrack(model.repeatTrackChoices, '')}\n testId=\"graph-repeat-track-select\"\n onChange={trackId => {\n model.setRepeatTrackId(trackId)\n }}\n >\n <Caption>\n The tandem repeat annotation walk rows measure and tile by\n </Caption>\n </TrackPickSetting>\n </Group>\n\n <Group title=\"Force-directed layout\">\n {model.hasGraph && !model.usesLayoutEngine ? (\n <div className={classes.section}>\n <Caption warn>\n No effect on the current layout until Layout is Force-directed\n </Caption>\n </div>\n ) : null}\n\n <SettingSelect\n label=\"Engine\"\n value={model.layoutEngine}\n options={LAYOUT_ENGINES}\n testId=\"graph-layout-engine-select\"\n onChange={engine => {\n model.setLayoutEngine(engine)\n }}\n >\n <Caption>\n Stress keeps the reference straight, so a zoom keeps the picture;\n FMMM lets the whole graph settle.\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Layout quality\"\n value={String(model.layoutQuality)}\n options={LAYOUT_QUALITIES.map(q => ({\n value: String(q.value),\n label: q.label,\n }))}\n testId=\"graph-layout-quality-select\"\n onChange={quality => {\n model.setLayoutQuality(Number(quality))\n }}\n >\n <Caption>\n The engine&apos;s iteration budget; higher is slower\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Bubble spread\"\n value={model.bubbleSpread}\n options={BUBBLE_SPREADS}\n testId=\"graph-bubble-spread-select\"\n onChange={spread => {\n model.setBubbleSpread(spread)\n }}\n >\n <Caption>How far the layout opens a bubble</Caption>\n </SettingSelect>\n\n {model.layoutEngine === 'stress' ? null : (\n <SettingSwitch\n label=\"Linear layout\"\n checked={model.linearLayout}\n onChange={linear => {\n model.setLinearLayout(linear)\n }}\n >\n <Caption>Keeps a chain of nodes on one line where it can</Caption>\n </SettingSwitch>\n )}\n </Group>\n </DialogContent>\n\n <DialogActions>\n <Button variant=\"contained\" color=\"primary\" onClick={onClose}>\n Close\n </Button>\n </DialogActions>\n </Dialog>\n )\n})\n\nexport default GraphSettingsDialog\n"],
5
5
  "mappings": "8WACA,IAAIA,EAAmB,CACrB,CAAE,MAAO,EAAG,MAAO,SAAU,EAC7B,CAAE,MAAO,EAAG,MAAO,MAAO,EAC1B,CAAE,MAAO,EAAG,MAAO,SAAU,EAC7B,CAAE,MAAO,EAAG,MAAO,MAAO,EAC1B,CAAE,MAAO,EAAG,MAAO,MAAO,CAC5B,ECee,SAARC,EAAkD,CACvD,MAAAC,EACA,MAAAC,EACA,QAAAC,EACA,OAAAC,EACA,KAAAC,EACA,GAAAC,EACA,SAAAC,EACA,MAAAC,EACA,MAAAC,EACA,SAAAC,CACF,EAYG,CACD,IAAMC,EAAUC,EAAM,EACtB,OACEC,EAACC,EAAA,CAAY,KAAMT,EAAM,GAAIC,EAAI,SAAUC,EAAU,MAAOC,EAC1D,UAAAO,EAACC,EAAA,CAAW,GAAIL,EAAS,OAAM,GAC5B,SAAAV,EACH,EACAc,EAACE,EAAA,CACC,QAASN,EACT,MAAOT,EACP,MAAOD,EACP,QAAO,GACP,aAAY,GACZ,cAAaG,EACb,YAAac,GACXT,GAASN,EAAQ,KAAKgB,GAAKA,EAAE,QAAUD,CAAM,GAAG,OAASA,EAE3D,SAAUE,GAAK,CACbV,EAASU,EAAE,OAAO,KAAU,CAC9B,EAEC,SAAAjB,EAAQ,IAAIgB,GACXJ,EAACM,EAAA,CAEC,MAAOF,EAAE,MACT,SAAUA,EAAE,SACZ,MAAOA,EAAE,SAAW,OAAYA,EAAE,YAElC,SAAAJ,EAACO,EAAA,CACC,QAASH,EAAE,MACX,UAAWA,EAAE,SAAWA,EAAE,YAAc,OAC1C,GARKA,EAAE,KAST,CACD,EACH,GACF,CAEJ,CCxDA,IAAMI,EAAYC,EAAW,EAAE,CAC7B,QAAS,CACP,aAAc,EAChB,EACA,MAAO,CACL,aAAc,EAChB,EACA,QAAS,CACP,aAAc,CAChB,CACF,CAAC,EAED,SAASC,EAAQ,CACf,KAAAC,EAAO,GACP,SAAAC,CACF,EAGG,CACD,OACEC,EAACC,EAAA,CACC,QAAQ,UACR,UAAU,MACV,MAAOH,EAAO,eAAiB,iBAE9B,SAAAC,EACH,CAEJ,CAEA,SAASG,EAAM,CAAE,MAAAC,EAAO,SAAAJ,CAAS,EAA2C,CAC1E,GAAM,CAAE,QAAAK,CAAQ,EAAIT,EAAU,EAC9B,OACEU,EAAC,WAAQ,UAAWD,EAAQ,MAC1B,UAAAJ,EAACC,EAAA,CAAW,QAAQ,YAAY,UAAWG,EAAQ,QAChD,SAAAD,EACH,EACCJ,GACH,CAEJ,CAEA,SAASO,EAAc,CACrB,MAAAC,EACA,QAAAC,EACA,SAAAC,EACA,SAAAV,CACF,EAKG,CACD,GAAM,CAAE,QAAAK,CAAQ,EAAIT,EAAU,EAC9B,OACEU,EAAC,OAAI,UAAWD,EAAQ,QACtB,UAAAJ,EAACU,EAAA,CACC,QACEV,EAACW,EAAA,CACC,QAASH,EACT,SAAUI,GAAK,CACbH,EAASG,EAAE,OAAO,OAAO,CAC3B,EACF,EAEF,MAAOL,EACT,EACCR,GACH,CAEJ,CAGA,SAASc,EAAgC,CACvC,SAAAd,EACA,GAAGe,CACL,EAEG,CACD,GAAM,CAAE,QAAAV,CAAQ,EAAIT,EAAU,EAC9B,OACEU,EAAC,OAAI,UAAWD,EAAQ,QACtB,UAAAJ,EAACe,EAAA,CAAe,GAAI,CAAE,SAAU,GAAI,EAAI,GAAGD,EAAO,EACjDf,GACH,CAEJ,CAEA,IAAMiB,EAAc,CAAC,IAAM,IAAQ,IAAQ,GAAO,EAGlD,SAASC,EAAiBC,EAAiB,CACzC,MAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGF,EAAaE,CAAO,CAAC,CAAC,EAC1C,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EACpB,IAAIC,IAAU,CAAE,MAAO,OAAOA,CAAK,EAAG,MAAOA,EAAM,eAAe,CAAE,EAAE,CAC3E,CAQA,SAASC,EAAiB,CACxB,MAAAf,EACA,QAAAgB,EACA,OAAAC,EACA,KAAAC,EACA,OAAAC,EACA,SAAAjB,EACA,SAAAV,CACF,EAQG,CACD,OAAOwB,EAAQ,OAAS,EACtBvB,EAACa,EAAA,CACC,MAAON,EACP,MAAOgB,EAAQ,KAAKI,GAAKA,EAAE,UAAYH,CAAM,EAAIA,EAAS,GAC1D,QAAS,CACP,CAAE,MAAO,GAAI,MAAO,cAAcC,GAAM,MAAQ,MAAM,GAAI,EAC1D,GAAGF,EAAQ,IAAI,CAAC,CAAE,QAAAK,EAAS,KAAAC,CAAK,KAAO,CACrC,MAAOD,EACP,MAAOC,CACT,EAAE,CACJ,EACA,OAAQH,EACR,SAAUjB,EAET,SAAAV,EACH,EACE,IACN,CAIA,IAAM+B,EAAsBC,EAAS,SAA6BjB,EAI/D,CACD,GAAM,CAAE,MAAAkB,EAAO,QAAAC,EAAS,SAAAlC,CAAS,EAAIe,EAC/B,CAAE,QAAAV,CAAQ,EAAIT,EAAU,EAE9B,OACEU,EAAC6B,EAAA,CAAO,KAAI,GAAC,QAASD,EAAS,MAAM,iBACnC,UAAA5B,EAAC8B,EAAA,CACC,UAAA9B,EAACH,EAAA,CAAM,MAAM,WACV,UAAAH,EACDC,EAACa,EAAA,CACC,MAAM,aACN,MAAO,OAAOmB,EAAM,aAAa,EACjC,QAASf,EAAiBe,EAAM,aAAa,EAC7C,OAAO,0BACP,SAAUX,GAAS,CACjBW,EAAM,iBAAiB,OAAOX,CAAK,CAAC,CACtC,EAEA,SAAArB,EAACH,EAAA,CAAQ,kGAGT,EACF,GACF,EAEAQ,EAACH,EAAA,CAAM,MAAM,UACV,UAAA8B,EAAM,YAAY,OAAS,EAC1BhC,EAACa,EAAA,CACC,MAAM,iBACN,MAAOmB,EAAM,qBAAuB,GACpC,QAASA,EAAM,YAAY,IAAI,CAAC,CAAE,KAAAH,CAAK,KAAO,CAC5C,MAAOA,EACP,MAAOA,CACT,EAAE,EACF,OAAO,8BACP,SAAUA,GAAQ,CAChBG,EAAM,iBAAiBH,CAAI,EACtBG,EAAM,gBAAgB,CAC7B,EAEA,SAAAhC,EAACH,EAAA,CAAQ,uDAA2C,EACtD,EACE,KAEJG,EAACa,EAAA,CACC,MAAM,aACN,MAAOmB,EAAM,UACb,QAASI,EACT,OAAO,0BACP,SAAUC,GAAS,CACjBL,EAAM,aAAaK,CAAK,CAC1B,EAEA,SAAArC,EAACH,EAAA,CAAQ,6FAGT,EACF,EAEAG,EAACa,EAAA,CACC,MAAM,aACN,MAAOmB,EAAM,UACb,QAASM,EACT,OAAO,0BACP,SAAUC,GAAS,CACjBP,EAAM,aAAaO,CAAK,CAC1B,EAEA,SAAAvC,EAACH,EAAA,CAAQ,iFAGT,EACF,EAEAQ,EAACC,EAAA,CACC,MAAM,aACN,QAAS0B,EAAM,UACf,SAAUQ,GAAQ,CAChBR,EAAM,SAAS,QAASQ,CAAI,CAC9B,EAEA,UAAAxC,EAACH,EAAA,CAAQ,sEAET,EACCmC,EAAM,WAAa,CAACA,EAAM,mBACzBhC,EAACH,EAAA,CAAQ,KAAI,GACV,SAAAmC,EAAM,UAAYS,EACf,QAAQT,EAAM,UAAU,eAAe,CAAC,sBAAsBS,CAAe,uBAC7E,kCACN,EACE,MACN,EAEAzC,EAACsB,EAAA,CACC,MAAM,aACN,QAASU,EAAM,iBACf,OAAQA,EAAM,YACd,KAAMU,EAAcV,EAAM,iBAAkB,EAAE,EAC9C,OAAO,0BACP,SAAUJ,GAAW,CACnBI,EAAM,eAAeJ,CAAO,CAC9B,EAEA,SAAA5B,EAACH,EAAA,CAAQ,iDAAqC,EAChD,EAEAG,EAACsB,EAAA,CACC,MAAM,eACN,QAASU,EAAM,mBACf,OAAQA,EAAM,cACd,KAAMW,EAAgBX,EAAM,mBAAoB,EAAE,EAClD,OAAO,4BACP,SAAUJ,GAAW,CACnBI,EAAM,iBAAiBJ,CAAO,CAChC,EAEA,SAAA5B,EAACH,EAAA,CAAQ,sEAET,EACF,GACF,EAEAQ,EAACH,EAAA,CAAM,MAAM,wBACV,UAAA8B,EAAM,UAAY,CAACA,EAAM,iBACxBhC,EAAC,OAAI,UAAWI,EAAQ,QACtB,SAAAJ,EAACH,EAAA,CAAQ,KAAI,GAAC,0EAEd,EACF,EACE,KAEJG,EAACa,EAAA,CACC,MAAM,SACN,MAAOmB,EAAM,aACb,QAASY,EACT,OAAO,6BACP,SAAUC,GAAU,CAClBb,EAAM,gBAAgBa,CAAM,CAC9B,EAEA,SAAA7C,EAACH,EAAA,CAAQ,+GAGT,EACF,EAEAG,EAACa,EAAA,CACC,MAAM,iBACN,MAAO,OAAOmB,EAAM,aAAa,EACjC,QAASc,EAAiB,IAAIC,IAAM,CAClC,MAAO,OAAOA,EAAE,KAAK,EACrB,MAAOA,EAAE,KACX,EAAE,EACF,OAAO,8BACP,SAAUC,GAAW,CACnBhB,EAAM,iBAAiB,OAAOgB,CAAO,CAAC,CACxC,EAEA,SAAAhD,EAACH,EAAA,CAAQ,2DAET,EACF,EAEAG,EAACa,EAAA,CACC,MAAM,gBACN,MAAOmB,EAAM,aACb,QAASiB,EACT,OAAO,6BACP,SAAUC,GAAU,CAClBlB,EAAM,gBAAgBkB,CAAM,CAC9B,EAEA,SAAAlD,EAACH,EAAA,CAAQ,6CAAiC,EAC5C,EAECmC,EAAM,eAAiB,SAAW,KACjChC,EAACM,EAAA,CACC,MAAM,gBACN,QAAS0B,EAAM,aACf,SAAUmB,GAAU,CAClBnB,EAAM,gBAAgBmB,CAAM,CAC9B,EAEA,SAAAnD,EAACH,EAAA,CAAQ,2DAA+C,EAC1D,GAEJ,GACF,EAEAG,EAACoD,EAAA,CACC,SAAApD,EAACqD,EAAA,CAAO,QAAQ,YAAY,MAAM,UAAU,QAASpB,EAAS,iBAE9D,EACF,GACF,CAEJ,CAAC,EAEMqB,GAAQxB",
6
6
  "names": ["LAYOUT_QUALITIES", "LabelledSelect", "label", "value", "options", "testId", "size", "sx", "disabled", "title", "shown", "onChange", "labelId", "useId", "jsxs", "FormControl", "jsx", "InputLabel", "Select", "picked", "o", "e", "MenuItem", "ListItemText", "useStyles", "makeStyles", "Caption", "warn", "children", "jsx", "Typography", "Group", "title", "classes", "jsxs", "SettingSwitch", "label", "checked", "onChange", "FormControlLabel", "Switch", "e", "SettingSelect", "props", "LabelledSelect", "NODE_LIMITS", "nodeLimitOptions", "current", "a", "b", "limit", "TrackPickSetting", "choices", "stored", "auto", "testId", "t", "trackId", "name", "GraphSettingsDialog", "observer", "model", "onClose", "Dialog", "DialogContent", "NODE_WIDTHS", "width", "EDGE_WIDTHS", "links", "draw", "MAX_PATH_COLORS", "pickGeneTrack", "pickRepeatTrack", "LAYOUT_ENGINES", "engine", "LAYOUT_QUALITIES", "q", "quality", "BUBBLE_SPREADS", "spread", "linear", "DialogActions", "Button", "GraphSettingsDialog_default"]
@@ -1,2 +1,2 @@
1
- import{l as b,m as $,n as S,p as E,q as x,r as T}from"./chunk-HAVM67SF.js";function A(e){let{refName:n,start:t,end:r}=e??{};return typeof n=="string"&&Number.isFinite(t)&&Number.isFinite(r)&&t<r?{refName:n,start:t,end:r}:void 0}function D(e){let n=Number(e);return e!=="auto"&&Number.isFinite(n)?n:"auto"}var w=e=>e.toLocaleString("en-US"),v=({refName:e,start:n,end:t})=>`${e}:${w(n+1)}-${w(t)}`,L=e=>`Forms of ${v(e)}: `;var C={deletion:{svType:"DEL",type:"deletion",alt:"<DEL>"},insertion:{svType:"INS",type:"insertion",alt:"<INS>"},duplication:{svType:"DUP",type:"tandem_duplication",alt:"<DUP:TANDEM>"},replacement:{svType:"CPX",type:"complex_substitution",alt:"<CPX>"},inversion:{svType:"INV",type:"inversion",alt:"<INV>",consequence:"inversion"},shift:{svType:"CPX",type:"complex_structural_alteration",alt:"<CPX>",consequence:"shift"},net:{svType:"CPX",type:"complex_structural_alteration",alt:"<CPX>",consequence:"net"}},_=e=>e.lopsided??(e.delta<0?"deletion":"insertion"),P=e=>C[e.kind].consequence??(_(e)==="deletion"?"loss":"gain"),f=e=>`F${e+1}`,O="other",l=8;function F(e,n){let t=100*e/n;return t>0&&t<1?"<1%":`${Math.round(t)}%`}var d=({forms:e},n)=>e.length>n+1?Math.max(0,n):e.length,m=e=>e.reduce((n,t)=>n+t.members.length,0);function U(e,n=l){let t=d(e,n),r=e.forms.slice(t);return[...e.forms.slice(0,t).map((s,a)=>({name:f(a),label:`${F(s.members.length,e.placed)} \xB7 ${T(s,e)}`,haplotypes:s.members.length,forms:1})),...r.length>0?[{name:O,label:`other forms \xB7 ${F(m(r),e.placed)}`,haplotypes:m(r),forms:r.length}]:[]]}var N=5;function k(e){let n=e.slice(0,N).join(", "),t=e.length-N;return t>0?`${n} and ${t} more`:n}var u=e=>`${e} haplotype${e===1?"":"s"}`;function j(e,n=l){let{abridged:t,unplaced:r,forms:s}=e,a=d(e,n),i=s.slice(a);return[...i.length>0?[`${i.length} smaller forms, ${u(m(i))}, share the empty "other forms" row; maxForms sets how many forms get a row of their own`]:[],...t.length>0?[`${u(t.length)} kept an abridged walk past the forms cut's step budget, which shows as a net change over its span: ${k(t)}`]:[],...r.length>0?[`${u(r.length)} ${r.length===1?"has":"have"} no walk over the pinned window, so no form: ${k(r)}`]:[]]}function V(e,n=l){return Object.fromEntries(e.forms.slice(0,d(e,n)).map((t,r)=>[f(r),"0"]))}function q({copied:e,refStart:n,refEnd:t}){let[r,s]=e??[n,t];return{start:r,end:Math.max(s,r+1)}}var R=(e,n)=>e===n?"1":e===$||e===S?".":"0";function K(e,n=l){let{sites:t,forms:r,placed:s}=e,a=d(e,n);return t.flatMap((i,g)=>i.edge?[]:i.states.flatMap(c=>{if(c.key===b)return[];let h=r.map(o=>x(e,o,g)),y=Object.fromEntries(h.slice(0,a).map((o,p)=>[f(p),R(o,c.key)])),M=m(r.filter((o,p)=>h[p]===c.key));return Object.values(y).includes("1")?c.marks.map((o,p)=>({id:`${g}:${c.key}:${p}`,...q(o),name:E(o),description:`${M} of ${u(s)}`,...C[o.kind],consequence:P(o),mark:o,genotypes:y})):[]}))}export{A as a,D as b,v as c,L as d,l as e,U as f,j as g,V as h,K as i};
2
- //# sourceMappingURL=chunk-TMFUYJFG.js.map
1
+ import{l as b,m as $,n as S,p as E,q as x,r as T}from"./chunk-UMCYJHEB.js";function A(e){let{refName:n,start:t,end:r}=e??{};return typeof n=="string"&&Number.isFinite(t)&&Number.isFinite(r)&&t<r?{refName:n,start:t,end:r}:void 0}function D(e){let n=Number(e);return e!=="auto"&&Number.isFinite(n)?n:"auto"}var w=e=>e.toLocaleString("en-US"),v=({refName:e,start:n,end:t})=>`${e}:${w(n+1)}-${w(t)}`,L=e=>`Forms of ${v(e)}: `;var C={deletion:{svType:"DEL",type:"deletion",alt:"<DEL>"},insertion:{svType:"INS",type:"insertion",alt:"<INS>"},duplication:{svType:"DUP",type:"tandem_duplication",alt:"<DUP:TANDEM>"},replacement:{svType:"CPX",type:"complex_substitution",alt:"<CPX>"},inversion:{svType:"INV",type:"inversion",alt:"<INV>",consequence:"inversion"},shift:{svType:"CPX",type:"complex_structural_alteration",alt:"<CPX>",consequence:"shift"},net:{svType:"CPX",type:"complex_structural_alteration",alt:"<CPX>",consequence:"net"}},_=e=>e.lopsided??(e.delta<0?"deletion":"insertion"),P=e=>C[e.kind].consequence??(_(e)==="deletion"?"loss":"gain"),f=e=>`F${e+1}`,O="other",l=8;function F(e,n){let t=100*e/n;return t>0&&t<1?"<1%":`${Math.round(t)}%`}var d=({forms:e},n)=>e.length>n+1?Math.max(0,n):e.length,m=e=>e.reduce((n,t)=>n+t.members.length,0);function U(e,n=l){let t=d(e,n),r=e.forms.slice(t);return[...e.forms.slice(0,t).map((s,a)=>({name:f(a),label:`${F(s.members.length,e.placed)} \xB7 ${T(s,e)}`,haplotypes:s.members.length,forms:1})),...r.length>0?[{name:O,label:`other forms \xB7 ${F(m(r),e.placed)}`,haplotypes:m(r),forms:r.length}]:[]]}var N=5;function k(e){let n=e.slice(0,N).join(", "),t=e.length-N;return t>0?`${n} and ${t} more`:n}var u=e=>`${e} haplotype${e===1?"":"s"}`;function j(e,n=l){let{abridged:t,unplaced:r,forms:s}=e,a=d(e,n),i=s.slice(a);return[...i.length>0?[`${i.length} smaller forms, ${u(m(i))}, share the empty "other forms" row; maxForms sets how many forms get a row of their own`]:[],...t.length>0?[`${u(t.length)} kept an abridged walk past the forms cut's step budget, which shows as a net change over its span: ${k(t)}`]:[],...r.length>0?[`${u(r.length)} ${r.length===1?"has":"have"} no walk over the pinned window, so no form: ${k(r)}`]:[]]}function V(e,n=l){return Object.fromEntries(e.forms.slice(0,d(e,n)).map((t,r)=>[f(r),"0"]))}function q({copied:e,refStart:n,refEnd:t}){let[r,s]=e??[n,t];return{start:r,end:Math.max(s,r+1)}}var R=(e,n)=>e===n?"1":e===$||e===S?".":"0";function K(e,n=l){let{sites:t,forms:r,placed:s}=e,a=d(e,n);return t.flatMap((i,g)=>i.edge?[]:i.states.flatMap(c=>{if(c.key===b)return[];let h=r.map(o=>x(e,o,g)),y=Object.fromEntries(h.slice(0,a).map((o,p)=>[f(p),R(o,c.key)])),M=m(r.filter((o,p)=>h[p]===c.key));return Object.values(y).includes("1")?c.marks.map((o,p)=>({id:`${g}:${c.key}:${p}`,...q(o),name:E(o),description:`${M} of ${u(s)}`,...C[o.kind],consequence:P(o),mark:o,genotypes:y})):[]}))}export{A as a,D as b,v as c,L as d,l as e,U as f,j as g,V as h,K as i};
2
+ //# sourceMappingURL=chunk-4CP5H6LQ.js.map
@@ -0,0 +1,3 @@
1
+ import{A as Cn,B as Ln,a as Re,g as V,h as rt,j as K,k as st,l as Nn,m as Pn,n as In,o as $n,p as Ae,r as Ne,s as it,u as at,v as ct,z as lt}from"./chunk-NLMAQYCK.js";import{a as gn,c as bn,e as Oe,f as ot,g as _n,i as On,j as An}from"./chunk-YVRZM7FP.js";import{B as et,C as tt,D as ie,E as I,F as nt,M as Rn,N as Tn,a as Te,c as xn,f as yn,g as j,h as wn,i as ze,j as _e,l as Ze,m as Mn,n as pe,o as vn,q as Sn,r as Je,s as En,t as kn,z as Qe}from"./chunk-BI2RYKPA.js";import{e as Bn}from"./chunk-JBQSIRNH.js";import{g as dn,j as mn}from"./chunk-B6YUND32.js";import{c as F,d as se,e as an,g as cn,j as Ue,k as Ee,l as pn,m as hn}from"./chunk-QCEM5AXZ.js";import{a as re,c as on,d as J,e as He,f as rn,g as N,q as ln,r as P,s as je,v as Ve,x as Ke}from"./chunk-ELO4G2TG.js";import{d as Se,e as sn,f as ue}from"./chunk-CCPRHM4X.js";import{a as fn,b as un}from"./chunk-6VNDP3UB.js";import{f as E}from"./chunk-3WG3GF2A.js";import{c as ke}from"./chunk-NIEZKWQV.js";var Pe=8,dt=34,Ie=12,rs=60;function ss({count:e,bounds:t,pixelRows:n,width:o,room:r,columns:s}){function i(l){let c=Math.ceil(e/l),f=Math.floor((o-(l-1)*Pe)/l),u=(r-c*dt-(c-1)*Pe)/c,d=(f-2*Ie)/t.w,p=t.h>0?(u-2*Ie)/t.h:1/0,m=n?d:Math.min(d,p),h=n?t.h:t.h*m,b=Math.floor(Math.max(rs,Math.min(h+2*Ie,u)));return{columns:l,width:f,height:b,scale:m,total:c*(b+dt)+(c-1)*Pe}}if(s!==void 0)return i(Math.max(1,Math.min(e,Math.round(s))));let a=i(1);if(n)return a;for(let l=2;l<=e;l++){let c=i(l);c.scale>a.scale&&(a=c)}return a}var is=[{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 as(e){let t=typeof e=="string"?{field:e}:e??{};return{field:t.field==="walk"||t.field==="sample"?t.field:"",sort:[...t.sort??t.domain??[]],...t.columns===void 0?{}:{columns:t.columns}}}function Xn(e,t){let n=new Map(t.map((r,s)=>[r,s])),o=r=>n.get(r)??t.length;return e.map((r,s)=>({name:r,i:s})).sort((r,s)=>o(r.name)-o(s.name)||r.i-s.i).map(({name:r})=>r)}function cs(e,t,n=[]){let o=Xn(e,n),r={columns:void 0,count:e.length,cells:e.map(c=>o.indexOf(c))};if(t==="walk")return r;let s=e.map(c=>{let f=sn(c);return f&&Number.isInteger(f.haplotype)&&f.haplotype>=0?{sample:f.sample,column:Math.max(0,f.haplotype-1)}:void 0}),i=Xn([...new Set(s.flatMap(c=>c?[c.sample]:[]))],n),a=Math.max(1,...s.map(c=>c?c.column+1:1)),l=s.map(c=>c?i.indexOf(c.sample)*a+c.column:-1);return l.includes(-1)||new Set(l).size<l.length?r:{columns:a,count:i.length*a,cells:l}}var ls=Math.PI/24;function Dn(e,t){let n=e[t-1],o=e[t],r=e[t+1];if(!n||!r)return 0;let s=Math.abs(Math.atan2(r.y-o.y,r.x-o.x)-Math.atan2(o.y-n.y,o.x-n.x));return s>Math.PI?2*Math.PI-s:s}function ds(e,t,n,o,r){let s=(m,h)=>Math.max(Math.hypot(h.x-m.x,h.y-m.y)**.5,1e-9),i=s(e,t),a=i+s(t,n),l=a+s(n,o),c=i+r*(a-i),f=(m,h,b,g)=>{let y=(c-b)/(g-b);return{x:m.x+(h.x-m.x)*y,y:m.y+(h.y-m.y)*y}},u=f(e,t,0,i),d=f(t,n,i,a),p=f(n,o,a,l);return f(f(u,d,0,a),f(d,p,i,l),i,a)}var Fn=(e,t)=>({x:2*t.x-e.x,y:2*t.y-e.y});function qn(e){if(e.length<3)return e;let t=[e[0]];for(let n=0;n+1<e.length;n++){let o=e[n],r=e[n+1],s=Math.ceil(Math.max(Dn(e,n),Dn(e,n+1))/ls),i=e[n-1]??Fn(r,o),a=e[n+2]??Fn(o,r);for(let l=1;l<s;l++)t.push(ds(i,o,r,a,l/s));t.push(r)}return t}function Gn(e,t){let o=e.nodes.filter(N).filter(b=>(t[b.id]?.length??0)>0).flatMap(b=>{let g=t[b.id],y=g.length-1,M=j(b.id)===(b.stable.strand??"+");return g.map((x,w)=>{let v=y===0?.5:w/y;return{x:x.x,y:x.y,r:b.stable.start+b.length*(M?v:1-v),w:b.length/g.length}})}),r=o.reduce((b,g)=>b+g.w,0);if(r===0)return t;let s=o.reduce((b,g)=>b+g.x*g.w,0)/r,i=o.reduce((b,g)=>b+g.y*g.w,0)/r,a=o.reduce((b,g)=>b+g.r*g.w,0)/r,l=0,c=0;for(let b of o)l+=b.w*(b.x-s)*(b.r-a),c+=b.w*(b.y-i)*(b.r-a);if(l===0&&c===0)return t;let f=-Math.atan2(c,l),u=Math.cos(f),d=Math.sin(f),p={};for(let[b,g]of Object.entries(t))p[b]=g.map(y=>{let M=y.x-s,x=y.y-i;return{x:s+u*M-d*x,y:i+d*M+u*x}});let m=0,h=0;for(let b of e.nodes)if(!N(b))for(let g of p[b.id]??[])g.y>i?m++:h++;if(h>m)for(let b of Object.values(p))for(let g of b)g.y=2*i-g.y;return p}var Wn=30;function fs(e,t){let{opts:n}=t,o=new Map(t.nodes.map(d=>[d.id,Oe(n,d.length)])),r=d=>o.get(d)??n.minimumNodeLength,s=e.nodes.filter(N).sort((d,p)=>d.stable.start-p.stable.start),i=new Map,a=0;for(let d of s)i.set(d.id,{x:a,y:0}),a+=r(d.id)+n.edgeLength;let l=Re(e),c=new Map(s.map(d=>[d.id,0])),f=s.map(d=>d.id);for(let d of f){let p=i.get(d),m=c.get(d)+1;for(let h of l.get(d)??[])c.has(h)||(c.set(h,m),i.set(h,{x:p.x+r(d)/2,y:Wn*m}),f.push(h))}let u=0;for(let d of e.nodes)i.has(d.id)||i.set(d.id,{x:u++*a/e.nodes.length,y:Wn*3});return i}function Yn(e,t){let n=fs(e,t);return t.nodes.map(o=>({...o,...n.get(o.id)}))}var us=.5;function Hn(e,t,n=new Set){let o=new Map(t.map(s=>[s.edgeIndex,`${gn}${s.edgeIndex}`])),r=[];return e.edges.forEach((s,i)=>{let a=o.get(i);if(!n.has(i))if(a===void 0)r.push(s);else{let{fromStrand:l,toStrand:c}=s;r.push({from:s.from,to:a,...l?{fromStrand:l}:{}},{from:a,to:s.to,...c?{toStrand:c}:{}})}}),{graph:{...e,nodes:[...e.nodes,...[...o.values()].map(s=>({id:s,name:s,length:0,depth:0}))],edges:r},routes:o,ids:new Set(o.values())}}function Un(e,t,n,o,r){let s=new Map(e.nodes.map(i=>[i.id,i.length]));return t.map(i=>{let a=i.bypassed.reduce((f,u)=>f+(s.get(u)??0),0),l=Math.max(r.minimumNodeLength,o(a)*us),c=n.get(i.edgeIndex);return{id:c,name:c,length:Math.round(l*1e6/r.nodeLengthPerMegabase),depth:0}})}function jn(e,t){let n={...e},o={};for(let[r,s]of t){let i=n[s];delete n[s],i?.length&&(o[r]=i)}return{nodePositions:n,deletionRoutes:o}}function ps(e,t){let n=e.indexOf(":"),o=e.indexOf(":",n+1);if(n!==-1&&o!==-1){let r=e.slice(0,n),s=e.slice(n+1,o),i=e.slice(o+1);s==="i"||s==="f"?t[r]=+i:s==="Z"&&(t[r]=i)}}function he(e){let t={};for(let n of e)ps(n,t);return t}function Kn(e){let{SN:t,SO:n,SR:o}=e.tags;return typeof t=="string"&&typeof n=="number"&&typeof o=="number"?{refName:t,start:n,rank:o}:void 0}var Vn=62,hs=60;function ms(e){let t=[],n="+",o=0;function r(s){s>o&&t.push({id:e.slice(o,s),strand:n})}for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);(i===Vn||i===hs)&&(r(s),n=i===Vn?"+":"-",o=s+1)}return r(e.length),t}function zn(e){let t={nodes:[],links:[],paths:[],walks:[],header:[],id:""};for(let n of e.split(`
2
+ `)){let o=n.endsWith("\r")?n.slice(0,-1):n,r=o.indexOf(" "),s=r===-1?o:o.slice(0,r);if(s==="H"){let[,...i]=o.split(" ");t.header.push(he(i))}else if(s==="S"){let[,i,...a]=o.split(" "),l,c,f,u=!1,d=a[0]??"*";/^\d+$/.test(d)?(l=+d,c=a[1]??"*",f=a.slice(2)):(u=!0,c=d,l=c==="*"?0:c.length,f=a.slice(1));let p=he(f);u&&"LN"in p&&(l=+p.LN),t.nodes.push({id:i,length:l,sequence:c,tags:p})}else if(s==="E"){let[,,i,a,,,,,l,...c]=o.split(" ");i&&a&&t.links.push({source:i.slice(0,-1),target:a.slice(0,-1),strand1:i.at(-1),strand2:a.at(-1),cigar:l??"*",tags:he(c)})}else if(s==="L"){let[,i,a,l,c,f,...u]=o.split(" ");i&&l&&c&&t.links.push({source:i,target:l,strand1:a,strand2:c,cigar:f??"*",tags:he(u)})}else if(s==="W"){let[,i,a,l,c,f,u,...d]=o.split(" ");i&&a&&l&&c&&f&&u&&t.walks.push({sample:i,haplotype:+a,contig:l,start:c==="*"?-1:+c,end:f==="*"?-1:+f,segments:ms(u),tags:he(d)})}else if(s==="P"){let[,i,a,...l]=o.split(" ");i&&a&&t.paths.push({name:i,path:a,rest:l})}}return t}function gs(e,t){let n=new Map,o=new Map;function r(i,a){n.has(i)||n.set(i,a)}function s(i,a){let l=o.get(i);l===void 0&&r(i,a),o.set(i,(l??0)+1)}for(let i of e.links)r(i.source,i.strand1==="-"?"-":"+"),r(i.target,i.strand2==="-"?"-":"+");for(let{steps:i}of t)for(let a of i)s(a.id,a.strand);for(let i of e.walks)for(let a of i.segments)s(a.id,a.strand);return{canonical:n,traversals:o}}var Zn=e=>e.start===-1?0:e.start;function bs(e){return{...P(e.name),steps:e.path.split(",").map(t=>({id:t.slice(0,-1),strand:t.endsWith("-")?"-":"+"}))}}function xs(e,t){return[...t,...e.walks.map(n=>({name:`${n.sample}#${n.haplotype}#${n.contig}`,start:Zn(n),steps:n.segments}))]}function ys(e){let t=e.tags.SM;if(typeof t!="string")return;let n=t.split(",").map(o=>o.trim()).filter(Boolean);return n.length>0?n:void 0}var me=e=>typeof e=="number"&&e>0?e:void 0;function ws({tags:e,length:t}){let n=me(e.RC)??me(e.FC)??me(e.KC);return me(e.dp)??me(e.DP)??(n!==void 0&&t>0?n/t:void 0)}function Ms(e,t,n){let o=e.tags.AF;return{id:`${e.id}${t}`,name:e.id,length:e.length,depth:n,...typeof o=="number"&&o>=0?{frequency:o}:{},stable:Kn(e),samples:ys(e),...e.tags.mv===1?{moved:!0}:{}}}function Jn(e,t="Imported GFA"){let n=[],o=[],r=e.paths.map(bs),{canonical:s,traversals:i}=gs(e,r),a=new Map,l=g=>{let y=a.get(g);return y===void 0&&(y=`${g}${s.get(g)??"+"}`,a.set(g,y)),y},c=new Map;for(let g of e.nodes){if(c.has(g.id))continue;c.set(g.id,g.length);let y=ws(g)??Math.max(i.get(g.id)??1,1);n.push(Ms(g,s.get(g.id)??"+",y))}for(let g of e.links)o.push({from:l(g.source),to:l(g.target),fromStrand:g.strand1==="-"?"-":"+",toStrand:g.strand2==="-"?"-":"+"});let f=[],u=new Map,d=(g,y)=>u.get(g)?.get(y);function p(g,y,M){let x=u.get(g);x||(x=new Map,u.set(g,x)),x.set(y,M)}let m=o.map(g=>{let y=d(g.from,g.to);return y||(y=new Set,p(g.from,g.to,y),p(g.to,g.from,y)),y});function h(g,y){for(let M=0;M<g.length-1;M++)d(g[M],g[M+1])?.add(y)}e.paths.forEach(({name:g},y)=>{let{start:M,steps:x}=r[y],w=x.map(v=>l(v.id));f.push({name:g,nodeIds:w,start:M}),h(w,g)});for(let g of e.walks){let y=g.segments.map(x=>l(x.id)),M=`${g.sample}#${g.haplotype}#${g.contig}`;f.push({name:M,nodeIds:y,start:Zn(g),sample:g.sample,haplotype:g.haplotype,contig:g.contig,...cn(g.tags)}),h(y,M)}o.forEach((g,y)=>{let M=m[y];M.size>0&&(g.pathIds=[...M])});let b=e.paths.length>0||e.walks.length>0?je(xs(e,r),g=>c.get(g)??0):void 0;return{name:t,nodes:n,edges:o,paths:f.length>0?f:void 0,anchorPaths:b?.anchorPaths,pathVisits:b?.pathVisits,anchoredBy:n.some(g=>g.stable)?"tags":void 0}}function Qn(e){let t=e.paths??[],n=new Set,o=new Set;if(t.some(r=>r.abridged)){for(let{from:r,to:s}of e.edges)n.add(r),n.add(s);for(let r of t)if(r.abridged)for(let s of r.nodeIds)n.has(s)||o.add(s)}if(o.size>0){for(let r of t)if(!r.abridged)for(let s of r.nodeIds)o.delete(s)}return o.size===0?e:{...e,nodes:e.nodes.filter(r=>!o.has(r.id))}}function vs(e,t){if(typeof e!="string")return Ue(e,t);let n=dn(e);return n?Ue(n,t):Jn(zn(e),t)}function fd(e,t,n={}){let o=vs(e,t);if(o.nodes.length===0)throw new Error(`No graph segments in ${t}`);if(n.maxNodes!==void 0&&o.nodes.length>n.maxNodes)throw new Error(`Graph too large to draw: ${o.nodes.length.toLocaleString()} nodes (limit ${n.maxNodes.toLocaleString()}). Zoom in to a smaller region, or raise maxGraphNodes on this view.`);return Ve(o,n.referencePath)}var Q={engine:"fmmm",quality:2,linearLayout:!1,bubbleSpread:"auto",spacing:1,componentSeparation:1,showDeletionEdges:!0};function eo(e={}){return{engine:e.engine??Q.engine,quality:e.quality??Q.quality,linearLayout:e.linearLayout??Q.linearLayout,bubbleSpread:e.bubbleSpread??Q.bubbleSpread,spacing:e.spacing??Q.spacing,componentSeparation:e.componentSeparation??Q.componentSeparation,showDeletionEdges:e.showDeletionEdges??Q.showDeletionEdges}}var Ss=15;function Es(e,t,n){let o=e.nodes.some(N),r=eo(n),s={...t,opts:{...t.opts,edgeLength:t.opts.edgeLength*r.spacing}};return{graph:{nodes:o?Yn(e,s):s.nodes,edges:e.edges},options:{quality:r.quality,linearLayout:r.linearLayout,...s.opts,componentSeparation:Ss*r.componentSeparation,...o?{rotateComponents:!1}:{},engine:r.engine}}}function ft(e,t){let n=e.nodes.some(N);return[...Object.values(eo(t)),n,e.referencePath??""].join("|")}async function to(e,t,n){let o=Qn(e),r=An(t.bubbleSpread),{shown:s,hidden:i}=et(o,Qe(o),t.showDeletionEdges!==!1),a=Hn(o,s,i),l=En(a.graph,a.ids),c={...l.graph,nodes:l.graph.nodes.filter(M=>!a.ids.has(M.id))},f=ot(c,r),{result:u,duration:d}=await n(Es(l.graph,{...f,nodes:[...f.nodes,...Un(o,s,a.routes,_n(c,r),f.opts)]},t)),p=ot(o,r),m=new Map(p.nodes.map(M=>[M.id,Oe(p.opts,M.length)])),h=Object.fromEntries(Object.entries(u.nodePositions).map(([M,x])=>[M,qn(x)])),b=kn(h,l.runs,M=>m.get(M)??0),{nodePositions:g,deletionRoutes:y}=jn(o.nodes.some(N)?Gn(o,b):b,a.routes);return{result:{...u,nodePositions:g,stranded:!0,...s.length?{deletionRoutes:y,extent:no(y)}:{}},duration:d}}function no(e){let t=1/0,n=1/0,o=-1/0,r=-1/0;for(let s of Object.values(e))for(let i of s)t=Math.min(t,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x),r=Math.max(r,i.y);return{minX:t,minY:n,maxX:o,maxY:r}}var ge=40,ks=1e-6,Rs=100;function ut(e){return Math.max(ks,Math.min(Rs,e))}function Ts(e,t,n,o=ge){let r=t-e.h*n;return o-e.minY*n+Math.max(0,r)/2}function ud(e,t,n,o,{minScale:r=0,padLeft:s=ge,padTop:i=ge,padRight:a=ge,padBottom:l=ge}={}){let c=t-s-a,f=n-i-l;if(c<=0||f<=0||!(e.w>0||!o&&e.h>0))return;let u=e.w>0?c/e.w:1/0,d=e.h>0?f/e.h:1/0,p=ut(Math.max(r,o?u:Math.min(u,d))),m=c-e.w*p;return{scale:p,translateX:s-e.minX*p+Math.max(0,m)/2,translateY:Ts(e,f,o?1:p,i)}}function pd(e,t={}){let{minX:n,minY:o,maxX:r,maxY:s}=no(e.nodePositions),{region:i}=t;e.referenceAxis&&i&&i.end>i.start&&(n=i.start,r=i.end);let a=t.extent??e.extent;return a&&(n=Math.min(n,a.minX??n),o=Math.min(o,a.minY??o),r=Math.max(r,a.maxX??r),s=Math.max(s,a.maxY??s)),{minX:n,minY:o,w:r-n,h:s-o}}var _s=4;function pt(e=_s){let t=new WeakMap,n=o=>{let r=t.get(o);return r||(r=new Map,t.set(o,r)),r};return{layout(o,r,s){let i=n(o),a=ft(o,r),l=i.get(a);if(l)return l.run;i.size>=e&&i.delete(i.keys().next().value);let c=performance.now(),f={run:to(o,r,s).then(u=>(f.done=u.result,{...u,duration:u.duration||performance.now()-c}))};return f.run.catch(()=>{i.get(a)===f&&i.delete(a)}),i.set(a,f),f.run},ready(o,r){return t.get(o)?.get(ft(o,r))?.done},inherit(o,r){let s=t.get(o);s&&o!==r&&t.set(r,s)}}}function Os(e,t){return{scaleX:e,scaleY:t?1:e,pixelRows:t}}function ht(e,t,n,o){return{minX:-e.translateX/t.scaleX,minY:-e.translateY/t.scaleY,maxX:(n-e.translateX)/t.scaleX,maxY:(o-e.translateY)/t.scaleY}}function As(e,t){let n=(e.maxX-e.minX)*t,o=(e.maxY-e.minY)*t;return{minX:e.minX-n,minY:e.minY-o,maxX:e.maxX+n,maxY:e.maxY+o}}function Ns(e,t){return t.minX>=e.minX&&t.maxX<=e.maxX&&t.minY>=e.minY&&t.maxY<=e.maxY}function Ps(e,t,n,o,r){let s=ut(e.scale*t),i=s/e.scale;return{scale:s,translateX:n-(n-e.translateX)*i,translateY:r?e.translateY:o-(o-e.translateY)*i}}function Is(e,t,n,o){return{x:(e-n.translateX)/o.scaleX,y:(t-n.translateY)/o.scaleY}}var ee=JBrowseExports["@jbrowse/render-core/RenderLifecycleMixin"],$s=e=>ee!=null&&e in Object(ee)?ee[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/render-core/RenderLifecycleMixin' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),oo=$s("RenderLifecycleMixin"),wf=ee&&ee.__esModule?ee.default:ee;function ro(e){return t=>e.includes(t)?t:void 0}function Sf(e){return E.snapshotProcessor(E.maybe(E.enumeration(e)),{preProcessor:ro(e)})}function $e(e,t){return E.snapshotProcessor(E.optional(E.enumeration(e),t),{preProcessor:ro(e)})}var $f=600,Cf=160,Lf=[1,1,1,1],Bf="rgb(255, 255, 255)",Xf=5,Df=new Set(["tubemap","tubemapref"]),Ff=ke(()=>import("./ChooseSamplesDialog-LO7FKFSS.js")),qf=ke(()=>import("./ChooseWalksDialog-JJSOVCEU.js")),Gf=ke(()=>import("./HighlightColorDialog-4VGVC7SN.js")),Wf=12,Yf=[{bp:0,label:"None"},{bp:3,label:"Under 3 bp"},{bp:10,label:"Under 10 bp"},{bp:50,label:"Under 50 bp, leaving structural variants"},{bp:1e3,label:"Under 1 kb"}];function Hf(e){if(typeof e.uri=="string")return e.uri;for(let[t,n]of[["segmentsLocation",fn],["graphLocation",un]]){let o=e[t]?.uri;if(typeof o=="string"&&o.endsWith(n))return o.slice(0,-n.length)}}var Uf=1.15,jf=1.6,Vf=150,Kf=1,zf=40,Zf=40,Jf=[{value:"each",label:"A tube per haplotype"},{value:"grouped",label:"A tube per haplotype, grouped by route"},{value:"bundled",label:"A tube per route"}],Cs={nodeStrokes:[],nodeStrokeRuns:new Map,arrows:[],arrowRuns:new Map,edgeCurves:[],edgeCurveRuns:new Map};function Qf(...e){}var Ls=5e6;function eu(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:`${Math.round(e/1e3)} kb`}var Bs=2e4;function tu(e){return("uri"in e?e.uri.split(/[?#]/)[0]:"localPath"in e?e.localPath:"name"in e?e.name:"").split(/[\\/]/).at(-1)??""}function nu(e){return e.builtViewport!==void 0&&e.paintedViewport===e.builtViewport&&e.builtViewport.viewportDirty===e.viewportDirty&&!e.viewportRebuildPending}function ou(e){let{width:t,height:n}=e.viewBox;return ht(e,e.axisScale,t,n)}var ru=pt(),su=E.compose("GraphPane",oo(),E.model({layoutQuality:E.optional(E.number,2),layoutEngine:$e(bn,"fmmm"),linearLayout:E.optional(E.boolean,!1),bubbleSpread:$e(On,"auto"),tubeMapFold:E.optional(E.number,0),tubeMapRoutes:$e(["each","grouped","bundled"],"each"),tubeMapColorBy:E.optional(E.string,""),geneTrackId:E.optional(E.string,""),repeatTrackId:E.optional(E.string,""),repeatKey:E.optional(E.string,""),walkLayers:E.optional(E.frozen(),[]),referencePath:E.optional(E.string,""),showPerf:E.optional(E.boolean,!1),connectorThickness:E.optional(E.number,2),scale:E.optional(E.number,1),translateX:E.optional(E.number,0),translateY:E.optional(E.number,0),paneHeight:E.maybe(E.number),maxGraphNodes:E.optional(E.number,Bs),connectedViewId:E.maybe(E.string),maxRegionBp:E.optional(E.number,Ls),subgraphContext:E.optional(E.number,1),subgraphHaplotypes:E.maybe(E.frozen()),expandedWalks:E.optional(E.frozen(),[])})).volatile(()=>({graph:void 0,walkCut:void 0,graphRegion:void 0,loadedReferencePath:void 0,layoutResult:void 0,drawnLayoutMode:void 0,legendSize:{width:0,height:0},indexBubbles:void 0,foldedBelowBp:void 0,geneTrackFeatures:void 0,walkGeneFeatures:void 0,ownGeneFeatures:void 0,walkRowSampleTable:void 0,repeatArrays:void 0,handledLayoutMode:void 0,openBubbles:[],error:void 0,isLoading:!1,loadCanceled:!1,statusMessage:"",hoveredNode:null,hoveredAt:null,hoveredTube:null,hoveredPanel:null,hoveredRowWalks:[],hoveredBubble:null,pointerInPane:!1,stripHover:null,hoveredWalkRow:null,hoveredEdge:null,selectedNode:null,viewportDirty:0,positionsVersion:0,morphEntering:void 0,drawnBatch:Cs,builtViewport:void 0,paintedViewport:void 0,draggingNode:null,isPanning:!1,viewportOwner:"fit",viewportDirtyTimer:void 0,positionsDirtyFrame:0,lastFetchMs:void 0,readsShown:void 0,lastLayoutMs:void 0,lastGeometryMs:void 0,lastGeometryStrokeCount:void 0,viewportRebuildPending:!1}));var C=e=>+e.toFixed(1),Xs=e=>+e.toFixed(3);function Ds(e){let t=/^rgba?\(([^,]+),([^,]+),([^,)]+)(?:,([^)]+))?\)$/.exec(e.replaceAll(" ",""));if(!t)return{color:e,opacity:1};let n=t[4]===void 0?1:Number(t[4]);return{color:`rgb(${t[1]},${t[2]},${t[3]})`,opacity:n}}function mt(e,t){let{color:n,opacity:o}=Ds(t);return`${e}="${n}"${o<1?` ${e}-opacity="${Xs(o)}"`:""}`}var so=.5,io=.25;function au(e,t){let n=[],o=[],r=(c,f)=>{let u={d:`M${C(c)} ${C(f)}`,segments:0,x0:c,x1:c,y0:f,y1:f};return o.push(u),u},s=c=>{let f=o.at(-1)??r(c[0],c[1]);for(let u=0;u<c.length;u+=2)f.x0=Math.min(f.x0,c[u]),f.x1=Math.max(f.x1,c[u]),f.y0=Math.min(f.y0,c[u+1]),f.y1=Math.max(f.y1,c[u+1]);return f.segments++,f},i=c=>{let f=new Set;return o.map(u=>{if(!c||u.x1-u.x0>=so||u.y1-u.y0>=so)return u.d;let d=(u.x0+u.x1)/2,p=(u.y0+u.y1)/2,m=`${Math.round(d/io)} ${Math.round(p/io)}`;return u.segments===0||f.has(m)?"":(f.add(m),`M${C(d)} ${C(p)}h0`)}).join("")},a={canvas:void 0,fillStyle:"#000",strokeStyle:"#000",lineWidth:1,lineCap:"butt",lineJoin:"miter",beginPath(){o=[]},moveTo(c,f){r(c,f)},lineTo(c,f){s([c,f]).d+=`L${C(c)} ${C(f)}`},bezierCurveTo(c,f,u,d,p,m){s([c,f,u,d,p,m]).d+=`C${C(c)} ${C(f)} ${C(u)} ${C(d)} ${C(p)} ${C(m)}`},closePath(){let c=o.at(-1);c&&(c.d+="Z")},stroke(){let c=i(a.lineCap!=="butt");c&&n.push(`<path d="${c}" fill="none" ${mt("stroke",a.strokeStyle)} stroke-width="${C(a.lineWidth)}" stroke-linecap="${a.lineCap}" stroke-linejoin="${a.lineJoin}"/>`)},fill(){let c=i(!1);c&&n.push(`<path d="${c}" ${mt("fill",a.fillStyle)}/>`)},clearRect(){n.length=0},fillRect(c,f,u,d){n.push(`<rect x="${C(c)}" y="${C(f)}" width="${C(u)}" height="${C(d)}" ${mt("fill",a.fillStyle)}/>`)}},l={width:e,height:t,style:{},getContext:()=>a};return a.canvas=l,{canvas:l,markup:()=>n.join("")}}var ao=2,co=8192;function ae(e=0,t=0){let n=typeof devicePixelRatio>"u"?1:Math.min(devicePixelRatio,ao);return Math.min(n,co/Math.max(e,t,1))}function gt(e,t,n){let o=ae(t,n),r=Math.round(t*o),s=Math.round(n*o);(e.width!==r||e.height!==s)&&(e.width=r,e.height=s);let i=`${t}px`,a=`${n}px`;return e.style.width!==i&&(e.style.width=i),e.style.height!==a&&(e.style.height=a),o}var uu=class{constructor(e){this.transform=null,this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.highlightFactor=1,this.fit=1,this.painted=null;let t=e.getContext("2d");if(!t)throw new Error("Canvas 2D context not available");this.canvas=e,this.ctx=t}setErrorHandler(e){}releaseOffscreenTargets(){}resize(e,t){this.fit=gt(this.canvas,e,t)/ae()}uploadGeometry(e){this.batch=e,this.highlightedEdge=null,this.painted=null}setNodeHighlights(e){this.nodeHighlights=e,this.painted=null}setEdgeHighlight(e,t){this.highlightedEdge=e,this.highlightFactor=t,this.painted=null}updateTransform(e){this.transform=e}fitted(){let e=this.transform,t=this.fit;return!e||t===1?e:{...e,scaleX:e.scaleX*t,scaleY:e.scaleY*t,translateX:e.translateX*t,translateY:e.translateY*t,dpr:e.dpr*t}}render(e){let t=this.fitted();if(!t)return;let n=this.ctx,{width:o,height:r}=n.canvas;e[3]<1&&n.clearRect(0,0,o,r),e[3]>0&&(n.fillStyle=rt([e[0],e[1],e[2]],e[3]),n.fillRect(0,0,o,r));let s=this.batch;if(!s)return;n.lineCap="round",n.lineJoin="round";let{edges:i,nodes:a,arrows:l}=this.paintedGroups(s);for(let{color:c,items:f}of i)this.strokeCurves(f,c,t);for(let{color:c,items:f}of a)this.strokeNodes(f,c,t);for(let{color:c,items:f}of l)this.fillArrows(f,c,t)}paintedGroups(e){if(this.painted)return this.painted;let t=this.highlightFactor,n=this.edgeRun(e.edgeCurveRuns),o=this.edgeRun(e.arrowRuns),r=this.liftedStrokes(e);return this.painted={edges:ce(e.edgeCurves,(s,i)=>({color:Ce(n,i)?K(s.color,t):s.color,weight:s.thickness,last:Ce(n,i)})),nodes:ce(e.nodeStrokes,(s,i)=>{let a=r.get(i);return{color:a===void 0?s.color:K(s.color,a),weight:s.thickness,last:a!==void 0}}),arrows:ce(e.arrows,(s,i)=>({color:Ce(o,i)?K(s.color,t):s.color,weight:0,last:Ce(o,i)}))}}renderHighlights(){let e=this.ctx;e.clearRect(0,0,e.canvas.width,e.canvas.height);let t=this.batch,n=this.fitted();if(!n||!t)return;e.lineCap="round",e.lineJoin="round";let o=this.highlightFactor,r=lo(t.edgeCurves,this.edgeRun(t.edgeCurveRuns));for(let{color:a,items:l}of ce(r,c=>({color:K(c.color,o),weight:c.thickness,last:!1})))this.strokeCurves(l,a,n);let s=[...this.liftedStrokes(t)];for(let{color:a,items:l}of ce(s,([c,f])=>({color:K(t.nodeStrokes[c].color,f),weight:t.nodeStrokes[c].thickness,last:!1})))this.strokeNodes(l.map(([c])=>t.nodeStrokes[c]),a,n);let i=lo(t.arrows,this.edgeRun(t.arrowRuns));for(let{color:a,items:l}of ce(i,c=>({color:K(c.color,o),weight:0,last:!1})))this.fillArrows(l,a,n)}edgeRun(e){return this.highlightedEdge===null?void 0:e.get(this.highlightedEdge)}liftedStrokes(e){let t=new Map;for(let[n,o]of this.nodeHighlights){let r=e.nodeStrokeRuns.get(n);if(r)for(let s=r.start;s<r.start+r.count;s++)t.set(s,o)}return t}strokeCurves(e,t,n){let o=this.ctx;o.strokeStyle=V(t),o.lineWidth=e[0].thickness*2*n.dpr,o.beginPath();for(let r of e){let s=r.curves[0];o.moveTo(s.x0*n.scaleX+n.translateX,s.y0*n.scaleY+n.translateY);for(let i of r.curves)o.bezierCurveTo(i.cx0*n.scaleX+n.translateX,i.cy0*n.scaleY+n.translateY,i.cx1*n.scaleX+n.translateX,i.cy1*n.scaleY+n.translateY,i.x1*n.scaleX+n.translateX,i.y1*n.scaleY+n.translateY)}o.stroke()}strokeNodes(e,t,n){let o=this.ctx;o.strokeStyle=V(t),o.lineWidth=e[0].thickness*2*n.dpr,o.beginPath();for(let r of e){let s=r.points[0];o.moveTo(s.x*n.scaleX+n.translateX,s.y*n.scaleY+n.translateY);for(let i=1,a=r.points.length;i<a;i++){let l=r.points[i];o.lineTo(l.x*n.scaleX+n.translateX,l.y*n.scaleY+n.translateY)}}o.stroke()}fillArrows(e,t,n){let o=this.ctx;o.fillStyle=V(t),o.beginPath();for(let r of e){let[s,i,a,l]=qs(r,n);o.moveTo(s.x,s.y),o.lineTo(i.x,i.y),o.lineTo(a.x,a.y),o.lineTo(l.x,l.y),o.closePath()}o.fill()}dispose(){this.batch=null,this.nodeHighlights=new Map,this.highlightedEdge=null,this.painted=null}},Fs=.25;function qs(e,t){let n=Math.cos(e.angle),o=Math.sin(e.angle),r=e.x*t.scaleX+t.translateX,s=e.y*t.scaleY+t.translateY,i=e.length*t.dpr,a=e.halfWidth*t.dpr,l=r-n*i,c=s-o*i,f=i*(1-Fs);return[{x:r,y:s},{x:l-o*a,y:c+n*a},{x:r-n*f,y:s-o*f},{x:l+o*a,y:c-n*a}]}function lo(e,t){return t?e.slice(t.start,t.start+t.count):[]}function Ce(e,t){return e!==void 0&&t>=e.start&&t<e.start+e.count}function ce(e,t){let n=new Map,o=new Map;for(let r=0,s=e.length;r<s;r++){let i=e[r],{color:a,weight:l,last:c}=t(i,r),f=c?o:n,u=`${a}:${l}`,d=f.get(u);d?d.items.push(i):f.set(u,{color:a,items:[i]})}return[...n.values(),...o.values()]}var Gs=50;function fo(e,t){return t>0?Math.max(1,e/t):Gs}function Ws(e){let t=new Set,n=1/0,o=-1/0;for(let r of e)t.add(r.minY),n=Math.min(n,r.minY),o=Math.max(o,r.minY);return t.size>1?(o-n)/(t.size-1):void 0}function uo(e,t,n){let o=fo(t,e.length);return{x:o,y:n>0?fo(n,e.length):Ws(e)??o}}function Ys(e,t,n,o){return e===void 0?uo(t,n,o):typeof e=="number"?{x:e,y:e}:e}function Hs(e,t,n){let o=e.get(t);o||(o=new Map,e.set(t,o));let r=o.get(n);return r||(r=[],o.set(n,r)),r}function po(e,t,n,o,r,s,i){let a=Math.floor(n/t.x),l=Math.floor(r/t.x),c=Math.floor(o/t.y),f=Math.floor(s/t.y);for(let u=a;u<=l;u++)for(let d=c;d<=f;d++)Hs(e,u,d).push(i)}function ho(e,t,n,o,r,s){let i=Math.floor((n-r)/t.x),a=Math.floor((n+r)/t.x),l=Math.floor((o-s)/t.y),c=Math.floor((o+s)/t.y),f=[],u=new Set;for(let d=i;d<=a;d++){let p=e.get(d);if(p)for(let m=l;m<=c;m++){let h=p.get(m);if(h)for(let b of h)u.has(b)||(u.add(b),f.push(b))}}return f}var mo=class{constructor(e,t){this.cells=new Map;let n=[],o=0,r=0;for(let[s,i]of Object.entries(e))for(let a=0;a<i.length-1;a++){let l=i[a],c=i[a+1],f=Math.min(l.x,c.x),u=Math.min(l.y,c.y),d=Math.max(l.x,c.x),p=Math.max(l.y,c.y);o+=d-f,r+=p-u,n.push({entry:{nodeId:s,segmentIdx:a},minX:f,minY:u,maxX:d,maxY:p})}this.cellSize=Ys(t,n,o,r);for(let s of n)po(this.cells,this.cellSize,s.minX,s.minY,s.maxX,s.maxY,s.entry)}query(e,t,n,o=n){return ho(this.cells,this.cellSize,e,t,n,o)}},go=class{constructor(e,t,n,o,r,s=0,i,a=!1){this.cells=new Map,this.edgeCurves=$n(e,t,o,r,s,i,a);let l=[],c=0,f=0;for(let u=0;u<t.edges.length;u++){let d=t.edges[u],p=e[d.from],m=e[d.to],h=this.edgeCurves.get(u);if(p?.length&&m?.length&&h){let{minX:b,minY:g,maxX:y,maxY:M}=xn(h),x=d.pathIds?.length??0;if(n&&x>0){let w=0,v=0;for(let k of _e(p,m,x,o))w=Math.max(w,Math.abs(k.x)),v=Math.max(v,Math.abs(k.y));b-=w,g-=v,y+=w,M+=v}c+=y-b,f+=M-g,l.push({ei:u,minX:b,minY:g,maxX:y,maxY:M})}}this.cellSize=uo(l,c,f);for(let u of l)po(this.cells,this.cellSize,u.minX,u.minY,u.maxX,u.maxY,u.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,t,n,o=n){return ho(this.cells,this.cellSize,e,t,n,o)}};function xo(e,t,n,o,r,s){let i=r-n,a=s-o,l=i*i+a*a;if(l===0)return Math.hypot(e-n,t-o);let c=Math.max(0,Math.min(1,((e-n)*i+(t-o)*a)/l));return Math.hypot(e-(n+c*i),t-(o+c*a))}function Us(e,t,n){let o=1/0,r=20,s=n.x0,i=n.y0;for(let a=1;a<=r;a++){let l=a/r,c=1-l,f=c*c*c*n.x0+3*c*c*l*n.cx0+3*c*l*l*n.cx1+l*l*l*n.x1,u=c*c*c*n.y0+3*c*c*l*n.cy0+3*c*l*l*n.cy1+l*l*l*n.y1;o=Math.min(o,xo(e,t,s,i,f,u)),s=f,i=u}return o}function bo(e,t,n,o=1){let r=1/0;for(let s of n){let i=Us(e,t,o===1?s:{x0:s.x0,y0:s.y0*o,cx0:s.cx0,cy0:s.cy0*o,cx1:s.cx1,cy1:s.cy1*o,x1:s.x1,y1:s.y1*o});i<r&&(r=i)}return r}var js=Ze();function yo(e,t){return js(e,[t],()=>new mo(e))}var Vs=Ze();function Ks(e,t,n,o,r,s,i,a=!1){return Vs(e,[t,n,o.scaleX,o.scaleY,r,s,i,a],()=>new go(e,t,n,o,s,r,i,a))}var zs=5;function Su(e,t,n,o,r=0,s){let i=ze(o),a=yo(e,r),l=p=>Math.max(zs,p)/o.scaleX,c=l(s?.maxHalfWidthPx??0),f=a.query(t,n,c,c/i),u=null,d=1/0;for(let{nodeId:p,segmentIdx:m}of f){let h=e[p],b=xo(t,n*i,h[m].x,h[m].y*i,h[m+1].x,h[m+1].y*i);b<d&&b<l(s?.halfWidthPx(p)??0)&&(d=b,u=p)}return u}function Zs(e,t,n){let o=t.x-e.x,r=t.y-e.y,s=0,i=1;for(let[a,l]of[[-o,e.x-n.x0],[o,n.x1-e.x],[-r,e.y-n.y0],[r,n.y1-e.y]])if(a===0){if(l<0)return!1}else a<0?s=Math.max(s,l/a):i=Math.min(i,l/a);return s<=i}function wo(e,t,n=0){let o=yo(e,n),r=s=>({x:s.x*t.scaleX+t.translateX,y:s.y*t.scaleY+t.translateY});return s=>{let i=new Set,a=o.query(((s.x0+s.x1)/2-t.translateX)/t.scaleX,((s.y0+s.y1)/2-t.translateY)/t.scaleY,Math.abs((s.x1-s.x0)/2/t.scaleX),Math.abs((s.y1-s.y0)/2/t.scaleY));for(let{nodeId:l,segmentIdx:c}of a){let f=e[l];!i.has(l)&&Zs(r(f[c]),r(f[c+1]),s)&&i.add(l)}return i}}function Eu(e,t,n,o,r,s,i=0,a,l,c,f=!1){let u=ze(r),d=10/r.scaleX,p=Ks(e,t,s,r,i,a,c,f),m=p.query(n,o,d,d/u),h=null,b=d;for(let g of m){let y=t.edges[g],M=e[y.from],x=e[y.to];if(!M?.length||!x?.length||l?.has(g))continue;let w=y.pathIds?.length??0,v=p.getCurves(g);if(!v)continue;let k;if(!s||w===0)k=bo(n,o*u,v,u);else{let T=1/0;for(let S of _e(M,x,w,r)){let _=S.x===0&&S.y===0?v:yn(v,S.x,S.y),O=bo(n,o*u,_,u);O<T&&(T=O)}k=T}k<b&&(b=k,h=g)}return h}var Mo=3.4,bt=6,Js=18,Qs=2,ei=3,ti=Mn+vn;function vo(e){let t=e.gene.end-e.gene.start;if(e.covered>=.98)return;let[n,o]=t>=999500?[1e6,"Mb"]:t>=1e3?[1e3,"kb"]:[1,"bp"],r=s=>+(s/n).toFixed(n===1?0:1);return`${r(e.covered*t)} of ${r(t)} ${o}`}function So(e,t,n,o){let r=n/2;return Eo(e,s=>s.gene.end-s.gene.start).map(s=>{let{x:i,y:a}=t(s.at),l=vo(s);return{item:s,x:i,y:a+n+Js,text:l?`${s.gene.name} \xB7 ${l}`:s.gene.name,fallback:l?`${s.gene.name} \u2026`:void 0,stack:Qs,fits:c=>[...o({x0:c.x0-r,x1:c.x1+r,y0:c.y0-r,y1:c.y1+r})].every(f=>s.nodeIds.has(f))}})}function Eo(e,t){return[...e].sort((n,o)=>t(o)-t(n))}function ni(e){let{paneWidth:t,canvasHeight:n,translateX:o,translateY:r}=e,{scaleX:s,scaleY:i}=e.axisScale,a={width:t,height:n},l=w=>({x:w.x*s+o,y:w.y*i+r}),c=e.drawnRowLabels.map(({label:w,y:v})=>tt(w,v*i+r)),f=e.referenceStripZonePx??0;f>0&&c.push({x0:0,x1:t,y0:0,y1:f}),e.legendSize.width>0&&c.push({x0:t-bt-e.legendSize.width,x1:t,y0:0,y1:f+bt+e.legendSize.height}),e.poppedFrom&&c.push({x0:0,x1:60+e.poppedFrom.label.length*pe*1.2,y0:0,y1:44});let u=Sn(a,c),d=e.drawnRowLabels.length>0,p=d?Math.min(...e.drawnRowLabels.map(w=>w.y)):1/0,m=e.contigThickness*Mo,h=(w,v)=>{let{x:k,y:T}=l({x:w.labelAt.x,y:Math.min(w.labelAt.y,p)}),S=T-m/2-v;return{x:k,y:d?Math.max(S,ti):S}},b=Eo(e.bubbleHalos.filter(w=>!w.tick),w=>w.whole?-1:w.members),g=Je(b.map(w=>({item:w,...h(w,6),text:w.label,fallback:w.label.includes(",")?w.label.split(",")[0]:void 0,stack:ei})),a,u),y=e.bubbleHalos.filter(w=>w.tick).map(w=>({item:w,...h(w,2)})).filter(w=>w.x>=0&&w.x<=t&&w.y>=0&&w.y<=n),M=Je(So(e.genePins,l,e.contigThickness,wo(e.nodePositions??{},{scaleX:s,scaleY:i,translateX:o,translateY:r},e.positionsVersion)),a,u),x=e.nodePositions&&e.labelsNodeSizes?nt({nodePositions:e.nodePositions,nodeLengths:e.nodeLengths,deletions:e.deletions,deletionRoutes:e.deletionRoutes,stranded:e.stranded,alleleDeletions:e.alleleDeletions,axis:e.axisScale,translateX:o,translateY:r,width:t,height:n,version:e.positionsVersion,take:u}):[];return{bubbles:g,ticks:y,genes:M,sizes:x}}var te=JBrowseExports.mobx,le=e=>te!=null&&e in Object(te)?te[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from 'mobx' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var Ku=le("autorun");var zu=le("computed");var ko=le("observable");var Zu=le("reaction");var Ro=le("runInAction");var Ju=le("untracked");var Qu=te&&te.__esModule?te.default:te;function xt(e,t){return t===j(e.id)?e.id:`-${e.id}`}function oi(e,t){let n=e.map(()=>{}),o=0,r=0;for(;r<e.length&&e[r]!==void 0;r++)n[r]=o,o+=e[r];let s=t;for(let i=e.length-1;i>r&&e[i]!==void 0;i--)s-=e[i],n[i]=s;return n}function ri(e,t){let n=e.path.map(()=>[]);if(e.cs===void 0)return n;let o=oi(t,e.pathLength),r=o.flatMap((d,p)=>d===void 0?[]:[p]),s=d=>o[r[d]],i=d=>s(d)+t[r[d]],a=0,l=d=>{for(;a<r.length&&i(a)<d;)a++;for(let p=a;p<r.length&&s(p)<=d;p++){let m=i(p);if(d<m)return{s:r[p],local:d-s(p),room:m-d}}},c=d=>{for(let p=a;p<r.length;p++)if(s(p)>d)return s(p)-d;return 1/0},f=(d,p)=>{let m=n[d],h=m.at(-1);p.type==="substitution"&&h?.type==="substitution"&&h.pos+h.seq.length===p.pos?h.seq+=p.seq:m.push(p)},u=e.pathStart;for(let d of mn(e.cs))if(d.op==="match")u+=d.length;else if(d.op==="substitution"){let p=l(u);p&&f(p.s,{type:"substitution",pos:p.local,seq:d.seq}),u+=1}else if(d.op==="insertion"){let p=u>e.pathStart&&u<e.pathEnd?l(u):void 0;p&&f(p.s,{type:"insertion",pos:p.local,seq:d.seq})}else{let p=d.length;for(;p>0;){let m=l(u),h=Math.min(p,m?m.room:c(u));m&&f(m.s,{type:"deletion",pos:m.local,length:h}),u+=h,p-=h}}return n}function To(e,t,n){let o=new Map(e.nodes.map(s=>[s.name,s])),r=[];for(let s of t){let i=s.path.map(f=>o.get(f.name)),a=i.flatMap((f,u)=>f?[u]:[]),l=a[0],c=a.at(-1);if(l!==void 0&&c!==void 0){let f=ri(s,i.map(p=>p?.length)),u=a.map(p=>xt(i[p],s.path[p].strand)),d=i[c].length;r.push({id:n+r.length,name:s.name,type:"read",sourceTrackID:1,sequence:u,sequenceNew:a.map((p,m)=>({nodeName:u[m],mismatches:f[p]})),firstNodeOffset:l===0?s.pathStart:0,finalNodeCoverLength:c===s.path.length-1?d-(s.pathLength-s.pathEnd):d,mapping_quality:s.mappingQuality===255?void 0:s.mappingQuality,is_secondary:s.secondary,is_reverse:s.strand==="-"})}}return r}var si=["#6baed6","#4292c6","#2171b5","#08519c"],ii=["#fb6a4a","#ef3b2c","#cb181d","#a50f15"];function _o(e){let t=e.is_reverse?ii:si;return t[e.id%t.length]}var ai=10;function ci(e,t){let n=e.end-e.start,o=e.longestAlleleLength-e.shortestAlleleLength;return t.find(r=>o<=ai*(r.end-r.start)&&(n===0?r.start<=e.start&&e.start<=r.end:Math.min(e.end,r.end)-Math.max(e.start,r.start)>=n/2))}var li=40;function di(e,t){let n=I(e),o=I(t),r=o.slice(o.indexOf(" "));return n.endsWith(r)?`${n.slice(0,-r.length)}\u2013${o}`:`${n}\u2013${o}`}function yt(e){return e>=Bn?"\u22652.1B routes":e>=1e5?`${(e/1e3).toFixed(0)}k routes`:`${e} routes`}function fi(e,t=[]){let n=ui(e,t);return e.partial?{...n,label:`${n.label}, partial`}:n}function ui(e,t){let n=e.end-e.start,{shortestAlleleLength:o,longestAlleleLength:r,pathCount:s,segmentCount:i,inversion:a}=e,l=di(o,r);if(i>=li)return{kind:"superbubble",label:`${l} superbubble, ${i} segments, ${yt(s)}${a?", inv":""}`};if(a)return{kind:"inversion",label:`${I(r)} inv`};if(e.offReference)return o===r?Oo(o):{kind:"complex",label:`${l}, ${yt(s)}`};let c=r!==o?ci(e,t):void 0;if(c){let u=c.name?` (${c.name})`:"";return{kind:"repeat",label:`${l} repeat array${u}, ${yt(s)}`}}let f=s>2?`, ${s} alleles`:"";return o===r&&o===n?Oo(n):n===0||o===n?{kind:"insertion",label:`\u2264${I(r-n)} ins${f}`}:r===n?{kind:"deletion",label:`${I(n-o)} del${f}`}:{kind:"complex",label:`${I(n)} ref \u2192 ${l}, ${s} alleles`}}function Oo(e){return e<=1?{kind:"snp",label:"SNP"}:{kind:"substitution",label:`${I(e)} sub`}}var pi={snp:"#5b6b7a",substitution:"#5b6b7a",insertion:"#2f8fd6",deletion:"#c94040",inversion:"#e07b00",repeat:"#8e3fbf",superbubble:"#8e3fbf",complex:"#8e3fbf"},hi={snp:"SNP",substitution:"substitution",insertion:"insertion",deletion:"deletion",inversion:"inversion",repeat:"repeat array",superbubble:"superbubble",complex:"site"};function mi(e){return e.segments.split(",").filter(Boolean)}function A(e,t={},...n){return{tag:e,attrs:t,children:n.filter(o=>!!o||o==="")}}function Ao(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function gi(e){return Ao(e).replaceAll('"',"&quot;")}function bi(e){if(typeof e=="string")return Ao(e);let t=Object.entries(e.attrs).filter(([,n])=>n!==void 0).map(([n,o])=>` ${n}="${gi(String(o))}"`).join("");return`<${e.tag}${t}>${e.children.map(bi).join("")}</${e.tag}>`}var Rt="#2f8fd6",Tt="#8e3fbf",No="#bdbdbd",vt="#8a8a8a",Po="#e2e2e2",Io="#d9a441",be="#1c1c22",_t=12,Le=4,St=1,Et=12,xi=6,yi=3;function W(e){return`${(e/1e3).toFixed(e<1e4?1:0)} kb`}function wi(e){let t=Math.abs(e);return`${e>0?"+":"\u2212"}${t<1e3?`${t} bp`:W(t)}`}function wt(e,t){return t?` \u2248 ${Math.round(e/t)} units`:""}var Mi=({refName:e,start:t})=>`${Se(e)}:${t<1e6?`${Math.round(t/1e3)} kb`:`${(t/1e6).toFixed(1)} Mb`}`;function vi(e){return e<1e3?`${e}`:`${Math.round(e/1e3)} k`}function Si(e,t,n=0){if(e<=0)return"";let o=(t??[]).filter(l=>l.gap);if(!o.some(l=>l.cause))return` \xB7 ${W(e)} ${se}`;let r=l=>o.filter(c=>c.cause===l).reduce((c,f)=>c+f.bp,0),s=[...new Set(o.flatMap(l=>l.chunk?[Mi(l.chunk)]:[]))],i=[[r("missing"),F.missing],[r("elsewhere"),`on nodes filed near ${s[0]}${s.length>1?` and ${s.length-1} more place${s.length>2?"s":""}`:""}`],[r("unknown"),F.unknown],[r("deleted"),F.deleted],[r(void 0),se]],a=r("abridged");return(a>0?` \xB7 ${vi(n)} steps, ${W(a)} not loaded`:"")+i.filter(([l])=>l>0).map(([l,c])=>` \xB7 ${W(l)} ${c}`).join("")}function $o(e,t,n,o){let{bp:r,gapBp:s,complete:i,stop:a}=e;if(!t)return`${W(r)}${wt(r,n)}`;let l=Si(s,e.runs,e.abridgedSteps),c=o?` \xB7 called ${W(o.bp)}${o.spanningReads===0?" \xB7 no spanning read":""}`:"";if(i){let d=r-t.bp,p=d===0?"":` (${wi(d)})`;return`${e.estimated?"\u2248 ":""}${W(r)}${wt(r,n)}${p}${l}${c}`}let f=n?"repeat":"window";if(a?.contigEnds&&r===0)return`contig ends ${a.shortBp>0?`${W(a.shortBp)} before`:"at"} the ${f}${c}`;let u=a?a.contigEnds?`contig ends inside the ${f}`:"does not rejoin the reference within the extracted subgraph":"partial walk";return`\u2265 ${W(r)}${wt(r,n)} \xB7 ${u}${l}${c}`}function Co(e,t,n){let o=t+6;return o+e.length*pe<n?{x:o,anchor:"start",halo:!1}:{x:t-6,anchor:"end",halo:!0}}function Lo(e,t,n){if(t*n<yi)return[];let o=[];for(let r=t;r<e;r+=t)o.push(r);return o}function xe(e){return e==="missing"?{fill:vt,px:St,label:F.missing}:e==="deleted"?{fill:vt,px:St,label:F.deleted}:e==="unknown"?{fill:Po,px:Le,label:F.unknown}:e==="abridged"?{fill:Io,px:Le,label:F.abridged}:{fill:No,px:Le,label:se}}function Bo(e,t){if(e.gap)return{fill:xe(e.cause).fill};if(!t)return{fill:e.onReference?Rt:Tt};if(e.referenceStart===void 0)return{fill:Ne};let n=Nn({...e,start:e.referenceStart},t);return n.length===1?{fill:st(n[0])}:{stops:n.map(st)}}function kt(e,t,n){return e.reversed?{start:e.start-n,end:e.start-t}:{start:t-e.start,end:n-e.start}}function Ei(e,t){return e.reversed?{start:e.start-t,end:e.start}:{start:e.start,end:e.start+t}}function ki(e,t){let n=new Map;for(let o of e){let r=t.get(o.name);if(!o.axis||!r)continue;let s=o.axis,i=({start:a,end:l})=>({start:Math.max(0,a),end:Math.min(o.bp,l)});n.set(o.name,r.map(a=>({name:a.name,...i(kt(s,a.start,a.end)),exons:a.exons.map(l=>i(kt(s,l.start,l.end))).filter(l=>l.end>l.start)})).filter(a=>a.end>a.start).sort((a,l)=>a.start-l.start))}return n}var Ri=9,Ti=5.2,_i=8,Xo=(e,t)=>Math.min(2,(e-t)/2-1);function Do(e,t){return Xo(e,t)>=1}function Fo(e,t,n,{rowPx:o=Te,barPx:r=_t}={}){if(!Do(o,r))return[];let s=Xo(o,r),i=e.map(c=>{let f=t(c.start);return{g:c,x:f,w:Math.max(2,t(c.end)-f)}}),a=[],l=new Set((r>=_i?[...i]:[]).sort((c,f)=>c.w-f.w).filter(({g:c,x:f,w:u})=>{let d=c.name.length*Ti/2,p=[f+u/2-d,f+u/2+d];return 2*d>u+6||a.some(([m,h])=>p[0]<h+2&&p[1]>m-2)?!1:(a.push(p),!0)}));return i.map(c=>({name:c.g.name,x:c.x,y:n-r/2-s,w:c.w,h:r+2*s,exons:c.g.exons.map(f=>({x:t(f.start),w:Math.max(1,t(f.end)-t(f.start))})),label:l.has(c)?{x:c.x+c.w/2,y:n+3,size:Ri}:void 0}))}var Mt=e=>`${e} row${e===1?"":"s"}`;function Oi(e,t={}){let n=t.annotation??"gene",o=[{swatch:t.ramp?{kind:"bar",fill:t.rampCss??In,ramp:!0}:{kind:"bar",fill:Rt},label:`on ${e.reference.label}'s path`},{swatch:{kind:"bar",fill:t.ramp?Ne:Tt},label:`off ${e.reference.label}'s path`}],r=[e.reference,...e.rows].flatMap(a=>a.runs.filter(l=>l.gap)),s=new Set(r.map(a=>xe(a.cause).label)),i=e.rows.some(a=>a.estimated);for(let a of[void 0,"missing","deleted","unknown","abridged"]){let{fill:l,px:c,label:f}=xe(a);s.has(f)&&o.push({swatch:{kind:"gap",fill:l,px:c},label:a==="abridged"&&i?`${f}; \u2248 length takes the reference's bp past the window`:f})}return t.genes?.crowded?o.push({swatch:{kind:"gene"},label:`${n}s left out: too many rows to box them in`,note:!0}):t.genes&&(o.push({swatch:{kind:"gene"},label:n}),t.genes.untracked&&o.push({swatch:{kind:"gene"},label:`no ${n} track for ${Mt(t.genes.untracked)}`,note:!0}),t.genes.unplaced&&o.push({swatch:{kind:"gene"},label:`no contig coordinates for ${Mt(t.genes.unplaced)}`,note:!0}),t.genes.unread&&o.push({swatch:{kind:"gene"},label:`${n}s not read for the last ${Mt(t.genes.unread)}`,note:!0})),o}var qo="#111",Go="#9e9e9e",Ot="#c62828";function Wo(e){return e.agrees===!1?Ot:e.spanningReads===0?Go:qo}function Ai(e,t,n,o="walk-key"){let r=0,s=e.flatMap((i,a)=>{let l=`${o}-ramp-${a}`,c=!i.note&&i.swatch.kind==="bar"&&i.swatch.ramp?A("linearGradient",{id:l},...Pn.map(d=>A("stop",{offset:d.offset,"stop-color":d.color}))):void 0,f=i.note?void 0:i.swatch.kind==="gene"?A("rect",{x:r,y:5,width:18,height:8,fill:"none",stroke:be,"stroke-width":1.5}):A("rect",{x:r,y:i.swatch.kind==="gap"?9-i.swatch.px/2:5,width:18,height:i.swatch.kind==="gap"?i.swatch.px:8,rx:2,fill:c?`url(#${l})`:i.swatch.fill}),u=A("text",{x:i.note?r:r+23,y:13,"font-style":i.note?"italic":void 0,fill:i.note?"#666":void 0},i.label);return r+=(i.note?0:23)+i.label.length*pe+16,[c,f,u].filter(d=>d!==void 0)});return{width:r,tree:A("g",{transform:`translate(${t} ${n})`,"font-family":"Helvetica, Arial, sans-serif","font-size":11},...s)}}function Ni(e,t,n=0){let o=t/Math.max(1,e),r=Math.max(n,Math.min(Te,o>=1?Math.floor(o):o));return{rowPx:r,barPx:r<=3?r:Math.max(3,Math.round(r*.6)),labelled:r>=Et,readouts:r>=Et}}function Yo(e,t){let n=1/t,o=[],r=[],s=()=>{if(r.length!==0){if(r.length===1)o.push(r[0]);else{let a=0,l=0;for(let u of r)u.onReference?a+=u.bp:l+=u.bp;let c=a>=l,f=r.find(u=>u.onReference===c);o.push({start:r[0].start,bp:a+l,onReference:c,referenceStart:c?f.referenceStart:void 0,...f.reversed?{reversed:!0}:{}})}r=[]}},i=0;for(let a of e){if(a.gap||a.bp>=n){s(),i=0,o.push(a);continue}r.push(a),i+=a.bp,i>=n&&(s(),i=0)}return s(),o}function Pi(e,t,n){return A("g",{class:"row-gene","data-testid":"graph-walk-gene"},A("title",{},e.name),...e.exons.map(o=>A("rect",{x:o.x,y:t-n/2,width:o.w,height:n,fill:be,opacity:.35})),A("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:be,"stroke-width":1.5}),e.label&&A("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:be,stroke:"white","stroke-width":2.5,"paint-order":"stroke"},e.name))}function ye(e,t,n={}){let o=h=>h*t.scaleX+t.translateX,r=t.rowPx??Te,s=t.barPx??_t,i=Math.min(3,Math.max(0,(r-s)/2)),a=h=>h*r*t.scaleY+t.translateY,{origin:l,unit:c,reference:f,rows:u}=e,d=h=>o(l+h),p=n.idPrefix??"walkrow",m=(h,b)=>{let g=a(b);if(g<-s||g>t.height+s)return;let y=t.bars===!1?[]:h.runs,M=Yo(y,t.scaleX).flatMap(T=>{let S=Bo(T,n.ramp),_=T.gap?Math.min(xe(T.cause).px,s):s,O=`${p}-${b}-${T.start}`,G=A("rect",{x:d(T.start),y:g-_/2,width:Math.max(1,T.bp*t.scaleX),height:_,fill:"stops"in S?`url(#${O})`:S.fill});return"stops"in S?[A("linearGradient",{id:O},...S.stops.map((z,H)=>A("stop",{offset:H/(S.stops.length-1),"stop-color":z}))),G]:[G]}),x=c&&s>=xi?Lo(h.bp,c,t.scaleX).map(T=>A("line",{x1:d(T),x2:d(T),y1:g-s/2,y2:g+s/2,stroke:"white","stroke-width":1})):[],{call:w}=h,v=t.readouts??!0?{text:$o(h,b===0?void 0:f,c,w)}:void 0,k=v&&Co(v.text,d(h.bp),t.width);return A("g",{"data-testid":b===0?"graph-walk-reference":"graph-walk-row"},...M,...x,...Fo(n.rowGenes?.get(h.name)??[],d,g,{rowPx:r,barPx:s}).map(T=>Pi(T,g,s)),w&&A("rect",{"data-testid":"graph-walk-call",x:d(w.bp)-1,y:g-s/2-i,width:2,height:s+2*i,fill:Wo(w)}),v&&k&&A("text",{x:k.x,y:g+4,"font-family":"sans-serif","font-size":11,fill:w?.agrees===!1?Ot:"#333",stroke:k.halo?"white":void 0,"stroke-width":k.halo?3:void 0,"paint-order":"stroke","text-anchor":k.anchor},v.text))};return A("g",{},...[f,...u].map(m))}function At({graph:e,layout:t}){let n=new Map(e.nodes.map(r=>[r.id,r])),o=new Map;t.nodes.forEach((r,s)=>{let i=n.get(r.name);if(r.order>=0&&i&&N(i)){let{refName:a,start:l}=i.stable;re(o,a,{name:r.name,index:s,bp0:l,bp1:l+i.length,x0:r.x,x1:r.x+r.pixelWidth})}});for(let r of o.values())r.sort((s,i)=>s.bp0-i.bp0);return o}function Be(e,t,n=!1){let o=J(e.length-1,r=>n?e[r].bp1<t:e[r].bp1<=t);return we(e[o],t)}function we(e,t){let n=e.bp1-e.bp0;return t<=e.bp0||n<=0?e.x0:e.x0+(Math.min(t,e.bp1)-e.bp0)/n*(e.x1-e.x0)}function Xe(e,t,n){let o=Be(e,t),r=Be(e,n,!0);return{x0:Math.min(o,r),x1:Math.max(o,r)}}function Ii(e){let t;for(let n of e.values())(!t||n.length>t.length)&&(t=n);return t}var Ho=5,$i=10,Ci=110,Li=3;function Uo(e){return e?"#b0b0b8":"#55555c"}function Bi(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 jo(e){let t=[];for(let n of e)t.every(o=>Math.abs(n.at-o.at)>=(n.width+o.width)/2+$i)&&t.push(n);return t.map(({text:n,at:o})=>({text:n,at:o}))}function Xi(e,t,n,o){let r=e[0],s=e.at(-1);if(!r||!s)return;let i=t(r.x0),a=t(s.x1),l=s.bp1-r.bp0;if(a<=i||l<=0)return;let c=Bi(l/(a-i)*Ci),f=[],u=[];for(let d=Math.ceil(r.bp0/c)*c;d<=s.bp1;d+=c){let p=Math.round(t(Be(e,d)))+.5;if(p>=0&&p<=n){f.push(p);let m=d.toLocaleString("en-US");u.push({text:m,at:p,width:o(m)})}}return{spans:[{x0:i,x1:a}],ticks:f,labels:jo(u)}}function Di(e,t,n,o){let r=e.map(m=>({box:m,s0:t(m.x0),s1:t(m.x1)})).filter(({s0:m,s1:h})=>h>=0&&m<=n),s=r[0],i=r.at(-1);if(!s||!i)return;let a=(m,h)=>({text:m,at:h,width:o(m)}),l=(m,h)=>a(m.toLocaleString("en-US"),h),c=[],f=[],u=[],d=[];for(let{box:m,s0:h,s1:b}of r){c.push({x0:h,x1:b}),f.push(Math.round(h)+.5),b-h>=Li&&f.push(Math.round(b)+.5);let g=a(I(m.bp1-m.bp0),(h+b)/2);g.width<=b-h&&u.push(g),m!==s.box&&d.push(l(m.bp0,h))}let p=[l(s.box.bp0,s.s0),l(i.box.bp1,i.s1)];return{spans:c,ticks:f,labels:jo([...p,...u,...d])}}function Vo(e,t,n,o,r=!1){return(r?Xi:Di)(e,t,n,o)}function Fi(e,t,n,o,r=!1){let{x:s,width:i,darkMode:a}=n;e.font="10px sans-serif";let l=Vo(t,s,i,u=>e.measureText(u).width,r);if(!l)return;let c=Uo(a),f=o+.5;e.strokeStyle=c,e.fillStyle=c,e.lineWidth=1,e.textAlign="center",e.textBaseline="top",e.beginPath();for(let{x0:u,x1:d}of l.spans)e.moveTo(Math.max(0,u),f),e.lineTo(Math.min(i,d),f);for(let u of l.ticks)e.moveTo(u,o),e.lineTo(u,o+Ho);e.stroke();for(let{text:u,at:d}of l.labels)e.fillText(u,d,o+Ho+2)}function qi(e,t,n,o){let r=[];for(let s of e){let i=n(s.x0),a=n(s.x1);a>=0&&i<=o&&r.push({node:s.name,top0:t(s.bp0),top1:t(s.bp1),bottom0:i,bottom1:a})}return r}var Gi=3;function Wi(e,t,n,o){if(t<=0||o<0||o>t)return;let r=o/t,s,i=Gi;for(let a of e){let l=a.top0+(a.bottom0-a.top0)*r,c=a.top1+(a.bottom1-a.top1)*r,f=Math.max(0,Math.min(l,c)-n,n-Math.max(l,c));f<i&&(i=f,s=a.node)}return s}function Ko(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 zo(e,t,n){e.moveTo(t.top0,0),e.lineTo(t.bottom0,n),e.moveTo(t.top1,0),e.lineTo(t.bottom1,n)}function Yi(e,t,n,{highlightNode:o,darkMode:r}){if(n<=0||t.length===0)return;let s=r?"255,255,255":"0,0,0";e.beginPath();for(let i of t)Ko(e,i,n);e.fillStyle=`rgba(${s},0.07)`,e.fill(),e.beginPath();for(let i of t)zo(e,i,n);e.strokeStyle=`rgba(${s},0.35)`,e.lineWidth=.5,e.stroke(),Zo(e,t,n,o)}function Zo(e,t,n,o){let r=n>0&&o?t.find(s=>s.node===o):void 0;r&&(e.beginPath(),Ko(e,r,n),e.fillStyle="rgba(255,192,203,0.5)",e.fill(),e.beginPath(),zo(e,r,n),e.strokeStyle="#ff0000",e.lineWidth=1,e.stroke())}function Jo(e,t){let n=new Map;for(let o of e){let r=t(o),s=n.get(r);s===void 0?n.set(r,[o]):s.push(o)}return n}var Hi=new Set(["_gbwt_ref","unknown"]);function Qo(e){let[t,n,o]=e?.split("#")??[];if(!(t===void 0||t===""||Hi.has(t)||n===void 0||!/^\d+$/.test(n)||o===void 0||o===""))return{sample:t,haplotype:Number(n),contig:o}}var Ui=["read_group","sample_name"],Dh=[...Ui,"haplotype_sample"],De=8.401;function ji({layers:e,coarsenedReadView:t=!1,showReads:n=!0},o){if(e!==void 0)return e;let r=t&&n,s=i=>i?{stat:"coarsen"}:{};return[{data:"haplotypes",...s(r&&!o)},{data:"reads",...s(r&&o)}]}function er(e,t){return e.find(n=>n.data===t)?.stat}function Vi(e,t){return{mergeNodes:e.mergeNodes??!0,showReads:e.showReads??!0,coarsenedReadView:e.coarsenedReadView??!1,layers:ji(e,t),ignoreStrand:e.ignoreStrand??!1,nodeWidthOption:e.nodeWidthOption??"normal",charWidth:e.charWidth??De,trackWidth:e.trackWidth??15,freqWidth:e.freqWidth??"log"}}function Ki(){return{rectangles:[],curves:[],corners:[],verticalRectangles:[]}}function pr(e){return{config:e,nodes:[],tracks:[],reads:[],nodeMap:new Map,nodesPerOrder:[],nodeOrders:[],assignments:[],extraLeft:[],extraRight:[],maxOrder:-1,shapes:Ki(),trackForRuler:void 0,coarsenedEdgeMeta:new Map}}function hr(e,t,n=[],o={}){let r=zi(e,t,n,o);return r&&Zi(r,o)}var mr=new WeakMap;function zi(e,t,n=[],o={}){let r=Qi(e,t,n,o);if(r===void 0)return;let s=gr(r,r.tracks,r.reads,"measure");return s.nodes.forEach((i,a)=>{i.order>=0&&(r.nodes[a].x=i.x)}),mr.set(r,s),r}function Zi(e,t={}){return Ji(e,oa(e,t.facet),ea(e,t))}function Ji(e,t,n,o){let r=mr.get(e);return r!==void 0&&t.length===e.tracks.length&&n.length===e.reads.length?r:gr(e,t,n,"topology",o)}function Qi(e,t,n,o){let r=pr(Vi(o,n.length>0));if(!(e.length===0||t.length===0)){structuredClone(e).forEach((s,i)=>{s.seq??="",s.sequenceLength??=s.seq.length,r.nodes[i+1]=s}),r.tracks=structuredClone(t),r.reads=r.config.showReads?structuredClone(n.filter(s=>s.is_secondary!==!0)):[];for(let s=r.tracks.length-1;s>=0;s-=1){let i=r.tracks[s];if(i.type??="haplotype",i.hidden===!0){r.tracks.splice(s,1);continue}i.indexOfFirstBase!==void 0&&(r.trackForRuler=i.name)}if(r.tracks.length!==0)return sa(r,0),r.nodeMap=rr(r),de(r,r.tracks),de(r,r.reads),fr(r),r.config.mergeNodes&&(sr(r),Pt(r),$t(r),Va(r),r.nodeMap=rr(r),fr(r),de(r,r.tracks),de(r,r.reads)),sr(r),Ra(r),Pt(r),Ta(r),Pt(r),$t(r),de(r,r.reads),{options:r.config,nodes:r.nodes,tracks:r.tracks,reads:r.reads,nodeMap:r.nodeMap,maxOrder:Ea(r),trackForRuler:r.trackForRuler}}}function ea(e,{mappingQualityCutoff:t=0,focusReadNames:n=null,facet:o}){let r=n?new Set(n):null;return e.reads.filter(s=>(s.mapping_quality??0)>=t&&(r===null||s.name!==void 0&&r.has(s.name))&&(o===void 0||ta(o,s)))}function ta(e,t){return e.by==="haplotype_sample"?"reads"in e:(t[e.by]??null)===e.key}function na(e){return new Set(e.tracks.filter((t,n)=>n===0||t.name===e.trackForRuler))}function oa(e,t){if(t?.by!=="haplotype_sample")return e.tracks;let n=na(e);return e.tracks.filter(o=>n.has(o)||!("reads"in t)&&ra(o)===t.key)}function ra(e){return Qo(e.name)?.sample??null}function gr(e,t,n,o,r={}){let s=pr(e.options);e.nodes.forEach((d,p)=>{s.nodes[p]={...d}}),s.tracks=t.map(d=>({...d})),s.reads=n.map(d=>({...d})),s.nodeMap=e.nodeMap,s.maxOrder=e.maxOrder,s.trackForRuler=e.trackForRuler;let{layers:i,ignoreStrand:a}=s.config,l=r.haplotypes??qa,c=er(i,"haplotypes")==="coarsen"?Ga(s,l):void 0;c!==void 0&&(s.tracks=[c.ref]),Da(s),Pa(s),ia(s);let f=er(i,"reads")==="coarsen"&&s.reads.length>0?Mr(s,s.reads,"read",r.reads??l+(c?.bands.length??0)):void 0;f!==void 0&&(s.reads=f.bands);let u={};for(let[d,p,m]of[["haplotypes","haplotype",c],["reads","read",f]])m!==void 0&&($t(s,m.bands),de(s,m.bands),u[d]={unit:p,total:m.total,reverse:!a&&m.bands.some(h=>h.is_reverse)});return c!==void 0&&(s.reads=c.bands.concat(s.reads)),ca(s),s.tracks=s.tracks.concat(s.reads),o==="measure"&&Oa(s),Fa(s),{nodes:s.nodes,tracks:s.tracks,reads:s.reads,nodeMap:s.nodeMap,shapes:s.shapes,bounds:xa(s),maxOrder:s.maxOrder,trackForRuler:s.trackForRuler,coarsenedEdgeMeta:s.coarsenedEdgeMeta,coarsened:u}}function L(e){return e.startsWith("-")}function B(e){return L(e)?e.substring(1):e}function br(e){return L(e)?e:`-${e}`}function Ct(e){return L(e)?B(e):br(e)}function tr(e){return e>0}function sa(e,t){let n=new Set,o=new Set;for(let r of e.tracks[t].sequence)L(r)?o.has(B(r))||n.add(B(r)):o.add(r);if(n.size!==0){for(let{sequence:r}of[...e.tracks,...e.reads])for(let s=0;s<r.length;s+=1)n.has(B(r[s]))&&(r[s]=Ct(r[s]));e.nodes.forEach(r=>{n.has(r.name)&&(r.seq=Xt(r.seq))})}}function ia(e){e.nodesPerOrder=Array.from({length:e.maxOrder+1},()=>[]);let t=new Map;e.nodes.forEach(n=>{n.y!==void 0&&nr(t,n.order,n.y+n.contentHeight)}),e.tracks.forEach(n=>{n.type==="haplotype"&&n.path.forEach(o=>{nr(t,o.order,(o.y??0)+n.width)})}),e.nodes.forEach((n,o)=>{n.order>=0&&n.y===void 0&&(n.y=(t.get(n.order)??0)+25,n.contentHeight=0,e.nodesPerOrder[n.order].push(o))})}function nr(e,t,n){let o=e.get(t);o===void 0?e.set(t,n):e.set(t,Math.max(o,n))}var Lt=7;function aa(e){e.nodes.forEach(t=>{t.incomingReads=[],t.outgoingReads=[],t.internalReads=[]}),e.reads.forEach((t,n)=>{(t.width===void 0||t.width===0)&&(t.width=Lt),t.path.forEach((o,r)=>{if(o.node===null)return;let s=e.nodes[o.node];t.path.length===1?s.internalReads.push(n):r===0?s.outgoingReads.push([n,r]):s.incomingReads.push([n,r])})})}function ca(e){e.reads.forEach(a=>{a.path=xr(e,a)}),aa(e);let t=e.nodes.filter(a=>a.order>=0);t.sort(Ft);let n=new Map;for(let a=0;a<e.reads.length;a++){let l=e.reads[a],c=l.haplotypeShare===void 0?1:0,f=l.sourceTrackID,u=`${c}:${f}`,d=n.get(u);d===void 0?n.set(u,{layer:c,source:f,reads:new Set([a])}):d.reads.add(a)}let o=[...n.values()].sort((a,l)=>a.layer-l.layer||a.source-l.source),r=o.length>1?Lt:0;t.forEach(a=>{for(let{reads:l}of o)la(e,l,a,r)});let s=ma(e),i=[];e.reads.forEach((a,l)=>{let c=[],f=[],u;a.path.forEach((d,p)=>{c[p]=u,d.node!==null&&(u=d)}),u=void 0;for(let d=a.path.length-1;d>=0;d-=1)f[d]=u,a.path[d].node!==null&&(u=a.path[d]);a.path.forEach((d,p)=>{if(d.y===void 0){let m=c[p],h=f[p],b=!!(h&&m&&(m.order>h.order||h.order===m.order&&h.isForward===m.isForward));d.betweenCycleReverseTraversal=b,i.push({readIndex:l,pathIndex:p,previousY:m?.y,previousNode:m?.node})}})}),i.sort((a,l)=>fa(e,a,l)),i.forEach(a=>{let l=e.reads[a.readIndex],c=l.path[a.pathIndex];c.y=s[c.order],s[c.order]+=l.width})}function la(e,t,n,o){let r=n.incomingReads.filter(([m])=>t.has(m)),s=n.outgoingReads.filter(([m])=>t.has(m)),i=n.internalReads.filter(m=>t.has(m));r.length===0&&s.length===0&&i.length===0&&(o=0);let a=n.y+n.contentHeight+o*2,l=r.map(m=>{let[h,b]=m,g=e.reads[h].path,y=b+1,M;for(let x=1;x<=b;x++){let w=g[b-x]?.y;if(w!==void 0){y=x,M=w;break}}return{entry:m,decisionStep:y,y:M}});l.sort(da),r=l.map(m=>m.entry);let c=a,f=new Map;r.forEach(m=>{let h=e.reads[m[0]];h.path[m[1]].y=c,or(f,h,m[1],c,n),c+=h.width});let u=c;s.sort((m,h)=>ua(e,m,h));let d=new Map;c=a,s.forEach(m=>{let h=e.reads[m[0]],b=h.firstNodeOffset??0;h.path[m[1]].y=c,d.set(c,b);let g=f.get(c);g===void 0||g+1<=b?(c+=h.width,u=Math.max(u,c)):(f.set(c,0),r.forEach(y=>{let M=e.reads[y[0]],x=M.path[y[1]];x.y!==void 0&&x.y>=c&&(x.y+=h.width,or(f,M,y[1],x.y,n))}),c+=h.width,u+=h.width)}),i.sort((m,h)=>ha(e,m,h)),i.forEach(m=>{let h=e.reads[m],b=h.firstNodeOffset??0,g=h.finalNodeCoverLength??0;for(c=a;b<(f.get(c)??-1/0)+2||g>(d.get(c)??1/0)-3;)c+=h.width;h.path[0].y=c,f.set(c,g),u=Math.max(u,c)});let p=u-n.y-n.contentHeight;n.contentHeight+=p,Ba(e,n,p)}function da(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 or(e,t,n,o,r){e.set(o,n===t.path.length-1?t.finalNodeCoverLength??0:r.sequenceLength)}function fa(e,t,n){let o=e.reads[t.readIndex],r=e.reads[n.readIndex],s=o.path[t.pathIndex],i=r.path[n.pathIndex];if(s.order!==i.order)return s.order-i.order;if(o.sourceTrackID!==r.sourceTrackID)return o.sourceTrackID-r.sourceTrackID;if(t.previousNode&&n.previousNode){let u=e.nodes[t.previousNode],d=e.nodes[n.previousNode];if(u&&d&&u.order!==d.order)return u.order-d.order}let a=t.previousY??0,l=n.previousY??0,c=s.betweenCycleReverseTraversal===!0,f=i.betweenCycleReverseTraversal===!0;return c!==f?c?1:-1:c?l-a:a-l}function ua(e,[t,n],[o,r]){let s=e.reads[t],i=e.reads[o],a=s.path.findLast(p=>p.y!==void 0)?.y,l=i.path.findLast(p=>p.y!==void 0)?.y;if(a!==void 0&&l!==void 0)return a-l;let c=(p,m)=>{let h=p.path[m]?.node;return h==null?null:e.nodes[h]??null},f=(p,m)=>{let h=m+1;for(;p.path[h]?.node===null;)h+=1;return h},u=c(s,n),d=c(i,r);for(;u!==null&&u===d;)n=f(s,n),r=f(i,r),u=c(s,n),d=c(i,r);return u!==null&&d!==null?Ft(u,d):u!==null||d!==null?u===null?-1:1:(s.firstNodeOffset??0)-(i.firstNodeOffset??0)||(s.finalNodeCoverLength??0)-(i.finalNodeCoverLength??0)}function pa(e,t){let n=e.path,o=t.path,r=0,s=0;for(;r<n.length&&s<o.length;){let i=n[r],a=o[s],l=i.order,c=a.order;if(l===c&&i.node&&a.node)return(a.y??0)-(i.y??0);l<c?r+=1:(l>c||(r+=1),s+=1)}return 0}function ha(e,t,n){let o=e.reads[t],r=e.reads[n];return(o.firstNodeOffset??0)-(r.firstNodeOffset??0)||(o.finalNodeCoverLength??0)-(r.finalNodeCoverLength??0)}function ma(e){let t=new Array(e.maxOrder+1).fill(0);return e.nodes.forEach(n=>{n.y!==void 0&&(t[n.order]=Math.max(t[n.order],n.y+n.contentHeight+20))}),e.tracks.forEach(n=>{n.path.forEach(o=>{t[o.order]=Math.max(t[o.order],(o.y??0)+n.width)})}),t}function xr(e,t){let n=[],o=(l,c)=>{n.push({order:l,isForward:c,node:null})},r=(l,c,f)=>{n.push({order:l,isForward:c,node:f})},s=Math.abs(t.indexSequence[0]),i=tr(t.indexSequence[0]),a=e.nodes[s];r(a.order,i,s);for(let l=1;l<t.sequence.length;l+=1){let c=a,f=i;s=Math.abs(t.indexSequence[l]),i=tr(t.indexSequence[l]),a=e.nodes[s];let{order:u}=a;if(u>c.order){f||o(c.order,!0);for(let d=c.order+1;d<u;d+=1)o(d,!0);i||o(u,!0)}else if(u<c.order){f&&o(c.order,!1);for(let d=c.order-1;d>u;d-=1)o(d,!1);i&&o(u,!1)}else i===f&&o(u,!i);r(u,i,s)}return n}function $t(e,t=e.reads){t.forEach(n=>{if(!n.sequence.every(L))return;n.is_reverse=n.is_reverse!==!0,n.sequence=n.sequence.toReversed().map(B),n.sequenceNew!==void 0&&(n.sequenceNew=n.sequenceNew.toReversed());for(let i of n.sequenceNew??[]){i.nodeName=B(i.nodeName);let{sequenceLength:a}=Nt(e,i.nodeName);i.mismatches=i.mismatches.map(l=>Bt(l,a))}let o=n.firstNodeOffset??0,r=Nt(e,n.sequence[0]).sequenceLength,s=Nt(e,n.sequence.at(-1)).sequenceLength;n.firstNodeOffset=r-(n.finalNodeCoverLength??0),n.finalNodeCoverLength=s-o})}function Bt(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:Xt(e.seq)}}}var ga={A:"T",T:"A",C:"G",G:"C"};function Xt(e){let t="";for(let n=e.length-1;n>=0;n-=1)t+=ga[e.charAt(n)]??"N";return t}function de(e,t){let n=new Map;t.forEach(o=>{o.indexSequence=o.sequence.map(r=>{let s=n.get(r);if(s===void 0){let i=e.nodeMap.get(B(r));if(i===void 0)throw new Error(`Track ${o.name??o.id} visits unknown node ${r}`);s=L(r)?-i:i,n.set(r,s)}return s})})}var ba=20;function xa(e){let t={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},{rectangles:n,verticalRectangles:o,curves:r}=e.shapes;for(let s of[n,o,r])for(let{xStart:i,xEnd:a}of s)t.minX=Math.min(t.minX,i,a),t.maxX=Math.max(t.maxX,i,a);return e.nodes.forEach(s=>{s.x!==void 0&&(t.minX=Math.min(t.minX,s.x-9),t.maxX=Math.max(t.maxX,s.x+ba+s.pixelWidth)),s.y!==void 0&&(t.minY=Math.min(t.minY,s.y-10),t.maxY=Math.max(t.maxY,s.y+s.contentHeight+10))}),e.tracks.forEach(s=>{s.path.forEach(i=>{let a=i.y??0;t.maxY=Math.max(t.maxY,a+s.width),t.minY=Math.min(t.minY,a)})}),t}function Nt(e,t){let n=e.nodeMap.get(B(t)),o=n===void 0?void 0:e.nodes[n];if(o===void 0)throw new Error(`Unknown node ${t}`);return o}function rr(e){let t=new Map;return e.nodes.forEach((n,o)=>{t.set(n.name,o)}),t}function sr(e){let t=e.nodes.map(()=>new Set),n=e.nodes.map(()=>new Set),o=r=>{for(let s=0;s<r.indexSequence.length-1;s+=1){let i=Math.abs(r.indexSequence[s]),a=Math.abs(r.indexSequence[s+1]);t[i].add(a),n[a].add(i)}};e.tracks.forEach(o),e.reads.forEach(o),e.nodes.forEach((r,s)=>{r.successors=Array.from(t[s]),r.predecessors=Array.from(n[s])})}function ir(e,t){let n=0,o=0,r=0;t.forEach(s=>{let i=Math.abs(s);if(s<0){let a=e.nodeOrders[i]??=o;a<r&&(r=a),n=a,o=a-1}else{let a=e.nodeOrders[i]??=n;n=a+1,o=a}}),r<0&&Dt(e,-r)}function ya(e,t){let n=0,o=0;for(;n<t.length&&e.nodeOrders[Math.abs(t[n])]===void 0;)n+=1;if(n>=t.length)return null;let r=t[n],s,i;r>=0?(s=e.nodeOrders[r]-1,i=-1):(s=e.nodeOrders[-r]+1,i=1);for(let a=n-1;a>=0;a-=1){let l=Math.abs(t[a]);e.nodeOrders[l]===void 0&&(e.nodeOrders[l]=s,o=Math.min(o,s),s+=i)}return o<0&&Dt(e,-o),n}var wa=-1;function Ma(e){return Array.from(e,t=>t??wa)}function va(e){let t=[...new Set(e.filter(o=>o>=0))].sort((o,r)=>o-r),n=new Map(t.map((o,r)=>[o,r]));return e.map(o=>n.get(o)??o)}function Pt(e){let t,n,o,r,s=0,i=e.tracks.concat(e.reads),a={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}),ir(e,e.tracks[0].indexSequence);for(let l=1;l<i.length;l+=1){if(o=ya(e,i[l].indexSequence),o===null){l<e.tracks.length?ir(e,i[l].indexSequence):(i.splice(l,1),e.reads.splice(l-e.tracks.length,1),l-=1);continue}for(t=ka(i[l].indexSequence);o<t.length;){for(r=o,o+=1;o<t.length&&e.nodeOrders[t[o]]===void 0;)o+=1;if(o<t.length){n=e.nodeOrders[t[r]]+1;for(let c=r+1;c<o;c+=1)e.nodeOrders[t[c]]=n,n+=1;if(e.nodeOrders[t[o]]>e.nodeOrders[t[r]])e.nodeOrders[t[o]]<n&&ar(e,t[o],t[o-1],n);else if(i[l].indexSequence[o]>=0&&!Sa(e,t[o],t[r],a))ar(e,t[o],t[o-1],n);else if(i[l].indexSequence[r]<0||e.nodes[t[r+1]].degree<2&&e.nodeOrders[t[o]]<e.nodeOrders[t[r]]){n=e.nodeOrders[t[r]]-1;for(let c=r+1;c<o;c+=1)e.nodeOrders[t[c]]=n,s=Math.min(s,n),n-=1}}else if(i[l].indexSequence[r]>=0){n=e.nodeOrders[t[r]]+1;for(let c=r+1;c<t.length;c+=1){let f=t[c];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,n+=1)}}else{n=e.nodeOrders[t[r]]-1;for(let c=r+1;c<t.length;c+=1){let f=t[c];e.nodeOrders[f]===void 0&&(e.nodeOrders[f]=n,s=Math.min(s,n),n-=1)}}}}s<0&&Dt(e,-s),e.nodeOrders=va(Ma(e.nodeOrders)),e.nodes.forEach((l,c)=>{l.order=e.nodeOrders[c]})}function Sa(e,t,n,o){o.generation+=1;let{stamp:r,generation:s}=o,i=[t];for(r[t]=s;i.length>0;){let a=i.pop();if(a===n)return!0;for(let l of e.nodes[a].successors)r[l]!==s&&(r[l]=s,i.push(l))}return!1}function Ea(e){let t=-1;return e.nodeOrders.forEach(n=>{n!==void 0&&n>t&&(t=n)}),t}function ka(e){return e.map(t=>Math.abs(t))}function Dt(e,t){e.nodeOrders.forEach((n,o)=>{n!==void 0&&(e.nodeOrders[o]=n+t)})}function ar(e,t,n,o){let r=new Map,s=[[t,o]],i=0;for(;i<s.length;){let[a,l]=s[i];i+=1;let c=e.nodeOrders[a];c!==void 0&&c<l&&(r.get(a)??-1/0)<l&&(r.set(a,l),e.nodes[a].successors.forEach(f=>{e.nodeOrders[f]>c&&f!==n&&s.push([f,l+1])}),a!==t&&e.nodes[a].predecessors.forEach(f=>{e.nodeOrders[f]>c&&f!==n&&s.push([f,l+1])}))}r.forEach((a,l)=>{e.nodeOrders[l]=a})}function Ra(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 Ta(e){_a(e,[...e.tracks.slice(1),...e.reads],e.tracks[0])}function _a(e,t,n){let o=new Int32Array(e.nodes.length),r=new Uint8Array(e.nodes.length);for(let s of n.sequence){let i=L(s)?void 0:e.nodeMap.get(s);i!==void 0&&(r[i]=1)}for(let s of t){let{sequence:i,indexSequence:a}=s,l=a.length-1;for(let c=0;c<=l;c+=1){let f=Math.abs(a[c]);if(r[f]===1)continue;let u=e.nodes[f].order,d=c>0?e.nodes[Math.abs(a[c-1])].order:void 0,p=c<l?e.nodes[Math.abs(a[c+1])].order:void 0,m=L(i[c])?1:-1;(d===void 0||d<u)&&(p===void 0||u<p)&&(o[f]+=m),(d===void 0||d>u)&&(p===void 0||u>p)&&(o[f]-=m)}}for(let s of t){let{sequence:i,indexSequence:a}=s;for(let l=0;l<a.length;l+=1)o[Math.abs(a[l])]>0&&(i[l]=Ct(i[l]),a[l]=-a[l])}e.nodes.forEach((s,i)=>{o[i]>0&&(s.seq=Xt(s.seq),s.switched=!0)})}function Oa(e){let t=0,n=20,o=-1,r=e.nodes.slice();r.sort(Ft);let s=Na(e);r.forEach(i=>{i.order>=0&&(i.order>o&&(o=i.order,t=n+10*s[i.order]),i.x=t,n=Math.max(n,t+40+i.pixelWidth))})}var It=35;function Aa(e){return e<=It?e/17.5:It/17.5*Math.sqrt(e/It)}function Na(e){let t=e.maxOrder+1,n=new Array(t).fill(0),o=new Array(t).fill(0),r=new Array(t).fill(0),s=[];e.tracks.forEach(i=>{for(let a=1;a<i.path.length;a+=1){let l=i.path[a],c=i.path[a-1];l.order===c.order?l.isForward?n[l.order]+=1:o[l.order]+=1:r[l.order]=Math.max(Aa(Math.abs((l.y??0)-(c.y??0))),r[l.order])}}),s.push(Math.max(0,n[0]-1));for(let i=1;i<=e.maxOrder;i+=1)s.push(Math.max(Math.max(0,n[i]-1)+Math.max(0,o[i-1]-1),r[i]));return s}function Pa(e){e.assignments=Array.from({length:e.maxOrder+1},()=>[]);let t=new Map;e.tracks.forEach((n,o)=>{n.path=xr(e,n),n.path.forEach(({order:r,node:s},i)=>{let a={trackID:o,segmentID:i},l=s===null?void 0:t.get(s);if(l===void 0){let c={node:s,tracks:[a]};e.assignments[r].push(c),s!==null&&t.set(s,c)}else l.tracks.push(a)})});for(let n=0;n<=e.maxOrder;n+=1)Ca(e,e.assignments[n],n)}function Ia(e,t,n){t.forEach(o=>{let r=0;o.tracks.forEach(s=>{let i=$a(e.tracks[s.trackID].path,s.segmentID,n-1);s.idealLane=i===void 0?s.trackID:i.lane,s.idealY=i===void 0?null:i.y,r+=s.idealLane}),o.idealLane=r/o.tracks.length})}function $a(e,t,n){if(t!==0)return e[t-1].order===n?e[t-1]:e[t+1]?.order===n?e[t+1]:e.slice(0,t).findLast(o=>o.order===n)}function Ca(e,t,n){let o=0,r=new Set,s=20,i=!1,a=-1;Ia(e,t,n),t.sort(cr),t.forEach(l=>{let c=l.node===null?void 0:e.nodes[l.node];c!==void 0?(i&&(s-=10),c.y=s,c.contentHeight=0,i=!1):(i?s-=25:s>20&&(s-=10),i=!0),l.tracks.sort(cr),l.tracks.forEach(f=>{let{path:u,width:d}=e.tracks[f.trackID];f.trackID===a&&c===void 0&&i&&(s+=10),u[f.segmentID].lane=o,u[f.segmentID].y=s,typeof f.idealY=="number"&&r.add(f.idealY-s),o+=1,s+=d,c!==void 0&&(c.contentHeight+=d),a=f.trackID}),s+=25}),La(e,t,r)}function La(e,t,n){let o=0,r=Number.MAX_SAFE_INTEGER;n.forEach(s=>{let i=Xa(e,t,s);i<r&&(r=i,o=s)}),t.forEach(s=>{s.node!==null&&(e.nodes[s.node].y+=o),s.tracks.forEach(i=>{let a=e.tracks[i.trackID].path[i.segmentID];a.y=a.y+o})})}function Ba(e,t,n){t.order<0||e.assignments[t.order]===void 0||(e.assignments[t.order].forEach(o=>{if(o.node!==null){let r=e.nodes[o.node];r!==t&&r.y>t.y&&(r.y+=n,o.tracks.forEach(s=>{let i=e.tracks[s.trackID].path[s.segmentID];i.y=i.y+n}))}else o.tracks.forEach(r=>{let s=e.tracks[r.trackID].path[r.segmentID];s.y>=t.y&&(s.y=s.y+n)})}),e.nodesPerOrder[t.order].forEach(o=>{let r=e.nodes[o];r!==t&&r.y>t.y&&(r.y+=n)}))}function Xa(e,t,n){let o=0;return t.forEach(r=>{r.tracks.forEach(s=>{let{type:i,path:a,width:l}=e.tracks[s.trackID];typeof s.idealY=="number"&&i!=="read"&&(o+=Math.abs(s.idealY-n-a[s.segmentID].y)*l)})}),o}function cr(e,t){return e.idealLane===void 0||t.idealLane===void 0?+(e.idealLane===void 0)-+(t.idealLane===void 0):e.idealLane-t.idealLane}function Ft(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 Da(e){let n=e.config.trackWidth;if(e.config.freqWidth==="linear"){for(let o of e.tracks)o.width=o.type==="read"?4:Math.max(1,Math.round(o.freq??1))*n;return}for(let o of e.tracks)o.width=o.freq!==void 0?Math.round((Math.log(Math.max(o.freq,1))+1)*4):o.type==="read"?4:n;e.tracks.every(o=>o.width===4)&&e.tracks.forEach(o=>{o.freq!==void 0&&(o.width=n)})}function lr(e,t,n){let o=e.nodes[t.node];return wr(o,t.isForward?n:o.sequenceLength-n)}function yr(e,t){return t>e.sequenceLength?null:wr(e,t)}function wr(e,t){let[n,o]=ja(e);if(e.sequenceLength===0)return n;let r=Math.min(Math.max(t,0),e.sequenceLength);return n+r/e.sequenceLength*(o-n)}function Fa(e){e.extraLeft=new Array(e.maxOrder+1).fill(0),e.extraRight=new Array(e.maxOrder+1).fill(0);let t=[],n=[];e.nodes.forEach(r=>{r.x!==void 0&&(t[r.order]=r.x,n[r.order]=Math.max(n[r.order]??-1/0,r.x+r.pixelWidth))});let o=e.tracks[0];e.tracks.sort(pa),e.tracks.forEach(r=>{let{id:s,name:i,type:a,width:l,path:c}=r,f=(g,y,M)=>{e.shapes.rectangles.push({xStart:Math.min(g,y),yStart:M,xEnd:Math.max(g,y),yEnd:M+l-1,id:s,name:i,type:a})},u=g=>g.isForward?n[g.order]:t[g.order],d=c[0],p=d.y,m=a==="read"?lr(e,d,r.firstNodeOffset??0):d.isForward?t[d.order]-20:n[d.order]+20;for(let g=1;g<c.length;g+=1){let y=c[g-1],M=c[g];if(M.y===p)continue;let x=u(y);x!==m&&f(m,x,p);let w=M.y,v=M.order-y.order;if(v===1||v===-1){let k=v===1?t[M.order]:n[M.order];e.shapes.curves.push({xStart:v===1?x:x+1,yStart:p,xEnd:v===1?k+1:k,yEnd:w,width:l,id:s,name:i,type:a,nodeStart:y.node,nodeEnd:M.node,orderStart:y.order,orderEnd:M.order,...r===o?{reference:!0}:{}}),m=k}else Ua(e,r,y.isForward?1:-1,x,p,w,M.order),m=x;p=w}let h=c[c.length-1],b=a==="read"?lr(e,h,r.finalNodeCoverLength??0):u(h)+(h.isForward?20:-20);f(m,b,p)})}var qa=1e9;function Mr(e,t,n,o){let r=new Map,s=0,i=e.nodes.length,a=(h,b)=>(h+i)*(2*i+1)+b+i,l=e.config.ignoreStrand;for(let[h,b]of t.entries()){let g=Math.max(b.freq??1,1);s+=g;let y=b.indexSequence;if(!(y.length<2))for(let M=0;M<y.length-1;M+=1){let x=y[M],w=y[M+1],v=e.nodes[Math.abs(x)],k=e.nodes[Math.abs(w)],T=l?Math.min(a(x,w),a(-w,-x)):a(x,w),S=r.get(T);S===void 0?r.set(T,{sSigned:x,dSigned:w,sName:x<0?`-${v.name}`:v.name,dName:w<0?`-${k.name}`:k.name,count:g,crossings:g,sourceTrackID:b.sourceTrackID,lastSource:h}):(S.crossings+=g,S.lastSource!==h&&(S.count+=g,S.lastSource=h))}}let c=0;for(let h of r.values())h.crossings>c&&(c=h.crossings);let f=Lt,u=60,d=h=>c<=1?f:f+(u-f)*Math.sqrt(h/c),p=[],m=0;for(let h of r.values()){let b=o+m,g=n==="haplotype"?{count:h.count,total:s}:void 0,y=g===void 0?"":` (${Ha(g)})`,M=h.crossings===h.count?"":`, ${h.crossings.toLocaleString()} crossings`,x=`${h.count.toLocaleString()} ${n}${h.count===1?"":"s"}${y}${M}: Node ${h.sName} \u2192 Node ${h.dName}`;e.coarsenedEdgeMeta.set(b,{count:h.count,label:x});let w=e.nodes[Math.abs(h.sSigned)].sequenceLength;p.push({id:b,sourceTrackID:h.sourceTrackID,type:"read",name:x,sequence:[h.sName,h.dName],indexSequence:[],path:[],width:d(h.crossings),firstNodeOffset:w,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:g}),m+=1}return{bands:p,total:s}}function Ga(e,t){let n=e.trackForRuler===void 0?-1:e.tracks.findIndex(f=>f.name===e.trackForRuler),o=n===-1?0:n,r=e.tracks[o],s=(r.freq??1)-1,i=Ya(e,r),a=e.tracks.filter((f,u)=>u!==o).map(f=>Wa(i,f));if(s>0&&a.push({...r,freq:s}),a.length===0)return;let{bands:l,total:c}=Mr(e,a,"haplotype",t);return l.length>0?{ref:r,bands:l,total:c}:void 0}function Wa(e,t){let n=0;for(let o of t.indexSequence){let r=e[Math.abs(o)];r!==void 0&&r!==0&&(n+=r===Math.sign(o)?1:-1)}return n>=0?t:{...t,sequence:t.sequence.map(Ct).reverse(),indexSequence:t.indexSequence.map(o=>-o).reverse()}}function Ya(e,t){let n=new Int8Array(e.nodes.length);for(let o of t.indexSequence){let r=Math.abs(o);n[r]===0&&(n[r]=Math.sign(o))}return n}function Ha({count:e,total:t}){let n=e/t;return n<.01?"<1%":n>.99&&e<t?">99%":`${Math.round(n*100)}%`}var dr=7;function Ua(e,{width:t,id:n,name:o,type:r},s,i,a,l,c){let f=s===1?e.extraRight:e.extraLeft,u=10*f[c],d=i+s*(u+5),p=dr,m=Math.min(dr,t),h=Math.min(a,l),b=Math.max(a,l),g=s===1?i:d-1,y=s===1?d:i,M=k=>{e.shapes.verticalRectangles.push({xStart:g,yStart:k,xEnd:y,yEnd:k+t-1,id:n,name:o,type:r})};M(a),e.shapes.verticalRectangles.push({xStart:s===1?d+p:d-p-m,yStart:h+t+p-1,xEnd:s===1?d+p+m-1:d-p-1,yEnd:b-p+1,id:n,name:o,type:r}),M(l);let x=d+s*p,w=d+s*(p+m),v=`M ${d} ${b}`;v+=` Q ${x} ${b} ${x} ${b-p}`,v+=` H ${w}`,v+=` Q ${w} ${b+t} ${d} ${b+t}`,v+=" Z ",e.shapes.corners.push({path:v,id:n,name:o,type:r}),v=`M ${d} ${h}`,v+=` Q ${w} ${h} ${w} ${h+t+p}`,v+=` H ${x}`,v+=` Q ${x} ${h+t} ${d} ${h+t}`,v+=" Z ",e.shapes.corners.push({path:v,id:n,name:o,type:r}),f[c]+=1}function ja(e){let t=e.x-4,n=e.x+e.pixelWidth+4;return[t,n]}function fr(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)*De)});break;case"small":e.nodes.forEach(t=>{t.width=t.sequenceLength/100,t.pixelWidth=Math.max(Math.round((t.width-1)*De),0)});break;case"fixed":e.nodes.forEach(t=>{t.width=10,t.pixelWidth=Math.round(t.width*De)});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 ne=0;function ur(e){return{first:new Int32Array(e),count:new Uint8Array(e)}}function D(e,t,n){let o=e.count[t];o===0?(e.first[t]=n,e.count[t]=1):o===1&&e.first[t]!==n&&(e.count[t]=2)}function Me(e,t){return e.count[t]===1?Math.abs(e.first[t]):0}function Va(e){let t=ur(e.nodes.length),n=ur(e.nodes.length),o=new Map,r=u=>{let d=o.get(u);if(d===void 0){let p=e.nodeMap.get(B(u));d=L(u)?-p:p,o.set(u,d)}return d};e.tracks.concat(e.reads).forEach(u=>{let{sequence:d}=u,p=u.type==="haplotype",m=d.length-1,h=ne,b=m>=0?r(d[0]):ne;for(let g=0;g<=m;g+=1){let y=g<m?r(d[g+1]):ne;if(b>0)g>0?(D(t,b,h),h<0&&D(t,b,-h)):p&&D(t,b,ne),g<m?(D(n,b,y),y<0&&D(n,b,-y)):p&&D(n,b,ne);else{let M=-b;g>0?(D(n,M,-h),h>0&&D(n,M,h)):p&&D(n,M,ne),g<m?(D(t,M,-y),y>0&&D(t,M,y)):p&&D(t,M,ne)}h=b,b=y}});let i=new Uint8Array(e.nodes.length);e.nodes.forEach((u,d)=>{Ka(d,t,n)&&(i[d]=1)});let a=new Int32Array(e.nodes.length),l=new Float64Array(e.nodes.length),c=new Float64Array(e.nodes.length);e.nodes.forEach((u,d)=>{if(i[d]!==1){a[d]=d,c[d]=u.sequenceLength;for(let p=d;za(p,t,n);)p=Me(n,p),a[p]=d,l[p]=u.sequenceLength,u.sequenceLength+=e.nodes[p].sequenceLength,u.seq+=e.nodes[p].seq,c[p]=u.sequenceLength}}),e.reads.forEach(u=>{let{sequence:d}=u,p=u.sequenceNew??d.map(M=>({nodeName:M,mismatches:[]})),m=M=>{let x=Math.abs(r(M));return L(M)?e.nodes[a[x]].sequenceLength-c[x]:l[x]},h=d.length-1;u.firstNodeOffset=(u.firstNodeOffset??0)+m(d[0]),u.finalNodeCoverLength=(u.finalNodeCoverLength??0)+m(d[h]);let b=[],g=[],y=[];d.forEach((M,x)=>{let w=Math.abs(r(M)),{mismatches:v}=p[x],k=m(M);if(v.forEach(T=>{T.pos+=k}),i[w]===1&&!L(M)&&x>0)g.at(-1).mismatches.push(...v);else if(i[w]===1&&L(M)&&x<h)y.push(...v);else{let T=e.nodes[a[w]].name,S=L(M)?br(T):T;b.push(S),g.push({nodeName:S,mismatches:y.concat(v)}),y=[]}}),u.sequence=b,u.sequenceNew!==void 0&&(u.sequenceNew=g)}),e.tracks.forEach(u=>{let{sequence:d}=u,p=0;for(let m of d)i[Math.abs(r(m))]===0&&(d[p]=m,p+=1);d.length=p});let f=1;for(let u=1;u<e.nodes.length;u+=1)i[u]===0&&(e.nodes[f]=e.nodes[u],f+=1);e.nodes.length=f}function Ka(e,t,n){let o=Me(t,e);return o!==0&&Me(n,o)!==0}function za(e,t,n){let o=Me(n,e);return o!==0&&Me(t,o)!==0}function Za(e,t){return t.xStart-e.xStart||e.yStart-t.yStart}function qt(e){return[e.nodeStart??-1,e.nodeEnd??-1,e.nodeStart===null?e.orderStart:-1,e.nodeEnd===null?e.orderEnd:-1]}function Ja(e,t){for(let n=0;n<e.length;n+=1){let o=e[n]-t[n];if(o!==0)return o}return 0}var vr=.75,Fe=.8;function Qa(e,t){let n=e[0],o=Math.min(Math.abs(n.xEnd-n.xStart),t);if(o===0)return e.map(()=>0);let r=e.length>5?.4/e.length:0,s=e.map(d=>{let p=Math.abs(d.yEnd-d.yStart),m=p/Math.hypot(p,o)*Math.min(d.width,Fe*vr*o);return Math.max(r,m/(vr*o))}),i=d=>s.reduce((p,m,h)=>p+(d(e[h])?m:0),0),a=i(d=>d.reference===!0),l=i(d=>d.reference!==!0),c=a>Fe?Fe/a:1,f=Fe-a*c,u=l>f?f/l:1;return s.map((d,p)=>d*(e[p].reference?c:u))}function Sr(e,t,{gapWidth:n=1/0}={}){let o=Jo(e.filter(r=>r.type===t),r=>qt(r).join(","));return o.forEach(r=>{r.sort(Za);let s=Qa(r,n),i=.5-s.reduce((a,l)=>a+l,0)/2;r.forEach((a,l)=>{let c=p=>a.xStart+(a.xEnd-a.xStart)*(a.yStart<a.yEnd?1-p:p),f=c(i);i+=s[l];let u=c(i),d=`M ${a.xStart} ${a.yStart}`;d+=` C ${f} ${a.yStart} ${f} ${a.yEnd} ${a.xEnd} ${a.yEnd}`,d+=` V ${a.yEnd+a.width}`,d+=` C ${u} ${a.yEnd+a.width} ${u} ${a.yStart+a.width} ${a.xStart} ${a.yStart+a.width}`,d+=" Z",a.path=d})}),[...o.values()].sort((r,s)=>Ja(qt(r[0]),qt(s[0]))).flat()}function Er(e,t=16){let n=e.match(/[A-Za-z]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=[],r=0,s=0,i=0,a=()=>Number(n[i++]);for(;i<n.length;){let l=n[i++];if(l==="M"||l==="L")r=a(),s=a(),o.push([r,s]);else if(l==="H")r=a(),o.push([r,s]);else if(l==="V")s=a(),o.push([r,s]);else if(l==="C"){let[c,f,u,d,p,m]=[a(),a(),a(),a(),a(),a()];for(let h=1;h<=t;h+=1){let b=h/t,g=1-b,y=g*g*g,M=3*g*g*b,x=3*g*b*b,w=b*b*b;o.push([y*r+M*c+x*u+w*p,y*s+M*f+x*d+w*m])}r=p,s=m}else if(l==="Q"){let[c,f,u,d]=[a(),a(),a(),a()];for(let p=1;p<=t;p+=1){let m=p/t,h=1-m;o.push([h*h*r+2*h*m*c+m*m*u,h*h*s+2*h*m*f+m*m*d])}r=u,s=d}else if(l!=="Z")throw new Error(`flattenPath: unsupported path command ${l}`)}return o}function kr(e){let t=`M ${e.x-9} ${e.y} Q ${e.x-9} ${e.y-9} ${e.x} ${e.y-9}`,n=e.x,o=e.y-9;return e.width>1&&(n+=e.pixelWidth,t+=` L ${n} ${o}`),t+=` Q ${n+9} ${o} ${n+9} ${o+9}`,n+=9,o+=9,e.contentHeight>0&&(o+=e.contentHeight,t+=` L ${n} ${o}`),t+=` Q ${n} ${o+9} ${n-9} ${o+9}`,n-=9,o+=9,e.width>1&&(n-=e.pixelWidth,t+=` L ${n} ${o}`),t+=` Q ${n-9} ${o} ${n-9} ${o-9}`,n-=9,o-=9,e.contentHeight>0&&(o-=e.contentHeight,t+=` L ${n} ${o}`),t}function Gt(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=e.pathVisits,o=n?.replay();return(e.paths??[]).map(r=>{let s=n?.pathIndex(P(r.name).name)??-1;return r.nodeIds.flatMap(i=>{let a=t.get(i);if(!a)return[];let l=n&&o?o(n.slot(a.name),s):-1;return[{node:a,strand:l>=0?n.strand(l):j(a.id)}]})})}function ec(e){let t=Gt(e),n=(e.paths??[]).flatMap((s,i)=>{let a=t[i].map(l=>xt(l.node,l.strand));return a.length>0?[{id:i,name:s.name,sequence:a,sourceTrackID:0,type:"haplotype",...s.members?{freq:s.members.length}:{}}]:[]}),o=Ee(e),r=n.findIndex(s=>P(s.name).name===o);return r>0&&n.unshift(...n.splice(r,1)),n}function tc(e){return e.nodes.map(t=>({name:t.id,seq:"",sequenceLength:Math.max(1,t.length)}))}function Tr(e){return(e.paths?.length??0)>0}var nc=600,oc=3,rc=15;function sc(e){return Math.max(oc,Math.min(rc,Math.floor(nc/Math.max(1,e))))}function ic(e){let t=new Set,n=new Set;for(let o of e?.sequence??[])L(o)?n.has(B(o))||t.add(B(o)):n.add(o);return t}function ac(e,t,n){let o=ic(n[0]),r=new Map;for(let{sequence:l,is_secondary:c}of n)c||l.forEach((f,u)=>{let d=B(f),m=L(f)!==o.has(d)?l[u+1]:l[u-1];!t.nodeMap.has(d)&&m!==void 0&&r.set(d,B(m))});let s=new Map(e.nodes.map(l=>[l.id,Math.max(1,l.length)])),i=new Map([...r].map(([l,c])=>[c,l])),a=new Map;for(let l of i.keys()){let c=t.nodeMap.get(l);if(c!==void 0){let f=[l];for(let d=i.get(l);d!==void 0;d=i.get(d))f.push(d);f.reduce((d,p)=>d+(s.get(p)??0),0)===t.nodes[c].sequenceLength&&a.set(l,f)}}return{members:a,flipped:o}}var cc={start:"end",end:"start"},Rr={"+":"-","-":"+"};function lc(e,{members:t,flipped:n}){if(t.size===0)return e;let o=new Map(e.nodes.map(d=>[d.id,d])),r=new Map,s=new Set,i=(d,p)=>n.has(d)?cc[p]:p;for(let[d,p]of t)p.forEach((m,h)=>{r.set(m,d);let b=p[h+1];b!==void 0&&s.add(`${m}:${i(m,"end")} ${b}:${i(b,"start")}`)});let a=new Set([...r].filter(([d,p])=>d!==p).map(([d])=>d)),l=e.nodes.flatMap(d=>{let p=t.get(d.id);if(!p)return a.has(d.id)?[]:[d];let m=p.map(b=>o.get(b)),h=m.flatMap(b=>b.stable?[b.stable.start]:[]);return[{...d,length:m.reduce((b,g)=>b+g.length,0),stable:d.stable&&{...d.stable,start:Math.min(...h)}}]}),c=(d,p,m)=>i(p,i(d,m))==="end"?j(p):Rr[j(p)],f=e.edges.flatMap(d=>{let p=wn(d),m=`${d.from}:${p.from}`,h=`${d.to}:${p.to}`;if(s.has(`${m} ${h}`)||s.has(`${h} ${m}`))return[];let b=r.get(d.from),g=r.get(d.to);return[{...d,...b===void 0?{}:{from:b,fromStrand:c(d.from,b,p.from)},...g===void 0?{}:{to:g,toStrand:Rr[c(d.to,g,p.to)]}}]}),u=new Set([...a].map(d=>o.get(d)?.name??d));return{...e,nodes:l,edges:f,paths:e.paths?.map(d=>({...d,nodeIds:d.nodeIds.filter(p=>!a.has(p))})),pathVisits:e.pathVisits?.filter(()=>!0,d=>!u.has(d))}}function _r(e){let t=e.paths??[],n=ec(e),o=e.reads?To(e,e.reads,t.length):[],r=o.length>0?Tn:Rn,s=t.map((f,u)=>r(u,t.length)),i=t.some(f=>f.members),a=t.reduce((f,u)=>f+(u.members?.length??1),0),l=hr(tc(e),n,o,{nodeWidthOption:"compressed",trackWidth:sc(i?a:n.length),...i?{freqWidth:"linear"}:{}});if(!l)return;let c=ac(e,l,[...n,...o]);return{layout:l,pathColors:s,members:c.members,graph:lc(e,c)}}function Wt(e){let t=[];return e.nodes.forEach(n=>{n.order>=0&&t.push(n)}),t}function Or(e,t,n,o){let r=e.y+e.contentHeight/2-t;return[{x:n,y:r},{x:o,y:r}]}function Ar(e,t){return{minY:e.bounds.minY-t,maxY:e.bounds.maxY-t}}function Zh(e){let t=Tr(e)?_r(e):void 0;if(!t)return;let{layout:n,...o}=t,r=n.bounds.minY,s={};for(let l of Wt(n))s[l.name]=Or(l,r,l.x,l.x+l.pixelWidth);let{minY:i,maxY:a}=Ar(n,r);return{nodePositions:s,tubeMap:{layout:n,yOffset:r,...o},extent:{minX:n.bounds.minX,maxX:n.bounds.maxX,minY:i,maxY:a}}}function dc(e,t){let n=new Map(e.nodes.map(a=>[a.id,a])),o=on(Wt(t),a=>a.order),r=[],s=-1/0;for(let a of[...o.keys()].sort((l,c)=>l-c)){let l=o.get(a),c=1/0,f=-1/0;for(let u of l){let d=n.get(u.name);d&&N(d)&&(c=Math.min(c,d.stable.start),f=Math.max(f,d.stable.start+d.length))}c===1/0&&(c=f=s),c<s&&(c=s,f=Math.max(s,f)),s=Math.max(s,f),r.push({order:a,x0:Math.min(...l.map(u=>u.x)),x1:Math.max(...l.map(u=>u.x+u.pixelWidth)),bp0:c,bp1:f})}let i=r.find(a=>a.bp0!==-1/0);for(let a of r)a.bp0===-1/0&&(a.bp0=a.bp1=i?.bp0??0);return r}function fc(e){return Tr(e)&&e.nodes.some(N)}function Jh(e){let t=fc(e)?_r(e):void 0;if(!t)return;let{layout:n,...o}=t,r=dc(o.graph,n),s=new Map(r.map(l=>[l.order,l])),i=n.bounds.minY,a={};for(let l of Wt(n)){let c=s.get(l.order);a[l.name]=Or(l,i,c.bp0,c.bp1)}return{nodePositions:a,tubeMap:{layout:n,yOffset:i,columns:r,...o},referenceAxis:!0,pixelRows:!0,extent:Ar(n,i)}}function uc(e,t){let n=[],o=()=>({a:-1/0,b:1/0,detour:[],bp:0}),r=[o()];for(let{node:s,strand:i}of t){let a=r.at(-1),l=n.at(-1);if(N(s)){let c=s.stable.start,f=c+s.length,u=i!==(s.stable.strand??"+"),d=l!==void 0&&a.detour.length===0;d&&!l.inverted&&!u&&l.end===c?l.end=f:d&&l.inverted&&u&&l.start===f?l.start=c:(n.push({start:c,end:f,inverted:u}),r.push(o()))}else a.detour.push({node:s,strand:i}),a.bp+=s.length}return n.forEach((s,i)=>{r[i].b=s.start,r[i+1].a=s.end}),{path:e,runs:n,gaps:r}}function Yt(e,t){return Number.isFinite(e.a)&&Number.isFinite(e.b)&&e.b>=e.a&&Math.max(e.b-e.a,e.bp)<t}function Nr(e,t,n){let o=J(e.length,r=>e[r]<=t);return o<e.length&&e[o]<n}function pc(e){let t=new Map;for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n],s=o.stable.start+o.length;s!==r.stable.start&&(t.set(s,"reference-gap"),t.set(r.stable.start,"reference-gap"))}return t}function hc(e,t,n){let o=(s,i)=>{Number.isFinite(s)&&!n.has(s)&&n.set(s,i)};for(let{runs:s,gaps:i}of e){let a=s[0],l=s.at(-1);a&&l&&(o(a.start,"walk-end"),o(l.end,"walk-end"));for(let c of s)c.inverted&&c.end-c.start>=t&&(o(c.start,"inversion"),o(c.end,"inversion"));for(let c of i)c.b<c.a?(o(c.a,"backward"),o(c.b,"backward")):Yt(c,t)||(o(c.a,"variant"),o(c.b,"variant"))}let r=e.flatMap(({runs:s,gaps:i})=>[...i.filter(a=>Yt(a,t)).map(a=>[a.a,a.b]),...s.filter(a=>a.inverted&&a.end-a.start<t).map(a=>[a.start,a.end])]);for(let s=!0;s;){s=!1;let i=[...n.keys()].sort((a,l)=>a-l);for(let[a,l]of r)Nr(i,a,l)&&(s||=!n.has(a)||!n.has(l),o(a,"overlap"),o(l,"overlap"))}return n}function mc(e,t){let n=[],o=[],r=()=>{let s=o[0],i=o.at(-1);if(s&&i){let a=s.stable.start,l=i.stable.start+i.length,c=`${a}-${l}`;n.push({node:{id:`${c}+`,name:c,length:l-a,depth:0,stable:{refName:s.stable.refName,start:a,rank:0,strand:"+"}},members:o})}o=[]};for(let s of e)t.has(s.stable.start)&&r(),o.push(s);return r(),n}function Ht(e,t,n){return Math.max(0,J(e.length,o=>t(e[o])<=n)-1)}function sm(e,t){let n=e.nodes.filter(N).sort((x,w)=>x.stable.start-w.stable.start),o=e.paths??[];if(n.length===0||o.length===0)return;let r=Gt(e),s=o.map((x,w)=>uc(x,r[w])),i=hc(s,t,pc(n)),a=[...i.keys()].sort((x,w)=>x-w),l=mc(n,i),c=x=>Ht(l,w=>w.node.stable.start,x),f=new Map,u=new Map;for(let x of l){f.set(x.node.id,x.members.map(w=>w.id));for(let w of x.members)u.set(w.id,x.node.id)}let d=new Map,p=x=>{let w=`${x.a} ${x.b} ${x.detour.map(k=>k.node.id+k.strand).join(",")}`,v=d.get(w);if(!v){let k=`r${d.size}`;v={id:`${k}+`,name:k,length:x.bp,depth:0,stable:{refName:n[0].stable.refName,start:Number.isFinite(x.a)?x.a:x.b,rank:1,strand:"+"}},d.set(w,v),f.set(v.id,x.detour.map(T=>T.node.id));for(let T of x.detour)u.has(T.node.id)||u.set(T.node.id,v.id)}return v},m=new Map,h=[],b=new ln,g=new Map,y=new Map;for(let{path:x,runs:w,gaps:v}of s){let k=[],T=[],S=!1,_=(R,X)=>{let $=k.at(-1);S&&$?.node===R&&$.strand===X||k.push({node:R,strand:X}),S=!0},O=R=>{S=!1,R.detour.length>0&&(_(p(R),"+"),S=!1)},G=R=>{(R.bp>0||R.b>R.a)&&T.push({start:R.a,end:R.b,bp:R.bp});let X=l[c(R.b>R.a?R.a:R.a-1)];for(let $ of R.detour)u.has($.node.id)||(u.set($.node.id,X.node.id),f.get(X.node.id).push($.node.id))};w.forEach((R,X)=>{let $=v[X];Yt($,t)&&!Nr(a,$.a,$.b)?G($):O($);let U=c(R.start),fe=c(R.end-1),ve=R.end-R.start<t;if(R.inverted&&!ve){S=!1;for(let Z=fe;Z>=U;Z--)_(l[Z].node,"-");S=!1}else{R.inverted&&T.push({start:R.start,end:R.end,bp:R.end-R.start,inverted:!0});for(let Z=U;Z<=fe;Z++)_(l[Z].node,"+")}}),O(v.at(-1));let z=P(x.name).name,H=0;k.forEach(({node:R,strand:X},$)=>{y.set(R.id,(y.get(R.id)??0)+1),b.add(R.name,z,x.sample??z,H,X==="-"),H+=R.length;let U=k[$+1];if(U){let fe=`${R.id}${X} ${U.node.id}${U.strand}`,ve=g.get(fe);ve?ve.pathIds.push(x.name):g.set(fe,{from:R.id,to:U.node.id,fromStrand:X,toStrand:U.strand,pathIds:[x.name]})}}),h.push({...x,nodeIds:k.map(R=>R.node.id)}),m.set(x.name,T)}let M=[...l.map(x=>x.node),...d.values()].filter(x=>y.has(x.id)).map(x=>({...x,depth:y.get(x.id)}));return{graph:{...e,nodes:M,edges:[...g.values()],paths:h,pathVisits:b.build(),reads:void 0},members:f,coarseOf:u,deviations:m,cuts:i}}function cm(e,t){return t?e.filter(n=>t.includes(n.sample)).sort((n,o)=>t.indexOf(n.sample)-t.indexOf(o.sample)||n.label.localeCompare(o.label)):e}function lm(e,t,n,o={}){let r=pn(e,t,o);return r&&hn(r,n)}function gc(e,t,n){let o=Ht(e,r=>r.bp0,t);return[e[o],e[o-1]].find(r=>r&&n.has(r.index)&&r.bp0<=t&&t<=r.bp1)}function bc(e,t){let n=new Map;for(let[r,s]of t)for(let i of s)re(n,P(r).name,i);let o=new Map;for(let r of e.paths??[])if(r.members){let s=new Map;for(let i of r.members.flatMap(a=>n.get(a)??[]))s.set(`${i.start}-${i.end}`,i);o.set(r.name,[...s.values()])}else o.set(r.name,t.get(r.name)??[]);return o}function Cm(e,t){let{graph:n,layout:o}=e,r=[...At(e).values()].flat().sort((a,l)=>a.bp0-l.bp0),s=bc(n,t),i=[];for(let a of o.tracks){let l=a.name?s.get(a.name):void 0;if(l?.length){let c=new Map;for(let f of a.path)f.node!==null&&f.y!==void 0&&!c.has(f.node)&&c.set(f.node,f.y);for(let f of l){let u=gc(r,f.start,c);u&&i.push({x0:we(u,f.start),x1:we(u,f.end),y:c.get(u.index),height:a.width})}}}return i}function xc(e){return e?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.8)"}function Lm(e,t,{x:n,y:o,width:r,darkMode:s}){if(t.length!==0){e.fillStyle=xc(s),e.beginPath();for(let i of t){let a=n(i.x0),l=Math.max(n(i.x1),a+1);if(l>=0&&a<=r){let c=o(i.y);e.rect(a,c,l-a,o(i.y+i.height)-c)}}e.fill()}}function yc(e,t){let n=[],o=e.sequenceNew??[],r=e.path.filter(s=>s.node!==null);return o.forEach((s,i)=>{let a=t.nodeMap.get(B(s.nodeName)),l=a===void 0?void 0:t.nodes[a],c=r[i];if(l&&c?.y!==void 0){let f={readId:e.id,y:c.y,height:e.width},u=d=>yr(l,d);for(let d of s.mismatches){let p=c.isForward?d:Bt(d,l.sequenceLength),m=u(p.pos);if(m!==null){if(p.type==="insertion")n.push({...f,kind:"insertion",x:m,seq:p.seq});else if(p.type==="deletion"&&p.length!==void 0){let h=u(p.pos+p.length);h!==null&&n.push({...f,kind:"deletion",x0:m,x1:h,length:p.length})}else if(p.type==="substitution"&&p.seq!==void 0){let h=u(p.pos+p.seq.length);h!==null&&n.push({...f,kind:"substitution",x0:m,x1:h,seq:p.seq})}}}}}),n}function Pr(e){return e.reads.flatMap(t=>yc(t,e))}var Ut=24,wc=.5,Mc=e=>e.bp1>e.bp0;function qm(e,t){let n=e.filter(Mc);if(n.length===0){let c=e[0];return c?[{tx:c.x0,sx:t(c.bp0)}]:[]}let o=[],r=[],s=[];n.forEach((c,f)=>{o.push(c.x0,c.x1),r.push(t(c.bp0),t(c.bp1)),s.push(f===0?0:Math.min(c.x0-n[f-1].x1,Ut),0)});let i=r.at(-1)-r[0],a=s.reduce((c,f)=>c+f,0),l=a>0?Math.min(1,wc*i/a):1;return vc(r,s,l).map((c,f)=>({tx:o[f],sx:c}))}function vc(e,t,n){let o=[],r=0;for(let i of t)r+=i*n,o.push(r);let s=[];return e.forEach((i,a)=>{let l={mean:i-o[a],n:1},c=s.at(-1);for(;c&&c.mean>=l.mean;){s.pop();let f=c.n+l.n;l={mean:(c.mean*c.n+l.mean*l.n)/f,n:f},c=s.at(-1)}s.push(l)}),s.flatMap(i=>Array(i.n).fill(i.mean)).map((i,a)=>i+o[a])}function Gm(e,t){let n=e.length;if(n===0)return t;let o=e[0],r=e[n-1];if(t<=o.tx)return o.sx+(t-o.tx);if(t>=r.tx)return r.sx+(t-r.tx);let s=1+J(n-2,c=>e[c+1].tx<=t),i=e[s-1],a=e[s],l=a.tx-i.tx;return l>0?i.sx+(t-i.tx)/l*(a.sx-i.sx):i.sx}function Kt(e){let t=e.trim().split(/[\s,]+/),n=[],o=0,r=()=>Number(t[o++]);for(;o<t.length;){let s=t[o++];s==="M"||s==="L"?n.push({op:s,x:r(),y:r()}):s==="H"?n.push({op:s,x:r()}):s==="V"?n.push({op:s,y:r()}):s==="Q"?n.push({op:s,x1:r(),y1:r(),x:r(),y:r()}):s==="C"?n.push({op:s,x1:r(),y1:r(),x2:r(),y2:r(),x:r(),y:r()}):s==="Z"&&n.push({op:s})}return n}function Lr(e){let t=1/0,n=-1/0;for(let o of e)"x"in o&&(t=Math.min(t,o.x),n=Math.max(n,o.x)),"x1"in o&&(t=Math.min(t,o.x1),n=Math.max(n,o.x1));return{x0:t,x1:n}}function Ir(e,t,n,o,r){let s=Kt(e);return{commands:s,outline:Er(e,12),color:t,id:n,haplotype:o,reference:r,...Lr(s)}}function Br(e,t){return new Map(e.tracks.map(n=>[n.id,n.type==="read"?_o(n):t[n.id]]))}function $r(e,t,n,o,r){let{shapes:s}=e,i=t==="haplotype",a=d=>n.get(d.id),l=d=>i&&o.has(d.id),c=[...s.rectangles,...s.verticalRectangles].filter(d=>d.type===t).map(d=>({color:a(d),id:d.id,haplotype:i,reference:l(d),x0:d.xStart,x1:d.xEnd+1,y0:d.yStart,y1:d.yEnd+1})),f=Sr(s.curves,t,{gapWidth:r}).map(d=>Ir(d.path,a(d),d.id,i,l(d))),u=s.corners.filter(d=>d.type===t).map(d=>Ir(d.path,a(d),d.id,i,l(d)));return{rects:c,shapes:[...f,...u]}}function Sc(e){let t=new Set,n=e&&Ee(e);return e?.paths?.forEach((o,r)=>{P(o.name).name===n&&t.add(r)}),t}function Ec({layout:e,pathColors:t,graph:n,columns:o}){let r=Br(e,t),s=Sc(n),i=o?Ut:void 0,a=[];return e.nodes.forEach(l=>{if(l.order>=0){let c=Kt(kr(l));a.push({name:l.name,commands:c,...Lr(c)})}}),{bounds:e.bounds,layers:[$r(e,"haplotype",r,s,i),$r(e,"read",r,s,i)],nodes:a,mismatches:Pr(e)}}function jt(e,t,n,o){let r=0,s=0;for(let i of t)switch(i.op){case"M":r=i.x,s=i.y,e.moveTo(n(r),o(s));break;case"L":r=i.x,s=i.y,e.lineTo(n(r),o(s));break;case"H":r=i.x,e.lineTo(n(r),o(s));break;case"V":s=i.y,e.lineTo(n(r),o(s));break;case"Q":r=i.x,s=i.y,e.quadraticCurveTo(n(i.x1),o(i.y1),n(r),o(s));break;case"C":r=i.x,s=i.y,e.bezierCurveTo(n(i.x1),o(i.y1),n(i.x2),o(i.y2),n(r),o(s));break;case"Z":e.closePath();break}}function Cr(e,t,n,o,r){let s=new Map;for(let i of t)n(i)&&re(s,o(i),i);for(let i of s.values()){e.fillStyle=o(i[0]),e.beginPath();for(let a of i)r(a);e.fill()}}var kc=12,Rc=.15;function Tc(e){return Math.max(Rc,Math.min(1,e/kc))}var _c=.55;function Oc(e,t,n){let{x:o,y:r,width:s}=n,i=f=>o(f.x1)>=0&&o(f.x0)<=s,a=f=>f.haplotype&&n.tubeColors?.[f.id]||f.color;e.globalAlpha=1;for(let f of t.layers)for(let u of[!1,!0]){let d=p=>p.reference===u;Cr(e,f.rects,p=>d(p)&&i(p),a,p=>{let m=o(p.x0),h=r(p.y0);e.rect(m,h,o(p.x1)-m,r(p.y1)-h)}),Cr(e,f.shapes,p=>d(p)&&i(p),a,p=>{jt(e,p.commands,o,r)})}let l=n.darkMode?"#d0d0d0":"#000000",c=n.darkMode?"rgba(40,40,40,0.4)":"rgba(255,255,255,0.4)";e.lineWidth=Xr(n);for(let f of t.nodes)if(i(f)&&f.name!==n.highlightNode){e.beginPath(),jt(e,f.commands,o,r);let u=n.nodeColors?.get(f.name);e.fillStyle=u??c,e.strokeStyle=l,e.globalAlpha=u?_c:1,e.fill(),e.globalAlpha=Tc(o(f.x1)-o(f.x0)),e.stroke(),e.globalAlpha=1}qe(e,t,n),Nc(e,t.mismatches,n)}function Xr(e){return 2*Math.max(.25,Math.min(1,e.yScale))}function qe(e,t,n){let o=n.highlightNode?t.nodes.find(r=>r.name===n.highlightNode):void 0;o&&(e.beginPath(),jt(e,o.commands,n.x,n.y),e.globalAlpha=1,e.lineWidth=Xr(n),e.fillStyle="rgba(255,192,203,0.5)",e.strokeStyle="#ff0000",e.fill(),e.stroke())}var Dr=12,Ac=6;function zt(e){return Dr*e>=Ac}function Vt(e,{x:t,width:n}){let[o,r]=e.kind==="insertion"?[e.x,e.x]:[e.x0,e.x1];return t(r)>=0&&t(o)<=n}function Nc(e,t,n){let{x:o,y:r,yScale:s,darkMode:i}=n;if(!zt(s)||t.length===0)return;let a=Dr*s;e.fillStyle="grey",e.beginPath();for(let l of t)if(l.kind==="deletion"&&Vt(l,n)){let c=o(l.x0),f=r(l.y);e.rect(c,f,o(l.x1)-c,r(l.y+l.height)-f)}e.fill(),e.font=`${a}px monospace`,e.textAlign="left",e.textBaseline="alphabetic",e.fillStyle=i?"#ffffff":"#000000";for(let l of t)Vt(l,n)&&(l.kind==="substitution"?e.fillText(l.seq,o(l.x0)+1,r(l.y+l.height)):l.kind==="insertion"&&e.fillText("*",o(l.x)-3,r(l.y+l.height)))}function Pc(e,t,n){let o=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){let[i,a]=e[r],[l,c]=e[s];a>n!=c>n&&t<(l-i)*(n-a)/(c-a)+i&&(o=!o)}return o}function Ic(e,{x:t,y:n},o,r){for(let s=e.layers.length-1;s>=0;s--){let{rects:i,shapes:a}=e.layers[s];for(let l of[!0,!1]){for(let c of i)if(c.reference===l&&t(c.x0)<=o&&o<=t(c.x1)&&n(c.y0)<=r&&r<=n(c.y1))return c.id;for(let c of a)if(c.reference===l&&t(c.x0)<=o&&o<=t(c.x1)&&Pc(c.outline.map(([f,u])=>[t(f),n(u)]),o,r))return c.id}}}var $c=4;function Cc(e,t,n,o){let{x:r,y:s,yScale:i}=t;return zt(i)?e.mismatches.find(a=>s(a.y)<=o&&o<=s(a.y+a.height)&&(a.kind==="insertion"?Math.abs(r(a.x)-n)<=$c:r(a.x0)<=n&&n<=r(a.x1))):void 0}var oe=JBrowseExports["@jbrowse/core/util/groupKeys"],Lc=e=>oe!=null&&e in Object(oe)?oe[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/core/util/groupKeys' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var Ge=Lc("groupKeyComparator");var Yg=oe&&oe.__esModule?oe.default:oe;var We=16;function Vg(e){let[t="",...n]=e.split(/\r\n|\r|\n/),o=t.split(" ").slice(1),r=new Map;for(let s of n){if(!s)continue;let[i="",...a]=s.split(" ");i&&!r.has(i)&&r.set(i,{...Object.fromEntries(o.map((l,c)=>[l,a[c]??""])),name:i})}return[...r.values()]}function Kg(e){let t=new Set;for(let n of e??[])for(let o of Object.keys(n))o!=="name"&&t.add(o);return[...t]}function zg(e){if(typeof e=="string")return e?{field:e}:void 0;let{field:t,sort:n,domain:o}=e??{};if(typeof t!="string"||!t)return;let r=n??o;return Array.isArray(r)?{field:t,sort:r.filter(s=>typeof s=="string")}:{field:t}}function Zt(e,t){return`${e} ${t}${e===1?"":"s"}`}function Jt(e,t){let n=new Map(t.map(o=>[o.name,o[e]??""]));return(o,r)=>n.get(o)||n.get(r)||""}function Qt(e,t,{field:n,sort:o},r,s){let i=new Map;for(let a of e){let l=t(a),c=i.get(l);c?c.push(a):i.set(l,[a])}return[...i.keys()].sort(Ge(o)).map(a=>{let l=i.get(a),c=new Set(l.map(s)).size;return{key:a,members:l,title:`${a||`${n}: none`} \xB7 ${Zt(c,r)}`}})}function Zg(e,t,n){let o=Jt(n.field,t),r=Qt(e,a=>o(a.label,a.sample),n,"haplotype",a=>a.label),s=1,i=r.map(({key:a,members:l,title:c})=>{let f={key:a,title:c,first:s,count:l.length};return s+=l.length,f});return{rows:r.flatMap(a=>a.members),sections:i}}function Jg(e,t){let n=r=>{let s=-1;for(;s+1<e.length&&e[s+1].first<=r;)s++;return s},o=r=>r*t+(n(r)+1)*We;return{rowY:o,headers:e.map((r,s)=>({...r,top:(r.first-.5)*t+s*We})),headersPx:e.length*We,rowAt(r,s){let i=0;for(let a=-1;a<e.length;a++){let l=a<0?0:e[a].first,c=a<0?Math.min(s,e[0]?.first??s):l+e[a].count,f=(a+1)*We,u=Math.min(c-1,Math.max(l,Math.round((r-f)/t)));Math.abs(o(u)-r)<Math.abs(o(i)-r)&&(i=u)}return i}}}function Qg(e,t,n,o,r){return t.length===0?[ye(e,o,r)]:[ye({...e,rows:[]},o,r),...t.flatMap((s,i)=>ye({...e,rows:e.rows.slice(s.first-1,s.first-1+s.count)},{...o,translateY:o.translateY+(n(s.first)-o.rowPx)*o.scaleY},{...r,idPrefix:`${r.idPrefix}-s${i}`}).children.filter(l=>typeof l!="string"&&l.attrs["data-testid"]!=="graph-walk-reference"))]}function Bc(e,t,n,o){let r=[],s=[],i=[e];for(o.add(e);i.length>0;){let a=i.pop(),l=t.get(a);if(l){r.push(l);for(let c of n.get(a)??[]){let f=t.get(c);f&&(f.stable.rank===He?s.push(f):o.has(c)||(o.add(c),i.push(c)))}}}return{members:r,anchors:s}}function Xc(e){if(new Set(e.map(a=>a.stable.refName)).size!==1||e.length<2)return;let n=[...e].sort((a,l)=>a.stable.start-l.stable.start),o=n[0],r=n.at(-1),s=o.stable.start+o.length,i=r.stable.start;return i>=s?{start:s,end:i,entry:o}:void 0}function Dc(e,t,n){let o=new Map(e.map(i=>[i.id,i])),r=new Map,s=[];for(let i of n.get(t.id)??[])o.has(i)&&(r.set(i,0),s.push(i));if(s.length===0)for(let i of e)r.set(i.id,0),s.push(i.id);for(let i of s){let a=r.get(i)+o.get(i).length;for(let l of n.get(i)??[])if(o.has(l)){let c=r.get(l);(c===void 0||a<c)&&(r.set(l,a),s.push(l))}}return r}function Fc(e,t,n){let o=Dc(e,t,n),r=[...e].sort((l,c)=>o.get(l.id)-o.get(c.id)),s=new Map(r.map((l,c)=>[l.id,c])),i=new Map(e.map(l=>[l.id,l])),a=new Map;for(let[l,c]of r.entries()){let f=0;for(let u of n.get(c.id)??[]){let d=i.get(u);d&&s.get(u)<l&&(f=Math.max(f,a.get(u)+d.length))}a.set(c.id,f)}return{offsets:a,ordered:r}}function qc(e){let t=new Map(e.nodes.filter(rn).map(s=>[s.id,s])),n=Re(e),o=new Set,r=[];for(let s of t.values())if(s.stable.rank!==He&&!o.has(s.id)){let{members:i,anchors:a}=Bc(s.id,t,n,o),l=Xc(a);if(l){let{offsets:c,ordered:f}=Fc(i,l.entry,n);r.push({start:l.start,refSpan:l.end-l.start,nodeIds:f.map(u=>u.id),nodeOffsets:f.map(u=>c.get(u.id)),pathLength:f.reduce((u,d)=>Math.max(u,c.get(d.id)+d.length),0)})}}return r.sort((s,i)=>s.start-i.start)}var Gc=28,Fr="#4d4d4d",Wc="#5b8cc4",Yc=[Wc,"#82abd9"],T0=["#8c8c8c","#adadad"],Hc="12px sans-serif",_0=[{field:"",label:"None"},{field:"sample",label:"A panel per sample"},{field:"walk",label:"A panel per haplotype"}],q=e=>P(e).name;function O0(e,t,n=Yc){let o=0;return e.map(r=>q(r.name)===t?Fr:n[o++%n.length])}var Uc=["#4e79a7","#f28e2b","#59a14f","#e15759","#b07aa1","#76b7b2","#edc948","#9c755f","#ff9da7","#bab0ac"],qr="#c8c8c8";function A0(e){let t=[...new Set(e)].filter(n=>n!=="").sort(Ge());return new Map(t.map((n,o)=>[n,Uc[o]??qr]))}function N0(e,t,n,o){return e.map(r=>{let s=q(r.name);return s===t?Fr:o.get(n(r.members?.[0]??s))??qr})}function jc(e,t){let n=Jt(e,t);return o=>{let{sample:r,haplotype:s}=ue(o);return n(`${r}#${s}`,r)}}function P0(e,t){let n=(e.paths??[]).map(l=>l.name).filter(l=>q(l)!==e.referencePath);if(t.by==="column"){let l=jc(t.field,t.table);return Qt(n,c=>l(q(c)),t,"sample",c=>ue(q(c)).sample).map(({key:c,members:f,title:u})=>({key:c,paths:f,label:u}))}let o=t.by==="sample"?l=>ue(l).sample:l=>l,r=new Map;for(let l of n){let c=o(q(l)),f=r.get(c);f?f.push(l):r.set(c,[l])}let s=t.sort??[],i=new Map(s.map((l,c)=>[l,c])),a=l=>i.get(l)??s.length;return[...r].map(([l,c],f)=>({key:l,paths:c,i:f})).sort((l,c)=>a(l.key)-a(c.key)||l.i-c.i).map(({key:l,paths:c})=>({key:l,paths:c}))}function I0(e,t){if(e.graph.nodes.some(n=>n.id===t))return t;for(let[n,o]of e.members)if(o.includes(t))return n}function $0(e,t,n,o,r){let s=e.flatMap(u=>{let d=t(u);return d?[{id:u,...d}]:[]});if(s.length===0)return;let i=s.reduce((u,d)=>Math.min(u,d.start),1/0),a=s.reduce((u,d)=>Math.max(u,d.end),-1/0),l=o>n?(r-n)/(o-n):0,c=i+Math.min(1,Math.max(0,l))*(a-i),f=u=>c<u.start?u.start-c:c>=u.end?c-u.end+1:0;return s.reduce((u,d)=>f(d)<f(u)?d:u).id}function C0(e,t){let n=new Set,o=new Set;for(let r of e.paths??[]){let s=q(r.name);if(s!==e.referencePath){let i=r.nodeIds.includes(t);for(let a of r.members??[s])n.add(a),i&&o.add(a)}}return{here:o.size,of:n.size}}var Vc="bold 11px sans-serif",Kc=80,zc=9;function L0(e,t,n,{x:o,y:r,width:s}){let i=n.paths??[];if(!i.some(l=>l.members))return;let a=new Map;i.forEach((l,c)=>{q(l.name)!==n.referencePath&&a.set(c,l.members?.length??1)}),e.font=Vc,e.textAlign="left",e.textBaseline="middle",e.fillStyle="#0b1f3a";for(let l of t.layers[0]?.rects??[]){let c=a.get(l.id),f=Math.max(0,o(l.x0)),u=Math.min(s,o(l.x1)),d=r(l.y0),p=r(l.y1);c!==void 0&&u-f>=Kc&&p-d>=zc&&e.fillText(`\xD7${c}`,f+4,(d+p)/2)}}var Zc="10px sans-serif",Jc=1e3;function B0(e,t,{x:n,y:o,width:r}){if(!t.columns)return;let s=new Map(t.graph.nodes.map(l=>[l.id,l.length]));e.font=Zc;let i=new Map;t.layout.nodes.forEach(l=>{let c=s.get(l.name)??0,f=n(l.x),u=n(l.x+l.pixelWidth),d=I(c);if(l.order>=0&&c>=Jc&&u-f<e.measureText(d).width){let p=(o(l.y)+o(l.y+l.contentHeight))/2,m=`${Math.round(u)}:${d}`,h=i.get(m);h?(h.count++,h.mid=Math.max(h.mid,p)):i.set(m,{text:d,right:u,mid:p,count:1})}}),e.textAlign="left",e.textBaseline="middle",e.lineJoin="round",e.lineWidth=3,e.strokeStyle="rgba(255,255,255,0.9)",e.fillStyle="rgba(0,0,0,0.75)";let a=[];for(let{text:l,right:c,mid:f,count:u}of i.values()){let d=u>1?`${l} each`:l,p={x0:c+3,x1:c+3+e.measureText(d).width,y0:f-6,y1:f+6};p.x1<=r&&!a.some(m=>m.x0<p.x1&&p.x0<m.x1&&m.y0<p.y1&&p.y0<m.y1)&&(a.push(p),e.strokeText(d,p.x0,f),e.fillText(d,p.x0,f))}}function X0(e,t,n,{width:o,lit:r}){t.forEach((s,i)=>{let a=n?.[i];a&&(r&&qe(e,s.picture,{...s.frame,width:o,highlightNode:a.box}),e.font=Hc,e.textAlign="left",e.textBaseline="top",e.fillStyle="#c00000",e.fillText(` \xB7 ${a.here} of ${Zt(a.of,"haplotype")} here`,6+e.measureText(s.label).width,s.titleTop+4))})}function D0(e,t){let n=new Set(t),o=(e.paths??[]).filter(c=>n.has(c.name)||q(c.name)===e.referencePath),r=new Set(o.map(c=>q(c.name))),s=new Set(o.flatMap(c=>c.nodeIds)),i=e.nodes.filter(c=>s.has(c.id)),a=new Set(i.map(c=>c.name)),l=e.pathVisits?.filter(c=>r.has(c),c=>a.has(c));return{...e,nodes:i,edges:e.edges.filter(c=>s.has(c.from)&&s.has(c.to)),paths:o,anchorPaths:e.anchorPaths?.filter(c=>r.has(c.name)),pathVisits:l,reads:void 0}}function F0(e,t){let n=[],o={},r=0,s=1/0,i=-1/0;for(let{key:a,paths:l,label:c,result:f}of t){let u=f?.tubeMap,d=f?.extent;if(u&&d){let p=r+Gc,m=(d.maxY??0)-(d.minY??0);n.push({key:a,paths:l,label:c,result:{...f,tubeMap:u},top:p,height:m});let h=p-(d.minY??0);for(let[b,g]of Object.entries(f.nodePositions))o[b]=g.map(y=>({x:y.x,y:y.y+h}));r=p+m,s=Math.min(s,d.minX??s),i=Math.max(i,d.maxX??i)}}return n.length>1?{...e,nodePositions:o,extent:{...s<=i?{minX:s,maxX:i}:{},minY:0,maxY:r},tubeMapPanels:n}:e}var Qc="#daa520",el=1,tl=2,nl=4;function W0(e,t,n,o=r=>r){let r=s=>{let i=t(s)*2;return n?.nodeIds.has(s)?Math.max(i,n.walks.length*nl):i};return e.flatMap(s=>s.exonsByNode.map(({nodeId:i,d:a})=>({key:`${s.gene.name}-${s.gene.start}-${i}`,d:o(a),inner:r(i)+2*el})))}function Y0(e,t){if(e.length===0)return;let n=(o,r,s)=>A("path",{d:o.d,fill:"none",stroke:r,"stroke-width":s,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":t.transform?"non-scaling-stroke":void 0});return A("g",{},A("mask",{id:t.id,maskUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height},A("g",{transform:t.transform},...e.map(o=>n(o,"#fff",o.inner+2*tl)),...e.map(o=>n(o,"#000",o.inner)))),A("rect",{width:t.width,height:t.height,fill:Qc,mask:`url(#${t.id})`}))}function ol(e,t,n){let o=new Set;for(let r of e.paths??[])for(let s of r.nodeIds)o.add(s);return e.nodes.every(r=>t.nodeIds.has(r.id)||o.has(r.id))?"only in other haplotypes":`nodes and links not on ${n}`}var Gr=(e,t)=>!!e.referencePath&&P(t).name===e.referencePath;function rl(e,t){let n=P(t).name;return(e.paths??[]).filter(o=>P(o.name).name===n).sort((o,r)=>(o.start??0)-(r.start??0))}var Wr=e=>new Map(e.nodes.map(t=>[t.id,t]));function sl(e){let t=new Map;return e.edges.forEach((n,o)=>{t.set(`${n.from}>${n.to}`,o)}),{byId:Wr(e),edgeAt:t}}function il(e,t,{byId:n,edgeAt:o}){let r=rl(e,t),s=r[0];if(!s)return;let i=S=>n.get(S)?.length??0,a=S=>S.nodeIds.reduce((_,O)=>_+i(O),0),l=r.reduce((S,_)=>S+a(_),0),c=S=>{let _=Math.min(...S.map(O=>O.start??1/0));return Number.isFinite(_)?{start:_,end:Math.max(...S.map(O=>(O.start??0)+a(O)))}:void 0},f=c(r),u=f&&{contig:s.contig??Se(P(t).name),...f},d=u?u.end-u.start:l,p=new Set,m=new Set,h=new Map,b=new Map,g=new Map,y=1,M=0;for(let S of r)u&&(M=Math.max(M,(S.start??0)-u.start)),S.nodeIds.forEach((_,O)=>{p.add(_);let G=(g.get(_)??0)+1;if(g.set(_,G),y=Math.max(y,G),O>0){let X=S.nodeIds[O-1],$=o.get(`${X}>${_}`)??o.get(`${_}>${X}`);$!==void 0&&m.add($)}let z=i(_),H=d>0?(M+z/2)/d:0;h.has(_)||h.set(_,H);let R=b.get(_);R?R.push(H):b.set(_,[H]),M+=z});let x=0,w=0,v;r.forEach((S,_)=>{if(v!==void 0&&S.start!==void 0&&S.start>v)for(let O of an(S.start-v,r[_-1].after,S.before))x+=O.cause==="missing"?O.bp:0,w+=O.cause==="unknown"?O.bp:0;v=S.start===void 0?void 0:S.start+a(S)});let k=Gr(e,t),T=()=>{let S=k?[]:(e.paths??[]).filter(O=>Gr(e,O.name));if(S.length===0)return;let _=c(S);return _?_.end-_.start:S.reduce((O,G)=>O+a(G),0)};return{name:t,reference:k,range:u,nodeIds:p,edgeIndexes:m,progress:h,passProgress:b,passes:g,mostPasses:y,route:r.map(S=>S.nodeIds),steps:r.reduce((S,_)=>S+_.nodeIds.length,0),bp:l,referenceBp:T(),missingBp:x,unknownBp:w}}function Yr(e,t,n,o,r){let s=o.field==="progress"||!r?void 0:al(e,t,n,r),i=new Map,a=new Map;for(let[l,c]of n.passProgress){let f=s?.get(l),u=c.map((d,p)=>Ln(o,s?f?.[p]:d));i.set(l,u[0]),a.set(l,u)}return{colors:i,passColors:a}}function al(e,t,n,o){let r=Ke(e),s=new Map;for(let i of n.route){let a=Number.NaN,l=Number.NaN;for(let c of i){let f=t.get(c),u=f&&it(f,o);if(f&&u!==void 0&&N(f)){let p=r(f),m=f.length,h=p[0];if(p.length>1&&!Number.isNaN(a)){let b=1/0;for(let g of p){let y=Math.min(Math.abs(g-a),Math.abs(g+m-a));y<b&&(h=g,b=y)}u=(h+m/2-o.start)/o.span}a=h+m===l?h:h+m,l=h}let d=s.get(c);d?d.push(u):s.set(c,[u])}}return s}function cl(e,t,n){let o=new Set,r=0,s=e.referencePath;if(!s||n.reference)return{reversed:o,bp:r};let i=e.pathVisits;if(!i)return{reversed:o,bp:r};let a=i.pathIndex(P(n.name).name),l=i.pathIndex(s);for(let c of n.progress.keys()){let f=t.get(c),u=f?i.slot(f.name):-1,d=u<0?-1:i.firstBy(u,a),p=u<0?-1:i.firstBy(u,l);d>=0&&p>=0&&i.reversed[d]!==i.reversed[p]&&(o.add(c),r+=f.length)}return{reversed:o,bp:r}}function ll(e,t,n){let o=sl(e),r=new Set,s=t.filter(c=>!r.has(c.walk)&&r.add(c.walk)).flatMap(c=>{let f=il(e,c.walk,o);return f?[{walk:f,layer:c}]:[]}).sort((c,f)=>Number(f.walk.reference)-Number(c.walk.reference));if(s.length===0)return;let i=0,a=Cn(s.map(({walk:c,layer:f})=>lt(f,c.reference,c.reference?0:i++,s.length===1))),l=s.map(({walk:c},f)=>{let u=a[f],{reversed:d,bp:p}=cl(e,o.byId,c);return{...c,encoding:u,...Yr(e,o.byId,c,u,n),reversed:d,reversedBp:p}});return Hr(l,n)}var dl={field:"progress",scheme:"red"};function fl(e,t,n,o){let r=Wr(e);return t.walks.map(s=>{let i=n.find(l=>l.walk===s.name)?.color,a=lt({walk:s.name,color:{...dl,...i}},s.reference,0);return Hr([{...s,encoding:a,...Yr(e,r,s,a,o)}],o)})}function Hr(e,t){return{walks:e,referenceDomain:t?{start:t.start,end:t.start+t.span}:void 0,nodeIds:new Set(e.flatMap(n=>[...n.nodeIds])),edgeIndexes:new Set(e.flatMap(n=>[...n.edgeIndexes])),names:new Set(e.map(n=>n.name))}}function en(e,t,n){let o=Math.round(t),r=Math.round(n);return`${e?`${e}:`:""}${ie(o+1)}-${ie(r)} (${I(r-o)})`}function ul(e,t){let{field:n}=e.encoding,o=e.range?en(e.range.contig,e.range.start,e.range.end):void 0,r=n==="progress"?o:n==="reference"&&t?en(t.name,t.start,t.end):void 0,s=e.range?e.range.end-e.range.start:e.bp,i=s-e.bp-e.missingBp-e.unknownBp,a=[[e.missingBp,F.missing],[e.unknownBp,F.unknown],[i,se]];return{delta:e.referenceBp===void 0||s===e.referenceBp?"":` ${s>e.referenceBp?"+":"\u2212"}${I(Math.abs(s-e.referenceBp))}`,gaps:a.filter(([l])=>l>0).map(([l,c])=>`, ${I(l)} ${c}`).join(""),reversed:e.reversedBp>0?`, ${I(e.reversedBp)} reversed`:"",shades:n!=="walk",scale:r,hover:r===o?void 0:o}}function pl(e,t,n){let o=e.progress.get(t),r=e.range;if(o===void 0||!r)return;let s=Math.round(r.start+o*(r.end-r.start)-n/2);return`${r.contig}:${ie(s+1)}-${ie(s+n)}`}function hl(e,t){let n=[];for(let o of t){let r=e.get(o.refName),s=r?.[0],i=r?.at(-1);if(!r||!s||!i)continue;let a=Math.max(o.start,s.bp0),l=Math.min(o.end,i.bp1);l<=a||n.push({gene:o,...Xe(r,a,l),exons:o.exons.filter(c=>c.end>a&&c.start<l).map(c=>Xe(r,Math.max(c.start,a),Math.min(c.end,l)))})}return n}var tn=22,ml=4,Ye=8,gl="11px sans-serif",bl=8;function xl(e){let t=e.flatMap(r=>[{x:r.x0,step:1},{x:r.x1,step:-1}]).sort((r,s)=>r.x-s.x||r.step-s.step),n=0,o=0;for(let{step:r}of t)n+=r,o=Math.max(o,n);return Math.min(ml,o)}function yl(e,t,n,o,r=0){let{x:s,width:i,darkMode:a}=n,l=Math.max(1,Math.floor((o-r)/tn)),c=[],f=a?"#e0e0e6":"#1c1c22";e.font=gl,e.textAlign="center",e.textBaseline="alphabetic",e.fillStyle=f,e.strokeStyle=f,e.lineWidth=1;let u=t.map(d=>({g:d,s0:s(d.x0),s1:s(d.x1)})).filter(({s0:d,s1:p})=>p>=0&&d<=i).sort((d,p)=>d.s0-p.s0);for(let{g:d,s0:p,s1:m}of u){let h=d.gene.strand>0?" \u2192":d.gene.strand<0?"\u2190 ":"",b=d.gene.strand<0?`${h}${d.gene.name}`:`${d.gene.name}${h}`,g=(Math.max(p,0)+Math.min(m,i))/2,y=e.measureText(b).width/2,M=Math.min(p,g-y),x=Math.max(m,g+y),w=c.findIndex(k=>k+bl<=M);w===-1&&(w=Math.min(c.length,l-1)),c[w]=Math.max(c[w]??-1/0,x);let v=o-w*tn-Ye/2;e.beginPath(),e.moveTo(p,v+.5),e.lineTo(m,v+.5),e.stroke();for(let k of d.exons){let T=s(k.x0);e.fillRect(T,v-Ye/2,Math.max(1,s(k.x1)-T),Ye)}e.fillText(b,g,v-Ye/2-2)}}var Y=12,zr=Y+8,Zr=8,Ur=Zr+3,wl=12;function Ml(e,{colorScheme:t,referenceRamp:n,walks:o}){let r=at(e,n),s=[];return e.nodes.forEach((i,a)=>{if(N(i)){let l=o?o.map(c=>{let f=c.colors.get(i.id);return f===void 0?Ae:V(f)}):[V(ct(i,a,t,r))];s.push({node:i.id,bp0:i.stable.start,bp1:i.stable.start+i.length,colors:l,faded:l.includes(Ae)})}}),s.sort((i,a)=>i.bp0-a.bp0)}function nn(e,t,n){let o=t*e.scale+e.translateX,r=n*e.scale+e.translateX;return o<r?[o,r]:[r,o]}var jr=2;function Jr(e,t,n){let o=-t.translateX/t.scale,r=(n-t.translateX)/t.scale,s=Math.min(o,r),i=Math.max(o,r),a=0,l=0;for(let c of e)a+=Math.max(0,Math.min(c.bp1,s)-c.bp0),l+=Math.max(0,c.bp1-Math.max(c.bp0,i));return t.scale>=0?{left:Math.round(a),right:Math.round(l)}:{left:Math.round(l),right:Math.round(a)}}function vl(e,t,n,o){if(o<0||o>Y+jr)return;let r,s=jr;for(let i of e){let[a,l]=nn(t,i.bp0,i.bp1),c=Math.max(0,a-n,n-l);c<=s&&(s=c,r=i.node)}return r}function Sl(e,t){let n=e?.[Math.floor(e.length/2)];return n?t(n):void 0}function Qr(e,t,n,o){let r=e.map(c=>{let[f,u]=nn(t,c.bp0,c.bp1),d=Math.round(f*o);return{colors:c.colors,x0:f,px0:d,px1:Math.max(Math.round(u*o),d+1)}}).filter(c=>c.px1>0&&c.px0<n*o).sort((c,f)=>c.x0-f.x0),s=[],i=-1/0,a=[-1/0,-1/0];for(let{colors:c,px0:f,px1:u}of r){let d=Math.max(f,i);if(u>d){let p=a[0]<d?0:1;a[p]=u,s.push({colors:c,x0:d/o,x1:u/o,tier:p}),i=u}}return(s.length>0?s.at(-1).x1-s[0].x0:0)>=s.length*wl?s:s.map(({tier:c,...f})=>f)}function Vr(e,t,n,o){let r=n>0?t:t-Ur;e.clearRect(r,0,Ur,Y);let s=t+n,i=s+n*Zr;e.beginPath(),e.moveTo(s,Y/2),e.lineTo(i,0),e.lineTo(i,Y),e.closePath(),e.fillStyle=o,e.fill()}function Kr(e,t,n){return Math.round(e*Y*n/t)/n}function El(e,t,n,{width:o,lit:r,darkMode:s,dpr:i=1}){let a=s?"#ffffff":"#18181c";e.clearRect(0,0,o,zr);for(let c of Qr(t,n,o,i)){let{tier:f}=c,u=f!==void 0&&c.colors.length===1,d=u?2:c.colors.length;c.colors.forEach((p,m)=>{let h=u?f:m,b=Kr(h,d,i);e.fillStyle=p,e.fillRect(c.x0,b,c.x1-c.x0,Kr(h+1,d,i)-b)})}let l=Jr(t,n,o);if(l.left>0&&Vr(e,0,1,a),l.right>0&&Vr(e,o,-1,a),r){let[c,f]=nn(n,r.start,r.end),u=Math.max(f-c,3),d=(c+f)/2-u/2;e.strokeStyle=a,e.lineWidth=1.5,e.strokeRect(d,.75,u,Y-1.5),r.anchor&&(e.beginPath(),e.moveTo(d+u/2,Y),e.lineTo(r.anchor.x,r.anchor.y),e.lineWidth=1,e.stroke())}}function kl(e,t){return Math.abs(t-e)<=.1*Math.max(e,t)}function Rl(e,t){let n=e.length,o=t.length,r=Array.from({length:n+1},()=>new Array(o+1).fill(0)),s=Array.from({length:n+1},()=>new Array(o+1).fill(!1));for(let a=n-1;a>=0;a--)for(let l=o-1;l>=0;l--){let c=Math.abs(e[a]-t[l])+r[a+1][l+1],f=n-a>o-l?r[a+1][l]:1/0,u=o-l>n-a?r[a][l+1]:1/0;r[a][l]=Math.min(c,f,u),s[a][l]=r[a][l]===c}let i=new Array(n).fill(void 0);for(let a=0,l=0;a<n&&l<o;)s[a][l]?i[a++]=l++:n-a>o-l?a++:l++;return i}function es(e,t){return e.map((n,o)=>({item:n,i:o})).sort((n,o)=>t(n.item)-t(o.item))}var ts=e=>e.spanningReads!==0;function Tl(e,t){return{...t,agrees:e.complete&&ts(t)?kl(e.bp,t.bp):void 0}}function _l(e,t){let n=new Map,o=new Set,r=es(e,i=>i.bp),s=(i,a)=>{let l=[[i.filter(c=>c.item.complete),a.filter(ts)],[i,a]];for(let[c,f]of l){let u=c.filter(p=>!n.has(p.i)),d=es(f.filter(p=>!o.has(p)),p=>p.bp);Rl(u.map(p=>p.item.bp),d.map(p=>p.item.bp)).forEach((p,m)=>{if(p!==void 0){let h=u[m],b=d[p].item;o.add(b),n.set(h.i,Tl(h.item,b))}})}};for(let i of new Set(t.flatMap(a=>a.haplotype??[])))s(r.filter(a=>a.item.haplotype===i),t.filter(a=>a.haplotype===i));return s(r,t.filter(i=>i.haplotype===void 0)),n}function $y(e,t){if(!t)return e;let n=new Map,o=new Map;for(let r of e){let s=o.get(r.sample);s?s.push(r):o.set(r.sample,[r])}for(let[r,s]of o){let i=t[r];if(i)for(let[a,l]of _l(s,i))n.set(s[a],l)}return e.map(r=>({...r,call:n.get(r)}))}var ns=ko.box(typeof devicePixelRatio>"u"?1:devicePixelRatio);function os(){matchMedia(`(resolution: ${devicePixelRatio}dppx)`).addEventListener("change",()=>{Ro(()=>{ns.set(devicePixelRatio)}),os()},{once:!0})}typeof matchMedia=="function"&&os();function Fy(e=0,t=0){return ns.get(),ae(e,t)}export{Ku as a,zu as b,Zu as c,Ju as d,qc as e,si as f,ii as g,Gt as h,Tr as i,Zh as j,fc as k,Jh as l,cm as m,lm as n,Qn as o,Sf as p,$e as q,Pe as r,dt as s,Ie as t,ss as u,is as v,as as w,cs as x,fd as y,Q as z,eo as A,ge as B,ut as C,Ts as D,ud as E,pd as F,Os as G,As as H,Ns as I,Ps as J,Is as K,$f as L,Cf as M,Lf as N,Bf as O,Xf as P,Df as Q,Ff as R,qf as S,Gf as T,Wf as U,Yf as V,Hf as W,Uf as X,jf as Y,Vf as Z,Kf as _,zf as $,Zf as aa,Jf as ba,Cs as ca,Qf as da,eu as ea,tu as fa,nu as ga,ou as ha,ru as ia,su as ja,fi as ka,pi as la,hi as ma,mi as na,sm as oa,A as pa,gi as qa,bi as ra,be as sa,_t as ta,Le as ua,St as va,$o as wa,xe as xa,Bo as ya,kt as za,Ei as Aa,ki as Ba,Do as Ca,Oi as Da,qo as Ea,Go as Fa,Ot as Ga,Ai as Ha,Ni as Ia,Yo as Ja,ye as Ka,At as La,Ii as Ma,Uo as Na,Fi as Oa,qi as Pa,Wi as Qa,Yi as Ra,Zo as Sa,Cm as Ta,xc as Ua,Lm as Va,qm as Wa,Gm as Xa,Ec as Ya,Oc as Za,qe as _a,zt as $a,Vt as ab,Ic as bb,Cc as cb,We as db,Vg as eb,Kg as fb,zg as gb,Zg as hb,Jg as ib,Qg as jb,Gc as kb,Fr as lb,Wc as mb,T0 as nb,Hc as ob,_0 as pb,O0 as qb,qr as rb,A0 as sb,N0 as tb,jc as ub,P0 as vb,I0 as wb,$0 as xb,C0 as yb,L0 as zb,B0 as Ab,X0 as Bb,D0 as Cb,F0 as Db,au as Eb,gt as Fb,uu as Gb,Qc as Hb,W0 as Ib,Y0 as Jb,Su as Kb,wo as Lb,Eu as Mb,Mo as Nb,bt as Ob,vo as Pb,So as Qb,ni as Rb,ol as Sb,ll as Tb,fl as Ub,en as Vb,ul as Wb,pl as Xb,hl as Yb,tn as Zb,xl as _b,yl as $b,zr as ac,Ml as bc,Jr as cc,vl as dc,Sl as ec,El as fc,$y as gc,Fy as hc};
3
+ //# sourceMappingURL=chunk-52L7CQAG.js.map