jbrowse-plugin-graphgenomeviewer 10.4.4 → 10.5.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 (93) hide show
  1. package/dist/chunks/{AddTrackWorkflow-D4QSDNWI.js → AddTrackWorkflow-DCGEOG4A.js} +2 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-RM4CXLLF.js → GbzBaseSyntenyAdapter-UZAMZKOH.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-RM4CXLLF.js.map → GbzBaseSyntenyAdapter-UZAMZKOH.js.map} +2 -2
  4. package/dist/chunks/{GraphGenomeView-QQFYOKM5.js → GraphGenomeView-MYE7DZOJ.js} +2 -2
  5. package/dist/chunks/GraphSettingsDialog-Q5XQNVCX.js +2 -0
  6. package/dist/chunks/{HighlightColorDialog-NNQM2AER.js → HighlightColorDialog-PMIZVFUP.js} +2 -2
  7. package/dist/chunks/LinearGraphDisplay-L4SH3WDU.js +2 -0
  8. package/dist/chunks/{MinigraphBubbleAdapter-JBYQHQRT.js → MinigraphBubbleAdapter-XOMY4TNZ.js} +2 -2
  9. package/dist/chunks/{RgfaTabixAdapter-6FJWPEHW.js → RgfaTabixAdapter-KNQSPMBO.js} +2 -2
  10. package/dist/chunks/{WalkFormsAdapter-IRGWL2G4.js → WalkFormsAdapter-TIRIE4Q2.js} +2 -2
  11. package/dist/chunks/{WalkTabixSyntenyAdapter-7RQNFBIG.js → WalkTabixSyntenyAdapter-BMCLSDBP.js} +2 -2
  12. package/dist/chunks/{chunk-ESUDWLHY.js → chunk-2OXO7QGS.js} +2 -2
  13. package/dist/chunks/{chunk-BPCYXZWU.js → chunk-5LL2NZGQ.js} +2 -2
  14. package/dist/chunks/{chunk-HHK5MBID.js → chunk-B3XU763Z.js} +1 -1
  15. package/dist/chunks/{chunk-HHK5MBID.js.map → chunk-B3XU763Z.js.map} +1 -1
  16. package/dist/chunks/{chunk-SRA6CKRA.js → chunk-CUCPYCYW.js} +2 -2
  17. package/dist/chunks/chunk-CUV34DJR.js +2 -0
  18. package/dist/chunks/chunk-CUV34DJR.js.map +7 -0
  19. package/dist/chunks/{chunk-E55FR7S6.js → chunk-F4MZBJ6U.js} +1 -1
  20. package/dist/chunks/{chunk-E55FR7S6.js.map → chunk-F4MZBJ6U.js.map} +1 -1
  21. package/dist/chunks/chunk-HC7UMW4R.js +2 -0
  22. package/dist/chunks/chunk-HC7UMW4R.js.map +7 -0
  23. package/dist/chunks/{chunk-GZROPRBI.js → chunk-HCR7MPCX.js} +2 -2
  24. package/dist/chunks/{chunk-GZROPRBI.js.map → chunk-HCR7MPCX.js.map} +2 -2
  25. package/dist/chunks/{chunk-JFNEV3BY.js → chunk-HXFACKC5.js} +2 -2
  26. package/dist/chunks/{chunk-JXMFPTPM.js → chunk-IYFGF6RV.js} +2 -2
  27. package/dist/chunks/chunk-J2WPBZDH.js +2 -0
  28. package/dist/chunks/{chunk-G7MXYOW5.js.map → chunk-J2WPBZDH.js.map} +3 -3
  29. package/dist/chunks/{chunk-7YC64WD6.js → chunk-LQPYJJ6B.js} +2 -2
  30. package/dist/chunks/chunk-MO7FJCN4.js +3 -0
  31. package/dist/chunks/chunk-MO7FJCN4.js.map +7 -0
  32. package/dist/chunks/chunk-MQAFQAPI.js +2 -0
  33. package/dist/chunks/{chunk-6GJELLIC.js.map → chunk-MQAFQAPI.js.map} +4 -4
  34. package/dist/chunks/{chunk-FSBDVHNR.js → chunk-OX6H7JFG.js} +1 -1
  35. package/dist/chunks/{chunk-FSBDVHNR.js.map → chunk-OX6H7JFG.js.map} +1 -1
  36. package/dist/chunks/{chunk-LOT3BKM3.js → chunk-P3GONGHK.js} +2 -2
  37. package/dist/chunks/{chunk-LOT3BKM3.js.map → chunk-P3GONGHK.js.map} +2 -2
  38. package/dist/chunks/chunk-RRVFVDXA.js +9 -0
  39. package/dist/chunks/{chunk-AYJ6SUB5.js.map → chunk-RRVFVDXA.js.map} +4 -4
  40. package/dist/chunks/{chunk-MX7R2F3F.js → chunk-T2GHTZSP.js} +2 -2
  41. package/dist/chunks/{chunk-MX7R2F3F.js.map → chunk-T2GHTZSP.js.map} +2 -2
  42. package/dist/chunks/{chunk-6T2VBP7Z.js → chunk-TF4IGCM7.js} +2 -2
  43. package/dist/chunks/{chunk-S4BXLNAH.js → chunk-VAXNCBLE.js} +2 -2
  44. package/dist/chunks/{chunk-S4BXLNAH.js.map → chunk-VAXNCBLE.js.map} +1 -1
  45. package/dist/chunks/{chunk-NZ7YFVK4.js → chunk-VVMZAIEJ.js} +2 -2
  46. package/dist/chunks/{chunk-NZ7YFVK4.js.map → chunk-VVMZAIEJ.js.map} +2 -2
  47. package/dist/chunks/{chunk-PZGI7L73.js → chunk-ZETKO3GX.js} +5 -5
  48. package/dist/chunks/chunk-ZETKO3GX.js.map +7 -0
  49. package/dist/chunks/{renderSvg-5YYSAMUL.js → renderSvg-DBAHU63F.js} +2 -2
  50. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
  51. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  52. package/package.json +2 -2
  53. package/src/GraphGenomeView/components/GraphCanvas.tsx +6 -3
  54. package/src/GraphGenomeView/extent.ts +5 -0
  55. package/src/GraphGenomeView/keyPlacement.ts +12 -0
  56. package/src/GraphGenomeView/model.ts +21 -2
  57. package/src/GraphGenomeView/pane/fitViews.ts +70 -22
  58. package/src/GraphGenomeView/pane/graphViews.ts +59 -8
  59. package/src/GraphGenomeView/viewWindow.test.ts +98 -0
  60. package/src/GraphGenomeView/viewWindow.ts +120 -0
  61. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +174 -1
  62. package/src/LinearGraphDisplay/configSchema.ts +33 -0
  63. package/src/LinearGraphDisplay/model.ts +16 -0
  64. package/src/version.ts +1 -1
  65. package/dist/chunks/GraphSettingsDialog-D6WOU4CU.js +0 -2
  66. package/dist/chunks/LinearGraphDisplay-OFZQJHYG.js +0 -2
  67. package/dist/chunks/chunk-5RK2OJEU.js +0 -3
  68. package/dist/chunks/chunk-5RK2OJEU.js.map +0 -7
  69. package/dist/chunks/chunk-5VZ5HRTH.js +0 -2
  70. package/dist/chunks/chunk-5VZ5HRTH.js.map +0 -7
  71. package/dist/chunks/chunk-6GJELLIC.js +0 -2
  72. package/dist/chunks/chunk-AYJ6SUB5.js +0 -9
  73. package/dist/chunks/chunk-G7MXYOW5.js +0 -2
  74. package/dist/chunks/chunk-NSWRDOLS.js +0 -2
  75. package/dist/chunks/chunk-NSWRDOLS.js.map +0 -7
  76. package/dist/chunks/chunk-PZGI7L73.js.map +0 -7
  77. /package/dist/chunks/{AddTrackWorkflow-D4QSDNWI.js.map → AddTrackWorkflow-DCGEOG4A.js.map} +0 -0
  78. /package/dist/chunks/{GraphGenomeView-QQFYOKM5.js.map → GraphGenomeView-MYE7DZOJ.js.map} +0 -0
  79. /package/dist/chunks/{GraphSettingsDialog-D6WOU4CU.js.map → GraphSettingsDialog-Q5XQNVCX.js.map} +0 -0
  80. /package/dist/chunks/{HighlightColorDialog-NNQM2AER.js.map → HighlightColorDialog-PMIZVFUP.js.map} +0 -0
  81. /package/dist/chunks/{LinearGraphDisplay-OFZQJHYG.js.map → LinearGraphDisplay-L4SH3WDU.js.map} +0 -0
  82. /package/dist/chunks/{MinigraphBubbleAdapter-JBYQHQRT.js.map → MinigraphBubbleAdapter-XOMY4TNZ.js.map} +0 -0
  83. /package/dist/chunks/{RgfaTabixAdapter-6FJWPEHW.js.map → RgfaTabixAdapter-KNQSPMBO.js.map} +0 -0
  84. /package/dist/chunks/{WalkFormsAdapter-IRGWL2G4.js.map → WalkFormsAdapter-TIRIE4Q2.js.map} +0 -0
  85. /package/dist/chunks/{WalkTabixSyntenyAdapter-7RQNFBIG.js.map → WalkTabixSyntenyAdapter-BMCLSDBP.js.map} +0 -0
  86. /package/dist/chunks/{chunk-ESUDWLHY.js.map → chunk-2OXO7QGS.js.map} +0 -0
  87. /package/dist/chunks/{chunk-BPCYXZWU.js.map → chunk-5LL2NZGQ.js.map} +0 -0
  88. /package/dist/chunks/{chunk-SRA6CKRA.js.map → chunk-CUCPYCYW.js.map} +0 -0
  89. /package/dist/chunks/{chunk-JFNEV3BY.js.map → chunk-HXFACKC5.js.map} +0 -0
  90. /package/dist/chunks/{chunk-JXMFPTPM.js.map → chunk-IYFGF6RV.js.map} +0 -0
  91. /package/dist/chunks/{chunk-7YC64WD6.js.map → chunk-LQPYJJ6B.js.map} +0 -0
  92. /package/dist/chunks/{chunk-6T2VBP7Z.js.map → chunk-TF4IGCM7.js.map} +0 -0
  93. /package/dist/chunks/{renderSvg-5YYSAMUL.js.map → renderSvg-DBAHU63F.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as $}from"./chunk-G7MXYOW5.js";import"./chunk-S4BXLNAH.js";import"./chunk-6T2VBP7Z.js";import{g as R,h as U}from"./chunk-AYJ6SUB5.js";import"./chunk-IK5G3JHR.js";import{a as V}from"./chunk-5RK2OJEU.js";import"./chunk-SRA6CKRA.js";import{q as v}from"./chunk-NZ7YFVK4.js";import"./chunk-PZGI7L73.js";import"./chunk-LOT3BKM3.js";import"./chunk-NSWRDOLS.js";import"./chunk-6GJELLIC.js";import"./chunk-FSBDVHNR.js";import"./chunk-ZQOMV674.js";import"./chunk-JM4W4PKP.js";import"./chunk-ESUDWLHY.js";import"./chunk-GZROPRBI.js";import"./chunk-YBLNN5FU.js";import"./chunk-MX7R2F3F.js";import"./chunk-HHK5MBID.js";import"./chunk-5VZ5HRTH.js";import"./chunk-D3QZGLZ3.js";import"./chunk-WKD7ALOU.js";import"./chunk-KGAZZNZC.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-E55FR7S6.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-J2WPBZDH.js";import"./chunk-VAXNCBLE.js";import"./chunk-TF4IGCM7.js";import{g as R,h as U}from"./chunk-RRVFVDXA.js";import"./chunk-IK5G3JHR.js";import{a as V}from"./chunk-MO7FJCN4.js";import"./chunk-CUCPYCYW.js";import{q as v}from"./chunk-VVMZAIEJ.js";import"./chunk-ZETKO3GX.js";import"./chunk-P3GONGHK.js";import"./chunk-CUV34DJR.js";import"./chunk-MQAFQAPI.js";import"./chunk-OX6H7JFG.js";import"./chunk-ZQOMV674.js";import"./chunk-JM4W4PKP.js";import"./chunk-2OXO7QGS.js";import"./chunk-HCR7MPCX.js";import"./chunk-YBLNN5FU.js";import"./chunk-T2GHTZSP.js";import"./chunk-B3XU763Z.js";import"./chunk-HC7UMW4R.js";import"./chunk-D3QZGLZ3.js";import"./chunk-WKD7ALOU.js";import"./chunk-KGAZZNZC.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-F4MZBJ6U.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-QQFYOKM5.js.map
10
+ //# sourceMappingURL=GraphGenomeView-MYE7DZOJ.js.map
@@ -0,0 +1,2 @@
1
+ import{b as a}from"./chunk-VAXNCBLE.js";import"./chunk-VVMZAIEJ.js";import"./chunk-CUV34DJR.js";import"./chunk-MQAFQAPI.js";import"./chunk-HC7UMW4R.js";import"./chunk-D3QZGLZ3.js";import"./chunk-TMM73K4C.js";import"./chunk-EGZZ3ADM.js";import"./chunk-F4MZBJ6U.js";import"./chunk-J2PN6CG3.js";import"./chunk-H42TSPVA.js";import"./chunk-DUU6T2I5.js";export{a as default};
2
+ //# sourceMappingURL=GraphSettingsDialog-Q5XQNVCX.js.map
@@ -1,2 +1,2 @@
1
- import{S as d,T as m}from"./chunk-LOT3BKM3.js";import"./chunk-6GJELLIC.js";import"./chunk-HHK5MBID.js";import"./chunk-5VZ5HRTH.js";import"./chunk-E55FR7S6.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-NNQM2AER.js.map
1
+ import{S as d,T as m}from"./chunk-P3GONGHK.js";import"./chunk-MQAFQAPI.js";import"./chunk-B3XU763Z.js";import"./chunk-HC7UMW4R.js";import"./chunk-F4MZBJ6U.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-PMIZVFUP.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b as i}from"./chunk-J2WPBZDH.js";import"./chunk-VAXNCBLE.js";import"./chunk-TF4IGCM7.js";import"./chunk-MO7FJCN4.js";import"./chunk-CUCPYCYW.js";import"./chunk-VVMZAIEJ.js";import"./chunk-ZETKO3GX.js";import"./chunk-P3GONGHK.js";import"./chunk-CUV34DJR.js";import"./chunk-MQAFQAPI.js";import"./chunk-OX6H7JFG.js";import"./chunk-ZQOMV674.js";import"./chunk-2OXO7QGS.js";import"./chunk-HCR7MPCX.js";import"./chunk-YBLNN5FU.js";import"./chunk-T2GHTZSP.js";import"./chunk-B3XU763Z.js";import"./chunk-HC7UMW4R.js";import"./chunk-D3QZGLZ3.js";import"./chunk-WKD7ALOU.js";import"./chunk-KGAZZNZC.js";import"./chunk-TMM73K4C.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-F4MZBJ6U.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-L4SH3WDU.js.map
@@ -1,2 +1,2 @@
1
- import{a as c,d,f as h}from"./chunk-FSBDVHNR.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-BPCYXZWU.js";import"./chunk-KGAZZNZC.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-E55FR7S6.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-JBYQHQRT.js.map
1
+ import{a as c,d,f as h}from"./chunk-OX6H7JFG.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-5LL2NZGQ.js";import"./chunk-KGAZZNZC.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-F4MZBJ6U.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-XOMY4TNZ.js.map
@@ -1,2 +1,2 @@
1
- import{a as y}from"./chunk-JFNEV3BY.js";import"./chunk-ZQOMV674.js";import"./chunk-JXMFPTPM.js";import{a as w}from"./chunk-V55TK2NP.js";import"./chunk-YBLNN5FU.js";import"./chunk-MX7R2F3F.js";import"./chunk-HHK5MBID.js";import"./chunk-5VZ5HRTH.js";import{a as u,c as f,d as p,e as F,g as c,h as d}from"./chunk-BPCYXZWU.js";import{A as R,w as b,x as k,y as x,z as N}from"./chunk-KGAZZNZC.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import{e as g}from"./chunk-EGZZ3ADM.js";import"./chunk-E55FR7S6.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-6FJWPEHW.js.map
1
+ import{a as y}from"./chunk-HXFACKC5.js";import"./chunk-ZQOMV674.js";import"./chunk-IYFGF6RV.js";import{a as w}from"./chunk-V55TK2NP.js";import"./chunk-YBLNN5FU.js";import"./chunk-T2GHTZSP.js";import"./chunk-B3XU763Z.js";import"./chunk-HC7UMW4R.js";import{a as u,c as f,d as p,e as F,g as c,h as d}from"./chunk-5LL2NZGQ.js";import{A as R,w as b,x as k,y as x,z as N}from"./chunk-KGAZZNZC.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import{e as g}from"./chunk-EGZZ3ADM.js";import"./chunk-F4MZBJ6U.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-KNQSPMBO.js.map
@@ -1,2 +1,2 @@
1
- import{c as d,d as _,e as D,f as L,g as V}from"./chunk-ZVMXECJA.js";import{a as b}from"./chunk-V55TK2NP.js";import{a as $,e as A}from"./chunk-BPCYXZWU.js";import{a as k,b as C,c as N,d as E,o as T,p as R,q as x,r as O,s as B,t as M,u as q,v as P}from"./chunk-KGAZZNZC.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-E55FR7S6.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"}},Q=e=>I[e.kind].consequence??(e.delta<0?"loss":"gain"),U=e=>`F${e+1}`,J="other";function W(e,o){let t=100*e/o;return t>0&&t<1?"<1%":`${Math.round(t)}%`}var h=({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=h(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:J,label:`other forms \xB7 ${W(l(n),e.placed)}`,haplotypes:l(n),forms:n.length}]:[]]}var j=5;function Y(e){let o=e.slice(0,j).join(", "),t=e.length-j;return t>0?`${o} and ${t} more`:o}var g=e=>`${e} haplotype${e===1?"":"s"}`;function H(e,o=d){let{unplaced:t,forms:n}=e,s=h(e,o),a=n.slice(s);return[...a.length>0?[`${a.length} smaller forms, ${g(l(a))}, share the empty "other forms" row; maxForms sets how many forms get a row of their own`]:[],...t.length>0?[`${g(t.length)} ${t.length===1?"has":"have"} no walk over the pinned window, so no form: ${Y(t)}`]:[]]}function G({copied:e,refStart:o,refEnd:t}){let[n,s]=e??[o,t];return{start:n,end:Math.max(s,n+1)}}var Z=(e,o)=>e===o?"1":e===R||e===x?".":"0";function K(e,o=d){let{sites:t,forms:n,placed:s}=e,a=h(e,o);return t.flatMap((r,m)=>r.edge?[]:r.states.flatMap(p=>{if(p.key===T)return[];let u=n.map(i=>M(e,i,m)),S=Object.fromEntries(u.slice(0,a).map((i,f)=>[U(f),Z(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}`,...G(i),name:B(i),description:`${z} of ${g(s)}`,...I[i.kind],consequence:Q(i),mark:i,genotypes:S})):[]}))}var X=e=>`${(e/1e6).toFixed(1)} MB`;function ee(e,o){if(!(e instanceof k))return e;let t=L(o),n=`walkByteBudget, ${X(e.limit)}`;return new Error(`The pinned window ${t} is too large to cut for structural forms: ${e.zoomHelps?`about ${E(e.fitsBp)} of it fits in ${n}. Pin a narrower window or raise walkByteBudget`:`its cut fetches ${X(e.bytes??0)}, over ${n}. Raise walkByteBudget`}`)}var te=8,c=new Map;function ne(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<=te)break;c.delete(s)}}return n}var y=class extends ${constructor(){super(...arguments);this.reader=A(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=_(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 ne(p,()=>v("Cutting walks",t.statusCallback,()=>P(this.reader,m,{byteBudget:s}).catch(u=>{throw ee(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??K(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 b(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-IRGWL2G4.js.map
1
+ import{c as d,d as _,e as D,f as L,g as V}from"./chunk-ZVMXECJA.js";import{a as b}from"./chunk-V55TK2NP.js";import{a as $,e as A}from"./chunk-5LL2NZGQ.js";import{a as k,b as C,c as N,d as E,o as T,p as R,q as x,r as O,s as B,t as M,u as q,v as P}from"./chunk-KGAZZNZC.js";import"./chunk-D6TY2QEG.js";import"./chunk-YBLNN5FU.js";import"./chunk-EGZZ3ADM.js";import"./chunk-F4MZBJ6U.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"}},Q=e=>I[e.kind].consequence??(e.delta<0?"loss":"gain"),U=e=>`F${e+1}`,J="other";function W(e,o){let t=100*e/o;return t>0&&t<1?"<1%":`${Math.round(t)}%`}var h=({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=h(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:J,label:`other forms \xB7 ${W(l(n),e.placed)}`,haplotypes:l(n),forms:n.length}]:[]]}var j=5;function Y(e){let o=e.slice(0,j).join(", "),t=e.length-j;return t>0?`${o} and ${t} more`:o}var g=e=>`${e} haplotype${e===1?"":"s"}`;function H(e,o=d){let{unplaced:t,forms:n}=e,s=h(e,o),a=n.slice(s);return[...a.length>0?[`${a.length} smaller forms, ${g(l(a))}, share the empty "other forms" row; maxForms sets how many forms get a row of their own`]:[],...t.length>0?[`${g(t.length)} ${t.length===1?"has":"have"} no walk over the pinned window, so no form: ${Y(t)}`]:[]]}function G({copied:e,refStart:o,refEnd:t}){let[n,s]=e??[o,t];return{start:n,end:Math.max(s,n+1)}}var Z=(e,o)=>e===o?"1":e===R||e===x?".":"0";function K(e,o=d){let{sites:t,forms:n,placed:s}=e,a=h(e,o);return t.flatMap((r,m)=>r.edge?[]:r.states.flatMap(p=>{if(p.key===T)return[];let u=n.map(i=>M(e,i,m)),S=Object.fromEntries(u.slice(0,a).map((i,f)=>[U(f),Z(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}`,...G(i),name:B(i),description:`${z} of ${g(s)}`,...I[i.kind],consequence:Q(i),mark:i,genotypes:S})):[]}))}var X=e=>`${(e/1e6).toFixed(1)} MB`;function ee(e,o){if(!(e instanceof k))return e;let t=L(o),n=`walkByteBudget, ${X(e.limit)}`;return new Error(`The pinned window ${t} is too large to cut for structural forms: ${e.zoomHelps?`about ${E(e.fitsBp)} of it fits in ${n}. Pin a narrower window or raise walkByteBudget`:`its cut fetches ${X(e.bytes??0)}, over ${n}. Raise walkByteBudget`}`)}var te=8,c=new Map;function ne(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<=te)break;c.delete(s)}}return n}var y=class extends ${constructor(){super(...arguments);this.reader=A(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=_(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 ne(p,()=>v("Cutting walks",t.statusCallback,()=>P(this.reader,m,{byteBudget:s}).catch(u=>{throw ee(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??K(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 b(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-TIRIE4Q2.js.map
@@ -1,2 +1,2 @@
1
- import{a as oe}from"./chunk-JFNEV3BY.js";import{a as re}from"./chunk-IK5G3JHR.js";import{a as se}from"./chunk-SRA6CKRA.js";import"./chunk-LOT3BKM3.js";import"./chunk-6GJELLIC.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-7YC64WD6.js";import"./chunk-JXMFPTPM.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-ESUDWLHY.js";import"./chunk-YBLNN5FU.js";import"./chunk-MX7R2F3F.js";import"./chunk-HHK5MBID.js";import"./chunk-5VZ5HRTH.js";import"./chunk-FQI75MV6.js";import{e as Z,h as J}from"./chunk-BPCYXZWU.js";import{e as G}from"./chunk-KGAZZNZC.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-E55FR7S6.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-7RQNFBIG.js.map
1
+ import{a as oe}from"./chunk-HXFACKC5.js";import{a as re}from"./chunk-IK5G3JHR.js";import{a as se}from"./chunk-CUCPYCYW.js";import"./chunk-P3GONGHK.js";import"./chunk-MQAFQAPI.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-LQPYJJ6B.js";import"./chunk-IYFGF6RV.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-2OXO7QGS.js";import"./chunk-YBLNN5FU.js";import"./chunk-T2GHTZSP.js";import"./chunk-B3XU763Z.js";import"./chunk-HC7UMW4R.js";import"./chunk-FQI75MV6.js";import{e as Z,h as J}from"./chunk-5LL2NZGQ.js";import{e as G}from"./chunk-KGAZZNZC.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-F4MZBJ6U.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-BMCLSDBP.js.map
@@ -1,2 +1,2 @@
1
- import{a as s}from"./chunk-E55FR7S6.js";var n=class extends Error{constructor(t){super(`a pair query names both lanes: queryAssemblyName ${t} came without a targetAssemblyName`);this.name="PairTargetError"}};function o(r){let{lanePairs:e,queryAssemblyName:t,targetAssemblyName:a}=r;if(e?.length)return e;if(t===void 0)return[];if(a===void 0)throw new n(t);return[{queryAssemblyName:t,targetAssemblyName:a}]}function m(r){let[e]=r;return r.length===1&&e?`Reading ${e.queryAssemblyName} against ${e.targetAssemblyName}`:`Reading ${r.length} lane pairs`}function l(r,e){return r[e]??r[s(e)]??e}export{n as a,o as b,m as c,l as d};
2
- //# sourceMappingURL=chunk-ESUDWLHY.js.map
1
+ import{a as s}from"./chunk-F4MZBJ6U.js";var n=class extends Error{constructor(t){super(`a pair query names both lanes: queryAssemblyName ${t} came without a targetAssemblyName`);this.name="PairTargetError"}};function o(r){let{lanePairs:e,queryAssemblyName:t,targetAssemblyName:a}=r;if(e?.length)return e;if(t===void 0)return[];if(a===void 0)throw new n(t);return[{queryAssemblyName:t,targetAssemblyName:a}]}function m(r){let[e]=r;return r.length===1&&e?`Reading ${e.queryAssemblyName} against ${e.targetAssemblyName}`:`Reading ${r.length} lane pairs`}function l(r,e){return r[e]??r[s(e)]??e}export{n as a,o as b,m as c,l as d};
2
+ //# sourceMappingURL=chunk-2OXO7QGS.js.map
@@ -1,2 +1,2 @@
1
- import{f as Y,g as X,h as De,i as He,j as Ie,k as ce,l as qe,n as $e}from"./chunk-KGAZZNZC.js";import{a as ae,b as Oe}from"./chunk-D6TY2QEG.js";import{e as Fe,j as Le}from"./chunk-EGZZ3ADM.js";import{d as ze,g as ye,h as re}from"./chunk-E55FR7S6.js";var D=JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],Ue=i=>D!=null&&i in Object(D)?D[i]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+i+"' from '@jbrowse/core/data_adapters/BaseAdapter' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:i});var Mt=Ue("BaseFeatureDataAdapter");var je=Ue("cachedSetup");var Bt=D&&D.__esModule?D.default:D;async function Et(i,e,t,n,s){return Ie(e,t,n),i.getLines(e,t,n,s)}async function Ve(i,e,t){for(let{refName:n,start:s,end:o}of e)Ie(n,s,o);return i.bytesForRegions(e,t)}function H(i){if(i?.aborted)throw ke(i)}function ke(i){let e=i.reason;return e===void 0?new DOMException("This operation was aborted","AbortError"):e}function Ge(i){return typeof i?.addEventListener=="function"}var z=class{entries=new Map;total=0;settledCount=0;limit;shared;fill;sizeOf;toCacheKey;idleTimeoutMs;sweepTimer;constructor({fill:e,maxSize:t=1/0,sizeOf:n=()=>1,cacheKey:s=a=>String(a),idleTimeoutMs:o=0,budget:r}={}){this.fill=e,this.limit=t,this.shared=r&&{budget:r,membership:r.register(this)},this.sizeOf=n,this.toCacheKey=s,this.idleTimeoutMs=o>0&&Number.isFinite(o)?o:void 0}get size(){return this.entries.size}get totalSize(){return this.total}get maxSize(){return this.limit}set maxSize(e){this.limit=e,this.evict()}waiterCount(e){return this.entries.get(this.toCacheKey(e))?.pending?.signals.size??0}async get(e,t,n){H(t);let s=this.toCacheKey(e),o=this.entries.get(s);o&&this.isDoomed(o)&&(this.release(s),o=void 0),o?this.touch(s,o):o=this.start(s,e,n),o.pending&&this.join(o.pending,t);try{return await this.settleFor(o,t)}finally{H(t)}}settleFor(e,t){if(!e.pending||!Ge(t))return e.promise;let n,s=new Promise((r,a)=>{n=a}),o=()=>{n(ke(t))};return t.addEventListener("abort",o,{once:!0}),Promise.race([e.promise,s]).finally(()=>{t.removeEventListener("abort",o)})}getIfCached(e){let t=this.toCacheKey(e),n=this.entries.get(t);if(n){if(this.isDoomed(n)){this.release(t);return}return this.touch(t,n),n.promise}}has(e){let t=this.entries.get(this.toCacheKey(e));return t!==void 0&&!this.isDoomed(t)}delete(e){this.release(this.toCacheKey(e))}clear(){this.entries.clear(),this.shared?.budget.charge(this.shared.membership,-this.total),this.total=0,this.settledCount=0,this.stopSweep()}touch(e,t){this.entries.delete(e),this.entries.set(e,t),t.lastTouched=Date.now(),t.seq=this.stamp()}stamp(){return this.shared?.budget.nextSeq()??0}isDoomed(e){return e.pending?.controller.signal.aborted===!0}sweepIdle(){let e=this.idleTimeoutMs;if(e===void 0)return;let t=Date.now()-e;for(let[n,s]of this.entries)!s.pending&&s.lastTouched<=t&&this.release(n);this.settledCount===0&&this.stopSweep()}startSweep(){let e=this.idleTimeoutMs;if(e===void 0||this.sweepTimer!==void 0)return;let t=Math.min(2**31-1,Math.max(1e3,Math.floor(e/4))),n=new WeakRef(this),s=setInterval(()=>{let o=n.deref();o?o.sweepIdle():clearInterval(s)},t);this.sweepTimer=s,s.unref?.()}stopSweep(){this.sweepTimer!==void 0&&(clearInterval(this.sweepTimer),this.sweepTimer=void 0)}start(e,t,n){let s=n??(this.fill&&(h=>this.fill(t,h)));if(!s)throw new Error("SharedReadCache needs a fill, either on the cache or on the get() call");let o={signals:new Map,pinned:!1,controller:new AbortController},r={promise:Promise.resolve(s(o.controller.signal)),pending:o,size:0,lastTouched:Date.now(),seq:this.stamp()};this.entries.set(e,r);let a=()=>this.entries.get(e)===r,l=()=>{for(let[h,c]of o.signals)h.removeEventListener("abort",c);r.pending=void 0};return r.promise.then(h=>{let c=a()?this.weigh(h):void 0,d=a();l(),d&&(c===void 0?this.entries.delete(e):(r.lastTouched=Date.now(),r.size=c,this.settledCount++,this.total+=c,this.shared?.budget.charge(this.shared.membership,c),this.startSweep())),this.evict(),this.shared?.budget.evict()},()=>{a()&&this.release(e),l()}),r}weigh(e){try{let t=this.sizeOf(e);return Number.isFinite(t)&&t>=0?t:void 0}catch{return}}join(e,t){if(!Ge(t))e.pinned=!0;else if(!t.aborted&&!e.signals.has(t)){let n=()=>{e.signals.delete(t),!e.pinned&&e.signals.size===0&&e.controller.abort(t.reason)};e.signals.set(t,n),t.addEventListener("abort",n,{once:!0})}}release(e){let t=this.entries.get(e);t&&(this.entries.delete(e),t.pending||this.settledCount--,this.total-=t.size,this.shared?.budget.charge(this.shared.membership,-t.size))}lruSpare(e=!1){if(!(this.settledCount<=(e?0:1))){for(let[t,n]of this.entries)if(!n.pending)return{cacheKey:t,seq:n.seq,last:this.settledCount===1}}}evict(){if(!(this.total<=this.limit))for(let[e,t]of this.entries){if(this.total<=this.limit||this.settledCount<=1)break;t.pending||this.release(e)}}};var A=class{minv;maxv;bin;endPosition;constructor(e,t,n,s=t.blockPosition+65536){this.minv=e,this.maxv=t,this.bin=n,this.endPosition=s}toString(){return`${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}fetchedSize(){return this.endPosition-this.minv.blockPosition}};function ve(i,e){if(!(e>0))throw new TypeError(`\`${i}\` must be a number greater than 0`)}var Q=class{#e=new Map;#t=new Map;#n;#s;#o;constructor(e){let t=e.maxAge??Number.POSITIVE_INFINITY;ve("maxSize",e.maxSize),ve("maxAge",t),this.#n=e.maxSize,this.#s=t,this.#o=e.onEviction}#r(e){let t=this.#o;if(t)for(let[n,s]of e)t(n,s.value)}#i(e,t){return t.expiry!==void 0&&t.expiry<=Date.now()?(this.#o?.(e,t.value),this.delete(e),!0):!1}#c(e,t){return this.#i(e,t)?void 0:t.value}#l(e,t){if(this.#t.delete(e),this.#e.set(e,t),this.#e.size>=this.#n){let n=this.#t;this.#t=this.#e,this.#e=new Map,this.#r(n)}}#h(e){this.#t=new Map(e),this.#e=new Map}*#a(){for(let e of[this.#t,this.#e])for(let t of e)this.#i(...t)||(yield t)}get(e){let t=this.#e.get(e);if(t)return this.#c(e,t);let n=this.#t.get(e);if(n&&!this.#i(e,n))return this.#l(e,n),n.value}set(e,t,{maxAge:n=this.#s}={}){let s={value:t,expiry:n===Number.POSITIVE_INFINITY?void 0:Date.now()+n};return this.#e.has(e)?this.#e.set(e,s):this.#l(e,s),this}has(e){let t=this.#e.get(e)??this.#t.get(e);return t!==void 0&&!this.#i(e,t)}peek(e){let t=this.#e.get(e)??this.#t.get(e);return t?this.#c(e,t):void 0}expiresIn(e){let t=this.#e.get(e)??this.#t.get(e);if(t)return t.expiry===void 0?Number.POSITIVE_INFINITY:t.expiry-Date.now()}delete(e){return this.#e.delete(e)||this.#t.delete(e)}clear(){this.#e.clear(),this.#t.clear()}resize(e){ve("maxSize",e);let t=[...this.#a()],n=t.length-e;n<0?(this.#e=new Map(t),this.#t=new Map):(this.#r(t.slice(0,n)),this.#h(t.slice(n))),this.#n=e}evict(e=1){if(!(e>0))return;let t=[...this.#a()],n=Math.trunc(Math.min(e,t.length-1));n>0&&(this.#r(t.slice(0,n)),this.#h(t.slice(n)))}get size(){return Math.min(this.#e.size+this.#t.size,this.#n)}get maxSize(){return this.#n}get maxAge(){return this.#s}*entriesAscending(){for(let[e,t]of this.#a())yield[e,t.value]}*entriesDescending(){for(let e of[this.#e,this.#t])for(let[t,n]of[...e].reverse())this.#i(t,n)||(yield[t,n.value])}entries(){return this.entriesAscending()}[Symbol.iterator](){return this.entriesAscending()}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}forEach(e,t=this){for(let[n,s]of this)e.call(t,s,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};function We(i,e=0){let t=i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24;return((i[e+4]|i[e+5]<<8|i[e+6]<<16|i[e+7]<<24)>>>0)*4294967296+(t>>>0)}var G=class{blockPosition;dataPosition;constructor(e,t){this.blockPosition=e,this.dataPosition=t}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}};function O(i,e=0){return new G(i[e+7]*1099511627776+i[e+6]*4294967296+i[e+5]*16777216+i[e+4]*65536+i[e+3]*256+i[e+2],i[e+1]<<8|i[e])}function le(i,e){let t=i.length;if(t===0)return i;let n;if(e){let a=e.blockPosition,l=e.dataPosition;n=[];for(let h=0;h<t;h++){let c=i[h];(c.maxv.blockPosition-a||c.maxv.dataPosition-l)>0&&n.push(c)}if(n.length===0)return n}else n=i;n.sort((a,l)=>{let h=a.minv.blockPosition-l.minv.blockPosition;return h===0?a.minv.dataPosition-l.minv.dataPosition:h});let s=[n[0]],o=n[0].minv.blockPosition,r=n[0].maxv.blockPosition;for(let a=1;a<n.length;a++){let l=n[a],h=l.minv.blockPosition,c=l.maxv.blockPosition;if(h-r<65e3&&c-o<5e6){let d=s.at(-1);(c-r||l.maxv.dataPosition-d.maxv.dataPosition)>0&&(s[s.length-1]=new A(d.minv,l.maxv,d.bin,l.endPosition),r=c)}else s.push(l),o=h,r=c}return at(s)}function at(i){let e=[i[0]];for(let t=1;t<i.length;t++){let n=i[t],s=e.at(-1).maxv;if((n.minv.blockPosition-s.blockPosition||n.minv.dataPosition-s.dataPosition)>=0){e.push(n);continue}(n.maxv.blockPosition-s.blockPosition||n.maxv.dataPosition-s.dataPosition)>0&&e.push(new A(s,n.maxv,n.bin,n.endPosition))}return e}function he(i,e=[]){let t=[...e];for(let n of i)t.push(n.minv.blockPosition,n.maxv.blockPosition);t.sort((n,s)=>n-s);for(let n of i){let s=n.maxv.blockPosition,o=0,r=t.length;for(;o<r;){let a=o+r>>>1;t[a]>s?r=a:o=a+1}o<t.length&&(n.endPosition=Math.min(n.endPosition,t[o]))}}function de(i,e,t,n,s=8){let o=n?n.blockPosition:1/0,r=n?n.dataPosition:0,a=!1;for(let l=0;l<t;l++){let h=e+l*s,c=i[h+7]*1099511627776+i[h+6]*4294967296+i[h+5]*16777216+i[h+4]*65536+i[h+3]*256+i[h+2],d=i[h+1]<<8|i[h];(c<o||c===o&&d<r)&&(o=c,r=d,a=!0)}return a?new G(o,r):n}function ct(i){let e=new TextDecoder("utf-8"),t=[],n={},s=0,o=0;for(;o<i.length;){let r=i.indexOf(0,o);if(r===-1)break;if(r>o){let a=e.decode(i.subarray(o,r));t[s]=a,n[a]=s}o=r+1,s++}return{refNameToId:n,refIdToName:t}}var lt={0:"generic",1:"SAM",2:"VCF",3:"GAF"};function fe(i,e){let t=new DataView(i.buffer,i.byteOffset,i.byteLength),n=t.getInt32(e,!0),s=n&65536?"zero-based-half-open":"1-based-closed",o=lt[n&15];if(!o)throw new Error(`invalid Tabix preset format flags ${n}`);let r={ref:t.getInt32(e+4,!0),start:t.getInt32(e+8,!0),end:t.getInt32(e+12,!0)},a=t.getInt32(e+16,!0),l=a?String.fromCharCode(a):void 0,h=t.getInt32(e+20,!0),c=t.getInt32(e+24,!0),{refIdToName:d,refNameToId:p}=ct(i.subarray(e+28,e+28+c));return{refIdToName:d,refNameToId:p,skipLines:h,metaChar:l,columnNumbers:r,format:o,coordinateType:s}}function ue(i,e){return{lineCount:We(i,e)}}function me(i,e=5){let t=new Q({maxSize:e});return n=>{let s=t.get(n);if(s!==void 0)return s;let o=i(n);return o!==void 0&&t.set(n,o),o}}function Ke(i){let e=0;for(let s of i)e+=s.length;let t=new Uint8Array(e),n=0;for(let s of i)t.set(s,n),n+=s.length;return t}var Je=10;function Se(i,e,t){let n,s=0;for(let o of i){let r=0;if(n){let h=o.indexOf(Je);if(h===-1){n=Ke([n,o]),e+=o.length;continue}if(t(Ke([n,o.subarray(0,h+1)]),s))return!0;r=h+1,n=void 0}let a=o.lastIndexOf(Je);if(a>=r&&t(o.subarray(r,a+1),e+r))return!0;let l=Math.max(r,a+1);l<o.length&&(n=o.slice(l),s=e+l),e+=o.length}return!1}function Ye(i,e,t){let n=[],s=0;for(let o of i){let r=Math.max(e-s,0),a=Math.min(t-s,o.length);r<a&&n.push(o.subarray(r,a)),s+=o.length}return n}function Pe(i,e,t){let n=0,s=i.length-1;for(;n<s;){let r=n+s+1>>>1;i[r]<=t.blockPosition?n=r:s=r-1}return(n===0?0:e[n])-e[0]+t.dataPosition}function ht(i,e,t,n){if(e>2**(t+n*3))return;let s=(8**(n+1)-1)/7,o=(8**n-1)/7+Math.floor((e-1)/2**t)+1;for(o>=s&&(o=0);;){for(;o%8===1;)o=(o-1)/8;if(o===0)return;let r=i[o];if(r?.length){let a=r[0].minv;for(let l=1;l<r.length;l++){let h=r[l].minv;h.compareTo(a)<0&&(a=h)}return a}o++}}function Xe(i,e){return i.format==="GAF"?0:i.refNameToId[e]}var q=class{filehandle;parseCache=new z({});constructor({filehandle:e}){this.filehandle=e}async readIndexBytes(e){let t=await this.filehandle.readFile({signal:e.signal,onProgress:e.onProgress}),n=await ce(t);return{bytes:n,dataView:new DataView(n.buffer,n.byteOffset,n.byteLength)}}async lineCount(e,t={}){let n=await this.parse(t),s=Xe(n,e);return s===void 0?-1:n.indices(s)?.stats?.lineCount??-1}async getMetadata(e={}){let{indices:t,...n}=await this.parse(e);return n}async blocksForRange(e,t,n,s={}){let o=await this.parse(s),r=Xe(o,e);if(r===void 0)return[];let a=o.indices(r);if(!a)return[];o.format==="GAF"&&(t=Math.max(t-1,0));let l=[];for(let[m,f]of this.reg2bins(t,n,o))for(let x=m;x<=f;x++){let b=a.binIndex[x];if(b)for(let v of b)l.push(v)}let h=this.lowestOffset(a,t,o),c=le(l,h),d=ht(a.binIndex,n,o.minShift,o.depth);if(d){let m=c.length;for(;m>0&&c[m-1].minv.compareTo(d)>=0;)m--;c.length=m}let p=c[0];if(p&&h){let m=2**(o.minShift+3),f=this.lowestOffset(a,Math.floor(t/m)*m,o),x=f&&f.compareTo(h)<0?f:h;p.minv.compareTo(x)<0&&(c[0]=new A(x,p.maxv,p.bin,p.endPosition))}return c}parse(e={}){return this.parseCache.get("index",e.signal,t=>this._parse({...e,signal:t}))}async hasRefSeq(e,t={}){return!!(await this.parse(t)).indices(e)?.binIndex}};var dt=21582659,ft=38359875;function Qe(i,e){return i*2**e}function Te(i,e){return Math.floor(i/2**e)}var $=class extends q{async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e),s=n.getUint32(0,!0),o;if(s===dt)o=1;else if(s===ft)o=2;else throw new Error(`Not a CSI file (magic=${s})`);let r=n.getInt32(4,!0),a=n.getInt32(8,!0),l=(8**(a+1)-1)/7,h=2**(r+a*3),c=n.getInt32(12,!0),d=c>=28&&(n.getInt32(16,!0)&15)===3;if(c<30&&!d)throw new Error("CSI index has no tabix header, so it names no references; it may be a BAM or BCF index");let p=fe(t,16),m=n.getInt32(16+c,!0),f=16+c+4,x,b=[];for(let y=0;y<m;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let u=0;u<I;u++){let S=n.getUint32(f,!0);if(f+=4,S>l)f+=44;else{x=de(t,f,1,x),f+=8;let g=n.getInt32(f,!0);f+=4+16*g}}}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C={},w;for(let F=0;F<S;F++){let k=n.getUint32(u,!0);if(u+=4,k>l)w=ue(t,u+28),u+=44;else{C[k]=O(t,u),u+=8;let R=n.getInt32(u,!0);u+=4;let T=Array.from({length:R});for(let _=0;_<R;_++)T[_]=new A(O(t,u),O(t,u+8),k),u+=16;g[k]=T}}return he(Object.values(g).flat()),{binIndex:g,loffsets:C,stats:w}}return{...p,csi:!0,refCount:m,maxBlockSize:65536,firstDataLine:x,csiVersion:o,indices:me(v),minShift:r,depth:a,maxBinNumber:l,maxRefLength:h}}lowestOffset(e,t,{minShift:n,depth:s}){let{loffsets:o}=e,r;if(o){let a=(Qe(1,3*s)-1)/7+Te(Math.max(t,0),n);for(;r===void 0&&a>0;)if(r=o[a],r===void 0){let l=Math.floor((a-1)/8),h=l*8+1;a=a>h?a-1:l}r??=o[0]}return r}reg2bins(e,t,{minShift:n,depth:s,maxBinNumber:o}){e=Math.max(e,0);let r=2**(n+s*3);t>r&&(t=r),t-=1;let a=0,l=0,h=n+s*3,c=[];for(;a<=s;h-=3,l+=Qe(1,a*3),a+=1){let d=l+Te(e,h),p=l+Te(t,h);if(p-d+c.length>o)throw new Error(`query ${e}-${t} is too large for current binning scheme (shift ${n}, depth ${s}), try a smaller query or a coarser index binning scheme`);c.push([d,p])}return c}};var ut=21578324,Ae=5,_e=14,pe=2**(_e+Ae*3);function Ze(i){return Math.min(Math.max(i,0),pe)}var L=class extends q{reg2bins(e,t){e>pe&&console.warn("querying outside of possible tabix range");let n=Ze(e),s=Math.min(t,pe)-1,o=[];return n<=s&&o.push([0,0],[1+(n>>26),1+(s>>26)],[9+(n>>23),9+(s>>23)],[73+(n>>20),73+(s>>20)],[585+(n>>17),585+(s>>17)],[4681+(n>>14),4681+(s>>14)]),o}lowestOffset(e,t){let n=e.linearIndex;return n?.[Math.min(Ze(t)>>_e,n.length-1)]}async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e);if(n.getUint32(0,!0)!==ut)throw new Error("Not a TBI file");let s=n.getUint32(4,!0),o=((1<<(Ae+1)*3)-1)/7,{refNameToId:r,refIdToName:a,coordinateType:l,format:h,columnNumbers:c,metaChar:d,skipLines:p}=fe(t,8),f=36+n.getInt32(32,!0),x,b=[];for(let y=0;y<s;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let S=0;S<I;S++){let g=n.getUint32(f,!0);f+=4;let C=n.getInt32(f,!0);if(f+=4,g>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");g<=o&&(x=de(t,f,C,x,16)),f+=16*C}let u=n.getInt32(f,!0);f+=4+8*u}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C;for(let k=0;k<S;k++){let R=n.getUint32(u,!0);if(u+=4,R>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(R===o+1){let T=n.getInt32(u,!0);u+=4,T===2&&(C=ue(t,u+16)),u+=16*T}else{let T=n.getInt32(u,!0);u+=4;let _=Array.from({length:T});for(let U=0;U<T;U++)_[U]=new A(O(t,u),O(t,u+8),R),u+=16;g[R]=_}}let w=n.getInt32(u,!0);u+=4;let F=Array.from({length:w});for(let k=0;k<w;k++)F[k]=O(t,u),u+=8;return he(Object.values(g).flat(),F.map(k=>k.blockPosition)),{binIndex:g,linearIndex:F,stats:C}}return{indices:me(v),metaChar:d,minShift:_e,depth:Ae,maxBinNumber:o,maxRefLength:pe,skipLines:p,firstDataLine:x,columnNumbers:c,coordinateType:l,format:h,refIdToName:a,refNameToId:r,maxBlockSize:65536}}};var Me=9,xe=10,nt=13,mt=59,pt=60,gt=62,xt=6,wt=1024*2**20,bt=180*1e3;function Ct(i,e,t){if(i)return i;if(e)return new X(e);if(t)return new Y(t);throw new TypeError("must provide either filehandle, path, or url")}function yt({tbiFilehandle:i,csiFilehandle:e,tbiPath:t,csiPath:n,tbiUrl:s,csiUrl:o,path:r,url:a}){if(i)return new L({filehandle:i});if(e)return new $({filehandle:e});if(t)return new L({filehandle:new X(t)});if(n)return new $({filehandle:new X(n)});if(o)return new $({filehandle:new Y(o)});if(s)return new L({filehandle:new Y(s)});if(r)return new L({filehandle:new X(`${r}.tbi`)});if(a)return new L({filehandle:new Y(`${a}.tbi`)});throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl")}function it(i,e,t,n,s){return i[t]*256+(n-e[t])+s+1}function It(i,e,t,n,s,o,r){let a=n-t,l=e+a,h=0;if(i[s]===46)return l;let c=s;for(let d=s;d<=o;d++)if(d===o||i[d]===mt){let p=d-c;if(p>=10&&i[c]===83&&i[c+1]===86&&i[c+2]===84&&i[c+3]===89&&i[c+4]===80&&i[c+5]===69&&i[c+6]===61&&i[c+7]===84&&i[c+8]===82&&i[c+9]===65)return e+1;if(p>=4&&i[c]===69&&i[c+1]===78&&i[c+2]===68&&i[c+3]===61){let m=ge(i,c+4,d);m>e&&(l=m)}else p>=6&&i[c]===83&&i[c+1]===86&&i[c+2]===76&&i[c+3]===69&&i[c+4]===78&&i[c+5]===61&&(h=vt(i,c+6,d,n+1,r));c=d+1}return Math.max(l,e+h)}var et=44;function kt(i,e,t){if(t-e<5||i[e]!==60||i[t-1]!==62)return!1;let n=i[e+4];if(n!==62&&n!==58)return!1;let s=i[e+1],o=i[e+2],r=i[e+3];return s===67&&o===78&&r===86||s===68&&o===69&&r===76||s===68&&o===85&&r===80||s===73&&o===78&&r===86}function vt(i,e,t,n,s){let o=0,r=e,a=n;for(;r<t&&a<s;){let l=i.indexOf(et,r);(l===-1||l>t)&&(l=t);let h=i.indexOf(et,a);if((h===-1||h>s)&&(h=s),kt(i,a,h)){let c=ge(i,i[r]===45?r+1:r,l);c>o&&(o=c)}r=l+1,a=h+1}return o}var st=new TextDecoder;function tt(i,e){let t=-1,n=e.charCodeAt(0);for(let s=0,o=i.length;s<o;s++){let r=i[s];if(s===t+1&&r!==n)break;r===xe&&(t=s)}return i.subarray(0,t+1)}function St(i,e){let t=0;for(let n=0;n<e;n++){let s=i.indexOf(xe,t);if(s===-1){t=i.length;break}t=s+1}return st.decode(i.subarray(0,t)).split(/\r?\n/).slice(0,e)}function ge(i,e,t){let n=0;for(let s=e;s<t;s++){let o=i[s];if(o>=48&&o<=57)n=n*10+(o-48);else break}return n}function Pt(i,e,t,n,s,{start:o,end:r,pathCol:a,metaCharCode:l,decoder:h,callback:c}){let d=0,p=0;for(;d<i.length;){let m=i.indexOf(xe,d);if(m===-1)break;let f=d;d=m+1;let x=f+e+s;for(;p<n.length&&x>=n[p];)p++;if(i[f]===l)continue;let b=f;for(let g=1;g<a;g++){let C=i.indexOf(Me,b);if(C===-1||C>=m){b=m;break}b=C+1}let v=i[b];if(v!==gt&&v!==pt)continue;let y=i.indexOf(Me,b);(y===-1||y>m)&&(y=m);let I=1/0,u=-1,S=b;for(;S<y;){let g=0,C=S+1;for(;C<y;C++){let w=i[C]-48;if(w<0||w>9)break;g=g*10+w}g<I&&(I=g),g>u&&(u=g),S=C}if(I>=r)return!0;if(u>=o){let g=i[m-1]===nt?m-1:m;c(h.decode(i.subarray(f,g)),it(t,n,p,f+e,s),I,u+1)}}return!1}var W=class{filehandle;index;chunkCache;requested=new Map;headerCache=new z({});bgzfWorkerPool;constructor({path:e,filehandle:t,url:n,tbiPath:s,tbiUrl:o,tbiFilehandle:r,csiPath:a,csiUrl:l,csiFilehandle:h,chunkCacheSize:c=wt,chunkCacheIdleTimeoutMs:d=bt,chunkCacheBudget:p,bgzfWorkerPool:m}){this.bgzfWorkerPool=m,this.filehandle=Ct(t,e,n),this.index=yt({tbiFilehandle:r,csiFilehandle:h,tbiPath:s,csiPath:a,tbiUrl:o,csiUrl:l,path:e,url:n}),this.chunkCache=new z({maxSize:c,sizeOf:f=>{let x=0;for(let b of f.segments)x+=b.byteLength;return x},cacheKey:f=>f.toString(),idleTimeoutMs:d,budget:p,fill:(f,x)=>this.readChunk(f,{signal:x})})}clearChunkCache(){this.chunkCache.clear(),this.requested.clear()}withCachedContainers(e){if(this.requested.size>2*this.chunkCache.size)for(let[n,s]of this.requested)this.chunkCache.has(s)||this.requested.delete(n);let t=[];for(let n=0;n<e.length;n++){let s=e[n],o=t[t.length-1],r=e[n+1],a;if(!this.chunkCache.has(s))for(let l of this.requested.values())l.minv.compareTo(s.minv)<=0&&l.maxv.compareTo(s.maxv)>=0&&(!o||l.minv.compareTo(o.maxv)>=0)&&(!r||l.maxv.compareTo(r.minv)<=0)&&(!a||l.fetchedSize()<a.fetchedSize())&&this.chunkCache.has(l)&&(a=l);t.push(a??s)}return t}async bytesForRegions(e,t={}){let n=[];for(let{refName:o,start:r,end:a}of e){let l=await this.index.blocksForRange(o,r,a,t);for(let h of l)n.push(h)}let s=0;for(let o of le(n))s+=o.fetchedSize();return s}async getLines(e,t,n,s){let o,r={},a,l;typeof s=="function"?a=s:(r=s,a=s.lineCallback,o=s.signal,l=s.onProgress);let h=await this.index.getMetadata(r),c=t??0,d=n??h.maxRefLength;if(c>d)throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(c===d)return;let p=await this.index.blocksForRange(e,c,d,r),m=this.withCachedContainers(p),f=h.format==="VCF",x=h.columnNumbers.ref||0,b=h.columnNumbers.start||0,v=f?8:h.columnNumbers.end||0,y=Math.max(x,b,v),I=h.metaChar?.charCodeAt(0),u=h.coordinateType==="1-based-closed"?-1:0,S=new TextEncoder,g=new TextDecoder,C=S.encode(e),w=new Int32Array(y+1),F=h.format==="GAF"?{start:c,end:d,pathCol:b,metaCharCode:I,decoder:g,callback:a}:void 0,k=0;for(let E of m)k+=E.fetchedSize();let R=0;l?.(0,k);let T=1,_=[],U=E=>{for(;_.length<Math.min(E,m.length);){let K=m[_.length];this.requested.set(K.toString(),K);let j=this.chunkCache.get(K,o);j.catch(()=>{}),_.push(j)}};U(1);for(let E=0,K=m.length;E<K;E++){let j=m[E],Be=await _[E],{cpositions:Z,dpositions:V}=Be;R+=j.fetchedSize(),l?.(R,k);let we=j.minv.dataPosition,be=p[E],ee=Be.segments,te=0;if(be!==j){te=Pe(Z,V,be.minv);let P=Pe(Z,V,be.maxv)+1;ee=Ye(ee,te,P)}if(F){if(Se(ee,te,(P,ne)=>Pt(P,ne,Z,V,we,F)))return}else if(Se(ee,te,(P,ne)=>{let M=0,ie=0;for(;M<P.length;){let B=P.indexOf(xe,M);if(B===-1)break;let rt=M+ne+we;for(;ie<V.length&&rt>=V[ie];)ie++;if(I!==void 0&&P[M]===I){M=B+1;continue}w[0]=M-1;for(let N=0;N<y;N++){let oe=w[N],Ce=oe<B?P.indexOf(Me,oe+1):-1;w[N+1]=Ce===-1||Ce>=B?B:Ce}let Ne=w[x-1]+1,Re=w[x]-Ne;if(Re!==C.length){M=B+1;continue}let Ee=!0;for(let N=0;N<Re;N++)if(P[Ne+N]!==C[N]){Ee=!1;break}if(!Ee){M=B+1;continue}let se=ge(P,w[b-1]+1,w[b])+u;if(se>=d)return!0;let J;if(v===0||v===b?J=se+1:f?J=It(P,se,w[3]+1,w[4],w[v-1]+1,w[v],w[5]):J=ge(P,w[v-1]+1,w[v]),J>c){let N=P[B-1]===nt?B-1:B,oe=g.decode(P.subarray(M,N));a(oe,it(Z,V,ie,M+ne,we),se,J)}M=B+1}return!1}))return;T=Math.min(T*2,xt),U(E+1+T)}}async getMetadata(e={}){return this.index.getMetadata(e)}async readHeaderBytes(e){let{firstDataLine:t,maxBlockSize:n}=await this.getMetadata(e);if(t?.blockPosition===0&&t.dataPosition===0)return new Uint8Array(0);let s=(t?.blockPosition??0)+n,o=await this.filehandle.read(s,0,e);return ce(o)}async parseHeader(e){let{metaChar:t,skipLines:n=0}=await this.getMetadata(e),s=await this.readHeaderBytes(e);return{header:st.decode(t?tt(s,t):s),skippedLines:n>0?St(s,n):[]}}getParsedHeader(e={}){return this.headerCache.get("header",e.signal,t=>this.parseHeader({...e,signal:t}))}async getHeaderBuffer(e={}){let{metaChar:t}=await this.getMetadata(e),n=await this.readHeaderBytes(e);return t?tt(n,t):n}async getSkippedLines(e={}){let{skipLines:t=0}=await this.getMetadata(e);return t<=0?[]:(await this.getParsedHeader(e)).skippedLines}async getHeader(e={}){return(await this.getParsedHeader(e)).header}async getHeaderLines(e={}){let{header:t,skippedLines:n}=await this.getParsedHeader(e);return(t?t.split(/\r?\n/):n).filter(Boolean)}async getReferenceSequenceNames(e={}){return(await this.getMetadata(e)).refIdToName}async lineCount(e,t={}){return this.index.lineCount(e,t)}async readChunk(e,t={}){let n=await this.filehandle.read(e.fetchedSize(),e.minv.blockPosition,t);H(t.signal);let s=await this.bgzfWorkerPool;return qe(n,e,s)}};function Mn(i,e,t){let n=i.pluginManager;return new W({filehandle:ae(i.getConf(e),n),...Oe(i.getConf([...t,"location"]),i.getConf([...t,"indexType"]),n)})}function Bn(i){let e=i.getConf("walksIndex");return Tt(i.getConf("walksLocation"),Fe(e)?e:void 0,i.pluginManager)}function Tt(i,e,t){return $e.fromFilehandles({data:ae(i,t),directory:ae(e??Le(i,n=>`${n}.idx`),t)})}function Nn(i){return{names:e=>i.getReferenceSequenceNames(e),bytes:(e,t)=>Ve(i,e,t)}}function At(i){return`${i.assemblyName} ${i.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${i.assemblyName} mapped to its prefix in assemblyNameToPanSN`}var ot=class{constructor(e,t){this.source=e;this.adapter=t;this.lookup=je({setup:async e=>De(await this.source.names(e))})}async assemblyRefNames(e={}){let t=await this.source.names(e),n=re(this.adapter,e.assemblyName),s=t.filter(o=>ye(o,n)).map(o=>ze(o));return s.length>0?[...new Set(s)]:t}async resolve(e,t){let n=await this.lookup(t);return He(n,re(this.adapter,e.assemblyName),e.refName)}async resolveMapped(e,t){let n=await this.resolve(e,t);if(n===void 0&&e.assemblyName){let s=await this.source.names(t),o=re(this.adapter,e.assemblyName);if(s.length>0&&s.every(r=>r.includes("#"))&&!s.some(r=>ye(r,o)))throw new Error(At(e))}return n}async resolveForCut(e,t){let n=await this.resolveMapped(e,t);if(n===void 0)throw new Error(`This graph has nothing on ${e.assemblyName} ${e.refName}`);return n}async regionBytes(e,t={}){let n=[];for(let s of e){let o=await this.resolve(s,t);o!==void 0&&n.push({refName:o,start:s.start,end:s.end})}return this.source.bytes(n,t)}};export{Mt as a,je as b,Et as c,Mn as d,Bn as e,Tt as f,Nn as g,ot as h};
2
- //# sourceMappingURL=chunk-BPCYXZWU.js.map
1
+ import{f as Y,g as X,h as De,i as He,j as Ie,k as ce,l as qe,n as $e}from"./chunk-KGAZZNZC.js";import{a as ae,b as Oe}from"./chunk-D6TY2QEG.js";import{e as Fe,j as Le}from"./chunk-EGZZ3ADM.js";import{d as ze,g as ye,h as re}from"./chunk-F4MZBJ6U.js";var D=JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],Ue=i=>D!=null&&i in Object(D)?D[i]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+i+"' from '@jbrowse/core/data_adapters/BaseAdapter' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:i});var Mt=Ue("BaseFeatureDataAdapter");var je=Ue("cachedSetup");var Bt=D&&D.__esModule?D.default:D;async function Et(i,e,t,n,s){return Ie(e,t,n),i.getLines(e,t,n,s)}async function Ve(i,e,t){for(let{refName:n,start:s,end:o}of e)Ie(n,s,o);return i.bytesForRegions(e,t)}function H(i){if(i?.aborted)throw ke(i)}function ke(i){let e=i.reason;return e===void 0?new DOMException("This operation was aborted","AbortError"):e}function Ge(i){return typeof i?.addEventListener=="function"}var z=class{entries=new Map;total=0;settledCount=0;limit;shared;fill;sizeOf;toCacheKey;idleTimeoutMs;sweepTimer;constructor({fill:e,maxSize:t=1/0,sizeOf:n=()=>1,cacheKey:s=a=>String(a),idleTimeoutMs:o=0,budget:r}={}){this.fill=e,this.limit=t,this.shared=r&&{budget:r,membership:r.register(this)},this.sizeOf=n,this.toCacheKey=s,this.idleTimeoutMs=o>0&&Number.isFinite(o)?o:void 0}get size(){return this.entries.size}get totalSize(){return this.total}get maxSize(){return this.limit}set maxSize(e){this.limit=e,this.evict()}waiterCount(e){return this.entries.get(this.toCacheKey(e))?.pending?.signals.size??0}async get(e,t,n){H(t);let s=this.toCacheKey(e),o=this.entries.get(s);o&&this.isDoomed(o)&&(this.release(s),o=void 0),o?this.touch(s,o):o=this.start(s,e,n),o.pending&&this.join(o.pending,t);try{return await this.settleFor(o,t)}finally{H(t)}}settleFor(e,t){if(!e.pending||!Ge(t))return e.promise;let n,s=new Promise((r,a)=>{n=a}),o=()=>{n(ke(t))};return t.addEventListener("abort",o,{once:!0}),Promise.race([e.promise,s]).finally(()=>{t.removeEventListener("abort",o)})}getIfCached(e){let t=this.toCacheKey(e),n=this.entries.get(t);if(n){if(this.isDoomed(n)){this.release(t);return}return this.touch(t,n),n.promise}}has(e){let t=this.entries.get(this.toCacheKey(e));return t!==void 0&&!this.isDoomed(t)}delete(e){this.release(this.toCacheKey(e))}clear(){this.entries.clear(),this.shared?.budget.charge(this.shared.membership,-this.total),this.total=0,this.settledCount=0,this.stopSweep()}touch(e,t){this.entries.delete(e),this.entries.set(e,t),t.lastTouched=Date.now(),t.seq=this.stamp()}stamp(){return this.shared?.budget.nextSeq()??0}isDoomed(e){return e.pending?.controller.signal.aborted===!0}sweepIdle(){let e=this.idleTimeoutMs;if(e===void 0)return;let t=Date.now()-e;for(let[n,s]of this.entries)!s.pending&&s.lastTouched<=t&&this.release(n);this.settledCount===0&&this.stopSweep()}startSweep(){let e=this.idleTimeoutMs;if(e===void 0||this.sweepTimer!==void 0)return;let t=Math.min(2**31-1,Math.max(1e3,Math.floor(e/4))),n=new WeakRef(this),s=setInterval(()=>{let o=n.deref();o?o.sweepIdle():clearInterval(s)},t);this.sweepTimer=s,s.unref?.()}stopSweep(){this.sweepTimer!==void 0&&(clearInterval(this.sweepTimer),this.sweepTimer=void 0)}start(e,t,n){let s=n??(this.fill&&(h=>this.fill(t,h)));if(!s)throw new Error("SharedReadCache needs a fill, either on the cache or on the get() call");let o={signals:new Map,pinned:!1,controller:new AbortController},r={promise:Promise.resolve(s(o.controller.signal)),pending:o,size:0,lastTouched:Date.now(),seq:this.stamp()};this.entries.set(e,r);let a=()=>this.entries.get(e)===r,l=()=>{for(let[h,c]of o.signals)h.removeEventListener("abort",c);r.pending=void 0};return r.promise.then(h=>{let c=a()?this.weigh(h):void 0,d=a();l(),d&&(c===void 0?this.entries.delete(e):(r.lastTouched=Date.now(),r.size=c,this.settledCount++,this.total+=c,this.shared?.budget.charge(this.shared.membership,c),this.startSweep())),this.evict(),this.shared?.budget.evict()},()=>{a()&&this.release(e),l()}),r}weigh(e){try{let t=this.sizeOf(e);return Number.isFinite(t)&&t>=0?t:void 0}catch{return}}join(e,t){if(!Ge(t))e.pinned=!0;else if(!t.aborted&&!e.signals.has(t)){let n=()=>{e.signals.delete(t),!e.pinned&&e.signals.size===0&&e.controller.abort(t.reason)};e.signals.set(t,n),t.addEventListener("abort",n,{once:!0})}}release(e){let t=this.entries.get(e);t&&(this.entries.delete(e),t.pending||this.settledCount--,this.total-=t.size,this.shared?.budget.charge(this.shared.membership,-t.size))}lruSpare(e=!1){if(!(this.settledCount<=(e?0:1))){for(let[t,n]of this.entries)if(!n.pending)return{cacheKey:t,seq:n.seq,last:this.settledCount===1}}}evict(){if(!(this.total<=this.limit))for(let[e,t]of this.entries){if(this.total<=this.limit||this.settledCount<=1)break;t.pending||this.release(e)}}};var A=class{minv;maxv;bin;endPosition;constructor(e,t,n,s=t.blockPosition+65536){this.minv=e,this.maxv=t,this.bin=n,this.endPosition=s}toString(){return`${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}fetchedSize(){return this.endPosition-this.minv.blockPosition}};function ve(i,e){if(!(e>0))throw new TypeError(`\`${i}\` must be a number greater than 0`)}var Q=class{#e=new Map;#t=new Map;#n;#s;#o;constructor(e){let t=e.maxAge??Number.POSITIVE_INFINITY;ve("maxSize",e.maxSize),ve("maxAge",t),this.#n=e.maxSize,this.#s=t,this.#o=e.onEviction}#r(e){let t=this.#o;if(t)for(let[n,s]of e)t(n,s.value)}#i(e,t){return t.expiry!==void 0&&t.expiry<=Date.now()?(this.#o?.(e,t.value),this.delete(e),!0):!1}#c(e,t){return this.#i(e,t)?void 0:t.value}#l(e,t){if(this.#t.delete(e),this.#e.set(e,t),this.#e.size>=this.#n){let n=this.#t;this.#t=this.#e,this.#e=new Map,this.#r(n)}}#h(e){this.#t=new Map(e),this.#e=new Map}*#a(){for(let e of[this.#t,this.#e])for(let t of e)this.#i(...t)||(yield t)}get(e){let t=this.#e.get(e);if(t)return this.#c(e,t);let n=this.#t.get(e);if(n&&!this.#i(e,n))return this.#l(e,n),n.value}set(e,t,{maxAge:n=this.#s}={}){let s={value:t,expiry:n===Number.POSITIVE_INFINITY?void 0:Date.now()+n};return this.#e.has(e)?this.#e.set(e,s):this.#l(e,s),this}has(e){let t=this.#e.get(e)??this.#t.get(e);return t!==void 0&&!this.#i(e,t)}peek(e){let t=this.#e.get(e)??this.#t.get(e);return t?this.#c(e,t):void 0}expiresIn(e){let t=this.#e.get(e)??this.#t.get(e);if(t)return t.expiry===void 0?Number.POSITIVE_INFINITY:t.expiry-Date.now()}delete(e){return this.#e.delete(e)||this.#t.delete(e)}clear(){this.#e.clear(),this.#t.clear()}resize(e){ve("maxSize",e);let t=[...this.#a()],n=t.length-e;n<0?(this.#e=new Map(t),this.#t=new Map):(this.#r(t.slice(0,n)),this.#h(t.slice(n))),this.#n=e}evict(e=1){if(!(e>0))return;let t=[...this.#a()],n=Math.trunc(Math.min(e,t.length-1));n>0&&(this.#r(t.slice(0,n)),this.#h(t.slice(n)))}get size(){return Math.min(this.#e.size+this.#t.size,this.#n)}get maxSize(){return this.#n}get maxAge(){return this.#s}*entriesAscending(){for(let[e,t]of this.#a())yield[e,t.value]}*entriesDescending(){for(let e of[this.#e,this.#t])for(let[t,n]of[...e].reverse())this.#i(t,n)||(yield[t,n.value])}entries(){return this.entriesAscending()}[Symbol.iterator](){return this.entriesAscending()}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}forEach(e,t=this){for(let[n,s]of this)e.call(t,s,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};function We(i,e=0){let t=i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24;return((i[e+4]|i[e+5]<<8|i[e+6]<<16|i[e+7]<<24)>>>0)*4294967296+(t>>>0)}var G=class{blockPosition;dataPosition;constructor(e,t){this.blockPosition=e,this.dataPosition=t}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}};function O(i,e=0){return new G(i[e+7]*1099511627776+i[e+6]*4294967296+i[e+5]*16777216+i[e+4]*65536+i[e+3]*256+i[e+2],i[e+1]<<8|i[e])}function le(i,e){let t=i.length;if(t===0)return i;let n;if(e){let a=e.blockPosition,l=e.dataPosition;n=[];for(let h=0;h<t;h++){let c=i[h];(c.maxv.blockPosition-a||c.maxv.dataPosition-l)>0&&n.push(c)}if(n.length===0)return n}else n=i;n.sort((a,l)=>{let h=a.minv.blockPosition-l.minv.blockPosition;return h===0?a.minv.dataPosition-l.minv.dataPosition:h});let s=[n[0]],o=n[0].minv.blockPosition,r=n[0].maxv.blockPosition;for(let a=1;a<n.length;a++){let l=n[a],h=l.minv.blockPosition,c=l.maxv.blockPosition;if(h-r<65e3&&c-o<5e6){let d=s.at(-1);(c-r||l.maxv.dataPosition-d.maxv.dataPosition)>0&&(s[s.length-1]=new A(d.minv,l.maxv,d.bin,l.endPosition),r=c)}else s.push(l),o=h,r=c}return at(s)}function at(i){let e=[i[0]];for(let t=1;t<i.length;t++){let n=i[t],s=e.at(-1).maxv;if((n.minv.blockPosition-s.blockPosition||n.minv.dataPosition-s.dataPosition)>=0){e.push(n);continue}(n.maxv.blockPosition-s.blockPosition||n.maxv.dataPosition-s.dataPosition)>0&&e.push(new A(s,n.maxv,n.bin,n.endPosition))}return e}function he(i,e=[]){let t=[...e];for(let n of i)t.push(n.minv.blockPosition,n.maxv.blockPosition);t.sort((n,s)=>n-s);for(let n of i){let s=n.maxv.blockPosition,o=0,r=t.length;for(;o<r;){let a=o+r>>>1;t[a]>s?r=a:o=a+1}o<t.length&&(n.endPosition=Math.min(n.endPosition,t[o]))}}function de(i,e,t,n,s=8){let o=n?n.blockPosition:1/0,r=n?n.dataPosition:0,a=!1;for(let l=0;l<t;l++){let h=e+l*s,c=i[h+7]*1099511627776+i[h+6]*4294967296+i[h+5]*16777216+i[h+4]*65536+i[h+3]*256+i[h+2],d=i[h+1]<<8|i[h];(c<o||c===o&&d<r)&&(o=c,r=d,a=!0)}return a?new G(o,r):n}function ct(i){let e=new TextDecoder("utf-8"),t=[],n={},s=0,o=0;for(;o<i.length;){let r=i.indexOf(0,o);if(r===-1)break;if(r>o){let a=e.decode(i.subarray(o,r));t[s]=a,n[a]=s}o=r+1,s++}return{refNameToId:n,refIdToName:t}}var lt={0:"generic",1:"SAM",2:"VCF",3:"GAF"};function fe(i,e){let t=new DataView(i.buffer,i.byteOffset,i.byteLength),n=t.getInt32(e,!0),s=n&65536?"zero-based-half-open":"1-based-closed",o=lt[n&15];if(!o)throw new Error(`invalid Tabix preset format flags ${n}`);let r={ref:t.getInt32(e+4,!0),start:t.getInt32(e+8,!0),end:t.getInt32(e+12,!0)},a=t.getInt32(e+16,!0),l=a?String.fromCharCode(a):void 0,h=t.getInt32(e+20,!0),c=t.getInt32(e+24,!0),{refIdToName:d,refNameToId:p}=ct(i.subarray(e+28,e+28+c));return{refIdToName:d,refNameToId:p,skipLines:h,metaChar:l,columnNumbers:r,format:o,coordinateType:s}}function ue(i,e){return{lineCount:We(i,e)}}function me(i,e=5){let t=new Q({maxSize:e});return n=>{let s=t.get(n);if(s!==void 0)return s;let o=i(n);return o!==void 0&&t.set(n,o),o}}function Ke(i){let e=0;for(let s of i)e+=s.length;let t=new Uint8Array(e),n=0;for(let s of i)t.set(s,n),n+=s.length;return t}var Je=10;function Se(i,e,t){let n,s=0;for(let o of i){let r=0;if(n){let h=o.indexOf(Je);if(h===-1){n=Ke([n,o]),e+=o.length;continue}if(t(Ke([n,o.subarray(0,h+1)]),s))return!0;r=h+1,n=void 0}let a=o.lastIndexOf(Je);if(a>=r&&t(o.subarray(r,a+1),e+r))return!0;let l=Math.max(r,a+1);l<o.length&&(n=o.slice(l),s=e+l),e+=o.length}return!1}function Ye(i,e,t){let n=[],s=0;for(let o of i){let r=Math.max(e-s,0),a=Math.min(t-s,o.length);r<a&&n.push(o.subarray(r,a)),s+=o.length}return n}function Pe(i,e,t){let n=0,s=i.length-1;for(;n<s;){let r=n+s+1>>>1;i[r]<=t.blockPosition?n=r:s=r-1}return(n===0?0:e[n])-e[0]+t.dataPosition}function ht(i,e,t,n){if(e>2**(t+n*3))return;let s=(8**(n+1)-1)/7,o=(8**n-1)/7+Math.floor((e-1)/2**t)+1;for(o>=s&&(o=0);;){for(;o%8===1;)o=(o-1)/8;if(o===0)return;let r=i[o];if(r?.length){let a=r[0].minv;for(let l=1;l<r.length;l++){let h=r[l].minv;h.compareTo(a)<0&&(a=h)}return a}o++}}function Xe(i,e){return i.format==="GAF"?0:i.refNameToId[e]}var q=class{filehandle;parseCache=new z({});constructor({filehandle:e}){this.filehandle=e}async readIndexBytes(e){let t=await this.filehandle.readFile({signal:e.signal,onProgress:e.onProgress}),n=await ce(t);return{bytes:n,dataView:new DataView(n.buffer,n.byteOffset,n.byteLength)}}async lineCount(e,t={}){let n=await this.parse(t),s=Xe(n,e);return s===void 0?-1:n.indices(s)?.stats?.lineCount??-1}async getMetadata(e={}){let{indices:t,...n}=await this.parse(e);return n}async blocksForRange(e,t,n,s={}){let o=await this.parse(s),r=Xe(o,e);if(r===void 0)return[];let a=o.indices(r);if(!a)return[];o.format==="GAF"&&(t=Math.max(t-1,0));let l=[];for(let[m,f]of this.reg2bins(t,n,o))for(let x=m;x<=f;x++){let b=a.binIndex[x];if(b)for(let v of b)l.push(v)}let h=this.lowestOffset(a,t,o),c=le(l,h),d=ht(a.binIndex,n,o.minShift,o.depth);if(d){let m=c.length;for(;m>0&&c[m-1].minv.compareTo(d)>=0;)m--;c.length=m}let p=c[0];if(p&&h){let m=2**(o.minShift+3),f=this.lowestOffset(a,Math.floor(t/m)*m,o),x=f&&f.compareTo(h)<0?f:h;p.minv.compareTo(x)<0&&(c[0]=new A(x,p.maxv,p.bin,p.endPosition))}return c}parse(e={}){return this.parseCache.get("index",e.signal,t=>this._parse({...e,signal:t}))}async hasRefSeq(e,t={}){return!!(await this.parse(t)).indices(e)?.binIndex}};var dt=21582659,ft=38359875;function Qe(i,e){return i*2**e}function Te(i,e){return Math.floor(i/2**e)}var $=class extends q{async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e),s=n.getUint32(0,!0),o;if(s===dt)o=1;else if(s===ft)o=2;else throw new Error(`Not a CSI file (magic=${s})`);let r=n.getInt32(4,!0),a=n.getInt32(8,!0),l=(8**(a+1)-1)/7,h=2**(r+a*3),c=n.getInt32(12,!0),d=c>=28&&(n.getInt32(16,!0)&15)===3;if(c<30&&!d)throw new Error("CSI index has no tabix header, so it names no references; it may be a BAM or BCF index");let p=fe(t,16),m=n.getInt32(16+c,!0),f=16+c+4,x,b=[];for(let y=0;y<m;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let u=0;u<I;u++){let S=n.getUint32(f,!0);if(f+=4,S>l)f+=44;else{x=de(t,f,1,x),f+=8;let g=n.getInt32(f,!0);f+=4+16*g}}}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C={},w;for(let F=0;F<S;F++){let k=n.getUint32(u,!0);if(u+=4,k>l)w=ue(t,u+28),u+=44;else{C[k]=O(t,u),u+=8;let R=n.getInt32(u,!0);u+=4;let T=Array.from({length:R});for(let _=0;_<R;_++)T[_]=new A(O(t,u),O(t,u+8),k),u+=16;g[k]=T}}return he(Object.values(g).flat()),{binIndex:g,loffsets:C,stats:w}}return{...p,csi:!0,refCount:m,maxBlockSize:65536,firstDataLine:x,csiVersion:o,indices:me(v),minShift:r,depth:a,maxBinNumber:l,maxRefLength:h}}lowestOffset(e,t,{minShift:n,depth:s}){let{loffsets:o}=e,r;if(o){let a=(Qe(1,3*s)-1)/7+Te(Math.max(t,0),n);for(;r===void 0&&a>0;)if(r=o[a],r===void 0){let l=Math.floor((a-1)/8),h=l*8+1;a=a>h?a-1:l}r??=o[0]}return r}reg2bins(e,t,{minShift:n,depth:s,maxBinNumber:o}){e=Math.max(e,0);let r=2**(n+s*3);t>r&&(t=r),t-=1;let a=0,l=0,h=n+s*3,c=[];for(;a<=s;h-=3,l+=Qe(1,a*3),a+=1){let d=l+Te(e,h),p=l+Te(t,h);if(p-d+c.length>o)throw new Error(`query ${e}-${t} is too large for current binning scheme (shift ${n}, depth ${s}), try a smaller query or a coarser index binning scheme`);c.push([d,p])}return c}};var ut=21578324,Ae=5,_e=14,pe=2**(_e+Ae*3);function Ze(i){return Math.min(Math.max(i,0),pe)}var L=class extends q{reg2bins(e,t){e>pe&&console.warn("querying outside of possible tabix range");let n=Ze(e),s=Math.min(t,pe)-1,o=[];return n<=s&&o.push([0,0],[1+(n>>26),1+(s>>26)],[9+(n>>23),9+(s>>23)],[73+(n>>20),73+(s>>20)],[585+(n>>17),585+(s>>17)],[4681+(n>>14),4681+(s>>14)]),o}lowestOffset(e,t){let n=e.linearIndex;return n?.[Math.min(Ze(t)>>_e,n.length-1)]}async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e);if(n.getUint32(0,!0)!==ut)throw new Error("Not a TBI file");let s=n.getUint32(4,!0),o=((1<<(Ae+1)*3)-1)/7,{refNameToId:r,refIdToName:a,coordinateType:l,format:h,columnNumbers:c,metaChar:d,skipLines:p}=fe(t,8),f=36+n.getInt32(32,!0),x,b=[];for(let y=0;y<s;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let S=0;S<I;S++){let g=n.getUint32(f,!0);f+=4;let C=n.getInt32(f,!0);if(f+=4,g>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");g<=o&&(x=de(t,f,C,x,16)),f+=16*C}let u=n.getInt32(f,!0);f+=4+8*u}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C;for(let k=0;k<S;k++){let R=n.getUint32(u,!0);if(u+=4,R>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(R===o+1){let T=n.getInt32(u,!0);u+=4,T===2&&(C=ue(t,u+16)),u+=16*T}else{let T=n.getInt32(u,!0);u+=4;let _=Array.from({length:T});for(let U=0;U<T;U++)_[U]=new A(O(t,u),O(t,u+8),R),u+=16;g[R]=_}}let w=n.getInt32(u,!0);u+=4;let F=Array.from({length:w});for(let k=0;k<w;k++)F[k]=O(t,u),u+=8;return he(Object.values(g).flat(),F.map(k=>k.blockPosition)),{binIndex:g,linearIndex:F,stats:C}}return{indices:me(v),metaChar:d,minShift:_e,depth:Ae,maxBinNumber:o,maxRefLength:pe,skipLines:p,firstDataLine:x,columnNumbers:c,coordinateType:l,format:h,refIdToName:a,refNameToId:r,maxBlockSize:65536}}};var Me=9,xe=10,nt=13,mt=59,pt=60,gt=62,xt=6,wt=1024*2**20,bt=180*1e3;function Ct(i,e,t){if(i)return i;if(e)return new X(e);if(t)return new Y(t);throw new TypeError("must provide either filehandle, path, or url")}function yt({tbiFilehandle:i,csiFilehandle:e,tbiPath:t,csiPath:n,tbiUrl:s,csiUrl:o,path:r,url:a}){if(i)return new L({filehandle:i});if(e)return new $({filehandle:e});if(t)return new L({filehandle:new X(t)});if(n)return new $({filehandle:new X(n)});if(o)return new $({filehandle:new Y(o)});if(s)return new L({filehandle:new Y(s)});if(r)return new L({filehandle:new X(`${r}.tbi`)});if(a)return new L({filehandle:new Y(`${a}.tbi`)});throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl")}function it(i,e,t,n,s){return i[t]*256+(n-e[t])+s+1}function It(i,e,t,n,s,o,r){let a=n-t,l=e+a,h=0;if(i[s]===46)return l;let c=s;for(let d=s;d<=o;d++)if(d===o||i[d]===mt){let p=d-c;if(p>=10&&i[c]===83&&i[c+1]===86&&i[c+2]===84&&i[c+3]===89&&i[c+4]===80&&i[c+5]===69&&i[c+6]===61&&i[c+7]===84&&i[c+8]===82&&i[c+9]===65)return e+1;if(p>=4&&i[c]===69&&i[c+1]===78&&i[c+2]===68&&i[c+3]===61){let m=ge(i,c+4,d);m>e&&(l=m)}else p>=6&&i[c]===83&&i[c+1]===86&&i[c+2]===76&&i[c+3]===69&&i[c+4]===78&&i[c+5]===61&&(h=vt(i,c+6,d,n+1,r));c=d+1}return Math.max(l,e+h)}var et=44;function kt(i,e,t){if(t-e<5||i[e]!==60||i[t-1]!==62)return!1;let n=i[e+4];if(n!==62&&n!==58)return!1;let s=i[e+1],o=i[e+2],r=i[e+3];return s===67&&o===78&&r===86||s===68&&o===69&&r===76||s===68&&o===85&&r===80||s===73&&o===78&&r===86}function vt(i,e,t,n,s){let o=0,r=e,a=n;for(;r<t&&a<s;){let l=i.indexOf(et,r);(l===-1||l>t)&&(l=t);let h=i.indexOf(et,a);if((h===-1||h>s)&&(h=s),kt(i,a,h)){let c=ge(i,i[r]===45?r+1:r,l);c>o&&(o=c)}r=l+1,a=h+1}return o}var st=new TextDecoder;function tt(i,e){let t=-1,n=e.charCodeAt(0);for(let s=0,o=i.length;s<o;s++){let r=i[s];if(s===t+1&&r!==n)break;r===xe&&(t=s)}return i.subarray(0,t+1)}function St(i,e){let t=0;for(let n=0;n<e;n++){let s=i.indexOf(xe,t);if(s===-1){t=i.length;break}t=s+1}return st.decode(i.subarray(0,t)).split(/\r?\n/).slice(0,e)}function ge(i,e,t){let n=0;for(let s=e;s<t;s++){let o=i[s];if(o>=48&&o<=57)n=n*10+(o-48);else break}return n}function Pt(i,e,t,n,s,{start:o,end:r,pathCol:a,metaCharCode:l,decoder:h,callback:c}){let d=0,p=0;for(;d<i.length;){let m=i.indexOf(xe,d);if(m===-1)break;let f=d;d=m+1;let x=f+e+s;for(;p<n.length&&x>=n[p];)p++;if(i[f]===l)continue;let b=f;for(let g=1;g<a;g++){let C=i.indexOf(Me,b);if(C===-1||C>=m){b=m;break}b=C+1}let v=i[b];if(v!==gt&&v!==pt)continue;let y=i.indexOf(Me,b);(y===-1||y>m)&&(y=m);let I=1/0,u=-1,S=b;for(;S<y;){let g=0,C=S+1;for(;C<y;C++){let w=i[C]-48;if(w<0||w>9)break;g=g*10+w}g<I&&(I=g),g>u&&(u=g),S=C}if(I>=r)return!0;if(u>=o){let g=i[m-1]===nt?m-1:m;c(h.decode(i.subarray(f,g)),it(t,n,p,f+e,s),I,u+1)}}return!1}var W=class{filehandle;index;chunkCache;requested=new Map;headerCache=new z({});bgzfWorkerPool;constructor({path:e,filehandle:t,url:n,tbiPath:s,tbiUrl:o,tbiFilehandle:r,csiPath:a,csiUrl:l,csiFilehandle:h,chunkCacheSize:c=wt,chunkCacheIdleTimeoutMs:d=bt,chunkCacheBudget:p,bgzfWorkerPool:m}){this.bgzfWorkerPool=m,this.filehandle=Ct(t,e,n),this.index=yt({tbiFilehandle:r,csiFilehandle:h,tbiPath:s,csiPath:a,tbiUrl:o,csiUrl:l,path:e,url:n}),this.chunkCache=new z({maxSize:c,sizeOf:f=>{let x=0;for(let b of f.segments)x+=b.byteLength;return x},cacheKey:f=>f.toString(),idleTimeoutMs:d,budget:p,fill:(f,x)=>this.readChunk(f,{signal:x})})}clearChunkCache(){this.chunkCache.clear(),this.requested.clear()}withCachedContainers(e){if(this.requested.size>2*this.chunkCache.size)for(let[n,s]of this.requested)this.chunkCache.has(s)||this.requested.delete(n);let t=[];for(let n=0;n<e.length;n++){let s=e[n],o=t[t.length-1],r=e[n+1],a;if(!this.chunkCache.has(s))for(let l of this.requested.values())l.minv.compareTo(s.minv)<=0&&l.maxv.compareTo(s.maxv)>=0&&(!o||l.minv.compareTo(o.maxv)>=0)&&(!r||l.maxv.compareTo(r.minv)<=0)&&(!a||l.fetchedSize()<a.fetchedSize())&&this.chunkCache.has(l)&&(a=l);t.push(a??s)}return t}async bytesForRegions(e,t={}){let n=[];for(let{refName:o,start:r,end:a}of e){let l=await this.index.blocksForRange(o,r,a,t);for(let h of l)n.push(h)}let s=0;for(let o of le(n))s+=o.fetchedSize();return s}async getLines(e,t,n,s){let o,r={},a,l;typeof s=="function"?a=s:(r=s,a=s.lineCallback,o=s.signal,l=s.onProgress);let h=await this.index.getMetadata(r),c=t??0,d=n??h.maxRefLength;if(c>d)throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(c===d)return;let p=await this.index.blocksForRange(e,c,d,r),m=this.withCachedContainers(p),f=h.format==="VCF",x=h.columnNumbers.ref||0,b=h.columnNumbers.start||0,v=f?8:h.columnNumbers.end||0,y=Math.max(x,b,v),I=h.metaChar?.charCodeAt(0),u=h.coordinateType==="1-based-closed"?-1:0,S=new TextEncoder,g=new TextDecoder,C=S.encode(e),w=new Int32Array(y+1),F=h.format==="GAF"?{start:c,end:d,pathCol:b,metaCharCode:I,decoder:g,callback:a}:void 0,k=0;for(let E of m)k+=E.fetchedSize();let R=0;l?.(0,k);let T=1,_=[],U=E=>{for(;_.length<Math.min(E,m.length);){let K=m[_.length];this.requested.set(K.toString(),K);let j=this.chunkCache.get(K,o);j.catch(()=>{}),_.push(j)}};U(1);for(let E=0,K=m.length;E<K;E++){let j=m[E],Be=await _[E],{cpositions:Z,dpositions:V}=Be;R+=j.fetchedSize(),l?.(R,k);let we=j.minv.dataPosition,be=p[E],ee=Be.segments,te=0;if(be!==j){te=Pe(Z,V,be.minv);let P=Pe(Z,V,be.maxv)+1;ee=Ye(ee,te,P)}if(F){if(Se(ee,te,(P,ne)=>Pt(P,ne,Z,V,we,F)))return}else if(Se(ee,te,(P,ne)=>{let M=0,ie=0;for(;M<P.length;){let B=P.indexOf(xe,M);if(B===-1)break;let rt=M+ne+we;for(;ie<V.length&&rt>=V[ie];)ie++;if(I!==void 0&&P[M]===I){M=B+1;continue}w[0]=M-1;for(let N=0;N<y;N++){let oe=w[N],Ce=oe<B?P.indexOf(Me,oe+1):-1;w[N+1]=Ce===-1||Ce>=B?B:Ce}let Ne=w[x-1]+1,Re=w[x]-Ne;if(Re!==C.length){M=B+1;continue}let Ee=!0;for(let N=0;N<Re;N++)if(P[Ne+N]!==C[N]){Ee=!1;break}if(!Ee){M=B+1;continue}let se=ge(P,w[b-1]+1,w[b])+u;if(se>=d)return!0;let J;if(v===0||v===b?J=se+1:f?J=It(P,se,w[3]+1,w[4],w[v-1]+1,w[v],w[5]):J=ge(P,w[v-1]+1,w[v]),J>c){let N=P[B-1]===nt?B-1:B,oe=g.decode(P.subarray(M,N));a(oe,it(Z,V,ie,M+ne,we),se,J)}M=B+1}return!1}))return;T=Math.min(T*2,xt),U(E+1+T)}}async getMetadata(e={}){return this.index.getMetadata(e)}async readHeaderBytes(e){let{firstDataLine:t,maxBlockSize:n}=await this.getMetadata(e);if(t?.blockPosition===0&&t.dataPosition===0)return new Uint8Array(0);let s=(t?.blockPosition??0)+n,o=await this.filehandle.read(s,0,e);return ce(o)}async parseHeader(e){let{metaChar:t,skipLines:n=0}=await this.getMetadata(e),s=await this.readHeaderBytes(e);return{header:st.decode(t?tt(s,t):s),skippedLines:n>0?St(s,n):[]}}getParsedHeader(e={}){return this.headerCache.get("header",e.signal,t=>this.parseHeader({...e,signal:t}))}async getHeaderBuffer(e={}){let{metaChar:t}=await this.getMetadata(e),n=await this.readHeaderBytes(e);return t?tt(n,t):n}async getSkippedLines(e={}){let{skipLines:t=0}=await this.getMetadata(e);return t<=0?[]:(await this.getParsedHeader(e)).skippedLines}async getHeader(e={}){return(await this.getParsedHeader(e)).header}async getHeaderLines(e={}){let{header:t,skippedLines:n}=await this.getParsedHeader(e);return(t?t.split(/\r?\n/):n).filter(Boolean)}async getReferenceSequenceNames(e={}){return(await this.getMetadata(e)).refIdToName}async lineCount(e,t={}){return this.index.lineCount(e,t)}async readChunk(e,t={}){let n=await this.filehandle.read(e.fetchedSize(),e.minv.blockPosition,t);H(t.signal);let s=await this.bgzfWorkerPool;return qe(n,e,s)}};function Mn(i,e,t){let n=i.pluginManager;return new W({filehandle:ae(i.getConf(e),n),...Oe(i.getConf([...t,"location"]),i.getConf([...t,"indexType"]),n)})}function Bn(i){let e=i.getConf("walksIndex");return Tt(i.getConf("walksLocation"),Fe(e)?e:void 0,i.pluginManager)}function Tt(i,e,t){return $e.fromFilehandles({data:ae(i,t),directory:ae(e??Le(i,n=>`${n}.idx`),t)})}function Nn(i){return{names:e=>i.getReferenceSequenceNames(e),bytes:(e,t)=>Ve(i,e,t)}}function At(i){return`${i.assemblyName} ${i.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${i.assemblyName} mapped to its prefix in assemblyNameToPanSN`}var ot=class{constructor(e,t){this.source=e;this.adapter=t;this.lookup=je({setup:async e=>De(await this.source.names(e))})}async assemblyRefNames(e={}){let t=await this.source.names(e),n=re(this.adapter,e.assemblyName),s=t.filter(o=>ye(o,n)).map(o=>ze(o));return s.length>0?[...new Set(s)]:t}async resolve(e,t){let n=await this.lookup(t);return He(n,re(this.adapter,e.assemblyName),e.refName)}async resolveMapped(e,t){let n=await this.resolve(e,t);if(n===void 0&&e.assemblyName){let s=await this.source.names(t),o=re(this.adapter,e.assemblyName);if(s.length>0&&s.every(r=>r.includes("#"))&&!s.some(r=>ye(r,o)))throw new Error(At(e))}return n}async resolveForCut(e,t){let n=await this.resolveMapped(e,t);if(n===void 0)throw new Error(`This graph has nothing on ${e.assemblyName} ${e.refName}`);return n}async regionBytes(e,t={}){let n=[];for(let s of e){let o=await this.resolve(s,t);o!==void 0&&n.push({refName:o,start:s.start,end:s.end})}return this.source.bytes(n,t)}};export{Mt as a,je as b,Et as c,Mn as d,Bn as e,Tt as f,Nn as g,ot as h};
2
+ //# sourceMappingURL=chunk-5LL2NZGQ.js.map
@@ -1,2 +1,2 @@
1
1
  var c=$=>$==="-"?"+":"-",f=$=>$==="-"?"-":"+";function l($,n,e,i){let t=`${$} ${f(n)} ${e} ${f(i)}`,o=`${e} ${c(i)} ${$} ${c(n)}`;return t<o?t:o}export{l as a};
2
- //# sourceMappingURL=chunk-HHK5MBID.js.map
2
+ //# sourceMappingURL=chunk-B3XU763Z.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.3.3/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-J5U3HYBK.js"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.3.5/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-J5U3HYBK.js"],
4
4
  "sourcesContent": ["// src/gfa/linkKey.ts\nvar flip = (strand) => strand === \"-\" ? \"+\" : \"-\";\nvar side = (strand) => strand === \"-\" ? \"-\" : \"+\";\nfunction linkKey(source, strand1, target, strand2) {\n const stated = `${source}\t${side(strand1)}\t${target}\t${side(strand2)}`;\n const turned = `${target}\t${flip(strand2)}\t${source}\t${flip(strand1)}`;\n return stated < turned ? stated : turned;\n}\n\nexport {\n linkKey\n};\n"],
5
5
  "mappings": "AACA,IAAIA,EAAQC,GAAWA,IAAW,IAAM,IAAM,IAC1CC,EAAQD,GAAWA,IAAW,IAAM,IAAM,IAC9C,SAASE,EAAQC,EAAQC,EAASC,EAAQC,EAAS,CACjD,IAAMC,EAAS,GAAGJ,CAAM,IAAIF,EAAKG,CAAO,CAAC,IAAIC,CAAM,IAAIJ,EAAKK,CAAO,CAAC,GAC9DE,EAAS,GAAGH,CAAM,IAAIN,EAAKO,CAAO,CAAC,IAAIH,CAAM,IAAIJ,EAAKK,CAAO,CAAC,GACpE,OAAOG,EAASC,EAASD,EAASC,CACpC",
6
6
  "names": ["flip", "strand", "side", "linkKey", "source", "strand1", "target", "strand2", "stated", "turned"]
@@ -1,2 +1,2 @@
1
- import{U as a}from"./chunk-LOT3BKM3.js";import{d as m}from"./chunk-ESUDWLHY.js";import{a as n,c as p}from"./chunk-E55FR7S6.js";function c(i,l){let t=new Map,o=new Map;for(let{name:s,color:e,assembly:r}of i)e&&a(e)&&(t.set(s,e),r&&!o.has(r)&&o.set(r,e));return s=>{let e=p(s)??s;return t.get(e)??t.get(n(e))??o.get(m(l,e))}}export{c as a};
2
- //# sourceMappingURL=chunk-SRA6CKRA.js.map
1
+ import{U as a}from"./chunk-P3GONGHK.js";import{d as m}from"./chunk-2OXO7QGS.js";import{a as n,c as p}from"./chunk-F4MZBJ6U.js";function c(i,l){let t=new Map,o=new Map;for(let{name:s,color:e,assembly:r}of i)e&&a(e)&&(t.set(s,e),r&&!o.has(r)&&o.set(r,e));return s=>{let e=p(s)??s;return t.get(e)??t.get(n(e))??o.get(m(l,e))}}export{c as a};
2
+ //# sourceMappingURL=chunk-CUCPYCYW.js.map
@@ -0,0 +1,2 @@
1
+ import{a as St}from"./chunk-MQAFQAPI.js";import{y as it}from"./chunk-HC7UMW4R.js";var ct=40,Ot=500,et=5;function Rt(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function Ct(e,t=et){let o=e.nodes.reduce((r,i)=>r+i.length,0)/1e6,s=Math.max(e.nodes.length*ct,Ot);return{nodeLengthPerMegabase:o>0?s/o:1e4,minimumNodeLength:Math.max(et,t),edgeLength:5,nodeSegmentLength:20}}var st={power:1,effect:1};function Tt(e){return e.power===1&&e.effect===1}function Ft(e,t){let n=e.nodes.length,o=e.nodes.reduce((i,c)=>i+c.length,0),s=n>0?o/n:0,r=n>0?Math.max(n*ct,Ot)/n:ct;return i=>{if(s<=0)return r;let c=(i/s)**t.power;return Math.max(r*((c-1)*t.effect+1),et)}}var It=1e3,Bt={law:st,minNodeLength:0};function sn(e){let t=new Map(e.nodes.map(r=>[r.id,r])),n=St(e),o=new Set,s=[];for(let r of e.nodes)if(!it(r)&&!o.has(r.id)){o.add(r.id);let i=[r],c=!1;for(let u of i)for(let l of n.get(u.id)??[]){let a=t.get(l);a&&it(a)?c=!0:a&&!o.has(l)&&(o.add(l),i.push(a))}c&&s.push(i)}return s}function rn(e,t){let n=t.map(()=>et),o=e,s=t.reduce((i,c)=>i+c,0),r=t.length;for(let i of t.map((c,u)=>u).sort((c,u)=>t[c]-t[u])){let c=s>0?o*t[i]/s:o/r,u=Math.max(c,et);n[i]=u,o-=u,s-=t[i],r-=1}return n}function Gn(e,t=Bt,n=0){let{law:o,minNodeLength:s}=t,r=Ct(e,s);if(Tt(o))return{nodes:e.nodes,opts:r};let i=Ft(e,o),c=n*e.nodes.filter(it).reduce((h,d)=>h+i(d.length),0),u=c/i(c*1e6/r.nodeLengthPerMegabase),l=h=>Math.max(i(h),Math.min(Rt(r,h),u*i(h))),a=new Map;for(let h of sn(e)){let d=h.map(m=>m.length),g=rn(l(d.reduce((m,M)=>m+M,0)),d);h.forEach((m,M)=>{a.set(m.id,g[M])})}let f=h=>it(h)?i(h.length):a.get(h.id)??l(h.length);return{nodes:e.nodes.map(h=>({...h,length:Math.round(f(h)*It)})),opts:{...r,nodeLengthPerMegabase:1e6/It,minimumNodeLength:et}}}function Dn(e,t=Bt){if(Tt(t.law)){let n=Ct(e,t.minNodeLength);return o=>Rt(n,o)}return Ft(e,t.law)}var Mt=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:st,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:st,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:st,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],cn="node lengths compressed, not to scale",an=Mt.map(e=>e.value);function ln(e){let t=Mt.find(n=>n.value===e);return{law:t?.law??st,minNodeLength:(t?.minNodeFactor??0)*ct}}var $t="\0deletion:";var Gt=25*Math.PI/180,Dt=.25,Ut=150,hn=[0,-.35,.35,-.7,.7,-1.05,1.05,-1.4,1.4],fn=[0,-1/3,1/3,-2/3,2/3],un=60,dn=64,wt=[0,1];function Ht(e){return e?0:1}function gt(e,t){let n=t.x-e.x,o=t.y-e.y,s=Math.hypot(n,o)||1;return{x:n/s,y:o/s}}function mt(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ut(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function qt([e,t],[n,o]){return ut(e,t,n)*ut(e,t,o)<0&&ut(n,o,e)*ut(n,o,t)<0}function pn([e,t],n){let o=Math.max(1,Math.ceil(Math.hypot(t.x-e.x,t.y-e.y)/n));return Array.from({length:o+1},(s,r)=>mt(e,t,r/o))}function Qt(e){let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function Jt(e){let t=new Float64Array(e.length);for(let n=1;n<e.length;n++)t[n]=t[n-1]+Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Zt(e){var t;return(t=Jt(e)[e.length-1])!==null&&t!==void 0?t:0}var dt=new Map;function yn(e){let t=dt.get(e);if(t!==void 0)return t;let n=gn(e);return dt.size>1e4&&dt.clear(),dt.set(e,n),n}function gn(e){let t=1e-6,n=2*Math.PI-1e-6;for(let o=0;o<60;o++){let s=(t+n)/2;s/(2*Math.sin(s/2))<e?t=s:n=s}return(t+n)/2}function mn(e,t){if(e<1e-9)return Math.PI*t;let n=(e*e/4+t*t)/(2*t),o=2*Math.asin(Math.min(1,e/(2*n)));return n*(t>n?2*Math.PI-o:o)}function vt(e,t,n,o){let s=t-2*n,r=e<1e-9?2*Math.PI:yn(s/e),i=s/r,c=Math.cos(r/2),u=e/2,l=o+n-i*c;return{at:a=>{if(a<=n)return{u:0,v:o+a};if(a>=t-n)return{u:e,v:o+t-a};let f=(a-n)/i-r/2;return{u:u+i*Math.sin(f),v:l+i*Math.cos(f)}},apex:o+n+i*(1-c),length:t}}function Kt(e,t,n){if(!n)return e;let o=Math.cos(n),s=Math.sin(n);return{...e,at:r=>{let{u:i,v:c}=e.at(r),u=i-t/2;return{u:t/2+u*o-c*s,v:u*s+c*o}}}}function xn(e){for(let t=0;t<=32;t++)if(e.at(e.length*t/32).v<-1e-6)return!0;return!1}function Wt(e,t,n,o,s){return{at:r=>({u:e+n*r,v:t+o*r}),apex:t+Math.max(0,o)*s,length:s}}var at=(e,t)=>e*2+t,ht=class{constructor(t,n,o=!1){var s;this.pts=t,this.normals=n,this.straight=o,this.arc=Jt(t),this.total=(s=this.arc[t.length-1])!==null&&s!==void 0?s:0}segment(t){let{arc:n}=this,o=1,s=n.length-1;for(;o<s;){let r=o+s>>1;n[r]<t?o=r+1:s=r}return o}fraction(t,n){let o=this.arc[t]-this.arc[t-1];return o>0?(n-this.arc[t-1])/o:0}pointAt(t){let{pts:n}=this,o=n.length-1;if(o===0)return{...n[0]};if(t<=0){let r=gt(n[0],n[1]);return{x:n[0].x+r.x*t,y:n[0].y+r.y*t}}if(t>=this.total){let r=gt(n[o-1],n[o]),i=t-this.total;return{x:n[o].x+r.x*i,y:n[o].y+r.y*i}}let s=this.segment(t);return mt(n[s-1],n[s],this.fraction(s,t))}normalAt(t){let{normals:n}=this;if(n.length===1||t<=0)return n[0];if(t>=this.total)return n[n.length-1];let o=this.segment(t),{x:s,y:r}=mt(n[o-1],n[o],this.fraction(o,t)),i=Math.hypot(s,r)||1;return{x:s/i,y:r/i}}};function Mn(e,t){let n=Qt(e);return e.map((o,s)=>{let r=gt(e[Math.max(0,s-1)],e[Math.min(e.length-1,s+1)]),i={x:-r.y,y:r.x},c=o.x-n.x,u=o.y-n.y,l=Math.hypot(c,u),a=i.x*c+i.y*u,f=t[s],h=l>1e-9&&Math.abs(a)>.3*l?Math.sign(a):Math.sign(i.x*f.x+i.y*f.y)||1;return{x:i.x*h,y:i.y*h}})}function Nt(e,t,n,o,s){let r=Math.min(s,Math.max(o.length/24,.5)),i=[],c=[];for(let u=0;u<=o.length+1e-9;u+=r){let{u:l,v:a}=o.at(Math.min(u,o.length)),f=e.pointAt(t+l),h=e.normalAt(t+l),d=h.x*n,g=h.y*n;i.push({x:f.x+d*a,y:f.y+g*a}),c.push({x:d,y:g})}return{pts:i,refs:c}}var wn=5,jt=10.5/2;function At(e,t,n,o,s,r){let i=s,c=Nt(e,t,n,o(i),r);if(e.straight)return c;for(let u=0;u<6;u++){let l=Zt(c.pts);if(!(l>0)||Math.abs(l/s-1)<.001)break;i*=s/l,c=Nt(e,t,n,o(i),r)}return c}function lt(e,t){return Array.from({length:t},(n,o)=>e+o*15/2)}function Vt(e){if(e.length===0)return 1/0;let t=1/0,n=-1/0;for(let o of e)t=Math.min(t,o.point.x),n=Math.max(n,o.point.x);return n-t}function pt(e,t){return e*73856093^t*19349663}function yt(e){return Math.floor(e/un)}function zt([e,t]){return{x0:yt(Math.min(e.x,t.x)),x1:yt(Math.max(e.x,t.x)),y0:yt(Math.min(e.y,t.y)),y1:yt(Math.max(e.y,t.y))}}var xt=class{constructor(t){this.c=t,this.grid=new Map,this.chordGrid=new Map,this.longChords=[];let{ids:n,first:o,count:s,per:r,seedX:i,seedY:c,backbone:u}=t,l=n.length;this.points=Array.from({length:l},()=>{}),this.params=Array.from({length:l},()=>{}),this.curves=Array.from({length:l},()=>{}),this.links=t.links.map((h,d)=>h.map(g=>g.filter(([m])=>m!==d))),this.route=n.map(h=>h.startsWith($t));let a=1/0,f=-1/0;for(let h=0;h<l;h++){let d=o[h];u[d]===0||Number.isNaN(i[d])||(a=Math.min(a,i[d]),f=Math.max(f,i[d]+r[h]*(s[h]-1)))}this.backbone=new ht([{x:a,y:0},{x:f,y:0}],[{x:0,y:1},{x:0,y:1}],!0),this.backboneCentroid={x:(a+f)/2,y:0};for(let h=0;h<l;h++){let d=o[h];if(u[d]===0||Number.isNaN(i[d]))continue;let g=[],m=[];for(let M=0;M<s[h];M++){let F=i[d]+M*r[h];g.push({x:F,y:c[d]}),m.push(F-a)}this.points[h]=g,this.params[h]=m,this.curves[h]=this.backbone,this.occupy(g,this.backbone)}}static hasBackbone(t){for(let n=0;n<t.ids.length;n++){let o=t.first[n];if(t.backbone[o]!==0&&!Number.isNaN(t.seedX[o]))return!0}return!1}run(){let t=[];for(let o=0;o<this.points.length;o++)this.points[o]||t.push(o);let n=this.componentsOf(t).map(o=>({members:o,anchors:this.anchorsOf(o)})).filter(o=>o.anchors.length).map(o=>({members:o.members,span:Vt(o.anchors),drawn:o.members.reduce((s,r)=>s+this.drawn(r),0),feet:o.anchors.map(s=>`${s.point.x},${s.point.y}`).sort().join(" ")})).sort((o,s)=>o.span-s.span||(o.feet===s.feet?s.drawn-o.drawn:o.drawn-s.drawn));for(let o of n)this.placePiece(o.members,this.backboneCentroid)}write(t,n){let{first:o}=this.c;this.points.forEach((s,r)=>{s?.forEach((i,c)=>{t[o[r]+c]=i.x,n[o[r]+c]=i.y})})}drawn(t){return this.c.per[t]*(this.c.count[t]-1)}endIndex(t,n){return n?this.c.count[t]-1:0}occupy(t,n){for(let o of t){let s=pt(Math.floor(o.x/10.5),Math.floor(o.y/10.5)),r=this.grid.get(s),i={x:o.x,y:o.y,curve:n};r?r.push(i):this.grid.set(s,[i])}}violations(t,n,o,s){var r;let i=0;for(let c of t){if(o.some(a=>Math.hypot(c.x-a.x,c.y-a.y)<15))continue;let u=Math.floor(c.x/10.5),l=Math.floor(c.y/10.5);for(let a=u-1;a<=u+1;a++)for(let f=l-1;f<=l+1;f++)for(let h of(r=this.grid.get(pt(a,f)))!==null&&r!==void 0?r:[])if(h.curve!==n&&Math.hypot(c.x-h.x,c.y-h.y)<10.5&&(i++,i>=s))return i}return i}choose(t,n,o){var s,r,i;let c,u,l,a,f=1/0,h=!1;for(let d=0;d<t.length&&!c;d++){let g=t[d],m=g.slid===!0;if(!m||h){let M=g(jt),F=this.violations(M.pts,n,o,f),L=(s=M.links)!==null&&s!==void 0?s:[];F===0?this.linksClear(L,n,o)?c=g:(!u&&!L.some(v=>this.crossesPlaced(v))&&(u=g),m||(l??(l=g))):!m&&F<f&&(f=F,a=g),m||(h=F===0)}}return((i=(r=c??u)!==null&&r!==void 0?r:l)!==null&&i!==void 0?i:a)(wn)}linksClear(t,n,o){return t.every(s=>this.violations(pn(s,jt),n,o,1)===0&&!this.crossesPlaced(s))}crossesPlaced(t){var n,o;let{x0:s,x1:r,y0:i,y1:c}=zt(t),u=this.longChords.some(l=>qt(t,l));for(let l=s;l<=r&&!u;l++)for(let a=i;a<=c&&!u;a++)u=(o=(n=this.chordGrid.get(pt(l,a)))===null||n===void 0?void 0:n.some(f=>qt(t,f)))!==null&&o!==void 0?o:!1;return u}placeChord(t){let{x0:n,x1:o,y0:s,y1:r}=zt(t);if((o-n+1)*(r-s+1)>dn)this.longChords.push(t);else for(let i=n;i<=o;i++)for(let c=s;c<=r;c++){let u=pt(i,c),l=this.chordGrid.get(u);l?l.push(t):this.chordGrid.set(u,[t])}}anchorsOf(t){let n=new Set(t),o=[];for(let s of t)for(let r of wt)for(let[i,c]of this.links[s][r]){let u=this.points[i];if(n.has(i)||!u)continue;let l=this.endIndex(i,c);o.push({u:s,uSide:r,v:i,vSide:c,point:u[l],curve:this.curves[i],t:this.params[i][l]})}return o}componentsOf(t){let n=new Set(t),o=new Set,s=[];for(let r of t){if(o.has(r))continue;let i=[r];o.add(r);for(let c of i)for(let u of wt)for(let[l]of this.links[c][u])n.has(l)&&!o.has(l)&&(o.add(l),i.push(l));s.push(i)}return s}spinePath(t,n,o,s,r){let i=new Set(t),c=(h,d)=>h===s&&Ht(d)===r,u=new Map([[at(n,o),-1]]),l=[[n,o]],a=[n,o];for(let[h,d]of l){if(a=[h,d],s!==void 0&&c(h,d))break;for(let[g,m]of this.links[h][Ht(d)])!i.has(g)||u.has(at(g,m))||(u.set(at(g,m),at(h,d)),l.push([g,m]))}if(s!==void 0&&!c(a[0],a[1]))return;let f=[];for(let h=at(a[0],a[1]);h!==-1;h=u.get(h))f.push({k:h>>1,enter:h%2===1?1:0});return f.reverse()}loosePath(t,n,o){let s=new Set(t),r=new Map([[n,-1]]),i=new Map([[n,0]]),c=[n];for(let l of c){if(l===o)break;for(let a of wt)for(let[f,h]of this.links[l][a])!s.has(f)||r.has(f)||(r.set(f,l),i.set(f,h),c.push(f))}let u=[];for(let l=o;l!==-1;l=r.get(l))u.push({k:l,enter:i.get(l)});return u.reverse()}spineLength(t){let{link:n}=this.c;return t.reduce((o,{k:s})=>o+this.drawn(s)+n,n)}layAlong(t,n,o,s){let{count:r,per:i,link:c}=this.c,u=o,l=[];for(let{k:a,enter:f}of t){let h=s??i[a],d=[],g=[];for(let m=0;m<r[a];m++)d.push(n.pointAt(u+m*h)),g.push(u+m*h);f===1&&(d.reverse(),g.reverse()),this.points[a]=d,this.params[a]=g,this.curves[a]=n,l.push(...d),u+=h*(r[a]-1)+c}return l}arcCandidates(t,n,o,s,r){let i=(r-s)/2-1e-6,c=r>2*s?hn:[0],u=[];for(let l of lt(0,8))for(let a of c)for(let f=0;f<=16;f++){let h=i*f/16,d=Kt(vt(s,r,h,l),s,a);f<16&&d.apex<12||xn(d)||u.push(g=>At(t,n,o,m=>Kt(vt(s,m,Math.min(h,(m-s)/2-1e-6),l),s,a),r,g))}return u}placePiece(t,n){var o,s;let{count:r,link:i}=this.c,c=this.anchorsOf(t);if(c.length===0)return;let u=t.every(b=>this.route[b]===!0),l=c.every(b=>b.curve===c[0].curve)?c[0].curve:void 0,a,f,h,d;if(l)c.sort((b,C)=>b.t-C.t),a=l,f=c[0].t,h=c[c.length-1].t,d=a===this.backbone&&u?-1:1;else{c.sort((T,H)=>T.point.x-H.point.x||T.point.y-H.point.y);let b=c[0].point,C=c[c.length-1].point,G=Math.hypot(C.x-b.x,C.y-b.y),q=G>1e-9?gt(b,C):{x:1,y:0},D={x:-q.y,y:q.x},j=mt(b,C,.5);d=c.some(T=>T.curve===this.backbone)?(u?-1:1)*(Math.sign(D.y)||1):(j.x-n.x)*D.x+(j.y-n.y)*D.y>=0?1:-1,a=new ht([b,C],[D,D],!0),f=0,h=G}let g=c[0],m=c[c.length-1],M=h-f,F=c.length===1||g.u===m.u&&g.uSide===m.uSide&&M<1e-9,L=[g.point,m.point],v=b=>this.choose(b,l,L),x,A,w=i,E;if(F){x=this.spinePath(t,g.u,g.uSide);let b=this.spineLength(x),C=g.vSide?Math.max(0,r[g.v]-2):Math.min(1,r[g.v]-1),q=(g.t>=this.params[g.v][C]?1:-1)*Math.cos(Gt),D=Math.sin(Gt);A=v(lt(0,12).map(j=>T=>At(a,f,d,H=>Wt(0,j,q,D,H),b,T)))}else{x=(o=this.spinePath(t,g.u,g.uSide,m.u,m.uSide))!==null&&o!==void 0?o:this.loosePath(t,g.u,m.u);let b=this.spineLength(x);if(u){let C=Math.max(12,Math.min(Dt*M,Ut));A=v(lt(C,12).map(q=>D=>Nt(a,f,d,vt(M,mn(M,q),0,0),D)));let G=Zt(A.pts);E=Math.max(.001,(G-2*i)/(r[x[0].k]-1))}else if(b>M+1e-6)A=v(this.arcCandidates(a,f,d,M,b));else{let C=b-2*i,G=Math.max(12,Math.min(Dt*(M-C),Ut)),q=(M-C)/2,D=(T,H)=>V=>At(a,f,d,z=>Wt(M/2+H*q-z/2,T,1,0,z),C,V),j=(T,H)=>Object.assign(V=>{let z=D(T,H)(V);return{...z,links:[[g.point,z.pts[0]],[z.pts.at(-1),m.point]]}},{slid:H!==0});A=v(l?lt(G,12).flatMap(T=>fn.map(H=>j(T,H))):lt(G,12).map(T=>D(T,0)));for(let T of(s=A.links)!==null&&s!==void 0?s:[])this.placeChord(T);w=0}}let O=new ht(A.pts,Mn(A.pts,A.refs)),S=this.layAlong(x,O,w,E);this.occupy(S,O);let B=Qt(S),R=t.filter(b=>!this.points[b]),K=this.componentsOf(R).map(b=>({members:b,span:Vt(this.anchorsOf(b))})).sort((b,C)=>b.span-C.span);for(let b of K)this.placePiece(b.members,B)}};function Lt(e){let t=new Float64Array(e.n).fill(NaN),n=new Float64Array(e.n).fill(NaN);if(xt.hasBackbone(e)){let o=new xt(e);o.run(),o.write(t,n)}return{X:t,Y:n}}var vn=[{walks:2,iterations:15},{walks:4,iterations:30},{walks:8,iterations:60},{walks:12,iterations:90},{walks:16,iterations:120}],An=20,Nn=3,bt=.3,Ln=2,bn=200,En=.1,kn=.5,_n=e=>{var t;return((t=e.stable)===null||t===void 0?void 0:t.rank)===0};function Yt(e,t){let n=t.at(-1);return(e==="+"||e==="-")&&(n==="+"||n==="-")&&e!==n}function Pn(e){let t=Math.imul(e,2654435761)>>>0||1;return()=>(t^=t<<13,t>>>=0,t^=t>>>17,t^=t<<5,t>>>=0,t/4294967296)}function Z(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Et(e,t){return Math.max(Z(e.nodeLengthPerMegabase,1e3)*t/1e6,Z(e.minimumNodeLength,1))}function Xt(e){let{nodes:t,edges:n}=e.graph,o=e.options,s=Z(o.nodeSegmentLength,1),r=Z(o.edgeLength,1),i=t.map(w=>w.id),c=new Int32Array(t.length),u=new Int32Array(t.length),l=new Float64Array(t.length),a=0;t.forEach((w,E)=>{let O=Et(o,w.length),S=Math.max(1,Math.ceil(O/s));c[E]=a,u[E]=S+1,l[E]=O/S,a+=S+1});let f=new Int32Array(a),h=new Int32Array(a),d=new Float64Array(a).fill(NaN),g=new Float64Array(a).fill(NaN),m=new Uint8Array(a),M=Array.from({length:a},()=>[]);t.forEach((w,E)=>{let O=typeof w.x=="number"&&typeof w.y=="number",S=_n(w)?1:0;for(let B=0;B<u[E];B++){let R=c[E]+B;f[R]=E,h[R]=B,m[R]=S,O&&(d[R]=w.x+B*l[E],g[R]=w.y),B>0&&(M[R-1].push([R,l[E]]),M[R].push([R-1,l[E]]))}});let F=new Map(i.map((w,E)=>[w,E])),L=t.map(()=>[[],[]]);for(let w of n){let E=F.get(w.from),O=F.get(w.to);if(E===void 0||O===void 0||E===O&&u[E]<=2)continue;let S=Yt(w.fromStrand,w.from)?0:1,B=Yt(w.toStrand,w.to)?1:0,R=c[E]+(S?u[E]-1:0),K=c[O]+(B?u[O]-1:0);M[R].push([K,r]),M[K].push([R,r]),L[E][S].push([O,B]),L[O][B].push([E,S])}let v=new Int32Array(a+1);for(let w=0;w<a;w++)v[w+1]=v[w]+M[w].length;let x=new Int32Array(v[a]),A=new Float64Array(v[a]);for(let w=0;w<a;w++)M[w].forEach(([E,O],S)=>{x[v[w]+S]=E,A[v[w]+S]=O});return{ids:i,first:c,count:u,per:l,links:L,chainOf:f,indexOf:h,seedX:d,seedY:g,backbone:m,off:v,nb:x,wt:A,n:a,link:r}}function Sn(e){let{n:t,off:n,nb:o}=e,s=new Int32Array(t).fill(-1),r=[];for(let i=0;i<t;i++){if(s[i]>=0)continue;let c=[i];s[i]=r.length;for(let u of c)for(let l=n[u];l<n[u+1];l++){let a=o[l];s[a]<0&&(s[a]=r.length,c.push(a))}r.push(c)}return{comp:s,members:r}}function In(e,t={}){var n,o,s;let r=Xt(e),{n:i,off:c,nb:u,wt:l,seedX:a,seedY:f,first:h,count:d,per:g,link:m}=r,M=e.options,F=vn[Math.max(0,Math.min(4,Z((n=t.quality)!==null&&n!==void 0?n:M.quality,2)))],L=Z((o=t.componentSeparation)!==null&&o!==void 0?o:M.componentSeparation,15),v=Pn(Z((s=t.seed)!==null&&s!==void 0?s:M.seed,1)),x=new Float64Array(i),A=new Float64Array(i),w={};if(i===0)return{nodePositions:w};let{comp:E,members:O}=Sn(r),S=1/0,B=0;for(let p=0;p<u.length;p++)S=Math.min(S,l[p]),B+=l[p];B/=2;let R=!1;for(let p=0;p<i;p++)if(!Number.isNaN(a[p])){R=!0;break}let K=R?Lt(r):void 0,b=Math.sqrt(i)*20;for(let p=0;p<i;p++)K&&!Number.isNaN(K.X[p])?(x[p]=K.X[p],A[p]=K.Y[p]):R&&!Number.isNaN(a[p])?(x[p]=a[p]+v()-.5,A[p]=f[p]+v()-.5):(x[p]=v()*b,A[p]=v()*b);let C=O.map(p=>K!==void 0&&p.every(N=>!Number.isNaN(K.X[N]))),G=[],q=!0;for(let p=0;p<i;p++)C[E[p]]||(G.push(p),q&&(q=!Number.isNaN(a[p])));let D=Math.max(B/4,S*10),j=D*D,T=En*S*S,{walks:H,iterations:V}=F,z=Math.log(j/T)/Math.max(1,V-1),kt=Math.log(S),tn=Math.log(D),_t=(p,N,y,k)=>{let P=k/(y*y);P>1&&(P=1);let _=x[p]-x[N],I=A[p]-A[N],Q=Math.sqrt(_*_+I*I)||1e-9,U=P*(Q-y)/(2*Q),J=U*_,W=U*I;x[p]=x[p]-J,A[p]=A[p]-W,x[N]=x[N]+J,A[N]=A[N]+W},rt=0,nn=(p,N)=>{let y=r.chainOf[p],k=r.indexOf[p],P=v()<.5?-1:1,_=N;for(let I=0;I<bn;I++){let Q=d[y],U=g[y],J=(P>0?Q-1-k:k)*U;if(_<=J){let X=Math.round(_/U);return rt=N-_+X*U,h[y]+k+P*X}_-=J;let W=r.links[y][P>0?1:0];if(W.length===0)return rt=N-_,h[y]+(P>0?Q-1:0);let[nt,Y]=W[Math.floor(v()*W.length)];if(_-=m,y=nt,P=Y===0?1:-1,k=Y===0?0:d[nt]-1,_<=0)return rt=N-_,h[y]+k}return-1},Pt=(p,N)=>{for(let y=c[p];y<c[p+1];y++){let k=u[y];k>p&&_t(p,k,l[y],N)}},tt=Int32Array.from(G),on=q?Math.floor(kn*V):0;for(let p=G.length?on:V;p<V;p++){let N=j*Math.exp(-z*p);for(let y=tt.length-1;y>0;y--){let k=Math.floor(v()*(y+1)),P=tt[y];tt[y]=tt[k],tt[k]=P}for(let y of tt){Pt(y,N);for(let k=0;k<H;k++){let P=Math.exp(kt+v()*(tn-kt)),_=nn(y,P);_>=0&&_!==y&&rt>0&&_t(y,_,rt,N)}}}let $=Nn*m,en=(p,N)=>Math.floor(p/$)*73856093^Math.floor(N/$)*19349663;for(let p=0;p<(G.length?An:0);p++){let N=new Map;for(let y of G){let k=en(x[y],A[y]),P=N.get(k);P?P.push(y):N.set(k,[y])}for(let y of G){let k=Math.floor(x[y]/$),P=Math.floor(A[y]/$);for(let _=k-1;_<=k+1;_++)for(let I=P-1;I<=P+1;I++){let Q=N.get(_*73856093^I*19349663);if(Q)for(let U of Q){if(U<=y)continue;let J=!1;for(let ot=c[y];ot<c[y+1];ot++)if(u[ot]===U){J=!0;break}if(J)continue;let W=x[y]-x[U],nt=A[y]-A[U],Y=Math.sqrt(W*W+nt*nt);if(Y>=$)continue;let X,ft;if(Y>1e-6){let ot=bt*($-Y)/(2*Y);X=ot*W,ft=ot*nt}else X=bt*$*(v()-.5),ft=bt*$*(v()-.5);x[y]=x[y]+X,A[y]=A[y]+ft,x[U]=x[U]-X,A[U]=A[U]-ft}}}for(let y of G)Pt(y,1/0)}for(let p=0;p<d.length;p++){let N=h[p],y=d[p];if(!(y<3)){for(let k=0;k<Ln;k++){let P=x.slice(N,N+y),_=A.slice(N,N+y);for(let I=1;I+1<y;I++)x[N+I]=.5*P[I]+.25*(P[I-1]+P[I+1]),A[N+I]=.5*_[I]+.25*(_[I-1]+_[I+1])}On(x,A,N,y,g[p])}}Cn(E,O,x,A,R,L);for(let p=0;p<r.ids.length;p++){let N=[];for(let y=0;y<d[p];y++)N.push({x:x[h[p]+y],y:A[h[p]+y]});w[r.ids[p]]=N}return{nodePositions:w}}function On(e,t,n,o,s){Rn(e,t,n,o,s*(o-1));let r=new Float64Array(o);for(let a=1;a<o;a++)r[a]=r[a-1]+Math.hypot(e[n+a]-e[n+a-1],t[n+a]-t[n+a-1]);if(!(r[o-1]>0))return;let i=r[o-1],c=e.slice(n,n+o),u=t.slice(n,n+o),l=1;for(let a=1;a+1<o;a++){let f=i*a/(o-1);for(;l<o-1&&r[l]<f;)l++;let h=r[l]-r[l-1],d=h>0?(f-r[l-1])/h:0;e[n+a]=c[l-1]+(c[l]-c[l-1])*d,t[n+a]=u[l-1]+(u[l]-u[l-1])*d}}function Rn(e,t,n,o,s){let r=n+o-1,i=e[n],c=t[n],u=Math.hypot(e[r]-i,t[r]-c),l=u>1e-9?(e[r]-i)/u:1,a=u>1e-9?(t[r]-c)/u:0,f=new Float64Array(o),h=new Float64Array(o),d=!0;for(let L=0;L<o;L++){let v=e[n+L]-i,x=t[n+L]-c;f[L]=v*l+x*a,h[L]=x*l-v*a,d&&(d=Math.abs(h[L])<1e-6)}let g=L=>{let v=0;for(let x=1;x<o;x++)v+=Math.hypot(f[x]-f[x-1],L*(h[x]-h[x-1]));return v};if(d||g(1)>=s)return;let m=1,M=2;for(;g(M)<s&&M<1e6;)m=M,M*=2;for(let L=0;L<40;L++){let v=(m+M)/2;g(v)<s?m=v:M=v}let F=(m+M)/2;for(let L=1;L+1<o;L++)e[n+L]=i+f[L]*l-F*h[L]*a,t[n+L]=c+f[L]*a+F*h[L]*l}function Cn(e,t,n,o,s,r){if(!s)for(let f of t)Tn(n,o,f);if(t.length<2)return;let i=new Float64Array(t.length).fill(1/0),c=new Float64Array(t.length).fill(1/0),u=new Float64Array(t.length).fill(-1/0);for(let f=0;f<n.length;f++){let h=e[f];i[h]=Math.min(i[h],n[f]),c[h]=Math.min(c[h],o[f]),u[h]=Math.max(u[h],o[f])}let l=new Float64Array(t.length),a=0;for(let f=0;f<t.length;f++)l[f]=a-c[f],a+=u[f]-c[f]+r;for(let f=0;f<n.length;f++){let h=e[f];n[f]=n[f]-i[h],o[f]=o[f]+l[h]}}function Tn(e,t,n){if(n.length<3)return;let o=0,s=0;for(let f of n)o+=e[f],s+=t[f];o/=n.length,s/=n.length;let r=0,i=0,c=0;for(let f of n){let h=e[f]-o,d=t[f]-s;r+=h*h,i+=d*d,c+=h*d}let u=-.5*Math.atan2(2*c,r-i),l=Math.cos(u),a=Math.sin(u);for(let f of n){let h=e[f]-o,d=t[f]-s;e[f]=o+l*h-a*d,t[f]=s+a*h+l*d}}export{$t as a,In as b,Rt as c,Tt as d,Gn as e,Dn as f,Mt as g,cn as h,an as i,ln as j};
2
+ //# sourceMappingURL=chunk-CUV34DJR.js.map