jbrowse-plugin-graphgenomeviewer 4.7.0 → 5.0.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.
- package/README.md +7 -1
- package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js +2 -0
- package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js.map +7 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js +4 -0
- package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js.map +7 -0
- package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js → GraphGenomeView-YYP4IFSI.js} +2 -2
- package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js → GraphTrackSettingsDialog-2WPJRAJC.js} +2 -2
- package/dist/chunks/LinearGraphDisplay-7YE624D5.js +2 -0
- package/dist/chunks/LinearGraphDisplay-7YE624D5.js.map +7 -0
- package/dist/chunks/chunk-2H7GDQ3R.js +6 -0
- package/dist/chunks/chunk-2H7GDQ3R.js.map +7 -0
- package/dist/chunks/chunk-BZOIENU5.js +2 -0
- package/dist/chunks/chunk-BZOIENU5.js.map +7 -0
- package/dist/chunks/{chunk-UTWFU4X6.js → chunk-H54W6OQQ.js} +2 -2
- package/dist/chunks/{chunk-UTWFU4X6.js.map → chunk-H54W6OQQ.js.map} +4 -4
- package/dist/chunks/{chunk-F2EPKNTV.js → chunk-O4XV3K35.js} +2 -2
- package/dist/chunks/{chunk-F2EPKNTV.js.map → chunk-O4XV3K35.js.map} +4 -4
- package/dist/chunks/chunk-SJNG2XK7.js +2 -0
- package/dist/chunks/chunk-SJNG2XK7.js.map +7 -0
- package/dist/chunks/chunk-WKVVIDCS.js +3 -0
- package/dist/chunks/{chunk-KCL5TF5X.js.map → chunk-WKVVIDCS.js.map} +3 -3
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
- package/package.json +3 -3
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +36 -2
- package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +67 -1
- package/src/GbzBaseSyntenyAdapter/test_data/fragmented.haplotype-index.db +0 -0
- package/src/GbzBaseSyntenyAdapter/test_data/micb-kir3dl1.haplotype-index.db +0 -0
- package/src/GbzBaseSyntenyAdapter/test_data/micb-kir3dl1.sampled.haplotype-index.db +0 -0
- package/src/GetHaplotypeOverview.ts +77 -0
- package/src/GraphGenomeView/components/ChooseWalksDialog.tsx +86 -0
- package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +205 -187
- package/src/GraphGenomeView/components/TubeMapLegend.test.tsx +29 -0
- package/src/GraphGenomeView/components/TubeMapOverlay.tsx +8 -0
- package/src/GraphGenomeView/host.ts +6 -0
- package/src/GraphGenomeView/model.ts +10 -4224
- package/src/GraphGenomeView/pane/fitViews.ts +589 -0
- package/src/GraphGenomeView/pane/graphViews.ts +829 -0
- package/src/GraphGenomeView/pane/hostViews.ts +193 -0
- package/src/GraphGenomeView/pane/launchActions.ts +407 -0
- package/src/GraphGenomeView/pane/launchViews.ts +191 -0
- package/src/GraphGenomeView/pane/loadActions.ts +701 -0
- package/src/GraphGenomeView/pane/paneBase.ts +479 -0
- package/src/GraphGenomeView/pane/renderingActions.ts +281 -0
- package/src/GraphGenomeView/pane/settingActions.ts +467 -0
- package/src/GraphGenomeView/pane/walkRowViews.ts +205 -0
- package/src/HaplotypeOverview/HaplotypeOverviewCanvas.tsx +203 -0
- package/src/HaplotypeOverview/draw.test.ts +136 -0
- package/src/HaplotypeOverview/draw.ts +433 -0
- package/src/HaplotypeOverview/model.ts +163 -0
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +184 -0
- package/src/LinearGraphDisplay/components/LinearGraphDisplay.tsx +12 -2
- package/src/LinearGraphDisplay/model.ts +107 -3
- package/src/gaf/gafFile.ts +2 -0
- package/src/index.ts +2 -0
- package/src/version.ts +1 -1
- package/dist/chunks/GbzBaseSyntenyAdapter-AZBYMDIW.js +0 -8
- package/dist/chunks/GbzBaseSyntenyAdapter-AZBYMDIW.js.map +0 -7
- package/dist/chunks/LinearGraphDisplay-MJ4ZBJRX.js +0 -2
- package/dist/chunks/LinearGraphDisplay-MJ4ZBJRX.js.map +0 -7
- package/dist/chunks/chunk-BUXVOMDL.js +0 -2
- package/dist/chunks/chunk-BUXVOMDL.js.map +0 -7
- package/dist/chunks/chunk-KCL5TF5X.js +0 -3
- /package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js.map → GraphGenomeView-YYP4IFSI.js.map} +0 -0
- /package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js.map → GraphTrackSettingsDialog-2WPJRAJC.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as w,b as N,c as H,d as R}from"./chunk-2H7GDQ3R.js";function j(e){if(typeof e!="object"||e===null)return!1;let n=e;return typeof n.horizontalScroll=="function"&&typeof n.zoomTo=="function"&&"coarseDynamicBlocks"in n&&"dynamicBlocks"in n}function P(e){return e.reduce((n,t)=>n&&n.end-n.start>=t.end-t.start?n:t,void 0)}function Q(e,n){let t=P(e.dynamicBlocks.contentBlocks.filter(s=>s.refName===n.refName&&s.assemblyName===n.assemblyName)),{bpPerPx:r}=e;if(!t||!(r>0))return;let o=t.offsetPx-e.offsetPx;return t.reversed?{scale:-1/r,translateX:o+t.end/r}:{scale:1/r,translateX:o-t.start/r}}function U(e){let n=P(e.dynamicBlocks.contentBlocks),t=n?.displayedRegionIndex===void 0?void 0:e.displayedRegions[n.displayedRegionIndex];return n&&e.bpPerPx>0?{refName:n.refName,assemblyName:n.assemblyName,start:n.start,end:n.end,bpPerPx:e.bpPerPx,span:e.bpPerPx*e.width,regionStart:t?.start??n.start,regionEnd:t?.end??n.end}:void 0}function C(e,n,t=!0){let r=e.end-e.start,o=t?Math.max(0,Math.min(e.span,(n-r)/2)):0,s=Math.max(e.regionStart,Math.floor(e.start-o)),i=Math.min(e.regionEnd,Math.ceil(e.end+o)),a=i-s-n;return a>0&&(s+=Math.floor(a/2),i-=Math.ceil(a/2)),{refName:e.refName,assemblyName:e.assemblyName,start:s,end:i}}function Y(e,n,t=!0){if(e?.refName!==n.refName||e.assemblyName!==n.assemblyName)return!1;if(t)return e.start<=n.start+1&&n.end<=e.end+1;let r=C(n,1/0,!1);return Math.abs(e.start-r.start)<1&&Math.abs(e.end-r.end)<1}var d={absent:[244,244,244],reference:[200,200,200],partial:[224,204,150],variant:[[132,166,200],[64,116,168],[33,82,132],[14,46,86]]},h=40,L=4,T=3,D=14,I=9,_=16384,B=["absent: no contig covers the bin","reference-like","partial: contigs cover under 90% of the bin","diverges"],$=["1 excursion","2\u20133 excursions","4\u201315 excursions","16+ excursions"],Z="SNPs and indels under 50 bp are not shown";function A(e){let n=e&3;return n===w?d.absent:n===N?d.reference:n===H?d.partial:d.variant[e>>2]}function ee(e){let n=e&3;return n===R?`diverges \u226550 bp, ${$[e>>2]}`:B[n]}function ne(e,n,t){let r=new Set([...e.reference,...e.pinned]),o=e.pinned.filter(f=>!e.reference.includes(f)),s=n?e.rows.flatMap((f,u)=>r.has(u)?[]:[u]):[],i=h+L,a=Math.max(0,t-i),l=o.length>0&&s.length>0?T:0,m=o.length===0?0:Math.min(D,(s.length>0?a*.4:a)/o.length),c=i+o.length*m+l;return{rows:[...o,...s],pinnedCount:o.length,pinnedHeight:m,restHeight:s.length>0?Math.max(0,t-c)/s.length:0,rowsTop:i,restTop:c}}function W(e,n){return n<e.pinnedCount?e.rowsTop+n*e.pinnedHeight:e.restTop+(n-e.pinnedCount)*e.restHeight}function te(e,n){let{pinnedCount:t,pinnedHeight:r,restHeight:o,rowsTop:s,restTop:i}=e,a=s+t*r,l=n>=s&&n<a?Math.floor((n-s)/r):n>=i&&o>0?t+Math.floor((n-i)/o):void 0;return l!==void 0&&l<e.rows.length?e.rows[l]:void 0}function re(e,n){let{bins:t}=e,r=0,o=t.length-1;for(;r<o;){let i=r+o+1>>1;t[i].start<=n?r=i:o=i-1}let s=t[r];return s&&s.start<=n&&n<s.end?r:void 0}function oe(e){let n=e.rows.length,t=new Set(e.reference);return e.bins.map((r,o)=>{let s=[0,0,0,0,0,0];for(let i=0;i<n;i++)if(!t.has(i)){let a=e.cells[o*n+i],l=a&3;l===R?s[2+(a>>2)]+=1:l===w?s[0]+=1:l===H&&(s[1]+=1)}return s})}function se(e,n){let t=e.bins[n],[r,o,s,i]=t.classes;return{span:`${t.start.toLocaleString()}\u2013${t.end.toLocaleString()}`,classes:`${o} reference-like, ${i} diverge \u226550 bp, ${s} partial, ${r} absent`,excursions:`${t.excursions.toLocaleString()} excursions, ${t.variants.toLocaleString()} of 50 bp or more, longest ${t.longestExcursion.toLocaleString()} bp`}}function S(e,n){let t=document.createElement("canvas");return t.width=Math.max(1,e),t.height=Math.max(1,n),t}function F(e){let n=[],t=0;return e.bins.forEach((r,o)=>{o>0&&r.start!==e.bins[o-1].end&&(n.push([t,o]),t=o)}),e.bins.length>0&&n.push([t,e.bins.length]),n}function O(e,n,t,r,o){let s=e.bins.length;if(n.length===0||s===0||r<=0)return;let i=S(s,n.length),a=i.getContext("2d"),l=a.createImageData(s,n.length),m=e.rows.length;n.forEach((g,p)=>{for(let b=0;b<s;b++){let[x,y,k]=A(e.cells[b*m+g]),v=(p*s+b)*4;l.data[v]=x,l.data[v+1]=y,l.data[v+2]=k,l.data[v+3]=255}}),a.putImageData(l,0,0);let c=Math.max(1,Math.round(r*o)),f=S(s,c),u=f.getContext("2d");return u.imageSmoothingEnabled=n.length>c,u.imageSmoothingQuality="high",u.drawImage(i,0,0,s,c),{image:f,top:t,height:r}}function ie(e,n,t){let{rows:r,pinnedCount:o,pinnedHeight:s,restHeight:i}=n;return[O(e,r.slice(0,o),n.rowsTop,o*s,t),O(e,r.slice(o),n.restTop,(r.length-o)*i,t)].filter(a=>a!==void 0)}function M(e,n,t){let r=e.xOf(n),o=e.xOf(t);return{left:Math.min(r,o),width:Math.abs(o-r),reversed:o<r}}function V(e,n,t,r){for(let[o,s]of F(n)){let{left:i,width:a,reversed:l}=M(r,n.bins[o].start,n.bins[s-1].end);if(!(i+a<0||i>r.width)){e.imageSmoothingEnabled=s-o>a*r.dpr;for(let{image:m,top:c,height:f}of t)e.save(),l&&(e.translate(2*i+a,0),e.scale(-1,1)),e.drawImage(m,o,0,s-o,m.height,i,c,a,f),e.restore()}}}function X(e,n,t,r){let o=n.rows.length-n.reference.length,s=Math.max(1,...n.bins.map(a=>a.variants)),i=[[175,175,175],d.partial,...d.variant];n.bins.forEach((a,l)=>{let m=M(r,a.start,a.end),{left:c}=m,f=Math.max(m.width,1/r.dpr);if(!(c+f<0||c>r.width))if(t){let u=h;for(let g of[5,4,3,2,1,0]){let p=h*t[l][g]/Math.max(1,o);if(p>0){let[b,x,y]=i[g];e.fillStyle=`rgb(${b},${x},${y})`,e.fillRect(c,u-p,f,p),u-=p}}}else{let u=h*a.variants/s,[g,p,b]=d.variant[1];e.fillStyle=`rgb(${g},${p},${b})`,e.fillRect(c,h-u,f,u)}})}function z(e,n,t){if(!(t.pinnedHeight<I)){e.font=`${Math.min(11,t.pinnedHeight-2)}px sans-serif`,e.textBaseline="middle";for(let r=0;r<t.pinnedCount;r++){let o=n.rows[t.rows[r]],s=W(t,r),i=e.measureText(o).width;e.fillStyle="rgba(255,255,255,0.8)",e.fillRect(2,s+1,i+6,t.pinnedHeight-2),e.fillStyle="#222",e.fillText(o,5,s+t.pinnedHeight/2)}}}function E(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:`${+(e/1e3).toFixed(1)} kb`}function G(e){let n=e.rows.length-e.reference.length;return e.bin<=_?`haplotypes diverging \u226550 bp, of ${n} \xB7 ${E(e.bin)} bins`:`excursions \u226550 bp per ${E(e.bin)} bin, all ${n} haplotypes`}function K(e,n){let t=G(n);e.font="10px sans-serif",e.textBaseline="top";let r=e.measureText(t).width;e.fillStyle="rgba(255,255,255,0.8)",e.fillRect(2,1,r+6,13),e.fillStyle="#444",e.fillText(t,5,2)}function ae(e,n,t,r,o,s){e.clearRect(0,0,s.width,s.height),X(e,n,t,s),V(e,n,o,s),z(e,n,r),K(e,n)}export{j as a,Q as b,U as c,C as d,Y as e,_ as f,Z as g,ee as h,ne as i,te as j,re as k,oe as l,se as m,ie as n,ae as o};
|
|
2
|
+
//# sourceMappingURL=chunk-BZOIENU5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/GraphGenomeView/host.ts", "../../src/HaplotypeOverview/draw.ts"],
|
|
4
|
+
"sourcesContent": ["import type { SubgraphRegion } from '../GetSubgraph'\n\n// The members of a LinearGenomeView a hosted pane reads and drives.\n// Structural, because this plugin takes no runtime dependency on the LGV\n// plugin (see hoverSync/index.tsx).\nexport interface HostBlock {\n refName: string\n assemblyName: string\n start: number\n end: number\n offsetPx: number\n reversed?: boolean\n displayedRegionIndex?: number\n}\n\nexport interface LinearHost {\n id: string\n initialized: boolean\n bpPerPx: number\n offsetPx: number\n width: number\n displayedRegions: readonly { start: number; end: number }[]\n dynamicBlocks: { contentBlocks: readonly HostBlock[] }\n coarseDynamicBlocks: readonly HostBlock[]\n horizontalScroll: (distance: number) => number\n zoomTo: (bpPerPx: number, offset?: number) => number\n navTo?: (loc: {\n refName: string\n assemblyName: string\n start: number\n end: number\n }) => void\n // whether the view's body is mounted, which an off-screen view's is not\n effectiveBodyMounted?: boolean\n hasVisibleContent?: boolean\n}\n\nexport function isLinearHost(view: unknown): view is LinearHost {\n if (typeof view !== 'object' || view === null) {\n return false\n }\n const v = view as Record<string, unknown>\n return (\n typeof v.horizontalScroll === 'function' &&\n typeof v.zoomTo === 'function' &&\n 'coarseDynamicBlocks' in v &&\n 'dynamicBlocks' in v\n )\n}\n\nfunction widest(blocks: readonly HostBlock[]) {\n return blocks.reduce<HostBlock | undefined>(\n (best, b) => (best && best.end - best.start >= b.end - b.start ? best : b),\n undefined,\n )\n}\n\nexport interface HostWindow {\n refName: string\n assemblyName: string\n start: number\n end: number\n bpPerPx: number\n // the view's width in bp, which the margin is sized by: a block at a contig\n // end is clipped, the zoom is not\n span: number\n regionStart: number\n regionEnd: number\n}\n\n// x is reference bp on an anchored layout, so the graph shows what the linear\n// view shows when one bp is as many px in both and the cut's refName sits at\n// the same screen x. Undefined when the linear view shows no block of that\n// refName, which is a re-cut's job rather than the frame's. A reversed block\n// runs bp right to left, which only the tube map's connectors can draw.\nexport function hostFrame(view: LinearHost, region: SubgraphRegion) {\n const block = widest(\n view.dynamicBlocks.contentBlocks.filter(\n b =>\n b.refName === region.refName && b.assemblyName === region.assemblyName,\n ),\n )\n const { bpPerPx } = view\n if (!block || !(bpPerPx > 0)) {\n return undefined\n }\n const left = block.offsetPx - view.offsetPx\n return block.reversed\n ? { scale: -1 / bpPerPx, translateX: left + block.end / bpPerPx }\n : { scale: 1 / bpPerPx, translateX: left - block.start / bpPerPx }\n}\n\n// Read off the LIVE blocks even when the coarse ones woke the caller: those\n// name where the window was half a second ago (SyntenyFollow/CLAUDE.md).\nexport function hostWindow(view: LinearHost): HostWindow | undefined {\n const block = widest(view.dynamicBlocks.contentBlocks)\n const displayed =\n block?.displayedRegionIndex === undefined\n ? undefined\n : view.displayedRegions[block.displayedRegionIndex]\n return block && view.bpPerPx > 0\n ? {\n refName: block.refName,\n assemblyName: block.assemblyName,\n start: block.start,\n end: block.end,\n bpPerPx: view.bpPerPx,\n span: view.bpPerPx * view.width,\n regionStart: displayed?.start ?? block.start,\n regionEnd: displayed?.end ?? block.end,\n }\n : undefined\n}\n\n// The window plus one window-width each side, clamped to the displayed\n// region, with the margins narrowed until the whole cut fits under `capBp`.\nexport function hostCut(\n window: HostWindow,\n capBp: number,\n margins = true,\n): SubgraphRegion {\n const visible = window.end - window.start\n const margin = margins\n ? Math.max(0, Math.min(window.span, (capBp - visible) / 2))\n : 0\n let start = Math.max(window.regionStart, Math.floor(window.start - margin))\n let end = Math.min(window.regionEnd, Math.ceil(window.end + margin))\n // Rounding outward can put a cut a base or two past the cap, which the load\n // refuses whole; trim it back rather than lose the cut.\n const over = end - start - capBp\n if (over > 0) {\n start += Math.floor(over / 2)\n end -= Math.ceil(over / 2)\n }\n return {\n refName: window.refName,\n assemblyName: window.assemblyName,\n start,\n end,\n }\n}\n\n// With margins, a cut holds while the window is inside it; without, only the\n// window itself does, since the drawing is the window.\nexport function cutHolds(\n cut: SubgraphRegion | undefined,\n window: HostWindow,\n margins = true,\n) {\n if (\n cut?.refName !== window.refName ||\n cut.assemblyName !== window.assemblyName\n ) {\n return false\n }\n // to the base, since a cut trimmed to its cap can end a base inside the window\n if (margins) {\n return cut.start <= window.start + 1 && window.end <= cut.end + 1\n }\n const exact = hostCut(window, Infinity, false)\n return (\n Math.abs(cut.start - exact.start) < 1 && Math.abs(cut.end - exact.end) < 1\n )\n}\n", "import {\n OVERVIEW_ABSENT,\n OVERVIEW_PARTIAL,\n OVERVIEW_REFERENCE,\n OVERVIEW_VARIANT,\n} from '@gmod/gbz-base'\n\nimport type { HaplotypeOverviewData } from '../GetHaplotypeOverview'\n\ntype Rgb = readonly [number, number, number]\n\n// The variant track's colours: reference grey, so the two tracks read alike,\n// and variant cells deepening with how many variant marks the bin holds\nexport const PALETTE = {\n absent: [244, 244, 244],\n reference: [200, 200, 200],\n partial: [224, 204, 150],\n variant: [\n [132, 166, 200],\n [64, 116, 168],\n [33, 82, 132],\n [14, 46, 86],\n ],\n} as const satisfies Record<string, Rgb | readonly Rgb[]>\n\nexport const DENSITY_PX = 40\nconst GAP_PX = 4\nconst PIN_GAP_PX = 3\nconst PIN_ROW_PX = 14\nconst LABEL_MIN_PX = 9\n// Past 16 kb bins nearly every bin holds a 50 bp excursion for most\n// haplotypes, so the density row counts variant excursions instead of\n// haplotypes per class\nexport const FINE_BIN_BP = 16_384\n\n// \"Diverges\" rather than \"variant\": only excursions of 50 bp or more and\n// rearrangements count, so a haplotype full of SNPs is reference-like\nconst CLASS_NAMES = [\n 'absent: no contig covers the bin',\n 'reference-like',\n 'partial: contigs cover under 90% of the bin',\n 'diverges',\n]\nconst MARK_BUCKETS = [\n '1 excursion',\n '2\u20133 excursions',\n '4\u201315 excursions',\n '16+ excursions',\n]\nexport const NOT_SHOWN = 'SNPs and indels under 50 bp are not shown'\n\nexport function cellColor(cell: number): Rgb {\n const klass = cell & 3\n return klass === OVERVIEW_ABSENT\n ? PALETTE.absent\n : klass === OVERVIEW_REFERENCE\n ? PALETTE.reference\n : klass === OVERVIEW_PARTIAL\n ? PALETTE.partial\n : PALETTE.variant[cell >> 2]!\n}\n\nexport function cellLabel(cell: number) {\n const klass = cell & 3\n return klass === OVERVIEW_VARIANT\n ? `diverges \u226550 bp, ${MARK_BUCKETS[cell >> 2]}`\n : CLASS_NAMES[klass]!\n}\n\nexport interface OverviewLayout {\n rows: number[]\n pinnedCount: number\n pinnedHeight: number\n restHeight: number\n rowsTop: number\n restTop: number\n}\n\n// The track's lanes first, at a height their labels fit when there is room,\n// then every other haplotype unless only the lanes are wanted, sharing what\n// is left. The reference sample's rows never draw.\nexport function overviewLayout(\n data: Pick<HaplotypeOverviewData, 'rows' | 'pinned' | 'reference'>,\n allRows: boolean,\n height: number,\n): OverviewLayout {\n const skip = new Set([...data.reference, ...data.pinned])\n const pinned = data.pinned.filter(row => !data.reference.includes(row))\n const rest = allRows\n ? data.rows.flatMap((_, row) => (skip.has(row) ? [] : [row]))\n : []\n const rowsTop = DENSITY_PX + GAP_PX\n const available = Math.max(0, height - rowsTop)\n const gap = pinned.length > 0 && rest.length > 0 ? PIN_GAP_PX : 0\n const pinnedHeight =\n pinned.length === 0\n ? 0\n : Math.min(\n PIN_ROW_PX,\n (rest.length > 0 ? available * 0.4 : available) / pinned.length,\n )\n const restTop = rowsTop + pinned.length * pinnedHeight + gap\n return {\n rows: [...pinned, ...rest],\n pinnedCount: pinned.length,\n pinnedHeight,\n restHeight:\n rest.length > 0 ? Math.max(0, height - restTop) / rest.length : 0,\n rowsTop,\n restTop,\n }\n}\n\nexport function rowTop(layout: OverviewLayout, index: number) {\n return index < layout.pinnedCount\n ? layout.rowsTop + index * layout.pinnedHeight\n : layout.restTop + (index - layout.pinnedCount) * layout.restHeight\n}\n\n// The haplotype row under y, or undefined over the density row or a gap\nexport function rowAt(layout: OverviewLayout, y: number) {\n const { pinnedCount, pinnedHeight, restHeight, rowsTop, restTop } = layout\n const pinnedEnd = rowsTop + pinnedCount * pinnedHeight\n const index =\n y >= rowsTop && y < pinnedEnd\n ? Math.floor((y - rowsTop) / pinnedHeight)\n : y >= restTop && restHeight > 0\n ? pinnedCount + Math.floor((y - restTop) / restHeight)\n : undefined\n return index !== undefined && index < layout.rows.length\n ? layout.rows[index]\n : undefined\n}\n\n// The bin holding bp, or undefined between fragments and past either end\nexport function binAt(data: Pick<HaplotypeOverviewData, 'bins'>, bp: number) {\n const { bins } = data\n let lo = 0\n let hi = bins.length - 1\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1\n if (bins[mid]!.start <= bp) {\n lo = mid\n } else {\n hi = mid - 1\n }\n }\n const bin = bins[lo]\n return bin && bin.start <= bp && bp < bin.end ? lo : undefined\n}\n\n// Per bin, the haplotypes that are not the reference counted by what the\n// density row stacks: absent, partial, and variant in each mark bucket\nexport function densityCounts(data: HaplotypeOverviewData) {\n const height = data.rows.length\n const reference = new Set(data.reference)\n return data.bins.map((_, b) => {\n const counts = [0, 0, 0, 0, 0, 0]\n for (let row = 0; row < height; row++) {\n if (!reference.has(row)) {\n const cell = data.cells[b * height + row]!\n const klass = cell & 3\n if (klass === OVERVIEW_VARIANT) {\n counts[2 + (cell >> 2)]! += 1\n } else if (klass === OVERVIEW_ABSENT) {\n counts[0]! += 1\n } else if (klass === OVERVIEW_PARTIAL) {\n counts[1]! += 1\n }\n }\n }\n return counts\n })\n}\n\nexport function describeBin(data: HaplotypeOverviewData, b: number) {\n const bin = data.bins[b]!\n const [absent, reference, partial, variant] = bin.classes\n return {\n span: `${bin.start.toLocaleString()}\u2013${bin.end.toLocaleString()}`,\n classes: `${reference} reference-like, ${variant} diverge \u226550 bp, ${partial} partial, ${absent} absent`,\n excursions: `${bin.excursions.toLocaleString()} excursions, ${bin.variants.toLocaleString()} of 50 bp or more, longest ${bin.longestExcursion.toLocaleString()} bp`,\n }\n}\n\ninterface Frame {\n // screen x of a bp on the overview's contig\n xOf: (bp: number) => number\n width: number\n height: number\n dpr: number\n}\n\nfunction makeCanvas(width: number, height: number) {\n const canvas = document.createElement('canvas')\n canvas.width = Math.max(1, width)\n canvas.height = Math.max(1, height)\n return canvas\n}\n\n// Consecutive bins with no gap between them, which one image can stretch over\nfunction contiguousRuns(data: HaplotypeOverviewData) {\n const runs: [number, number][] = []\n let first = 0\n data.bins.forEach((bin, b) => {\n if (b > 0 && bin.start !== data.bins[b - 1]!.end) {\n runs.push([first, b])\n first = b\n }\n })\n if (data.bins.length > 0) {\n runs.push([first, data.bins.length])\n }\n return runs\n}\n\nexport interface RowImage {\n image: HTMLCanvasElement\n top: number\n height: number\n}\n\n// One image per group of rows, built once per overview and layout: a pixel\n// per cell, scaled to the group's device height with smoothing only when\n// rows outnumber pixels\nfunction rowImage(\n data: HaplotypeOverviewData,\n rows: number[],\n top: number,\n height: number,\n dpr: number,\n): RowImage | undefined {\n const cols = data.bins.length\n if (rows.length === 0 || cols === 0 || height <= 0) {\n return undefined\n }\n const cells = makeCanvas(cols, rows.length)\n const cellsCtx = cells.getContext('2d')!\n const pixels = cellsCtx.createImageData(cols, rows.length)\n const stride = data.rows.length\n rows.forEach((row, y) => {\n for (let b = 0; b < cols; b++) {\n const [r, g, bl] = cellColor(data.cells[b * stride + row]!)\n const o = (y * cols + b) * 4\n pixels.data[o] = r\n pixels.data[o + 1] = g\n pixels.data[o + 2] = bl\n pixels.data[o + 3] = 255\n }\n })\n cellsCtx.putImageData(pixels, 0, 0)\n const devHeight = Math.max(1, Math.round(height * dpr))\n const image = makeCanvas(cols, devHeight)\n const ctx = image.getContext('2d')!\n ctx.imageSmoothingEnabled = rows.length > devHeight\n ctx.imageSmoothingQuality = 'high'\n ctx.drawImage(cells, 0, 0, cols, devHeight)\n return { image, top, height }\n}\n\nexport function rowImages(\n data: HaplotypeOverviewData,\n layout: OverviewLayout,\n dpr: number,\n) {\n const { rows, pinnedCount, pinnedHeight, restHeight } = layout\n return [\n rowImage(\n data,\n rows.slice(0, pinnedCount),\n layout.rowsTop,\n pinnedCount * pinnedHeight,\n dpr,\n ),\n rowImage(\n data,\n rows.slice(pinnedCount),\n layout.restTop,\n (rows.length - pinnedCount) * restHeight,\n dpr,\n ),\n ].filter(image => image !== undefined)\n}\n\n// The screen span of bp [start, end), which runs right to left on a\n// reversed block\nfunction screenSpan(frame: Frame, start: number, end: number) {\n const a = frame.xOf(start)\n const b = frame.xOf(end)\n return { left: Math.min(a, b), width: Math.abs(b - a), reversed: b < a }\n}\n\n// Each run of bins stretched to its bp, smoothed only when bins outnumber\n// pixels, and mirrored on a reversed block\nfunction blitRows(\n ctx: CanvasRenderingContext2D,\n data: HaplotypeOverviewData,\n images: RowImage[],\n frame: Frame,\n) {\n for (const [first, end] of contiguousRuns(data)) {\n const { left, width, reversed } = screenSpan(\n frame,\n data.bins[first]!.start,\n data.bins[end - 1]!.end,\n )\n if (left + width < 0 || left > frame.width) {\n continue\n }\n ctx.imageSmoothingEnabled = end - first > width * frame.dpr\n for (const { image, top, height } of images) {\n ctx.save()\n if (reversed) {\n ctx.translate(2 * left + width, 0)\n ctx.scale(-1, 1)\n }\n ctx.drawImage(\n image,\n first,\n 0,\n end - first,\n image.height,\n left,\n top,\n width,\n height,\n )\n ctx.restore()\n }\n }\n}\n\nfunction drawDensity(\n ctx: CanvasRenderingContext2D,\n data: HaplotypeOverviewData,\n counts: number[][] | undefined,\n frame: Frame,\n) {\n const total = data.rows.length - data.reference.length\n const most = Math.max(1, ...data.bins.map(bin => bin.variants))\n const stack: Rgb[] = [[175, 175, 175], PALETTE.partial, ...PALETTE.variant]\n data.bins.forEach((bin, b) => {\n const span = screenSpan(frame, bin.start, bin.end)\n const { left } = span\n const width = Math.max(span.width, 1 / frame.dpr)\n if (left + width < 0 || left > frame.width) {\n return\n }\n if (counts) {\n let y = DENSITY_PX\n for (const i of [5, 4, 3, 2, 1, 0]) {\n const h = (DENSITY_PX * counts[b]![i]!) / Math.max(1, total)\n if (h > 0) {\n const [r, g, bl] = stack[i]!\n ctx.fillStyle = `rgb(${r},${g},${bl})`\n ctx.fillRect(left, y - h, width, h)\n y -= h\n }\n }\n } else {\n const h = (DENSITY_PX * bin.variants) / most\n const [r, g, bl] = PALETTE.variant[1]\n ctx.fillStyle = `rgb(${r},${g},${bl})`\n ctx.fillRect(left, DENSITY_PX - h, width, h)\n }\n })\n}\n\nfunction drawLabels(\n ctx: CanvasRenderingContext2D,\n data: HaplotypeOverviewData,\n layout: OverviewLayout,\n) {\n if (layout.pinnedHeight < LABEL_MIN_PX) {\n return\n }\n ctx.font = `${Math.min(11, layout.pinnedHeight - 2)}px sans-serif`\n ctx.textBaseline = 'middle'\n for (let i = 0; i < layout.pinnedCount; i++) {\n const label = data.rows[layout.rows[i]!]!\n const y = rowTop(layout, i)\n const w = ctx.measureText(label).width\n ctx.fillStyle = 'rgba(255,255,255,0.8)'\n ctx.fillRect(2, y + 1, w + 6, layout.pinnedHeight - 2)\n ctx.fillStyle = '#222'\n ctx.fillText(label, 5, y + layout.pinnedHeight / 2)\n }\n}\n\nfunction formatBp(bp: number) {\n return bp >= 1_000_000\n ? `${+(bp / 1_000_000).toFixed(1)} Mb`\n : `${+(bp / 1000).toFixed(1)} kb`\n}\n\n// What the density band counts, which changes with the bin size\nexport function densityLabel(data: HaplotypeOverviewData) {\n const haplotypes = data.rows.length - data.reference.length\n return data.bin <= FINE_BIN_BP\n ? `haplotypes diverging \u226550 bp, of ${haplotypes} \u00B7 ${formatBp(data.bin)} bins`\n : `excursions \u226550 bp per ${formatBp(data.bin)} bin, all ${haplotypes} haplotypes`\n}\n\nfunction drawDensityLabel(\n ctx: CanvasRenderingContext2D,\n data: HaplotypeOverviewData,\n) {\n const label = densityLabel(data)\n ctx.font = '10px sans-serif'\n ctx.textBaseline = 'top'\n const w = ctx.measureText(label).width\n ctx.fillStyle = 'rgba(255,255,255,0.8)'\n ctx.fillRect(2, 1, w + 6, 13)\n ctx.fillStyle = '#444'\n ctx.fillText(label, 5, 2)\n}\n\n// The density band from per-class counts at bins up to FINE_BIN_BP, from\n// excursion counts past them (undefined counts)\nexport function drawOverview(\n ctx: CanvasRenderingContext2D,\n data: HaplotypeOverviewData,\n counts: number[][] | undefined,\n layout: OverviewLayout,\n images: RowImage[],\n frame: Frame,\n) {\n ctx.clearRect(0, 0, frame.width, frame.height)\n drawDensity(ctx, data, counts, frame)\n blitRows(ctx, data, images, frame)\n drawLabels(ctx, data, layout)\n drawDensityLabel(ctx, data)\n}\n"],
|
|
5
|
+
"mappings": "6DAqCO,SAASA,EAAaC,EAAmC,CAC9D,GAAI,OAAOA,GAAS,UAAYA,IAAS,KACvC,MAAO,GAET,IAAMC,EAAID,EACV,OACE,OAAOC,EAAE,kBAAqB,YAC9B,OAAOA,EAAE,QAAW,YACpB,wBAAyBA,GACzB,kBAAmBA,CAEvB,CAEA,SAASC,EAAOC,EAA8B,CAC5C,OAAOA,EAAO,OACZ,CAACC,EAAMC,IAAOD,GAAQA,EAAK,IAAMA,EAAK,OAASC,EAAE,IAAMA,EAAE,MAAQD,EAAOC,EACxE,MACF,CACF,CAoBO,SAASC,EAAUN,EAAkBO,EAAwB,CAClE,IAAMC,EAAQN,EACZF,EAAK,cAAc,cAAc,OAC/BK,GACEA,EAAE,UAAYE,EAAO,SAAWF,EAAE,eAAiBE,EAAO,YAC9D,CACF,EACM,CAAE,QAAAE,CAAQ,EAAIT,EACpB,GAAI,CAACQ,GAAS,EAAEC,EAAU,GACxB,OAEF,IAAMC,EAAOF,EAAM,SAAWR,EAAK,SACnC,OAAOQ,EAAM,SACT,CAAE,MAAO,GAAKC,EAAS,WAAYC,EAAOF,E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A,SAASC,EACPxB,EACAzD,EACA,CACA,IAAM4E,EAAQG,EAAa/E,CAAI,EAC/ByD,EAAI,KAAO,kBACXA,EAAI,aAAe,MACnB,IAAMoB,EAAIpB,EAAI,YAAYmB,CAAK,EAAE,MACjCnB,EAAI,UAAY,wBAChBA,EAAI,SAAS,EAAG,EAAGoB,EAAI,EAAG,EAAE,EAC5BpB,EAAI,UAAY,OAChBA,EAAI,SAASmB,EAAO,EAAG,CAAC,CAC1B,CAIO,SAASM,GACdzB,EACAzD,EACA+B,EACAjB,EACAmD,EACAL,EACA,CACAH,EAAI,UAAU,EAAG,EAAGG,EAAM,MAAOA,EAAM,MAAM,EAC7CQ,EAAYX,EAAKzD,EAAM+B,EAAQ6B,CAAK,EACpCI,EAASP,EAAKzD,EAAMiE,EAAQL,CAAK,EACjCe,EAAWlB,EAAKzD,EAAMc,CAAM,EAC5BmE,EAAiBxB,EAAKzD,CAAI,CAC5B",
|
|
6
|
+
"names": ["isLinearHost", "view", "v", "widest", "blocks", "best", "b", "hostFrame", "region", "block", "bpPerPx", "left", "hostWindow", "displayed", "hostCut", "window", "capBp", "margins", "visible", "margin", "start", "end", "over", "cutHolds", "cut", "exact", "PALETTE", "DENSITY_PX", "GAP_PX", "PIN_GAP_PX", "PIN_ROW_PX", "LABEL_MIN_PX", "FINE_BIN_BP", "CLASS_NAMES", "MARK_BUCKETS", "NOT_SHOWN", "cellColor", "cell", "klass", "OVERVIEW_ABSENT", "OVERVIEW_REFERENCE", "OVERVIEW_PARTIAL", "cellLabel", "OVERVIEW_VARIANT", "overviewLayout", "data", "allRows", "height", "skip", "pinned", "row", "rest", "_", "rowsTop", "available", "gap", "pinnedHeight", "restTop", "rowTop", "layout", "index", "rowAt", "y", "pinnedCount", "restHeight", "pinnedEnd", "binAt", "bp", "bins", "lo", "hi", "mid", "bin", "densityCounts", "reference", "b", "counts", "describeBin", "absent", "partial", "variant", "makeCanvas", "width", "canvas", "contiguousRuns", "runs", "first", "rowImage", "rows", "top", "dpr", "cols", "cells", "cellsCtx", "pixels", "stride", "r", "g", "bl", "o", "devHeight", "image", "ctx", "rowImages", "screenSpan", "frame", "start", "end", "a", "blitRows", "images", "left", "reversed", "drawDensity", "total", "most", "stack", "span", "i", "h", "drawLabels", "label", "w", "formatBp", "densityLabel", "haplotypes", "drawDensityLabel", "drawOverview"]
|
|
7
|
+
}
|
|
@@ -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-
|
|
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
|