"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8797],{58797:(t,e,a)=>{a.r(e),a.d(e,{default:()=>i});var s=a(8656),r=a(68584),n=a(46377),c=a(57097);class h{constructor(t){this.url=t.url.endsWith("/")?t.url:`${t.url}/`}async readMeta(){const t=await this.loadFile("meta.json"),{compress:e,track_names:a}=t;return{hashHexCharacters:Math.ceil(t.hash_bits/4),compress:e,tracks:a}}async getHashHexCharacters(){return(await this.readMeta()).hashHexCharacters}async getCompress(){return(await this.readMeta()).compress}async getTrackNames(){return(await this.readMeta()).tracks}async get(t){return(await this.getBucket(t))[t]}async getBucket(t){const e=this.hash(t),a=await this.hexToDirPath(e);return this.loadFile(a)}async loadFile(t){const e=await fetch(`${this.url}${t}`);if(!e.ok)throw new Error(`HTTP ${e.status} ${e.statusText}`);return e.json()}async hexToDirPath(t){const e=await this.getHashHexCharacters();if(e){const a=await this.getCompress();for(;t.length<8;)t=`0${t}`;t=t.slice(8-e);const s=[];for(let e=0;e<t.length;e+=3)s.push(t.slice(e,e+3));return`${s.join("/")}.json${a?"z":""}`}return""}hash(t){return(0,c.A)(t).toString(16).toLowerCase().replace("-","n")}}class i extends n.BaseAdapter{constructor(t,e,a){super(t,e,a);const s=(0,r.readConfObject)(t,"namesIndexLocation"),{baseUri:n,uri:c}=s;this.httpMap=new h({url:n?new URL(c,n).href:c})}async loadIndexFile(t){return this.httpMap.getBucket(t)}async searchIndex(t){const{searchType:e,queryString:a}=t,s=this.tracksNames||await this.httpMap.getTrackNames(),r=a.toLowerCase(),n=await this.loadIndexFile(r);return n[r]?this.formatResults(n[r],s,e):[]}formatResults(t,e,a){return[..."exact"===a?[]:t.prefix.map(t=>new s.A({label:"object"==typeof t?t.name:t,matchedAttribute:"name",matchedObject:{result:t}})),...t.exact.map(t=>{const a=t[0],r=t[1],n=`${t[3]||a}:${t[4]}-${t[5]}`;return new s.A({locString:n,label:a,matchedAttribute:"name",matchedObject:t,trackId:e[r]})})].filter(t=>"too many matches"!==t.getLabel())}}}}]);
//# sourceMappingURL=8797.92c2d67b.chunk.js.map