jbrowse-plugin-graphgenomeviewer 4.7.0 → 4.8.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 (42) hide show
  1. package/README.md +3 -1
  2. package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js +2 -0
  3. package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js.map +7 -0
  4. package/dist/chunks/{GbzBaseSyntenyAdapter-AZBYMDIW.js → GbzBaseSyntenyAdapter-VOGKGHQ6.js} +1 -1
  5. package/dist/chunks/{GbzBaseSyntenyAdapter-AZBYMDIW.js.map → GbzBaseSyntenyAdapter-VOGKGHQ6.js.map} +2 -2
  6. package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js → GraphGenomeView-YYP4IFSI.js} +2 -2
  7. package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js → GraphTrackSettingsDialog-2WPJRAJC.js} +2 -2
  8. package/dist/chunks/{LinearGraphDisplay-MJ4ZBJRX.js → LinearGraphDisplay-4HYL7PDU.js} +2 -2
  9. package/dist/chunks/{chunk-UTWFU4X6.js → chunk-H54W6OQQ.js} +2 -2
  10. package/dist/chunks/{chunk-UTWFU4X6.js.map → chunk-H54W6OQQ.js.map} +4 -4
  11. package/dist/chunks/{chunk-F2EPKNTV.js → chunk-O4XV3K35.js} +2 -2
  12. package/dist/chunks/{chunk-F2EPKNTV.js.map → chunk-O4XV3K35.js.map} +4 -4
  13. package/dist/chunks/chunk-SJNG2XK7.js +2 -0
  14. package/dist/chunks/chunk-SJNG2XK7.js.map +7 -0
  15. package/dist/chunks/chunk-WKVVIDCS.js +3 -0
  16. package/dist/chunks/{chunk-KCL5TF5X.js.map → chunk-WKVVIDCS.js.map} +3 -3
  17. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
  18. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  19. package/package.json +2 -2
  20. package/src/GraphGenomeView/components/ChooseWalksDialog.tsx +86 -0
  21. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +205 -187
  22. package/src/GraphGenomeView/components/TubeMapLegend.test.tsx +29 -0
  23. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +8 -0
  24. package/src/GraphGenomeView/model.ts +10 -4224
  25. package/src/GraphGenomeView/pane/fitViews.ts +589 -0
  26. package/src/GraphGenomeView/pane/graphViews.ts +829 -0
  27. package/src/GraphGenomeView/pane/hostViews.ts +193 -0
  28. package/src/GraphGenomeView/pane/launchActions.ts +407 -0
  29. package/src/GraphGenomeView/pane/launchViews.ts +191 -0
  30. package/src/GraphGenomeView/pane/loadActions.ts +701 -0
  31. package/src/GraphGenomeView/pane/paneBase.ts +479 -0
  32. package/src/GraphGenomeView/pane/renderingActions.ts +281 -0
  33. package/src/GraphGenomeView/pane/settingActions.ts +467 -0
  34. package/src/GraphGenomeView/pane/walkRowViews.ts +205 -0
  35. package/src/gaf/gafFile.ts +2 -0
  36. package/src/version.ts +1 -1
  37. package/dist/chunks/chunk-BUXVOMDL.js +0 -2
  38. package/dist/chunks/chunk-BUXVOMDL.js.map +0 -7
  39. package/dist/chunks/chunk-KCL5TF5X.js +0 -3
  40. /package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js.map → GraphGenomeView-YYP4IFSI.js.map} +0 -0
  41. /package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js.map → GraphTrackSettingsDialog-2WPJRAJC.js.map} +0 -0
  42. /package/dist/chunks/{LinearGraphDisplay-MJ4ZBJRX.js.map → LinearGraphDisplay-4HYL7PDU.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as x}from"./chunk-KCL5TF5X.js";import"./chunk-F2EPKNTV.js";import"./chunk-UQEPPJEO.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-BUXVOMDL.js";import{Z as L}from"./chunk-UTWFU4X6.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import{a as B}from"./chunk-J6KYLXRD.js";import{a as s,b as v,c as g,d as G}from"./chunk-TYJTJGPO.js";import{b as a}from"./chunk-FY3BTKY4.js";var S=a(g(),1);var m=a(v(),1),n=a(G(),1),C=a(g(),1),P=a(L(),1),o=a(s(),1),I=(0,P.makeStyles)()({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}}),b=(0,C.observer)(function({model:e}){let{classes:r}=I();return e.isLoading?(0,o.jsxs)(n.Paper,{className:r.paper,"data-testid":"graph-genome-loading",children:[(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(m.LoadingEllipses,{variant:"h6",message:e.statusMessage}),(0,o.jsx)(n.Button,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),(0,o.jsx)(n.LinearProgress,{variant:"indeterminate"})]}):e.error?(0,o.jsx)(n.Paper,{className:r.paper,children:(0,o.jsx)(m.ErrorBanner,{error:e.error,onReset:()=>{e.retryLoad()}})}):(0,o.jsx)(n.Paper,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(n.Typography,{variant:"h6",children:"Loading canceled"}),(0,o.jsx)(n.Button,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),h=b;var M=a(B(),1),N=a(v(),1),i=a(G(),1),w=a(g(),1),E=a(L(),1),t=a(s(),1),k=`H VN:Z:1.0
1
+ import{a as x}from"./chunk-WKVVIDCS.js";import"./chunk-SJNG2XK7.js";import"./chunk-O4XV3K35.js";import{Z as L}from"./chunk-H54W6OQQ.js";import"./chunk-UQEPPJEO.js";import"./chunk-SCMIJAAX.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import"./chunk-FCWXYIFC.js";import{a as B}from"./chunk-J6KYLXRD.js";import{a as s,b as v,c as g,d as G}from"./chunk-TYJTJGPO.js";import{b as a}from"./chunk-FY3BTKY4.js";var S=a(g(),1);var m=a(v(),1),n=a(G(),1),C=a(g(),1),P=a(L(),1),o=a(s(),1),I=(0,P.makeStyles)()({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}}),b=(0,C.observer)(function({model:e}){let{classes:r}=I();return e.isLoading?(0,o.jsxs)(n.Paper,{className:r.paper,"data-testid":"graph-genome-loading",children:[(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(m.LoadingEllipses,{variant:"h6",message:e.statusMessage}),(0,o.jsx)(n.Button,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),(0,o.jsx)(n.LinearProgress,{variant:"indeterminate"})]}):e.error?(0,o.jsx)(n.Paper,{className:r.paper,children:(0,o.jsx)(m.ErrorBanner,{error:e.error,onReset:()=>{e.retryLoad()}})}):(0,o.jsx)(n.Paper,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(n.Typography,{variant:"h6",children:"Loading canceled"}),(0,o.jsx)(n.Button,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),h=b;var M=a(B(),1),N=a(v(),1),i=a(G(),1),w=a(g(),1),E=a(L(),1),t=a(s(),1),k=`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`,z=(0,E.makeStyles)()({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},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"}}),R=(0,w.observer)(function({model:e}){let{classes:r}=z(),[d,T]=(0,M.useState)("");function y(){d.trim()&&e.loadGFAFromLocation({uri:d,locationType:"UriLocation"})}function A(p){let c=p.target.files?.[0];c&&c.text().then(f=>e.loadGFA(f,c.name)).catch(f=>{e.setError(f)})}return(0,t.jsxs)(i.Paper,{className:r.paper,children:[(0,t.jsx)("div",{className:r.header,children:(0,t.jsx)(i.Typography,{variant:"h6",children:"Load a GFA graph"})}),(0,t.jsxs)("div",{className:r.column,children:[(0,t.jsxs)("div",{className:r.rowCenter,children:[(0,t.jsxs)(i.Button,{variant:"outlined",component:"label",size:"small",children:["Choose file",(0,t.jsx)("input",{type:"file",accept:".gfa,.gfa1,.gfa2",hidden:!0,onChange:p=>{A(p)}})]}),(0,t.jsx)(i.Typography,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),(0,t.jsxs)("div",{className:r.rowEnd,children:[(0,t.jsx)(i.TextField,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:d,onChange:p=>{T(p.target.value)},onKeyDown:p=>{p.key==="Enter"&&y()},className:r.flex1}),(0,t.jsx)(i.Button,{variant:"contained",onClick:()=>{y()},disabled:!d.trim(),children:"Open"})]})]}),(0,t.jsx)("div",{className:r.footer,children:(0,t.jsx)(i.Button,{size:"small",onClick:()=>{e.loadGFA(k,"Example graph")},children:"Load 4-node example"})}),e.error?(0,t.jsx)(N.ErrorBanner,{error:e.error}):null]})}),F=R;var l=a(s(),1),U=(0,S.observer)(function({model:e}){return e.hasGraph?(0,l.jsx)(x,{model:e}):e.canRetryLoad&&(e.error||e.loadCanceled)?(0,l.jsx)(h,{model:e}):(0,l.jsxs)(l.Fragment,{children:[e.isLoading?(0,l.jsx)(h,{model:e}):null,(0,l.jsx)("div",{hidden:e.isLoading,children:(0,l.jsx)(F,{model:e})})]})}),O=U;export{O as default};
10
- //# sourceMappingURL=GraphGenomeView-HZ2EQUOC.js.map
10
+ //# sourceMappingURL=GraphGenomeView-YYP4IFSI.js.map
@@ -1,4 +1,4 @@
1
- import{a as g}from"./chunk-BUXVOMDL.js";import{Z as f}from"./chunk-UTWFU4X6.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import{a as x}from"./chunk-J6KYLXRD.js";import{a as l,c as m,d as y}from"./chunk-TYJTJGPO.js";import{b as o}from"./chunk-FY3BTKY4.js";var a=o(y(),1),b=o(m(),1),S=o(f(),1),n=o(l(),1),L=(0,S.makeStyles)()({section:{marginBottom:24},formControl:{minWidth:200}}),w=[{value:0,label:"None"},{value:1,label:"1 hop"},{value:2,label:"2 hops"}],k=(0,b.observer)(function({model:e}){let{classes:t}=L();return(0,n.jsxs)("div",{className:t.section,children:[(0,n.jsxs)(a.FormControl,{className:t.formControl,children:[(0,n.jsx)(a.InputLabel,{children:"Graph context"}),(0,n.jsx)(a.Select,{value:e.subgraphContext,label:"Graph context","data-testid":"graph-context-select",onChange:p=>{e.setSubgraphContext(p.target.value),e.cut()},children:w.map(({value:p,label:u})=>(0,n.jsx)(a.MenuItem,{value:p,children:u},p))})]}),(0,n.jsx)(a.Typography,{variant:"caption",color:"text.secondary",children:"How far the cut follows links out of the region, one hop by default. A detour that leaves the reference before the window and rejoins after it is indexed under its own sequence, so at none its middle is missing and the one bubble draws as two unrelated stubs. Each hop costs a query per off-reference segment already reached."})]})}),v=k;var C=o(x(),1),d=o(y(),1),c=o(m(),1),G=o(f(),1),i=o(l(),1),T=(0,G.makeStyles)()({section:{marginBottom:24}});function M(r){let e=r.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t!=="");return e.length===0?void 0:e}var F=(0,c.observer)(function({model:e}){let[t,p]=(0,C.useState)(e.chosenHaplotypes?.join(", ")??""),u=()=>{let s=M(t)??[];s.join(`
1
+ import{a as g}from"./chunk-SJNG2XK7.js";import{Z as f}from"./chunk-H54W6OQQ.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import{a as x}from"./chunk-J6KYLXRD.js";import{a as l,c as m,d as y}from"./chunk-TYJTJGPO.js";import{b as o}from"./chunk-FY3BTKY4.js";var a=o(y(),1),b=o(m(),1),S=o(f(),1),n=o(l(),1),L=(0,S.makeStyles)()({section:{marginBottom:24},formControl:{minWidth:200}}),w=[{value:0,label:"None"},{value:1,label:"1 hop"},{value:2,label:"2 hops"}],k=(0,b.observer)(function({model:e}){let{classes:t}=L();return(0,n.jsxs)("div",{className:t.section,children:[(0,n.jsxs)(a.FormControl,{className:t.formControl,children:[(0,n.jsx)(a.InputLabel,{children:"Graph context"}),(0,n.jsx)(a.Select,{value:e.subgraphContext,label:"Graph context","data-testid":"graph-context-select",onChange:p=>{e.setSubgraphContext(p.target.value),e.cut()},children:w.map(({value:p,label:u})=>(0,n.jsx)(a.MenuItem,{value:p,children:u},p))})]}),(0,n.jsx)(a.Typography,{variant:"caption",color:"text.secondary",children:"How far the cut follows links out of the region, one hop by default. A detour that leaves the reference before the window and rejoins after it is indexed under its own sequence, so at none its middle is missing and the one bubble draws as two unrelated stubs. Each hop costs a query per off-reference segment already reached."})]})}),v=k;var C=o(x(),1),d=o(y(),1),c=o(m(),1),G=o(f(),1),i=o(l(),1),T=(0,G.makeStyles)()({section:{marginBottom:24}});function M(r){let e=r.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t!=="");return e.length===0?void 0:e}var F=(0,c.observer)(function({model:e}){let[t,p]=(0,C.useState)(e.chosenHaplotypes?.join(", ")??""),u=()=>{let s=M(t)??[];s.join(`
2
2
  `)===(e.chosenHaplotypes??[]).join(`
3
3
  `)||(e.setSubgraphHaplotypes(s),e.cut())};return(0,i.jsx)(d.TextField,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:t,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:s=>{p(s.target.value)},onBlur:()=>{u()},onKeyDown:s=>{s.key==="Enter"&&u()}})}),N=(0,c.observer)(function({model:e}){let{classes:t}=T();return e.adapterConfig.type==="GbzBaseSyntenyAdapter"?(0,i.jsxs)("div",{className:t.section,children:[(0,i.jsx)(F,{model:e},e.chosenHaplotypes?.join(",")??""),(0,i.jsx)(d.Typography,{variant:"caption",color:"text.secondary",children:"The haplotypes the cut is for, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both), separated by commas. The cut keeps their walks and the nodes those walks visit, with the reference. Empty is every haplotype."})]}):null}),H=N;var h=o(l(),1);function B({model:r,open:e,onClose:t}){return(0,h.jsxs)(g,{model:r,open:e,onClose:t,children:[(0,h.jsx)(v,{model:r}),(0,h.jsx)(H,{model:r})]})}export{B as default};
4
- //# sourceMappingURL=GraphTrackSettingsDialog-JVPM25GV.js.map
4
+ //# sourceMappingURL=GraphTrackSettingsDialog-2WPJRAJC.js.map
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-KCL5TF5X.js";import"./chunk-F2EPKNTV.js";import"./chunk-UQEPPJEO.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-BUXVOMDL.js";import"./chunk-UTWFU4X6.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import"./chunk-J6KYLXRD.js";import{a as e,c as d}from"./chunk-TYJTJGPO.js";import{a as h,b as t}from"./chunk-FY3BTKY4.js";var p=h((l,o)=>{o.exports=JBrowseExports["@jbrowse/display-kit/DisplayChrome"]});var s=t(p(),1),n=t(d(),1);var r=t(e(),1),y=(0,n.observer)(function({model:a}){return(0,r.jsx)(s.DisplayStatusChrome,{model:a,phase:a.displayPhase,drawn:a.painted&&a.geometryPainted,testid:"linear-graph-display","data-layout":a.chosenLayoutMode,"data-cut-tier":a.cutTier,"data-recuts":a.recuts,"data-node-count":a.hasGraph?a.nodeCount:void 0,"data-loading":a.isLoading?"":void 0,style:{width:a.paneWidth,height:a.height,overflow:"hidden"},children:(0,r.jsx)(i,{model:a,ownChrome:!1})})}),c=y;export{c as default};
2
- //# sourceMappingURL=LinearGraphDisplay-MJ4ZBJRX.js.map
1
+ import{a as i}from"./chunk-WKVVIDCS.js";import"./chunk-SJNG2XK7.js";import"./chunk-O4XV3K35.js";import"./chunk-H54W6OQQ.js";import"./chunk-UQEPPJEO.js";import"./chunk-SCMIJAAX.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import"./chunk-FCWXYIFC.js";import"./chunk-J6KYLXRD.js";import{a as e,c as d}from"./chunk-TYJTJGPO.js";import{a as h,b as t}from"./chunk-FY3BTKY4.js";var p=h((l,o)=>{o.exports=JBrowseExports["@jbrowse/display-kit/DisplayChrome"]});var s=t(p(),1),n=t(d(),1);var r=t(e(),1),y=(0,n.observer)(function({model:a}){return(0,r.jsx)(s.DisplayStatusChrome,{model:a,phase:a.displayPhase,drawn:a.painted&&a.geometryPainted,testid:"linear-graph-display","data-layout":a.chosenLayoutMode,"data-cut-tier":a.cutTier,"data-recuts":a.recuts,"data-node-count":a.hasGraph?a.nodeCount:void 0,"data-loading":a.isLoading?"":void 0,style:{width:a.paneWidth,height:a.height,overflow:"hidden"},children:(0,r.jsx)(i,{model:a,ownChrome:!1})})}),c=y;export{c as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-4HYL7PDU.js.map
@@ -1,2 +1,2 @@
1
- import{b as v,g as ie}from"./chunk-7BKUWQE5.js";import{a as ae,b as ce}from"./chunk-KULNKXPT.js";import{a as ze}from"./chunk-FY3BTKY4.js";var Kt=ze((Zn,De)=>{De.exports=JBrowseExports["tss-react/mui"]});function Zt(e){let t=n=>Math.round(n*100)/100;return e.map((n,r)=>`${r?"L":"M"}${t(n.x)},${t(n.y)}`).join("")}function ue(e,t,n,r,s){let o=Math.hypot(r-t,n-e);if(o===0)return[n,r];let a=(n-e)/o,c=(r-t)/o;return[n+s*a,r+s*c]}function V(e,t){let n=1-t,r=n*n*n,s=3*n*n*t,o=3*n*t*t,a=t*t*t;return{x:r*e.x0+s*e.cx0+o*e.cx1+a*e.x1,y:r*e.y0+s*e.cy0+o*e.cy1+a*e.y1}}function xe(e){let t=e[Math.floor(e.length/2)];return t?V(t,.5):void 0}function ye(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(let o of e)t=Math.min(t,o.x0,o.cx0,o.cx1,o.x1),r=Math.max(r,o.x0,o.cx0,o.cx1,o.x1),n=Math.min(n,o.y0,o.cy0,o.cy1,o.y1),s=Math.max(s,o.y0,o.cy0,o.cy1,o.y1);return{minX:t,minY:n,maxX:r,maxY:s}}function $e(e,t,n){let r=V(e,t),s=V(e,n),o=(n-t)/3,a=de(e,t),c=de(e,n);return{x0:r.x,y0:r.y,cx0:r.x+a.x*o,cy0:r.y+a.y*o,cx1:s.x-c.x*o,cy1:s.y-c.y*o,x1:s.x,y1:s.y}}function de(e,t){let n=1-t,r=3*n*n,s=6*n*t,o=3*t*t;return{x:r*(e.cx0-e.x0)+s*(e.cx1-e.cx0)+o*(e.x1-e.cx1),y:r*(e.cy0-e.y0)+s*(e.cy1-e.cy0)+o*(e.y1-e.cy1)}}function en(e,t){let n=e.map(a=>Math.hypot(a.cx0-a.x0,a.cy0-a.y0)+Math.hypot(a.cx1-a.cx0,a.cy1-a.cy0)+Math.hypot(a.x1-a.cx1,a.y1-a.cy1)),r=n.reduce((a,c)=>a+c,0),s=Math.max(3,Math.round(r/t)|1),o=[];for(let a=0;a<s;a+=2){let c=a/s*r,i=(a+1)/s*r,u=[],l=0;e.forEach((h,p)=>{let d=n[p],m=l+d;d>0&&m>c&&l<i&&u.push($e(h,Math.max(0,(c-l)/d),Math.min(1,(i-l)/d))),l=m}),u.length&&o.push(u)}return o}function tn(e,t,n){let r=new Array(e.length);for(let s=0;s<e.length;s++){let o=e[s];r[s]={x0:o.x0+t,y0:o.y0+n,cx0:o.cx0+t,cy0:o.cy0+n,cx1:o.cx1+t,cy1:o.cy1+n,x1:o.x1+t,y1:o.y1+n}}return r}function X(e,t){let n=e.length-1;return t==="end"?{at:e[n],inward:e[n-1]}:{at:e[0],inward:e[1]}}var We=.5,Ye=80;function me(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.x),n=Math.max(n,r.x);return{min:t,max:n}}function le(e,t){return Math.max(0,t.min-e,e-t.max)}function pe(e,t,n){let r=le(e[0].x,t),s=le(e[e.length-1].x,t);return r===s?n:r<s?"start":"end"}function Ue(e,t){return{from:pe(e,me(t),"end"),to:pe(t,me(e),"start")}}var je=.75,Ve=1.15,qe=.35,Ke=60;function Je(e,t,n,r,s,o){let a=Math.hypot(n-e,r-t),c=a===0?1:(n-e)/a,i=a===0?0:(r-t)/a,u=0,l=1/0,h=-1/0;for(let f of s){let b=f.x-e,x=f.y-t,y=b*-i+x*c;Math.abs(y)>Math.abs(u)&&(u=y);let N=b*c+x*i;l=Math.min(l,N),h=Math.max(h,N)}let p=s.length?h-l:0,d=Math.max(Math.abs(u)*Ve/je,p*qe),m=o===void 0?d:Math.min(d,o);return u<0?-m:m}function be({scaleX:e,scaleY:t}){return t/e}var Qe=3;function U(e,t,n){let r=t.x-e.x,s=(t.y-e.y)*n,o=Math.hypot(r,s);return o===0?void 0:{x:r/o,y:s/o}}function nn(e,t,n,r,s=Qe){let o=be(r),a=U(e[e.length-1],t[0],o)??U(e[0],e.at(-1),o)??U(t[0],t.at(-1),o)??{x:1,y:0},c=[];for(let i=0;i<n;i++){let u=(i-(n-1)/2)*s;c.push({x:-a.y*u,y:a.x*u/o})}return c}function j(e,t){return e.map(n=>({x:n.x,y:n.y*t}))}function Ze(e,t){for(let n of e)n.y0/=t,n.cy0/=t,n.cy1/=t,n.y1/=t;return e}var et=12,tt=40;function fe(e,t){let n=0;for(let o=1;o<e.length;o++)n+=Math.hypot(e[o].x-e[o-1].x,e[o].y-e[o-1].y);let r=n*t;return Math.min(tt,Math.max(et,r/2))/Math.max(t,Number.EPSILON)}function on(e){return e.from!==e.to?!1:e.fromStrand&&e.toStrand&&e.fromStrand!==e.toStrand?e.fromStrand==="+"?"end":"start":!0}function nt(e,t,n,r){let{at:s,inward:o}=e,a=o?s.x-o.x:1,c=o?s.y-o.y:0,i=Math.hypot(a,c)||1,u=a/i,l=c/i,h=s.x+n,p=s.y+r,d=h+u*t/3,m=p+l*t/3,f=h+u*t,b=p+l*t,x=-l*t/2,y=u*t/2;return[{x0:h,y0:p,cx0:d,cy0:m,cx1:f+x,cy1:b+y,x1:f,y1:b},{x0:f,y0:b,cx0:f-x,cy0:b-y,cx1:d,cy1:m,x1:h,y1:p}]}function q(e,t,n,r,s,o,a=[],c){let i=o.scaleX,u=be(o),l=c??(o.pixelRows?Ke:void 0);if(u!==1)return Ze(q(j(e,u),j(t,u),n,r,s*u,{scaleX:i,scaleY:i},j(a,u),l===void 0?void 0:l*u),u);if(typeof n=="string")return nt(X(e,n),fe(e,i),r,s);let h=n?{from:"end",to:"start"}:Ue(e,t),p=X(e,h.from),d=X(t,h.to),m=p.at,f=d.at,b=m.x+r,x=m.y+s,y=f.x+r,N=f.y+s;if(n){let E=1,L=0;if(p.inward){let C=m.x-p.inward.x,R=m.y-p.inward.y,G=Math.hypot(C,R);G>0&&(E=C/G,L=R/G)}let g=fe(e,i),A=-L,M=E,S=(m.x+f.x)/2+r+A*g,w=(m.y+f.y)/2+s+M*g,B=b+E*g,O=x+L*g,P=y-E*g,_=N-L*g;return[{x0:b,y0:x,cx0:B,cy0:O,cx1:B+A*g,cy1:O+M*g,x1:S,y1:w},{x0:S,y0:w,cx0:P+A*g,cy0:_+M*g,cx1:P,cy1:_,x1:y,y1:N}]}else{let E=p.inward??{x:m.x-(f.x-m.x),y:m.y-(f.y-m.y)},L=d.inward??{x:f.x-(m.x-f.x),y:f.y-(m.y-f.y)},g=Math.hypot(y-b,N-x),A=(te,ne,He,Xe)=>{let oe=ne.x-te.x,re=ne.y-te.y,se=Math.hypot(oe,re),ke=se===0?0:(He*oe+Xe*re)/se;return Math.max(0,Math.min(g*We,Ye,ke*.5))},M=f.x-m.x,S=f.y-m.y,[w,B]=ue(E.x,E.y,m.x,m.y,A(E,m,M,S)),[O,P]=ue(L.x,L.y,f.x,f.y,A(L,f,-M,-S)),_=a.length?Je(b,x,y,N,a,l):0,C=g===0?1:g,R=(y-b)/C,G=(N-x)/C,H=-G*_,Q=R*_,Z=R*Math.abs(_),ee=G*Math.abs(_);return[{x0:b,y0:x,cx0:w+r+H-Z,cy0:B+s+Q-ee,cx1:O+r+H+Z,cy1:P+s+Q+ee,x1:y,y1:N}]}}function he(e,t){let n=e[0],r=e.at(-1);return Math.hypot(n.x-t.x,n.y-t.y)<Math.hypot(r.x-t.x,r.y-t.y)?"start":"end"}function ge(e,t,n){let r=X(e,he(e,n[0])),s=X(t,he(t,n.at(-1))),o=[r.at,...n,s.at],a=i=>{let u=o[i],l=p=>Math.hypot(p.x-u.x,p.y-u.y),h=(p,d)=>{let m=p?l(p):0,f=l(d);return m===0?{x:d.x-u.x,y:d.y-u.y}:{x:(u.x-p.x)/m*f,y:(u.y-p.y)/m*f}};if(i===0)return h(r.inward,o[1]);if(i===o.length-1){let p=h(s.inward,o[i-1]);return{x:-p.x,y:-p.y}}return{x:(o[i+1].x-o[i-1].x)/2,y:(o[i+1].y-o[i-1].y)/2}},c=[];for(let i=0;i<o.length-1;i++){let u=o[i],l=o[i+1],h=a(i),p=a(i+1);c.push({x0:u.x,y0:u.y,cx0:u.x+h.x/3,cy0:u.y+h.y/3,cx1:l.x-p.x/3,cy1:l.y-p.y/3,x1:l.x,y1:l.y})}return c}var ot=1;function rt(e,t){return t.flatMap(n=>e[n]??[])}function Ne(e,t,n,r){let s=e[t.from],o=e[t.to];if(!(!s?.length||!o?.length))return r?ge(s,o,r):q(s,o,t.from===t.to,0,0,n,rt(e,t.bypassed))}function st(e){let t=new Map;for(let n of e.nodes)if(v(n)){let r=t.get(n.stable.refName);r?r.push(n):t.set(n.stable.refName,[n])}for(let n of t.values())n.sort((r,s)=>r.stable.start-s.stable.start);return t}function at(e,t,n){let r=[];if(e)for(let s=ie(e,t);s<e.length;s++){let o=e[s];if(o.stable.start>=n)break;o.stable.start+o.length<=n&&r.push(o.id)}return r}function ct(e,t,n,r){let{fromStrand:s,toStrand:o}=e;if(s===void 0||o===void 0)return!0;let a=s===(t.stable.strand??"+"),c=o===(n.stable.strand??"+");return r?a&&c:!a&&!c}function cn(e){let t=new Map(e.nodes.map(s=>[s.id,s])),n=st(e),r=[];for(let s=0;s<e.edges.length;s++){let o=e.edges[s],a=t.get(o.from),c=t.get(o.to);if(a!==void 0&&c!==void 0&&v(a)&&v(c)&&a.stable.refName===c.stable.refName){let i=a.stable.start<=c.stable.start,[u,l]=i?[a,c]:[c,a],h=u.stable.start+u.length,p=l.stable.start,d=p-h;if(d>=ot&&ct(o,a,c,i)){let m=u.stable.refName;r.push({edgeIndex:s,from:o.from,to:o.to,refName:m,start:h,end:p,bp:d,bypassed:at(n.get(m),h,p)})}}}return r}function T(e){return e.endsWith("-")?"-":"+"}function Le(e){return e==="+"?"-":"+"}function it(e){let t=(e.fromStrand??T(e.from))===T(e.from)?"end":"start",n=(e.toStrand??T(e.to))===T(e.to)?"start":"end";return{from:t,to:n}}function mn(e,t=new Set){let n=e.edges.map(it),r=new Map,s=(d,m,f)=>{let b=`${d}|${m}`,x=r.get(b);x?x.push(f):r.set(b,[f])};e.edges.forEach((d,m)=>{s(d.from,n[m].from,m),s(d.to,n[m].to,m)});let o=d=>{let m=r.get(`${d}|end`);if(m?.length!==1)return;let f=m[0],b=e.edges[f];return b.from===d&&b.to!==d&&!t.has(d)&&!t.has(b.to)&&n[f].from==="end"&&n[f].to==="start"&&r.get(`${b.to}|start`)?.length===1?f:void 0},a=new Set,c=new Map,i=new Map;for(let d of e.nodes){let m=r.get(`${d.id}|start`),f=m?.length===1?e.edges[m[0]].from:void 0;if(c.has(d.id)||f!==void 0&&o(f)===m[0])continue;let b=[d.id];for(;;){let x=o(b.at(-1)),y=x===void 0?void 0:e.edges[x].to;if(y===void 0||c.has(y))break;a.add(x),b.push(y)}for(let x of b)c.set(x,d.id);b.length>1&&i.set(d.id,b)}for(let d of e.nodes)c.has(d.id)||c.set(d.id,d.id);let u=new Map(e.nodes.map(d=>[d.id,d])),l=[];for(let d of e.nodes){if(c.get(d.id)!==d.id)continue;let m=i.get(d.id);if(!m){l.push(d);continue}let f=m.map(y=>u.get(y)),b=f.filter(v),x=b.length?b.reduce((y,N)=>y.stable.start<=N.stable.start?y:N):f[0];l.push({id:d.id,name:d.name,length:f.reduce((y,N)=>y+N.length,0),depth:d.depth,stable:x.stable})}let h=new Set,p=[];return e.edges.forEach((d,m)=>{let f=c.get(d.from),b=c.get(d.to),x=n[m],y=`${f}|${x.from}>${b}|${x.to}`;a.has(m)||h.has(y)||(h.add(y),p.push({from:f,to:b,...x.from==="start"?{fromStrand:Le(T(f))}:{},...x.to==="end"?{toStrand:Le(T(b))}:{}}))}),{graph:{...e,nodes:l,edges:p,paths:void 0,pathVisits:void 0},runs:i}}function ln(e,t,n){let r={...e};for(let[s,o]of t){let a=e[s];if(!a?.length)continue;delete r[s];let c=J(a),i=c.at(-1),u=o.map(p=>Math.max(n(p),0)),l=u.reduce((p,d)=>p+d,0)||o.length,h=0;o.forEach((p,d)=>{let m=l?u[d]/l*i:i/o.length,f=d===o.length-1?i:h+m;r[p]=Me(a,c,h,f),h=f})}return r}function pn(e,t,n){if(e.length===0)return[];let r=J(e),s=r.at(-1);return Me(e,r,t*s,n*s)}function Se(e){let t=J(e);return K(e,t,t.at(-1)/2)}function J(e){let t=[0];for(let n=1;n<e.length;n++)t.push(t[n-1]+Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y));return t}function K(e,t,n){if(n<=0)return{...e[0]};let r=1;for(;r<t.length&&t[r]<n;)r++;if(r>=t.length)return{...e.at(-1)};let s=t[r]-t[r-1],o=s>0?(n-t[r-1])/s:0,a=e[r-1],c=e[r];return{x:a.x+(c.x-a.x)*o,y:a.y+(c.y-a.y)*o}}function Me(e,t,n,r){let s=[K(e,t,n)];for(let o=0;o<e.length;o++)t[o]>n&&t[o]<r&&s.push({...e[o]});return s.push(K(e,t,r)),s}function ut(e){return e.length*6.2+8}function dt(e,t){return e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0}function Ee(e,t){return e.x1<=0||e.x0>=t.width||e.y1<=0||e.y0>=t.height}function mt(e,t){return e.x0>=0&&e.x1<=t.width&&e.y0>=0&&e.y1<=t.height}function lt(e,t=[]){let n=[...t];return r=>Ee(r,e)||n.some(s=>dt(s,r))?!1:(n.push(r),!0)}function hn(e,t,n){let r=[],o=(a,c)=>{let i=ut(c),u=a.y>t.height/2?-1:1;for(let l=0;l<=(a.stack??0);l++){let h=a.y+u*l*19,p={x0:a.x-i/2,x1:a.x+i/2,y0:h-11-4,y1:h+4};if(Ee(p,t))return;if(mt(p,t)&&n(p))return{...a,text:c,y:h,w:i}}};for(let a of e){let c=o(a,a.text)??(a.fallback===void 0?void 0:o(a,a.fallback));c&&r.push(c)}return r}var pt=26,ft=4e4,ht=8,xt=8,yt=5.7,bt=6,gt=13,k=3,z=2;function W(e){return(e.length*yt+bt+k)/2}var I=(gt+k)/2,Nt=W("1 bp");function F(e,t,n){return{x0:t-e,x1:t+e,y0:n-I,y1:n+I}}function Ln(e,t){return{x0:6,x1:6+e.length*6.2+8+k,y0:t-8-k/2,y1:t+8+k/2}}function $(e,t,n){return n<t?e:Math.min(Math.max(e,t),n)}function we(e){return String(e).replace(/\B(?=(\d{3})+$)/g,",")}function Pe(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:e>=1e3?`${+(e/1e3).toFixed(1)} kb`:`${e} bp`}function Ae(e){return`${Pe(e)} del`}function Lt(e,t,n,r){let s=e[0],o=e[e.length-1],a=(t.x-(s.x0+o.x1)/2)*n,c=(t.y-(s.y0+o.y1)/2)*r,i=Math.hypot(a,c);return i===0?{x:0,y:-1}:{x:a/i,y:c/i}}function St(e,t){return Math.abs(t.x)*(e.x1-e.x0)/2+Math.abs(t.y)*(e.y1-e.y0)/2}function Mt(e,t){let n=(e.x1-e.x0)/2,r=(e.y1-e.y0)/2;return Math.min(t.x===0?1/0:n/Math.abs(t.x),t.y===0?1/0:r/Math.abs(t.y))}function Et(e,t,n){let r=0;for(let s=1;s<e.length;s++){let o=e[s-1],a=e[s];r+=Math.hypot((a.x-o.x)*t,(a.y-o.y)*n)}return r}function At(e,t){let n=1/0,r=1/0,s=-1/0,o=-1/0;for(let a of e)for(let c of t[a]??[])n=Math.min(n,c.x),s=Math.max(s,c.x),r=Math.min(r,c.y),o=Math.max(o,c.y);return n===1/0?void 0:{minX:n,minY:r,maxX:s,maxY:o}}var _e=new WeakMap;function _t(e,t){let n=_e.get(e);if(n?.nodeLengths===t)return n.order;let r=Object.entries(e).filter(([s,o])=>o.length>0&&t.has(s)).sort(([s],[o])=>t.get(o)-t.get(s));return _e.set(e,{nodeLengths:t,order:r}),r}var Be=new WeakMap;function Bt(e,t,n,r,s){let{scaleX:o,scaleY:a}=n,c=Be.get(e);if(c?.deletions===t&&c.routes===s&&c.scaleX===o&&c.scaleY===a&&c.version===r)return c.arcs;let i=[];for(let u of[...t].sort((l,h)=>h.bp-l.bp)){let l=Ne(e,u,n,s?.[u.edgeIndex]),h=l?xe(l):void 0;if(l&&h){let{minX:p,minY:d,maxX:m,maxY:f}=ye(l);i.push({deletion:u,curves:l,apex:h,extent:Math.max((m-p)*o,(f-d)*a)})}}return Be.set(e,{deletions:t,routes:s,scaleX:o,scaleY:a,version:r,arcs:i}),i}function Sn({nodePositions:e,nodeLengths:t,deletions:n,deletionRoutes:r,alleleDeletions:s,axis:o,translateX:a,translateY:c,width:i,height:u,version:l=0}){let{scaleX:h,scaleY:p}=o,d=[],m=[];for(let{deletion:x,curves:y,apex:N,extent:E}of Bt(e,n,o,l,r))if(E>=pt){let L=Ae(x.bp),g=W(L),A=F(g,0,0),M=N.x*h+a,S=N.y*p+c,w=E>=g*2/z,B=Lt(y,N,h,p),O=St(A,B)+xt,P=w?M:$(M+B.x*O,g,i-g),_=w?S:$(S+B.y*O,I,u-I),C=Math.hypot(P-M,_-S),R;if(C>0){let G={x:(P-M)/C,y:(_-S)/C},H=Mt(A,G);R={arcX:M,arcY:S,labelX:P-G.x*H,labelY:_-G.y*H}}d.push({label:{key:`del:${x.edgeIndex}`,text:L,x:P,y:_,kind:"deletion",leader:R},box:F(g,P,_)})}let f=new Set,b=[...s??[]].sort((x,y)=>y.bp-x.bp);for(let x of b){let y=At(x.nodeIds,e);if(!y)continue;let N=Math.max(y.minX*h+a,0),E=Math.min(y.maxX*h+a,i),L=Math.max(y.minY*p+c,0),g=Math.min(y.maxY*p+c,u);if(E<N||g<L)continue;let A=Math.max(E-N,g-L),M=Ae(x.bp),S=W(M);if(A>=S*2/z){for(let O of x.nodeIds)f.add(O);let w=$((N+E)/2,S,i-S),B=$((L+g)/2,I,u-I);d.push({label:{key:`alleledel:${x.nodeIds.join(",")}`,text:M,x:w,y:B,kind:"deletion"},box:F(S,w,B)})}}for(let[x,y]of _t(e,t)){if(f.has(x))continue;let{x:N,y:E}=Se(y),L=E*p+c;if(L+I<=0||L-I>=u)continue;let g=Et(y,h,p);if(g<Nt*2/z)continue;let A=Pe(t.get(x)),M=W(A);if(g>=M*2/z){let S=N*h+a;m.push({label:{key:`node:${x}`,text:A,x:S,y:L,kind:"node"},box:F(M,S,L)})}}return{deletions:d,nodes:m}}function Mn(e,t){return Math.max(ht,Math.floor(e*t/ft))}function En(e,t,n=1/0){let r=[];for(let{label:s,box:o}of e){if(r.length>=n)break;t(o)&&r.push(s)}return r}var Pt=/:(\d+)-\d+$/;function Y(e){let t=Pt.exec(e);return t?{name:e.slice(0,t.index),start:+t[1]}:{name:e,start:0}}function wn(e,t){let n=[],r=new Map;for(let s of e){let o=ae(s.name),a=s.start;for(let c of s.steps){let i={path:s.name,sample:o,start:a,strand:c.strand},u=r.get(c.id);u?u.push(i):r.set(c.id,[i]),a+=t(c.id)}n.push({name:s.name,sample:o,start:s.start,length:a-s.start})}return{anchorPaths:n,pathVisits:r}}function Gt(e,t){return e.find(r=>r.sample===t||r.name===t)??e[0]}var Ot=1;function Ct(e,t,n){let r=e;if(t&&t.length>0){let s=t.find(o=>o.path===n)??t[0];r={...e,stable:{refName:s.path,start:s.start,rank:s.path===n?0:Ot,strand:s.strand},samples:[...new Set(t.map(o=>o.sample))].sort()}}return r}function Rt(e,t){let{anchorPaths:n,pathVisits:r}=e,s=n&&r?Gt(n,t):void 0;return s&&r?{...e,nodes:e.nodes.map(o=>Ct(o,r.get(o.name),s.name)),anchoredBy:"paths",referencePath:s.name}:e}function Pn(e,t){return e.anchoredBy==="tags"?e:Rt(e,t)}function Gn(e,t){if(!e.anchorPaths)return;let n=new Map(e.nodes.map(o=>[o.id,o.length])),r=(o,a=o.length)=>{let c=0;for(let i=0;i<a;i++)c+=n.get(o[i])??0;return c},s=new Map;for(let o of e.paths??[]){let a=Y(o.name).name;s.set(a,[...s.get(a)??[],o])}return e.anchorPaths.map(o=>{let a=s.get(o.name),c=a?.length===1?a[0]:void 0,i=c&&t.get(c.name);return c&&i?{...o,start:o.start+r(c.nodeIds,i.first),length:r(i.nodeIds)}:o})}function vn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Math.abs(t%360)}function It(e,t){return e*360/t}var vt=.7,Tt=.5,Dt=16;function Tn(e){return e>0&&e<=Dt}function Ht(e,t){return`hsl(${It(e,t)}, ${vt*100}%, ${Tt*100}%)`}function Dn(e,t){return`hsl(0, 0%, ${t>1?25+45*e/(t-1):45}%)`}function Xt(e){let t=Y(e).name.split("#"),n=t.join("#");if(t.length>=3&&ce(t[0])){let r=t.slice(2).join("#");return[r,r,n]}return[t[0],t.slice(0,2).join("#"),n]}function kt(e,t){let{start:n}=Y(e);return t.map(r=>`${r} @${we(n)}`)}function Hn(e,t){let n=new Map;e.forEach((i,u)=>{n.has(i.name)||n.set(i.name,u)});let r=[...n].map(([i,u])=>({name:i,i:u})),s=r.map(i=>Xt(i.name)),o=[0,1,2].flatMap(i=>[r.map((u,l)=>s[l][i]),r.map((u,l)=>kt(u.name,s[l])[i])]),c=o.find(i=>new Set(i).size===r.length)??o.at(-1);return r.map(({name:i,i:u},l)=>({name:i,label:c[l],color:t?.[u]??Ht(u,e.length)}))}function zt(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function Oe(e,t=5){let r=e.nodes.reduce((o,a)=>o+a.length,0)/1e6,s=Math.max(e.nodes.length*40,500);return{nodeLengthPerMegabase:r>0?s/r:1e4,minimumNodeLength:Math.max(5,t),edgeLength:5,nodeSegmentLength:20}}var D={power:1,effect:1};function Ce(e){return e.power===1&&e.effect===1}function Re(e,t){let n=e.nodes.length,r=e.nodes.reduce((a,c)=>a+c.length,0),s=n>0?r/n:0,o=n>0?Math.max(n*40,500)/n:40;return a=>{if(s<=0)return o;let c=(a/s)**t.power;return Math.max(o*((c-1)*t.effect+1),5)}}var Ge=1e3,Ie={law:D,minNodeLength:0};function kn(e,t=Ie){let{law:n,minNodeLength:r}=t,s=Oe(e,r);if(Ce(n))return{nodes:e.nodes,opts:s};let o=Re(e,n);return{nodes:e.nodes.map(a=>({...a,length:Math.round(o(a.length)*Ge)})),opts:{...s,nodeLengthPerMegabase:1e6/Ge,minimumNodeLength:5}}}function zn(e,t=Ie){if(Ce(t.law)){let n=Oe(e,t.minNodeLength);return r=>zt(n,r)}return Re(e,t.law)}var ve=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:D,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:D,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:D,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],Wn=ve.map(e=>e.value);function Yn(e){let t=ve.find(n=>n.value===e);return{law:t?.law??D,minNodeLength:(t?.minNodeFactor??0)*40}}var $t=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node Length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],jn=$t.map(e=>e.value);function Vn(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}var Wt=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],Kn=Wt.map(e=>e.value),Yt=.3,Te=3;function Ut(e){let t=0,n=0;for(let r of e.nodes)t+=r.depth*r.length,n+=r.length;return n>0?t/n:0}function jt(e,t){return!(t>0)||!(e.depth>0)?1:Math.min(Te,Math.max(Yt,Math.sqrt(e.depth/t)))}function Vt(e,t,n,r){return t*(n==="depth"?jt(e,r):1)}function qt(e,t){return e*(t==="depth"?Te:1)}function Jn(e,t,n,r){let s=e?Ut(e):0;return{maxHalfWidthPx:qt(n,r)/2,halfWidthPx:o=>{let a=t?.get(o);return a?Vt(a,n,r,s)/2:n/2}}}export{Y as a,wn as b,Gt as c,Rt as d,Pn as e,Gn as f,Zt as g,ye as h,en as i,tn as j,be as k,nn as l,on as m,q as n,ge as o,rt as p,cn as q,mn as r,ln as s,pn as t,lt as u,hn as v,Ln as w,we as x,Pe as y,Sn as z,Mn as A,En as B,vn as C,It as D,vt as E,Tt as F,Dt as G,Tn as H,Ht as I,Dn as J,Hn as K,zt as L,kn as M,zn as N,ve as O,Wn as P,Yn as Q,$t as R,jn as S,Vn as T,Wt as U,Kn as V,Ut as W,Vt as X,Jn as Y,Kt as Z};
2
- //# sourceMappingURL=chunk-UTWFU4X6.js.map
1
+ import{b as v,g as ie}from"./chunk-7BKUWQE5.js";import{a as ae,b as ce}from"./chunk-KULNKXPT.js";import{a as ze}from"./chunk-FY3BTKY4.js";var Kt=ze((Zn,De)=>{De.exports=JBrowseExports["tss-react/mui"]});function Zt(e){let t=n=>Math.round(n*100)/100;return e.map((n,r)=>`${r?"L":"M"}${t(n.x)},${t(n.y)}`).join("")}function ue(e,t,n,r,s){let o=Math.hypot(r-t,n-e);if(o===0)return[n,r];let a=(n-e)/o,c=(r-t)/o;return[n+s*a,r+s*c]}function V(e,t){let n=1-t,r=n*n*n,s=3*n*n*t,o=3*n*t*t,a=t*t*t;return{x:r*e.x0+s*e.cx0+o*e.cx1+a*e.x1,y:r*e.y0+s*e.cy0+o*e.cy1+a*e.y1}}function xe(e){let t=e[Math.floor(e.length/2)];return t?V(t,.5):void 0}function ye(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(let o of e)t=Math.min(t,o.x0,o.cx0,o.cx1,o.x1),r=Math.max(r,o.x0,o.cx0,o.cx1,o.x1),n=Math.min(n,o.y0,o.cy0,o.cy1,o.y1),s=Math.max(s,o.y0,o.cy0,o.cy1,o.y1);return{minX:t,minY:n,maxX:r,maxY:s}}function $e(e,t,n){let r=V(e,t),s=V(e,n),o=(n-t)/3,a=de(e,t),c=de(e,n);return{x0:r.x,y0:r.y,cx0:r.x+a.x*o,cy0:r.y+a.y*o,cx1:s.x-c.x*o,cy1:s.y-c.y*o,x1:s.x,y1:s.y}}function de(e,t){let n=1-t,r=3*n*n,s=6*n*t,o=3*t*t;return{x:r*(e.cx0-e.x0)+s*(e.cx1-e.cx0)+o*(e.x1-e.cx1),y:r*(e.cy0-e.y0)+s*(e.cy1-e.cy0)+o*(e.y1-e.cy1)}}function en(e,t){let n=e.map(a=>Math.hypot(a.cx0-a.x0,a.cy0-a.y0)+Math.hypot(a.cx1-a.cx0,a.cy1-a.cy0)+Math.hypot(a.x1-a.cx1,a.y1-a.cy1)),r=n.reduce((a,c)=>a+c,0),s=Math.max(3,Math.round(r/t)|1),o=[];for(let a=0;a<s;a+=2){let c=a/s*r,i=(a+1)/s*r,u=[],l=0;e.forEach((h,p)=>{let d=n[p],m=l+d;d>0&&m>c&&l<i&&u.push($e(h,Math.max(0,(c-l)/d),Math.min(1,(i-l)/d))),l=m}),u.length&&o.push(u)}return o}function tn(e,t,n){let r=new Array(e.length);for(let s=0;s<e.length;s++){let o=e[s];r[s]={x0:o.x0+t,y0:o.y0+n,cx0:o.cx0+t,cy0:o.cy0+n,cx1:o.cx1+t,cy1:o.cy1+n,x1:o.x1+t,y1:o.y1+n}}return r}function X(e,t){let n=e.length-1;return t==="end"?{at:e[n],inward:e[n-1]}:{at:e[0],inward:e[1]}}var We=.5,Ye=80;function me(e){let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.x),n=Math.max(n,r.x);return{min:t,max:n}}function le(e,t){return Math.max(0,t.min-e,e-t.max)}function pe(e,t,n){let r=le(e[0].x,t),s=le(e[e.length-1].x,t);return r===s?n:r<s?"start":"end"}function Ue(e,t){return{from:pe(e,me(t),"end"),to:pe(t,me(e),"start")}}var je=.75,Ve=1.15,qe=.35,Ke=60;function Je(e,t,n,r,s,o){let a=Math.hypot(n-e,r-t),c=a===0?1:(n-e)/a,i=a===0?0:(r-t)/a,u=0,l=1/0,h=-1/0;for(let f of s){let b=f.x-e,x=f.y-t,y=b*-i+x*c;Math.abs(y)>Math.abs(u)&&(u=y);let N=b*c+x*i;l=Math.min(l,N),h=Math.max(h,N)}let p=s.length?h-l:0,d=Math.max(Math.abs(u)*Ve/je,p*qe),m=o===void 0?d:Math.min(d,o);return u<0?-m:m}function be({scaleX:e,scaleY:t}){return t/e}var Qe=3;function U(e,t,n){let r=t.x-e.x,s=(t.y-e.y)*n,o=Math.hypot(r,s);return o===0?void 0:{x:r/o,y:s/o}}function nn(e,t,n,r,s=Qe){let o=be(r),a=U(e[e.length-1],t[0],o)??U(e[0],e.at(-1),o)??U(t[0],t.at(-1),o)??{x:1,y:0},c=[];for(let i=0;i<n;i++){let u=(i-(n-1)/2)*s;c.push({x:-a.y*u,y:a.x*u/o})}return c}function j(e,t){return e.map(n=>({x:n.x,y:n.y*t}))}function Ze(e,t){for(let n of e)n.y0/=t,n.cy0/=t,n.cy1/=t,n.y1/=t;return e}var et=12,tt=40;function fe(e,t){let n=0;for(let o=1;o<e.length;o++)n+=Math.hypot(e[o].x-e[o-1].x,e[o].y-e[o-1].y);let r=n*t;return Math.min(tt,Math.max(et,r/2))/Math.max(t,Number.EPSILON)}function on(e){return e.from!==e.to?!1:e.fromStrand&&e.toStrand&&e.fromStrand!==e.toStrand?e.fromStrand==="+"?"end":"start":!0}function nt(e,t,n,r){let{at:s,inward:o}=e,a=o?s.x-o.x:1,c=o?s.y-o.y:0,i=Math.hypot(a,c)||1,u=a/i,l=c/i,h=s.x+n,p=s.y+r,d=h+u*t/3,m=p+l*t/3,f=h+u*t,b=p+l*t,x=-l*t/2,y=u*t/2;return[{x0:h,y0:p,cx0:d,cy0:m,cx1:f+x,cy1:b+y,x1:f,y1:b},{x0:f,y0:b,cx0:f-x,cy0:b-y,cx1:d,cy1:m,x1:h,y1:p}]}function q(e,t,n,r,s,o,a=[],c){let i=o.scaleX,u=be(o),l=c??(o.pixelRows?Ke:void 0);if(u!==1)return Ze(q(j(e,u),j(t,u),n,r,s*u,{scaleX:i,scaleY:i},j(a,u),l===void 0?void 0:l*u),u);if(typeof n=="string")return nt(X(e,n),fe(e,i),r,s);let h=n?{from:"end",to:"start"}:Ue(e,t),p=X(e,h.from),d=X(t,h.to),m=p.at,f=d.at,b=m.x+r,x=m.y+s,y=f.x+r,N=f.y+s;if(n){let E=1,L=0;if(p.inward){let C=m.x-p.inward.x,R=m.y-p.inward.y,G=Math.hypot(C,R);G>0&&(E=C/G,L=R/G)}let g=fe(e,i),A=-L,M=E,S=(m.x+f.x)/2+r+A*g,w=(m.y+f.y)/2+s+M*g,B=b+E*g,O=x+L*g,P=y-E*g,_=N-L*g;return[{x0:b,y0:x,cx0:B,cy0:O,cx1:B+A*g,cy1:O+M*g,x1:S,y1:w},{x0:S,y0:w,cx0:P+A*g,cy0:_+M*g,cx1:P,cy1:_,x1:y,y1:N}]}else{let E=p.inward??{x:m.x-(f.x-m.x),y:m.y-(f.y-m.y)},L=d.inward??{x:f.x-(m.x-f.x),y:f.y-(m.y-f.y)},g=Math.hypot(y-b,N-x),A=(te,ne,He,Xe)=>{let oe=ne.x-te.x,re=ne.y-te.y,se=Math.hypot(oe,re),ke=se===0?0:(He*oe+Xe*re)/se;return Math.max(0,Math.min(g*We,Ye,ke*.5))},M=f.x-m.x,S=f.y-m.y,[w,B]=ue(E.x,E.y,m.x,m.y,A(E,m,M,S)),[O,P]=ue(L.x,L.y,f.x,f.y,A(L,f,-M,-S)),_=a.length?Je(b,x,y,N,a,l):0,C=g===0?1:g,R=(y-b)/C,G=(N-x)/C,H=-G*_,Q=R*_,Z=R*Math.abs(_),ee=G*Math.abs(_);return[{x0:b,y0:x,cx0:w+r+H-Z,cy0:B+s+Q-ee,cx1:O+r+H+Z,cy1:P+s+Q+ee,x1:y,y1:N}]}}function he(e,t){let n=e[0],r=e.at(-1);return Math.hypot(n.x-t.x,n.y-t.y)<Math.hypot(r.x-t.x,r.y-t.y)?"start":"end"}function ge(e,t,n){let r=X(e,he(e,n[0])),s=X(t,he(t,n.at(-1))),o=[r.at,...n,s.at],a=i=>{let u=o[i],l=p=>Math.hypot(p.x-u.x,p.y-u.y),h=(p,d)=>{let m=p?l(p):0,f=l(d);return m===0?{x:d.x-u.x,y:d.y-u.y}:{x:(u.x-p.x)/m*f,y:(u.y-p.y)/m*f}};if(i===0)return h(r.inward,o[1]);if(i===o.length-1){let p=h(s.inward,o[i-1]);return{x:-p.x,y:-p.y}}return{x:(o[i+1].x-o[i-1].x)/2,y:(o[i+1].y-o[i-1].y)/2}},c=[];for(let i=0;i<o.length-1;i++){let u=o[i],l=o[i+1],h=a(i),p=a(i+1);c.push({x0:u.x,y0:u.y,cx0:u.x+h.x/3,cy0:u.y+h.y/3,cx1:l.x-p.x/3,cy1:l.y-p.y/3,x1:l.x,y1:l.y})}return c}var ot=1;function rt(e,t){return t.flatMap(n=>e[n]??[])}function Ne(e,t,n,r){let s=e[t.from],o=e[t.to];if(!(!s?.length||!o?.length))return r?ge(s,o,r):q(s,o,t.from===t.to,0,0,n,rt(e,t.bypassed))}function st(e){let t=new Map;for(let n of e.nodes)if(v(n)){let r=t.get(n.stable.refName);r?r.push(n):t.set(n.stable.refName,[n])}for(let n of t.values())n.sort((r,s)=>r.stable.start-s.stable.start);return t}function at(e,t,n){let r=[];if(e)for(let s=ie(e,t);s<e.length;s++){let o=e[s];if(o.stable.start>=n)break;o.stable.start+o.length<=n&&r.push(o.id)}return r}function ct(e,t,n,r){let{fromStrand:s,toStrand:o}=e;if(s===void 0||o===void 0)return!0;let a=s===(t.stable.strand??"+"),c=o===(n.stable.strand??"+");return r?a&&c:!a&&!c}function cn(e){let t=new Map(e.nodes.map(s=>[s.id,s])),n=st(e),r=[];for(let s=0;s<e.edges.length;s++){let o=e.edges[s],a=t.get(o.from),c=t.get(o.to);if(a!==void 0&&c!==void 0&&v(a)&&v(c)&&a.stable.refName===c.stable.refName){let i=a.stable.start<=c.stable.start,[u,l]=i?[a,c]:[c,a],h=u.stable.start+u.length,p=l.stable.start,d=p-h;if(d>=ot&&ct(o,a,c,i)){let m=u.stable.refName;r.push({edgeIndex:s,from:o.from,to:o.to,refName:m,start:h,end:p,bp:d,bypassed:at(n.get(m),h,p)})}}}return r}function T(e){return e.endsWith("-")?"-":"+"}function Le(e){return e==="+"?"-":"+"}function it(e){let t=(e.fromStrand??T(e.from))===T(e.from)?"end":"start",n=(e.toStrand??T(e.to))===T(e.to)?"start":"end";return{from:t,to:n}}function mn(e,t=new Set){let n=e.edges.map(it),r=new Map,s=(d,m,f)=>{let b=`${d}|${m}`,x=r.get(b);x?x.push(f):r.set(b,[f])};e.edges.forEach((d,m)=>{s(d.from,n[m].from,m),s(d.to,n[m].to,m)});let o=d=>{let m=r.get(`${d}|end`);if(m?.length!==1)return;let f=m[0],b=e.edges[f];return b.from===d&&b.to!==d&&!t.has(d)&&!t.has(b.to)&&n[f].from==="end"&&n[f].to==="start"&&r.get(`${b.to}|start`)?.length===1?f:void 0},a=new Set,c=new Map,i=new Map;for(let d of e.nodes){let m=r.get(`${d.id}|start`),f=m?.length===1?e.edges[m[0]].from:void 0;if(c.has(d.id)||f!==void 0&&o(f)===m[0])continue;let b=[d.id];for(;;){let x=o(b.at(-1)),y=x===void 0?void 0:e.edges[x].to;if(y===void 0||c.has(y))break;a.add(x),b.push(y)}for(let x of b)c.set(x,d.id);b.length>1&&i.set(d.id,b)}for(let d of e.nodes)c.has(d.id)||c.set(d.id,d.id);let u=new Map(e.nodes.map(d=>[d.id,d])),l=[];for(let d of e.nodes){if(c.get(d.id)!==d.id)continue;let m=i.get(d.id);if(!m){l.push(d);continue}let f=m.map(y=>u.get(y)),b=f.filter(v),x=b.length?b.reduce((y,N)=>y.stable.start<=N.stable.start?y:N):f[0];l.push({id:d.id,name:d.name,length:f.reduce((y,N)=>y+N.length,0),depth:d.depth,stable:x.stable})}let h=new Set,p=[];return e.edges.forEach((d,m)=>{let f=c.get(d.from),b=c.get(d.to),x=n[m],y=`${f}|${x.from}>${b}|${x.to}`;a.has(m)||h.has(y)||(h.add(y),p.push({from:f,to:b,...x.from==="start"?{fromStrand:Le(T(f))}:{},...x.to==="end"?{toStrand:Le(T(b))}:{}}))}),{graph:{...e,nodes:l,edges:p,paths:void 0,pathVisits:void 0},runs:i}}function ln(e,t,n){let r={...e};for(let[s,o]of t){let a=e[s];if(!a?.length)continue;delete r[s];let c=J(a),i=c.at(-1),u=o.map(p=>Math.max(n(p),0)),l=u.reduce((p,d)=>p+d,0)||o.length,h=0;o.forEach((p,d)=>{let m=l?u[d]/l*i:i/o.length,f=d===o.length-1?i:h+m;r[p]=Me(a,c,h,f),h=f})}return r}function pn(e,t,n){if(e.length===0)return[];let r=J(e),s=r.at(-1);return Me(e,r,t*s,n*s)}function Se(e){let t=J(e);return K(e,t,t.at(-1)/2)}function J(e){let t=[0];for(let n=1;n<e.length;n++)t.push(t[n-1]+Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y));return t}function K(e,t,n){if(n<=0)return{...e[0]};let r=1;for(;r<t.length&&t[r]<n;)r++;if(r>=t.length)return{...e.at(-1)};let s=t[r]-t[r-1],o=s>0?(n-t[r-1])/s:0,a=e[r-1],c=e[r];return{x:a.x+(c.x-a.x)*o,y:a.y+(c.y-a.y)*o}}function Me(e,t,n,r){let s=[K(e,t,n)];for(let o=0;o<e.length;o++)t[o]>n&&t[o]<r&&s.push({...e[o]});return s.push(K(e,t,r)),s}function ut(e){return e.length*6.2+8}function dt(e,t){return e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0}function Ee(e,t){return e.x1<=0||e.x0>=t.width||e.y1<=0||e.y0>=t.height}function mt(e,t){return e.x0>=0&&e.x1<=t.width&&e.y0>=0&&e.y1<=t.height}function lt(e,t=[]){let n=[...t];return r=>Ee(r,e)||n.some(s=>dt(s,r))?!1:(n.push(r),!0)}function hn(e,t,n){let r=[],o=(a,c)=>{let i=ut(c),u=a.y>t.height/2?-1:1;for(let l=0;l<=(a.stack??0);l++){let h=a.y+u*l*19,p={x0:a.x-i/2,x1:a.x+i/2,y0:h-11-4,y1:h+4};if(Ee(p,t))return;if(mt(p,t)&&n(p))return{...a,text:c,y:h,w:i}}};for(let a of e){let c=o(a,a.text)??(a.fallback===void 0?void 0:o(a,a.fallback));c&&r.push(c)}return r}var pt=26,ft=4e4,ht=8,xt=8,yt=5.7,bt=6,gt=13,k=3,z=2;function W(e){return(e.length*yt+bt+k)/2}var I=(gt+k)/2,Nt=W("1 bp");function F(e,t,n){return{x0:t-e,x1:t+e,y0:n-I,y1:n+I}}function Ln(e,t){return{x0:6,x1:6+e.length*6.2+8+k,y0:t-8-k/2,y1:t+8+k/2}}function $(e,t,n){return n<t?e:Math.min(Math.max(e,t),n)}function we(e){return String(e).replace(/\B(?=(\d{3})+$)/g,",")}function Pe(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:e>=1e3?`${+(e/1e3).toFixed(1)} kb`:`${e} bp`}function Ae(e){return`${Pe(e)} del`}function Lt(e,t,n,r){let s=e[0],o=e[e.length-1],a=(t.x-(s.x0+o.x1)/2)*n,c=(t.y-(s.y0+o.y1)/2)*r,i=Math.hypot(a,c);return i===0?{x:0,y:-1}:{x:a/i,y:c/i}}function St(e,t){return Math.abs(t.x)*(e.x1-e.x0)/2+Math.abs(t.y)*(e.y1-e.y0)/2}function Mt(e,t){let n=(e.x1-e.x0)/2,r=(e.y1-e.y0)/2;return Math.min(t.x===0?1/0:n/Math.abs(t.x),t.y===0?1/0:r/Math.abs(t.y))}function Et(e,t,n){let r=0;for(let s=1;s<e.length;s++){let o=e[s-1],a=e[s];r+=Math.hypot((a.x-o.x)*t,(a.y-o.y)*n)}return r}function At(e,t){let n=1/0,r=1/0,s=-1/0,o=-1/0;for(let a of e)for(let c of t[a]??[])n=Math.min(n,c.x),s=Math.max(s,c.x),r=Math.min(r,c.y),o=Math.max(o,c.y);return n===1/0?void 0:{minX:n,minY:r,maxX:s,maxY:o}}var _e=new WeakMap;function _t(e,t){let n=_e.get(e);if(n?.nodeLengths===t)return n.order;let r=Object.entries(e).filter(([s,o])=>o.length>0&&t.has(s)).sort(([s],[o])=>t.get(o)-t.get(s));return _e.set(e,{nodeLengths:t,order:r}),r}var Be=new WeakMap;function Bt(e,t,n,r,s){let{scaleX:o,scaleY:a}=n,c=Be.get(e);if(c?.deletions===t&&c.routes===s&&c.scaleX===o&&c.scaleY===a&&c.version===r)return c.arcs;let i=[];for(let u of[...t].sort((l,h)=>h.bp-l.bp)){let l=Ne(e,u,n,s?.[u.edgeIndex]),h=l?xe(l):void 0;if(l&&h){let{minX:p,minY:d,maxX:m,maxY:f}=ye(l);i.push({deletion:u,curves:l,apex:h,extent:Math.max((m-p)*o,(f-d)*a)})}}return Be.set(e,{deletions:t,routes:s,scaleX:o,scaleY:a,version:r,arcs:i}),i}function Sn({nodePositions:e,nodeLengths:t,deletions:n,deletionRoutes:r,alleleDeletions:s,axis:o,translateX:a,translateY:c,width:i,height:u,version:l=0}){let{scaleX:h,scaleY:p}=o,d=[],m=[];for(let{deletion:x,curves:y,apex:N,extent:E}of Bt(e,n,o,l,r))if(E>=pt){let L=Ae(x.bp),g=W(L),A=F(g,0,0),M=N.x*h+a,S=N.y*p+c,w=E>=g*2/z,B=Lt(y,N,h,p),O=St(A,B)+xt,P=w?M:$(M+B.x*O,g,i-g),_=w?S:$(S+B.y*O,I,u-I),C=Math.hypot(P-M,_-S),R;if(C>0){let G={x:(P-M)/C,y:(_-S)/C},H=Mt(A,G);R={arcX:M,arcY:S,labelX:P-G.x*H,labelY:_-G.y*H}}d.push({label:{key:`del:${x.edgeIndex}`,text:L,x:P,y:_,kind:"deletion",leader:R},box:F(g,P,_)})}let f=new Set,b=[...s??[]].sort((x,y)=>y.bp-x.bp);for(let x of b){let y=At(x.nodeIds,e);if(!y)continue;let N=Math.max(y.minX*h+a,0),E=Math.min(y.maxX*h+a,i),L=Math.max(y.minY*p+c,0),g=Math.min(y.maxY*p+c,u);if(E<N||g<L)continue;let A=Math.max(E-N,g-L),M=Ae(x.bp),S=W(M);if(A>=S*2/z){for(let O of x.nodeIds)f.add(O);let w=$((N+E)/2,S,i-S),B=$((L+g)/2,I,u-I);d.push({label:{key:`alleledel:${x.nodeIds.join(",")}`,text:M,x:w,y:B,kind:"deletion"},box:F(S,w,B)})}}for(let[x,y]of _t(e,t)){if(f.has(x))continue;let{x:N,y:E}=Se(y),L=E*p+c;if(L+I<=0||L-I>=u)continue;let g=Et(y,h,p);if(g<Nt*2/z)continue;let A=Pe(t.get(x)),M=W(A);if(g>=M*2/z){let S=N*h+a;m.push({label:{key:`node:${x}`,text:A,x:S,y:L,kind:"node"},box:F(M,S,L)})}}return{deletions:d,nodes:m}}function Mn(e,t){return Math.max(ht,Math.floor(e*t/ft))}function En(e,t,n=1/0){let r=[];for(let{label:s,box:o}of e){if(r.length>=n)break;t(o)&&r.push(s)}return r}var Pt=/:(\d+)-\d+$/;function Y(e){let t=Pt.exec(e);return t?{name:e.slice(0,t.index),start:+t[1]}:{name:e,start:0}}function wn(e,t){let n=[],r=new Map;for(let s of e){let o=ae(s.name),a=s.start;for(let c of s.steps){let i={path:s.name,sample:o,start:a,strand:c.strand},u=r.get(c.id);u?u.push(i):r.set(c.id,[i]),a+=t(c.id)}n.push({name:s.name,sample:o,start:s.start,length:a-s.start})}return{anchorPaths:n,pathVisits:r}}function Gt(e,t){return e.find(r=>r.sample===t||r.name===t)??e[0]}var Ot=1;function Ct(e,t,n){let r=e;if(t&&t.length>0){let s=t.find(o=>o.path===n)??t[0];r={...e,stable:{refName:s.path,start:s.start,rank:s.path===n?0:Ot,strand:s.strand},samples:[...new Set(t.map(o=>o.sample))].sort()}}return r}function Rt(e,t){let{anchorPaths:n,pathVisits:r}=e,s=n&&r?Gt(n,t):void 0;return s&&r?{...e,nodes:e.nodes.map(o=>Ct(o,r.get(o.name),s.name)),anchoredBy:"paths",referencePath:s.name}:e}function Pn(e,t){return e.anchoredBy==="tags"?e:Rt(e,t)}function Gn(e,t){if(!e.anchorPaths)return;let n=new Map(e.nodes.map(o=>[o.id,o.length])),r=(o,a=o.length)=>{let c=0;for(let i=0;i<a;i++)c+=n.get(o[i])??0;return c},s=new Map;for(let o of e.paths??[]){let a=Y(o.name).name;s.set(a,[...s.get(a)??[],o])}return e.anchorPaths.map(o=>{let a=s.get(o.name),c=a?.length===1?a[0]:void 0,i=c&&t.get(c.name);return c&&i?{...o,start:o.start+r(c.nodeIds,i.first),length:r(i.nodeIds)}:o})}function vn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Math.abs(t%360)}function It(e,t){return e*360/t}var vt=.7,Tt=.5,Dt=16;function Tn(e){return e>0&&e<=Dt}function Ht(e,t){return`hsl(${It(e,t)}, ${vt*100}%, ${Tt*100}%)`}function Dn(e,t){return`hsl(0, 0%, ${t>1?25+45*e/(t-1):45}%)`}function Xt(e){let t=Y(e).name.split("#"),n=t.join("#");if(t.length>=3&&ce(t[0])){let r=t.slice(2).join("#");return[r,r,n]}return[t[0],t.slice(0,2).join("#"),n]}function kt(e,t){let{start:n}=Y(e);return t.map(r=>`${r} @${we(n)}`)}function Hn(e,t){let n=new Map;e.forEach((i,u)=>{n.has(i.name)||n.set(i.name,u)});let r=[...n].map(([i,u])=>({name:i,i:u})),s=r.map(i=>Xt(i.name)),o=[0,1,2].flatMap(i=>[r.map((u,l)=>s[l][i]),r.map((u,l)=>kt(u.name,s[l])[i])]),c=o.find(i=>new Set(i).size===r.length)??o.at(-1);return r.map(({name:i,i:u},l)=>({name:i,label:c[l],color:t?.[u]??Ht(u,e.length)}))}var zt=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node Length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],kn=zt.map(e=>e.value);function zn(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}var Ft=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],$n=Ft.map(e=>e.value),$t=.3,Ge=3;function Wt(e){let t=0,n=0;for(let r of e.nodes)t+=r.depth*r.length,n+=r.length;return n>0?t/n:0}function Yt(e,t){return!(t>0)||!(e.depth>0)?1:Math.min(Ge,Math.max($t,Math.sqrt(e.depth/t)))}function Ut(e,t,n,r){return t*(n==="depth"?Yt(e,r):1)}function jt(e,t){return e*(t==="depth"?Ge:1)}function Wn(e,t,n,r){let s=e?Wt(e):0;return{maxHalfWidthPx:jt(n,r)/2,halfWidthPx:o=>{let a=t?.get(o);return a?Ut(a,n,r,s)/2:n/2}}}function Vt(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function Ce(e,t=5){let r=e.nodes.reduce((o,a)=>o+a.length,0)/1e6,s=Math.max(e.nodes.length*40,500);return{nodeLengthPerMegabase:r>0?s/r:1e4,minimumNodeLength:Math.max(5,t),edgeLength:5,nodeSegmentLength:20}}var D={power:1,effect:1};function Re(e){return e.power===1&&e.effect===1}function Ie(e,t){let n=e.nodes.length,r=e.nodes.reduce((a,c)=>a+c.length,0),s=n>0?r/n:0,o=n>0?Math.max(n*40,500)/n:40;return a=>{if(s<=0)return o;let c=(a/s)**t.power;return Math.max(o*((c-1)*t.effect+1),5)}}var Oe=1e3,ve={law:D,minNodeLength:0};function Un(e,t=ve){let{law:n,minNodeLength:r}=t,s=Ce(e,r);if(Re(n))return{nodes:e.nodes,opts:s};let o=Ie(e,n);return{nodes:e.nodes.map(a=>({...a,length:Math.round(o(a.length)*Oe)})),opts:{...s,nodeLengthPerMegabase:1e6/Oe,minimumNodeLength:5}}}function jn(e,t=ve){if(Re(t.law)){let n=Ce(e,t.minNodeLength);return r=>Vt(n,r)}return Ie(e,t.law)}var Te=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:D,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:D,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:D,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],Kn=Te.map(e=>e.value);function Jn(e){let t=Te.find(n=>n.value===e);return{law:t?.law??D,minNodeLength:(t?.minNodeFactor??0)*40}}export{Y as a,wn as b,Gt as c,Rt as d,Pn as e,Gn as f,Zt as g,ye as h,en as i,tn as j,be as k,nn as l,on as m,q as n,ge as o,rt as p,cn as q,mn as r,ln as s,pn as t,lt as u,hn as v,Ln as w,we as x,Pe as y,Sn as z,Mn as A,En as B,vn as C,It as D,vt as E,Tt as F,Dt as G,Tn as H,Ht as I,Dn as J,Hn as K,zt as L,kn as M,zn as N,Ft as O,$n as P,Wt as Q,Ut as R,Wn as S,Vt as T,Un as U,jn as V,Te as W,Kn as X,Jn as Y,Kt as Z};
2
+ //# sourceMappingURL=chunk-H54W6OQQ.js.map