"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4864],{34864:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var a=r(60972),s=r(46377),n=r(99834),i=r(66885),o=r(4101),c=r(32598),l=r(7706);class d extends s.BaseFeatureDataAdapter{intervalTrees={};static capabilities=["getFeatures","getRefNames"];async loadDataP(e={}){const t=this.pluginManager,r=this.getConf("bedLocation"),s=await(0,n.openLocation)(r,t).readFile(e),i=function(e){return 31===e[0]&&139===e[1]&&8===e[2]}(s)?await(0,l.unzip)(s):s;if(i.length>536870888)throw new Error("Data exceeds maximum string length (512MB)");const o=new TextDecoder("utf8",{fatal:!0}).decode(i).split(/\n|\r\n|\r/).filter((e=>!!e)),c=[];let d=0;for(;d<o.length&&o[d].startsWith("#");d++)c.push(o[d]);const u=c.join("\n"),h={};for(;d<o.length;d++){const e=o[d],t=e.indexOf("\t"),r=e.slice(0,t);h[r]||(h[r]=[]),h[r].push(e)}const f=this.getConf("autoSql");return{header:u,features:h,parser:new a.A({autoSql:f}),columnNames:this.getConf("columnNames"),scoreColumn:this.getConf("scoreColumn"),colRef:this.getConf("colRef"),colStart:this.getConf("colStart"),colEnd:this.getConf("colEnd")}}async loadData(e={}){return this.bedFeatures||(this.bedFeatures=this.loadDataP(e).catch((e=>{throw this.bedFeatures=void 0,e}))),this.bedFeatures}async getRefNames(e={}){const{features:t}=await this.loadData(e);return Object.keys(t)}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 r=e.split(/\n|\r\n|\r/).filter((e=>!!e)).at(-1);return r?.includes("\t")?r.slice(1).split("\t").map((e=>e.trim())):void 0}async loadFeatureIntervalTreeHelper(e){const{colRef:t,colStart:r,colEnd:a,features:s,parser:n,scoreColumn:i}=await this.loadData(),l=s[e];if(!l)return;const d=await this.getNames(),u=new c.Ay,h=l.map(((s,c)=>{const l=`${this.id}-${e}-${c}`;return(0,o.d)(s,t,r,a,i,n,l,d)}));for(const e of h)u.insert([e.get("start"),e.get("end")],e);return u}async loadFeatureIntervalTree(e){return this.intervalTrees[e]||(this.intervalTrees[e]=this.loadFeatureIntervalTreeHelper(e).catch((t=>{throw this.intervalTrees[e]=void 0,t}))),this.intervalTrees[e]}getFeatures(e,t={}){return(0,i.ObservableCreate)((async t=>{const{start:r,end:a,refName:s}=e,n=await this.loadFeatureIntervalTree(s);n?.search([r,a]).forEach((e=>t.next(e))),t.complete()}),t.signal)}freeResources(){}}},4101:(e,t,r)=>{r.d(t,{B:()=>s,d:()=>n});var a=r(99546);function s(e){const t=e.children(),r=e.get("thickStart"),s=e.get("thickEnd"),n=e.get("refName");if(!r&&!s)return e;const i=t?t.filter((e=>"block"===e.get("type"))).sort(((e,t)=>e.get("start")-t.get("start"))):[],o=[];i.forEach((t=>{const a=t.get("start"),i=t.get("end");if(r>=i){const t=e.get("strand")>0?"five":"three";o.push({type:`${t}_prime_UTR`,start:a,end:i,refName:n})}else if(r>a&&r<i&&s>=i){const t=e.get("strand")>0?"five":"three";o.push({type:`${t}_prime_UTR`,start:a,end:r,refName:n},{type:"CDS",start:r,end:i,refName:n})}else if(r<=a&&s>=i)o.push({type:"CDS",start:a,end:i,refName:n});else if(r>a&&r<i&&s<i){const t=e.get("strand")>0?"five":"three",c=e.get("strand")>0?"three":"five";o.push({type:`${t}_prime_UTR`,start:a,end:r,refName:n},{type:"CDS",start:r,end:s,refName:n},{type:`${c}_prime_UTR`,start:s,end:i,refName:n})}else if(r<=a&&s>a&&s<i){const t=e.get("strand")>0?"three":"five";o.push({type:"CDS",start:a,end:s,refName:n},{type:`${t}_prime_UTR`,start:s,end:i,refName:n})}else if(s<=a){const t=e.get("strand")>0?"three":"five";o.push({type:`${t}_prime_UTR`,start:a,end:i,refName:n})}}));const c=Object.fromEntries(e.tags().map((t=>[t,e.get(t)])));return c.subfeatures=o,c.type="mRNA",c.uniqueId=e.id(),delete c.chromStarts,delete c.chromStart,delete c.chromEnd,delete c.chrom,delete c.blockStarts,delete c.blockSizes,delete c.blockCount,delete c.thickStart,delete c.thickEnd,new a.SimpleFeature({data:c,id:e.id()})}function n(e,t,r,n,i,o,c,l){const d=e.split("\t"),u=d[t],h=+d[r],f=r===n?1:0,m=+d[n]+f,p=l?function(e,t){return Object.fromEntries(t.split("\t").map(((t,r)=>[e[r],t])))}(l,e):o.parseLine(e,{uniqueId:c}),{blockCount:g,blockSizes:b,blockStarts:w,chromStarts:y}=p;if(g){const e=y||w||[],t=b,r=h;p.subfeatures=[];for(let a=0;a<g;a+=1){const s=(e[a]||0)+r,n=s+(t[a]||0);p.subfeatures.push({uniqueId:`${c}-${a}`,start:s,end:n,refName:u,type:"block"})}}i&&(p.score=+p[i]),delete p.chrom,delete p.chromStart,delete p.chromEnd;const N=new a.SimpleFeature({...p,start:h,end:m,refName:u,uniqueId:c});return N.get("thickStart")?s(N):N}}}]);
//# sourceMappingURL=4864.2691eeba.chunk.js.map