import{B as h,f as g}from"./util-CK2N18We.js";import{T as b}from"./tabixIndexedFile-B_BgWenS.js";import{i as c,s as l,u as x}from"./rpcWorker-CVTx5FIM.js";import{B as C}from"./index-P3rx-5SH.js";import{r as k}from"./rxjs-Dgg09m9e.js";import"./AbortablePromiseCache-xs5eyOH3.js";class N extends C.BaseFeatureDataAdapter{constructor(t,n,e){super(t,n,e);const s=this.getConf("bedGzLocation"),i=this.getConf(["index","indexType"]),o=this.getConf(["index","location"]),r=this.getConf("autoSql"),a=this.pluginManager;this.bed=new b({filehandle:c.openLocation(s,a),csiFilehandle:i==="CSI"?c.openLocation(o,a):void 0,tbiFilehandle:i!=="CSI"?c.openLocation(o,a):void 0,chunkCacheSize:50*2**20}),this.columnNames=this.getConf("columnNames"),this.scoreColumn=this.getConf("scoreColumn"),this.parser=new h({autoSql:r})}async getRefNames(t={}){return this.bed.getReferenceSequenceNames(t)}async getHeader(){return this.bed.getHeader()}async getNames(){if(this.columnNames.length)return this.columnNames;const e=(await this.bed.getHeader()).split(/\n|\r\n|\r/).filter(s=>!!s).at(-1);return e!=null&&e.includes("	")?e.slice(1).split("	").map(s=>s.trim()):void 0}getFeatures(t,n={}){const{stopToken:e}=n;return k.ObservableCreate(async s=>{const i=await this.bed.getMetadata(),{columnNumbers:o}=i,r=o.ref-1,a=o.start-1,m=o.end-1,p=await this.getNames();let d=performance.now();l.checkStopToken(e),await this.bed.getLines(t.refName,t.start,t.end,{lineCallback:(u,f)=>{performance.now()-d>200&&(l.checkStopToken(e),d=performance.now()),s.next(new x.SimpleFeature(g({line:u,colRef:r,colStart:a,colEnd:m,scoreColumn:this.scoreColumn,parser:this.parser,uniqueId:`${this.id}-${f}`,names:p})))},stopToken:n.stopToken}),s.complete()},n.stopToken)}freeResources(){}}N.capabilities=["getFeatures","getRefNames"];export{N as default};
