"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[583],{60583:(e,t,n)=>{n.d(t,{doConnect:()=>r});var i=n(68584),a=n(99546),s=n(99834);function o(e,t){if("object"==typeof e&&null!==e)for(const n of Object.keys(e))"object"==typeof e[n]&&null!==e[n]?o(e[n],t):"uri"===n&&(e.baseUri=t.href)}async function r(e){const t=(0,a.getSession)(e);try{const a=(0,i.getConf)(e,"configJsonLocation"),c=JSON.parse(await(0,s.openLocation)(a).readFile("utf8")),h=(n=a.uri,r=a.baseUri,new URL(n,r).href);if(o(c,new URL(h)),c.assemblies)for(const e of c.assemblies)t.assemblyManager.get(e.name)||t.addSessionAssembly(e);c.tracks&&e.addTrackConfs(c.tracks),t.notify("Successfully loaded","success")}catch(n){console.error(n),t.notifyError(`${(0,i.getConf)(e,"name")}: "${n}"`,n),t.breakConnection?.(e.configuration)}var n,r}n(67057)},67057:(e,t,n)=>{n.d(t,{pN:()=>r,a9:()=>c,qt:()=>h,OO:()=>o});class i{constructor(e=[],t){this.data={};const{checkIndent:n=!0,skipValidation:i=!1}=t??{},a="string"==typeof e?e.trimEnd().split(/\r?\n/):e;let s,o;for(const e of a){if(""===e)throw new Error("Invalid stanza, contained blank lines");if(e.trim().startsWith("#"))continue;if(e.trimEnd().endsWith("\\")){const t=e.trimEnd().slice(0,-1);o?o+=t.trimStart():o=t;continue}let t=e;if(o&&(t=o+t.trimStart(),o=void 0),s??n){const e=/^([ \t]+)/.exec(t);if(void 0===s)e?[,s]=e:s="";else if(""===s&&null!==e||s&&e&&s!==e[1])throw new Error("Inconsistent indentation of stanza")}else s="";const i=t.trim(),a=i.indexOf(" ");if(-1===a){if(!this.nameKey)throw new Error("First line in a stanza must have both a key and a value");if(this.data[i])continue;this.data[i]="";continue}const r=i.slice(0,a),c=i.slice(a+1);if(this.data[r]&&c!==this.data[r])throw new Error(`Got duplicate key with a different value in stanza: "${r}" key has both ${this.data[r]} and ${c}`);this.nameKey||(this.nameKey=r,this.name=i.slice(a+1)),this.data[r]=c}i||this.validate()}validate(){}}class a{constructor(e=[],t){this.data={};const{checkIndent:n=!0,skipValidation:a=!1}=t??{},s="string"==typeof e?e.trimEnd().split(/(?:[\t ]*\r?\n){2,}/):e;for(const e of s){if(""===e)throw new Error("Invalid stanza, was empty");if(e.startsWith("include"))continue;if(e.trim().startsWith("#")&&e.trimEnd().split(/\r?\n/).map(e=>e.trim()).every(e=>e.startsWith("#")))continue;const t=new i(e,{checkIndent:n});if(this.nameKey){if(t.nameKey!==this.nameKey)throw new Error(`The first line in each stanza must have the same key. Saw both ${this.nameKey} and ${t.nameKey}`)}else this.nameKey=t.nameKey;if(!t.name)throw new Error(`No stanza name: ${t.name}`);if(this.data[t.name])throw new Error(`Got duplicate stanza name: ${t.name}`);this.data[t.name]=t}a||this.validate()}validate(){}}function s(e,t,n=""){const i=[];for(const n of t)e.data[n]||i.push(n);if(i.length>0)throw new Error(`${n} is missing required entr${1===i.length?"y":"ies"}: ${i.join(", ")}`)}class o extends a{constructor(e,t){super(e,{...t,checkIndent:!1})}validate(){if("track"!==this.nameKey)throw new Error(`trackDb has "${this.nameKey}" instead of "track" as the first line in each track`);for(const[e,t]of Object.entries(this.data)){const n=Object.keys(t.data);s(t,["track","shortLabel"],`Track ${e}`);const i=new Set(["superTrack","compositeTrack","container","view"]);if(!n.some(e=>i.has(e))){if(!n.includes("bigDataUrl"))throw new Error(`Track ${e} is missing required key "bigDataUrl"`);if(!n.includes("type")&&!Object.keys(this.settings(e)).includes("type"))throw new Error(`Neither track ${e} nor any of its parent tracks have the required key "type"`)}let a=e;do{a=this.data[a]?.parent,a&&([a]=a.split(" "))}while(a);const o=this.data[e];o&&(this.data[e]=o)}}settings(e){if(!this.data[e])throw new Error(`Track ${e} does not exist`);const t=[e];let n=e;do{n=this.data[n]?.parent,n&&t.push(n)}while(n);const i={};t.reverse();for(const e of t){const t=this.data[e];if(t)for(const[e,n]of Object.entries(t))i[e]=n}return i}}class r extends a{validate(e=["genome","trackDb"]){if("genome"!==this.nameKey)throw new Error('Genomes file must begin with a line like "genome <genome_name>"');for(const[t,n]of Object.entries(this.data))s(n,e,`genome ${t}`)}}class c extends i{validate(){s(this,["hub","shortLabel","longLabel","genomesFile","email"],"Hub file")}}class h{constructor(e){const[t,n,...a]=e.trimEnd().split(/(?:[\t ]*\r?\n){2,}/);this.hubData=new i(t),this.validateHub(),this.genome=new i(n),this.validateGenomeSection(),this.tracks=new o(a.join("\n\n"),{skipValidation:!1})}validateHub(){if("hub"!==this.hubData.nameKey)throw new Error('Hub file must begin with a line like "hub <hub_name>"');s(this.hubData,["hub","shortLabel","longLabel","email"])}validateGenomeSection(){if("genome"!==this.genome.nameKey)throw new Error('Genomes file must begin with a line like "genome <genome_name>"')}}}}]);
//# sourceMappingURL=583.36390dc7.chunk.js.map