jbrowse-plugin-graphgenomeviewer 10.4.0 → 10.4.2
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/dist/chunks/{AddTrackWorkflow-4S5QEZTJ.js → AddTrackWorkflow-P5APNL32.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-64HUHYVC.js → GbzBaseSyntenyAdapter-46A4LMVD.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-64HUHYVC.js.map → GbzBaseSyntenyAdapter-46A4LMVD.js.map} +1 -1
- package/dist/chunks/{GraphGenomeView-EGR7L5WT.js → GraphGenomeView-MXRAP7QB.js} +2 -2
- package/dist/chunks/GraphSettingsDialog-HIOYWTO7.js +2 -0
- package/dist/chunks/{HighlightColorDialog-FHRKHBDZ.js → HighlightColorDialog-UKFUS5S4.js} +2 -2
- package/dist/chunks/LinearGraphDisplay-KPWFPVFK.js +2 -0
- package/dist/chunks/{MinigraphBubbleAdapter-LQ2NYC6O.js → MinigraphBubbleAdapter-QSPPG4LG.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-UM7L6HPH.js → RgfaTabixAdapter-UPCOXYVG.js} +2 -2
- package/dist/chunks/{WalkFormsAdapter-4D6MTHLE.js → WalkFormsAdapter-LHKGRYC6.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-V5IQCHP4.js → WalkTabixSyntenyAdapter-ELTYD73I.js} +2 -2
- package/dist/chunks/{chunk-5KWWMR7X.js → chunk-2TMZO3P5.js} +2 -2
- package/dist/chunks/{chunk-HYQOBARI.js → chunk-43EUXRKZ.js} +2 -2
- package/dist/chunks/{chunk-HYQOBARI.js.map → chunk-43EUXRKZ.js.map} +1 -1
- package/dist/chunks/{chunk-L5HPUPUZ.js → chunk-4QYWBDUL.js} +2 -2
- package/dist/chunks/{chunk-L5HPUPUZ.js.map → chunk-4QYWBDUL.js.map} +1 -1
- package/dist/chunks/{chunk-LDY26KXZ.js → chunk-52BUFQHJ.js} +3 -3
- package/dist/chunks/{chunk-LDY26KXZ.js.map → chunk-52BUFQHJ.js.map} +2 -2
- package/dist/chunks/{chunk-ZMUXLTEP.js → chunk-5N4B6FEH.js} +2 -2
- package/dist/chunks/{chunk-2OH3T4CR.js → chunk-AC5KEN36.js} +2 -2
- package/dist/chunks/{chunk-2OH3T4CR.js.map → chunk-AC5KEN36.js.map} +1 -1
- package/dist/chunks/{chunk-QVQIHX2Y.js → chunk-BLE63OIT.js} +2 -2
- package/dist/chunks/{chunk-QVQIHX2Y.js.map → chunk-BLE63OIT.js.map} +3 -3
- package/dist/chunks/{chunk-55PR5XJY.js → chunk-DZXYOIGJ.js} +2 -2
- package/dist/chunks/{chunk-5CTDN4UC.js → chunk-E3GNTGWW.js} +1 -1
- package/dist/chunks/{chunk-5CTDN4UC.js.map → chunk-E3GNTGWW.js.map} +1 -1
- package/dist/chunks/{chunk-XXMAC5EP.js → chunk-E5ERNAYL.js} +1 -1
- package/dist/chunks/{chunk-XXMAC5EP.js.map → chunk-E5ERNAYL.js.map} +1 -1
- package/dist/chunks/chunk-KGAZZNZC.js +8 -0
- package/dist/chunks/chunk-KGAZZNZC.js.map +7 -0
- package/dist/chunks/{chunk-4IPVOCXX.js → chunk-L7ZSEA4T.js} +2 -2
- package/dist/chunks/{chunk-4IPVOCXX.js.map → chunk-L7ZSEA4T.js.map} +1 -1
- package/dist/chunks/chunk-M5XKM6D2.js +5 -0
- package/dist/chunks/chunk-M5XKM6D2.js.map +7 -0
- package/dist/chunks/chunk-N2TMTGYP.js +2 -0
- package/dist/chunks/{chunk-HE7BFKXW.js → chunk-QOMV5OG7.js} +2 -2
- package/dist/chunks/{chunk-5PMRULDS.js → chunk-RDTLCMD2.js} +1 -1
- package/dist/chunks/{chunk-5PMRULDS.js.map → chunk-RDTLCMD2.js.map} +1 -1
- package/dist/chunks/{chunk-SBHNFZRS.js → chunk-RUKWE5MB.js} +2 -2
- package/dist/chunks/chunk-SMZZWPRX.js +3 -0
- package/dist/chunks/chunk-SMZZWPRX.js.map +7 -0
- package/dist/chunks/{chunk-EYNSJ5AX.js → chunk-TM22QR6V.js} +2 -2
- package/dist/chunks/{chunk-EYNSJ5AX.js.map → chunk-TM22QR6V.js.map} +1 -1
- package/dist/chunks/{chunk-2XAPUOET.js → chunk-VY7G4FSX.js} +2 -2
- package/dist/chunks/{chunk-2XAPUOET.js.map → chunk-VY7G4FSX.js.map} +2 -2
- package/dist/chunks/{chunk-4GC42TBO.js → chunk-WBDZVWK4.js} +2 -2
- package/dist/chunks/{chunk-4GC42TBO.js.map → chunk-WBDZVWK4.js.map} +1 -1
- package/dist/chunks/{chunk-4WMWSJXJ.js → chunk-YIGESHTA.js} +2 -2
- package/dist/chunks/{chunk-4WMWSJXJ.js.map → chunk-YIGESHTA.js.map} +1 -1
- package/dist/chunks/{chunk-LOR4V6JJ.js → chunk-YLB6GKFG.js} +2 -2
- package/dist/chunks/{chunk-LOR4V6JJ.js.map → chunk-YLB6GKFG.js.map} +1 -1
- package/dist/chunks/{renderSvg-WQ5CH3G3.js → renderSvg-4AG3PPI5.js} +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/GraphGenomeView/host.test.ts +1 -0
- package/src/GraphGenomeView/host.ts +9 -3
- package/src/GraphGenomeView/pane/fitViews.ts +2 -2
- package/src/GraphGenomeView/pane/graphViews.ts +8 -5
- package/src/GraphGenomeView/pane/hostViews.ts +2 -4
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +22 -0
- package/src/WalkFormsAdapter/formsMenu.test.ts +1 -0
- package/src/version.ts +1 -1
- package/dist/chunks/GraphSettingsDialog-6VOMA2TZ.js +0 -2
- package/dist/chunks/LinearGraphDisplay-R3A64XKK.js +0 -2
- package/dist/chunks/chunk-3S24TQNP.js +0 -5
- package/dist/chunks/chunk-3S24TQNP.js.map +0 -7
- package/dist/chunks/chunk-GPNGXGMH.js +0 -3
- package/dist/chunks/chunk-GPNGXGMH.js.map +0 -7
- package/dist/chunks/chunk-RRQGLRKY.js +0 -8
- package/dist/chunks/chunk-RRQGLRKY.js.map +0 -7
- package/dist/chunks/chunk-VOD5M5MV.js +0 -2
- /package/dist/chunks/{AddTrackWorkflow-4S5QEZTJ.js.map → AddTrackWorkflow-P5APNL32.js.map} +0 -0
- /package/dist/chunks/{GraphGenomeView-EGR7L5WT.js.map → GraphGenomeView-MXRAP7QB.js.map} +0 -0
- /package/dist/chunks/{GraphSettingsDialog-6VOMA2TZ.js.map → GraphSettingsDialog-HIOYWTO7.js.map} +0 -0
- /package/dist/chunks/{HighlightColorDialog-FHRKHBDZ.js.map → HighlightColorDialog-UKFUS5S4.js.map} +0 -0
- /package/dist/chunks/{LinearGraphDisplay-R3A64XKK.js.map → LinearGraphDisplay-KPWFPVFK.js.map} +0 -0
- /package/dist/chunks/{MinigraphBubbleAdapter-LQ2NYC6O.js.map → MinigraphBubbleAdapter-QSPPG4LG.js.map} +0 -0
- /package/dist/chunks/{RgfaTabixAdapter-UM7L6HPH.js.map → RgfaTabixAdapter-UPCOXYVG.js.map} +0 -0
- /package/dist/chunks/{WalkFormsAdapter-4D6MTHLE.js.map → WalkFormsAdapter-LHKGRYC6.js.map} +0 -0
- /package/dist/chunks/{WalkTabixSyntenyAdapter-V5IQCHP4.js.map → WalkTabixSyntenyAdapter-ELTYD73I.js.map} +0 -0
- /package/dist/chunks/{chunk-5KWWMR7X.js.map → chunk-2TMZO3P5.js.map} +0 -0
- /package/dist/chunks/{chunk-ZMUXLTEP.js.map → chunk-5N4B6FEH.js.map} +0 -0
- /package/dist/chunks/{chunk-55PR5XJY.js.map → chunk-DZXYOIGJ.js.map} +0 -0
- /package/dist/chunks/{chunk-VOD5M5MV.js.map → chunk-N2TMTGYP.js.map} +0 -0
- /package/dist/chunks/{chunk-HE7BFKXW.js.map → chunk-QOMV5OG7.js.map} +0 -0
- /package/dist/chunks/{chunk-SBHNFZRS.js.map → chunk-RUKWE5MB.js.map} +0 -0
- /package/dist/chunks/{renderSvg-WQ5CH3G3.js.map → renderSvg-4AG3PPI5.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{U as a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{U as a}from"./chunk-VY7G4FSX.js";import{d as m}from"./chunk-DZXYOIGJ.js";import{a as n,c as p}from"./chunk-RDTLCMD2.js";function c(i,l){let t=new Map,o=new Map;for(let{name:s,color:e,assembly:r}of i)e&&a(e)&&(t.set(s,e),r&&!o.has(r)&&o.set(r,e));return s=>{let e=p(s)??s;return t.get(e)??t.get(n(e))??o.get(m(l,e))}}export{c as a};
|
|
2
|
+
//# sourceMappingURL=chunk-QOMV5OG7.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var s="#";function c(n){return n.split(s)[0]}var a=new Set(["_gbwt_ref"]);function u(n){return a.has(n)}function f(n){let t=n.split(s);return t.length>=3?`${t[0]}${s}${t[1]}`:void 0}function y(n){let t=n.split(s);return t.length>=3?t.slice(2).join(s):t.length===2?t[1]:n}function N(n){let[t="",e="",...o]=n.split(s);return o.length>0&&/^\d+$/.test(e)?{sample:t,haplotype:+e,contig:o.join(s)}:void 0}function m(n){let t=n.split(s),e=t.length>=2&&t[1]!==""?Number(t[1]):Number.NaN;return{sample:t[0],haplotype:Number.isFinite(e)?e:void 0}}function S(n,t){return t!==void 0&&(n===t||n.startsWith(t+s))}var p=n=>typeof n=="object"&&n!==null&&Object.values(n).every(t=>typeof t=="string");function r(n){let t=n.getConf("assemblyNameToPanSN");return p(t)?t:{}}function g(n,t){return t===void 0?void 0:r(n)[t]??t}function l(n){let t=n.getConf("assemblyNames");return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}var i=new WeakMap;function h(n){let t=i.get(n);if(t===void 0){let e=r(n);t={};for(let o of new Set([...Object.keys(e),...l(n)]))t[e[o]??o]=o;i.set(n,t)}return t}export{c as a,u as b,f as c,y as d,N as e,m as f,S as g,g as h,h as i};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-RDTLCMD2.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.3.
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@14.3.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-W6DDM47C.js"],
|
|
4
4
|
"sourcesContent": ["// src/pansn.ts\nvar SEP = \"#\";\nfunction panSNSample(refName) {\n return refName.split(SEP)[0];\n}\nvar GENERIC_SAMPLES = /* @__PURE__ */ new Set([\"_gbwt_ref\"]);\nfunction isGenericSample(sample) {\n return GENERIC_SAMPLES.has(sample);\n}\nfunction panSNHaplotype(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? `${parts[0]}${SEP}${parts[1]}` : void 0;\n}\nfunction panSNContig(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? parts.slice(2).join(SEP) : parts.length === 2 ? parts[1] : refName;\n}\nfunction panSNFields(name) {\n const [sample = \"\", haplotype = \"\", ...contig] = name.split(SEP);\n return contig.length > 0 && /^\\d+$/.test(haplotype) ? { sample, haplotype: +haplotype, contig: contig.join(SEP) } : void 0;\n}\nfunction parsePanSN(refName) {\n const parts = refName.split(SEP);\n const haplotype = parts.length >= 2 && parts[1] !== \"\" ? Number(parts[1]) : Number.NaN;\n return {\n sample: parts[0],\n haplotype: Number.isFinite(haplotype) ? haplotype : void 0\n };\n}\nfunction panSNMatchesPrefix(refName, prefix) {\n return prefix !== void 0 && (refName === prefix || refName.startsWith(prefix + SEP));\n}\nvar isNameMap = (value) => typeof value === \"object\" && value !== null && Object.values(value).every((v) => typeof v === \"string\");\nfunction assemblyNameToPanSN(adapter) {\n const map = adapter.getConf(\"assemblyNameToPanSN\");\n return isNameMap(map) ? map : {};\n}\nfunction resolvePanSNPrefix(adapter, name) {\n return name === void 0 ? void 0 : assemblyNameToPanSN(adapter)[name] ?? name;\n}\nfunction assemblyNames(adapter) {\n const names = adapter.getConf(\"assemblyNames\");\n return Array.isArray(names) ? names.filter((name) => typeof name === \"string\") : [];\n}\nvar asmByPrefixCache = /* @__PURE__ */ new WeakMap();\nfunction assemblyByPanSNPrefix(adapter) {\n let out = asmByPrefixCache.get(adapter);\n if (out === void 0) {\n const map = assemblyNameToPanSN(adapter);\n out = {};\n for (const asm of /* @__PURE__ */ new Set([\n ...Object.keys(map),\n ...assemblyNames(adapter)\n ])) {\n out[map[asm] ?? asm] = asm;\n }\n asmByPrefixCache.set(adapter, out);\n }\n return out;\n}\n\nexport {\n panSNSample,\n isGenericSample,\n panSNHaplotype,\n panSNContig,\n panSNFields,\n parsePanSN,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n assemblyByPanSNPrefix\n};\n"],
|
|
5
5
|
"mappings": "AACA,IAAIA,EAAM,IACV,SAASC,EAAYC,EAAS,CAC5B,OAAOA,EAAQ,MAAMF,CAAG,EAAE,CAAC,CAC7B,CACA,IAAIG,EAAkC,IAAI,IAAI,CAAC,WAAW,CAAC,EAC3D,SAASC,EAAgBC,EAAQ,CAC/B,OAAOF,EAAgB,IAAIE,CAAM,CACnC,CACA,SAASC,EAAeJ,EAAS,CAC/B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EAC/B,OAAOO,EAAM,QAAU,EAAI,GAAGA,EAAM,CAAC,CAAC,GAAGP,CAAG,GAAGO,EAAM,CAAC,CAAC,GAAK,MAC9D,CACA,SAASC,EAAYN,EAAS,CAC5B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EAC/B,OAAOO,EAAM,QAAU,EAAIA,EAAM,MAAM,CAAC,EAAE,KAAKP,CAAG,EAAIO,EAAM,SAAW,EAAIA,EAAM,CAAC,EAAIL,CACxF,CACA,SAASO,EAAYC,EAAM,CACzB,GAAM,CAACL,EAAS,GAAIM,EAAY,GAAI,GAAGC,CAAM,EAAIF,EAAK,MAAMV,CAAG,EAC/D,OAAOY,EAAO,OAAS,GAAK,QAAQ,KAAKD,CAAS,EAAI,CAAE,OAAAN,EAAQ,UAAW,CAACM,EAAW,OAAQC,EAAO,KAAKZ,CAAG,CAAE,EAAI,MACtH,CACA,SAASa,EAAWX,EAAS,CAC3B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EACzBW,EAAYJ,EAAM,QAAU,GAAKA,EAAM,CAAC,IAAM,GAAK,OAAOA,EAAM,CAAC,CAAC,EAAI,OAAO,IACnF,MAAO,CACL,OAAQA,EAAM,CAAC,EACf,UAAW,OAAO,SAASI,CAAS,EAAIA,EAAY,MACtD,CACF,CACA,SAASG,EAAmBZ,EAASa,EAAQ,CAC3C,OAAOA,IAAW,SAAWb,IAAYa,GAAUb,EAAQ,WAAWa,EAASf,CAAG,EACpF,CACA,IAAIgB,EAAaC,GAAU,OAAOA,GAAU,UAAYA,IAAU,MAAQ,OAAO,OAAOA,CAAK,EAAE,MAAOC,GAAM,OAAOA,GAAM,QAAQ,EACjI,SAASC,EAAoBC,EAAS,CACpC,IAAMC,EAAMD,EAAQ,QAAQ,qBAAqB,EACjD,OAAOJ,EAAUK,CAAG,EAAIA,EAAM,CAAC,CACjC,CACA,SAASC,EAAmBF,EAASV,EAAM,CACzC,OAAOA,IAAS,OAAS,OAASS,EAAoBC,CAAO,EAAEV,CAAI,GAAKA,CAC1E,CACA,SAASa,EAAcH,EAAS,CAC9B,IAAMI,EAAQJ,EAAQ,QAAQ,eAAe,EAC7C,OAAO,MAAM,QAAQI,CAAK,EAAIA,EAAM,OAAQd,GAAS,OAAOA,GAAS,QAAQ,EAAI,CAAC,CACpF,CACA,IAAIe,EAAmC,IAAI,QAC3C,SAASC,EAAsBN,EAAS,CACtC,IAAIO,EAAMF,EAAiB,IAAIL,CAAO,EACtC,GAAIO,IAAQ,OAAQ,CAClB,IAAMN,EAAMF,EAAoBC,CAAO,EACvCO,EAAM,CAAC,EACP,QAAWC,KAAuB,IAAI,IAAI,CACxC,GAAG,OAAO,KAAKP,CAAG,EAClB,GAAGE,EAAcH,CAAO,CAC1B,CAAC,EACCO,EAAIN,EAAIO,CAAG,GAAKA,CAAG,EAAIA,EAEzBH,EAAiB,IAAIL,EAASO,CAAG,CACnC,CACA,OAAOA,CACT",
|
|
6
6
|
"names": ["SEP", "panSNSample", "refName", "GENERIC_SAMPLES", "isGenericSample", "sample", "panSNHaplotype", "parts", "panSNContig", "panSNFields", "name", "haplotype", "contig", "parsePanSN", "panSNMatchesPrefix", "prefix", "isNameMap", "value", "v", "assemblyNameToPanSN", "adapter", "map", "resolvePanSNPrefix", "assemblyNames", "names", "asmByPrefixCache", "assemblyByPanSNPrefix", "out", "asm"]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as Y,g as X,h as De,i as He,j as Ie,k as ce,l as qe,n as $e}from"./chunk-RRQGLRKY.js";import{a as ae,b as Oe}from"./chunk-D6TY2QEG.js";import{e as Fe,j as Le}from"./chunk-EGZZ3ADM.js";import{d as ze,g as ye,h as re}from"./chunk-5PMRULDS.js";var D=JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],Ue=i=>D!=null&&i in Object(D)?D[i]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+i+"' from '@jbrowse/core/data_adapters/BaseAdapter' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:i});var Mt=Ue("BaseFeatureDataAdapter");var je=Ue("cachedSetup");var Bt=D&&D.__esModule?D.default:D;async function Et(i,e,t,n,s){return Ie(e,t,n),i.getLines(e,t,n,s)}async function Ve(i,e,t){for(let{refName:n,start:s,end:o}of e)Ie(n,s,o);return i.bytesForRegions(e,t)}function H(i){if(i?.aborted)throw ke(i)}function ke(i){let e=i.reason;return e===void 0?new DOMException("This operation was aborted","AbortError"):e}function Ge(i){return typeof i?.addEventListener=="function"}var z=class{entries=new Map;total=0;settledCount=0;limit;shared;fill;sizeOf;toCacheKey;idleTimeoutMs;sweepTimer;constructor({fill:e,maxSize:t=1/0,sizeOf:n=()=>1,cacheKey:s=a=>String(a),idleTimeoutMs:o=0,budget:r}={}){this.fill=e,this.limit=t,this.shared=r&&{budget:r,membership:r.register(this)},this.sizeOf=n,this.toCacheKey=s,this.idleTimeoutMs=o>0&&Number.isFinite(o)?o:void 0}get size(){return this.entries.size}get totalSize(){return this.total}get maxSize(){return this.limit}set maxSize(e){this.limit=e,this.evict()}waiterCount(e){return this.entries.get(this.toCacheKey(e))?.pending?.signals.size??0}async get(e,t,n){H(t);let s=this.toCacheKey(e),o=this.entries.get(s);o&&this.isDoomed(o)&&(this.release(s),o=void 0),o?this.touch(s,o):o=this.start(s,e,n),o.pending&&this.join(o.pending,t);try{return await this.settleFor(o,t)}finally{H(t)}}settleFor(e,t){if(!e.pending||!Ge(t))return e.promise;let n,s=new Promise((r,a)=>{n=a}),o=()=>{n(ke(t))};return t.addEventListener("abort",o,{once:!0}),Promise.race([e.promise,s]).finally(()=>{t.removeEventListener("abort",o)})}getIfCached(e){let t=this.toCacheKey(e),n=this.entries.get(t);if(n){if(this.isDoomed(n)){this.release(t);return}return this.touch(t,n),n.promise}}has(e){let t=this.entries.get(this.toCacheKey(e));return t!==void 0&&!this.isDoomed(t)}delete(e){this.release(this.toCacheKey(e))}clear(){this.entries.clear(),this.shared?.budget.charge(this.shared.membership,-this.total),this.total=0,this.settledCount=0,this.stopSweep()}touch(e,t){this.entries.delete(e),this.entries.set(e,t),t.lastTouched=Date.now(),t.seq=this.stamp()}stamp(){return this.shared?.budget.nextSeq()??0}isDoomed(e){return e.pending?.controller.signal.aborted===!0}sweepIdle(){let e=this.idleTimeoutMs;if(e===void 0)return;let t=Date.now()-e;for(let[n,s]of this.entries)!s.pending&&s.lastTouched<=t&&this.release(n);this.settledCount===0&&this.stopSweep()}startSweep(){let e=this.idleTimeoutMs;if(e===void 0||this.sweepTimer!==void 0)return;let t=Math.min(2**31-1,Math.max(1e3,Math.floor(e/4))),n=new WeakRef(this),s=setInterval(()=>{let o=n.deref();o?o.sweepIdle():clearInterval(s)},t);this.sweepTimer=s,s.unref?.()}stopSweep(){this.sweepTimer!==void 0&&(clearInterval(this.sweepTimer),this.sweepTimer=void 0)}start(e,t,n){let s=n??(this.fill&&(h=>this.fill(t,h)));if(!s)throw new Error("SharedReadCache needs a fill, either on the cache or on the get() call");let o={signals:new Map,pinned:!1,controller:new AbortController},r={promise:Promise.resolve(s(o.controller.signal)),pending:o,size:0,lastTouched:Date.now(),seq:this.stamp()};this.entries.set(e,r);let a=()=>this.entries.get(e)===r,l=()=>{for(let[h,c]of o.signals)h.removeEventListener("abort",c);r.pending=void 0};return r.promise.then(h=>{let c=a()?this.weigh(h):void 0,d=a();l(),d&&(c===void 0?this.entries.delete(e):(r.lastTouched=Date.now(),r.size=c,this.settledCount++,this.total+=c,this.shared?.budget.charge(this.shared.membership,c),this.startSweep())),this.evict(),this.shared?.budget.evict()},()=>{a()&&this.release(e),l()}),r}weigh(e){try{let t=this.sizeOf(e);return Number.isFinite(t)&&t>=0?t:void 0}catch{return}}join(e,t){if(!Ge(t))e.pinned=!0;else if(!t.aborted&&!e.signals.has(t)){let n=()=>{e.signals.delete(t),!e.pinned&&e.signals.size===0&&e.controller.abort(t.reason)};e.signals.set(t,n),t.addEventListener("abort",n,{once:!0})}}release(e){let t=this.entries.get(e);t&&(this.entries.delete(e),t.pending||this.settledCount--,this.total-=t.size,this.shared?.budget.charge(this.shared.membership,-t.size))}lruSpare(e=!1){if(!(this.settledCount<=(e?0:1))){for(let[t,n]of this.entries)if(!n.pending)return{cacheKey:t,seq:n.seq,last:this.settledCount===1}}}evict(){if(!(this.total<=this.limit))for(let[e,t]of this.entries){if(this.total<=this.limit||this.settledCount<=1)break;t.pending||this.release(e)}}};var A=class{minv;maxv;bin;endPosition;constructor(e,t,n,s=t.blockPosition+65536){this.minv=e,this.maxv=t,this.bin=n,this.endPosition=s}toString(){return`${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}fetchedSize(){return this.endPosition-this.minv.blockPosition}};function ve(i,e){if(!(e>0))throw new TypeError(`\`${i}\` must be a number greater than 0`)}var Q=class{#e=new Map;#t=new Map;#n;#s;#o;constructor(e){let t=e.maxAge??Number.POSITIVE_INFINITY;ve("maxSize",e.maxSize),ve("maxAge",t),this.#n=e.maxSize,this.#s=t,this.#o=e.onEviction}#r(e){let t=this.#o;if(t)for(let[n,s]of e)t(n,s.value)}#i(e,t){return t.expiry!==void 0&&t.expiry<=Date.now()?(this.#o?.(e,t.value),this.delete(e),!0):!1}#c(e,t){return this.#i(e,t)?void 0:t.value}#l(e,t){if(this.#t.delete(e),this.#e.set(e,t),this.#e.size>=this.#n){let n=this.#t;this.#t=this.#e,this.#e=new Map,this.#r(n)}}#h(e){this.#t=new Map(e),this.#e=new Map}*#a(){for(let e of[this.#t,this.#e])for(let t of e)this.#i(...t)||(yield t)}get(e){let t=this.#e.get(e);if(t)return this.#c(e,t);let n=this.#t.get(e);if(n&&!this.#i(e,n))return this.#l(e,n),n.value}set(e,t,{maxAge:n=this.#s}={}){let s={value:t,expiry:n===Number.POSITIVE_INFINITY?void 0:Date.now()+n};return this.#e.has(e)?this.#e.set(e,s):this.#l(e,s),this}has(e){let t=this.#e.get(e)??this.#t.get(e);return t!==void 0&&!this.#i(e,t)}peek(e){let t=this.#e.get(e)??this.#t.get(e);return t?this.#c(e,t):void 0}expiresIn(e){let t=this.#e.get(e)??this.#t.get(e);if(t)return t.expiry===void 0?Number.POSITIVE_INFINITY:t.expiry-Date.now()}delete(e){return this.#e.delete(e)||this.#t.delete(e)}clear(){this.#e.clear(),this.#t.clear()}resize(e){ve("maxSize",e);let t=[...this.#a()],n=t.length-e;n<0?(this.#e=new Map(t),this.#t=new Map):(this.#r(t.slice(0,n)),this.#h(t.slice(n))),this.#n=e}evict(e=1){if(!(e>0))return;let t=[...this.#a()],n=Math.trunc(Math.min(e,t.length-1));n>0&&(this.#r(t.slice(0,n)),this.#h(t.slice(n)))}get size(){return Math.min(this.#e.size+this.#t.size,this.#n)}get maxSize(){return this.#n}get maxAge(){return this.#s}*entriesAscending(){for(let[e,t]of this.#a())yield[e,t.value]}*entriesDescending(){for(let e of[this.#e,this.#t])for(let[t,n]of[...e].reverse())this.#i(t,n)||(yield[t,n.value])}entries(){return this.entriesAscending()}[Symbol.iterator](){return this.entriesAscending()}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}forEach(e,t=this){for(let[n,s]of this)e.call(t,s,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};function We(i,e=0){let t=i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24;return((i[e+4]|i[e+5]<<8|i[e+6]<<16|i[e+7]<<24)>>>0)*4294967296+(t>>>0)}var G=class{blockPosition;dataPosition;constructor(e,t){this.blockPosition=e,this.dataPosition=t}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}};function O(i,e=0){return new G(i[e+7]*1099511627776+i[e+6]*4294967296+i[e+5]*16777216+i[e+4]*65536+i[e+3]*256+i[e+2],i[e+1]<<8|i[e])}function le(i,e){let t=i.length;if(t===0)return i;let n;if(e){let a=e.blockPosition,l=e.dataPosition;n=[];for(let h=0;h<t;h++){let c=i[h];(c.maxv.blockPosition-a||c.maxv.dataPosition-l)>0&&n.push(c)}if(n.length===0)return n}else n=i;n.sort((a,l)=>{let h=a.minv.blockPosition-l.minv.blockPosition;return h===0?a.minv.dataPosition-l.minv.dataPosition:h});let s=[n[0]],o=n[0].minv.blockPosition,r=n[0].maxv.blockPosition;for(let a=1;a<n.length;a++){let l=n[a],h=l.minv.blockPosition,c=l.maxv.blockPosition;if(h-r<65e3&&c-o<5e6){let d=s.at(-1);(c-r||l.maxv.dataPosition-d.maxv.dataPosition)>0&&(s[s.length-1]=new A(d.minv,l.maxv,d.bin,l.endPosition),r=c)}else s.push(l),o=h,r=c}return at(s)}function at(i){let e=[i[0]];for(let t=1;t<i.length;t++){let n=i[t],s=e.at(-1).maxv;if((n.minv.blockPosition-s.blockPosition||n.minv.dataPosition-s.dataPosition)>=0){e.push(n);continue}(n.maxv.blockPosition-s.blockPosition||n.maxv.dataPosition-s.dataPosition)>0&&e.push(new A(s,n.maxv,n.bin,n.endPosition))}return e}function he(i,e=[]){let t=[...e];for(let n of i)t.push(n.minv.blockPosition,n.maxv.blockPosition);t.sort((n,s)=>n-s);for(let n of i){let s=n.maxv.blockPosition,o=0,r=t.length;for(;o<r;){let a=o+r>>>1;t[a]>s?r=a:o=a+1}o<t.length&&(n.endPosition=Math.min(n.endPosition,t[o]))}}function de(i,e,t,n,s=8){let o=n?n.blockPosition:1/0,r=n?n.dataPosition:0,a=!1;for(let l=0;l<t;l++){let h=e+l*s,c=i[h+7]*1099511627776+i[h+6]*4294967296+i[h+5]*16777216+i[h+4]*65536+i[h+3]*256+i[h+2],d=i[h+1]<<8|i[h];(c<o||c===o&&d<r)&&(o=c,r=d,a=!0)}return a?new G(o,r):n}function ct(i){let e=new TextDecoder("utf-8"),t=[],n={},s=0,o=0;for(;o<i.length;){let r=i.indexOf(0,o);if(r===-1)break;if(r>o){let a=e.decode(i.subarray(o,r));t[s]=a,n[a]=s}o=r+1,s++}return{refNameToId:n,refIdToName:t}}var lt={0:"generic",1:"SAM",2:"VCF",3:"GAF"};function fe(i,e){let t=new DataView(i.buffer,i.byteOffset,i.byteLength),n=t.getInt32(e,!0),s=n&65536?"zero-based-half-open":"1-based-closed",o=lt[n&15];if(!o)throw new Error(`invalid Tabix preset format flags ${n}`);let r={ref:t.getInt32(e+4,!0),start:t.getInt32(e+8,!0),end:t.getInt32(e+12,!0)},a=t.getInt32(e+16,!0),l=a?String.fromCharCode(a):void 0,h=t.getInt32(e+20,!0),c=t.getInt32(e+24,!0),{refIdToName:d,refNameToId:p}=ct(i.subarray(e+28,e+28+c));return{refIdToName:d,refNameToId:p,skipLines:h,metaChar:l,columnNumbers:r,format:o,coordinateType:s}}function ue(i,e){return{lineCount:We(i,e)}}function me(i,e=5){let t=new Q({maxSize:e});return n=>{let s=t.get(n);if(s!==void 0)return s;let o=i(n);return o!==void 0&&t.set(n,o),o}}function Ke(i){let e=0;for(let s of i)e+=s.length;let t=new Uint8Array(e),n=0;for(let s of i)t.set(s,n),n+=s.length;return t}var Je=10;function Se(i,e,t){let n,s=0;for(let o of i){let r=0;if(n){let h=o.indexOf(Je);if(h===-1){n=Ke([n,o]),e+=o.length;continue}if(t(Ke([n,o.subarray(0,h+1)]),s))return!0;r=h+1,n=void 0}let a=o.lastIndexOf(Je);if(a>=r&&t(o.subarray(r,a+1),e+r))return!0;let l=Math.max(r,a+1);l<o.length&&(n=o.slice(l),s=e+l),e+=o.length}return!1}function Ye(i,e,t){let n=[],s=0;for(let o of i){let r=Math.max(e-s,0),a=Math.min(t-s,o.length);r<a&&n.push(o.subarray(r,a)),s+=o.length}return n}function Pe(i,e,t){let n=0,s=i.length-1;for(;n<s;){let r=n+s+1>>>1;i[r]<=t.blockPosition?n=r:s=r-1}return(n===0?0:e[n])-e[0]+t.dataPosition}function ht(i,e,t,n){if(e>2**(t+n*3))return;let s=(8**(n+1)-1)/7,o=(8**n-1)/7+Math.floor((e-1)/2**t)+1;for(o>=s&&(o=0);;){for(;o%8===1;)o=(o-1)/8;if(o===0)return;let r=i[o];if(r?.length){let a=r[0].minv;for(let l=1;l<r.length;l++){let h=r[l].minv;h.compareTo(a)<0&&(a=h)}return a}o++}}function Xe(i,e){return i.format==="GAF"?0:i.refNameToId[e]}var q=class{filehandle;parseCache=new z({});constructor({filehandle:e}){this.filehandle=e}async readIndexBytes(e){let t=await this.filehandle.readFile({signal:e.signal,onProgress:e.onProgress}),n=await ce(t);return{bytes:n,dataView:new DataView(n.buffer,n.byteOffset,n.byteLength)}}async lineCount(e,t={}){let n=await this.parse(t),s=Xe(n,e);return s===void 0?-1:n.indices(s)?.stats?.lineCount??-1}async getMetadata(e={}){let{indices:t,...n}=await this.parse(e);return n}async blocksForRange(e,t,n,s={}){let o=await this.parse(s),r=Xe(o,e);if(r===void 0)return[];let a=o.indices(r);if(!a)return[];o.format==="GAF"&&(t=Math.max(t-1,0));let l=[];for(let[m,f]of this.reg2bins(t,n,o))for(let x=m;x<=f;x++){let b=a.binIndex[x];if(b)for(let v of b)l.push(v)}let h=this.lowestOffset(a,t,o),c=le(l,h),d=ht(a.binIndex,n,o.minShift,o.depth);if(d){let m=c.length;for(;m>0&&c[m-1].minv.compareTo(d)>=0;)m--;c.length=m}let p=c[0];if(p&&h){let m=2**(o.minShift+3),f=this.lowestOffset(a,Math.floor(t/m)*m,o),x=f&&f.compareTo(h)<0?f:h;p.minv.compareTo(x)<0&&(c[0]=new A(x,p.maxv,p.bin,p.endPosition))}return c}parse(e={}){return this.parseCache.get("index",e.signal,t=>this._parse({...e,signal:t}))}async hasRefSeq(e,t={}){return!!(await this.parse(t)).indices(e)?.binIndex}};var dt=21582659,ft=38359875;function Qe(i,e){return i*2**e}function Te(i,e){return Math.floor(i/2**e)}var $=class extends q{async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e),s=n.getUint32(0,!0),o;if(s===dt)o=1;else if(s===ft)o=2;else throw new Error(`Not a CSI file (magic=${s})`);let r=n.getInt32(4,!0),a=n.getInt32(8,!0),l=(8**(a+1)-1)/7,h=2**(r+a*3),c=n.getInt32(12,!0),d=c>=28&&(n.getInt32(16,!0)&15)===3;if(c<30&&!d)throw new Error("CSI index has no tabix header, so it names no references; it may be a BAM or BCF index");let p=fe(t,16),m=n.getInt32(16+c,!0),f=16+c+4,x,b=[];for(let y=0;y<m;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let u=0;u<I;u++){let S=n.getUint32(f,!0);if(f+=4,S>l)f+=44;else{x=de(t,f,1,x),f+=8;let g=n.getInt32(f,!0);f+=4+16*g}}}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C={},w;for(let F=0;F<S;F++){let k=n.getUint32(u,!0);if(u+=4,k>l)w=ue(t,u+28),u+=44;else{C[k]=O(t,u),u+=8;let R=n.getInt32(u,!0);u+=4;let T=Array.from({length:R});for(let _=0;_<R;_++)T[_]=new A(O(t,u),O(t,u+8),k),u+=16;g[k]=T}}return he(Object.values(g).flat()),{binIndex:g,loffsets:C,stats:w}}return{...p,csi:!0,refCount:m,maxBlockSize:65536,firstDataLine:x,csiVersion:o,indices:me(v),minShift:r,depth:a,maxBinNumber:l,maxRefLength:h}}lowestOffset(e,t,{minShift:n,depth:s}){let{loffsets:o}=e,r;if(o){let a=(Qe(1,3*s)-1)/7+Te(Math.max(t,0),n);for(;r===void 0&&a>0;)if(r=o[a],r===void 0){let l=Math.floor((a-1)/8),h=l*8+1;a=a>h?a-1:l}r??=o[0]}return r}reg2bins(e,t,{minShift:n,depth:s,maxBinNumber:o}){e=Math.max(e,0);let r=2**(n+s*3);t>r&&(t=r),t-=1;let a=0,l=0,h=n+s*3,c=[];for(;a<=s;h-=3,l+=Qe(1,a*3),a+=1){let d=l+Te(e,h),p=l+Te(t,h);if(p-d+c.length>o)throw new Error(`query ${e}-${t} is too large for current binning scheme (shift ${n}, depth ${s}), try a smaller query or a coarser index binning scheme`);c.push([d,p])}return c}};var ut=21578324,Ae=5,_e=14,pe=2**(_e+Ae*3);function Ze(i){return Math.min(Math.max(i,0),pe)}var L=class extends q{reg2bins(e,t){e>pe&&console.warn("querying outside of possible tabix range");let n=Ze(e),s=Math.min(t,pe)-1,o=[];return n<=s&&o.push([0,0],[1+(n>>26),1+(s>>26)],[9+(n>>23),9+(s>>23)],[73+(n>>20),73+(s>>20)],[585+(n>>17),585+(s>>17)],[4681+(n>>14),4681+(s>>14)]),o}lowestOffset(e,t){let n=e.linearIndex;return n?.[Math.min(Ze(t)>>_e,n.length-1)]}async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e);if(n.getUint32(0,!0)!==ut)throw new Error("Not a TBI file");let s=n.getUint32(4,!0),o=((1<<(Ae+1)*3)-1)/7,{refNameToId:r,refIdToName:a,coordinateType:l,format:h,columnNumbers:c,metaChar:d,skipLines:p}=fe(t,8),f=36+n.getInt32(32,!0),x,b=[];for(let y=0;y<s;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let S=0;S<I;S++){let g=n.getUint32(f,!0);f+=4;let C=n.getInt32(f,!0);if(f+=4,g>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");g<=o&&(x=de(t,f,C,x,16)),f+=16*C}let u=n.getInt32(f,!0);f+=4+8*u}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C;for(let k=0;k<S;k++){let R=n.getUint32(u,!0);if(u+=4,R>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(R===o+1){let T=n.getInt32(u,!0);u+=4,T===2&&(C=ue(t,u+16)),u+=16*T}else{let T=n.getInt32(u,!0);u+=4;let _=Array.from({length:T});for(let U=0;U<T;U++)_[U]=new A(O(t,u),O(t,u+8),R),u+=16;g[R]=_}}let w=n.getInt32(u,!0);u+=4;let F=Array.from({length:w});for(let k=0;k<w;k++)F[k]=O(t,u),u+=8;return he(Object.values(g).flat(),F.map(k=>k.blockPosition)),{binIndex:g,linearIndex:F,stats:C}}return{indices:me(v),metaChar:d,minShift:_e,depth:Ae,maxBinNumber:o,maxRefLength:pe,skipLines:p,firstDataLine:x,columnNumbers:c,coordinateType:l,format:h,refIdToName:a,refNameToId:r,maxBlockSize:65536}}};var Me=9,xe=10,nt=13,mt=59,pt=60,gt=62,xt=6,wt=1024*2**20,bt=180*1e3;function Ct(i,e,t){if(i)return i;if(e)return new X(e);if(t)return new Y(t);throw new TypeError("must provide either filehandle, path, or url")}function yt({tbiFilehandle:i,csiFilehandle:e,tbiPath:t,csiPath:n,tbiUrl:s,csiUrl:o,path:r,url:a}){if(i)return new L({filehandle:i});if(e)return new $({filehandle:e});if(t)return new L({filehandle:new X(t)});if(n)return new $({filehandle:new X(n)});if(o)return new $({filehandle:new Y(o)});if(s)return new L({filehandle:new Y(s)});if(r)return new L({filehandle:new X(`${r}.tbi`)});if(a)return new L({filehandle:new Y(`${a}.tbi`)});throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl")}function it(i,e,t,n,s){return i[t]*256+(n-e[t])+s+1}function It(i,e,t,n,s,o,r){let a=n-t,l=e+a,h=0;if(i[s]===46)return l;let c=s;for(let d=s;d<=o;d++)if(d===o||i[d]===mt){let p=d-c;if(p>=10&&i[c]===83&&i[c+1]===86&&i[c+2]===84&&i[c+3]===89&&i[c+4]===80&&i[c+5]===69&&i[c+6]===61&&i[c+7]===84&&i[c+8]===82&&i[c+9]===65)return e+1;if(p>=4&&i[c]===69&&i[c+1]===78&&i[c+2]===68&&i[c+3]===61){let m=ge(i,c+4,d);m>e&&(l=m)}else p>=6&&i[c]===83&&i[c+1]===86&&i[c+2]===76&&i[c+3]===69&&i[c+4]===78&&i[c+5]===61&&(h=vt(i,c+6,d,n+1,r));c=d+1}return Math.max(l,e+h)}var et=44;function kt(i,e,t){if(t-e<5||i[e]!==60||i[t-1]!==62)return!1;let n=i[e+4];if(n!==62&&n!==58)return!1;let s=i[e+1],o=i[e+2],r=i[e+3];return s===67&&o===78&&r===86||s===68&&o===69&&r===76||s===68&&o===85&&r===80||s===73&&o===78&&r===86}function vt(i,e,t,n,s){let o=0,r=e,a=n;for(;r<t&&a<s;){let l=i.indexOf(et,r);(l===-1||l>t)&&(l=t);let h=i.indexOf(et,a);if((h===-1||h>s)&&(h=s),kt(i,a,h)){let c=ge(i,i[r]===45?r+1:r,l);c>o&&(o=c)}r=l+1,a=h+1}return o}var st=new TextDecoder;function tt(i,e){let t=-1,n=e.charCodeAt(0);for(let s=0,o=i.length;s<o;s++){let r=i[s];if(s===t+1&&r!==n)break;r===xe&&(t=s)}return i.subarray(0,t+1)}function St(i,e){let t=0;for(let n=0;n<e;n++){let s=i.indexOf(xe,t);if(s===-1){t=i.length;break}t=s+1}return st.decode(i.subarray(0,t)).split(/\r?\n/).slice(0,e)}function ge(i,e,t){let n=0;for(let s=e;s<t;s++){let o=i[s];if(o>=48&&o<=57)n=n*10+(o-48);else break}return n}function Pt(i,e,t,n,s,{start:o,end:r,pathCol:a,metaCharCode:l,decoder:h,callback:c}){let d=0,p=0;for(;d<i.length;){let m=i.indexOf(xe,d);if(m===-1)break;let f=d;d=m+1;let x=f+e+s;for(;p<n.length&&x>=n[p];)p++;if(i[f]===l)continue;let b=f;for(let g=1;g<a;g++){let C=i.indexOf(Me,b);if(C===-1||C>=m){b=m;break}b=C+1}let v=i[b];if(v!==gt&&v!==pt)continue;let y=i.indexOf(Me,b);(y===-1||y>m)&&(y=m);let I=1/0,u=-1,S=b;for(;S<y;){let g=0,C=S+1;for(;C<y;C++){let w=i[C]-48;if(w<0||w>9)break;g=g*10+w}g<I&&(I=g),g>u&&(u=g),S=C}if(I>=r)return!0;if(u>=o){let g=i[m-1]===nt?m-1:m;c(h.decode(i.subarray(f,g)),it(t,n,p,f+e,s),I,u+1)}}return!1}var W=class{filehandle;index;chunkCache;requested=new Map;headerCache=new z({});bgzfWorkerPool;constructor({path:e,filehandle:t,url:n,tbiPath:s,tbiUrl:o,tbiFilehandle:r,csiPath:a,csiUrl:l,csiFilehandle:h,chunkCacheSize:c=wt,chunkCacheIdleTimeoutMs:d=bt,chunkCacheBudget:p,bgzfWorkerPool:m}){this.bgzfWorkerPool=m,this.filehandle=Ct(t,e,n),this.index=yt({tbiFilehandle:r,csiFilehandle:h,tbiPath:s,csiPath:a,tbiUrl:o,csiUrl:l,path:e,url:n}),this.chunkCache=new z({maxSize:c,sizeOf:f=>{let x=0;for(let b of f.segments)x+=b.byteLength;return x},cacheKey:f=>f.toString(),idleTimeoutMs:d,budget:p,fill:(f,x)=>this.readChunk(f,{signal:x})})}clearChunkCache(){this.chunkCache.clear(),this.requested.clear()}withCachedContainers(e){if(this.requested.size>2*this.chunkCache.size)for(let[n,s]of this.requested)this.chunkCache.has(s)||this.requested.delete(n);let t=[];for(let n=0;n<e.length;n++){let s=e[n],o=t[t.length-1],r=e[n+1],a;if(!this.chunkCache.has(s))for(let l of this.requested.values())l.minv.compareTo(s.minv)<=0&&l.maxv.compareTo(s.maxv)>=0&&(!o||l.minv.compareTo(o.maxv)>=0)&&(!r||l.maxv.compareTo(r.minv)<=0)&&(!a||l.fetchedSize()<a.fetchedSize())&&this.chunkCache.has(l)&&(a=l);t.push(a??s)}return t}async bytesForRegions(e,t={}){let n=[];for(let{refName:o,start:r,end:a}of e){let l=await this.index.blocksForRange(o,r,a,t);for(let h of l)n.push(h)}let s=0;for(let o of le(n))s+=o.fetchedSize();return s}async getLines(e,t,n,s){let o,r={},a,l;typeof s=="function"?a=s:(r=s,a=s.lineCallback,o=s.signal,l=s.onProgress);let h=await this.index.getMetadata(r),c=t??0,d=n??h.maxRefLength;if(c>d)throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(c===d)return;let p=await this.index.blocksForRange(e,c,d,r),m=this.withCachedContainers(p),f=h.format==="VCF",x=h.columnNumbers.ref||0,b=h.columnNumbers.start||0,v=f?8:h.columnNumbers.end||0,y=Math.max(x,b,v),I=h.metaChar?.charCodeAt(0),u=h.coordinateType==="1-based-closed"?-1:0,S=new TextEncoder,g=new TextDecoder,C=S.encode(e),w=new Int32Array(y+1),F=h.format==="GAF"?{start:c,end:d,pathCol:b,metaCharCode:I,decoder:g,callback:a}:void 0,k=0;for(let E of m)k+=E.fetchedSize();let R=0;l?.(0,k);let T=1,_=[],U=E=>{for(;_.length<Math.min(E,m.length);){let K=m[_.length];this.requested.set(K.toString(),K);let j=this.chunkCache.get(K,o);j.catch(()=>{}),_.push(j)}};U(1);for(let E=0,K=m.length;E<K;E++){let j=m[E],Be=await _[E],{cpositions:Z,dpositions:V}=Be;R+=j.fetchedSize(),l?.(R,k);let we=j.minv.dataPosition,be=p[E],ee=Be.segments,te=0;if(be!==j){te=Pe(Z,V,be.minv);let P=Pe(Z,V,be.maxv)+1;ee=Ye(ee,te,P)}if(F){if(Se(ee,te,(P,ne)=>Pt(P,ne,Z,V,we,F)))return}else if(Se(ee,te,(P,ne)=>{let M=0,ie=0;for(;M<P.length;){let B=P.indexOf(xe,M);if(B===-1)break;let rt=M+ne+we;for(;ie<V.length&&rt>=V[ie];)ie++;if(I!==void 0&&P[M]===I){M=B+1;continue}w[0]=M-1;for(let N=0;N<y;N++){let oe=w[N],Ce=oe<B?P.indexOf(Me,oe+1):-1;w[N+1]=Ce===-1||Ce>=B?B:Ce}let Ne=w[x-1]+1,Re=w[x]-Ne;if(Re!==C.length){M=B+1;continue}let Ee=!0;for(let N=0;N<Re;N++)if(P[Ne+N]!==C[N]){Ee=!1;break}if(!Ee){M=B+1;continue}let se=ge(P,w[b-1]+1,w[b])+u;if(se>=d)return!0;let J;if(v===0||v===b?J=se+1:f?J=It(P,se,w[3]+1,w[4],w[v-1]+1,w[v],w[5]):J=ge(P,w[v-1]+1,w[v]),J>c){let N=P[B-1]===nt?B-1:B,oe=g.decode(P.subarray(M,N));a(oe,it(Z,V,ie,M+ne,we),se,J)}M=B+1}return!1}))return;T=Math.min(T*2,xt),U(E+1+T)}}async getMetadata(e={}){return this.index.getMetadata(e)}async readHeaderBytes(e){let{firstDataLine:t,maxBlockSize:n}=await this.getMetadata(e);if(t?.blockPosition===0&&t.dataPosition===0)return new Uint8Array(0);let s=(t?.blockPosition??0)+n,o=await this.filehandle.read(s,0,e);return ce(o)}async parseHeader(e){let{metaChar:t,skipLines:n=0}=await this.getMetadata(e),s=await this.readHeaderBytes(e);return{header:st.decode(t?tt(s,t):s),skippedLines:n>0?St(s,n):[]}}getParsedHeader(e={}){return this.headerCache.get("header",e.signal,t=>this.parseHeader({...e,signal:t}))}async getHeaderBuffer(e={}){let{metaChar:t}=await this.getMetadata(e),n=await this.readHeaderBytes(e);return t?tt(n,t):n}async getSkippedLines(e={}){let{skipLines:t=0}=await this.getMetadata(e);return t<=0?[]:(await this.getParsedHeader(e)).skippedLines}async getHeader(e={}){return(await this.getParsedHeader(e)).header}async getHeaderLines(e={}){let{header:t,skippedLines:n}=await this.getParsedHeader(e);return(t?t.split(/\r?\n/):n).filter(Boolean)}async getReferenceSequenceNames(e={}){return(await this.getMetadata(e)).refIdToName}async lineCount(e,t={}){return this.index.lineCount(e,t)}async readChunk(e,t={}){let n=await this.filehandle.read(e.fetchedSize(),e.minv.blockPosition,t);H(t.signal);let s=await this.bgzfWorkerPool;return qe(n,e,s)}};function Mn(i,e,t){let n=i.pluginManager;return new W({filehandle:ae(i.getConf(e),n),...Oe(i.getConf([...t,"location"]),i.getConf([...t,"indexType"]),n)})}function Bn(i){let e=i.getConf("walksIndex");return Tt(i.getConf("walksLocation"),Fe(e)?e:void 0,i.pluginManager)}function Tt(i,e,t){return $e.fromFilehandles({data:ae(i,t),directory:ae(e??Le(i,n=>`${n}.idx`),t)})}function Nn(i){return{names:e=>i.getReferenceSequenceNames(e),bytes:(e,t)=>Ve(i,e,t)}}function At(i){return`${i.assemblyName} ${i.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${i.assemblyName} mapped to its prefix in assemblyNameToPanSN`}var ot=class{constructor(e,t){this.source=e;this.adapter=t;this.lookup=je({setup:async e=>De(await this.source.names(e))})}async assemblyRefNames(e={}){let t=await this.source.names(e),n=re(this.adapter,e.assemblyName),s=t.filter(o=>ye(o,n)).map(o=>ze(o));return s.length>0?[...new Set(s)]:t}async resolve(e,t){let n=await this.lookup(t);return He(n,re(this.adapter,e.assemblyName),e.refName)}async resolveMapped(e,t){let n=await this.resolve(e,t);if(n===void 0&&e.assemblyName){let s=await this.source.names(t),o=re(this.adapter,e.assemblyName);if(s.length>0&&s.every(r=>r.includes("#"))&&!s.some(r=>ye(r,o)))throw new Error(At(e))}return n}async resolveForCut(e,t){let n=await this.resolveMapped(e,t);if(n===void 0)throw new Error(`This graph has nothing on ${e.assemblyName} ${e.refName}`);return n}async regionBytes(e,t={}){let n=[];for(let s of e){let o=await this.resolve(s,t);o!==void 0&&n.push({refName:o,start:s.start,end:s.end})}return this.source.bytes(n,t)}};export{Mt as a,je as b,Et as c,Mn as d,Bn as e,Tt as f,Nn as g,ot as h};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{f as Y,g as X,h as De,i as He,j as Ie,k as ce,l as qe,n as $e}from"./chunk-KGAZZNZC.js";import{a as ae,b as Oe}from"./chunk-D6TY2QEG.js";import{e as Fe,j as Le}from"./chunk-EGZZ3ADM.js";import{d as ze,g as ye,h as re}from"./chunk-RDTLCMD2.js";var D=JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"],Ue=i=>D!=null&&i in Object(D)?D[i]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+i+"' from '@jbrowse/core/data_adapters/BaseAdapter' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:i});var Mt=Ue("BaseFeatureDataAdapter");var je=Ue("cachedSetup");var Bt=D&&D.__esModule?D.default:D;async function Et(i,e,t,n,s){return Ie(e,t,n),i.getLines(e,t,n,s)}async function Ve(i,e,t){for(let{refName:n,start:s,end:o}of e)Ie(n,s,o);return i.bytesForRegions(e,t)}function H(i){if(i?.aborted)throw ke(i)}function ke(i){let e=i.reason;return e===void 0?new DOMException("This operation was aborted","AbortError"):e}function Ge(i){return typeof i?.addEventListener=="function"}var z=class{entries=new Map;total=0;settledCount=0;limit;shared;fill;sizeOf;toCacheKey;idleTimeoutMs;sweepTimer;constructor({fill:e,maxSize:t=1/0,sizeOf:n=()=>1,cacheKey:s=a=>String(a),idleTimeoutMs:o=0,budget:r}={}){this.fill=e,this.limit=t,this.shared=r&&{budget:r,membership:r.register(this)},this.sizeOf=n,this.toCacheKey=s,this.idleTimeoutMs=o>0&&Number.isFinite(o)?o:void 0}get size(){return this.entries.size}get totalSize(){return this.total}get maxSize(){return this.limit}set maxSize(e){this.limit=e,this.evict()}waiterCount(e){return this.entries.get(this.toCacheKey(e))?.pending?.signals.size??0}async get(e,t,n){H(t);let s=this.toCacheKey(e),o=this.entries.get(s);o&&this.isDoomed(o)&&(this.release(s),o=void 0),o?this.touch(s,o):o=this.start(s,e,n),o.pending&&this.join(o.pending,t);try{return await this.settleFor(o,t)}finally{H(t)}}settleFor(e,t){if(!e.pending||!Ge(t))return e.promise;let n,s=new Promise((r,a)=>{n=a}),o=()=>{n(ke(t))};return t.addEventListener("abort",o,{once:!0}),Promise.race([e.promise,s]).finally(()=>{t.removeEventListener("abort",o)})}getIfCached(e){let t=this.toCacheKey(e),n=this.entries.get(t);if(n){if(this.isDoomed(n)){this.release(t);return}return this.touch(t,n),n.promise}}has(e){let t=this.entries.get(this.toCacheKey(e));return t!==void 0&&!this.isDoomed(t)}delete(e){this.release(this.toCacheKey(e))}clear(){this.entries.clear(),this.shared?.budget.charge(this.shared.membership,-this.total),this.total=0,this.settledCount=0,this.stopSweep()}touch(e,t){this.entries.delete(e),this.entries.set(e,t),t.lastTouched=Date.now(),t.seq=this.stamp()}stamp(){return this.shared?.budget.nextSeq()??0}isDoomed(e){return e.pending?.controller.signal.aborted===!0}sweepIdle(){let e=this.idleTimeoutMs;if(e===void 0)return;let t=Date.now()-e;for(let[n,s]of this.entries)!s.pending&&s.lastTouched<=t&&this.release(n);this.settledCount===0&&this.stopSweep()}startSweep(){let e=this.idleTimeoutMs;if(e===void 0||this.sweepTimer!==void 0)return;let t=Math.min(2**31-1,Math.max(1e3,Math.floor(e/4))),n=new WeakRef(this),s=setInterval(()=>{let o=n.deref();o?o.sweepIdle():clearInterval(s)},t);this.sweepTimer=s,s.unref?.()}stopSweep(){this.sweepTimer!==void 0&&(clearInterval(this.sweepTimer),this.sweepTimer=void 0)}start(e,t,n){let s=n??(this.fill&&(h=>this.fill(t,h)));if(!s)throw new Error("SharedReadCache needs a fill, either on the cache or on the get() call");let o={signals:new Map,pinned:!1,controller:new AbortController},r={promise:Promise.resolve(s(o.controller.signal)),pending:o,size:0,lastTouched:Date.now(),seq:this.stamp()};this.entries.set(e,r);let a=()=>this.entries.get(e)===r,l=()=>{for(let[h,c]of o.signals)h.removeEventListener("abort",c);r.pending=void 0};return r.promise.then(h=>{let c=a()?this.weigh(h):void 0,d=a();l(),d&&(c===void 0?this.entries.delete(e):(r.lastTouched=Date.now(),r.size=c,this.settledCount++,this.total+=c,this.shared?.budget.charge(this.shared.membership,c),this.startSweep())),this.evict(),this.shared?.budget.evict()},()=>{a()&&this.release(e),l()}),r}weigh(e){try{let t=this.sizeOf(e);return Number.isFinite(t)&&t>=0?t:void 0}catch{return}}join(e,t){if(!Ge(t))e.pinned=!0;else if(!t.aborted&&!e.signals.has(t)){let n=()=>{e.signals.delete(t),!e.pinned&&e.signals.size===0&&e.controller.abort(t.reason)};e.signals.set(t,n),t.addEventListener("abort",n,{once:!0})}}release(e){let t=this.entries.get(e);t&&(this.entries.delete(e),t.pending||this.settledCount--,this.total-=t.size,this.shared?.budget.charge(this.shared.membership,-t.size))}lruSpare(e=!1){if(!(this.settledCount<=(e?0:1))){for(let[t,n]of this.entries)if(!n.pending)return{cacheKey:t,seq:n.seq,last:this.settledCount===1}}}evict(){if(!(this.total<=this.limit))for(let[e,t]of this.entries){if(this.total<=this.limit||this.settledCount<=1)break;t.pending||this.release(e)}}};var A=class{minv;maxv;bin;endPosition;constructor(e,t,n,s=t.blockPosition+65536){this.minv=e,this.maxv=t,this.bin=n,this.endPosition=s}toString(){return`${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}fetchedSize(){return this.endPosition-this.minv.blockPosition}};function ve(i,e){if(!(e>0))throw new TypeError(`\`${i}\` must be a number greater than 0`)}var Q=class{#e=new Map;#t=new Map;#n;#s;#o;constructor(e){let t=e.maxAge??Number.POSITIVE_INFINITY;ve("maxSize",e.maxSize),ve("maxAge",t),this.#n=e.maxSize,this.#s=t,this.#o=e.onEviction}#r(e){let t=this.#o;if(t)for(let[n,s]of e)t(n,s.value)}#i(e,t){return t.expiry!==void 0&&t.expiry<=Date.now()?(this.#o?.(e,t.value),this.delete(e),!0):!1}#c(e,t){return this.#i(e,t)?void 0:t.value}#l(e,t){if(this.#t.delete(e),this.#e.set(e,t),this.#e.size>=this.#n){let n=this.#t;this.#t=this.#e,this.#e=new Map,this.#r(n)}}#h(e){this.#t=new Map(e),this.#e=new Map}*#a(){for(let e of[this.#t,this.#e])for(let t of e)this.#i(...t)||(yield t)}get(e){let t=this.#e.get(e);if(t)return this.#c(e,t);let n=this.#t.get(e);if(n&&!this.#i(e,n))return this.#l(e,n),n.value}set(e,t,{maxAge:n=this.#s}={}){let s={value:t,expiry:n===Number.POSITIVE_INFINITY?void 0:Date.now()+n};return this.#e.has(e)?this.#e.set(e,s):this.#l(e,s),this}has(e){let t=this.#e.get(e)??this.#t.get(e);return t!==void 0&&!this.#i(e,t)}peek(e){let t=this.#e.get(e)??this.#t.get(e);return t?this.#c(e,t):void 0}expiresIn(e){let t=this.#e.get(e)??this.#t.get(e);if(t)return t.expiry===void 0?Number.POSITIVE_INFINITY:t.expiry-Date.now()}delete(e){return this.#e.delete(e)||this.#t.delete(e)}clear(){this.#e.clear(),this.#t.clear()}resize(e){ve("maxSize",e);let t=[...this.#a()],n=t.length-e;n<0?(this.#e=new Map(t),this.#t=new Map):(this.#r(t.slice(0,n)),this.#h(t.slice(n))),this.#n=e}evict(e=1){if(!(e>0))return;let t=[...this.#a()],n=Math.trunc(Math.min(e,t.length-1));n>0&&(this.#r(t.slice(0,n)),this.#h(t.slice(n)))}get size(){return Math.min(this.#e.size+this.#t.size,this.#n)}get maxSize(){return this.#n}get maxAge(){return this.#s}*entriesAscending(){for(let[e,t]of this.#a())yield[e,t.value]}*entriesDescending(){for(let e of[this.#e,this.#t])for(let[t,n]of[...e].reverse())this.#i(t,n)||(yield[t,n.value])}entries(){return this.entriesAscending()}[Symbol.iterator](){return this.entriesAscending()}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}forEach(e,t=this){for(let[n,s]of this)e.call(t,s,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};function We(i,e=0){let t=i[e]|i[e+1]<<8|i[e+2]<<16|i[e+3]<<24;return((i[e+4]|i[e+5]<<8|i[e+6]<<16|i[e+7]<<24)>>>0)*4294967296+(t>>>0)}var G=class{blockPosition;dataPosition;constructor(e,t){this.blockPosition=e,this.dataPosition=t}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}};function O(i,e=0){return new G(i[e+7]*1099511627776+i[e+6]*4294967296+i[e+5]*16777216+i[e+4]*65536+i[e+3]*256+i[e+2],i[e+1]<<8|i[e])}function le(i,e){let t=i.length;if(t===0)return i;let n;if(e){let a=e.blockPosition,l=e.dataPosition;n=[];for(let h=0;h<t;h++){let c=i[h];(c.maxv.blockPosition-a||c.maxv.dataPosition-l)>0&&n.push(c)}if(n.length===0)return n}else n=i;n.sort((a,l)=>{let h=a.minv.blockPosition-l.minv.blockPosition;return h===0?a.minv.dataPosition-l.minv.dataPosition:h});let s=[n[0]],o=n[0].minv.blockPosition,r=n[0].maxv.blockPosition;for(let a=1;a<n.length;a++){let l=n[a],h=l.minv.blockPosition,c=l.maxv.blockPosition;if(h-r<65e3&&c-o<5e6){let d=s.at(-1);(c-r||l.maxv.dataPosition-d.maxv.dataPosition)>0&&(s[s.length-1]=new A(d.minv,l.maxv,d.bin,l.endPosition),r=c)}else s.push(l),o=h,r=c}return at(s)}function at(i){let e=[i[0]];for(let t=1;t<i.length;t++){let n=i[t],s=e.at(-1).maxv;if((n.minv.blockPosition-s.blockPosition||n.minv.dataPosition-s.dataPosition)>=0){e.push(n);continue}(n.maxv.blockPosition-s.blockPosition||n.maxv.dataPosition-s.dataPosition)>0&&e.push(new A(s,n.maxv,n.bin,n.endPosition))}return e}function he(i,e=[]){let t=[...e];for(let n of i)t.push(n.minv.blockPosition,n.maxv.blockPosition);t.sort((n,s)=>n-s);for(let n of i){let s=n.maxv.blockPosition,o=0,r=t.length;for(;o<r;){let a=o+r>>>1;t[a]>s?r=a:o=a+1}o<t.length&&(n.endPosition=Math.min(n.endPosition,t[o]))}}function de(i,e,t,n,s=8){let o=n?n.blockPosition:1/0,r=n?n.dataPosition:0,a=!1;for(let l=0;l<t;l++){let h=e+l*s,c=i[h+7]*1099511627776+i[h+6]*4294967296+i[h+5]*16777216+i[h+4]*65536+i[h+3]*256+i[h+2],d=i[h+1]<<8|i[h];(c<o||c===o&&d<r)&&(o=c,r=d,a=!0)}return a?new G(o,r):n}function ct(i){let e=new TextDecoder("utf-8"),t=[],n={},s=0,o=0;for(;o<i.length;){let r=i.indexOf(0,o);if(r===-1)break;if(r>o){let a=e.decode(i.subarray(o,r));t[s]=a,n[a]=s}o=r+1,s++}return{refNameToId:n,refIdToName:t}}var lt={0:"generic",1:"SAM",2:"VCF",3:"GAF"};function fe(i,e){let t=new DataView(i.buffer,i.byteOffset,i.byteLength),n=t.getInt32(e,!0),s=n&65536?"zero-based-half-open":"1-based-closed",o=lt[n&15];if(!o)throw new Error(`invalid Tabix preset format flags ${n}`);let r={ref:t.getInt32(e+4,!0),start:t.getInt32(e+8,!0),end:t.getInt32(e+12,!0)},a=t.getInt32(e+16,!0),l=a?String.fromCharCode(a):void 0,h=t.getInt32(e+20,!0),c=t.getInt32(e+24,!0),{refIdToName:d,refNameToId:p}=ct(i.subarray(e+28,e+28+c));return{refIdToName:d,refNameToId:p,skipLines:h,metaChar:l,columnNumbers:r,format:o,coordinateType:s}}function ue(i,e){return{lineCount:We(i,e)}}function me(i,e=5){let t=new Q({maxSize:e});return n=>{let s=t.get(n);if(s!==void 0)return s;let o=i(n);return o!==void 0&&t.set(n,o),o}}function Ke(i){let e=0;for(let s of i)e+=s.length;let t=new Uint8Array(e),n=0;for(let s of i)t.set(s,n),n+=s.length;return t}var Je=10;function Se(i,e,t){let n,s=0;for(let o of i){let r=0;if(n){let h=o.indexOf(Je);if(h===-1){n=Ke([n,o]),e+=o.length;continue}if(t(Ke([n,o.subarray(0,h+1)]),s))return!0;r=h+1,n=void 0}let a=o.lastIndexOf(Je);if(a>=r&&t(o.subarray(r,a+1),e+r))return!0;let l=Math.max(r,a+1);l<o.length&&(n=o.slice(l),s=e+l),e+=o.length}return!1}function Ye(i,e,t){let n=[],s=0;for(let o of i){let r=Math.max(e-s,0),a=Math.min(t-s,o.length);r<a&&n.push(o.subarray(r,a)),s+=o.length}return n}function Pe(i,e,t){let n=0,s=i.length-1;for(;n<s;){let r=n+s+1>>>1;i[r]<=t.blockPosition?n=r:s=r-1}return(n===0?0:e[n])-e[0]+t.dataPosition}function ht(i,e,t,n){if(e>2**(t+n*3))return;let s=(8**(n+1)-1)/7,o=(8**n-1)/7+Math.floor((e-1)/2**t)+1;for(o>=s&&(o=0);;){for(;o%8===1;)o=(o-1)/8;if(o===0)return;let r=i[o];if(r?.length){let a=r[0].minv;for(let l=1;l<r.length;l++){let h=r[l].minv;h.compareTo(a)<0&&(a=h)}return a}o++}}function Xe(i,e){return i.format==="GAF"?0:i.refNameToId[e]}var q=class{filehandle;parseCache=new z({});constructor({filehandle:e}){this.filehandle=e}async readIndexBytes(e){let t=await this.filehandle.readFile({signal:e.signal,onProgress:e.onProgress}),n=await ce(t);return{bytes:n,dataView:new DataView(n.buffer,n.byteOffset,n.byteLength)}}async lineCount(e,t={}){let n=await this.parse(t),s=Xe(n,e);return s===void 0?-1:n.indices(s)?.stats?.lineCount??-1}async getMetadata(e={}){let{indices:t,...n}=await this.parse(e);return n}async blocksForRange(e,t,n,s={}){let o=await this.parse(s),r=Xe(o,e);if(r===void 0)return[];let a=o.indices(r);if(!a)return[];o.format==="GAF"&&(t=Math.max(t-1,0));let l=[];for(let[m,f]of this.reg2bins(t,n,o))for(let x=m;x<=f;x++){let b=a.binIndex[x];if(b)for(let v of b)l.push(v)}let h=this.lowestOffset(a,t,o),c=le(l,h),d=ht(a.binIndex,n,o.minShift,o.depth);if(d){let m=c.length;for(;m>0&&c[m-1].minv.compareTo(d)>=0;)m--;c.length=m}let p=c[0];if(p&&h){let m=2**(o.minShift+3),f=this.lowestOffset(a,Math.floor(t/m)*m,o),x=f&&f.compareTo(h)<0?f:h;p.minv.compareTo(x)<0&&(c[0]=new A(x,p.maxv,p.bin,p.endPosition))}return c}parse(e={}){return this.parseCache.get("index",e.signal,t=>this._parse({...e,signal:t}))}async hasRefSeq(e,t={}){return!!(await this.parse(t)).indices(e)?.binIndex}};var dt=21582659,ft=38359875;function Qe(i,e){return i*2**e}function Te(i,e){return Math.floor(i/2**e)}var $=class extends q{async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e),s=n.getUint32(0,!0),o;if(s===dt)o=1;else if(s===ft)o=2;else throw new Error(`Not a CSI file (magic=${s})`);let r=n.getInt32(4,!0),a=n.getInt32(8,!0),l=(8**(a+1)-1)/7,h=2**(r+a*3),c=n.getInt32(12,!0),d=c>=28&&(n.getInt32(16,!0)&15)===3;if(c<30&&!d)throw new Error("CSI index has no tabix header, so it names no references; it may be a BAM or BCF index");let p=fe(t,16),m=n.getInt32(16+c,!0),f=16+c+4,x,b=[];for(let y=0;y<m;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let u=0;u<I;u++){let S=n.getUint32(f,!0);if(f+=4,S>l)f+=44;else{x=de(t,f,1,x),f+=8;let g=n.getInt32(f,!0);f+=4+16*g}}}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C={},w;for(let F=0;F<S;F++){let k=n.getUint32(u,!0);if(u+=4,k>l)w=ue(t,u+28),u+=44;else{C[k]=O(t,u),u+=8;let R=n.getInt32(u,!0);u+=4;let T=Array.from({length:R});for(let _=0;_<R;_++)T[_]=new A(O(t,u),O(t,u+8),k),u+=16;g[k]=T}}return he(Object.values(g).flat()),{binIndex:g,loffsets:C,stats:w}}return{...p,csi:!0,refCount:m,maxBlockSize:65536,firstDataLine:x,csiVersion:o,indices:me(v),minShift:r,depth:a,maxBinNumber:l,maxRefLength:h}}lowestOffset(e,t,{minShift:n,depth:s}){let{loffsets:o}=e,r;if(o){let a=(Qe(1,3*s)-1)/7+Te(Math.max(t,0),n);for(;r===void 0&&a>0;)if(r=o[a],r===void 0){let l=Math.floor((a-1)/8),h=l*8+1;a=a>h?a-1:l}r??=o[0]}return r}reg2bins(e,t,{minShift:n,depth:s,maxBinNumber:o}){e=Math.max(e,0);let r=2**(n+s*3);t>r&&(t=r),t-=1;let a=0,l=0,h=n+s*3,c=[];for(;a<=s;h-=3,l+=Qe(1,a*3),a+=1){let d=l+Te(e,h),p=l+Te(t,h);if(p-d+c.length>o)throw new Error(`query ${e}-${t} is too large for current binning scheme (shift ${n}, depth ${s}), try a smaller query or a coarser index binning scheme`);c.push([d,p])}return c}};var ut=21578324,Ae=5,_e=14,pe=2**(_e+Ae*3);function Ze(i){return Math.min(Math.max(i,0),pe)}var L=class extends q{reg2bins(e,t){e>pe&&console.warn("querying outside of possible tabix range");let n=Ze(e),s=Math.min(t,pe)-1,o=[];return n<=s&&o.push([0,0],[1+(n>>26),1+(s>>26)],[9+(n>>23),9+(s>>23)],[73+(n>>20),73+(s>>20)],[585+(n>>17),585+(s>>17)],[4681+(n>>14),4681+(s>>14)]),o}lowestOffset(e,t){let n=e.linearIndex;return n?.[Math.min(Ze(t)>>_e,n.length-1)]}async _parse(e={}){let{bytes:t,dataView:n}=await this.readIndexBytes(e);if(n.getUint32(0,!0)!==ut)throw new Error("Not a TBI file");let s=n.getUint32(4,!0),o=((1<<(Ae+1)*3)-1)/7,{refNameToId:r,refIdToName:a,coordinateType:l,format:h,columnNumbers:c,metaChar:d,skipLines:p}=fe(t,8),f=36+n.getInt32(32,!0),x,b=[];for(let y=0;y<s;y++){b.push(f);let I=n.getInt32(f,!0);f+=4;for(let S=0;S<I;S++){let g=n.getUint32(f,!0);f+=4;let C=n.getInt32(f,!0);if(f+=4,g>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");g<=o&&(x=de(t,f,C,x,16)),f+=16*C}let u=n.getInt32(f,!0);f+=4+8*u}function v(y){let I=b[y];if(I===void 0)return;let u=I,S=n.getInt32(u,!0);u+=4;let g={},C;for(let k=0;k<S;k++){let R=n.getUint32(u,!0);if(u+=4,R>o+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(R===o+1){let T=n.getInt32(u,!0);u+=4,T===2&&(C=ue(t,u+16)),u+=16*T}else{let T=n.getInt32(u,!0);u+=4;let _=Array.from({length:T});for(let U=0;U<T;U++)_[U]=new A(O(t,u),O(t,u+8),R),u+=16;g[R]=_}}let w=n.getInt32(u,!0);u+=4;let F=Array.from({length:w});for(let k=0;k<w;k++)F[k]=O(t,u),u+=8;return he(Object.values(g).flat(),F.map(k=>k.blockPosition)),{binIndex:g,linearIndex:F,stats:C}}return{indices:me(v),metaChar:d,minShift:_e,depth:Ae,maxBinNumber:o,maxRefLength:pe,skipLines:p,firstDataLine:x,columnNumbers:c,coordinateType:l,format:h,refIdToName:a,refNameToId:r,maxBlockSize:65536}}};var Me=9,xe=10,nt=13,mt=59,pt=60,gt=62,xt=6,wt=1024*2**20,bt=180*1e3;function Ct(i,e,t){if(i)return i;if(e)return new X(e);if(t)return new Y(t);throw new TypeError("must provide either filehandle, path, or url")}function yt({tbiFilehandle:i,csiFilehandle:e,tbiPath:t,csiPath:n,tbiUrl:s,csiUrl:o,path:r,url:a}){if(i)return new L({filehandle:i});if(e)return new $({filehandle:e});if(t)return new L({filehandle:new X(t)});if(n)return new $({filehandle:new X(n)});if(o)return new $({filehandle:new Y(o)});if(s)return new L({filehandle:new Y(s)});if(r)return new L({filehandle:new X(`${r}.tbi`)});if(a)return new L({filehandle:new Y(`${a}.tbi`)});throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, csiPath, tbiUrl, csiUrl")}function it(i,e,t,n,s){return i[t]*256+(n-e[t])+s+1}function It(i,e,t,n,s,o,r){let a=n-t,l=e+a,h=0;if(i[s]===46)return l;let c=s;for(let d=s;d<=o;d++)if(d===o||i[d]===mt){let p=d-c;if(p>=10&&i[c]===83&&i[c+1]===86&&i[c+2]===84&&i[c+3]===89&&i[c+4]===80&&i[c+5]===69&&i[c+6]===61&&i[c+7]===84&&i[c+8]===82&&i[c+9]===65)return e+1;if(p>=4&&i[c]===69&&i[c+1]===78&&i[c+2]===68&&i[c+3]===61){let m=ge(i,c+4,d);m>e&&(l=m)}else p>=6&&i[c]===83&&i[c+1]===86&&i[c+2]===76&&i[c+3]===69&&i[c+4]===78&&i[c+5]===61&&(h=vt(i,c+6,d,n+1,r));c=d+1}return Math.max(l,e+h)}var et=44;function kt(i,e,t){if(t-e<5||i[e]!==60||i[t-1]!==62)return!1;let n=i[e+4];if(n!==62&&n!==58)return!1;let s=i[e+1],o=i[e+2],r=i[e+3];return s===67&&o===78&&r===86||s===68&&o===69&&r===76||s===68&&o===85&&r===80||s===73&&o===78&&r===86}function vt(i,e,t,n,s){let o=0,r=e,a=n;for(;r<t&&a<s;){let l=i.indexOf(et,r);(l===-1||l>t)&&(l=t);let h=i.indexOf(et,a);if((h===-1||h>s)&&(h=s),kt(i,a,h)){let c=ge(i,i[r]===45?r+1:r,l);c>o&&(o=c)}r=l+1,a=h+1}return o}var st=new TextDecoder;function tt(i,e){let t=-1,n=e.charCodeAt(0);for(let s=0,o=i.length;s<o;s++){let r=i[s];if(s===t+1&&r!==n)break;r===xe&&(t=s)}return i.subarray(0,t+1)}function St(i,e){let t=0;for(let n=0;n<e;n++){let s=i.indexOf(xe,t);if(s===-1){t=i.length;break}t=s+1}return st.decode(i.subarray(0,t)).split(/\r?\n/).slice(0,e)}function ge(i,e,t){let n=0;for(let s=e;s<t;s++){let o=i[s];if(o>=48&&o<=57)n=n*10+(o-48);else break}return n}function Pt(i,e,t,n,s,{start:o,end:r,pathCol:a,metaCharCode:l,decoder:h,callback:c}){let d=0,p=0;for(;d<i.length;){let m=i.indexOf(xe,d);if(m===-1)break;let f=d;d=m+1;let x=f+e+s;for(;p<n.length&&x>=n[p];)p++;if(i[f]===l)continue;let b=f;for(let g=1;g<a;g++){let C=i.indexOf(Me,b);if(C===-1||C>=m){b=m;break}b=C+1}let v=i[b];if(v!==gt&&v!==pt)continue;let y=i.indexOf(Me,b);(y===-1||y>m)&&(y=m);let I=1/0,u=-1,S=b;for(;S<y;){let g=0,C=S+1;for(;C<y;C++){let w=i[C]-48;if(w<0||w>9)break;g=g*10+w}g<I&&(I=g),g>u&&(u=g),S=C}if(I>=r)return!0;if(u>=o){let g=i[m-1]===nt?m-1:m;c(h.decode(i.subarray(f,g)),it(t,n,p,f+e,s),I,u+1)}}return!1}var W=class{filehandle;index;chunkCache;requested=new Map;headerCache=new z({});bgzfWorkerPool;constructor({path:e,filehandle:t,url:n,tbiPath:s,tbiUrl:o,tbiFilehandle:r,csiPath:a,csiUrl:l,csiFilehandle:h,chunkCacheSize:c=wt,chunkCacheIdleTimeoutMs:d=bt,chunkCacheBudget:p,bgzfWorkerPool:m}){this.bgzfWorkerPool=m,this.filehandle=Ct(t,e,n),this.index=yt({tbiFilehandle:r,csiFilehandle:h,tbiPath:s,csiPath:a,tbiUrl:o,csiUrl:l,path:e,url:n}),this.chunkCache=new z({maxSize:c,sizeOf:f=>{let x=0;for(let b of f.segments)x+=b.byteLength;return x},cacheKey:f=>f.toString(),idleTimeoutMs:d,budget:p,fill:(f,x)=>this.readChunk(f,{signal:x})})}clearChunkCache(){this.chunkCache.clear(),this.requested.clear()}withCachedContainers(e){if(this.requested.size>2*this.chunkCache.size)for(let[n,s]of this.requested)this.chunkCache.has(s)||this.requested.delete(n);let t=[];for(let n=0;n<e.length;n++){let s=e[n],o=t[t.length-1],r=e[n+1],a;if(!this.chunkCache.has(s))for(let l of this.requested.values())l.minv.compareTo(s.minv)<=0&&l.maxv.compareTo(s.maxv)>=0&&(!o||l.minv.compareTo(o.maxv)>=0)&&(!r||l.maxv.compareTo(r.minv)<=0)&&(!a||l.fetchedSize()<a.fetchedSize())&&this.chunkCache.has(l)&&(a=l);t.push(a??s)}return t}async bytesForRegions(e,t={}){let n=[];for(let{refName:o,start:r,end:a}of e){let l=await this.index.blocksForRange(o,r,a,t);for(let h of l)n.push(h)}let s=0;for(let o of le(n))s+=o.fetchedSize();return s}async getLines(e,t,n,s){let o,r={},a,l;typeof s=="function"?a=s:(r=s,a=s.lineCallback,o=s.signal,l=s.onProgress);let h=await this.index.getMetadata(r),c=t??0,d=n??h.maxRefLength;if(c>d)throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(c===d)return;let p=await this.index.blocksForRange(e,c,d,r),m=this.withCachedContainers(p),f=h.format==="VCF",x=h.columnNumbers.ref||0,b=h.columnNumbers.start||0,v=f?8:h.columnNumbers.end||0,y=Math.max(x,b,v),I=h.metaChar?.charCodeAt(0),u=h.coordinateType==="1-based-closed"?-1:0,S=new TextEncoder,g=new TextDecoder,C=S.encode(e),w=new Int32Array(y+1),F=h.format==="GAF"?{start:c,end:d,pathCol:b,metaCharCode:I,decoder:g,callback:a}:void 0,k=0;for(let E of m)k+=E.fetchedSize();let R=0;l?.(0,k);let T=1,_=[],U=E=>{for(;_.length<Math.min(E,m.length);){let K=m[_.length];this.requested.set(K.toString(),K);let j=this.chunkCache.get(K,o);j.catch(()=>{}),_.push(j)}};U(1);for(let E=0,K=m.length;E<K;E++){let j=m[E],Be=await _[E],{cpositions:Z,dpositions:V}=Be;R+=j.fetchedSize(),l?.(R,k);let we=j.minv.dataPosition,be=p[E],ee=Be.segments,te=0;if(be!==j){te=Pe(Z,V,be.minv);let P=Pe(Z,V,be.maxv)+1;ee=Ye(ee,te,P)}if(F){if(Se(ee,te,(P,ne)=>Pt(P,ne,Z,V,we,F)))return}else if(Se(ee,te,(P,ne)=>{let M=0,ie=0;for(;M<P.length;){let B=P.indexOf(xe,M);if(B===-1)break;let rt=M+ne+we;for(;ie<V.length&&rt>=V[ie];)ie++;if(I!==void 0&&P[M]===I){M=B+1;continue}w[0]=M-1;for(let N=0;N<y;N++){let oe=w[N],Ce=oe<B?P.indexOf(Me,oe+1):-1;w[N+1]=Ce===-1||Ce>=B?B:Ce}let Ne=w[x-1]+1,Re=w[x]-Ne;if(Re!==C.length){M=B+1;continue}let Ee=!0;for(let N=0;N<Re;N++)if(P[Ne+N]!==C[N]){Ee=!1;break}if(!Ee){M=B+1;continue}let se=ge(P,w[b-1]+1,w[b])+u;if(se>=d)return!0;let J;if(v===0||v===b?J=se+1:f?J=It(P,se,w[3]+1,w[4],w[v-1]+1,w[v],w[5]):J=ge(P,w[v-1]+1,w[v]),J>c){let N=P[B-1]===nt?B-1:B,oe=g.decode(P.subarray(M,N));a(oe,it(Z,V,ie,M+ne,we),se,J)}M=B+1}return!1}))return;T=Math.min(T*2,xt),U(E+1+T)}}async getMetadata(e={}){return this.index.getMetadata(e)}async readHeaderBytes(e){let{firstDataLine:t,maxBlockSize:n}=await this.getMetadata(e);if(t?.blockPosition===0&&t.dataPosition===0)return new Uint8Array(0);let s=(t?.blockPosition??0)+n,o=await this.filehandle.read(s,0,e);return ce(o)}async parseHeader(e){let{metaChar:t,skipLines:n=0}=await this.getMetadata(e),s=await this.readHeaderBytes(e);return{header:st.decode(t?tt(s,t):s),skippedLines:n>0?St(s,n):[]}}getParsedHeader(e={}){return this.headerCache.get("header",e.signal,t=>this.parseHeader({...e,signal:t}))}async getHeaderBuffer(e={}){let{metaChar:t}=await this.getMetadata(e),n=await this.readHeaderBytes(e);return t?tt(n,t):n}async getSkippedLines(e={}){let{skipLines:t=0}=await this.getMetadata(e);return t<=0?[]:(await this.getParsedHeader(e)).skippedLines}async getHeader(e={}){return(await this.getParsedHeader(e)).header}async getHeaderLines(e={}){let{header:t,skippedLines:n}=await this.getParsedHeader(e);return(t?t.split(/\r?\n/):n).filter(Boolean)}async getReferenceSequenceNames(e={}){return(await this.getMetadata(e)).refIdToName}async lineCount(e,t={}){return this.index.lineCount(e,t)}async readChunk(e,t={}){let n=await this.filehandle.read(e.fetchedSize(),e.minv.blockPosition,t);H(t.signal);let s=await this.bgzfWorkerPool;return qe(n,e,s)}};function Mn(i,e,t){let n=i.pluginManager;return new W({filehandle:ae(i.getConf(e),n),...Oe(i.getConf([...t,"location"]),i.getConf([...t,"indexType"]),n)})}function Bn(i){let e=i.getConf("walksIndex");return Tt(i.getConf("walksLocation"),Fe(e)?e:void 0,i.pluginManager)}function Tt(i,e,t){return $e.fromFilehandles({data:ae(i,t),directory:ae(e??Le(i,n=>`${n}.idx`),t)})}function Nn(i){return{names:e=>i.getReferenceSequenceNames(e),bytes:(e,t)=>Ve(i,e,t)}}function At(i){return`${i.assemblyName} ${i.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${i.assemblyName} mapped to its prefix in assemblyNameToPanSN`}var ot=class{constructor(e,t){this.source=e;this.adapter=t;this.lookup=je({setup:async e=>De(await this.source.names(e))})}async assemblyRefNames(e={}){let t=await this.source.names(e),n=re(this.adapter,e.assemblyName),s=t.filter(o=>ye(o,n)).map(o=>ze(o));return s.length>0?[...new Set(s)]:t}async resolve(e,t){let n=await this.lookup(t);return He(n,re(this.adapter,e.assemblyName),e.refName)}async resolveMapped(e,t){let n=await this.resolve(e,t);if(n===void 0&&e.assemblyName){let s=await this.source.names(t),o=re(this.adapter,e.assemblyName);if(s.length>0&&s.every(r=>r.includes("#"))&&!s.some(r=>ye(r,o)))throw new Error(At(e))}return n}async resolveForCut(e,t){let n=await this.resolveMapped(e,t);if(n===void 0)throw new Error(`This graph has nothing on ${e.assemblyName} ${e.refName}`);return n}async regionBytes(e,t={}){let n=[];for(let s of e){let o=await this.resolve(s,t);o!==void 0&&n.push({refName:o,start:s.start,end:s.end})}return this.source.bytes(n,t)}};export{Mt as a,je as b,Et as c,Mn as d,Bn as e,Tt as f,Nn as g,ot as h};
|
|
2
|
+
//# sourceMappingURL=chunk-RUKWE5MB.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as ei}from"./chunk-QOMV5OG7.js";import{d as rr,i as ti,j as ri,l as Wt,m as Ht,n as Ft,o as oi,p as ni}from"./chunk-AC5KEN36.js";import{A as Yo,Ab as Qe,B as fr,Bb as et,Bc as qn,C as gr,Cb as Pn,D as ze,E as ve,Eb as An,F as on,Fa as cn,Fb as Tn,G as we,Ga as Pt,Gc as Jn,H as Ke,Ha as mn,Hb as Wr,I as yr,Ib as Et,J as Ue,Ja as ln,Jb as Gt,Ka as un,L as kr,Lb as En,M as K,Mb as Gn,N as J,Nb as In,Nc as ii,O as pe,Ob as Bn,Pb as Le,Rc as ai,Sa as hn,Sb as Ne,T as nn,Tb as It,U as ce,Ua as fn,Ub as oe,Uc as Fr,Va as Ir,Vb as Bt,Wa as gn,Wc as si,X as vt,Xb as Ct,Xc as di,Y as an,Yb as _t,Yc as pi,Z as Lt,Za as Je,_ as Rr,_b as Cn,ac as _n,b as He,bc as On,ca as xr,cb as wn,cc as Ot,da as Nt,db as bn,dc as $n,eb as Br,ec as Wn,fa as Sr,fc as Hn,ga as vr,gb as yn,gc as Fn,gd as ci,ha as F,hc as $t,ja as Lr,jc as Dn,kb as Cr,la as Nr,lb as kn,mb as Rn,na as Ze,nb as xn,nc as Xn,oa as Mr,oc as Vn,pa as Pr,pb as Sn,pc as jn,q as Ho,qa as Ar,ra as Tr,rc as tt,sa as Er,sb as Ln,ta as Gr,tc as zn,u as ur,ua as qe,ub as be,uc as Yn,v as Xo,va as Mt,vb as Nn,vc as Kn,w as hr,wa as sn,wb as Tt,wc as Un,x as Vo,xb as Mn,xc as Hr,y as jo,ya as dn,yb as Or,yc as Zn,z as zo,za as pn,zb as $r}from"./chunk-M5XKM6D2.js";import{B as br,D as xt,O as Ye,P as tn,Q as rn,R as St,b as Ko,c as q,d as Uo,g as Zo,l as qo,m as Jo,n as Qo,o as en,x as wr}from"./chunk-VY7G4FSX.js";import{$ as yt,B as Xe,C as gt,G as Se,H as de,I as Ve,X as wt,Y as bt,Z as Fo,a as se,aa as Do,b as mr,f as lr,i as Fe,j as De,na as kt,qa as je,ra as Rt,x as ft}from"./chunk-BLE63OIT.js";import{b as At,c as _r,e as vn}from"./chunk-E3GNTGWW.js";import{a as Qn}from"./chunk-ZQOMV674.js";import{b as sr,c as $e,d as dr,f as pr}from"./chunk-WBDZVWK4.js";import{j as Oo,k as cr}from"./chunk-L7ZSEA4T.js";import{B as ae,C as nr,D as he,F as ir,G as _e,K as ge,Q as Co,a as Ie,b as Eo,c as Go,d as Io,e as Z,f as or,la as re,ma as _o,n as ue,na as We,w as Be,x as W,y as Ce}from"./chunk-43EUXRKZ.js";import{c as Wo,h as ht}from"./chunk-D3QZGLZ3.js";import{a as ut,b as $o}from"./chunk-TMM73K4C.js";import{e as To}from"./chunk-EGZZ3ADM.js";import{a as fe,c as Oe,d as ar,i as Bo}from"./chunk-RDTLCMD2.js";import{f as Po,g as lt,h as Ao,j as te}from"./chunk-5L276I7O.js";import{b as Y}from"./chunk-DUU6T2I5.js";var ye=JBrowseExports["@mui/material/SvgIcon"],Ta=e=>ye!=null&&e in Object(ye)?ye[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@mui/material/SvgIcon' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),X=Ta("createSvgIcon"),ed=ye&&ye.__esModule?ye.default:ye;var Ea=.015;function Dt({graph:e,span:t,rowY:r,positions:o}){let n=t*Ea,i={...e,edges:_o(e.edges)},a=Ho(i),s=new Map(i.nodes.map(p=>[p.id,p])),d=[];for(let p of a){let u=p.refSpan-p.pathLength;u>=lr&&d.push({nodeIds:p.nodeIds,bp:u});let m=Math.max(p.refSpan,n),l=p.pathLength>0?m/p.pathLength:0;p.nodeIds.forEach((h,g)=>{let b=s.get(h);if(b){let R=p.nodeOffsets[g],x=m/p.nodeIds.length,w=k=>p.start+k*l,y=r(b);o[h]=l?[{x:w(R),y},{x:w(R+b.length),y}]:[{x:p.start+g*x,y},{x:p.start+(g+1)*x,y}]}})}let c=se(i),f=Object.keys(o);for(let p of f){let u=o[p].at(-1).x;for(let m of c.get(p)??[]){let l=s.get(m);if(l&&!(m in o)){let h=r(l);o[m]=[{x:u,y:h},{x:u+n,y:h}],f.push(m)}}}return d}function Ga(e,t){let r=new Map;for(let n of e.nodes)if(Ce(n)){let i=fe(n.stable.refName);r.set(i,(r.get(i)??0)+n.length)}let o=new Map(t.map((n,i)=>[n,i]));return[...r.keys()].sort((n,i)=>(o.get(n)??1/0)-(o.get(i)??1/0)||r.get(i)-r.get(n)||We(n,i))}function mi(e,t,r=[]){let o=ae(e),n=Ga(e,r);if(o.length===0||n.length===0)return;let i=_e(o,t),a=new Map(n.map((u,m)=>[u,m+1])),s=he(o),d=n.length+1,c=Dt({graph:e,span:i,rowY:u=>{let m=u.stable;return((m?a.get(fe(m.refName)):void 0)??d)*Z},positions:s}),p=[{label:fe(o[0].stable.refName),y:0},...n.map(u=>({label:u,y:a.get(u)*Z}))];return{nodePositions:s,rowLabels:p,sampleRows:n,referenceAxis:!0,pixelRows:!0,alleleDeletions:c}}function Ia(e){let t=new Set;for(let r of e.nodes)r.stable&&t.add(r.stable.rank);return new Map([...t].sort((r,o)=>r-o).map((r,o)=>[r,o]))}function li(e,t){let r=ae(e);if(r.length===0)return;let o=_e(r,t),n=Ia(e),i=he(r),a=Dt({graph:e,span:o,rowY:d=>(d.stable?n.get(d.stable.rank)??n.size:n.size)*Z,positions:i}),s=[...n].map(([d,c])=>({label:d===0?"Reference (rank 0)":`Rank ${d}`,y:c*Z}));return{nodePositions:i,rowLabels:s,referenceAxis:!0,pixelRows:!0,alleleDeletions:a}}var Ba=12,Dr=Z;function ui(e){return 10+8*Math.log2(1+e.length)}function fi(e,t){return re(e.at,t.at)||re(e.side,t.side)||re(e.hops,t.hops)}var hi={at:1/0,side:0,hops:0};function Xr(e){let t=new Map(e.nodes.map(o=>[o.id,o])),r=Oa(e);return e.nodes.map(o=>o.id).sort((o,n)=>fi(r.get(o)??hi,r.get(n)??hi)||re(t.get(o).name,t.get(n).name)||re(o,n))}function Ca(e,t){let r=new Set(e.nodes.map(f=>f.id)),o=new Map(t.map(f=>[f.id,f.stable.start])),n=new Map,i=new Map;t.forEach((f,p)=>{i.set(f.id,t[p-1]?.id),n.set(f.id,t[p+1]?.id)});let a=t[0]?.id,s=(f,p)=>{let u=n.get(f);n.set(f,p),i.set(p,f),n.set(p,u),u!==void 0&&i.set(u,p)},d=(f,p)=>{let u=i.get(f);u===void 0?(a=p,i.set(p,void 0),n.set(p,f),i.set(f,p)):s(u,p)};for(let f of e.paths??[]){let p=0,u=0,m;for(let b of f.nodeIds){let R=o.get(b);R!==void 0&&(m!==void 0&&R!==m&&(R>m?p++:u++),m=R)}let l=u>p?[...f.nodeIds].reverse():f.nodeIds,h,g=new Set;for(let b of l)if(n.has(b)){if(h===void 0)for(let R of g)d(b,R);h=b}else r.has(b)&&(h===void 0?g.add(b):(s(h,b),h=b))}let c=[];for(let f=a;f!==void 0;f=n.get(f))c.push(f);return c}function _a(e,t,r){let o=[...t.entries()].sort(([s,d],[c,f])=>fi(d,f)||re(s,c)).map(([s])=>s),n=o.length;for(let s of o){let d=t.get(s);for(let c of e.get(s)??[])r.has(c)&&!t.has(c)&&(t.set(c,{at:d.at,side:1,hops:d.hops+1}),o.push(c))}let i=new Set(o.slice(n)),a=new Set;for(let s of i){if(a.has(s))continue;let{at:d}=t.get(s),c=[s];a.add(s);let f=!0;for(let p of c){let{hops:u}=t.get(p),m=!0,l=!1;for(let h of e.get(p)??[]){let g=t.get(h);g&&(g.at===d&&i.has(h)?(m&&=g.hops<=u,a.has(h)||(a.add(h),c.push(h))):g.at!==d&&(l||=g.at<d,f&&=g.at<d))}f&&=!m||l}if(f)for(let p of c){let u=t.get(p);t.set(p,{...u,side:-1,hops:-u.hops})}}}function Oa(e){let t=e.nodes.filter(W).sort((o,n)=>re(o.stable.refName,n.stable.refName)||re(o.stable.start,n.stable.start)||re(o.name,n.name)),r=new Map;return Ca(e,t).forEach((o,n)=>{r.set(o,{at:n,side:0,hops:0})}),_a(se(e),r,new Set(e.nodes.map(o=>o.id))),r}function $a(e){let t=new Map(e.nodes.map(p=>[p.id,p])),r=Xr(e),o=new Map(r.map((p,u)=>[p,u])),n=p=>W(t.get(p)),i=new Map(r.map(p=>[p,[]])),a=new Map(r.map(p=>[p,[]])),s=(p,u)=>{i.get(u).push(p),a.get(p).push(u)};for(let p of e.edges)p.from===p.to||!o.has(p.from)||!o.has(p.to)||(o.get(p.from)<o.get(p.to)?s(p.from,p.to):s(p.to,p.from));let d=r.filter(n);for(let p=1;p<d.length;p++)s(d[p-1],d[p]);let c=new Map;for(let p of r){let u=0;for(let m of i.get(p))u=Math.max(u,c.get(m)+1);c.set(p,u)}for(let p=r.length-1;p>=0;p--){let u=r[p],m=a.get(u);if(n(u)||m.length===0)continue;let l=1/0;for(let b of m)l=Math.min(l,c.get(b));let h=c.get(u),g=Math.max(h,l-1);c.set(u,Math.floor((h+g)/2))}let f=[];for(let p of r)(f[c.get(p)]??=[]).push(p);return{layers:f,layerOf:c,preds:i}}function gi(e){if(!e.nodes.some(W))return;let t=new Map(e.nodes.map(p=>[p.id,p])),r=p=>W(t.get(p)),{layers:o,layerOf:n,preds:i}=$a(e),a=o.map(p=>{let u=0;for(let m of p)u=Math.max(u,ui(t.get(m)));return u}),s=[],d=0;for(let p=0;p<o.length;p++)s[p]=d,d+=a[p]+Ba;let c=new Map;for(let p of o){let u=[];for(let l of p){if(r(l)){c.set(l,0);continue}let h=i.get(l).filter(b=>c.has(b)),g=0;for(let b of h)g+=c.get(b)/h.length;u.push({id:l,ideal:g===0?Dr:g})}u.sort((l,h)=>l.ideal-h.ideal);let m=new Set([0]);for(let{id:l,ideal:h}of u){let g=Math.round(h/Dr);g===0&&(g=h>=0?1:-1);for(let b=1;m.has(g);b++)m.has(g+b)?m.has(g-b)||(g-=b):g+=b;m.add(g),c.set(l,g*Dr)}}let f={};for(let p of e.nodes){let u=n.get(p.id),m=ui(p),l=s[u]+a[u]/2,h=c.get(p.id);f[p.id]=[{x:l-m/2,y:h},{x:l+m/2,y:h}]}return{nodePositions:f,referenceAxis:!1,pixelRows:!0}}var Xt=1.3;function Vt(e){return e.rows.reduce((t,r)=>Math.max(t,ce(r)),ce(e.reference))}function Me(e,t={rowPx:Z,readouts:!0}){return{maxX:e.origin+Vt(e)*(t.readouts?Xt:1),maxY:e.rows.length*t.rowPx}}function Pe(e,t,r){return e?r&&!r.labelled?[]:[e.reference,...e.rows].map((o,n)=>({label:o.label,y:n*(r?.rowPx??Z)})):t?.rowLabels??[]}function Vr(e,t){let r=ve(e,t);return r&&wi(e,r,t)}function wi(e,t,r){let o=ae(e);if(o.length===0)return;let n=r?o.filter(a=>nr(a,r)):o;return{nodePositions:he(n.length>0?n:o),rowLabels:Pe(t),referenceAxis:!0,pixelRows:!0,extent:Me(t)}}var ki="Force-directed layout",Ae=e=>e.nodes.some(W),bi=e=>Ae(e)&&(e.paths?.length??0)>1,yi=e=>Ae(e)&&e.nodes.some(Ce),jt=[{value:"auto",label:"Anchored",description:"x is reference bp, one row per stable rank. Needs rGFA tags or a reference path.",run:(e,t)=>li(e,t),cutMargins:!0,wholeWalks:!1,available:Ae,drawsLocally:Ae,drawsNodes:!0},{value:"samplerows",label:"Sample rows",description:"x is reference bp, one row per contributing assembly. Needs rGFA tags or a reference path.",run:(e,t,r)=>mi(e,t,r),cutMargins:!0,wholeWalks:!1,available:yi,drawsLocally:yi,drawsNodes:!0},{value:"walkrows",label:"Walk rows",description:"x is each walk's own bp: one bar per haplotype, blue on the reference's path and purple off it, so a repeat expansion reads as bar length, and each bar boxes its haplotype's own genes where the session has them. Needs a reference and two or more walks.",run:Vr,cutMargins:!1,wholeWalks:!0,available:bi,drawsLocally:bi,drawsNodes:!1},{value:"ordered",label:"Ordered",description:"x is reference order, not bp: every node gets room, bubbles read as lenses. Needs rGFA tags or a reference path.",run:e=>gi(e),cutMargins:!1,wholeWalks:!1,available:Ae,drawsLocally:Ae,drawsNodes:!0},{value:"tubemap",label:"Tube map",description:"sequenceTubeMap: every path a coloured tube through boxed nodes, columns in node order and node widths log-scaled. Needs P or W lines.",run:Xo,cutMargins:!1,wholeWalks:!1,available:ur,drawsLocally:ur,drawsNodes:!1},{value:"tubemapref",label:"Tube map on reference",description:"The tube map with each column at the reference bp it covers, so the tubes line up with the tracks around them. Needs P or W lines and a reference path.",run:Vo,cutMargins:!0,wholeWalks:!1,available:hr,drawsLocally:hr,drawsNodes:!1},{value:"force",label:ki,description:"OGDF FMMM (wasm) or stress, whichever engine is chosen.",run:()=>{},cutMargins:!1,wholeWalks:!1,available:()=>!0,drawsLocally:()=>!1,drawsNodes:!0}],Wa=jt.map(e=>e.value);function jr(e,t){return!V(e).drawsLocally(t)}function V(e){return jt.find(t=>t.value===e)??jt[0]}function zt(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.horizontalScroll=="function"&&typeof t.zoomTo=="function"&&"coarseDynamicBlocks"in t&&"dynamicBlocks"in t}function zr(e){return e.reduce((t,r)=>t&&t.end-t.start>=r.end-r.start?t:r,void 0)}function ke(e){return e.initialized?e.dynamicBlocks.contentBlocks:[]}function Ri(e,t){let r=zr(ke(e).filter(i=>i.refName===t.refName&&i.assemblyName===t.assemblyName)),{bpPerPx:o}=e;if(!r||!(o>0))return;let n=r.offsetPx-e.offsetPx;return r.reversed?{scale:-1/o,translateX:n+r.end/o}:{scale:1/o,translateX:n-r.start/o}}function Yr(e){let t=zr(ke(e)),r=t?.displayedRegionIndex===void 0?void 0:e.displayedRegions[t.displayedRegionIndex];return t&&e.bpPerPx>0?{refName:t.refName,assemblyName:t.assemblyName,start:t.start,end:t.end,bpPerPx:e.bpPerPx,span:e.bpPerPx*e.width,regionStart:r?.start??t.start,regionEnd:r?.end??t.end}:void 0}function xi(e){let t=zr(ke(e)),r=t&&t.start-(t.offsetPx-e.offsetPx)*e.bpPerPx;return r===void 0?void 0:{start:r,end:r+e.bpPerPx*e.width}}function Ha(e,t,r=!0){let o=e.end-e.start,n=r?Math.max(0,Math.min(e.span,(t-o)/2)):0,i=Math.max(e.regionStart,Math.floor(e.start-n)),a=Math.min(e.regionEnd,Math.ceil(e.end+n)),s=a-i-t;return s>0&&(i+=Math.floor(s/2),a-=Math.ceil(s/2)),{refName:e.refName,assemblyName:e.assemblyName,start:i,end:a}}function Si(e){return e==="force"?"snapped":V(e).cutMargins?"margins":"window"}function Fa(e){return 2**(Math.ceil(Math.log2(e)*2-1e-9)/2)}function Xp(e){let t=Fa(e.span),r=Math.round((e.start+e.end)/t)*(t/2);return{refName:e.refName,assemblyName:e.assemblyName,start:Math.max(e.regionStart,Math.round(r-.75*t)),end:Math.min(e.regionEnd,Math.round(r+.75*t))}}function Vp(e,t){return e?.refName===t.refName&&e.assemblyName===t.assemblyName&&e.start===t.start&&e.end===t.end}function jp(e,t,r=!0){if(e?.refName!==t.refName||e.assemblyName!==t.assemblyName)return!1;if(r)return e.start<=t.start+1&&t.end<=e.end+1;let o=Ha(t,1/0,!1);return Math.abs(e.start-o.start)<1&&Math.abs(e.end-o.end)<1}function D(e){return typeof e=="object"&&e!==null}function vi(e){return Array.isArray(e)}var Da=/^[^#]+#\d+$/,Xa=/^([^#]+)\.(\d+)$/;function Va({aliases:e}){return e.find(t=>Da.test(t))}function ja({name:e}){let t=Xa.exec(e);return t?`${t[1]}#${t[2]}`:void 0}function za(e,t,r){let o=e.assemblyNameToPanSN??{},n=new Set(Object.values(o)),i={},a=t.filter(s=>s.name!==r);for(let[s,d]of[[Va,t],[ja,a]])for(let c of d){let f=s(c);f!==void 0&&!n.has(f)&&!(c.name in o)&&!(c.name in i)&&(i[c.name]=f,n.add(f))}return Object.keys(i).length===0?e:{...e,assemblyNameToPanSN:{...i,...o}}}function Li(e,t){return e.find(r=>r.name===t||r.aliases.includes(t))?.name??t}function Ya(e,t){let r=a=>Li(t,a),o=e.assemblyNames??[],n=e.assemblyNameToPanSN??{};if([...o,...Object.keys(n)].every(a=>r(a)===a))return e;let i=new Map;for(let[a,s]of Object.entries(n)){let d=r(a);(d===a||!i.has(d))&&i.set(d,s)}for(let a of o){let s=r(a);s!==a&&!i.has(s)&&i.set(s,a)}return{...e,assemblyNames:o.map(r),assemblyNameToPanSN:Object.fromEntries(i)}}var Ka=new Set(["GbzBaseSyntenyAdapter","WalkTabixSyntenyAdapter"]);function Ni(e,t){let r=ht(t);if(!Ka.has(r.type)&&!Wo(r))return r;let o=te(e).assemblyManager.assemblyList.map(i=>({name:rr(i,"name"),aliases:rr(i,"aliases")})),[n]=ut(t);return za(Ya(r,o),o,n===void 0?void 0:Li(o,n))}var tc=X(Y("path",{d:"M19 15.18V7c0-2.21-1.79-4-4-4s-4 1.79-4 4v10c0 1.1-.9 2-2 2s-2-.9-2-2V8.82C8.16 8.4 9 7.3 9 6c0-1.66-1.34-3-3-3S3 4.34 3 6c0 1.3.84 2.4 2 2.82V17c0 2.21 1.79 4 4 4s4-1.79 4-4V7c0-1.1.9-2 2-2s2 .9 2 2v8.18c-1.16.41-2 1.51-2 2.82 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82"}),"Route");var ic=X(Y("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");function Kr(e){return Be(e)?Ur(e):void 0}function Ur(e){return{sample:fe(e.stable.refName),haplotype:Oe(e.stable.refName),refName:ar(e.stable.refName),start:e.stable.start,end:e.stable.start+e.length}}function Mi(e,t,r,o){let n=new Map,i=s=>{let d=Re(r,s),c=`${d} ${s.refName} ${s.start}`;d!==void 0&&d!==o&&n.set(c,{assemblyName:d,refName:s.refName,start:s.start,end:s.end})},a=Kr(t);a&&i(a);for(let s of e.pathVisits?.get(t.name)??[])i({sample:fe(s.path),haplotype:Oe(s.path),refName:ar(s.path),start:s.start,end:s.start+t.length});return[...n.values()]}function Pi(e,t,r){let o=new Map,n=new Set((e.paths??[]).flatMap(a=>Oe(a.name)??[])),i=new Set;for(let a of e.nodes){if(!Be(a)||a.stable.rank===0)continue;let s=a.stable.refName;if(i.has(s))continue;if(n.size>0&&!n.has(Oe(s)??"")){i.add(s);continue}let d=Ur(a),c=o.get(s);if(c){c.start=Math.min(c.start,d.start),c.end=Math.max(c.end,d.end);continue}let f=Re(t,d);f===void 0||f===r?i.add(s):o.set(s,{stableRefName:s,assemblyName:f,refName:d.refName,start:d.start,end:d.end})}return[...o.values()]}function Ua(e,t){let r=[...e].sort((i,a)=>i.start-a.start),o,n;for(let i of r)n=n&&i.start-n.end<=t?{start:n.start,end:Math.max(n.end,i.end)}:{start:i.start,end:i.end},(!o||n.end-n.start>o.end-o.start)&&(o=n);return o}function Za(e){return`${e.haplotype??e.sample}\0${e.refName}`}function Ai(e,{maxGap:t=1/0}={}){let r=new Map;for(let n of e.nodes)if(Be(n)){let i=Ur(n),a=Za(i),s=r.get(a);s?(s.spans.push({start:i.start,end:i.end}),s.rank=Math.min(s.rank,n.stable.rank)):r.set(a,{sample:i.sample,haplotype:i.haplotype,refName:i.refName,rank:n.stable.rank,spans:[{start:i.start,end:i.end}]})}let o=new Map;for(let n of r.values()){let i=Ua(n.spans,t);if(i){let a={sample:n.sample,haplotype:n.haplotype,refName:n.refName,start:i.start,end:i.end,rank:n.rank,nodeCount:n.spans.length},s=n.haplotype??n.sample,d=o.get(s);(!d||a.nodeCount>d.nodeCount)&&o.set(s,a)}}return[...o.values()].sort((n,i)=>+(n.rank!==0)-+(i.rank!==0)||n.sample.localeCompare(i.sample)||(n.haplotype??"").localeCompare(i.haplotype??""))}function Re(e,t){return(t.haplotype===void 0?void 0:e(t.haplotype))??e(t.sample)}function Ti(e,t){let r=new Map,o=n=>`${n.sample} ${n.refName}`;for(let n of e)n.haplotype!==void 0&&r.set(o(n),(r.get(o(n))??0)+1);return e.flatMap(n=>{let i=(r.get(o(n))??0)>1?t(n.haplotype):Re(t,n);return i===void 0?[]:[{...n,sample:i}]})}function Yt(e){return`${e.refName}:${e.start+1}-${e.end}`}function qa(e){return D(e)&&e.type==="LinearGenomeView"&&typeof e.id=="string"&&typeof e.navToLocString=="function"&&Array.isArray(e.assemblyNames)}function Ei(e){return e.flatMap(t=>D(t)&&vi(t.views)?[t,...t.views]:[t])}function kc(e){return new Set(Ei(e).flatMap(t=>D(t)&&typeof t.id=="string"?[t.id]:[]))}function Te({views:e,connectedViewId:t,assemblyName:r}){let o=Ei(e).filter(i=>qa(i)).filter(i=>i.assemblyNames.includes(r));return o.find(i=>i.id===t)??(o.length===1?o[0]:void 0)}function Zr(e,t){let r=e.assemblyManager;return r?.has(t)?r.get(t)?.name??t:t}function Nc(e,t){let r=e.assemblyManager,o=r?.has(t.assemblyName)?r.get(t.assemblyName):void 0;return o?{...t,assemblyName:o.name,refName:o.getCanonicalRefName2?.(t.refName)??t.refName}:t}function qr(e,t){return ut(t).map(r=>Zr(e,r))}function Jr(e,t,r){r.catch(o=>{console.error(`[GraphGenomeView] ${t}`,o),e.notifyError?.(`${t}: ${o}`,o)})}var Ja=1e3;function Qr(e,t=Ja){let r=Math.max(0,Math.ceil((t-(e.end-e.start))/2));return{...e,start:Math.max(0,e.start-r),end:e.end+r}}function Ii(e,t){return t?e.map(r=>r.rank===0?{...r,sample:t.assemblyName,haplotype:void 0,refName:t.refName,start:t.start,end:t.end}:r):e}function Mc({session:e,location:t,assembly:r,connectedViewId:o,tracks:n=[]}){let i=Te({views:e.views,connectedViewId:o,assemblyName:r}),a;return i?(Jr(e,`Could not show ${r} ${Le(t)}`,Promise.resolve(i.navToLocString(Yt(t),r))),a=i.id):a=e.addView("LinearGenomeView",{displayName:`${r} \u2014 ${Le(t)}`,init:{assembly:r,loc:Yt(t),tracks:n}}).id,a}function Pc({session:e,trackId:t,assembly:r,loc:o}){let n=Te({views:e.views,connectedViewId:void 0,assemblyName:r});n?.showTrack?(Jr(e,`Could not show ${r} ${o}`,Promise.resolve(n.navToLocString(o,r))),n.showTrack(t)):e.addView("LinearGenomeView",{init:{assembly:r,loc:o,tracks:[t]}})}function Ac({session:e,location:t,assembly:r,connectedViewId:o}){Te({views:e.views,connectedViewId:o,assemblyName:r})&&e.addHighlight?.({refName:t.refName,start:t.start,end:t.end,assemblyName:r})}function Gi(e,t){let r=t===void 0?void 0:e.tracks.find(o=>o.trackId===t);return r?qr(e,r):[]}function Tc({session:e,contributors:t,trackId:r,graphTrackId:o}){let n=Gi(e,o),i=Gi(e,r),a=t.filter(c=>i.includes(c.sample)),s=a.length>=2?a:t,d={init:{views:s.map(c=>({assembly:c.sample,loc:Yt(c),...o!==void 0&&n.includes(c.sample)?{tracks:[o]}:{}})),tracks:r?s.slice(1).map(()=>[r]):[],collapseEmptyRows:!0}};Jr(e,"Could not open the synteny view",e.launchView("LinearSyntenyView",d))}function eo(e){return e.walkStrip&&e.mode.drawsNodes&&!e.drawsPicture&&!e.popped&&!e.host&&e.walks>1}function to(e,t){return e.wholeWalks||t.walkStrip&&!t.host}var rt=6,_i=260,Qa=11,es=3,ts="#111",Bi=3;function ro(e,t,r){let o=e.pathVisits?.get(r.name)??[],n=[];for(let i of t){let a=i.axis;if(!a)continue;let s=ge(i.name).name;for(let d of o){if(d.path!==s)continue;let{start:c,end:f}=fr(a,d.start,d.start+r.length);f>0&&c<i.bp&&n.push({row:i.name,start:c,bp:f-c})}}return n}var Ci=new WeakMap;function rs(e,t){let r=Ci.get(e);if(r||(r=new Map,Ci.set(e,r)),r.has(t))return r.get(t);let o=new Map(e.nodes.map(s=>[s.id,s.length])),n=ge(t).name,i=(e.paths??[]).filter(s=>ge(s.name).name===n),a;if(i.every(s=>s.start!==void 0)){a={ids:[],starts:[],ends:[]};for(let s of[...i].sort((d,c)=>d.start-c.start)){let d=s.start;for(let c of s.nodeIds){let f=o.get(c)??0;a.ids.push(c),a.starts.push(d),a.ends.push(d+f),d+=f}}}return r.set(t,a),a}function os(e,t,r,o){let n=t.axis,i=n&&rs(e,t.name);if(!n||!i||r<0||r>t.bp)return;let a=n.reversed?n.start-r:n.start+r,s=.5/o,d=vt(n,t.bp),c=Math.max(a-s,d.start),f=Math.min(a+s,d.end),p=Io(i.starts.length,h=>i.ends[h]<=c),u,m=-1,l=!1;for(let h=p;h<i.starts.length&&i.starts[h]<f;h++){let g=i.ends[h]-i.starts[h],b=i.starts[h]<=a&&a<i.ends[h];(g>m||g===m&&b&&!l)&&(m=g,u=i.ids[h],l=b)}return u}function ot(e,t){let r=t.maxHeight??_i,o=t.labelPx??e.rows.reduce((m,l)=>Math.max(m,l.label.length),e.reference.label.length)*de+16,n=e.rows.length+1,{rowPx:i,barPx:a,labelled:s,readouts:d}=Nt(n,r-2*rt,es),c=Math.max(Vt(e),1),f=s?o:rt,u=Math.max(1,t.width-f-rt)/(c*(d?Xt:1));return{scaleX:u,scaleY:1,translateX:f-e.origin*u,translateY:rt+i/2,width:t.width,height:n*i+2*rt,rowPx:i,barPx:a,readouts:d,labelled:s,boxesGenes:Lt(i,a)}}function ns(e,t,r,o){let n=Math.round((o-t.translateY)/t.rowPx),i=[e.reference,...e.rows][n],a=(r-t.translateX)/t.scaleX-e.origin;return i&&n>=0&&a>=0&&a<=ce(i)?{index:n,row:i,offset:a}:void 0}function is(e,t,r){let o=new Map([e.reference,...e.rows].map((i,a)=>[i.name,a])),n=i=>(e.origin+i)*t.scaleX+t.translateX;return kr("g",{"data-testid":"graph-walk-marks"},r.flatMap(i=>{let a=o.get(i.row);if(a===void 0)return[];let s=a*t.rowPx+t.translateY,d=n(i.start),c=Math.max(2,i.bp*t.scaleX),f=p=>K("rect",{x:d,y:p,width:c,height:Bi,fill:ts});return[f(s-t.barPx/2-Bi-1),f(s+t.barPx/2+1)]}))}function oo(e,t,r=new Set){return kr("g",{"font-family":"sans-serif","font-size":Qa,fill:"#333"},(t.labelled?[e.reference,...e.rows]:[]).map((o,n)=>K("text",{x:6,y:n*t.rowPx+t.translateY+4,"font-weight":r.has(o.name)?600:void 0},o.label)))}function no(e,t,r){if(t?.size)return e.boxesGenes?r:{untracked:0,unread:0,...r,crowded:!0}}function it(e,t){let r=t?[t.reference,...t.rows]:[];return(e?.walks??[]).flatMap(o=>{let n=o.walkPasses,i=we([o])[0];return n?.passes.length&&!r.some(a=>Ke(o.name,a)&&!!i&&yr(i,a))?[{walk:o.name,bp:o.range?o.range.end-o.range.start:o.bp,ownInk:n.ownInk,runs:n.runs.map(a=>({...a,ink:on(n,a.pass)})),passes:n.passes.map((a,s)=>({pass:s,start:a.start,end:a.end,repeatBp:a.repeatBp,againBp:a.againBp,reversedBp:a.reversedBp,text:n.bundled?`${s+1}`:a.title,ink:a.ink,reversed:a.reversed})),bundled:n.bundled}]:[]})}var io={"font-family":"Helvetica, Arial, sans-serif","font-size":11},as=6.2,Kt=12,ss=13,nt=34,Ee=40,Ge=16,Oi=4,Ut=Ee+Ge+26,ds=(e,t)=>{let r=e/t,o=10**Math.floor(Math.log10(r));return[1,2,5,10].map(n=>n*o).find(n=>n>=r)??r};function ao(e,t,r){let o=r-2*Kt,n=h=>Kt+(e.bp>0?h/e.bp*o:0),i=o>0?e.bp/o:1,a=[];for(let h of e.runs){let g=a.at(-1);g?.pass===h.pass&&h.start-g.end<i?g.end=h.end:a.push({...h})}let s=e.bp>0?ds(e.bp,8):1,d=Array.from({length:e.bp>0?Math.floor(e.bp/s)+1:0},(h,g)=>g*s),c=K("text",{x:Kt,y:ss,...io,"font-weight":"bold"},`${t} along its length`),f=[],p=e.passes.flatMap(h=>{let g=[];for(let v of e.runs){let T=g.at(-1);v.pass===h.pass&&T&&v.start-T.end<i?T.end=v.end:v.pass===h.pass&&g.push({start:v.start,end:v.end})}let b=q(h.ink),R=g.map(v=>K("path",{d:`M${n(v.start)},${nt+3}V${nt}H${n(v.end)}V${nt+3}`,fill:"none",stroke:b,"stroke-width":1.5})),x=g.slice(1).map((v,T)=>`M${n(g[T]?.end??v.start)},${nt}H${n(v.start)}`).join(""),w=g.reduce((v,T)=>!v||T.end-T.start>v.end-v.start?T:v,void 0),y=h.text.length*as/2+2,k=w&&Math.min(Math.max((n(w.start)+n(w.end))/2,y),r-y),S=k!==void 0&&f.every(v=>k+y<=v.from||k-y>=v.to);S&&f.push({from:k-y,to:k+y});let O=S&&K("text",{x:k,y:nt-3,...io,"font-weight":"bold",fill:b,"text-anchor":"middle"},h.text),ie=K("path",{d:x,fill:"none",stroke:b,"stroke-width":.75,"stroke-dasharray":"1 2"});return(x?[ie]:[]).concat(R,O?[O]:[])}),u=K("rect",{x:Kt,y:Ee,width:o,height:Ge,fill:q(e.ownInk)}),m=a.map(h=>K("rect",{x:n(h.start),y:Ee,width:Math.max(.5,n(h.end)-n(h.start)),height:Ge,fill:q(h.ink)})),l=d.flatMap(h=>[K("line",{x1:n(h),x2:n(h),y1:Ee+Ge,y2:Ee+Ge+Oi,stroke:"#666"}),K("text",{x:n(h),y:Ee+Ge+Oi+11,...io,fill:"#444","text-anchor":"middle"},h===0?"0":yt(h))]);return{tag:"g",attrs:{},children:[c].concat(p,[u],m,l)}}var $i="14.3.1";function at(e,t,r={}){return{nodePositions:r.drawsRows?{}:e.nodePositions,deletions:t.bypassed,deletionRoutes:e.deletionRoutes,stranded:e.stranded,hiddenEdges:t.hidden}}var j={...Lr,width:vr,height:800,colorScheme:"auto",nodeWidth:"depth",edgeWidth:"uniform",contigThickness:6,connectorThickness:2,nodeLengths:wt.nodeLengths,smallSites:"hidden"};var Wi=[{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"}],ps=Wi.map(e=>e.value);function st(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}function Hi(e,t,r){let o=r.region,n=r.colorDomain??o,i=r.walkRows,a=qe(t,{region:r.fitToDrawing?void 0:o,extent:i&&t.extent?Me(i,r.walkRowPitch):void 0}),s=new Map(e.nodes.map(S=>[S.id,S])),d=st(r.colorScheme??j.colorScheme,e),c=d==="reference-position"&&!t.tubeMap?Ye(e,n):void 0,f=De(e,t.tubeMap?[]:Fe(e),r.showDeletionEdges),p=r.walks??[],u=p.some(S=>S.color?.field==="reference")?c??Ye(e,n):void 0,m=p.length>0&&!t.tubeMap?Qe(e,p,u):void 0,l=t.tubeMap?[]:[...new Set(p.map(S=>S.walk))].filter(S=>!m?.names.has(S)),h=Ct(r.facet),g=h.field&&m&&m.walks.length>1?et(e,m,p,u):void 0,b=h.field&&g?{panels:g,place:_t(g.map(S=>S.walks[0].name),h.field,h.sort)}:void 0,R=Rt(e.paths?.length?je(e.paths):[]),x=r.referenceName??$e(e,o),w=r.contigThickness??j.contigThickness,y=r.nodeWidth??j.nodeWidth,k=m?.referenceDomain&&{...m.referenceDomain,name:x};return{bounds:a,nodeById:s,colorScheme:d,referenceRamp:c,drawnDeletions:f,layers:p,lift:m,unmatchedWalks:l,facet:h,facets:b,labelOf:S=>R.get(S)??S,referenceName:x,walkReference:k,keyText:S=>{let O=Or(S,k);return{note:O.gaps,scale:O.scale}},contigThickness:w,nodeWidth:y,geometry:(S,O)=>St({...at(t,f,{drawsRows:!!i}),graph:e,nodeById:s,colorScheme:d,contigThickness:w,connectorThickness:r.connectorThickness??j.connectorThickness,drawPaths:!1,nodeWidth:y,edgeWidth:r.edgeWidth??j.edgeWidth,linearLayout:r.linearLayout,highlight:S,axis:O,referenceRamp:c,smallSites:r.smallSites??j.smallSites})}}var Zt='font-family="Helvetica, Arial, sans-serif" font-size="11"',po=48,ne=18,Fi=8,Xi=16,co=16,cs=32,ms=22,so=6,Vi="#1c1c22",dt=10,ji="#18181c",Q=(e,t)=>{let r=Ko(t);return`${e}="${q(t)}"${r<255?` ${e}-opacity="${+(r/255).toFixed(3)}"`:""}`},ls=e=>e?e.kind==="scale"||e.kind==="width"?po:ne:0;function us(e,t){let r=t?qo:Fi,o=r*Jo,n=(t?[o,ne]:[ne-1]).map(i=>{let[a,s,d,c]=On({x:i,y:9,angle:0,length:o,halfWidth:r/2,color:e},{scaleX:1,scaleY:1,translateX:0,translateY:0,dpr:1});return`M${[a,s,d,c].map(f=>`${+f.x.toFixed(1)},${+f.y.toFixed(1)}`).join("L")}Z`}).join("");return[`<line y1="9" y2="9" x2="${ne}" ${Q("stroke",e)} stroke-width="${t?wr:Fi}"/>`,t?`<path d="${n}" fill="none" stroke="#ffffff" stroke-width="${2*Qo}" stroke-linejoin="round"/>`:"",`<path d="${n}" fill="${q(en(e,!t))}"/>`].join("")}function hs(e,t){switch(e.kind){case"scale":return`<linearGradient id="${t}">${e.stops.map(r=>`<stop offset="${+r.offset.toFixed(4)}" stop-color="${q(r.ink)}"/>`).join("")}</linearGradient><rect y="5" width="${po}" height="8" rx="2" fill="url(#${t})"/>`;case"swatch":return`<rect y="5" width="${ne}" height="8" rx="2" ${Q("fill",e.ink)}/>`;case"chip":return`<rect x="4" y="4" width="10" height="10" rx="2" ${Q("fill",e.ink)}/>`;case"width":return`<rect y="${9-e.px/2}" width="${po}" height="${e.px}" ${Q("fill",e.ink)}/>`;case"hollow":return`<rect x="1" y="5" width="${ne-2}" height="8" rx="4" ${Q("fill",e.ink)} ${Q("stroke",e.rim)} stroke-width="${e.rimPx}"/>`;case"line":return e.dashed?`<line y1="9" y2="9" x2="${ne}" ${Q("stroke",e.ink)} stroke-width="2" stroke-dasharray="4 3"/>`:`<line y1="9" y2="9" x1="5" x2="${ne-5}" ${Q("stroke",e.ink)} stroke-width="1.5"/>`;case"outline":return`<rect x="1" y="4" width="${ne-2}" height="10" rx="4" fill="none" ${Q("stroke",e.ink)} stroke-width="2"/>`;case"halo":return`<line y1="9" y2="9" x1="5" x2="13" ${Q("stroke",e.ink)} stroke-opacity="0.35" stroke-width="8" stroke-linecap="round"/>`;case"threads":return[6,9,12].map(r=>`<line y1="${r}" y2="${r}" x2="${ne}" ${Q("stroke",e.ink)} stroke-width="${wr}"/>`).join("");case"overhang":return`<path d="M0,9 L8,4 L8,14 Z M18,9 L10,4 L10,14 Z" fill="${q(br)}"/>`;case"overrun":return`<path d="M4,4 L0,13 L8,13 Z M14,14 L10,5 L18,5 Z" fill="${q(br)}"/>`;case"heads":return us(e.ink,e.haloed)}}function zi(e,t){let r=ls(e.swatch),o=r>0?r+5:0,n=e.strong??"",i=Math.max(o+(n.length+e.text.length)*de,(e.under?.length??0)*de);return(a,s)=>({width:i,height:e.under?cs:co,markup:`<g transform="translate(${a} ${s})" ${Zt}>${e.swatch?hs(e.swatch,t):""}<text${o>0?` x="${o}"`:""} y="13">${n?`<tspan font-weight="bold">${J(n)}</tspan>`:""}${J(e.text)}</text>${e.under?`<text y="28">${J(e.under)}</text>`:""}</g>`})}function fs(e){return(t,r)=>({width:e.length*de,height:co,markup:`<g transform="translate(${t} ${r})" ${Zt}><text y="13" font-weight="bold">${J(e)}</text></g>`})}var gs=new Set(["Node thickness","Link thickness"]);function ws(e,t){return e.flatMap(({id:r,group:o,entries:n})=>[...o&&gs.has(o)?[fs(o)]:[],...n.map((i,a)=>zi(i,`${t}-${r}-${a}`))])}function bs(e,t){let r=[],o=6,n=2,i=0;for(let a of e){let s=a(0,0);o>6&&o+s.width>t-6&&(o=6,n+=i+4,i=0),r.push(a(o,n).markup),o+=s.width+Xi,i=Math.max(i,s.height)}return{markup:r,height:n+i}}function ys(e,t){return e.replaceAll(/([ML])(-?[\d.e-]+),(-?[\d.e-]+)/g,(r,o,n,i)=>`${o}${+(Number(n)*t.scaleX+t.translateX).toFixed(1)},${+(Number(i)*t.scaleY+t.translateY).toFixed(1)}`)}function ks(e,t,r,o,n){return`<rect x="${e-r/2}" y="${t-Se-Ve+2}" width="${r}" height="${Se+Ve*2-2}" rx="3" fill="#fff" fill-opacity="0.85" stroke="${Nn}"/><text x="${e}" y="${t}" font-family="Helvetica, Arial, sans-serif" font-size="${Se}" fill="${Vi}" text-anchor="middle"><tspan font-style="italic" font-weight="600">${J(o)}</tspan>${n?J(n):""}</text>`}function Rs(e,t,r){let o=r.length*dt*.56+6;return`<rect x="${e-o/2}" y="${t-dt*.65}" width="${o}" height="${dt*1.3}" rx="3" fill="#fff" fill-opacity="0.8"/><text x="${e}" y="${t+dt*.35}" font-family="Helvetica, Arial, sans-serif" font-size="${dt}" fill="${ji}" text-anchor="middle">${J(r)}</text>`}function Di(e,t,r){let o=e(0),n=r(o);for(let i=0;i<3&&!t(o,e(n.header));i++)o=e(n.header),n=r(o);return n}function mo(e,t,r={}){let o=r.width??j.width,n=r.height??j.height,i=r.walkRows,{bounds:a,nodeById:s,referenceRamp:d,layers:c,lift:f,facet:p,facets:u,labelOf:m,referenceName:l,walkReference:h,contigThickness:g,nodeWidth:b,geometry:R}=Hi(e,t,r),x=t.pixelRows??!1,w=d&&{start:d.start,end:d.start+d.span},y=r.genes?.length&&!t.tubeMap&&!i?Ue(e,r.genes,t.nodePositions,t.stranded):[],k=Pe(i,t,r.walkRowPitch),S=bt(e.nodes,r.nodeLengths??j.nodeLengths),O=k.reduce((L,{label:M})=>Math.max(L,2*so+M.length*de),F),ie=0;function v(L,M,C,A,E,P){let _=[],G=ft(e,s,g,b,0,P.collapsed?.through),I=Mn(Tt(y,G.halfWidthPx,L,N=>ys(N,M),Xe(P)),{id:`exons${ie++}`,width:A,height:E});I&&_.push(pe(I));let $=N=>({x:N.x*M.scaleX+M.translateX,y:N.y*M.scaleY+M.translateY});for(let{item:N,x:B,y:H,w:mt,text:tr}of C.genes){let{pin:xe,name:le}=N,{x1:Na,y1:Ma,x2:Pa,y2:Aa}=En({x:B,y:H},$(xe.at),g);_.push(`<line x1="${Na}" x2="${Pa}" y1="${Ma}" y2="${Aa}" stroke="${Vi}" stroke-width="0.8" stroke-opacity="0.6"/>`,ks(B,H,mt,le,tr.slice(le.length)))}for(let{item:N,x:B,y:H,w:mt,text:tr}of C.passes){let xe=Bn({x:B,y:H},N.at),le=q(N.ink);_.push(`<line x1="${xe.x1}" x2="${xe.x2}" y1="${xe.y1}" y2="${xe.y2}" stroke="${le}" stroke-width="1"/>`,`<circle cx="${N.at.x}" cy="${N.at.y}" r="2" fill="${le}"/>`,`<rect x="${B-mt/2}" y="${H-Se-Ve+2}" width="${mt}" height="${Se+Ve*2-2}" rx="3" fill="#fff" fill-opacity="0.9" stroke="${le}"/>`,`<text x="${B}" y="${H}" ${Zt} font-weight="bold" fill="${le}" text-anchor="middle">${J(tr)}</text>`)}for(let N of C.sizes){let B=Do(N);B&&_.push(`<line x1="${B.x1}" x2="${B.x2}" y1="${B.y1}" y2="${B.y2}" stroke="${ji}" stroke-width="0.8" stroke-opacity="0.6"/>`),_.push(Rs(N.x,N.y,N.text))}i&&_.push(pe(Sr(i,{...M,width:A,height:E,...r.walkRowPitch},{ramp:w,rowGenes:r.rowGenes})));for(let{label:N,y:B}of k){let H=B*M.scaleY+M.translateY;H>=0&&H<=E&&_.push(`<rect x="${so-2}" y="${H-7}" width="${N.length*de+4}" height="14" fill="#fff" fill-opacity="0.85"/>`,`<text x="${so}" y="${H+4}" ${Zt} stroke="#fff" stroke-width="3" paint-order="stroke">${J(N)}</text>`)}return _.join("")}function T(L,M,C,A){let E=A?{scale:A.scaleX,translateX:A.translateX,translateY:A.translateY}:Ze(a,M,C,x,u?{padLeft:oe,padTop:oe,padRight:oe,padBottom:oe}:{padLeft:O});if(E){let P=A?{scaleX:A.scaleX,scaleY:A.scaleY,pixelRows:x}:Mt(E.scale,x),_=R(L,P),G={scaleX:P.scaleX,scaleY:P.scaleY,translateX:E.translateX,translateY:E.translateY};return{highlight:L,batch:_,t:G,labels:Gn({paneWidth:M,canvasHeight:C,axisScale:P,translateX:E.translateX,translateY:E.translateY,contigThickness:g,legendSize:{width:0,height:0},drawnRowLabels:k,bubbleHalos:[],genePins:y,liftedWalks:L?.walks.map(I=>I.name),nodePositions:t.nodePositions,labelsNodeSizes:!t.tubeMap&&!L,nodeLengths:S,nodeById:s,graph:e,drawnInk:_,alleleDeletions:t.alleleDeletions??[],positionsVersion:0,folded:_.collapsed?.nodes,passLabels:u?[]:In(_,L,G,{width:M,height:C})})}}}function U(L,M,C){if(!L)return"";let{canvas:A,markup:E}=Cn(M,C),P=new _n(A);return P.uploadGeometry(L.batch),P.updateTransform({...L.t,dpr:1}),P.render([1,1,1,1]),E()+v(L.highlight,L.t,L.labels,M,C,L.batch)}let er=(L,M,C)=>{let A=ws(Tn(e,t,{region:r.region,referenceName:l,referenceRamp:d,lift:f,panels:u?.panels,walkLabel:m,nodeWidth:b,contigThickness:g,edgeWidth:r.edgeWidth??j.edgeWidth,connectorThickness:r.connectorThickness??j.connectorThickness,drawsNodes:!i&&!t.tubeMap,marks:Pn(L.flatMap(E=>E?[E.batch]:[]),C),genePins:y,unlabelled:M}),"key");return i&&Rr(i,{ramp:w,genes:r.rowGenes?.size?r.rowGeneGaps:void 0,annotation:r.rowAnnotation}).forEach((E,P)=>{A.push((_,G)=>{let I=xr([E],_,G,`rows-key-${P}`);return{width:I.width-Xi,height:co,markup:pe(I.tree)}})}),bs(A,o)},me=[],z;if(u){let{panels:L,place:M}=u,C=G=>Bt({count:M.count,bounds:a,pixelRows:x,width:o,room:n-G,columns:M.columns??p.columns}),{drawn:A,header:E}=Di(C,(G,I)=>G.columns===I.columns&&G.width===I.width&&G.height===I.height,G=>{let I=L.map(N=>T(N,G.width,G.height)),$=er(I);return{drawn:{views:I,key:$,grid:G},header:$.markup.length>0?$.height+Ne:0}}),{grid:P,key:_}=A;for(let G of _.markup)me.push(G);L.forEach((G,I)=>{let $=M.cells[I],N=$%P.columns*(P.width+Ne),B=E+Math.floor($/P.columns)*(P.height+It+Ne),H=G.walks[0];me.push(zi(An(H,m(H.name),h),`key${I}`)(N+6,B+2).markup,`<svg x="${N}" y="${B+It}" width="${P.width}" height="${P.height}">${U(A.views[I],P.width,P.height)}</svg>`)}),z=E+P.total}else{let L=o-2*F,M=x||!(a.w>0)?a.h:a.h*L/a.w,C=r.frame,A=$=>C?n:Math.max(160,Math.min(n-$,Math.ceil(M+2*F))),{drawn:E,header:P}=Di(A,($,N)=>$===N,$=>{let N=T(f,o,$,C),B=er([N],N?.labels.unlabelled,C&&N?sn(N.t,N.t,o,$):void 0);return{drawn:{v:N,key:B,h:$},header:B.markup.length>0?Math.max(It,B.height):0}}),{v:_,key:G,h:I}=E;for(let $ of G.markup)me.push($);me.push(`<svg y="${P}" width="${o}" height="${I}">${U(_,o,I)}</svg>`),z=P+I}let ee=r.walkStrip,va=u?[]:it(f,ee&&!i&&!t.tubeMap?ee.rows:void 0);for(let L of va)me.push(`<svg y="${z}" width="${o}" height="${Ut}">${pe(ao(L,m(L.walk),o))}</svg>`),z+=Ut;if(ee&&!i&&!t.tubeMap){let L=ot(ee.rows,{width:o}),M=we(u?u.panels.map(A=>A.walks[0]):f?.walks??[]),C=xr(Rr(ee.rows,{inks:M,ramp:w,genes:no(L,ee.rowGenes,ee.rowGeneGaps),annotation:r.rowAnnotation,markUnloaded:!0}),6,z+L.height,"strip-key");me.push(`<line x1="0" x2="${o}" y1="${z+.5}" y2="${z+.5}" stroke="#ddd"/>`,`<svg y="${z}" width="${o}" height="${L.height}">${pe(Sr(ee.rows,L,{inks:M,ramp:w,rowGenes:ee.rowGenes,idPrefix:"strip",markUnloaded:!0}))}${pe(oo(ee.rows,L,new Set(c.map(A=>A.walk))))}</svg>`,pe(C.tree)),z+=L.height+ms}let La=JSON.stringify({generator:`@jbrowse/bandage-core@${$i}`,...r.spec===void 0?{}:{spec:r.spec}});return`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${z}" viewBox="0 0 ${o} ${z}"><metadata>${J(La)}</metadata><rect width="${o}" height="${z}" fill="#fff"/>${me.join("")}</svg>
|
|
2
|
+
`}var xs=.9;function pt(e,t){return e+2>=t||e>=xs*t}var Ss=50;function lo(e,t,r,o=[]){let n=new Map(e.nodes.map(a=>[a.name,a])),i=[];for(let a of t){let s=[],d=1/0,c=-1/0,f=1/0,p=[],u=be(a);for(let[h,g]of u.entries()){let b=n.get(g),R=b&&r[b.id];if(!(!b||!R?.length)&&!(a.key?h===0||h===u.length-1:W(b)&&(b.stable.start<a.start||b.stable.start>=a.end))){p.push(b.id),s.push(or(R.length===1?[R[0],R[0]]:R));for(let x of R)d=Math.min(d,x.x),c=Math.max(c,x.x),f=Math.min(f,x.y)}}if(p.length===0)continue;let m={x:(d+c)/2,y:f},l=a.covering===!0||pt(p.length,e.nodes.length);i.push({bubble:a,label:Ln(a,o),path:s.join(""),labelAt:m,members:p.length,nodeIds:p,whole:l,tick:!l&&!a.partial&&a.longestAlleleLength<Ss})}return i}function ct(e,t){let r=new Set(t),o=e.nodes.filter(d=>r.has(d.name)),n=new Set(o.map(d=>d.id)),i=new Map(e.nodes.map(d=>[d.id,d.length])),a=new Map,s=e.paths?.flatMap(d=>{let c=d.nodeIds.findIndex(u=>n.has(u));if(c<0)return[];let f=d.nodeIds.filter(u=>n.has(u));a.set(d.name,{first:c,nodeIds:f});let p=d.nodeIds.slice(0,c).reduce((u,m)=>u+(i.get(m)??0),0);return[{...d,nodeIds:f,...d.refStarts?{refStarts:d.refStarts.filter((u,m)=>n.has(d.nodeIds[m]))}:{},...d.start===void 0?{}:{start:d.start+p}}]});return{name:e.name,nodes:o,edges:e.edges.filter(d=>n.has(d.from)&&n.has(d.to)),...s?.length?{paths:s}:{},anchorPaths:Co(e,a),pathVisits:e.pathVisits,anchoredBy:e.anchoredBy,referencePath:e.referencePath,revisited:e.revisited,...e.depthStated?{depthStated:!0}:{}}}function uo(e,t,r,o){let n=e.get(t);e.set(t,{min:Math.min(n?.min??1/0,r.min+o),max:Math.max(n?.max??-1/0,r.max+o),n:Math.min(vn,r.n+(n?.n??0))})}var Yi=(e,t)=>e<t?`${e} ${t}`:`${t} ${e}`,Ki=e=>e.stable.strand==="-"?"start":"end",Ui=e=>e.stable.strand==="-"?"end":"start";function vs(e,t,r){return e.length===0||e.some(o=>{let n=ue(o);return o.fromStrand===void 0||o.toStrand===void 0||(o.from===t.id?n.from===Ki(t)&&n.to===Ui(r):n.from===Ui(r)&&n.to===Ki(t))})}function Zi(e){if(!e.nodes.some(W))return[];let t=new Map(e.nodes.map(m=>[m.id,m])),r=Xr(e),o=new Map(r.map((m,l)=>[m,l])),n=new Int32Array(r.length+1),i=new Map,a=new Set,s=new Map;for(let m of e.edges){let l=o.get(m.from),h=o.get(m.to);if(l===void 0||h===void 0||l===h)continue;a.add(`${m.from}>${m.to}`).add(`${m.to}>${m.from}`),Ie(s,Yi(m.from,m.to),m);let[g,b]=l<h?[l,h]:[h,l];n[g+1]++,n[b]--;let[R,x]=l<h?[m.from,m.to]:[m.to,m.from];Eo(i,R,x)}for(let m=1;m<n.length;m++)n[m]+=n[m-1];let d=e.nodes.filter(W).sort((m,l)=>m.stable.start-l.stable.start),c=new Set([...Go(d,m=>m.stable.refName).values()].flatMap(m=>[m[0].id,m.at(-1).id])),f=d.map(m=>[m,o.get(m.id)]).filter(([m,l])=>c.has(m.id)||n[l]===0).sort(([m,l],[h,g])=>l-g||m.stable.start-h.stable.start),p=ho(e,f.map(([m])=>m.id)),u=[];for(let m=0;m+1<f.length;m++){let[l,h]=f[m],[g,b]=f[m+1],R=r.slice(h+1,b);if(R.length===0||l.stable.refName!==g.stable.refName)continue;let x=new Map([[l.id,{min:0,max:0,n:1}]]);for(let v of[l.id,...R]){let T=x.get(v);if(T)for(let U of i.get(v)??[])o.get(U)>b||uo(x,U,T,U===g.id?0:t.get(U).length)}let w=fo(e,t,p,l.id,g.id,{inside:new Set(R),beyond:(v,T)=>{let U=o.get(v);return U!==void 0&&(T===l.id?U<h:U>b)},direct:vs(s.get(Yi(l.id,g.id))??[],l,g)},()=>x.get(g.id)??{min:0,max:0,n:0}),y=l.stable.start+l.length,k=g.stable.start,S=[l.id,...R.filter(v=>W(t.get(v))),g.id],O=S.some((v,T)=>T>0&&!a.has(`${S[T-1]}>${v}`)),ie=k-y;u.push(bo({refName:l.stable.refName,start:y,end:k},[l,...R.map(v=>t.get(v)),g],O&&!w.routes?{...w,min:ie,max:ie}:w,O||w.walksLeave))}return u}function ho(e,t){let r=e.paths;if(!r)return;let o=new Map;for(let n of t)o.set(n,new Int32Array(r.length).fill(-1));return r.forEach((n,i)=>{let a=n.nodeIds;for(let s=0;s<a.length;s++){let d=o.get(a[s]);d?.[i]===-1&&(d[i]=s)}}),o}function fo(e,t,r,o,n,i,a){if(!r)return{...a(),walksLeave:!1};let s=r.get(o),d=r.get(n),c=[o,n];return wo(e,t,(f,p)=>{let u=s[p],m=d[p],l=Math.min(u,m)+1,h=Math.max(u,m);return u<0||m<0?u>=0||m>=0?"leaves":void 0:Ls(f,l,h,c,i)?{lo:l,hi:h,endFirst:m<u}:go(f,c,i)??"leaves"},a)}function Ls(e,t,r,o,n){let{beyond:i}=n;return r>t&&i?!(i(e[t],e[t-1])&&i(e[r-1],e[r])):qi(e,t,r,o,n)}function qi(e,t,r,o,{inside:n,direct:i}){let a=r>t||i;for(let s=t;s<r&&a;s++){let d=e[s];a=n.has(d)||d===o[0]||d===o[1]}return a}function go(e,t,r){let o,n=-1;for(let i=0;i<e.length&&!o;i++){let a=e[i];a===t[0]||a===t[1]?(n<0||e[n]!==a)&&(n>=0&&qi(e,n+1,i,t,r)?o={lo:n+1,hi:i,endFirst:e[n]===t[1]}:n=i):r.inside.has(a)||(n=-1)}return o}function wo(e,t,r,o){let n=[],i=1/0,a=-1/0,s=0;e.paths?.forEach((c,f)=>{let p=c.nodeIds,u=r(p,f);if(u==="leaves")s++;else if(u){let{lo:m,hi:l,endFirst:h}=u,g=h?R=>p[l-1-R]:R=>p[m+R],b=n.find(R=>R.steps.length===l-m&&R.steps.every((x,w)=>x===g(w)));if(!b){let R=Array.from({length:l-m},(w,y)=>g(y)),x=0;for(let w of R)x+=t.get(w)?.length??0;b={steps:R,bp:x,walks:[]},n.push(b)}b.walks.push(c.name),i=Math.min(i,b.bp),a=Math.max(a,b.bp)}});let d=s>0;return n.length?{min:i,max:a,n:n.length,routes:n,walksLeave:d}:{...o(),walksLeave:d}}function bo(e,t,{min:r,max:o,n,routes:i},a){return{...e,segmentCount:t.length,pathCount:n,inversion:!1,shortestAlleleLength:r,longestAlleleLength:o,segments:t.map(s=>s.name).join(","),shortestAllele:void 0,longestAllele:void 0,partial:a,routes:i,...t.some(s=>s.placeholder)?{unloaded:!0}:{}}}function Ns(e,t){let r=e.nodes.length*2,o=new Set,n=[],i=new Int32Array(r);for(let c of e.edges){let f=t.get(c.from),p=t.get(c.to);if(f===void 0||p===void 0)continue;let u=ue(c),m=f*2+(u.from==="end"?1:0),l=p*2+(u.to==="end"?1:0),h=Math.min(m,l)*r+Math.max(m,l);o.has(h)||(o.add(h),n.push(m,l),i[m]++,m!==l&&i[l]++)}let a=new Int32Array(r+1);for(let c=0;c<r;c++)a[c+1]=a[c]+i[c];let s=new Int32Array(a[r]),d=a.slice(0,r);for(let c=0;c<n.length;c+=2){let f=n[c],p=n[c+1];s[d[f]++]=p,f!==p&&(s[d[p]++]=f)}return{offset:a,next:s}}function Ms(e,t,r){let o=new Int32Array(e),n=new Uint8Array(e*2),i=new Int32Array(e*2),a=new Int32Array(e),s=[],d=0;return c=>{let f=c>>1;d++,s.length=0;let p=0,u=0,m=0,l,h=g=>{n[g]||(n[g]=1,p++,s.push(g))};h(c),i[u++]=c;e:for(;u>0;){let g=i[--u],b=g>>1;if(o[b]=d,b!==f&&(a[m++]=g),n[g]&&(n[g]=0,p--),t[g]===t[g+1])break;for(let R=t[g];R<t[g+1];R++){let x=r[R],w=x>>1;if(w===f)break e;if(h(x^1),o[w]===d)continue;let y=!0;for(let k=t[x];k<t[x+1];k++)if(o[r[k]>>1]!==d){y=!1;break}y&&(i[u++]=x^1)}if(u===1&&p===1){m>0&&(l={source:c,sink:i[0],inside:a.slice(0,m)});break}}for(let g of s)n[g]=0;return l}}function Ji(e){return{source:e.sink^1,sink:e.source^1,inside:e.inside.map(t=>t^1).reverse()}}function ra(e,t){return W(e)&&W(t)&&e.stable.refName===t.stable.refName}function Qi(e,t){return(e&1)===(t[e>>1].stable.strand==="-"?0:1)}function Ps(e,t){let r=t[e.source>>1],o=t[e.sink>>1];return ra(r,o)&&r.stable.start!==o.stable.start&&Qi(e.source,t)===r.stable.start>o.stable.start&&Qi(e.sink^1,t)===o.stable.start>r.stable.start}function yo(e,t){return ra(t[e.source>>1],t[e.sink>>1])&&!Ps(e,t)}function ea(e,t){let r=t[e.source>>1],o=t[e.sink>>1],n=yo(e,t)?r.stable.start-o.stable.start:0,i=((e.sink^1)&1)-(e.source&1);return(n||i||We(r.name,o.name))<0}function ta(e){return[e.source>>1,...Array.from(e.inside,t=>t>>1),e.sink>>1]}function As(e,t){let r=e.source>>1,o=e.sink>>1;return Math.min(r,o)*t+Math.max(r,o)}function Ts(e){let{nodes:t}=e,r=t.length*2,o=new Map(t.map((p,u)=>[p.id,u])),{offset:n,next:i}=Ns(e,o),a=Ms(t.length,n,i),s=new Map;for(let p=0;p<r;p++){let u=a(p);if(u){let m=u.source,l=u.sink^1,h=Math.min(m,l)*r+Math.max(m,l);(ea(u,t)||!s.has(h))&&s.set(h,u)}}let d=new Map;for(let p of s.values()){let u=ea(p,t)?p:Ji(p);Ie(d,As(u,t.length),u)}let c=[],f=new Map;for(let p of d.values()){let u=p.length===2&&p[0].source>>1===p[1].source>>1,m=p.map(l=>u&&(l.source&1)===0?Ji(l):l);c.push(...m),m.length===2&&f.set(m[0],m[1]).set(m[1],m[0])}return{found:c,twins:f,offset:n,next:i}}function Es(e,t,r,o){return o.subarray(r[e*2],r[e*2+2]).some(n=>n>>1===t)}function ko(e,t,r){return r.subarray(t[e.source],t[e.source+1]).includes(e.sink^1)}function Gs(e,t,r,o,n,i,a){let{nodes:s}=e,d=[s[r.source>>1].id,s[r.sink>>1].id],c=new Set(Array.from(r.inside,l=>s[l>>1].id)),f=ko(r,n,i),p=f&&ko(o,n,i),u={inside:c,direct:f&&!p},m=(l,h)=>p&&h>0&&l[h]!==l[h-1]&&d.includes(l[h])&&d.includes(l[h-1]);return wo(e,t,l=>go(l,d,u)??(l.some((h,g)=>c.has(h)||m(l,g))?"leaves":void 0),a)}function Is(e,t,r,o){let n=o.sink>>1,i=new Map([[o.source>>1,{min:0,max:0,n:1}]]);for(let a of[o.source,...o.inside]){let s=i.get(a>>1);if(s)for(let d=t[a];d<t[a+1];d++){let c=r[d]>>1;uo(i,c,s,c===n?0:e[c].length)}}return i.get(n)??{min:0,max:0,n:0}}function Ro(e,t){let{nodes:r}=e,{found:o,twins:n,offset:i,next:a}=Ts(e),s=o.map(l=>pt(l.inside.length,r.length)),d=o.map(ta),c=new Map;d.forEach((l,h)=>{for(let g of l)Ie(c,g,h)});let f=(l,h)=>c.get(l.inside[0]>>1).some(g=>g!==h&&!s[g]&&d[g].length>d[h].length&&d[h].every(b=>c.get(b).includes(g))),p=o.filter((l,h)=>!s[h]&&(t!==void 0||yo(l,r))&&!f(l,h)),u=new Map(r.map(l=>[l.id,l])),m=ho(e,p.flatMap(l=>[r[l.source>>1].id,r[l.sink>>1].id]));return p.map(l=>{let h=r[l.source>>1],g=r[l.sink>>1],b=n.get(l),R=()=>Is(r,i,a,l),x=b?Gs(e,u,l,b,i,a,R):fo(e,u,m,h.id,g.id,{inside:new Set(Array.from(l.inside,S=>r[S>>1].id)),direct:ko(l,i,a)||!Es(l.source>>1,l.sink>>1,i,a)},R),w=yo(l,r),[y,k]=!w||h.stable.start<=g.stable.start?[h,g]:[g,h];return{...bo({refName:w?h.stable.refName:t.refName,start:w?y.stable.start+y.length:t.start,end:w?k.stable.start:t.end},ta(l).map(S=>r[S]),x,x.walksLeave),key:`${h.name}>${g.name}`,...w?{}:{offReference:!0}}}).sort((l,h)=>l.start-h.start||l.end-h.end||We(l.key,h.key))}function qt(e,t){let r=e.nodes.length,o=Zi(e);if(o.length===0){let n=Ro(e,t);return t?[...n,{...t,covering:!0}]:n}return o.flatMap(n=>pt(n.segmentCount-2,r)?[...Ro(n.segmentCount===r?e:ct(e,be(n)),n),{...n,covering:!0}]:[n])}function xo(e,t,r){return t==="uniform"||t==="grey"?void 0:Bs(e,t,r)}function Bs(e,t,r){let o=tn(e,r);return new Map(e.nodes.flatMap((n,i)=>n.placeholder?[]:[[n.id,Uo(rn(n,i,t,o))]]))}var Jt=JBrowseExports["@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain"];var oa=Jt&&Jt.__esModule?Jt.default:Jt;var So={paths:!1,bubbles:!1,deletions:!0,genes:!0,lengths:wt.nodeLengths,referenceStrip:!0,walkStrip:!1,walkRibbons:!1,walkBlocks:!1,smallSites:!1};function na(e){let t=D(e)?e:{};return new Set(Object.keys(So).filter(r=>t[r]??So[r]))}function _S(e,t,r){let{[t]:o,...n}=D(e)?e:{};return r===So[t]?n:{...n,[t]:r}}var vo={depth:"depth",length:"node-length",rank:"stable-rank",position:"reference-position"},ia=Object.fromEntries(Object.entries(vo).map(([e,t])=>[t,e]));function aa(e){if(D(e)){let{field:t,value:r,scale:o}=e;if(r==="grey"||r==="uniform")return r;if(t==="id")return D(o)&&o.scheme==="rainbow"?"rainbow":"random";if(typeof t=="string"&&t in vo)return vo[t]}return"auto"}function sa(e){let t=D(e)?e.scale:void 0;return D(t)&&typeof t.domainMin=="number"&&typeof t.domainMax=="number"?{start:t.domainMin,end:t.domainMax}:void 0}function WS(e,t){return e==="grey"||e==="uniform"?{value:e}:e==="random"?{field:"id",scale:{type:"ordinal"}}:e==="rainbow"?{field:"id",scale:{scheme:"rainbow"}}:e==="reference-position"&&t?{field:"position",scale:{domainMin:t.start,domainMax:t.end}}:ia[e]?{field:ia[e]}:{}}var da=6;function Qt(e){return typeof e=="number"?{width:"uniform",px:e,links:"uniform"}:D(e)?{width:e.field==="depth"||e.field==="frequency"?e.field:"uniform",px:typeof e.value=="number"?e.value:da,links:e.links==="walks"?"walks":"uniform"}:{width:"depth",px:da,links:"uniform"}}function DS({width:e,px:t,links:r}){return e==="uniform"&&r==="uniform"?t:{...e==="uniform"?{}:{field:e},value:t,...r==="walks"?{links:r}:{}}}function pa(e,t,r,o){let n=Oo(e,t,{visits:o});return n?cr(n,r):void 0}var Cs=[];function _s(e,t){return e.gene.name===t.gene.name&&e.gene.refName===t.gene.refName&&e.gene.start===t.gene.start&&e.gene.end===t.gene.end&&e.exons===t.exons&&e.at.x===t.at.x&&e.at.y===t.at.y&&e.covered===t.covered&&e.onReference===t.onReference&&e.walks===t.walks&&e.nodeIds.size===t.nodeIds.size&&[...e.nodeIds].every(r=>t.nodeIds.has(r))}function Os(e,t){return e.length===t.length&&e.every((r,o)=>{let n=t[o];return n!==void 0&&_s(r,n)})}function Lo(e,t){return e.size===t.size&&[...e.keys()].every(r=>t.has(r))}function ca(e){try{return e()}catch{return}}function ma(e){let t=new Map;for(let r of e.nodes)t.set(r.id,r);return t}function la(e,t,r){return t&&r?mr({nodeId:e,nodeById:t,neighbors:r}):void 0}var ua=yn.views(e=>({sessionTrack(t){return te(e).tracks.find(r=>r.trackId===t)},get grammar(){return{}},get hasPendingSource(){return!1},get canRetryLoad(){return!1},get sourceTrack(){return ca(()=>Po(e).configuration)},get sourceAdapter(){let t=this.sourceTrack;return t?Ni(e,t):void 0},get containingView(){return ca(()=>lt(e))}})).views(e=>{let t=a=>He(a,{equals:(s,d)=>JSON.stringify(s)===JSON.stringify(d)}),r=t(()=>sa(e.grammar.encoding?.color)),o=t(()=>Ct(e.grammar.facet)),n=t(()=>{let a=Yn(e.grammar.facet);return a&&a.field!=="walk"&&a.field!=="sample"?a:void 0}),i=t(()=>e.grammar.walks??[]);return{get walkLayers(){return i.get()},get chosenLayoutMode(){return e.grammar.layoutMode??"force"},get chosenLayoutEngine(){return e.grammar.layoutEngine??"fmmm"},get chosenColorScheme(){return aa(e.grammar.encoding?.color)},get statedColorDomain(){return r.get()},get chosenHover(){return e.grammar.hover??"nodes"},get chosenLinks(){return e.grammar.links??Qn},get nodeWidth(){return Qt(e.grammar.size).width},get contigThickness(){return Qt(e.grammar.size).px},get linkWidth(){return Qt(e.grammar.size).links},get layerSet(){return na(e.grammar.layers)},get drawPaths(){return this.layerSet.has("paths")},get showBubbles(){return this.layerSet.has("bubbles")},get showDeletionEdges(){return this.layerSet.has("deletions")},get smallSites(){return this.layerSet.has("smallSites")?"nodes":"hidden"},get showGenes(){return this.layerSet.has("genes")},get showReferenceStrip(){return this.layerSet.has("referenceStrip")},get walkStrip(){return this.layerSet.has("walkStrip")},get walkRibbons(){return this.layerSet.has("walkRibbons")},get facetSetting(){return o.get()},get walkRowGroupBy(){return n.get()},get walkRowSamples(){let a=e.grammar.rows?.kept;return Array.isArray(a)?a:void 0},get walkRowsFollowLift(){return e.grammar.rows?.kept==="lifted"},get walkRowOrder(){return e.grammar.rows?.order==="shared"?"shared":void 0},get hoverLightsEverything(){return this.chosenHover==="everything"},get litNode(){return this.chosenHover==="off"?null:e.hoveredNode}}}).views(e=>({get paneMeasured(){let t=lt(e);return!zt(t)||t.initialized},get paneWidth(){return this.paneMeasured?lt(e).width:0},get drawnGraph(){return e.layoutResult?.tubeMap?.graph??e.graph}})).views(e=>({get nodeById(){return e.drawnGraph&&ma(e.drawnGraph)},get nodeLengths(){return bt(e.drawnGraph?.nodes??[],e.layerSet.has("lengths"))},get nodeCount(){return e.graph?.nodes.length??0},get edgeCount(){return e.graph?.edges.length??0},get pathCount(){return e.graph?.paths?.length??0},get legendAtRest(){return e.hoveredNode===null&&e.hoveredRowWalks.length===0},get hasGraph(){return e.graph!==void 0},get canCancelLoad(){return e.isLoading&&!e.layoutResult},get usesLayoutEngine(){return e.graph?jr(e.chosenLayoutMode,e.graph):!1},get anchorPaths(){return e.graph?.anchorPaths??[]},get walkChoices(){let t=e.graph?.paths;return t?.length?je(t):[]},get effectiveDrawPaths(){return e.drawPaths&&kt(e.graph?.paths?.length??0)},get activeReferencePath(){return e.graph?.referencePath},get rampDomain(){let t=e.openBubbles.at(-1);return t&&!t.offReference&&t.end>t.start?{start:t.start,end:t.end}:e.statedColorDomain??e.graphRegion},get drawnReferenceRamp(){let t=e.drawnGraph;return t?Ye(t,this.rampDomain):void 0},get walkRamp(){return e.walkLayers.some(t=>t.color?.field==="reference")?this.drawnReferenceRamp:void 0},get modeDrawsNodes(){return V(e.chosenLayoutMode).drawsNodes},get liftedWalkLayers(){return e.walkLayers.length>0||!this.modeDrawsNodes?e.walkLayers:e.hoveredRowWalks.map(t=>({walk:t}))},get sheetColorOf(){let t=e.walkRowSampleTable,r=e.sourceAdapter;return t&&r?ei(t,Bo({getConf:o=>r[o]})):void 0},get coloredWalkLayers(){let t=this.sheetColorOf;return this.liftedWalkLayers.map(r=>{let{field:o,scheme:n,value:i}=r.color??{},a=(o??n??i)===void 0?t?.(r.walk):void 0;return a===void 0?r:{...r,color:{...r.color,value:a}}})},get walkLift(){let{graph:t}=e,r=this.coloredWalkLayers;return t&&!e.walkCut&&r.length>0&&!e.layoutResult?.tubeMap?Qe(t,r,this.walkRamp):void 0},get facetPanels(){let{graph:t}=e,r=this.walkLift;return e.facetSetting.field!==""&&this.modeDrawsNodes&&t&&r&&e.walkLayers.length>1&&r.walks.length>1?et(t,r,this.coloredWalkLayers,this.walkRamp):void 0},get drawnWalks(){return this.facetPanels?.map(t=>t.walks[0])??this.walkLift?.walks??[]},get walksShadedAlong(){let t=this.drawnWalks;return t.length>0&&t.every(r=>r.encoding.field==="progress")},get liftsWalks(){return!un.has(e.chosenLayoutMode)},get walkReference(){let t=this.walkLift?.referenceDomain;return t&&{...t,name:e.graph&&$e(e.graph,e.graphRegion)}},get liftedWalks(){return this.walkLift?.walks.map(t=>t.name)},get walkLabels(){return Rt(this.walkChoices)},walkLabel(t){return this.walkLabels.get(t)??t},get liftedWalksLabel(){let t=this.walkLift?.walks??[];return t.length===1?this.walkLabel(t[0].name):"these walks"},get effectiveColorScheme(){return e.layoutResult?.tubeMap&&(this.tubeMapReads||e.chosenColorScheme==="auto")?"uniform":st(e.chosenColorScheme,e.graph)},get tubeMapReads(){let t=e.layoutResult;return!t?.tubeMapPanels&&(t?.tubeMap?.layout.reads.length??0)>0},get colorSchemeLock(){return this.walkLift?{value:"By walk",why:"Each highlighted haplotype colours its own lane: set it under Haplotypes, Color highlighted..."}:this.tubeMapReads?{value:"By strand",why:"Reads take the reds and blues, so the tube map leaves its nodes clear"}:void 0},get nodePositions(){return e.layoutResult?.nodePositions},get alleleDeletions(){return e.layoutResult?.alleleDeletions??[]},get deletionRoutes(){return e.layoutResult?.deletionRoutes},get stranded(){return e.layoutResult?.stranded},get pixelRows(){return e.layoutResult?.pixelRows??!1},get zoomPercent(){return`${(e.scale*100).toFixed(1)}%`},get isDefaultViewport(){return e.scale===1&&e.translateX===0&&e.translateY===0}})).views(e=>({get derivedBubbles(){return e.graph?qt(e.graph):[]},get openBubbleInsides(){let{graph:t}=e;return t?e.openBubbles.map(r=>qt(ct(t,be(r)),r).filter(o=>!o.covering)):[]},get openBubble(){return e.openBubbles.at(-1)},get openBubbleFocus(){let t=this.openBubble,{graph:r}=e;if(!t||!r)return;let o=new Set(be(t)),n=new Set(r.nodes.filter(a=>o.has(a.name)).map(a=>a.id)),i=new Set;return r.edges.forEach((a,s)=>{n.has(a.from)&&n.has(a.to)&&i.add(s)}),{walks:[],nodeIds:n,edgeIndexes:i,names:new Set}},get drawnHighlight(){return e.walkLift??this.openBubbleFocus},bubbleIsOpen(t){return e.openBubbles.some(r=>At(r,t))},bubbleFaded({bubble:t,nodeIds:r}){let o=e.walkLift,n=this.openBubbleFocus;return o?!r.some(i=>o.nodeIds.has(i)):!!n&&!this.bubbleIsOpen(t)&&!r.every(i=>n.nodeIds.has(i))},nodeFaded(t){let r=this.drawnHighlight;return!!r&&!r.nodeIds.has(t)}})).views(e=>({get bubbles(){let t=e.indexBubbles?.length?e.indexBubbles:e.derivedBubbles,r=[...t],o=new Set(t.map(_r));for(let n of e.openBubbleInsides.flat()){let i=_r(n);o.has(i)||(o.add(i),r.push(n))}return r},get foldNote(){let t=e.foldedBelowBp;return t===void 0?void 0:`variants under ${yt(t)} folded into the reference`}})).views(e=>({get cutHaplotypes(){},get sourceTrackId(){return e.sourceTrack?.trackId},get sessionTracks(){let t=te(e);return t.tracks.map(r=>({trackId:r.trackId,name:$o(r,t),adapterType:ht(r).type,assemblies:qr(t,r)}))}})).views(e=>({get assemblyTrackChoices(){let t=e.graphRegion,r=t&&Zr(te(e),t.assemblyName);return r?e.sessionTracks.filter(o=>o.assemblies.includes(r)):[]}})).views(e=>({get geneTrackChoices(){return e.assemblyTrackChoices.filter(t=>Wt.has(t.adapterType))},get repeatTrackChoices(){return e.assemblyTrackChoices.filter(t=>ti.has(t.adapterType))},get repeatChoices(){return e.repeatArrays??[]}})).views(e=>({get repeatTrack(){return ri(e.repeatTrackChoices,e.repeatTrackId)},get geneTrack(){return Ht(e.geneTrackChoices,e.geneTrackId)},get walkRowAnnotation(){return Ft(this.geneTrack)},get repeatOptions(){return[{value:"",label:"Whole window"},...e.repeatChoices.map(({key:t,name:r,unit:o})=>({value:t,label:`${r} \xB7 ${o.toLocaleString()} bp unit`}))]},get selectedRepeat(){return e.repeatChoices.find(t=>t.key===e.repeatKey)},get backbone(){return e.graph?sr(e.graph):void 0},get cutWalkRows(){let t=e.walkCut,r=t?.walkRowRuns,o=this.rowVisitsNeeded;return t&&r&&o&&e.graphRegion?pa(t,e.graphRegion,void 0,!0):r?cr(r):e.graph?ve(e.graph,e.graphRegion,void 0,{visits:o}):void 0},get rowVisitsNeeded(){return e.chosenLayoutMode==="walkrows"&&(e.walkRibbons||e.layerSet.has("walkBlocks")||e.walkRowOrder==="shared")},assemblySpellings(t){let{assemblyManager:r}=te(e),o=r.has(t)?r.get(t):void 0,n=e.sourceAdapter?.assemblyNameToPanSN??{},i=[t,...o?[o.name,...o.aliases]:[]];return{name:t,aliases:[...i,...i.flatMap(a=>n[a]??[])]}},get drawsLoadedReference(){let t=e.graph;return t?.anchoredBy==="tags"||t?.referencePath!==void 0&&t.referencePath===e.loadedReferencePath}})).views(e=>({get geneAssembly(){let t=e.graphRegion;return t?e.assemblySpellings(t.assemblyName):void 0},get geneLaneFilter(){let t=e.containingView;if(!t)return;let r=oi(t,e.geneTrack?.trackId);return r.length?new oa({filters:r,jexl:Ao(e).pluginManager.jexl}):void 0},get geneFeatures(){let t=e.geneTrackFeatures,r=this.geneLaneFilter;return t?ni(r?t.filter(o=>r.passes(o)):t):void 0},get genesBindBackbone(){let{geneAssembly:t}=this;return e.drawsLoadedReference||t!==void 0&&dr(e.backbone,[t])!==void 0},get backboneGenes(){let{backbone:t}=e,{geneFeatures:r}=this;return t&&r&&this.genesBindBackbone?pr(r,t):void 0}})).views(e=>{let t=He(()=>{let o=e.drawnBatch.collapsed;return{nodes:o?.nodes??gt.nodes,within:o?.within??gt.within}},{equals:(o,n)=>Lo(o.nodes,n.nodes)&&Lo(o.within,n.within)}),r=He(()=>Xe(e.drawnBatch),{equals:Lo});return{get folded(){return t.get().nodes},get notDrawn(){return r.get()},get foldedWithin(){return t.get().within}}}).views(e=>({get nodeNeighbors(){return e.drawnGraph?se(e.drawnGraph):void 0},get drawnFold(){return e.drawnBatch.collapsed},get nodeInk(){return ft(e.drawnGraph,e.nodeById,e.contigThickness,e.nodeWidth,0,this.drawnFold?.through)},get allDeletions(){return e.graph&&this.drawsNodes?Fe(e.graph):[]},get cohortWalkRows(){if(e.chosenLayoutMode!=="walkrows"||!e.graph)return;let t=e.selectedRepeat,r=e.walkCut,o=e.rowVisitsNeeded,n=t?r?pa(r,t,t.unit,o):ve(e.graph,t,t.unit,{visits:o}):e.cutWalkRows;if(!n)return;let[i,...a]=ii([n.reference,...n.rows],t?.calls);return{...n,reference:i,rows:a}},get walkRowSampleChoices(){let t=this.cohortWalkRows?.rows??[];return{samples:[...new Set(t.map(r=>r.sample))].sort(),disagreeing:[...new Set(t.filter(r=>r.call?.agrees===!1).map(r=>r.sample))]}},get walkRowSamplesTsv(){let t=e.sourceAdapter?.samplesTsvLocation;return t&&To(t)?t:void 0},get walkRowGroupFields(){return zn(e.walkRowSampleTable)},get tubeMapColoring(){let t=e.tubeMapColorBy,r=e.walkRowSampleTable;if(!t||!r||!this.walkRowGroupFields.includes(t))return;let o=pi(t,r),n=(e.graph?.paths??[]).map(i=>ge(i.name).name).filter(i=>i!==e.graph?.referencePath);return{field:t,valueOf:o,palette:si(n.map(o)),unvalued:n.some(i=>o(i)==="")}},get tableGroupBy(){let t=e.walkRowGroupBy,r=e.walkRowSampleTable;return t&&r&&this.walkRowGroupFields.includes(t.field)?{groupBy:t,table:r}:void 0},get tubeMapPanelSplit(){let{field:t,sort:r}=e.facetSetting,o=this.tableGroupBy;return t!==""?{by:t,sort:r}:o?{by:"column",...o.groupBy,table:o.table}:void 0},get liftedRowHaplotypes(){let t=e.drawnWalks;return[...new Set((e.cutWalkRows?.rows??[]).filter(r=>t.some(o=>Ke(o.name,r))).map(gr))]},get keptRowSamples(){return e.walkRowsFollowLift?this.liftedRowHaplotypes:e.walkRowSamples},get keptCohortRows(){let t=this.cohortWalkRows,r=t&&ze(t.rows,this.keptRowSamples);if(!t||!r||e.walkRowOrder!=="shared")return r;let o=[t.reference,...r];return jo(o).filter(n=>n>0).map(n=>o[n])},get walkRowGroups(){let t=this.keptCohortRows,r=this.tableGroupBy;return t&&r?Kn(t,r.table,r.groupBy):void 0},get walkRowBars(){let t=this.cohortWalkRows,r=this.keptCohortRows;return t&&r?{...t,rows:this.walkRowGroups?.rows??r}:void 0},get walkRowList(){let t=this.walkRowBars;return t?[t.reference,...t.rows]:[]},get walkRowRibbons(){let t=this.walkRowGroups?.sections??[];return e.walkRibbons&&e.rowVisitsNeeded&&this.walkRowBars?zo(this.walkRowList).filter(({row:r})=>Hr(t,r)===Hr(t,r+1)):void 0},get sharedBlocks(){return e.layerSet.has("walkBlocks")&&e.rowVisitsNeeded&&this.walkRowBars?Yo(this.walkRowList):void 0},get drawsNodes(){return V(e.drawnLayoutMode??e.chosenLayoutMode).drawsNodes},get labelsNodeSizes(){return this.drawsNodes&&!e.layoutResult?.tubeMap&&!e.walkLift},get bubbleHalos(){Je(e.positionsVersion);let t=e.layoutResult?.nodePositions,r=e.showBubbles?e.bubbles:e.hoveredBubble?[e.hoveredBubble]:[];if(r.length===0||!this.drawsNodes||!e.graph||!t)return[];let{folded:o,foldedWithin:n}=e,i=o.size?Object.fromEntries(Object.entries(t).filter(([a])=>!o.has(a))):t;return lo(e.graph,r,i,e.repeatArrays).filter(a=>!a.nodeIds.every(s=>n.has(s)))},get referenceRamp(){return e.effectiveColorScheme==="reference-position"?e.drawnReferenceRamp:void 0},get assemblyNames(){let t=e.graphRegion;return t?[t.assemblyName]:[]},get axisScale(){return Mt(e.scale,e.pixelRows)},get scaleX(){return this.axisScale.scaleX},get scaleY(){return this.axisScale.scaleY}})).views(e=>{let t=He(()=>{Je(e.positionsVersion);let r=e.layoutResult?.nodePositions,o=[...e.backboneGenes??[],...e.ownGeneFeatures??[]];return e.showGenes&&e.drawsNodes&&e.graph&&o.length>0&&r?Ue(e.graph,o,r,e.layoutResult?.stranded):Cs},{equals:Os});return{get genePins(){return t.get()}}}).views(e=>({get exonOutlines(){let{genePins:t,walkLift:r}=e,o=r?void 0:e.openBubbleFocus,n=o?t.map(i=>({...i,exonsByNode:i.exonsByNode.filter(a=>o.nodeIds.has(a.nodeId))})):t;return Tt(n,e.nodeInk.halfWidthPx,r,void 0,e.notDrawn)}})).views(e=>({get screenTransform(){return{scaleX:e.scaleX,scaleY:e.scaleY,translateX:e.translateX,translateY:e.translateY}},toScreen(t){return{x:t.x*e.scaleX+e.translateX,y:t.y*e.scaleY+e.translateY}},get deletionDrawing(){return e.graph?De(e.graph,e.allDeletions,e.showDeletionEdges):void 0},get deletions(){return this.deletionDrawing?.shown??[]},get deletionEdgeIndexes(){return this.deletionDrawing?.bypassed},get hiddenEdgeIndexes(){return this.deletionDrawing?.hidden},get referenceRampDomain(){let t=e.referenceRamp;return t?{start:t.start,end:t.start+t.span}:void 0},get paintsNodeColors(){return e.drawsNodes||!!e.layoutResult?.tubeMap},get tubeMapNodeColors(){let t=e.drawnGraph;return e.layoutResult?.tubeMap&&t?xo(t,e.effectiveColorScheme,e.referenceRamp):void 0},get tubeColorKind(){let t=e.layoutResult,r=e.drawnGraph?.paths??[],o=e.tubeMapReads;return t?.tubeMap?e.tubeMapColoring&&!o?"value":t.tubeMapPanels?"role":this.tubeMapNodeColors?"tinted":!o&&(!kt(r.length)||r.some(n=>n.members))?"role":"path":void 0},tubeColorsOf(t,r){let o=t.paths??[],n=this.tubeColorKind,i=e.tubeMapColoring;return n==="value"&&i?di(o,t.referencePath,i.valueOf,i.palette):n==="tinted"?Fr(o,t.referencePath,ai):n==="role"?Fr(o,t.referencePath):r},fadeUnhovered(t,r,o){let n=new Set(e.hoveredRowWalks);return n.size>0?t.map((i,a)=>{let s=r[a]?.name??"";return n.has(s)||o!==void 0&&ge(s).name===o?i:xt}):t},get tubeMapTubeColors(){let t=e.layoutResult?.tubeMap,r=e.drawnGraph;return t&&r?this.fadeUnhovered(this.tubeColorsOf(r,t.pathColors),r.paths??[]):void 0},nodeSpan(t){return la(t,e.nodeById,e.nodeNeighbors)},get hoverDrawing(){let t=e.hoveredPanel;return(t===null?void 0:e.layoutResult?.tubeMapPanels?.[t]?.result.tubeMap)??e.layoutResult?.tubeMap},get hoverGraph(){return this.hoverDrawing?.graph??e.drawnGraph},get hoverNodeById(){let t=this.hoverGraph;return t===e.drawnGraph?e.nodeById:t&&ma(t)},get hoverNeighbors(){let t=this.hoverGraph;return t===e.drawnGraph?e.nodeNeighbors:t&&se(t)}})).views(e=>({get pathLegend(){let t=e.drawnGraph?.paths;return(e.layoutResult?.tubeMap?e.tubeColorKind==="path":e.drawPaths)&&t&&kt(t.length)&&!t.some(o=>o.members)?je(t,e.tubeMapTubeColors):[]},get hoveredSpan(){let t=e.hoveredNode,r=e.hoveredBubble;return t!==null?la(t,e.hoverNodeById,e.hoverNeighbors):r&&!r.offReference?{start:r.start,end:r.end}:void 0},get hoverHighlight(){let t=e.graphRegion,r=this.hoveredSpan;return t&&r&&e.chosenHover!=="off"?{refName:t.refName,assemblyName:t.assemblyName,...r}:void 0}}));var ha=ua.views(e=>({get host(){let t=e.containingView;return zt(t)?t:void 0}})).views(e=>({get pairedViewId(){return e.host?.id??e.connectedViewId}})).views(e=>({get contributingAssemblies(){let t=e.graph,r=t?ae(t):[];return t?Ai(t,{maxGap:r.length>0?ir(r):1/0}):[]}})).views(e=>({get assemblyResolver(){let{assemblyManager:t}=te(e),r=e.sourceAdapter?.assemblyNameToPanSN,o=new Map(Object.entries(r??{}).map(([i,a])=>[a,i])),n=i=>i!==void 0&&t.has(i)?t.get(i)?.name??i:void 0;return i=>n(o.get(i))??n(i)},get geneTracksByAssembly(){let t=new Map;for(let r of e.sessionTracks)if(Wt.has(r.adapterType)&&Ft(r)===e.walkRowAnnotation)for(let o of r.assemblies)t.set(o,[...t.get(o)??[],r]);return new Map([...t].flatMap(([r,o])=>{let n=Ht(o,"");return n?[[r,n]]:[]}))}})).views(e=>({get launchableAssemblies(){return Ti(Ii(e.contributingAssemblies,e.graphRegion),e.assemblyResolver)},get canHighlightInLinearView(){let t=e.graphRegion;return t!==void 0&&Te({views:[...te(e).views],connectedViewId:e.pairedViewId,assemblyName:t.assemblyName})!==void 0},nodeLaunchTargets(t){let r=e.nodeById?.get(t),o=r?Kr(r):void 0,n=o?Re(e.assemblyResolver,o):void 0,i=e.graphRegion,a=i?e.nodeSpan(t):void 0,s=i&&a?{sample:i.assemblyName,haplotype:void 0,refName:i.refName,...a}:void 0;return{own:o&&n?{location:Qr(o),assembly:n}:void 0,reference:i&&s?{location:Qr(s),assembly:i.assemblyName}:void 0,highlight:i&&s?{location:s,assembly:i.assemblyName}:void 0}},get ownGeneReads(){let{graph:t}=e;return!t||!e.showGenes||!e.modeDrawsNodes?[]:Pi(t,e.assemblyResolver,e.graphRegion?.assemblyName).flatMap(({stableRefName:r,assemblyName:o,refName:n,start:i,end:a})=>{let s=e.geneTracksByAssembly.get(o);return s?[{stableRefName:r,trackId:s.trackId,region:{assemblyName:o,refName:n,start:i,end:a}}]:[]}).slice(0,gn)},get assemblyHoverHighlights(){let t=e.hoveredNode,r=t===null?void 0:e.nodeById?.get(t);return r&&e.graph&&e.chosenHover!=="off"?Mi(e.graph,r,e.assemblyResolver,e.graphRegion?.assemblyName):[]}}));var fa=ha.views(e=>({get walkStripShown(){return eo({walkStrip:e.walkStrip,mode:{drawsNodes:e.modeDrawsNodes},drawsPicture:!!e.layoutResult?.tubeMap||!!e.walkRowBars,walks:e.graph?.paths?.length??0,host:!!e.host})},get walkStripRows(){let t=this.walkStripShown?e.cutWalkRows:void 0;return t?{...t,rows:ze(t.rows,e.keptRowSamples)}:void 0},get walkStripInks(){return we(e.drawnWalks)},get walkStripFrame(){let t=this.walkStripRows;return t?{...ot(t,{width:e.paneWidth}),measure:tt}:void 0},get cutsWholeWalks(){let t=V(e.chosenLayoutMode);return e.sourceAdapter?.type==="GbzBaseSyntenyAdapter"&&to(t,{walkStrip:e.walkStrip&&t.drawsNodes,host:!!e.host})},get walkStripMarks(){let t=this.walkStripRows,r=e.hoveredNode??e.selectedNode,o=r===null?void 0:e.nodeById?.get(r);return t&&o&&e.graph?ro(e.graph,[t.reference,...t.rows],o):[]},rowLocation(t,r){let o={sample:t.sample,haplotype:t.haplotype===void 0?void 0:`${t.sample}#${t.haplotype}`};return{...o,assembly:Re(e.assemblyResolver,o),span:{refName:r.contig,...vt(r,t.bp)}}},get comparedRows(){return e.rowVisitsNeeded?e.walkRowBars?.rows??[]:[]},get passBars(){return!e.host&&e.drawsNodes&&!e.facetPanels?it(e.walkLift,this.walkStripRows):[]},get walkStripLocator(){let t=e.stripHover?e.hoveredNode:null;return t===null||e.folded.has(t)?void 0:$t(e.nodePositions?.[t],e.toScreen)}})).views(e=>({get walkGeneReads(){let t=e.walkRowBars??e.walkStripRows;if(!t||!e.showGenes)return;let r=t.rows.filter(i=>!i.stepless),o=r.flatMap(i=>{let a=i.axis?e.rowLocation(i,i.axis):void 0,s=a?.assembly,d=s?e.geneTracksByAssembly.get(s):void 0;return a&&s&&d?[{row:i.name,trackId:d.trackId,region:{assemblyName:s,...a.span}}]:[]}),n=r.filter(i=>!i.axis).length;return{reads:o.slice(0,Ir),gaps:{untracked:r.length-n-o.length,unplaced:n,unread:Math.max(0,o.length-Ir)}}},get walkRowGeneGaps(){return this.walkGeneReads?.gaps},walkRowLaunchTarget(t,r=e.walkRowBars){let o=r?[r.reference,...r.rows][t]:void 0;if(!o?.axis)return;let{sample:n,haplotype:i,assembly:a,span:s}=e.rowLocation(o,o.axis);return{label:o.label,assembly:t===0?e.graphRegion?.assemblyName:a,location:{sample:n,haplotype:i,...s}}},get walkRowGenes(){let t=e.walkRowBars??e.walkStripRows;if(!t||!e.showGenes)return;let r=new Map(e.walkGeneFeatures??[]);return e.geneFeatures&&e.genesBindBackbone&&r.set(t.reference.name,e.geneFeatures),r.size?an([t.reference,...t.rows],r):void 0}}));var ga=fa.views(e=>({get xIsReferenceBp(){return e.layoutResult?.referenceAxis===!0&&V(e.drawnLayoutMode??e.chosenLayoutMode).cutMargins}})).views(e=>({get hostPlacesX(){let{host:t,graphRegion:r}=e;return t!==void 0&&t.initialized&&r!==void 0&&e.xIsReferenceBp&&!ke(t).some(o=>o.refName===r.refName&&o.reversed)}})).views(e=>({get hostBpFrame(){let{host:t,graphRegion:r}=e;return t?.initialized&&r?Ri(t,r):void 0}})).views(e=>({get hostFrame(){return e.hostPlacesX?e.hostBpFrame:void 0},get tubeMapPicture(){let t=e.layoutResult?.tubeMap;return t?Jn(t):void 0},get tubeMapReference(){let t=e.layoutResult?.tubeMap;return t?Dn(t):void 0},get tubeMapDeviations(){let t=e.layoutResult?.tubeMap;return t?.coarse?qn(t,t.coarse.deviations):[]},get tubeMapConnectedBoxes(){let t=this.tubeMapReference,{layoutResult:r}=e;return t&&!r?.referenceAxis&&!r?.tubeMapPanels?[...t.values()].flat():void 0}})).views(e=>({get tubeMapGenes(){let t=e.tubeMapReference;return e.showGenes&&!e.host&&t&&e.backboneGenes&&!e.layoutResult?.tubeMapPanels?Xn(t,e.backboneGenes):[]},get referenceStripApplies(){return!!e.host?.initialized&&!!e.layoutResult&&e.drawsNodes&&!e.hostPlacesX&&!e.facetPanels}})).views(e=>({get referenceStripBlocks(){let{graph:t}=e;if(!e.showReferenceStrip||!e.referenceStripApplies||!t)return[];let r=$n(t,{colorScheme:e.effectiveColorScheme,referenceRamp:e.referenceRamp,walks:e.walkLift?.walks}),o=e.walkLift?void 0:e.openBubbleFocus;return o?r.map(n=>o.nodeIds.has(n.node)?n:{...n,colors:[xt],faded:!0}):r}})).views(e=>({get referenceStripShown(){return e.referenceStripBlocks.length>0&&e.hostBpFrame!==void 0},get referenceStripOverhangs(){let t=e.hostBpFrame;if(!t||e.referenceStripBlocks.length===0)return!1;let{left:r,right:o}=Wn(e.referenceStripBlocks,t,e.paneWidth);return r>0||o>0},get referenceStripFaded(){let t=e.hostBpFrame;return t!==void 0&&Hn(e.referenceStripBlocks,t,e.paneWidth)}})).views(e=>({get referenceStripLit(){if(!e.referenceStripShown)return;let t=e.hoveredNode===null?e.hoveredBubble:null;if(t&&!t.offReference){let n=e.bubbleHalos.find(i=>At(i.bubble,t));return{start:t.start,end:t.end,anchor:n?e.toScreen(n.labelAt):void 0}}let r=e.hoveredNode??e.selectedNode,o=r===null?void 0:e.nodeSpan(r);return o&&r!==null?{...o,anchor:e.folded.has(r)?void 0:$t(e.nodePositions?.[r],e.toScreen)}:void 0},referenceStripNodeAt(t,r){let o=e.hostBpFrame;return e.referenceStripShown&&o?Fn(e.referenceStripBlocks,o,t,r):void 0},get referenceStripZonePx(){return e.referenceStripShown?Ot:0}}));var $s=3e3,Ws=350,Hs=34;function Fs(e){let t=[0];for(let r=1;r<e.length;r++)t.push(t[r-1]+Math.hypot(e[r].x-e[r-1].x,e[r].y-e[r-1].y));return t}function Ds(e,t){if(e.length===1||t===1)return Array.from({length:t},()=>({...e[0]}));let r=Fs(e),o=r.at(-1),n=[],i=1;for(let a=0;a<t;a++){let s=o*a/(t-1);for(;i<e.length-1&&r[i]<s;)i++;let d=r[i]-r[i-1],c=d>0?(s-r[i-1])/d:0,f=e[i-1],p=e[i];n.push({x:f.x+(p.x-f.x)*c,y:f.y+(p.y-f.y)*c})}return n}var Xs=400,wa=1.8,Vs=.1;function DL(e,t,r,o,n){let i=w=>({x:(w.x*t.scaleX+t.translateX-o.translateX)/o.scaleX,y:(w.y*t.scaleY+t.translateY-o.translateY)/o.scaleY}),a={};for(let[w,y]of Object.entries(r)){let k=e[w];k?.length&&y.length&&(a[w]=Ds(k.map(i),y.length))}let s=new Map,d=(w,y)=>{let k=s.get(w);k?k.push(y):s.set(w,[y])};for(let w of n){let{from:y,to:k}=w;if(y!==k&&r[y]?.length&&r[k]?.length){let S=ue(w);d(y,{id:k,side:S.to}),d(k,{id:y,side:S.from})}}let c=new Map,f=w=>c.get(w.id)??(w.side==="start"?a[w.id][0]:a[w.id].at(-1)),p=Object.keys(a),u=[];for(let w of p)for(let y of s.get(w)??[]){if(a[y.id]||c.has(y.id))continue;let k=s.get(y.id).find(S=>S.id===w);c.set(y.id,{...f(k)}),p.push(y.id),u.push(y.id)}let m=new Map(u.map((w,y)=>[w,y])),l=new Float64Array(u.map(w=>c.get(w).x)),h=new Float64Array(u.map(w=>c.get(w).y)),g=new Float64Array(u.length),b=new Float64Array(u.length),R=u.map((w,y)=>s.get(w).flatMap(k=>{let S=m.get(k.id);if(S===void 0){let O=f(k);return g[y]+=O.x,b[y]+=O.y,[]}return[S]})),x=u.map(w=>s.get(w).length);for(let w=0;w<Xs;w++){let y=0;for(let k=0;k<u.length;k++){let S=g[k],O=b[k];for(let T of R[k])S+=l[T],O+=h[T];let ie=wa*(S/x[k]-l[k]),v=wa*(O/x[k]-h[k]);y=Math.max(y,Math.abs(ie*o.scaleX)+Math.abs(v*o.scaleY)),l[k]+=ie,h[k]+=v}if(y<Vs)break}u.forEach((w,y)=>{a[w]=r[w].map(()=>({x:l[y],y:h[y]}))});for(let[w,y]of Object.entries(r))a[w]??=y.map(k=>({...k}));return a}function js(e,t){let r=0,o=1/0;return e.forEach((n,i)=>{let a=(n.x-t.x)**2+(n.y-t.y)**2;a<o&&(o=a,r=i)}),r}function XL(e,t,r,o){let n=(i,a)=>{let s=r[i],d=o[i];if(!s||!d||d.length===0)return{x:0,y:0};let c=js(d,a);return{x:s[c].x-d[c].x,y:s[c].y-d[c].y}};return Object.fromEntries(Object.entries(e).map(([i,a])=>{let s=t[Number(i)],d=n(s?.from??"",a[0]),c=n(s?.to??"",a.at(-1));return[i,a.map((f,p)=>{let u=a.length>1?p/(a.length-1):0;return{x:f.x+d.x+(c.x-d.x)*u,y:f.y+d.y+(c.y-d.y)*u}})]}))}function ba(e,t,{ids:r,alpha:o}){let n=(i,a)=>{for(let s=0;a&&s<a.count;s++){let d=i[a.start+s];d.color=Zo(d.color,o)}};for(let i of r)n(e.nodeStrokes,e.nodeStrokeRuns.get(i));t.forEach(({from:i,to:a},s)=>{(r.has(i)||r.has(a))&&(n(e.edgeCurves,e.edgeCurveRuns.get(s)),n(e.arrows,e.arrowRuns.get(s)))})}function zs(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function VL(e,t,r,o){return!(e.referenceAxis||t.referenceAxis||e.pixelRows||t.pixelRows||t.tubeMap||o||r>$s)}function jL(){return typeof requestAnimationFrame<"u"&&!("matchMedia"in window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}function zL(e,t,r){let o={frame:0,finish:()=>{e(1)}},n=0,i=performance.now(),a=()=>{if(!t()){e(1),r();return}let s=performance.now();n+=Math.min(s-i,Hs),i=s;let d=Math.min(1,n/Ws);e(zs(d)),d<1?o.frame=requestAnimationFrame(a):r()};return o.frame=requestAnimationFrame(a),o}function YL(e,t,r,o){for(let[n,i]of Object.entries(e)){let a=t[n],s=r[n];!a||!s||i.forEach((d,c)=>{d.x=o===1?s[c].x:a[c].x+(s[c].x-a[c].x)*o,d.y=o===1?s[c].y:a[c].y+(s[c].y-a[c].y)*o})}}function ka(e,t,r){let o=Mr(e,t.nodePositions);return{profile:o,bounds:r&&Pr(e,t,r),segments:kn(e,t),reference:Rn(o)}}var No=new WeakMap;function y1(e,t,r){No.has(t)||No.set(t,ka(e,t,r))}var Ys=8,Ks=19,ya=Ne+Ks,Us=48;function Zs(e,t,r){if(!(!e||!t))return Lt(e.rowPx,e.barPx)?r:{untracked:0,unread:0,...r,crowded:!0}}var k1=ga.views(e=>({get paneCeiling(){return Math.max(Pt,e.paneHeight??cn)},get fitRoom(){return e.host?this.canvasHeight:this.paneCeiling},get walkRowPitch(){let t=e.walkRowBars;if(t)return Nt(t.rows.length+1,this.fitRoom-this.fitPadTop-F-Un(e.walkRowGroups?.sections??[]))},get walkRowPlacement(){let t=this.walkRowPitch;return t?Zn(e.walkRowGroups?.sections??[],t.rowPx):void 0},get walkRowGeneKey(){return Zs(this.walkRowPitch,!!e.walkRowGenes?.size,e.walkRowGeneGaps)},get drawnRowLabels(){let t=this.walkRowPlacement,r=Pe(e.walkRowBars,e.layoutResult,this.walkRowPitch);return e.walkRowBars&&t?r.map((o,n)=>({...o,y:t.rowY(n)})):r},get visibleRowLabels(){return this.drawnRowLabels.flatMap(({label:t,y:r})=>{let o=e.toScreen({x:0,y:r}).y;return o>=0&&o<=this.canvasHeight?[{label:t,y:r,top:o}]:[]})},get fitPadLeft(){return this.drawnRowLabels.reduce((t,r)=>Math.max(t,Fo(r.label,0).x1+6),F)},get layoutBounds(){let t=e.layoutResult,r=e.walkRowBars,o=r&&t?.extent?Me(r,this.walkRowPitch):void 0;return t?qe(t,{region:e.graphRegion,extent:o&&{...o,maxY:o.maxY+(this.walkRowPlacement?.headersPx??0)}}):void 0},get keyColumnPx(){return e.facetPanels||e.tubeMapReads?0:Et({legendSize:this.framedLegendSize})},get framedLegendSize(){return e.keyFrame??e.legendSize},get drawingWidth(){return e.paneWidth-this.keyColumnPx},get canvasFloor(){return Math.max(Pt,e.facetPanels?0:Gt({legendSize:this.framedLegendSize,referenceStripZonePx:e.referenceStripZonePx}))},walkRowReadoutOf(t){let r=e.walkRowBars;return r?nn(r,t,{scaleX:e.scaleX,translateX:e.translateX,width:this.drawingWidth,measure:tt},{comparing:e.rowVisitsNeeded}):void 0},get hoveredWalkRowText(){let t=e.walkRowList.findIndex(n=>n.name===e.hoveredWalkRow),r=e.walkRowList[t],o=r?this.walkRowReadoutOf(t):void 0;return r&&o&&(this.walkRowPitch?.readouts===!1||o.cut)?{label:r.label,readout:o.text}:void 0},walkRowAt(t,r){let o=e.walkRowBars,n=this.walkRowPitch,i=this.walkRowPlacement;if(!o||!n||!i)return;let a=i.rowAt((r-e.translateY)/e.scaleY,o.rows.length+1),s=e.walkRowList[a],d=i.rowY(a)*e.scaleY+e.translateY,c=(t-e.translateX)/e.scaleX-o.origin,f=s&&n.readouts?this.walkRowReadoutOf(a):void 0,p=s?(o.origin+ce(s))*e.scaleX+e.translateX:0,u=!!f?.cut&&t>=p&&t<=f.x+tt(f.shown);return s&&Math.abs(r-d)<=n.barPx/2+2&&(c>=0&&c<=ce(s)||u)?a:void 0},get fitPadTop(){let t=jn(e.tubeMapGenes);return F+Math.max(0,t-1)*Vn+e.referenceStripZonePx},get layoutFit(){return{width:this.drawingWidth,height:this.fitRoom-(e.host?.initialized&&e.showReferenceStrip?Ot:0)}},get minFitScale(){let t=this.layoutBounds,r=e.layoutResult,o=r?.tubeMap?.layout.tracks[0]?.width;return t&&t.h>0&&o&&!r.referenceAxis?Math.min(ln/o,(this.paneCeiling-this.fitPadTop-F)/t.h):0},get facetSpec(){let{field:t,sort:r,columns:o}=e.facetSetting;return t===""?void 0:r.length===0&&o===void 0?t:{field:t,sort:[...r],...o===void 0?{}:{columns:o}}},get facetPlacement(){let t=e.facetPanels,{field:r,sort:o}=e.facetSetting;return t?_t(t.map(n=>n.walks[0].name),e.hostPlacesX||r===""?"walk":r,o):void 0},facetGridIn(t){let r=this.facetPlacement,o=this.layoutBounds;return r&&o&&o.w>0?Bt({count:r.count,bounds:o,pixelRows:e.pixelRows,width:e.paneWidth,room:t,columns:e.hostPlacesX?1:r.columns??e.facetSetting.columns}):void 0},get facetGrid(){return this.facetGridIn(this.fitRoom-ya)},get canvasHeight(){let t=this.layoutBounds,r=this.paneCeiling;if(!t)return r;let o=this.facetGrid;if(o)return Math.max(Pt,o.total+ya);let n=this.canvasFloor,i=this.fitPads,a=i.top+i.bottom;if(e.pixelRows)return Math.min(r,Math.max(n,t.h+a));let s=e.paneWidth-this.keyColumnPx-i.left-i.right;return t.w>0&&s>0?Math.min(r,Math.max(n,t.h*Math.max(s/t.w,this.minFitScale)+a)):r},get viewBox(){let t=this.facetGrid;return t?{width:t.width,height:t.height}:{width:e.paneWidth,height:this.canvasHeight}},get fitPads(){return this.facetGrid?{left:oe,top:oe,right:oe,bottom:oe}:{left:this.fitPadLeft,top:this.fitPadTop,right:F,bottom:F}},get usableHeight(){let{top:t,bottom:r}=this.fitPads;return this.viewBox.height-t-r},get snapsHostCut(){let{host:t,graphRegion:r}=e,o=t&&Yr(t);return!!t&&Si(e.chosenLayoutMode)==="snapped"&&!ke(t).some(n=>n.reversed&&(n.refName===r?.refName||n.refName===o?.refName))},get followsWindow(){let t=e.layoutResult;return this.snapsHostCut&&e.drawnLayoutMode==="force"&&!!t&&!t.referenceAxis&&!t.pixelRows&&!t.tubeMap&&!e.facetPanels},get trackFit(){return"fit"},get referenceRoom(){return this.canvasHeight},get heldLayout(){let{graph:t,layoutResult:r,graphRegion:o}=e;return t&&r&&this.followsWindow?No.get(r)??ka(t,r,o):void 0},get heldReference(){return this.heldLayout?.profile},get heldBounds(){return this.heldLayout?.bounds??this.layoutBounds},get followPads(){return{padLeft:this.fitPadLeft,padTop:this.fitPadTop,padRight:F,padBottom:F}},get heldWindow(){let{host:t}=e;return t&&this.followsWindow?Yr(t):void 0},get viewSpan(){return this.heldWindow?.span},get heldScale(){let t=this.heldReference,r=e.graphRegion,o=this.heldBounds,n=this.viewSpan;return t&&r&&o&&n?Cr(this.trackFit)?Ar(t,r,n,this.drawingWidth,this.referenceRoom,this.followPads):Tr(t,r,n,o,this.drawingWidth,this.canvasHeight,this.followPads):void 0},get windowTransform(){let{graphRegion:t,layoutResult:r,host:o}=e,n=this.heldWindow,i=n&&o?xi(o):void 0,a=this.heldReference,s=this.heldScale,d=this.heldBounds,c=this.heldLayout,f=n&&i&&a&&s!==void 0&&d?Gr(a,i,s,d,this.drawingWidth,this.canvasHeight,this.followPads):void 0,p=n&&f&&c&&d&&Cr(this.trackFit)?{...f,translateY:xn({segments:c.segments,reference:c.reference,held:Er(c.profile,n),scale:f.scale,translateX:f.translateX,bounds:d,paneWidth:this.drawingWidth,paneHeight:this.canvasHeight,pads:this.followPads})}:f;return p&&r&&(t?.refName!==n?.refName||t?.assemblyName!==n?.assemblyName)?{...p,translateX:e.paneWidth+this.drawingWidth-p.scale*Nr(r.nodePositions).minX}:p},get edgeMarks(){let t=this.followsWindow?this.heldLayout:void 0;return t?Sn(t.segments,{scale:e.scale,translateX:e.translateX,translateY:e.translateY},this.drawingWidth,{top:e.referenceStripZonePx,bottom:this.canvasHeight}):void 0},get runsPastEdge(){let t=this.edgeMarks;return!!t&&t.top.length+t.bottom.length>0},get drawingClip(){return this.followsWindow?`inset(0px ${e.paneWidth-this.drawingWidth}px 0px 0px)`:void 0},get fittedTransform(){let t=this.layoutBounds,r=this.facetGrid,{width:o,height:n}=r??{width:this.drawingWidth,height:this.canvasHeight},i=this.fitPads;return this.windowTransform??(t?Ze(t,o,n,e.pixelRows,{minScale:this.facetGrid?0:this.minFitScale,padLeft:i.left,padTop:i.top,padRight:i.right,padBottom:i.bottom}):void 0)}})).views(e=>({get tooltipRightPx(){return!e.facetPanels&&e.legendSize.width>0&&Gt(e)-Wr>e.canvasHeight-Us?Et(e):Ys}})).views(e=>({get liveBuildView(){return{axis:e.axisScale,bounds:dn(Br(e),fn)}},get buildViewSettled(){let t=e.settledBuildView;return t!==void 0&&t.layout===e.layoutResult&&wn(t.view.axis,e.axisScale)&&pn(t.view.bounds,Br(e))}})).views(e=>({get buildView(){return e.settledBuildView?.view??e.liveBuildView}})).views(e=>({get geometryPainted(){return bn(e)},get paintSuperseded(){return!this.geometryPainted},get showLoading(){return e.error===void 0&&(e.isLoading||e.hasPendingSource||e.graph!==void 0&&!this.geometryPainted)}})).views(e=>({applySelection(t){let r=e.selectedNode;t.setNodeHighlights(r===null||e.folded.has(r)?new Map:new Map([[r,hn]]))},get hoverLayerNode(){let{litNode:t,selectedNode:r}=e;return t===r?null:t},get paintTransform(){let t=ci();return{scaleX:e.scaleX*t,scaleY:e.scaleY*t,translateX:e.translateX*t,translateY:e.translateY*t,dpr:t}}})).views(e=>({paint(t){t.updateTransform(e.paintTransform),t.render(e.referenceStripShown?[0,0,0,0]:mn)}})).views(e=>({buildDrawing(t,r,o=e.buildView){let{graph:n,nodeById:i,layoutResult:a,deletionDrawing:s}=e;if(!n||!i||!a||!s)return;Je(e.positionsVersion);let d=St({...at(a,s,{drawsRows:!!e.walkRowBars}),graph:n,nodeById:i,colorScheme:e.effectiveColorScheme,contigThickness:e.contigThickness,connectorThickness:e.connectorThickness,drawPaths:r,nodeWidth:e.nodeWidth,edgeWidth:e.linkWidth,highlight:t,axis:o.axis,linearLayout:e.linearLayout,viewportBounds:o.bounds,referenceRamp:e.referenceRamp,version:e.positionsVersion,smallSites:e.smallSites}),c=e.morphEntering;return c?.layout===a&&ba(d,n.edges,c),{batch:d,view:o}},get facetDrawings(){return e.facetPanels?.map(t=>this.buildDrawing(t,!1))},hoveredOn(t){let r=e.hoveredNode,o=r?e.nodeById?.get(r):void 0;return o?$r(t,o.id,o.length)??"not on this walk":void 0},get figureUnavailable(){return e.layoutResult?e.walkRowGroups?"The SVG export cannot group walk rows yet: set Group by... to None first":e.drawsNodes||e.walkRowBars?void 0:`${V(e.chosenLayoutMode).label} draws a picture of its own, which the SVG export does not`:"Nothing is drawn yet"},figure(){let{graph:t,layoutResult:r}=e,o=!!e.host&&!e.facetGrid;return t&&r&&!this.figureUnavailable?mo(t,r,{width:o?e.drawingWidth:e.paneWidth,height:o?e.canvasHeight:e.paneCeiling,frame:o?e.screenTransform:void 0,walks:e.walkLayers,facet:e.facetSpec,colorScheme:e.effectiveColorScheme,nodeWidth:e.nodeWidth,edgeWidth:e.linkWidth,showDeletionEdges:e.showDeletionEdges,smallSites:e.smallSites,linearLayout:e.linearLayout,contigThickness:e.contigThickness,connectorThickness:e.connectorThickness,region:e.graphRegion,colorDomain:e.statedColorDomain,genes:e.showGenes?[...e.backboneGenes??[],...e.ownGeneFeatures??[]]:void 0,walkRows:e.walkRowBars,walkRowPitch:e.walkRowPitch,rowGenes:e.walkRowGenes,rowGeneGaps:e.walkRowGeneGaps,rowAnnotation:e.walkRowAnnotation,walkStrip:e.walkStripRows&&{rows:e.walkStripRows,rowGenes:e.walkRowGenes,rowGeneGaps:e.walkRowGeneGaps}}):void 0}})).views(e=>({get followsHostView(){let t=e.layoutResult;return!!e.host&&!e.hostPlacesX&&!!t&&!t.referenceAxis&&!t.pixelRows&&!t.tubeMap&&!e.facetGrid}}));var Mo=X(Y("path",{d:"M3 16h5v-2H3zm6.5 0h5v-2h-5zm6.5 0h5v-2h-5zM3 20h2v-2H3zm4 0h2v-2H7zm4 0h2v-2h-2zm4 0h2v-2h-2zm4 0h2v-2h-2zM3 12h8v-2H3zm10 0h8v-2h-8zM3 4v4h18V4z"}),"LineStyle");var Ra=X(Y("path",{d:"M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z"}),"CompareArrows");var xa=X(Y("path",{d:"M17 5h-2V3h2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6zm4-12h2V7h-2zm0 4h2v-2h-2zm-8 8h2v-2h-2zM7 5h2V3H7zM3 17h2v-2H3zm2 4v-2H3c0 1.1.9 2 2 2M19 3v2h2c0-1.1-.9-2-2-2m-8 2h2V3h-2zM3 9h2V7H3zm4 12h2v-2H7zm-4-8h2v-2H3zm0-8h2V3c-1.1 0-2 .9-2 2"}),"HighlightAlt");var qs="Linear genome view",Js="Linear synteny view",Qs="No synteny track in this session aligns these assemblies";function Sa({label:e,icon:t,entries:r,entryLabel:o,onSelect:n,disabledHelpText:i,nameTheOnlyEntry:a=!0}){let[s]=r,d=i?[{label:e,icon:t,disabled:!0,disabledHelpText:i,onClick:()=>{}}]:[];return r.length===0?d:r.length===1&&s?[{label:a?`${e} \u2014 ${o(s)}`:e,icon:t,onClick:n(s)}]:[{label:e,icon:t,type:"subMenu",subMenu:r.map(c=>({label:o(c),onClick:n(c)}))}]}function C1({contributors:e,linearContributors:t=e,syntenyTracks:r,onShowLinear:o,onShowSynteny:n}){let i=r[0]?.coverage??e.length;return[...Sa({label:qs,icon:Mo,entries:t,entryLabel:a=>`${a.sample} ${Le(a)}`,onSelect:a=>()=>{o({location:a,assembly:a.sample})}}),...e.length>=2?Sa({label:`${Js} (${i} assemblies)`,icon:Ra,entries:r,entryLabel:a=>a.coverage<i?`${a.name} (${a.coverage} of ${i})`:a.name,nameTheOnlyEntry:!1,disabledHelpText:Qs,onSelect:a=>()=>{n(a.trackId)}}):[]]}function _1({own:e,reference:t,highlight:r,onShowLinear:o,onHighlight:n}){let i=[e?{label:`Open in ${e.assembly} \u2014 ${Le(e.location)}`,target:e}:void 0,t&&t.assembly!==e?.assembly?{label:`Open in ${t.assembly} \u2014 around this node`,target:t}:void 0].filter(a=>a!==void 0);return[...n&&r?[{label:`Highlight in ${r.assembly}`,icon:xa,onClick:()=>{n(r)}}]:[],...i.map(({label:a,target:s})=>({label:a,icon:Mo,onClick:()=>{o(s)}}))]}var H1=X(Y("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");export{X as a,wi as b,jt as c,Wa as d,V as e,tc as f,ic as g,zt as h,Yr as i,Ha as j,Si as k,Fa as l,Xp as m,Vp as n,jp as o,Kr as p,D as q,vi as r,Ei as s,kc as t,Zr as u,Nc as v,qr as w,Mc as x,Pc as y,Ac as z,Tc as A,Wi as B,H1 as C,os as D,ns as E,is as F,oo as G,no as H,Ut as I,ao as J,xo as K,Ka as L,Ni as M,_S as N,WS as O,DS as P,DL as Q,XL as R,VL as S,jL as T,zL as U,YL as V,y1 as W,Ys as X,Ks as Y,ya as Z,k1 as _,Mo as $,C1 as aa,_1 as ba};
|
|
3
|
+
//# sourceMappingURL=chunk-SMZZWPRX.js.map
|