"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4864],{34864:(t,e,r)=>{r.r(e),r.d(e,{default:()=>u});var a=r(60972),s=r(46377),n=r(99834),o=r(66885),i=r(32598),c=r(7706),l=r(4101);class u 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=function(t){return 31===t[0]&&139===t[1]&&8===t[2]}(s)?await(0,c.unzip)(s):s;if(o.length>536870888)throw new Error("Data exceeds maximum string length (512MB)");const i=new TextDecoder("utf8",{fatal:!0}).decode(o).split(/\n|\r\n|\r/).filter((t=>!!t)),l=[];let u=0;for(;u<i.length&&i[u].startsWith("#");u++)l.push(i[u]);const h=l.join("\n"),f={};for(;u<i.length;u++){const t=i[u],e=t.indexOf("\t"),r=t.slice(0,e);f[r]||(f[r]=[]),f[r].push(t)}const d=this.getConf("autoSql");return{header:h,features:f,parser:new a.A({autoSql:d}),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(),c=s[t];if(!c)return;const u=await this.getNames(),h=new i.Ay,f=c.map(((s,i)=>{const c=`${this.id}-${t}-${i}`;return(0,l.dE)(s,e,r,a,o,n,c,u)}));for(const t of f)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,dE:()=>o,xD:()=>i,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 f=t.split("\t"),d=f[e],m=+f[r],p=r===o?1:0,b=+f[o]+p,k=h?function(t,e){const{blockStarts:r,blockCount:a,chromStarts:s,thickEnd:n,thickStart:o,blockSizes:i,...c}=Object.fromEntries(e.split("\t").map(((e,r)=>[t[r],e])));return{...c,blockStarts:r?.split(",").map((t=>+t)),chromStarts:s?.split(",").map((t=>+t)),blockSizes:i?.split(",").map((t=>+t)),thickStart:+o,thickEnd:+n,blockCount:+a}}(h,t):l.parseLine(t,{uniqueId:u}),{blockCount:S,blockSizes:g,blockStarts:y,chromStarts:C,thickStart:N,thickEnd:w,type:v,score:T,chrom:_,chromStart:D,chromEnd:E,...F}=k,R=S?n({start:m,uniqueId:u,refName:d,chromStarts:C,blockCount:S,blockSizes:g,blockStarts:y}):[],$={...F,type:v,score:c?+k[c]:T,start:m,end:b,refName:d,uniqueId:u,subfeatures:R};return new a.SimpleFeature({id:u,data:i(k)?s({thickStart:N,thickEnd:w,blockCount:S,blockSizes:g,chromStarts:C,...$}):$})}function i(t){return t.thickStart&&t.blockCount&&0!==t.strand}}}]);
//# sourceMappingURL=4864.f994a37a.chunk.js.map