jbrowse-plugin-graphgenomeviewer 10.1.1 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/chunks/{AddTrackWorkflow-33CIFO4U.js → AddTrackWorkflow-BY23IVYG.js} +2 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-HFPXWTES.js → GbzBaseSyntenyAdapter-XAMRWAYZ.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-HFPXWTES.js.map → GbzBaseSyntenyAdapter-XAMRWAYZ.js.map} +1 -1
  4. package/dist/chunks/{GraphGenomeView-QRKOT4XI.js → GraphGenomeView-7FALCHVY.js} +2 -2
  5. package/dist/chunks/GraphSettingsDialog-XXCBW2UA.js +2 -0
  6. package/dist/chunks/{HighlightColorDialog-AZTOOI72.js → HighlightColorDialog-AD7B53ZA.js} +2 -2
  7. package/dist/chunks/LinearGraphDisplay-26MRFDXW.js +2 -0
  8. package/dist/chunks/{MinigraphBubbleAdapter-EYQBOSUD.js → MinigraphBubbleAdapter-W7RUVFVI.js} +2 -2
  9. package/dist/chunks/{RgfaTabixAdapter-MKQTIDHN.js → RgfaTabixAdapter-QOEMTN56.js} +2 -2
  10. package/dist/chunks/{WalkFormsAdapter-DBX4OARV.js → WalkFormsAdapter-AV746ZGI.js} +2 -2
  11. package/dist/chunks/{WalkTabixSyntenyAdapter-JKMTJX64.js → WalkTabixSyntenyAdapter-HEXLZ5YL.js} +2 -2
  12. package/dist/chunks/chunk-3QEIRGMZ.js +2 -0
  13. package/dist/chunks/{chunk-MOQJ2IEL.js → chunk-4FDZC66W.js} +1 -1
  14. package/dist/chunks/{chunk-MOQJ2IEL.js.map → chunk-4FDZC66W.js.map} +1 -1
  15. package/dist/chunks/{chunk-MH3KMMEC.js → chunk-4JYYNBSO.js} +2 -2
  16. package/dist/chunks/{chunk-MH3KMMEC.js.map → chunk-4JYYNBSO.js.map} +1 -1
  17. package/dist/chunks/chunk-5BMTS4FH.js +5 -0
  18. package/dist/chunks/chunk-5BMTS4FH.js.map +7 -0
  19. package/dist/chunks/{chunk-PKHR5PYT.js → chunk-7V5D6ZDX.js} +1 -1
  20. package/dist/chunks/{chunk-PKHR5PYT.js.map → chunk-7V5D6ZDX.js.map} +1 -1
  21. package/dist/chunks/{chunk-Q7WYREE4.js → chunk-AW7U7KMG.js} +2 -2
  22. package/dist/chunks/{chunk-Q7WYREE4.js.map → chunk-AW7U7KMG.js.map} +1 -1
  23. package/dist/chunks/{chunk-VTXAOEHQ.js → chunk-B65Y26K2.js} +2 -2
  24. package/dist/chunks/{chunk-VTXAOEHQ.js.map → chunk-B65Y26K2.js.map} +1 -1
  25. package/dist/chunks/{chunk-WSHN4CQP.js → chunk-BCRRODIU.js} +2 -2
  26. package/dist/chunks/{chunk-CKQNUMI7.js → chunk-BDBERNEC.js} +2 -2
  27. package/dist/chunks/{chunk-CKQNUMI7.js.map → chunk-BDBERNEC.js.map} +1 -1
  28. package/dist/chunks/{chunk-CK5762BL.js → chunk-CVHICHF5.js} +2 -2
  29. package/dist/chunks/chunk-CWT6WZ3D.js +3 -0
  30. package/dist/chunks/chunk-CWT6WZ3D.js.map +7 -0
  31. package/dist/chunks/{chunk-NIWIX7TE.js → chunk-FSVORNAP.js} +2 -2
  32. package/dist/chunks/{chunk-GZW7Q3SG.js → chunk-H6TKCTCB.js} +2 -2
  33. package/dist/chunks/{chunk-GD5RMI3A.js → chunk-HT3RFCRI.js} +2 -2
  34. package/dist/chunks/{chunk-GD5RMI3A.js.map → chunk-HT3RFCRI.js.map} +1 -1
  35. package/dist/chunks/chunk-IAN7FKQ5.js +5 -0
  36. package/dist/chunks/chunk-IAN7FKQ5.js.map +7 -0
  37. package/dist/chunks/{chunk-G6SF7JOB.js → chunk-IQURFLWC.js} +2 -2
  38. package/dist/chunks/{chunk-26XYOMO2.js → chunk-KFSVGH3X.js} +2 -2
  39. package/dist/chunks/{chunk-26XYOMO2.js.map → chunk-KFSVGH3X.js.map} +1 -1
  40. package/dist/chunks/{chunk-XMCXA4BB.js → chunk-L2YRM5BR.js} +2 -2
  41. package/dist/chunks/{chunk-XMCXA4BB.js.map → chunk-L2YRM5BR.js.map} +1 -1
  42. package/dist/chunks/{chunk-TNB64ZLS.js → chunk-NGTPDYX7.js} +1 -1
  43. package/dist/chunks/{chunk-TNB64ZLS.js.map → chunk-NGTPDYX7.js.map} +1 -1
  44. package/dist/chunks/chunk-SMC6O3CR.js +6 -0
  45. package/dist/chunks/chunk-SMC6O3CR.js.map +7 -0
  46. package/dist/chunks/{chunk-ADZSOZAK.js → chunk-TD6XNJRC.js} +2 -2
  47. package/dist/chunks/{chunk-ADZSOZAK.js.map → chunk-TD6XNJRC.js.map} +1 -1
  48. package/dist/chunks/{chunk-V3TJ4VSL.js → chunk-V5ZGDS4W.js} +2 -2
  49. package/dist/chunks/{chunk-V3TJ4VSL.js.map → chunk-V5ZGDS4W.js.map} +1 -1
  50. package/dist/chunks/{chunk-HFKTRWQO.js → chunk-Z6IFVSZS.js} +3 -3
  51. package/dist/chunks/{chunk-HFKTRWQO.js.map → chunk-Z6IFVSZS.js.map} +3 -3
  52. package/dist/chunks/{renderSvg-BQSCA7GW.js → renderSvg-KEQ6NZ4A.js} +2 -2
  53. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
  54. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
  55. package/package.json +3 -3
  56. package/src/GraphGenomeView/components/LegendSwatch.tsx +8 -0
  57. package/src/GraphGenomeView/legendSections.ts +4 -0
  58. package/src/GraphGenomeView/model.ts +2 -1
  59. package/src/GraphGenomeView/pane/hostViews.ts +3 -8
  60. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +9 -3
  61. package/src/version.ts +1 -1
  62. package/dist/chunks/GraphSettingsDialog-BOUQ722U.js +0 -2
  63. package/dist/chunks/LinearGraphDisplay-N65SG6LH.js +0 -2
  64. package/dist/chunks/chunk-7B37TB2B.js +0 -2
  65. package/dist/chunks/chunk-HLUBCP2I.js +0 -5
  66. package/dist/chunks/chunk-HLUBCP2I.js.map +0 -7
  67. package/dist/chunks/chunk-TM74CDYQ.js +0 -5
  68. package/dist/chunks/chunk-TM74CDYQ.js.map +0 -7
  69. package/dist/chunks/chunk-TQZH7NNB.js +0 -6
  70. package/dist/chunks/chunk-TQZH7NNB.js.map +0 -7
  71. package/dist/chunks/chunk-U6LTMPHE.js +0 -3
  72. package/dist/chunks/chunk-U6LTMPHE.js.map +0 -7
  73. /package/dist/chunks/{AddTrackWorkflow-33CIFO4U.js.map → AddTrackWorkflow-BY23IVYG.js.map} +0 -0
  74. /package/dist/chunks/{GraphGenomeView-QRKOT4XI.js.map → GraphGenomeView-7FALCHVY.js.map} +0 -0
  75. /package/dist/chunks/{GraphSettingsDialog-BOUQ722U.js.map → GraphSettingsDialog-XXCBW2UA.js.map} +0 -0
  76. /package/dist/chunks/{HighlightColorDialog-AZTOOI72.js.map → HighlightColorDialog-AD7B53ZA.js.map} +0 -0
  77. /package/dist/chunks/{LinearGraphDisplay-N65SG6LH.js.map → LinearGraphDisplay-26MRFDXW.js.map} +0 -0
  78. /package/dist/chunks/{MinigraphBubbleAdapter-EYQBOSUD.js.map → MinigraphBubbleAdapter-W7RUVFVI.js.map} +0 -0
  79. /package/dist/chunks/{RgfaTabixAdapter-MKQTIDHN.js.map → RgfaTabixAdapter-QOEMTN56.js.map} +0 -0
  80. /package/dist/chunks/{WalkFormsAdapter-DBX4OARV.js.map → WalkFormsAdapter-AV746ZGI.js.map} +0 -0
  81. /package/dist/chunks/{WalkTabixSyntenyAdapter-JKMTJX64.js.map → WalkTabixSyntenyAdapter-HEXLZ5YL.js.map} +0 -0
  82. /package/dist/chunks/{chunk-7B37TB2B.js.map → chunk-3QEIRGMZ.js.map} +0 -0
  83. /package/dist/chunks/{chunk-WSHN4CQP.js.map → chunk-BCRRODIU.js.map} +0 -0
  84. /package/dist/chunks/{chunk-CK5762BL.js.map → chunk-CVHICHF5.js.map} +0 -0
  85. /package/dist/chunks/{chunk-NIWIX7TE.js.map → chunk-FSVORNAP.js.map} +0 -0
  86. /package/dist/chunks/{chunk-GZW7Q3SG.js.map → chunk-H6TKCTCB.js.map} +0 -0
  87. /package/dist/chunks/{chunk-G6SF7JOB.js.map → chunk-IQURFLWC.js.map} +0 -0
  88. /package/dist/chunks/{renderSvg-BQSCA7GW.js.map → renderSvg-KEQ6NZ4A.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as $}from"./chunk-XMCXA4BB.js";import"./chunk-VTXAOEHQ.js";import"./chunk-TM74CDYQ.js";import{g as R,h as U}from"./chunk-HFKTRWQO.js";import"./chunk-IK5G3JHR.js";import{a as V}from"./chunk-U6LTMPHE.js";import"./chunk-WSHN4CQP.js";import{q as v}from"./chunk-V3TJ4VSL.js";import"./chunk-HLUBCP2I.js";import"./chunk-CKQNUMI7.js";import"./chunk-Q7WYREE4.js";import"./chunk-MH3KMMEC.js";import"./chunk-PKHR5PYT.js";import"./chunk-ZQOMV674.js";import"./chunk-JM4W4PKP.js";import"./chunk-G6SF7JOB.js";import"./chunk-GD5RMI3A.js";import"./chunk-YBLNN5FU.js";import"./chunk-26XYOMO2.js";import"./chunk-TNB64ZLS.js";import"./chunk-ADZSOZAK.js";import"./chunk-D3QZGLZ3.js";import"./chunk-WKD7ALOU.js";import"./chunk-TQZH7NNB.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-MOQJ2IEL.js";import{j as A,o as F}from"./chunk-5L276I7O.js";import{e as O,i as c}from"./chunk-J2PN6CG3.js";import{B as y,G as x,I as p,e as N,j as B,m as E,n as D,o as l,s as P,y as z}from"./chunk-H42TSPVA.js";import{a as L,b as e,c as n,d}from"./chunk-DUU6T2I5.js";var K=v()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},actions:{display:"flex",justifyContent:"flex-end",gap:8}}),_=d(function({model:t}){return e(l,{size:"small","data-testid":"graph-genome-choose-another",onClick:()=>{t.clearGraph()},children:"Choose another graph"})}),X=d(function({model:t}){let{classes:r}=K();return!t.error&&!t.loadCanceled?n(y,{className:r.paper,"data-testid":"graph-genome-loading",children:[n("div",{className:r.row,children:[e(B,{variant:"h6",message:t.statusMessage||void 0}),t.canCancelLoad?e(l,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{t.cancelLoad()},children:"Cancel"}):null]}),e(z,{variant:"indeterminate"})]}):t.error?n(y,{className:r.paper,children:[e(N,{error:t.error,onReset:()=>{t.retryLoad()}}),e("div",{className:r.actions,children:e(_,{model:t})})]}):e(y,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:n("div",{className:r.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),n("div",{className:r.actions,children:[e(_,{model:t}),e(l,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{t.retryLoad()},children:"Retry"})]})]})})}),I=X;var q=V(e("path",{d:"M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7m2.85 11.1-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1"}),"LightbulbOutlined");var Z=v()({column:{display:"flex",flexDirection:"column",gap:12},actions:{display:"flex",justifyContent:"flex-end"}}),J=d(function({model:t,choices:r}){let{classes:T}=Z(),f=A(t),{assemblyManager:g}=f,[S,G]=c(r[0]?.trackId),[w,k]=c(),[C,h]=c(),a=r.find(o=>o.trackId===S)??r[0],i=a?.assembly,M=(i?g.get(i):void 0)?.regions?.[0],b=w??(a?R(f.views,a.assembly)??(M?U(a,M):""):"");O(()=>{i&&g.waitForAssembly(i).catch(()=>{})},[g,i]);async function W(){if(a)try{let o=await g.waitForAssembly(a.assembly),s=o?F(b,u=>o.isValidRefName(u)):void 0;!o||!s||!o.isValidRefName(s.refName)?h(`No sequence ${s?.refName??b} in ${a.assembly}`):t.showTrackInLinearView(a.trackId,a.assembly,b)}catch(o){h(String(o instanceof Error?o.message:o))}}return n("form",{className:T.column,"data-testid":"graph-track-picker",onSubmit:o=>{o.preventDefault(),W()},children:[e(D,{options:r,value:a??null,getOptionLabel:o=>o.name,isOptionEqualToValue:(o,s)=>o.trackId===s.trackId,onChange:(o,s)=>{s&&(G(s.trackId),k(void 0),h(void 0))},renderOption:({key:o,...s},u)=>e("li",{...s,children:n("div",{children:[e(p,{variant:"body2",children:u.name}),n(p,{variant:"caption",color:"text.secondary",children:[u.assembly," \xB7 ",u.reach]})]})},u.trackId),renderInput:o=>e(x,{...o,size:"small",label:"Graph track",helperText:a?`${a.assembly} \xB7 ${a.reach}`:""})}),e(x,{size:"small",label:"Region",name:"region",value:b,placeholder:"chr1:1,000,001-1,020,000",error:C!==void 0,helperText:C??"A sequence name, or name:start-end",onChange:o=>{k(o.target.value),h(void 0)}}),e("div",{className:T.actions,children:e(l,{type:"submit",variant:"contained","data-testid":"graph-track-show",disabled:!a||!b.trim(),children:"Show in linear genome view"})})]})}),H=J;var Q=`H VN:Z:1.0
1
+ import{b as $}from"./chunk-L2YRM5BR.js";import"./chunk-B65Y26K2.js";import"./chunk-IAN7FKQ5.js";import{g as R,h as U}from"./chunk-Z6IFVSZS.js";import"./chunk-IK5G3JHR.js";import{a as V}from"./chunk-CWT6WZ3D.js";import"./chunk-BCRRODIU.js";import{q as v}from"./chunk-V5ZGDS4W.js";import"./chunk-5BMTS4FH.js";import"./chunk-BDBERNEC.js";import"./chunk-AW7U7KMG.js";import"./chunk-4JYYNBSO.js";import"./chunk-7V5D6ZDX.js";import"./chunk-ZQOMV674.js";import"./chunk-JM4W4PKP.js";import"./chunk-IQURFLWC.js";import"./chunk-HT3RFCRI.js";import"./chunk-YBLNN5FU.js";import"./chunk-KFSVGH3X.js";import"./chunk-NGTPDYX7.js";import"./chunk-TD6XNJRC.js";import"./chunk-D3QZGLZ3.js";import"./chunk-WKD7ALOU.js";import"./chunk-SMC6O3CR.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-4FDZC66W.js";import{j as A,o as F}from"./chunk-5L276I7O.js";import{e as O,i as c}from"./chunk-J2PN6CG3.js";import{B as y,G as x,I as p,e as N,j as B,m as E,n as D,o as l,s as P,y as z}from"./chunk-H42TSPVA.js";import{a as L,b as e,c as n,d}from"./chunk-DUU6T2I5.js";var K=v()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},actions:{display:"flex",justifyContent:"flex-end",gap:8}}),_=d(function({model:t}){return e(l,{size:"small","data-testid":"graph-genome-choose-another",onClick:()=>{t.clearGraph()},children:"Choose another graph"})}),X=d(function({model:t}){let{classes:r}=K();return!t.error&&!t.loadCanceled?n(y,{className:r.paper,"data-testid":"graph-genome-loading",children:[n("div",{className:r.row,children:[e(B,{variant:"h6",message:t.statusMessage||void 0}),t.canCancelLoad?e(l,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{t.cancelLoad()},children:"Cancel"}):null]}),e(z,{variant:"indeterminate"})]}):t.error?n(y,{className:r.paper,children:[e(N,{error:t.error,onReset:()=>{t.retryLoad()}}),e("div",{className:r.actions,children:e(_,{model:t})})]}):e(y,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:n("div",{className:r.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),n("div",{className:r.actions,children:[e(_,{model:t}),e(l,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{t.retryLoad()},children:"Retry"})]})]})})}),I=X;var q=V(e("path",{d:"M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7m2.85 11.1-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1"}),"LightbulbOutlined");var Z=v()({column:{display:"flex",flexDirection:"column",gap:12},actions:{display:"flex",justifyContent:"flex-end"}}),J=d(function({model:t,choices:r}){let{classes:T}=Z(),f=A(t),{assemblyManager:g}=f,[S,G]=c(r[0]?.trackId),[w,k]=c(),[C,h]=c(),a=r.find(o=>o.trackId===S)??r[0],i=a?.assembly,M=(i?g.get(i):void 0)?.regions?.[0],b=w??(a?R(f.views,a.assembly)??(M?U(a,M):""):"");O(()=>{i&&g.waitForAssembly(i).catch(()=>{})},[g,i]);async function W(){if(a)try{let o=await g.waitForAssembly(a.assembly),s=o?F(b,u=>o.isValidRefName(u)):void 0;!o||!s||!o.isValidRefName(s.refName)?h(`No sequence ${s?.refName??b} in ${a.assembly}`):t.showTrackInLinearView(a.trackId,a.assembly,b)}catch(o){h(String(o instanceof Error?o.message:o))}}return n("form",{className:T.column,"data-testid":"graph-track-picker",onSubmit:o=>{o.preventDefault(),W()},children:[e(D,{options:r,value:a??null,getOptionLabel:o=>o.name,isOptionEqualToValue:(o,s)=>o.trackId===s.trackId,onChange:(o,s)=>{s&&(G(s.trackId),k(void 0),h(void 0))},renderOption:({key:o,...s},u)=>e("li",{...s,children:n("div",{children:[e(p,{variant:"body2",children:u.name}),n(p,{variant:"caption",color:"text.secondary",children:[u.assembly," \xB7 ",u.reach]})]})},u.trackId),renderInput:o=>e(x,{...o,size:"small",label:"Graph track",helperText:a?`${a.assembly} \xB7 ${a.reach}`:""})}),e(x,{size:"small",label:"Region",name:"region",value:b,placeholder:"chr1:1,000,001-1,020,000",error:C!==void 0,helperText:C??"A sequence name, or name:start-end",onChange:o=>{k(o.target.value),h(void 0)}}),e("div",{className:T.actions,children:e(l,{type:"submit",variant:"contained","data-testid":"graph-track-show",disabled:!a||!b.trim(),children:"Show in linear genome view"})})]})}),H=J;var Q=`H VN:Z:1.0
2
2
  S 1 ACGT
3
3
  S 2 GGCC
4
4
  S 3 TTAA
@@ -7,4 +7,4 @@ L 1 + 2 + 0M
7
7
  L 1 + 3 + 0M
8
8
  L 2 + 4 + 0M
9
9
  L 3 + 4 + 0M`,Y=v()(m=>({column:{display:"flex",flexDirection:"column",gap:8},rowEnd:{display:"flex",gap:8,alignItems:"flex-end"},rowCenter:{display:"flex",gap:8,alignItems:"center"},flex1:{flex:1},paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto"},header:{marginBottom:12},tip:{marginBottom:16},divider:{marginBlock:16},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"},dragging:{outline:`2px dashed ${m.palette.primary.main}`,outlineOffset:-4}})),ee=d(function({model:t}){let{classes:r,cx:T}=Y(),[f,g]=c(""),[S,G]=c(!1),{graphTracks:w}=t;function k(){let a=f.trim();a&&t.openGfaLocation({uri:a,locationType:"UriLocation"})}function C(a){let i=a.target.files?.[0];a.target.value="",i&&t.loadGFAFile(i,i.name)}function h(a){a.preventDefault(),G(!1);let i=a.dataTransfer.files[0];i&&t.loadGFAFile(i,i.name)}return n(y,{className:T(r.paper,S&&r.dragging),"data-testid":"graph-import-form",onDragOver:a=>{a.preventDefault(),G(a.dataTransfer.types.includes("Files"))},onDragLeave:a=>{(!(a.relatedTarget instanceof Node)||!a.currentTarget.contains(a.relatedTarget))&&G(!1)},onDrop:a=>{h(a)},children:[n(E,{severity:"info",icon:e(q,{fontSize:"inherit"}),className:r.tip,"data-testid":"graph-import-tip",children:["A pangenome graph usually reads best as a track in a linear genome view, which redraws it as you pan and zoom."," ",w.length>0?"Pick a graph track and a region below.":"Index it with gfa-to-tabix and open it with File \u2192 Open track."]}),w.length>0?n(L,{children:[e("div",{className:r.header,children:e(p,{variant:"h6",children:"Show a graph track"})}),e(H,{model:t,choices:w}),e(P,{className:r.divider}),e("div",{className:r.header,children:e(p,{variant:"subtitle1",children:"Or open a small GFA file"})})]}):e("div",{className:r.header,children:e(p,{variant:"h6",children:"Open a small GFA file"})}),n("div",{className:r.column,children:[n("div",{className:r.rowCenter,children:[n(l,{variant:"outlined",component:"label",size:"small",children:["Choose file",e("input",{type:"file",accept:".gfa,.gfa1,.gfa2,.gz",hidden:!0,onChange:a=>{C(a)}})]}),e(p,{variant:"caption",color:"text.secondary",children:"Or drop one here. The whole file is drawn at once."})]}),n("div",{className:r.rowEnd,children:[e(x,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:f,onChange:a=>{g(a.target.value)},onKeyDown:a=>{a.key==="Enter"&&k()},className:r.flex1}),e(l,{variant:"contained",onClick:()=>{k()},disabled:!f.trim(),children:"Open"})]})]}),e("div",{className:r.footer,children:e(l,{size:"small",onClick:()=>{t.loadGFA(Q,"Example graph")},children:"Load 4-node example"})}),t.error?e(N,{error:t.error}):null]})}),j=ee;var ae=d(function({model:t}){return t.hasGraph?e($,{model:t}):t.canRetryLoad?e(I,{model:t}):n(L,{children:[t.isLoading?e(I,{model:t}):null,e("div",{hidden:t.isLoading,children:e(j,{model:t})})]})}),Ve=ae;export{Ve as default};
10
- //# sourceMappingURL=GraphGenomeView-QRKOT4XI.js.map
10
+ //# sourceMappingURL=GraphGenomeView-7FALCHVY.js.map
@@ -0,0 +1,2 @@
1
+ import{b as a}from"./chunk-B65Y26K2.js";import"./chunk-V5ZGDS4W.js";import"./chunk-AW7U7KMG.js";import"./chunk-4JYYNBSO.js";import"./chunk-TD6XNJRC.js";import"./chunk-D3QZGLZ3.js";import"./chunk-TMM73K4C.js";import"./chunk-EGZZ3ADM.js";import"./chunk-4FDZC66W.js";import"./chunk-J2PN6CG3.js";import"./chunk-H42TSPVA.js";import"./chunk-DUU6T2I5.js";export{a as default};
2
+ //# sourceMappingURL=GraphSettingsDialog-XXCBW2UA.js.map
@@ -1,2 +1,2 @@
1
- import{S as d,T as m}from"./chunk-CKQNUMI7.js";import"./chunk-MH3KMMEC.js";import"./chunk-TNB64ZLS.js";import"./chunk-ADZSOZAK.js";import"./chunk-MOQJ2IEL.js";import{A as h,G as c,I as n,d as v,o as f,q as C,r as b}from"./chunk-H42TSPVA.js";import{a as y,b as l,c as s,d as g}from"./chunk-DUU6T2I5.js";var D=g(function({model:o,onClose:t}){return s(v,{open:!0,onClose:t,title:"Color highlighted haplotypes",children:[s(b,{sx:{display:"grid",gridTemplateColumns:"auto 1fr 1fr",alignItems:"center",gap:1.5},children:[l(n,{variant:"subtitle2",children:"Haplotype"}),l(n,{variant:"subtitle2",children:"Color by"}),l(n,{variant:"subtitle2",children:"Palette"}),o.drawnWalks.map(({name:a,encoding:p})=>l(S,{label:o.walkLabel(a),field:p.field,scheme:p.scheme,onField:i=>{o.setWalkColor(a,{field:i})},onScheme:i=>{o.setWalkColor(a,{scheme:i})}},a))]}),l(C,{children:l(f,{variant:"contained",onClick:t,children:"Done"})})]})}),S=g(function({label:o,field:t,scheme:a,onField:p,onScheme:i}){return s(y,{children:[l(n,{variant:"body2",children:o}),l(c,{select:!0,size:"small",value:t,slotProps:{select:{SelectDisplayProps:{"aria-label":`Color ${o} by`}}},onChange:e=>{let r=d.find(u=>u.value===e.target.value);r&&p(r.value)},children:d.map(e=>l(h,{value:e.value,children:e.label},e.value))}),l(c,{select:!0,size:"small",value:a,slotProps:{select:{SelectDisplayProps:{"aria-label":`Palette for ${o}`}}},onChange:e=>{let r=m.find(u=>u.value===e.target.value);r&&i(r.value)},children:m.filter(e=>e.value!=="rainbow"||t==="reference").map(e=>l(h,{value:e.value,children:e.label},e.value))})]})}),L=D;export{L as default};
2
- //# sourceMappingURL=HighlightColorDialog-AZTOOI72.js.map
1
+ import{S as d,T as m}from"./chunk-BDBERNEC.js";import"./chunk-4JYYNBSO.js";import"./chunk-NGTPDYX7.js";import"./chunk-TD6XNJRC.js";import"./chunk-4FDZC66W.js";import{A as h,G as c,I as n,d as v,o as f,q as C,r as b}from"./chunk-H42TSPVA.js";import{a as y,b as l,c as s,d as g}from"./chunk-DUU6T2I5.js";var D=g(function({model:o,onClose:t}){return s(v,{open:!0,onClose:t,title:"Color highlighted haplotypes",children:[s(b,{sx:{display:"grid",gridTemplateColumns:"auto 1fr 1fr",alignItems:"center",gap:1.5},children:[l(n,{variant:"subtitle2",children:"Haplotype"}),l(n,{variant:"subtitle2",children:"Color by"}),l(n,{variant:"subtitle2",children:"Palette"}),o.drawnWalks.map(({name:a,encoding:p})=>l(S,{label:o.walkLabel(a),field:p.field,scheme:p.scheme,onField:i=>{o.setWalkColor(a,{field:i})},onScheme:i=>{o.setWalkColor(a,{scheme:i})}},a))]}),l(C,{children:l(f,{variant:"contained",onClick:t,children:"Done"})})]})}),S=g(function({label:o,field:t,scheme:a,onField:p,onScheme:i}){return s(y,{children:[l(n,{variant:"body2",children:o}),l(c,{select:!0,size:"small",value:t,slotProps:{select:{SelectDisplayProps:{"aria-label":`Color ${o} by`}}},onChange:e=>{let r=d.find(u=>u.value===e.target.value);r&&p(r.value)},children:d.map(e=>l(h,{value:e.value,children:e.label},e.value))}),l(c,{select:!0,size:"small",value:a,slotProps:{select:{SelectDisplayProps:{"aria-label":`Palette for ${o}`}}},onChange:e=>{let r=m.find(u=>u.value===e.target.value);r&&i(r.value)},children:m.filter(e=>e.value!=="rainbow"||t==="reference").map(e=>l(h,{value:e.value,children:e.label},e.value))})]})}),L=D;export{L as default};
2
+ //# sourceMappingURL=HighlightColorDialog-AD7B53ZA.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b as i}from"./chunk-L2YRM5BR.js";import"./chunk-B65Y26K2.js";import"./chunk-IAN7FKQ5.js";import"./chunk-CWT6WZ3D.js";import"./chunk-BCRRODIU.js";import"./chunk-V5ZGDS4W.js";import"./chunk-5BMTS4FH.js";import"./chunk-BDBERNEC.js";import"./chunk-AW7U7KMG.js";import"./chunk-4JYYNBSO.js";import"./chunk-7V5D6ZDX.js";import"./chunk-ZQOMV674.js";import"./chunk-IQURFLWC.js";import"./chunk-HT3RFCRI.js";import"./chunk-YBLNN5FU.js";import"./chunk-KFSVGH3X.js";import"./chunk-NGTPDYX7.js";import"./chunk-TD6XNJRC.js";import"./chunk-D3QZGLZ3.js";import"./chunk-WKD7ALOU.js";import"./chunk-SMC6O3CR.js";import"./chunk-TMM73K4C.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-4FDZC66W.js";import"./chunk-5L276I7O.js";import"./chunk-J2PN6CG3.js";import"./chunk-H42TSPVA.js";import{b as o,d as t}from"./chunk-DUU6T2I5.js";var e=JBrowseExports["@jbrowse/display-kit/DisplayChrome"];var s=e&&e.__esModule?e.default:e;var p=t(function({model:r}){return o(s,{model:r,factory:a,testid:"linear-graph-display","data-layout":r.chosenLayoutMode,"data-cut-tier":r.cutTier,"data-recuts":r.recuts,"data-node-count":r.hasGraph?r.nodeCount:void 0,"data-loading":r.isLoading?"":void 0,style:{width:r.paneWidth,height:r.height,overflow:"hidden"},children:n=>o(i,{model:r,handle:n})})}),c=p;export{c as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-26MRFDXW.js.map
@@ -1,2 +1,2 @@
1
- import{a as c,d,f as h}from"./chunk-PKHR5PYT.js";import{a as m}from"./chunk-V55TK2NP.js";import{a as b,c as p,d as u,g as f,h as g}from"./chunk-GZW7Q3SG.js";import"./chunk-TQZH7NNB.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-MOQJ2IEL.js";import{a as i,q as l}from"./chunk-5L276I7O.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=u(this,["bubblesLocation"],["index"]);this.refNames=new g(f(this.bubbles),this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:N}=s;return m(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",N,()=>p(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(y,R)=>{let e=c(y);r.next(new i({uniqueId:`bubble-${R}`,refName:t.refName,start:e.start,end:e.end,name:d(e),description:h(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-EYQBOSUD.js.map
1
+ import{a as c,d,f as h}from"./chunk-7V5D6ZDX.js";import{a as m}from"./chunk-V55TK2NP.js";import{a as b,c as p,d as u,g as f,h as g}from"./chunk-H6TKCTCB.js";import"./chunk-SMC6O3CR.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-4FDZC66W.js";import{a as i,q as l}from"./chunk-5L276I7O.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=u(this,["bubblesLocation"],["index"]);this.refNames=new g(f(this.bubbles),this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:N}=s;return m(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",N,()=>p(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(y,R)=>{let e=c(y);r.next(new i({uniqueId:`bubble-${R}`,refName:t.refName,start:e.start,end:e.end,name:d(e),description:h(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
2
+ //# sourceMappingURL=MinigraphBubbleAdapter-W7RUVFVI.js.map
@@ -1,2 +1,2 @@
1
- import{a as y}from"./chunk-NIWIX7TE.js";import"./chunk-ZQOMV674.js";import"./chunk-7B37TB2B.js";import{a as w}from"./chunk-V55TK2NP.js";import"./chunk-YBLNN5FU.js";import"./chunk-26XYOMO2.js";import"./chunk-TNB64ZLS.js";import"./chunk-ADZSOZAK.js";import{a as u,c as f,d as p,e as F,g as c,h as d}from"./chunk-GZW7Q3SG.js";import{A as R,w as b,x as k,y as x,z as N}from"./chunk-TQZH7NNB.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import{e as g}from"./chunk-EGZZ3ADM.js";import"./chunk-MOQJ2IEL.js";import{a as m,q as l}from"./chunk-5L276I7O.js";var h=class extends u{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let t=this.getConf("walksLocation"),n=e.length===0&&g(t)?new y(F(this),this):void 0,r=e.length===0?this.getConf("graphLocation"):this.getConf(["coarse","graphLocation"]);if(g(r)){let s=p(this,[...e,"graphLocation"],[...e,"graphIndex"]);return{graph:s,walks:n,refNames:new d(n?.source??c(s),this)}}let a=p(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),i=p(this,[...e,"linksLocation"],[...e,"linksIndex"]);return{segments:a,links:i,walks:n,refNames:new d(n?.source??c(a),this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async getRegionByteSize(e,t={}){return this.fine.refNames.regionBytes(e,t)}async hasDataForRefName(){return!0}getFeatures(e,t={}){return w(async n=>{let r=await this.fine.refNames.resolveMapped(e,t);if(r!==void 0){let{walks:a}=this.fine,i=s=>{n.next(s)};await(a?this.walkFeatures(a,r,e,t,i):this.segmentFeatures(r,e,t,i))}n.complete()},t.signal)}async walkFeatures(e,t,n,r,a){let i=await l("Downloading walks",r.statusCallback,()=>e.referenceNodes(t,n,r));for(let s of i){let o=String(s.id);a(new m({uniqueId:o,refName:n.refName,start:s.start,end:s.end,name:o,type:"segment",rank:0,stableName:s.refName}))}}async segmentRows(e,t,n,r){let a=this.fine;if("graph"in a){let i=x(await a.graph.getHeaderLines({signal:n.signal}));return f(a.graph,e,t.start,t.end,{signal:n.signal,lineCallback:s=>{let o=N(s,i);o?.kind==="N"&&r(o.segment,i.anchored)}})}return f(a.segments,e,t.start,t.end,{signal:n.signal,lineCallback:i=>{let{segment:s,anchored:o}=b(i);r(s,o)}})}async segmentFeatures(e,t,n,r){await l("Downloading segments",n.statusCallback,()=>this.segmentRows(e,t,n,(a,i)=>{if(i&&a.refName!==e)return;let s=k(a);r(new m({uniqueId:a.id,refName:t.refName,start:a.start,end:a.end,name:a.id,type:"segment",rank:a.rank,stableName:a.refName,...s&&{samples:s,sampleCount:s.length}}))}))}async getSubgraph(e,t={}){let{hops:n,signal:r,tier:a}=t,i=this.index(a),s=await i.refNames.resolveForCut(e,{signal:r});return i.walks?i.walks.subgraph(s,e,t):R(i,{refName:s,start:e.start,end:e.end},{hops:n,signal:r})}};export{h as default};
2
- //# sourceMappingURL=RgfaTabixAdapter-MKQTIDHN.js.map
1
+ import{a as y}from"./chunk-FSVORNAP.js";import"./chunk-ZQOMV674.js";import"./chunk-3QEIRGMZ.js";import{a as w}from"./chunk-V55TK2NP.js";import"./chunk-YBLNN5FU.js";import"./chunk-KFSVGH3X.js";import"./chunk-NGTPDYX7.js";import"./chunk-TD6XNJRC.js";import{a as u,c as f,d as p,e as F,g as c,h as d}from"./chunk-H6TKCTCB.js";import{A as R,w as b,x as k,y as x,z as N}from"./chunk-SMC6O3CR.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import{e as g}from"./chunk-EGZZ3ADM.js";import"./chunk-4FDZC66W.js";import{a as m,q as l}from"./chunk-5L276I7O.js";var h=class extends u{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let t=this.getConf("walksLocation"),n=e.length===0&&g(t)?new y(F(this),this):void 0,r=e.length===0?this.getConf("graphLocation"):this.getConf(["coarse","graphLocation"]);if(g(r)){let s=p(this,[...e,"graphLocation"],[...e,"graphIndex"]);return{graph:s,walks:n,refNames:new d(n?.source??c(s),this)}}let a=p(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),i=p(this,[...e,"linksLocation"],[...e,"linksIndex"]);return{segments:a,links:i,walks:n,refNames:new d(n?.source??c(a),this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async getRegionByteSize(e,t={}){return this.fine.refNames.regionBytes(e,t)}async hasDataForRefName(){return!0}getFeatures(e,t={}){return w(async n=>{let r=await this.fine.refNames.resolveMapped(e,t);if(r!==void 0){let{walks:a}=this.fine,i=s=>{n.next(s)};await(a?this.walkFeatures(a,r,e,t,i):this.segmentFeatures(r,e,t,i))}n.complete()},t.signal)}async walkFeatures(e,t,n,r,a){let i=await l("Downloading walks",r.statusCallback,()=>e.referenceNodes(t,n,r));for(let s of i){let o=String(s.id);a(new m({uniqueId:o,refName:n.refName,start:s.start,end:s.end,name:o,type:"segment",rank:0,stableName:s.refName}))}}async segmentRows(e,t,n,r){let a=this.fine;if("graph"in a){let i=x(await a.graph.getHeaderLines({signal:n.signal}));return f(a.graph,e,t.start,t.end,{signal:n.signal,lineCallback:s=>{let o=N(s,i);o?.kind==="N"&&r(o.segment,i.anchored)}})}return f(a.segments,e,t.start,t.end,{signal:n.signal,lineCallback:i=>{let{segment:s,anchored:o}=b(i);r(s,o)}})}async segmentFeatures(e,t,n,r){await l("Downloading segments",n.statusCallback,()=>this.segmentRows(e,t,n,(a,i)=>{if(i&&a.refName!==e)return;let s=k(a);r(new m({uniqueId:a.id,refName:t.refName,start:a.start,end:a.end,name:a.id,type:"segment",rank:a.rank,stableName:a.refName,...s&&{samples:s,sampleCount:s.length}}))}))}async getSubgraph(e,t={}){let{hops:n,signal:r,tier:a}=t,i=this.index(a),s=await i.refNames.resolveForCut(e,{signal:r});return i.walks?i.walks.subgraph(s,e,t):R(i,{refName:s,start:e.start,end:e.end},{hops:n,signal:r})}};export{h as default};
2
+ //# sourceMappingURL=RgfaTabixAdapter-QOEMTN56.js.map
@@ -1,2 +1,2 @@
1
- import{c as d,d as A,e as D,f as L,g as V}from"./chunk-ZVMXECJA.js";import{a as $}from"./chunk-V55TK2NP.js";import{a as k,e as _}from"./chunk-GZW7Q3SG.js";import{a as b,b as C,c as N,d as T,o as E,p as R,q as x,r as O,s as B,t as M,u as q,v as P}from"./chunk-TQZH7NNB.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-MOQJ2IEL.js";import{a as F,q as v}from"./chunk-5L276I7O.js";var I={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"}},Q=e=>e.lopsided??(e.delta<0?"deletion":"insertion"),J=e=>I[e.kind].consequence??(Q(e)==="deletion"?"loss":"gain"),U=e=>`F${e+1}`,Y="other";function W(e,o){let t=100*e/o;return t>0&&t<1?"<1%":`${Math.round(t)}%`}var g=({forms:e},o)=>e.length>o+1?Math.max(0,o):e.length,l=e=>e.reduce((o,t)=>o+t.members.length,0);function w(e,o=d){let t=g(e,o),n=e.forms.slice(t);return[...e.forms.slice(0,t).map((s,a)=>({name:U(a),label:`${W(s.members.length,e.placed)} \xB7 ${q(s,e)}`,haplotypes:s.members.length,forms:1})),...n.length>0?[{name:Y,label:`other forms \xB7 ${W(l(n),e.placed)}`,haplotypes:l(n),forms:n.length}]:[]]}var j=5;function G(e){let o=e.slice(0,j).join(", "),t=e.length-j;return t>0?`${o} and ${t} more`:o}var h=e=>`${e} haplotype${e===1?"":"s"}`;function H(e,o=d){let{unplaced:t,forms:n}=e,s=g(e,o),a=n.slice(s);return[...a.length>0?[`${a.length} smaller forms, ${h(l(a))}, share the empty "other forms" row; maxForms sets how many forms get a row of their own`]:[],...t.length>0?[`${h(t.length)} ${t.length===1?"has":"have"} no walk over the pinned window, so no form: ${G(t)}`]:[]]}function Z({copied:e,refStart:o,refEnd:t}){let[n,s]=e??[o,t];return{start:n,end:Math.max(s,n+1)}}var ee=(e,o)=>e===o?"1":e===R||e===x?".":"0";function X(e,o=d){let{sites:t,forms:n,placed:s}=e,a=g(e,o);return t.flatMap((r,m)=>r.edge?[]:r.states.flatMap(p=>{if(p.key===E)return[];let u=n.map(i=>M(e,i,m)),S=Object.fromEntries(u.slice(0,a).map((i,f)=>[U(f),ee(i,p.key)])),z=l(n.filter((i,f)=>u[f]===p.key));return Object.values(S).includes("1")?p.marks.map((i,f)=>({id:`${m}:${p.key}:${f}`,...Z(i),name:B(i),description:`${z} of ${h(s)}`,...I[i.kind],consequence:J(i),mark:i,genotypes:S})):[]}))}var K=e=>`${(e/1e6).toFixed(1)} MB`;function te(e,o){if(!(e instanceof b))return e;let t=L(o),n=`walkByteBudget, ${K(e.limit)}`;return new Error(`The pinned window ${t} is too large to cut for structural forms: ${e.zoomHelps?`about ${T(e.fitsBp)} of it fits in ${n}. Pin a narrower window or raise walkByteBudget`:`its cut fetches ${K(e.bytes??0)}, over ${n}. Raise walkByteBudget`}`)}var ne=8,c=new Map;function re(e,o){let t=c.get(e),n=t??o();if(c.delete(e),c.set(e,n),!t){n.catch(()=>{c.get(e)===n&&c.delete(e)});for(let s of c.keys()){if(c.size<=ne)break;c.delete(s)}}return n}var y=class extends k{constructor(){super(...arguments);this.reader=_(this);this.variants=new WeakMap}static{this.capabilities=["getFeatures","getRefNames"]}async referenceSample(t){let{references:n}=await this.reader.header(t);return n[0]??""}async getRefNames(t={}){let n=await this.reader.referenceSequences(t),s=await this.referenceSample(t),a=n.filter(r=>N(r,s)).map(r=>C(r));return a.length>0?[...new Set(a)]:n}pinned(){let t=A(this.getConf("pinned"));if(!t)throw new Error("WalkFormsAdapter needs `pinned`, the window its forms come from: { refName, start, end }");return t}async pinnedSequence(t){let n=await this.referenceSample(t),s=[this.pinned().refName,...this.getConf("pinnedAliases")];return(await Promise.all(s.map(r=>this.reader.sequenceFor(n,r,t)))).find(r=>r!==void 0)}forms(t){if(!this.formsRead){let n=this.pinned(),s=this.getConf("walkByteBudget"),a=this.pinnedSequence({}).then(r=>{let m={...n,refName:r??n.refName},p=`${JSON.stringify(this.getConf("walksLocation"))} ${m.refName}:${m.start}-${m.end} ${s}`;return re(p,()=>v("Cutting walks",t.statusCallback,()=>P(this.reader,m,{byteBudget:s}).catch(u=>{throw te(u,n)})))}).then(r=>O(r,{window:n,floorBp:D(this.getConf("floorBp")),exclude:this.getConf("exclude")}));a.catch(()=>{this.formsRead===a&&(this.formsRead=void 0)}),this.formsRead=a}return this.formsRead}variantsOf(t){let n=this.variants.get(t),s=n??X(t,this.maxForms());return n||this.variants.set(t,s),s}maxForms(){return this.getConf("maxForms")}async getSourcesAndWarnings(t={}){let n=await this.forms(t),s=V(this.pinned());return{sources:w(n,this.maxForms()),warnings:H(n,this.maxForms()).map(a=>s+a)}}async getSources(t,n={}){return w(await this.forms(n),this.maxForms())}async onPinnedSequence(t,n){let s=await this.referenceSample(n),[a,r]=await Promise.all([this.reader.sequenceFor(s,t,n),this.pinnedSequence(n)]);return a!==void 0&&a===r}getFeatures(t,n={}){return $(async s=>{if(await this.onPinnedSequence(t.refName,n)){let a=await this.forms(n);for(let r of this.variantsOf(a))r.start<t.end&&r.end>t.start&&s.next(new F({uniqueId:`forms-${a.floorBp}-${r.id}`,refName:t.refName,start:r.start,end:r.end,name:r.name,description:r.description,type:r.type,svType:r.svType,consequence:r.consequence,REF:"N",ALT:[r.alt],INFO:{SVTYPE:[r.svType],SVLEN:[r.mark.delta]},mark:r.mark,genotypes:r.genotypes}))}s.complete()},n.signal)}};export{y as default};
2
- //# sourceMappingURL=WalkFormsAdapter-DBX4OARV.js.map
1
+ import{c as d,d as A,e as D,f as L,g as V}from"./chunk-ZVMXECJA.js";import{a as $}from"./chunk-V55TK2NP.js";import{a as k,e as _}from"./chunk-H6TKCTCB.js";import{a as b,b as C,c as N,d as T,o as E,p as R,q as x,r as O,s as B,t as M,u as q,v as P}from"./chunk-SMC6O3CR.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-4FDZC66W.js";import{a as F,q as v}from"./chunk-5L276I7O.js";var I={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"}},Q=e=>e.lopsided??(e.delta<0?"deletion":"insertion"),J=e=>I[e.kind].consequence??(Q(e)==="deletion"?"loss":"gain"),U=e=>`F${e+1}`,Y="other";function W(e,o){let t=100*e/o;return t>0&&t<1?"<1%":`${Math.round(t)}%`}var g=({forms:e},o)=>e.length>o+1?Math.max(0,o):e.length,l=e=>e.reduce((o,t)=>o+t.members.length,0);function w(e,o=d){let t=g(e,o),n=e.forms.slice(t);return[...e.forms.slice(0,t).map((s,a)=>({name:U(a),label:`${W(s.members.length,e.placed)} \xB7 ${q(s,e)}`,haplotypes:s.members.length,forms:1})),...n.length>0?[{name:Y,label:`other forms \xB7 ${W(l(n),e.placed)}`,haplotypes:l(n),forms:n.length}]:[]]}var j=5;function G(e){let o=e.slice(0,j).join(", "),t=e.length-j;return t>0?`${o} and ${t} more`:o}var h=e=>`${e} haplotype${e===1?"":"s"}`;function H(e,o=d){let{unplaced:t,forms:n}=e,s=g(e,o),a=n.slice(s);return[...a.length>0?[`${a.length} smaller forms, ${h(l(a))}, share the empty "other forms" row; maxForms sets how many forms get a row of their own`]:[],...t.length>0?[`${h(t.length)} ${t.length===1?"has":"have"} no walk over the pinned window, so no form: ${G(t)}`]:[]]}function Z({copied:e,refStart:o,refEnd:t}){let[n,s]=e??[o,t];return{start:n,end:Math.max(s,n+1)}}var ee=(e,o)=>e===o?"1":e===R||e===x?".":"0";function X(e,o=d){let{sites:t,forms:n,placed:s}=e,a=g(e,o);return t.flatMap((r,m)=>r.edge?[]:r.states.flatMap(p=>{if(p.key===E)return[];let u=n.map(i=>M(e,i,m)),S=Object.fromEntries(u.slice(0,a).map((i,f)=>[U(f),ee(i,p.key)])),z=l(n.filter((i,f)=>u[f]===p.key));return Object.values(S).includes("1")?p.marks.map((i,f)=>({id:`${m}:${p.key}:${f}`,...Z(i),name:B(i),description:`${z} of ${h(s)}`,...I[i.kind],consequence:J(i),mark:i,genotypes:S})):[]}))}var K=e=>`${(e/1e6).toFixed(1)} MB`;function te(e,o){if(!(e instanceof b))return e;let t=L(o),n=`walkByteBudget, ${K(e.limit)}`;return new Error(`The pinned window ${t} is too large to cut for structural forms: ${e.zoomHelps?`about ${T(e.fitsBp)} of it fits in ${n}. Pin a narrower window or raise walkByteBudget`:`its cut fetches ${K(e.bytes??0)}, over ${n}. Raise walkByteBudget`}`)}var ne=8,c=new Map;function re(e,o){let t=c.get(e),n=t??o();if(c.delete(e),c.set(e,n),!t){n.catch(()=>{c.get(e)===n&&c.delete(e)});for(let s of c.keys()){if(c.size<=ne)break;c.delete(s)}}return n}var y=class extends k{constructor(){super(...arguments);this.reader=_(this);this.variants=new WeakMap}static{this.capabilities=["getFeatures","getRefNames"]}async referenceSample(t){let{references:n}=await this.reader.header(t);return n[0]??""}async getRefNames(t={}){let n=await this.reader.referenceSequences(t),s=await this.referenceSample(t),a=n.filter(r=>N(r,s)).map(r=>C(r));return a.length>0?[...new Set(a)]:n}pinned(){let t=A(this.getConf("pinned"));if(!t)throw new Error("WalkFormsAdapter needs `pinned`, the window its forms come from: { refName, start, end }");return t}async pinnedSequence(t){let n=await this.referenceSample(t),s=[this.pinned().refName,...this.getConf("pinnedAliases")];return(await Promise.all(s.map(r=>this.reader.sequenceFor(n,r,t)))).find(r=>r!==void 0)}forms(t){if(!this.formsRead){let n=this.pinned(),s=this.getConf("walkByteBudget"),a=this.pinnedSequence({}).then(r=>{let m={...n,refName:r??n.refName},p=`${JSON.stringify(this.getConf("walksLocation"))} ${m.refName}:${m.start}-${m.end} ${s}`;return re(p,()=>v("Cutting walks",t.statusCallback,()=>P(this.reader,m,{byteBudget:s}).catch(u=>{throw te(u,n)})))}).then(r=>O(r,{window:n,floorBp:D(this.getConf("floorBp")),exclude:this.getConf("exclude")}));a.catch(()=>{this.formsRead===a&&(this.formsRead=void 0)}),this.formsRead=a}return this.formsRead}variantsOf(t){let n=this.variants.get(t),s=n??X(t,this.maxForms());return n||this.variants.set(t,s),s}maxForms(){return this.getConf("maxForms")}async getSourcesAndWarnings(t={}){let n=await this.forms(t),s=V(this.pinned());return{sources:w(n,this.maxForms()),warnings:H(n,this.maxForms()).map(a=>s+a)}}async getSources(t,n={}){return w(await this.forms(n),this.maxForms())}async onPinnedSequence(t,n){let s=await this.referenceSample(n),[a,r]=await Promise.all([this.reader.sequenceFor(s,t,n),this.pinnedSequence(n)]);return a!==void 0&&a===r}getFeatures(t,n={}){return $(async s=>{if(await this.onPinnedSequence(t.refName,n)){let a=await this.forms(n);for(let r of this.variantsOf(a))r.start<t.end&&r.end>t.start&&s.next(new F({uniqueId:`forms-${a.floorBp}-${r.id}`,refName:t.refName,start:r.start,end:r.end,name:r.name,description:r.description,type:r.type,svType:r.svType,consequence:r.consequence,REF:"N",ALT:[r.alt],INFO:{SVTYPE:[r.svType],SVLEN:[r.mark.delta]},mark:r.mark,genotypes:r.genotypes}))}s.complete()},n.signal)}};export{y as default};
2
+ //# sourceMappingURL=WalkFormsAdapter-AV746ZGI.js.map
@@ -1,2 +1,2 @@
1
- import{a as oe}from"./chunk-NIWIX7TE.js";import{a as re}from"./chunk-IK5G3JHR.js";import{a as se}from"./chunk-WSHN4CQP.js";import"./chunk-CKQNUMI7.js";import"./chunk-MH3KMMEC.js";import"./chunk-ZQOMV674.js";import{p as C,q as V,r as U,s as Q,t as Y,u as ae,v as ne}from"./chunk-CK5762BL.js";import"./chunk-7B37TB2B.js";import{a as z}from"./chunk-V55TK2NP.js";import"./chunk-JM4W4PKP.js";import{b as ee,c as te,d as L}from"./chunk-G6SF7JOB.js";import"./chunk-YBLNN5FU.js";import"./chunk-26XYOMO2.js";import"./chunk-TNB64ZLS.js";import"./chunk-ADZSOZAK.js";import"./chunk-FQI75MV6.js";import{e as Z,h as J}from"./chunk-GZW7Q3SG.js";import{e as G}from"./chunk-TQZH7NNB.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import{e as q}from"./chunk-EGZZ3ADM.js";import{a as E,c as X,d as A,g as M,h as F,i as v}from"./chunk-MOQJ2IEL.js";import{q as K}from"./chunk-5L276I7O.js";var ge=50;function be(n){let s=[];for(let e=0;e<n.length;e++){let[t,o]=n[e],[a,r]=n[e+1]??[];o===r&&o<=ge&&(t==="I"&&a==="D"||t==="D"&&a==="I")?(s.push(["X",o]),e++):s.push([t,o])}return s}function R({ids:n,rev:s}){let e=new Array(n.length);for(let t=0;t<n.length;t++)e[t]=2*n[t]+s[t];return e}function P(n){let s=new Map;return e=>{let t=s.get(e);return t===void 0&&(t={value:n(e)},s.set(e,t)),t.value}}function B(n,s){let e=n.get(s);return e===void 0?0:e.end-e.start}function me(n){let s=new Map,e=o=>{let a=B(n,o),r=s.get(a);return r===void 0&&(r="N".repeat(a),s.set(a,r)),r},t=P(R);return(o,a)=>V({query:t(o),target:t(a),sequenceOf:e,bases:!1})}var _=100;function I(n,s,e){let t=n.at(-1);e>0&&(t?.[0]===s?t[1]+=e:n.push([s,e]))}function ye(n){let s=le(n);return(e,t)=>s(e,t).records}function le(n){let s=a=>B(n,a>>1),e=a=>{let r=new Float64Array(a.length+1);for(let i=0;i<a.length;i++)r[i+1]=r[i]+s(a[i]);return r},t=P(a=>{let r=R(a);return{handles:r,at:e(r),passed:new Set(r)}}),o=(a,r)=>{let i=0;for(let l of a)r.has(l^1)&&(i+=s(l));return i};return(a,r)=>{let{handles:i,at:l,passed:f}=t(r),c=R(a),u=o(c,f),[g,b]=C(c,i,s),[y,d]=u>b?C(c.map(p=>p^1).reverse(),i,s):[[],0],N=d>b,h=N?y:g,S=Math.max(b,d);if(S<_)return{records:[],turnedBases:u};let k=e(c),W=p=>N?c.length-1-h[p][0]:h[p][0],w=[];for(let p=0;p<h.length;p++){let O=h[p][1];if(p>0){let j=W(p-1),H=W(p);I(w,"I",k[Math.max(j,H)]-k[Math.min(j,H)+1]),I(w,"D",l[O]-l[h[p-1][1]+1])}I(w,"=",s(i[O]))}let x=W(0),m=W(h.length-1);return{turnedBases:u,records:[{queryStart:k[Math.min(x,m)],queryEnd:k[Math.max(x,m)+1],targetStart:l[h[0][1]],targetEnd:l[h.at(-1)[1]+1],strand:N?"-":"+",edits:w,sharedBases:S}]}}}function Ne(n){let s=new Map,e=new Set;n.ids.forEach((t,o)=>{s.has(t)?e.add(t):s.set(t,n.rev[o])});for(let t of e)s.delete(t);return s}function ce(n){let s=P(Ne);return(e,t)=>{let o=s(t),a=0,r=0;for(let[i,l]of s(e)){let f=o.get(i);f===l?a+=B(n,i):f!==void 0&&(r+=B(n,i))}return{same:a,opposite:r}}}function ue(n){let s=ye(n),e=me(n),t=ce(n);return(o,a)=>{let{same:r,opposite:i}=t(o,a);return r>=_&&i>=_?e(o,a):s(o,a)}}var ie=1e4;function pe(n){let s=le(n),e=me(n),t=ce(n),o=(a,r)=>{let{same:i,opposite:l}=t(a,r);return Math.min(i,l)>=ie};return(a,r)=>{let{records:i,turnedBases:l}=s(a,r),f=i[0]?.strand;return f===void 0||l<ie||!o(a,r)?i:[...i,...e(a,r).filter(c=>c.strand!==f)]}}function D({chain:n,target:s,query:e,assemblyName:t,refName:o,mateAssemblyName:a}){let r=be(n.edits);return ne({target:{name:s.name,assemblyName:t,refName:o,start:s.hapStart+n.targetStart,end:s.hapStart+n.targetEnd},query:{name:e.name,assemblyName:a,refName:A(e.name),start:e.hapStart+n.queryStart,end:e.hapStart+n.queryEnd},strand:n.strand,cigar:U(r),matches:r.reduce((i,[l,f])=>i+(l==="="?f:0),0),columns:r.reduce((i,[,l])=>i+l,0)})}function fe(n,s,e,t){return n.ids.some(o=>{let a=s.get(o);return a?.rank===0&&a.refName===e&&a.start<t.end&&a.end>t.start})}function de({leavePos:n,rejoinPos:s},e){return Math.min(n,s)<=e.start&&Math.max(n,s)>=e.end}function he({departure:n,refName:s,assemblyName:e,mateAssemblyName:t}){let{name:o,hapStart:a,ownBp:r,leavePos:i,rejoinPos:l,rejoinReversed:f}=n,c=`${o}:${a}:${i}:departure`;return new Q({uniqueId:c,assemblyName:e,refName:s,start:Math.min(i,l),end:Math.max(i,l),type:"departure",strand:f?-1:1,syntenyId:c,spansWindow:!0,mate:{refName:A(o),start:a,end:a+r,assemblyName:t}})}var T=({name:n})=>X(n)??n,$=class extends Y{constructor(){super(...arguments);this.walks=new oe(Z(this),this);this.refNames=new J(this.walks.source,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let[{haplotypes:t},o]=await Promise.all([this.walks.reader.header(e),this.sheetColors(e)]),{anchor:a}=this,r=F(this,a),i=v(this),l=c=>c===r||E(c)===r,f=o?.(t.find(l)??r);return{hasCoarseTier:!1,anchorAssemblyName:a,...f===void 0?{}:{anchorColor:f},lanes:t.filter(c=>!l(c)).map(c=>{let u=o?.(c);return{name:L(i,c),label:c,group:E(c),...u===void 0?{}:{color:u}}})}}async sheetColors(e){let t=this.getConf("samplesTsvLocation");return q(t)?re({location:t,names:void 0,namesLabel:"the walk file",pluginManager:this.pluginManager,opts:e}).then(({sources:o})=>se(o,v(this)),()=>{}):void 0}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let o=await this.refNames.resolveForCut(e,{signal:t.signal});return this.walks.subgraph(o,e,t)}async laneWalks(e,t,o,a,r){let i=G(o,e);return K(r,a.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.cutOptions(),signal:a.signal,keep:i,expand:i,links:"none"}).catch(l=>{throw ae(l,t.end-t.start)}))}async anchorFeatures(e,t,o){let a=o.haplotypes?.length?o.haplotypes.map(m=>F(this,m)):void 0,r=F(this,o.targetAssemblyName),i=r===void 0?a:a===void 0||a.some(m=>M(r,m)||M(m,r))?[r]:[];if(i?.length===0)return[];let{start:l,end:f}=t,c=`Reading walks ${t.refName}:${l.toLocaleString()}-${f.toLocaleString()}`,{graph:u,fragments:g,departures:b}=await this.laneWalks(e,t,i,o,c),y=P(m=>i===void 0?0:i.findIndex(p=>M(m,p))),d=({name:m})=>y(m),N=pe(u.nodes),h=v(this),S=m=>L(h,T(m)),k=g.filter(m=>m.name===e),W=g.filter(m=>m.name!==e&&d(m)>=0).map(m=>({rank:d(m),features:k.flatMap(p=>N(m,p).map(O=>D({chain:O,target:p,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:S(m)})))})),w=new Set(g.filter(m=>fe(m,u.nodes,e,t)).map(T)),x=b.filter(m=>d(m)>=0&&!w.has(T(m))&&de(m,t)).sort((m,p)=>m.name.localeCompare(p.name)).map(m=>({rank:d(m),features:[he({departure:m,refName:t.refName,assemblyName:t.assemblyName,mateAssemblyName:S(m)})]}));return[...W,...x].sort((m,p)=>m.rank-p.rank).flatMap(m=>m.features)}async pairFeatures(e,t,o,a){let r=o.map(u=>({pair:u,featurePrefix:F(this,u.queryAssemblyName),matePrefix:F(this,u.targetAssemblyName)})),{graph:i,fragments:l}=await this.laneWalks(e,t,r.flatMap(u=>[u.featurePrefix,u.matePrefix]),a,te(o)),f=ue(i.nodes),c=u=>l.filter(g=>M(g.name,u));return r.flatMap(({pair:u,featurePrefix:g,matePrefix:b})=>c(g).flatMap(y=>c(b).flatMap(d=>f(d,y).map(N=>D({chain:N,target:y,query:d,assemblyName:u.queryAssemblyName,refName:A(y.name),mateAssemblyName:u.targetAssemblyName})))))}getFeatures(e,t={}){return z(async o=>{let a=e.assemblyName===this.anchor?await this.refNames.resolveMapped(e,t):void 0;if(a!==void 0){let r=ee(t),i=r.length>0?await this.pairFeatures(a,e,r,t):await this.anchorFeatures(a,e,t);for(let l of i)o.next(l)}o.complete()},t.signal)}};export{$ as default};
2
- //# sourceMappingURL=WalkTabixSyntenyAdapter-JKMTJX64.js.map
1
+ import{a as oe}from"./chunk-FSVORNAP.js";import{a as re}from"./chunk-IK5G3JHR.js";import{a as se}from"./chunk-BCRRODIU.js";import"./chunk-BDBERNEC.js";import"./chunk-4JYYNBSO.js";import"./chunk-ZQOMV674.js";import{p as C,q as V,r as U,s as Q,t as Y,u as ae,v as ne}from"./chunk-CVHICHF5.js";import"./chunk-3QEIRGMZ.js";import{a as z}from"./chunk-V55TK2NP.js";import"./chunk-JM4W4PKP.js";import{b as ee,c as te,d as L}from"./chunk-IQURFLWC.js";import"./chunk-YBLNN5FU.js";import"./chunk-KFSVGH3X.js";import"./chunk-NGTPDYX7.js";import"./chunk-TD6XNJRC.js";import"./chunk-FQI75MV6.js";import{e as Z,h as J}from"./chunk-H6TKCTCB.js";import{e as G}from"./chunk-SMC6O3CR.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import{e as q}from"./chunk-EGZZ3ADM.js";import{a as E,c as X,d as A,g as M,h as F,i as v}from"./chunk-4FDZC66W.js";import{q as K}from"./chunk-5L276I7O.js";var ge=50;function be(n){let s=[];for(let e=0;e<n.length;e++){let[t,o]=n[e],[a,r]=n[e+1]??[];o===r&&o<=ge&&(t==="I"&&a==="D"||t==="D"&&a==="I")?(s.push(["X",o]),e++):s.push([t,o])}return s}function R({ids:n,rev:s}){let e=new Array(n.length);for(let t=0;t<n.length;t++)e[t]=2*n[t]+s[t];return e}function P(n){let s=new Map;return e=>{let t=s.get(e);return t===void 0&&(t={value:n(e)},s.set(e,t)),t.value}}function B(n,s){let e=n.get(s);return e===void 0?0:e.end-e.start}function me(n){let s=new Map,e=o=>{let a=B(n,o),r=s.get(a);return r===void 0&&(r="N".repeat(a),s.set(a,r)),r},t=P(R);return(o,a)=>V({query:t(o),target:t(a),sequenceOf:e,bases:!1})}var _=100;function I(n,s,e){let t=n.at(-1);e>0&&(t?.[0]===s?t[1]+=e:n.push([s,e]))}function ye(n){let s=le(n);return(e,t)=>s(e,t).records}function le(n){let s=a=>B(n,a>>1),e=a=>{let r=new Float64Array(a.length+1);for(let i=0;i<a.length;i++)r[i+1]=r[i]+s(a[i]);return r},t=P(a=>{let r=R(a);return{handles:r,at:e(r),passed:new Set(r)}}),o=(a,r)=>{let i=0;for(let l of a)r.has(l^1)&&(i+=s(l));return i};return(a,r)=>{let{handles:i,at:l,passed:f}=t(r),c=R(a),u=o(c,f),[g,b]=C(c,i,s),[y,d]=u>b?C(c.map(p=>p^1).reverse(),i,s):[[],0],N=d>b,h=N?y:g,S=Math.max(b,d);if(S<_)return{records:[],turnedBases:u};let k=e(c),W=p=>N?c.length-1-h[p][0]:h[p][0],w=[];for(let p=0;p<h.length;p++){let O=h[p][1];if(p>0){let j=W(p-1),H=W(p);I(w,"I",k[Math.max(j,H)]-k[Math.min(j,H)+1]),I(w,"D",l[O]-l[h[p-1][1]+1])}I(w,"=",s(i[O]))}let x=W(0),m=W(h.length-1);return{turnedBases:u,records:[{queryStart:k[Math.min(x,m)],queryEnd:k[Math.max(x,m)+1],targetStart:l[h[0][1]],targetEnd:l[h.at(-1)[1]+1],strand:N?"-":"+",edits:w,sharedBases:S}]}}}function Ne(n){let s=new Map,e=new Set;n.ids.forEach((t,o)=>{s.has(t)?e.add(t):s.set(t,n.rev[o])});for(let t of e)s.delete(t);return s}function ce(n){let s=P(Ne);return(e,t)=>{let o=s(t),a=0,r=0;for(let[i,l]of s(e)){let f=o.get(i);f===l?a+=B(n,i):f!==void 0&&(r+=B(n,i))}return{same:a,opposite:r}}}function ue(n){let s=ye(n),e=me(n),t=ce(n);return(o,a)=>{let{same:r,opposite:i}=t(o,a);return r>=_&&i>=_?e(o,a):s(o,a)}}var ie=1e4;function pe(n){let s=le(n),e=me(n),t=ce(n),o=(a,r)=>{let{same:i,opposite:l}=t(a,r);return Math.min(i,l)>=ie};return(a,r)=>{let{records:i,turnedBases:l}=s(a,r),f=i[0]?.strand;return f===void 0||l<ie||!o(a,r)?i:[...i,...e(a,r).filter(c=>c.strand!==f)]}}function D({chain:n,target:s,query:e,assemblyName:t,refName:o,mateAssemblyName:a}){let r=be(n.edits);return ne({target:{name:s.name,assemblyName:t,refName:o,start:s.hapStart+n.targetStart,end:s.hapStart+n.targetEnd},query:{name:e.name,assemblyName:a,refName:A(e.name),start:e.hapStart+n.queryStart,end:e.hapStart+n.queryEnd},strand:n.strand,cigar:U(r),matches:r.reduce((i,[l,f])=>i+(l==="="?f:0),0),columns:r.reduce((i,[,l])=>i+l,0)})}function fe(n,s,e,t){return n.ids.some(o=>{let a=s.get(o);return a?.rank===0&&a.refName===e&&a.start<t.end&&a.end>t.start})}function de({leavePos:n,rejoinPos:s},e){return Math.min(n,s)<=e.start&&Math.max(n,s)>=e.end}function he({departure:n,refName:s,assemblyName:e,mateAssemblyName:t}){let{name:o,hapStart:a,ownBp:r,leavePos:i,rejoinPos:l,rejoinReversed:f}=n,c=`${o}:${a}:${i}:departure`;return new Q({uniqueId:c,assemblyName:e,refName:s,start:Math.min(i,l),end:Math.max(i,l),type:"departure",strand:f?-1:1,syntenyId:c,spansWindow:!0,mate:{refName:A(o),start:a,end:a+r,assemblyName:t}})}var T=({name:n})=>X(n)??n,$=class extends Y{constructor(){super(...arguments);this.walks=new oe(Z(this),this);this.refNames=new J(this.walks.source,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let[{haplotypes:t},o]=await Promise.all([this.walks.reader.header(e),this.sheetColors(e)]),{anchor:a}=this,r=F(this,a),i=v(this),l=c=>c===r||E(c)===r,f=o?.(t.find(l)??r);return{hasCoarseTier:!1,anchorAssemblyName:a,...f===void 0?{}:{anchorColor:f},lanes:t.filter(c=>!l(c)).map(c=>{let u=o?.(c);return{name:L(i,c),label:c,group:E(c),...u===void 0?{}:{color:u}}})}}async sheetColors(e){let t=this.getConf("samplesTsvLocation");return q(t)?re({location:t,names:void 0,namesLabel:"the walk file",pluginManager:this.pluginManager,opts:e}).then(({sources:o})=>se(o,v(this)),()=>{}):void 0}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let o=await this.refNames.resolveForCut(e,{signal:t.signal});return this.walks.subgraph(o,e,t)}async laneWalks(e,t,o,a,r){let i=G(o,e);return K(r,a.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.cutOptions(),signal:a.signal,keep:i,expand:i,links:"none"}).catch(l=>{throw ae(l,t.end-t.start)}))}async anchorFeatures(e,t,o){let a=o.haplotypes?.length?o.haplotypes.map(m=>F(this,m)):void 0,r=F(this,o.targetAssemblyName),i=r===void 0?a:a===void 0||a.some(m=>M(r,m)||M(m,r))?[r]:[];if(i?.length===0)return[];let{start:l,end:f}=t,c=`Reading walks ${t.refName}:${l.toLocaleString()}-${f.toLocaleString()}`,{graph:u,fragments:g,departures:b}=await this.laneWalks(e,t,i,o,c),y=P(m=>i===void 0?0:i.findIndex(p=>M(m,p))),d=({name:m})=>y(m),N=pe(u.nodes),h=v(this),S=m=>L(h,T(m)),k=g.filter(m=>m.name===e),W=g.filter(m=>m.name!==e&&d(m)>=0).map(m=>({rank:d(m),features:k.flatMap(p=>N(m,p).map(O=>D({chain:O,target:p,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:S(m)})))})),w=new Set(g.filter(m=>fe(m,u.nodes,e,t)).map(T)),x=b.filter(m=>d(m)>=0&&!w.has(T(m))&&de(m,t)).sort((m,p)=>m.name.localeCompare(p.name)).map(m=>({rank:d(m),features:[he({departure:m,refName:t.refName,assemblyName:t.assemblyName,mateAssemblyName:S(m)})]}));return[...W,...x].sort((m,p)=>m.rank-p.rank).flatMap(m=>m.features)}async pairFeatures(e,t,o,a){let r=o.map(u=>({pair:u,featurePrefix:F(this,u.queryAssemblyName),matePrefix:F(this,u.targetAssemblyName)})),{graph:i,fragments:l}=await this.laneWalks(e,t,r.flatMap(u=>[u.featurePrefix,u.matePrefix]),a,te(o)),f=ue(i.nodes),c=u=>l.filter(g=>M(g.name,u));return r.flatMap(({pair:u,featurePrefix:g,matePrefix:b})=>c(g).flatMap(y=>c(b).flatMap(d=>f(d,y).map(N=>D({chain:N,target:y,query:d,assemblyName:u.queryAssemblyName,refName:A(y.name),mateAssemblyName:u.targetAssemblyName})))))}getFeatures(e,t={}){return z(async o=>{let a=e.assemblyName===this.anchor?await this.refNames.resolveMapped(e,t):void 0;if(a!==void 0){let r=ee(t),i=r.length>0?await this.pairFeatures(a,e,r,t):await this.anchorFeatures(a,e,t);for(let l of i)o.next(l)}o.complete()},t.signal)}};export{$ as default};
2
+ //# sourceMappingURL=WalkTabixSyntenyAdapter-HEXLZ5YL.js.map
@@ -0,0 +1,2 @@
1
+ import{j as o}from"./chunk-KFSVGH3X.js";import{B as e}from"./chunk-SMC6O3CR.js";function d(r,n,t){let a=e(r);return t?{...r,abridged:a,walkRowRuns:o(r,n)}:{...r,abridged:a}}export{d as a};
2
+ //# sourceMappingURL=chunk-3QEIRGMZ.js.map
@@ -1,2 +1,2 @@
1
1
  var s="#";function c(n){return n.split(s)[0]}var a=new Set(["_gbwt_ref"]);function u(n){return a.has(n)}function f(n){let t=n.split(s);return t.length>=3?`${t[0]}${s}${t[1]}`:void 0}function y(n){let t=n.split(s);return t.length>=3?t.slice(2).join(s):t.length===2?t[1]:n}function N(n){let[t="",e="",...o]=n.split(s);return o.length>0&&/^\d+$/.test(e)?{sample:t,haplotype:+e,contig:o.join(s)}:void 0}function m(n){let t=n.split(s),e=t.length>=2&&t[1]!==""?Number(t[1]):Number.NaN;return{sample:t[0],haplotype:Number.isFinite(e)?e:void 0}}function S(n,t){return t!==void 0&&(n===t||n.startsWith(t+s))}var p=n=>typeof n=="object"&&n!==null&&Object.values(n).every(t=>typeof t=="string");function r(n){let t=n.getConf("assemblyNameToPanSN");return p(t)?t:{}}function g(n,t){return t===void 0?void 0:r(n)[t]??t}function l(n){let t=n.getConf("assemblyNames");return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}var i=new WeakMap;function h(n){let t=i.get(n);if(t===void 0){let e=r(n);t={};for(let o of new Set([...Object.keys(e),...l(n)]))t[e[o]??o]=o;i.set(n,t)}return t}export{c as a,u as b,f as c,y as d,N as e,m as f,S as g,g as h,h as i};
2
- //# sourceMappingURL=chunk-MOQJ2IEL.js.map
2
+ //# sourceMappingURL=chunk-4FDZC66W.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.1.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-W6DDM47C.js"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.2.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-W6DDM47C.js"],
4
4
  "sourcesContent": ["// src/pansn.ts\nvar SEP = \"#\";\nfunction panSNSample(refName) {\n return refName.split(SEP)[0];\n}\nvar GENERIC_SAMPLES = /* @__PURE__ */ new Set([\"_gbwt_ref\"]);\nfunction isGenericSample(sample) {\n return GENERIC_SAMPLES.has(sample);\n}\nfunction panSNHaplotype(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? `${parts[0]}${SEP}${parts[1]}` : void 0;\n}\nfunction panSNContig(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? parts.slice(2).join(SEP) : parts.length === 2 ? parts[1] : refName;\n}\nfunction panSNFields(name) {\n const [sample = \"\", haplotype = \"\", ...contig] = name.split(SEP);\n return contig.length > 0 && /^\\d+$/.test(haplotype) ? { sample, haplotype: +haplotype, contig: contig.join(SEP) } : void 0;\n}\nfunction parsePanSN(refName) {\n const parts = refName.split(SEP);\n const haplotype = parts.length >= 2 && parts[1] !== \"\" ? Number(parts[1]) : Number.NaN;\n return {\n sample: parts[0],\n haplotype: Number.isFinite(haplotype) ? haplotype : void 0\n };\n}\nfunction panSNMatchesPrefix(refName, prefix) {\n return prefix !== void 0 && (refName === prefix || refName.startsWith(prefix + SEP));\n}\nvar isNameMap = (value) => typeof value === \"object\" && value !== null && Object.values(value).every((v) => typeof v === \"string\");\nfunction assemblyNameToPanSN(adapter) {\n const map = adapter.getConf(\"assemblyNameToPanSN\");\n return isNameMap(map) ? map : {};\n}\nfunction resolvePanSNPrefix(adapter, name) {\n return name === void 0 ? void 0 : assemblyNameToPanSN(adapter)[name] ?? name;\n}\nfunction assemblyNames(adapter) {\n const names = adapter.getConf(\"assemblyNames\");\n return Array.isArray(names) ? names.filter((name) => typeof name === \"string\") : [];\n}\nvar asmByPrefixCache = /* @__PURE__ */ new WeakMap();\nfunction assemblyByPanSNPrefix(adapter) {\n let out = asmByPrefixCache.get(adapter);\n if (out === void 0) {\n const map = assemblyNameToPanSN(adapter);\n out = {};\n for (const asm of /* @__PURE__ */ new Set([\n ...Object.keys(map),\n ...assemblyNames(adapter)\n ])) {\n out[map[asm] ?? asm] = asm;\n }\n asmByPrefixCache.set(adapter, out);\n }\n return out;\n}\n\nexport {\n panSNSample,\n isGenericSample,\n panSNHaplotype,\n panSNContig,\n panSNFields,\n parsePanSN,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n assemblyByPanSNPrefix\n};\n"],
5
5
  "mappings": "AACA,IAAIA,EAAM,IACV,SAASC,EAAYC,EAAS,CAC5B,OAAOA,EAAQ,MAAMF,CAAG,EAAE,CAAC,CAC7B,CACA,IAAIG,EAAkC,IAAI,IAAI,CAAC,WAAW,CAAC,EAC3D,SAASC,EAAgBC,EAAQ,CAC/B,OAAOF,EAAgB,IAAIE,CAAM,CACnC,CACA,SAASC,EAAeJ,EAAS,CAC/B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EAC/B,OAAOO,EAAM,QAAU,EAAI,GAAGA,EAAM,CAAC,CAAC,GAAGP,CAAG,GAAGO,EAAM,CAAC,CAAC,GAAK,MAC9D,CACA,SAASC,EAAYN,EAAS,CAC5B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EAC/B,OAAOO,EAAM,QAAU,EAAIA,EAAM,MAAM,CAAC,EAAE,KAAKP,CAAG,EAAIO,EAAM,SAAW,EAAIA,EAAM,CAAC,EAAIL,CACxF,CACA,SAASO,EAAYC,EAAM,CACzB,GAAM,CAACL,EAAS,GAAIM,EAAY,GAAI,GAAGC,CAAM,EAAIF,EAAK,MAAMV,CAAG,EAC/D,OAAOY,EAAO,OAAS,GAAK,QAAQ,KAAKD,CAAS,EAAI,CAAE,OAAAN,EAAQ,UAAW,CAACM,EAAW,OAAQC,EAAO,KAAKZ,CAAG,CAAE,EAAI,MACtH,CACA,SAASa,EAAWX,EAAS,CAC3B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EACzBW,EAAYJ,EAAM,QAAU,GAAKA,EAAM,CAAC,IAAM,GAAK,OAAOA,EAAM,CAAC,CAAC,EAAI,OAAO,IACnF,MAAO,CACL,OAAQA,EAAM,CAAC,EACf,UAAW,OAAO,SAASI,CAAS,EAAIA,EAAY,MACtD,CACF,CACA,SAASG,EAAmBZ,EAASa,EAAQ,CAC3C,OAAOA,IAAW,SAAWb,IAAYa,GAAUb,EAAQ,WAAWa,EAASf,CAAG,EACpF,CACA,IAAIgB,EAAaC,GAAU,OAAOA,GAAU,UAAYA,IAAU,MAAQ,OAAO,OAAOA,CAAK,EAAE,MAAOC,GAAM,OAAOA,GAAM,QAAQ,EACjI,SAASC,EAAoBC,EAAS,CACpC,IAAMC,EAAMD,EAAQ,QAAQ,qBAAqB,EACjD,OAAOJ,EAAUK,CAAG,EAAIA,EAAM,CAAC,CACjC,CACA,SAASC,EAAmBF,EAASV,EAAM,CACzC,OAAOA,IAAS,OAAS,OAASS,EAAoBC,CAAO,EAAEV,CAAI,GAAKA,CAC1E,CACA,SAASa,EAAcH,EAAS,CAC9B,IAAMI,EAAQJ,EAAQ,QAAQ,eAAe,EAC7C,OAAO,MAAM,QAAQI,CAAK,EAAIA,EAAM,OAAQd,GAAS,OAAOA,GAAS,QAAQ,EAAI,CAAC,CACpF,CACA,IAAIe,EAAmC,IAAI,QAC3C,SAASC,EAAsBN,EAAS,CACtC,IAAIO,EAAMF,EAAiB,IAAIL,CAAO,EACtC,GAAIO,IAAQ,OAAQ,CAClB,IAAMN,EAAMF,EAAoBC,CAAO,EACvCO,EAAM,CAAC,EACP,QAAWC,KAAuB,IAAI,IAAI,CACxC,GAAG,OAAO,KAAKP,CAAG,EAClB,GAAGE,EAAcH,CAAO,CAC1B,CAAC,EACCO,EAAIN,EAAIO,CAAG,GAAKA,CAAG,EAAIA,EAEzBH,EAAiB,IAAIL,EAASO,CAAG,CACnC,CACA,OAAOA,CACT",
6
6
  "names": ["SEP", "panSNSample", "refName", "GENERIC_SAMPLES", "isGenericSample", "sample", "panSNHaplotype", "parts", "panSNContig", "panSNFields", "name", "haplotype", "contig", "parsePanSN", "panSNMatchesPrefix", "prefix", "isNameMap", "value", "v", "assemblyNameToPanSN", "adapter", "map", "resolvePanSNPrefix", "assemblyNames", "names", "asmByPrefixCache", "assemblyByPanSNPrefix", "out", "asm"]
@@ -1,2 +1,2 @@
1
- import{A as at,C as St,E as Jt,J as te,K as J,Q as ee,R as ne,a as $,b as wt,c as K,d as Y,g as W,h as Vt,i as U,ka as oe,m as Z,ma as se,n as st,na as Q,o as jt,p as bt,q as rt,r as G,s as Kt,t as Ut,u as Zt,x as R}from"./chunk-ADZSOZAK.js";import{b as Qt,c as ct}from"./chunk-MOQJ2IEL.js";var ss=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"frequency",label:"By frequency",description:"As wide as the share of haplotypes that pass a node, or its AF tag: full width at 100%, half at 50%, and wider where a haplotype passes it more than once."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],sn=.3,kt=3,rn=.05;function re(t){let e=0,n=0;for(let o of t.nodes)e+=o.depth*o.length,n+=o.length;return n>0?e/n:0}function It(t){return t.sample===void 0?ct(t.name)??t.name:`${t.sample}#${t.haplotype??0}`}function At(t){let e=new Map;for(let n of t.paths??[]){let o=It(n);e.has(o)||e.set(o,e.size)}return e}function an(t){return At(t).size}function cn(t,e){return t.frequency??(e>0?t.depth/e:void 0)}function _t(t,e){return e==="depth"?re(t):e==="frequency"?an(t):0}function ae(t){return Math.min(kt,Math.max(rn,t))}function fn(t,e){let n=cn(t,e);return n===void 0?1:ae(n)}function rs(t){return[1,.5,.1].map(e=>({label:`${e*100}%`,widthPx:t*ae(e)}))}function ce(t,e){return!(e>0)||!(t>0)?1:Math.min(kt,Math.max(sn,Math.sqrt(t/e)))}function as(t,e,n){let o=1/0,s=-1/0;for(let{id:a,depth:c}of t.nodes)(!n||n.has(a))&&(o=Math.min(o,c),s=Math.max(s,c));let r=re(t);return(o<s?[s,o]:o===s?[s]:[]).map(a=>({depth:a,widthPx:e*ce(a,r)}))}function Et(t,e,n,o){return e*(n==="depth"?ce(t.depth,o):n==="frequency"?fn(t,o):1)}function ln(t,e){return t*(e==="uniform"?1:kt)}var dn=4;function un(t,e){return Math.max(t/e,dn)}function hn(t,e,n){let o=[...t.from,...t.to].flatMap(s=>{let r=n(s);return r===void 0?[]:[r]});return o.length>0?o.reduce((s,r)=>Math.min(s,r),1/0):e}function cs(t,e,n,o,s=0,r){let a=t?_t(t,o):0,c=f=>s>0?un(f,s)*s/2:f/2,i=f=>{let l=e?.get(f);return l?Et(l,n,o,a):void 0};return{maxHalfWidthPx:c(ln(n,o)),halfWidthPx:f=>{let l=i(f)??n,d=r?.get(f);return c(d?hn(d,l,i):l)}}}function Nt(t){return t==="+"?"-":"+"}function hs(t,e=new Set){let n=t.edges.map(st),o=new Map,s=(u,m,h)=>{$(o,`${u}|${m}`,h)};t.edges.forEach((u,m)=>{s(u.from,n[m].from,m),s(u.to,n[m].to,m)});let r=u=>{let m=o.get(`${u}|end`);if(m?.length!==1)return;let h=m[0],v=t.edges[h];return v.from===u&&v.to!==u&&!e.has(u)&&!e.has(v.to)&&n[h].from==="end"&&n[h].to==="start"&&o.get(`${v.to}|start`)?.length===1?h:void 0},a=new Set,c=new Map,i=new Map;for(let u of t.nodes){let m=o.get(`${u.id}|start`),h=m?.length===1?t.edges[m[0]].from:void 0;if(c.has(u.id)||h!==void 0&&r(h)===m[0])continue;let v=[u.id];for(;;){let y=r(v.at(-1)),M=y===void 0?void 0:t.edges[y].to;if(M===void 0||c.has(M))break;a.add(y),v.push(M)}for(let y of v)c.set(y,u.id);v.length>1&&i.set(u.id,v)}for(let u of t.nodes)c.has(u.id)||c.set(u.id,u.id);let f=new Map(t.nodes.map(u=>[u.id,u])),l=[];for(let u of t.nodes){if(c.get(u.id)!==u.id)continue;let m=i.get(u.id);if(!m){l.push(u);continue}let h=m.map(M=>f.get(M)),v=h.filter(R),y=v.length?v.reduce((M,S)=>M.stable.start<=S.stable.start?M:S):h[0];l.push({id:u.id,name:u.name,length:h.reduce((M,S)=>M+S.length,0),depth:u.depth,stable:y.stable&&Z(y.id)!==Z(u.id)?{...y.stable,strand:Nt(y.stable.strand??"+")}:y.stable})}let d=new Set,p=[];return t.edges.forEach((u,m)=>{let h=c.get(u.from),v=c.get(u.to),y=n[m],M=`${h}|${y.from}>${v}|${y.to}`;a.has(m)||d.has(M)||(d.add(M),p.push({from:h,to:v,...y.from==="start"?{fromStrand:Nt(Z(h))}:{},...y.to==="end"?{toStrand:Nt(Z(v))}:{}}))}),{graph:{...t,nodes:l,edges:p,paths:void 0,pathVisits:void 0},runs:i}}function ps(t,e,n){let o={...t};for(let[s,r]of e){let a=t[s];if(!a?.length)continue;delete o[s];let c=Lt(a),i=c.at(-1),f=r.map(p=>Math.max(n(p),0)),l=f.reduce((p,u)=>p+u,0),d=0;r.forEach((p,u)=>{let m=l?f[u]/l*i:i/r.length,h=u===r.length-1?i:d+m;o[p]=fe(a,c,d,h),d=h})}return o}function ms(t,e,n){if(t.length===0)return[];let o=Lt(t),s=o.at(-1);return fe(t,o,e*s,n*s)}function it(t,e){let n=Lt(t);return t.length===0?{x:Number.NaN,y:Number.NaN}:Ot(t,n,n.at(-1)*e)}function Lt(t){let e=[0];for(let n=1;n<t.length;n++)e.push(e[n-1]+Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y));return e}var ie=(t,e)=>Y(t.length,n=>t[n]<e);function Ot(t,e,n){if(n<=0)return{...t[0]};let o=ie(e,n);if(o>=e.length)return{...t.at(-1)};let s=e[o]-e[o-1],r=s>0?(n-e[o-1])/s:0,a=t[o-1],c=t[o];return{x:a.x+(c.x-a.x)*r,y:a.y+(c.y-a.y)*r}}function fe(t,e,n,o){let s=[Ot(t,e,n)];for(let r=ie(e,n);r<t.length&&e[r]<o;r++)e[r]>n&&s.push({...t[r]});return s.push(Ot(t,e,o)),s}var le=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],pn=[.362683783378362,.3137066458778873,.2223810344533745,.1012285362903763],mn=1e-10,yn=40;function gn(t,e,n){let o=3*(t.cx0-t.x0)*e,s=3*(t.cx1-t.cx0)*e,r=3*(t.x1-t.cx1)*e,a=3*(t.cy0-t.y0)*n,c=3*(t.cy1-t.cy0)*n,i=3*(t.y1-t.cy1)*n;return f=>{let l=1-f,d=l*l,p=2*l*f,u=f*f;return Math.hypot(d*o+p*s+u*r,d*a+p*c+u*i)}}function Pt(t,e,n){let o=(n-e)/2,s=(e+n)/2,r=0;for(let a=0;a<le.length;a++){let c=o*le[a];r+=pn[a]*(t(s-c)+t(s+c))}return r*o}function Ct(t,e,n,o,s,r){let a=(e+n)/2,c=Pt(t,e,a),i=Pt(t,a,n);return r>=yn||!(Math.abs(c+i-o)>s)?c+i:Ct(t,e,a,c,s/2,r+1)+Ct(t,a,n,i,s/2,r+1)}function de(t,e,n){let o=(a,c,i,f)=>Math.hypot((i-a)*e,(f-c)*n),s=o(t.x0,t.y0,t.cx0,t.cy0)+o(t.cx0,t.cy0,t.cx1,t.cy1)+o(t.cx1,t.cy1,t.x1,t.y1),r=gn(t,e,n);return Ct(r,0,1,Pt(r,0,1),mn*s,0)}var xn=1e-6,ft=100;function xs(t){return Math.max(xn,Math.min(ft,t))}var V=(t,e)=>{let n=Math.max(0,t),o=Math.min(1,e);return n<=o?[n,o]:void 0};function ue(t,e,n,o){return e===0?t>=n&&t<=o?V(0,1):void 0:V(Math.min((n-t)/e,(o-t)/e),Math.max((n-t)/e,(o-t)/e))}var Mn=(t,e)=>t&&e?V(Math.max(t[0],e[0]),Math.min(t[1],e[1])):void 0;function lt(t,e,n,o){let s=e.x-t.x,r=e.y-t.y,a=t.x-n.x,c=t.y-n.y,i=s*s+r*r,f=2*(a*s+c*r),l=a*a+c*c-o*o,d=f*f-4*i*l;return i===0?l<=0?V(0,1):void 0:d<0?void 0:V((-f-Math.sqrt(d))/(2*i),(-f+Math.sqrt(d))/(2*i))}function vn(t,e,n,o,s){let r=Math.hypot(o.x-n.x,o.y-n.y),a=r>0?(o.x-n.x)/r:0,c=r>0?(o.y-n.y)/r:0,i=t.x-n.x,f=t.y-n.y,l=e.x-t.x,d=e.y-t.y,p=r>0?Mn(ue(i*a+f*c,l*a+d*c,0,r),ue(i*c-f*a,l*c-d*a,-s,s)):void 0,u=[lt(t,e,n,s),lt(t,e,o,s),p].filter(m=>m!==void 0);return u.length>0?V(u.reduce((m,h)=>Math.min(m,h[0]),1),u.reduce((m,h)=>Math.max(m,h[1]),0)):void 0}var he=1e-9;function Xt(t,e,n,o=0){let s=n.halfWidth-o,r=[];for(let c of n.lines){for(let f=1;f<c.length;f++){let l=vn(t,e,c[f-1],c[f],s);l&&r.push(l)}let i=c.length===1?lt(t,e,c[0],s):void 0;i&&r.push(i)}for(let c of n.points){let i=lt(t,e,c,s);i&&r.push(i)}r.sort((c,i)=>c[0]-i[0]);let a=0;for(let[c,i]of r)a=c<=a+he?Math.max(a,i):a;return s>=0&&a>=1-he}var Tt=(t,e)=>Xt(t,t,e);function pe(t,e,n,o){let s={x0:t.x0*e,y0:t.y0*n,cx0:t.cx0*e,cy0:t.cy0*n,cx1:t.cx1*e,cy1:t.cy1*n,x1:t.x1*e,y1:t.y1*n},r=Math.max(Math.hypot(s.x0-2*s.cx0+s.cx1,s.y0-2*s.cy0+s.cy1),Math.hypot(s.cx0-2*s.cx1+s.x1,s.cy0-2*s.cy1+s.y1)),a=Math.max(1,Math.ceil(Math.sqrt(.75*r/o)));return Array.from({length:Number.isFinite(a)?a+1:0},(c,i)=>W(s,i/a))}function H(){let t=new WeakMap;return(e,n,o)=>{let s=t.get(e);if(s?.deps.length===n.length&&s.deps.every((a,c)=>Object.is(a,n[c])))return s.value;let r=o();return t.set(e,{deps:n,value:r}),r}}var q=3,me=.01;function Xs(t){let e=new Set(t.collapsed?.nodes);for(let n of t.laneOnly?.nodes??[])e.add(n);return e}var Ts={sites:[],nodes:new Set,edges:new Set,siteOf:new Map,pxPerBp:0,within:new Map,through:new Map,bridges:new Map,runOf:new Map},z=t=>!!t&&R(t)&&!t.placeholder,dt=(t,e)=>t.stable.start+(at(t,e)?t.length:0),Bt=(t,e)=>t.stable.start+(at(t,e)?0:t.length),ye=(t,e,n)=>n===at(t,e)?"end":"start";function wn(t){let e=At(t),n=new Map,o=new Map;for(let r of t.paths??[]){let a=e.get(It(r))??0;n.set(r.name,a);for(let c of r.nodeIds)wt(o,c,a)}let s=r=>n.get(r)??e.get(ct(r)??r);for(let r of t.nodes)for(let{path:a}of r.departureVisits??[]){let c=s(a);c!==void 0&&wt(o,r.id,c)}return{total:e.size,byNode:o,walkNamed:s}}function bn(t,e,n){let o=new Map(t.nodes.map(g=>[g.id,g])),{total:s,byNode:r,walkNamed:a}=wn(t),c=new Map;for(let g of t.nodes)R(g)||c.set(g.id,g.id);let i=g=>{let x=g,b=c.get(x);for(;b!==void 0&&b!==x;)x=b,b=c.get(x);let k=g;for(;k!==x;){let I=c.get(k)??x;c.set(k,x),k=I}return x},f=g=>c.has(g);for(let{from:g,to:x}of t.edges)f(g)&&f(x)&&c.set(i(g),i(x));let l=new Map,d=g=>{let x=i(g),b=l.get(x),k=b??{nodes:[],edges:[],feet:[],attachments:[],ends:new Set,refNames:new Set,walks:[],bp:0,skip:void 0,tail:!1,tied:!1};return b||l.set(x,k),k};for(let g of t.nodes)if(f(g.id)){let x=d(g.id);x.nodes.push(g.id),x.bp+=g.length}let p=[],u=new Map;t.edges.forEach(({from:g,to:x,fromStrand:b,toStrand:k,pathIds:I},_)=>{let T=f(g)?g:f(x)?x:void 0,X=f(g)?x:g,O=o.get(X),w=o.get(g),L=o.get(x);if(T!==void 0){let A=d(T);A.edges.push(_),f(X)||(z(O)?(A.feet.push({edge:_,atEnd:X===x}),A.refNames.add(O.stable.refName),A.attachments.push(X===g?dt(O,b):Bt(O,k)),A.ends.add(X===g?ye(O,b,!0):ye(O,k,!1))):A.tied=!0)}else if(z(w)&&z(L)&&w.stable.refName===L.stable.refName&&dt(w,b)===Bt(L,k)){let A=u.get(w.stable.refName)??[];A.push({edge:_,at:dt(w,b)}),u.set(w.stable.refName,A)}else if(e?.has(_)&&!n?.has(_)&&z(w)&&z(L)){let A=new Set;for(let B of I??[]){let P=a(B);P!==void 0&&A.add(P)}if(A.size>0){let B=[dt(w,b),Bt(L,k)];p.push({nodes:[],edges:[_],feet:[{edge:_,atEnd:!1},{edge:_,atEnd:!0}],attachments:B,refNames:new Set([w.stable.refName,L.stable.refName]),walks:[...A],bp:ge(B),skip:_,tail:!1})}}});let m=[...p],h=oe(t);for(let{tied:g,ends:x,...b}of l.values()){let k=new Set;for(let _ of b.nodes)for(let T of r.get(_)??[])k.add(T);let I=b.nodes.some(_=>h.has(_));!g&&(x.size===2||b.feet.length===1)&&(!I||b.nodes.every(_=>o.get(_)?.placeholder))&&k.size>0&&m.push({...b,bp:b.bp+ge(b.attachments),walks:[...k],tail:I})}let v=t.nodes.filter(z),y=new Map,M=g=>{let x=y.get(g),b=x??{spans:[],links:[],endingAt:new Map,startingAt:new Map};return x||y.set(g,b),b};for(let g of v){let{refName:x,start:b}=g.stable,k=M(x),I=b+g.length;k.spans.push({id:g.id,start:b,end:I}),$(k.endingAt,I,g.id),$(k.startingAt,b,g.id)}for(let[g,x]of u)M(g).links=x;for(let g of y.values())g.spans.sort((x,b)=>x.start-b.start),g.links.sort((x,b)=>x.at-b.at);let S=g=>g.nodes[0]??`#${g.skip}`;return{units:m.map(g=>({unit:g,start:tt(g.attachments),key:S(g)})).sort((g,x)=>g.start!==x.start?g.start-x.start:g.key<x.key?-1:g.key>x.key?1:0).map(({unit:g})=>g),total:s,backbone:v.map(g=>g.id),backboneBp:v.reduce((g,x)=>g+x.length,0),references:y}}function pt(t,e,n){let o=[];for(let s=Y(t.length,r=>t[r].start<e);s<t.length&&t[s].start<n;s++){let r=t[s];r.end<=n&&r.end>r.start&&o.push(r)}return o}function Sn(t,e){let n=new Map;for(let o of t){let s=e.get(o.refName)?.spans??[];for(let r of pt(s,o.start,o.end))n.set(r.id,o)}return n}function kn(t,e){let n=new Map,o=new Map,s=new Map,r=t.toSorted((c,i)=>c.refName!==i.refName?c.refName<i.refName?-1:1:c.start-i.start),a=0;for(;a<r.length;){let{refName:c}=r[a],{start:i}=r[a],{end:f}=r[a],l=a;for(a++;a<r.length&&r[a].refName===c&&r[a].start<=f;)f=Math.max(f,r[a].end),a++;let d=e.get(c);if(d){let p=pt(d.spans,i,f),u={start:i,end:f,from:d.endingAt.get(i)??[],to:d.startingAt.get(f)??[]};for(let h of p)n.set(h.id,u);for(let h of r.slice(l,a))s.set(h,u);let{links:m}=d;for(let h=Y(m.length,v=>m[v].at<i);h<m.length&&m[h].at<=f;h++)o.set(m[h].edge,{run:u,at:m[h].at})}}return{nodes:n,bridges:o,runOf:s}}var tt=t=>t.reduce((e,n)=>Math.min(e,n),1/0),ht=t=>t.reduce((e,n)=>Math.max(e,n),-1/0),ge=t=>t.length>0?ht(t)-tt(t):0,In=H();function An(t,{edge:e,atEnd:n}){let o=t.get(e),s=o?.[0],r=o?.at(-1);return!s||!r?void 0:n?{x:r.x1,y:r.y1}:{x:s.x0,y:s.y0}}var _n=t=>({x:t.reduce((e,n)=>e+n.x,0)/t.length,y:t.reduce((e,n)=>e+n.y,0)/t.length}),En=(t,e)=>t.reduce((n,o)=>n+de(o,e.scaleX,e.scaleY),0);function Nn(t,e){let n=t[0],o=t.at(-1);return n&&o?Math.hypot((o.x1-n.x0)*e.scaleX,(o.y1-n.y0)*e.scaleY):0}function xe(t,e,n,o){let s=tt(t.attachments),r=ht(t.attachments),a=e?.links??[],c=0;for(let i of t.nodes)c+=n(i);for(let i of t.edges)c+=o(i);for(let i of e?pt(e.spans,s,r):[])c+=n(i.id);for(let i=Y(a.length,f=>a[f].at<s);i<a.length&&a[i].at<=r;i++)c+=o(a[i].edge);return c}function Me(t){let e=new Map;return n=>{let o=e.get(n),s=o??t(n);return o===void 0&&e.set(n,s),s}}function Rt(t,e,n,o){let s=t.reduce((r,a)=>r+G(n[a]??[],o.scaleX,o.scaleY),0);return e>0?s/e:0}var On=H();function Bs(t,e,n,o=0){return On(e,[t,n.scaleX,n.scaleY,o],()=>{let s=t.filter(z);return Rt(s.map(r=>r.id),s.reduce((r,a)=>r+a.length,0),e,n)})}var ut=(t,e)=>({x:t.x*e.scaleX,y:t.y*e.scaleY});function Ln(t,e,n,o,s){let r=t.nodes.map(c=>(n[c]??[]).map(i=>ut(i,s))),a=(c,i)=>c.every((f,l)=>l===0||Xt(c[l-1],f,e,i));return r.every(c=>c.every(i=>Tt(i,e)))&&r.every(c=>a(c,0))&&t.edges.every(c=>(o.get(c)??[]).every(i=>a(pe(i,s.scaleX,s.scaleY,me),me)))}function Pn(t,e,n,o,s,r,a){let{units:c,total:i,backbone:f,backboneBp:l,references:d}=In(t,[s,r],()=>bn(t,s,r)),p=Rt(f,l,e,n),u={...n,scaleX:ft,scaleY:n.pixelRows?n.scaleY:ft},m=Rt(f,l,e,u),h=new Set(t.nodes.flatMap(w=>w.placeholder?[w.id]:[])),v=(w,L)=>({node:Me(A=>G(e[A]??[],w.scaleX,w.scaleY)),edge:Me(A=>L(o.get(A)??[],w))}),y=v(n,En),M=v(u,Nn),S=(w,L)=>{let A=d.get(L),B=xe(w,A,y.node,y.edge),P=xe(w,A,M.node,M.edge),E=w.nodes.some(C=>h.has(C))&&p>0;return w.tail?{shown:w.bp*p,back:w.bp*m}:{shown:E?Math.min(B,w.bp*p):B,back:E?Math.min(P,w.bp*m):P}},N=new Map(t.nodes.map(w=>[w.id,w])),g=_t(t,a.nodeWidth),x=w=>{let L=N.get(w);return L?Et(L,a.contigThickness,a.nodeWidth,g)/2:0},b=(w,L,A,B)=>{let P=L?pt(L.spans,tt(w.attachments),ht(w.attachments)).map(C=>C.id):[],E=w.feet.flatMap(({edge:C,atEnd:j})=>{let vt=t.edges[C];return vt?[j?vt.to:vt.from]:[]});return{lines:P.map(C=>(e[C]??[]).map(j=>ut(j,B))),points:A.map(C=>ut(C,B)),halfWidth:[...P,...E].reduce((C,j)=>Math.min(C,x(j)),1/0)}},k=(w,L,A)=>{let B=()=>{let P=b(w,L,A,u);return w.nodes.some(E=>(e[E]??[]).some(C=>!Tt(ut(C,u),P)))};return w.nodes.length>0&&w.bp*p<q&&w.bp*m>=q&&Ln(w,b(w,L,A,n),e,o,n)&&B()},I=new Set,_=new Set,T=new Map,X=[];for(let w of c){let L=w.feet.flatMap(P=>{let E=An(o,P);return E?[E]:[]}),[A]=w.refNames,B=A!==void 0&&w.refNames.size===1&&w.bp>0&&L.length===w.feet.length&&w.nodes.every(P=>e[P]?.length)?S(w,A):void 0;if(A!==void 0&&B&&B.back>=q&&(B.shown<q||k(w,d.get(A),L))){let P={nodes:w.nodes,edges:w.edges,refName:A,start:tt(w.attachments),end:ht(w.attachments),bp:w.bp,..._n(L),count:w.walks.length,total:i};X.push(P);for(let E of w.nodes)I.add(E),T.set(E,P);for(let E of w.edges)_.add(E)}}let O=kn(X,d);return{sites:X,nodes:I,edges:_,siteOf:T,pxPerBp:p,within:Sn(X,d),through:O.nodes,bridges:O.bridges,runOf:O.runOf}}var Cn=H(),Rs=t=>t.sites.reduce((e,n)=>Math.max(e,n.bp+1),0);function Hs(t,e,n,o,s,r,a){return Cn(o,[t,e,s,r,a.contigThickness,a.nodeWidth],()=>Pn(t,e,n,o,s,r,a))}var ve=11,Xn=6.2,mt=4;function yt(t){return t.length*Xn+mt*2}function Se(t,e){return t.x0<e.x1&&t.x1>e.x0&&t.y0<e.y1&&t.y1>e.y0}function ke(t,e){return t.x1<=0||t.x0>=e.width||t.y1<=0||t.y0>=e.height}function D(t,e){return t.x0>=0&&t.x1<=e.width&&t.y0>=0&&t.y1<=e.height}function Ie(t,e){return{x0:t.x0-e,x1:t.x1+e,y0:t.y0-e,y1:t.y1+e}}function Tn(t,e=[]){let n=[...e];return(o,s)=>{let r=s?[o,s]:[o];if(ke(o,t)||n.some(a=>r.some(c=>Se(a,c))))return!1;for(let a of r)n.push(a);return!0}}var we=8;function be(t){let e=[0];for(let n=we;n<t;n+=we)e.push(-n,n);return t>0&&e.push(-t,t),e}function Ys(t,e,n,o=[],s=0){let r=[],a=0,c=ve+mt*2,i=(h,v,y)=>({x0:h-y/2,x1:h+y/2,y0:v-ve-mt,y1:v+mt}),f=(h,v,y,M)=>{let S=yt(v),N=[];for(let x=0;x<=(h.stack??0);x++){let b=y+M*x*c;if(ke(i(h.x,b,S),e))break;for(let k of be(h.slide??0))N.push({dx:k,y:b,distance:Math.hypot(k,x*c)})}N.sort((x,b)=>x.distance-b.distance);let g=!1;for(let{dx:x,y:b}of N){let k=i(h.x+x,b,S);if(D(k,e)&&(h.fits?.(k)??!0)){if(n(k))return{placed:{...h,x:h.x+x,text:v,y:b,w:S},crowded:g};g||=!o.some(I=>Se(I,k))}}return{placed:void 0,crowded:g}},l=(h,v)=>{let y=f(h,v,h.y,h.y>e.height/2?-1:1);return y.placed||h.flipY===void 0||y.crowded?y:f(h,v,h.flipY,h.flipY<h.y?-1:1)},d=Math.ceil(e.height/c),p=h=>{let v=[];for(let y=-d;y<=d;y++)for(let M of be(h))v.push({dx:M,dy:y*c,distance:Math.hypot(M,y*c)});return v.sort((y,M)=>y.distance-M.distance)},u,m=(h,v,y)=>{let M=yt(v),S=D({x0:y.x,x1:y.x,y0:y.y,y1:y.y},e)?u??=p(e.width):p(h.slide??0),N=x=>{let b;for(let k=0;k<S.length&&!b;k++){let I=y.x+S[k].dx,_=y.y+S[k].dy,T=i(I,_,M);b=D(T,e)&&x(T)?{x:I,y:_}:void 0}return b},g=N(x=>(h.fits?.(x)??!0)&&n(x))??N(n);return g&&{...h,x:g.x,y:g.y,text:v,w:M}};for(let h of t){let v=l(h,h.text),y=v.placed||h.fallback===void 0?void 0:l(h,h.fallback),M=v.placed??y?.placed,S=v.crowded||y?.crowded===!0,N=M||h.nearest===void 0||S&&a>=s?void 0:m(h,h.text,h.nearest);N&&a++;let g=M??N;g&&r.push(g)}return r}function qs(t,e){let n=new Set(t.nodes.filter(i=>R(i)&&St(i,e)).map(i=>i.id)),o=t.paths??[];if(n.size===0||o.length===0)return t;let s=o.map(i=>{let f=-1,l=-1;return i.nodeIds.forEach((d,p)=>{n.has(d)&&(f<0&&(f=p),l=p)}),f<0?void 0:{first:f,last:l}});if(s.every((i,f)=>i?.first===0&&i.last===o[f].nodeIds.length-1))return t;let r=new Set,a=[],c=new Map;return o.forEach((i,f)=>{let l=s[f];if(l){let d=i.nodeIds.slice(l.first,l.last+1);for(let p of d)r.add(p);a.push({...i,nodeIds:d,...i.refStarts?{refStarts:i.refStarts.subarray(l.first,l.last+1)}:{}}),c.set(i.name,{first:l.first,nodeIds:d})}}),{...t,nodes:t.nodes.filter(i=>r.has(i.id)),edges:t.edges.filter(i=>r.has(i.from)&&r.has(i.to)),paths:a,pathVisits:t.pathVisits&&Bn(t.pathVisits,o,s,new Map(t.nodes.map(i=>[i.id,i.name]))),anchorPaths:ee(t,c)}}function Bn(t,e,n,o){let s=t.replay(),r=new te;return e.forEach((a,c)=>{let i=t.pathIndex(J(a.name).name),f=n[c];a.nodeIds.forEach((l,d)=>{let p=o.get(l)??l,u=s(t.slot(p),i);u>=0&&f&&d>=f.first&&d<=f.last&&r.add(p,t.paths[i],t.samples[i],t.start[u],t.reversed[u]===1)})}),r.build()}function Gs(t,e,n){let o=t.nodes.map(s=>{if(!R(s))return s;let r=s.stable.start,a=r+s.length,[c,i]=St(s,e)?[Math.max(r,e.start),Math.min(a,e.end)]:a<=e.start?[Math.max(r,a-n),a]:[r,Math.min(a,r+n)];return c===r&&i===a?s:{...s,length:i-c,stable:{...s.stable,start:c},unclipped:{start:r,length:s.length}}});return o.some((s,r)=>s!==t.nodes[r])?{...t,nodes:o}:t}function Ae(t){return t.nodes.some(e=>e.unclipped)?{...t,nodes:t.nodes.map(({unclipped:e,...n})=>e&&n.stable?{...n,length:e.length,stable:{...n.stable,start:e.start}}:n)}:t}var Rn=1,er=t=>`skips ${t??"the reference"} sequence`,nr="short skip";function Hn(t,e){return e.flatMap(n=>t[n]??[])}function Ht(t,e,n,o,s,r){let a=t[e.from],c=t[e.to];if(!(!a?.length||!c?.length))return s?Zt(a,c,s,r?st(e):void 0):Ut(a,c,Kt(e,r),n,o?Hn(t,o):[])}function $n(t){let e=K(t.nodes.filter(R),n=>n.stable.refName);for(let n of e.values())n.sort((o,s)=>o.stable.start-s.stable.start);return e}function Yn(t,e,n){let o=[];if(t)for(let s=Jt(t,e);s<t.length;s++){let r=t[s];if(r.stable.start>=n)break;r.stable.start+r.length<=n&&o.push(r.id)}return o}function Wn(t,e,n,o){let{fromStrand:s,toStrand:r}=t;if(s===void 0||r===void 0)return!0;let a=s===e.strand,c=r===n.strand;return o?a&&c:!a&&!c}function Dn(t,e,n,o){let s;for(let[r,a]of o){let c=r.start<=a.start,i=c?{start:r.start+e.length,end:a.start}:{start:a.start+n.length,end:r.start};Wn(t,r,a,c)&&(!s||Math.abs(i.end-i.start)<Math.abs(s.end-s.start))&&(s=i)}return s}function Fn(t,e,n){return n(t).flatMap(o=>n(e).map(s=>[o,s]))}function zn(t){let{pathVisits:e}=t;return(n,o)=>{let s;if(e){let r=e.pathIndex(n.stable.refName),a=e.slot(n.name);if(a>=0&&r>=0)for(let c=e.offsets[a];c<e.offsets[a+1]&&!s;c++)e.path[c]===r&&e.start[c]===o&&(s={start:o,strand:e.strand(c)})}return s}}function qn(t,e){let n=new Map;for(let r of e){let{from:a,to:c}=t.edges[r],i=n.get(a);i||(i=new Map,n.set(a,i)),$(i,c,r)}let o=new Map,s=(r,a,c)=>{let i=o.get(r);if(i||(i=[],o.set(r,i)),!Number.isNaN(a)&&!Number.isNaN(c)){let f=!1;for(let l=0;l<i.length&&!f;l+=2)f=i[l]===a&&i[l+1]===c;f||i.push(a,c)}};for(let{nodeIds:r,refStarts:a}of t.paths??[])if(a)for(let c=1;c<r.length;c++){let i=r[c-1],f=r[c];for(let l of n.get(i)?.get(f)??[])s(l,a[c-1],a[c]);for(let l of n.get(f)?.get(i)??[])s(l,a[c],a[c-1])}return o}function Gn(t,e,n,o){let s=[];for(let r=0;r<n.length;r+=2){let a=o(t,n[r]),c=o(e,n[r+1]);a&&c&&s.push([a,c])}return s}var Vn=.01;function jn(t,e){let n=new Map;for(let[o,s]of t){let r=s.flatMap(a=>{let c=e(a).map(i=>i.start);return c.slice(1).map((i,f)=>({at:c[f],copy:i-c[f]}))});r.length&&n.set(o,r.sort((a,c)=>a.at-c.at))}return n}function Kn(t,e,n){if(!t)return!1;let o=Y(t.length,r=>t[r].at<e),s=[t[o-1],t[o]].filter(r=>r!==void 0).sort((r,a)=>Math.abs(r.at-e)-Math.abs(a.at-e))[0];return s!==void 0&&Math.abs(s.at-e)<=s.copy&&Math.abs(n-s.copy)<=s.copy*Vn}function Un(t){let e=Ae(t),n=new Map(e.nodes.map(l=>[l.id,l])),o=$n(e),s=ne(e),r=e.edges.flatMap((l,d)=>{let p=n.get(l.from),u=n.get(l.to);return!l.foldBridge&&p!==void 0&&u!==void 0&&R(p)&&R(u)&&p.stable.refName===u.stable.refName?[{edgeIndex:d,edge:l,from:p,to:u}]:[]}),c=e.paths!==void 0&&e.paths.length>0&&e.paths.every(l=>l.refStarts)?qn(e,r.map(l=>l.edgeIndex)):new Map,i=zn(e);return{links:r.map(({edgeIndex:l,edge:d,from:p,to:u})=>{let m=c.get(l);return{edgeIndex:l,edge:d,refName:p.stable.refName,span:Dn(d,p,u,m?Gn(p,u,m,i):Fn(p,u,s))}}),backbone:o,copies:jn(o,s)}}function Ee(t){let{links:e,backbone:n,copies:o}=Un(t);return e.flatMap(({edgeIndex:s,edge:r,refName:a,span:c})=>{let i=c?c.end-c.start:0;return c&&i>=Rn&&!Kn(o.get(a),c.start,i)?[{edgeIndex:s,from:r.from,to:r.to,...r.fromStrand?{fromStrand:r.fromStrand}:{},...r.toStrand?{toStrand:r.toStrand}:{},refName:a,start:c.start,end:c.end,bp:i,bypassed:Yn(n.get(a),c.start,c.end)}]:[]})}function Zn(t,e){let n=new Map,o=a=>{let c=a;for(;n.has(c);)c=n.get(c);return c!==a&&n.set(a,c),c},s=(a,c)=>{let[i,f]=[o(a),o(c)];return i!==f&&n.set(i,f),i!==f},r=new Set(e);return t.edges.forEach((a,c)=>{r.has(c)||s(a.from,a.to)}),new Set(se(e.map(a=>({...t.edges[a],ei:a}))).filter(a=>!s(a.from,a.to)).map(({ei:a})=>a))}var _e=new WeakMap;function or(t,e,n=!0){let o=_e.get(e);o||(o=new Map,_e.set(e,o));let s=o.get(n);if(!s){let r=n?new Set:Zn(t,e.map(a=>a.edgeIndex));s={shown:e.filter(a=>!r.has(a.edgeIndex)),bypassed:new Map(e.map(a=>[a.edgeIndex,a.bypassed])),hidden:r},o.set(n,s)}return s}var Jn=class extends Map{constructor(){super(...arguments),this.arcs=new Set}},Qn=1,to=11,eo=3*to,no=t=>t>=eo,$t=5,Pe=8,oo=64,Yt=-1,Ce=12,Ne=16,so=Ce+$t;function ro(t,e,n,o){let s=l=>({x:l.x*o.scaleX,y:l.y*o.scaleY}),r=t[0],a=t.at(-1),c=[s({x:r.x0,y:r.y0}),...e.flatMap(l=>(n[l]??[]).map(s)),s({x:a.x1,y:a.y1})],i=0,f=0;for(let l of t)for(let d=0;d<=Ne;d++){let p=s(W(l,d/Ne)),u=!1;for(let m=1;m<c.length&&!u;m++){let h=c[m-1],v=c[m];u=U(p.x,p.y,h.x,h.y,v.x,v.y)<=Ce}f++,i+=u?1:0}return i*2>f}function ao(t,e,n,o){let{ax:s,ay:r,ux:a,uy:c}=gt(t,o),i=0;for(let f of e)for(let l of n[f]??[]){let d=(l.y*o.scaleY-r)*a-(l.x*o.scaleX-s)*c;i=Math.abs(d)>Math.abs(i)?d:i}return Math.abs(i)>=1?-Math.sign(i):Math.sign(Wt(t,o,Pe))||Yt}function Oe(t,e){return gt(t,e).length}var co=H();function Xe(t,e,n,o,s,r,a=!1){return co(t,[e,n.scaleX,n.scaleY,!!n.pixelRows,o,r,a,s],()=>{let c=new Jn;for(let i=0;i<e.edges.length;i++){let f=e.edges[i],l=o?.get(i),d=r?.[i],p=l?Ht(t,f,n,l,d,a):void 0,u=l&&d&&p&&no(Oe(p,n))&&ro(p,l,t,n)?Le(p,n,so*ao(p,l,t,n)):p,m=u!==void 0&&Oe(u,n)>=Qn,h=m?u:Ht(t,f,n,void 0,void 0,a);h&&(c.set(i,h),m&&c.arcs.add(i))}if(o){let i=new Map(e.nodes.map(y=>[y.id,y])),{spans:f,levels:l,alone:d}=io(o,[e],()=>fo(Ee(e).filter(y=>o.has(y.edgeIndex)))),p=y=>l.get(y)??1,u=new Map(Array.from(c.arcs,y=>[y,lo(c.get(y),n)])),m=new Map;for(let y of u.values())m.set(y,(m.get(y)??0)+1);let h=new Map,v=new Map;for(let y of Array.from(c.arcs).sort((M,S)=>p(M)-p(S)||M-S)){let M=u.get(y),S=Math.max(p(y),(h.get(M)??0)+1);h.set(M,S),v.set(y,S*$t)}Te(f.filter(y=>c.arcs.has(y.edgeIndex)),(y,M)=>{let S=y.edgeIndex,N=e.edges[S],g=c.get(S),x=Math.max(v.get(S),M>0?M+$t:0),b=Wt(g,n,Pe),I=(!d.has(S)||m.get(u.get(S))>1)&&Math.abs(b)<x;if(I){let _=i.get(N.from)?.stable?.start??0,T=i.get(N.to)?.stable?.start??0,X=r?.[S]?_<=T?Yt:-Yt:Math.sign(b)||1;c.set(S,Le(g,n,x*X))}return I?x:Math.abs(Wt(g,n,oo))})}return c})}var io=H();function Te(t,e){for(let n of K(t,o=>o.refName).values()){let o=Array.from(new Set(n.map(r=>r.start))).sort((r,a)=>a-r),s=new Array(o.length+1).fill(0);for(let r of n.toSorted((a,c)=>a.end-c.end||c.start-a.start||a.edgeIndex-c.edgeIndex)){let a=Y(o.length,f=>o[f]>r.start)+1,c=0;for(let f=a;f>0;f-=f&-f)c=Math.max(c,s[f]);let i=e(r,c);for(let f=a;f<=o.length;f+=f&-f)s[f]=Math.max(s[f],i)}}}function fo(t){let e=new Map;Te(t,(o,s)=>(e.set(o.edgeIndex,s+1),s+1));let n=new Set;for(let o of K(t,s=>s.refName).values()){let s;for(let r of o.toSorted((a,c)=>a.start-c.start))s&&r.start<s.end&&(n.add(r.edgeIndex),n.add(s.edgeIndex)),s=s&&s.end>=r.end?s:r}return{spans:t,levels:e,alone:new Set(t.flatMap(o=>n.has(o.edgeIndex)?[]:[o.edgeIndex]))}}function lo(t,e){let n=t[0],o=t.at(-1);return[`${Math.round(n.x0*e.scaleX)},${Math.round(n.y0*e.scaleY)}`,`${Math.round(o.x1*e.scaleX)},${Math.round(o.y1*e.scaleY)}`].sort().join(" ")}function gt(t,e){let n=t[0],o=t.at(-1),s=n.x0*e.scaleX,r=n.y0*e.scaleY,a=Math.hypot(o.x1*e.scaleX-s,o.y1*e.scaleY-r);return{ax:s,ay:r,length:a,ux:(o.x1*e.scaleX-s)/a,uy:(o.y1*e.scaleY-r)/a}}function Wt(t,e,n){let{ax:o,ay:s,ux:r,uy:a}=gt(t,e),c=0;for(let i of t)for(let f=1;f<n;f++){let l=W(i,f/n),d=(l.y*e.scaleY-s)*r-(l.x*e.scaleX-o)*a;c=Math.abs(d)>Math.abs(c)?d:c}return c}function Le(t,e,n){let o=t[0],s=t.at(-1),{ux:r,uy:a}=gt(t,e),c=n/jt,i=-a*c/e.scaleX,f=r*c/e.scaleY,l=r*Math.abs(c)/e.scaleX,d=a*Math.abs(c)/e.scaleY;return[{x0:o.x0,y0:o.y0,cx0:o.x0+i-l,cy0:o.y0+f-d,cx1:s.x1+i+l,cy1:s.y1+f+d,x1:s.x1,y1:s.y1}]}var uo=50;function Be(t,e){return e>0?Math.max(1,t/e):uo}function ho(t){let e=new Set,n=1/0,o=-1/0;for(let s of t)e.add(s.minY),n=Math.min(n,s.minY),o=Math.max(o,s.minY);return e.size>1?(o-n)/(e.size-1):void 0}function He(t,e,n){let o=Be(e,t.length);return{x:o,y:n>0?Be(n,t.length):ho(t)??o}}function po(t,e,n,o){return t===void 0?He(e,n,o):typeof t=="number"?{x:t,y:t}:t}function mo(t,e,n){let o=t.get(e);o||(o=new Map,t.set(e,o));let s=o.get(n);return s||(s=[],o.set(n,s)),s}function $e(t,e,n,o,s,r,a){let c=Math.floor(n/e.x),i=Math.floor(s/e.x),f=Math.floor(o/e.y),l=Math.floor(r/e.y);for(let d=c;d<=i;d++)for(let p=f;p<=l;p++)mo(t,d,p).push(a)}function*Re(t,e,n){if(n-e<t.size)for(let o=e;o<=n;o++){let s=t.get(o);s!==void 0&&(yield s)}else{let o=[];for(let s of t)s[0]>=e&&s[0]<=n&&o.push(s);o.sort((s,r)=>s[0]-r[0]);for(let[,s]of o)yield s}}function*Ye(t,e,n,o,s,r){let a=Math.floor((o-r)/e.y),c=Math.floor((o+r)/e.y);for(let i of Re(t,Math.floor((n-s)/e.x),Math.floor((n+s)/e.x)))yield*Re(i,a,c)}function We(t,e,n,o,s,r){let a=[],c=new Set;for(let i of Ye(t,e,n,o,s,r))for(let f of i)c.has(f)||(c.add(f),a.push(f));return a}function yo(t,e,n,o,s,r,a){let c=!1;for(let i of Ye(t,e,n,o,s,r))if(c=i.some(a),c)break;return c}var Dt=class{constructor(t,e,n={x:0,y:0}){this.cells=new Map;let o=[],s=0,r=0;for(let[c,i]of Object.entries(t))for(let f=0;f<i.length-1;f++){let l=i[f],d=i[f+1],p=Math.min(l.x,d.x),u=Math.min(l.y,d.y),m=Math.max(l.x,d.x),h=Math.max(l.y,d.y);s+=m-p,r+=h-u,o.push({entry:{nodeId:c,segmentIdx:f},minX:p,minY:u,maxX:m,maxY:h})}let a=po(e,o,s,r);this.cellSize={x:Math.max(a.x,n.x),y:Math.max(a.y,n.y)};for(let c of o)$e(this.cells,this.cellSize,c.minX,c.minY,c.maxX,c.maxY,c.entry)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}some(t,e,n,o,s){return yo(this.cells,this.cellSize,t,e,n,o,s)}},De=class{constructor(t,e,n,o,s,r=0,a,c=!1){this.cells=new Map,this.edgeCurves=Xe(t,e,o,s,r,a,c);let i=[],f=0,l=0;for(let d=0;d<e.edges.length;d++){let p=e.edges[d],u=t[p.from],m=t[p.to],h=this.edgeCurves.get(d);if(u?.length&&m?.length&&h){let{minX:v,minY:y,maxX:M,maxY:S}=Vt(h),N=p.pathIds?.length??0;if(n&&N>0){let g=0,x=0;for(let b of rt(u,m,N,o,h))g=Math.max(g,Math.abs(b.x)),x=Math.max(x,Math.abs(b.y));v-=g,y-=x,M+=g,S+=x}f+=M-v,l+=S-y,i.push({ei:d,minX:v,minY:y,maxX:M,maxY:S})}}this.cellSize=He(i,f,l);for(let d of i)$e(this.cells,this.cellSize,d.minX,d.minY,d.maxX,d.maxY,d.ei)}getCurves(t){return this.edgeCurves.get(t)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}};var Fe=20;function go(t,e,n,o=1){let s=1/0,r=W(n,0);for(let a=1;a<=Fe;a++){let c=W(n,a/Fe);s=Math.min(s,U(t,e,r.x,r.y*o,c.x,c.y*o)),r=c}return s}function xo(t,e,n,o){let s=1/0;for(let r of n){let a=go(t,e,r,o);a<s&&(s=a)}return s}var Mo=H();function vo(t,e){return Mo(t,[e],()=>new Dt(t))}var ze=16,wo=H();function bo(t,e,n,o){return wo(t,[e,n,o],()=>new Dt(t,void 0,{x:ze/Math.abs(n),y:ze/Math.abs(o)}))}var So=H();function ko(t,e,n,o,s,r,a,c){return So(t,[e,n,o.scaleX,o.scaleY,!!o.pixelRows,s,r,a,c],()=>new De(t,e,n,o,r,s,a,c))}var Io=5;function vr(t,e,n,o,s,r,a){let c=bt(o),i=vo(t,s),f=m=>Math.max(Io,m)/o.scaleX,l=f(r?.maxHalfWidthPx??0),d=i.query(e,n,l,l/c),p=null,u=1/0;for(let{nodeId:m,segmentIdx:h}of d){let v=t[m],y=a?.nodes.has(m)?1/0:U(e,n*c,v[h].x,v[h].y*c,v[h+1].x,v[h+1].y*c);y<u&&y<f(r?.halfWidthPx(m)??0)&&(u=y,p=m)}return p}function xt(t,e,n){let o=e.x-t.x,s=e.y-t.y,r=0,a=1;for(let[c,i]of[[-o,t.x-n.x0],[o,n.x1-t.x],[-s,t.y-n.y0],[s,n.y1-t.y]])c===0?r=i<0?1/0:r:c<0?r=Math.max(r,i/c):a=Math.min(a,i/c);return r<=a?[r,a]:void 0}function Ao(t,e,n){return xt(t,e,n)!==void 0}function wr(t,e,n=0){let o=r=>({x:r.x*e.scaleX+e.translateX,y:r.y*e.scaleY+e.translateY}),s;return(r,a)=>(s??=bo(t,n,e.scaleX,e.scaleY),s.some(((r.x0+r.x1)/2-e.translateX)/e.scaleX,((r.y0+r.y1)/2-e.translateY)/e.scaleY,Math.abs((r.x1-r.x0)/2/e.scaleX),Math.abs((r.y1-r.y0)/2/e.scaleY),({nodeId:c,segmentIdx:i})=>{let f=t[c],l=f?.[i],d=f?.[i+1];return l!==void 0&&d!==void 0&&!a(c)&&Ao(o(l),o(d),r)}))}var _o={x:0,y:0};function br(t,e,n,o,s,r,a,c,i,f,l,d){let p=bt(s),u=10/s.scaleX,m=ko(t,e,r,s,a,c,f,l),h=m.query(n,o,u,u/p),v=null,y=u;for(let M of h){let S=e.edges[M],N=t[S.from],g=t[S.to],x=m.getCurves(M);if(N?.length&&g?.length&&x&&!i?.has(M)&&!d?.edges.has(M)){let b=S.pathIds?.length??0,k=r&&b>0?rt(N,g,b,s,x):[_o];for(let I of k){let _=xo(n-I.x,(o-I.y)*p,x,p);_<y&&(y=_,v=M)}}}return v}var Eo={nodeLengths:!0};function Cr(t,e=Eo.nodeLengths){let n=new Map;for(let o of t)(e||o.placeholder)&&n.set(o.id,o.length);return n}var No=4e4,Oo=8,Lo=5.7,Po=6,ot=13,et=3,Ft=ot,Co=3,Xo=2;function Gt(t){return(t.length*Lo+Po+et)/2}var F=(ot+et)/2,qe=2*F+2*Ft,Ke=({x:t,y:e},{width:n,height:o})=>t>=0&&t<=n&&e+F>0&&e-F<o;function Mt(t,e,n){return{x0:e-t,x1:e+t,y0:n-F,y1:n+F}}function Xr(t,e){return{x0:6,x1:6+yt(t)+et,y0:e-8-et/2,y1:e+8+et/2}}function Ue(t){return String(t).replace(/\B(?=(\d{3})+$)/g,",")}function zt(t){let[e,n]=t>=999500?[t/1e6,"Mb"]:t>=1e3?[t/1e3,"kb"]:[];return e===void 0?`${t} bp`:`${+e.toFixed(e>=100?0:1)} ${n}`}var To=H();function Bo(t,e,n){return To(t,[e,n],()=>Object.entries(t).filter(([o,s])=>s.length>0&&e.has(o)).map(([o,s])=>({id:o,segments:s,kept:n?.get(o)?.placeholder===!0})).sort((o,s)=>o.kept===s.kept?e.get(s.id)-e.get(o.id)||Q(o.id,s.id):o.kept?-1:1))}var Ze=Array.from({length:15},(t,e)=>(e+1)/16).sort((t,e)=>Math.abs(t-.5)-Math.abs(e-.5)||t-e);function Je(t,e,n,o){let s=[0];for(let r=Ge;r<=e;r+=Ge)s.push(-r,r);return Array.from({length:o},(r,a)=>a+1).flatMap(r=>[1,-1].flatMap(a=>s.map(c=>({x:n.x+c,y:n.y+a*r*qt,distance:Math.hypot(c,r*qt)})))).sort((r,a)=>r.distance-a.distance).map(({x:r,y:a})=>({label:{...t,x:r,y:a,leader:n},box:Mt(e,r,a)}))}var Ge=8,Ro=2*F,Qe=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y)<Ro,qt=2*F,tn=t=>Math.ceil(t/qt);function Tr({x:t,y:e,leader:n}){return n?en({x:t,y:e},n):void 0}function en({x:t,y:e},n){return{x1:t,y1:n.y>e?e+ot/2:e-ot/2,x2:n.x,y2:n.y}}function Ho(t,e){let{x1:n,y1:o}=en(t,e),s=Math.hypot(n-e.x,o-e.y),r=s>0?Math.min(1,F/s):1,a=e.x+(n-e.x)*r,c=e.y+(o-e.y)*r;return{x0:Math.min(n,a)-1,x1:Math.max(n,a)+1,y0:Math.min(o,c),y1:Math.max(o,c)}}function nn(t,e){let n=0,o=1/0,s=-1/0,r=0,a=!1;return t.forEach((c,i)=>{let f=t[i-1],l=f?xt(f,c,e):void 0,d=f?Math.hypot(c.x-f.x,c.y-f.y):0;l&&(o=Math.min(o,n+l[0]*d),s=n+l[1]*d),r+=l&&!a?1:0,a=!!l,n+=d}),r===1&&o>=Ft&&n-s>=Ft}function Br({nodePositions:t,nodeLengths:e,nodeById:n,alleleDeletions:o,pxPerBp:s=0,axis:r,translateX:a,translateY:c,width:i,height:f}){let{scaleX:l,scaleY:d}=r,p=new Set(o?.flatMap(y=>y.nodeIds)),u=[],m=({x:y,y:M})=>({x:y*l+a,y:M*d+c}),h={width:i,height:f},v=y=>m(it(t[y]??[],.5));for(let{id:y,segments:M,kept:S}of Bo(t,e,n)){let N=p.has(y)?[]:Ze.map(I=>m(it(M,I))).filter(I=>Ke(I,h)),g=e.get(y),x=N.length>0?G(M,l,d):0,b=S||g*s>=q,[k]=N;if(k&&(x>=qe||b)){let I={key:`node:${y}`,node:y,text:zt(g)},_=Gt(I.text),T=x>=qe?M.map(m):[],X=N.map(({x:O,y:w})=>({label:{...I,x:O,y:w},box:Mt(_,O,w)})).filter(({box:O})=>D(O,h)&&nn(T,O));(X.length>0||b)&&u.push({id:y,kept:S,middle:k,along:X,own:({node:O})=>O===y||O!==void 0&&(t[O]?.length??0)>0&&Qe(v(O),v(y)),stacked:b?()=>Je(I,_,k,S?tn(f):Co).filter(({box:O})=>D(O,h)):void 0})}}return u}var $o=H();function Rr(t){return $o(t.nodes,[t.paths],()=>{let e=new Map(t.nodes.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t.paths??[]){let c=[],i=0,f=!0,l=!1;for(let d of a.nodeIds){let p=e.get(d);if(p&&R(p)){let u=c.join(" ");l&&f&&c.length>0&&!n.has(u)&&(n.add(u),o.push({nodes:c,bp:i})),l=!0,c=[],i=0,f=!0}else c.push(d),i+=p?.length??0,f&&=!!p&&!p.placeholder}}o.sort((a,c)=>c.bp-a.bp||Q(a.nodes[0]??"",c.nodes[0]??"")||c.nodes.length-a.nodes.length);let s=[],r=new Map;for(let a of o){let c=new Map;for(let l of new Set(a.nodes))for(let d of r.get(l)??[])c.set(d,(c.get(d)??0)+(e.get(l)?.length??0));let i;for(let[l,d]of c)i??=2*d>=s[l].bp?l:void 0;let f=i===void 0?void 0:s[i];if(f){f.least=Math.min(f.least,a.bp);for(let l of a.nodes)f.drawn.add(l)}else{for(let l of new Set(a.nodes))$(r,l,s.length);s.push({...a,least:a.bp,drawn:new Set(a.nodes)})}}return s})}function Yo(t,e){let n=zt(t),o=zt(e),[s,r]=n.split(" ");return n===o?o:r===o.split(" ")[1]?`${s}\u2013${o}`:`${n}\u2013${o}`}var nt=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Ve=(t,e)=>Math.min(nt(t,e[0]??t),nt(t,e.at(-1)??t));function Wo(t,e){let n=t.map(a=>e[a]??[]),o=[],s=[],r=0;return n.forEach((a,c)=>{let i=a[0],f=a.at(-1),l=n[c+1]??[],d=o.at(-1),p=i&&f?d?nt(d,f)<nt(d,i):l.length>0&&Ve(i,l)<Ve(f,l):!1;for(let u=0;u<a.length;u++){let m=a[p?a.length-1-u:u],h=o.at(-1);r+=h?nt(h,m):0,o.push(m)}s.push(r)}),n.every(a=>a.length>0)?{line:o,ends:s}:void 0}var Do=H(),je=()=>!1;function Fo(t,e){let n=0,o=!1,s=0;return t.forEach((r,a)=>{let c=t[a-1],i=c?xt(c,r,e):void 0;n+=i&&!o?1:0,o=!!i,s+=i&&c?(i[1]-i[0])*Math.hypot(r.x-c.x,r.y-c.y):0}),n===1&&s<=Math.hypot(e.x1-e.x0,e.y1-e.y0)}function Hr({loops:t,edges:e,nodePositions:n,folded:o,pxPerBp:s,ink:r,axis:a,translateX:c,translateY:i,width:f,height:l}){let{scaleX:d,scaleY:p}=a,u=Do(n,[t],()=>t.flatMap(M=>{let S=Wo(M.nodes,n);return S?[{loop:M,...S}]:[]})),m=({x:M,y:S})=>({x:M*d+c,y:S*p+i}),h={width:f,height:l},v=new Map,y=[];for(let{loop:M,line:S,ends:N}of u){let g=Yo(M.least,M.bp),x=Gt(g);if(M.bp*s>=q&&G(S,d,p)>=x*2/Xo&&!M.nodes.every(b=>o?.has(b))){let b=N.at(-1)??0,k=M.nodes[N.findIndex(E=>E>=b/2)]??M.nodes[0],I=`${M.nodes[0]}>${M.nodes.at(-1)}`,_=v.get(I)??0;v.set(I,_+1);let T={key:`loop:${I}${_?`#${_}`:""}`,node:k,text:g},{drawn:X}=M,O=({node:E,edge:C})=>E!==void 0?X.has(E):C!==void 0&&(X.has(e[C]?.from??"")||X.has(e[C]?.to??"")),w=S.map(m),L=r.widest(M.nodes),A=Ze.map(E=>m(it(S,E))).filter(E=>Ke(E,h)),B=A.map(({x:E,y:C})=>({label:{...T,x:E,y:C},box:Mt(x,E,C)})).filter(({box:E})=>D(E,h)&&nn(w,E)&&Fo(w,Ie(E,L))),[P]=A;P&&y.push({id:T.key,kept:!1,middle:P,along:B,own:O,stacked:()=>Je(T,x,P,tn(l)).filter(({box:E})=>D(E,h))})}}return y}function $r(t,e){return Math.max(Oo,Math.floor(t*e/No))}var zo=(t,e)=>Math.hypot(Math.max(0,t.x0-e.x1,e.x0-t.x1),Math.max(0,t.y0-e.y1,e.y0-t.y1));function Yr(t,e,{budget:n=1/0,placed:o=[],leaders:s=1/0,under:r=je}={}){let a=[],c=o.slice(),i=d=>c.some(({middle:p})=>Qe(p,d)),f=({label:d,box:p})=>c.every(u=>u.label.text!==d.text||zo(p,Mt(Gt(d.text),u.label.x,u.label.y))>=ot),l=0;for(let d of t)if((d.kept||c.length<n)&&!i(d.middle)){let p=m=>d.own(m)||m.exon!==void 0&&d.own({node:m.exon}),u=d.along.find(m=>f(m)&&!r(m.box,d.own)&&e(m.box))??(l<s?d.stacked?.().find(m=>{let h=Ho(m.label,d.middle);return f(m)&&!r(m.box,je)&&!r(h,p)&&e(m.box,h)}):void 0);if(u){let m={label:u.label,middle:d.middle};a.push(m),c.push(m),l+=u.label.leader?1:0}}return a}function Wr(t,e,n){let o=new Set(e.map(c=>c.node)),s=0,r=1/0,a=0;for(let{id:c,kept:i}of t)if(i&&!o.has(c)){let f=n.get(c);s++,r=Math.min(r,f),a=Math.max(a,f)}return s>0?{count:s,smallest:r,largest:a}:void 0}function Vr(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e%360)}function qo(t,e){return t*360/e}var Go=.7,Vo=.5,jo=16;function jr(t){return t>0&&t<=jo}function Ko(t,e){return`hsl(${qo(t,e)}, ${Go*100}%, ${Vo*100}%)`}function Kr(t,e){return`hsl(0, 0%, ${e>1?25+45*t/(e-1):45}%)`}function Uo(t){let e=J(t).name.split("#"),n=e.join("#");if(e.length>=3&&Qt(e[0])){let o=e.slice(2).join("#");return[o,o,n]}return[e[0],e.slice(0,2).join("#"),n]}function Zo(t,e){let{start:n}=J(t);return e.map(o=>`${o} @${Ue(n)}`)}function Ur(t,e){let n=new Map;t.forEach((l,d)=>{n.has(l.name)||n.set(l.name,d)});let o=[...n].map(([l,d])=>({name:l,i:d})),s=o.map(l=>Uo(l.name)),r=l=>o.map((d,p)=>s[p][l]),a=l=>o.map((d,p)=>Zo(d.name,s[p])[l]),c=[r(0),r(1),a(0),r(2),a(1),a(2)],f=c.find(l=>new Set(l).size===o.length)??c.at(-1);return o.map(({name:l,i:d},p)=>({name:l,label:f[p],color:e?.[d]??Ko(d,t.length)}))}function Zr(t){let e=new Map;return new Map([...t].sort((n,o)=>Q(n.label,o.label)).map(n=>{let o=(e.get(n.label)??0)+1;return e.set(n.label,o),[n.name,o>1?`${n.label} (${o})`:n.label]}))}var Qr=[{value:"uniform",label:"Uniform",description:"Every link the same thickness."},{value:"walks",label:"By walks",description:"Thicker the more walks take a link, on the square root of its count against the busiest link in the cut. A graph without walks draws uniform."}],on=.5,Jo=4;function ta(t){let e=0;for(let n of t.edges)e=Math.max(e,n.pathIds?.length??0);return e}function ea(t,e,n){return n==="uniform"||e===0?1:on+(Jo-on)*Math.sqrt(t/e)}var Qo=4;function ts(t){let e=new Map;for(let n of t.edges)$(e,n.from,n.to),$(e,n.to,n.from);return e}function es({nodeId:t,nodeById:e,neighbors:n}){let o=new Set([t]),s=[t],r=1/0,a=-1/0;for(let c=0;c<Qo&&s.length>0;c++){let i=[];for(let f of s){let l=n.get(f);if(l){for(let d of l)if(!o.has(d)){o.add(d);let p=e.get(d);p&&R(p)?(r=Math.min(r,p.stable.start+p.length),a=Math.max(a,p.stable.start)):i.push(d)}}}s=i}return r===1/0?void 0:{start:Math.min(r,a),end:Math.max(r,a)}}function ns({nodeId:t,nodeById:e,neighbors:n}){let o=e.get(t);return o===void 0?void 0:R(o)?{start:o.stable.start,end:o.stable.start+o.length}:es({nodeId:t,nodeById:e,neighbors:n})}function ra(t,e=ts(t)){let n=new Map(t.nodes.map(s=>[s.id,s])),o=new Map;for(let s of t.nodes){let r=ns({nodeId:s.id,nodeById:n,neighbors:e});r&&o.set(s.id,(r.start+r.end)/2)}return o}export{ts as a,ns as b,ra as c,qs as d,Gs as e,Rn as f,er as g,nr as h,Ee as i,or as j,hs as k,ps as l,ms as m,xs as n,ss as o,re as p,_t as q,rs as r,as as s,Et as t,dn as u,un as v,hn as w,cs as x,pe as y,H as z,q as A,Xs as B,Ts as C,Bs as D,Rs as E,Hs as F,ve as G,Xn as H,mt as I,yt as J,Ie as K,Tn as L,Ys as M,to as N,no as O,Oe as P,Xe as Q,vr as R,xt as S,Ao as T,wr as U,br as V,Eo as W,Cr as X,Xr as Y,Ue as Z,zt as _,Tr as $,Br as aa,Rr as ba,Yo as ca,Hr as da,$r as ea,Yr as fa,Wr as ga,Vr as ha,qo as ia,Go as ja,Vo as ka,jo as la,jr as ma,Ko as na,Kr as oa,Ur as pa,Zr as qa,Qr as ra,ta as sa,ea as ta};
2
- //# sourceMappingURL=chunk-MH3KMMEC.js.map
1
+ import{A as at,C as St,E as Jt,J as te,K as J,Q as ee,R as ne,a as $,b as wt,c as K,d as Y,g as W,h as Vt,i as U,ka as oe,m as Z,ma as se,n as st,na as Q,o as jt,p as bt,q as rt,r as G,s as Kt,t as Ut,u as Zt,x as R}from"./chunk-TD6XNJRC.js";import{b as Qt,c as ct}from"./chunk-4FDZC66W.js";var ss=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"frequency",label:"By frequency",description:"As wide as the share of haplotypes that pass a node, or its AF tag: full width at 100%, half at 50%, and wider where a haplotype passes it more than once."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],sn=.3,kt=3,rn=.05;function re(t){let e=0,n=0;for(let o of t.nodes)e+=o.depth*o.length,n+=o.length;return n>0?e/n:0}function It(t){return t.sample===void 0?ct(t.name)??t.name:`${t.sample}#${t.haplotype??0}`}function At(t){let e=new Map;for(let n of t.paths??[]){let o=It(n);e.has(o)||e.set(o,e.size)}return e}function an(t){return At(t).size}function cn(t,e){return t.frequency??(e>0?t.depth/e:void 0)}function _t(t,e){return e==="depth"?re(t):e==="frequency"?an(t):0}function ae(t){return Math.min(kt,Math.max(rn,t))}function fn(t,e){let n=cn(t,e);return n===void 0?1:ae(n)}function rs(t){return[1,.5,.1].map(e=>({label:`${e*100}%`,widthPx:t*ae(e)}))}function ce(t,e){return!(e>0)||!(t>0)?1:Math.min(kt,Math.max(sn,Math.sqrt(t/e)))}function as(t,e,n){let o=1/0,s=-1/0;for(let{id:a,depth:c}of t.nodes)(!n||n.has(a))&&(o=Math.min(o,c),s=Math.max(s,c));let r=re(t);return(o<s?[s,o]:o===s?[s]:[]).map(a=>({depth:a,widthPx:e*ce(a,r)}))}function Et(t,e,n,o){return e*(n==="depth"?ce(t.depth,o):n==="frequency"?fn(t,o):1)}function ln(t,e){return t*(e==="uniform"?1:kt)}var dn=4;function un(t,e){return Math.max(t/e,dn)}function hn(t,e,n){let o=[...t.from,...t.to].flatMap(s=>{let r=n(s);return r===void 0?[]:[r]});return o.length>0?o.reduce((s,r)=>Math.min(s,r),1/0):e}function cs(t,e,n,o,s=0,r){let a=t?_t(t,o):0,c=f=>s>0?un(f,s)*s/2:f/2,i=f=>{let l=e?.get(f);return l?Et(l,n,o,a):void 0};return{maxHalfWidthPx:c(ln(n,o)),halfWidthPx:f=>{let l=i(f)??n,d=r?.get(f);return c(d?hn(d,l,i):l)}}}function Nt(t){return t==="+"?"-":"+"}function hs(t,e=new Set){let n=t.edges.map(st),o=new Map,s=(u,m,h)=>{$(o,`${u}|${m}`,h)};t.edges.forEach((u,m)=>{s(u.from,n[m].from,m),s(u.to,n[m].to,m)});let r=u=>{let m=o.get(`${u}|end`);if(m?.length!==1)return;let h=m[0],v=t.edges[h];return v.from===u&&v.to!==u&&!e.has(u)&&!e.has(v.to)&&n[h].from==="end"&&n[h].to==="start"&&o.get(`${v.to}|start`)?.length===1?h:void 0},a=new Set,c=new Map,i=new Map;for(let u of t.nodes){let m=o.get(`${u.id}|start`),h=m?.length===1?t.edges[m[0]].from:void 0;if(c.has(u.id)||h!==void 0&&r(h)===m[0])continue;let v=[u.id];for(;;){let y=r(v.at(-1)),M=y===void 0?void 0:t.edges[y].to;if(M===void 0||c.has(M))break;a.add(y),v.push(M)}for(let y of v)c.set(y,u.id);v.length>1&&i.set(u.id,v)}for(let u of t.nodes)c.has(u.id)||c.set(u.id,u.id);let f=new Map(t.nodes.map(u=>[u.id,u])),l=[];for(let u of t.nodes){if(c.get(u.id)!==u.id)continue;let m=i.get(u.id);if(!m){l.push(u);continue}let h=m.map(M=>f.get(M)),v=h.filter(R),y=v.length?v.reduce((M,S)=>M.stable.start<=S.stable.start?M:S):h[0];l.push({id:u.id,name:u.name,length:h.reduce((M,S)=>M+S.length,0),depth:u.depth,stable:y.stable&&Z(y.id)!==Z(u.id)?{...y.stable,strand:Nt(y.stable.strand??"+")}:y.stable})}let d=new Set,p=[];return t.edges.forEach((u,m)=>{let h=c.get(u.from),v=c.get(u.to),y=n[m],M=`${h}|${y.from}>${v}|${y.to}`;a.has(m)||d.has(M)||(d.add(M),p.push({from:h,to:v,...y.from==="start"?{fromStrand:Nt(Z(h))}:{},...y.to==="end"?{toStrand:Nt(Z(v))}:{}}))}),{graph:{...t,nodes:l,edges:p,paths:void 0,pathVisits:void 0},runs:i}}function ps(t,e,n){let o={...t};for(let[s,r]of e){let a=t[s];if(!a?.length)continue;delete o[s];let c=Lt(a),i=c.at(-1),f=r.map(p=>Math.max(n(p),0)),l=f.reduce((p,u)=>p+u,0),d=0;r.forEach((p,u)=>{let m=l?f[u]/l*i:i/r.length,h=u===r.length-1?i:d+m;o[p]=fe(a,c,d,h),d=h})}return o}function ms(t,e,n){if(t.length===0)return[];let o=Lt(t),s=o.at(-1);return fe(t,o,e*s,n*s)}function it(t,e){let n=Lt(t);return t.length===0?{x:Number.NaN,y:Number.NaN}:Ot(t,n,n.at(-1)*e)}function Lt(t){let e=[0];for(let n=1;n<t.length;n++)e.push(e[n-1]+Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y));return e}var ie=(t,e)=>Y(t.length,n=>t[n]<e);function Ot(t,e,n){if(n<=0)return{...t[0]};let o=ie(e,n);if(o>=e.length)return{...t.at(-1)};let s=e[o]-e[o-1],r=s>0?(n-e[o-1])/s:0,a=t[o-1],c=t[o];return{x:a.x+(c.x-a.x)*r,y:a.y+(c.y-a.y)*r}}function fe(t,e,n,o){let s=[Ot(t,e,n)];for(let r=ie(e,n);r<t.length&&e[r]<o;r++)e[r]>n&&s.push({...t[r]});return s.push(Ot(t,e,o)),s}var le=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],pn=[.362683783378362,.3137066458778873,.2223810344533745,.1012285362903763],mn=1e-10,yn=40;function gn(t,e,n){let o=3*(t.cx0-t.x0)*e,s=3*(t.cx1-t.cx0)*e,r=3*(t.x1-t.cx1)*e,a=3*(t.cy0-t.y0)*n,c=3*(t.cy1-t.cy0)*n,i=3*(t.y1-t.cy1)*n;return f=>{let l=1-f,d=l*l,p=2*l*f,u=f*f;return Math.hypot(d*o+p*s+u*r,d*a+p*c+u*i)}}function Pt(t,e,n){let o=(n-e)/2,s=(e+n)/2,r=0;for(let a=0;a<le.length;a++){let c=o*le[a];r+=pn[a]*(t(s-c)+t(s+c))}return r*o}function Ct(t,e,n,o,s,r){let a=(e+n)/2,c=Pt(t,e,a),i=Pt(t,a,n);return r>=yn||!(Math.abs(c+i-o)>s)?c+i:Ct(t,e,a,c,s/2,r+1)+Ct(t,a,n,i,s/2,r+1)}function de(t,e,n){let o=(a,c,i,f)=>Math.hypot((i-a)*e,(f-c)*n),s=o(t.x0,t.y0,t.cx0,t.cy0)+o(t.cx0,t.cy0,t.cx1,t.cy1)+o(t.cx1,t.cy1,t.x1,t.y1),r=gn(t,e,n);return Ct(r,0,1,Pt(r,0,1),mn*s,0)}var xn=1e-6,ft=100;function xs(t){return Math.max(xn,Math.min(ft,t))}var V=(t,e)=>{let n=Math.max(0,t),o=Math.min(1,e);return n<=o?[n,o]:void 0};function ue(t,e,n,o){return e===0?t>=n&&t<=o?V(0,1):void 0:V(Math.min((n-t)/e,(o-t)/e),Math.max((n-t)/e,(o-t)/e))}var Mn=(t,e)=>t&&e?V(Math.max(t[0],e[0]),Math.min(t[1],e[1])):void 0;function lt(t,e,n,o){let s=e.x-t.x,r=e.y-t.y,a=t.x-n.x,c=t.y-n.y,i=s*s+r*r,f=2*(a*s+c*r),l=a*a+c*c-o*o,d=f*f-4*i*l;return i===0?l<=0?V(0,1):void 0:d<0?void 0:V((-f-Math.sqrt(d))/(2*i),(-f+Math.sqrt(d))/(2*i))}function vn(t,e,n,o,s){let r=Math.hypot(o.x-n.x,o.y-n.y),a=r>0?(o.x-n.x)/r:0,c=r>0?(o.y-n.y)/r:0,i=t.x-n.x,f=t.y-n.y,l=e.x-t.x,d=e.y-t.y,p=r>0?Mn(ue(i*a+f*c,l*a+d*c,0,r),ue(i*c-f*a,l*c-d*a,-s,s)):void 0,u=[lt(t,e,n,s),lt(t,e,o,s),p].filter(m=>m!==void 0);return u.length>0?V(u.reduce((m,h)=>Math.min(m,h[0]),1),u.reduce((m,h)=>Math.max(m,h[1]),0)):void 0}var he=1e-9;function Xt(t,e,n,o=0){let s=n.halfWidth-o,r=[];for(let c of n.lines){for(let f=1;f<c.length;f++){let l=vn(t,e,c[f-1],c[f],s);l&&r.push(l)}let i=c.length===1?lt(t,e,c[0],s):void 0;i&&r.push(i)}for(let c of n.points){let i=lt(t,e,c,s);i&&r.push(i)}r.sort((c,i)=>c[0]-i[0]);let a=0;for(let[c,i]of r)a=c<=a+he?Math.max(a,i):a;return s>=0&&a>=1-he}var Tt=(t,e)=>Xt(t,t,e);function pe(t,e,n,o){let s={x0:t.x0*e,y0:t.y0*n,cx0:t.cx0*e,cy0:t.cy0*n,cx1:t.cx1*e,cy1:t.cy1*n,x1:t.x1*e,y1:t.y1*n},r=Math.max(Math.hypot(s.x0-2*s.cx0+s.cx1,s.y0-2*s.cy0+s.cy1),Math.hypot(s.cx0-2*s.cx1+s.x1,s.cy0-2*s.cy1+s.y1)),a=Math.max(1,Math.ceil(Math.sqrt(.75*r/o)));return Array.from({length:Number.isFinite(a)?a+1:0},(c,i)=>W(s,i/a))}function H(){let t=new WeakMap;return(e,n,o)=>{let s=t.get(e);if(s?.deps.length===n.length&&s.deps.every((a,c)=>Object.is(a,n[c])))return s.value;let r=o();return t.set(e,{deps:n,value:r}),r}}var q=3,me=.01;function Xs(t){let e=new Set(t.collapsed?.nodes);for(let n of t.laneOnly?.nodes??[])e.add(n);return e}var Ts={sites:[],nodes:new Set,edges:new Set,siteOf:new Map,pxPerBp:0,within:new Map,through:new Map,bridges:new Map,runOf:new Map},z=t=>!!t&&R(t)&&!t.placeholder,dt=(t,e)=>t.stable.start+(at(t,e)?t.length:0),Bt=(t,e)=>t.stable.start+(at(t,e)?0:t.length),ye=(t,e,n)=>n===at(t,e)?"end":"start";function wn(t){let e=At(t),n=new Map,o=new Map;for(let r of t.paths??[]){let a=e.get(It(r))??0;n.set(r.name,a);for(let c of r.nodeIds)wt(o,c,a)}let s=r=>n.get(r)??e.get(ct(r)??r);for(let r of t.nodes)for(let{path:a}of r.departureVisits??[]){let c=s(a);c!==void 0&&wt(o,r.id,c)}return{total:e.size,byNode:o,walkNamed:s}}function bn(t,e,n){let o=new Map(t.nodes.map(g=>[g.id,g])),{total:s,byNode:r,walkNamed:a}=wn(t),c=new Map;for(let g of t.nodes)R(g)||c.set(g.id,g.id);let i=g=>{let x=g,b=c.get(x);for(;b!==void 0&&b!==x;)x=b,b=c.get(x);let k=g;for(;k!==x;){let I=c.get(k)??x;c.set(k,x),k=I}return x},f=g=>c.has(g);for(let{from:g,to:x}of t.edges)f(g)&&f(x)&&c.set(i(g),i(x));let l=new Map,d=g=>{let x=i(g),b=l.get(x),k=b??{nodes:[],edges:[],feet:[],attachments:[],ends:new Set,refNames:new Set,walks:[],bp:0,skip:void 0,tail:!1,tied:!1};return b||l.set(x,k),k};for(let g of t.nodes)if(f(g.id)){let x=d(g.id);x.nodes.push(g.id),x.bp+=g.length}let p=[],u=new Map;t.edges.forEach(({from:g,to:x,fromStrand:b,toStrand:k,pathIds:I},_)=>{let T=f(g)?g:f(x)?x:void 0,X=f(g)?x:g,O=o.get(X),w=o.get(g),L=o.get(x);if(T!==void 0){let A=d(T);A.edges.push(_),f(X)||(z(O)?(A.feet.push({edge:_,atEnd:X===x}),A.refNames.add(O.stable.refName),A.attachments.push(X===g?dt(O,b):Bt(O,k)),A.ends.add(X===g?ye(O,b,!0):ye(O,k,!1))):A.tied=!0)}else if(z(w)&&z(L)&&w.stable.refName===L.stable.refName&&dt(w,b)===Bt(L,k)){let A=u.get(w.stable.refName)??[];A.push({edge:_,at:dt(w,b)}),u.set(w.stable.refName,A)}else if(e?.has(_)&&!n?.has(_)&&z(w)&&z(L)){let A=new Set;for(let B of I??[]){let P=a(B);P!==void 0&&A.add(P)}if(A.size>0){let B=[dt(w,b),Bt(L,k)];p.push({nodes:[],edges:[_],feet:[{edge:_,atEnd:!1},{edge:_,atEnd:!0}],attachments:B,refNames:new Set([w.stable.refName,L.stable.refName]),walks:[...A],bp:ge(B),skip:_,tail:!1})}}});let m=[...p],h=oe(t);for(let{tied:g,ends:x,...b}of l.values()){let k=new Set;for(let _ of b.nodes)for(let T of r.get(_)??[])k.add(T);let I=b.nodes.some(_=>h.has(_));!g&&(x.size===2||b.feet.length===1)&&(!I||b.nodes.every(_=>o.get(_)?.placeholder))&&k.size>0&&m.push({...b,bp:b.bp+ge(b.attachments),walks:[...k],tail:I})}let v=t.nodes.filter(z),y=new Map,M=g=>{let x=y.get(g),b=x??{spans:[],links:[],endingAt:new Map,startingAt:new Map};return x||y.set(g,b),b};for(let g of v){let{refName:x,start:b}=g.stable,k=M(x),I=b+g.length;k.spans.push({id:g.id,start:b,end:I}),$(k.endingAt,I,g.id),$(k.startingAt,b,g.id)}for(let[g,x]of u)M(g).links=x;for(let g of y.values())g.spans.sort((x,b)=>x.start-b.start),g.links.sort((x,b)=>x.at-b.at);let S=g=>g.nodes[0]??`#${g.skip}`;return{units:m.map(g=>({unit:g,start:tt(g.attachments),key:S(g)})).sort((g,x)=>g.start!==x.start?g.start-x.start:g.key<x.key?-1:g.key>x.key?1:0).map(({unit:g})=>g),total:s,backbone:v.map(g=>g.id),backboneBp:v.reduce((g,x)=>g+x.length,0),references:y}}function pt(t,e,n){let o=[];for(let s=Y(t.length,r=>t[r].start<e);s<t.length&&t[s].start<n;s++){let r=t[s];r.end<=n&&r.end>r.start&&o.push(r)}return o}function Sn(t,e){let n=new Map;for(let o of t){let s=e.get(o.refName)?.spans??[];for(let r of pt(s,o.start,o.end))n.set(r.id,o)}return n}function kn(t,e){let n=new Map,o=new Map,s=new Map,r=t.toSorted((c,i)=>c.refName!==i.refName?c.refName<i.refName?-1:1:c.start-i.start),a=0;for(;a<r.length;){let{refName:c}=r[a],{start:i}=r[a],{end:f}=r[a],l=a;for(a++;a<r.length&&r[a].refName===c&&r[a].start<=f;)f=Math.max(f,r[a].end),a++;let d=e.get(c);if(d){let p=pt(d.spans,i,f),u={start:i,end:f,from:d.endingAt.get(i)??[],to:d.startingAt.get(f)??[]};for(let h of p)n.set(h.id,u);for(let h of r.slice(l,a))s.set(h,u);let{links:m}=d;for(let h=Y(m.length,v=>m[v].at<i);h<m.length&&m[h].at<=f;h++)o.set(m[h].edge,{run:u,at:m[h].at})}}return{nodes:n,bridges:o,runOf:s}}var tt=t=>t.reduce((e,n)=>Math.min(e,n),1/0),ht=t=>t.reduce((e,n)=>Math.max(e,n),-1/0),ge=t=>t.length>0?ht(t)-tt(t):0,In=H();function An(t,{edge:e,atEnd:n}){let o=t.get(e),s=o?.[0],r=o?.at(-1);return!s||!r?void 0:n?{x:r.x1,y:r.y1}:{x:s.x0,y:s.y0}}var _n=t=>({x:t.reduce((e,n)=>e+n.x,0)/t.length,y:t.reduce((e,n)=>e+n.y,0)/t.length}),En=(t,e)=>t.reduce((n,o)=>n+de(o,e.scaleX,e.scaleY),0);function Nn(t,e){let n=t[0],o=t.at(-1);return n&&o?Math.hypot((o.x1-n.x0)*e.scaleX,(o.y1-n.y0)*e.scaleY):0}function xe(t,e,n,o){let s=tt(t.attachments),r=ht(t.attachments),a=e?.links??[],c=0;for(let i of t.nodes)c+=n(i);for(let i of t.edges)c+=o(i);for(let i of e?pt(e.spans,s,r):[])c+=n(i.id);for(let i=Y(a.length,f=>a[f].at<s);i<a.length&&a[i].at<=r;i++)c+=o(a[i].edge);return c}function Me(t){let e=new Map;return n=>{let o=e.get(n),s=o??t(n);return o===void 0&&e.set(n,s),s}}function Rt(t,e,n,o){let s=t.reduce((r,a)=>r+G(n[a]??[],o.scaleX,o.scaleY),0);return e>0?s/e:0}var On=H();function Bs(t,e,n,o=0){return On(e,[t,n.scaleX,n.scaleY,o],()=>{let s=t.filter(z);return Rt(s.map(r=>r.id),s.reduce((r,a)=>r+a.length,0),e,n)})}var ut=(t,e)=>({x:t.x*e.scaleX,y:t.y*e.scaleY});function Ln(t,e,n,o,s){let r=t.nodes.map(c=>(n[c]??[]).map(i=>ut(i,s))),a=(c,i)=>c.every((f,l)=>l===0||Xt(c[l-1],f,e,i));return r.every(c=>c.every(i=>Tt(i,e)))&&r.every(c=>a(c,0))&&t.edges.every(c=>(o.get(c)??[]).every(i=>a(pe(i,s.scaleX,s.scaleY,me),me)))}function Pn(t,e,n,o,s,r,a){let{units:c,total:i,backbone:f,backboneBp:l,references:d}=In(t,[s,r],()=>bn(t,s,r)),p=Rt(f,l,e,n),u={...n,scaleX:ft,scaleY:n.pixelRows?n.scaleY:ft},m=Rt(f,l,e,u),h=new Set(t.nodes.flatMap(w=>w.placeholder?[w.id]:[])),v=(w,L)=>({node:Me(A=>G(e[A]??[],w.scaleX,w.scaleY)),edge:Me(A=>L(o.get(A)??[],w))}),y=v(n,En),M=v(u,Nn),S=(w,L)=>{let A=d.get(L),B=xe(w,A,y.node,y.edge),P=xe(w,A,M.node,M.edge),E=w.nodes.some(C=>h.has(C))&&p>0;return w.tail?{shown:w.bp*p,back:w.bp*m}:{shown:E?Math.min(B,w.bp*p):B,back:E?Math.min(P,w.bp*m):P}},N=new Map(t.nodes.map(w=>[w.id,w])),g=_t(t,a.nodeWidth),x=w=>{let L=N.get(w);return L?Et(L,a.contigThickness,a.nodeWidth,g)/2:0},b=(w,L,A,B)=>{let P=L?pt(L.spans,tt(w.attachments),ht(w.attachments)).map(C=>C.id):[],E=w.feet.flatMap(({edge:C,atEnd:j})=>{let vt=t.edges[C];return vt?[j?vt.to:vt.from]:[]});return{lines:P.map(C=>(e[C]??[]).map(j=>ut(j,B))),points:A.map(C=>ut(C,B)),halfWidth:[...P,...E].reduce((C,j)=>Math.min(C,x(j)),1/0)}},k=(w,L,A)=>{let B=()=>{let P=b(w,L,A,u);return w.nodes.some(E=>(e[E]??[]).some(C=>!Tt(ut(C,u),P)))};return w.nodes.length>0&&w.bp*p<q&&w.bp*m>=q&&Ln(w,b(w,L,A,n),e,o,n)&&B()},I=new Set,_=new Set,T=new Map,X=[];for(let w of c){let L=w.feet.flatMap(P=>{let E=An(o,P);return E?[E]:[]}),[A]=w.refNames,B=A!==void 0&&w.refNames.size===1&&w.bp>0&&L.length===w.feet.length&&w.nodes.every(P=>e[P]?.length)?S(w,A):void 0;if(A!==void 0&&B&&B.back>=q&&(B.shown<q||k(w,d.get(A),L))){let P={nodes:w.nodes,edges:w.edges,refName:A,start:tt(w.attachments),end:ht(w.attachments),bp:w.bp,..._n(L),count:w.walks.length,total:i};X.push(P);for(let E of w.nodes)I.add(E),T.set(E,P);for(let E of w.edges)_.add(E)}}let O=kn(X,d);return{sites:X,nodes:I,edges:_,siteOf:T,pxPerBp:p,within:Sn(X,d),through:O.nodes,bridges:O.bridges,runOf:O.runOf}}var Cn=H(),Rs=t=>t.sites.reduce((e,n)=>Math.max(e,n.bp+1),0);function Hs(t,e,n,o,s,r,a){return Cn(o,[t,e,s,r,a.contigThickness,a.nodeWidth],()=>Pn(t,e,n,o,s,r,a))}var ve=11,Xn=6.2,mt=4;function yt(t){return t.length*Xn+mt*2}function Se(t,e){return t.x0<e.x1&&t.x1>e.x0&&t.y0<e.y1&&t.y1>e.y0}function ke(t,e){return t.x1<=0||t.x0>=e.width||t.y1<=0||t.y0>=e.height}function D(t,e){return t.x0>=0&&t.x1<=e.width&&t.y0>=0&&t.y1<=e.height}function Ie(t,e){return{x0:t.x0-e,x1:t.x1+e,y0:t.y0-e,y1:t.y1+e}}function Tn(t,e=[]){let n=[...e];return(o,s)=>{let r=s?[o,s]:[o];if(ke(o,t)||n.some(a=>r.some(c=>Se(a,c))))return!1;for(let a of r)n.push(a);return!0}}var we=8;function be(t){let e=[0];for(let n=we;n<t;n+=we)e.push(-n,n);return t>0&&e.push(-t,t),e}function Ys(t,e,n,o=[],s=0){let r=[],a=0,c=ve+mt*2,i=(h,v,y)=>({x0:h-y/2,x1:h+y/2,y0:v-ve-mt,y1:v+mt}),f=(h,v,y,M)=>{let S=yt(v),N=[];for(let x=0;x<=(h.stack??0);x++){let b=y+M*x*c;if(ke(i(h.x,b,S),e))break;for(let k of be(h.slide??0))N.push({dx:k,y:b,distance:Math.hypot(k,x*c)})}N.sort((x,b)=>x.distance-b.distance);let g=!1;for(let{dx:x,y:b}of N){let k=i(h.x+x,b,S);if(D(k,e)&&(h.fits?.(k)??!0)){if(n(k))return{placed:{...h,x:h.x+x,text:v,y:b,w:S},crowded:g};g||=!o.some(I=>Se(I,k))}}return{placed:void 0,crowded:g}},l=(h,v)=>{let y=f(h,v,h.y,h.y>e.height/2?-1:1);return y.placed||h.flipY===void 0||y.crowded?y:f(h,v,h.flipY,h.flipY<h.y?-1:1)},d=Math.ceil(e.height/c),p=h=>{let v=[];for(let y=-d;y<=d;y++)for(let M of be(h))v.push({dx:M,dy:y*c,distance:Math.hypot(M,y*c)});return v.sort((y,M)=>y.distance-M.distance)},u,m=(h,v,y)=>{let M=yt(v),S=D({x0:y.x,x1:y.x,y0:y.y,y1:y.y},e)?u??=p(e.width):p(h.slide??0),N=x=>{let b;for(let k=0;k<S.length&&!b;k++){let I=y.x+S[k].dx,_=y.y+S[k].dy,T=i(I,_,M);b=D(T,e)&&x(T)?{x:I,y:_}:void 0}return b},g=N(x=>(h.fits?.(x)??!0)&&n(x))??N(n);return g&&{...h,x:g.x,y:g.y,text:v,w:M}};for(let h of t){let v=l(h,h.text),y=v.placed||h.fallback===void 0?void 0:l(h,h.fallback),M=v.placed??y?.placed,S=v.crowded||y?.crowded===!0,N=M||h.nearest===void 0||S&&a>=s?void 0:m(h,h.text,h.nearest);N&&a++;let g=M??N;g&&r.push(g)}return r}function qs(t,e){let n=new Set(t.nodes.filter(i=>R(i)&&St(i,e)).map(i=>i.id)),o=t.paths??[];if(n.size===0||o.length===0)return t;let s=o.map(i=>{let f=-1,l=-1;return i.nodeIds.forEach((d,p)=>{n.has(d)&&(f<0&&(f=p),l=p)}),f<0?void 0:{first:f,last:l}});if(s.every((i,f)=>i?.first===0&&i.last===o[f].nodeIds.length-1))return t;let r=new Set,a=[],c=new Map;return o.forEach((i,f)=>{let l=s[f];if(l){let d=i.nodeIds.slice(l.first,l.last+1);for(let p of d)r.add(p);a.push({...i,nodeIds:d,...i.refStarts?{refStarts:i.refStarts.subarray(l.first,l.last+1)}:{}}),c.set(i.name,{first:l.first,nodeIds:d})}}),{...t,nodes:t.nodes.filter(i=>r.has(i.id)),edges:t.edges.filter(i=>r.has(i.from)&&r.has(i.to)),paths:a,pathVisits:t.pathVisits&&Bn(t.pathVisits,o,s,new Map(t.nodes.map(i=>[i.id,i.name]))),anchorPaths:ee(t,c)}}function Bn(t,e,n,o){let s=t.replay(),r=new te;return e.forEach((a,c)=>{let i=t.pathIndex(J(a.name).name),f=n[c];a.nodeIds.forEach((l,d)=>{let p=o.get(l)??l,u=s(t.slot(p),i);u>=0&&f&&d>=f.first&&d<=f.last&&r.add(p,t.paths[i],t.samples[i],t.start[u],t.reversed[u]===1)})}),r.build()}function Gs(t,e,n){let o=t.nodes.map(s=>{if(!R(s))return s;let r=s.stable.start,a=r+s.length,[c,i]=St(s,e)?[Math.max(r,e.start),Math.min(a,e.end)]:a<=e.start?[Math.max(r,a-n),a]:[r,Math.min(a,r+n)];return c===r&&i===a?s:{...s,length:i-c,stable:{...s.stable,start:c},unclipped:{start:r,length:s.length}}});return o.some((s,r)=>s!==t.nodes[r])?{...t,nodes:o}:t}function Ae(t){return t.nodes.some(e=>e.unclipped)?{...t,nodes:t.nodes.map(({unclipped:e,...n})=>e&&n.stable?{...n,length:e.length,stable:{...n.stable,start:e.start}}:n)}:t}var Rn=1,er=t=>`skips ${t??"the reference"} sequence`,nr="short skip";function Hn(t,e){return e.flatMap(n=>t[n]??[])}function Ht(t,e,n,o,s,r){let a=t[e.from],c=t[e.to];if(!(!a?.length||!c?.length))return s?Zt(a,c,s,r?st(e):void 0):Ut(a,c,Kt(e,r),n,o?Hn(t,o):[])}function $n(t){let e=K(t.nodes.filter(R),n=>n.stable.refName);for(let n of e.values())n.sort((o,s)=>o.stable.start-s.stable.start);return e}function Yn(t,e,n){let o=[];if(t)for(let s=Jt(t,e);s<t.length;s++){let r=t[s];if(r.stable.start>=n)break;r.stable.start+r.length<=n&&o.push(r.id)}return o}function Wn(t,e,n,o){let{fromStrand:s,toStrand:r}=t;if(s===void 0||r===void 0)return!0;let a=s===e.strand,c=r===n.strand;return o?a&&c:!a&&!c}function Dn(t,e,n,o){let s;for(let[r,a]of o){let c=r.start<=a.start,i=c?{start:r.start+e.length,end:a.start}:{start:a.start+n.length,end:r.start};Wn(t,r,a,c)&&(!s||Math.abs(i.end-i.start)<Math.abs(s.end-s.start))&&(s=i)}return s}function Fn(t,e,n){return n(t).flatMap(o=>n(e).map(s=>[o,s]))}function zn(t){let{pathVisits:e}=t;return(n,o)=>{let s;if(e){let r=e.pathIndex(n.stable.refName),a=e.slot(n.name);if(a>=0&&r>=0)for(let c=e.offsets[a];c<e.offsets[a+1]&&!s;c++)e.path[c]===r&&e.start[c]===o&&(s={start:o,strand:e.strand(c)})}return s}}function qn(t,e){let n=new Map;for(let r of e){let{from:a,to:c}=t.edges[r],i=n.get(a);i||(i=new Map,n.set(a,i)),$(i,c,r)}let o=new Map,s=(r,a,c)=>{let i=o.get(r);if(i||(i=[],o.set(r,i)),!Number.isNaN(a)&&!Number.isNaN(c)){let f=!1;for(let l=0;l<i.length&&!f;l+=2)f=i[l]===a&&i[l+1]===c;f||i.push(a,c)}};for(let{nodeIds:r,refStarts:a}of t.paths??[])if(a)for(let c=1;c<r.length;c++){let i=r[c-1],f=r[c];for(let l of n.get(i)?.get(f)??[])s(l,a[c-1],a[c]);for(let l of n.get(f)?.get(i)??[])s(l,a[c],a[c-1])}return o}function Gn(t,e,n,o){let s=[];for(let r=0;r<n.length;r+=2){let a=o(t,n[r]),c=o(e,n[r+1]);a&&c&&s.push([a,c])}return s}var Vn=.01;function jn(t,e){let n=new Map;for(let[o,s]of t){let r=s.flatMap(a=>{let c=e(a).map(i=>i.start);return c.slice(1).map((i,f)=>({at:c[f],copy:i-c[f]}))});r.length&&n.set(o,r.sort((a,c)=>a.at-c.at))}return n}function Kn(t,e,n){if(!t)return!1;let o=Y(t.length,r=>t[r].at<e),s=[t[o-1],t[o]].filter(r=>r!==void 0).sort((r,a)=>Math.abs(r.at-e)-Math.abs(a.at-e))[0];return s!==void 0&&Math.abs(s.at-e)<=s.copy&&Math.abs(n-s.copy)<=s.copy*Vn}function Un(t){let e=Ae(t),n=new Map(e.nodes.map(l=>[l.id,l])),o=$n(e),s=ne(e),r=e.edges.flatMap((l,d)=>{let p=n.get(l.from),u=n.get(l.to);return!l.foldBridge&&p!==void 0&&u!==void 0&&R(p)&&R(u)&&p.stable.refName===u.stable.refName?[{edgeIndex:d,edge:l,from:p,to:u}]:[]}),c=e.paths!==void 0&&e.paths.length>0&&e.paths.every(l=>l.refStarts)?qn(e,r.map(l=>l.edgeIndex)):new Map,i=zn(e);return{links:r.map(({edgeIndex:l,edge:d,from:p,to:u})=>{let m=c.get(l);return{edgeIndex:l,edge:d,refName:p.stable.refName,span:Dn(d,p,u,m?Gn(p,u,m,i):Fn(p,u,s))}}),backbone:o,copies:jn(o,s)}}function Ee(t){let{links:e,backbone:n,copies:o}=Un(t);return e.flatMap(({edgeIndex:s,edge:r,refName:a,span:c})=>{let i=c?c.end-c.start:0;return c&&i>=Rn&&!Kn(o.get(a),c.start,i)?[{edgeIndex:s,from:r.from,to:r.to,...r.fromStrand?{fromStrand:r.fromStrand}:{},...r.toStrand?{toStrand:r.toStrand}:{},refName:a,start:c.start,end:c.end,bp:i,bypassed:Yn(n.get(a),c.start,c.end)}]:[]})}function Zn(t,e){let n=new Map,o=a=>{let c=a;for(;n.has(c);)c=n.get(c);return c!==a&&n.set(a,c),c},s=(a,c)=>{let[i,f]=[o(a),o(c)];return i!==f&&n.set(i,f),i!==f},r=new Set(e);return t.edges.forEach((a,c)=>{r.has(c)||s(a.from,a.to)}),new Set(se(e.map(a=>({...t.edges[a],ei:a}))).filter(a=>!s(a.from,a.to)).map(({ei:a})=>a))}var _e=new WeakMap;function or(t,e,n=!0){let o=_e.get(e);o||(o=new Map,_e.set(e,o));let s=o.get(n);if(!s){let r=n?new Set:Zn(t,e.map(a=>a.edgeIndex));s={shown:e.filter(a=>!r.has(a.edgeIndex)),bypassed:new Map(e.map(a=>[a.edgeIndex,a.bypassed])),hidden:r},o.set(n,s)}return s}var Jn=class extends Map{constructor(){super(...arguments),this.arcs=new Set}},Qn=1,to=11,eo=3*to,no=t=>t>=eo,$t=5,Pe=8,oo=64,Yt=-1,Ce=12,Ne=16,so=Ce+$t;function ro(t,e,n,o){let s=l=>({x:l.x*o.scaleX,y:l.y*o.scaleY}),r=t[0],a=t.at(-1),c=[s({x:r.x0,y:r.y0}),...e.flatMap(l=>(n[l]??[]).map(s)),s({x:a.x1,y:a.y1})],i=0,f=0;for(let l of t)for(let d=0;d<=Ne;d++){let p=s(W(l,d/Ne)),u=!1;for(let m=1;m<c.length&&!u;m++){let h=c[m-1],v=c[m];u=U(p.x,p.y,h.x,h.y,v.x,v.y)<=Ce}f++,i+=u?1:0}return i*2>f}function ao(t,e,n,o){let{ax:s,ay:r,ux:a,uy:c}=gt(t,o),i=0;for(let f of e)for(let l of n[f]??[]){let d=(l.y*o.scaleY-r)*a-(l.x*o.scaleX-s)*c;i=Math.abs(d)>Math.abs(i)?d:i}return Math.abs(i)>=1?-Math.sign(i):Math.sign(Wt(t,o,Pe))||Yt}function Oe(t,e){return gt(t,e).length}var co=H();function Xe(t,e,n,o,s,r,a=!1){return co(t,[e,n.scaleX,n.scaleY,!!n.pixelRows,o,r,a,s],()=>{let c=new Jn;for(let i=0;i<e.edges.length;i++){let f=e.edges[i],l=o?.get(i),d=r?.[i],p=l?Ht(t,f,n,l,d,a):void 0,u=l&&d&&p&&no(Oe(p,n))&&ro(p,l,t,n)?Le(p,n,so*ao(p,l,t,n)):p,m=u!==void 0&&Oe(u,n)>=Qn,h=m?u:Ht(t,f,n,void 0,void 0,a);h&&(c.set(i,h),m&&c.arcs.add(i))}if(o){let i=new Map(e.nodes.map(y=>[y.id,y])),{spans:f,levels:l,alone:d}=io(o,[e],()=>fo(Ee(e).filter(y=>o.has(y.edgeIndex)))),p=y=>l.get(y)??1,u=new Map(Array.from(c.arcs,y=>[y,lo(c.get(y),n)])),m=new Map;for(let y of u.values())m.set(y,(m.get(y)??0)+1);let h=new Map,v=new Map;for(let y of Array.from(c.arcs).sort((M,S)=>p(M)-p(S)||M-S)){let M=u.get(y),S=Math.max(p(y),(h.get(M)??0)+1);h.set(M,S),v.set(y,S*$t)}Te(f.filter(y=>c.arcs.has(y.edgeIndex)),(y,M)=>{let S=y.edgeIndex,N=e.edges[S],g=c.get(S),x=Math.max(v.get(S),M>0?M+$t:0),b=Wt(g,n,Pe),I=(!d.has(S)||m.get(u.get(S))>1)&&Math.abs(b)<x;if(I){let _=i.get(N.from)?.stable?.start??0,T=i.get(N.to)?.stable?.start??0,X=r?.[S]?_<=T?Yt:-Yt:Math.sign(b)||1;c.set(S,Le(g,n,x*X))}return I?x:Math.abs(Wt(g,n,oo))})}return c})}var io=H();function Te(t,e){for(let n of K(t,o=>o.refName).values()){let o=Array.from(new Set(n.map(r=>r.start))).sort((r,a)=>a-r),s=new Array(o.length+1).fill(0);for(let r of n.toSorted((a,c)=>a.end-c.end||c.start-a.start||a.edgeIndex-c.edgeIndex)){let a=Y(o.length,f=>o[f]>r.start)+1,c=0;for(let f=a;f>0;f-=f&-f)c=Math.max(c,s[f]);let i=e(r,c);for(let f=a;f<=o.length;f+=f&-f)s[f]=Math.max(s[f],i)}}}function fo(t){let e=new Map;Te(t,(o,s)=>(e.set(o.edgeIndex,s+1),s+1));let n=new Set;for(let o of K(t,s=>s.refName).values()){let s;for(let r of o.toSorted((a,c)=>a.start-c.start))s&&r.start<s.end&&(n.add(r.edgeIndex),n.add(s.edgeIndex)),s=s&&s.end>=r.end?s:r}return{spans:t,levels:e,alone:new Set(t.flatMap(o=>n.has(o.edgeIndex)?[]:[o.edgeIndex]))}}function lo(t,e){let n=t[0],o=t.at(-1);return[`${Math.round(n.x0*e.scaleX)},${Math.round(n.y0*e.scaleY)}`,`${Math.round(o.x1*e.scaleX)},${Math.round(o.y1*e.scaleY)}`].sort().join(" ")}function gt(t,e){let n=t[0],o=t.at(-1),s=n.x0*e.scaleX,r=n.y0*e.scaleY,a=Math.hypot(o.x1*e.scaleX-s,o.y1*e.scaleY-r);return{ax:s,ay:r,length:a,ux:(o.x1*e.scaleX-s)/a,uy:(o.y1*e.scaleY-r)/a}}function Wt(t,e,n){let{ax:o,ay:s,ux:r,uy:a}=gt(t,e),c=0;for(let i of t)for(let f=1;f<n;f++){let l=W(i,f/n),d=(l.y*e.scaleY-s)*r-(l.x*e.scaleX-o)*a;c=Math.abs(d)>Math.abs(c)?d:c}return c}function Le(t,e,n){let o=t[0],s=t.at(-1),{ux:r,uy:a}=gt(t,e),c=n/jt,i=-a*c/e.scaleX,f=r*c/e.scaleY,l=r*Math.abs(c)/e.scaleX,d=a*Math.abs(c)/e.scaleY;return[{x0:o.x0,y0:o.y0,cx0:o.x0+i-l,cy0:o.y0+f-d,cx1:s.x1+i+l,cy1:s.y1+f+d,x1:s.x1,y1:s.y1}]}var uo=50;function Be(t,e){return e>0?Math.max(1,t/e):uo}function ho(t){let e=new Set,n=1/0,o=-1/0;for(let s of t)e.add(s.minY),n=Math.min(n,s.minY),o=Math.max(o,s.minY);return e.size>1?(o-n)/(e.size-1):void 0}function He(t,e,n){let o=Be(e,t.length);return{x:o,y:n>0?Be(n,t.length):ho(t)??o}}function po(t,e,n,o){return t===void 0?He(e,n,o):typeof t=="number"?{x:t,y:t}:t}function mo(t,e,n){let o=t.get(e);o||(o=new Map,t.set(e,o));let s=o.get(n);return s||(s=[],o.set(n,s)),s}function $e(t,e,n,o,s,r,a){let c=Math.floor(n/e.x),i=Math.floor(s/e.x),f=Math.floor(o/e.y),l=Math.floor(r/e.y);for(let d=c;d<=i;d++)for(let p=f;p<=l;p++)mo(t,d,p).push(a)}function*Re(t,e,n){if(n-e<t.size)for(let o=e;o<=n;o++){let s=t.get(o);s!==void 0&&(yield s)}else{let o=[];for(let s of t)s[0]>=e&&s[0]<=n&&o.push(s);o.sort((s,r)=>s[0]-r[0]);for(let[,s]of o)yield s}}function*Ye(t,e,n,o,s,r){let a=Math.floor((o-r)/e.y),c=Math.floor((o+r)/e.y);for(let i of Re(t,Math.floor((n-s)/e.x),Math.floor((n+s)/e.x)))yield*Re(i,a,c)}function We(t,e,n,o,s,r){let a=[],c=new Set;for(let i of Ye(t,e,n,o,s,r))for(let f of i)c.has(f)||(c.add(f),a.push(f));return a}function yo(t,e,n,o,s,r,a){let c=!1;for(let i of Ye(t,e,n,o,s,r))if(c=i.some(a),c)break;return c}var Dt=class{constructor(t,e,n={x:0,y:0}){this.cells=new Map;let o=[],s=0,r=0;for(let[c,i]of Object.entries(t))for(let f=0;f<i.length-1;f++){let l=i[f],d=i[f+1],p=Math.min(l.x,d.x),u=Math.min(l.y,d.y),m=Math.max(l.x,d.x),h=Math.max(l.y,d.y);s+=m-p,r+=h-u,o.push({entry:{nodeId:c,segmentIdx:f},minX:p,minY:u,maxX:m,maxY:h})}let a=po(e,o,s,r);this.cellSize={x:Math.max(a.x,n.x),y:Math.max(a.y,n.y)};for(let c of o)$e(this.cells,this.cellSize,c.minX,c.minY,c.maxX,c.maxY,c.entry)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}some(t,e,n,o,s){return yo(this.cells,this.cellSize,t,e,n,o,s)}},De=class{constructor(t,e,n,o,s,r=0,a,c=!1){this.cells=new Map,this.edgeCurves=Xe(t,e,o,s,r,a,c);let i=[],f=0,l=0;for(let d=0;d<e.edges.length;d++){let p=e.edges[d],u=t[p.from],m=t[p.to],h=this.edgeCurves.get(d);if(u?.length&&m?.length&&h){let{minX:v,minY:y,maxX:M,maxY:S}=Vt(h),N=p.pathIds?.length??0;if(n&&N>0){let g=0,x=0;for(let b of rt(u,m,N,o,h))g=Math.max(g,Math.abs(b.x)),x=Math.max(x,Math.abs(b.y));v-=g,y-=x,M+=g,S+=x}f+=M-v,l+=S-y,i.push({ei:d,minX:v,minY:y,maxX:M,maxY:S})}}this.cellSize=He(i,f,l);for(let d of i)$e(this.cells,this.cellSize,d.minX,d.minY,d.maxX,d.maxY,d.ei)}getCurves(t){return this.edgeCurves.get(t)}query(t,e,n,o=n){return We(this.cells,this.cellSize,t,e,n,o)}};var Fe=20;function go(t,e,n,o=1){let s=1/0,r=W(n,0);for(let a=1;a<=Fe;a++){let c=W(n,a/Fe);s=Math.min(s,U(t,e,r.x,r.y*o,c.x,c.y*o)),r=c}return s}function xo(t,e,n,o){let s=1/0;for(let r of n){let a=go(t,e,r,o);a<s&&(s=a)}return s}var Mo=H();function vo(t,e){return Mo(t,[e],()=>new Dt(t))}var ze=16,wo=H();function bo(t,e,n,o){return wo(t,[e,n,o],()=>new Dt(t,void 0,{x:ze/Math.abs(n),y:ze/Math.abs(o)}))}var So=H();function ko(t,e,n,o,s,r,a,c){return So(t,[e,n,o.scaleX,o.scaleY,!!o.pixelRows,s,r,a,c],()=>new De(t,e,n,o,r,s,a,c))}var Io=5;function vr(t,e,n,o,s,r,a){let c=bt(o),i=vo(t,s),f=m=>Math.max(Io,m)/o.scaleX,l=f(r?.maxHalfWidthPx??0),d=i.query(e,n,l,l/c),p=null,u=1/0;for(let{nodeId:m,segmentIdx:h}of d){let v=t[m],y=a?.nodes.has(m)?1/0:U(e,n*c,v[h].x,v[h].y*c,v[h+1].x,v[h+1].y*c);y<u&&y<f(r?.halfWidthPx(m)??0)&&(u=y,p=m)}return p}function xt(t,e,n){let o=e.x-t.x,s=e.y-t.y,r=0,a=1;for(let[c,i]of[[-o,t.x-n.x0],[o,n.x1-t.x],[-s,t.y-n.y0],[s,n.y1-t.y]])c===0?r=i<0?1/0:r:c<0?r=Math.max(r,i/c):a=Math.min(a,i/c);return r<=a?[r,a]:void 0}function Ao(t,e,n){return xt(t,e,n)!==void 0}function wr(t,e,n=0){let o=r=>({x:r.x*e.scaleX+e.translateX,y:r.y*e.scaleY+e.translateY}),s;return(r,a)=>(s??=bo(t,n,e.scaleX,e.scaleY),s.some(((r.x0+r.x1)/2-e.translateX)/e.scaleX,((r.y0+r.y1)/2-e.translateY)/e.scaleY,Math.abs((r.x1-r.x0)/2/e.scaleX),Math.abs((r.y1-r.y0)/2/e.scaleY),({nodeId:c,segmentIdx:i})=>{let f=t[c],l=f?.[i],d=f?.[i+1];return l!==void 0&&d!==void 0&&!a(c)&&Ao(o(l),o(d),r)}))}var _o={x:0,y:0};function br(t,e,n,o,s,r,a,c,i,f,l,d){let p=bt(s),u=10/s.scaleX,m=ko(t,e,r,s,a,c,f,l),h=m.query(n,o,u,u/p),v=null,y=u;for(let M of h){let S=e.edges[M],N=t[S.from],g=t[S.to],x=m.getCurves(M);if(N?.length&&g?.length&&x&&!i?.has(M)&&!d?.edges.has(M)){let b=S.pathIds?.length??0,k=r&&b>0?rt(N,g,b,s,x):[_o];for(let I of k){let _=xo(n-I.x,(o-I.y)*p,x,p);_<y&&(y=_,v=M)}}}return v}var Eo={nodeLengths:!0};function Cr(t,e=Eo.nodeLengths){let n=new Map;for(let o of t)(e||o.placeholder)&&n.set(o.id,o.length);return n}var No=4e4,Oo=8,Lo=5.7,Po=6,ot=13,et=3,Ft=ot,Co=3,Xo=2;function Gt(t){return(t.length*Lo+Po+et)/2}var F=(ot+et)/2,qe=2*F+2*Ft,Ke=({x:t,y:e},{width:n,height:o})=>t>=0&&t<=n&&e+F>0&&e-F<o;function Mt(t,e,n){return{x0:e-t,x1:e+t,y0:n-F,y1:n+F}}function Xr(t,e){return{x0:6,x1:6+yt(t)+et,y0:e-8-et/2,y1:e+8+et/2}}function Ue(t){return String(t).replace(/\B(?=(\d{3})+$)/g,",")}function zt(t){let[e,n]=t>=999500?[t/1e6,"Mb"]:t>=1e3?[t/1e3,"kb"]:[];return e===void 0?`${t} bp`:`${+e.toFixed(e>=100?0:1)} ${n}`}var To=H();function Bo(t,e,n){return To(t,[e,n],()=>Object.entries(t).filter(([o,s])=>s.length>0&&e.has(o)).map(([o,s])=>({id:o,segments:s,kept:n?.get(o)?.placeholder===!0})).sort((o,s)=>o.kept===s.kept?e.get(s.id)-e.get(o.id)||Q(o.id,s.id):o.kept?-1:1))}var Ze=Array.from({length:15},(t,e)=>(e+1)/16).sort((t,e)=>Math.abs(t-.5)-Math.abs(e-.5)||t-e);function Je(t,e,n,o){let s=[0];for(let r=Ge;r<=e;r+=Ge)s.push(-r,r);return Array.from({length:o},(r,a)=>a+1).flatMap(r=>[1,-1].flatMap(a=>s.map(c=>({x:n.x+c,y:n.y+a*r*qt,distance:Math.hypot(c,r*qt)})))).sort((r,a)=>r.distance-a.distance).map(({x:r,y:a})=>({label:{...t,x:r,y:a,leader:n},box:Mt(e,r,a)}))}var Ge=8,Ro=2*F,Qe=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y)<Ro,qt=2*F,tn=t=>Math.ceil(t/qt);function Tr({x:t,y:e,leader:n}){return n?en({x:t,y:e},n):void 0}function en({x:t,y:e},n){return{x1:t,y1:n.y>e?e+ot/2:e-ot/2,x2:n.x,y2:n.y}}function Ho(t,e){let{x1:n,y1:o}=en(t,e),s=Math.hypot(n-e.x,o-e.y),r=s>0?Math.min(1,F/s):1,a=e.x+(n-e.x)*r,c=e.y+(o-e.y)*r;return{x0:Math.min(n,a)-1,x1:Math.max(n,a)+1,y0:Math.min(o,c),y1:Math.max(o,c)}}function nn(t,e){let n=0,o=1/0,s=-1/0,r=0,a=!1;return t.forEach((c,i)=>{let f=t[i-1],l=f?xt(f,c,e):void 0,d=f?Math.hypot(c.x-f.x,c.y-f.y):0;l&&(o=Math.min(o,n+l[0]*d),s=n+l[1]*d),r+=l&&!a?1:0,a=!!l,n+=d}),r===1&&o>=Ft&&n-s>=Ft}function Br({nodePositions:t,nodeLengths:e,nodeById:n,alleleDeletions:o,pxPerBp:s=0,axis:r,translateX:a,translateY:c,width:i,height:f}){let{scaleX:l,scaleY:d}=r,p=new Set(o?.flatMap(y=>y.nodeIds)),u=[],m=({x:y,y:M})=>({x:y*l+a,y:M*d+c}),h={width:i,height:f},v=y=>m(it(t[y]??[],.5));for(let{id:y,segments:M,kept:S}of Bo(t,e,n)){let N=p.has(y)?[]:Ze.map(I=>m(it(M,I))).filter(I=>Ke(I,h)),g=e.get(y),x=N.length>0?G(M,l,d):0,b=S||g*s>=q,[k]=N;if(k&&(x>=qe||b)){let I={key:`node:${y}`,node:y,text:zt(g)},_=Gt(I.text),T=x>=qe?M.map(m):[],X=N.map(({x:O,y:w})=>({label:{...I,x:O,y:w},box:Mt(_,O,w)})).filter(({box:O})=>D(O,h)&&nn(T,O));(X.length>0||b)&&u.push({id:y,kept:S,middle:k,along:X,own:({node:O})=>O===y||O!==void 0&&(t[O]?.length??0)>0&&Qe(v(O),v(y)),stacked:b?()=>Je(I,_,k,S?tn(f):Co).filter(({box:O})=>D(O,h)):void 0})}}return u}var $o=H();function Rr(t){return $o(t.nodes,[t.paths],()=>{let e=new Map(t.nodes.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t.paths??[]){let c=[],i=0,f=!0,l=!1;for(let d of a.nodeIds){let p=e.get(d);if(p&&R(p)){let u=c.join(" ");l&&f&&c.length>0&&!n.has(u)&&(n.add(u),o.push({nodes:c,bp:i})),l=!0,c=[],i=0,f=!0}else c.push(d),i+=p?.length??0,f&&=!!p&&!p.placeholder}}o.sort((a,c)=>c.bp-a.bp||Q(a.nodes[0]??"",c.nodes[0]??"")||c.nodes.length-a.nodes.length);let s=[],r=new Map;for(let a of o){let c=new Map;for(let l of new Set(a.nodes))for(let d of r.get(l)??[])c.set(d,(c.get(d)??0)+(e.get(l)?.length??0));let i;for(let[l,d]of c)i??=2*d>=s[l].bp?l:void 0;let f=i===void 0?void 0:s[i];if(f){f.least=Math.min(f.least,a.bp);for(let l of a.nodes)f.drawn.add(l)}else{for(let l of new Set(a.nodes))$(r,l,s.length);s.push({...a,least:a.bp,drawn:new Set(a.nodes)})}}return s})}function Yo(t,e){let n=zt(t),o=zt(e),[s,r]=n.split(" ");return n===o?o:r===o.split(" ")[1]?`${s}\u2013${o}`:`${n}\u2013${o}`}var nt=(t,e)=>Math.hypot(t.x-e.x,t.y-e.y),Ve=(t,e)=>Math.min(nt(t,e[0]??t),nt(t,e.at(-1)??t));function Wo(t,e){let n=t.map(a=>e[a]??[]),o=[],s=[],r=0;return n.forEach((a,c)=>{let i=a[0],f=a.at(-1),l=n[c+1]??[],d=o.at(-1),p=i&&f?d?nt(d,f)<nt(d,i):l.length>0&&Ve(i,l)<Ve(f,l):!1;for(let u=0;u<a.length;u++){let m=a[p?a.length-1-u:u],h=o.at(-1);r+=h?nt(h,m):0,o.push(m)}s.push(r)}),n.every(a=>a.length>0)?{line:o,ends:s}:void 0}var Do=H(),je=()=>!1;function Fo(t,e){let n=0,o=!1,s=0;return t.forEach((r,a)=>{let c=t[a-1],i=c?xt(c,r,e):void 0;n+=i&&!o?1:0,o=!!i,s+=i&&c?(i[1]-i[0])*Math.hypot(r.x-c.x,r.y-c.y):0}),n===1&&s<=Math.hypot(e.x1-e.x0,e.y1-e.y0)}function Hr({loops:t,edges:e,nodePositions:n,folded:o,pxPerBp:s,ink:r,axis:a,translateX:c,translateY:i,width:f,height:l}){let{scaleX:d,scaleY:p}=a,u=Do(n,[t],()=>t.flatMap(M=>{let S=Wo(M.nodes,n);return S?[{loop:M,...S}]:[]})),m=({x:M,y:S})=>({x:M*d+c,y:S*p+i}),h={width:f,height:l},v=new Map,y=[];for(let{loop:M,line:S,ends:N}of u){let g=Yo(M.least,M.bp),x=Gt(g);if(M.bp*s>=q&&G(S,d,p)>=x*2/Xo&&!M.nodes.every(b=>o?.has(b))){let b=N.at(-1)??0,k=M.nodes[N.findIndex(E=>E>=b/2)]??M.nodes[0],I=`${M.nodes[0]}>${M.nodes.at(-1)}`,_=v.get(I)??0;v.set(I,_+1);let T={key:`loop:${I}${_?`#${_}`:""}`,node:k,text:g},{drawn:X}=M,O=({node:E,edge:C})=>E!==void 0?X.has(E):C!==void 0&&(X.has(e[C]?.from??"")||X.has(e[C]?.to??"")),w=S.map(m),L=r.widest(M.nodes),A=Ze.map(E=>m(it(S,E))).filter(E=>Ke(E,h)),B=A.map(({x:E,y:C})=>({label:{...T,x:E,y:C},box:Mt(x,E,C)})).filter(({box:E})=>D(E,h)&&nn(w,E)&&Fo(w,Ie(E,L))),[P]=A;P&&y.push({id:T.key,kept:!1,middle:P,along:B,own:O,stacked:()=>Je(T,x,P,tn(l)).filter(({box:E})=>D(E,h))})}}return y}function $r(t,e){return Math.max(Oo,Math.floor(t*e/No))}var zo=(t,e)=>Math.hypot(Math.max(0,t.x0-e.x1,e.x0-t.x1),Math.max(0,t.y0-e.y1,e.y0-t.y1));function Yr(t,e,{budget:n=1/0,placed:o=[],leaders:s=1/0,under:r=je}={}){let a=[],c=o.slice(),i=d=>c.some(({middle:p})=>Qe(p,d)),f=({label:d,box:p})=>c.every(u=>u.label.text!==d.text||zo(p,Mt(Gt(d.text),u.label.x,u.label.y))>=ot),l=0;for(let d of t)if((d.kept||c.length<n)&&!i(d.middle)){let p=m=>d.own(m)||m.exon!==void 0&&d.own({node:m.exon}),u=d.along.find(m=>f(m)&&!r(m.box,d.own)&&e(m.box))??(l<s?d.stacked?.().find(m=>{let h=Ho(m.label,d.middle);return f(m)&&!r(m.box,je)&&!r(h,p)&&e(m.box,h)}):void 0);if(u){let m={label:u.label,middle:d.middle};a.push(m),c.push(m),l+=u.label.leader?1:0}}return a}function Wr(t,e,n){let o=new Set(e.map(c=>c.node)),s=0,r=1/0,a=0;for(let{id:c,kept:i}of t)if(i&&!o.has(c)){let f=n.get(c);s++,r=Math.min(r,f),a=Math.max(a,f)}return s>0?{count:s,smallest:r,largest:a}:void 0}function Vr(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e%360)}function qo(t,e){return t*360/e}var Go=.7,Vo=.5,jo=16;function jr(t){return t>0&&t<=jo}function Ko(t,e){return`hsl(${qo(t,e)}, ${Go*100}%, ${Vo*100}%)`}function Kr(t,e){return`hsl(0, 0%, ${e>1?25+45*t/(e-1):45}%)`}function Uo(t){let e=J(t).name.split("#"),n=e.join("#");if(e.length>=3&&Qt(e[0])){let o=e.slice(2).join("#");return[o,o,n]}return[e[0],e.slice(0,2).join("#"),n]}function Zo(t,e){let{start:n}=J(t);return e.map(o=>`${o} @${Ue(n)}`)}function Ur(t,e){let n=new Map;t.forEach((l,d)=>{n.has(l.name)||n.set(l.name,d)});let o=[...n].map(([l,d])=>({name:l,i:d})),s=o.map(l=>Uo(l.name)),r=l=>o.map((d,p)=>s[p][l]),a=l=>o.map((d,p)=>Zo(d.name,s[p])[l]),c=[r(0),r(1),a(0),r(2),a(1),a(2)],f=c.find(l=>new Set(l).size===o.length)??c.at(-1);return o.map(({name:l,i:d},p)=>({name:l,label:f[p],color:e?.[d]??Ko(d,t.length)}))}function Zr(t){let e=new Map;return new Map([...t].sort((n,o)=>Q(n.label,o.label)).map(n=>{let o=(e.get(n.label)??0)+1;return e.set(n.label,o),[n.name,o>1?`${n.label} (${o})`:n.label]}))}var Qr=[{value:"uniform",label:"Uniform",description:"Every link the same thickness."},{value:"walks",label:"By walks",description:"Thicker the more walks take a link, on the square root of its count against the busiest link in the cut. A graph without walks draws uniform."}],on=.5,Jo=4;function ta(t){let e=0;for(let n of t.edges)e=Math.max(e,n.pathIds?.length??0);return e}function ea(t,e,n){return n==="uniform"||e===0?1:on+(Jo-on)*Math.sqrt(t/e)}var Qo=4;function ts(t){let e=new Map;for(let n of t.edges)$(e,n.from,n.to),$(e,n.to,n.from);return e}function es({nodeId:t,nodeById:e,neighbors:n}){let o=new Set([t]),s=[t],r=1/0,a=-1/0;for(let c=0;c<Qo&&s.length>0;c++){let i=[];for(let f of s){let l=n.get(f);if(l){for(let d of l)if(!o.has(d)){o.add(d);let p=e.get(d);p&&R(p)?(r=Math.min(r,p.stable.start+p.length),a=Math.max(a,p.stable.start)):i.push(d)}}}s=i}return r===1/0?void 0:{start:Math.min(r,a),end:Math.max(r,a)}}function ns({nodeId:t,nodeById:e,neighbors:n}){let o=e.get(t);return o===void 0?void 0:R(o)?{start:o.stable.start,end:o.stable.start+o.length}:es({nodeId:t,nodeById:e,neighbors:n})}function ra(t,e=ts(t)){let n=new Map(t.nodes.map(s=>[s.id,s])),o=new Map;for(let s of t.nodes){let r=ns({nodeId:s.id,nodeById:n,neighbors:e});r&&o.set(s.id,(r.start+r.end)/2)}return o}export{ts as a,ns as b,ra as c,qs as d,Gs as e,Rn as f,er as g,nr as h,Ee as i,or as j,hs as k,ps as l,ms as m,xs as n,ss as o,re as p,_t as q,rs as r,as as s,Et as t,dn as u,un as v,hn as w,cs as x,pe as y,H as z,q as A,Xs as B,Ts as C,Bs as D,Rs as E,Hs as F,ve as G,Xn as H,mt as I,yt as J,Ie as K,Tn as L,Ys as M,to as N,no as O,Oe as P,Xe as Q,vr as R,xt as S,Ao as T,wr as U,br as V,Eo as W,Cr as X,Xr as Y,Ue as Z,zt as _,Tr as $,Br as aa,Rr as ba,Yo as ca,Hr as da,$r as ea,Yr as fa,Wr as ga,Vr as ha,qo as ia,Go as ja,Vo as ka,jo as la,jr as ma,Ko as na,Kr as oa,Ur as pa,Zr as qa,Qr as ra,ta as sa,ea as ta};
2
+ //# sourceMappingURL=chunk-4JYYNBSO.js.map