import{T as F}from"./tabixIndexedFile-BzYBftJ8.js";import{a9 as h,u as L}from"./index-Bm2SqMk3.js";import{B as S}from"./index-6rN3ss-L.js";import{r as v}from"./rxjs-DT7GVwt0.js";class T extends S.BaseFeatureDataAdapter{async configurePre(){const e=this.pluginManager,n=this.getConf("bedGraphGzLocation"),s=this.getConf(["index","location"]),o=this.getConf(["index","indexType"]),t=h.openLocation(n,e),a=o==="CSI",i=new F({filehandle:t,csiFilehandle:a?h.openLocation(s,e):void 0,tbiFilehandle:a?void 0:h.openLocation(s,e),chunkCacheSize:50*2**20}),l=this.getConf("columnNames"),c=await i.getHeader();return{columnNames:l,bedGraph:i,header:c}}async configure(){return this.configured||(this.configured=this.configurePre().catch(e=>{throw this.configured=void 0,e})),this.configured}async getNames(){const{bedGraph:e,columnNames:n}=await this.configure();if(n.length)return n;const t=(await e.getHeader()).split(/\n|\r\n|\r/).filter(a=>!!a).at(-1);return t!=null&&t.includes("	")?t.slice(1).split("	").map(a=>a.trim()):void 0}async getRefNames(e={}){const{bedGraph:n}=await this.configure();return n.getReferenceSequenceNames(e)}async getHeader(){const{bedGraph:e}=await this.configure();return e.getHeader()}getFeatures(e,n={}){return v.ObservableCreate(async s=>{var o;const{bedGraph:t}=await this.configure(),a=await t.getMetadata(),{columnNumbers:i}=a,l=i.ref-1,c=i.start-1,u=i.end-1,f=c===u,x=((o=await this.getNames())===null||o===void 0?void 0:o.slice(f?2:3))||[];await t.getLines(e.refName,e.start+(f?-1:0),e.end,{lineCallback:(b,w)=>{const d=b.split("	"),G=d[l],p=+d[c],N=+(f?p+1:d[u]),g=d.slice(u+1);for(let r=0;r<g.length;r++){const C=`${this.id}-${w}-${r}`,m=Math.abs(+g[r]),y=x[r]||`col${r}`;m&&s.next(new L.SimpleFeature({id:C,data:{refName:G,start:p,end:N,score:m,source:y}}))}},...n}),s.complete()})}freeResources(){}}export{T as default};
