"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8738],{28738:(e,t,a)=>{a.r(t),a.d(t,{default:()=>d});var s=a(32598),r=a(46377),n=a(99546),i=a(99834),o=a(66885);const c=new Set(["DUP","TRA","INV","CNV","DEL"]);function l(e,t,a,s){const r=e.split("\t"),i=r[a?3:0],o=+r[a?4:1],l=+r[a?5:2],d=r[a?0:3],u=+r[a?1:4],p=+r[a?2:5],f=r[6],m=+r[7],b=h(r[8]),w=h(r[9]),g=r.slice(10),T=s?Object.fromEntries(s.slice(10).map((e,t)=>[e,g[t]])):{},y=c.has(g[0])?`<${g[0]}>`:void 0;return new n.SimpleFeature({...T,start:o,end:l,type:"paired_feature",refName:i,strand:b,name:f,score:m,uniqueId:t,mate:{refName:d,start:u,end:p,strand:w},...y?{ALT:[y]}:{}})}function h(e){return"+"===e?1:"-"===e?-1:"."===e?0:void 0}class d extends r.BaseFeatureDataAdapter{intervalTrees={};static capabilities=["getFeatures","getRefNames"];async loadDataP(e){const t=(await(0,n.fetchAndMaybeUnzipText)((0,i.openLocation)(this.getConf("bedpeLocation"),this.pluginManager),e)).split(/\n|\r\n|\r/).filter(e=>!!e),a=[];let s=0;for(;s<t.length&&t[s].startsWith("#");s++)a.push(t[s]);const r=a.join("\n"),o={},c={};for(;s<t.length;s++){const e=t[s],a=e.split("\t"),r=a[0],n=a[3];o[r]||(o[r]=[]),c[n]||(c[n]=[]),o[r].push(e),c[n].push(e)}return{header:r,feats1:o,feats2:c,columnNames:this.getConf("columnNames")}}async loadData(e={}){return this.bedpeFeatures||(this.bedpeFeatures=this.loadDataP(e).catch(e=>{throw this.bedpeFeatures=void 0,e})),this.bedpeFeatures}async getRefNames(e={}){const{feats1:t,feats2:a}=await this.loadData(e);return[...new Set([...Object.keys(t),...Object.keys(a)])]}async getHeader(e={}){const{header:t}=await this.loadData(e);return t}async getNames(){const{header:e,columnNames:t}=await this.loadData();if(t.length)return t;const a=e.split(/\n|\r\n|\r/).filter(e=>!!e).at(-1);return a?.includes("\t")?a.slice(1).split("\t").map(e=>e.trim()):void 0}async loadFeatureTreeP(e){const{feats1:t,feats2:a}=await this.loadData(),r=await this.getNames(),n=new s.Ay,i=t[e]?.map((t,a)=>l(t,`${this.id}-${e}-${a}-r1`,!1,r))??[],o=a[e]?.map((t,a)=>l(t,`${this.id}-${e}-${a}-r2`,!0,r))??[];for(const e of[...i,...o])n.insert([e.get("start"),e.get("end")],e);return n}async loadFeatureTree(e){return this.intervalTrees[e]||(this.intervalTrees[e]=this.loadFeatureTreeP(e).catch(t=>{throw this.intervalTrees[e]=void 0,t})),this.intervalTrees[e]}getFeatures(e,t={}){return(0,o.ObservableCreate)(async t=>{const{start:a,end:s,refName:r}=e,n=await this.loadFeatureTree(r);for(const e of n?.search([a,s])||[])t.next(e);t.complete()},t.stopToken)}}}}]);
//# sourceMappingURL=8738.881ebefb.chunk.js.map