"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4284,7706],{94284:(e,t,n)=>{n.r(t),n.d(t,{default:()=>o});var r=n(7706),i=n(99546),a=n(99834),s=n(46377);class o extends s.BaseAdapter{async getData(){const e=this.pluginManager,t=this.getConf("cytobandLocation");if(""===t.uri||"/path/to/cytoband.txt.gz"===t.uri)return[];const n=await(0,a.openLocation)(t,e).readFile(),s=(0,i.isGzip)(n)?await(0,r.unzip)(n):n;return new TextDecoder("utf8",{fatal:!0}).decode(s).split(/\n|\r\n|\r/).filter((e=>!!e.trim())).map(((e,t)=>{const[n,r,a,s,o]=e.split("\t");return new i.SimpleFeature({uniqueId:`${t}`,refName:n,start:+r,end:+a,name:s,type:o})}))}freeResources(){}}},7706:(e,t,n)=>{n.d(t,{sG:()=>d,unzip:()=>s,i2:()=>o});var r=n(35451),i=n(45834),a=n(57864);async function s(e){try{let t,n=0,i=0;const s=[];let o,l=0;do{const r=e.subarray(n);if(o=new a.Inflate,({strm:t}=o),o.push(r,a.Z_SYNC_FLUSH),o.err)throw new Error(o.msg);n+=t.next_in,s[i]=o.result,l+=s[i].length,i+=1}while(t.avail_in);const h=new Uint8Array(l);for(let e=0,t=0;e<s.length;e++)h.set(s[e],t),t+=s[e].length;return r.hp.from(h)}catch(e){if(`${e}`.match(/incorrect header check/))throw new Error("problem decompressing block: incorrect gzip header check");throw e}}async function o(e,t){try{let n;const{minv:i,maxv:s}=t;let o=i.blockPosition,l=i.dataPosition;const h=[],c=[],d=[];let f=0,w=0;do{const t=e.subarray(o-i.blockPosition),r=new a.Inflate;if(({strm:n}=r),r.push(t,a.Z_SYNC_FLUSH),r.err)throw new Error(r.msg);const u=r.result;h.push(u);let g=u.length;c.push(o),d.push(l),1===h.length&&i.dataPosition&&(h[0]=h[0].subarray(i.dataPosition),g=h[0].length);const p=o;if(o+=n.next_in,l+=g,p>=s.blockPosition){h[w]=h[w].subarray(0,s.blockPosition===i.blockPosition?s.dataPosition-i.dataPosition+1:s.dataPosition+1),c.push(o),d.push(l),f+=h[w].length;break}f+=h[w].length,w++}while(n.avail_in);const u=new Uint8Array(f);for(let e=0,t=0;e<h.length;e++)u.set(h[e],t),t+=h[e].length;return{buffer:r.hp.from(u),cpositions:c,dpositions:d}}catch(e){if(`${e}`.match(/incorrect header check/))throw new Error("problem decompressing block: incorrect gzip header check");throw e}}var l=n(59086),h=n.n(l);class c{constructor({filehandle:e,path:t}){if(e)this.filehandle=e;else{if(!t)throw new TypeError("either filehandle or path must be defined");this.filehandle=new i.EY(t)}}_readLongWithOverflow(e,t=0,n=!0){const r=h().fromBytesLE(e.slice(t,t+8),n);if(r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new TypeError("integer overflow");return r.toNumber()}_getIndex(){return this.index||(this.index=this._readIndex()),this.index}async _readIndex(){let e=r.hp.allocUnsafe(8);await this.filehandle.read(e,0,8,0);const t=this._readLongWithOverflow(e,0,!0);if(!t)return[[0,0]];const n=new Array(t+1);n[0]=[0,0];const i=16*t;if(i>Number.MAX_SAFE_INTEGER)throw new TypeError("integer overflow");e=r.hp.allocUnsafe(i),await this.filehandle.read(e,0,i,8);for(let r=0;r<t;r+=1){const t=this._readLongWithOverflow(e,16*r),i=this._readLongWithOverflow(e,16*r+8);n[r+1]=[t,i]}return n}async getLastBlock(){const e=await this._getIndex();if(e.length)return e[e.length-1]}async getRelevantBlocksForRead(e,t){const n=t+e;if(0===e)return[];const r=await this._getIndex(),i=[],a=(e,n)=>{const r=e[1],i=n?n[1]:1/0;return r<=t&&i>t?0:r<t?-1:1};let s=0,o=r.length-1,l=Math.floor(r.length/2),h=a(r[l],r[l+1]);for(;0!==h;)h>0?o=l-1:h<0&&(s=l+1),l=Math.ceil((o-s)/2)+s,h=a(r[l],r[l+1]);i.push(r[l]);let c=l+1;for(;c<r.length&&(i.push(r[c]),!(r[c][1]>=n));c+=1);return i[i.length-1][1]<n&&i.push([]),i}}class d{constructor({filehandle:e,path:t,gziFilehandle:n,gziPath:r}){if(e)this.filehandle=e;else{if(!t)throw new TypeError("either filehandle or path must be defined");this.filehandle=new i.EY(t)}if(!n&&!r&&!t)throw new TypeError("either gziFilehandle or gziPath must be defined");this.gzi=new c({filehandle:n,path:n||r||!t?`${t}.gzi`:r})}async stat(){const e=await this.filehandle.stat();return Object.assign(e,{size:await this.getUncompressedFileSize(),blocks:void 0,blksize:void 0})}async getUncompressedFileSize(){const[,e]=await this.gzi.getLastBlock(),{size:t}=await this.filehandle.stat(),n=r.hp.allocUnsafe(4),{bytesRead:i}=await this.filehandle.read(n,0,4,t-28-4);if(4!==i)throw new Error("read error");return e+n.readUInt32LE(0)}async _readAndUncompressBlock(e,[t],[n]){let r=n;r||(r=(await this.filehandle.stat()).size);const i=r-t;return await this.filehandle.read(e,0,i,t),await s(e.slice(0,i))}async read(e,t,n,i){const a=await this.gzi.getRelevantBlocksForRead(n,i),s=r.hp.allocUnsafe(65536);let o=t,l=0;for(let t=0;t<a.length-1;t+=1){const r=await this._readAndUncompressBlock(s,a[t],a[t+1]),[,h]=a[t],c=h>=i?0:i-h,d=Math.min(i+n,h+r.length)-h;c>=0&&c<r.length&&(r.copy(e,o,c,d),o+=d-c,l+=d-c)}return{bytesRead:l,buffer:e}}}}}]);
//# sourceMappingURL=4284.61dbc58f.chunk.js.map