"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8343],{98343:(e,t,a)=>{a.r(t),a.d(t,{default:()=>u});var s=a(32598),r=a(6854),n=a(46377),i=a(99546),c=a(99834),o=a(66885),l=a(54702);class u extends n.BaseFeatureDataAdapter{calculatedIntervalTreeMap={};static capabilities=["getFeatures","getRefNames"];async getHeader(){const{header:e}=await this.setup();return e}async getMetadata(){const{parser:e}=await this.setup();return e.getMetadata()}async setupP(e){const{statusCallback:t=()=>{}}=e||{},a=(0,c.openLocation)(this.getConf("vcfLocation"),this.pluginManager),n=await(0,i.fetchAndMaybeUnzip)(a,e),o=[],u={};let p=0;const h=new TextDecoder("utf8");let f=0;for(;p<n.length;){const e=n.indexOf(10,p),a=-1===e?n.subarray(p):n.subarray(p,e),s=h.decode(a).trim();if(s)if(s.startsWith("#"))o.push(s);else{const e=s.indexOf("\t"),t=s.slice(0,e);u[t]||(u[t]=[]),u[t].push(s)}f++%1e4==0&&t(`Loading ${Math.floor(p/1e6).toLocaleString("en-US")}/${Math.floor(n.length/1e6).toLocaleString("en-US")} MB`),p=e+1}const d=o.join("\n"),g=new r.A({header:d}),b=Object.fromEntries(Object.entries(u).map((([e,t])=>[e,a=>{if(!this.calculatedIntervalTreeMap[e]){a?.("Parsing VCF data");let r=0;const n=new s.Ay;for(const a of t){const t=new l.A({variant:g.parseLine(a),parser:g,id:`${this.id}-${e}-${r++}`});n.insert([t.get("start"),t.get("end")],t)}this.calculatedIntervalTreeMap[e]=n}return this.calculatedIntervalTreeMap[e]}])));return{header:d,parser:g,intervalTreeMap:b}}async setup(){return this.vcfFeatures||(this.vcfFeatures=this.setupP().catch((e=>{throw this.vcfFeatures=void 0,e}))),this.vcfFeatures}async getRefNames(e={}){const{intervalTreeMap:t}=await this.setup();return Object.keys(t)}getFeatures(e,t={}){return(0,o.ObservableCreate)((async a=>{try{const{start:s,end:r,refName:n}=e,{intervalTreeMap:i}=await this.setup();i[n]?.(t.statusCallback).search([s,r]).forEach((e=>{a.next(e)})),a.complete()}catch(e){a.error(e)}}),t.stopToken)}async getSources(){const e=this.getConf("samplesTsvLocation");if(""===e.uri||"/path/to/samples.tsv"===e.uri){const{parser:e}=await this.setup();return e.samples.map((e=>({name:e})))}{const t=(await(0,c.openLocation)(e).readFile("utf8")).split(/\n|\r\n|\r/),a=t[0].split("\t"),{parser:s}=await this.setup(),r=new Set(s.samples);return t.slice(1).map((e=>{const t=e.split("\t");return{name:t[0],...Object.fromEntries(t.slice(1).map(((e,t)=>[a[t+1],e])))}})).filter((e=>r.has(e.name)))}}freeResources(){}}}}]);
//# sourceMappingURL=8343.9f3b631d.chunk.js.map