"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8343],{98343:(e,t,a)=>{a.r(t),a.d(t,{default:()=>h});var s=a(46377),r=a(99546),n=a(99834),i=a(66885),c=a(32598),o=a(7706),u=a(9502),l=a(54702);class h extends s.BaseFeatureDataAdapter{calculatedIntervalTreeMap={};static capabilities=["getFeatures","getRefNames"];async getHeader(){const{header:e}=await this.setup();return e}async getMetadata(){const{header:e}=await this.setup();return new u.A({header:e}).getMetadata()}async setupP(e){const{statusCallback:t=()=>{}}=e||{},a=await(0,n.openLocation)(this.getConf("vcfLocation"),this.pluginManager).readFile(e),s=(0,r.isGzip)(a)?await(0,r.updateStatus)("Unzipping",t,(()=>(0,o.unzip)(a))):a,i=[],h={};let d=0;const p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;let f=0;for(;d<s.length;){const e=s.indexOf("\n",d),a=-1===e?s.subarray(d):s.subarray(d,e),r=(p?.decode(a)||a.toString()).trim();if(r)if(r.startsWith("#"))i.push(r);else{const e=r.indexOf("\t"),t=r.slice(0,e);h[t]||(h[t]=[]),h[t].push(r)}f++%1e4==0&&t(`Loading ${Math.floor(d/1e6).toLocaleString("en-US")}/${Math.floor(s.length/1e6).toLocaleString("en-US")} MB`),d=e+1}const g=i.join("\n"),b=new u.A({header:g});return{header:g,intervalTreeMap:Object.fromEntries(Object.entries(h).map((([e,t])=>[e,a=>{if(!this.calculatedIntervalTreeMap[e]){a?.("Parsing VCF data");let s=0;const r=new c.Ay;for(const a of t){const t=new l.A({variant:b.parseLine(a),parser:b,id:`${this.id}-${e}-${s++}`});r.insert([t.get("start"),t.get("end")],t)}this.calculatedIntervalTreeMap[e]=r}return this.calculatedIntervalTreeMap[e]}])))}}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,i.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.signal)}freeResources(){}}}}]);
//# sourceMappingURL=8343.dd515382.chunk.js.map