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