jbrowse-plugin-graphgenomeviewer 10.0.2 → 10.0.4
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-W7XIQ5F3.js → AddTrackWorkflow-47H3VBK4.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-JMYDJODG.js → GbzBaseSyntenyAdapter-X6AW5IYW.js} +2 -2
- package/dist/chunks/{GraphGenomeView-2WSTZQNY.js → GraphGenomeView-ZTZEYNUY.js} +2 -2
- package/dist/chunks/{LinearGraphDisplay-VYCJVUW4.js → LinearGraphDisplay-QWJZ5PSO.js} +2 -2
- package/dist/chunks/{MinigraphBubbleAdapter-N5BOXD7U.js → MinigraphBubbleAdapter-WUTIBCFA.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-FZZ7W2HN.js → RgfaTabixAdapter-VT7TYMNE.js} +2 -2
- package/dist/chunks/{WalkFormsAdapter-TZW5UBRI.js → WalkFormsAdapter-VRJ4FYQB.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-XM7HBNJA.js → WalkTabixSyntenyAdapter-ZYWYXAC7.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-XM7HBNJA.js.map → WalkTabixSyntenyAdapter-ZYWYXAC7.js.map} +2 -2
- package/dist/chunks/chunk-4MTS65XF.js +3 -0
- package/dist/chunks/{chunk-ZKQLPKNN.js.map → chunk-4MTS65XF.js.map} +3 -3
- package/dist/chunks/{chunk-NLHJYXCS.js → chunk-5FMNLEED.js} +2 -2
- package/dist/chunks/{chunk-NDWP2KNR.js → chunk-JJ2TPWSH.js} +2 -2
- package/dist/chunks/{chunk-EVYIBH4N.js → chunk-MQ43JVZM.js} +2 -2
- package/dist/chunks/{chunk-D7BAG2VJ.js → chunk-P7V5S3V3.js} +2 -2
- package/dist/chunks/{chunk-D7BAG2VJ.js.map → chunk-P7V5S3V3.js.map} +2 -2
- package/dist/chunks/chunk-TDHUAADJ.js +6 -0
- package/dist/chunks/chunk-TDHUAADJ.js.map +7 -0
- package/dist/chunks/{chunk-AVUNIRM5.js → chunk-TP6OXTXD.js} +5 -5
- package/dist/chunks/chunk-TP6OXTXD.js.map +7 -0
- package/dist/chunks/{chunk-JLIDLLZG.js → chunk-UPSA4KVF.js} +2 -2
- package/dist/chunks/{chunk-HTVBMX7V.js → chunk-UXBGMTAO.js} +2 -2
- package/dist/chunks/chunk-VV5LVNCP.js +9 -0
- package/dist/chunks/chunk-VV5LVNCP.js.map +7 -0
- package/dist/chunks/renderSvg-SEYWHXD7.js +2 -0
- package/dist/chunks/renderSvg-SEYWHXD7.js.map +7 -0
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/GraphGenomeView/components/PaneSvg.tsx +2 -1
- package/src/GraphGenomeView/model.facetRebuild.test.ts +10 -7
- package/src/GraphGenomeView/model.fold.test.ts +2 -5
- package/src/GraphGenomeView/model.geneNames.test.ts +4 -4
- package/src/GraphGenomeView/model.layout.test.ts +6 -13
- package/src/GraphGenomeView/model.passes.test.tsx +2 -5
- package/src/GraphGenomeView/model.ts +2 -8
- package/src/GraphGenomeView/pane/fitViews.ts +63 -20
- package/src/GraphGenomeView/pane/graphViews.ts +1 -18
- package/src/GraphGenomeView/pane/paneBase.ts +28 -13
- package/src/GraphGenomeView/pane/renderingActions.ts +34 -66
- package/src/GraphGenomeView/pane/settingActions.ts +47 -28
- package/src/GraphGenomeView/renderPipeline.test.ts +28 -9
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +6 -6
- package/src/RgfaTabixAdapter/walkReader.ts +4 -2
- package/src/WalkTabixSyntenyAdapter/WalkTabixSyntenyAdapter.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/chunks/chunk-AVUNIRM5.js.map +0 -7
- package/dist/chunks/chunk-CTQBRAQH.js +0 -6
- package/dist/chunks/chunk-CTQBRAQH.js.map +0 -7
- package/dist/chunks/chunk-EUXYBAW2.js +0 -9
- package/dist/chunks/chunk-EUXYBAW2.js.map +0 -7
- package/dist/chunks/chunk-ZKQLPKNN.js +0 -3
- package/dist/chunks/renderSvg-X3BRMJX3.js +0 -2
- package/dist/chunks/renderSvg-X3BRMJX3.js.map +0 -7
- /package/dist/chunks/{AddTrackWorkflow-W7XIQ5F3.js.map → AddTrackWorkflow-47H3VBK4.js.map} +0 -0
- /package/dist/chunks/{GbzBaseSyntenyAdapter-JMYDJODG.js.map → GbzBaseSyntenyAdapter-X6AW5IYW.js.map} +0 -0
- /package/dist/chunks/{GraphGenomeView-2WSTZQNY.js.map → GraphGenomeView-ZTZEYNUY.js.map} +0 -0
- /package/dist/chunks/{LinearGraphDisplay-VYCJVUW4.js.map → LinearGraphDisplay-QWJZ5PSO.js.map} +0 -0
- /package/dist/chunks/{MinigraphBubbleAdapter-N5BOXD7U.js.map → MinigraphBubbleAdapter-WUTIBCFA.js.map} +0 -0
- /package/dist/chunks/{RgfaTabixAdapter-FZZ7W2HN.js.map → RgfaTabixAdapter-VT7TYMNE.js.map} +0 -0
- /package/dist/chunks/{WalkFormsAdapter-TZW5UBRI.js.map → WalkFormsAdapter-VRJ4FYQB.js.map} +0 -0
- /package/dist/chunks/{chunk-NLHJYXCS.js.map → chunk-5FMNLEED.js.map} +0 -0
- /package/dist/chunks/{chunk-NDWP2KNR.js.map → chunk-JJ2TPWSH.js.map} +0 -0
- /package/dist/chunks/{chunk-EVYIBH4N.js.map → chunk-MQ43JVZM.js.map} +0 -0
- /package/dist/chunks/{chunk-JLIDLLZG.js.map → chunk-UPSA4KVF.js.map} +0 -0
- /package/dist/chunks/{chunk-HTVBMX7V.js.map → chunk-UXBGMTAO.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as o}from"./chunk-ZLQEXXMV.js";import{B as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{i as o}from"./chunk-ZLQEXXMV.js";import{B as e}from"./chunk-TDHUAADJ.js";function d(r,n,t){let a=e(r);return t?{...r,abridged:a,walkRowRuns:o(r,n)}:{...r,abridged:a}}export{d as a};
|
|
2
|
+
//# sourceMappingURL=chunk-UPSA4KVF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as Y,g as X,h as De,i as He,j as Ie,k as ce,l as qe,n as $e}from"./chunk-CTQBRAQH.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-H5PFNYKH.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-TDHUAADJ.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-H5PFNYKH.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-UXBGMTAO.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{b as Zo}from"./chunk-IK5G3JHR.js";import{A as Yo,C as Xo,D as Uo,E as ut,F as qo,G as Qo,N as pr,Q as lr,R as gr,S as ct,T as Tr,U as xr,V as Pr,W as Gr,X as Cr,Y as ht,Z as Ar,a as j,aa as Ae,b as wo,ba as Br,c as yo,da as Or,e as Y,f as No,g as Eo,i as ee,j as Fo,k as rt,l as Oo,m as ge,n as xe,o as Wo,p as Do,s as st,t as X,u as Ko,v as $o,w as Pe,x as we,z as zo}from"./chunk-4MTS65XF.js";import{a as $t,c as D,e as zt,k as cr,l as mr,p as hr}from"./chunk-OP2PTYDR.js";import{$a as tt,$c as vr,Aa as Ro,Ac as rr,Bb as it,Bc as nr,Dc as ar,Eb as Vo,Ec as ir,Fc as sr,Gc as ur,Hc as dr,Ja as J,Jc as mt,Ka as vo,La as Lo,Lb as _o,Lc as br,Ma as To,Mb as jo,Mc as wr,Na as xo,Oa as Po,Oc as yr,Pa as Go,Qa as Qe,Qc as fr,Sa as Le,Sb as Jo,Uc as Ge,Vb as dt,Vc as kr,Wa as Co,Wc as Mr,Xa as Q,Xc as Sr,Ya as Te,Za as et,_a as ue,_c as Rr,a as Se,ab as ot,ad as Lr,b as se,bd as Ce,c as T,cd as Ir,dd as Hr,e as ze,eb as le,ec as er,f as to,fb as Ao,fc as pt,fd as Nr,gb as Bo,gd as Er,h as so,ha as ve,ib as Io,id as Fr,j as uo,ja as fo,jd as Be,la as ko,ma as Mo,n as po,nb as Ho,qb as nt,t as bo,tb as at,wc as tr,xa as So,zc as or}from"./chunk-TP6OXTXD.js";import{C as Je,D as qe,V as Ze}from"./chunk-4RZCYOCW.js";import{b as be}from"./chunk-NTXLYTF6.js";import{a as Ye,b as Xe,c as ao,d as io}from"./chunk-JM4W4PKP.js";import{e as De}from"./chunk-LRBNBP2K.js";import{f as Ke,j as Qt}from"./chunk-ZLQEXXMV.js";import{J as ce,L as qt,N as Me,a as Xt,c as Ut,l as ke,la as Zt,w as K}from"./chunk-RQSCKHNS.js";import{a as co,b as Ue,c as mo,e as Re,f as he,g as ho,h as lo,i as go}from"./chunk-D3QZGLZ3.js";import{a as S,b as W,d as H,e as U}from"./chunk-WKD7ALOU.js";import{b as eo,d as me}from"./chunk-TMM73K4C.js";import{a as $e}from"./chunk-D6TY2QEG.js";import{f as Yt}from"./chunk-EGZZ3ADM.js";import{a as Jt}from"./chunk-H5PFNYKH.js";import{h as pe,i as Z,j as G,l as Kt,p as je}from"./chunk-5L276I7O.js";import{c as no}from"./chunk-J2PN6CG3.js";import{i as oo,l as ro}from"./chunk-H42TSPVA.js";import{b as O}from"./chunk-DUU6T2I5.js";var Wr=j([O("circle",{cx:"7.2",cy:"14.4",r:"3.2"},"0"),O("circle",{cx:"14.8",cy:"18",r:"2"},"1"),O("circle",{cx:"15.2",cy:"8.8",r:"4.8"},"2")],"BubbleChart");function Vr(e){return typeof e.reads=="string"&&e.reads!==""||Yt(e.readsLocation)}var lt=class extends uo{constructor(){super(...arguments);this.name="GetGraphReads"}async execute(o){let{nodeNames:r,signal:n}=o,{adapter:a}=await po(this.pluginManager,o,"getReads");return a?a.getReads(r,{signal:n}):{records:[],total:0}}};var te=JBrowseExports["@jbrowse/core/svg/svgReady"],Hn=e=>te!=null&&e in Object(te)?te[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/core/svg/svgReady' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var _r=Hn("computeSvgReady");var Aa=te&&te.__esModule?te.default:te;var Ie=JBrowseExports["@jbrowse/display-kit/HeightModeMixin"];var jr=Ie&&Ie.__esModule?Ie.default:Ie;var oe=JBrowseExports["@jbrowse/display-kit/plotMenu"],Nn=e=>oe!=null&&e in Object(oe)?oe[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/display-kit/plotMenu' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),Dr=Nn("editPlotMenuItems");var Ha=oe&&oe.__esModule?oe.default:oe;var re=JBrowseExports["@jbrowse/render-core/displayPhase"],Kr=e=>re!=null&&e in Object(re)?re[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/render-core/displayPhase' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),$r=Kr("computeActivityPhase"),zr=Kr("computeDisplayPhase");var Ea=re&&re.__esModule?re.default:re;var Yr=j(O("path",{d:"M13 6.99h3L12 3 8 6.99h3v10.02H8L12 21l4-3.99h-3z"}),"Height");function gt(e,t){if(e?.refName!==t.refName||e.assemblyName!==t.assemblyName)return!1;let o=e.end-e.start;return t.end-t.start>=o&&t.end>e.start-o&&t.start<e.end+o}var Xr=j(O("path",{d:"M8.4 18.2c.38.5.6 1.12.6 1.8 0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3c.44 0 .85.09 1.23.26l1.41-1.77c-.92-1.03-1.29-2.39-1.09-3.69l-2.03-.68c-.54.83-1.46 1.38-2.52 1.38-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3c0 .07 0 .14-.01.21l2.03.68c.64-1.21 1.82-2.09 3.22-2.32V5.91C9.96 5.57 9 4.4 9 3c0-1.66 1.34-3 3-3s3 1.34 3 3c0 1.4-.96 2.57-2.25 2.91v2.16c1.4.23 2.58 1.11 3.22 2.32L18 9.71V9.5c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3c-1.06 0-1.98-.55-2.52-1.37l-2.03.68c.2 1.29-.16 2.65-1.09 3.69l1.41 1.77Q17.34 17 18 17c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3c0-.68.22-1.3.6-1.8l-1.41-1.77c-1.35.75-3.01.76-4.37 0z"}),"Hub");var Ur=j(O("path",{d:"M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9m5.5 11c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m-3-4c-.83 0-1.5-.67-1.5-1.5S13.67 6 14.5 6s1.5.67 1.5 1.5S15.33 9 14.5 9M5 11.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5S7.33 13 6.5 13 5 12.33 5 11.5m6-4c0 .83-.67 1.5-1.5 1.5S8 8.33 8 7.5 8.67 6 9.5 6s1.5.67 1.5 1.5"}),"Palette");var Jr=j([O("circle",{cx:"12",cy:"12",r:"3.2"},"0"),O("path",{d:"M9 2 7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5"},"1")],"PhotoCamera");function wt(e,t,{cut:o=!1}={}){if(!(t>0)||e.paths?.length||!e.nodes.some(f=>K(f)))return e;let{nodes:r,edges:n}=Fn(e),a=new Map(r.map((f,x)=>[f.id,x])),i=n.map(Qr),u=Wn(r.length,n,i,a),d=_n(r,n,i,a),p=Ut(d.keys(),f=>d[f]),h=new Uint8Array(r.length),R=[];for(let f of p.values())if(jn(f,r,u,d)>=t){for(let x of f)h[x]=1;K(r[f[0]])||R.push(f)}let{dist:A,pred:w}=$n(r,u);for(let f of R)for(let[x,C]of Dn(f,r,u,d)){let N=Kn(x,C,u,d,A,r);for(;N!==void 0&&!h[N];)h[N]=1,N=K(r[N])?void 0:w[N]}let v=n.map(f=>[a.get(f.from),a.get(f.to)]),B=n.map((f,x)=>{let[C,N]=v[x];return C!==void 0&&N!==void 0&&!!h[C]&&!!h[N]}),F=n.flatMap((f,x)=>{let[C,N]=v[x];if(!B[x])return[];let ae=Vn(r[C],i[x].from,r[N],i[x].to);return ae>0&&ae<t?[{k:x,bp:ae}]:[]}).sort((f,x)=>f.bp-x.bp).map(({k:f})=>f);for(let f of F)B[f]=!1;let k=new Set(o?En(r.length,v,B,F):[]),g=n.flatMap((f,x)=>k.has(x)?[{...f,foldBridge:!0}]:B[x]?[f]:[]);return Yn({...e,nodes:r,edges:g},h,d)}function En(e,t,o,r){let n=Array.from({length:e},(u,d)=>d),a=u=>{for(;n[u]!==u;)n[u]=n[n[u]],u=n[u];return u},i=u=>{let[d,p]=t[u],[h,R]=[a(d),a(p)];return n[h]=R,h!==R};return o.forEach((u,d)=>{u&&i(d)}),r.filter(i)}function Fn({nodes:e,edges:t}){let o=new Set(e.filter(n=>n.stable?.strand==="-").map(n=>n.id));if(o.size===0)return{nodes:e,edges:t};let r=(n,a)=>{let i=a??ke(n);return o.has(n)?On(i):i};return{nodes:e.map(n=>o.has(n.id)?{...n,stable:{...n.stable,strand:"+"}}:n),edges:t.map(n=>o.has(n.from)||o.has(n.to)?{...n,fromStrand:r(n.from,n.fromStrand),toStrand:r(n.to,n.toStrand)}:n)}}function On(e){return e==="+"?"-":"+"}function Qr(e){return{from:(e.fromStrand??ke(e.from))==="+"?"e":"s",to:(e.toStrand??ke(e.to))==="+"?"s":"e"}}function Wn(e,t,o,r){let n=Array.from({length:e},()=>[]);return t.forEach((a,i)=>{let u=r.get(a.from),d=r.get(a.to);if(u!==void 0&&d!==void 0){let{from:p,to:h}=o[i];n[u].push({other:d,side:p,otherSide:h}),n[d].push({other:u,side:h,otherSide:p})}}),n}function en(e,t){let o=e.stable,r=t.stable;return o&&r?.refName===o.refName&&r.rank===o.rank?[o,r]:void 0}function yt(e,t,o,r){let n=en(e,o);if(!n)return!1;let[a,i]=n;return t==="e"&&r==="s"&&a.start+e.length===i.start||r==="e"&&t==="s"&&i.start+o.length===a.start}function Vn(e,t,o,r){let n=en(e,o);if(!n||yt(e,t,o,r))return 0;let[a,i]=n;return Math.abs(bt(i,o,r)-bt(a,e,t))}function bt({start:e},t,o){return o==="s"?e:e+t.length}function _n(e,t,o,r){let n=e.map((i,u)=>u),a=i=>{for(;n[i]!==i;)n[i]=n[n[i]],i=n[i];return i};return t.forEach((i,u)=>{let d=r.get(i.from),p=r.get(i.to);d!==void 0&&p!==void 0&&yt(e[d],o[u].from,e[p],o[u].to)&&(n[a(d)]=a(p))}),e.map((i,u)=>a(u))}function jn(e,t,o,r){if(K(t[e[0]]))return 1/0;let n=0,a,i=1/0,u=-1/0,d=!0;for(let p of e){n+=t[p].length;for(let{other:h,otherSide:R}of o[p]){let A=t[h];if(r[h]!==r[p]&&K(A)){a??=A.stable.refName,d&&=A.stable.refName===a;let w=bt(A.stable,A,R);i=Math.min(i,w),u=Math.max(u,w)}}}return d&&u>i?Math.max(n,u-i):n}function Dn(e,t,o,r){let n=p=>t[p].stable?.start??0,a=p=>n(p)+t[p].length,i=e[0],u=e[0];for(let p of e)n(p)<n(i)&&(i=p),a(p)>a(u)&&(u=p);let d=[];for(let p of new Set([i,u]))for(let h of["s","e"])o[p].some(R=>R.side===h&&r[R.other]===r[p])||d.push([p,h]);return d}function Kn(e,t,o,r,n,a){let i;for(let u of o[e]){let d=u.other;u.side===t&&r[d]!==r[e]&&Number.isFinite(n[d])&&(i===void 0||n[d]<n[i]||n[d]===n[i]&&a[d].name<a[i].name)&&(i=d)}return i}function $n(e,t){let o=new Float64Array(e.length).fill(1/0),r=new Int32Array(e.length).fill(-1),n=new zn(([a,i],[u,d])=>a-u||qr(e[i].name,e[d].name));e.forEach((a,i)=>{K(a)&&(o[i]=0,n.push([0,i]))});for(let a=n.pop();a!==void 0;a=n.pop()){let[i,u]=a;if(!(i>o[u]))for(let{other:d}of t[u]){if(K(e[d]))continue;let p=i+e[d].length;p<o[d]?(o[d]=p,r[d]=u,n.push([p,d])):p===o[d]&&qr(e[u].name,e[r[d]].name)<0&&(r[d]=u)}}return{dist:o,pred:Array.from(r,a=>a<0?void 0:a)}}function qr(e,t){return e<t?-1:e>t?1:0}var zn=class{constructor(e){this.order=e,this.items=[]}push(e){let{items:t}=this;t.push(e);let o=t.length-1;for(;o>0;){let r=o-1>>1;if(this.order(t[o],t[r])>=0)break;[t[o],t[r]]=[t[r],t[o]],o=r}}pop(){let{items:e}=this,t=e[0],o=e.pop();if(e.length>0&&o!==void 0){e[0]=o;let r=0;for(;;){let n=2*r+1,a=n+1,i=r;if(n<e.length&&this.order(e[n],e[i])<0&&(i=n),a<e.length&&this.order(e[a],e[i])<0&&(i=a),i===r)break;[e[r],e[i]]=[e[i],e[r]],r=i}}return t}};function Yn(e,t,o){let{nodes:r,edges:n}=e,a=new Map(r.map((k,g)=>[k.id,g])),i=n.map(Qr),u=n.map((k,g)=>[{i:a.get(k.from),side:i[g].from},{i:a.get(k.to),side:i[g].to}]),d=new Map,p=(k,g)=>`${k}${g}`;for(let k of u)for(let{i:g,side:f}of k)d.set(p(g,f),(d.get(p(g,f))??0)+1);let h=new Map,R=new Set,A=new Set;u.forEach(([k,g],f)=>{if(k.i!==g.i&&o[k.i]===o[g.i]&&yt(r[k.i],k.side,r[g.i],g.side)&&d.get(p(k.i,k.side))===1&&d.get(p(g.i,g.side))===1){let[x,C]=k.side==="e"?[k,g]:[g,k];h.set(x.i,{j:C.i,out:x.side,in:C.side}),R.add(C.i),A.add(f)}});let w=r.map((k,g)=>g),v=new Map,B=new Map;r.forEach((k,g)=>{if(!t[g]||R.has(g)||!h.has(g))return;let f=[g],x=Zr(h.get(g).out);v.set(p(g,x),"s");for(let C=h.get(g);C;C=h.get(C.j))f.push(C.j),x=C.in;v.set(p(f.at(-1),Zr(x)),"e");for(let C of f)w[C]=g;B.set(g,Xn(f.map(C=>r[C])))});let F=({i:k,side:g})=>({id:r[w[k]].id,side:w[k]===k&&!B.has(k)?g:v.get(p(k,g))});return{...e,nodes:r.flatMap((k,g)=>!t[g]||w[g]!==g?[]:[B.get(g)??k]),edges:n.flatMap((k,g)=>{if(A.has(g))return[];let[f,x]=u[g];if(!B.has(w[f.i])&&!B.has(w[x.i]))return[k];let C=F(f),N=F(x);return[{...k,from:C.id,to:N.id,fromStrand:C.side==="e"?"+":"-",toStrand:N.side==="s"?"+":"-"}]})}}function Zr(e){return e==="s"?"e":"s"}function Xn(e){let{samples:t,...o}=e[0],r=e.reduce((i,u)=>i+u.length,0),n=r>0?e.reduce((i,u)=>i+u.depth*u.length,0)/r:o.depth,a=e.every(i=>i.samples)?e.reduce((i,u)=>i.filter(d=>u.samples.includes(d)),t):void 0;return a?{...o,length:r,depth:n,samples:a}:{...o,length:r,depth:n}}function ft(e,t=()=>"",o=!0){let r=e.paths??[],n=bo(e),a=new Map;r.forEach((w,v)=>{Xt(a,ce(w.name).name,v)});let i=w=>n[w].map(v=>`${v.node.id}${v.strand}`).join(","),u=w=>a.get(w).map(v=>r[v]),d=new Map,p=new Map;for(let[w,v]of a){let B=w===e.referencePath?`\0${w}`:v.map(i).join("|"),F=t(w),k=d.get(B)??d.size;d.set(B,k);let g=`${B} ${F}`,f=p.get(g);f?f.walks.push(w):p.set(g,{rank:k,group:F,walks:[w]})}if(o&&p.size===a.size)return e;let h=[...p.values()].sort((w,v)=>w.rank-v.rank||Zt(w.group,v.group));if(!o)return{...e,paths:h.flatMap(({walks:w})=>w.flatMap(u))};let R=h.flatMap(({walks:w})=>u(w[0]).map(v=>w.length>1?{...v,members:w}:v)),A=new Set(h.map(w=>w.walks[0]));return{...e,paths:R,anchorPaths:e.anchorPaths?.filter(w=>A.has(w.name)),pathVisits:e.pathVisits?.filter(w=>A.has(w))}}function tn(e,t,o){let r=Math.min(48,t,o);return Math.max(0,r-(e+t))-Math.max(0,e-(o-r))}function on(e,t,o){return{translateX:t.translateX+tn(e.minX*t.scaleX+t.translateX,e.w*t.scaleX,o.width),translateY:t.translateY+tn(e.minY*t.scaleY+t.translateY,e.h*t.scaleY,o.height)}}function rn(e,t,o){let r=e.minX*t.scaleX+t.translateX,n=e.minY*t.scaleY+t.translateY;return r<o.width&&r+e.w*t.scaleX>0&&n<o.height&&n+e.h*t.scaleY>0}var Un=.05,He=9;function Jn(e,t){let{minY:o,maxY:r}=e.layout.bounds,n=r-o;return e.columns&&n>0?Math.max(Un,Math.min(1,t/n)):1}function Ne(e,t){let{scaleX:o,translateX:r,translateY:n}=t,a=t.scaleY*Jn(e,t.usableHeight),i=d=>(d-e.yOffset)*a+n,{columns:u}=e;if(u){let d=or(u,p=>p*o+r);return{x:p=>rr(d,p),y:i,yScale:a}}return{x:d=>d*o+r,y:i,yScale:a}}function kt(e,{x:t,y:o},r,n){let a=null;return e.layout.nodes.forEach(i=>{i.order>=0&&t(i.x-He)<=r&&r<=t(i.x+i.pixelWidth+He)&&o(i.y-He)<=n&&n<=o(i.y+i.contentHeight+He)&&(a=i.name)}),a}var nn=20,qn=.05,an=6;function Zn(e){let t=e.length-an;return t>0?`${e.slice(0,an).join(", ")} and ${t} more`:e.join(", ")}function Qn(e){if(e.kind==="deletion")return`deletion of ${Ze(e.length)}`;if(e.kind==="substitution")return`substitution ${e.seq}`;let t=e.seq??"",o=t.length>nn?`${t.slice(0,nn)}\u2026`:t;return`insertion of ${Ze(t.length)} ${o}`.trim()}function ea(e,t,o){let r={substitution:!1,insertion:!1,deletion:!1};if(e&&t&&ir(t.yScale)){let n=3;for(let a of e.mismatches)if(!r[a.kind]&&sr(a,{x:t.x,width:o})&&(r[a.kind]=!0,--n===0))break}return r}var sn=Br.views(e=>({get tubeMapFrame(){let t=e.layoutResult?.tubeMap;return t?Ne(t,{...e.screenTransform,usableHeight:e.usableHeight}):void 0},get tubeMapRulerBoxes(){let t=e.tubeMapReference;return t&&!e.hostPlacesX&&!e.layoutResult?.tubeMapPanels?pt(t):void 0},get tubeMapPanelRulerBoxes(){let{layoutResult:t}=e,o=t?.tubeMapPanels?.at(-1);return o&&t?.referenceAxis&&!e.hostPlacesX?pt(er(o.result.tubeMap)):void 0},get connectorZoneBottom(){let t=e.tubeMapPicture,o=this.tubeMapFrame;return t&&o?o.y(t.bounds.minY)-2:0},get tubeMapConnectors(){let t=e.tubeMapConnectedBoxes,o=this.tubeMapFrame,r=t&&o?e.hostBpFrame:void 0;return t&&o&&r?Ir(t,n=>n*r.scale+r.translateX,o.x,e.paneWidth):[]},get tubeMapPanelPictures(){let t=e.layoutResult?.tubeMapPanels;if(!t)return;let{field:o}=e.facetSetting;return t.map(r=>{let n=r.result.tubeMap,{graph:a,coarse:i}=n;return{panel:r,label:r.label??(o==="walk"?e.walkLabel(r.paths[0]):r.key),picture:nr(n),tubeColors:e.tubeColorsOf(a,n.pathColors),nodeColors:e.tubeMapNodeColors?pr(a,e.effectiveColorScheme,e.referenceRamp):void 0,deviations:i?tr(n,i.deviations):[]}})}})).views(e=>({get hoveredMember(){let t=e.hoveredNode,o=t===null?void 0:e.hoverDrawing?.members.get(t);if(!o)return t;let r=e.hoveredAt,n=e.hoveredPanel,a=n===null?void 0:this.tubeMapPanelViews?.[n],i;return a?.panel.result.tubeMap.layout.nodes.forEach(d=>{d.name===t&&(i=d)}),(r&&a&&i?Mr(o,d=>e.nodeSpan(d),a.frame.x(i.x),a.frame.x(i.x+i.pixelWidth),r.x):void 0)??o[0]},get tubeMapPanelHover(){let t=e.hoveredNode,o=e.tubeMapPanelPictures;if(t===null||!o)return;let r=this.hoveredMember??t,n=e.layoutResult?.tubeMap?.coarse?.graph??e.graph,a=n?.nodes.find(i=>i.id===r);return o.map(({panel:i})=>{let u=i.result.tubeMap,d=kr(u,r);return d&&n&&a?{box:d,...Sr(n,a,u.graph)}:void 0})},get tubeMapPanelTubeColors(){return e.tubeMapPanelPictures?.map(({panel:t,tubeColors:o})=>{let{graph:r}=t.result.tubeMap;return e.fadeUnhovered(o,r.paths??[],r.referencePath)})},get tubeMapPanelViews(){let t=e.tubeMapPanelPictures,o=this.tubeMapPanelTubeColors,r=e.layoutResult;if(!t||!o||!r)return;let n=t.length*mt,a=t.reduce((p,h)=>p+h.panel.height,0),i=e.usableHeight-n,u=e.scaleY*(r.referenceAxis&&a>0?Math.max(qn,Math.min(1,i/a)):1),d=e.translateY;return t.map((p,h)=>{let{panel:R}=p,A=R.result.extent?.minY??0,w=d,v=w+mt;return d=v+R.height*u,{...p,tubeColors:o[h],frame:Ne(R.result.tubeMap,{scaleX:e.scaleX,translateX:e.translateX,scaleY:u,translateY:v-A*u,usableHeight:1/0}),titleTop:w,top:v,bottom:d}})},tubeMapPanelAt(t){let o=this.tubeMapPanelViews?.findIndex(r=>r.titleTop<=t&&t<=r.bottom)??-1;return o<0?null:o}})).views(e=>({paintHover(t,o){let r=e.tubeMapPicture,n=e.tubeMapFrame,a=e.hoverLayerNode;if(r&&n){let{ctx:i,canvas:u}=t,d=Ce(e.paneWidth,e.canvasHeight);i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,u.width,u.height),i.setTransform(d,0,0,d,0,0);let p=e.tubeMapPanelViews;p?Rr(i,p,e.tubeMapPanelHover,{width:e.paneWidth,lit:a!==null}):ar(i,r,{...n,width:e.paneWidth,highlightNode:a}),Nr(i,e.tubeMapConnectors,e.connectorZoneBottom,a),i.setTransform(1,0,0,1,0,0)}else t.uploadGeometry(o),t.setNodeHighlights(a===null?new Map:new Map([[a,Qe]])),t.setEdgeHighlight(e.hoveredEdge,Qe),t.updateTransform(e.paintTransform),t.renderHighlights()}})).views(e=>{let t=(n,a)=>JSON.stringify(n)===JSON.stringify(a),o=se(()=>ea(e.layoutResult?.tubeMapPanels!==void 0?void 0:e.tubeMapPicture,e.tubeMapFrame,e.paneWidth),{equals:t}),r=se(()=>{let n=e.layoutResult,i=n?.tubeMapPanels!==void 0?[]:n?.tubeMap?.layout.reads??[],u=e.drawnGraph?.paths??[],d=e.tubeMapColoring,p=e.tubeColorKind;return{bundled:u.some(h=>h.members),values:p==="value"&&d?[...[...d.palette].map(([h,R])=>({value:h,color:R})),...d.unvalued?[{value:`${d.field}: none`,color:fr}]:[]]:void 0,roles:p==="role"||p==="tinted",haplotypeTube:p==="tinted"?wr[0]:br,logWidths:n?.tubeMap!==void 0&&!n.referenceAxis,foldBp:e.tubeMapDeviations.length>0?e.tubeMapFold:void 0,forwardReads:i.some(h=>!h.is_reverse),reverseReads:i.some(h=>h.is_reverse)}},{equals:t});return{get tubeMapKeys(){return{...r.get(),...o.get()}}}}).views(e=>({tubeMapUnder(t){let o=e.tubeMapPanelViews;if(o){let i=e.tubeMapPanelAt(t),u=i===null?void 0:o[i];return u&&{drawing:u.panel.result.tubeMap,...u}}let r=e.layoutResult?.tubeMap,n=e.tubeMapPicture,a=e.tubeMapFrame;return r&&n&&a?{drawing:r,picture:n,frame:a}:void 0},tubeMapNodeAt(t,o){let r=this.tubeMapUnder(o);return(r?kt(r.drawing,r.frame,t,o):null)??Hr(e.tubeMapConnectors,e.connectorZoneBottom,t,o)??null},tubeAt(t,o){let r=this.tubeMapUnder(o);if(!r)return null;let{picture:n,frame:a}=r,i=dr(n,a,t,o),u=i?.readId??ur(n,a,t,o);return u===void 0?null:{track:u,mismatch:i}},get hoveredTubeText(){let t=e.hoveredTube,o=e.layoutResult?.tubeMap?.layout,r=t&&o?.reads.find(i=>i.id===t.track);if(t&&r){let i=r.mapping_quality;return{label:r.name??"read",readout:[`MAPQ ${i??"unknown"}`,`${r.is_reverse?"reverse":"forward"} strand`,...t.mismatch?[Qn(t.mismatch)]:[]].join(", ")}}let n=t?e.hoverGraph?.paths?.[t.track]:void 0,a=n?.members;return a?{label:`${a.length} haplotypes`,readout:`one route: ${Zn(a.map(i=>e.walkLabel(i)))}`}:n?{label:e.walkLabel(n.name),readout:"haplotype"}:void 0}}));var ta=80,un=sn.actions(()=>({writeGrammar(e){}})).actions(e=>({keepDrawingInView(){let t=e.layoutBounds,o=e.viewBox;if(!t||e.viewportOwner==="fit"||!e.paneMeasured||o.width<=0||o.height<=0)return;let r=on(t,e,o);e.viewportOwner!=="host"&&(e.translateX=r.translateX),e.translateY=r.translateY}})).actions(e=>{let t;return{setColorScheme(o){(e.statedColorDomain||e.chosenColorScheme==="reference-position")&&(t=e.statedColorDomain),e.writeGrammar({encoding:{color:gr(o,t)}})}}}).actions(e=>({setError(t){e.error=t,e.isLoading=!1,e.statusMessage=""},finishLoading(){e.isLoading=!1,e.statusMessage=""},setStatusMessage(t){e.statusMessage=t},setFetchMs(t){e.lastFetchMs=t},setLayoutMs(t){e.lastLayoutMs=t},setGeometryMetrics(t,o,r){e.lastGeometryMs=t,e.lastGeometryStrokeCount=o.nodeStrokes.length,e.builtViewport={view:r},e.drawnBatch=o,e.morphing||(e.settledBatch=o)},setMorphing(t){e.morphing=t,t||(e.settledBatch=e.drawnBatch)},markPainted(){e.paintedViewport=e.builtViewport},setLayoutQuality(t){e.layoutQuality=t},setLayoutEngine(t){e.writeGrammar({layoutEngine:t})},setLinearLayout(t){e.linearLayout=t},setLayoutMode(t){e.writeGrammar({layoutMode:t})},setHover(t){e.writeGrammar({hover:t}),e.hoverLightsEverything||(e.hoveredEdge=null)},setReferencePath(t){e.referencePath=t;let o=e.graph;if(o?.anchoredBy==="paths"){let r=Me(o,t);le.inherit(o,r),e.graph=r}},setLayer(t,o){e.writeGrammar({layers:lr(e.grammar.layers,t,o)})},setShowPerf(t){e.showPerf=t},setBubbleSpread(t){e.bubbleSpread=t},setMaxGraphNodes(t){e.maxGraphNodes=t},setNodeWidth(t){e.writeGrammar({size:ct({width:t,px:e.contigThickness,links:e.linkWidth})})},setLinkWidth(t){e.writeGrammar({size:ct({width:e.nodeWidth,px:e.contigThickness,links:t})})},setTubeMapFold(t){e.tubeMapFold=t},setTubeMapRoutes(t){e.tubeMapRoutes=t},setTubeMapColorBy(t){e.tubeMapColorBy=t},setGeneTrackId(t){e.geneTrackId=t},setRepeatTrackId(t){e.repeatTrackId=t},setRepeatKey(t){e.repeatKey=t},setWalkLayers(t){e.walkLayers=t},liftWalks(t){let o=new Map(e.walkLayers.map(r=>[r.walk,r]));e.walkLayers=t.map(r=>o.get(r)??{walk:r})},liftAmongChoices(t){let o=new Set(e.walkChoices.map(r=>r.name));this.liftWalks([...t,...e.walkLayers.map(r=>r.walk).filter(r=>!o.has(r))])},setFacet(t){let o=e.facetSetting;t===""?o.field!==""&&e.writeGrammar({facet:{}}):e.writeGrammar({facet:{...o,field:t,sort:t===o.field?o.sort:[]}})},toggleWalk(t){let o=e.walkLayers;e.walkLayers=o.some(r=>r.walk===t)?o.filter(r=>r.walk!==t):[...o,{walk:t}]},setWalkColor(t,o){e.walkLayers=e.walkLayers.map(r=>r.walk===t?{...r,color:{...r.color,...o}}:r)},shadeWalksAlong(t){e.walkLayers=e.walkLayers.map(o=>({...o,color:{...o.color,field:t?"progress":"walk"}}))},setWalkRowSamples(t){let o=e.walkRowOrder;e.writeGrammar({rows:{...t?{kept:t}:{},...o?{order:o}:{}}})},setWalkRowOrder(t){let o=e.grammar.rows?.kept;e.writeGrammar({rows:{...o?{kept:o}:{},...t?{order:t}:{}}})},setWalkRowGroupBy(t){(t||e.walkRowGroupBy)&&e.writeGrammar({facet:t??{}})},pairWithLinearView(t){let o=e.connectedViewId;o!==void 0&&Pe([...G(e).views]).has(o)||(e.connectedViewId=t)},setHoveredNode(t,o){e.hoveredNode=t,e.hoveredAt=t===null?null:o??null},setHoveredPanel(t){e.hoveredPanel=t},setHoveredTube(t){let o=e.hoveredTube;(t?.track!==o?.track||t?.mismatch!==o?.mismatch)&&(e.hoveredTube=t)},applyHoveredRowWalks(t){t.join(`
|
|
2
|
+
`)!==e.hoveredRowWalks.join(`
|
|
3
|
+
`)&&(e.hoveredRowWalks=t)},setHoveredWalkRow(t){e.hoveredWalkRow=t},setHoveredBubble(t){e.hoveredBubble=t},setPointerInPane(t){e.pointerInPane=t},setWalkStrip(t){this.setLayer("walkStrip",t),e.stripHover=null},setStripHover(t){e.stripHover=t;let o=e.walkStripRows,r=e.walkStripFrame,n=t&&o?[o.reference,...o.rows].find(i=>i.name===t.row):void 0,a=n&&r&&e.graph?Qo(e.graph,n,t.offset,r.scaleX):void 0;e.hoveredNode=a??null},setAnsweredKeyFloor(t){e.answeredKeyFloor=t},setKeyShapeOf(t){e.keyShapeOf=t},setLegendSize(t,o){o!==void 0&&(e.measuredKeyShape=o),(t.width!==e.legendSize.width||t.height!==e.legendSize.height)&&(e.legendSize=t);let r=e.keyFrame;(!r||!e.keyFrameHeld&&(t.width!==r.width||t.height!==r.height))&&(e.keyFrame=t)},setKeyFrameHeld(t){e.keyFrameHeld=t},setHoveredEdge(t){e.hoveredEdge=e.hoverLightsEverything?t:null},setSelectedNode(t){e.selectedNode=t},setDraggingNode(t){e.draggingNode=t},setPanning(t){e.isPanning=t},stopDragging(){e.draggingNode=null,e.isPanning=!1},clearHover(){e.hoveredNode=null,e.hoveredAt=null,e.hoveredTube=null,e.hoveredPanel=null,e.hoveredWalkRow=null,e.hoveredBubble=null,e.hoveredEdge=null},clearInteractionState(){this.clearHover(),e.hoveredRowWalks=[],e.stripHover=null,e.selectedNode=null,e.draggingNode=null,e.isPanning=!1},showNodeDetails(t){let o=e.nodeById?.get(t);if(o){let r=G(e),n=e.graphRegion,a=n?e.nodeSpan(t):void 0;Kt(r)&&r.showWidget(r.addWidget("BaseFeatureWidget","baseFeature",{featureData:{id:o.id,name:o.name,length:o.length,depth:o.depth,rank:o.stable?.rank,stableName:o.stable?.refName,contributingAssembly:st(o)?.sample,contributingHaplotype:st(o)?.haplotype,sampleCount:o.samples?.length,samples:o.samples,...n&&a?{refName:n.refName,assemblyName:n.assemblyName,start:a.start,end:a.end}:{}}}))}},setTransform(t,o,r){let{host:n}=e;e.viewportOwner==="host"&&n?n.horizontalScroll(e.translateX-o):(e.viewportOwner="user",e.scale=ko(t),e.translateX=o),e.translateY=r,e.keepDrawingInView()},zoom(t,o,r){let{host:n}=e;if(e.viewportOwner==="host"&&n){n.zoomTo(n.bpPerPx/t,o);return}e.viewportOwner="user";let a=Ro(e,t,o,r,e.pixelRows);e.scale=a.scale,e.translateX=a.translateX,e.translateY=a.translateY,e.keepDrawingInView()},settleBuildView(){e.settledBuildView={view:e.liveBuildView,layout:e.layoutResult}},setPositionsDirty(){e.positionsVersion++},setMorphFrame(t){e.morphEntering=t,e.positionsVersion++},zoomToFit(){if(e.viewportOwner==="host"){let o=e.layoutBounds,{usableHeight:r}=e;o&&r>0&&(e.translateY=Mo(o,r,e.scaleY,e.fitPads.top));return}let t=e.fittedTransform;t&&(e.scale=t.scale,e.translateX=t.translateX,e.translateY=t.translateY)},clearPerfMetrics(){e.lastFetchMs=void 0,e.lastLayoutMs=void 0,e.lastGeometryMs=void 0,e.lastGeometryStrokeCount=void 0,e.builtViewport=void 0}})).actions(e=>{let t,o;return{setHoveredRowWalks(r){let n=r.join(`
|
|
4
|
+
`);n!==o&&(clearTimeout(t),o=void 0,r.length>0&&e.hoveredRowWalks.length>0?(o=n,t=setTimeout(()=>{o=void 0,H(e)&&e.hoveredRowWalks.length>0&&e.applyHoveredRowWalks(r)},ta)):e.applyHoveredRowWalks(r))}}}).actions(e=>({hostTransform(t,o){let r=e.viewportOwner!=="host";r&&(e.viewportOwner="host"),e.scale=t,e.translateX=o,r&&e.zoomToFit()},followNewLayout(t){let o=e.layoutBounds;if(e.followsWindow&&e.viewportOwner==="user"&&(e.viewportOwner="fit"),e.viewportOwner!=="user"||!o||t===e.layoutResult)return;let r=t?.referenceAxis===!0&&e.xIsReferenceBp;t===void 0||r&&(!e.paneMeasured||rn(o,e,e.viewBox))?e.keepDrawingInView():(e.viewportOwner="fit",e.zoomToFit())},refitView(){e.viewportOwner==="user"&&(e.viewportOwner="fit"),e.zoomToFit()},releaseHost(){e.viewportOwner==="host"&&(e.xIsReferenceBp?e.viewportOwner="user":(e.viewportOwner="fit",e.zoomToFit()))}})).actions(e=>{let t,o=0;function r(){cancelAnimationFrame(o),o=requestAnimationFrame(()=>{H(e)&&e.setPositionsDirty()})}let n;function a(){n&&(cancelAnimationFrame(n.frame),n=void 0),H(e)&&e.morphing&&e.setMorphing(!1)}function i(){let u=n;a(),u?.finish()}return{morphFrom(u,d){let p=e.layoutResult;if(u===p)return;let h=n&&u?structuredClone(u.nodePositions):u?.nodePositions;i();let R=e.graph;if(!u||!h||!p||!R||!Pr(u,p,R.nodes.length,!!e.facetGrid)||!Gr())return;e.viewportOwner==="fit"&&e.zoomToFit();let A=p.deletionRoutes??{},w=structuredClone({nodes:p.nodePositions,routes:A}),v=Tr(h,d,p.nodePositions,e.screenTransform,R.edges),B={nodes:v,routes:xr(A,R.edges,v,w.nodes)},F=new Set(Object.keys(p.nodePositions).filter(g=>!h[g])),k=g=>{ht(p.nodePositions,B.nodes,w.nodes,g),ht(A,B.routes,w.routes,g),H(e)&&e.setMorphFrame(g<1&&F.size>0?{layout:p,ids:F,alpha:g}:void 0)};e.setMorphing(!0),k(0),n=Cr(k,()=>H(e)&&e.layoutResult===p,()=>{n=void 0,H(e)&&e.setMorphing(!1)})},finishMorph:i,moveNode(u,d,p){i();let h=e.layoutResult?.nodePositions;if(h?.[u]){for(let R of h[u])R.x+=d,R.y+=p;r()}},afterAttach(){S(e,()=>{clearTimeout(t)}),S(e,Se(()=>{Te(e.liveBuildView),clearTimeout(t),e.buildViewSettled||(e.settledBuildView?.layout!==e.layoutResult||e.viewportOwner==="fit"?e.settleBuildView():t=setTimeout(()=>{H(e)&&e.settleBuildView()},Le))},{name:"GraphBuildViewSettle"}))}}});var ne=JBrowseExports["@jbrowse/core/util/unzip"],oa=e=>ne!=null&&e in Object(ne)?ne[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from '@jbrowse/core/util/unzip' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e}),dn=oa("unzip"),$u=ne&&ne.__esModule?ne.default:ne;async function Mt(e){let t=e[0]===31&&e[1]===139;return new TextDecoder().decode(t?await dn(e):e)}function pn(e,t,o){let r=e.walks,n=r.offsets[1]??0,a={nodes:e.nodes,links:e.links,walks:{names:r.names.slice(0,1),starts:r.starts.subarray(0,1),ends:r.ends.subarray(0,1),offsets:Int32Array.of(0,n),steps:r.steps.subarray(0,n),reversed:r.reversed.subarray(0,n)},departures:e.departures,revisited:e.revisited},i=ve(a,t,{referencePath:o}),u=new Int32Array(e.nodes.names.length);for(let p of r.steps)u[p]++;i.nodes.forEach((p,h)=>{p.depth=Math.max(u[h],1)});let d=r.names.slice(1).flatMap((p,h)=>r.offsets[h+2]>r.offsets[h+1]?[{...Ke(r,h+1),nodeIds:[]}]:[]);return i.paths=[...i.paths??[],...d],i}var ra=4,na=un.views(e=>({get engineSettings(){return fo({engine:e.chosenLayoutEngine,quality:e.layoutQuality,linearLayout:e.linearLayout,bubbleSpread:e.bubbleSpread,showDeletionEdges:e.showDeletionEdges})}})),cn=na.actions(e=>{let t=new AbortController,o,r,n=new WeakMap;function a(s){s!==r&&(r?.abort(),r=s)}function i(s,c){let{rpcManager:m}=G(e);return m.call(Z(e),"GraphComputeLayout",{...s,signal:c.signal,statusCallback:b=>{c===r&&e.setStatusMessage(je(b)??"")}})}function u(s){if(s.nodes.length>e.maxGraphNodes){let c=Y("walkrows").available(s)?"Pick Layout \u2192 Walk rows, zoom in to a smaller region":"Zoom in to a smaller region";throw new ao(`Graph too large to draw: ${s.nodes.length.toLocaleString()} nodes (limit ${e.maxGraphNodes.toLocaleString()}). ${c}, or raise the node limit in Graph settings.`)}}function*d(s,c,m,b){let l;for(;!l;){let y=new AbortController,M=le.layout(s,c,I=>i(I,y),m),L=n.get(M)??y;n.set(M,L);let P=L.signal.aborted;a(L),l=yield P?M.catch(I=>{if(!b())throw I}):M}return l}function*p(s,c){let m=performance.now(),b=J.has(e.chosenLayoutMode),l=e.graphRegion,y=b&&l?Je(s,l):s,M=b&&e.tubeMapFold>0&&!y.reads?dt(y,e.tubeMapFold):void 0,L=M?.graph??y,P=de=>b&&e.tubeMapRoutes!=="each"?ft(de,e.tubeMapColoring?.valueOf,e.tubeMapRoutes==="bundled"):de,I=e.walkCut?.walkRowRuns,E=e.chosenLayoutMode==="walkrows"&&I?wo(s,Qt(I),e.graphRegion):Y(e.chosenLayoutMode).run(P(L),e.graphRegion,e.host?e.layoutResult?.sampleRows:void 0);if(E){a();let de=q=>M&&q.tubeMap?{...q,tubeMap:{...q.tubeMap,coarse:M}}:q,_t=de(E),jt=e.tubeMapPanelSplit;return{result:b&&jt?Lr(_t,Ge(L,jt).map(q=>{let Dt=Y(e.chosenLayoutMode).run(P(vr(L,q.paths)),e.graphRegion);return{...q,result:Dt&&de(Dt)}})):_t,duration:performance.now()-m,mode:e.chosenLayoutMode}}u(s);let V=e.engineSettings,z=e.layoutFit,_=le.ready(s,V,z);return _?(a(),{result:_,duration:performance.now()-m,mode:"force"}):{...yield*d(s,V,z,c),mode:"force"}}let h=0,R=!1,A,w,v=new Map,B={walk:new AbortController,own:new AbortController,genes:new AbortController,repeats:new AbortController};function F(s){return B[s].abort(),B[s]=new AbortController,B[s].signal}function k(){for(let s of Object.values(B))s.abort()}function g(){e.graph!==w&&(w=void 0,e.layoutResult=void 0,e.drawnLayoutMode=void 0)}function*f(s){let c=++h;R=!0;let m=()=>e.graph===s&&c===h,{signal:b}=t,l;try{e.modeDrawsNodes&&u(s),l=yield*p(s,()=>m()&&!b.aborted)}catch(M){if(!m()||b.aborted)return!1;throw a(),A=M,g(),M}finally{c===h&&(R=!1,Ct())}let y=m();if(y){A!==void 0&&e.error===A&&(e.error=void 0),A=void 0;let M=e.layoutResult,L=e.screenTransform;e.snapsHostCut&&Ar(s,l.result,e.graphRegion),w=s,e.layoutResult=l.result,e.drawnLayoutMode=l.mode,e.setLayoutMs(l.duration),e.followNewLayout(M),e.morphFrom(M,L)}return y}function x(s,c){let m=s.anchorPaths;return s.anchoredBy==="paths"&&m?(De(s,e.assemblySpellings(c.assemblyName))??qt(m,c.assemblyName))?.name:void 0}function C(s,c,m,b=!1){let l=e.referencePath||m?.assemblyName,y=typeof s!="string"&&s.walkRowRuns&&!b?pn(s,c,l):ve(s,c,{referencePath:l});return y.anchoredBy==="tags"&&!y.referencePath&&y.paths?.length&&m&&(y.referencePath=De(y,e.assemblySpellings(m.assemblyName))?.name),y}function N(s){e.graph=s?.graph,e.walkCut=s?.walkCut,e.abridged=s?.abridged??[],e.graphRegion=s?.region,e.loadedReferencePath=s?.loadedReferencePath,e.foldedBelowBp=s?.foldedBelowBp,e.readsShown=s?.readsShown,e.indexBubbles=void 0,e.geneTrackFeatures=void 0,e.walkGeneFeatures=void 0,e.ownGeneFeatures=void 0,e.labelsAwaitReads=!0,v.clear(),k(),e.repeatArrays=void 0,e.clearInteractionState()}function*ae(s,c,m,b,l=0){let{signal:y}=t,M=typeof s!="string"&&s.walkRowRuns?s:void 0,L=C(s,c,m),P=m?x(L,m):void 0,I=!e.referencePath&&P!==void 0&&P!==L.referencePath?Me(L,P):L,E=l>0&&!b?wt(I,l,{cut:!0}):I,V=m&&E!==I?qe(E,m,l):E,z;if(b){e.setStatusMessage("Reading alignments");try{let{records:_,total:fe}=yield b(V);V.reads=_,z={shown:_.length,total:fe}}catch(_){if(y.aborted)return;console.warn("[GraphGenomeView] no reads for this graph",_)}if(y.aborted)return}return{graph:V,walkCut:M,abridged:typeof s=="string"?[]:s.abridged??[],region:m,loadedReferencePath:P,foldedBelowBp:E===I?void 0:l,readsShown:z}}function*Pt(s,c,m){let{signal:b}=t,{graph:l}=s,y=c?e.selectedNode:null;N(s);let M=new Set(l.nodes.map(P=>P.name));e.openBubbles=e.openBubbles.filter(P=>at(P).some(I=>M.has(I))),y!==null&&l.nodes.some(P=>P.id===y)&&(e.selectedNode=y),e.setStatusMessage("Computing layout");let L=m?.();L?.catch(()=>{}),yield*f(l),L&&!b.aborted&&(e.setStatusMessage("Reading annotations"),yield L)}function*Pn(s,c,m,b){let l=yield*ae(s,c,m);l&&(yield*Pt(l,!1,b))}let ie=new Map;function Gn(s,c){ie.delete(s),ie.set(s,c);for(let m of ie.keys())ie.size>ra&&ie.delete(m);return c}let Oe=0,ye;function Gt(){t.abort(),a(),t=new AbortController}function Cn(){let s=++Oe;return Gt(),ye=s,e.loadCanceled=!1,{isLive:()=>s===Oe,signal:t.signal}}function Ct(){ye===void 0&&!R&&e.finishLoading()}function An(){ye=void 0,Ct()}function*At(s,c){let m=Cn();e.isLoading=!0,e.error=void 0;try{return yield*c(m)}catch(b){m.isLive()&&(console.error(`[GraphGenomeView.${s}]`,b),e.error=b)}finally{m.isLive()&&An()}}function*We(s){e.featureReadsInFlight++;try{return yield s}finally{H(e)&&e.featureReadsInFlight--}}function*Bt(s,c,m,b){try{return yield*We(G(e).rpcManager.call(Z(e),"CoreGetFeatures",{adapterConfig:s,regions:[c],signal:b}))}catch(l){b?.aborted||console.warn(`[GraphGenomeView] no ${m} for this graph`,l);return}}let It=new Set;function*Bn(s,c,m,b,l=0){let y=Go(s),M=`${y}.bubbles.bed.gz`;if(s.type!=="RgfaTabixAdapter"||y===void 0||It.has(M))return;let L=yield*Bt({type:"MinigraphBubbleAdapter",uri:M,baseUri:s.baseUri,assemblyNameToPanSN:s.assemblyNameToPanSN},c,"bubble index",b);L===void 0&&!b?.aborted&&It.add(M),L&&m()&&(e.indexBubbles=L.flatMap(P=>{let I=P.get("start"),E=P.get("end"),V=P.get("longestAlleleLength");return Math.max(E-I,V)<l?[]:[{refName:c.refName,start:I,end:E,segmentCount:P.get("segmentCount"),pathCount:P.get("pathCount")??0,inversion:P.get("inversion"),shortestAlleleLength:P.get("shortestAlleleLength"),longestAlleleLength:V,segments:P.get("segments"),shortestAllele:void 0,longestAllele:void 0}]}))}function*Ht(s,c,m,b){let l=s?e.sessionTrack(s):void 0;if(l)return yield*Bt(lo(l),c,m,b)}function*Nt(s,c,m){let b=`${s} ${c.refName}:${c.start}-${c.end}`,l=v.get(b);if(!l){let y=yield*Ht(s,c,"haplotype genes",m);if(!y)return;l=hr(y).map(M=>({...M,refName:c.refName})),v.set(b,l)}return l}let Et={genes:{trackId:()=>e.geneTrack?.trackId,set:s=>{e.geneTrackFeatures=s}},repeats:{trackId:()=>e.repeatTrack?.trackId,set:s=>{e.repeatArrays=s&&cr(s)}}};function*Ft(s,c,m,b){let{trackId:l,set:y}=Et[s],M=l(),L=yield*Ht(M,c,s,b);L&&m()&&l()===M&&y(L)}function Ot(s,c,m){return["genes","repeats"].map(b=>W(Ft)(b,s,c,m))}function*Wt(s){let c=e.graphRegion;c&&(Et[s].set(void 0),yield*Ft(s,c,()=>e.graphRegion===c,F(s)))}function*Ve(s,c,m){yield*At("loadWholeGFA",function*({isLive:b,signal:l}){let y=typeof c=="string"?c:yield c(l);b()&&(yield*Pn(y,s,m,m&&(()=>Promise.all(Ot(m,b,l)))))})}function _e(){Gt(),ye=void 0,Oe++,h++,R=!1}function In(){let s=e.walkCut,c=e.graph;if(!s||!c||e.chosenLayoutMode==="walkrows")return c;let m=C(s,c.name,e.graphRegion,!0);return e.graph=m,e.walkCut=void 0,m}function Vt(){_e(),e.finishMorph(),e.morphEntering=void 0,e.drawnBatch=Q,e.paintedViewport=void 0,N(),e.cutKeyOnRecord=void 0,w=void 0,A=void 0,e.layoutResult=void 0,e.drawnLayoutMode=void 0,e.walkRowSampleTable=void 0,o=void 0,e.openBubbles=[],e.error=void 0,e.isLoading=!1,e.loadCanceled=!1,e.statusMessage="",e.clearPerfMetrics(),e.viewportOwner==="user"&&(e.viewportOwner="fit")}return{stopAwaitingReads(){e.labelsAwaitReads=!1},clearGraph(){Vt(),e.expandedWalks=[]},cancelLoad(){e.canCancelLoad&&(Vt(),e.loadCanceled=!0)},stopLoad(){_e(),g(),e.layoutResult||N(),e.isLoading=!1,e.statusMessage="",e.loadCanceled=!0},beforeDestroy(){_e(),k()},loadGFA:W(function*(s,c){yield*Ve(c??"Imported GFA",s)}),loadGFAFile:W(function*(s,c){e.setStatusMessage("Reading file"),yield*Ve(c,()=>s.arrayBuffer().then(m=>Mt(new Uint8Array(m))))}),loadGFAFromLocation:W(function*(s,c){e.setStatusMessage("Fetching GFA"),yield*Ve(tt(s)||"GFA",m=>$e(s,pe(e).pluginManager).readFile({signal:m}).then(Mt),c)}),cutSubgraph:W(function*(s,c,m={},b,l){return yield*At("cutSubgraph",function*({isLive:y,signal:M}){let L=Vr(s)?z=>G(e).rpcManager.call(Z(e),"GetGraphReads",{adapterConfig:s,nodeNames:z.nodes.map(_=>_.name),signal:M}):void 0,P=()=>Promise.all([m.tier==="coarse"?void 0:W(Bn)(s,c,y,M,e.foldedBelowBp),...Ot(c,y,M)]),I=JSON.stringify([s,c,m,b,e.referencePath]),E=l&&!L?ie.get(I):void 0;if(!E){e.setStatusMessage("Fetching subgraph");let z=performance.now(),_=yield G(e).rpcManager.call(Z(e),"GetSubgraph",{adapterConfig:s,region:c,opts:m,signal:M,statusCallback:fe=>{y()&&e.setStatusMessage(je(fe)??"Fetching subgraph")}});if(y()){if(e.setFetchMs(performance.now()-z),!_)throw new Error("Adapter returned no GFA \u2014 region may be outside indexed data or the adapter does not implement getSubgraph");E=yield*ae(_,Do(c),c,L,b)}}let V=l===!0&&!!E&&e.modeDrawsNodes&&E.graph.nodes.length>e.maxGraphNodes;return E&&!V&&(yield*Pt(l&&!L?Gn(I,E):E,!0,P)),V})}),reloadRepeats:W(function*(){yield*Wt("repeats")}),reloadGenes:W(function*(){yield*Wt("genes")}),loadWalkRowSampleTable:W(function*(){let s=e.walkRowSamplesTsv,c=s?JSON.stringify(s):void 0;if(c!==o&&(o=c,e.walkRowSampleTable=void 0,!!s))try{let m=yield $e(s,pe(e).pluginManager).readFile("utf8");H(e)&&c===o&&(e.walkRowSampleTable=Zo(m,void 0,"the samples table","the walks").sources)}catch(m){H(e)&&c===o&&(o=void 0,G(e).notify(`Walk rows cannot be grouped: the samples table did not load (${String(m)})`,"warning"))}}),loadWalkGenes:W(function*(){let s=e.walkGeneReads?.reads??[],c=JSON.stringify(s),m=e.graph,b=F("walk"),l=new Map;s.length>0&&(yield*We(Promise.all(s.map(({row:y,trackId:M,region:L})=>W(function*(){let P=yield*Nt(M,L,b);P&&l.set(y,P)})())))),!b.aborted&&H(e)&&e.graph===m&&JSON.stringify(e.walkGeneReads?.reads??[])===c&&(e.walkGeneFeatures=s.length?l:void 0)}),loadOwnGenes:W(function*(){let s=e.ownGeneReads,c=JSON.stringify(s),m=e.graph,b=F("own"),l=s.length===0?[]:yield*We(Promise.all(s.map(({stableRefName:y,trackId:M,region:L})=>W(function*(){return((yield*Nt(M,L,b))??[]).map(I=>({...I,refName:y}))})())));!b.aborted&&H(e)&&e.graph===m&&JSON.stringify(e.ownGeneReads)===c&&(e.ownGeneFeatures=s.length?l.flat():void 0)}),toggleBubble(s){let c=e.openBubbles,m=c.findIndex(M=>be(M,s));if(m>=0){e.openBubbles=c.slice(0,m);return}let b=new Set(at(s));if(!e.graph?.nodes.some(M=>b.has(M.name))){G(e).notify("None of the segments of this bubble are in the cut; widen the graph context to open it","info");return}let l=e.openBubbleInsides,y=l.length-1;for(;y>=0&&!l[y].some(M=>be(M,s));)y--;e.openBubbles=[...c.slice(0,y+1),s]},closeBubbles(){e.openBubbles.length>0&&(e.openBubbles=[])},recomputeLayout:W(function*(){let s=In();if(s){e.isLoading=!0,e.setStatusMessage("Computing layout");try{yield*f(s)}catch(c){console.error("[GraphGenomeView.recomputeLayout]",c),e.error=c}}})}});function mn(e){return X(e)&&typeof e.get=="function"}function Ee(e,t){let o=mn(e)?e.get(t):X(e)?e[t]:void 0;return typeof o=="string"?o:void 0}function hn(e){let t;if(X(e)&&X(e.hoverPosition)){let{refName:o,coord:r,coord0:n,assemblyName:a}=e.hoverPosition;typeof o=="string"&&typeof r=="number"&&(t={refName:o,coord:typeof n=="number"?n:r-1,assemblyName:typeof a=="string"?a:void 0,featureName:Ee(e.hoverFeature,"name"),featureSegments:Ee(e.hoverFeature,"segments"),viewId:typeof e.viewId=="string"?e.viewId:void 0})}return t}function ln(e,t,o){return e.viewId===void 0||t===void 0||!o.has(t)||e.viewId===t}function gn(e){if(!mn(e))return;let t=e.get("refName"),o=e.get("start");return typeof t=="string"&&typeof o=="number"?{refName:t,coord:o,featureName:Ee(e,"name"),featureSegments:Ee(e,"segments")}:void 0}function St(e,t){return(e.assemblyName===void 0||e.assemblyName===t.assemblyName)&&e.refName===t.refName&&e.coord>=t.start&&e.coord<t.end}function bn({hover:e,nodes:t}){let o,r;for(let n of t)n.name===e.featureName?o=n.id:r===void 0&&K(n)&&e.coord>=n.stable.start&&e.coord<n.stable.start+n.length&&(r=n.id);return o??r??null}function wn(e){let t=e.key?.split(">")??e.segments.split(",").filter(Boolean);return t.length>=2?[t[0],t.at(-1)].sort().join(" "):void 0}function aa(e){if(e.featureSegments)return wn({segments:e.featureSegments});let t=/^([<>][^<>]+){2}$/.test(e.featureName??"")?e.featureName.split(/[<>]/).filter(Boolean):[];return t.length===2?t.sort().join(" "):void 0}function Rt(e,t){let o=aa(e);return o===void 0?void 0:t().find(r=>wn(r)===o)}var ia=/^(.+) HP([1-9]\d*)$/,sa=/^(.+)\.(\d+)$/;function ua(e){let t=ia.exec(e),o=sa.exec(e);return[...t?[{sample:t[1],haplotype:t[2]}]:[],...o?[{sample:o[1],haplotype:o[2]}]:[],{sample:e,haplotype:void 0}]}function da(e){return ce(e).name.split("#")[1]}function yn(e,t){let o=t.map(r=>r.name);for(let{sample:r,haplotype:n}of ua(e)){let a=o.filter(i=>Jt(ce(i).name)===r&&(n===void 0||da(i)===n));if(a.length>0)return a}return[]}var pa=1500,fn=cn.views(e=>({get keyShape(){return e.keyShapeOf?.()}})).views(e=>({get labelFrameSettled(){let t=e.keyShape===void 0||!e.legendAtRest||e.measuredKeyShape===e.keyShape,o=e.answeredKeyFloor===void 0||e.answeredKeyFloor===e.canvasFloor;return e.layoutResult!==void 0&&!e.morphing&&(e.featureReadsInFlight===0||!e.labelsAwaitReads)&&t&&o}})).actions(e=>({startRenderingBackend(t){if(!e.autorunsInstalled){let o;S(e,()=>{clearTimeout(o)}),S(e,T(()=>e.labelsAwaitReads?e.layoutResult:void 0,r=>{clearTimeout(o),o=r?setTimeout(()=>{H(e)&&e.stopAwaitingReads()},pa):void 0},{fireImmediately:!0})),S(e,T(()=>e.labelFrameSettled,r=>{r&&e.stopAwaitingReads()},{fireImmediately:!0})),S(e,T(()=>e.fittedTransform,r=>{r&&e.viewportOwner==="fit"&&e.zoomToFit()},{fireImmediately:!0,name:"GraphKeepFitted"})),S(e,T(()=>`${e.viewBox.width} ${e.viewBox.height}`,()=>{e.keepDrawingInView()})),S(e,T(()=>{let r=e.facetGrid;return r?`${e.facetSetting.field} ${e.facetPanels?.length} ${r.columns}`:""},()=>{e.refitView()})),S(e,T(()=>({graph:e.graph,reads:JSON.stringify(e.walkGeneReads?.reads??[])}),()=>{e.loadWalkGenes()},{fireImmediately:!0,equals:(r,n)=>r.graph===n.graph&&r.reads===n.reads})),S(e,T(()=>({graph:e.graph,reads:JSON.stringify(e.ownGeneReads)}),()=>{e.loadOwnGenes()},{fireImmediately:!0,equals:(r,n)=>r.graph===n.graph&&r.reads===n.reads})),S(e,T(()=>e.graph&&(e.chosenLayoutMode==="walkrows"||J.has(e.chosenLayoutMode)||e.walkLayers.length>0)?[e.graph,JSON.stringify(e.walkRowSamplesTsv??null)]:void 0,r=>{r&&e.loadWalkRowSampleTable()},{fireImmediately:!0})),S(e,T(()=>`${e.fitPadTop} ${e.layoutBounds?.h} ${e.usableHeight}`,()=>{e.viewportOwner==="host"&&e.zoomToFit()})),S(e,T(()=>({hover:hn(G(e).hovered),lightsNode:e.hoverLightsEverything}),({hover:r,lightsNode:n})=>{let a=e.graphRegion,i=e.graph,u=r&&a&&St(r,a)&&ln(r,e.pairedViewId,Pe([...G(e).views]))?r:void 0,d=u?.featureName&&i?.paths?yn(u.featureName,i.paths):[],p=u&&Rt(u,()=>e.bubbles);a&&i&&!e.pointerInPane&&(e.setHoveredBubble(p??null),e.setHoveredNode(u&&n&&d.length===0&&!p?bn({hover:u,nodes:i.nodes}):null)),e.setHoveredRowWalks(d)},{fireImmediately:!0,name:"GraphMirrorLgvHover"})),S(e,T(()=>gn(G(e).selection),r=>{let n=e.graphRegion,a=r&&n&&St(r,n)&&Rt(r,()=>e.bubbles);a&&!e.openBubbles.some(i=>be(i,a))&&e.toggleBubble(a)})),S(e,T(()=>`${e.scale}-${e.translateX}-${e.translateY}`,()=>{e.clearHover()},{name:"GraphClearHoverOnViewportChange"})),S(e,Se(()=>{let r=e.currentRenderingBackend;r&&(e.applySelection(r),e.renderNow())}))}e.attachRenderingBackend(t,()=>({upload:o=>{if(Te(Ce()),o.resize(e.paneWidth,e.canvasHeight),e.layoutResult?.tubeMap)return o.uploadGeometry(Q),e.setGeometryMetrics(0,Q,e.buildView),!0;let r=e.facetDrawings?.[0];if(r)return o.uploadGeometry(Q),e.setGeometryMetrics(0,Q,r.view),!0;let n=performance.now(),a=e.buildDrawing(e.drawnHighlight,e.effectiveDrawPaths);return a?(o.uploadGeometry(a.batch),e.setGeometryMetrics(performance.now()-n,a.batch,a.view),!0):!1},render:o=>e.nodePositions?(e.paint(o),e.markPainted(),!0):!1,releaseTargets:o=>{o.releaseOffscreenTargets()}}))}})).actions(e=>({relayoutFrom(t){return e.recomputeLayout()}})).actions(e=>({relayout(t){return e.handledLayoutMode=e.chosenLayoutMode,e.relayoutFrom(t)}})).actions(e=>({switchLayout(t){let o=e.chosenLayoutMode;return e.setLayoutMode(t),e.relayout(o)},retryLoad(){},afterAttach(){e.isDefaultViewport||(e.viewportOwner="user");for(let[t,o]of[[()=>e.geneTrack?.trackId,()=>e.reloadGenes()],[()=>e.repeatTrack?.trackId,()=>e.reloadRepeats()]])S(e,T(()=>({track:t(),region:e.graphRegion}),(r,n)=>{r.region&&r.region===n.region&&o()},{equals:(r,n)=>r.track===n.track&&r.region===n.region}));S(e,T(()=>e.chosenLayoutMode,(t,o)=>{t!==e.handledLayoutMode&&e.relayout(o)})),S(e,T(()=>({mode:e.chosenLayoutMode,engine:JSON.stringify(e.engineSettings),maxNodes:e.maxGraphNodes}),(t,o)=>{e.graph&&t.mode===o.mode&&(t.engine!==o.engine&&e.usesLayoutEngine||t.maxNodes!==o.maxNodes&&e.modeDrawsNodes)&&e.recomputeLayout()},{equals:(t,o)=>t.mode===o.mode&&t.engine===o.engine&&t.maxNodes===o.maxNodes})),S(e,T(()=>J.has(e.chosenLayoutMode)?JSON.stringify({fold:e.tubeMapFold,facet:e.facetSetting,groupBy:e.walkRowGroupBy,table:e.walkRowGroupBy&&e.walkRowSampleTable?.length,routes:e.tubeMapRoutes,bundledBy:e.tubeMapRoutes!=="each"?e.tubeMapColoring?.field:void 0}):void 0,(t,o)=>{t!==void 0&&o!==void 0&&e.graph&&e.recomputeLayout()}))}})).actions(e=>({switchForceEngine(t){return e.setLayoutEngine(t),e.chosenLayoutMode==="force"?void 0:e.switchLayout("force")}})).actions(e=>({expandWalks(t){let o=t.filter(r=>!e.expandedWalks.includes(r));o.length>0&&(e.expandedWalks=e.expandedWalks.concat(o))}})).actions(e=>({expandWalk(t){e.expandWalks([t])},afterAttach(){S(e,T(()=>{let t=e.abridged.map(r=>r.name).filter(r=>e.walkLayers.some(n=>n.walk===r)),o=J.has(e.chosenLayoutMode)?Er(e.graph,e.abridged):[];return Array.from(new Set(t.concat(o,Fr(e.comparedRows))))},t=>{e.expandWalks(t)},{fireImmediately:!0,equals:(t,o)=>t.join(`
|
|
5
|
+
`)===o.join(`
|
|
6
|
+
`)}))}}));var kn=j(O("path",{d:"M9.19 6.35c-2.04 2.29-3.44 5.58-3.57 5.89L2 10.69l4.05-4.05c.47-.47 1.15-.68 1.81-.55zM11.17 17s3.74-1.55 5.89-3.7c5.4-5.4 4.5-9.62 4.21-10.57-.95-.3-5.17-1.19-10.57 4.21C8.55 9.09 7 12.83 7 12.83zm6.48-2.19c-2.29 2.04-5.58 3.44-5.89 3.57L13.31 22l4.05-4.05c.47-.47.68-1.15.55-1.81zM9 18c0 .83-.34 1.58-.88 2.12C6.94 21.3 2 22 2 22s.7-4.94 1.88-6.12C4.42 15.34 5.17 15 6 15c1.66 0 3 1.34 3 3m4-9c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2"}),"RocketLaunch");function Fe(e,t){ro(e,t);let o=e.find(r=>"subMenu"in r&&r.label===oo);o&&!o.icon&&(o.icon=kn)}var ca="SyntenyTrack",ma="Synteny adapters";function ha(e,t){let{type:o,adapter:r}=me(e);if(o===ca)return!0;let n=r?.type;return typeof n=="string"&&t.hasAdapterType(n)&&t.getAdapterType(n).adapterMetadata?.category===ma}function Mn(e,t,o){let r=new Set(t),n=[];for(let a of e.tracks)if(ha(a,o)){let i=zo(e,a).filter(u=>r.has(u)).length;i>=2&&n.push({trackId:me(a).trackId,name:eo(a,e),coverage:i})}return n.sort((a,i)=>i.coverage-a.coverage)}function Sn(e,t,o="image/svg+xml"){let r=URL.createObjectURL(new Blob([e],{type:o})),n=document.createElement("a");n.href=r,n.download=t,n.click(),setTimeout(()=>{URL.revokeObjectURL(r)},0)}var Rn=["off","nodes","everything"];var vn=[["fmmm","FMMM"],["stress","stress"]],vt=e=>e.label.replace(/ layout$/,"");function $(e,t,o){return e.map(({value:r,label:n,disabled:a})=>({type:"radio",label:n,disabled:a,checked:r===t,onClick:()=>{o(r)}}))}var Ln=fn.actions(e=>({showInLinearView(t){let o=G(e),r=t.assembly===e.graphRegion?.assemblyName,n=we(o,t.assembly),a=(r?e.geneTrack:e.geneTracksByAssembly.get(n))??e.sessionTracks.find(u=>u.assemblies.includes(n)&&mr.has(u.adapterType)),i=Yo({session:o,location:t.location,assembly:t.assembly,connectedViewId:e.pairedViewId,tracks:[...new Set([r?e.sourceTrackId:void 0,a?.trackId].filter(u=>u!==void 0))]});r&&e.pairWithLinearView(i)},highlightInLinearView(t){Xo({session:G(e),location:t.location,assembly:t.assembly,connectedViewId:e.pairedViewId})},showSyntenyView(t){Uo({session:G(e),contributors:e.launchableAssemblies,trackId:t,graphTrackId:e.sourceTrackId})}})).views(e=>({get syntenyLaunchTracks(){let t=e.launchableAssemblies.map(o=>o.sample);return t.length>=2?Mn(G(e),t,pe(e).pluginManager):[]}})).views(e=>({walkRowSampleMenuItems(){let{disagreeing:t}=e.walkRowSampleChoices,o=e.walkRowSamples,r=e.walkRowsFollowLift,n=a=>a.join(`
|
|
7
|
+
`)===o?.join(`
|
|
8
|
+
`);return[{type:"radio",label:"Every sample",checked:o===void 0&&!r,onClick:()=>{e.setWalkRowSamples(void 0)}},...r||e.drawnWalks.length>0?[{type:"radio",label:"Haplotypes of the lifted walks",checked:r,onClick:()=>{e.setWalkRowSamples("lifted")}}]:[],...t.length>0?[{type:"radio",label:"Where walk and call disagree",checked:n(t),onClick:()=>{e.setWalkRowSamples(t)}}]:[],{type:"radio",label:"Choose samples...",checked:o!==void 0&&!n(t),onClick:()=>{G(e).queueDialog(a=>[vo,{model:e,onClose:a}])}}]},walkRowGroupMenuItems(){let t=e.walkRowGroups?e.walkRowGroupBy?.field:void 0;return $([{value:void 0,label:"None"},...e.walkRowGroupFields.map(o=>({value:o,label:o}))],t,o=>{e.setWalkRowGroupBy(o===void 0?void 0:{field:o})})},tubeMapPanelMenuItems(){let{graph:t,walkRowSampleTable:o}=e,{field:r}=e.facetSetting,n=r===""?e.walkRowGroupBy?.field:void 0,a=i=>!!t&&Ge(t,i).length>1;return[...$(yr.map(i=>({value:i.field,label:i.label,disabled:i.field!==""&&!a({by:i.field})})),n?void 0:r,i=>{e.setFacet(i),i===""&&e.setWalkRowGroupBy(void 0)}),...$(e.walkRowGroupFields.map(i=>({value:i,label:`By ${i}`,disabled:!o||!a({by:"column",field:i,table:o})})),n,i=>{e.setFacet(""),e.setWalkRowGroupBy({field:i})})]},layoutOptionMenuItems({repeat:t=!0}={}){return[...J.has(e.chosenLayoutMode)?[{label:"Fold variants",subMenu:$(Po.map(({bp:o,label:r})=>({value:o,label:r,disabled:o>0&&e.graph?.reads!==void 0})),e.graph?.reads?0:e.tubeMapFold,e.setTubeMapFold)},{label:"Panels",subMenu:this.tubeMapPanelMenuItems()},{label:"Routes",subMenu:$(Co,e.tubeMapRoutes,e.setTubeMapRoutes)},...e.walkRowGroupFields.length>0?[{label:"Tube color",subMenu:$(["",...e.walkRowGroupFields].map(o=>({value:o,label:o?`By ${o}`:"By role"})),e.tubeMapColorBy,e.setTubeMapColorBy)}]:[]]:[],...t&&e.chosenLayoutMode==="walkrows"&&e.repeatChoices.length>0?[{label:"Repeat",subMenu:$(e.repeatOptions,e.selectedRepeat?.key??"",e.setRepeatKey)}]:[],...e.chosenLayoutMode==="walkrows"&&e.walkRowBars||e.walkStripShown?[{label:"Samples",subMenu:this.walkRowSampleMenuItems()}]:[],...e.chosenLayoutMode==="walkrows"&&e.walkRowBars?[{type:"checkbox",label:"Ribbons between rows",checked:e.walkRibbons,helpText:Be(e.comparedRows),onClick:()=>{e.setLayer("walkRibbons",!e.walkRibbons)}},{type:"checkbox",label:"Letter shared blocks",checked:e.layerSet.has("walkBlocks"),helpText:Be(e.comparedRows),onClick:()=>{e.setLayer("walkBlocks",!e.layerSet.has("walkBlocks"))}},{type:"checkbox",label:"Order rows by shared sequence",checked:e.walkRowOrder==="shared",helpText:Be(e.comparedRows),onClick:()=>{e.setWalkRowOrder(e.walkRowOrder==="shared"?void 0:"shared")}}]:[],...e.chosenLayoutMode==="walkrows"&&e.walkRowBars&&e.walkRowGroupFields.length>0?[{label:"Group by...",subMenu:this.walkRowGroupMenuItems()}]:[]]},showMenuItems(){let t=(o,r)=>({type:"checkbox",label:o,checked:e.layerSet.has(r),onClick:()=>{e.setLayer(r,!e.layerSet.has(r))}});return[t("Show bubble halos","bubbles"),t("Show links that skip reference","deletions"),{...t("Show small sites","smallSites"),helpText:"Draw every node and skip at any zoom. Off, a site too small to see at this zoom is left out and counted in the key, and drawn again as you zoom in"},t("Show node lengths","lengths"),{label:"Hover highlight",subMenu:$(Rn.map(o=>({value:o,label:o[0].toUpperCase()+o.slice(1)})),e.chosenHover,e.setHover)},t("Show genes on the backbone","genes"),...e.referenceStripApplies?[t("Show reference strip","referenceStrip")]:[]]},exportMenuItems(){return[{label:"Export SVG",icon:Jr,disabled:e.figureUnavailable!==void 0,disabledHelpText:e.figureUnavailable,onClick:()=>{let t=e.figure();t&&Sn(t,`${(e.graph?.name??"graph").replaceAll(/[^\w.-]+/g,"_")}.svg`)}}]},highlightMenuItems({picks:t=!0}={}){let o=t?e.walkChoices:[];if(e.walkChoices.length===0||!e.liftsWalks||!t&&e.walkLayers.length===0)return[];let r=a=>e.walkLayers.some(i=>i.walk===a),n=o.length>xo;return[{type:"subHeader",label:"Highlight"},...n?[{label:"Choose haplotypes...",onClick:()=>{G(e).queueDialog(a=>[Lo,{model:e,onClose:a}])}}]:[],...(n?o.filter(a=>r(a.name)):o).map(a=>({type:"checkbox",label:a.label,checked:r(a.name),onClick:()=>{e.toggleWalk(a.name)}})),{label:"Clear highlights",disabled:e.walkLayers.length===0,onClick:()=>{e.setWalkLayers([])}},...e.drawnWalks.length>0?[{label:"Color highlighted...",onClick:()=>{G(e).queueDialog(a=>[To,{model:e,onClose:a}])}}]:[],...e.drawnWalks.length>1?[{type:"checkbox",label:"Shade each light to dark along itself",checked:e.walksShadedAlong,onClick:()=>{e.shadeWalksAlong(!e.walksShadedAlong)}}]:[],...e.walkLayers.length>1&&e.modeDrawsNodes?[{type:"subHeader",label:"Arrange"},...$(Jo.map(({value:a,label:i})=>({value:a,label:a==="walk"?"A panel per haplotype":i})),e.facetSetting.field,e.setFacet)]:[]]},colorSchemeLabel(t){let o=ut.find(r=>r.value===t)?.label??t;return t==="auto"?`${o} (${this.colorSchemeLabel(e.effectiveColorScheme)})`:o},graphMenuItems(){let t=this.layoutOptionMenuItems(),o=Y(e.chosenLayoutMode),r=vn.find(([n])=>n===e.chosenLayoutEngine)[1];return[{label:`Layout: ${vt(o)}${o.value==="force"?` (${r})`:""}`,icon:Xr,subMenu:[...yo.flatMap(n=>{let a={type:"radio",disabled:e.graph?!n.available(e.graph):!1,disabledHelpText:n.description};return n.value==="force"?vn.map(([i,u])=>({...a,label:`${vt(n)} (${u})`,checked:e.chosenLayoutMode===n.value&&e.chosenLayoutEngine===i,onClick:()=>{e.switchForceEngine(i)}})):[{...a,label:vt(n),checked:e.chosenLayoutMode===n.value,onClick:()=>{e.switchLayout(n.value)}}]}),...t.length>0?[{type:"divider"},...t]:[],...e.hostPlacesX?[]:[{type:"divider"},{label:"Zoom to fit",onClick:()=>{e.refitView()}}]]},{label:`Color: ${e.colorSchemeLock?.value??this.colorSchemeLabel(e.chosenColorScheme)}`,icon:Ur,disabled:e.colorSchemeLock!==void 0,disabledHelpText:e.colorSchemeLock?.why,subMenu:$(ut.map(({value:n})=>({value:n,label:this.colorSchemeLabel(n)})),e.chosenColorScheme,e.setColorScheme)},{label:"Show",icon:qo,subMenu:this.showMenuItems()}]},launchMenuItems(){let t=[],o=e.launchableAssemblies,r=e.graphRegion?.assemblyName;for(let n of Or({contributors:o,linearContributors:e.host?o.filter(a=>a.sample!==r):o,syntenyTracks:e.syntenyLaunchTracks,onShowLinear:a=>{e.showInLinearView(a)},onShowSynteny:a=>{e.showSyntenyView(a)}}))Fe(t,n);return t}}));var la={bubbles:[],ticks:[],genes:[],passes:[],sizes:[]},ga=(e,t)=>!!t&&e.key===t.key&&e.text===t.text&&e.strong===t.strong&&e.under===t.under&&e.hover===t.hover&&e.walk===t.walk&&JSON.stringify(e.swatch)===JSON.stringify(t.swatch),ba=(e,t)=>e.length===t.length&&e.every((o,r)=>{let n=t[r];return!!n&&o.id===n.id&&o.group===n.group&&o.entries.length===n.entries.length&&o.entries.every((a,i)=>ga(a,n.entries[i]))}),Tn=Ln.volatile(()=>({settledKeyView:void 0})).actions(e=>({setSettledKeyView(t){e.settledKeyView={view:t,layout:e.layoutResult}}})).views(e=>({get liveKeyView(){return So(e,e.axisScale,{paneWidth:e.drawingClip?e.drawingWidth:e.paneWidth,canvasHeight:e.canvasHeight,referenceStripZonePx:e.referenceStripZonePx})},get keyView(){let t=e.settledKeyView;return t&&t.layout===e.layoutResult?t.view:this.liveKeyView}})).views(e=>{let t=se(()=>{let o=e.drawnGraph,r=e.facetDrawings;return o?Vo(o,e.layoutResult??{},{region:e.graphRegion,referenceRamp:e.referenceRamp,lift:e.walkLift,panels:e.facetPanels,walkLabel:n=>e.walkLabel(n),nodeWidth:e.nodeWidth,contigThickness:e.contigThickness,edgeWidth:e.linkWidth,connectorThickness:e.connectorThickness,drawsNodes:e.drawsNodes,marks:r?it(r.flatMap(n=>n?[n.batch]:[])):it([e.settledBatch],e.keyView),genePins:e.genePins,halos:e.bubbleHalos,stripOverhangs:e.referenceStripOverhangs||e.runsPastEdge,unlabelled:e.labelsNodeSizes?"reserved":void 0}):[]},{equals:ba});return{get graphKey(){return t.get()}}}).views(e=>({get passLabels(){return!e.facetPanels&&e.walkLift?.walks.some(t=>t.walkPasses)?jo(e.drawnBatch,e.walkLift,e.screenTransform,{width:e.paneWidth,height:e.canvasHeight}):[]}})).views(e=>{let t=se(()=>e.drawnBatch,{equals:(o,r)=>ze(()=>nt(o,r,{...e.screenTransform,width:e.paneWidth,height:e.canvasHeight}))});return{get drawnInk(){return t.get(),ze(()=>e.drawnBatch)}}}).views(e=>({get overlayLabels(){return e.labelFrameSettled?_o(e):la}})).views(e=>({get trackHaplotypes(){let t=e.sourceAdapter;return t&&he(t)}})).views(e=>({get cutHaplotypes(){return e.subgraphHaplotypes??e.trackHaplotypes},offReference(t){let o=e.sourceTrack,r=o&&ho(o),n=G(e);return r===void 0?void 0:go(we(n,r),we(n,t.assemblyName))}})).views(e=>({get cutOptions(){return{hops:e.subgraphContext,haplotypes:e.cutHaplotypes,...e.chosenLayoutMode==="walkrows"?{walkRows:!0}:{},...e.cutsWholeWalks?{snarls:"overlapping"}:{},...e.expandedWalks.length>0?{expand:e.expandedWalks}:{},...e.forcedByteBudget?{forcedByteBudget:e.forcedByteBudget}:{}}}})).views(e=>({get cutKey(){return JSON.stringify(e.cutOptions)}})).views(e=>({get cutStale(){return e.cutKeyOnRecord!==void 0&&e.cutKeyOnRecord!==e.cutKey}})).actions(e=>({markCut(){e.cutKeyOnRecord=e.cutKey},setSubgraphContext(t){e.subgraphContext=t},setSubgraphHaplotypes(t){e.subgraphHaplotypes=t},setHaplotypeNames(t){e.haplotypeNames=t}})).actions(e=>({async fetchHaplotypeNames(t,o){try{let r=await G(e).rpcManager.call(Z(e),"GetGraphHaplotypes",{adapterConfig:t,signal:o});H(e)&&!o?.aborted&&e.setHaplotypeNames(r)}catch(r){o?.aborted||console.warn("[GraphGenomeView] no haplotype names",r)}}})).actions(e=>({afterAttach(){let t;S(e,()=>{t?.abort()}),S(e,T(()=>{let o=e.sourceAdapter;return o&&mo(o)?o:void 0},o=>{t?.abort(),t=void 0,e.setHaplotypeNames(void 0),o&&(t=new AbortController,e.fetchHaplotypeNames(o,t.signal))},{fireImmediately:!0,equals:(o,r)=>JSON.stringify(o)===JSON.stringify(r),name:"GraphHaplotypeNames"})),S(e,T(()=>e.liveKeyView,o=>{e.setSettledKeyView(o)},{delay:Le,fireImmediately:!0,equals:ot,name:"GraphKeyView"})),S(e,T(()=>({shape:e.keyShape,view:e.keyView,rebuilt:e.builtViewport?.view,layout:e.layoutResult,width:e.paneWidth,owner:e.viewportOwner}),(o,r)=>{let n=!ot(o.view,r.view)||o.rebuilt!==r.rebuilt;e.setKeyFrameHeld(o.owner!=="fit"&&o.layout===r.layout&&o.width===r.width&&(n||o.shape===r.shape&&e.keyFrameHeld))},{name:"GraphKeyFrame"})),S(e,T(()=>({mode:e.chosenLayoutMode,key:e.cutKey}),(o,r)=>{o.mode===r.mode&&e.cutStale&&e.retryLoad()},{equals:(o,r)=>o.mode===r.mode&&o.key===r.key,name:"GraphCutOptions"}))}}));var wa=new Set(["scale","translateX","translateY"]);function ya(e){return Object.fromEntries(Object.keys(Ao.properties).filter(t=>!wa.has(t)).map(t=>[t,e[t]]))}var Lt=10;function Tt(e){let{aboveBpPerPx:t,foldBelowBp:o}=e??{};return typeof t=="number"?t:typeof o=="number"&&o>0?o/Lt:void 0}var fa=64,ka=no(()=>import("./GraphSettingsDialog-TW6UZMWK.js"));function Lc(e){return U.compose("LinearGraphDisplay",so,jr(),Tn,U.model({type:U.literal("LinearGraphDisplay"),configuration:$t(e),cutRegion:U.maybe(U.frozen()),coarseCut:U.optional(U.boolean,!1)})).volatile(()=>({recuts:0,settledWindow:void 0,dense:void 0,cutFoldBp:0,overLimit:new Set})).views(t=>({get grammar(){return{layoutMode:D(t,"layoutMode"),layoutEngine:D(t,"layoutEngine"),encoding:D(t,"encoding"),size:D(t,"size"),layers:D(t,"layers"),facet:{field:D(t,["facet","field"]),sort:D(t,["facet","sort"]),columns:D(t,["facet","columns"])},rows:D(t,"rows"),hover:D(t,"hover")}},get drawsGenomicCoordinates(){return t.layoutResult===void 0||t.hostPlacesX},get canvasHeight(){return t.height},get trackFit(){return t.heightMode},get referenceRoom(){return t.heightMode==="grow"?t.growMaxHeight:t.height},get canRetryLoad(){return t.cutRegion!==void 0},get trackHaplotypes(){let o=t.sourceAdapter,r=t.sourceTrack;return(o&&he(o))??(r&&Ue(r))},get coarseAboveBpPerPx(){return Tt(t.sourceAdapter?.coarse)},get growTargetHeight(){let o=t.followsWindow?t.heldScale:void 0,r=t.heldBounds;return o!==void 0&&r?Math.max(t.canvasFloor,Ho(r,o,t.followPads)):t.fitTargetHeight}})).views(t=>({tierAt(o){let r=t.coarseAboveBpPerPx;return r!==void 0&&o>r?"coarse":"fine"},capFor(o){return o==="coarse"?1/0:t.maxRegionBp},foldDrifted(o){let r=Lt*o,n=t.cutFoldBp;return!t.graph?.paths?.length&&(r>=2*Math.max(n,1)||t.foldedBelowBp!==void 0&&r<=n/2)},get cutTier(){return t.coarseCut&&t.coarseAboveBpPerPx!==void 0?"coarse":"fine"},foldFor(o,r){let n=r?.bpPerPx??t.host?.bpPerPx??0;return Math.round(Lt*(r&&t.snapsHostCut&&xe(o,ge(r))?n*Oo(r.span)/r.span:n))}})).views(t=>({overLimitKey(o,r){return JSON.stringify([o,t.tierAt(r.bpPerPx),t.foldFor(o,r),t.cutKey,t.maxGraphNodes])}})).views(t=>({cutFor(o){let r=t.capFor(t.tierAt(o.bpPerPx)),n=ge(o);return t.snapsHostCut&&n.end-n.start<=r&&!t.overLimit.has(t.overLimitKey(n,o))?n:Fo(o,r,Y(t.chosenLayoutMode).cutMargins)}})).views(t=>({snapped(o,r){return t.snapsHostCut&&xe(o,ge(r))},cutHoldsAt(o){return t.snapsHostCut?xe(t.cutRegion,t.cutFor(o))&&(!!t.graph?.paths?.length||t.cutFoldBp===t.foldFor(t.cutRegion,o)):Wo(t.cutRegion,o,Y(t.chosenLayoutMode).cutMargins)&&!t.foldDrifted(o.bpPerPx)}})).views(t=>({get settledCapBp(){let o=t.settledWindow;return o?t.capFor(t.tierAt(o.bpPerPx)):1/0},get unzoomableBytes(){return Xe(t.error)?t.error.bytes:void 0}})).views(t=>({get regionTooLarge(){let o=t.settledWindow;return o!==void 0&&o.end-o.start>t.settledCapBp},get regionTooLargeReason(){let o=t.settledWindow;return Xe(t.error)?t.error.message:o?`Region too large for a graph cut (${ue(o.end-o.start)}, max ${ue(t.settledCapBp)})`:""},get zoomCanReleaseGate(){return t.unzoomableBytes===void 0},get fetchCanceled(){return t.loadCanceled}})).views(t=>({get showsTooLarge(){return t.regionTooLarge||t.unzoomableBytes!==void 0}})).views(t=>({get svgReady(){return _r({error:t.error,regionTooLarge:t.showsTooLarge,extraTerminal:!1,fetchCanceled:t.loadCanceled},()=>!t.isLoading&&t.hasGraph&&!!t.layoutResult)}})).views(t=>({get displayPhase(){return zr({renderError:t.renderError,regionTooLarge:t.showsTooLarge,error:t.error},()=>$r({isMinimized:t.isMinimized,fetchInert:!1,viewportEmpty:t.host?.initialized===!0&&t.host.hasVisibleContent===!1,isLoading:t.isLoading||!t.hasGraph,fetchCanceled:t.loadCanceled,awaitingDependentData:!1,rendersCanvas:!0,canvasDrawn:t.painted},()=>!0,()=>t.host?.effectiveBodyMounted??!0))}})).actions(t=>{let{setSubgraphContext:o,setSubgraphHaplotypes:r}=t;return{setSubgraphContext(n){o(n),t.dense=void 0},setSubgraphHaplotypes(n){r(n),t.dense=void 0}}}).actions(t=>({writeGrammar(o){for(let[r,n]of Object.entries(o))zt(t,r,n)},setDense(o){t.dense=o},setMaxRegionBp(o){t.maxRegionBp=o},cut(){let o=t.cutRegion,r=t.sourceAdapter;if(!o||!r)return;let n=t.offReference(o);if(n){t.clearGraph(),t.setError(new Error(n));return}let a=t.cutTier==="coarse",i=t.settledWindow??(t.host?ee(t.host):void 0);return t.cutFoldBp=t.foldFor(o,i),t.markCut(),t.cutSubgraph(r,o,{...t.cutOptions,tier:a?"coarse":void 0},t.cutFoldBp,!!i&&t.snapped(o,i))}})).actions(t=>({recutAt(o){let r=t.tierAt(o.bpPerPx);return t.coarseCut=r==="coarse",t.cutRegion=t.cutFor(o),t.recuts++,t.cut()}})).actions(t=>{let o=0;return{followCut(r,n){let a=++o,i=t.cutRegion;Promise.resolve(r).then(u=>{H(t)&&o===a&&(u===!0||Ye(t.error))&&(t.snapped(i,n)?this.refuseSnappedCut(n):this.refuseDenseCut(n))})},settleOn(r){return t.settledWindow=r,t.regionTooLarge||gt(t.dense,r)||!t.loadCanceled&&t.tierAt(r.bpPerPx)===t.cutTier&&t.cutHoldsAt(r)&&!t.cutStale?!1:(this.followCut(t.recutAt(r),r),!0)},refuseSnappedCut(r){let{overLimit:n}=t;n.add(t.overLimitKey(ge(r),r));for(let a of n)n.size>fa&&n.delete(a);this.settleOn(t.settledWindow??r)},refuseDenseCut(r){t.setDense(r),t.cutRegion=void 0,this.settleOn(t.settledWindow??r)},recut(){t.cutRegion?this.reload():t.settledWindow&&this.settleOn(t.settledWindow)},relayoutFrom(r){let n=t.host?ee(t.host):void 0;if(n&&!t.regionTooLarge&&(t.cutStale||rt(r)!==rt(t.chosenLayoutMode))){let a=t.recutAt(n);return this.followCut(a,n),a}return t.recomputeLayout()},retryLoad(){this.recut()},reload(){let r=t.settledWindow??(t.host?ee(t.host):void 0),n=t.cut();r&&this.followCut(n,r)},cancelFetchByUser(){t.stopLoad()}}}).actions(t=>({stretchWithHost(o,r){let n=t.layoutBounds;if(!n||!t.followsHostView||t.snapsHostCut)return;t.viewportOwner==="fit"&&(t.viewportOwner="user");let a=o.bpPerPx/r.bpPerPx,i=t.translateY+t.scaleY*(n.minY+n.h/2);t.scale*=a,t.translateX=a*(t.translateX+o.offsetPx)-r.offsetPx,t.translateY=i-a*(i-t.translateY)}})).actions(t=>({forceLoad(){let o=t.unzoomableBytes,r=t.settledWindow;o!==void 0?(t.forcedByteBudget=o,t.setDense(void 0),t.recut()):r&&(t.setMaxRegionBp(Math.ceil(r.end-r.start)),t.settleOn(r))},afterAttach(){t.cutRegion&&!t.graph&&S(t,to(()=>!t.host||ee(t.host)!==void 0,()=>{t.recuts===0&&t.reload()})),S(t,T(()=>t.hostPlacesX,r=>{r||t.releaseHost()},{name:"GraphHostPlacesX"})),S(t,T(()=>t.hostFrame,r=>{r&&t.hostTransform(r.scale,r.translateX)},{equals:(r,n)=>r?.scale===n?.scale&&r?.translateX===n?.translateX,fireImmediately:!0,name:"GraphHostFrame"}));let o;S(t,T(()=>t.host&&!t.hostPlacesX?{bpPerPx:t.host.bpPerPx,offsetPx:t.host.offsetPx}:void 0,r=>{let n=o;o=r,r&&n&&r.bpPerPx>0&&t.stretchWithHost(n,r)},{equals:(r,n)=>r?.bpPerPx===n?.bpPerPx&&r?.offsetPx===n?.offsetPx,fireImmediately:!0,name:"GraphHostStretch"})),S(t,T(()=>`${t.facetSetting.field} ${t.facetPlacement?.count}`,()=>{let r=(t.facetGridIn(t.paneCeiling-Ae)?.total??0)+Ae;(t.facetGrid?.total??0)+Ae>t.height&&t.setHeight(Math.max(t.height,Math.ceil(r)))},{name:"GraphFacetHeight"})),t.setAnsweredKeyFloor(t.canvasFloor),S(t,T(()=>t.canvasFloor,r=>{r>t.height&&t.setHeight(Math.ceil(r)),t.setAnsweredKeyFloor(r)},{name:"GraphKeyHeight"})),S(t,T(()=>t.error,r=>{let n=t.settledWindow;n&&io(r)&&t.snapped(t.cutRegion,n)&&t.refuseSnappedCut(n)},{name:"GraphSnapDrawLimit"})),S(t,T(()=>t.maxGraphNodes,()=>{let r=t.settledWindow;r&&t.snapsHostCut&&t.settleOn(r)},{name:"GraphSnapNodeLimit"})),S(t,T(()=>t.host?.coarseDynamicBlocks,r=>{let{host:n}=t,a=r&&n?ee(n):void 0;a&&t.settleOn(a)},{fireImmediately:!0,name:"GraphHostSettle"}))}})).views(t=>({get graphViewSpec(){let o=t.host?ee(t.host):void 0,r=t.sourceTrackId;if(!o||!r||!t.hasGraph||t.coarseCut||t.regionTooLarge||gt(t.dense,o))return;let n=Math.floor(o.start),a=Math.ceil(o.end),{encoding:i,...u}=t.grammar;return{...ya(t),loadedTrackId:r,loadedRegion:{refName:o.refName,assemblyName:o.assemblyName,start:n,end:a},subgraphHaplotypes:t.cutHaplotypes,maxRegionBp:Math.max(t.maxRegionBp,a-n),...u,color:i?.color,layoutMode:t.chosenLayoutMode,connectedViewId:t.host?.id}}})).actions(t=>({openGraphView(){let o=t.graphViewSpec;o&&G(t).addView("GraphGenomeView",o)}})).views(t=>({cutMenuItems(){let o=t.sourceAdapter,r=t.sourceTrack;if(!o||!r||!Re(o))return[];let n=he(o),a=Ue(r),i=t.haplotypeNames,u=t.subgraphHaplotypes;return[{type:"subHeader",label:"Load"},{type:"radio",label:i?`Every haplotype in the graph (${i.length.toLocaleString()})`:"Every haplotype in the graph",checked:u?u.length===0:!n&&!a,onClick:()=>{t.setSubgraphHaplotypes([])}},...n||a?[{type:"radio",label:n?"The track's default haplotypes":`The track's ${a?.length} assemblies`,checked:u===void 0,onClick:()=>{t.setSubgraphHaplotypes(void 0)}}]:[],{type:"radio",label:"Chosen in Graph settings...",checked:(u?.length??0)>0,onClick:()=>{this.openSettings()}}]},openSettings(){G(t).queueDialog(o=>[ka,{model:t,onClose:o}])},async renderSvg(o){let{renderGraphTrackSvg:r}=await import("./renderSvg-SEYWHXD7.js");return r(t,o)},trackMenuItems(){let o=t.launchMenuItems();Fe(o,{label:"Graph genome view",icon:Wr,disabled:!t.graphViewSpec,disabledHelpText:t.error&&!Ye(t.error)?"The track could not cut a graph here":t.isLoading&&!t.hasGraph?"The track is still cutting its graph":t.unzoomableBytes!==void 0?"Force load the track to cut a graph here":"Zoom in until the track cuts a graph",onClick:()=>{t.openGraphView()}});let r=[...this.cutMenuItems(),...t.highlightMenuItems()];return[...r.length>0?[{label:"Haplotypes",icon:No,subMenu:r}]:[],...t.graphMenuItems(),{label:"Track sizing",icon:Yr,subMenu:Bo.map(n=>({type:"radio",label:Io[n],checked:t.heightMode===n,onClick:()=>{t.setHeightMode(n)}}))},{label:"Graph settings...",icon:Eo,helpText:"Subgraph, drawing and force-directed layout",onClick:()=>{this.openSettings()}},...o,...Dr(t)]}}))}function xt(e){return e.type==="RgfaTabixAdapter"&&Tt(e.coarse)!==void 0}function xn(e){let t=xt(e)?"Any zoom: a coarse graph when zoomed out":`Zoomed in: under ${ue(et)}`;return Re(e)?`${t} \xB7 haplotype walks`:t}var Ma=2e4;function Sa(e){let t=me(e),{trackId:o,name:r,assemblyNames:n,adapter:a}=X(t)?t:{},i=Ko(n)?n[0]:void 0;return typeof o=="string"&&X(a)&&typeof a.type=="string"&&co.has(a.type)&&typeof i=="string"?[{trackId:o,name:typeof r=="string"&&r?r:o,assembly:i,reach:xn(a),anyZoom:xt(a)}]:[]}function Ec(e){let t=e.flatMap(Sa);return[...t.filter(o=>o.anyZoom),...t.filter(o=>!o.anyZoom)]}function Fc(e,t){let o=$o(e).flatMap(r=>X(r)&&r.type==="LinearGenomeView"&&Array.isArray(r.assemblyNames)&&r.assemblyNames.includes(t)&&typeof r.visibleLocStrings=="string"&&r.visibleLocStrings!==""?[r.visibleLocStrings]:[]);return o.length===1?o[0]:void 0}function Oc(e,t){let{refName:o,start:r,end:n}=t;return e.anyZoom?o:`${o}:${(r+1).toLocaleString("en-US")}-${Math.min(n,r+Ma).toLocaleString("en-US")}`}export{Wr as a,lt as b,Rn as c,Tn as d,Lc as e,Ec as f,Fc as g,Oc as h};
|
|
9
|
+
//# sourceMappingURL=chunk-VV5LVNCP.js.map
|